@arcgis/core 4.33.0-next.20250521 → 4.33.0-next.20250522

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 (237) hide show
  1. package/applications/Components/analysisUtils.d.ts +2 -0
  2. package/applications/Components/analysisUtils.js +1 -1
  3. package/arcade/featureset/actions/GroupBy.js +1 -1
  4. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  5. package/assets/esri/core/workers/RemoteClient.js +1 -1
  6. package/assets/esri/core/workers/chunks/0a770f283eb77c8dc97a.js +1 -0
  7. package/assets/esri/core/workers/chunks/0dcab04dd1feeb5521cf.js +1 -0
  8. package/assets/esri/core/workers/chunks/{8a2cee726b7843c7408a.js → 0fb5de3f8a4d69b2d514.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{7c819b3e6d69c526f4b2.js → 1c86aa3802d9ae0230ae.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{b53a7040a71b0f1f3854.js → 23f6e98ef22f099f846c.js} +1 -1
  11. package/assets/esri/core/workers/chunks/28b1819bf744ce957dfd.js +2 -0
  12. package/assets/esri/core/workers/chunks/28b1819bf744ce957dfd.js.LICENSE.txt +33 -0
  13. package/assets/esri/core/workers/chunks/{234117cc5cb7c6863313.js → 2d90806faa4269828948.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{e2cada6644c49b1b6e79.js → 36b0d6b4089a96475201.js} +1 -1
  15. package/assets/esri/core/workers/chunks/40f54c4f8ae63c6f3df9.js +1 -0
  16. package/assets/esri/core/workers/chunks/4193c52799aa3b6337c9.js +2 -0
  17. package/assets/esri/core/workers/chunks/{9588328d4ed6b0f04166.js.LICENSE.txt → 4193c52799aa3b6337c9.js.LICENSE.txt} +0 -34
  18. package/assets/esri/core/workers/chunks/42d9989b2aad3ac28d4d.js +1 -0
  19. package/assets/esri/core/workers/chunks/{8a6aac37b3133de74cce.js → 51c31e6d014005107d42.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{5c8d52b72a3bea4202ac.js → 634a418310e44e2436e0.js} +1 -1
  21. package/assets/esri/core/workers/chunks/6ee41e9c92ed8ba4c763.js +1 -0
  22. package/assets/esri/core/workers/chunks/{83fcc6f770ad084b8ab9.js → 86023cc5ccbc7ac43479.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{cc4a6f4000cb6680be48.js → ac2607f1e8cd2e99907c.js} +2 -2
  24. package/assets/esri/core/workers/chunks/bf3555f91492a1a3b613.js +1 -0
  25. package/assets/esri/core/workers/chunks/d2ebb72a43d995ed368a.js +1 -0
  26. package/assets/esri/core/workers/chunks/dbe10c20df7e0e563a0b.js +1 -0
  27. package/assets/esri/core/workers/chunks/df933eac03dc63064723.js +1 -0
  28. package/assets/esri/core/workers/chunks/e77371ddbaf4b2d9be8d.js +1 -0
  29. package/assets/esri/core/workers/chunks/{19a58adc75a34f84b0ef.js → ee6240636d04d7d37b7b.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{f74f8ed3f17713a208c3.js → fa63b0f7fa799cb2f81d.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{6c29a768f02dc7ce0ed6.js → fb9e9b9e567e32f37042.js} +1 -1
  32. package/assets/esri/core/workers/chunks/fc61d02286b6ff5447cc.js +1 -0
  33. package/assets/esri/themes/base/widgets/_Editor.scss +40 -2
  34. package/assets/esri/themes/base/widgets/_FeatureForm.scss +4 -0
  35. package/assets/esri/themes/base/widgets/_SelectionList.scss +21 -15
  36. package/assets/esri/themes/base/widgets/_SelectionToolbar.scss +1 -0
  37. package/assets/esri/themes/dark/main.css +1 -1
  38. package/assets/esri/themes/light/main.css +1 -1
  39. package/assets/esri/themes/light/view.css +1 -1
  40. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ar.json +1 -1
  41. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bg.json +1 -1
  42. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bs.json +1 -1
  43. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ca.json +1 -1
  44. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_cs.json +1 -1
  45. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_da.json +1 -1
  46. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_de.json +1 -1
  47. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_el.json +1 -1
  48. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_es.json +1 -1
  49. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_et.json +1 -1
  50. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fi.json +1 -1
  51. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fr.json +1 -1
  52. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_he.json +1 -1
  53. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hr.json +1 -1
  54. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hu.json +1 -1
  55. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_id.json +1 -1
  56. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_it.json +1 -1
  57. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ja.json +1 -1
  58. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ko.json +1 -1
  59. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lt.json +1 -1
  60. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lv.json +1 -1
  61. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_nl.json +1 -1
  62. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_no.json +1 -1
  63. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pl.json +1 -1
  64. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-BR.json +1 -1
  65. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-PT.json +1 -1
  66. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ro.json +1 -1
  67. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ru.json +1 -1
  68. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sk.json +1 -1
  69. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sl.json +1 -1
  70. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sr.json +1 -1
  71. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sv.json +1 -1
  72. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_th.json +1 -1
  73. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_tr.json +1 -1
  74. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_uk.json +1 -1
  75. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_vi.json +1 -1
  76. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-CN.json +1 -1
  77. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-HK.json +1 -1
  78. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-TW.json +1 -1
  79. package/assets/esri/widgets/Editor/t9n/Editor.json +1 -1
  80. package/assets/esri/widgets/Editor/t9n/Editor_en.json +1 -1
  81. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm.json +1 -1
  82. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_en.json +1 -1
  83. package/assets/esri/widgets/Home/t9n/Home_pt-BR.json +1 -1
  84. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer.json +1 -1
  85. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ar.json +1 -1
  86. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bg.json +1 -1
  87. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bs.json +1 -1
  88. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ca.json +1 -1
  89. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_cs.json +1 -1
  90. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_da.json +1 -1
  91. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_de.json +1 -1
  92. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_el.json +1 -1
  93. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_en.json +1 -1
  94. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_es.json +1 -1
  95. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_et.json +1 -1
  96. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fi.json +1 -1
  97. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fr.json +1 -1
  98. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_he.json +1 -1
  99. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hr.json +1 -1
  100. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hu.json +1 -1
  101. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_id.json +1 -1
  102. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_it.json +1 -1
  103. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ja.json +1 -1
  104. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ko.json +1 -1
  105. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lt.json +1 -1
  106. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lv.json +1 -1
  107. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_nl.json +1 -1
  108. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_no.json +1 -1
  109. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pl.json +1 -1
  110. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-BR.json +1 -1
  111. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-PT.json +1 -1
  112. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ro.json +1 -1
  113. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ru.json +1 -1
  114. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sk.json +1 -1
  115. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sl.json +1 -1
  116. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sr.json +1 -1
  117. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sv.json +1 -1
  118. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_th.json +1 -1
  119. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_tr.json +1 -1
  120. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_uk.json +1 -1
  121. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_vi.json +1 -1
  122. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-CN.json +1 -1
  123. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-HK.json +1 -1
  124. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-TW.json +1 -1
  125. package/chunks/ComponentShader.glsl.js +24 -15
  126. package/core/sanitizerUtils.js +5 -0
  127. package/editing/sharedTemplates/SharedTemplate.js +1 -1
  128. package/editing/sharedTemplates/templateDefinitions/FeatureTemplateDefinition.js +1 -1
  129. package/editing/sharedTemplates/templateDefinitions/GroupTemplateDefinition.js +1 -1
  130. package/editing/sharedTemplates/templateDefinitions/PresetTemplateDefinition.js +1 -1
  131. package/editing/sharedTemplates/templateDefinitions/parts/FeatureTemplateRelationshipPart.js +1 -1
  132. package/editing/sharedTemplates/templateDefinitions/parts/GroupTemplatePart.js +1 -1
  133. package/editing/sharedTemplates/templateDefinitions/parts/PresetTemplatePart.js +1 -1
  134. package/interfaces.d.ts +193 -11
  135. package/layers/IntegratedMeshLayer.js +1 -1
  136. package/layers/WMSLayer.js +1 -1
  137. package/layers/graphics/data/QueryEngineCapabilities.js +1 -1
  138. package/layers/graphics/sources/OGCFeatureSource.js +1 -1
  139. package/layers/mixins/ArcGISImageService.js +1 -1
  140. package/layers/support/VideoElement.js +1 -1
  141. package/layers/support/capabilities.js +1 -1
  142. package/layers/support/rasterFunctions/clipUtils.js +1 -1
  143. package/layers/support/serviceCapabilitiesUtils.js +1 -1
  144. package/libs/maquette/projection.js +1 -1
  145. package/networks/UnitIdentifierManager.js +5 -0
  146. package/networks/support/UNTraceConfiguration.js +1 -1
  147. package/package.json +1 -1
  148. package/rest/featureService/FeatureService.js +1 -1
  149. package/rest/knowledgeGraph/GraphAddNamedTypesResult.d.ts +4 -0
  150. package/rest/knowledgeGraph/GraphDeleteNamedTypeResult.d.ts +4 -0
  151. package/rest/knowledgeGraphService.d.ts +2 -0
  152. package/rest/networks/unitIdentifiers/support/UnitQueryResult.js +1 -1
  153. package/rest/query/executeQuery.js +1 -1
  154. package/rest/query/executeQueryJSON.js +1 -1
  155. package/rest/query/executeQueryPBF.js +1 -1
  156. package/rest/query.js +1 -1
  157. package/smartMapping/renderers/support/spikeUtils.js +1 -1
  158. package/support/revision.js +1 -1
  159. package/views/2d/LabelManager.js +1 -1
  160. package/views/2d/engine/imagery/RasterBitmap.js +1 -1
  161. package/views/2d/engine/vectorTiles/decluttering/SymbolDeclutterer.js +1 -1
  162. package/views/2d/engine/vectorTiles/decluttering/core.js +1 -1
  163. package/views/2d/engine/webgl/FeatureTile.js +1 -1
  164. package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
  165. package/views/2d/engine/webgl/collisions/LabelMetric.js +1 -1
  166. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  167. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterColorizerTechnique.js +1 -1
  168. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ReprojectTechnique.js +1 -1
  169. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/BaseRasterColorizerShader.js +1 -1
  170. package/views/2d/layers/VectorTileLayerView2D.js +1 -1
  171. package/views/2d/layers/features/FeatureContainer.js +1 -1
  172. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  173. package/views/2d/layers/support/vectorTileDebugUtils.js +1 -1
  174. package/views/3d/FocusAreasView.js +1 -1
  175. package/views/3d/layers/I3SMeshView3D.js +1 -1
  176. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  177. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  178. package/views/3d/layers/i3s/enums.js +1 -1
  179. package/views/3d/terrain/TerrainRenderer.js +1 -1
  180. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  181. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  182. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  183. package/views/3d/webgl-engine/core/renderPasses/AllRenderPasses.js +1 -1
  184. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  185. package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
  186. package/views/3d/webgl-engine/lib/RenderSlot.js +1 -1
  187. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  188. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  189. package/views/ui/UI.js +1 -1
  190. package/views/webgl/Texture.js +1 -1
  191. package/views/webgl/rasterUtils.js +1 -1
  192. package/webscene/Slide.js +1 -1
  193. package/widgets/DirectionalPad.js +1 -1
  194. package/widgets/Editor/EditorViewModel.js +1 -1
  195. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  196. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  197. package/widgets/Editor/UpdateRecordWorkflowData.js +1 -1
  198. package/widgets/Editor/UpdateWorkflow.js +1 -1
  199. package/widgets/Editor/VisibleElements.js +1 -1
  200. package/widgets/Editor/components/FooterActions.js +1 -1
  201. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  202. package/widgets/Editor/css.js +1 -1
  203. package/widgets/Editor.js +1 -1
  204. package/widgets/FeatureForm/TextElementInput.js +1 -1
  205. package/widgets/FeatureForm/css.js +1 -1
  206. package/widgets/FeatureForm.js +1 -1
  207. package/widgets/FeatureTable/AttachmentsColumn.js +1 -1
  208. package/widgets/FeatureTable/FieldColumn.js +1 -1
  209. package/widgets/FeatureTable/Grid/Column.js +1 -1
  210. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  211. package/widgets/FeatureTable/Grid/support/ButtonMenu.js +1 -1
  212. package/widgets/FeatureTable/support/exportUtils.js +1 -1
  213. package/widgets/FeatureTable.js +1 -1
  214. package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
  215. package/widgets/Sketch.js +1 -1
  216. package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
  217. package/widgets/support/SelectionList/VisibleElements.js +1 -1
  218. package/widgets/support/SelectionList.js +1 -1
  219. package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
  220. package/widgets/support/SelectionToolbar/VisibleElements.js +1 -1
  221. package/widgets/support/SelectionToolbar.js +1 -1
  222. package/widgets/support/Selector2D/SelectionOperation.js +1 -1
  223. package/widgets/support/Selector2D/selectorUtils.js +1 -1
  224. package/widgets/support/widget.js +1 -1
  225. package/widgets/support/widgetUtils.js +1 -1
  226. package/assets/esri/core/workers/chunks/0c50ee1f3cdd30d96479.js +0 -1
  227. package/assets/esri/core/workers/chunks/133e4bde346828d4510b.js +0 -1
  228. package/assets/esri/core/workers/chunks/5228d39c05d660a135b6.js +0 -1
  229. package/assets/esri/core/workers/chunks/5f4ca51b82daf0e51010.js +0 -1
  230. package/assets/esri/core/workers/chunks/8fda0a5b247385e68dc0.js +0 -1
  231. package/assets/esri/core/workers/chunks/938f1eebc48871be64e9.js +0 -1
  232. package/assets/esri/core/workers/chunks/9588328d4ed6b0f04166.js +0 -2
  233. package/assets/esri/core/workers/chunks/9839309d0cd804fe52c2.js +0 -1
  234. package/assets/esri/core/workers/chunks/9b610fbfcd47c3dde34d.js +0 -1
  235. package/assets/esri/core/workers/chunks/be2c8c0a8b2bce7979b6.js +0 -1
  236. package/assets/esri/core/workers/chunks/f218a190015de1444018.js +0 -1
  237. package/assets/esri/core/workers/chunks/f9567108862629f25c8b.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../core/Error.js";import"../../core/has.js";import e from"../../core/Logger.js";import{abortMaybe as i}from"../../core/maybe.js";import{throwIfAborted as r,isAbortError as s}from"../../core/promiseUtils.js";import{checkWebGLError as o}from"./checkWebGLError.js";import{TextureType as a,ResourceType as n,CompressedTextureFormat as p,TextureSamplingMode as l,TextureConstants as h,PixelFormat as m}from"./enums.js";import{FBOAttachmentType as d}from"./FBOAttachmentType.js";import{estimateMemory as c}from"./TextureDescriptor.js";import{isCompressedData as _,deriveInternalFormat as u,isTexImageSource as g,is3DTarget as T,validateTexture as x,isCompressedFormat as E,getDimensions as M,calcMipmapLevels as A,isSizedPixelFormat as b,isSizedDepthFormat as f,isSizedDepthStencilFormat as w}from"./textureUtils.js";import{ValidatedTextureDescriptor as I}from"./ValidatedTextureDescriptor.js";const R=null,D=()=>e.getLogger("esri/views/webgl/Texture");let S=class e{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(e,i=null,r=null){if(this.type=d.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._shadowFilterDirty=!1,this._wasImmutablyAllocated=!1,"context"in e)this._descriptor=e,r=i;else{const r=I.validate(e,i);if(!r)throw new t("texture:invalid-descriptor","Texture descriptor invalid");this._descriptor=r}this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return c(this._descriptor)}get cachedMemory(){return this.usedMemory}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty||this._shadowFilterDirty}get hasWebGLTextureObject(){return!!this._glName}dispose(){this.abortCompression(),this._descriptor.context.gl&&this.hasWebGLTextureObject&&(this._descriptor.context.instanceCounter.decrement(n.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("texture:immutable-resize","Immutable textures can't be resized!");r.width=e,r.height=i,this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}enableCompression(t,e){this._descriptor.compressionHandle=t,this._descriptor.compressionCallback=e}disableCompression(){this._descriptor.compressionHandle=null,this._descriptor.compressionCallback=null}setData(t){this.abortCompression(),!_(t)&&this._descriptor.internalFormat&&this._descriptor.internalFormat in p&&(this._descriptor.internalFormat=void 0),this._setData(t),!_(t)&&this._descriptor.compressionHandle&&this._compressOnWorker(t)}updateData(i,r,s,o,a,n,p=0){n||D().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||D().error("An attempt to update uninitialized texture!");const l=this._descriptor;l.internalFormat=u(l);const{context:h,pixelFormat:m,dataType:d,target:c,isImmutable:T}=l;if(T&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");const x=h.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES,!0);(r<0||s<0||r+o>l.width||s+a>l.height)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:E}=h;p&&(o&&a||D().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),E.pixelStorei(E.UNPACK_SKIP_ROWS,p)),g(n)?E.texSubImage2D(c,i,r,s,o,a,m,d,n):_(n)?E.compressedTexSubImage2D(c,i,r,s,o,a,l.internalFormat,n.levels[i]):E.texSubImage2D(c,i,r,s,o,a,m,d,n),p&&E.pixelStorei(E.UNPACK_SKIP_ROWS,0),h.bindTexture(x,e.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(i,r,s,o,a,n,p,l){l||D().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||D().error("An attempt to update an uninitialized texture!");const h=this._descriptor;h.internalFormat=u(h);const{context:m,pixelFormat:d,dataType:c,isImmutable:g,target:x}=h;if(g&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");T(x)||D().warn("Attempting to set 3D texture data on a non-3D texture");const E=m.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);m.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),(r<0||s<0||o<0||r+a>h.width||s+n>h.height||o+p>h.depth)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:M}=m;if(_(l))l=l.levels[i],M.compressedTexSubImage3D(x,i,r,s,o,a,n,p,h.internalFormat,l);else{const t=l;M.texSubImage3D(x,i,r,s,o,a,n,p,d,c,t)}m.bindTexture(E,e.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const i=this._descriptor;if(0===i.width||0===i.height)return;if(!i.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot add mipmaps to immutable texture after allocation");i.hasMipmap=!0,this._samplingModeDirty=!0,x(i)}i.samplingMode===l.LINEAR?(this._samplingModeDirty=!0,i.samplingMode=l.LINEAR_MIPMAP_NEAREST):i.samplingMode===l.NEAREST&&(this._samplingModeDirty=!0,i.samplingMode=l.NEAREST_MIPMAP_NEAREST);const r=this._descriptor.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(i.target),this._descriptor.context.bindTexture(r,e.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,x(e)}e.samplingMode===l.LINEAR_MIPMAP_NEAREST?(this._samplingModeDirty=!0,e.samplingMode=l.LINEAR):e.samplingMode===l.NEAREST_MIPMAP_NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=l.NEAREST)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,x(this._descriptor),this._wrapModeDirty=!0)}setShadowFiltering(t){t!==this._descriptor.linearFilterDepth&&(this._descriptor.linearFilterDepth=t,this._descriptor.compareEnabled=t,this.setSamplingMode(t?l.LINEAR:l.NEAREST),x(this._descriptor),this._shadowFilterDirty=!0)}applyChanges(){this._samplingModeDirty&&(this._applySamplingMode(),this._samplingModeDirty=!1),this._wrapModeDirty&&(this._applyWrapMode(),this._wrapModeDirty=!1),this._shadowFilterDirty&&(this._applyShadowMode(),this._shadowFilterDirty=!1)}abortCompression(){this._compressionAbortController=i(this._compressionAbortController)}_setData(i,r){const s=this._descriptor,a=s.context?.gl;if(!a)return;o(a),this.hasWebGLTextureObject||(this._glName=a.createTexture(),s.context.instanceCounter.increment(n.Texture,this)),x(s);const p=s.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);s.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),o(a);const l=r??s.target,h=T(l);if(g(i))this._setDataFromTexImageSource(i,l);else{const{width:e,height:r,depth:n}=s;if(null==e||null==r)throw new t("texture:missing-size","Width and height must be specified!");if(h&&null==n)throw new t("texture:missing-depth","Depth must be specified!");if(s.internalFormat=u(s),s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(l,s.internalFormat,s.hasMipmap,e,r,n),_(i)){if(!E(s.internalFormat))throw new t("texture:format-mismatch","Attempting to use compressed data with an uncompressed format!");this._setDataFromCompressedSource(i,s.internalFormat,l)}else this._texImage(l,0,s.internalFormat,e,r,n,i),o(a),s.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),this._applyShadowMode(),o(a),s.context.bindTexture(p,e.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(t=null){for(let e=a.TEXTURE_CUBE_MAP_POSITIVE_X;e<=a.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_setDataFromTexImageSource(t,e){const{gl:i}=this._descriptor.context,r=this._descriptor;r.internalFormat=u(r);const s=T(e),{width:a,height:n,depth:p}=M(t);r.width&&r.height,r.width||(r.width=a),r.height||(r.height=n),s&&r.depth,s&&(r.depth=p),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(e,r.internalFormat,r.hasMipmap,a,n,p),this._texImage(e,0,r.internalFormat,a,n,p,t),o(i),r.hasMipmap&&(this.generateMipmap(),o(i))}_setDataFromCompressedSource(t,e,i){const r=this._descriptor,{width:s,height:o,depth:a}=r,n=t.levels,p=A(i,s,o,a),l=Math.min(p,n.length)-1;this._descriptor.context.gl.texParameteri(r.target,h.MAX_LEVEL,l),this._forEachMipmapLevel(((t,r,s,o)=>{const a=n[Math.min(t,n.length-1)];this._compressedTexImage(i,t,e,r,s,o,a)}),l)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!b(i)&&!f(i)&&!w(i))throw new t("texture:missing-format","Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const p=r?A(e,s,o,a):1;if(T(e)){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");n.texStorage3D(e,p,i,s,o,a)}else n.texStorage2D(e,p,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=T(e),{isImmutable:h,pixelFormat:m,dataType:d}=this._descriptor;if(h){if(null!=n){const r=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texSubImage3D(e,i,0,0,0,s,o,a,m,d,r)}else p.texSubImage2D(e,i,0,0,s,o,m,d,r)}}else{const h=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texImage3D(e,i,r,s,o,a,0,m,d,h)}else p.texImage2D(e,i,r,s,o,0,m,d,h)}}_compressedTexImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=T(e);if(this._descriptor.isImmutable){if(null!=n)if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else p.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexImage3D(e,i,r,s,o,a,0,n)}else p.compressedTexImage2D(e,i,r,s,o,0,n)}async _compressOnWorker(t){const{width:i,height:o,context:a,compressionHandle:n,compressionCallback:p,flipped:l,preMultiplyAlpha:h,hasMipmap:d}=this._descriptor,{compressedTextureETC:c,compressedTextureS3TC:_}=a.capabilities;if(!e.compressionWorkerHandle?.isCompressible(t,this._descriptor)||!c&&!_)return;this.abortCompression();const u=new AbortController;this._compressionAbortController=u,n.increment();try{let s;t instanceof Uint8Array?s=t.buffer:(s=await createImageBitmap(t,{imageOrientation:l?"flipY":"none"}),r(u));const a={data:s,width:i,height:o,needsFlip:t instanceof Uint8Array&&this.descriptor.flipped,components:this._descriptor.pixelFormat===m.RGBA?4:3,preMultiplyAlpha:h,hasMipmap:d,hasETC:!!c,hasS3TC:!!_},n=await e.compressionWorkerHandle.invoke(a,u.signal);if(r(u),n&&this.hasWebGLTextureObject){const t=this.usedMemory;this._descriptor.internalFormat=n.internalFormat,this._setData(n.compressedTexture),p?.(t-this.usedMemory)}}catch(g){s(g)||D().error("Texture compression failed!")}finally{n.decrement(),this._compressionAbortController?.signal.aborted&&(this._compressionAbortController=null)}}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:o,hasMipmap:n,target:p}=this._descriptor;const l=p===a.TEXTURE_3D;if(null==r||null==s||l&&null==o)throw new t("texture:missing-size","Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,o),n&&(1!==r||1!==s||l&&1!==o)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),l&&(o=Math.max(1,o>>1))}_applySamplingMode(){const t=this._descriptor,e=t.context?.gl;let i=t.samplingMode,r=t.samplingMode;i===l.LINEAR_MIPMAP_NEAREST||i===l.LINEAR_MIPMAP_LINEAR?(i=l.LINEAR,t.hasMipmap||(r=l.LINEAR)):i!==l.NEAREST_MIPMAP_NEAREST&&i!==l.NEAREST_MIPMAP_LINEAR||(i=l.NEAREST,t.hasMipmap||(r=l.NEAREST)),e.texParameteri(t.target,e.TEXTURE_MAG_FILTER,i),e.texParameteri(t.target,e.TEXTURE_MIN_FILTER,r)}_applyWrapMode(){const t=this._descriptor,e=t.context?.gl;"number"==typeof t.wrapMode?(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode)):(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode.s),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode.t))}_applyShadowMode(){const t=this._descriptor,e=t.context?.gl,i=t.compareEnabled?e.COMPARE_REF_TO_TEXTURE:e.NONE;e.texParameteri(t.target,e.TEXTURE_COMPARE_MODE,i),t.compareEnabled&&e.texParameteri(t.target,e.TEXTURE_COMPARE_FUNC,e.GREATER),o(e)}_applyAnisotropicFilteringParameters(){const t=this._descriptor,e=t.context.capabilities.textureFilterAnisotropic;if(!e)return;t.context.gl.texParameterf(t.target,e.TEXTURE_MAX_ANISOTROPY,t.maxAnisotropy??1)}};export{S as Texture,R as tracer};
5
+ import t from"../../core/Error.js";import"../../core/has.js";import e from"../../core/Logger.js";import{abortMaybe as i}from"../../core/maybe.js";import{throwIfAborted as r,isAbortError as s}from"../../core/promiseUtils.js";import{checkWebGLError as o}from"./checkWebGLError.js";import{TextureType as a,ResourceType as n,CompressedTextureFormat as p,TextureSamplingMode as l,TextureConstants as h,PixelFormat as m}from"./enums.js";import{FBOAttachmentType as d}from"./FBOAttachmentType.js";import{estimateMemory as c}from"./TextureDescriptor.js";import{isCompressedData as _,deriveInternalFormat as u,isTexImageSource as g,is3DTarget as T,validateTexture as x,isCompressedFormat as E,getDimensions as M,calcMipmapLevels as A,isSizedPixelFormat as b,isSizedDepthFormat as f,isSizedDepthStencilFormat as w}from"./textureUtils.js";import{ValidatedTextureDescriptor as I}from"./ValidatedTextureDescriptor.js";const R=null,D=()=>e.getLogger("esri/views/webgl/Texture");let S=class e{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(e,i=null,r=null){if(this.type=d.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._shadowFilterDirty=!1,this._wasImmutablyAllocated=!1,"context"in e)this._descriptor=e,r=i;else{const r=I.validate(e,i);if(!r)throw new t("texture:invalid-descriptor","Texture descriptor invalid");this._descriptor=r}this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return c(this._descriptor)}get cachedMemory(){return this.usedMemory}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty||this._shadowFilterDirty}get hasWebGLTextureObject(){return!!this._glName}dispose(){this.abortCompression(),this._descriptor.context.gl&&this.hasWebGLTextureObject&&(this._descriptor.context.instanceCounter.decrement(n.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("texture:immutable-resize","Immutable textures can't be resized!");r.width=e,r.height=i,this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}enableCompression(t,e){this._descriptor.compressionHandle=t,this._descriptor.compressionCallback=e}disableCompression(){this._descriptor.compressionHandle=null,this._descriptor.compressionCallback=null}setData(t){this.abortCompression(),!_(t)&&this._descriptor.internalFormat&&this._descriptor.internalFormat in p&&(this._descriptor.internalFormat=void 0),this._setData(t),!_(t)&&this._descriptor.compressionHandle&&this._compressOnWorker(t)}updateData(i,r,s,o,a,n,p=0){n||D().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||D().error("An attempt to update uninitialized texture!");const l=this._descriptor;l.internalFormat=u(l);const{context:h,pixelFormat:m,dataType:d,target:c,isImmutable:T}=l;if(T&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");const x=h.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES,!0);(r<0||s<0||r+o>l.width||s+a>l.height)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:E}=h;p&&(o&&a||D().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),E.pixelStorei(E.UNPACK_SKIP_ROWS,p)),g(n)?E.texSubImage2D(c,i,r,s,o,a,m,d,n):_(n)?E.compressedTexSubImage2D(c,i,r,s,o,a,l.internalFormat,n.levels[i]):E.texSubImage2D(c,i,r,s,o,a,m,d,n),p&&E.pixelStorei(E.UNPACK_SKIP_ROWS,0),h.bindTexture(x,e.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(i,r,s,o,a,n,p,l){l||D().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||D().error("An attempt to update an uninitialized texture!");const h=this._descriptor;h.internalFormat=u(h);const{context:m,pixelFormat:d,dataType:c,isImmutable:g,target:x}=h;if(g&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");T(x)||D().warn("Attempting to set 3D texture data on a non-3D texture");const E=m.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);m.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),(r<0||s<0||o<0||r+a>h.width||s+n>h.height||o+p>h.depth)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:M}=m;if(_(l))l=l.levels[i],M.compressedTexSubImage3D(x,i,r,s,o,a,n,p,h.internalFormat,l);else{const t=l;M.texSubImage3D(x,i,r,s,o,a,n,p,d,c,t)}m.bindTexture(E,e.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const i=this._descriptor;if(0===i.width||0===i.height)return;if(!i.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot add mipmaps to immutable texture after allocation");i.hasMipmap=!0,this._samplingModeDirty=!0,x(i)}i.samplingMode===l.LINEAR?(this._samplingModeDirty=!0,i.samplingMode=l.LINEAR_MIPMAP_NEAREST):i.samplingMode===l.NEAREST&&(this._samplingModeDirty=!0,i.samplingMode=l.NEAREST_MIPMAP_NEAREST);const r=this._descriptor.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(i.target),this._descriptor.context.bindTexture(r,e.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,x(e)}e.samplingMode===l.LINEAR_MIPMAP_NEAREST?(this._samplingModeDirty=!0,e.samplingMode=l.LINEAR):e.samplingMode===l.NEAREST_MIPMAP_NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=l.NEAREST)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,x(this._descriptor),this._wrapModeDirty=!0)}setShadowFiltering(t){t!==this._descriptor.linearFilterDepth&&(this._descriptor.linearFilterDepth=t,this._descriptor.compareEnabled=t,this.setSamplingMode(t?l.LINEAR:l.NEAREST),x(this._descriptor),this._shadowFilterDirty=!0)}applyChanges(){this._samplingModeDirty&&(this._applySamplingMode(),this._samplingModeDirty=!1),this._wrapModeDirty&&(this._applyWrapMode(),this._wrapModeDirty=!1),this._shadowFilterDirty&&(this._applyShadowMode(),this._shadowFilterDirty=!1)}abortCompression(){this._compressionAbortController=i(this._compressionAbortController)}_setData(i,r){const s=this._descriptor,a=s.context?.gl;if(!a)return;o(a),this.hasWebGLTextureObject||(this._glName=a.createTexture(),s.context.instanceCounter.increment(n.Texture,this)),x(s);const p=s.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);s.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),o(a);const l=r??s.target,h=T(l);if(g(i))this._setDataFromTexImageSource(i,l);else{const{width:e,height:r,depth:n}=s;if(null==e||null==r)throw new t("texture:missing-size","Width and height must be specified!");if(h&&null==n)throw new t("texture:missing-depth","Depth must be specified!");if(s.internalFormat=u(s),s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(l,s.internalFormat,s.hasMipmap,e,r,n),_(i)){if(!E(s.internalFormat))throw new t("texture:format-mismatch","Attempting to use compressed data with an uncompressed format!");this._setDataFromCompressedSource(i,s.internalFormat,l)}else this._texImage(l,0,s.internalFormat,e,r,n,i),o(a),s.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),this._applyShadowMode(),o(a),s.context.bindTexture(p,e.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(t=null){for(let e=a.TEXTURE_CUBE_MAP_POSITIVE_X;e<=a.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_setDataFromTexImageSource(t,e){const{gl:i}=this._descriptor.context,r=this._descriptor;r.internalFormat=u(r);const s=T(e),{width:a,height:n,depth:p}=M(t);r.width&&r.height,r.width||(r.width=a),r.height||(r.height=n),s&&r.depth,s&&(r.depth=p),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(e,r.internalFormat,r.hasMipmap,a,n,p),this._texImage(e,0,r.internalFormat,a,n,p,t),o(i),r.hasMipmap&&(this.generateMipmap(),o(i))}_setDataFromCompressedSource(t,e,i){const r=this._descriptor,{width:s,height:o,depth:a}=r,n=t.levels,p=A(i,s,o,a),l=Math.min(p,n.length)-1;this._descriptor.context.gl.texParameteri(r.target,h.MAX_LEVEL,l),this._forEachMipmapLevel(((t,r,s,o)=>{const a=n[Math.min(t,n.length-1)];this._compressedTexImage(i,t,e,r,s,o,a)}),l)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!b(i)&&!f(i)&&!w(i))throw new t("texture:missing-format","Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const p=r?A(e,s,o,a):1;if(T(e)){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");n.texStorage3D(e,p,i,s,o,a)}else n.texStorage2D(e,p,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=T(e),{isImmutable:h,pixelFormat:m,dataType:d}=this._descriptor;if(h){if(null!=n){const r=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texSubImage3D(e,i,0,0,0,s,o,a,m,d,r)}else p.texSubImage2D(e,i,0,0,s,o,m,d,r)}}else{const h=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texImage3D(e,i,r,s,o,a,0,m,d,h)}else p.texImage2D(e,i,r,s,o,0,m,d,h)}}_compressedTexImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=T(e);if(this._descriptor.isImmutable){if(null!=n)if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else p.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexImage3D(e,i,r,s,o,a,0,n)}else p.compressedTexImage2D(e,i,r,s,o,0,n)}async _compressOnWorker(t){const{width:i,height:o,context:a,compressionHandle:n,compressionCallback:p,flipped:l,preMultiplyAlpha:h,hasMipmap:d}=this._descriptor,{compressedTextureETC:c,compressedTextureS3TC:_}=a.capabilities;if(!e.compressionWorkerHandle?.isCompressible(t,this._descriptor)||!c&&!_)return;this.abortCompression();const u=new AbortController;this._compressionAbortController=u,n.increment();try{let s;t instanceof Uint8Array?s=t.buffer:(s=await createImageBitmap(t,{imageOrientation:l?"flipY":"none"}),r(u));const a={data:s,width:i,height:o,needsFlip:t instanceof Uint8Array&&this.descriptor.flipped,components:this._descriptor.pixelFormat===m.RGBA?4:3,preMultiplyAlpha:h,hasMipmap:d,hasETC:!!c,hasS3TC:!!_},n=await e.compressionWorkerHandle.invoke(a,u.signal);if(r(u),n.compressedTexture&&this.hasWebGLTextureObject){const t=this.usedMemory;this._descriptor.internalFormat=n.internalFormat,this._setData(n.compressedTexture),p?.(t-this.usedMemory)}}catch(g){s(g)||D().error("Texture compression failed!")}finally{n.decrement(),this._compressionAbortController?.signal.aborted&&(this._compressionAbortController=null)}}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:o,hasMipmap:n,target:p}=this._descriptor;const l=p===a.TEXTURE_3D;if(null==r||null==s||l&&null==o)throw new t("texture:missing-size","Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,o),n&&(1!==r||1!==s||l&&1!==o)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),l&&(o=Math.max(1,o>>1))}_applySamplingMode(){const t=this._descriptor,e=t.context?.gl;let i=t.samplingMode,r=t.samplingMode;i===l.LINEAR_MIPMAP_NEAREST||i===l.LINEAR_MIPMAP_LINEAR?(i=l.LINEAR,t.hasMipmap||(r=l.LINEAR)):i!==l.NEAREST_MIPMAP_NEAREST&&i!==l.NEAREST_MIPMAP_LINEAR||(i=l.NEAREST,t.hasMipmap||(r=l.NEAREST)),e.texParameteri(t.target,e.TEXTURE_MAG_FILTER,i),e.texParameteri(t.target,e.TEXTURE_MIN_FILTER,r)}_applyWrapMode(){const t=this._descriptor,e=t.context?.gl;"number"==typeof t.wrapMode?(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode)):(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode.s),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode.t))}_applyShadowMode(){const t=this._descriptor,e=t.context?.gl,i=t.compareEnabled?e.COMPARE_REF_TO_TEXTURE:e.NONE;e.texParameteri(t.target,e.TEXTURE_COMPARE_MODE,i),t.compareEnabled&&e.texParameteri(t.target,e.TEXTURE_COMPARE_FUNC,e.GREATER),o(e)}_applyAnisotropicFilteringParameters(){const t=this._descriptor,e=t.context.capabilities.textureFilterAnisotropic;if(!e)return;t.context.gl.texParameterf(t.target,e.TEXTURE_MAX_ANISOTROPY,t.maxAnisotropy??1)}};export{S as Texture,R as tracer};
@@ -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{ZEROS as t}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{SizedPixelFormat as e,PixelType as n,TextureSamplingMode as a,TextureWrapMode as i,PixelFormat as u}from"./enums.js";import{Texture as r}from"./Texture.js";import{TextureDescriptor as o}from"./TextureDescriptor.js";function s(t,s,m="nearest",l=!1){const f=!(l&&"u8"===s.pixelType),c=f?n.FLOAT:n.UNSIGNED_BYTE,p=null==s.pixels||0===s.pixels.length?null:f?s.getAsRGBAFloat():s.getAsRGBA(),_=t.capabilities.textureFloatLinear,g=new o;return g.width=s.width,g.height=s.height,g.internalFormat=f?e.RGBA32F:u.RGBA,g.samplingMode=!_||"bilinear"!==m&&"cubic"!==m?a.NEAREST:a.LINEAR,g.dataType=c,g.wrapMode=i.CLAMP_TO_EDGE,new r(t,g,p)}function m(t,u){const{spacing:s,offsets:m,coefficients:l,size:[f,c]}=u,p=s[0]>1,_=new o;_.width=p?4*f:f,_.height=c,_.internalFormat=e.RGBA32F,_.dataType=n.FLOAT,_.samplingMode=a.NEAREST,_.wrapMode=i.CLAMP_TO_EDGE;const g=new Float32Array(p?f*c*16:2*m.length);if(p&&null!=l)for(let e=0,n=0;e<l.length;e++)g[n++]=l[e],e%3==2&&(g[n++]=1);else for(let e=0;e<c;e++)for(let t=0;t<f;t++){const n=4*(e*f+t),a=2*(t*c+e);g[n]=m[a],g[n+1]=m[a+1],g[n+3]=-1===m[a]?0:1}return new r(t,_,g)}function l(t,e){const n=new o;return n.internalFormat=u.RGBA,n.width=e.length/4,n.height=1,n.samplingMode=a.NEAREST,n.wrapMode=i.CLAMP_TO_EDGE,new r(t,n,e)}function f(e,n,a,i=1,u=!0){return{u_flipY:u,u_applyTransform:!!e,u_opacity:i,u_transformSpacing:e?e.spacing:t,u_transformGridSize:e?e.size:t,u_targetImageSize:n,u_srcImageSize:a}}function c(t,e){return{u_colormapOffset:e||0,u_colormapMaxIndex:t?t.length/4-1:0}}function p(t){return{u_bandCount:t.bandCount,u_minOutput:t.minOutput,u_maxOutput:t.maxOutput,u_minCutOff:t.minCutOff,u_maxCutOff:t.maxCutOff,u_factor:t.factor,u_useGamma:t.useGamma,u_gamma:t.gamma,u_gammaCorrection:t.gammaCorrection}}function _(t){return{u_hillshadeType:t.hillshadeType,u_sinZcosAs:t.sinZcosAs,u_sinZsinAs:t.sinZsinAs,u_cosZs:t.cosZs,u_weights:t.weights,u_factor:t.factor,u_minValue:t.minValue,u_maxValue:t.maxValue}}export{l as createColormapTexture,s as createRasterTexture,m as createTransformTexture,c as getColormapUniforms,f as getCommonUniforms,_ as getShadedReliefUniforms,p as getStretchUniforms};
5
+ import{ZEROS as t}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{SizedPixelFormat as e,PixelType as n,TextureSamplingMode as a,TextureWrapMode as i,PixelFormat as r}from"./enums.js";import{Texture as u}from"./Texture.js";import{TextureDescriptor as o}from"./TextureDescriptor.js";function s(t,s,m="nearest",l=!1){const c=!(l&&"u8"===s.pixelType),f=c?n.FLOAT:n.UNSIGNED_BYTE,p=null==s.pixels||0===s.pixels.length?null:c?s.getAsRGBAFloat():s.getAsRGBA(),_=t.capabilities.textureFloatLinear,g=new o;return g.width=s.width,g.height=s.height,g.internalFormat=c?e.RGBA32F:r.RGBA,g.samplingMode=!_||"bilinear"!==m&&"cubic"!==m?a.NEAREST:a.LINEAR,g.dataType=f,g.wrapMode=i.CLAMP_TO_EDGE,new u(t,g,p)}function m(t,r){const{spacing:s,offsets:m,coefficients:l,size:[c,f]}=r,p=s[0]>1,_=new o;_.width=p?4*c:c,_.height=f,_.internalFormat=e.RGBA32F,_.dataType=n.FLOAT,_.samplingMode=a.NEAREST,_.wrapMode=i.CLAMP_TO_EDGE;const g=new Float32Array(p?c*f*16:2*m.length);if(p&&null!=l)for(let e=0,n=0;e<l.length;e++)g[n++]=l[e],e%3==2&&(g[n++]=1);else for(let e=0;e<f;e++)for(let t=0;t<c;t++){const n=4*(e*c+t),a=2*(t*f+e);g[n]=m[a],g[n+1]=m[a+1],g[n+3]=-1===m[a]?0:1}return new u(t,_,g)}function l(t,e){const n=new o;return n.internalFormat=r.RGBA,n.width=e.length/4,n.height=1,n.samplingMode=a.NEAREST,n.wrapMode=i.CLAMP_TO_EDGE,new u(t,n,e)}function c(t,e,s){const m=new o;return m.internalFormat=r.ALPHA,m.pixelFormat=r.ALPHA,m.dataType=n.UNSIGNED_BYTE,m.width=s[0],m.height=s[1],m.samplingMode=a.NEAREST,m.wrapMode=i.CLAMP_TO_EDGE,new u(t,m,e)}function f(e,n,a,i=1,r=!0){return{u_flipY:r,u_applyTransform:!!e,u_opacity:i,u_transformSpacing:e?e.spacing:t,u_transformGridSize:e?e.size:t,u_targetImageSize:n,u_srcImageSize:a}}function p(t,e){return{u_colormapOffset:e||0,u_colormapMaxIndex:t?t.length/4-1:0}}function _(t){return{u_bandCount:t.bandCount,u_minOutput:t.minOutput,u_maxOutput:t.maxOutput,u_minCutOff:t.minCutOff,u_maxCutOff:t.maxCutOff,u_factor:t.factor,u_useGamma:t.useGamma,u_gamma:t.gamma,u_gammaCorrection:t.gammaCorrection}}function g(t){return{u_hillshadeType:t.hillshadeType,u_sinZcosAs:t.sinZcosAs,u_sinZsinAs:t.sinZsinAs,u_cosZs:t.cosZs,u_weights:t.weights,u_factor:t.factor,u_minValue:t.minValue,u_maxValue:t.maxValue}}export{l as createColormapTexture,c as createPixelMaskTexture,s as createRasterTexture,m as createTransformTexture,p as getColormapUniforms,f as getCommonUniforms,g as getShadedReliefUniforms,_ as getStretchUniforms};
package/webscene/Slide.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Basemap.js";import i from"../Viewpoint.js";import{result as n}from"../core/asyncUtils.js";import r from"../core/Clonable.js";import s from"../core/Collection.js";import{referenceSetter as o}from"../core/collectionUtils.js";import a from"../core/JSONSupport.js";import l from"../core/Logger.js";import{moduloPositive as p}from"../core/mathUtils.js";import{destroyMaybe as m,removeMaybe as c}from"../core/maybe.js";import{onAbortOrThrow as h,createAbortError as d,isAbortError as u}from"../core/promiseUtils.js";import{whenOnce as y,when as g}from"../core/reactiveUtils.js";import{property as b}from"../core/accessorSupport/decorators/property.js";import{cast as v}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as w}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as f}from"../core/accessorSupport/ensureType.js";import{s as T}from"../chunks/vec32.js";import{create as j}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import L from"../layers/Layer.js";import{basemapEnsureType as C,clonePreservingTiledLayers as _}from"../support/basemapEnsureType.js";import{TaskPriority as E}from"../views/support/Scheduler.js";import{SlideThumbnail as S}from"../webdoc/support/SlideThumbnail.js";import{timeExtent as A}from"../webdoc/support/timeProperties.js";import k from"./SunLighting.js";import V from"./VirtualLighting.js";import U from"./support/Description.js";import x from"./support/SlideElements.js";import{SlideEnvironment as F}from"./support/SlideEnvironment.js";import I from"./support/SlideGround.js";import{SlideVisibleLayer as D}from"./support/SlideVisibleLayer.js";import R from"./support/Title.js";let M=0;const O=s.ofType(D),P=["caption","cover","none"];let q=class extends(r.ClonableMixin(a)){constructor(e){super(e),this.id=Date.now().toString(16)+"-slide-"+M++,this.title=new R,this.description=new U,this.hidden=!1,this.thumbnail=new S,this.viewpoint=null,this.basemap=null,this.ground=null,this.layout="caption",this.environment=new F,this.timeExtent=null,this.elements=new x,this.visibleLayers=new O,this.enabledFocusAreas=new s}destroy(){this.visibleLayers.removeAll(),this.enabledFocusAreas?.removeAll(),this.basemap=null,this.thumbnail=m(this.thumbnail),this.description=null,this.title=null,this.thumbnail=null,this.elements=null}castTitle(e){return"string"==typeof e?new R({text:e}):f(R,e)}castDescription(e){return"string"==typeof e?new U({text:e}):f(U,e)}castThumbnail(e){return"string"==typeof e?new S({url:e}):f(S,e)}castBasemap(e){return C(e)}set visibleLayers(e){this._set("visibleLayers",o(e,this._get("visibleLayers"),O))}castVisibleLayers(e){return e&&"function"==typeof e.map?e.map((e=>{if("string"==typeof e)return{id:e};if(e instanceof L){const t=N(e);return{id:e.id,sublayerIds:t}}return e.id?{id:e.id,sublayerIds:"sublayerIds"in e?e.sublayerIds:void 0}:(l.getLogger(this).warn('Invalid visible layer, expected { id }, Layer or "id"'),e)})):null}async _updateVisibleLayers(e){const t=[];await Promise.allSettled(this._getLayers(e.map).map((i=>e.whenLayerView(i).then((e=>{if(e.visible){const n=N(i);t.push(new D({id:e.layer.id,sublayerIds:n}))}})))).toArray()),this.visibleLayers.removeAll(),this.visibleLayers.addMany(t)}async updateFrom(e,t){const i={format:"png",quality:80,width:120,height:75,disableDecorations:!0,...t?.screenshot};await e.when(),this.viewpoint=e.viewpoint.clone(),this.environment.lighting="virtual"===e.environment.lighting.type?V.prototype.clone.apply(e.environment.lighting):k.prototype.clone.apply(e.environment.lighting),this.environment.weather=e.environment.weather.clone(),this.enabledFocusAreas=e.focusAreasView?.enabledAreas?new s(e.focusAreasView?.enabledAreas.map((({id:e})=>e))):null,this.basemap=e.map.basemap?.clone()||null,this.ground=e.map.ground?I.fromGround(e.map.ground):null,this.timeExtent=e.timeExtent?.clone()??null,this.elements.analyses.updateFrom(e),await this._updateVisibleLayers(e);const n=await e.takeScreenshot(i);return this.thumbnail=new S({url:n.dataUrl}),this}async applyTo(e,t){null!=this._applyToController&&this._applyToController.abort();let i=new AbortController;this._applyToController=i;const r=h(t,(()=>i?.abort())),s=()=>{this._applyToController===i&&(this._applyToController=null),i=null,r?.remove()};try{await y((()=>e.ready),i.signal)}catch(c){throw s(),c}if(i.signal.aborted)throw s(),d();const o=e.resourceController.scheduler.registerTask(E.SLIDE);let a=!1;const l={animate:!0,...t,signal:this._applyToController.signal},p=async()=>{await Promise.all([o.schedule((async()=>a=await this._setViewpointOfInterest(e,l))),o.schedule((()=>this._applyBasemap(e,l)),l.signal),o.schedule((()=>this._loadLayersWithSublayerVisibility(e)))]),await Promise.all([o.schedule((()=>this._applyLayerVisibility(e)),l.signal),o.schedule((()=>this._applyFocusAreaEnabled(e.map?.focusAreas.areas))),o.schedule((()=>this._applyGround(e)),l.signal),o.schedule((()=>this.elements.analyses.applyTo(e)),l.signal),o.schedule((()=>this._applyViewpoint(e,l)),l.signal),o.schedule((()=>e.timeExtent=this.timeExtent?.clone()??null),l.signal),o.schedule((()=>e.environment.weather=this.environment.weather.clone()))])},m=await n(e.addUpdatingPromise(p()));if(a&&(e.contentCamera=null),o.remove(),s(),!1===m.ok)throw m.error;return this}async _applyBasemap(e,t){if(this.basemap){try{await this.basemap.load(t)}catch(i){if(u(i))throw i}e.map.basemap=_(this.basemap,e.map.basemap)}}_applyGround(e){this.ground&&(e.map.ground=this.ground.cloneAndApplyTo(e.map.ground))}_applyFocusAreaEnabled(e){if(e&&this.enabledFocusAreas)for(const t of e)t.enabled=this.enabledFocusAreas.includes(t.id)}_getLayers(e){const t=new s;return this._collectLayers(e,t),this._collectLayers(e.ground,t),t}_collectLayers(e,t){e.layers.forEach((e=>{e.persistenceEnabled&&(t.add(e),"layers"in e&&this._collectLayers(e,t))}))}async _loadLayersWithSublayerVisibility(e){this.visibleLayers&&await Promise.allSettled(this._getLayers(e.map).items.map((e=>{const t=this.visibleLayers.find((t=>t.id===e.id))?.sublayerIds;return t?e.load():null})))}_applyLayerVisibility(e){if(!this.visibleLayers)return;this._getLayers(e.map).forEach((e=>{const t=this.visibleLayers.find((t=>t.id===e.id));e.visible=null!=t;const i=t?.sublayerIds,n=G(e);i&&n&&n.forEach((e=>e.visible=i.includes(e.id)))}))}async _setViewpointOfInterest(e,t){if(e.state.fixedContentCamera||!this.viewpoint||t?.ignoreViewpoint||!t?.useDestinationCamera)return!1;const{toCameraAsync:i}=await import("../views/3d/support/viewpointUtils.js"),n=await i(e,this.viewpoint);return e.contentCamera=n,null!=n}async _applyViewpoint(e,t){if(this._applyCachedCameraTrackingEnabled(e),this.viewpoint&&!t.ignoreViewpoint){const i=this.environment.lighting;if(t.animate&&"sun"===i.type&&i.date)return this._animateToLighting(e,t);t.animate&&(e.environment.applyLighting(i.clone()),await e.goTo(this.viewpoint,t)),e.viewpoint=this.viewpoint}e.environment.applyLighting(this.environment.lighting.clone())}async _animateToLighting(e,t){let i=null;"virtual"!==e.environment.lighting.type&&"virtual"!==this.environment.lighting.type&&("global"===e.viewingMode&&(i=this._animateLightingWithCamera(e,e.environment.lighting,this.environment.lighting)),e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1),e.environment.lighting.directShadowsEnabled=this.environment.lighting.directShadowsEnabled,"virtual"===this.environment.lighting.type||"virtual"===e.environment.lighting.type?(e.environment.applyLighting(this.environment.lighting.clone()),"virtual"!==e.environment.lighting.type&&(e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1)):null!=this.environment.lighting.displayUTCOffset&&(e.environment.lighting.displayUTCOffset=this.environment.lighting.displayUTCOffset);return e.goTo(this.viewpoint,t).then((()=>{this._applyCachedCameraTrackingEnabled(e),e.environment.applyLighting(this.environment.lighting.clone())})).catch((t=>{throw null==e.animation&&this._applyCachedCameraTrackingEnabled(e),t})).finally((()=>{c(i)}))}_applyCachedCameraTrackingEnabled(e){null!=e.environment.cachedCameraTrackingEnabled&&(e.environment.lighting.cameraTrackingEnabled=e.environment.cachedCameraTrackingEnabled,e.environment.cachedCameraTrackingEnabled=null)}_getTime(e){return[e.getTime(),3600*e.getUTCHours()+60*e.getUTCMinutes()+e.getUTCSeconds()]}_setTime(e,t,i){return e.setTime(t),e.setUTCHours(i/3600),e.setUTCMinutes(i%3600/60),e.setUTCSeconds(i%3600%60),e}_animateLightingWithCamera(e,t,i){const n=new Date(t.date.toString()),[r,s]=this._getTime(n),[o,a]=this._getTime(i.date),l=J(s,a),p=e.renderCoordsHelper,m=j();p.toRenderCoords(e.camera.position,m);const c=j(),h=j();null!=this.viewpoint.camera&&p.toRenderCoords(this.viewpoint.camera.position,c);const d=new Date;return g((()=>e.camera),(e=>{p.toRenderCoords(e.position,h);const i=T(m,h),n=T(c,h);let a=0;i+n!==0&&(a=i/(i+n));const u=r+(o-r)*a,y=z(s,l*a);t.date=this._setTime(d,u,y)}))}write(e,t){const i=super.write(e,t);return i?.elements&&0===Object.keys(i.elements).length&&delete i.elements,i}static createFrom(e,t){return(new this).updateFrom(e,t)}};e([b({type:String,json:{write:{isRequired:!0}}})],q.prototype,"id",void 0),e([b({type:R,json:{default:()=>new R({text:""}),write:{isRequired:!0}}})],q.prototype,"title",void 0),e([v("title")],q.prototype,"castTitle",null),e([b({type:U,json:{write:{overridePolicy:e=>({enabled:!(!e||!e.text)})}}})],q.prototype,"description",void 0),e([v("description")],q.prototype,"castDescription",null),e([b({type:Boolean,nonNullable:!0,json:{write:!0,default:!1}})],q.prototype,"hidden",void 0),e([b({type:S,json:{default:()=>new S({url:""}),write:{isRequired:!0}}})],q.prototype,"thumbnail",void 0),e([v("thumbnail")],q.prototype,"castThumbnail",null),e([b({type:i,nonNullable:!0,json:{write:{isRequired:!0}}})],q.prototype,"viewpoint",void 0),e([b({type:t,json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],q.prototype,"basemap",void 0),e([v("basemap")],q.prototype,"castBasemap",null),e([b({type:I,json:{write:!0}})],q.prototype,"ground",void 0),e([b({type:P,json:{write:!0,default:"caption"},nonNullable:!0})],q.prototype,"layout",void 0),e([b({type:O,json:{write:{isRequired:!0}}})],q.prototype,"visibleLayers",null),e([v("visibleLayers")],q.prototype,"castVisibleLayers",null),e([b({type:F,json:{write:!0}})],q.prototype,"environment",void 0),e([b({type:s,json:{write:!1}})],q.prototype,"enabledFocusAreas",void 0),e([b(A)],q.prototype,"timeExtent",void 0),e([b({type:x,nonNullable:!0,json:{write:!0}})],q.prototype,"elements",void 0),q=e([w("esri.webscene.Slide")],q);const B=q;function G(e){if("building-scene"===e.type||"map-image"===e.type)return e.allSublayers.toArray()}function N(e){const t=G(e);if(t)return t.filter((e=>e.visible)).map((e=>e.id))}const W=86400,H=43200;function J(e,t){let i=t-e;return i>H&&(i-=W),i<-43200&&(i+=W),i}function z(e,t){return p(e+t,W)}export{B as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Basemap.js";import i from"../Viewpoint.js";import{result as n}from"../core/asyncUtils.js";import r from"../core/Clonable.js";import s from"../core/Collection.js";import{referenceSetter as o}from"../core/collectionUtils.js";import a from"../core/JSONSupport.js";import l from"../core/Logger.js";import{moduloPositive as p}from"../core/mathUtils.js";import{destroyMaybe as m,removeMaybe as c}from"../core/maybe.js";import{onAbortOrThrow as h,createAbortError as d,isAbortError as u}from"../core/promiseUtils.js";import{whenOnce as y,when as g}from"../core/reactiveUtils.js";import{Milliseconds as b,Seconds as v}from"../core/time.js";import{property as w}from"../core/accessorSupport/decorators/property.js";import{cast as f}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as T}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as j}from"../core/accessorSupport/ensureType.js";import{s as L}from"../chunks/vec32.js";import{create as C}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import _ from"../layers/Layer.js";import{basemapEnsureType as E,clonePreservingTiledLayers as S}from"../support/basemapEnsureType.js";import{TaskPriority as A}from"../views/support/Scheduler.js";import{SlideThumbnail as k}from"../webdoc/support/SlideThumbnail.js";import{timeExtent as V}from"../webdoc/support/timeProperties.js";import U from"./SunLighting.js";import x from"./VirtualLighting.js";import F from"./support/Description.js";import I from"./support/SlideElements.js";import{SlideEnvironment as D}from"./support/SlideEnvironment.js";import R from"./support/SlideGround.js";import{SlideVisibleLayer as M}from"./support/SlideVisibleLayer.js";import O from"./support/Title.js";let P=0;const q=s.ofType(M),B=["caption","cover","none"];let G=class extends(r.ClonableMixin(a)){constructor(e){super(e),this.id=Date.now().toString(16)+"-slide-"+P++,this.title=new O,this.description=new F,this.hidden=!1,this.thumbnail=new k,this.viewpoint=null,this.basemap=null,this.ground=null,this.layout="caption",this.environment=new D,this.timeExtent=null,this.elements=new I,this.visibleLayers=new q,this.enabledFocusAreas=new s}destroy(){this.visibleLayers.removeAll(),this.enabledFocusAreas?.removeAll(),this.basemap=null,this.thumbnail=m(this.thumbnail),this.description=null,this.title=null,this.thumbnail=null,this.elements=null}castTitle(e){return"string"==typeof e?new O({text:e}):j(O,e)}castDescription(e){return"string"==typeof e?new F({text:e}):j(F,e)}castThumbnail(e){return"string"==typeof e?new k({url:e}):j(k,e)}castBasemap(e){return E(e)}set visibleLayers(e){this._set("visibleLayers",o(e,this._get("visibleLayers"),q))}castVisibleLayers(e){return e&&"function"==typeof e.map?e.map((e=>{if("string"==typeof e)return{id:e};if(e instanceof _){const t=H(e);return{id:e.id,sublayerIds:t}}return e.id?{id:e.id,sublayerIds:"sublayerIds"in e?e.sublayerIds:void 0}:(l.getLogger(this).warn('Invalid visible layer, expected { id }, Layer or "id"'),e)})):null}async _updateVisibleLayers(e){const t=[];await Promise.allSettled(this._getLayers(e.map).map((i=>e.whenLayerView(i).then((e=>{if(e.visible){const n=H(i);t.push(new M({id:e.layer.id,sublayerIds:n}))}})))).toArray()),this.visibleLayers.removeAll(),this.visibleLayers.addMany(t)}async updateFrom(e,t){const i={format:"png",quality:80,width:120,height:75,disableDecorations:!0,...t?.screenshot};await e.when(),this.viewpoint=e.viewpoint.clone(),this.environment.lighting="virtual"===e.environment.lighting.type?x.prototype.clone.apply(e.environment.lighting):U.prototype.clone.apply(e.environment.lighting),this.environment.weather=e.environment.weather.clone(),this.enabledFocusAreas=e.focusAreasView?.enabledAreas?new s(e.focusAreasView?.enabledAreas.map((({id:e})=>e))):null,this.basemap=e.map.basemap?.clone()||null,this.ground=e.map.ground?R.fromGround(e.map.ground):null,this.timeExtent=e.timeExtent?.clone()??null,this.elements.analyses.updateFrom(e),await this._updateVisibleLayers(e);const n=await e.takeScreenshot(i);return this.thumbnail=new k({url:n.dataUrl}),this}async applyTo(e,t){null!=this._applyToController&&this._applyToController.abort();let i=new AbortController;this._applyToController=i;const r=h(t,(()=>i?.abort())),s=()=>{this._applyToController===i&&(this._applyToController=null),i=null,r?.remove()};try{await y((()=>e.ready),i.signal)}catch(c){throw s(),c}if(i.signal.aborted)throw s(),d();const o=e.resourceController.scheduler.registerTask(A.SLIDE);let a=!1;const l={animate:!0,...t,signal:this._applyToController.signal},p=async()=>{await Promise.all([o.schedule((async()=>a=await this._setViewpointOfInterest(e,l))),o.schedule((()=>this._applyBasemap(e,l)),l.signal),o.schedule((()=>this._loadLayersWithSublayerVisibility(e)))]),await Promise.all([o.schedule((()=>this._applyLayerVisibility(e)),l.signal),o.schedule((()=>this._applyFocusAreaEnabled(e.map?.focusAreas.areas))),o.schedule((()=>this._applyGround(e)),l.signal),o.schedule((()=>this.elements.analyses.applyTo(e)),l.signal),o.schedule((()=>this._applyViewpoint(e,l)),l.signal),o.schedule((()=>e.timeExtent=this.timeExtent?.clone()??null),l.signal),o.schedule((()=>e.environment.weather=this.environment.weather.clone()))])},m=await n(e.addUpdatingPromise(p()));if(a&&(e.contentCamera=null),o.remove(),s(),!1===m.ok)throw m.error;return this}async _applyBasemap(e,t){if(this.basemap){try{await this.basemap.load(t)}catch(i){if(u(i))throw i}e.map.basemap=S(this.basemap,e.map.basemap)}}_applyGround(e){this.ground&&(e.map.ground=this.ground.cloneAndApplyTo(e.map.ground))}_applyFocusAreaEnabled(e){if(e&&this.enabledFocusAreas)for(const t of e)t.enabled=this.enabledFocusAreas.includes(t.id)}_getLayers(e){const t=new s;return this._collectLayers(e,t),this._collectLayers(e.ground,t),t}_collectLayers(e,t){e.layers.forEach((e=>{e.persistenceEnabled&&(t.add(e),"layers"in e&&this._collectLayers(e,t))}))}async _loadLayersWithSublayerVisibility(e){this.visibleLayers&&await Promise.allSettled(this._getLayers(e.map).items.map((e=>{const t=this.visibleLayers.find((t=>t.id===e.id))?.sublayerIds;return t?e.load():null})))}_applyLayerVisibility(e){if(!this.visibleLayers)return;this._getLayers(e.map).forEach((e=>{const t=this.visibleLayers.find((t=>t.id===e.id));e.visible=null!=t;const i=t?.sublayerIds,n=W(e);i&&n&&n.forEach((e=>e.visible=i.includes(e.id)))}))}async _setViewpointOfInterest(e,t){if(e.state.fixedContentCamera||!this.viewpoint||t?.ignoreViewpoint||!t?.useDestinationCamera)return!1;const{toCameraAsync:i}=await import("../views/3d/support/viewpointUtils.js"),n=await i(e,this.viewpoint);return e.contentCamera=n,null!=n}async _applyViewpoint(e,t){if(this._applyCachedCameraTrackingEnabled(e),this.viewpoint&&!t.ignoreViewpoint){const i=this.environment.lighting;if(t.animate&&"sun"===i.type&&i.date)return this._animateToLighting(e,t);t.animate&&(e.environment.applyLighting(i.clone()),await e.goTo(this.viewpoint,t)),e.viewpoint=this.viewpoint}e.environment.applyLighting(this.environment.lighting.clone())}async _animateToLighting(e,t){let i=null;"virtual"!==e.environment.lighting.type&&"virtual"!==this.environment.lighting.type&&("global"===e.viewingMode&&(i=this._animateLightingWithCamera(e,e.environment.lighting,this.environment.lighting)),e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1),e.environment.lighting.directShadowsEnabled=this.environment.lighting.directShadowsEnabled,"virtual"===this.environment.lighting.type||"virtual"===e.environment.lighting.type?(e.environment.applyLighting(this.environment.lighting.clone()),"virtual"!==e.environment.lighting.type&&(e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1)):null!=this.environment.lighting.displayUTCOffset&&(e.environment.lighting.displayUTCOffset=this.environment.lighting.displayUTCOffset);return e.goTo(this.viewpoint,t).then((()=>{this._applyCachedCameraTrackingEnabled(e),e.environment.applyLighting(this.environment.lighting.clone())})).catch((t=>{throw null==e.animation&&this._applyCachedCameraTrackingEnabled(e),t})).finally((()=>{c(i)}))}_applyCachedCameraTrackingEnabled(e){null!=e.environment.cachedCameraTrackingEnabled&&(e.environment.lighting.cameraTrackingEnabled=e.environment.cachedCameraTrackingEnabled,e.environment.cachedCameraTrackingEnabled=null)}_getTime(e){return[b(e.getTime()),v(3600*e.getUTCHours()+60*e.getUTCMinutes()+e.getUTCSeconds())]}_setTime(e,t,i){return e.setTime(t),e.setUTCHours(i/3600),e.setUTCMinutes(i%3600/60),e.setUTCSeconds(i%3600%60),e}_animateLightingWithCamera(e,t,i){const n=new Date(t.date.toString()),[r,s]=this._getTime(n),[o,a]=this._getTime(i.date),l=K(s,a),p=e.renderCoordsHelper,m=C();p.toRenderCoords(e.camera.position,m);const c=C(),h=C();null!=this.viewpoint.camera&&p.toRenderCoords(this.viewpoint.camera.position,c);const d=new Date;return g((()=>e.camera),(e=>{p.toRenderCoords(e.position,h);const i=L(m,h),n=L(c,h);let a=0;i+n!==0&&(a=i/(i+n));const u=r+(o-r)*a,y=Q(s,v(l*a));t.date=this._setTime(d,u,y)}))}write(e,t){const i=super.write(e,t);return i?.elements&&0===Object.keys(i.elements).length&&delete i.elements,i}static createFrom(e,t){return(new this).updateFrom(e,t)}};e([w({type:String,json:{write:{isRequired:!0}}})],G.prototype,"id",void 0),e([w({type:O,json:{default:()=>new O({text:""}),write:{isRequired:!0}}})],G.prototype,"title",void 0),e([f("title")],G.prototype,"castTitle",null),e([w({type:F,json:{write:{overridePolicy:e=>({enabled:!(!e||!e.text)})}}})],G.prototype,"description",void 0),e([f("description")],G.prototype,"castDescription",null),e([w({type:Boolean,nonNullable:!0,json:{write:!0,default:!1}})],G.prototype,"hidden",void 0),e([w({type:k,json:{default:()=>new k({url:""}),write:{isRequired:!0}}})],G.prototype,"thumbnail",void 0),e([f("thumbnail")],G.prototype,"castThumbnail",null),e([w({type:i,nonNullable:!0,json:{write:{isRequired:!0}}})],G.prototype,"viewpoint",void 0),e([w({type:t,json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],G.prototype,"basemap",void 0),e([f("basemap")],G.prototype,"castBasemap",null),e([w({type:R,json:{write:!0}})],G.prototype,"ground",void 0),e([w({type:B,json:{write:!0,default:"caption"},nonNullable:!0})],G.prototype,"layout",void 0),e([w({type:q,json:{write:{isRequired:!0}}})],G.prototype,"visibleLayers",null),e([f("visibleLayers")],G.prototype,"castVisibleLayers",null),e([w({type:D,json:{write:!0}})],G.prototype,"environment",void 0),e([w({type:s,json:{write:!1}})],G.prototype,"enabledFocusAreas",void 0),e([w(V)],G.prototype,"timeExtent",void 0),e([w({type:I,nonNullable:!0,json:{write:!0}})],G.prototype,"elements",void 0),G=e([T("esri.webscene.Slide")],G);const N=G;function W(e){if("building-scene"===e.type||"map-image"===e.type)return e.allSublayers.toArray()}function H(e){const t=W(e);if(t)return t.filter((e=>e.visible)).map((e=>e.id))}const J=v(86400),z=v(43200);function K(e,t){let i=t-e;return i>z&&(i-=J),i<-z&&(i+=J),v(i)}function Q(e,t){return v(p(e+t,J))}export{N as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../chunks/tslib.es6.js";import{deprecateWidget as e}from"../core/deprecate.js";import i from"../core/Logger.js";import{watch as o}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import r from"./Widget.js";import{canShowNorth as a}from"./Compass/utils.js";import{directionalPadAngles as l,directionalPadArrows as d}from"./DirectionalPad/constants.js";import{css as c}from"./DirectionalPad/css.js";import p from"./DirectionalPad/DirectionalPadViewModel.js";import{findElementCenter as u}from"./DirectionalPad/utils.js";import h from"./DirectionalPad/VisibleElements.js";import{loadCalciteComponents as m}from"./support/componentsUtils.js";import{globalCss as v}from"./support/globalCss.js";import{isActivationKey as b,setFocus as _}from"./support/widgetUtils.js";import{messageBundle as g}from"./support/decorators/messageBundle.js";import{tsx as w}from"./support/jsxFactory.js";let f=class extends r{constructor(t,o){super(t,o),this._buttonsContainer=null,this._buttons={},this.messages=null,this.visibleElements=new h,this.viewModel=new p,this.visualScale="s",this._rotateIcon=t=>({"--rotation":`rotate(${t}deg)`}),this._afterButtonContainerCreate=t=>{this._buttonsContainer=t,this._buttonsContainer.addEventListener("contextmenu",this._onContextMenu,{capture:!0})},this._afterButtonContainerRemoved=()=>{this._buttonsContainer?.removeEventListener("contextmenu",this._onContextMenu,{capture:!0}),this._buttonsContainer=null},this._afterButtonCreate=(t,e)=>{this._buttons[t]=e},this._afterButtonRemoved=t=>{this._buttons[t]=void 0},this._onContextMenu=t=>t.preventDefault(),this._onButtonPointerDown=t=>{if(null===this._buttonsContainer)return;const e=t.target,i=e?.shadowRoot?.querySelector("button");i?.hasPointerCapture(t.pointerId)&&i.releasePointerCapture(t.pointerId);const o=u(this._buttonsContainer);this.viewModel.beginFollowingPointer(t,o)},this._onKeyDown=(t,{key:e})=>{b(e)&&this.viewModel.moveOnce(t)},this._onSliderInput=({currentTarget:t})=>{"number"==typeof t.value&&(this.viewModel.rotation=t.value)},this._onRotationReset=()=>{this.viewModel.rotation=0},e(i.getLogger(this),"Directional Pad","arcgis-directional-pad",{version:"4.32"})}loadDependencies(){return m({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),"action-pad":()=>import("@esri/calcite-components/dist/components/calcite-action-pad"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider")})}initialize(){this.addHandles(o((()=>this.viewModel.angle),(()=>{const t=this._buttonsContainer?.contains(document.activeElement);t&&(null==this.viewModel.angle?this.container?.focus():_(this._buttons[this.viewModel.angle]))})))}get disabled(){return this.viewModel.disabled}set disabled(t){this.viewModel.disabled=t}get icon(){return"move"}set icon(t){this._overrideIfSome("icon",t)}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}get speed(){return this.viewModel.speed}set speed(t){this.viewModel.speed=t}get _rotationEnabled(){return!this.view?.ready||this.view.constraints.rotationEnabled}render(){const{label:t,disabled:e,viewModel:i}=this,o=this.classes(c.base,v.widget,e?v.disabled:null);return w("div",{"aria-label":t,class:o,tabIndex:-1},i.supported?this._renderContent():this._renderUnsupportedMessage())}_renderUnsupportedMessage(){return w("section",{class:c.error,key:"unsupported"},w("p",null,this.messages.unsupported))}_renderContent(){return[this.visibleElements.directionalButtons?this._renderDirectionalButtons():void 0,this.visibleElements.rotationSlider?this._renderRotation():void 0]}_renderDirectionalButtons(){return w("calcite-action-pad",{expandDisabled:!0,key:"directional-buttons-container",layout:"grid"},w("calcite-action-group",{afterCreate:this._afterButtonContainerCreate,afterRemoved:this._afterButtonContainerRemoved,class:c.buttonsContainer,dir:"ltr"},l.slice(0,4).map((t=>this._renderButton(t))),this._renderCompass(),l.slice(4).map((t=>this._renderButton(t)))))}_renderButton(t){const{label:e,iconName:i}=d[t],o=this.messages[e];return w("calcite-action",{active:this.viewModel.angle===t,afterCreate:e=>this._afterButtonCreate(t,e),afterRemoved:()=>this._afterButtonRemoved(t),alignment:"center",class:c.button,"data-angle":t.toString(),disabled:this.disabled,key:t,onkeydown:this._onKeyDown.bind(void 0,t),onpointerdown:this._onButtonPointerDown,scale:this.visualScale,text:o,title:o},w("calcite-icon",{icon:i,scale:this.visualScale}))}_renderCompass(){const t=this.disabled||a(this.view)?"compass-needle":"arrow-up",e=0===this.viewModel.rotation,i=this.messages.resetHeading;return w("calcite-action",{alignment:"center",class:c.compassButton,disabled:this.disabled||!this._rotationEnabled||e,key:"compass",onclick:this._onRotationReset,scale:this.visualScale,styles:this._rotateIcon(this.viewModel.rotation),text:i,title:i},!e&&w("calcite-icon",{icon:t,scale:this.visualScale}))}_renderRotation(){return w("calcite-action-pad",{expandDisabled:!0,key:"slider-container",layout:"horizontal"},w("calcite-action-group",{class:c.rotationContainer},this.visibleElements.rotationResetButton?this._renderRotationResetButton():null,this._renderRotationSlider()))}_renderRotationResetButton(){const t=this.messages.resetHeading;return w("calcite-action",{alignment:"center",class:c.rotationReset,disabled:this.disabled||!this._rotationEnabled,onclick:this._onRotationReset,scale:this.visualScale,text:t,title:t},w("calcite-icon",{flipRtl:!0,icon:"rotate",scale:this.visualScale}))}_renderRotationSlider(){return w("div",{class:c.rotationSliderContainer},w("calcite-slider",{"aria-label":this.messages.heading,disabled:this.disabled||!this._rotationEnabled,labelHandles:!0,max:360,min:0,required:!0,scale:this.visualScale,value:Math.round(this.viewModel.rotation),onCalciteSliderInput:this._onSliderInput}))}};t([s()],f.prototype,"_buttonsContainer",void 0),t([s()],f.prototype,"_buttons",void 0),t([s()],f.prototype,"disabled",null),t([s()],f.prototype,"icon",null),t([s()],f.prototype,"label",null),t([s(),g("esri/widgets/DirectionalPad/t9n/DirectionalPad")],f.prototype,"messages",void 0),t([s({type:h,nonNullable:!0})],f.prototype,"visibleElements",void 0),t([s()],f.prototype,"view",null),t([s({type:p})],f.prototype,"viewModel",void 0),t([s()],f.prototype,"visualScale",void 0),t([s()],f.prototype,"speed",null),t([s({readOnly:!0})],f.prototype,"_rotationEnabled",null),f=t([n("esri.widgets.DirectionalPad")],f);const C=f;export{C as default};
5
+ import{_ as t}from"../chunks/tslib.es6.js";import{deprecateWidget as e}from"../core/deprecate.js";import i from"../core/Logger.js";import{watch as o}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import r from"./Widget.js";import{canShowNorth as a}from"./Compass/utils.js";import{directionalPadAngles as l,directionalPadArrows as c}from"./DirectionalPad/constants.js";import{css as d}from"./DirectionalPad/css.js";import u from"./DirectionalPad/DirectionalPadViewModel.js";import{findElementCenter as p}from"./DirectionalPad/utils.js";import h from"./DirectionalPad/VisibleElements.js";import{loadCalciteComponents as m}from"./support/componentsUtils.js";import{globalCss as v}from"./support/globalCss.js";import{isActivationKey as b,setFocus as _}from"./support/widgetUtils.js";import{messageBundle as g}from"./support/decorators/messageBundle.js";import{tsx as w}from"./support/jsxFactory.js";let f=class extends r{constructor(t,o){super(t,o),this._buttonsContainer=null,this._buttons={},this.messages=null,this.visibleElements=new h,this.viewModel=new u,this.visualScale="s",this._rotateIcon=t=>({"--rotation":`rotate(${t}deg)`}),this._afterButtonContainerCreate=t=>{this._buttonsContainer=t,this._buttonsContainer.addEventListener("contextmenu",this._onContextMenu,{capture:!0})},this._afterButtonContainerRemoved=()=>{this._buttonsContainer?.removeEventListener("contextmenu",this._onContextMenu,{capture:!0}),this._buttonsContainer=null},this._afterButtonCreate=(t,e)=>{this._buttons[t]=e},this._afterButtonRemoved=t=>{this._buttons[t]=void 0},this._onContextMenu=t=>t.preventDefault(),this._onButtonPointerDown=t=>{if(null===this._buttonsContainer)return;const e=t.target,i=e?.shadowRoot?.querySelector("button");i?.hasPointerCapture(t.pointerId)&&i.releasePointerCapture(t.pointerId);const o=p(this._buttonsContainer);this.viewModel.beginFollowingPointer(t,o)},this._onKeyDown=(t,{key:e})=>{b(e)&&this.viewModel.moveOnce(t)},this._onSliderInput=({currentTarget:t})=>{"number"==typeof t.value&&(this.viewModel.rotation=t.value)},this._onRotationReset=()=>{this.viewModel.rotation=0},e(i.getLogger(this),"Directional Pad","arcgis-directional-pad",{version:"4.32"})}loadDependencies(){return m({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider")})}initialize(){this.addHandles(o((()=>this.viewModel.angle),(()=>{const t=this._buttonsContainer?.contains(document.activeElement);t&&(null==this.viewModel.angle?this.container?.focus():_(this._buttons[this.viewModel.angle]))})))}get disabled(){return this.viewModel.disabled}set disabled(t){this.viewModel.disabled=t}get icon(){return"move"}set icon(t){this._overrideIfSome("icon",t)}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}get speed(){return this.viewModel.speed}set speed(t){this.viewModel.speed=t}get _rotationEnabled(){return!this.view?.ready||this.view.constraints.rotationEnabled}render(){const{label:t,disabled:e,viewModel:i}=this,o=this.classes(d.base,v.widget,e?v.disabled:null);return w("div",{"aria-label":t,class:o,tabIndex:-1},i.supported?this._renderContent():this._renderUnsupportedMessage())}_renderUnsupportedMessage(){return w("section",{class:d.error,key:"unsupported"},w("p",null,this.messages.unsupported))}_renderContent(){return[this.visibleElements.directionalButtons?this._renderDirectionalButtons():void 0,this.visibleElements.rotationSlider?this._renderRotation():void 0]}_renderDirectionalButtons(){return w("calcite-action-bar",{expandDisabled:!0,floating:!0,key:"directional-buttons-container",layout:"grid",overflowActionsDisabled:!0},w("calcite-action-group",{afterCreate:this._afterButtonContainerCreate,afterRemoved:this._afterButtonContainerRemoved,class:d.buttonsContainer,dir:"ltr"},l.slice(0,4).map((t=>this._renderButton(t))),this._renderCompass(),l.slice(4).map((t=>this._renderButton(t)))))}_renderButton(t){const{label:e,iconName:i}=c[t],o=this.messages[e];return w("calcite-action",{active:this.viewModel.angle===t,afterCreate:e=>this._afterButtonCreate(t,e),afterRemoved:()=>this._afterButtonRemoved(t),alignment:"center",class:d.button,"data-angle":t.toString(),disabled:this.disabled,key:t,onkeydown:this._onKeyDown.bind(void 0,t),onpointerdown:this._onButtonPointerDown,scale:this.visualScale,text:o,title:o},w("calcite-icon",{icon:i,scale:this.visualScale}))}_renderCompass(){const t=this.disabled||a(this.view)?"compass-needle":"arrow-up",e=0===this.viewModel.rotation,i=this.messages.resetHeading;return w("calcite-action",{alignment:"center",class:d.compassButton,disabled:this.disabled||!this._rotationEnabled||e,key:"compass",onclick:this._onRotationReset,scale:this.visualScale,styles:this._rotateIcon(this.viewModel.rotation),text:i,title:i},!e&&w("calcite-icon",{icon:t,scale:this.visualScale}))}_renderRotation(){return w("calcite-action-bar",{expandDisabled:!0,floating:!0,key:"slider-container",layout:"horizontal"},w("calcite-action-group",{class:d.rotationContainer},this.visibleElements.rotationResetButton?this._renderRotationResetButton():null,this._renderRotationSlider()))}_renderRotationResetButton(){const t=this.messages.resetHeading;return w("calcite-action",{alignment:"center",class:d.rotationReset,disabled:this.disabled||!this._rotationEnabled,onclick:this._onRotationReset,scale:this.visualScale,text:t,title:t},w("calcite-icon",{flipRtl:!0,icon:"rotate",scale:this.visualScale}))}_renderRotationSlider(){return w("div",{class:d.rotationSliderContainer},w("calcite-slider",{"aria-label":this.messages.heading,disabled:this.disabled||!this._rotationEnabled,labelHandles:!0,max:360,min:0,required:!0,scale:this.visualScale,value:Math.round(this.viewModel.rotation),onCalciteSliderInput:this._onSliderInput}))}};t([s()],f.prototype,"_buttonsContainer",void 0),t([s()],f.prototype,"_buttons",void 0),t([s()],f.prototype,"disabled",null),t([s()],f.prototype,"icon",null),t([s()],f.prototype,"label",null),t([s(),g("esri/widgets/DirectionalPad/t9n/DirectionalPad")],f.prototype,"messages",void 0),t([s({type:h,nonNullable:!0})],f.prototype,"visibleElements",void 0),t([s()],f.prototype,"view",null),t([s({type:u})],f.prototype,"viewModel",void 0),t([s()],f.prototype,"visualScale",void 0),t([s()],f.prototype,"speed",null),t([s({readOnly:!0})],f.prototype,"_rotationEnabled",null),f=t([n("esri.widgets.DirectionalPad")],f);const C=f;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 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{destroyMaybe as l,abortMaybe as p,removeMaybe as d}from"../../core/maybe.js";import{throwIfAborted as c,createResolver as u}from"../../core/promiseUtils.js";import{watch as h,on as w,when as f,syncAndInitial as m,initial as y,sync as g,whenOnce 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 V}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as b}from"../../portal/support/urlUtils.js";import A from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as L}from"../../views/interactive/snapping/SnappingManager.js";import U from"../../views/interactive/snapping/SnappingOptions.js";import C from"../Attachments/AttachmentsViewModel.js";import O from"./CreateFeaturesWorkflow.js";import S from"./UpdateFeaturesWorkflow.js";import j from"./UpdateWorkflow.js";import{getLayersFromWorkflow as P,isUpdateWorkflow as R,whenEditorLayerView as H}from"./workflowUtils.js";import G from"./support/EditorItem.js";import{makeTemplateGroupInfoForLayer as x}from"../FeatureTemplates/featureTemplatesUtils.js";import D from"../FeatureTemplates/FeatureTemplatesViewModel.js";import B from"../Sketch/SketchViewModel.js";import q from"../Spinner/SpinnerViewModel.js";import{goTo as N}from"../support/goToUtils.js";function Q(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 r,this.editorItems=new r,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new C({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new D({disabledItemFunction:({layer:t})=>this._itemIsSuspended(t)}),this.layerInfos=null,this.ownSketchViewModel=new B({layer:this._sketchGraphicsLayer}),this.sketchOptions=new A,this.snappingOptions=new U({attributeRulesEnabled:!0}),this.spinnerViewModel=new q,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()=>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()),m),h((()=>this.hideTemplatesForInactiveLayers),(()=>this.syncFeatureTemplates())),w((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),w((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),w((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),f((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),y),w((()=>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}),m),f((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),w((()=>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}),m),w((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(t.stopPropagation(),this.back())})),w((()=>this.sketchViewModel),["create","delete","update"],(t=>{const{activeWorkflow:e}=this,a="update"===e?.type,r=P(e),i=a?e?.activeWorkflow?.parentLayer:void 0,s=`sketch-${t.type}`;this.emit(s,{type:s,detail:t,layer:r[0],layers:r,parentLayer:i})}),g),h((()=>this.view),(t=>{if(this._snappingManager=l(this._snappingManager),!t)return;const e=this.snappingOptions;this._snappingManager=new L({view:t,options:e}),this.ownSketchViewModel.snappingManager=this._snappingManager}),m),h((()=>this.snappingOptions),(t=>{this._snappingManager&&(this._snappingManager.options=t)}),m)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=p(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=d(this._sketchEventListenerHandle)}get _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&&R(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 formViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeFeatureFormViewModel:"create-features"===t?.type?t.featureFormViewModel:"update-features"===t?.type?t.formViewModel: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 k((()=>!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 k((()=>!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 startUpdateFeaturesWorkflow(t){if(await k((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateFeaturesWorkflow(t);this._set("activeWorkflow",e),await e.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{e.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await k((()=>!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 k((()=>!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 k((()=>!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&&N(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=>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(){p(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 H(t,l).catch((()=>null));(e?r:a?i:s).push(new G({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(){p(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(x(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)})}_createUpdateFeaturesWorkflow(t){const e=S.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,features:t,applyEdits:(t,e,a)=>this._applyEdits(t,e,a),applyEditsFeatureService:(t,e,a)=>this._applyEditsFeatureService(t,e,a)});return e.addHandles(w((()=>e),"commit",(()=>{e.destroy(),this.activeWorkflow===e&&this._set("activeWorkflow",null)}))),e}_createUpdateWorkflow(t){return j.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),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 V(t.url):null,s={returnServiceEditsOption:(!i||!b(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 H(a,t).catch((()=>null));return r=await t.applyEdits(e,s),i&&await k((()=>!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()],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:C})],z.prototype,"attachmentsViewModel",void 0),t([v()],z.prototype,"featureFormViewModel",null),t([v()],z.prototype,"formViewModel",null),t([v()],z.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),t([v({type:D})],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:U,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([_("esri.widgets.Editor.EditorViewModel")],z);const Z=z;export{Z as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{isSome as t}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import a 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{destroyMaybe as l,abortMaybe as p,removeMaybe as c}from"../../core/maybe.js";import{throwIfAborted as d,createResolver as h}from"../../core/promiseUtils.js";import{watch as u,on as w,when as f,syncAndInitial as m,initial as y,sync as g,whenOnce 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 M}from"../../editing/templateUtils.js";import F from"../../layers/GraphicsLayer.js";import{isEditableLayer as E}from"../../layers/support/editableLayers.js";import{isFeatureLayer as b,isSubtypeGroupLayer as V,getOwningPortalUrl as T}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as I}from"../../portal/support/urlUtils.js";import L from"../../views/SelectionManager.js";import A from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as U}from"../../views/interactive/snapping/SnappingManager.js";import S from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as C}from"../../views/support/selectionUtils.js";import O from"../Attachments/AttachmentsViewModel.js";import j from"./CreateFeaturesWorkflow.js";import P from"./UpdateFeaturesWorkflow.js";import R from"./UpdateWorkflow.js";import{getLayersFromWorkflow as H,isUpdateWorkflow as G,whenEditorLayerView as x}from"./workflowUtils.js";import D from"./support/EditorItem.js";import{makeTemplateGroupInfoForLayer as B}from"../FeatureTemplates/featureTemplatesUtils.js";import q from"../FeatureTemplates/FeatureTemplatesViewModel.js";import N from"../Sketch/SketchViewModel.js";import Q from"../Spinner/SpinnerViewModel.js";import{goTo as z}from"../support/goToUtils.js";import{isFeatureItem as Z,isLayerItem as $}from"../support/SelectionList/selectionListUtils.js";import J from"../support/SelectionList/SelectionListViewModel.js";import K from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function X(e,t){return e?.find((e=>e.layer===t))}let Y=class extends s.EventedAccessor{constructor(e){super(e),this._templatesByLayer=new Map,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new F({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 a,this.editorItems=new a,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new O({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new q({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new N({layer:this._sketchGraphicsLayer}),this.selectionListViewModel=new J,this.selectionManager=new L,this.selectionToolbarViewModel=new K,this.sketchOptions=new A,this.snappingOptions=new S({attributeRulesEnabled:!0}),this.spinnerViewModel=new Q,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{this.selectionToolbarViewModel.cancel(),"viewing-selection-list"!==this.state?this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits})):this.effectiveSelectionManager.clear()},this.saveWorkflow=async()=>await(this.activeWorkflow?.save()),this.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;this._candidateCommitted||"update"!==i?.type||(i.data.rootFeature=e,t&&(i.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([u((()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,a=i?.filter((e=>!!t?.includes(e.layer)));return[t,a,this.layerInfos]}),(()=>this._updateEditorItems()),m),u((()=>this.hideTemplatesForInactiveLayers),(()=>this.syncFeatureTemplates())),w((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),w((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),w((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),f((()=>this.view?.map),(e=>e.add(this._sketchGraphicsLayer)),y),w((()=>this.editorItems),"change",(()=>this._afterEditorItemsChange())),u((()=>[this.canCreate,this.canUpdateVisible]),(()=>this._afterEditorItemsChange())),u((()=>this.page),((e,t)=>{const i=[...this.pageStack];if(-1===i.indexOf(e))i.push(e);else for(;i.length&&i.at(-1)!==e;)i.pop();this.pageStack=i}),m),f((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),w((()=>this.featureTemplatesViewModel),"select",(async({item:e,oldItem:t})=>{const{activeWorkflow:i}=this;if(i){if("update"===i.type&&"awaiting-feature-creation-info"===i.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(t,{emit:!1})}}if(!e)return;const a={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(a);this.startCreateFeaturesWorkflowAtFeatureCreation(a)})),u((()=>[this.view,this.featureTemplatesViewModel]),(([e,t])=>{t.view=e}),m),w((()=>this.view),"key-down",(e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())})),w((()=>this.sketchViewModel),["create","delete","update"],(e=>{const{activeWorkflow:t}=this,i="update"===t?.type,a=H(t),r=i?t?.activeWorkflow?.parentLayer:void 0,s=`sketch-${e.type}`;this.emit(s,{type:s,detail:e,layer:a[0],layers:a,parentLayer:r})}),g),u((()=>this.view),(e=>{if(this._snappingManager=l(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new U({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager}),m),u((()=>this.snappingOptions),(e=>{this._snappingManager&&(this._snappingManager.options=e)}),m),w((()=>this.selectionToolbarViewModel),"complete",(e=>this._onSelectionComplete(e))),u((()=>({view:this.view,selectionManager:this.effectiveSelectionManager,selectionListViewModel:this.selectionListViewModel,selectionToolbarViewModel:this.selectionToolbarViewModel})),(({view:e,selectionManager:t,selectionListViewModel:i,selectionToolbarViewModel:a})=>{t.view=e,i.view=e,a.view=e}),m),u((()=>this.effectiveSelectionManager),(e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e}),m)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=p(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=c(this._sketchEventListenerHandle)}get _featureTemplatesLayersAndTables(){const e=new a;for(const t of this.editorItems){const i=this.hideTemplatesForInactiveLayers&&!t.visible;t.supportsCreateFeaturesWorkflow&&!i&&e.push(t.layer)}return e}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&G(e)?e.activeWorkflow??e:e}get canCreate(){return this.editorItems.some((e=>e.supportsCreateFeaturesWorkflow))}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some((e=>e.supportsUpdateWorkflow))}get canUpdateVisible(){return this.editorItems.some((e=>e.supportsUpdateWorkflow&&e.visible))}get featureTemplatesLayers(){return this._featureTemplatesLayersAndTables.filter((e=>"scene"===e.type||!e.isTable))}get effectiveSelectionManager(){return this.selectionManager}get featureFormViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:null}get formViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:"update-features"===e?.type?e.formViewModel:null}get utilityNetworkAssociationAddAssociationViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeUtilityNetworkAssociationAddAssociationViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get sketchViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeSketchViewModel:"create-features"===e?.type?e.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this,i=!t?.stepId;return this.effectiveSelectionManager.count&&i?"viewing-selection-list":i?"ready":"update"===t.type&&t.activeWorkflow?.stepId?t.activeWorkflow.stepId:t.stepId}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(e){this.sketchOptions.tooltips=e}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}set view(e){this.ownSketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}get canZoomTo(){const e=this.sketchViewModel,t=e?.createGraphic?.geometry?.type;return!(!e?.updateGraphics?.length&&"multipoint"!==t)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associatedLayer)return"viewing-associated-features";if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associationId)return"viewing-associated-layers";if("update"===e?.type&&"awaiting-feature-to-update"===e.stepId)return"ready";if("create-features"===e?.type&&0===e.numPendingFeatures){const t=e.data.upload;if(t)return"default"===t.state?"ready":"creating-features-upload-details"}return t??"disabled"}get featureFormDisabled(){const{activeWorkflow:e}=this;return"update"===e?.type&&(!1===e.activeEditorItem?.capabilities.update.attributes||!0===e.activeFeatureFormViewModel?.disabled)}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:e}=this;return!!e&&"update"===e.type&&!!e.activeEditorItem?.capabilities.delete.enabled}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}getTemplatesForLayer(e){return this._templatesByLayer.get(e)??[]}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(await k((()=>!this.updating)),!this.canCreate)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled.");const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const i=this._createCreateFeaturesWorkflow(e,t);this._set("activeWorkflow",i),await i.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await k((()=>!this.updating));const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,a=i?this.findEditorItemForLayer(i):void 0;if(!a?.supportsCreateFeaturesWorkflow)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const s=this._createCreateFeaturesWorkflow({initialFeature:t,layer:a.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",s),await s.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateFeaturesWorkflow(e){if(await k((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateFeaturesWorkflow(e);this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await k((()=>!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();this._set("activeWorkflow",e),await e.start()}catch(t){this._logErrorAndCancelWorkflow(t)}finally{e.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(await k((()=>!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("awaiting-update-feature-candidate");t.data.candidates=e,this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureEdit(e){if(await k((()=>!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("editing-existing-feature");t.data.rootFeature=e,t.addHandles(w((()=>t),"commit",(()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)}))),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount)throw new r("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new r("editing:features-different-layers","Cannot start workflow with features from different layers.");const t=e.activeLayerItem??e.layerItems.find((e=>e.total>0));if(!t)throw new r("editing:no-layer-item","Unable to determine source layer of active selection.");const i=t.selection.map((e=>e.graphic));1===i.length?this.startUpdateWorkflowAtFeatureEdit(i[0]):this.startUpdateFeaturesWorkflow(i)}async deleteFeatureFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveFeature():this._logError("editing:unsupported-workflow","Deleting a feature requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveAssociation():this._logError("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warnIfNoWorkflow:!0,...e})}findEditorItemForLayer(e){return this.editorItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(e){return null!=e&&!0===this.findEditorItemForLayer(e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const i=this.sketchViewModel,a=e?e.geometry:i?.updateGraphics.length?i?.updateGraphics.toArray().map((e=>e.geometry)).filter(t):i?.createGraphic?.geometry;a&&this.view&&z(this.view,a)}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()))}async onSelectionListItemSelect(e){Z(e)&&this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e){if(Z(e))this.startUpdateWorkflowAtFeatureEdit(e.graphic);else if($(e)){const t=e.selection.map((e=>e.graphic));1===t.length?this.startUpdateWorkflowAtFeatureEdit(t[0]):this.startUpdateFeaturesWorkflow(t)}}restrictFeatureTemplatesViewModelToLayer(e){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([e]),o((()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)}))}async _getEditorItemCandidates(e){const{view:t}=this;if(!t?.map)return[];const{map:i}=t,a=i.editableLayers.toArray(),r=i.allTables.toArray().filter((e=>b(e)||V(e)));return await Promise.allSettled([...a.flatMap((e=>this._getLayerLoadPromise(e))),...r.flatMap((e=>this._getLayerLoadPromise(e)))]),d(e),[...a.reverse(),...r.reverse()].filter((e=>E(e)&&("mesh"!==e.geometryType||"3d"===t.type))).flatMap((e=>"subtype-group"===e.type?e.sublayers.toArray():e))}_getLayerLoadPromise(e){return V(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain((e=>e.destroy()))}_updateEditorItems(){p(this._updateItemsTask);const{view:e}=this,t=i((async t=>{if(!e?.map||!e?.allLayerViews)return;const i=await this._getEditorItemCandidates(t);if(!i.length)return void this._drainEditorItems();const a=[],r=[],s=[],{layerInfos:o}=this;for(const l of i){const t=X(o,l),i=await x(e,l).catch((()=>null));(t?a:i?r:s).push(new D({layer:l,layerInfo:t,layerView:i}))}o?.length&&a.sort(((e,t)=>o.findIndex((({layer:t})=>t===e.layer))-o.findIndex((({layer:e})=>e===t.layer))));const n=[...a,...r,...s];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))}));this._updatingHandles.addPromise(t.promise),this._updateItemsTask=t}_updateTemplates(){p(this._updateTemplatesTask);const e=i((async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter((e=>!t.has(e)));if(i.length>0){const a=await M(i.toArray(),this.view,e);for(const{layer:e,templates:i}of a)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)}));this._updatingHandles.addPromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const a of e){const e=t.get(a);e&&e.length>0&&i.push(B(a,e))}this.featureTemplatesViewModel.templateInfos=i}_afterEditorItemsChange(){const{activeWorkflow:e}=this;if(this.syncFeatureTemplates(),this._syncSelectionSources(),!e)return;const{stepId:t}=e;"create-features"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===t&&!e.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e?.warnIfNoWorkflow&&this._logError("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force){this.emit("workflow-cancel"),this._set("activeWorkflow",null);try{await t.cancel(e)}finally{t.destroy()}}else try{await t.cancel(e),this._set("activeWorkflow",null),t.destroy()}catch(i){}}_createCreateFeaturesWorkflow(e,t){return j.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateFeaturesWorkflow(e){const t=P.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,features:e,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i)});return t.addHandles(w((()=>t),"commit",(()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)}))),t}_createUpdateWorkflow(e){return R.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_addAttachments(e,t){const i=t.map((t=>this._addAttachment(e,t.feature,t.attachment)))??[];return Promise.all(i)}async _addAttachment(e,t,i){let a=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new r("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(a=await(e.addAttachment?.(t,i).catch((e=>{throw e?.error||e})))??null,a))),a}async _applyEdits(e,t,i){let a=null;const r=e.url?await T(e.url):null,s={returnServiceEditsOption:(!r||!I(r))&&!RegExp("/hosted/","i").test(e.url)?"original-and-current-features":void 0,...i};return await this._queueOperation((async()=>{const{view:i}=this;if(!i)return null;const r=await x(i,e).catch((()=>null));return a=await e.applyEdits(t,s),r&&await k((()=>!r.updating)),a})),a}async _applyEditsFeatureService(e,t,i){let a=null;return await this._queueOperation((async()=>a=await e.applyEdits(t,i))),a}_queueOperation(e){this._activityQueue.push(e);const t=(e,t)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)};return e().then((e=>(Array.isArray(e)?e.forEach((e=>this._handleEditsResultError(e))):this._handleEditsResultError(e),e))).catch((i=>{this._logError("editing:operation-error","An error occurred.",{error:i});const a={error:i,retry:()=>(t(a,this.failures),this._queueOperation(e)),cancel:()=>{t(a,this.failures)}};this._set("failures",[...this.failures,a])})).then((()=>{t(e,this._activityQueue)}))}_handleEditsResultError(e){if(null!=e&&"error"in e&&null!=e.error)throw e.error;if(null!=e&&"addFeatureResults"in e){const{addFeatureResults:t,deleteFeatureResults:i,updateFeatureResults:a}=e,r=t.find((e=>!!e.error))||a.find((e=>!!e.error))||i.find((e=>!!e.error));if(r)throw r.error}}_createUpdatingResolver(){const e=h();return this._updatingHandles.addPromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:a}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,a??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=this.findEditorItemForLayer(e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){n.getLogger(this).error(new r(e,t,i))}_syncSelectionSources(){const{selectionManager:e}=this,t=[];this.editorItems.forEach((e=>{C(e.layer)&&e.supportsUpdateWorkflow&&t.push(e.layer)})),e.sources.removeAll(),e.sources.addMany(t)}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:a}=this,r="ready"===this.state,s=1===i.length;if(r&&s&&(0===a.count&&"add"===t||"replace"===t))return this.startUpdateWorkflowAtFeatureEdit(i[0]);switch(t){case"remove":a.updateSelection({current:[],added:[],removed:i});break;case"replace":a.clear(),a.updateSelection({current:i,added:[],removed:[]});break;case"add":a.updateSelection({current:i,added:[],removed:[]})}}};e([v()],Y.prototype,"_featureTemplatesLayersAndTables",null),e([v()],Y.prototype,"_snappingManager",void 0),e([v({readOnly:!0})],Y.prototype,"activeWorkflow",void 0),e([v()],Y.prototype,"activeLeafWorkflow",null),e([v({readOnly:!0})],Y.prototype,"_activityQueue",void 0),e([v({readOnly:!0})],Y.prototype,"canCreate",null),e([v()],Y.prototype,"canCreateVisible",null),e([v({readOnly:!0})],Y.prototype,"canUpdate",null),e([v()],Y.prototype,"canUpdateVisible",null),e([v()],Y.prototype,"featureTemplatesLayers",null),e([v()],Y.prototype,"editorItems",void 0),e([v()],Y.prototype,"effectiveSelectionManager",null),e([v({readOnly:!0})],Y.prototype,"failures",void 0),e([v()],Y.prototype,"hideTemplatesForInactiveLayers",void 0),e([v({type:O})],Y.prototype,"attachmentsViewModel",void 0),e([v()],Y.prototype,"featureFormViewModel",null),e([v()],Y.prototype,"formViewModel",null),e([v()],Y.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([v({type:q})],Y.prototype,"featureTemplatesViewModel",void 0),e([v()],Y.prototype,"labelOptions",null),e([v()],Y.prototype,"layerInfos",void 0),e([v()],Y.prototype,"ownSketchViewModel",void 0),e([v()],Y.prototype,"selectionListViewModel",void 0),e([v()],Y.prototype,"selectionManager",void 0),e([v()],Y.prototype,"selectionToolbarViewModel",void 0),e([v()],Y.prototype,"sketchOptions",void 0),e([v()],Y.prototype,"sketchViewModel",null),e([v({type:S,nonNullable:!0})],Y.prototype,"snappingOptions",void 0),e([v()],Y.prototype,"spinnerViewModel",void 0),e([v()],Y.prototype,"state",null),e([v({readOnly:!0})],Y.prototype,"syncing",null),e([v()],Y.prototype,"updating",null),e([v()],Y.prototype,"tooltipOptions",null),e([v()],Y.prototype,"valueOptions",null),e([v()],Y.prototype,"view",null),e([v()],Y.prototype,"canZoomTo",null),e([v()],Y.prototype,"pageStack",void 0),e([v()],Y.prototype,"showDiscardEditsPrompt",void 0),e([v()],Y.prototype,"_candidateCommitted",void 0),e([v()],Y.prototype,"page",null),e([v()],Y.prototype,"featureFormDisabled",null),e([v()],Y.prototype,"featureFormHasAssociation",null),e([v()],Y.prototype,"canGoBack",null),e([v()],Y.prototype,"shouldShowDeleteButton",null),e([v()],Y.prototype,"hasPendingEdits",null),e([v()],Y.prototype,"snappingManager",null),Y=e([_("esri.widgets.Editor.EditorViewModel")],Y);const ee=Y;export{ee as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as o}from"../../core/maybe.js";import{watch as s}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import l from"../../layers/GraphicsLayer.js";import{hasEffectiveFeatureExpressionInfo as d}from"../../support/elevationInfoUtils.js";import{highlightsSupported as n}from"../../views/support/layerViewUtils.js";import h from"./UpdateFeatureWorkflowData.js";import{UpdateRecordWorkflow as c,handleKeys as p}from"./UpdateRecordWorkflow.js";import{getVisualVariableAttributes as w,setUpGeometryUpdate as m,updateGraphicSymbolWhenRequired as u,swapForEditingSession as y,cloneGraphicExceptMesh as f,canCreateInteractiveEditSession as g,isTerminalUpdateEventType as k}from"./workflowUtils.js";import _ from"../Sketch/SketchViewModel.js";var V;const v={...p,highlights:Symbol(),sketchGraphics:Symbol(),sketchViewModel:Symbol(),waitingForTool:Symbol()};let M=V=class extends c{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._sketchViewModel=null,this._webStyleCache=new Map}destroy(){this._layerViewEditSession?.rollback()}async commit(){this.removeHandles(v.sketchGraphics);try{const e=this.data.edits.stagedForDelete;await super.commit();const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async start(){return await super.start(),await this._initializeSketchViewModel()}_initializeFeatureFormViewModel(){super._initializeFeatureFormViewModel(),this.addHandles([this._featureFormViewModel.on("value-change",(e=>{this._layerViewEditSession?.setAttribute(e.fieldName,e.value)})),s((()=>this._featureFormViewModel.feature?.sourceLayer),(e=>this._sketchGraphicClone.sourceLayer=e))])}_configureHighlight(){const{edits:e,layerView:t}=this.data;n(t)&&this.addHandles(t.highlight(e.feature),v.highlights)}async _configureSketchViewModel(){const e=this._sketchViewModel;if(!e)return;const{data:t,_featureFormViewModel:i,_sketchGraphicClone:o}=this,{edits:s,viewModel:a}=t,r=s.feature,{view:l}=a,d=w(r),n=await m({feature:r,featureClone:o,visualVariableAttributes:d,sketchViewModel:e,view:l,onUpdate:({geometry:e,attributes:t},o)=>{if(s.updateAttributes(t),s.updateGeometry(e),i.feature&&(i.feature.geometry=e),null!=d.rotation){const{field:e}=d.rotation;i.setValue(e,t[e])}if(null!=d.size){const{field:e}=d.size;i.setValue(e,t[e])}("undo"===o.type||"redo"===o.type||"update"===o.type&&null!=o.toolEventInfo&&k(o.toolEventInfo.type))&&i.notifyFeatureGeometryChanged()},addUpdatingPromise:e=>{this._updatingHandles.addPromise(e)},addHandle:e=>{this.addHandles(e,v.waitingForTool)},webStyleCache:this._webStyleCache});this.addHandles(n,v.sketchGraphics),e.addHandles(n)}async _initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,s=e.edits.feature,{capabilities:a,layer:r}=e.editorItem,{view:n}=e.viewModel;if(this.removeHandles([v.highlights,v.sketchGraphics,v.sketchViewModel,v.waitingForTool]),!a.update.geometry||"3d"===n?.type&&d(r.elevationInfo))return{enter:async()=>{this.hasHandles(v.highlights)||this._configureHighlight()},exit:()=>this.removeHandles([v.highlights])};const h=new l({elevationInfo:r.elevationInfo,internal:!0,listMode:"hide"}),c=new _({allowDeleteKey:!1,layer:h,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,view:n});return this._sketchViewModel=c,n?.map.add(h),await(n?.whenLayerView(h)),this.addHandles(i((()=>{n?.destroyed||n?.map.remove(h),h.destroy(),this._sketchViewModel=o(c)})),v.sketchViewModel),await u(t,this._webStyleCache,"2d"===n?.type?n.scale:null),this.addHandles([await y(c,s,t)]),{enter:async()=>{this.hasHandles(v.sketchGraphics)||await this._configureSketchViewModel()},exit:()=>this.removeHandles([v.sketchGraphics]),viewModel:c}}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e);const t=this._sketchGraphicClone=f(e),{edits:i,layerView:o}=this.data;i.updateGeometry(e.geometry),i.trackChanges(),g(o)&&(this._layerViewEditSession=o.createInteractiveEditSession(t))}static async create(e){const t=new V({data:await h.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}get test(){}};e([a()],M.prototype,"_layerViewEditSession",void 0),e([a()],M.prototype,"_sketchGraphicClone",void 0),e([a()],M.prototype,"_sketchViewModel",void 0),M=V=e([r("esri.widgets.Editor.UpdateFeatureWorkflow")],M);export{M as UpdateFeatureWorkflow,v as handleKeys};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as o}from"../../core/maybe.js";import{watch as s}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import l from"../../layers/GraphicsLayer.js";import{hasEffectiveFeatureExpressionInfo as d}from"../../support/elevationInfoUtils.js";import{highlightsSupported as n}from"../../views/support/layerViewUtils.js";import h from"./UpdateFeatureWorkflowData.js";import{UpdateRecordWorkflow as c,handleKeys as p}from"./UpdateRecordWorkflow.js";import{getVisualVariableAttributes as w,setUpGeometryUpdate as m,updateGraphicSymbolWhenRequired as u,swapForEditingSession as y,cloneGraphicExceptMesh as f,canCreateInteractiveEditSession as g,isTerminalUpdateEventType as k}from"./workflowUtils.js";import _ from"../Sketch/SketchViewModel.js";var V;const v={...p,highlights:Symbol(),sketchGraphics:Symbol(),sketchViewModel:Symbol(),waitingForTool:Symbol()};let M=V=class extends c{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._sketchViewModel=null,this._webStyleCache=new Map}destroy(){this._layerViewEditSession?.rollback()}async commit(){this.removeHandles(v.sketchGraphics);try{const e=this.data.edits.stagedForDelete;await super.commit();const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async start(){return await super.start(),await this._initializeSketchViewModel()}_initializeFeatureFormViewModel(){super._initializeFeatureFormViewModel(),this.addHandles([this._featureFormViewModel.on("value-change",(e=>{this._layerViewEditSession?.setAttribute(e.fieldName,e.value)})),s((()=>this._featureFormViewModel.feature?.sourceLayer),(e=>this._sketchGraphicClone.sourceLayer=e))])}_configureHighlight(){const{edits:e,layerView:t}=this.data;n(t)&&this.addHandles(t.highlight(e.feature),v.highlights)}async _configureSketchViewModel(){const e=this._sketchViewModel;if(!e)return;const{data:t,_featureFormViewModel:i,_sketchGraphicClone:o}=this,{edits:s,viewModel:a}=t,r=s.feature,{view:l}=a,d=w(r),n=await m({feature:r,featureClone:o,visualVariableAttributes:d,sketchViewModel:e,view:l,onUpdate:({geometry:e,attributes:t},o)=>{if(s.updateAttributes(t),s.updateGeometry(e),i.feature&&(i.feature.geometry=e),null!=d.rotation){const{field:e}=d.rotation;i.setValue(e,t[e])}if(null!=d.size){const{field:e}=d.size;i.setValue(e,t[e])}("undo"===o.type||"redo"===o.type||"update"===o.type&&null!=o.toolEventInfo&&k(o.toolEventInfo.type))&&i.notifyFeatureGeometryChanged()},addUpdatingPromise:e=>{this._updatingHandles.addPromise(e)},addHandle:e=>{this.addHandles(e,v.waitingForTool)},webStyleCache:this._webStyleCache});this.addHandles(n,v.sketchGraphics),e.addHandles(n)}async _initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,{readOnly:s}=e,a=e.edits.feature,{capabilities:r,layer:n}=e.editorItem,{view:h}=e.viewModel;if(this.removeHandles([v.highlights,v.sketchGraphics,v.sketchViewModel,v.waitingForTool]),!r.update.geometry||s||"3d"===h?.type&&d(n.elevationInfo))return{enter:async()=>{this.hasHandles(v.highlights)||this._configureHighlight()},exit:()=>this.removeHandles([v.highlights])};const c=new l({elevationInfo:n.elevationInfo,internal:!0,listMode:"hide"}),p=new _({allowDeleteKey:!1,layer:c,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,view:h});return this._sketchViewModel=p,h?.map.add(c),await(h?.whenLayerView(c)),this.addHandles(i((()=>{h?.destroyed||h?.map.remove(c),c.destroy(),this._sketchViewModel=o(p)})),v.sketchViewModel),await u(t,this._webStyleCache,"2d"===h?.type?h.scale:null),this.addHandles([await y(p,a,t)]),{enter:async()=>{this.hasHandles(v.sketchGraphics)||await this._configureSketchViewModel()},exit:()=>this.removeHandles([v.sketchGraphics]),viewModel:p}}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e);const t=this._sketchGraphicClone=f(e),{edits:i,layerView:o}=this.data;i.updateGeometry(e.geometry),i.trackChanges(),g(o)&&(this._layerViewEditSession=o.createInteractiveEditSession(t))}static async create(e){const t=new V({data:await h.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}get test(){}};e([a()],M.prototype,"_layerViewEditSession",void 0),e([a()],M.prototype,"_sketchGraphicClone",void 0),e([a()],M.prototype,"_sketchViewModel",void 0),M=V=e([r("esri.widgets.Editor.UpdateFeatureWorkflow")],M);export{M as UpdateFeatureWorkflow,v as handleKeys};
@@ -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/Error.js";import{makeHandle as i,abortHandle as r}from"../../core/handleUtils.js";import{isAborted as a}from"../../core/promiseUtils.js";import{watch as o}from"../../core/reactiveUtils.js";import{property as s}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 n from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as d}from"../../views/support/HighlightDefaults.js";import c from"./UpdateRecordWorkflowData.js";import u from"./Workflow.js";import{fetchFullFeatures as m}from"./workflowUtils.js";import h from"../FeatureForm/FeatureFormViewModel.js";var p;const f={exit:Symbol()};let g=class extends u{static{p=this}constructor(e){super(e),this._highlightHelper=null,this.fullFeature=null,this.type="update-table-record"}initialize(){const{data:e}=this,{edits:o}=e,{view:s}=e.viewModel,l=o.feature;s&&(this._highlightHelper=new n({view:s,highlightName:d}),this.addHandles(i((()=>this._highlightHelper?.removeAll()))));const c=new AbortController;this.addHandles(r(c)),this._updatingHandles.addPromise(m([l],l.sourceLayer,e.viewModel.view.spatialReference,c.signal).then((([e])=>{a(c)||(this._onFullFeatureLoaded(e),this._initializeFeatureFormViewModel())}),(e=>this.cancel({force:!0,error:new t("editor:failed-to-fetch-full-feature","Failed to retrieve all information for this feature. The update cannot proceed.",{detail:{error:e}})}))))}get editorItem(){return this.data.editorItem}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){return this.data.edits.modified}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get shouldShowAttachments(){return this.editorItem.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return this.editorItem.capabilities.update.attachments.enabled}get reliesOnOwnerAdminPrivileges(){const e=this.editorItem.capabilities;return e.update.reliesOnOwnerAdminPrivileges||e.delete.reliesOnOwnerAdminPrivileges}async deleteAndCommit(){return this.data.edits.stageDelete(),this.commit()}async enter(){this._configureAttachmentsViewModel()}exit(e){this.removeHandles(f.exit)}async start(){return await super.start(),null}_configureAttachmentsViewModel(){const{data:e,fullFeature:t}=this,{attachmentsCapabilities:r,viewModel:a}=e,{attachmentsViewModel:s}=a;s.set({capabilities:r,graphic:t,filesEnabled:!1,mode:"view"}),this.addHandles([i((()=>s.fileInfos.removeAll())),o((()=>s.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}}))],f.exit)}_initializeFeatureFormViewModel(){const{association:e,edits:t,formTemplate:i,viewModel:{view:r}}=this.data,a=this._featureFormViewModel=new h({activeAssociation:e,editType:"UPDATE",feature:this.fullFeature,formTemplate:i,highlightHelper:this._highlightHelper,map:r?.map,spatialReference:r.spatialReference,timeZone:r?.timeZone});a.callbacks={...this.data.featureFormCallbacks,showAllRelatedRecords:e=>a.relationshipId=e.relationshipId,viewAssociatedLayers:e=>a.associationId=e.associationId,viewAssociatedFeatures:e=>a.associatedLayer=e.associatedLayer};const{initialFeature:s}=t;s&&a.overrideInitialFeature(s),this.addHandles([a.on("value-change",(()=>{t.updateAttributes(a.getValues()),this.fullFeature.attributes=t.feature.attributes})),o((()=>r?.timeZone),(e=>a.timeZone=e))])}_onFullFeatureLoaded(e){this.fullFeature=e;const{edits:t}=this.data;t.updateAttributes(e.attributes),t.trackChanges()}static async create(e){const t=new p({data:await c.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}static _createWorkflowSteps(e){const{attachmentsViewModel:t}=e.data.viewModel;return[{id:"editing-attributes",async setUp(){},async tearDown(){}},{id:"adding-attachment",async setUp(){},async tearDown(){t.mode="view"}},{id:"editing-attachment",async setUp(){},async tearDown(){t.mode="view"}}]}static{this._onCommitFactory=e=>async t=>{const{edits:i}=t,{feature:r}=i;if(!r)return;const a=r.sourceLayer,o=r.clone();if(!i.attributesModified||i.stagedForDelete){const e=a.objectIdField;if(o.attributes={[e]:r.getAttribute(e)},"scene"===a.type&&null!=a.infoFor3D){const e=a.associatedLayer?.globalIdField;null!=e&&o.setAttribute(e,r.getAttribute(e))}}i.geometryModified&&!i.stagedForDelete||(o.geometry=null);const s=i.stagedForDelete?"deleteFeatures":"updateFeatures";await e(a,{[s]:[o]})}}};e([s()],g.prototype,"_featureFormViewModel",void 0),e([s()],g.prototype,"editorItem",null),e([s()],g.prototype,"featureFormViewModel",null),e([s()],g.prototype,"fullFeature",void 0),e([s()],g.prototype,"hasPendingEdits",null),e([s()],g.prototype,"layer",null),e([s()],g.prototype,"parent",null),e([s()],g.prototype,"parentLayer",null),e([s()],g.prototype,"shouldShowAttachments",null),e([s()],g.prototype,"shouldAllowAttachmentEditing",null),e([s()],g.prototype,"reliesOnOwnerAdminPrivileges",null),g=p=e([l("esri.widgets.Editor.UpdateRecordWorkflow")],g);export{g as UpdateRecordWorkflow,f as handleKeys};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{makeHandle as i,abortHandle as r}from"../../core/handleUtils.js";import{isAborted as a}from"../../core/promiseUtils.js";import{watch as o}from"../../core/reactiveUtils.js";import{property as s}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 n from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as d}from"../../views/support/HighlightDefaults.js";import c from"./UpdateRecordWorkflowData.js";import u from"./Workflow.js";import{fetchFullFeatures as m}from"./workflowUtils.js";import h from"../FeatureForm/FeatureFormViewModel.js";var p;const f={exit:Symbol()};let g=class extends u{static{p=this}constructor(e){super(e),this._highlightHelper=null,this.fullFeature=null,this.type="update-table-record"}initialize(){const{data:e}=this,{edits:o}=e,{view:s}=e.viewModel,l=o.feature;s&&(this._highlightHelper=new n({view:s,highlightName:d}),this.addHandles(i((()=>this._highlightHelper?.removeAll()))));const c=new AbortController;this.addHandles(r(c)),this._updatingHandles.addPromise(m([l],l.sourceLayer,e.viewModel.view.spatialReference,c.signal).then((([e])=>{a(c)||(this._onFullFeatureLoaded(e),this._initializeFeatureFormViewModel())}),(e=>this.cancel({force:!0,error:new t("editor:failed-to-fetch-full-feature","Failed to retrieve all information for this feature. The update cannot proceed.",{detail:{error:e}})}))))}get editorItem(){return this.data.editorItem}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){return this.data.edits.modified}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get shouldShowAttachments(){return this.editorItem.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return this.editorItem.capabilities.update.attachments.enabled}get reliesOnOwnerAdminPrivileges(){const e=this.editorItem.capabilities;return e.update.reliesOnOwnerAdminPrivileges||e.delete.reliesOnOwnerAdminPrivileges}async deleteAndCommit(){return this.data.edits.stageDelete(),this.commit()}async enter(){this._configureAttachmentsViewModel()}exit(e){this.removeHandles(f.exit)}async start(){return await super.start(),null}_configureAttachmentsViewModel(){const{data:e,fullFeature:t}=this,{attachmentsCapabilities:r,viewModel:a}=e,{attachmentsViewModel:s}=a,l=e.readOnly?{editing:!1}:r;s.set({capabilities:l,graphic:t,filesEnabled:!1,mode:"view"}),this.addHandles([i((()=>s.fileInfos.removeAll())),o((()=>s.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}}))],f.exit)}_initializeFeatureFormViewModel(){const{association:e,edits:t,formTemplate:i,viewModel:{view:r},readOnly:a}=this.data,s=this._featureFormViewModel=new h({activeAssociation:e,editType:"UPDATE",feature:this.fullFeature,formTemplate:i,highlightHelper:this._highlightHelper,map:r?.map,spatialReference:r.spatialReference,timeZone:r?.timeZone,disabled:a});s.callbacks={...this.data.featureFormCallbacks,showAllRelatedRecords:e=>s.relationshipId=e.relationshipId,viewAssociatedLayers:e=>s.associationId=e.associationId,viewAssociatedFeatures:e=>s.associatedLayer=e.associatedLayer};const{initialFeature:l}=t;l&&s.overrideInitialFeature(l),this.addHandles([s.on("value-change",(()=>{t.updateAttributes(s.getValues()),this.fullFeature.attributes=t.feature.attributes})),o((()=>r?.timeZone),(e=>s.timeZone=e))])}_onFullFeatureLoaded(e){this.fullFeature=e;const{edits:t}=this.data;t.updateAttributes(e.attributes),t.trackChanges()}static async create(e){const t=new p({data:await c.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}static _createWorkflowSteps(e){const{attachmentsViewModel:t}=e.data.viewModel;return[{id:"editing-attributes",async setUp(){},async tearDown(){}},{id:"adding-attachment",async setUp(){},async tearDown(){t.mode="view"}},{id:"editing-attachment",async setUp(){},async tearDown(){t.mode="view"}}]}static{this._onCommitFactory=e=>async t=>{const{edits:i}=t,{feature:r}=i;if(!r)return;const a=r.sourceLayer,o=r.clone();if(!i.attributesModified||i.stagedForDelete){const e=a.objectIdField;if(o.attributes={[e]:r.getAttribute(e)},"scene"===a.type&&null!=a.infoFor3D){const e=a.associatedLayer?.globalIdField;null!=e&&o.setAttribute(e,r.getAttribute(e))}}i.geometryModified&&!i.stagedForDelete||(o.geometry=null);const s=i.stagedForDelete?"deleteFeatures":"updateFeatures";await e(a,{[s]:[o]})}}};e([s()],g.prototype,"_featureFormViewModel",void 0),e([s()],g.prototype,"editorItem",null),e([s()],g.prototype,"featureFormViewModel",null),e([s()],g.prototype,"fullFeature",void 0),e([s()],g.prototype,"hasPendingEdits",null),e([s()],g.prototype,"layer",null),e([s()],g.prototype,"parent",null),e([s()],g.prototype,"parentLayer",null),e([s()],g.prototype,"shouldShowAttachments",null),e([s()],g.prototype,"shouldAllowAttachmentEditing",null),e([s()],g.prototype,"reliesOnOwnerAdminPrivileges",null),g=p=e([l("esri.widgets.Editor.UpdateRecordWorkflow")],g);export{g as UpdateRecordWorkflow,f as handleKeys};
@@ -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"../../core/Accessor.js";import o from"../../core/Error.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 s}from"../../core/accessorSupport/decorators/subclass.js";import i from"./Edits.js";var a;let p=a=class extends e{constructor(t){super(t),this.association=null,this.editorItem=null,this.edits=null,this.parent=null,this.featureFormCallbacks=null,this.viewModel=null}get attachmentsCapabilities(){const t=this.editorItem.capabilities.update.attachments.enabled;return{editing:!0,operations:{add:t,update:t,delete:t}}}get formTemplate(){return this.editorItem.formTemplate}static async create(t){const e=a._makeConstructorProps(t);return new a(e)}static _makeConstructorProps(t){const{association:e,feature:r,parent:s,featureFormCallbacks:a,viewModel:p}=t,c=p.editorItems.find((t=>t.layer===r.layer));if(!c)throw new o("no-editorItem-found","The EditorViewModel provided did not have an EditorItem associated with the specified Graphic's layer");return{association:e,editorItem:c,edits:new i({feature:r}),parent:s,featureFormCallbacks:a,viewModel:p}}};t([r()],p.prototype,"association",void 0),t([r()],p.prototype,"attachmentsCapabilities",null),t([r({constructOnly:!0})],p.prototype,"editorItem",void 0),t([r()],p.prototype,"edits",void 0),t([r()],p.prototype,"formTemplate",null),t([r()],p.prototype,"parent",void 0),t([r()],p.prototype,"featureFormCallbacks",void 0),t([r()],p.prototype,"viewModel",void 0),p=a=t([s("esri.widgets.Editor.UpdateRecordWorkflowData")],p);const c=p;export{c as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import o from"../../core/Error.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 s}from"../../core/accessorSupport/decorators/subclass.js";import a from"./Edits.js";var i;let p=i=class extends e{constructor(t){super(t),this.association=null,this.editorItem=null,this.edits=null,this.parent=null,this.featureFormCallbacks=null,this.viewModel=null,this.readOnly=!1}get attachmentsCapabilities(){const t=this.editorItem.capabilities.update.attachments.enabled;return{editing:!0,operations:{add:t,update:t,delete:t}}}get formTemplate(){return this.editorItem.formTemplate}static async create(t){const e=i._makeConstructorProps(t);return new i(e)}static _makeConstructorProps(t){const{association:e,feature:r,parent:s,featureFormCallbacks:i,viewModel:p,readOnly:d}=t,l=p.editorItems.find((t=>t.layer===r.layer));if(!l)throw new o("no-editorItem-found","The EditorViewModel provided did not have an EditorItem associated with the specified Graphic's layer");return{association:e,editorItem:l,edits:new a({feature:r}),parent:s,featureFormCallbacks:i,viewModel:p,readOnly:d}}};t([r()],p.prototype,"association",void 0),t([r()],p.prototype,"attachmentsCapabilities",null),t([r({constructOnly:!0})],p.prototype,"editorItem",void 0),t([r()],p.prototype,"edits",void 0),t([r()],p.prototype,"formTemplate",null),t([r()],p.prototype,"parent",void 0),t([r()],p.prototype,"featureFormCallbacks",void 0),t([r()],p.prototype,"viewModel",void 0),t([r()],p.prototype,"readOnly",void 0),p=i=t([s("esri.widgets.Editor.UpdateRecordWorkflowData")],p);const d=p;export{d 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{debounce as s,createResolver as n,onAbort as l,createAbortError as d,throwIfAborted as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,watch as h,sync as w,when 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 V}from"./UpdateRecordWorkflow.js";import j from"./UpdateWorkflowData.js";import U from"./Workflow.js";import{createWorkflowSteps as P,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 U{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 j({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(){const{activeFeatureFormViewModel:e}=this;if(e){if(e.submit(),!e.submittable||e.pendingSubtypeChoice)return;const t=e.getValues();if(e.validateContingencyConstraints(t,{includeIncompleteViolations:!0}).length>0)return}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)?V: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 P(["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 s=null;e.addHandles(i((()=>{s=r(s)})),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",(async i=>{const r=n();e._updatingHandles.addPromise(r.promise);try{t.location=i.mapPoint,t.visible=!0,s?.abort();const{editorItems:r}=o.viewModel;s=new AbortController;const n=await i.defer((()=>new Promise(((e,t)=>{l(s?.signal,(()=>t(d()))),e(R(r,a,i,s?.signal))}))));if(c(s),o.candidates=n.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=f((()=>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)}),w),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=s((async()=>{await u((()=>!e.updating)),e.previous()}));e.addHandles([h((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&o()}),w)],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};
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{debounce as s,createResolver as n,onAbort as l,createAbortError as d,throwIfAborted as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,watch as h,sync as w,when 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 V}from"./UpdateRecordWorkflow.js";import j from"./UpdateWorkflowData.js";import U from"./Workflow.js";import{createWorkflowSteps as P,fetchCandidates as R}from"./workflowUtils.js";import{findUtilityNetwork as L,isGraphicForRelatableFeatureSupportedLayer as O}from"../Feature/support/featureUtils.js";var x;let T=x=class extends U{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&&!a?.disabled){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 x({data:new j({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(){const{activeFeatureFormViewModel:e}=this;if(e){if(e.submit(),!e.submittable||e.pendingSubtypeChoice)return;const t=e.getValues();if(e.validateContingencyConstraints(t,{includeIncompleteViolations:!0}).length>0)return}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,i=!1){try{const a=await this._createNestedUpdateWorkflow(e,i,t);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 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,a){const i=A(e.sourceLayer)?V:E,{applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data,d="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,c=await i.create({association:a,feature:e,parent:d,sketchOptions:s,snappingManager:n,viewModel:l,readOnly:t,applyEdits:o,applyEditsFeatureService:r,featureFormCallbacks:{addRelatedRecord:async e=>await this._updatingHandles.addPromise(this.startCreatingRelatedRecord(e)),editRelatedRecord:async({relatedFeature:e,readOnly:t})=>await this._updatingHandles.addPromise(this.startUpdating(e,void 0,t)),selectAssociatedFeature:async({feature:e,association:a})=>await this._updatingHandles.addPromise(this.startUpdating(e,a,t)),addAssociation:async e=>await this._updatingHandles.addPromise(this.startAddAssociation(e.feature,e.utilityNetwork,e.associationType))}});return await u((()=>!c.updating)),c}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(!O(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=H(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=H(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 P(["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 s=null;e.addHandles(i((()=>{s=r(s)})),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",(async i=>{const r=n();e._updatingHandles.addPromise(r.promise);try{t.location=i.mapPoint,t.visible=!0,s?.abort();const{editorItems:r}=o.viewModel;s=new AbortController;const n=await i.defer((()=>new Promise(((e,t)=>{l(s?.signal,(()=>t(d()))),e(R(r,a,i,s?.signal))}))));if(c(s),o.candidates=n.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=f((()=>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)}),w),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=s((async()=>{await u((()=>!e.updating)),e.previous()}));e.addHandles([h((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&o()}),w)],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 H(e,{keyField:t}){return e.getField(t)?.name??t}e([v()],T.prototype,"activeEditorItem",null),e([v()],T.prototype,"activeFeatureFormViewModel",null),e([v()],T.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([v()],T.prototype,"activeSketchViewModel",null),e([v()],T.prototype,"canDeleteAssociation",null),e([v()],T.prototype,"activeWorkflow",null),e([v()],T.prototype,"updating",null),e([v()],T.prototype,"data",void 0),e([v()],T.prototype,"hasPreviousStep",null),e([v()],T.prototype,"hasUpdatableCandidates",null),e([v()],T.prototype,"nestedWorkflowCount",null),e([v()],T.prototype,"shouldShowAttachments",null),e([v()],T.prototype,"shouldAllowAttachmentEditing",null),e([v()],T.prototype,"hasPendingEdits",null),e([v()],T.prototype,"helpMessage",null),e([v()],T.prototype,"reliesOnOwnerAdminPrivileges",null),e([v()],T.prototype,"hasInvalidFormTemplate",null),T=x=e([k("esri.widgets.Editor.UpdateWorkflow")],T);const N=e=>!!e&&/update-/.test(e.type),D=T;export{D 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/Accessor.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 n from"../support/SnappingControls/VisibleElements.js";let l=class extends e{constructor(o){super(o),this.createFeaturesSection=!0,this.directionModePicker=!1,this.editFeaturesSection=!0,this.flow=!0,this.labelsToggle=!0,this.settingsMenu=!0,this.snappingControls=!0,this.snappingControlsElements=new n,this.tooltipsToggle=!0,this.undoRedoButtons=!0,this.sketch=!0,this.zoomToButton=!0}};o([t({type:Boolean,nonNullable:!0})],l.prototype,"createFeaturesSection",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"directionModePicker",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"editFeaturesSection",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"flow",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"labelsToggle",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"settingsMenu",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"snappingControls",void 0),o([t({type:n,nonNullable:!0})],l.prototype,"snappingControlsElements",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"tooltipsToggle",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"undoRedoButtons",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"sketch",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"zoomToButton",void 0),l=o([s("esri.widgets.Editor.VisibleElements")],l);const p=l;export{p as default};
5
+ import{_ as o}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.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 l}from"../../core/accessorSupport/decorators/subclass.js";import n from"../support/SnappingControls/VisibleElements.js";let s=class extends e{constructor(o){super(o),this.batchUpdateActions=!0,this.createFeaturesSection=!0,this.directionModePicker=!1,this.editFeaturesSection=!0,this.flow=!0,this.labelsToggle=!0,this.selectionToolbar=!0,this.settingsMenu=!0,this.sketch=!0,this.snappingControls=!0,this.snappingControlsElements=new n,this.tooltipsToggle=!0,this.undoRedoButtons=!0,this.zoomToButton=!0}};o([t({type:Boolean,nonNullable:!0})],s.prototype,"batchUpdateActions",void 0),o([t({type:Boolean,nonNullable:!0})],s.prototype,"createFeaturesSection",void 0),o([t({type:Boolean,nonNullable:!0})],s.prototype,"directionModePicker",void 0),o([t({type:Boolean,nonNullable:!0})],s.prototype,"editFeaturesSection",void 0),o([t({type:Boolean,nonNullable:!0})],s.prototype,"flow",void 0),o([t({type:Boolean,nonNullable:!0})],s.prototype,"labelsToggle",void 0),o([t({type:Boolean,nonNullable:!0})],s.prototype,"selectionToolbar",void 0),o([t({type:Boolean,nonNullable:!0})],s.prototype,"settingsMenu",void 0),o([t({type:Boolean,nonNullable:!0})],s.prototype,"sketch",void 0),o([t({type:Boolean,nonNullable:!0})],s.prototype,"snappingControls",void 0),o([t({type:n,nonNullable:!0})],s.prototype,"snappingControlsElements",void 0),o([t({type:Boolean,nonNullable:!0})],s.prototype,"tooltipsToggle",void 0),o([t({type:Boolean,nonNullable:!0})],s.prototype,"undoRedoButtons",void 0),o([t({type:Boolean,nonNullable:!0})],s.prototype,"zoomToButton",void 0),s=o([l("esri.widgets.Editor.VisibleElements")],s);const p=s;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{isSome as t}from"../../../core/arrayUtils.js";import{loadCalciteComponents as o}from"../../support/componentsUtils.js";import"../../support/widgetUtils.js";import{tsx as i}from"../../support/jsxFactory.js";const e={base:"esri-editor__actions"},n=()=>o({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),"split-button":()=>import("@esri/calcite-components/dist/components/calcite-split-button"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item")});function c({buttons:o,key:n}){return i("div",{class:e.base,key:n??"footer-actions",slot:"footer"},o.filter(t).map(((t,o)=>"split-button"===t.type?l(t,o):s(t,o))))}const s=({disabled:t,onClick:o,label:e,key:n,...c},s)=>i("calcite-button",{disabled:t??!1,key:n??`action-${s}`,onclick:o,width:"full",...c},e),l=({disabled:o,onClick:e,key:n,dropdownItems:c,...s},l)=>i("calcite-split-button",{disabled:o??!1,key:n??`split-action-${l}`,width:"full",onCalciteSplitButtonPrimaryClick:e,...s},i("calcite-dropdown-group",{selectionMode:"none"},c.filter(t).map(p))),p=({disabled:t,onClick:o,label:e,key:n,...c},s)=>i("calcite-dropdown-item",{disabled:t??!1,key:n??`dropdown-item-${s}`,onCalciteDropdownItemSelect:o,...c},e);export{c as FooterActions,e as css,n as loadFooterActionsComponents};
5
+ import{isSome as t}from"../../../core/arrayUtils.js";import{loadCalciteComponents as o}from"../../support/componentsUtils.js";import"../../support/widgetUtils.js";import{tsx as i}from"../../support/jsxFactory.js";const e={base:"esri-editor__actions",notice:"esri-editor__actions--notice"},c=()=>o({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),"split-button":()=>import("@esri/calcite-components/dist/components/calcite-split-button"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon")});function n({buttons:o,key:c,notice:n}){return i("div",{class:e.base,key:c??"footer-actions",slot:"footer"},n?i("div",{class:e.notice},n.icon?i("calcite-icon",{icon:n.icon,scale:"s"}):void 0,i("span",null,n.text)):void 0,i("div",null,o.filter(t).map(((t,o)=>"split-button"===t.type?l(t,o):s(t,o)))))}const s=({disabled:t,onClick:o,label:e,key:c,...n},s)=>i("calcite-button",{disabled:t??!1,key:c??`action-${s}`,onclick:o,width:"full",...n},e),l=({disabled:o,onClick:e,key:c,dropdownItems:n,...s},l)=>i("calcite-split-button",{disabled:o??!1,key:c??`split-action-${l}`,width:"full",onCalciteSplitButtonPrimaryClick:e,...s},i("calcite-dropdown-group",{selectionMode:"none"},n.filter(t).map(p))),p=({disabled:t,onClick:o,label:e,key:c,...n},s)=>i("calcite-dropdown-item",{disabled:t??!1,key:c??`dropdown-item-${s}`,onCalciteDropdownItemSelect:o,...n},e);export{n as FooterActions,e as css,c as loadFooterActionsComponents};
@@ -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{substitute as e}from"../../../intl/substitute.js";import{isUpdateFeaturesWorkflow as t,isBatchAttributeFormViewModel as o}from"../workflowUtils.js";import{loadFooterActionsComponents as i,FooterActions as n}from"./FooterActions.js";import{loadNoticesComponents as a,Notices as s}from"./Notices.js";import{loadPanelContentComponents as r,PanelContentSection as l,PanelContentSectionGroup as u,PanelContent as d}from"./PanelContent.js";import c from"./PendingFeatureList.js";import{Heading as p,incrementHeadingLevel as m}from"../../support/Heading.js";import"../../support/widgetUtils.js";import{tsx as f,tsxFragment as g}from"../../support/jsxFactory.js";const h=()=>Promise.all([i(),a(),r()]);function w({editorViewModel:i,headingLevel:a,messages:r,messagesCommon:h,onDelete:w,onDeleteAssociation:y,onSave:b,renderAttachments:v,renderFeatureForm:k,renderBatchAttributeForm:F,renderSketchToolbar:A}){const{activeLeafWorkflow:j,activeWorkflow:C,formViewModel:S,syncing:L}=i;if(!j||!C||!S)return null;const P=j.type.includes("update"),D=o(S),H=P&&!j.hasPendingEdits||L||S.updating,I=P?h.update:h.create,T="create-features"===j?.type?j.numPendingFeaturesExcludingHidden:0,x="create-features"!==j?.type||!!j.data.selectedPendingFeature,B=T>1?e(r.createFeaturesTemplate,{numFeatures:T}):I,M="shouldShowAttachments"in j&&j.shouldShowAttachments&&!D&&!S.activeRelationshipInput&&!S.activeAssociationInput,V=(D?S.activeForm.inputs:S.inputs).every((e=>!e.visible))&&!M,E=t(j)?F:k,U=V?f(l,null,"create-features"===j.type?f(c,{headingLevel:a,key:"pending-feature-list",workflow:j}):void 0):f(l,{key:"panel-content-section"},f(s,{messages:r,workflow:C}),f(u,null,x||"create-features"!==j.type?E():f(c,{headingLevel:a,key:"pending-feature-list",workflow:j}),M?f("div",{key:"attachments"},f(p,{level:m(a)},r.attachments),v()):null)),W=()=>{const{featureFormViewModel:e}=i;null!=e?.associationId&&(e.associationId=null)},N={appearance:"solid",onClick:b,disabled:H,label:B,type:"button"},R={appearance:"outline",onClick:w,disabled:L,kind:"danger",label:h.delete,type:"button"},q={...R,onClick:y,label:r.deleteAssociationTitle,type:"button"},z={...R,primaryLabel:h.delete,primaryText:h.delete,dropdownItems:[{onClick:y,label:r.deleteAssociationTitle}],type:"split-button"},G={appearance:"outline",onClick:W,disabled:L,label:h.cancel,type:"button"},J="viewing-associated-features"===i.page||"viewing-associated-layers"===i.page?[G]:[N,i.shouldShowDeleteButton&&!i.featureFormHasAssociation?R:void 0,i.shouldShowDeleteButton&&i.featureFormHasAssociation?z:void 0,!i.shouldShowDeleteButton&&i.featureFormHasAssociation?q:void 0];return f(g,null,V?A?.():void 0,f(d,{key:"attribute-panel-content"},U),f(n,{buttons:J}))}export{w as UpdateFeaturePanelContent,h as loadUpdateFeaturePanelContentComponents};
5
+ import{substitute as e}from"../../../intl/substitute.js";import{isUpdateFeaturesWorkflow as t,isBatchAttributeFormViewModel as o}from"../workflowUtils.js";import{loadFooterActionsComponents as i,FooterActions as a}from"./FooterActions.js";import{loadNoticesComponents as n,Notices as s}from"./Notices.js";import{loadPanelContentComponents as l,PanelContentSection as r,PanelContentSectionGroup as d,PanelContent as u}from"./PanelContent.js";import c from"./PendingFeatureList.js";import{Heading as p,incrementHeadingLevel as m}from"../../support/Heading.js";import"../../support/widgetUtils.js";import{tsx as f,tsxFragment as g}from"../../support/jsxFactory.js";const h=()=>Promise.all([i(),n(),l()]);function w({editorViewModel:i,headingLevel:n,messages:l,messagesCommon:h,onDelete:w,onDeleteAssociation:b,onSave:y,renderAttachments:v,renderFeatureForm:k,renderBatchAttributeForm:F,renderSketchToolbar:A}){const{activeLeafWorkflow:j,activeWorkflow:C,formViewModel:S,syncing:L}=i;if(!j||!C||!S)return null;const P=j.type.includes("update"),D=o(S),H=P&&!j.hasPendingEdits||L||S.updating||S.disabled,I=P?h.update:h.create,T="create-features"===j?.type?j.numPendingFeaturesExcludingHidden:0,x="create-features"!==j?.type||!!j.data.selectedPendingFeature,B=T>1?e(l.createFeaturesTemplate,{numFeatures:T}):I,M="shouldShowAttachments"in j&&j.shouldShowAttachments&&!D&&!S.activeRelationshipInput&&!S.activeAssociationInput,V=(D?S.activeForm.inputs:S.inputs).every((e=>!e.visible))&&!M,E=t(j)?F:k,U=V?f(r,null,"create-features"===j.type?f(c,{headingLevel:n,key:"pending-feature-list",workflow:j}):void 0):f(r,{key:"panel-content-section"},f(s,{messages:l,workflow:C}),f(d,null,x||"create-features"!==j.type?E():f(c,{headingLevel:n,key:"pending-feature-list",workflow:j}),M?f("div",{key:"attachments"},f(p,{level:m(n)},l.attachments),v()):null)),W=()=>{const{featureFormViewModel:e}=i;null!=e?.associationId&&(e.associationId=null)},N={appearance:"solid",onClick:y,disabled:H,label:B,type:"button"},R={appearance:"outline",onClick:w,disabled:L,kind:"danger",label:h.delete,type:"button"},q={...R,onClick:b,label:l.deleteAssociationTitle,type:"button"},z={...R,primaryLabel:h.delete,primaryText:h.delete,dropdownItems:[{onClick:b,label:l.deleteAssociationTitle}],type:"split-button"},G={appearance:"outline",onClick:W,disabled:L,label:h.cancel,type:"button"},J="viewing-associated-features"===i.page||"viewing-associated-layers"===i.page?[G]:[N,i.shouldShowDeleteButton&&!i.featureFormHasAssociation?R:void 0,i.shouldShowDeleteButton&&i.featureFormHasAssociation?z:void 0,!i.shouldShowDeleteButton&&i.featureFormHasAssociation?q:void 0];return f(g,null,V?A?.():void 0,f(u,{key:"attribute-panel-content"},U),f(a,{buttons:J}))}export{w as UpdateFeaturePanelContent,h as loadUpdateFeaturePanelContentComponents};
@@ -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
- const e="esri-editor",t={base:e,helpMessage:`${e}__help-message`,updateActions:`${e}__update-actions`,updateActionsList:`${e}__update-actions-list`,featureTemplatesContainer:`${e}__feature-templates-container`,templateItemContentEnd:`${e}__template-item-content-end`,sketchContainer:`${e}__sketch-container`,pendingFeatureListIcon:`${e}__pending-feature-list-icon`};export{t as css};
5
+ const e="esri-editor",t={base:e,helpMessage:`${e}__help-message`,updateActions:`${e}__update-actions`,updateActionsList:`${e}__update-actions-list`,featureTemplatesContainer:`${e}__feature-templates-container`,templateItemContentEnd:`${e}__template-item-content-end`,sketchContainer:`${e}__sketch-container`,pendingFeatureListIcon:`${e}__pending-feature-list-icon`,selectionToolbarContainer:`${e}__selection-toolbar-container`};export{t as css};