@arcgis/core 4.33.0-next.20250423 → 4.33.0-next.20250425

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (294) hide show
  1. package/Graphic.js +1 -1
  2. package/WebScene.js +1 -1
  3. package/analysis/Analysis.d.ts +4 -0
  4. package/analysis/Analysis.js +1 -1
  5. package/analysis/SliceAnalysis.js +1 -1
  6. package/analysis/SlicePlane.js +1 -1
  7. package/analysis/support/AnalysisOriginWebScene.d.ts +4 -0
  8. package/analysis/support/AnalysisOriginWebScene.js +5 -0
  9. package/analysis/support/SliceAnalysisExcludedLayer.js +5 -0
  10. package/assets/esri/core/workers/RemoteClient.js +1 -1
  11. package/assets/esri/core/workers/chunks/{d4d011eea16a89a5aad9.js → 0219c3f9408d3fa3c9a0.js} +1 -1
  12. package/assets/esri/core/workers/chunks/070839cb71c8e764b8d7.js +1 -0
  13. package/assets/esri/core/workers/chunks/19084a293694c5a00cae.js +1 -0
  14. package/assets/esri/core/workers/chunks/{8ba7d44eff348004f084.js → 1a6d2d090b643a87408a.js} +1 -1
  15. package/assets/esri/core/workers/chunks/1b8cc83aa1179245b2dc.js +1 -0
  16. package/assets/esri/core/workers/chunks/{5e5225623977e61fd0ef.js → 213adc87c843d627c5d6.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{fa8a3c75f9b41d31559b.js → 265f69d153b7b6f07e42.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{769b66cca8347f0f84db.js → 279bbd61b32577693a4a.js} +1 -1
  19. package/assets/esri/core/workers/chunks/290b065b377f9d2ee058.js +1 -0
  20. package/assets/esri/core/workers/chunks/29d3245261a7223124ed.js +1 -0
  21. package/assets/esri/core/workers/chunks/2bed8a5ed9ae3760fa2f.js +1 -0
  22. package/assets/esri/core/workers/chunks/2e3019ce49e972a815ca.js +1 -0
  23. package/assets/esri/core/workers/chunks/335b539893569e3d7b82.js +1 -0
  24. package/assets/esri/core/workers/chunks/38f5e6a202ce292edd9f.js +1 -0
  25. package/assets/esri/core/workers/chunks/415903f481392c72870f.js +1 -0
  26. package/assets/esri/core/workers/chunks/4351b3e54b309935faed.js +1 -0
  27. package/assets/esri/core/workers/chunks/4da99f058cca83937e9b.js +1 -0
  28. package/assets/esri/core/workers/chunks/5acdd49c5f1a49fdc6e7.js +1 -0
  29. package/assets/esri/core/workers/chunks/60f7cd05e88701f43d3f.js +1 -0
  30. package/assets/esri/core/workers/chunks/{26e0a0a13060cd3e4291.js → 626ba3a7dee952308566.js} +1 -1
  31. package/assets/esri/core/workers/chunks/7cd32b10ed0e18e44ef2.js +1 -0
  32. package/assets/esri/core/workers/chunks/9661ee8569ee208e6237.js +1 -0
  33. package/assets/esri/core/workers/chunks/968f2f841c011095a6d2.js +1 -0
  34. package/assets/esri/core/workers/chunks/974742af7beb000c4b4a.js +1 -0
  35. package/assets/esri/core/workers/chunks/{e27fa1e84f16b7f19a90.js → 9850ff14bd9c7da81c65.js} +1 -1
  36. package/assets/esri/core/workers/chunks/a0c51c4c30a5f749dfc6.js +1 -0
  37. package/assets/esri/core/workers/chunks/a2676f3f135ad5fdf872.js +1 -0
  38. package/assets/esri/core/workers/chunks/a8430e1e2142f1ce9b92.js +1 -0
  39. package/assets/esri/core/workers/chunks/{fdcbd28f38bc485ac5e3.js → ab6ecd8eeec5ff761b34.js} +1 -1
  40. package/assets/esri/core/workers/chunks/b53300b46646cfad2526.js +319 -0
  41. package/assets/esri/core/workers/chunks/bf543bdec3da0fe278fb.js +1 -0
  42. package/assets/esri/core/workers/chunks/{5bdd5ae2d2f23ef6b331.js → c87e2a63b96e0da77dfe.js} +1 -1
  43. package/assets/esri/core/workers/chunks/cc4dd739c4c7e3ccea3f.js +1 -0
  44. package/assets/esri/core/workers/chunks/d3a74087e076a3ae76ca.js +1 -0
  45. package/assets/esri/core/workers/chunks/{7c42281188b874ffcdad.js → db5913824d5e5a2a8365.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{48a1bb1e171dd06a7c6e.js → dd94585508f49863dc15.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{9408a72968cbd985dd24.js → f2cef954b58c6604642c.js} +34 -34
  48. package/assets/esri/core/workers/chunks/f52e597dca4b32a81881.js +1 -0
  49. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  50. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  51. package/chunks/BloomBlur.glsl.js +7 -7
  52. package/chunks/BloomComposition.glsl.js +24 -25
  53. package/chunks/ShadowCastAccumulate.glsl.js +13 -9
  54. package/chunks/ShadowCastVisualize.glsl.js +24 -9
  55. package/chunks/cameraUtilsSpherical.js +1 -1
  56. package/chunks/lyr3DMain.js +1 -1
  57. package/chunks/lyr3DWorker.js +1 -1
  58. package/chunks/sphere.js +1 -1
  59. package/core/Collection.js +1 -1
  60. package/core/JSONSupport.js +1 -1
  61. package/core/SetUtils.js +1 -1
  62. package/{views/webgl/GLObjectType.js → core/support/jsonUtils.js} +1 -1
  63. package/core/urlUtils.js +1 -1
  64. package/geometry/Mesh.js +1 -1
  65. package/geometry/support/normalizeUtilsSync.js +1 -1
  66. package/geometry/support/sphere.js +1 -1
  67. package/interfaces.d.ts +544 -116
  68. package/layers/DimensionLayer.js +1 -1
  69. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  70. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  71. package/layers/ParquetLayer.js +1 -1
  72. package/layers/RouteLayer.js +1 -1
  73. package/layers/SubtypeGroupLayer.js +1 -1
  74. package/layers/ViewshedLayer.js +1 -1
  75. package/layers/graphics/data/QueryEngine.js +1 -1
  76. package/layers/mixins/ImageryTileMixin.js +1 -1
  77. package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
  78. package/layers/orientedImagery/transformations/utils.js +1 -1
  79. package/layers/support/FieldsIndex.js +1 -1
  80. package/layers/support/ParquetEncodingLocation.d.ts +4 -0
  81. package/layers/support/ParquetEncodingLocation.js +1 -1
  82. package/layers/support/ParquetEncodingWkb.d.ts +4 -0
  83. package/layers/support/ParquetEncodingWkb.js +1 -1
  84. package/layers/support/RasterStorageInfo.js +1 -1
  85. package/layers/support/VideoElement.js +1 -1
  86. package/layers/support/layerUtils.js +1 -1
  87. package/layers/support/parquetUtils.d.ts +3 -0
  88. package/layers/support/parquetUtils.js +1 -1
  89. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  90. package/layers/support/rasterDatasets/FunctionRaster.js +1 -1
  91. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  92. package/layers/support/rasterDatasets/RawBlockCache.js +1 -1
  93. package/layers/support/rasterDatasets/TIFFRaster.js +1 -1
  94. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  95. package/layers/support/rasterFormats/pixelRangeUtils.js +1 -1
  96. package/layers/support/rasterFormats/{TiffTags.js → tiffTag.js} +1 -1
  97. package/layers/support/rasterFunctions/BandArithmeticFunction.js +1 -1
  98. package/layers/support/rasterFunctions/BaseRasterFunction.js +1 -1
  99. package/layers/support/rasterFunctions/ExtractBandFunction.js +1 -1
  100. package/layers/support/rasterFunctions/NDVIFunction.js +1 -1
  101. package/layers/support/rasterFunctions/RemapFunction.js +1 -1
  102. package/layers/support/rasterFunctions/rasterFunctionHelper.js +1 -1
  103. package/layers/support/videoUtils.js +5 -0
  104. package/package.json +2 -2
  105. package/portal/schemas/definitions.js +1 -1
  106. package/portal/schemas/integratedMesh3DTilesLayerItem.js +1 -1
  107. package/renderers/UniqueValueRenderer.js +1 -1
  108. package/renderers/support/colorRampUtils.js +1 -1
  109. package/support/revision.js +1 -1
  110. package/symbols/IconSymbol3DLayer.js +1 -1
  111. package/symbols/cim/effects/EffectTaperedPolygon.js +1 -1
  112. package/views/2d/engine/webgl/meshing/Mesh.js +1 -1
  113. package/views/2d/engine/webgl/shaderGraph/typed/TypedShaderProgram.js +1 -1
  114. package/views/2d/engine/webgl/textureUtils.js +1 -1
  115. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  116. package/views/2d/layers/MediaLayerView2D.js +1 -1
  117. package/views/2d/layers/TileLayerView2D.js +1 -1
  118. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  119. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  120. package/views/2d/layers/support/DebugOverlay.js +1 -1
  121. package/views/2d/layers/support/MediaLayerInteraction.js +1 -1
  122. package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
  123. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  124. package/views/3d/analysis/LineOfSightAnalysisView3D.js +1 -1
  125. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  126. package/views/3d/analysis/Slice/SliceVisualization.js +1 -1
  127. package/views/3d/analysis/SliceAnalysisView3D.js +1 -1
  128. package/views/3d/analysis/Viewshed/ViewshedAnalysisVisualization.js +1 -1
  129. package/views/3d/analysis/Viewshed/ViewshedVisualization.js +1 -1
  130. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  131. package/views/3d/camera/constraintUtils/distance.js +1 -1
  132. package/views/3d/camera/intersectionUtils.js +1 -1
  133. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  134. package/views/3d/environment/atmosphereUtils.js +1 -1
  135. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  136. package/views/3d/interactive/visualElements/DrapedVisualElementResources.js +1 -1
  137. package/views/3d/interactive/visualElements/EngineVisualElement.js +1 -1
  138. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  139. package/views/3d/interactive/visualElements/LabelVisualElement.js +1 -1
  140. package/views/3d/interactive/visualElements/LaserlineVisualElement.js +1 -1
  141. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  142. package/views/3d/interactive/visualElements/MarkerVisualElement.js +1 -1
  143. package/views/3d/interactive/visualElements/MeasurementAreaVisualElement.js +1 -1
  144. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  145. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  146. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  147. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  148. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  149. package/views/3d/interactive/visualElements/SlicePlaneVisualElement.js +1 -1
  150. package/views/3d/interactive/visualElements/VerticesVisualElement.js +1 -1
  151. package/views/3d/interactive/visualElements/ViewshedShapeVisualElement.js +1 -1
  152. package/views/3d/interactive/visualElements/VisualElement.js +1 -1
  153. package/views/3d/interactive/visualElements/VisualElementResources.js +1 -1
  154. package/views/3d/layers/I3SMeshView3D.js +1 -1
  155. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  156. package/views/3d/layers/Lyr3DWorker.js +1 -1
  157. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  158. package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
  159. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
  160. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +1 -1
  161. package/views/3d/layers/graphics/pipeline/PipelineCommand.js +1 -1
  162. package/views/3d/layers/graphics/pipeline/Tile3DManager.js +1 -1
  163. package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
  164. package/views/3d/layers/graphics/pipeline/rendering/RenderCommandContext.js +1 -1
  165. package/views/3d/layers/graphics/pipeline/symbolization/Factory.js +5 -0
  166. package/views/3d/layers/graphics/pipeline/symbolization/SimpleFeatureRenderer.js +5 -0
  167. package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
  168. package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
  169. package/views/3d/layers/graphics/pipeline/symbolization/UniqueValueFeatureRenderer.js +1 -1
  170. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  171. package/views/3d/layers/support/MediaLayerInteraction.js +1 -1
  172. package/views/3d/state/ConstraintsManager.js +1 -1
  173. package/views/3d/state/NearFarHeuristic.js +1 -1
  174. package/views/3d/state/ViewState.js +1 -1
  175. package/views/3d/state/ViewStateManager.js +1 -1
  176. package/views/3d/state/utils/navigationUtils.js +1 -1
  177. package/views/3d/support/cameraUtilsSpherical.js +1 -1
  178. package/views/3d/support/geometryUtils/sphere.js +1 -1
  179. package/views/3d/terrain/OverlayRenderTargets.js +1 -1
  180. package/views/3d/webgl/ManagedDepthTexture.js +1 -1
  181. package/views/3d/webgl/ManagedFBO.js +1 -1
  182. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  183. package/views/3d/webgl-engine/core/FBOCacheFormats.js +5 -0
  184. package/views/3d/webgl-engine/core/shaderLibrary/Laserline.glsl.js +12 -20
  185. package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +1 -1
  186. package/views/3d/webgl-engine/core/shaderLibrary/util/BlendColorsPremultiplied.glsl.js +5 -0
  187. package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
  188. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  189. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  190. package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
  191. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  192. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  193. package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
  194. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  195. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  196. package/views/3d/webgl-engine/lib/DepthRange.js +1 -1
  197. package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
  198. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  199. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  200. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  201. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  202. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  203. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  204. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  205. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  206. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  207. package/views/3d/webgl-engine/shaders/ShadowCastAccumulate.glsl.js +1 -1
  208. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechnique.js +1 -1
  209. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechniqueConfiguration.js +5 -0
  210. package/views/3d/webgl-engine/shaders/ShadowCastVisualize.glsl.js +1 -1
  211. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechnique.js +1 -1
  212. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechniqueConfiguration.js +1 -1
  213. package/views/PopupView.js +1 -1
  214. package/views/SceneView.js +1 -1
  215. package/views/SelectionManager.js +1 -1
  216. package/views/VideoView.js +1 -1
  217. package/views/analysis/analysisViewUtils.js +1 -1
  218. package/views/input/InputManager.js +1 -1
  219. package/views/input/ViewEvents.js +1 -1
  220. package/views/support/selectionUtils.js +1 -1
  221. package/views/webgl/FBOAttachmentType.js +5 -0
  222. package/views/webgl/FramebufferObject.js +1 -1
  223. package/views/webgl/Renderbuffer.js +1 -1
  224. package/views/webgl/RenderbufferDescriptor.js +1 -1
  225. package/views/webgl/Texture.js +1 -1
  226. package/views/webgl/TextureDescriptor.js +1 -1
  227. package/views/webgl/textureUtils.js +1 -1
  228. package/webscene/InitialViewProperties.js +1 -1
  229. package/webscene/Presentation.js +1 -1
  230. package/webscene/Slide.js +1 -1
  231. package/webscene/SlideLegendInfo.js +1 -1
  232. package/webscene/background/ColorBackground.js +1 -1
  233. package/webscene/spec-certification/api.js +1 -1
  234. package/webscene/spec-certification/compare.js +1 -1
  235. package/webscene/spec-certification/index.js +1 -1
  236. package/webscene/spec-certification/spec.js +1 -1
  237. package/webscene/spec-certification/utils.js +1 -1
  238. package/webscene/support/Description.js +1 -1
  239. package/webscene/support/SlideElements.js +1 -1
  240. package/webscene/support/SlideEnvironment.js +1 -1
  241. package/webscene/support/SlideGround.js +1 -1
  242. package/webscene/support/SlideVisibleLayer.js +1 -1
  243. package/webscene/support/Title.js +1 -1
  244. package/webscene/support/analysisUtils.js +5 -0
  245. package/widgets/BatchAttributeForm/expressions/ExpressionsManager.js +1 -1
  246. package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js +1 -1
  247. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  248. package/widgets/Editor/EditorViewModel.js +1 -1
  249. package/widgets/Editor/UpdateWorkflow.js +1 -1
  250. package/widgets/Editor/support/SketchController.js +5 -0
  251. package/widgets/Editor/workflowUtils.js +1 -1
  252. package/widgets/ElevationProfile/ElevationProfileInteraction.js +1 -1
  253. package/widgets/Feature/FeatureUtilityNetworkAssociationList.js +1 -1
  254. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
  255. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  256. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  257. package/widgets/FeatureTable/support/tableUtils.js +1 -1
  258. package/widgets/FeatureTable.js +1 -1
  259. package/widgets/LayerList/LayerListItem.js +1 -1
  260. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  261. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  262. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  263. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  264. package/widgets/ShadowCast/ThresholdOptions.js +1 -1
  265. package/widgets/Sketch/SketchViewModel.js +1 -1
  266. package/widgets/VideoPlayer.js +1 -1
  267. package/widgets/Widget.js +1 -1
  268. package/widgets/support/AnalysisViewModel.js +1 -1
  269. package/widgets/support/SelectionList.js +1 -1
  270. package/widgets/support/SnappingControls.js +1 -1
  271. package/assets/esri/core/workers/chunks/184d7c8ea818bec5c462.js +0 -1
  272. package/assets/esri/core/workers/chunks/22f604726529ee6f8c25.js +0 -1
  273. package/assets/esri/core/workers/chunks/244d2196bac5ef279436.js +0 -1
  274. package/assets/esri/core/workers/chunks/26fcbe053194bd78fcc3.js +0 -1
  275. package/assets/esri/core/workers/chunks/32f2e0c88046b39916cc.js +0 -1
  276. package/assets/esri/core/workers/chunks/388a763da712ca71ccf4.js +0 -1
  277. package/assets/esri/core/workers/chunks/4f8782b3b6ad414409e8.js +0 -1
  278. package/assets/esri/core/workers/chunks/5ffc3ca6c6a4d32e1282.js +0 -1
  279. package/assets/esri/core/workers/chunks/642a595353a86f3717e3.js +0 -1
  280. package/assets/esri/core/workers/chunks/8dd26b12c625d20196ed.js +0 -319
  281. package/assets/esri/core/workers/chunks/931275cfa2c55eb0f504.js +0 -1
  282. package/assets/esri/core/workers/chunks/93e9dfd1ba8f393c6c47.js +0 -1
  283. package/assets/esri/core/workers/chunks/95379fdd6917c8a84c71.js +0 -1
  284. package/assets/esri/core/workers/chunks/9b21dc4659922cc577cb.js +0 -1
  285. package/assets/esri/core/workers/chunks/a197c86d42cc9ce21924.js +0 -1
  286. package/assets/esri/core/workers/chunks/a276980c06d5d311a37e.js +0 -1
  287. package/assets/esri/core/workers/chunks/b42ecc7c3eb2fd8d1308.js +0 -1
  288. package/assets/esri/core/workers/chunks/ccc50f28f217e50cc2c3.js +0 -1
  289. package/assets/esri/core/workers/chunks/d04efa51da9b4eb3a8a7.js +0 -1
  290. package/assets/esri/core/workers/chunks/d81bebbb6fe000200d35.js +0 -1
  291. package/assets/esri/core/workers/chunks/dd8e72d6784a8ebc115d.js +0 -1
  292. package/assets/esri/core/workers/chunks/e9fba86036b8fe700a41.js +0 -1
  293. package/assets/esri/core/workers/chunks/ed3d1d0465f4a4d8df4a.js +0 -1
  294. package/views/webgl/formats.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../core/Error.js";import{json as t}from"../../portal/schemas/webScene.js";import{ScanContext as r,sorted as n}from"./utils.js";function s(e,t){if(t.properties){if("layerType"in t.properties)return t.properties.layerType.enum[0];if("type"in t.properties&&t.properties.type.enum)return t.properties.type.enum[0]}switch(e){case"multipoint_geometry_schema.json":return"multipoint";case"point_geometry_schema.json":return"point";case"polyline_geometry_schema.json":return"polyline";case"polygon_geometry_schema.json":return"polygon";case"extent_schema.json":return"extent"}}function i(e){return"array"===e.type?`${i(e.items)}[]`:e.type}function a(e){const t={count:e.length,refsCount:0,typesCount:0,distinctTypes:[],type:null},r=new Set;for(const n in e){const s=e[n];s.$ref?t.refsCount++:s.type&&(t.typesCount++,r.add(i(s)))}return r.forEach((e=>t.distinctTypes.push(e))),t.distinctTypes.sort(),t.refsCount===t.count?t.type="refs":2===t.count&&t.refsCount>0&&1===t.distinctTypes.length&&"null"===t.distinctTypes[0]?t.type="refsAndNull":t.typesCount===t.count?(t.type="types",t.distinctTypes=t.distinctTypes):t.type="mix",t}function o(e,t){const r=t.stack[t.stack.length-1],n=t.definitions[r.klass.name];return n?.required&&n.required.includes(e.replace("[]",""))}function c(e){return"array"===e.type||!("properties"in e)}function l(e,t,r){if(!r.hasFilteredProperties)return`${e}--${t}`;return`${e}--${t}--${r.filteredPropertiesArray.join("/")}`}async function u(e,t,r,n,i){i.schemaStack.push(e);const a=s(e,r),u=n?n.replace("<?TYPE?>",a?`<${a}>`:""):"";if(c(r)){const n=i.currentClass?null:{type:e,name:e,id:`${e}--${t}`,typeValue:t,properties:[]};return n&&i.push(null,n),await T(r,u,i),i.schemaStack.pop(),n}const p=l(e,t,i),f="drawingInfo_schema.json"!==e&&"layer_schema.json"!==e&&i.seen.get(p);if(f&&u)return i.addProperty({name:u,type:f,required:o(u,i)}),i.schemaStack.pop(),f;const h={type:e,name:e,id:p,typeValue:t,properties:[]};return u&&i.addProperty({name:u,type:h,required:o(u,i)}),i.push(u,h),await T(r,"",i),i.schemaStack.pop(),i.pop()}async function p(e,t,r){const n=await r.requestSchema(e.$ref),s=L(n.schema);if(s){for(const e of s){const s={...n.schema};s.properties={...s.properties,type:{type:"string",enum:[e]}};const i=t&&!t.includes("<?TYPE?>")?`${t}<?TYPE?>`:t;await u(n.schemaId,e,s,i,r)}return}const i="layer_schema.json"===n.schemaId&&r.schemaStack.length?r.schemaStack[r.schemaStack.length-1].replace(/_schema\.json/,""):null;await u(n.schemaId,i,n.schema,t,r)}function f(e,t){if(!m(e))return!1;const r=e.stack.map((e=>e.klass.type)).join("/");return/.*pointCloudLayer_schema\.json\/layerDefinition_schema\.json\/drawingInfo_schema\.json$/.test(r)&&"renderer"===t}function h(e,t){if(!y(e)&&!d(e))return!1;const r=e.stack.map((e=>e.klass.type)).join("/");return(/.*(imageServiceLayer|tiledImageServiceLayer|wcsLayer)_schema\.json\/(layerDefinition|rasterLayerDefinition)_schema\.json\/rasterDrawingInfo_schema\.json$/.test(r)||/.*rasterPresetRenderer_schema\.json$/.test(r))&&"renderer"===t}function m(e){return!!e.currentClass&&"drawingInfo_schema.json"===e.currentClass.name}function y(e){return!!e.currentClass&&"rasterDrawingInfo_schema.json"===e.currentClass.name}function d(e){return!!e.currentClass&&"rasterPresetRenderer_schema.json"===e.currentClass.name}function _(e){switch(e.schemaStack[e.schemaStack.length-1]){case"operationalLayers_schema.json":case"elevationLayers_schema.json":case"baseMapLayer_schema.json":return!0}return!1}const w=/raster.*Renderer|vectorFieldRenderer/,j=/(uniqueValueRenderer|classBreaksRenderer|raster.*Renderer|vectorFieldRenderer)/,$=/(rasterUniqueValueRenderer|rasterClassBreaksRenderer)/;function g(e,t,r){if(m(r)||y(r)||d(r)){const n=f(r,t),s=h(r,t);return e.filter((e=>{if(/uniqueValueFromStyleRenderer_schema\.json$/.test(e.$ref))return!1;if(s)return j.test(e.$ref)&&!$.test(e.$ref);if(w.test(e.$ref))return!1;const t=/pointCloud.*Renderer/.test(e.$ref);return n===t}))}if(_(r)){const t=["kmlLayer","rasterDataElevationLayer","rasterDataLayer","object3DTilesLayer"];return e.filter((e=>!t.some((t=>e.$ref.replace(/.*\//,"")===`${t}_schema.json`))))}return e}async function P(e,t,r){await T(e.items,`${t}[]`,r)}async function S(e,t,r){for(const n in e.properties)if(!("webscene_schema.json"===r.currentClass?.name&&"mapRangeInfo"===n||"baseMap_schema.json"===r.currentClass?.name&&"elevationLayers"===n)){if(m(r)){const e=r.stack.map((e=>e.klass.type)).join("/");if(/imageServiceLayer|tiledImageServiceLayer/.test(e)&&"transparency"===n)continue}await r.withFilter(n,(async()=>{const s=t?`${t}.${n}`:n;await T(e.properties[n],s,r)}))}}function k(e,t="",r=new Set){for(const n of e)if("properties"in n)for(const e in n.properties){const s=n.properties[e],i=t?`${t}.${e}`:e,a=Object.keys(s);if(0===a.length||1===a.length&&"$ref"===a[0])r.add(i);else{if(1!==a.length||"allOf"!==a[0])throw new Error(`unexpected allOf filter construct: ${JSON.stringify(s)}`);r.add(i),k(s.allOf,i,r)}}return r}async function R(e,t,r){let n=null;for(const i of e.allOf)if("$ref"in i){if(n)throw new Error("Cannot process more than 1 ref in an allOf construct");n=i}else if(!("properties"in i))throw new Error("allOf construct only allows simple top-level property filters");const s=k(e.allOf);await r.addFilter(s,(()=>p(n,t,r)))}async function C(e,t,r){const s=a(e.oneOf);if("refs"!==s.type&&"refsAndNull"!==s.type)if("types"!==s.type)for(const n in e.oneOf){const s=`.oneOf[${n}]`;await T(e.oneOf[n],`${t}${s}`,r)}else r.addProperty({name:t,type:n(s.distinctTypes).join("|"),required:o(t,r)});else{const n=g(e.oneOf,t,r);for(const e of n)if("null"===e.type);else{const s=`${t||""}`+(1!==n.length?"<?TYPE?>":"");await T(e,s,r)}}}function L(e){if("layerDefinition"===e.title)return null;const t=e.properties?.type;return t?.enum?t.enum:null}async function q(e,t,r){await p(e,t,r)}async function O(e,t,r){let s="unknown";e.type&&(s=Array.isArray(e.type)?n(e.type).join("|"):e.type.replaceAll(" ","").split(",").join("|"));const i={name:t,type:s,default:e.default,required:o(t,r)};e.enum&&(i.enum=n(e.enum).map((e=>"string"==typeof e?`"${e}"`:`${e}`)).join("|")),r.addProperty(i)}async function T(e,t,r){return"array"===e.type?P(e,t,r):"properties"in e?S(e,t,r):"allOf"in e?R(e,t,r):"oneOf"in e?C(e,t,r):"$ref"in e?q(e,t,r):O(e,t,r)}const b="#/definitions/";function E(e){return 0===e.indexOf(b)?e.slice(b.length):e}async function I(e,t){const r=await v.create(e,t);return u(`${e||"webscene"}_schema.json`,null,r.schemaRoot,null,r)}class v extends r{constructor(e,t,r){super(),this.definitions=e,this.schemaRoot=t,this.requestSchema=r,this._filteredProperties=null,this.schemaStack=[],this.requestSchema.bind(this)}get hasFilteredProperties(){return!!this._filteredProperties&&this._filteredProperties.size>0}get filteredPropertiesArray(){const e=[];return this._filteredProperties?.forEach((t=>e.push(t))),e}async withFilter(e,t){if(!this.hasFilteredProperties)return t();if(!this._filteredProperties?.has(e))return;const r=this._filteredProperties;this._filteredProperties=null;const n=e=>{this._filteredProperties||(this._filteredProperties=new Set),this._filteredProperties.add(e)};r.forEach((t=>{const r=t.split(".",2);r.length>1&&r[0]===e&&n(r[1])})),await t(),this._filteredProperties=r}async addFilter(e,t){const r=this._filteredProperties;this._filteredProperties=null;const n=e=>{this._filteredProperties||(this._filteredProperties=new Set),this._filteredProperties.add(e)};r&&r.forEach(n),e&&e.forEach(n);const s=await t();return this._filteredProperties=r,s}static async create(e,t){return t?.useRemoteSchema?v.createRemote(e,t?.baseUrl):v.createLocal(e)}static createLocal(e){const r=e&&"webscene"!==e?t.definitions[`${e}_schema.json`]:t;return new v(t.definitions,r,v._getLocalSchemaRequest())}static async createRemote(e,t){const r=await v._getRemoteSchemaRequest(t),n=new v({},null,r),s=(await n.requestSchema(`${e||"webscene"}_schema.json`)).schema;return new v(n.definitions,s,r)}static _getLocalSchemaRequest(){return function(t){const r=E(t),n=this.definitions[r];return n?Promise.resolve({schemaId:r,schema:n}):Promise.reject(new e("spec-certification:spec-invalid-local-schema","Schema reference is not a local reference"))}}static async _getRemoteSchemaRequest(t){if(!t)return Promise.reject(new e("spec-certification:spec-missing-base-url","The base url of the remote schema directory must be specified when using a remote schema"));const r=v._getLocalSchemaRequest(),n=(await import("../../request.js")).default;return function(e){return r.call(this,e).catch((()=>n(`${t}/${e}`,{responseType:"json"}).then((t=>(this.definitions[E(e)]=t.data,{schemaId:e,schema:t.data})))))}}}const F=Object.keys(t.definitions).map((e=>e.replace(/_schema\.json$/,"")));export{I as scan,F as schemaDefinitions};
5
+ import e from"../../core/Error.js";import{json as t}from"../../portal/schemas/webScene.js";import{ScanContext as r,sorted as n}from"./utils.js";function s(e,t){if(t.properties){if("layerType"in t.properties)return t.properties.layerType.enum[0];if("type"in t.properties&&t.properties.type.enum)return t.properties.type.enum[0]}switch(e){case"multipoint_geometry_schema.json":return"multipoint";case"point_geometry_schema.json":return"point";case"polyline_geometry_schema.json":return"polyline";case"polygon_geometry_schema.json":return"polygon";case"extent_schema.json":return"extent"}}function i(e){return"array"===e.type?`${i(e.items)}[]`:e.type}function a(e){const t={count:e.length,refsCount:0,typesCount:0,distinctTypes:[],type:null},r=new Set;for(const n in e){const s=e[n];s.$ref?t.refsCount++:s.type&&(t.typesCount++,r.add(i(s)))}return r.forEach((e=>t.distinctTypes.push(e))),t.distinctTypes.sort(),t.refsCount===t.count?t.type="refs":2===t.count&&t.refsCount>0&&1===t.distinctTypes.length&&"null"===t.distinctTypes[0]?t.type="refsAndNull":t.typesCount===t.count?(t.type="types",t.distinctTypes=t.distinctTypes):t.type="mix",t}function o(e,t){const r=t.stack[t.stack.length-1],n=t.definitions[r.klass.name];return n?.required&&n.required.includes(e.replace("[]",""))}function c(e){return"array"===e.type||!("properties"in e)}function l(e,t,r){if(!r.hasFilteredProperties)return`${e}--${t}`;return`${e}--${t}--${r.filteredPropertiesArray.join("/")}`}async function u(e,t,r,n,i){i.schemaStack.push(e);const a=s(e,r),u=n?n.replace("<?TYPE?>",a?`<${a}>`:""):"";if(c(r)){const n=i.currentClass?null:{type:e,name:e,id:`${e}--${t}`,typeValue:t,properties:[]};return n&&i.push(null,n),await T(r,u,i),i.schemaStack.pop(),n}const p=l(e,t,i),f="drawingInfo_schema.json"!==e&&"layer_schema.json"!==e&&i.seen.get(p);if(f&&u)return i.addProperty({name:u,type:f,required:o(u,i)}),i.schemaStack.pop(),f;const h={type:e,name:e,id:p,typeValue:t,properties:[]};return u&&i.addProperty({name:u,type:h,required:o(u,i)}),i.push(u,h),await T(r,"",i),i.schemaStack.pop(),i.pop()}async function p(e,t,r){const n=await r.requestSchema(e.$ref),s=L(n.schema);if(s){for(const e of s){const s={...n.schema};s.properties={...s.properties,type:{type:"string",enum:[e]}};const i=t&&!t.includes("<?TYPE?>")?`${t}<?TYPE?>`:t;await u(n.schemaId,e,s,i,r)}return}const i="layer_schema.json"===n.schemaId&&r.schemaStack.length?r.schemaStack[r.schemaStack.length-1].replace(/_schema\.json/,""):null;await u(n.schemaId,i,n.schema,t,r)}function f(e,t){if(!m(e))return!1;const r=e.stack.map((e=>e.klass.type)).join("/");return/.*pointCloudLayer_schema\.json\/layerDefinition_schema\.json\/drawingInfo_schema\.json$/.test(r)&&"renderer"===t}function h(e,t){if(!y(e)&&!d(e))return!1;const r=e.stack.map((e=>e.klass.type)).join("/");return(/.*(imageServiceLayer|tiledImageServiceLayer|wcsLayer)_schema\.json\/(layerDefinition|rasterLayerDefinition)_schema\.json\/rasterDrawingInfo_schema\.json$/.test(r)||/.*rasterPresetRenderer_schema\.json$/.test(r))&&"renderer"===t}function m(e){return!!e.currentClass&&"drawingInfo_schema.json"===e.currentClass.name}function y(e){return!!e.currentClass&&"rasterDrawingInfo_schema.json"===e.currentClass.name}function d(e){return!!e.currentClass&&"rasterPresetRenderer_schema.json"===e.currentClass.name}function _(e){switch(e.schemaStack[e.schemaStack.length-1]){case"operationalLayers_schema.json":case"elevationLayers_schema.json":case"baseMapLayer_schema.json":return!0}return!1}const w=/raster.*Renderer|vectorFieldRenderer/,j=/(uniqueValueRenderer|classBreaksRenderer|raster.*Renderer|vectorFieldRenderer)/,$=/(rasterUniqueValueRenderer|rasterClassBreaksRenderer)/;function g(e,t,r){if(m(r)||y(r)||d(r)){const n=f(r,t),s=h(r,t);return e.filter((e=>{if(/uniqueValueFromStyleRenderer_schema\.json$/.test(e.$ref))return!1;if(s)return j.test(e.$ref)&&!$.test(e.$ref);if(w.test(e.$ref))return!1;const t=/pointCloud.*Renderer/.test(e.$ref);return n===t}))}if(_(r)){const t=["kmlLayer","rasterDataElevationLayer","rasterDataLayer","object3DTilesLayer"];return e.filter((e=>!t.some((t=>e.$ref.replace(/.*\//,"")===`${t}_schema.json`))))}return e}async function P(e,t,r){await T(e.items,`${t}[]`,r)}async function S(e,t,r){for(const n in e.properties)if(!("webscene_schema.json"===r.currentClass?.name&&"mapRangeInfo"===n||"baseMap_schema.json"===r.currentClass?.name&&"elevationLayers"===n)){if(m(r)){const e=r.stack.map((e=>e.klass.type)).join("/");if(/imageServiceLayer|tiledImageServiceLayer/.test(e)&&"transparency"===n)continue}await r.withFilter(n,(async()=>{const s=t?`${t}.${n}`:n;await T(e.properties[n],s,r)}))}}function k(e,t="",r=new Set){for(const n of e)if("properties"in n)for(const e in n.properties){const s=n.properties[e],i=t?`${t}.${e}`:e,a=Object.keys(s);if(0===a.length||1===a.length&&"$ref"===a[0])r.add(i);else{if(1!==a.length||"allOf"!==a[0])throw new Error(`unexpected allOf filter construct: ${JSON.stringify(s)}`);r.add(i),k(s.allOf,i,r)}}return r}async function R(e,t,r){let n=null;for(const i of e.allOf)if("$ref"in i){if(n)throw new Error("Cannot process more than 1 ref in an allOf construct");n=i}else if(!("properties"in i))throw new Error("allOf construct only allows simple top-level property filters");const s=k(e.allOf);await r.addFilter(s,(()=>p(n,t,r)))}async function C(e,t,r){const s=a(e.oneOf);if("refs"!==s.type&&"refsAndNull"!==s.type)if("types"!==s.type)for(const n in e.oneOf){const s=`.oneOf[${n}]`;await T(e.oneOf[n],`${t}${s}`,r)}else r.addProperty({name:t,type:n(s.distinctTypes).join("|"),required:o(t,r)});else{const n=g(e.oneOf,t,r);for(const e of n)if("null"===e.type);else{const s=`${t||""}`+(1!==n.length?"<?TYPE?>":"");await T(e,s,r)}}}function L(e){if("layerDefinition"===e.title)return null;const t=e.properties?.type;return t?.enum?t.enum:null}async function q(e,t,r){await p(e,t,r)}async function O(e,t,r){let s="unknown";e.type&&(s=Array.isArray(e.type)?n(e.type).join("|"):e.type.replaceAll(" ","").split(",").join("|"));const i={name:t,type:s,default:e.default,required:o(t,r)};e.enum&&(i.enum=n(e.enum).map((e=>"string"==typeof e?`"${e}"`:`${e}`)).join("|")),r.addProperty(i)}async function T(e,t,r){return"array"===e.type?P(e,t,r):"properties"in e?S(e,t,r):"allOf"in e?R(e,t,r):"oneOf"in e?C(e,t,r):"$ref"in e?q(e,t,r):O(e,t,r)}const b="#/definitions/";function E(e){return 0===e.indexOf(b)?e.slice(b.length):e}async function I(e,t){const r=await v.create(e,t);return u(`${e||"webscene"}_schema.json`,null,r.schemaRoot,null,r)}class v extends r{constructor(e,t,r){super(),this.definitions=e,this.schemaRoot=t,this.requestSchema=r,this._filteredProperties=null,this.schemaStack=[],this.requestSchema.bind(this)}get hasFilteredProperties(){return(this._filteredProperties?.size??0)>0}get filteredPropertiesArray(){const e=[];return this._filteredProperties?.forEach((t=>e.push(t))),e}async withFilter(e,t){if(!this.hasFilteredProperties)return t();if(!this._filteredProperties?.has(e))return;const r=this._filteredProperties;this._filteredProperties=null;const n=e=>{this._filteredProperties||(this._filteredProperties=new Set),this._filteredProperties.add(e)};r.forEach((t=>{const r=t.split(".",2);r.length>1&&r[0]===e&&n(r[1])})),await t(),this._filteredProperties=r}async addFilter(e,t){const r=this._filteredProperties;this._filteredProperties=null;const n=e=>{this._filteredProperties||(this._filteredProperties=new Set),this._filteredProperties.add(e)};r&&r.forEach(n),e&&e.forEach(n);const s=await t();return this._filteredProperties=r,s}static async create(e,t){return t?.useRemoteSchema?v.createRemote(e,t?.baseUrl):v.createLocal(e)}static createLocal(e){const r=e&&"webscene"!==e?t.definitions[`${e}_schema.json`]:t;return new v(t.definitions,r,v._getLocalSchemaRequest())}static async createRemote(e,t){const r=await v._getRemoteSchemaRequest(t),n=new v({},null,r),s=(await n.requestSchema(`${e||"webscene"}_schema.json`)).schema;return new v(n.definitions,s,r)}static _getLocalSchemaRequest(){return function(t){const r=E(t),n=this.definitions[r];return n?Promise.resolve({schemaId:r,schema:n}):Promise.reject(new e("spec-certification:spec-invalid-local-schema","Schema reference is not a local reference"))}}static async _getRemoteSchemaRequest(t){if(!t)return Promise.reject(new e("spec-certification:spec-missing-base-url","The base url of the remote schema directory must be specified when using a remote schema"));const r=v._getLocalSchemaRequest(),n=(await import("../../request.js")).default;return function(e){return r.call(this,e).catch((()=>n(`${t}/${e}`,{responseType:"json"}).then((t=>(this.definitions[E(e)]=t.data,{schemaId:e,schema:t.data})))))}}}const F=Object.keys(t.definitions).map((e=>e.replace(/_schema\.json$/,"")));export{I as scan,F as schemaDefinitions};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- function t(t){return e(t,"",new Set,{})}function e(t,n,s,r){if(s.has(t))return r;s.add(t),n&&t.id&&(r[n]=t);for(const p of t.properties)if("string"!=typeof p.type){const t=n?`${n}.${p.name}`:p.name;e(p.type,t,s,r)}return s.delete(t),r}function n(t){const e=s(t,"",[]);return e.sort(((t,e)=>(t.name??"").localeCompare(e.name??""))),e}function s(t,e,n){for(const r of t.properties){const t=e?`${e}.${r.name}`:r.name;"string"==typeof r.type?n.push({name:t,type:r.type,default:r.default,enum:r.enum}):0===r.type.properties.length?n.push({name:t,type:"unknown",default:r.default,enum:r.enum}):s(r.type,t,n)}return n}class r{constructor(){this.stack=[],this.seen=new Map}addProperty(t){this.currentClass?.properties.push(t)}push(t,e){this.seen.set(e.id,e),this.stack.push({klass:e,propertyName:t})}pop(){return this.stack.pop()?.klass??null}get currentClass(){return this.stack.length?this.stack[this.stack.length-1].klass:null}get pathString(){return this.stack.map((t=>t.propertyName)).filter((t=>!!t)).join(".")}}function p(t){const e=t.slice();return e.sort(),e}export{r as ScanContext,t as collectClassPaths,n as flatten,p as sorted};
5
+ function e(e){return t(e,"",new Set,new Map)}function t(e,s,n,r){if(n.has(e))return r;n.add(e),s&&e.id&&r.set(s,e);for(const a of e.properties)if("string"!=typeof a.type){const e=s?`${s}.${a.name}`:a.name;t(a.type,e,n,r)}return n.delete(e),r}function s(e){const t=n(e,"",[]);return t.sort(((e,t)=>(e.name??"").localeCompare(t.name??""))),t}function n(e,t,s){for(const r of e.properties){const e=t?`${t}.${r.name}`:r.name;"string"==typeof r.type?s.push({name:e,type:r.type,default:r.default,enum:r.enum}):0===r.type.properties.length?s.push({name:e,type:"unknown",default:r.default,enum:r.enum}):n(r.type,e,s)}return s}class r{constructor(){this.stack=[],this.seen=new Map,this._uniqueDeclaredClasses=new Map}[Symbol.dispose](){this.seen.clear(),this.stack.length=0,this._uniqueDeclaredClasses.clear()}getDeclaredClass(e){const{_uniqueDeclaredClasses:t}=this,s=e.prototype.declaredClass.replaceAll(".","/");let n=0;for(;;){const r=n?`${s}/${n}`:s;n++;const a=t.get(r);if(!a)return t.set(r,e),r;if(a===e)return r}}addProperty(e){this.currentClass?.properties.push(e)}push(e,t){this.seen.set(t.id,t),this.stack.push({klass:t,propertyName:e})}pop(){return this.stack.pop()?.klass??null}get currentClass(){return this.stack.length?this.stack[this.stack.length-1].klass:null}get pathString(){return this.stack.map((e=>e.propertyName)).filter((e=>!!e)).join(".")}}function a(e){const t=e.slice();return t.sort(),t}export{r as ScanContext,e as collectClassPaths,s as flatten,a as sorted};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as r}from"../../chunks/tslib.es6.js";import o from"../../core/JSONSupport.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as e}from"../../core/accessorSupport/decorators/subclass.js";var s;let p=s=class extends o{constructor(){super(...arguments),this.text=""}clone(){return new s({text:this.text})}};r([t({type:String,json:{write:{isRequired:!0}}})],p.prototype,"text",void 0),p=s=r([e("esri.webscene.support.Description")],p);const c=p;export{c as default};
5
+ import{_ as o}from"../../chunks/tslib.es6.js";import r from"../../core/Clonable.js";import s from"../../core/JSONSupport.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";let p=class extends(r.ClonableMixin(s)){constructor(){super(...arguments),this.text=""}};o([e({type:String,json:{write:{isRequired:!0}}})],p.prototype,"text",void 0),p=o([t("esri.webscene.support.Description")],p);const c=p;export{c as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../chunks/tslib.es6.js";import e from"../../core/JSONSupport.js";import{clone as r}from"../../core/lang.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";import p from"../SlideLegendInfo.js";var n;let c=n=class extends e{constructor(){super(...arguments),this.legendInfo=null}clone(){return new n({legendInfo:r(this.legendInfo)})}};o([s({type:p,json:{write:!0}})],c.prototype,"legendInfo",void 0),c=n=o([t("esri.webscene.support.SlideElements")],c);const i=c;export{i as default};
5
+ import{_ as o}from"../../chunks/tslib.es6.js";import s from"../../core/Clonable.js";import r from"../../core/JSONSupport.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";import p from"../SlideLegendInfo.js";import{WebSceneAnalysesCollection as i,webSceneAnalysisCollectionProperty as n}from"./analysisUtils.js";let a=class extends(s.ClonableMixin(r)){constructor(o){super(o),this.analyses=new i,this.legendInfo=null}};o([e(n("analyses"))],a.prototype,"analyses",void 0),o([e({type:p,json:{write:!0}})],a.prototype,"legendInfo",void 0),a=o([t("esri.webscene.support.SlideElements")],a);const l=a;export{l as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as r}from"../../chunks/tslib.es6.js";import e from"../../core/JSONSupport.js";import{clone as o}from"../../core/lang.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import i from"../../views/3d/environment/SunnyWeather.js";import{weatherTypes as n}from"../../views/3d/environment/weather.js";import{lightingTypes as p}from"../lightingTypes.js";import m from"../SunLighting.js";var c;let h=c=class extends e{constructor(){super(...arguments),this.lighting=new m,this.weather=new i}clone(){return new c({lighting:o(this.lighting),weather:o(this.weather)})}};r([t({types:p,json:{write:!0}})],h.prototype,"lighting",void 0),r([t({types:n,json:{write:!0}})],h.prototype,"weather",void 0),h=c=r([s("esri.webscene.Environment")],h);export{h as SlideEnvironment};
5
+ import{_ as o}from"../../chunks/tslib.es6.js";import r from"../../core/Clonable.js";import e from"../../core/JSONSupport.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import i from"../../views/3d/environment/SunnyWeather.js";import{weatherTypes as p}from"../../views/3d/environment/weather.js";import{lightingTypes as n}from"../lightingTypes.js";import m from"../SunLighting.js";let c=class extends(r.ClonableMixin(e)){constructor(){super(...arguments),this.lighting=new m,this.weather=new i}};o([t({types:n,json:{write:!0}})],c.prototype,"lighting",void 0),o([t({types:p,json:{write:!0}})],c.prototype,"weather",void 0),c=o([s("esri.webscene.support.SlideEnvironment")],c);export{c as SlideEnvironment};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as r}from"../../chunks/tslib.es6.js";import o from"../../Ground.js";import t from"../../core/JSONSupport.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import{Integer as s}from"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{transparencyToOpacity as c,opacityToTransparency as a}from"../../webdoc/support/opacityUtils.js";var i;let n=i=class extends t{constructor(){super(...arguments),this.opacity=null}clone(){return new i({opacity:this.opacity})}cloneAndApplyTo(r){return null==this.opacity||((r=r?.clone()??new o).opacity=this.opacity),r}static fromGround(r){return new i({opacity:r.opacity})}};r([e({type:Number,json:{type:s,read:{reader:c,source:"transparency"},write:{writer:(r,o)=>{o.transparency=a(r)},target:"transparency"}}})],n.prototype,"opacity",void 0),n=i=r([p("esri.webscene.support.SlideGround")],n);const u=n;export{u as default};
5
+ import{_ as o}from"../../chunks/tslib.es6.js";import r from"../../Ground.js";import t from"../../core/Clonable.js";import s from"../../core/JSONSupport.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import{Integer as p}from"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{transparencyToOpacity as i,opacityToTransparency as a}from"../../webdoc/support/opacityUtils.js";var n;const m={type:Number,json:{type:p,name:"transparency",read:i,write:(o,r,t)=>{r[t]=a(o)}}};let u=n=class extends(t.ClonableMixin(s)){constructor(){super(...arguments),this.opacity=null}cloneAndApplyTo(o){return null==this.opacity||((o=o?.clone()??new r).opacity=this.opacity),o}static fromGround(o){return new n({opacity:o.opacity})}};o([e(m)],u.prototype,"opacity",void 0),u=n=o([c("esri.webscene.support.SlideGround")],u);const l=u;export{l as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as r}from"../../chunks/tslib.es6.js";import s from"../../core/JSONSupport.js";import{clone as e}from"../../core/lang.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import{Integer as t}from"../../core/accessorSupport/ensureType.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";var i;let c=i=class extends s{constructor(r){super(r),this.id="",this.sublayerIds=null}clone(){return new i({id:this.id,sublayerIds:e(this.sublayerIds)})}};r([o({type:String,json:{write:!0}})],c.prototype,"id",void 0),r([o({type:[t],json:{read:{source:"subLayerIds"},write:{target:"subLayerIds"}}})],c.prototype,"sublayerIds",void 0),c=i=r([p("esri.webscene.support.SlideVisibleLayer")],c);export{c as SlideVisibleLayer};
5
+ import{_ as r}from"../../chunks/tslib.es6.js";import o from"../../core/Clonable.js";import s from"../../core/JSONSupport.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import{Integer as t}from"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";let i=class extends(o.ClonableMixin(s)){constructor(r){super(r),this.id="",this.sublayerIds=null}};r([e({type:String,json:{write:!0}})],i.prototype,"id",void 0),r([e({type:[t],json:{name:"subLayerIds",write:!0}})],i.prototype,"sublayerIds",void 0),i=r([p("esri.webscene.support.SlideVisibleLayer")],i);export{i as SlideVisibleLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as r}from"../../chunks/tslib.es6.js";import o from"../../core/JSONSupport.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as e}from"../../core/accessorSupport/decorators/subclass.js";var s;let p=s=class extends o{constructor(){super(...arguments),this.text=""}clone(){return new s({text:this.text})}};r([t({type:String,json:{write:{isRequired:!0}}})],p.prototype,"text",void 0),p=s=r([e("esri.webscene.support.Title")],p);const c=p;export{c as default};
5
+ import{_ as o}from"../../chunks/tslib.es6.js";import r from"../../core/Clonable.js";import s from"../../core/JSONSupport.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";let p=class extends(r.ClonableMixin(s)){constructor(){super(...arguments),this.text=""}};o([e({type:String,json:{write:{isRequired:!0}}})],p.prototype,"text",void 0),p=o([t("esri.webscene.support.Title")],p);const c=p;export{c as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
+ */
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import s from"../../analysis/support/AnalysisOriginWebScene.js";import t from"../../core/Collection.js";import{castForReferenceSetter as i,referenceSetter as o}from"../../core/collectionUtils.js";import"../../core/Logger.js";import"../../core/has.js";import"../../core/RandomLCG.js";import"../../core/Error.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";const r=["slice"];let a=class extends t{constructor(e){super(e),this.addHandles([this.on("after-add",(e=>{this._setOrigin(e.item)})),this.on("before-remove",(e=>{const{origin:s}=e.item;"web-scene"===s?.type&&this._setOrigin(e.item,null)}))])}initialize(){for(const e of this.items)this._setOrigin(e)}_setOrigin(e,t=new s){e.origin=t}updateFrom(e){const t=e.analyses.filter((e=>c(e)));this.removeAll(),t.length&&this.addMany(t.map((e=>(e.origin=new s,e.clone()))))}applyTo(e){e.analyses.destroyMany(e.analyses.filter((({origin:e})=>"web-scene"===e?.type))),e.analyses.addMany(this.map((e=>e.clone())))}toJSON(e){return this.items.filter(c).map((s=>s.toJSON(e)))}};function l(e){return{type:a,cast:i,set(s){this._set(e,o(s,this._get(e),a))},json:{read(s,t,i){i?.hooks?.onAfterLoad((()=>p(this[e],s,i)))},write:{overridePolicy:e=>({enabled:e.length>0})}}}}function c(e){return r.includes(e.type)&&e.valid}async function p(e,s,t){if(!s)return;const i=await Promise.allSettled(s.map((e=>m(e,t))));for(const o of i)"fulfilled"===o.status&&e.add(o.value)}async function m(e,s){const t=new(await d[e.type]());return t.read(e,s),t}a=e([n("esri.webscene.support.analysisUtils.WebSceneAnalysesCollection")],a);const d={slice:async()=>{const{default:e}=await import("../../analysis/SliceAnalysis.js");return e}};export{a as WebSceneAnalysesCollection,l as webSceneAnalysisCollectionProperty,d as webSceneAnalysisRegistry};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/Error.js";import s from"../../../core/Logger.js";import{getOrCreateMapValue as o}from"../../../core/MapUtils.js";import{whenOrAbort as a}from"../../../core/promiseUtils.js";import i from"../../../core/ReactiveMap.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{DateOnly as u}from"../../../core/sql/DateOnly.js";import{TimeOnly as c}from"../../../core/sql/TimeOnly.js";import{makeUseId as p}from"../inputs/support/inputUtils.js";import{isGroupElementTemplate as d,isFieldElementTemplate as f}from"../templates/support/templateUtils.js";let m=null;const h="esri.widgets.BatchAttributeForm.expressions.ExpressionsManager",g=()=>s.getLogger(h);let y=class extends t{constructor(e){super(e),this.calculating=!1,this.arcadeContext=null,this._abortController=new AbortController,this.layerExpressionsModelMap=new Map,this.evaluatedExpressions=new i,this.expressionEvaluationFailed=!1}abort(){this._abortController.abort()}async runAllExpressions(e,t=!1){this.calculating=!0;try{const r=[];for(const s of e){const e=this.layerExpressionsModelMap.get(s.layer);if(!e||0===e.components.length)continue;const o=new Set;r.push(this.evaluateAffectedComponents(e.components,s,e,t,o))}await a(Promise.all(r),this._abortController)}catch(r){g().error(r),this.expressionEvaluationFailed=!0}finally{this.calculating=!1}}async valueChanged(e,t,r=!0){try{this.calculating=!0;const s=t.map((t=>this.evaluateValueChangedForFeature(e,t,r)));await Promise.all(s)}catch(s){g().error(s),this.expressionEvaluationFailed=!0}finally{this.calculating=!1}}async evaluateValueChangedForFeature(e,t,r){if(this._abortController.signal.aborted)return;const s=this.layerExpressionsModelMap.get(t.layer);if(!s||0===s.components.length)return;const o=new Set,a=new Set([e]),i=new Set;for(;a.size>0;){const[e]=a;if(a.delete(e),o.has(e))continue;o.add(e);const n=s.fieldReferencesMap.get(e.toLowerCase());if(!n)continue;for(const t of n)i.has(t)&&n.delete(t);if(0===n.size)continue;const l=new Set;await this.evaluateAffectedComponents([...n],t,s,r,l);for(const t of n)i.add(t);for(const t of l)o.has(t)||a.add(t)}}async evaluateAffectedComponents(e,t,r,s,o){const a=new Map;for(const n of e)a.has(n)||a.set(n,this.createSccEvaluator(n,t,a,r));if(0===a.size)return;const i=[...a.values()].map((e=>e.evaluate(s,o)));await Promise.all(i)}createSccEvaluator(e,t,r,s){const a=new v(e,t,this.arcadeContext,s,this.evaluatedExpressions,this._abortController);for(const i of e.adjacencyList)a.dependentEvaluators.push(o(r,i,(()=>this.createSccEvaluator(i,t,r,s))));return a}};e([n()],y.prototype,"calculating",void 0),e([n({constructOnly:!0})],y.prototype,"arcadeContext",void 0),e([n()],y.prototype,"_abortController",void 0),e([n()],y.prototype,"layerExpressionsModelMap",void 0),e([n()],y.prototype,"evaluatedExpressions",void 0),e([n()],y.prototype,"expressionEvaluationFailed",void 0),y=e([l(h)],y);class v{constructor(e,t,r,s,o,a){this.scc=e,this.feature=t,this.arcadeContextInfo=r,this.expressionsModel=s,this.evaluatedExpressions=o,this._abortController=a,this.dependentEvaluators=[],this._evaluatorPromise=null}get baseContext(){const{editType:e,map:t,spatialReference:r,timeZone:s}=this.arcadeContextInfo,o=this.feature.layer,a="scene"===o?.type&&null!=o.associatedLayer?o.associatedLayer:o;return{variables:{$originalfeature:this.feature.original.clone(),$editcontext:{editType:e},$layer:a,$featureset:a,$datastore:a?.url,$feature:this.feature.plainGraphic.clone(),$map:t},executeContext:{rawOutput:!0,spatialReference:r??void 0,timeZone:s,abortSignal:this._abortController.signal}}}evaluate(e,t){return null==this._evaluatorPromise&&(this._evaluatorPromise=this._evaluate(e,t)),this._evaluatorPromise}async _evaluate(e,t){null===m&&(m=await import("../../../arcade/languageUtils.js"));const s=this.dependentEvaluators.map((r=>r.evaluate(e,t)));await a(Promise.all(s),this._abortController);for(const a of this.scc.executors){const s=this.baseContext;if(this._abortController.signal.aborted)break;const l=this.expressionsModel.arcadeExecutorUses.get(a)??[],u=o(this.evaluatedExpressions,this.feature,(()=>new i));let c=null,m=null;try{c=a.isAsync?await a.executeAsync(s.variables,s.executeContext):a.execute(s.variables,s.executeContext),m={result:c,status:"success"}}catch(n){m={error:n,status:"error"}}for(const r of l){const s=this.expressionsModel.elementTemplateMap.get(r.elementId);switch(r.executorPurpose){case"editable":case"required":u.set(p(r.elementId,r.executorPurpose),m);break;case"value":{if("error"===m?.status)continue;const e=s.getExpressionExecutorsForLayer(this.feature.layer);let r=!0;if(e?.editableExpression&&(r=!1===u.get(p(s.elementId,"editable"))?.result),r){const e=this.feature.getAttribute(s.fieldName)??null,r=x(m.result,this.feature,s.fieldName,this.arcadeContextInfo.timeZone);r!==e&&(this.feature.setAttribute(s.fieldName,r),t.add(s.fieldName))}}break;case"visibility":if(u.set(p(r.elementId,r.executorPurpose),m),!this.expressionsModel.preserveFieldValuesWhenHidden&&!1===m.result&&e)if(d(s)){for(const e of s.elements)if(f(e)){null!==this.feature.getAttribute(e.fieldName)&&t.add(e.fieldName),this.feature.setAttribute(e.fieldName,null)}}else if(f(s)){null!==this.feature.getAttribute(s.fieldName)&&t.add(s.fieldName),this.feature.setAttribute(s.fieldName,null)}}}if("error"===m?.status){const e=new Set;for(const t of l){const r=this.expressionsModel.elementTemplateMap.get(t.elementId);if(r)switch(t.executorPurpose){case"editable":e.add(r.label+" - Editable expression");break;case"required":e.add(r.label+" - Required expression");break;case"value":e.add(r.label+" - Value expression");break;case"visibility":e.add(r.label+" - Visibility expression")}}if(e.size>0)throw new r("expression-evaluation-failed","Arcade evaluation failed ("+[...e].join(",")+")");throw new r("expression-evaluation-failed","Arcade evaluation failed ")}}}}function x(e,t,s,o){if(null===e)return null;const a=t.layer.fieldsIndex.get(s);if(!a)throw new r("field-not-found","Unable set field value as the field cannot be found. ("+s+")");switch(a.type){case"big-integer":case"integer":case"long":case"oid":case"small-integer":case"single":case"double":return m.toNumber(e);case"global-id":case"guid":case"string":return m.toString(e);case"date":{if(m.isDate(e))return e.getTime();const t=m.toDate(e,o);if(!t)throw new r("unsupported-value-type","Arcade return type is not a supported field type. ("+s+")");return t.getTime()}case"date-only":{if(m.isDateOnly(e))return e.toStorageFormat();if(m.isDate(e))return u.fromDateTime(e.toDateTime()).toStorageFormat();const t=u.fromString(m.toString(e));if(!t)throw new r("unsupported-value-type","Arcade return type is not a supported field type.");return t.toStorageFormat()}case"time-only":{if(m.isTime(e))return e.toStorageString();if(m.isDate(e)){return c.fromDateTime(e.toDateTime()).toStorageString()}const t=c.fromString(m.toString(e));if(!t)throw new r("unsupported-value-type","Arcade return type is not a supported field type.");return t.toStorageString()}case"timestamp-offset":{if(m.isDate(e))return e.toISOString(!1);const t=m.toDate(e,o);if(!t)throw new r("unsupported-value-type","Arcade return type is not a supported field type. ("+s+")");return t.toISOString(!1)}}throw new r("unsupported-value-type","Arcade return type is not a supported field type. ("+s+")")}export{y as ExpressionsManager};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/Error.js";import s from"../../../core/Logger.js";import{getOrCreateMapValue as o}from"../../../core/MapUtils.js";import{whenOrAbort as a}from"../../../core/promiseUtils.js";import i from"../../../core/ReactiveMap.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{DateOnly as u}from"../../../core/sql/DateOnly.js";import{TimeOnly as c}from"../../../core/sql/TimeOnly.js";import{makeUseId as p}from"../inputs/support/inputUtils.js";import{isGroupElementTemplate as d,isFieldElementTemplate as f}from"../templates/support/templateUtils.js";let m=null,h=class extends t{constructor(e){super(e),this.calculating=!1,this.arcadeContext=null,this._abortController=new AbortController,this.layerExpressionsModelMap=new Map,this.evaluatedExpressions=new i,this.expressionEvaluationFailed=!1}abort(){this._abortController.abort()}async runAllExpressions(e,t=!1){this.calculating=!0;try{const r=[];for(const s of e){const e=this.layerExpressionsModelMap.get(s.layer);if(!e||0===e.components.length)continue;const o=new Set;r.push(this.evaluateAffectedComponents(e.components,s,e,t,o))}await a(Promise.all(r),this._abortController)}catch(r){s.getLogger(this).error(r),this.expressionEvaluationFailed=!0}finally{this.calculating=!1}}async valueChanged(e,t,r=!0){try{this.calculating=!0;const s=t.map((t=>this.evaluateValueChangedForFeature(e,t,r)));await Promise.all(s)}catch(o){s.getLogger(this).error(o),this.expressionEvaluationFailed=!0}finally{this.calculating=!1}}async evaluateValueChangedForFeature(e,t,r){if(this._abortController.signal.aborted)return;const s=this.layerExpressionsModelMap.get(t.layer);if(!s||0===s.components.length)return;const o=new Set,a=new Set([e]),i=new Set;for(;a.size>0;){const[e]=a;if(a.delete(e),o.has(e))continue;o.add(e);const n=s.fieldReferencesMap.get(e.toLowerCase());if(!n)continue;for(const t of n)i.has(t)&&n.delete(t);if(0===n.size)continue;const l=new Set;await this.evaluateAffectedComponents([...n],t,s,r,l);for(const t of n)i.add(t);for(const t of l)o.has(t)||a.add(t)}}async evaluateAffectedComponents(e,t,r,s,o){const a=new Map;for(const n of e)a.has(n)||a.set(n,this.createSccEvaluator(n,t,a,r));if(0===a.size)return;const i=[...a.values()].map((e=>e.evaluate(s,o)));await Promise.all(i)}createSccEvaluator(e,t,r,s){const a=new g(e,t,this.arcadeContext,s,this.evaluatedExpressions,this._abortController);for(const i of e.adjacencyList)a.dependentEvaluators.push(o(r,i,(()=>this.createSccEvaluator(i,t,r,s))));return a}};e([n()],h.prototype,"calculating",void 0),e([n({constructOnly:!0})],h.prototype,"arcadeContext",void 0),e([n()],h.prototype,"_abortController",void 0),e([n()],h.prototype,"layerExpressionsModelMap",void 0),e([n()],h.prototype,"evaluatedExpressions",void 0),e([n()],h.prototype,"expressionEvaluationFailed",void 0),h=e([l("esri.widgets.BatchAttributeForm.expressions.ExpressionsManager")],h);class g{constructor(e,t,r,s,o,a){this.scc=e,this.feature=t,this.arcadeContextInfo=r,this.expressionsModel=s,this.evaluatedExpressions=o,this._abortController=a,this.dependentEvaluators=[],this._evaluatorPromise=null}get baseContext(){const{editType:e,map:t,spatialReference:r,timeZone:s}=this.arcadeContextInfo,o=this.feature.layer,a="scene"===o?.type&&null!=o.associatedLayer?o.associatedLayer:o;return{variables:{$originalfeature:this.feature.original.clone(),$editcontext:{editType:e},$layer:a,$featureset:a,$datastore:a?.url,$feature:this.feature.plainGraphic.clone(),$map:t},executeContext:{rawOutput:!0,spatialReference:r??void 0,timeZone:s,abortSignal:this._abortController.signal}}}evaluate(e,t){return null==this._evaluatorPromise&&(this._evaluatorPromise=this._evaluate(e,t)),this._evaluatorPromise}async _evaluate(e,t){null===m&&(m=await import("../../../arcade/languageUtils.js"));const s=this.dependentEvaluators.map((r=>r.evaluate(e,t)));await a(Promise.all(s),this._abortController);for(const a of this.scc.executors){const s=this.baseContext;if(this._abortController.signal.aborted)break;const l=this.expressionsModel.arcadeExecutorUses.get(a)??[],u=o(this.evaluatedExpressions,this.feature,(()=>new i));let c=null,m=null;try{c=a.isAsync?await a.executeAsync(s.variables,s.executeContext):a.execute(s.variables,s.executeContext),m={result:c,status:"success"}}catch(n){m={error:n,status:"error"}}for(const r of l){const s=this.expressionsModel.elementTemplateMap.get(r.elementId);switch(r.executorPurpose){case"editable":case"required":u.set(p(r.elementId,r.executorPurpose),m);break;case"value":{if("error"===m?.status)continue;const e=s.getExpressionExecutorsForLayer(this.feature.layer);let r=!0;if(e?.editableExpression&&(r=!1===u.get(p(s.elementId,"editable"))?.result),r){const e=this.feature.getAttribute(s.fieldName)??null,r=y(m.result,this.feature,s.fieldName,this.arcadeContextInfo.timeZone);r!==e&&(this.feature.setAttribute(s.fieldName,r),t.add(s.fieldName))}}break;case"visibility":if(u.set(p(r.elementId,r.executorPurpose),m),!this.expressionsModel.preserveFieldValuesWhenHidden&&!1===m.result&&e)if(d(s)){for(const e of s.elements)if(f(e)){null!==this.feature.getAttribute(e.fieldName)&&t.add(e.fieldName),this.feature.setAttribute(e.fieldName,null)}}else if(f(s)){null!==this.feature.getAttribute(s.fieldName)&&t.add(s.fieldName),this.feature.setAttribute(s.fieldName,null)}}}if("error"===m?.status){const e=new Set;for(const t of l){const r=this.expressionsModel.elementTemplateMap.get(t.elementId);if(r)switch(t.executorPurpose){case"editable":e.add(r.label+" - Editable expression");break;case"required":e.add(r.label+" - Required expression");break;case"value":e.add(r.label+" - Value expression");break;case"visibility":e.add(r.label+" - Visibility expression")}}if(e.size>0)throw new r("expression-evaluation-failed","Arcade evaluation failed ("+[...e].join(",")+")");throw new r("expression-evaluation-failed","Arcade evaluation failed ")}}}}function y(e,t,s,o){if(null===e)return null;const a=t.layer.fieldsIndex.get(s);if(!a)throw new r("field-not-found","Unable set field value as the field cannot be found. ("+s+")");switch(a.type){case"big-integer":case"integer":case"long":case"oid":case"small-integer":case"single":case"double":return m.toNumber(e);case"global-id":case"guid":case"string":return m.toString(e);case"date":{if(m.isDate(e))return e.getTime();const t=m.toDate(e,o);if(!t)throw new r("unsupported-value-type","Arcade return type is not a supported field type. ("+s+")");return t.getTime()}case"date-only":{if(m.isDateOnly(e))return e.toStorageFormat();if(m.isDate(e))return u.fromDateTime(e.toDateTime()).toStorageFormat();const t=u.fromString(m.toString(e));if(!t)throw new r("unsupported-value-type","Arcade return type is not a supported field type.");return t.toStorageFormat()}case"time-only":{if(m.isTime(e))return e.toStorageString();if(m.isDate(e)){return c.fromDateTime(e.toDateTime()).toStorageString()}const t=c.fromString(m.toString(e));if(!t)throw new r("unsupported-value-type","Arcade return type is not a supported field type.");return t.toStorageString()}case"timestamp-offset":{if(m.isDate(e))return e.toISOString(!1);const t=m.toDate(e,o);if(!t)throw new r("unsupported-value-type","Arcade return type is not a supported field type. ("+s+")");return t.toISOString(!1)}}throw new r("unsupported-value-type","Arcade return type is not a supported field type. ("+s+")")}export{h as ExpressionsManager};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../analysis/DirectLineMeasurementAnalysis.js";import{watch as i,syncAndInitial as s}from"../../core/reactiveUtils.js";import{measurementLengthUnits as n}from"../../core/unitUtils.js";import{property as r}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{defaultUnitPropertyMetadata as o}from"../../properties/defaultUnit.js";import a from"../../views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js";import{InteractiveAnalysisViewModel as u}from"../support/InteractiveAnalysisViewModel.js";let p=class extends u{constructor(t){super(t),this.analysis=null,this.supportedViewType="3d",this.unsupportedErrorMessage="DirectLineMeasurement3DViewModel is only supported in 3D views.",this._userUnit=null,this._userUnitOptions=null}initialize(){this.addHandles(i((()=>({analysis:this.analysis,unit:this.unit})),(({analysis:t,unit:e})=>{null!=t&&(t.unit=e)}),s))}get state(){return this.disabled||!this.ready?"disabled":null==this.tool?"ready":this.tool.state}get measurement(){const{tool:t}=this;if(null==t)return null;const e=()=>({text:null,state:"unavailable"}),i=t=>({text:t,state:"available"}),{analysisViewData:s}=t,n=null!=s.result;return{mode:s.result?.mode??"euclidean",directDistance:n&&"euclidean"===s.actualVisualizedMeasurement?i(s.directLabelText):e(),horizontalDistance:n?i(s.horizontalLabelText):e(),verticalDistance:n?i(s.verticalLabelText):e()}}set unitOptions(t){this._userUnitOptions=t,this._set("unitOptions",this._filteredOrAllUnits(this._userUnitOptions))}get unitOptions(){return this._filteredOrAllUnits(this._userUnitOptions)}set unit(t){this._userUnit=t?this._findSelectableUnit(t,this._userUnit):null}get unit(){return this._userUnit?(this._userUnit=this._findSelectableUnit(this._userUnit,this.defaultUnit),this._userUnit):this._findSelectableUnit(this.defaultUnit)}constructAnalysis(){return new e}constructTool(){return new a({view:this.view,analysis:this.analysis,analysisViewData:this.analysisView,visible:this.visible})}_findSelectableUnit(t,e){const i=this.unitOptions;return i.includes(t)?t:e?this._findSelectableUnit(e):i[0]}_filteredOrAllUnits(t){if(!t)return n.slice();const e=t.filter((t=>n.includes(t)));return 0===e.length?n.slice():e}};t([r({type:e})],p.prototype,"analysis",void 0),t([r({readOnly:!0})],p.prototype,"state",null),t([r({readOnly:!0})],p.prototype,"measurement",null),t([r()],p.prototype,"unitOptions",null),t([r()],p.prototype,"unit",null),t([r(o)],p.prototype,"defaultUnit",void 0),t([r()],p.prototype,"_userUnit",void 0),t([r()],p.prototype,"_userUnitOptions",void 0),p=t([l("esri.widgets.DirectLineMeasurement3D.DirectLineMeasurement3DViewModel")],p);const c=p;export{c as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../analysis/DirectLineMeasurementAnalysis.js";import{watch as s,syncAndInitial as i}from"../../core/reactiveUtils.js";import{measurementLengthUnits as r}from"../../core/unitUtils.js";import{property as n}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{defaultUnitPropertyMetadata as l}from"../../properties/defaultUnit.js";import{AnalysisViewModel as a}from"../support/AnalysisViewModel.js";let u=class extends a{constructor(t){super(t),this.analysis=null,this.supportedViewType="3d",this.unsupportedErrorMessage="DirectLineMeasurement3DViewModel is only supported in 3D views.",this._userUnit=null,this._userUnitOptions=null}initialize(){this.addHandles(s((()=>({analysis:this.analysis,unit:this.unit})),(({analysis:t,unit:e})=>{null!=t&&(t.unit=e)}),i))}get state(){return this.disabled||!this.ready?"disabled":null==this.tool?"ready":this.tool.state}get measurement(){const{tool:t}=this;if(null==t)return null;const e=()=>({text:null,state:"unavailable"}),s=t=>({text:t,state:"available"}),{analysisViewData:i}=t,r=null!=i.result;return{mode:i.result?.mode??"euclidean",directDistance:r&&"euclidean"===i.actualVisualizedMeasurement?s(i.directLabelText):e(),horizontalDistance:r?s(i.horizontalLabelText):e(),verticalDistance:r?s(i.verticalLabelText):e()}}set unitOptions(t){this._userUnitOptions=t}get unitOptions(){const t=this._userUnitOptions?.filter((t=>r.includes(t)));return t&&t.length>0?t:r.slice()}set unit(t){this._userUnit=t}get unit(){const t=this._userUnit,e=this.unitOptions;if(t&&e.includes(t))return t;const s=this.defaultUnit;return s&&e.includes(s)?s:e[0]}constructAnalysis(){return new e}};t([n({type:e})],u.prototype,"analysis",void 0),t([n({readOnly:!0})],u.prototype,"state",null),t([n({readOnly:!0})],u.prototype,"measurement",null),t([n()],u.prototype,"unitOptions",null),t([n()],u.prototype,"unit",null),t([n(l)],u.prototype,"defaultUnit",void 0),t([n()],u.prototype,"_userUnit",void 0),t([n()],u.prototype,"_userUnitOptions",void 0),u=t([o("esri.widgets.DirectLineMeasurement3D.DirectLineMeasurement3DViewModel")],u);const p=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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import o from"../../core/Logger.js";import{removeMaybe as n,destroyMaybe as l}from"../../core/maybe.js";import{isPromiseLike as d,debounce as c}from"../../core/promiseUtils.js";import{watch as u,when as h,initial as p,whenOnce as m,syncAndInitial as f}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplateOrMetadata as v,isSharedTemplate as F,isStandardFeatureTemplate as _}from"../../editing/templateUtils.js";import b from"../../layers/GraphicsLayer.js";import{isTable as M}from"../../layers/support/layerUtils.js";import{getDisplayedSymbol as I}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as V}from"../../views/draw/support/helpMessageUtils.js";import k from"../../views/draw/support/HighlightHelper.js";import S from"../../views/interactive/sketch/SketchOptions.js";import C from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as A}from"../../views/support/HighlightDefaults.js";import E from"./CreateFeaturesWorkflowData.js";import{isModelUpload as P,handleModelUpload as T}from"./modelUploadUtils.js";import H from"./Workflow.js";import{createToolFromGeometryType as j,getServiceEditsFromWorkflowData as U,getServiceInfoForLayer as L,orderEditsByRelationshipDependencies as x,getFullTemplateForCreationInfo as O,getServiceLayersById as W,startCreatingNewFeature as D,findLayerInfo as R,updateGraphicSymbolWhenRequired as z,isTerminalUpdateEventType as G,getVisualVariableAttributes as N,startUpdatingFeatureGeometry as K,createWorkflowSteps as Z,avoidFeatureTemplateSelectionWithOnlyOneItem as q,getCreationAttributes as B,setRelationshipFields as J,prepareAttachmentsForCreateFeaturesWorkflow as Q,showProgressCursor as X,setUpSketchCreateWatchers as Y,setVisualVariablesAndElevationInfoForUpdate as $,visualVariableInteractiveUpdate as ee}from"./workflowUtils.js";import te from"../FeatureForm/FeatureFormViewModel.js";import ae from"../Sketch/SketchViewModel.js";var ie;const re=Symbol(),se=Symbol(),oe=Symbol(),ne=Symbol(),le={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let de=ie=class extends H{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new te,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.pendingFeatures.some((e=>!!this.data.getEditsForPendingFeature(e)?.modified)))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 hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!P(this.data.creationInfo)}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}const r=this._sketchViewModel.activeCreateToolDrawMode,s=this._sketchViewModel.activeTool;return V("rectangle"===s?"rectangle":"circle"===s?"circle":a,i?.geometry,r)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter((e=>this.data.isDisplayable(e))).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.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(v(this.data.fullTemplate)){const{tool:t}=j(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...le[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([oe])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),M(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{featureFormViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find((e=>this._hasValidationErrors(e)));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||P(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||P(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.layer.graphics.remove(e))}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,applyEditsFeatureServiceCallback:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new S,u=s?.layer,h=u?d.findEditorItemForLayer(u):void 0,p=new ie({data:new E({creationInfo:s,editorItem:h,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=p._attachmentFileInfos,{fullTemplate:c}=e,u=U(p.data),h=F(c)&&u;if(n){if(pe(s),h){let t=fe(u,l);const a=await L(o,d.view);a&&(t=x({edits:t,serviceInfo:a,view:d.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await i(c.featureService,t,{globalIdUsed:!0,gdbVersion:c.layer.gdbVersion??void 0})}else{const e=me(s,l);await a(o,e,{globalIdUsed:!0})}return}const m=h?await i(c.featureService,u,{gdbVersion:c.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];m&&l.size>0&&await Promise.all(m.map((e=>{if(e?.addFeatureResults)return t(o,he(s,e.addFeatureResults,o,l))})))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,i((()=>e.opacity=t))}async _initializeFullTemplateAndExecutorInfo(e){const{creationInfo:t}=e,{view:a}=e.viewModel;if(!t||!a)return null;const i=await O(t,a);if(e.fullTemplate=i,i&&F(i)){const{createTemplateExecutor:r}=await import("../../editing/sharedTemplates/executor/createTemplateExecutor.js"),s={completionResults:[],executor:await r(i),serviceLayersById:await W(t.layer,a)};e.templateExecutorInfo=s}return i}async _startCreating(){this.removeHandles(se);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new",await D(this._sketchViewModel,e,this._webStyleCache)}async _clearSelectedFeature(){const e=this._featureFormViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=n(this._featureFormHandle),this._featureFormViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||this.data.viewModel.activeWorkflow?.previous()}_stashValidationState(){const e=this._featureFormViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._featureFormViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_featureFormViewModel:o,_sketchViewModel:l}=this,{creationInfo:d,viewModel:c}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=c;if(!m||!d)return;n(this._featureFormHandle);const f=e.sourceLayer,w=R(p,f),g=w?.formTemplate,y=m.spatialReference;o.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||c.activeWorkflow?.previous(),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>h.addFile(e,t))),await z(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([o.on("value-change",(async()=>{v?.updateAttributes(o.getValues()),await z(e,s,"2d"===m.type?m.scale:null)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&G(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()})),u((()=>o.feature?.sourceLayer),(t=>e.sourceLayer=t)),u((()=>[o.feature,o.submittable]),(()=>this._stashValidationState()))]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchViewModel:a,data:i}=this,{creationInfo:r,viewModel:s}=i,{view:o}=s;if(!o||!r)return;const n=e.sourceLayer??r.layer;return M(n)?void 0:(this._visualVariableAttributes=N(e),K({graphic:e,sketchViewModel:a,sourceLayer:n,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=Z(["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&&(P(t)?e.addHandles(await T({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),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)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([oe,re,se,ne]),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 q(a,i)}static _configureSketchViewModel(e){const{data:t}=e,a=e._webStyleCache,{creationInfo:s,viewModel:o}=t,{view:n}=o,l=e._sketchViewModel,d=[];if(!n)return i();if("2d"===n.type){s&&d.push(e._fadeExistingFeatures(s.layer));const t=c(((e,t)=>Promise.all(e.map((e=>z(e,a,t))))));d.push(u((()=>n.scale),(e=>t(l.layer.graphics,e))))}const p=B(t.fullTemplate,s?.attributeOverrides),m=u((()=>l.createGraphic),(i=>{i&&!e.hasHandles(se)&&e._updatingHandles.addPromise(Y({creationAttributes:p,data:t,sketchViewModel:l,view:n,webStyleCache:a}).then((t=>e.addHandles(t,se))))})),f=async t=>{if("cancel"!==t.state&&"complete"!==t.state||e.removeHandles(se),"cancel"===t.state&&null!==n.activeTool&&n.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===t.state&&t.graphic){const a=await e._processEdits(t.graphic,{scale:"2d"===n.type?n.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});a&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:a}))}},w=async a=>{const{attachmentsViewModel:i}=o,{_featureFormViewModel:r}=e;if(a.graphics.length>1)return void await e._clearSelectedFeature();const d=a.graphics[0];if("complete"===a.state){const{submittable:t}=r;if(e.numPendingFeatures!==s?.maxFeatures&&t||r.submit(),await e._clearSelectedFeature(),"add"!==i.mode&&"edit"!==i.mode||o.activeWorkflow?.previous(),!a.aborted&&n.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===a.state)return d.sourceLayer??=t.creationInfo?.layer,await $({sketchViewModel:l,graphic:d,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===a.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;await ee(n,d,a,t,e._webStyleCache);const i=d.attributes,{rotation:s,size:o}=t;if(null!=s){const{field:e}=s;r.setValue(e,i[e])}if(null!=o){const{field:e}=o;r.setValue(e,i[e])}}}},g=async a=>{if(a.graphics.forEach((e=>{t.removePendingFeature(e)})),!P(t.creationInfo))return e._startCreating()},y=async()=>{if(P(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};d.push(m,l.on("create",(t=>e._updatingHandles.addPromise(f(t)))),l.on("update",(t=>e._updatingHandles.addPromise(w(t)))),l.on("delete",(t=>e._updatingHandles.addPromise(g(t)))),h((()=>!e.numPendingFeatures),(()=>e._updatingHandles.addPromise(y()))),i((()=>{l.cancel()})),ce(l,t),...ue(t));const v=r(d);return l.addHandles(v),v}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new b({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new ae({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchViewModel=r,t?.map.add(a),this.addHandles([i((()=>{t?.destroyed||t?.map.remove(a),a.destroy()})),u((()=>this.numPendingFeatures>0),(e=>this._sketchViewModel.updateOnGraphicClick=e),p)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._featureFormViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a,_featureFormViewModel:i}=this,{layerInfos:r,view:s}=a.viewModel;i.arcadeEditType="INSERT",i.map=s?.map,i.spatialReference=s?.spatialReference;const{templateExecutorInfo:o}=a;if(!o){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}const n=this.sketchViewModel.layer;n.remove(e);const{executor:l}=o,c=l(e.geometry,"completion"),u=d(c)?await c:c;o.completionResults.push(u),J(u.relationships),i.arcadeEditType="INSERT",i.map=s?.map,i.spatialReference=s?.spatialReference,u.primary&&a.creationInfo?.attributeOverrides&&(u.primary.graphic.attributes={...u.primary.graphic.attributes,...a.creationInfo.attributeOverrides});for(const d of u.edits){let e=null;if(d.addFeatures)for(const a of d.addFeatures){const i=a.clone();i.geometry=null,null!=a.geometry&&(a.symbol=await I(a,t),n.add(a)),a.sourceLayer!==e?.layer&&(e=R(r,a.sourceLayer));const s=!!u.associationGraphics?.has(a);await this._addAndInitializeEdits(a,i,e,s)}}i.feature=null,await m((()=>!i.updating));return u.edits.reduce(((e,t)=>e+(t.addFeatures?.length??0)),0)>1?null:u.primary?.graphic}async _addAndInitializeEdits(e,t,a,i=!1){const{data:r,_featureFormViewModel:s}=this,{layerInfos:o}=r.viewModel,n=r.addPendingFeature(e,t,{isAssociation:i});a??=R(o,e.sourceLayer),s.feature=e,s.formTemplate=a?.formTemplate,await m((()=>!s.updating)),n.submittable=s.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(oe))return;const{data:e,sketchViewModel:s}=this,{creationInfo:o,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!o?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:h,layer:m}=o,f=[],w=[];this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=l.findEditorItemForLayer(o.layer),o.template&&(null==e.fullTemplate&&await this._initializeFullTemplateAndExecutorInfo(e),w.push(i((()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])})))),s.allowDeleteKey=!e.isSharedTemplateWorkflow,Q(d),f.push(u((()=>d.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const g=X(c);f.push(g);const y=M(o.layer),{template:F}=o,b=!F||_(F)||v(F)&&"feature"===F.type,I=y&&b;try{if(I){const a=h??new t({attributes:B(e.fullTemplate,o.attributeOverrides),sourceLayer:m}),i=await this._processEdits(a);i&&await this._startUpdating({feature:i})}else f.push(ie._configureSketchViewModel(this)),h?(P(o)&&o.geometryToPlace&&(h.attributes=B(e.fullTemplate,o.attributeOverrides)),s.layer.add(h),await this._startUpdating({feature:h})):await this._startCreating()}finally{g.remove()}const V=i((()=>{for(const t of e.pendingFeatures)s.layer.remove(t),e.removePendingFeature(t)})),k=u((()=>c?.timeZone),(e=>{this._featureFormViewModel.timeZone=e,this.data.timeZone=e}),p),S=i((()=>{P(o)&&l.cancelWorkflow({warnIfNoWorkflow:!1})}));this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles(w,this._handleKeys.afterCommit),this.addHandles([i((()=>d.fileInfos.removeAll())),r(f),r(w),S,V,k],oe)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),ne),await m((()=>null==e?.activeTool),t.signal),t.abort()}};function ce(e,t){let a=null;const s=()=>e.snappingOptions.featureSources,o=()=>(a=new C({layer:e.layer}),s().add(a),a),n=()=>{null!=a&&(s().remove(a),a=l(a))};return r([u((()=>{const e=t.creationInfo?.layer,a=s().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return n();a??=o(),a.enabled=t}),f),i(n)])}function ue(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new k({view:t});a.push(u((()=>e.selectedPendingFeature),((e,t)=>{r.remove(e),r.add(t)})),i((()=>r.destroy())))}const r=new k({view:t,highlightName:A});return a.push(u((()=>e.temporaryHighlightFeature),(e=>{r.removeAll(),r.add(e)})),i((()=>r.destroy()))),a}function he(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach((({form:e})=>r.push({feature:o,attachment:e})))}})),r}function pe(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}function me(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:w(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function fe(e,t){return e.map((e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:w(),data:t}})}return i.length?{...e,addAttachments:i}:e}))}e([g()],de.prototype,"createFeatureState",void 0),e([g()],de.prototype,"data",void 0),e([g({constructOnly:!0})],de.prototype,"isNested",void 0),e([g()],de.prototype,"featureFormViewModel",null),e([g()],de.prototype,"hasPendingEdits",null),e([g()],de.prototype,"hasPreviousStep",null),e([g()],de.prototype,"_getDrawMeshHelpMessage",void 0),e([g()],de.prototype,"helpMessage",null),e([g()],de.prototype,"layer",null),e([g()],de.prototype,"parent",null),e([g()],de.prototype,"parentLayer",null),e([g()],de.prototype,"keyboardCancellationEnabled",null),e([g()],de.prototype,"reliesOnOwnerAdminPrivileges",null),e([g()],de.prototype,"shouldShowAttachments",null),e([g()],de.prototype,"shouldAllowAttachmentEditing",null),e([g()],de.prototype,"sketchViewModel",null),e([g()],de.prototype,"availableCreateTools",null),e([g()],de.prototype,"_attachmentsActive",null),de=ie=e([y("esri.widgets.Editor.CreateFeaturesWorkflow")],de);const we=de;export{we as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import o from"../../core/Logger.js";import{removeMaybe as n,destroyMaybe as l}from"../../core/maybe.js";import{isPromiseLike as d,debounce as c}from"../../core/promiseUtils.js";import{watch as u,when as h,initial as p,whenOnce as m,syncAndInitial as f}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplateOrMetadata as v,isSharedTemplate as F,isStandardFeatureTemplate as _}from"../../editing/templateUtils.js";import b from"../../layers/GraphicsLayer.js";import{isTable as M}from"../../layers/support/layerUtils.js";import{getDisplayedSymbol as I}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as V}from"../../views/draw/support/helpMessageUtils.js";import k from"../../views/draw/support/HighlightHelper.js";import S from"../../views/interactive/sketch/SketchOptions.js";import C from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as A}from"../../views/support/HighlightDefaults.js";import E from"./CreateFeaturesWorkflowData.js";import{isModelUpload as P,handleModelUpload as T}from"./modelUploadUtils.js";import H from"./Workflow.js";import{createToolFromGeometryType as j,getServiceEditsFromWorkflowData as U,getServiceInfoForLayer as L,orderEditsByRelationshipDependencies as x,getFullTemplateForCreationInfo as O,getServiceLayersById as W,startCreatingNewFeature as D,findLayerInfo as R,updateGraphicSymbolWhenRequired as z,isTerminalUpdateEventType as G,getVisualVariableAttributes as N,startUpdatingFeatureGeometry as K,createWorkflowSteps as Z,avoidFeatureTemplateSelectionWithOnlyOneItem as q,getCreationAttributes as B,setRelationshipFields as J,prepareAttachmentsForCreateFeaturesWorkflow as Q,showProgressCursor as X,setUpSketchCreateWatchers as Y,setVisualVariablesAndElevationInfoForUpdate as $,visualVariableInteractiveUpdate as ee}from"./workflowUtils.js";import te from"../FeatureForm/FeatureFormViewModel.js";import ae from"../Sketch/SketchViewModel.js";var ie;const re=Symbol(),se=Symbol(),oe=Symbol(),ne=Symbol(),le={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let de=ie=class extends H{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new te,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.pendingFeatures.some((e=>!!this.data.getEditsForPendingFeature(e)?.modified)))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 hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!P(this.data.creationInfo)}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}const r=this._sketchViewModel.activeCreateToolDrawMode,s=this._sketchViewModel.activeTool;return V("rectangle"===s?"rectangle":"circle"===s?"circle":a,i?.geometry,r)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter((e=>this.data.isDisplayable(e))).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.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(v(this.data.fullTemplate)){const{tool:t}=j(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...le[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([oe])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),M(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{featureFormViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find((e=>this._hasValidationErrors(e)));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||P(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||P(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.layer.graphics.remove(e))}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,applyEditsFeatureServiceCallback:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new S,u=s?.layer,h=u?d.findEditorItemForLayer(u):void 0,p=new ie({data:new E({creationInfo:s,editorItem:h,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=p._attachmentFileInfos,{fullTemplate:c}=e,u=U(p.data),h=F(c)&&u;if(n){if(pe(s),h){let t=fe(u,l);const a=await L(o,d.view);a&&(t=x({edits:t,serviceInfo:a,view:d.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await i(c.featureService,t,{globalIdUsed:!0,gdbVersion:c.layer.gdbVersion??void 0})}else{const e=me(s,l);await a(o,e,{globalIdUsed:!0})}return}const m=h?await i(c.featureService,u,{gdbVersion:c.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];m&&l.size>0&&await Promise.all(m.map((e=>{if(e?.addFeatureResults)return t(o,he(s,e.addFeatureResults,o,l))})))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,i((()=>e.opacity=t))}async _initializeFullTemplateAndExecutorInfo(e){const{creationInfo:t}=e,{view:a}=e.viewModel;if(!t||!a)return null;const i=await O(t,a);if(e.fullTemplate=i,i&&F(i)){const{createTemplateExecutor:r}=await import("../../editing/sharedTemplates/executor/createTemplateExecutor.js"),s={completionResults:[],executor:await r(i),serviceLayersById:await W(t.layer,a)};e.templateExecutorInfo=s}return i}async _startCreating(){this.removeHandles(se);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new",await D(this._sketchViewModel,e,this._webStyleCache)}async _clearSelectedFeature(){const e=this._featureFormViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=n(this._featureFormHandle),this._featureFormViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||this.data.viewModel.activeWorkflow?.previous()}_stashValidationState(){const e=this._featureFormViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._featureFormViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_featureFormViewModel:o,_sketchViewModel:l}=this,{creationInfo:d,viewModel:c}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=c;if(!m||!d)return;n(this._featureFormHandle);const f=e.sourceLayer,w=R(p,f),g=w?.formTemplate,y=m.spatialReference;o.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||c.activeWorkflow?.previous(),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>h.addFile(e,t))),await z(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([o.on("value-change",(async()=>{v?.updateAttributes(o.getValues()),await z(e,s,"2d"===m.type?m.scale:null)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&G(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()})),u((()=>o.feature?.sourceLayer),(t=>e.sourceLayer=t)),u((()=>[o.feature,o.submittable]),(()=>this._stashValidationState()))]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchViewModel:a,data:i}=this,{creationInfo:r,viewModel:s}=i,{view:o}=s;if(!o||!r)return;const n=e.sourceLayer??r.layer;return M(n)?void 0:(this._visualVariableAttributes=N(e),K({graphic:e,sketchViewModel:a,sourceLayer:n,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=Z(["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&&(P(t)?e.addHandles(await T({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),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)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([oe,re,se,ne]),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 q(a,i)}static _configureSketchViewModel(e){const{data:t}=e,a=e._webStyleCache,{creationInfo:s,viewModel:o}=t,{view:n}=o,l=e._sketchViewModel,d=[];if(!n)return i();if("2d"===n.type){s&&d.push(e._fadeExistingFeatures(s.layer));const t=c(((e,t)=>Promise.all(e.map((e=>z(e,a,t))))));d.push(u((()=>n.scale),(e=>t(l.layer.graphics,e))))}const p=B(t.fullTemplate,s?.attributeOverrides),m=u((()=>l.createGraphic),(i=>{i&&!e.hasHandles(se)&&e._updatingHandles.addPromise(Y({creationAttributes:p,data:t,sketchViewModel:l,view:n,webStyleCache:a}).then((t=>e.addHandles(t,se))))})),f=async t=>{if("cancel"!==t.state&&"complete"!==t.state||e.removeHandles(se),"cancel"===t.state&&null!==n.activeTool&&n.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===t.state&&t.graphic){const a=await e._processEdits(t.graphic,{scale:"2d"===n.type?n.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});a&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:a}))}},w=async a=>{const{attachmentsViewModel:i}=o,{_featureFormViewModel:r}=e;if(a.graphics.length>1)return void await e._clearSelectedFeature();const d=a.graphics[0];if("complete"===a.state){const{submittable:t}=r;if(e.numPendingFeatures!==s?.maxFeatures&&t||r.submit(),await e._clearSelectedFeature(),"add"!==i.mode&&"edit"!==i.mode||o.activeWorkflow?.previous(),!a.aborted&&n.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===a.state)return d.sourceLayer??=t.creationInfo?.layer,await $({sketchViewModel:l,graphic:d,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===a.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;ee(n,d,a,t)&&await z(d,e._webStyleCache,"2d"===n.type?n.scale:null);const i=d.attributes,{rotation:s,size:o}=t;if(null!=s){const{field:e}=s;r.setValue(e,i[e])}if(null!=o){const{field:e}=o;r.setValue(e,i[e])}}}},g=async a=>{if(a.graphics.forEach((e=>{t.removePendingFeature(e)})),!P(t.creationInfo))return e._startCreating()},y=async()=>{if(P(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};d.push(m,l.on("create",(t=>e._updatingHandles.addPromise(f(t)))),l.on("update",(t=>e._updatingHandles.addPromise(w(t)))),l.on("delete",(t=>e._updatingHandles.addPromise(g(t)))),h((()=>!e.numPendingFeatures),(()=>e._updatingHandles.addPromise(y()))),i((()=>{l.cancel()})),ce(l,t),...ue(t));const v=r(d);return l.addHandles(v),v}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new b({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new ae({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchViewModel=r,t?.map.add(a),this.addHandles([i((()=>{t?.destroyed||t?.map.remove(a),a.destroy()})),u((()=>this.numPendingFeatures>0),(e=>this._sketchViewModel.updateOnGraphicClick=e),p)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._featureFormViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a,_featureFormViewModel:i}=this,{layerInfos:r,view:s}=a.viewModel;i.arcadeEditType="INSERT",i.map=s?.map,i.spatialReference=s?.spatialReference;const{templateExecutorInfo:o}=a;if(!o){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}const n=this.sketchViewModel.layer;n.remove(e);const{executor:l}=o,c=l(e.geometry,"completion"),u=d(c)?await c:c;o.completionResults.push(u),J(u.relationships),i.arcadeEditType="INSERT",i.map=s?.map,i.spatialReference=s?.spatialReference,u.primary&&a.creationInfo?.attributeOverrides&&(u.primary.graphic.attributes={...u.primary.graphic.attributes,...a.creationInfo.attributeOverrides});for(const d of u.edits){let e=null;if(d.addFeatures)for(const a of d.addFeatures){const i=a.clone();i.geometry=null,null!=a.geometry&&(a.symbol=await I(a,t),n.add(a)),a.sourceLayer!==e?.layer&&(e=R(r,a.sourceLayer));const s=!!u.associationGraphics?.has(a);await this._addAndInitializeEdits(a,i,e,s)}}i.feature=null,await m((()=>!i.updating));return u.edits.reduce(((e,t)=>e+(t.addFeatures?.length??0)),0)>1?null:u.primary?.graphic}async _addAndInitializeEdits(e,t,a,i=!1){const{data:r,_featureFormViewModel:s}=this,{layerInfos:o}=r.viewModel,n=r.addPendingFeature(e,t,{isAssociation:i});a??=R(o,e.sourceLayer),s.feature=e,s.formTemplate=a?.formTemplate,await m((()=>!s.updating)),n.submittable=s.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(oe))return;const{data:e,sketchViewModel:s}=this,{creationInfo:o,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!o?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:h,layer:m}=o,f=[],w=[];this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=l.findEditorItemForLayer(o.layer),o.template&&(null==e.fullTemplate&&await this._initializeFullTemplateAndExecutorInfo(e),w.push(i((()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])})))),s.allowDeleteKey=!e.isSharedTemplateWorkflow,Q(d),f.push(u((()=>d.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const g=X(c);f.push(g);const y=M(o.layer),{template:F}=o,b=!F||_(F)||v(F)&&"feature"===F.type,I=y&&b;try{if(I){const a=h??new t({attributes:B(e.fullTemplate,o.attributeOverrides),sourceLayer:m}),i=await this._processEdits(a);i&&await this._startUpdating({feature:i})}else f.push(ie._configureSketchViewModel(this)),h?(P(o)&&o.geometryToPlace&&(h.attributes=B(e.fullTemplate,o.attributeOverrides)),s.layer.add(h),await this._startUpdating({feature:h})):await this._startCreating()}finally{g.remove()}const V=i((()=>{for(const t of e.pendingFeatures)s.layer.remove(t),e.removePendingFeature(t)})),k=u((()=>c?.timeZone),(e=>{this._featureFormViewModel.timeZone=e,this.data.timeZone=e}),p),S=i((()=>{P(o)&&l.cancelWorkflow({warnIfNoWorkflow:!1})}));this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles(w,this._handleKeys.afterCommit),this.addHandles([i((()=>d.fileInfos.removeAll())),r(f),r(w),S,V,k],oe)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),ne),await m((()=>null==e?.activeTool),t.signal),t.abort()}};function ce(e,t){let a=null;const s=()=>e.snappingOptions.featureSources,o=()=>(a=new C({layer:e.layer}),s().add(a),a),n=()=>{null!=a&&(s().remove(a),a=l(a))};return r([u((()=>{const e=t.creationInfo?.layer,a=s().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return n();a??=o(),a.enabled=t}),f),i(n)])}function ue(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new k({view:t});a.push(u((()=>e.selectedPendingFeature),((e,t)=>{r.remove(e),r.add(t)})),i((()=>r.destroy())))}const r=new k({view:t,highlightName:A});return a.push(u((()=>e.temporaryHighlightFeature),(e=>{r.removeAll(),r.add(e)})),i((()=>r.destroy()))),a}function he(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach((({form:e})=>r.push({feature:o,attachment:e})))}})),r}function pe(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}function me(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:w(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function fe(e,t){return e.map((e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:w(),data:t}})}return i.length?{...e,addAttachments:i}:e}))}e([g()],de.prototype,"createFeatureState",void 0),e([g()],de.prototype,"data",void 0),e([g({constructOnly:!0})],de.prototype,"isNested",void 0),e([g()],de.prototype,"featureFormViewModel",null),e([g()],de.prototype,"hasPendingEdits",null),e([g()],de.prototype,"hasPreviousStep",null),e([g()],de.prototype,"_getDrawMeshHelpMessage",void 0),e([g()],de.prototype,"helpMessage",null),e([g()],de.prototype,"layer",null),e([g()],de.prototype,"parent",null),e([g()],de.prototype,"parentLayer",null),e([g()],de.prototype,"keyboardCancellationEnabled",null),e([g()],de.prototype,"reliesOnOwnerAdminPrivileges",null),e([g()],de.prototype,"shouldShowAttachments",null),e([g()],de.prototype,"shouldAllowAttachmentEditing",null),e([g()],de.prototype,"sketchViewModel",null),e([g()],de.prototype,"availableCreateTools",null),e([g()],de.prototype,"_attachmentsActive",null),de=ie=e([y("esri.widgets.Editor.CreateFeaturesWorkflow")],de);const we=de;export{we as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{isSome as e}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import i from"../../core/Collection.js";import r from"../../core/Error.js";import s from"../../core/Evented.js";import{makeHandle as o}from"../../core/handleUtils.js";import n from"../../core/Logger.js";import{abortMaybe as l,removeMaybe as p,destroyMaybe as d}from"../../core/maybe.js";import{throwIfAborted as c,createResolver as u}from"../../core/promiseUtils.js";import{watch as h,on as f,when as w,whenOnce as m,syncAndInitial as y,initial as g,sync as k}from"../../core/reactiveUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as W}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as F}from"../../editing/templateUtils.js";import M from"../../layers/GraphicsLayer.js";import{isEditableLayer as E}from"../../layers/support/editableLayers.js";import{isFeatureLayer as I,isSubtypeGroupLayer as T,getOwningPortalUrl as b}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as V}from"../../portal/support/urlUtils.js";import A from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as C}from"../../views/interactive/snapping/SnappingManager.js";import L from"../../views/interactive/snapping/SnappingOptions.js";import U from"../Attachments/AttachmentsViewModel.js";import O from"./CreateFeaturesWorkflow.js";import S from"./UpdateWorkflow.js";import{isUpdateWorkflow as j,whenEditorLayerView as P}from"./workflowUtils.js";import R from"./support/EditorItem.js";import{makeTemplateGroupInfoForLayer as H}from"../FeatureTemplates/featureTemplatesUtils.js";import G from"../FeatureTemplates/FeatureTemplatesViewModel.js";import x from"../Sketch/SketchViewModel.js";import D from"../Spinner/SpinnerViewModel.js";import{goTo as B}from"../support/goToUtils.js";const q="esri.widgets.Editor.EditorViewModel",N=()=>n.getLogger(q);function Q(t,e,a){N().error(new r(t,e,a))}function z(t,e){return t?.find((t=>t.layer===e))}let Z=class extends s.EventedAccessor{constructor(t){super(t),this._templatesByLayer=new Map,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new M({listMode:"hide",internal:!0}),this._snappingManager=null,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new W,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new i,this.editorItems=new i,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new U({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new G({disabledItemFunction:({layer:t})=>this._itemIsSuspended(t)}),this.layerInfos=null,this.ownSketchViewModel=new x({layer:this._sketchGraphicsLayer}),this.sketchOptions=new A,this.snappingOptions=new L({attributeRulesEnabled:!0}),this.spinnerViewModel=new D,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&&"create-features"!==this.activeWorkflow?.type){if(t.submit(),!t.submittable||t.pendingSubtypeChoice)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([h((()=>{const t=this.view,e=t?.map?.editableLayers.toArray(),a=t?.allLayerViews,i=a?.filter((t=>!!e?.includes(t.layer)));return[e,i,this.layerInfos]}),(()=>this._updateEditorItems()),y),h((()=>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)})),w((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),g),f((()=>this.editorItems),"change",(()=>this._afterEditorItemsChange())),h((()=>[this.canCreate,this.canUpdateVisible]),(()=>this._afterEditorItemsChange())),h((()=>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}),y),w((()=>"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)})),h((()=>[this.view,this.featureTemplatesViewModel]),(([t,e])=>{e.view=t}),y),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})}),k),h((()=>this.view),(t=>{if(this._snappingManager=d(this._snappingManager),!t)return;const e=this.snappingOptions;this._snappingManager=new C({view:t,options:e}),this.ownSketchViewModel.snappingManager=this._snappingManager}),y),h((()=>this.snappingOptions),(t=>{this._snappingManager&&(this._snappingManager.options=t)}),y)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=l(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=p(this._sketchEventListenerHandle)}get _featureTemplatesLayersAndTables(){const t=new i;for(const e of this.editorItems){const a=this.hideTemplatesForInactiveLayers&&!e.visible;e.supportsCreateFeaturesWorkflow&&!a&&t.push(e.layer)}return t}get activeLeafWorkflow(){const t=this.activeWorkflow;return t&&j(t)?t.activeWorkflow??t: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(){return this._featureTemplatesLayersAndTables.filter((t=>"scene"===t.type||!t.isTable))}get featureFormViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeFeatureFormViewModel:"create-features"===t?.type?t.featureFormViewModel:null}get utilityNetworkAssociationAddAssociationViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeUtilityNetworkAssociationAddAssociationViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(t){this.sketchOptions.labels=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 canZoomTo(){const t=this.sketchViewModel,e=t?.createGraphic?.geometry?.type;return!(!t?.updateGraphics?.length&&"multipoint"!==e)}get page(){const{activeWorkflow:t,state:e}=this;if("update"===t?.type&&null!=t?.activeWorkflow?.featureFormViewModel?.associatedLayer)return"viewing-associated-features";if("update"===t?.type&&null!=t?.activeWorkflow?.featureFormViewModel?.associationId)return"viewing-associated-layers";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 featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}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}get snappingManager(){return this._snappingManager}getTemplatesForLayer(t){return this._templatesByLayer.get(t)??[]}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await m((()=>!this.updating)),!this.canCreate)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled.");const a=this._createUpdatingResolver();try{await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);this._set("activeWorkflow",a),await a.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{a.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(t){await m((()=>!this.updating));const e=this._createUpdatingResolver();try{const{initialFeature:e}=t,a=e.sourceLayer=e.layer,i=a?this.findEditorItemForLayer(a):void 0;if(!i?.supportsCreateFeaturesWorkflow)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const s=this._createCreateFeaturesWorkflow({initialFeature:e,layer:i.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",s),await s.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{e.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await m((()=>!this.updating)),!this.canUpdate)return void Q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow();this._set("activeWorkflow",t),await t.start()}catch(e){this._logErrorAndCancelWorkflow(e)}finally{t.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await m((()=>!this.updating)),!this.canUpdate)return void Q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,this._set("activeWorkflow",e),await e.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{e.resolve()}}async startUpdateWorkflowAtFeatureEdit(t){if(await m((()=>!this.updating)),!this.canUpdate)return void Q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.rootFeature=t,this._set("activeWorkflow",e),await e.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{e.resolve()}}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():Q("editing:unsupported-workflow","Deleting a feature requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveAssociation():Q("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warnIfNoWorkflow:!0,...t})}findEditorItemForLayer(t){return this.editorItems.find((e=>e.layer===t))}itemHasInvalidFormTemplate(t){return null!=t&&!0===this.findEditorItemForLayer(t.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(t){const a=this.sketchViewModel,i=t?t.geometry:a?.updateGraphics.length?a?.updateGraphics.toArray().map((t=>t.geometry)).filter(e):a?.createGraphic?.geometry;i&&this.view&&B(this.view,i)}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()))}restrictFeatureTemplatesViewModelToLayer(t){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([t]),o((()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)}))}async _getEditorItemCandidates(t){const{view:e}=this;if(!e?.map)return[];const{map:a}=e,i=a.editableLayers.toArray(),r=a.allTables.toArray().filter((t=>I(t)||T(t)));return await Promise.allSettled([...i.flatMap((t=>this._getLayerLoadPromise(t))),...r.flatMap((t=>this._getLayerLoadPromise(t)))]),c(t),[...i.reverse(),...r.reverse()].filter((t=>E(t)&&("mesh"!==t.geometryType||"3d"===e.type))).flatMap((t=>"subtype-group"===t.type?t.sublayers.toArray():t))}_getLayerLoadPromise(t){return T(t)?t.loadAll():t.load()}_drainEditorItems(){this.editorItems.drain((t=>t.destroy()))}_updateEditorItems(){l(this._updateItemsTask);const{view:t}=this,e=a((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=z(o,l),a=await P(t,l).catch((()=>null));(e?i:a?r:s).push(new R({layer:l,layerInfo:e,layerView:a}))}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(e.promise),this._updateItemsTask=e}_updateTemplates(){l(this._updateTemplatesTask);const t=a((async t=>{const e=this._templatesByLayer,a=this._featureTemplatesLayersAndTables.filter((t=>!e.has(t)));if(a.length>0){const i=await F(a.toArray(),this.view,t);for(const{layer:t,templates:a}of i)e.set(t,a)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)}));this._updatingHandles.addPromise(t.promise),this._updateTemplatesTask=t}_setFeatureTemplatesViewModelLayers(t){const e=this._templatesByLayer,a=[];for(const i of t){const t=e.get(i);t&&t.length>0&&a.push(H(i,t))}this.featureTemplatesViewModel.templateInfos=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){this.emit("workflow-cancel"),this._set("activeWorkflow",null);try{await e.cancel(t)}finally{e.destroy()}}else try{await e.cancel(t),this._set("activeWorkflow",null),e.destroy()}catch(a){}}_createCreateFeaturesWorkflow(t,e){return O.create({viewModel:this,creationInfo:t,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),applyEditsFeatureServiceCallback:(t,e,a)=>this._applyEditsFeatureService(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_createUpdateWorkflow(t){return S.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),applyEditsFeatureServiceCallback:(t,e,a)=>this._applyEditsFeatureService(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 r("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 b(t.url):null,s={returnServiceEditsOption:(!r||!V(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 P(a,t).catch((()=>null));return i=await t.applyEdits(e,s),r&&await m((()=>!r.updating)),i})),i}async _applyEditsFeatureService(t,e,a){let i=null;return await this._queueOperation((async()=>i=await t.applyEdits(e,a))),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=>(Array.isArray(t)?t.forEach((t=>this._handleEditsResultError(t))):this._handleEditsResultError(t),t))).catch((a=>{Q("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)}))}_handleEditsResultError(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}}_createUpdatingResolver(){const t=u();return this._updatingHandles.addPromise(t.promise),t}_logErrorAndCancelWorkflow(t){const{name:e,message:a,details:i}=t;Q(e??"editing:workflow-start-failed",a??void 0,i??t),this._cancelWorkflow({force:!0})}_itemIsSuspended(t){const e=this.findEditorItemForLayer(t);return null!=e&&(!e.visible||e.disabled)}};t([v()],Z.prototype,"_featureTemplatesLayersAndTables",null),t([v()],Z.prototype,"_snappingManager",void 0),t([v({readOnly:!0})],Z.prototype,"activeWorkflow",void 0),t([v()],Z.prototype,"activeLeafWorkflow",null),t([v({readOnly:!0})],Z.prototype,"_activityQueue",void 0),t([v({readOnly:!0})],Z.prototype,"canCreate",null),t([v()],Z.prototype,"canCreateVisible",null),t([v({readOnly:!0})],Z.prototype,"canUpdate",null),t([v()],Z.prototype,"canUpdateVisible",null),t([v()],Z.prototype,"featureTemplatesLayers",null),t([v()],Z.prototype,"editorItems",void 0),t([v({readOnly:!0})],Z.prototype,"failures",void 0),t([v()],Z.prototype,"hideTemplatesForInactiveLayers",void 0),t([v({type:U})],Z.prototype,"attachmentsViewModel",void 0),t([v()],Z.prototype,"featureFormViewModel",null),t([v()],Z.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),t([v({type:G})],Z.prototype,"featureTemplatesViewModel",void 0),t([v()],Z.prototype,"labelOptions",null),t([v()],Z.prototype,"layerInfos",void 0),t([v()],Z.prototype,"ownSketchViewModel",void 0),t([v()],Z.prototype,"sketchOptions",void 0),t([v()],Z.prototype,"sketchViewModel",null),t([v({type:L,nonNullable:!0})],Z.prototype,"snappingOptions",void 0),t([v()],Z.prototype,"spinnerViewModel",void 0),t([v()],Z.prototype,"state",null),t([v({readOnly:!0})],Z.prototype,"syncing",null),t([v()],Z.prototype,"updating",null),t([v()],Z.prototype,"tooltipOptions",null),t([v()],Z.prototype,"valueOptions",null),t([v()],Z.prototype,"view",null),t([v()],Z.prototype,"canZoomTo",null),t([v()],Z.prototype,"pageStack",void 0),t([v()],Z.prototype,"showDiscardEditsPrompt",void 0),t([v()],Z.prototype,"_candidateCommitted",void 0),t([v()],Z.prototype,"page",null),t([v()],Z.prototype,"featureFormDisabled",null),t([v()],Z.prototype,"featureFormHasAssociation",null),t([v()],Z.prototype,"canGoBack",null),t([v()],Z.prototype,"shouldShowDeleteButton",null),t([v()],Z.prototype,"hasPendingEdits",null),t([v()],Z.prototype,"snappingManager",null),Z=t([_(q)],Z);const $=Z;export{$ as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{isSome as e}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{makeHandle as o}from"../../core/handleUtils.js";import n from"../../core/Logger.js";import{abortMaybe as l,removeMaybe as p,destroyMaybe as d}from"../../core/maybe.js";import{throwIfAborted as c,createResolver as u}from"../../core/promiseUtils.js";import{watch as h,on as f,when as w,whenOnce as m,syncAndInitial as y,initial as g,sync as k}from"../../core/reactiveUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as W}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as F}from"../../editing/templateUtils.js";import E from"../../layers/GraphicsLayer.js";import{isEditableLayer as M}from"../../layers/support/editableLayers.js";import{isFeatureLayer as I,isSubtypeGroupLayer as T,getOwningPortalUrl as b}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as V}from"../../portal/support/urlUtils.js";import A from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as C}from"../../views/interactive/snapping/SnappingManager.js";import L from"../../views/interactive/snapping/SnappingOptions.js";import U from"../Attachments/AttachmentsViewModel.js";import O from"./CreateFeaturesWorkflow.js";import S from"./UpdateWorkflow.js";import{isUpdateWorkflow as j,whenEditorLayerView as P}from"./workflowUtils.js";import R from"./support/EditorItem.js";import{makeTemplateGroupInfoForLayer as H}from"../FeatureTemplates/featureTemplatesUtils.js";import G from"../FeatureTemplates/FeatureTemplatesViewModel.js";import x from"../Sketch/SketchViewModel.js";import D from"../Spinner/SpinnerViewModel.js";import{goTo as B}from"../support/goToUtils.js";function q(t,e){return t?.find((t=>t.layer===e))}let N=class extends s.EventedAccessor{constructor(t){super(t),this._templatesByLayer=new Map,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new E({listMode:"hide",internal:!0}),this._snappingManager=null,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new W,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new r,this.editorItems=new r,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new U({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new G({disabledItemFunction:({layer:t})=>this._itemIsSuspended(t)}),this.layerInfos=null,this.ownSketchViewModel=new x({layer:this._sketchGraphicsLayer}),this.sketchOptions=new A,this.snappingOptions=new L({attributeRulesEnabled:!0}),this.spinnerViewModel=new D,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&&"create-features"!==this.activeWorkflow?.type){if(t.submit(),!t.submittable||t.pendingSubtypeChoice)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([h((()=>{const t=this.view,e=t?.map?.editableLayers.toArray(),a=t?.allLayerViews,r=a?.filter((t=>!!e?.includes(t.layer)));return[e,r,this.layerInfos]}),(()=>this._updateEditorItems()),y),h((()=>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)})),w((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),g),f((()=>this.editorItems),"change",(()=>this._afterEditorItemsChange())),h((()=>[this.canCreate,this.canUpdateVisible]),(()=>this._afterEditorItemsChange())),h((()=>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}),y),w((()=>"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)})),h((()=>[this.view,this.featureTemplatesViewModel]),(([t,e])=>{e.view=t}),y),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})}),k),h((()=>this.view),(t=>{if(this._snappingManager=d(this._snappingManager),!t)return;const e=this.snappingOptions;this._snappingManager=new C({view:t,options:e}),this.ownSketchViewModel.snappingManager=this._snappingManager}),y),h((()=>this.snappingOptions),(t=>{this._snappingManager&&(this._snappingManager.options=t)}),y)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=l(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=p(this._sketchEventListenerHandle)}get _featureTemplatesLayersAndTables(){const t=new r;for(const e of this.editorItems){const a=this.hideTemplatesForInactiveLayers&&!e.visible;e.supportsCreateFeaturesWorkflow&&!a&&t.push(e.layer)}return t}get activeLeafWorkflow(){const t=this.activeWorkflow;return t&&j(t)?t.activeWorkflow??t: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(){return this._featureTemplatesLayersAndTables.filter((t=>"scene"===t.type||!t.isTable))}get featureFormViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeFeatureFormViewModel:"create-features"===t?.type?t.featureFormViewModel:null}get utilityNetworkAssociationAddAssociationViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeUtilityNetworkAssociationAddAssociationViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(t){this.sketchOptions.labels=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 canZoomTo(){const t=this.sketchViewModel,e=t?.createGraphic?.geometry?.type;return!(!t?.updateGraphics?.length&&"multipoint"!==e)}get page(){const{activeWorkflow:t,state:e}=this;if("update"===t?.type&&null!=t?.activeWorkflow?.featureFormViewModel?.associatedLayer)return"viewing-associated-features";if("update"===t?.type&&null!=t?.activeWorkflow?.featureFormViewModel?.associationId)return"viewing-associated-layers";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 featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}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}get snappingManager(){return this._snappingManager}getTemplatesForLayer(t){return this._templatesByLayer.get(t)??[]}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await m((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");const a=this._createUpdatingResolver();try{await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);this._set("activeWorkflow",a),await a.start()}catch(r){this._logErrorAndCancelWorkflow(r)}finally{a.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(t){await m((()=>!this.updating));const e=this._createUpdatingResolver();try{const{initialFeature:e}=t,a=e.sourceLayer=e.layer,r=a?this.findEditorItemForLayer(a):void 0;if(!r?.supportsCreateFeaturesWorkflow)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const s=this._createCreateFeaturesWorkflow({initialFeature:e,layer:r.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",s),await s.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{e.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await m((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow();this._set("activeWorkflow",t),await t.start()}catch(e){this._logErrorAndCancelWorkflow(e)}finally{t.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await m((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,this._set("activeWorkflow",e),await e.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{e.resolve()}}async startUpdateWorkflowAtFeatureEdit(t){if(await m((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.rootFeature=t,this._set("activeWorkflow",e),await e.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{e.resolve()}}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():this._logError("editing:unsupported-workflow","Deleting a feature requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveAssociation():this._logError("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warnIfNoWorkflow:!0,...t})}findEditorItemForLayer(t){return this.editorItems.find((e=>e.layer===t))}itemHasInvalidFormTemplate(t){return null!=t&&!0===this.findEditorItemForLayer(t.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(t){const a=this.sketchViewModel,r=t?t.geometry:a?.updateGraphics.length?a?.updateGraphics.toArray().map((t=>t.geometry)).filter(e):a?.createGraphic?.geometry;r&&this.view&&B(this.view,r)}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()))}restrictFeatureTemplatesViewModelToLayer(t){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([t]),o((()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)}))}async _getEditorItemCandidates(t){const{view:e}=this;if(!e?.map)return[];const{map:a}=e,r=a.editableLayers.toArray(),i=a.allTables.toArray().filter((t=>I(t)||T(t)));return await Promise.allSettled([...r.flatMap((t=>this._getLayerLoadPromise(t))),...i.flatMap((t=>this._getLayerLoadPromise(t)))]),c(t),[...r.reverse(),...i.reverse()].filter((t=>M(t)&&("mesh"!==t.geometryType||"3d"===e.type))).flatMap((t=>"subtype-group"===t.type?t.sublayers.toArray():t))}_getLayerLoadPromise(t){return T(t)?t.loadAll():t.load()}_drainEditorItems(){this.editorItems.drain((t=>t.destroy()))}_updateEditorItems(){l(this._updateItemsTask);const{view:t}=this,e=a((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=q(o,l),a=await P(t,l).catch((()=>null));(e?r:a?i:s).push(new R({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(e.promise),this._updateItemsTask=e}_updateTemplates(){l(this._updateTemplatesTask);const t=a((async t=>{const e=this._templatesByLayer,a=this._featureTemplatesLayersAndTables.filter((t=>!e.has(t)));if(a.length>0){const r=await F(a.toArray(),this.view,t);for(const{layer:t,templates:a}of r)e.set(t,a)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)}));this._updatingHandles.addPromise(t.promise),this._updateTemplatesTask=t}_setFeatureTemplatesViewModelLayers(t){const e=this._templatesByLayer,a=[];for(const r of t){const t=e.get(r);t&&t.length>0&&a.push(H(r,t))}this.featureTemplatesViewModel.templateInfos=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&&this._logError("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force){this.emit("workflow-cancel"),this._set("activeWorkflow",null);try{await e.cancel(t)}finally{e.destroy()}}else try{await e.cancel(t),this._set("activeWorkflow",null),e.destroy()}catch(a){}}_createCreateFeaturesWorkflow(t,e){return O.create({viewModel:this,creationInfo:t,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),applyEditsFeatureServiceCallback:(t,e,a)=>this._applyEditsFeatureService(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_createUpdateWorkflow(t){return S.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),applyEditsFeatureServiceCallback:(t,e,a)=>this._applyEditsFeatureService(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 i("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 b(t.url):null,s={returnServiceEditsOption:(!i||!V(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 P(a,t).catch((()=>null));return r=await t.applyEdits(e,s),i&&await m((()=>!i.updating)),r})),r}async _applyEditsFeatureService(t,e,a){let r=null;return await this._queueOperation((async()=>r=await t.applyEdits(e,a))),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=>(Array.isArray(t)?t.forEach((t=>this._handleEditsResultError(t))):this._handleEditsResultError(t),t))).catch((a=>{this._logError("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)}))}_handleEditsResultError(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}}_createUpdatingResolver(){const t=u();return this._updatingHandles.addPromise(t.promise),t}_logErrorAndCancelWorkflow(t){const{name:e,message:a,details:r}=t;this._logError(e??"editing:workflow-start-failed",a??void 0,r??t),this._cancelWorkflow({force:!0})}_itemIsSuspended(t){const e=this.findEditorItemForLayer(t);return null!=e&&(!e.visible||e.disabled)}_logError(t,e,a){n.getLogger(this).error(new i(t,e,a))}};t([v()],N.prototype,"_featureTemplatesLayersAndTables",null),t([v()],N.prototype,"_snappingManager",void 0),t([v({readOnly:!0})],N.prototype,"activeWorkflow",void 0),t([v()],N.prototype,"activeLeafWorkflow",null),t([v({readOnly:!0})],N.prototype,"_activityQueue",void 0),t([v({readOnly:!0})],N.prototype,"canCreate",null),t([v()],N.prototype,"canCreateVisible",null),t([v({readOnly:!0})],N.prototype,"canUpdate",null),t([v()],N.prototype,"canUpdateVisible",null),t([v()],N.prototype,"featureTemplatesLayers",null),t([v()],N.prototype,"editorItems",void 0),t([v({readOnly:!0})],N.prototype,"failures",void 0),t([v()],N.prototype,"hideTemplatesForInactiveLayers",void 0),t([v({type:U})],N.prototype,"attachmentsViewModel",void 0),t([v()],N.prototype,"featureFormViewModel",null),t([v()],N.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),t([v({type:G})],N.prototype,"featureTemplatesViewModel",void 0),t([v()],N.prototype,"labelOptions",null),t([v()],N.prototype,"layerInfos",void 0),t([v()],N.prototype,"ownSketchViewModel",void 0),t([v()],N.prototype,"sketchOptions",void 0),t([v()],N.prototype,"sketchViewModel",null),t([v({type:L,nonNullable:!0})],N.prototype,"snappingOptions",void 0),t([v()],N.prototype,"spinnerViewModel",void 0),t([v()],N.prototype,"state",null),t([v({readOnly:!0})],N.prototype,"syncing",null),t([v()],N.prototype,"updating",null),t([v()],N.prototype,"tooltipOptions",null),t([v()],N.prototype,"valueOptions",null),t([v()],N.prototype,"view",null),t([v()],N.prototype,"canZoomTo",null),t([v()],N.prototype,"pageStack",void 0),t([v()],N.prototype,"showDiscardEditsPrompt",void 0),t([v()],N.prototype,"_candidateCommitted",void 0),t([v()],N.prototype,"page",null),t([v()],N.prototype,"featureFormDisabled",null),t([v()],N.prototype,"featureFormHasAssociation",null),t([v()],N.prototype,"canGoBack",null),t([v()],N.prototype,"shouldShowDeleteButton",null),t([v()],N.prototype,"hasPendingEdits",null),t([v()],N.prototype,"snappingManager",null),N=t([_("esri.widgets.Editor.EditorViewModel")],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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{abortMaybe as r}from"../../core/maybe.js";import{createResolver as s,onAbort as n,createAbortError as l,throwIfAborted as d,debounce as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,when as w,watch as h,sync as f}from"../../core/reactiveUtils.js";import{last as v}from"../../core/SetUtils.js";import{property as k}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as g}from"../../core/accessorSupport/decorators/subclass.js";import{isEditableLayer as m}from"../../layers/support/editableLayers.js";import{isFeatureLayer as y,isSubtypeSublayer as W,isSubtypeGroupLayer as b,isTable as A}from"../../layers/support/layerUtils.js";import{createFeatureServices as C}from"../../rest/featureService/utils.js";import _ from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as M}from"../../views/input/InputManager.js";import S from"../../views/interactive/sketch/SketchOptions.js";import{temporaryHighlightName as F}from"../../views/support/HighlightDefaults.js";import I from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as E}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as j}from"./UpdateRecordWorkflow.js";import U from"./UpdateWorkflowData.js";import P from"./Workflow.js";import{createWorkflowSteps as V,fetchCandidates as L}from"./workflowUtils.js";import{findUtilityNetwork as x,isGraphicForRelatableFeatureSupportedLayer as T}from"../Feature/support/featureUtils.js";var H;const O="esri.widgets.Editor.UpdateWorkflow",R=()=>o.getLogger(O);let N=H=class extends P{constructor(e){super(e),this._workflowStack=new p(v),this._sketchStack=new p(v),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack((e=>e.cancel({force:!0})))}get activeEditorItem(){return this.activeWorkflow?.data.editorItem??void 0}get activeFeatureFormViewModel(){return this.activeWorkflow?.featureFormViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{activeFeatureFormViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!e)return!1;const{activeAssociation:t,feature:a}=e;return!(!t||!a?.sourceLayer||!y(a?.sourceLayer)&&!W(a?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.featureFormViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||null!=e?.relationshipId||"view"!==this.data.viewModel.attachmentsViewModel.mode||null!=e?.associationId||null!=e?.associatedLayer}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some((({layer:e})=>t.findEditorItemForLayer(e)?.supportsUpdateWorkflow))}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditorItem?.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return!!this.activeEditorItem?.capabilities.update.attachments.enabled}get hasPendingEdits(){return Array.from(this._workflowStack).some((e=>e.hasPendingEdits))}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditorItem?.hasInvalidFormTemplate}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,a=t?.featureFormViewModel;if(a?.activeRelationshipInput){const e=a.activeRelationshipInput;if(e.activeCategory)return void(e.activeCategory=null);if(null!=a.relationshipId)return void(a.relationshipId=null);if(e.showAllEnabled)return void(e.showAllEnabled=!1)}if("add-association"===t?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:e}=this;if(e?.filterOptionsVisible)return void(e.filterOptionsVisible=!1);e?.featureSpatialItems.length&&e.reset()}if(null==a?.associatedLayer)if(null==a?.associationId)if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else a.associationId=null;else a.associatedLayer=null}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((e=>e.commit())),await super.commit()}static create(e){const{viewModel:t,snappingManager:a,startAt:i,addAttachmentsCallback:o,applyEditsCallback:r,applyEditsFeatureServiceCallback:s}=e,n=e.sketchOptions??new S,l=new H({data:new U({addAttachmentsCallback:o,applyEditsCallback:r,applyEditsFeatureServiceCallback:s,sketchOptions:n,snappingManager:a,viewModel:t}),onCommit:async()=>{}});return l._set("steps",this._createWorkflowSteps(l,i)),l}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startCreatingRelatedRecord(e){try{const t=await this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:t})}}async startUpdating(e,t){try{const a=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflow(a)}catch(i){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:i})}}async startAddAssociation(e,t,i){try{const a=await this._createNestedAddAssociationWorkflow(e,t,i);await this._pushWorkflow(a)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");G(e)?await e.deleteAndCommit():await e.cancel(),1===this.nestedWorkflowCount?await this.reset():(await this._popWorkflow(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new a("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflow(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack((e=>e.cancel({force:!0})))}async _deleteActiveAssociation(){const{activeFeatureFormViewModel:e,data:t}=this,{activeAssociation:i,feature:o}=e,{applyEditsFeatureServiceCallback:r,viewModel:s}=t,{sourceLayer:n}=o,l=W(n)&&n.parent?n.parent:n,d=C([l]),c=d.values().next().value?.featureService;if(!c)throw new a("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(c?.load());const p=s.view.map,u=x(p,l);await(u?.networkSystemLayers.loadAssociationsTable());const w=u?.generateDeleteAssociations([i]);if(!w)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");const h=u?.gdbVersion??void 0;await r(c,[w],{gdbVersion:h,globalIdUsed:!0})}async _returnToPageWithContent(){const{activeFeatureFormViewModel:e}=this;if(!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:a}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==a||t.associatedFeatureInfos.size||(e.associationId=null)}async _createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!m(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0;return I.create({addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!m(i)||b(i))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const{viewModel:o}=this.data,r={layer:i,maxFeatures:1},s=this._makeRelatedRecordAttributes(e),n=o.getTemplatesForLayer(i);return n?.length>0?(r.attributeOverrides=s,1===n.length&&(r.template=n[0])):r.initialFeature=new t({sourceLayer:i,attributes:s}),r}async _createNestedUpdateWorkflow(e,t){const a=A(e.sourceLayer)?j:E,{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,d=await a.create({association:t,feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:i,applyEditsFeatureService:o,featureFormCallbacks:{addRelatedRecord:async e=>await this._updatingHandles.addPromise(this.startCreatingRelatedRecord(e)),editRelatedRecord:async({relatedFeature:e})=>await this._updatingHandles.addPromise(this.startUpdating(e)),selectAssociatedFeature:async({feature:e,association:t})=>await this._updatingHandles.addPromise(this.startUpdating(e,t)),addAssociation:async e=>await this._updatingHandles.addPromise(this.startAddAssociation(e.feature,e.utilityNetwork,e.associationType))}});return await u((()=>!d.updating)),d}async _createNestedAddAssociationWorkflow(e,t,a){const{AddAssociationWorkflow:i}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:o,applyEditsFeatureServiceCallback:r,viewModel:s}=this.data,n="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,l=this.activeFeatureFormViewModel?.activeAssociationInput,d=await i.create({utilityNetwork:t,associationType:a,feature:e,parent:n,viewModel:s,associationInput:l,applyEdits:o,applyEditsFeatureService:r});return await u((()=>!d.updating)),d}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(;t.length>0;){const i=t.pop();this._sketchStack.pop();const o=e(i).then((()=>i.destroy()));this._updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:i}=e;if(!T(t))return;const o=a.relationships?.find((e=>e.id===i));if(!o)return void q("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===o.role)return void q("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;o.relatedTableId!==r.layerId&&q("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find((e=>e.id===i));if(!s)return void q("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=D(r,s),l=t.getAttribute(n);l||q("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=D(a,o);return{[d]:l}}async _popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflow(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,o=await(e?.start()),r=i.peek();o?(r?.exit(),i.push(o)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const a=e.peek();return await(a?.enter()),await(t.peek()?.enter()),{activeWorkflow:a,failureCount:0}}catch(a){e.pop().destroy(),t.pop();const{activeWorkflow:i,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:i,failureCount:o+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!A(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:o}=e;return V(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=o.viewModel,a=o.viewModel.view;a.activeTool=null;let c=null;e.addHandles(i((()=>{c=r(c)})),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",(async i=>{const r=s();e._updatingHandles.addPromise(r.promise);try{t.location=i.mapPoint,t.visible=!0,c?.abort();const{editorItems:r}=o.viewModel;c=new AbortController;const s=await i.async((()=>new Promise(((e,t)=>{n(c?.signal,(()=>t(l()))),e(L(r,a,i,c?.signal))}))));if(d(c),o.candidates=s.filter((e=>"fulfilled"===e.status)).flatMap((e=>e.value)).filter((e=>!e.isAggregate)),t.visible=1===o.candidates.length,0===o.candidates.length)return;i.stopPropagation(),1===o.candidates.length?(o.rootFeature=o.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>t.visible=!1))):e.next()}finally{r.resolve()}}),M.TOOL),u=w((()=>null!=a.activeTool),(()=>e.cancel({force:!0})),{once:!0});a.focus(),e.addHandles([p,u],this.id)},async tearDown(){0===o.candidates.length&&(o.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null;const{view:t}=o.viewModel;if(!t)return;const a=new _({view:t,highlightName:F});e.addHandles([h((()=>o.rootFeature),((e,t)=>{a.remove(t),a.add(e)}),f),i((()=>a.removeAll()))],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:t,viewModel:i}=e.data;if(!t)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await e.startUpdating(t),i.spinnerViewModel.visible=!1;const o=c((async()=>{await u((()=>!e.updating)),e.previous()}));e.addHandles([h((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&o()}),f)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}})})}};function D(e,{keyField:t}){return e.getField(t)?.name??t}e([k()],N.prototype,"activeEditorItem",null),e([k()],N.prototype,"activeFeatureFormViewModel",null),e([k()],N.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([k()],N.prototype,"activeSketchViewModel",null),e([k()],N.prototype,"canDeleteAssociation",null),e([k()],N.prototype,"activeWorkflow",null),e([k()],N.prototype,"updating",null),e([k()],N.prototype,"data",void 0),e([k()],N.prototype,"hasPreviousStep",null),e([k()],N.prototype,"hasUpdatableCandidates",null),e([k()],N.prototype,"nestedWorkflowCount",null),e([k()],N.prototype,"shouldShowAttachments",null),e([k()],N.prototype,"shouldAllowAttachmentEditing",null),e([k()],N.prototype,"hasPendingEdits",null),e([k()],N.prototype,"helpMessage",null),e([k()],N.prototype,"reliesOnOwnerAdminPrivileges",null),e([k()],N.prototype,"hasInvalidFormTemplate",null),N=H=e([g(O)],N);const q=(e,t)=>R().warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature."),G=e=>!!e&&/update-/.test(e.type),z=N;export{z as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{abortMaybe as r}from"../../core/maybe.js";import{createResolver as s,onAbort as n,createAbortError as l,throwIfAborted as d,debounce as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,when as h,watch as w,sync as f}from"../../core/reactiveUtils.js";import{last as g}from"../../core/SetUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{isEditableLayer as m}from"../../layers/support/editableLayers.js";import{isFeatureLayer as y,isSubtypeSublayer as W,isSubtypeGroupLayer as b,isTable as A}from"../../layers/support/layerUtils.js";import{createFeatureServices as C}from"../../rest/featureService/utils.js";import _ from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as M}from"../../views/input/InputManager.js";import S from"../../views/interactive/sketch/SketchOptions.js";import{temporaryHighlightName as F}from"../../views/support/HighlightDefaults.js";import I from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as E}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as j}from"./UpdateRecordWorkflow.js";import U from"./UpdateWorkflowData.js";import P from"./Workflow.js";import{createWorkflowSteps as V,fetchCandidates as R}from"./workflowUtils.js";import{findUtilityNetwork as L,isGraphicForRelatableFeatureSupportedLayer as x}from"../Feature/support/featureUtils.js";var T;let H=T=class extends P{constructor(e){super(e),this._workflowStack=new p(g),this._sketchStack=new p(g),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack((e=>e.cancel({force:!0})))}get activeEditorItem(){return this.activeWorkflow?.data.editorItem??void 0}get activeFeatureFormViewModel(){return this.activeWorkflow?.featureFormViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{activeFeatureFormViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!e)return!1;const{activeAssociation:t,feature:a}=e;return!(!t||!a?.sourceLayer||!y(a?.sourceLayer)&&!W(a?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.featureFormViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||null!=e?.relationshipId||"view"!==this.data.viewModel.attachmentsViewModel.mode||null!=e?.associationId||null!=e?.associatedLayer}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some((({layer:e})=>t.findEditorItemForLayer(e)?.supportsUpdateWorkflow))}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditorItem?.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return!!this.activeEditorItem?.capabilities.update.attachments.enabled}get hasPendingEdits(){return Array.from(this._workflowStack).some((e=>e.hasPendingEdits))}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditorItem?.hasInvalidFormTemplate}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,a=t?.featureFormViewModel;if(a?.activeRelationshipInput){const e=a.activeRelationshipInput;if(e.activeCategory)return void(e.activeCategory=null);if(null!=a.relationshipId)return void(a.relationshipId=null);if(e.showAllEnabled)return void(e.showAllEnabled=!1)}if("add-association"===t?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:e}=this;if(e?.filterOptionsVisible)return void(e.filterOptionsVisible=!1);e?.featureSpatialItems.length&&e.reset()}if(null==a?.associatedLayer)if(null==a?.associationId)if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else a.associationId=null;else a.associatedLayer=null}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((e=>e.commit())),await super.commit()}static create(e){const{viewModel:t,snappingManager:a,startAt:i,addAttachmentsCallback:o,applyEditsCallback:r,applyEditsFeatureServiceCallback:s}=e,n=e.sketchOptions??new S,l=new T({data:new U({addAttachmentsCallback:o,applyEditsCallback:r,applyEditsFeatureServiceCallback:s,sketchOptions:n,snappingManager:a,viewModel:t}),onCommit:async()=>{}});return l._set("steps",this._createWorkflowSteps(l,i)),l}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startCreatingRelatedRecord(e){try{const t=await this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:t})}}async startUpdating(e,t){try{const a=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflow(a)}catch(i){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:i})}}async startAddAssociation(e,t,i){try{const a=await this._createNestedAddAssociationWorkflow(e,t,i);await this._pushWorkflow(a)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");N(e)?await e.deleteAndCommit():await e.cancel(),1===this.nestedWorkflowCount?await this.reset():(await this._popWorkflow(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new a("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflow(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack((e=>e.cancel({force:!0})))}async _deleteActiveAssociation(){const{activeFeatureFormViewModel:e,data:t}=this,{activeAssociation:i,feature:o}=e,{applyEditsFeatureServiceCallback:r,viewModel:s}=t,{sourceLayer:n}=o,l=W(n)&&n.parent?n.parent:n,d=C([l]),c=d.values().next().value?.featureService;if(!c)throw new a("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(c?.load());const p=s.view.map,u=L(p,l);await(u?.networkSystemLayers.loadAssociationsTable());const h=u?.generateDeleteAssociations([i]);if(!h)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");const w=u?.gdbVersion??void 0;await r(c,[h],{gdbVersion:w,globalIdUsed:!0})}async _returnToPageWithContent(){const{activeFeatureFormViewModel:e}=this;if(!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:a}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==a||t.associatedFeatureInfos.size||(e.associationId=null)}async _createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!m(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0;return I.create({addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!m(i)||b(i))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const{viewModel:o}=this.data,r={layer:i,maxFeatures:1},s=this._makeRelatedRecordAttributes(e),n=o.getTemplatesForLayer(i);return n?.length>0?(r.attributeOverrides=s,1===n.length&&(r.template=n[0])):r.initialFeature=new t({sourceLayer:i,attributes:s}),r}async _createNestedUpdateWorkflow(e,t){const a=A(e.sourceLayer)?j:E,{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,d=await a.create({association:t,feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:i,applyEditsFeatureService:o,featureFormCallbacks:{addRelatedRecord:async e=>await this._updatingHandles.addPromise(this.startCreatingRelatedRecord(e)),editRelatedRecord:async({relatedFeature:e})=>await this._updatingHandles.addPromise(this.startUpdating(e)),selectAssociatedFeature:async({feature:e,association:t})=>await this._updatingHandles.addPromise(this.startUpdating(e,t)),addAssociation:async e=>await this._updatingHandles.addPromise(this.startAddAssociation(e.feature,e.utilityNetwork,e.associationType))}});return await u((()=>!d.updating)),d}async _createNestedAddAssociationWorkflow(e,t,a){const{AddAssociationWorkflow:i}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:o,applyEditsFeatureServiceCallback:r,viewModel:s}=this.data,n="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,l=this.activeFeatureFormViewModel?.activeAssociationInput,d=await i.create({utilityNetwork:t,associationType:a,feature:e,parent:n,viewModel:s,associationInput:l,applyEdits:o,applyEditsFeatureService:r});return await u((()=>!d.updating)),d}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(;t.length>0;){const i=t.pop();this._sketchStack.pop();const o=e(i).then((()=>i.destroy()));this._updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:i}=e;if(!x(t))return;const o=a.relationships?.find((e=>e.id===i));if(!o)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===o.role)return void this._logContinuingWithoutRelationshipWarning("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;o.relatedTableId!==r.layerId&&this._logContinuingWithoutRelationshipWarning("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find((e=>e.id===i));if(!s)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=O(r,s),l=t.getAttribute(n);l||this._logContinuingWithoutRelationshipWarning("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=O(a,o);return{[d]:l}}async _popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflow(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,o=await(e?.start()),r=i.peek();o?(r?.exit(),i.push(o)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const a=e.peek();return await(a?.enter()),await(t.peek()?.enter()),{activeWorkflow:a,failureCount:0}}catch(a){e.pop().destroy(),t.pop();const{activeWorkflow:i,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:i,failureCount:o+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!A(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:o}=e;return V(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=o.viewModel,a=o.viewModel.view;a.activeTool=null;let c=null;e.addHandles(i((()=>{c=r(c)})),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",(async i=>{const r=s();e._updatingHandles.addPromise(r.promise);try{t.location=i.mapPoint,t.visible=!0,c?.abort();const{editorItems:r}=o.viewModel;c=new AbortController;const s=await i.defer((()=>new Promise(((e,t)=>{n(c?.signal,(()=>t(l()))),e(R(r,a,i,c?.signal))}))));if(d(c),o.candidates=s.filter((e=>"fulfilled"===e.status)).flatMap((e=>e.value)).filter((e=>!e.isAggregate)),t.visible=1===o.candidates.length,0===o.candidates.length)return;i.stopPropagation(),1===o.candidates.length?(o.rootFeature=o.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>t.visible=!1))):e.next()}finally{r.resolve()}}),M.TOOL),u=h((()=>null!=a.activeTool),(()=>e.cancel({force:!0})),{once:!0});a.focus(),e.addHandles([p,u],this.id)},async tearDown(){0===o.candidates.length&&(o.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null;const{view:t}=o.viewModel;if(!t)return;const a=new _({view:t,highlightName:F});e.addHandles([w((()=>o.rootFeature),((e,t)=>{a.remove(t),a.add(e)}),f),i((()=>a.removeAll()))],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:t,viewModel:i}=e.data;if(!t)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await e.startUpdating(t),i.spinnerViewModel.visible=!1;const o=c((async()=>{await u((()=>!e.updating)),e.previous()}));e.addHandles([w((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&o()}),f)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}})})}_logContinuingWithoutRelationshipWarning(e,t){o.getLogger(this).warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature.")}};function O(e,{keyField:t}){return e.getField(t)?.name??t}e([v()],H.prototype,"activeEditorItem",null),e([v()],H.prototype,"activeFeatureFormViewModel",null),e([v()],H.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([v()],H.prototype,"activeSketchViewModel",null),e([v()],H.prototype,"canDeleteAssociation",null),e([v()],H.prototype,"activeWorkflow",null),e([v()],H.prototype,"updating",null),e([v()],H.prototype,"data",void 0),e([v()],H.prototype,"hasPreviousStep",null),e([v()],H.prototype,"hasUpdatableCandidates",null),e([v()],H.prototype,"nestedWorkflowCount",null),e([v()],H.prototype,"shouldShowAttachments",null),e([v()],H.prototype,"shouldAllowAttachmentEditing",null),e([v()],H.prototype,"hasPendingEdits",null),e([v()],H.prototype,"helpMessage",null),e([v()],H.prototype,"reliesOnOwnerAdminPrivileges",null),e([v()],H.prototype,"hasInvalidFormTemplate",null),H=T=e([k("esri.widgets.Editor.UpdateWorkflow")],H);const N=e=>!!e&&/update-/.test(e.type),D=H;export{D as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
+ */
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{isSome as i}from"../../../core/arrayUtils.js";import s from"../../../core/Error.js";import{abortHandle as o}from"../../../core/handleUtils.js";import{debounce as r}from"../../../core/promiseUtils.js";import{whenOnce as a,watch as n}from"../../../core/reactiveUtils.js";import{first as l}from"../../../core/SetUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../../core/support/UpdatingHandles.js";import d from"../../../layers/GraphicsLayer.js";import u from"../../../views/interactive/sketch/SketchOptions.js";import{getVisualVariablesForLayer as y,updateGraphicSymbolWhenRequired as m,setVisualVariablesAndElevationInfoForUpdate as w,swapForEditingSession as v,getRotationVariableAttribute as f,getSizeVariableAttribute as g,visualVariableInteractiveUpdate as b}from"../workflowUtils.js";import k from"../../Sketch/SketchViewModel.js";const _=Symbol();let S=class extends t{constructor(e){super(e),this.features=[],this.onSketchUpdate=()=>{},this.sketchOptions=new u,this.snappingManager=null,this.sourceLayer=null,this.view=null,this.viewModel=null,this._sketchGraphics=new Map,this._sketchLayer=null,this._updatingHandles=new h,this._visualVariableAttributes=new Map,this._visualVariablesForLayer=null,this._webStyleCache=new Map}async initialize(){this._visualVariablesForLayer=y(this.sourceLayer),this._initializeSketchGraphics(),this._initializeSketchLayer(),await this._updatingHandles.addPromise(this._initializeSketchViewModel())}destroy(){const{_sketchLayer:e,view:t}=this;t?.destroyed||t?.map.remove(e),e.destroy(),this.viewModel.destroy()}get updating(){return this._updatingHandles.updating}async enter(){throw new Error("enter() not implemented")}async exit(){throw new Error("exit() not implemented")}notifyAttributesChanged({features:e,fieldName:t}){const i=this._webStyleCache,s=this.view.scale;for(const o of e){const e=this._sketchGraphics.get(o),r=o.getAttribute(t);if(!e||e.getAttribute(t)===r)continue;e.setAttribute(t,r);const a=this._visualVariableAttributes.get(o);null==a?.size||a.size.isUpdatingInteractively||a.size.field!==t||a.size.setInitialValue(r),null==a?.rotation||a.rotation.isUpdatingInteractively||a.rotation.field!==t||a.rotation.setInitialValue(r),m(e,i,s)}}async startUpdatingFeatures(e,t,s){const{_sketchGraphics:r,sourceLayer:n,view:l,viewModel:c,_webStyleCache:p}=this,h=e.map((e=>r.get(e))).filter(i),d={multipleSelectionEnabled:!1};this.removeHandles(_),c.complete();let u=null;if(1===e.length){const t=e[0],i=this._visualVariableAttributes.get(t);!(!i?.rotation&&!i?.size)&&(w({sketchViewModel:c,graphic:h[0],sourceLayer:n,visualVariables:i,webStyleCache:p}),"point"===n.geometryType&&(d.enableRotation=null!=i.rotation,d.enableScaling=null!=i.size,u=async e=>{const o=e.graphics[0];b(l,o,e,i)&&(s?.(t,o.attributes,e),await m(o,p,"2d"===l.type?l.scale:null))}))}const y=()=>c.update(h,d);await y();const v=c.on("update",(i=>{if("complete"===i.state){if(null===l.activeTool)return void y();const e=new AbortController,t=o(e);return this.addHandles(t,_),void this._updatingHandles.addPromise(a((()=>null===l.activeTool),e.signal).then((async()=>{e.signal.aborted||(e.abort(),await y())})))}for(const s of e){const e=r.get(s);e&&t?.(s,e.geometry,i)}u?.(i)}));this.addHandles(v,_),c.addHandles(v)}_initializeSketchGraphics(){const{features:e,_sketchGraphics:t,sourceLayer:i,_visualVariableAttributes:s}=this,o=this._visualVariablesForLayer,r=o.rotation?.field,a=o.size?.field,n={rotation:r?i.getField(r):null,size:a?i.getField(a):null},l=!(!n.rotation&&!n.size);for(const c of e)t.set(c,c.clone()),l&&s.set(c,z(o,n))}_initializeSketchLayer(){const e=new d({elevationInfo:this.sourceLayer.elevationInfo,internal:!0,listMode:"hide"});this._sketchLayer=e,this.view.map.add(e)}async _initializeSketchViewModel(){const{_sketchGraphics:e,view:t,_webStyleCache:i}=this,s=Array.from(e.entries()),o=new k({allowDeleteKey:!1,layer:this._sketchLayer,sketchOptions:this.sketchOptions,snappingManager:this.snappingManager,updateOnGraphicClick:!1,view:this.view});this.viewModel=o;const a=r((e=>Promise.all(s.map((([,t])=>m(t,i,e))))));await a("2d"===t.type?t.scale:null),"2d"===t.type&&this.addHandles(n((()=>t.scale),(e=>a(e)))),this.addHandles(await Promise.all(s.map((([e,t])=>v(o,e,t)))))}};function L({features:e,sketchOptions:t,snappingManager:i,view:o}){const r=new Set(e.map((e=>e.sourceLayer)));if(1!==r.size)throw new s("editor:features-must-belong-to-same-layer","All features must belong to the same layer.");const a=l(r);return new S({view:o,features:e,sketchOptions:t,snappingManager:i,sourceLayer:a})}function z({rotation:e,size:t},i){return{rotation:e?f(e,i.rotation):null,size:t?g(t,i.size):null}}e([c()],S.prototype,"features",void 0),e([c()],S.prototype,"onSketchUpdate",void 0),e([c()],S.prototype,"sketchOptions",void 0),e([c()],S.prototype,"snappingManager",void 0),e([c()],S.prototype,"sourceLayer",void 0),e([c()],S.prototype,"updating",null),e([c()],S.prototype,"view",void 0),e([c()],S.prototype,"viewModel",void 0),e([c()],S.prototype,"_sketchGraphics",void 0),e([c()],S.prototype,"_sketchLayer",void 0),e([c()],S.prototype,"_visualVariablesForLayer",void 0),S=e([p("esri.widgets.Editor.support.SketchController")],S);export{S as SketchController,L as createSketchController};