@arcgis/core 5.0.0-next.7 → 5.0.0-next.9

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 (365) hide show
  1. package/applications/KnowledgeStudio/resourceSerializationUtils.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{8f56f298e7c1a283f407.js → 0030d68d9edf42b4af57.js} +1 -1
  4. package/assets/esri/core/workers/chunks/01d460398f3ba6767a37.js +1 -0
  5. package/assets/esri/core/workers/chunks/02e7359162cf974b41b6.js +1 -0
  6. package/assets/esri/core/workers/chunks/{17d5f8dba6ebb1184506.js → 042cd64e1f4eb326c30f.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{66db5f77e09d25e33951.js → 063905fbf9a0c6586949.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{9486032af3e934d85582.js → 0a5d74414dd02a2fb8e1.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{3815ffa13e7b439bca6e.js → 0d5212f59e9b62c16164.js} +1 -1
  10. package/assets/esri/core/workers/chunks/0f735b0dec173142f3b6.js +2 -0
  11. package/assets/esri/core/workers/chunks/{a8f998b8ec8c56150479.js.LICENSE.txt → 0f735b0dec173142f3b6.js.LICENSE.txt} +1 -1
  12. package/assets/esri/core/workers/chunks/{73487b9d85e726e9c012.js → 1257c37bf04d39c27b62.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{398f356b11fd33bd3831.js → 136a7d781dad05a7463b.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{1e4e7aedf4b779241a02.js → 15c7c10ff9ac63f0e792.js} +1 -1
  15. package/assets/esri/core/workers/chunks/17784cf16fa91504b9ea.js +1 -0
  16. package/assets/esri/core/workers/chunks/{a395373e3173e6458a56.js → 1ab37e13947d0e2e4181.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{f03635ddf56e2ef90e4c.js → 1d06fcae4c2f02fb1c95.js} +1 -1
  18. package/assets/esri/core/workers/chunks/1dfca37f95f2b968aa54.js +1 -0
  19. package/assets/esri/core/workers/chunks/{5bd36dbf46c25bd961c8.js → 21293b0c6405a10ec7b6.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{285762ff92d5388b6024.js → 2166238a7ad63a2d43c7.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{620a94b54be3ed78350d.js → 22ca80f491e070b2a5e7.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{88074189fa10c335370b.js → 24cd7b84cd0f3de4bff2.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{ccc0da0e01f023c8aa1f.js → 28d1f2cf6aae547615c3.js} +1 -1
  24. package/assets/esri/core/workers/chunks/292daac70bb828e4923f.js +1 -0
  25. package/assets/esri/core/workers/chunks/{7e43c105f1cfc44b7bd0.js → 2fa01bd3f3608616fd7f.js} +1 -1
  26. package/assets/esri/core/workers/chunks/30e220f4f843681a4cdd.js +1 -0
  27. package/assets/esri/core/workers/chunks/{5d3661d1fe46dd29aae9.js → 311b564e44ae637c960d.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{f4d0ae6be1b3984228d0.js → 31b6406960261da21dd4.js} +1 -1
  29. package/assets/esri/core/workers/chunks/31c7ce65e16f7858400f.js +1 -0
  30. package/assets/esri/core/workers/chunks/31dbe07047dc61303d7d.js +1 -0
  31. package/assets/esri/core/workers/chunks/{8a314b3790313e6dc5db.js → 333b62dad3811cff0f14.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{c8733cd621105afab2ac.js → 35c9b24e4430bd6c2b6b.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{e31192ae920e3e19b6aa.js → 37c1f155da14de91565a.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{c55c096669677321a227.js → 38cd3648932bf2534b0f.js} +1 -1
  35. package/assets/esri/core/workers/chunks/3a457e718a901a45902e.js.LICENSE.txt +1 -1
  36. package/assets/esri/core/workers/chunks/{f5e47eea8720ba84665b.js → 3c07aa2015ab1dff5f7b.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{e9311386f58f3cb95c22.js → 42a1e71d09e8583a7327.js} +1 -1
  38. package/assets/esri/core/workers/chunks/443dfe7029ec208f670c.js +1 -0
  39. package/assets/esri/core/workers/chunks/{b75930d60449eceb0f1c.js → 4baf6f6e7ddedb25f806.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{bb5484b5eeacc9ad2ceb.js → 4d0cbf9584446f411a37.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{17103e6542aae53c7301.js → 4e3e27673d0671fc2b58.js} +1 -1
  42. package/assets/esri/core/workers/chunks/4fb5f1c671892001a4fd.js +1 -0
  43. package/assets/esri/core/workers/chunks/{5fc7b61f467f1d60a284.js → 51ab2acac4ecc1ca9c34.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{fc4417d1260b717a9385.js → 52282f767bd0e99ddca0.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{dedc4583b5f32a278124.js → 5350d50b47b6a4e0e169.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{fc06014fb484fc8c697e.js → 53654edd766d9b4ef750.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{90f8b4bda28af43ea019.js → 538f509d7fc8337d37ac.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{ed8a85efbd90241512bb.js → 588533c3abe876f20f62.js} +1 -1
  49. package/assets/esri/core/workers/chunks/58e59ead33368ce38c8f.js +1 -0
  50. package/assets/esri/core/workers/chunks/5db37547963857295273.js +1 -0
  51. package/assets/esri/core/workers/chunks/{72846fb9c87c6642daf0.js → 5e2ce34def5e053913b2.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{8c056eac35d05d9524b7.js → 5f29422a051311ef9b3c.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{ac26e3e77df4302f47a2.js → 604777417722d4effe06.js} +1 -1
  54. package/assets/esri/core/workers/chunks/{ff35a077ac6776469805.js → 61d970ed75c2c358b1e9.js} +1 -1
  55. package/assets/esri/core/workers/chunks/{7a6a96edc892d7060b7d.js → 629127877042ad784ad2.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{90b2b43b8b54c9a1ec35.js → 664ae441617afe4b17ec.js} +1 -1
  57. package/assets/esri/core/workers/chunks/67f03d042455cd0f7009.js +1 -0
  58. package/assets/esri/core/workers/chunks/{4c5a7249a311070d8f43.js → 6af18d7a0d314d7c1756.js} +1 -1
  59. package/assets/esri/core/workers/chunks/{f35aaa04cca676c2d3f8.js → 6b59f94040c7d2f6728a.js} +1 -1
  60. package/assets/esri/core/workers/chunks/6d9f2b113d6bde936a04.js +1 -0
  61. package/assets/esri/core/workers/chunks/{5132ca68e8c7af111a47.js → 6e22b02a9715c10578d0.js} +1 -1
  62. package/assets/esri/core/workers/chunks/{f0e0a63962784acb4ba1.js → 6f0aec7428021e440ac9.js} +1 -1
  63. package/assets/esri/core/workers/chunks/{deb2854bb7d082a26f52.js → 7005d956c990a04ee8b2.js} +1 -1
  64. package/assets/esri/core/workers/chunks/{a3991ae8caa713d4ddcd.js → 731f7b552dde0fb325cd.js} +1 -1
  65. package/assets/esri/core/workers/chunks/7565b382f6b3d2cb46a3.js +2 -0
  66. package/assets/esri/core/workers/chunks/{b96eb0ea506379182d62.js.LICENSE.txt → 7565b382f6b3d2cb46a3.js.LICENSE.txt} +1 -1
  67. package/assets/esri/core/workers/chunks/{464d42bebb365287808d.js → 773f2c6c9d38db76dfed.js} +1 -1
  68. package/assets/esri/core/workers/chunks/{3f3d492f1093b7832aab.js → 7803495f8862d9025bcd.js} +1 -1
  69. package/assets/esri/core/workers/chunks/7d641f2f5edd95b9bc18.js +1 -0
  70. package/assets/esri/core/workers/chunks/7e4c14d4502e3f06d94b.js +1 -0
  71. package/assets/esri/core/workers/chunks/812f2ccc01f44e3cfd41.js +1 -0
  72. package/assets/esri/core/workers/chunks/826fa0dfb63df77bfd95.js +1 -0
  73. package/assets/esri/core/workers/chunks/{7544316a75dbd981aea6.js → 86cb097deec50b0da3f3.js} +1 -1
  74. package/assets/esri/core/workers/chunks/87921f3fa9001f5801ed.js +1 -0
  75. package/assets/esri/core/workers/chunks/{95c594a87b732f5c4979.js → 89b748e064ca90b4f76a.js} +1 -1
  76. package/assets/esri/core/workers/chunks/8a40ed2ee4b032822c30.js +1 -0
  77. package/assets/esri/core/workers/chunks/{09de8be660174a229efb.js → 8cbb28476151a37ae958.js} +1 -1
  78. package/assets/esri/core/workers/chunks/{fe77ae6cf232a7a3298e.js → 8d9d3797c6d62fdfff9d.js} +1 -1
  79. package/assets/esri/core/workers/chunks/{62a49cfd9a2508950e9f.js → 8fedfd33c37172dba6bf.js} +1 -1
  80. package/assets/esri/core/workers/chunks/91aa1157da32f650983b.js +1 -0
  81. package/assets/esri/core/workers/chunks/{e7638b9ab6674bc8a18f.js → 91dfd29e2dba200eab09.js} +1 -1
  82. package/assets/esri/core/workers/chunks/{794748fd1edc29a621cd.js → 9698f36c143953a975d4.js} +1 -1
  83. package/assets/esri/core/workers/chunks/98584902c9db6faa3e4d.js +1 -0
  84. package/assets/esri/core/workers/chunks/9e5e05d6430712b0b1bc.js +1 -0
  85. package/assets/esri/core/workers/chunks/{e5a06ce0ef6a9a90e100.js → 9f21436016ff7a899e79.js} +1 -1
  86. package/assets/esri/core/workers/chunks/{67d9cfe02613cb73ee37.js → 9ff8ee6ed6b98c03ae7e.js} +2 -2
  87. package/assets/esri/core/workers/chunks/{67d9cfe02613cb73ee37.js.LICENSE.txt → 9ff8ee6ed6b98c03ae7e.js.LICENSE.txt} +1 -1
  88. package/assets/esri/core/workers/chunks/a6ee40dfc471d6612f3c.js +1 -0
  89. package/assets/esri/core/workers/chunks/aa78b69219d9a0ef1c54.js.LICENSE.txt +1 -1
  90. package/assets/esri/core/workers/chunks/{a4db5c9a90107e097df8.js → af47272aaaef0ea57e71.js} +1 -1
  91. package/assets/esri/core/workers/chunks/b05208d56a724a8f1661.js +1 -0
  92. package/assets/esri/core/workers/chunks/{79968c183135281d2a6f.js → b3613a38178cad2ebc82.js} +1 -1
  93. package/assets/esri/core/workers/chunks/{22d6b8102e75bdef204c.js → b7eb486354994dc70855.js} +1 -1
  94. package/assets/esri/core/workers/chunks/bc19a232076d98825eef.js +1 -0
  95. package/assets/esri/core/workers/chunks/c29486c4eeb3e72effff.js +1 -0
  96. package/assets/esri/core/workers/chunks/{2b94623cabc6ae0f86ce.js → c37f7756d48ff9af2656.js} +1 -1
  97. package/assets/esri/core/workers/chunks/{1c52999a6392370844a6.js → c4090a60d149a5962179.js} +1 -1
  98. package/assets/esri/core/workers/chunks/c715fd32f814a0f14f40.js +1 -0
  99. package/assets/esri/core/workers/chunks/{73c1d43070b4fe1e5c1e.js → c8e686efe344a33a0258.js} +1 -1
  100. package/assets/esri/core/workers/chunks/{6bb5158de43c4b59107f.js → c9b16fd41cd59d452522.js} +1 -1
  101. package/assets/esri/core/workers/chunks/ce16489cf7eb0d78c741.js.LICENSE.txt +1 -1
  102. package/assets/esri/core/workers/chunks/cf971e7b1b98d9c502d3.js +1 -0
  103. package/assets/esri/core/workers/chunks/{279366e6b743f9680603.js → cfff044859e6e6dcc75d.js} +1 -1
  104. package/assets/esri/core/workers/chunks/d07f911d40bf05fc0306.js +1 -0
  105. package/assets/esri/core/workers/chunks/{8833c3d168951be4bf20.js → d0d79dd3e88eecf5c314.js} +1 -1
  106. package/assets/esri/core/workers/chunks/d1ca7c3a32ce00ed8b81.js +1 -0
  107. package/assets/esri/core/workers/chunks/{76ae1702fecc7ad7017c.js → d1e97cce5047f1791e22.js} +1 -1
  108. package/assets/esri/core/workers/chunks/{17acde0245ecd956306c.js → d233cc33497a663450f9.js} +1 -1
  109. package/assets/esri/core/workers/chunks/{b017bac40dc8328013e3.js → d391bfbaf0e790cd10d6.js} +2 -2
  110. package/assets/esri/core/workers/chunks/{b017bac40dc8328013e3.js.LICENSE.txt → d391bfbaf0e790cd10d6.js.LICENSE.txt} +1 -1
  111. package/assets/esri/core/workers/chunks/d6e0528eacee7ea4c1ce.js.LICENSE.txt +1 -1
  112. package/assets/esri/core/workers/chunks/{36fe6b8228e622407ec2.js → d8793eead02491136841.js} +1 -1
  113. package/assets/esri/core/workers/chunks/{4d599008e1ea42321b37.js → da24ad57747714ac5eda.js} +1 -1
  114. package/assets/esri/core/workers/chunks/db678a6e352275e507a9.js +1 -0
  115. package/assets/esri/core/workers/chunks/{facb3886714222772ab2.js → ddfd01bb9ba8577c3ffc.js} +1 -1
  116. package/assets/esri/core/workers/chunks/de2ebd9cc3d9e68d435b.js +1 -0
  117. package/assets/esri/core/workers/chunks/{50d9f69d5255af4b29bb.js → df5afa06c6deb6b40109.js} +1 -1
  118. package/assets/esri/core/workers/chunks/e25c4b4a03270d48f408.js +1 -0
  119. package/assets/esri/core/workers/chunks/e3294318daf1192b8319.js +1 -0
  120. package/assets/esri/core/workers/chunks/e599125e746c27de106e.js +1 -0
  121. package/assets/esri/core/workers/chunks/{da573ecc68e6aa8f6da9.js → e767f83f9e2de6650f80.js} +1 -1
  122. package/assets/esri/core/workers/chunks/e9d4cae2144974489d6e.js +1 -0
  123. package/assets/esri/core/workers/chunks/{91df8638b8b904e6d8c5.js → ead8d0cbcebd12dbfad7.js} +1 -1
  124. package/assets/esri/core/workers/chunks/{f9324e88c359c03f35aa.js → eb9c166db0db6fa60e95.js} +1 -1
  125. package/assets/esri/core/workers/chunks/ebcc94234d9d4be1941f.js +316 -0
  126. package/assets/esri/core/workers/chunks/ee5f0fd5384caa11c986.js +1 -0
  127. package/assets/esri/core/workers/chunks/{bc241c7735e4efba734a.js → f34e3fa0c5b28531e289.js} +1 -1
  128. package/assets/esri/core/workers/chunks/f64037a88ab03662dc2a.js +1 -0
  129. package/assets/esri/core/workers/chunks/f651c05604eab83aef5f.js.LICENSE.txt +1 -1
  130. package/assets/esri/core/workers/chunks/{d97fadbc69e055d183a0.js → f77f4bd6a577b92cf66f.js} +1 -1
  131. package/assets/esri/core/workers/chunks/f80f5dbf96c343ac4df6.js +1 -0
  132. package/assets/esri/core/workers/chunks/{16d66770ef841564ee3f.js → f89c90f98c85667b0ebc.js} +1 -1
  133. package/assets/esri/core/workers/chunks/{4c4227b0ea21a5e429ab.js → fb192de7e4fa152342bb.js} +1 -1
  134. package/assets/esri/core/workers/chunks/fbd8d2f61f8a15bcf3db.js +1 -0
  135. package/assets/esri/core/workers/chunks/fccd931f95d81ecc57b2.js +1 -0
  136. package/assets/esri/core/workers/chunks/{2f78861afe0e9037dd8d.js → fe49321dca22dc60d105.js} +1 -1
  137. package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
  138. package/assets/esri/themes/base/widgets/_NavigationToggle.scss +1 -1
  139. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +4 -4
  140. package/assets/esri/themes/base/widgets/_Widget.scss +1 -1
  141. package/assets/esri/themes/dark/main.css +1 -1
  142. package/assets/esri/themes/light/main.css +1 -1
  143. package/assets/esri/themes/light/view.css +1 -1
  144. package/chunks/MultiPathImpl.js +1 -1
  145. package/chunks/Point2D.js +1 -1
  146. package/chunks/UnitFactory.js +1 -1
  147. package/config.js +1 -1
  148. package/core/QueueProcessor.js +1 -1
  149. package/core/SetUtils.js +1 -1
  150. package/core/has.js +1 -1
  151. package/form/FormTemplate.js +1 -1
  152. package/form/elements/Element.js +1 -1
  153. package/form/elements/FieldElement.js +1 -1
  154. package/form/elements/GroupElement.js +1 -1
  155. package/geometry/operators/gx/operatorOffset.js +1 -1
  156. package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
  157. package/identity/Credential.js +1 -1
  158. package/identity/IdentityManager.js +1 -1
  159. package/identity/IdentityManagerBase.js +1 -1
  160. package/interfaces.d.ts +92 -50
  161. package/kernel.js +1 -1
  162. package/layers/FeatureLayer.js +1 -1
  163. package/layers/SceneLayer.js +1 -1
  164. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  165. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  166. package/layers/graphics/sources/connections/GeoEventConnection.js +1 -1
  167. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  168. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  169. package/layers/knowledgeGraph/layerUtils.js +1 -1
  170. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  171. package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
  172. package/layers/support/RasterJobHandler.js +1 -1
  173. package/layers/support/RasterWorker.js +1 -1
  174. package/layers/support/fieldConfigUtils.js +1 -1
  175. package/layers/support/rasterDatasets/pixelReader.js +1 -1
  176. package/layers/support/rasterFunctions/pixelTransformUtils.js +5 -0
  177. package/layers/support/rasterFunctions/pixelUtils.js +1 -1
  178. package/layers/support/source/DataLayerSource.js +1 -1
  179. package/package.json +4 -4
  180. package/popup/FieldInfo.js +1 -1
  181. package/processRequest.js +5 -0
  182. package/request.js +1 -1
  183. package/requestConfig.js +5 -0
  184. package/requestQueue.js +5 -0
  185. package/rest/query/executeForCount.js +1 -1
  186. package/rest/query/executeForExtent.js +1 -1
  187. package/rest/query/executeForIds.js +1 -1
  188. package/rest/query/executeQueryJSON.js +1 -1
  189. package/rest/query/executeQueryPBF.js +1 -1
  190. package/rest/query/operations/query.js +1 -1
  191. package/rest/support/BaseImageMeasureResultValue.js +5 -0
  192. package/rest/support/ImageAreaResult.js +1 -1
  193. package/rest/support/ImageDistanceResult.js +1 -1
  194. package/rest/support/ImageHeightResult.js +1 -1
  195. package/rest/support/ImageMeasureResultAngleValue.js +5 -0
  196. package/rest/support/ImageMeasureResultAreaValue.js +5 -0
  197. package/rest/support/ImageMeasureResultLengthValue.js +5 -0
  198. package/rest/support/ImageWithType.js +5 -0
  199. package/rest/support/imageMeasureUtils.js +1 -1
  200. package/smartMapping/renderers/size.js +1 -1
  201. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  202. package/smartMapping/support/adapters/InMemoryLayerAdapter.js +1 -1
  203. package/smartMapping/support/adapters/support/histogramUtils.js +1 -1
  204. package/smartMapping/support/adapters/support/utils.js +1 -1
  205. package/support/revision.js +1 -1
  206. package/symbols/support/utils.js +1 -1
  207. package/views/2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js +1 -1
  208. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  209. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  210. package/views/2d/layers/features/schema/SourceSchema.js +1 -1
  211. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  212. package/views/2d/layers/features/sources/strategies/AFeatureLoadStrategy.js +1 -1
  213. package/views/2d/layers/features/sources/strategies/ALoadStrategy.js +1 -1
  214. package/views/2d/layers/features/sources/strategies/ParquetSnapshotLoadStrategy.js +1 -1
  215. package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
  216. package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
  217. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  218. package/views/{3d/support/ImageWithType.js → 2d/layers/features/sources/strategies/constants.js} +1 -1
  219. package/views/2d/layers/features/sources/strategies/support/queryAdapters.js +1 -1
  220. package/views/3d/GroundView3D.js +1 -1
  221. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  222. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  223. package/views/3d/analysis/VolumeMeasurement/volumeMeasurementErrors.js +1 -1
  224. package/views/3d/glTF/DefaultLoadingContext.js +1 -1
  225. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  226. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  227. package/views/3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js +1 -1
  228. package/views/3d/layers/ElevationLayerView3D.js +1 -1
  229. package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
  230. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  231. package/views/3d/layers/graphics/FeatureGraphics3DGraphicsPipeline.js +1 -1
  232. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  233. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  234. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  235. package/views/3d/layers/graphics/Graphics3DSymbolCreationContext.js +1 -1
  236. package/views/3d/layers/graphics/ObjectResourceCache.js +1 -1
  237. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  238. package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
  239. package/views/3d/layers/graphics/pipeline/fetching/Tile3DFetcher.js +1 -1
  240. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  241. package/views/3d/layers/i3s/I3SDataRequester.js +5 -0
  242. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  243. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  244. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  245. package/views/3d/layers/support/FeatureTile.js +1 -1
  246. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  247. package/views/3d/layers/support/MediaLayerInteractionOptions.js +1 -1
  248. package/views/3d/layers/support/MediaLayerInteractionReshapeOptions.js +5 -0
  249. package/views/3d/layers/support/SampledGeometryMaxDistanceRatio.js +5 -0
  250. package/views/3d/layers/support/featureTileQuery3D.js +1 -1
  251. package/views/3d/layers/support/fetchTile.js +1 -1
  252. package/views/3d/support/ResourceController.js +1 -1
  253. package/views/3d/support/SharedSymbolResources.js +1 -1
  254. package/views/3d/support/StreamTextureCollection.js +1 -1
  255. package/views/3d/terrain/TerrainSurface.js +1 -1
  256. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  257. package/views/3d/webgl-engine/lighting/SceneLighting.js +1 -1
  258. package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +6 -0
  259. package/views/SceneView.js +1 -1
  260. package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
  261. package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +1 -1
  262. package/views/draw/MultipointDrawAction.js +1 -1
  263. package/views/draw/PointDrawAction.js +1 -1
  264. package/views/draw/PolygonDrawAction.js +1 -1
  265. package/views/draw/PolylineDrawAction.js +1 -1
  266. package/views/draw/SegmentDrawAction.js +1 -1
  267. package/views/draw/input/CursorUpdateEvents.js +5 -0
  268. package/views/draw/input/DrawCompleteEvent.js +5 -0
  269. package/views/draw/input/VertexAddEvent.js +5 -0
  270. package/views/draw/input/VertexRemoveEvent.js +5 -0
  271. package/views/draw/input/VertexUpdateEvent.js +5 -0
  272. package/views/interactive/editGeometry/CheckpointingEditGeometryOperations.js +5 -0
  273. package/views/interactive/editGeometry/EditGeometry.js +1 -1
  274. package/views/interactive/editGeometry/operations/ReplayableAppendVertex.js +5 -0
  275. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  276. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
  277. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.js +1 -1
  278. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
  279. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTilesSimple.js +1 -1
  280. package/views/support/PromiseQueue.js +1 -1
  281. package/views/support/Scheduler.js +1 -1
  282. package/webscene/spec-certification/api.js +1 -1
  283. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  284. package/widgets/CoordinateConversion.js +1 -1
  285. package/widgets/Editor/AddAssociationWorkflow.js +1 -1
  286. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  287. package/widgets/Editor/EditorViewModel.js +1 -1
  288. package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
  289. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  290. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  291. package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
  292. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  293. package/widgets/Editor/UpdateRecordWorkflowData.js +1 -1
  294. package/widgets/Editor/UpdateWorkflow.js +1 -1
  295. package/widgets/Editor/UpdateWorkflowData.js +1 -1
  296. package/widgets/Editor/support/SketchController.js +1 -1
  297. package/widgets/Editor/support/errors.js +5 -0
  298. package/widgets/Editor/workflowUtils.js +1 -1
  299. package/widgets/Editor.js +1 -1
  300. package/widgets/Legend/LegendViewModel.js +1 -1
  301. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  302. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  303. package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
  304. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  305. package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
  306. package/widgets/OrientedImageryViewer/services/DepthImageService.js +1 -1
  307. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  308. package/widgets/PanoramicViewer/PanoramicZoomManager.js +1 -1
  309. package/widgets/PanoramicViewer/support/PanoramicMeshManager.js +1 -1
  310. package/widgets/PanoramicViewer/support/PanoramicTileNode.js +1 -1
  311. package/widgets/PanoramicViewer/support/PanoramicTilePyramid.js +1 -1
  312. package/widgets/PanoramicViewer/support/getVisibleTiles.js +5 -0
  313. package/widgets/Sketch/CreateToolVisibilityMap.js +5 -0
  314. package/widgets/Sketch/SelectionToolVisibilityMap.js +5 -0
  315. package/widgets/Sketch/VisibleElements.js +1 -1
  316. package/widgets/Sketch.js +1 -1
  317. package/assets/esri/core/workers/chunks/020c8913d8e35d63080b.js +0 -1
  318. package/assets/esri/core/workers/chunks/02e69f0c63d97661da60.js +0 -1
  319. package/assets/esri/core/workers/chunks/05eee334d58a0b9f6316.js +0 -1
  320. package/assets/esri/core/workers/chunks/06ba43843e9c4988049b.js +0 -1
  321. package/assets/esri/core/workers/chunks/087973e7c4fea5fcfa5e.js +0 -1
  322. package/assets/esri/core/workers/chunks/326a76a4e80269d4029d.js +0 -1
  323. package/assets/esri/core/workers/chunks/377a66034e7c1bad5599.js +0 -1
  324. package/assets/esri/core/workers/chunks/4442817beb7a76c95770.js +0 -1
  325. package/assets/esri/core/workers/chunks/459a67928bde4a62b6a4.js +0 -1
  326. package/assets/esri/core/workers/chunks/4eebd74ebc20579dade8.js +0 -1
  327. package/assets/esri/core/workers/chunks/53bd8996e8812f1ad7b2.js +0 -1
  328. package/assets/esri/core/workers/chunks/557960763695abee4a83.js +0 -1
  329. package/assets/esri/core/workers/chunks/6201356f7f91e5c06425.js +0 -1
  330. package/assets/esri/core/workers/chunks/6c3b99209d542efa64d4.js +0 -1
  331. package/assets/esri/core/workers/chunks/6f4bd0ee85e7e5a74340.js +0 -1
  332. package/assets/esri/core/workers/chunks/7413e582bc2b16af6a0f.js +0 -1
  333. package/assets/esri/core/workers/chunks/7461124454bfb4fb6474.js +0 -1
  334. package/assets/esri/core/workers/chunks/75bf27271a31e26e1b21.js +0 -1
  335. package/assets/esri/core/workers/chunks/7aaaebbabee27690283c.js +0 -1
  336. package/assets/esri/core/workers/chunks/7c4a63aeead2505d6f02.js +0 -1
  337. package/assets/esri/core/workers/chunks/811d4c46c75cf6a63e78.js +0 -1
  338. package/assets/esri/core/workers/chunks/8ffd4710d168c2fcfd96.js +0 -1
  339. package/assets/esri/core/workers/chunks/90250e9239c173aace88.js +0 -1
  340. package/assets/esri/core/workers/chunks/9786f91455350eaae493.js +0 -1
  341. package/assets/esri/core/workers/chunks/99859dce1925b406ccd0.js +0 -1
  342. package/assets/esri/core/workers/chunks/9c5cbf8810f37b1a4718.js +0 -1
  343. package/assets/esri/core/workers/chunks/9e8dceef4c961f56940d.js +0 -1
  344. package/assets/esri/core/workers/chunks/9fac5a12e878cd745354.js +0 -1
  345. package/assets/esri/core/workers/chunks/a06bac9b8f9e18874de8.js +0 -316
  346. package/assets/esri/core/workers/chunks/a712cdff78fc826acd8c.js +0 -1
  347. package/assets/esri/core/workers/chunks/a8f998b8ec8c56150479.js +0 -2
  348. package/assets/esri/core/workers/chunks/aa54b6f2aba6952af149.js +0 -1
  349. package/assets/esri/core/workers/chunks/b96eb0ea506379182d62.js +0 -2
  350. package/assets/esri/core/workers/chunks/c476643002387f60ea42.js +0 -1
  351. package/assets/esri/core/workers/chunks/c4e4da69969499a89a2c.js +0 -1
  352. package/assets/esri/core/workers/chunks/cd1930f08e1fc8b30b14.js +0 -1
  353. package/assets/esri/core/workers/chunks/d1fe816b6990918c13c7.js +0 -1
  354. package/assets/esri/core/workers/chunks/d305a21666b1ed5bf33d.js +0 -1
  355. package/assets/esri/core/workers/chunks/d40f57f9fc47f9a9f97c.js +0 -1
  356. package/assets/esri/core/workers/chunks/e0bbfbe1ed39c82f1bd4.js +0 -1
  357. package/assets/esri/core/workers/chunks/e82f5437bd66779c6740.js +0 -1
  358. package/assets/esri/core/workers/chunks/f6c8beb60f6d29945a2e.js +0 -1
  359. package/assets/esri/core/workers/chunks/f746e3f7ebff2bbdf333.js +0 -1
  360. package/assets/esri/core/workers/chunks/fd2efd1d1cf9d95a87e6.js +0 -1
  361. package/views/3d/layers/i3s/I3SStreamDataController.js +0 -5
  362. package/views/3d/support/StreamDataLoader.js +0 -5
  363. package/views/3d/support/StreamDataRequester.js +0 -5
  364. package/views/3d/support/downloadSlots.js +0 -5
  365. package/views/draw/input/DrawEvents.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{isSome as t}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import{deprecatedFunction as o}from"../../core/deprecate.js";import a from"../../core/Error.js";import{EventedAccessor as s}from"../../core/Evented.js";import{abortHandle as n,makeHandle as l}from"../../core/handleUtils.js";import"../../core/has.js";import d from"../../core/Logger.js";import{destroyMaybe as p,abortMaybe as c,removeMaybe as u}from"../../core/maybe.js";import{throwIfAborted as h,createResolver as w}from"../../core/promiseUtils.js";import{watch as f,on as m,when as y,syncAndInitial as g,initial as k,sync as v,whenOnce as _}from"../../core/reactiveUtils.js";import{property as W}from"../../core/accessorSupport/decorators/property.js";import{subclass as M}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as F}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as b}from"../../editing/templateUtils.js";import{getGraphicLayer as T}from"../../graphic/graphicOriginUtils.js";import V from"../../layers/GraphicsLayer.js";import{isEditableLayer as E}from"../../layers/support/editableLayers.js";import{isFeatureLayer as I,isSubtypeGroupLayer as S,getOwningPortalUrl as L}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as U}from"../../portal/support/urlUtils.js";import{isGraphic as A}from"../../support/guards.js";import C from"../../views/SelectionManager.js";import O from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as j}from"../../views/interactive/snapping/SnappingManager.js";import P from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as R}from"../../views/support/selectionUtils.js";import H from"../Attachments/AttachmentsViewModel.js";import q from"./CreateFeaturesWorkflow.js";import G from"./UpdateFeaturesWorkflow.js";import x from"./UpdateWorkflow.js";import{getLayersFromWorkflow as D,isCreateFeaturesWorkflow as B,isUpdateRecordWorkflow as N,isUpdateFeaturesWorkflow as Q,isUpdateWorkflow as z,findEditorItemForLayerOrThrow as Z,assertSplitWorkflowCapabilities as $,fetchFullFeatures as J,featuresToFeatureInfos as K,makeMultipleSourceLayersError as X,findEditorItemForLayer as Y,whenEditorLayerView as ee}from"./workflowUtils.js";import te from"./support/EditorItem.js";import{makeTemplateGroupInfoForLayer as ie}from"../FeatureTemplates/featureTemplatesUtils.js";import re from"../FeatureTemplates/FeatureTemplatesViewModel.js";import oe from"../Sketch/SketchViewModel.js";import ae from"../Spinner/SpinnerViewModel.js";import{goTo as se}from"../support/goToUtils.js";import{isFeatureItem as ne,isLayerItem as le}from"../support/SelectionList/selectionListUtils.js";import de from"../support/SelectionList/SelectionListViewModel.js";import pe from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function ce(e,t){return e?.find(e=>e.layer===t)}let ue=class extends s{constructor(e){super(e),this._queuedSelectionTool=null,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new V({listMode:"hide",internal:!0,title:"Editor sketch layer"}),this._snappingManager=null,this._templatesByLayer=new Map,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new F,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new r,this.editorItems=new r,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new H({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new re({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new oe({layer:this._sketchGraphicsLayer}),this.selectionListViewModel=new de,this.selectionManager=new C,this.selectionToolbarViewModel=new pe({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new O,this.snappingOptions=new P({attributeRulesEnabled:!0}),this.spinnerViewModel=new ae,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{if("viewing-selection-list"===this.state)return this.selectionListViewModel.filterText=void 0,void this.effectiveSelectionManager.clear();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=(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([f(()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,r=i?.filter(e=>!!t?.includes(e.layer));return[t,r,this.layerInfos]},()=>this._updateEditorItems(),g),f(()=>this.hideTemplatesForInactiveLayers,()=>this.syncFeatureTemplates()),f(()=>this._selectionSources,()=>this._syncSelectionSources(),k),m(()=>this.activeWorkflow,"cancel",()=>this.emit("workflow-cancel")),m(()=>this.activeWorkflow,"commit",()=>this.emit("workflow-commit")),m(()=>this.activeWorkflow,"complete",()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)}),y(()=>!this.activeWorkflow&&this._queuedSelectionTool,()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool)),f(()=>this.activeWorkflow,e=>this.selectionManager.showHighlight=!e),y(()=>this.view?.map,e=>e.add(this._sketchGraphicsLayer),k),m(()=>this.editorItems,"change",()=>this._afterEditorItemsChange()),f(()=>[this.canCreate,this.canUpdateVisible],()=>this._afterEditorItemsChange()),f(()=>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},g),y(()=>"awaiting-update-feature-candidate"===this.state,()=>this._candidateCommitted=!1),m(()=>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 r={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(r);await this.startCreateFeaturesWorkflowAtFeatureCreation(r)}),f(()=>[this.view,this.featureTemplatesViewModel],([e,t])=>{t.view=e},g),m(()=>this.view,"key-down",e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())}),m(()=>this.sketchViewModel,["create","delete","update"],e=>{const{activeWorkflow:t}=this,i=D(t),r=`sketch-${e.type}`;this.emit(r,{type:r,detail:e,layer:i[0],layers:i})},v),f(()=>this.view,e=>{if(this._snappingManager=p(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new j({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager},g),f(()=>this.snappingOptions,e=>{this._snappingManager&&(this._snappingManager.options=e)},g),m(()=>this.selectionToolbarViewModel,"complete",e=>this._onSelectionComplete(e)),f(()=>({view:this.view,selectionManager:this.effectiveSelectionManager,selectionListViewModel:this.selectionListViewModel,selectionToolbarViewModel:this.selectionToolbarViewModel}),({view:e,selectionManager:t,selectionListViewModel:i,selectionToolbarViewModel:r})=>{t.view=e,i.view=e,r.view=e},g),f(()=>this.effectiveSelectionManager,e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e},g)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then(()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null}),this._updateItemsTask=c(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=u(this._sketchEventListenerHandle),this.selectionListViewModel?.destroy(),this.selectionToolbarViewModel?.destroy(),this.selectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new r;for(const t of this.editorItems){const i=this.hideTemplatesForInactiveLayers&&!t.visible;t.supportsCreateFeaturesWorkflow&&!i&&e.push(t.layer)}return e}get _selectionSources(){const e=new r;for(const t of this.editorItems)R(t.layer)&&t.supportsUpdateWorkflow&&t.visible&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return B(e)?e.pendingFeatures.length:N(e)&&e.data.edits.feature?1:Q(e)?e.data.fullFeatures.length:0}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&z(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||"update-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{activeLeafWorkflow:e}=this;if(N(e))return!1===e.data.editorItem?.capabilities.update.attributes||!0===e.featureFormViewModel.disabled;if(Q(e)){const{formViewModel:t}=e;return t.disabled||t.readOnly}return!1}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeLeafWorkflow:e}=this;if(N(e)){const{data:t}=e;return t.editorItem?.capabilities.delete.enabled&&!t.readOnly}return!!Q(e)&&e.data.editorItems.every(e=>e.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 _(()=>!this.updating),!this.canCreate)throw new a("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(r){this._logErrorAndCancelWorkflow(r)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await _(()=>!this.updating);const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,r=i?Z(this.editorItems,i):void 0;if(!r?.supportsCreateFeaturesWorkflow)throw new a("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const o=this._createCreateFeaturesWorkflow({initialFeature:t,layer:r.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",o),await o.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startSplitFeatureWorkflow(e,t={}){await _(()=>!this.updating);const{view:i}=this;if(!i)throw new a("editing:view-required","A view is required to start a split feature workflow.");const r=T(e);if(!r)throw new a("editing:layer-required","The feature must be associated with a layer to start a split feature workflow.");const o=Z(this.editorItems,r);$(o);const s=this._createUpdatingResolver(),l=new AbortController;this.addHandles(n(l));try{await this._cancelWorkflow();const o=await J([e],r,i.spatialReference,l.signal);if(0===o.length)throw new a("editing:fetch-feature","Failed to fetch the full feature from the service.");const s=this._createUpdateWorkflow("editing-existing-feature",{rootFeature:o[0],rootWorkflowOptions:{type:"split",props:t}});this._set("activeWorkflow",s),this.addHandles(this._destroyWorkflowOnCommit(s)),await s.start()}catch(d){this._logErrorAndCancelWorkflow(d)}finally{s.resolve()}}async startUpdateFeaturesWorkflow(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");let t=[];if(t=e.some(e=>A(e))?K(e):e,t.length>1)throw X();const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateFeaturesWorkflow({featureInfos:t});this._set("activeWorkflow",e),await e.start()}catch(r){this._logErrorAndCancelWorkflow(r)}finally{i.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await _(()=>!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 _(()=>!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 _(()=>!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",{rootFeature:e});t.addHandles(this._destroyWorkflowOnCommit(t)),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount||!e.visibleLayerCount)throw new a("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new a("editing:features-different-layers","Cannot start workflow with features from different layers.");const t=e.layerItems.find(e=>e.visible);t&&await this._startUpdateWorkflowWithLayerItem(t)}async deleteFeatureFromWorkflow(){o(d.getLogger(this),"EditorViewModel.deleteFeatureFromWorkflow is deprecated. Use EditorViewModel.deleteFeatures instead.",{version:"4.33",replacement:"EditorViewModel.deleteFeatures",warnOnce:!0}),await this.deleteFeatures()}async deleteFeatures(){const e=this.activeWorkflow;return z(e)?e.deleteActiveFeature():Q(e)?e.deleteAndCommit():void this._logError("editing:unsupported-workflow","Deleting features 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})}itemHasInvalidFormTemplate(e){return null!=e&&!0===Y(this.editorItems,e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:i,sketchViewModel:r}=this;if(!i)return;const o=void 0,a=e??r?.createGraphic;if(a)"mesh"===a.geometry?.type?se(i,a.geometry,o):se(i,a,o);else{const e=r?.updateGraphics?.toArray();"3d"===i.type&&e?.some(e=>"mesh"===e.geometry?.type)?se(i,e.map(e=>e.geometry).filter(t),o):e&&se(i,e,o)}}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){ne(e)&&await this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e){ne(e)?await this.startUpdateWorkflowAtFeatureEdit(e.graphic):le(e)&&await this._startUpdateWorkflowWithLayerItem(e)}restrictFeatureTemplatesViewModelToLayer(e){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([e]),l(()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)})}async _getEditorItemCandidates(e){const{view:t}=this;if(!t?.map)return[];const{map:i}=t,r=i.editableLayers.toArray(),o=i.allTables.toArray().filter(e=>I(e)||S(e));return await Promise.allSettled([...r.flatMap(e=>this._getLayerLoadPromise(e)),...o.flatMap(e=>this._getLayerLoadPromise(e))]),h(e),[...r.reverse(),...o.reverse()].filter(e=>E(e)&&("mesh"!==e.geometryType||"3d"===t.type)).flatMap(e=>"subtype-group"===e.type?e.sublayers.toArray():e)}_getLayerLoadPromise(e){return S(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain(e=>e.destroy())}_updateEditorItems(){c(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 r=[],o=[],a=[],{layerInfos:s}=this;for(const l of i){const t=ce(s,l),i=await ee(e,l).catch(()=>null);(t?r:i?o:a).push(new te({layer:l,layerInfo:t,layerView:i}))}s?.length&&r.sort((e,t)=>s.findIndex(({layer:t})=>t===e.layer)-s.findIndex(({layer:e})=>e===t.layer));const n=[...r,...o,...a];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))});this._updatingHandles.addPromise(t.promise),this._updateItemsTask=t}_updateTemplates(){c(this._updateTemplatesTask);const e=i(async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter(e=>!t.has(e));if(i.length>0){const r=await b({layers:i.toArray(),view:this.view,signal:e,queryOptions:{returnVisibleTemplatesOnly:!0}});for(const{layer:e,templates:i}of r)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 r of e){const e=t.get(r);e&&e.length>0&&i.push(ie(r,e))}this.featureTemplatesViewModel.templateInfos=i}_afterEditorItemsChange(){const{activeWorkflow:e}=this;if(this.syncFeatureTemplates(),!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 q.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateFeaturesWorkflow({features:e,featureInfos:t}){const i=G.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,features:e,featureInfos:t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i)});return this.addHandles(this._destroyWorkflowOnCommit(i)),i}_createUpdateWorkflow(e,t){const i=x.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,rootFeature:t?.rootFeature,rootWorkflowOptions:t?.rootWorkflowOptions,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)});return i}_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 r=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new a("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation(async()=>(r=await(e.addAttachment?.(t,i).catch(e=>{throw e?.error||e}))??null,r)),r}async _applyEdits(e,t,i){let r=null;const o=e.url?await L(e.url):null,a={returnServiceEditsOption:(!o||!U(o))&&!/\/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 o=await ee(i,e).catch(()=>null);return r=await e.applyEdits(t,a),o&&await _(()=>!o.updating),r}),r}async _applyEditsFeatureService(e,t,i){let r=null;return await this._queueOperation(async()=>r=await e.applyEdits(t,i)),r}_destroyWorkflowOnCommit(e){return m(()=>e,"commit",()=>{e.destroy(),this.activeWorkflow===e&&this._set("activeWorkflow",null)})}_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 r={error:i,retry:()=>(t(r,this.failures),this._queueOperation(e)),cancel:()=>{t(r,this.failures)}};this._set("failures",[...this.failures,r])}).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:r}=e,o=t.find(e=>!!e.error)||r.find(e=>!!e.error)||i.find(e=>!!e.error);if(o)throw o.error}}_createUpdatingResolver(){const e=w();return this._updatingHandles.addPromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:r}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,r??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=Z(this.editorItems,e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){d.getLogger(this).error(new a(e,t,i))}_syncSelectionSources(){this.selectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:r}=this,o="ready"===this.state,a=1===i.length;if(this._queuedSelectionTool=void 0,o&&a&&"replace"===t)return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(i[0]);switch(t){case"remove":r.updateSelection({current:[],added:[],removed:i});break;case"replace":r.clear(),r.updateSelection({current:i,added:[],removed:[]});break;case"add":r.updateSelection({current:i,added:[],removed:[]})}}async _startUpdateWorkflowWithLayerItem(e){if(!e.objectIds?.length)return;const t=e.featureItems.filter(e=>e.visible).map(e=>e.graphic),i=this.selectionListViewModel.filterText;1===t.length?await this.startUpdateWorkflowAtFeatureEdit(t[0]):null!=i&&""!==i?await this.startUpdateFeaturesWorkflow(t):await this.startUpdateFeaturesWorkflow([{layer:e.layer,objectIds:e.objectIds}])}};e([W()],ue.prototype,"_featureTemplatesLayersAndTables",null),e([W()],ue.prototype,"_queuedSelectionTool",void 0),e([W()],ue.prototype,"_snappingManager",void 0),e([W()],ue.prototype,"_selectionSources",null),e([W()],ue.prototype,"activeFeatureCount",null),e([W({readOnly:!0})],ue.prototype,"activeWorkflow",void 0),e([W()],ue.prototype,"activeLeafWorkflow",null),e([W({readOnly:!0})],ue.prototype,"_activityQueue",void 0),e([W({readOnly:!0})],ue.prototype,"canCreate",null),e([W()],ue.prototype,"canCreateVisible",null),e([W({readOnly:!0})],ue.prototype,"canUpdate",null),e([W()],ue.prototype,"canUpdateVisible",null),e([W()],ue.prototype,"featureTemplatesLayers",null),e([W()],ue.prototype,"editorItems",void 0),e([W()],ue.prototype,"effectiveSelectionManager",null),e([W({readOnly:!0})],ue.prototype,"failures",void 0),e([W()],ue.prototype,"hideTemplatesForInactiveLayers",void 0),e([W({type:H})],ue.prototype,"attachmentsViewModel",void 0),e([W()],ue.prototype,"featureFormViewModel",null),e([W()],ue.prototype,"formViewModel",null),e([W()],ue.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([W({type:re})],ue.prototype,"featureTemplatesViewModel",void 0),e([W()],ue.prototype,"labelOptions",null),e([W()],ue.prototype,"layerInfos",void 0),e([W()],ue.prototype,"ownSketchViewModel",void 0),e([W()],ue.prototype,"selectionListViewModel",void 0),e([W()],ue.prototype,"selectionManager",void 0),e([W()],ue.prototype,"selectionToolbarViewModel",void 0),e([W()],ue.prototype,"sketchOptions",void 0),e([W()],ue.prototype,"sketchViewModel",null),e([W({type:P,nonNullable:!0})],ue.prototype,"snappingOptions",void 0),e([W()],ue.prototype,"spinnerViewModel",void 0),e([W()],ue.prototype,"state",null),e([W({readOnly:!0})],ue.prototype,"syncing",null),e([W()],ue.prototype,"updating",null),e([W()],ue.prototype,"tooltipOptions",null),e([W()],ue.prototype,"valueOptions",null),e([W()],ue.prototype,"view",null),e([W()],ue.prototype,"canZoomTo",null),e([W()],ue.prototype,"pageStack",void 0),e([W()],ue.prototype,"showDiscardEditsPrompt",void 0),e([W()],ue.prototype,"_candidateCommitted",void 0),e([W()],ue.prototype,"page",null),e([W()],ue.prototype,"featureFormDisabled",null),e([W()],ue.prototype,"featureFormHasAssociation",null),e([W()],ue.prototype,"canGoBack",null),e([W()],ue.prototype,"shouldShowDeleteButton",null),e([W()],ue.prototype,"hasPendingEdits",null),e([W()],ue.prototype,"snappingManager",null),ue=e([M("esri.widgets.Editor.EditorViewModel")],ue);const he=ue;export{he as default};
5
+ import{__decorate as e}from"tslib";import{isSome as t}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import o from"../../core/Collection.js";import{deprecatedFunction as r}from"../../core/deprecate.js";import a from"../../core/Error.js";import{EventedAccessor as s}from"../../core/Evented.js";import{abortHandle as n,makeHandle as l}from"../../core/handleUtils.js";import"../../core/has.js";import d from"../../core/Logger.js";import{destroyMaybe as c,abortMaybe as p,removeMaybe as h}from"../../core/maybe.js";import{throwIfAborted as u,createResolver as w}from"../../core/promiseUtils.js";import{watch as f,on as m,when as y,syncAndInitial as g,initial as k,sync as v,whenOnce as _}from"../../core/reactiveUtils.js";import{property as W}from"../../core/accessorSupport/decorators/property.js";import{subclass as M}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as F}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as b}from"../../editing/templateUtils.js";import{getGraphicLayer as T}from"../../graphic/graphicOriginUtils.js";import V from"../../layers/GraphicsLayer.js";import{isEditableLayer as E}from"../../layers/support/editableLayers.js";import{isFeatureLayer as I,isSubtypeGroupLayer as S,getOwningPortalUrl as L}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as U}from"../../portal/support/urlUtils.js";import{isGraphic as A}from"../../support/guards.js";import C from"../../views/SelectionManager.js";import O from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as j}from"../../views/interactive/snapping/SnappingManager.js";import R from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as P}from"../../views/support/selectionUtils.js";import H from"../Attachments/AttachmentsViewModel.js";import q from"./CreateFeaturesWorkflow.js";import x from"./UpdateWorkflow.js";import{getLayersFromWorkflow as G,isCreateFeaturesWorkflow as D,isUpdateRecordWorkflow as B,isUpdateFeaturesWorkflow as N,isUpdateWorkflow as Q,isFeatureFormViewModel as z,findEditorItemForLayerOrThrow as Z,assertMergeWorkflowCapabilities as $,fetchFullFeatures as J,assertSplitWorkflowCapabilities as K,featuresToFeatureInfos as X,findEditorItemForLayer as Y,whenEditorLayerView as ee}from"./workflowUtils.js";import te from"./support/EditorItem.js";import{assertMinimumFeatureCount as ie,assertFeaturesAreFromSameLayer as oe,MissingOriginLayerError as re,FetchFullFeatureError as ae,MultipleSourceLayersError as se}from"./support/errors.js";import{makeTemplateGroupInfoForLayer as ne}from"../FeatureTemplates/featureTemplatesUtils.js";import le from"../FeatureTemplates/FeatureTemplatesViewModel.js";import de from"../Sketch/SketchViewModel.js";import ce from"../Spinner/SpinnerViewModel.js";import{goTo as pe}from"../support/goToUtils.js";import{isFeatureItem as he,isLayerItem as ue}from"../support/SelectionList/selectionListUtils.js";import we from"../support/SelectionList/SelectionListViewModel.js";import fe from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function me(e,t){return e?.find(e=>e.layer===t)}let ye=class extends s{constructor(e){super(e),this._queuedSelectionTool=null,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new V({listMode:"hide",internal:!0,title:"Editor sketch layer"}),this._snappingManager=null,this._templatesByLayer=new Map,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new F,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new o,this.editorItems=new o,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new H({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new le({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new de({layer:this._sketchGraphicsLayer}),this.selectionListViewModel=new we,this.selectionManager=new C,this.selectionToolbarViewModel=new fe({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new O,this.snappingOptions=new R({attributeRulesEnabled:!0}),this.spinnerViewModel=new ce,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{if("viewing-selection-list"===this.state)return this.selectionListViewModel.filterText=void 0,void this.effectiveSelectionManager.clear();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=(e,t=!1)=>{const i=this.activeWorkflow;if(this._candidateCommitted||"update"!==i?.type)return;const{rootFeatures:o}=i.data;o.removeAll(),e&&o.add(e),t&&(i.next(),this._candidateCommitted=!0)}}initialize(){this.addHandles([f(()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,o=i?.filter(e=>!!t?.includes(e.layer));return[t,o,this.layerInfos]},()=>this._updateEditorItems(),g),f(()=>this.hideTemplatesForInactiveLayers,()=>this.syncFeatureTemplates()),f(()=>this._selectionSources,()=>this._syncSelectionSources(),k),m(()=>this.activeWorkflow,"cancel",()=>this.emit("workflow-cancel")),m(()=>this.activeWorkflow,"commit",()=>this.emit("workflow-commit")),m(()=>this.activeWorkflow,"complete",()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)}),y(()=>!this.activeWorkflow&&this._queuedSelectionTool,()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool)),f(()=>this.activeWorkflow,e=>this.selectionManager.showHighlight=!e),y(()=>this.view?.map,e=>e.add(this._sketchGraphicsLayer),k),m(()=>this.editorItems,"change",()=>this._afterEditorItemsChange()),f(()=>[this.canCreate,this.canUpdateVisible],()=>this._afterEditorItemsChange()),f(()=>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},g),y(()=>"awaiting-update-feature-candidate"===this.state,()=>this._candidateCommitted=!1),m(()=>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 o={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(o);await this.startCreateFeaturesWorkflowAtFeatureCreation(o)}),f(()=>[this.view,this.featureTemplatesViewModel],([e,t])=>{t.view=e},g),m(()=>this.view,"key-down",e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())}),m(()=>this.sketchViewModel,["create","delete","update"],e=>{const{activeWorkflow:t}=this,i=G(t),o=`sketch-${e.type}`;this.emit(o,{type:o,detail:e,layer:i[0],layers:i})},v),f(()=>this.view,e=>{if(this._snappingManager=c(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new j({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager},g),f(()=>this.snappingOptions,e=>{this._snappingManager&&(this._snappingManager.options=e)},g),m(()=>this.selectionToolbarViewModel,"complete",e=>this._onSelectionComplete(e)),f(()=>({view:this.view,selectionManager:this.effectiveSelectionManager,selectionListViewModel:this.selectionListViewModel,selectionToolbarViewModel:this.selectionToolbarViewModel}),({view:e,selectionManager:t,selectionListViewModel:i,selectionToolbarViewModel:o})=>{t.view=e,i.view=e,o.view=e},g),f(()=>this.effectiveSelectionManager,e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e},g)])}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=h(this._sketchEventListenerHandle),this.selectionListViewModel?.destroy(),this.selectionToolbarViewModel?.destroy(),this.selectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new o;for(const t of this.editorItems){const i=this.hideTemplatesForInactiveLayers&&!t.visible;t.supportsCreateFeaturesWorkflow&&!i&&e.push(t.layer)}return e}get _selectionSources(){const e=new o;for(const t of this.editorItems)P(t.layer)&&t.supportsUpdateWorkflow&&t.visible&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return D(e)?e.pendingFeatures.length:B(e)&&e.data.edits.feature?1:N(e)?e.data.fullFeatures.length:0}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&Q(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,t="update"===e?.type?e.activeFormViewModel:e?.formViewModel;return z(t)?t:null}get formViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFormViewModel:e?.formViewModel}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&&z(e.activeFormViewModel)){const{associatedLayer:t,associationId:i}=e.activeFormViewModel;if(t||null!=i)return"viewing-associated-features"}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{activeLeafWorkflow:e}=this;if(B(e))return!1===e.data.editorItem?.capabilities.update.attributes||!0===e.formViewModel.disabled;if(N(e)){const{formViewModel:t}=e;return t.disabled||t.readOnly}return!1}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeLeafWorkflow:e}=this;if(B(e)){const{data:t}=e;return t.editorItem?.capabilities.delete.enabled&&!t.readOnly}return!!N(e)&&e.data.editorItems.every(e=>e.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 _(()=>!this.updating),!this.canCreate)throw new a("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(o){this._logErrorAndCancelWorkflow(o)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await _(()=>!this.updating);const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,o=i?Z(this.editorItems,i):void 0;if(!o?.supportsCreateFeaturesWorkflow)throw new a("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const r=this._createCreateFeaturesWorkflow({initialFeature:t,layer:o.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",r),await r.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startMergeFeaturesWorkflow(e,t={}){await _(()=>!this.updating),ie(e,2),oe(e);const i=T(e[0]);if(!i)throw new re;const r=Z(this.editorItems,i);$(r);const a=this._createUpdatingResolver(),s=new AbortController;this.addHandles(n(s));try{await this._cancelWorkflow();const r=await J(e,i,this.view?.spatialReference,s.signal);if(r.length!==e.length)throw new ae;let a;if(t.keyFeature){const e=t.keyFeature.getObjectId();a=r.find(t=>t.getObjectId()===e)??t.keyFeature}const n=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new o(r),rootWorkflowOptions:{type:"merge",props:{...t,keyFeature:a}}});this._set("activeWorkflow",n),this.addHandles(this._destroyWorkflowOnCommit(n)),await n.start()}catch(l){this._logErrorAndCancelWorkflow(l)}finally{a.resolve()}}async startSplitFeatureWorkflow(e,t={}){await _(()=>!this.updating);const i=T(e);if(!i)throw new re;const r=Z(this.editorItems,i);K(r);const a=this._createUpdatingResolver(),s=new AbortController;this.addHandles(n(s));try{await this._cancelWorkflow();const r=await J([e],i,this.view?.spatialReference,s.signal);if(1!==r.length)throw new ae;const a=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new o(r),rootWorkflowOptions:{type:"split",props:t}});this._set("activeWorkflow",a),this.addHandles(this._destroyWorkflowOnCommit(a)),await a.start()}catch(l){this._logErrorAndCancelWorkflow(l)}finally{a.resolve()}}async startUpdateFeaturesWorkflow(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");let t=[];if(t=e.some(e=>A(e))?X(e):e,t.length>1)throw new se;const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature",{rootFeatureInfos:t,rootWorkflowOptions:{type:"update-multiple"}});e.addHandles(this._destroyWorkflowOnCommit(e)),this._set("activeWorkflow",e),await e.start()}catch(o){this._logErrorAndCancelWorkflow(o)}finally{i.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await _(()=>!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 _(()=>!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 _(()=>!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",{rootFeatures:new o([e])});t.addHandles(this._destroyWorkflowOnCommit(t)),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount||!e.visibleLayerCount)throw new a("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new a("editing:features-different-layers","Cannot start workflow with features from different layers.");const t=e.layerItems.find(e=>e.visible);t&&await this._startUpdateWorkflowWithLayerItem(t)}async deleteFeatureFromWorkflow(){r(d.getLogger(this),"EditorViewModel.deleteFeatureFromWorkflow is deprecated. Use EditorViewModel.deleteFeatures instead.",{version:"4.33",replacement:"EditorViewModel.deleteFeatures",warnOnce:!0}),await this.deleteFeatures()}async deleteFeatures(){const e=this.activeWorkflow;if(Q(e))return e.deleteActiveFeatures();this._logError("editing:unsupported-workflow","Deleting features 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})}itemHasInvalidFormTemplate(e){return null!=e&&!0===Y(this.editorItems,e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:i,sketchViewModel:o}=this;if(!i)return;const r=void 0,a=e??o?.createGraphic;if(a)"mesh"===a.geometry?.type?pe(i,a.geometry,r):pe(i,a,r);else{const e=o?.updateGraphics?.toArray();"3d"===i.type&&e?.some(e=>"mesh"===e.geometry?.type)?pe(i,e.map(e=>e.geometry).filter(t),r):e&&pe(i,e,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()))}async onSelectionListItemSelect(e){he(e)&&await this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e){he(e)?await this.startUpdateWorkflowAtFeatureEdit(e.graphic):ue(e)&&await this._startUpdateWorkflowWithLayerItem(e)}restrictFeatureTemplatesViewModelToLayer(e){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([e]),l(()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)})}async _getEditorItemCandidates(e){const{view:t}=this;if(!t?.map)return[];const{map:i}=t,o=i.editableLayers.toArray(),r=i.allTables.toArray().filter(e=>I(e)||S(e));return await Promise.allSettled([...o.flatMap(e=>this._getLayerLoadPromise(e)),...r.flatMap(e=>this._getLayerLoadPromise(e))]),u(e),[...o.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 S(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 o=[],r=[],a=[],{layerInfos:s}=this;for(const l of i){const t=me(s,l),i=await ee(e,l).catch(()=>null);(t?o:i?r:a).push(new te({layer:l,layerInfo:t,layerView:i}))}s?.length&&o.sort((e,t)=>s.findIndex(({layer:t})=>t===e.layer)-s.findIndex(({layer:e})=>e===t.layer));const n=[...o,...r,...a];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 o=await b({layers:i.toArray(),view:this.view,signal:e,queryOptions:{returnVisibleTemplatesOnly:!0}});for(const{layer:e,templates:i}of o)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 o of e){const e=t.get(o);e&&e.length>0&&i.push(ne(o,e))}this.featureTemplatesViewModel.templateInfos=i}_afterEditorItemsChange(){const{activeWorkflow:e}=this;if(this.syncFeatureTemplates(),!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 q.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateWorkflow(e,t){const i=x.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,...t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)});return i}_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 o=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new a("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation(async()=>(o=await(e.addAttachment?.(t,i).catch(e=>{throw e?.error||e}))??null,o)),o}async _applyEdits(e,t,i){let o=null;const r=e.url?await L(e.url):null,a={returnServiceEditsOption:(!r||!U(r))&&!/\/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 ee(i,e).catch(()=>null);return o=await e.applyEdits(t,a),r&&await _(()=>!r.updating),o}),o}async _applyEditsFeatureService(e,t,i){let o=null;return await this._queueOperation(async()=>o=await e.applyEdits(t,i)),o}_destroyWorkflowOnCommit(e){return m(()=>e,"commit",()=>{e.destroy(),this.activeWorkflow===e&&this._set("activeWorkflow",null)})}_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 o={error:i,retry:()=>(t(o,this.failures),this._queueOperation(e)),cancel:()=>{t(o,this.failures)}};this._set("failures",[...this.failures,o])}).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:o}=e,r=t.find(e=>!!e.error)||o.find(e=>!!e.error)||i.find(e=>!!e.error);if(r)throw r.error}}_createUpdatingResolver(){const e=w();return this._updatingHandles.addPromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:o}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,o??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=Z(this.editorItems,e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){d.getLogger(this).error(new a(e,t,i))}_syncSelectionSources(){this.selectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:o}=this,r="ready"===this.state,a=1===i.length;if(this._queuedSelectionTool=void 0,r&&a&&"replace"===t)return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(i[0]);switch(t){case"remove":o.updateSelection({current:[],added:[],removed:i});break;case"replace":o.clear(),o.updateSelection({current:i,added:[],removed:[]});break;case"add":o.updateSelection({current:i,added:[],removed:[]})}}async _startUpdateWorkflowWithLayerItem(e){if(!e.objectIds?.length)return;const t=e.featureItems.filter(e=>e.visible).map(e=>e.graphic),i=this.selectionListViewModel.filterText;1===t.length?await this.startUpdateWorkflowAtFeatureEdit(t[0]):null!=i&&""!==i?await this.startUpdateFeaturesWorkflow(t):await this.startUpdateFeaturesWorkflow([{layer:e.layer,objectIds:e.objectIds}])}};e([W()],ye.prototype,"_featureTemplatesLayersAndTables",null),e([W()],ye.prototype,"_queuedSelectionTool",void 0),e([W()],ye.prototype,"_snappingManager",void 0),e([W()],ye.prototype,"_selectionSources",null),e([W()],ye.prototype,"activeFeatureCount",null),e([W({readOnly:!0})],ye.prototype,"activeWorkflow",void 0),e([W()],ye.prototype,"activeLeafWorkflow",null),e([W({readOnly:!0})],ye.prototype,"_activityQueue",void 0),e([W({readOnly:!0})],ye.prototype,"canCreate",null),e([W()],ye.prototype,"canCreateVisible",null),e([W({readOnly:!0})],ye.prototype,"canUpdate",null),e([W()],ye.prototype,"canUpdateVisible",null),e([W()],ye.prototype,"featureTemplatesLayers",null),e([W()],ye.prototype,"editorItems",void 0),e([W()],ye.prototype,"effectiveSelectionManager",null),e([W({readOnly:!0})],ye.prototype,"failures",void 0),e([W()],ye.prototype,"hideTemplatesForInactiveLayers",void 0),e([W({type:H})],ye.prototype,"attachmentsViewModel",void 0),e([W()],ye.prototype,"featureFormViewModel",null),e([W()],ye.prototype,"formViewModel",null),e([W()],ye.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([W({type:le})],ye.prototype,"featureTemplatesViewModel",void 0),e([W()],ye.prototype,"labelOptions",null),e([W()],ye.prototype,"layerInfos",void 0),e([W()],ye.prototype,"ownSketchViewModel",void 0),e([W()],ye.prototype,"selectionListViewModel",void 0),e([W()],ye.prototype,"selectionManager",void 0),e([W()],ye.prototype,"selectionToolbarViewModel",void 0),e([W()],ye.prototype,"sketchOptions",void 0),e([W()],ye.prototype,"sketchViewModel",null),e([W({type:R,nonNullable:!0})],ye.prototype,"snappingOptions",void 0),e([W()],ye.prototype,"spinnerViewModel",void 0),e([W()],ye.prototype,"state",null),e([W({readOnly:!0})],ye.prototype,"syncing",null),e([W()],ye.prototype,"updating",null),e([W()],ye.prototype,"tooltipOptions",null),e([W()],ye.prototype,"valueOptions",null),e([W()],ye.prototype,"view",null),e([W()],ye.prototype,"canZoomTo",null),e([W()],ye.prototype,"pageStack",void 0),e([W()],ye.prototype,"showDiscardEditsPrompt",void 0),e([W()],ye.prototype,"_candidateCommitted",void 0),e([W()],ye.prototype,"page",null),e([W()],ye.prototype,"featureFormDisabled",null),e([W()],ye.prototype,"featureFormHasAssociation",null),e([W()],ye.prototype,"canGoBack",null),e([W()],ye.prototype,"shouldShowDeleteButton",null),e([W()],ye.prototype,"hasPendingEdits",null),e([W()],ye.prototype,"snappingManager",null),ye=e([M("esri.widgets.Editor.EditorViewModel")],ye);const ge=ye;export{ge 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{destroyMaybe as r}from"../../core/maybe.js";import{on as i,whenOnce as o}from"../../core/reactiveUtils.js";import{property as a}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{getGraphicLayer as n}from"../../graphic/graphicOriginUtils.js";import l from"../../layers/GraphicsLayer.js";import d from"../../views/draw/support/HighlightHelper.js";import p from"./Edits.js";import h from"./MergeFeaturesWorkflowData.js";import m from"./Workflow.js";import{assertMergeWorkflowCapabilities as u,updateGraphicSymbolWhenRequired as c,makeMinimalAttributes as f}from"./workflowUtils.js";import{mergeFeatures as g}from"./support/mergeFeaturesUtils.js";import w from"../FeatureForm/FeatureFormViewModel.js";var y;let _=y=class extends m{constructor(e){super(e),this.type="merge-features",this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new d({view:e}):null,this._initializeFeatureFormViewModel(),this._initializeGraphicsLayer(),this._createAndInitializeEdits(this.data.keyFeature)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=r(this._graphicsLayer),this._formViewModel?.destroy(),this._highlightHelper?.destroy()}get featureFormViewModel(){return this._formViewModel}get parent(){return this.data.parent}get updating(){return this._updatingHandles.updating||this._formViewModel.updating}static async create(e){const{applyEdits:r,applyEditsFeatureService:i,...o}=e,{editorItem:a,features:s}=o;if(u(a),s.length<2)throw new t("editing:invalid-argument","At least two features are required to perform a merge.");if(!s.every(e=>n(e)===a.layer))throw new t("editing:invalid-argument","All features in a merge workflow must belong to the same layer.");const l=await g(s),d=new y({data:new h({...o,mergedGeometry:l}),onCommit:M(r)});return d._set("steps",F()),d}async enter(){}exit(){}async setKeyFeature(e){const{data:r}=this;if(!r.features.includes(e))throw new t("editing:invalid-argument","Key feature must be one of the features being merged");r.keyFeature=e,await this._createAndInitializeEdits(e)}async start(){return await super.start(),this._makeSketchController()}async _createAndInitializeEdits(e){const{data:t}=this,r=e.clone();r.geometry=t.mergedGeometry;const i=new p({feature:r});t.edits=i,i.trackChanges(e),await this._setFeatureOnFormViewModel(r)}_initializeFeatureFormViewModel(){const{data:e,_webStyleCache:t}=this,r=e.viewModel.view,o=new w({disabled:!0,editType:"UPDATE",formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:r?.map,spatialReference:r?.spatialReference,timeZone:e.timeZone});this._formViewModel=o,this.addHandles(i(()=>o,"value-change",({feature:i,fieldName:o,value:a})=>{const s=e.edits;i&&s&&(s.setAttribute(o,a),c(i,t,r?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,r=new l({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"mergeFeaturesWorkflow-internal"});this._graphicsLayer=r,t?.map.add(r)}_makeSketchController(){return{enter:async()=>{for(const e of this.data.features)this._highlightHelper?.add(e)},exit:()=>{this._highlightHelper?.removeAll()}}}async _setFeatureOnFormViewModel(e){const t=this._formViewModel;t.feature=e,await o(()=>!t.updating)}};e([a()],_.prototype,"featureFormViewModel",null),e([a()],_.prototype,"parent",null),e([a()],_.prototype,"type",void 0),e([a()],_.prototype,"updating",null),e([a()],_.prototype,"_formViewModel",void 0),e([a()],_.prototype,"_graphicsLayer",void 0),e([a()],_.prototype,"_highlightHelper",void 0),_=y=e([s("esri.widgets.Editor.MergeFeaturesWorkflow")],_);const v=_;function F(){return[{id:"choosing-key-feature",async setUp(){},async tearDown(){}}]}function M(e){return async r=>{const{edits:i,keyFeature:o}=r,a=i?.feature?.cloneShallow(),s=r.editorItem.layer;if(!i||!a)throw new t("editing:missing-feature","Workflow data has no edits to submit.");i.attributesModified||(a.attributes=f(a,r.editorItem.layer));const n=[];for(const e of r.features){if(e===o)continue;const t=e.cloneShallow();t.attributes=f(t,s),t.geometry=null,n.push(t)}await e(s,{updateFeatures:[a],deleteFeatures:n})}}export{v as default};
5
+ import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{destroyMaybe as r}from"../../core/maybe.js";import{on as i,whenOnce as o}from"../../core/reactiveUtils.js";import{property as a}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 l from"../../layers/GraphicsLayer.js";import n from"../../views/draw/support/HighlightHelper.js";import d from"./Edits.js";import p from"./MergeFeaturesWorkflowData.js";import h from"./Workflow.js";import{assertMergeWorkflowCapabilities as m,updateGraphicSymbolWhenRequired as c,makeMinimalAttributes as u}from"./workflowUtils.js";import{assertMinimumFeatureCount as f,assertFeaturesAreFromSameLayer as y,InvalidKeyFeatureError as w}from"./support/errors.js";import{mergeFeatures as g}from"./support/mergeFeaturesUtils.js";import _ from"../FeatureForm/FeatureFormViewModel.js";var F;let v=F=class extends h{constructor(e){super(e),this.type="merge-features",this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new n({view:e}):null,this._initializeFeatureFormViewModel(),this._initializeGraphicsLayer(),this._createAndInitializeEdits(this.data.keyFeature)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=r(this._graphicsLayer),this._formViewModel?.destroy(),this._highlightHelper?.destroy()}get formViewModel(){return this._formViewModel}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get updating(){return this._updatingHandles.updating||this._formViewModel.updating}static async create(e){const{applyEdits:t,applyEditsFeatureService:r,...i}=e,{editorItem:o,features:a}=i;if(m(o),f(a,2),y(a),i.keyFeature&&!a.includes(i.keyFeature))throw new w;const s=await g(a),l=new F({data:new p({...i,mergedGeometry:s}),onCommit:k(t)});return l._set("steps",j()),l}async enter(){}exit(){}async setKeyFeature(e){const{data:t}=this;if(!t.features.includes(e))throw new w;t.keyFeature=e,await this._createAndInitializeEdits(e)}async start(){return await super.start(),this._makeSketchController()}async _createAndInitializeEdits(e){const{data:t}=this,r=e.clone();r.geometry=t.mergedGeometry;const i=new d({feature:r});t.edits=i,i.trackChanges(e),await this._setFeatureOnFormViewModel(r)}_initializeFeatureFormViewModel(){const{data:e,_webStyleCache:t}=this,r=e.viewModel.view,o=new _({disabled:!0,editType:"UPDATE",formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:r?.map,spatialReference:r?.spatialReference,timeZone:e.timeZone});this._formViewModel=o,this.addHandles(i(()=>o,"value-change",({feature:i,fieldName:o,value:a})=>{const s=e.edits;i&&s&&(s.setAttribute(o,a),c(i,t,r?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,r=new l({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"mergeFeaturesWorkflow-internal"});this._graphicsLayer=r,t?.map.add(r)}_makeSketchController(){return{enter:async()=>{for(const e of this.data.features)this._highlightHelper?.add(e)},exit:()=>{this._highlightHelper?.removeAll()}}}async _setFeatureOnFormViewModel(e){const t=this._formViewModel;t.feature=e,await o(()=>!t.updating)}};e([a()],v.prototype,"formViewModel",null),e([a()],v.prototype,"layer",null),e([a()],v.prototype,"parent",null),e([a()],v.prototype,"type",void 0),e([a()],v.prototype,"updating",null),e([a()],v.prototype,"_formViewModel",void 0),e([a()],v.prototype,"_graphicsLayer",void 0),e([a()],v.prototype,"_highlightHelper",void 0),v=F=e([s("esri.widgets.Editor.MergeFeaturesWorkflow")],v);const M=v;function j(){return[{id:"choosing-key-feature",async setUp(){},async tearDown(){}}]}function k(e){return async r=>{const{edits:i,keyFeature:o}=r,a=i?.feature?.cloneShallow(),s=r.editorItem.layer;if(!i||!a)throw new t("editing:missing-feature","Workflow data has no edits to submit.");i.attributesModified||(a.attributes=u(a,r.editorItem.layer));const l=[];for(const e of r.features){if(e===o)continue;const t=e.cloneShallow();t.attributes=u(t,s),t.geometry=null,l.push(t)}await e(s,{updateFeatures:[a],deleteFeatures:l})}}export{M as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,handlesGroup as r}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as a}from"../../core/maybe.js";import{debounce as o}from"../../core/promiseUtils.js";import{watch as s,on as l,whenOnce as n}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../layers/GraphicsLayer.js";import{getDrawHelpMessage as u}from"../../views/draw/support/helpMessageUtils.js";import c from"../../views/draw/support/HighlightHelper.js";import m from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as y}from"../../views/support/HighlightDefaults.js";import g from"./Edits.js";import w from"./SplitFeatureWorkflowData.js";import f from"./Workflow.js";import{assertSplitWorkflowCapabilities as v,createWorkflowSteps as _,swapForEditingSession as F,updateGraphicSymbolWhenRequired as M,makeMinimalAttributes as b}from"./workflowUtils.js";import{getCompatibleSpitterGeometryType as S,ensureSplittableGeometry as k,makeNewFeatureAttributes as V,splitGeometry as G,canSplitByPoint as T,isSplitterGeometry as H}from"./support/splitFeatureUtils.js";import I from"../FeatureForm/FeatureFormViewModel.js";import j from"../Sketch/SketchViewModel.js";var E;const C=Symbol();let x=E=class extends f{constructor(e){super(e),this.defaultSplitterGeometryType=null,this.type="split-feature",this._activeFeature=null,this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._lastSplitterGeometryWasInvalid=!1,this._sketchViewModel=null,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new c({view:e,highlightName:y}):null,this._initializeFeatureFormViewModel();const t=this._initializeGraphicsLayer();this._initializeSketchViewModel(t)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=a(this._graphicsLayer),this._formViewModel.destroy(),this._sketchViewModel.destroy(),this._highlightHelper?.destroy()}get activeFeature(){return this._activeFeature}get availableCreateTools(){const e=["polyline","polygon","rectangle","circle","freehandPolyline","freehandPolygon"];switch(this.data.editorItem.layer.geometryType){case"polygon":case"multipoint":return e;case"polyline":return["point",...e];default:return[]}}get featureFormViewModel(){return this._formViewModel}get hasPreviousStep(){return null!==this._activeFeature||this._stepIndex>0}get helpMessage(){if(this._lastSplitterGeometryWasInvalid)return"invalidSplitterGeometry";const{activeCreateToolDrawMode:e,activeTool:t,createGraphic:i}=this._sketchViewModel,r="rectangle"===t||"circle"===t?t:this.data.editorItem.layer.geometryType;return"mesh"!==r?u(r,i?.geometry,e):void 0}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||this._sketchViewModel.updating}async back(e){return this.activeFeature?await this.setActiveFeature(null):await super.back(e)}static create(e){const{applyEdits:i,applyEditsFeatureService:r,defaultSplitterGeometryType:a,startAt:o,...s}=e;if(v(s.editorItem),"reviewing-features"===o){if(!s.splitterGeometry)throw new t("editing:split-geometry-required","Must provide the split geometry to start at the 'reviewing-features' step.");const e=S(k(s.originalFeature.geometry),s.splitterGeometry.type);if(s.splitterGeometry.type!==e)throw new t("editing:incompatible-split-geometries",`Geometry of type '${s.splitterGeometry.type}' cannot be used to split geometry of type '${s.originalFeature.geometry?.type}'.`)}const l=new E({data:new w(s),defaultSplitterGeometryType:a,onCommit:W(e.applyEdits)});return l._set("steps",E._createWorkflowSteps(l,o)),l}async enter(){}exit(){if("reviewing-features"!==this.stepId)throw new t("editing:invalid-exit-state","The SplitFeatureWorkflow can only be exited when in the 'reviewing-features' step.")}highlightFeature(e,t){this._highlightHelper?.add(e,t)}clearHighlights(){this._highlightHelper?.removeAll()}async setActiveFeature(e){const i=this._activeFeature;if(e===i)return;const r=this.data;this.clearHighlights();const a=i?r.getEditsForFeature(i):null;if(a&&(a.submittable=this._formViewModel.submittable),this._activeFeature=e,null==e)return;const o=this.data.getRoleForFeature(e);if(!o)throw new t("editing:unknown-feature","The provided feature is not part of this workflow.");this.highlightFeature(e),await this._setFeatureOnFormViewModel(e,o)}async start(){return await super.start(),this._makeSketchController()}async _createAndInitializeEdits({newPart:e,remainingPart:t}){const{data:i}=this,r=i.originalFeature,a=this._formViewModel,o=r.clone();o.geometry=t;const s=new g({feature:o});i.existingFeatureEdits=s,s.trackChanges(r),await this._setFeatureOnFormViewModel(o,"existing"),s.submittable=a.submittable;const l=r.clone();l.geometry=e,l.attributes=V(r.attributes,i.editorItem.layer);const n=new g({feature:l});return i.newFeatureEdits=n,n.trackChanges(),await this._setFeatureOnFormViewModel(l,"new"),n.submittable=a.submittable,{featureToCreate:l,featureToUpdate:o}}static _createWorkflowSteps(e,i="drawing-splitter-geometry"){const{data:r}=e;return _(["drawing-splitter-geometry","reviewing-features"],i,{"drawing-splitter-geometry":()=>({id:"drawing-splitter-geometry",async setUp(){const i=k(r.originalFeature.geometry),a=S(i,e.defaultSplitterGeometryType),{snappingManager:o}=r;T(i)&&o&&e.addHandles(U(o,e.layer));const n=e._sketchViewModel;e.addHandles([l(()=>n,"create",async i=>{if("start"===i.state&&e._lastSplitterGeometryWasInvalid&&(e._lastSplitterGeometryWasInvalid=!1),"complete"===i.state){e._graphicsLayer.removeAll();const o=i.graphic?.geometry;try{if(!H(o))throw new t("editing:invalid-split-geometry","The geometry produced by the Sketch operation cannot be used for splitting.");r.splitterGeometry=o,r.splitResult=await e._updatingHandles.addPromise(e._executeSplit(o)),await e.next()}catch(a){e._lastSplitterGeometryWasInvalid=!0,await n.create(i.tool)}}}),s(()=>n.activeTool,(t,i)=>{"point"===t&&!e.hasHandles(C)&&o?e.addHandles(P(o,e.layer),C):"point"===i&&e.removeHandles(C)})],this.id),await n.create(a)},async tearDown(){e.removeHandles(this.id)}}),"reviewing-features":()=>({id:"reviewing-features",async setUp(){const i=r.splitterGeometry;if(!i)throw new t("editing:missing-splitter-geometry","The `splitterGeometry` property of the workflow's data must be set in order to start the 'reviewing-features' step.");const a=r.splitResult??await e._executeSplit(i),{featureToCreate:o,featureToUpdate:s}=await e._createAndInitializeEdits(a),l=await e._displayFeatureGraphics(s,o);e.addHandles(l,this.id)},async tearDown(){e.clearHighlights()}})})}async _displayFeatureGraphics(e,t){const{data:a,_graphicsLayer:l}=this,n=a.viewModel.view,p=[];if(!e||!t||!n)return i();const d=o(i=>Promise.all([M(e,this._webStyleCache,i),M(t,this._webStyleCache,i)]));return await d("2d"===n.type?n.scale:null),"2d"===n.type&&p.push(s(()=>n.scale,e=>d(e))),l.add(t),p.push(i(()=>l.remove(t))),p.push(await F(l,n,a.originalFeature,e)),r(p)}async _executeSplit(e){const{data:i}=this,{originalFeature:r}=i,a=r.geometry;if(!a)throw new t("editing:feature-has-no-geometry","Cannot split the provided feature as it has no geometry.");const o=await G(a,e);if(!o||!o.newPart)throw new t("editing:split-failed","The split operation did not produce a valid result.");return o}_initializeFeatureFormViewModel(){const{data:e,_webStyleCache:t}=this,i=e.viewModel.view,r=new I({formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:i?.map,spatialReference:i?.spatialReference,timeZone:e.timeZone});this._formViewModel=r,this.addHandles(l(()=>r,"value-change",({feature:r,fieldName:a,value:o})=>{r&&(e.getEditsForFeature(r)?.setAttribute(a,o),M(r,t,i?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,i=new h({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"splitFeatureWorkflow-internal"});return this._graphicsLayer=i,t?.map.add(i),i}_initializeSketchViewModel(e){const{data:t}=this,{view:i}=t.viewModel;this._sketchViewModel=new j({layer:e,creationMode:"single",sketchOptions:t.sketchOptions,snappingManager:t.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:i})}_makeSketchController(){return{enter:async()=>{const{activeFeature:e}=this;e&&this.highlightFeature(e)},exit:()=>{this.clearHighlights()},viewModel:this._sketchViewModel}}async _setFeatureOnFormViewModel(e,t){const{data:i}=this,r=this._formViewModel;r.feature=e,"existing"===t?(r.editType="UPDATE",r.overrideInitialFeature(i.originalFeature)):r.editType="INSERT",await n(()=>!r.updating)}get test(){}};e([p()],x.prototype,"activeFeature",null),e([p()],x.prototype,"availableCreateTools",null),e([p()],x.prototype,"defaultSplitterGeometryType",void 0),e([p()],x.prototype,"featureFormViewModel",null),e([p()],x.prototype,"hasPreviousStep",null),e([p()],x.prototype,"helpMessage",null),e([p()],x.prototype,"layer",null),e([p()],x.prototype,"parent",null),e([p()],x.prototype,"type",void 0),e([p()],x.prototype,"updating",null),e([p()],x.prototype,"_activeFeature",void 0),e([p()],x.prototype,"_formViewModel",void 0),e([p()],x.prototype,"_graphicsLayer",void 0),e([p()],x.prototype,"_highlightHelper",void 0),e([p()],x.prototype,"_lastSplitterGeometryWasInvalid",void 0),e([p()],x.prototype,"_sketchViewModel",void 0),x=E=e([d("esri.widgets.Editor.SplitFeatureWorkflow")],x);const L=x;function W(e){return async i=>{const{existingFeatureEdits:r,newFeatureEdits:a}=i,o=r?.feature?.cloneShallow(),s=a?.feature?.cloneShallow(),l=i.editorItem.layer;if(null==o||null==s)throw new t("editing:missing-features","Expected both a feature to update and a feature to add for the split operation.");r?.attributesModified||(o.attributes=b(o,i.editorItem.layer)),await e(l,{addFeatures:[s],updateFeatures:[o]})}}function U(e,t){if(e.options.featureSources.some(e=>e.layer===t))return i();const r=new m({enabled:!1,layer:t});return e.options.featureSources.add(r),i(()=>{e.options.featureSources.remove(r),r.destroy()})}function P(e,t){const{options:r}=e,a=r.enabled;r.enabled=!0;const o=r.featureEnabled;r.featureEnabled=!0;const s=r.distance;r.distance=15;const l=new Map;for(const i of r.featureSources)l.set(i,i.enabled),i.layer===t?i.enabled=!0:i.enabled=!1;return i(()=>{r.enabled=a,r.featureEnabled=o,r.distance=s;for(const[e,t]of l)e.enabled=t})}export{L as default};
5
+ import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,handlesGroup as r}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as a}from"../../core/maybe.js";import{debounce as o}from"../../core/promiseUtils.js";import{watch as s,on as l,whenOnce as n}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../layers/GraphicsLayer.js";import{getDrawHelpMessage as u}from"../../views/draw/support/helpMessageUtils.js";import c from"../../views/draw/support/HighlightHelper.js";import m from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as y}from"../../views/support/HighlightDefaults.js";import g from"./Edits.js";import w from"./SplitFeatureWorkflowData.js";import f from"./Workflow.js";import{assertSplitWorkflowCapabilities as v,createWorkflowSteps as _,swapForEditingSession as F,updateGraphicSymbolWhenRequired as M,makeMinimalAttributes as b}from"./workflowUtils.js";import{getCompatibleSpitterGeometryType as S,ensureSplittableGeometry as k,makeNewFeatureAttributes as T,splitGeometry as V,canSplitByPoint as G,isSplitterGeometry as I}from"./support/splitFeatureUtils.js";import H from"../FeatureForm/FeatureFormViewModel.js";import j from"../Sketch/SketchViewModel.js";var E;const C=Symbol();let x=E=class extends f{constructor(e){super(e),this.defaultSplitterGeometryType=null,this.type="split-feature",this._activeFeature=null,this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._lastSplitterGeometryWasInvalid=!1,this._sketchViewModel=null,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new c({view:e,highlightName:y}):null,this._initializeFormViewModel();const t=this._initializeGraphicsLayer();this._initializeSketchViewModel(t)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=a(this._graphicsLayer),this._formViewModel.destroy(),this._sketchViewModel.destroy(),this._highlightHelper?.destroy()}get activeFeature(){return this._activeFeature}get availableCreateTools(){const e=["polyline","polygon","rectangle","circle","freehandPolyline","freehandPolygon"];switch(this.data.editorItem.layer.geometryType){case"polygon":case"multipoint":return e;case"polyline":return["point",...e];default:return[]}}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPreviousStep(){return null!==this._activeFeature||this._stepIndex>0}get helpMessage(){if(this._lastSplitterGeometryWasInvalid)return"invalidSplitterGeometry";const{activeCreateToolDrawMode:e,activeTool:t,createGraphic:i}=this._sketchViewModel,r="rectangle"===t||"circle"===t?t:this.data.editorItem.layer.geometryType;return"mesh"!==r?u(r,i?.geometry,e):void 0}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||this._sketchViewModel.updating}async back(e){return this.activeFeature?await this.setActiveFeature(null):await super.back(e)}static create(e){const{applyEdits:i,applyEditsFeatureService:r,defaultSplitterGeometryType:a,startAt:o,...s}=e;if(v(s.editorItem),"reviewing-features"===o){if(!s.splitterGeometry)throw new t("editing:split-geometry-required","Must provide the split geometry to start at the 'reviewing-features' step.");const e=S(k(s.originalFeature.geometry),s.splitterGeometry.type);if(s.splitterGeometry.type!==e)throw new t("editing:incompatible-split-geometries",`Geometry of type '${s.splitterGeometry.type}' cannot be used to split geometry of type '${s.originalFeature.geometry?.type}'.`)}const l=new E({data:new w(s),defaultSplitterGeometryType:a,onCommit:W(e.applyEdits)});return l._set("steps",E._createWorkflowSteps(l,o)),l}async enter(){}exit(){if("reviewing-features"!==this.stepId)throw new t("editing:invalid-exit-state","The SplitFeatureWorkflow can only be exited when in the 'reviewing-features' step.")}highlightFeature(e,t){this._highlightHelper?.add(e,t)}clearHighlights(){this._highlightHelper?.removeAll()}async setActiveFeature(e){const i=this._activeFeature;if(e===i)return;const r=this.data;this.clearHighlights();const a=i?r.getEditsForFeature(i):null;if(a&&(a.submittable=this._formViewModel.submittable),this._activeFeature=e,null==e)return;const o=this.data.getRoleForFeature(e);if(!o)throw new t("editing:unknown-feature","The provided feature is not part of this workflow.");this.highlightFeature(e),await this._setFeatureOnFormViewModel(e,o)}async start(){return await super.start(),this._makeSketchController()}async _createAndInitializeEdits({newPart:e,remainingPart:t}){const{data:i}=this,r=i.originalFeature,a=this._formViewModel,o=r.clone();o.geometry=t;const s=new g({feature:o});i.existingFeatureEdits=s,s.trackChanges(r),await this._setFeatureOnFormViewModel(o,"existing"),s.submittable=a.submittable;const l=r.clone();l.geometry=e,l.attributes=T(r.attributes,i.editorItem.layer);const n=new g({feature:l});return i.newFeatureEdits=n,n.trackChanges(),await this._setFeatureOnFormViewModel(l,"new"),n.submittable=a.submittable,{featureToCreate:l,featureToUpdate:o}}static _createWorkflowSteps(e,i="drawing-splitter-geometry"){const{data:r}=e;return _(["drawing-splitter-geometry","reviewing-features"],i,{"drawing-splitter-geometry":()=>({id:"drawing-splitter-geometry",async setUp(){const i=k(r.originalFeature.geometry),a=S(i,e.defaultSplitterGeometryType),{snappingManager:o}=r;G(i)&&o&&e.addHandles(U(o,e.layer));const n=e._sketchViewModel;e.addHandles([l(()=>n,"create",async i=>{if("start"===i.state&&e._lastSplitterGeometryWasInvalid&&(e._lastSplitterGeometryWasInvalid=!1),"complete"===i.state){e._graphicsLayer.removeAll();const o=i.graphic?.geometry;try{if(!I(o))throw new t("editing:invalid-split-geometry","The geometry produced by the Sketch operation cannot be used for splitting.");r.splitterGeometry=o,r.splitResult=await e._updatingHandles.addPromise(e._executeSplit(o)),await e.next()}catch(a){e._lastSplitterGeometryWasInvalid=!0,await n.create(i.tool)}}}),s(()=>n.activeTool,(t,i)=>{"point"===t&&!e.hasHandles(C)&&o?e.addHandles(P(o,e.layer),C):"point"===i&&e.removeHandles(C)})],this.id),await n.create(a)},async tearDown(){e.removeHandles(this.id)}}),"reviewing-features":()=>({id:"reviewing-features",async setUp(){const i=r.splitterGeometry;if(!i)throw new t("editing:missing-splitter-geometry","The `splitterGeometry` property of the workflow's data must be set in order to start the 'reviewing-features' step.");const a=r.splitResult??await e._executeSplit(i),{featureToCreate:o,featureToUpdate:s}=await e._createAndInitializeEdits(a),l=await e._displayFeatureGraphics(s,o);e.addHandles(l,this.id)},async tearDown(){e.clearHighlights()}})})}async _displayFeatureGraphics(e,t){const{data:a,_graphicsLayer:l}=this,n=a.viewModel.view,p=[];if(!e||!t||!n)return i();const d=o(i=>Promise.all([M(e,this._webStyleCache,i),M(t,this._webStyleCache,i)]));return await d("2d"===n.type?n.scale:null),"2d"===n.type&&p.push(s(()=>n.scale,e=>d(e))),l.add(t),p.push(i(()=>l.remove(t))),p.push(await F(l,n,a.originalFeature,e)),r(p)}async _executeSplit(e){const{data:i}=this,{originalFeature:r}=i,a=r.geometry;if(!a)throw new t("editing:feature-has-no-geometry","Cannot split the provided feature as it has no geometry.");const o=await V(a,e);if(!o||!o.newPart)throw new t("editing:split-failed","The split operation did not produce a valid result.");return o}_initializeFormViewModel(){const{data:e,_webStyleCache:t}=this,i=e.viewModel.view,r=new H({formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:i?.map,spatialReference:i?.spatialReference,timeZone:e.timeZone});this._formViewModel=r,this.addHandles(l(()=>r,"value-change",({feature:r,fieldName:a,value:o})=>{r&&(e.getEditsForFeature(r)?.setAttribute(a,o),M(r,t,i?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,i=new h({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"splitFeatureWorkflow-internal"});return this._graphicsLayer=i,t?.map.add(i),i}_initializeSketchViewModel(e){const{data:t}=this,{view:i}=t.viewModel;this._sketchViewModel=new j({layer:e,creationMode:"single",sketchOptions:t.sketchOptions,snappingManager:t.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:i})}_makeSketchController(){return{enter:async()=>{const{activeFeature:e}=this;e&&this.highlightFeature(e)},exit:()=>{this.clearHighlights()},viewModel:this._sketchViewModel}}async _setFeatureOnFormViewModel(e,t){const{data:i}=this,r=this._formViewModel;r.feature=e,"existing"===t?(r.editType="UPDATE",r.overrideInitialFeature(i.originalFeature)):r.editType="INSERT",await n(()=>!r.updating)}get test(){}};e([p()],x.prototype,"activeFeature",null),e([p()],x.prototype,"availableCreateTools",null),e([p()],x.prototype,"defaultSplitterGeometryType",void 0),e([p()],x.prototype,"formViewModel",null),e([p()],x.prototype,"hasInvalidFormTemplate",null),e([p()],x.prototype,"hasPreviousStep",null),e([p()],x.prototype,"helpMessage",null),e([p()],x.prototype,"layer",null),e([p()],x.prototype,"parent",null),e([p()],x.prototype,"type",void 0),e([p()],x.prototype,"updating",null),e([p()],x.prototype,"_activeFeature",void 0),e([p()],x.prototype,"_formViewModel",void 0),e([p()],x.prototype,"_graphicsLayer",void 0),e([p()],x.prototype,"_highlightHelper",void 0),e([p()],x.prototype,"_lastSplitterGeometryWasInvalid",void 0),e([p()],x.prototype,"_sketchViewModel",void 0),x=E=e([d("esri.widgets.Editor.SplitFeatureWorkflow")],x);const L=x;function W(e){return async i=>{const{existingFeatureEdits:r,newFeatureEdits:a}=i,o=r?.feature?.cloneShallow(),s=a?.feature?.cloneShallow(),l=i.editorItem.layer;if(null==o||null==s)throw new t("editing:missing-features","Expected both a feature to update and a feature to add for the split operation.");r?.attributesModified||(o.attributes=b(o,i.editorItem.layer)),await e(l,{addFeatures:[s],updateFeatures:[o]})}}function U(e,t){if(e.options.featureSources.some(e=>e.layer===t))return i();const r=new m({enabled:!1,layer:t});return e.options.featureSources.add(r),i(()=>{e.options.featureSources.remove(r),r.destroy()})}function P(e,t){const{options:r}=e,a=r.enabled;r.enabled=!0;const o=r.featureEnabled;r.featureEnabled=!0;const s=r.distance;r.distance=15;const l=new Map;for(const i of r.featureSources)l.set(i,i.enabled),i.layer===t?i.enabled=!0:i.enabled=!1;return i(()=>{r.enabled=a,r.featureEnabled=o,r.distance=s;for(const[e,t]of l)e.enabled=t})}export{L as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as s}from"../../core/maybe.js";import{watch as o}from"../../core/reactiveUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import l from"../../layers/GraphicsLayer.js";import{highlightsSupported as h}from"../../views/support/layerViewUtils.js";import d from"./UpdateFeatureWorkflowData.js";import{UpdateRecordWorkflow as n,handleKeys as c}from"./UpdateRecordWorkflow.js";import{getVisualVariableAttributes as p,setUpGeometryUpdate as w,updateGraphicSymbolWhenRequired as u,swapForEditingSession as m,cloneGraphicExceptMesh as y,canCreateInteractiveEditSession as f,isTerminalUpdateEventType as k}from"./workflowUtils.js";import g from"../Sketch/SketchViewModel.js";var _;const V={...c,highlights:Symbol(),sketchGraphics:Symbol(),sketchViewModel:Symbol(),waitingForTool:Symbol()};let v=_=class extends n{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._sketchLayer=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)}),o(()=>this._featureFormViewModel.feature?.sourceLayer,e=>this._sketchGraphicClone.sourceLayer=e)])}_configureHighlight(){const{edits:e,layerView:t}=this.data;h(t)&&this.addHandles(t.highlight(e.feature),V.highlights)}async _configureSketchViewModel(){const{_sketchLayer:e,_sketchViewModel:t}=this;if(!t||!e)return;const{data:i,_featureFormViewModel:s,_sketchGraphicClone:o}=this,{edits:r,viewModel:a}=i,l=r.feature,{view:h}=a,d=p(l),n=await w({feature:l,featureClone:o,visualVariableAttributes:d,sketchLayer:e,sketchViewModel:t,view:h,onUpdate:({geometry:e,attributes:t},i)=>{if(r.updateAttributes(t),r.updateGeometry(e),s.feature&&(s.feature.geometry=e),null!=d.rotation){const{field:e}=d.rotation;s.setValue(e,t[e])}if(null!=d.size){const{field:e}=d.size;s.setValue(e,t[e])}("undo"===i.type||"redo"===i.type||"update"===i.type&&null!=i.toolEventInfo&&k(i.toolEventInfo.type))&&s.notifyFeatureGeometryChanged()},addUpdatingPromise:e=>{this._updatingHandles.addPromise(e)},addHandle:e=>{this.addHandles(e,V.waitingForTool)},webStyleCache:this._webStyleCache});this.addHandles(n,V.sketchGraphics),t.addHandles(n)}async _initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,{readOnly:o}=e,r=e.edits.feature,{capabilities:a,layer:h}=e.editorItem,d=e.viewModel.view;if(this.removeHandles([V.highlights,V.sketchGraphics,V.sketchViewModel,V.waitingForTool]),!a.update.geometry||o)return{enter:async()=>{this.hasHandles(V.highlights)||this._configureHighlight()},exit:()=>this.removeHandles([V.highlights])};const n=new l({elevationInfo:h.elevationInfo,internal:!0,listMode:"hide",title:"updateFeaturesWorkflow-internal"}),c=new g({allowDeleteKey:!1,layer:n,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,view:d});return this._sketchLayer=n,this._sketchViewModel=c,d?.map.add(n),await(d?.whenLayerView(n)),this.addHandles(i(()=>{d?.destroyed||d?.map.remove(n),n.destroyed||n.destroy(),this._sketchViewModel=s(c)}),V.sketchViewModel),await u(t,this._webStyleCache,"2d"===d?.type?d.scale:null),this.addHandles([await m(n,d,r,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=y(e),{edits:i,layerView:s}=this.data;i.updateGeometry(e.geometry),i.trackChanges(),f(s)&&(this._layerViewEditSession=s.createInteractiveEditSession(t))}static async create(e){const t=new _({data:await d.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}get test(){}};e([r()],v.prototype,"_layerViewEditSession",void 0),e([r()],v.prototype,"_sketchGraphicClone",void 0),e([r()],v.prototype,"_sketchLayer",void 0),e([r()],v.prototype,"_sketchViewModel",void 0),v=_=e([a("esri.widgets.Editor.UpdateFeatureWorkflow")],v);export{v as UpdateFeatureWorkflow,V as handleKeys};
5
+ import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as s}from"../../core/maybe.js";import{watch as o}from"../../core/reactiveUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import l from"../../layers/GraphicsLayer.js";import{highlightsSupported as h}from"../../views/support/layerViewUtils.js";import d from"./UpdateFeatureWorkflowData.js";import{UpdateRecordWorkflow as n,handleKeys as c}from"./UpdateRecordWorkflow.js";import{getVisualVariableAttributes as p,setUpGeometryUpdate as w,updateGraphicSymbolWhenRequired as m,swapForEditingSession as u,cloneGraphicExceptMesh as y,canCreateInteractiveEditSession as f,isTerminalUpdateEventType as k}from"./workflowUtils.js";import g from"../Sketch/SketchViewModel.js";var _;const V={...c,highlights:Symbol(),sketchGraphics:Symbol(),sketchViewModel:Symbol(),waitingForTool:Symbol()};let v=_=class extends n{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._sketchLayer=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()}_initializeFormViewModel(){super._initializeFormViewModel(),this.addHandles([this._formViewModel.on("value-change",e=>{this._layerViewEditSession?.setAttribute(e.fieldName,e.value)}),o(()=>this._formViewModel.feature?.sourceLayer,e=>this._sketchGraphicClone.sourceLayer=e)])}_configureHighlight(){const{edits:e,layerView:t}=this.data;h(t)&&this.addHandles(t.highlight(e.feature),V.highlights)}async _configureSketchViewModel(){const{_sketchLayer:e,_sketchViewModel:t}=this;if(!t||!e)return;const{data:i,_formViewModel:s,_sketchGraphicClone:o}=this,{edits:r,viewModel:a}=i,l=r.feature,{view:h}=a,d=p(l),n=await w({feature:l,featureClone:o,visualVariableAttributes:d,sketchLayer:e,sketchViewModel:t,view:h,onUpdate:({geometry:e,attributes:t},i)=>{if(r.updateAttributes(t),r.updateGeometry(e),s.feature&&(s.feature.geometry=e),null!=d.rotation){const{field:e}=d.rotation;s.setValue(e,t[e])}if(null!=d.size){const{field:e}=d.size;s.setValue(e,t[e])}("undo"===i.type||"redo"===i.type||"update"===i.type&&null!=i.toolEventInfo&&k(i.toolEventInfo.type))&&s.notifyFeatureGeometryChanged()},addUpdatingPromise:e=>{this._updatingHandles.addPromise(e)},addHandle:e=>{this.addHandles(e,V.waitingForTool)},webStyleCache:this._webStyleCache});this.addHandles(n,V.sketchGraphics),t.addHandles(n)}async _initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,{readOnly:o}=e,r=e.edits.feature,{capabilities:a,layer:h}=e.editorItem,d=e.viewModel.view;if(this.removeHandles([V.highlights,V.sketchGraphics,V.sketchViewModel,V.waitingForTool]),!a.update.geometry||o)return{enter:async()=>{this.hasHandles(V.highlights)||this._configureHighlight()},exit:()=>this.removeHandles([V.highlights])};const n=new l({elevationInfo:h.elevationInfo,internal:!0,listMode:"hide",title:"updateFeaturesWorkflow-internal"}),c=new g({allowDeleteKey:!1,layer:n,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,view:d});return this._sketchLayer=n,this._sketchViewModel=c,d?.map.add(n),await(d?.whenLayerView(n)),this.addHandles(i(()=>{d?.destroyed||d?.map.remove(n),n.destroyed||n.destroy(),this._sketchViewModel=s(c)}),V.sketchViewModel),await m(t,this._webStyleCache,"2d"===d?.type?d.scale:null),this.addHandles([await u(n,d,r,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=y(e),{edits:i,layerView:s}=this.data;i.updateGeometry(e.geometry),i.trackChanges(),f(s)&&(this._layerViewEditSession=s.createInteractiveEditSession(t))}static async create(e){const t=new _({data:await d.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}get test(){}};e([r()],v.prototype,"_layerViewEditSession",void 0),e([r()],v.prototype,"_sketchGraphicClone",void 0),e([r()],v.prototype,"_sketchLayer",void 0),e([r()],v.prototype,"_sketchViewModel",void 0),v=_=e([a("esri.widgets.Editor.UpdateFeatureWorkflow")],v);export{v 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../core/Collection.js";import r from"../../core/Error.js";import o from"../../core/Logger.js";import{destroyMaybe as i}from"../../core/maybe.js";import{whenOnce as s}from"../../core/reactiveUtils.js";import{property as a}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{isTable as l}from"../../layers/support/layerUtils.js";import d from"../BatchAttributeForm/BatchAttributeFormViewModel.js";import u from"./UpdateFeaturesWorkflowData.js";import c from"./Workflow.js";import{whenEditorLayerView as p,findEditorItemForLayer as f,makeMultipleSourceLayersError as h}from"./workflowUtils.js";import{SketchController as m}from"./support/SketchController.js";var w;const g=()=>o.getLogger("esri.widgets.Editor.UpdateFeaturesWorkflow");let y=w=class extends c{constructor(e){super(e),this.type="update-features",this._formViewModel=null,this._sketchController=null}async initialize(){this._initializeFormViewModel();try{await this._updatingHandles.addPromise((async()=>{const{fullFeatures:e}=await this.data.when();this._formViewModel.features=new t(e),await this._initializeVisuals(e)})())}catch(e){this.cancel({force:!0,error:new r("update-features-workflow:initialize","Failed to initialize the workflow data.",e)})}}destroy(){this._sketchController=i(this._sketchController),this._formViewModel.destroy()}get features(){return this.data.features}get featureInfos(){return this.data.featureInfos}get formViewModel(){return this._formViewModel}get hasPendingEdits(){const{data:e}=this;return e.fullFeatures.some(t=>!!e.getPendingEditsForFeature(t)?.modified)}get parent(){return this.data.parent}get selectedFeature(){return this.data.selectedFeature}get sketchViewModel(){return this._sketchController?.viewModel}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||!!this._sketchController?.updating}async commit(){const{data:e,_formViewModel:t}=this;for(const r of e.fullFeatures)v(e.getPendingEditsForFeature(r),t.getValues(r));await super.commit()}static create(e){const{applyEdits:t,applyEditsFeatureService:r,...o}=e,{features:i,featureInfos:s,viewModel:a}=o,n=new Set;function l(e){const t=f(a.editorItems,e);t&&n.add(t)}s?.length?s.forEach(({layer:e})=>l(e)):i?.length&&(g().warn("editor:update-features-workflow-data-features","UpdateFeaturesWorkflow: 'features' is deprecrated, use 'featureInfos'"),i.forEach(e=>l(e.sourceLayer??e.layer)));const d=Array.from(n),c=new w({data:new u({...o,editorItems:d}),onCommit:b(e.applyEdits)});return c._set("steps",_()),c}async deleteAndCommit(){return this.data.stageDelete(),this.commit()}enter(){throw new Error("Method not implemented.")}exit(e){throw new Error("Method not implemented.")}async reset(){}async save(){const{formViewModel:e}=this;e.submit(),e.valid&&await super.save()}async start(){await super.start(),await s(()=>!this.updating)}_initializeFormViewModel(){const{data:e}=this,t=e.viewModel.view,r=e.getEditorItemForLayer(k(e)),o=new d({editType:"UPDATE",map:t?.map,readOnly:!1===r?.capabilities.update.attributes,spatialReference:t?.spatialReference,timeZone:e.timeZone});this._formViewModel=o,this.addHandles(o.on("value-change",t=>{for(const r of t.features)e.getPendingEditsForFeature(r)?.setAttribute(t.fieldName,t.value);this._sketchController?.notifyAttributesChanged(t)}))}async _initializeHighlights(e,t,r){const o=await p(r,t);this.addHandles(o.highlight(e))}async _initializeSketchController(e,t,r){const o=new m({sourceLayer:t,view:r,features:e});this._sketchController=o,await s(()=>!o.updating);const{data:i}=this;await o.startUpdatingFeatures(e,e=>{const t=[];for(const{feature:r,geometry:o}of e)i.getPendingEditsForFeature(r)?.updateGeometry(o),t.push(r);this._formViewModel.notifyGeometriesChanged(t)},()=>{g().warnOnce("editor:batch-update-visual-variables","UpdateFeaturesWorkflow does not currently support modifying visual variables through the scale and rotate tools.")})}async _initializeVisuals(e){const{data:t}=this,{view:r}=t.viewModel;if(!r)return;const o=k(t);if(l(o))return;const i=t.getEditorItemForLayer(o);return i?.capabilities.update.geometry?this._initializeSketchController(e,o,r):this._initializeHighlights(e,o,r)}};e([a()],y.prototype,"features",null),e([a()],y.prototype,"featureInfos",null),e([a()],y.prototype,"formViewModel",null),e([a()],y.prototype,"hasPendingEdits",null),e([a()],y.prototype,"parent",null),e([a()],y.prototype,"selectedFeature",null),e([a()],y.prototype,"sketchViewModel",null),e([a()],y.prototype,"type",void 0),e([a()],y.prototype,"updating",null),e([a()],y.prototype,"_formViewModel",void 0),e([a()],y.prototype,"_sketchController",void 0),y=w=e([n("esri.widgets.Editor.UpdateFeaturesWorkflow")],y);const F=y;function _(){return[{id:"editing-features",async setUp(){},async tearDown(){}}]}function b(e){return async t=>{const r=k(t),o=[],i=[];for(const e of t.fullFeatures){const r=t.getPendingEditsForFeature(e),s=r?.stagedForDelete;if(!r?.modified&&!s)continue;const a=e.clone();if(!r?.attributesModified||s){const t=e.sourceLayer;if(!t){g().warn("Feature has no sourceLayer. It will not be included in any applyEdits payload.");continue}const r=t.objectIdField;if(a.attributes={[r]:e.getAttribute(r)},"scene"===t.type&&null!=t.infoFor3D){const r=t.associatedLayer?.globalIdField;null!=r&&a.setAttribute(r,e.getAttribute(r))}}r?.geometryModified&&!s||(a.geometry=null),s?i.push(a):o.push(a)}if(o.length+i.length===0)return void g().warn("No edits to apply. Workflow will finish without sending an applyEdits request.");const s={updateFeatures:o.length>0?o:void 0,deleteFeatures:i.length>0?i:void 0};await e(r,s)}}function k(e){if(e.layers.length>1)throw h();return e.layers[0]}function v(e,t){if(!e||!e.feature)return;const{attributes:r}=e.feature;Object.keys(t).some(e=>t[e]!==r[e])&&e.updateAttributes(t)}export{F as default};
5
+ import{__decorate as e}from"tslib";import t from"../../core/Collection.js";import r from"../../core/Error.js";import o from"../../core/Logger.js";import{destroyMaybe as i}from"../../core/maybe.js";import{whenOnce as s}from"../../core/reactiveUtils.js";import{property as a}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{isTable as l}from"../../layers/support/layerUtils.js";import d from"../BatchAttributeForm/BatchAttributeFormViewModel.js";import u from"./UpdateFeaturesWorkflowData.js";import c from"./Workflow.js";import{whenEditorLayerView as p,findEditorItemForLayer as f}from"./workflowUtils.js";import{MultipleSourceLayersError as h}from"./support/errors.js";import{SketchController as m}from"./support/SketchController.js";var w;const g=()=>o.getLogger("esri.widgets.Editor.UpdateFeaturesWorkflow"),y=Symbol();let F=w=class extends c{constructor(e){super(e),this.type="update-features",this._formViewModel=null,this._sketchController=null}async initialize(){this._initializeFormViewModel();try{await this._updatingHandles.addPromise((async()=>{const{fullFeatures:e}=await this.data.when();this._formViewModel.features=new t(e),this._initializeVisuals(e)})())}catch(e){this.cancel({force:!0,error:new r("update-features-workflow:initialize","Failed to initialize the workflow data.",e)})}}destroy(){this._sketchController=i(this._sketchController),this._formViewModel.destroy()}get features(){return this.data.features}get featureInfos(){return this.data.featureInfos}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return this.data.editorItems.some(e=>e.hasInvalidFormTemplate)}get hasPendingEdits(){const{data:e}=this;return e.fullFeatures.some(t=>!!e.getPendingEditsForFeature(t)?.modified)}get parent(){return this.data.parent}get selectedFeature(){return this.data.selectedFeature}get sketchViewModel(){return this._sketchController?.viewModel}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||!!this._sketchController?.updating}async commit(){const{data:e,_formViewModel:t}=this;for(const r of e.fullFeatures)M(e.getPendingEditsForFeature(r),t.getValues(r));await super.commit()}static create(e){const{applyEdits:t,applyEditsFeatureService:r,...o}=e,{features:i,featureInfos:s,viewModel:a}=o,n=new Set;function l(e){const t=f(a.editorItems,e);t&&n.add(t)}s?.length?s.forEach(({layer:e})=>l(e)):i?.length&&(g().warn("editor:update-features-workflow-data-features","UpdateFeaturesWorkflow: 'features' is deprecrated, use 'featureInfos'"),i.forEach(e=>l(e.sourceLayer??e.layer)));const d=Array.from(n),c=new w({data:new u({...o,editorItems:d}),onCommit:b(e.applyEdits)});return c._set("steps",_()),c}async deleteAndCommit(){return this.data.stageDelete(),this.commit()}async enter(){}exit(e){}async reset(){}async save(){const{formViewModel:e}=this;e.submit(),e.valid&&await super.save()}async start(){await super.start(),await s(()=>!this.updating);const e=this._sketchController;if(e)return e;const{data:t}=this,{view:r}=t.viewModel,o=k(t);return!r||l(o)?{enter:async()=>{},exit:()=>{}}:{enter:()=>this._initializeHighlights(t.fullFeatures,o,r),exit:()=>this.removeHandles(y)}}_initializeFormViewModel(){const{data:e}=this,t=e.viewModel.view,r=e.getEditorItemForLayer(k(e)),o=new d({editType:"UPDATE",map:t?.map,readOnly:!1===r?.capabilities.update.attributes,spatialReference:t?.spatialReference,timeZone:e.timeZone});this._formViewModel=o,this.addHandles(o.on("value-change",t=>{for(const r of t.features)e.getPendingEditsForFeature(r)?.setAttribute(t.fieldName,t.value);this._sketchController?.notifyAttributesChanged(t)}))}async _initializeHighlights(e,t,r){const o=await p(r,t);this.addHandles(o.highlight(e),y)}_initializeSketchController(e,t,r){const{data:o}=this,i=new m({sourceLayer:t,view:r,features:e,onGeometriesUpdated:e=>{const t=[];for(const{feature:r,geometry:i}of e)o.getPendingEditsForFeature(r)?.updateGeometry(i),t.push(r);this._formViewModel.notifyGeometriesChanged(t)},onVisualVariableAttributesUpdated:()=>{g().warnOnce("editor:batch-update-visual-variables","UpdateFeaturesWorkflow does not currently support modifying visual variables through the scale and rotate tools.")}});this._sketchController=i}_initializeVisuals(e){const{data:t}=this,{view:r}=t.viewModel;if(!r)return;const o=k(t);if(l(o))return;const i=t.getEditorItemForLayer(o);i?.capabilities.update.geometry&&this._initializeSketchController(e,o,r)}};e([a()],F.prototype,"features",null),e([a()],F.prototype,"featureInfos",null),e([a()],F.prototype,"formViewModel",null),e([a()],F.prototype,"hasInvalidFormTemplate",null),e([a()],F.prototype,"hasPendingEdits",null),e([a()],F.prototype,"parent",null),e([a()],F.prototype,"selectedFeature",null),e([a()],F.prototype,"sketchViewModel",null),e([a()],F.prototype,"type",void 0),e([a()],F.prototype,"updating",null),e([a()],F.prototype,"_formViewModel",void 0),e([a()],F.prototype,"_sketchController",void 0),F=w=e([n("esri.widgets.Editor.UpdateFeaturesWorkflow")],F);const v=F;function _(){return[{id:"editing-features",async setUp(){},async tearDown(){}}]}function b(e){return async t=>{const r=k(t),o=[],i=[];for(const e of t.fullFeatures){const r=t.getPendingEditsForFeature(e),s=r?.stagedForDelete;if(!r?.modified&&!s)continue;const a=e.clone();if(!r?.attributesModified||s){const t=e.sourceLayer;if(!t){g().warn("Feature has no sourceLayer. It will not be included in any applyEdits payload.");continue}const r=t.objectIdField;if(a.attributes={[r]:e.getAttribute(r)},"scene"===t.type&&null!=t.infoFor3D){const r=t.associatedLayer?.globalIdField;null!=r&&a.setAttribute(r,e.getAttribute(r))}}r?.geometryModified&&!s||(a.geometry=null),s?i.push(a):o.push(a)}if(o.length+i.length===0)return void g().warn("No edits to apply. Workflow will finish without sending an applyEdits request.");const s={updateFeatures:o.length>0?o:void 0,deleteFeatures:i.length>0?i:void 0};await e(r,s)}}function k(e){if(e.layers.length>1)throw new h;return e.layers[0]}function M(e,t){if(!e||!e.feature)return;const{attributes:r}=e.feature;Object.keys(t).some(e=>t[e]!==r[e])&&e.updateAttributes(t)}export{v 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";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 d from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as n}from"../../views/support/HighlightDefaults.js";import c from"./UpdateRecordWorkflowData.js";import u from"./Workflow.js";import{fetchFullFeatures as h}from"./workflowUtils.js";import m 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 d({view:s,highlightName:n}),this.addHandles(i(()=>this._highlightHelper?.removeAll())));const c=new AbortController;this.addHandles(r(c)),this._updatingHandles.addPromise(h([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 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}stageDelete(){this.data.edits.stageDelete()}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 m({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,"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{__decorate as e}from"tslib";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 m from"./Workflow.js";import{fetchFullFeatures as h}from"./workflowUtils.js";import p from"../FeatureForm/FeatureFormViewModel.js";var u;const f={exit:Symbol()};let g=class extends m{static{u=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(h([l],l.sourceLayer,e.viewModel.view.spatialReference,c.signal).then(([e])=>{a(c)||(this._onFullFeatureLoaded(e),this._initializeFormViewModel())},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 formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return this.data.editorItem.hasInvalidFormTemplate}get hasPendingEdits(){return this.data.edits.modified}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}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 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)}_initializeFormViewModel(){const{association:e,edits:t,formTemplate:i,viewModel:{view:r},readOnly:a}=this.data,s=this._formViewModel=new p({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 u({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,"_formViewModel",void 0),e([s()],g.prototype,"editorItem",null),e([s()],g.prototype,"formViewModel",null),e([s()],g.prototype,"fullFeature",void 0),e([s()],g.prototype,"hasInvalidFormTemplate",null),e([s()],g.prototype,"hasPendingEdits",null),e([s()],g.prototype,"layer",null),e([s()],g.prototype,"parent",null),e([s()],g.prototype,"shouldShowAttachments",null),e([s()],g.prototype,"shouldAllowAttachmentEditing",null),e([s()],g.prototype,"reliesOnOwnerAdminPrivileges",null),g=u=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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";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";import{findEditorItemForLayer as a}from"./workflowUtils.js";var p;let d=p=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=p._makeConstructorProps(t);return new p(e)}static _makeConstructorProps(t){const{association:e,feature:r,parent:s,featureFormCallbacks:p,viewModel:d,readOnly:l}=t,n=a(d.editorItems,r.sourceLayer);if(!n)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:n,edits:new i({feature:r}),parent:s,featureFormCallbacks:p,viewModel:d,readOnly:l??!1}}};t([r()],d.prototype,"association",void 0),t([r()],d.prototype,"attachmentsCapabilities",null),t([r({constructOnly:!0})],d.prototype,"editorItem",void 0),t([r()],d.prototype,"edits",void 0),t([r()],d.prototype,"formTemplate",null),t([r()],d.prototype,"parent",void 0),t([r()],d.prototype,"featureFormCallbacks",void 0),t([r()],d.prototype,"viewModel",void 0),t([r()],d.prototype,"readOnly",void 0),d=p=t([s("esri.widgets.Editor.UpdateRecordWorkflowData")],d);const l=d;export{l as default};
5
+ import{__decorate as t}from"tslib";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";import{findEditorItemForLayer as a}from"./workflowUtils.js";var p;let d=p=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=p._makeConstructorProps(t);return new p(e)}stageDelete(){this.edits.stageDelete()}static _makeConstructorProps(t){const{association:e,feature:r,parent:s,featureFormCallbacks:p,viewModel:d,readOnly:l}=t,n=a(d.editorItems,r.sourceLayer);if(!n)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:n,edits:new i({feature:r}),parent:s,featureFormCallbacks:p,viewModel:d,readOnly:l??!1}}};t([r()],d.prototype,"association",void 0),t([r()],d.prototype,"attachmentsCapabilities",null),t([r({constructOnly:!0})],d.prototype,"editorItem",void 0),t([r()],d.prototype,"edits",void 0),t([r()],d.prototype,"formTemplate",null),t([r()],d.prototype,"parent",void 0),t([r()],d.prototype,"featureFormCallbacks",void 0),t([r()],d.prototype,"viewModel",void 0),t([r()],d.prototype,"readOnly",void 0),d=p=t([s("esri.widgets.Editor.UpdateRecordWorkflowData")],d);const l=d;export{l as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../Graphic.js";import i from"../../core/Error.js";import{makeHandle as a}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 w,sync as h,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 A,isTable as _}from"../../layers/support/layerUtils.js";import{createFeatureServices as b}from"../../rest/featureService/utils.js";import C from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as F}from"../../views/input/InputManager.js";import{temporaryHighlightName as S}from"../../views/support/HighlightDefaults.js";import M from"./CreateFeaturesWorkflow.js";import I from"./SplitFeatureWorkflow.js";import{UpdateFeatureWorkflow as E}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as R}from"./UpdateRecordWorkflow.js";import V from"./UpdateWorkflowData.js";import U from"./Workflow.js";import{findEditorItemForLayer as j,isSplitFeatureWorkflow as P,isUpdateRecordWorkflow as L,isParentWorkflow as O,findEditorItemForLayerOrThrow as x,createWorkflowSteps as T,fetchCandidates as H}from"./workflowUtils.js";import{findUtilityNetwork as N,isGraphicForRelatableFeatureSupportedLayer as D}from"../Feature/support/featureUtils.js";var q;let G=q=class extends U{constructor(t){super(t),this._workflowStack=new p(g),this._sketchStack=new p(g),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack(t=>t.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:t}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!t)return!1;const{activeAssociation:e,feature:i}=t;return!(!e||!i?.sourceLayer||!y(i?.sourceLayer)&&!W(i?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const t=this.activeWorkflow?.featureFormViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||null!=t?.relationshipId||"view"!==this.data.viewModel.attachmentsViewModel.mode||null!=t?.associationId||null!=t?.associatedLayer}get hasUpdatableCandidates(){const{candidates:t,viewModel:e}=this.data;return t.some(({layer:t})=>j(e.editorItems,t)?.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(t=>t.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(t=()=>Promise.resolve(!0)){const{activeWorkflow:e}=this,i=e?.featureFormViewModel;if(i?.activeRelationshipInput){const t=i.activeRelationshipInput;if(t.activeCategory)return void(t.activeCategory=null);if(null!=i.relationshipId)return void(i.relationshipId=null);if(t.showAllEnabled)return void(t.showAllEnabled=!1)}if("add-association"===e?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:t}=this;if(t?.filterOptionsVisible)return void(t.filterOptionsVisible=!1);t?.featureSpatialItems.length&&t.reset()}if(null==i?.associatedLayer)if(null==i?.associationId)if("create-features"===e?.type&&e.hasPreviousStep)await e.previous({cancelCurrentStep:!0});else{if(P(e)&&e.hasPreviousStep)return await e.back();if(e){if(e.hasPendingEdits&&!i?.disabled){if(!await t())return}e.hasPreviousStep?await e.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}else i.associationId=null;else i.associatedLayer=null}async cancelActiveWorkflow(t){await(this.activeWorkflow?.cancel(t)),await this._popWorkflowAndReconcile()}async commit(){await this._drainWorkflowStack(t=>t.commit()),await super.commit()}static create(t){const{startAt:e,applyEdits:i,applyEditsFeatureService:a,...o}=t,r=new q({data:new V({applyEditsCallback:i,applyEditsFeatureServiceCallback:a,...o}),onCommit:async()=>{}});return r._set("steps",this._createWorkflowSteps(r,e)),r}async save(){const{activeFeatureFormViewModel:t}=this;if(t){if(t.submit(),!t.submittable||t.pendingSubtypeChoice)return;const e=t.getValues();if(t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0)return}if(this.nestedWorkflowCount<2)return await this.commit();const{activeWorkflow:e}=this;if(await(e?.commit()),!P(e))return void await this._popWorkflowAndReconcile();this._popWorkflow();const i=this._workflowStack.peek();if(i&&i===e?.parent&&(await i.cancel(),this._popWorkflow(),0===this.nestedWorkflowCount))return await this.commit();await this._reconcileWorkflowStack()}async startCreatingRelatedRecord(t){try{const e=this._createNestedCreateFeaturesWorkflow(t);await this._pushWorkflowAndReconcile(e)}catch(e){throw new i("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:e})}}async startSplittingFeature(t,e){try{const i=await this._createNestedSplitFeatureWorkflow(t,e);await this._pushWorkflowAndReconcile(i)}catch(a){throw new i("editor:unable-to-start-splitting","Could not begin splitting the provided feature.",{error:a})}}async startUpdating(t,e){try{const i=await this._createNestedUpdateWorkflow(t,e);await this._pushWorkflowAndReconcile(i)}catch(a){throw new i("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:a})}}async startAddAssociation(t,e,a){try{const i=await this._createNestedAddAssociationWorkflow(t,e,a);await this._pushWorkflowAndReconcile(i)}catch(o){throw new i("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}}async deleteActiveFeature(){const{activeWorkflow:t}=this;if(!t)throw new i("editor:nothing-to-delete","There is no feature to delete");const e=L(t);e?(t.stageDelete(),t.data.edits.feature===this.data.rootFeature&&this._removeRootFeatureFromCandidates()):await t.cancel(),this.nestedWorkflowCount<2?e?await this.commit():await this.cancel({force:!0}):(e&&await t.commit(),await this._popWorkflowAndReconcile(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new i("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflowAndReconcile(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack(t=>t.cancel({force:!0}))}async _deleteActiveAssociation(){const{activeFeatureFormViewModel:t,data:e}=this,{activeAssociation:a,feature:o}=t,{applyEditsFeatureServiceCallback:r,viewModel:s}=e,{sourceLayer:n}=o,l=W(n)&&n.parent?n.parent:n,d=b([l]),c=d.values().next().value?.featureService;if(!c)throw new i("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(c?.load());const p=s.view.map,u=N(p,l);await(u?.networkSystemLayers.loadAssociationsTable());const w=u?.generateDeleteAssociations([a]);if(!w)throw new i("editor:failed-to-delete-association","Could not create payload needed to delete association");const h=u?.gdbVersion??void 0;await r(c,[w],{gdbVersion:h,globalIdUsed:!0})}_removeRootFeatureFromCandidates(){const{candidates:t,rootFeature:e}=this.data;if(0===t.length||!e)return;const i=t.indexOf(e);i>-1&&t.splice(i,1)}async _returnToPageWithContent(){const{activeFeatureFormViewModel:t}=this;if(!t?.activeAssociationInput)return;const{activeAssociationInput:e,associationId:i}=t;await e.refresh(),e.associatedLayer&&!e.associatedFeatures?.length&&(t.associatedLayer=null),null==i||e.associatedFeatureInfos.size||(t.associationId=null)}_createNestedCreateFeaturesWorkflow(t){const{relatedLayer:e}=t,{addAttachmentsCallback:a,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!m(e))throw new i("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(t),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p=O(this.activeWorkflow)?this.activeWorkflow:void 0;return M.create({addAttachmentsCallback:a,applyEdits:o,applyEditsFeatureService:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(t){const{relatedLayer:a}=t;if(!m(a)||A(a))throw new i("editor:unsupported-layer","Editing is not supported on the provided layer");const{viewModel:o}=this.data,r={layer:a,maxFeatures:1},s=this._makeRelatedRecordAttributes(t),n=o.getTemplatesForLayer(a);return n?.length>0?(r.attributeOverrides=s,1===n.length&&(r.template=n[0])):r.initialFeature=new e({sourceLayer:a,attributes:s}),r}async _createNestedUpdateWorkflow(t,e={}){const i=_(t.sourceLayer)?R:E,{applyEditsCallback:a,applyEditsFeatureServiceCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l=O(this.activeWorkflow)?this.activeWorkflow:void 0,d=await i.create({feature:t,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:a,applyEditsFeatureService:o,featureFormCallbacks:{addRelatedRecord:async t=>await this._updatingHandles.addPromise(this.startCreatingRelatedRecord(t)),editRelatedRecord:async({relatedFeature:t,readOnly:e})=>await this._updatingHandles.addPromise(this.startUpdating(t,{readOnly:e})),selectAssociatedFeature:async({feature:t,association:e})=>await this._updatingHandles.addPromise(this.startUpdating(t,{association:e})),addAssociation:async t=>await this._updatingHandles.addPromise(this.startAddAssociation(t.feature,t.utilityNetwork,t.associationType))},...e});return await u(()=>!d.updating),d}async _createNestedAddAssociationWorkflow(t,e,i){const{AddAssociationWorkflow:a}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:o,applyEditsFeatureServiceCallback:r,viewModel:s}=this.data,n=O(this.activeWorkflow)?this.activeWorkflow:void 0,l=this.activeFeatureFormViewModel?.activeAssociationInput,d=await a.create({utilityNetwork:e,associationType:i,feature:t,parent:n,viewModel:s,associationInput:l,applyEdits:o,applyEditsFeatureService:r});return await u(()=>!d.updating),d}async _createNestedSplitFeatureWorkflow(t,e){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,sketchOptions:o,snappingManager:r,viewModel:s}=this.data,n=O(this.activeWorkflow)?this.activeWorkflow:void 0,l=x(s.editorItems,t.sourceLayer),d=I.create({applyEdits:i,applyEditsFeatureService:a,editorItem:l,originalFeature:t,parent:n,sketchOptions:o,snappingManager:r,viewModel:s,...e});return await u(()=>!d.updating),d}async _drainWorkflowStack(t){const e=this._workflowStack,i=[];for(const a of e){const e=t(a).finally(()=>a.destroy());this._updatingHandles.addPromise(e),i.push(e)}await Promise.all(i),this._workflowStack.clear(),this._sketchStack.clear()}_makeRelatedRecordAttributes(t){const{parentFeature:e,relatedLayer:i,relationshipId:a}=t;if(!D(e))return;const o=i.relationships?.find(t=>t.id===a);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=e.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(t=>t.id===a);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=z(r,s),l=e.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=z(i,o);return{[d]:l}}_popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop()}async _popWorkflowAndReconcile(){this._popWorkflow();const t=await this._reconcileWorkflowStack();if(t.failureCount>0)throw new i("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",t)}async _pushWorkflowAndReconcile(t){const e=this._workflowRequiresSketchViewModel(t);this.activeWorkflow?.exit({removeSketchHandles:e});const a=this._sketchStack,o=await(t?.start()),r=a.peek();o?(r?.exit(),a.push(o)):a.push(this._cloneSketchController(r)),this._workflowStack.push(t);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new i("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const t=this._workflowStack,e=this._sketchStack;try{const i=t.peek();return await(i?.enter()),await(e.peek()?.enter()),{activeWorkflow:i,failureCount:0}}catch(i){t.pop().destroy(),e.pop();const{activeWorkflow:a,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:a,failureCount:o+1}}}_cloneSketchController(t){return{enter:t?.enter??(async()=>{}),exit:t?.exit??(async()=>{}),viewModel:t?.viewModel}}_workflowRequiresSketchViewModel(t){const{type:e}=t;return"update-feature"===e||"create-features"===e&&!_(t.data.creationInfo?.layer)}static _createWorkflowSteps(t,e="awaiting-feature-to-update"){const{data:o}=t;return T(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],e,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:e}=o.viewModel,i=o.viewModel.view;i.activeTool=null;let s=null;t.addHandles(a(()=>{s=r(s)}),this.id),o.rootFeature=null,o.candidates=[];const p=i.on("immediate-click",async a=>{const r=n();t._updatingHandles.addPromise(r.promise);try{e.location=a.mapPoint,e.visible=!0,s?.abort();const{editorItems:r}=o.viewModel;s=new AbortController;const n=await a.defer(()=>new Promise((t,e)=>{l(s?.signal,()=>e(d())),t(H(r,i,a,s?.signal))}));if(c(s),o.candidates=n.filter(t=>"fulfilled"===t.status).flatMap(t=>t.value).filter(t=>!t.isAggregate),e.visible=1===o.candidates.length,0===o.candidates.length)return;a.stopPropagation(),1===o.candidates.length?(o.rootFeature=o.candidates[0],t.go("editing-existing-feature").catch(()=>{}).then(()=>e.visible=!1)):t.next()}finally{r.resolve()}},F.TOOL),u=f(()=>null!=i.activeTool,()=>t.cancel({force:!0}),{once:!0});i.focus(),t.addHandles([p,u],this.id)},async tearDown(){0===o.candidates.length&&(o.viewModel.spinnerViewModel.visible=!1),t.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null;const{view:e}=o.viewModel;if(!e)return;const i=new C({view:e,highlightName:S});t.addHandles([w(()=>o.rootFeature,(t,e)=>{i.remove(e),i.add(t)},h),a(()=>i.removeAll())],this.id)},async tearDown(){t.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{data:e}=t,{rootFeature:a}=e;if(!a)throw new i("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");"split"===e.rootWorkflowOptions?.type?await t.startSplittingFeature(a,e.rootWorkflowOptions.props):await t.startUpdating(a),e.viewModel.spinnerViewModel.visible=!1;const o=s(async()=>{await u(()=>!t.updating),t.previous()});t.addHandles([w(()=>t.nestedWorkflowCount,(t,e)=>{0===t&&0!==e&&o()},h)],this.id)},async tearDown(){await t.cancelAll(),t.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(t,e){o.getLogger(this).warn(`editor:${t}`,e,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature.")}};function z(t,{keyField:e}){return t.getField(e)?.name??e}t([v()],G.prototype,"activeEditorItem",null),t([v()],G.prototype,"activeFeatureFormViewModel",null),t([v()],G.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),t([v()],G.prototype,"activeSketchViewModel",null),t([v()],G.prototype,"canDeleteAssociation",null),t([v()],G.prototype,"activeWorkflow",null),t([v()],G.prototype,"updating",null),t([v()],G.prototype,"data",void 0),t([v()],G.prototype,"hasPreviousStep",null),t([v()],G.prototype,"hasUpdatableCandidates",null),t([v()],G.prototype,"nestedWorkflowCount",null),t([v()],G.prototype,"shouldShowAttachments",null),t([v()],G.prototype,"shouldAllowAttachmentEditing",null),t([v()],G.prototype,"hasPendingEdits",null),t([v()],G.prototype,"helpMessage",null),t([v()],G.prototype,"reliesOnOwnerAdminPrivileges",null),t([v()],G.prototype,"hasInvalidFormTemplate",null),G=q=t([k("esri.widgets.Editor.UpdateWorkflow")],G);const Q=G;export{Q as default};
5
+ import{__decorate as t}from"tslib";import e from"../../Graphic.js";import{remove as i}from"../../core/arrayUtils.js";import a from"../../core/Error.js";import{makeHandle as o}from"../../core/handleUtils.js";import r from"../../core/Logger.js";import{abortMaybe as s}from"../../core/maybe.js";import{debounce as n,createResolver as l,onAbort as d,createAbortError as c,throwIfAborted as p}from"../../core/promiseUtils.js";import u from"../../core/Queue.js";import{whenOnce as w,watch as h,sync as f,on as g,when as v}from"../../core/reactiveUtils.js";import{last as k}from"../../core/SetUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{getGraphicLayer as W}from"../../graphic/graphicOriginUtils.js";import{isEditableLayer as A}from"../../layers/support/editableLayers.js";import{isFeatureLayer as _,isSubtypeSublayer as b,isSubtypeGroupLayer as S,isTable as C}from"../../layers/support/layerUtils.js";import{createFeatureServices as F}from"../../rest/featureService/utils.js";import M from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as E}from"../../views/input/InputManager.js";import{temporaryHighlightName as I}from"../../views/support/HighlightDefaults.js";import U from"./CreateFeaturesWorkflow.js";import R from"./MergeFeaturesWorkflow.js";import j from"./SplitFeatureWorkflow.js";import V from"./UpdateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as P}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as L}from"./UpdateRecordWorkflow.js";import N from"./UpdateWorkflowData.js";import O from"./Workflow.js";import{isFeatureFormViewModel as T,findEditorItemForLayer as x,isSplitFeatureWorkflow as H,workflowInfluencesOutcomeOfParent as D,isAnyUpdateLeafWorkflow as q,isUpdateRecordWorkflow as z,isParentWorkflow as G,findEditorItemForLayerOrThrow as Q,createWorkflowSteps as $,fetchCandidates as B,isUpdateFeaturesWorkflowOptions as J,featuresToFeatureInfos as K,isMergeWorkflowOptions as X,isSplitWorkflowOptions as Y}from"./workflowUtils.js";import{assertFeaturesAreFromSameLayer as Z}from"./support/errors.js";import{findUtilityNetwork as tt,isGraphicForRelatableFeatureSupportedLayer as et}from"../Feature/support/featureUtils.js";var it;let at=it=class extends O{constructor(t){super(t),this._workflowStack=new u(k),this._sketchStack=new u(k),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack(t=>t.cancel({force:!0}))}get activeFormViewModel(){return this.activeWorkflow?.formViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{activeFormViewModel:t}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!T(t))return!1;const{activeAssociation:e,feature:i}=t;return!(!e||!i?.sourceLayer||!_(i?.sourceLayer)&&!b(i?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const t=this.activeWorkflow?.formViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||"view"!==this.data.viewModel.attachmentsViewModel.mode||T(t)&&(null!=t.relationshipId||null!=t.associationId||null!=t.associatedLayer)}get hasUpdatableCandidates(){const{candidates:t,viewModel:e}=this.data;return t.some(({layer:t})=>x(e.editorItems,t)?.supportsUpdateWorkflow)}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return this.activeWorkflow?.shouldShowAttachments??!1}get shouldAllowAttachmentEditing(){return this.activeWorkflow?.shouldAllowAttachmentEditing??!1}get hasPendingEdits(){return Array.from(this._workflowStack).some(t=>t.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.activeWorkflow?.hasInvalidFormTemplate??!1}async back(t=()=>Promise.resolve(!0)){const{activeWorkflow:e}=this,i=e?.formViewModel;if(T(i)){if(i?.activeRelationshipInput){const t=i.activeRelationshipInput;if(t.activeCategory)return void(t.activeCategory=null);if(null!=i.relationshipId)return void(i.relationshipId=null);if(t.showAllEnabled)return void(t.showAllEnabled=!1)}if("add-association"===e?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:t}=this;if(t?.filterOptionsVisible)return void(t.filterOptionsVisible=!1);t?.featureSpatialItems.length&&t.reset()}if(null!=i?.associatedLayer)return void(i.associatedLayer=null);if(null!=i?.associationId)return void(i.associationId=null)}if("create-features"===e?.type&&e.hasPreviousStep)await e.previous({cancelCurrentStep:!0});else{if(H(e)&&e.hasPreviousStep)return await e.back();if(e){if(e.hasPendingEdits&&!i?.disabled){if(!await t())return}e.hasPreviousStep?await e.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}}async cancelActiveWorkflow(t){await(this.activeWorkflow?.cancel(t)),await this._popWorkflowAndReconcile()}async commit(){await this._drainWorkflowStack(t=>t.commit()),await super.commit()}static create(t){const{startAt:e,applyEdits:i,applyEditsFeatureService:a,...o}=t,r=new it({data:new N({applyEditsCallback:i,applyEditsFeatureServiceCallback:a,...o}),onCommit:async()=>{}});return r._set("steps",this._createWorkflowSteps(r,e)),r}async save(){const{activeFormViewModel:t}=this;if(t&&(t.submit(),!t.submittable||T(t)&&rt(t)))return;if(this.nestedWorkflowCount<2)return await this.commit();const{activeWorkflow:e}=this;if(await(e?.commit()),!D(e))return void await this._popWorkflowAndReconcile();this._popWorkflow();const i=this._workflowStack.peek();if(i&&i===e?.parent&&(await i.cancel(),this._popWorkflow(),0===this.nestedWorkflowCount))return await this.commit();await this._reconcileWorkflowStack()}async startCreatingRelatedRecord(t){try{const e=this._createNestedCreateFeaturesWorkflow(t);await this._pushWorkflowAndReconcile(e)}catch(e){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:e})}}async startMergingFeatures(t,e){try{const i=await this._createNestedMergeFeaturesWorkflow(t,e);await this._pushWorkflowAndReconcile(i)}catch(i){throw new a("editor:unable-to-start-merging","Could not begin merging the provided features.",{error:i})}}async startSplittingFeature(t,e){try{const i=await this._createNestedSplitFeatureWorkflow(t,e);await this._pushWorkflowAndReconcile(i)}catch(i){throw new a("editor:unable-to-start-splitting","Could not begin splitting the provided feature.",{error:i})}}async startUpdatingSingle(t,e){try{const i=await this._createNestedUpdateWorkflow(t,e);await this._pushWorkflowAndReconcile(i)}catch(i){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:i})}}async startUpdatingMultiple(t,e){try{const i=await this._createNestedUpdateFeaturesWorkflow(t,e);await this._pushWorkflowAndReconcile(i)}catch(i){throw new a("editor:unable-to-start-updating","Could not begin updating the provided features or table records.",{error:i})}}async startAddAssociation(t,e,i){try{const a=await this._createNestedAddAssociationWorkflow(t,e,i);await this._pushWorkflowAndReconcile(a)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}}async deleteActiveFeatures(){const{activeWorkflow:t}=this;if(!t)throw new a("editor:nothing-to-delete","There is no feature to delete");const e=q(t);if(e){t.data.stageDelete();const e=z(t)?t.data.edits.feature?[t.data.edits.feature]:[]:t.data.features;this._removeFeaturesFromCandidates(e)}else await t.cancel();this.nestedWorkflowCount<2?e?await this.commit():await this.cancel({force:!0}):(e&&await t.commit(),await this._popWorkflowAndReconcile(),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._popWorkflowAndReconcile(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack(t=>t.cancel({force:!0}))}async _deleteActiveAssociation(){const{activeFormViewModel:t}=this;if(!T(t))throw new a("editing:failed-to-delete-association","The active workflow does not support editing associations");const{activeAssociation:e,feature:i}=t,{applyEditsFeatureServiceCallback:o,viewModel:r}=this.data,{sourceLayer:s}=i,n=b(s)&&s.parent?s.parent:s,l=F([n]),d=l.values().next().value?.featureService;if(!d)throw new a("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(d?.load());const c=r.view.map,p=tt(c,n);await(p?.networkSystemLayers.loadAssociationsTable());const u=p?.generateDeleteAssociations([e]);if(!u)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");const w=p?.gdbVersion??void 0;await o(d,[u],{gdbVersion:w,globalIdUsed:!0})}_removeFeaturesFromCandidates(t){const{candidates:e}=this.data;if(0!==e.length&&0!==t.length)for(const a of t)i(e,a)}async _returnToPageWithContent(){const{activeFormViewModel:t}=this;if(!T(t)||!t?.activeAssociationInput)return;const{activeAssociationInput:e,associationId:i}=t;await e.refresh(),e.associatedLayer&&!e.associatedFeatures?.length&&(t.associatedLayer=null),null==i||e.associatedFeatureInfos.size||(t.associationId=null)}_createNestedCreateFeaturesWorkflow(t){const{relatedLayer:e}=t,{addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!A(e))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(t),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p=G(this.activeWorkflow)?this.activeWorkflow:void 0;return U.create({addAttachmentsCallback:i,applyEdits:o,applyEditsFeatureService:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(t){const{relatedLayer:i}=t;if(!A(i)||S(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(t),n=o.getTemplatesForLayer(i);return n?.length>0?(r.attributeOverrides=s,1===n.length&&(r.template=n[0])):r.initialFeature=new e({sourceLayer:i,attributes:s}),r}async _createNestedUpdateWorkflow(t,e={}){const i=C(t.sourceLayer)?L:P,{applyEditsCallback:a,applyEditsFeatureServiceCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l=G(this.activeWorkflow)?this.activeWorkflow:void 0,d=await i.create({feature:t,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:a,applyEditsFeatureService:o,featureFormCallbacks:{addRelatedRecord:async t=>await this._updatingHandles.addPromise(this.startCreatingRelatedRecord(t)),editRelatedRecord:async({relatedFeature:t,readOnly:e})=>await this._updatingHandles.addPromise(this.startUpdatingSingle(t,{readOnly:e})),selectAssociatedFeature:async({feature:t,association:e})=>await this._updatingHandles.addPromise(this.startUpdatingSingle(t,{association:e})),addAssociation:async t=>await this._updatingHandles.addPromise(this.startAddAssociation(t.feature,t.utilityNetwork,t.associationType))},...e});return await w(()=>!d.updating),d}async _createNestedUpdateFeaturesWorkflow(t,e={}){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,viewModel:o}=this.data,r=V.create({applyEdits:i,applyEditsFeatureService:a,featureInfos:t,viewModel:o,...e});return await w(()=>!r.updating),r}async _createNestedAddAssociationWorkflow(t,e,i){const{AddAssociationWorkflow:o}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:r,applyEditsFeatureServiceCallback:s,viewModel:n}=this.data,l=G(this.activeWorkflow)?this.activeWorkflow:void 0,{activeFormViewModel:d}=this,c=T(d)?d.activeAssociationInput:null;if(!c)throw new a("editing:unable-to-add-association","There is no active association input in the current workflow's form.");const p=await o.create({utilityNetwork:e,associationType:i,feature:t,parent:l,viewModel:n,associationInput:c,applyEdits:r,applyEditsFeatureService:s});return await w(()=>!p.updating),p}async _createNestedMergeFeaturesWorkflow(t,e){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,viewModel:o}=this.data;Z(t);const r=Q(this.data.viewModel.editorItems,W(t[0])),s=G(this.activeWorkflow)?this.activeWorkflow:void 0,n=await R.create({applyEdits:i,applyEditsFeatureService:a,editorItem:r,features:t,parent:s,viewModel:o,...e});return await w(()=>!n.updating),n}async _createNestedSplitFeatureWorkflow(t,e){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,sketchOptions:o,snappingManager:r,viewModel:s}=this.data,n=G(this.activeWorkflow)?this.activeWorkflow:void 0,l=Q(s.editorItems,t.sourceLayer),d=j.create({applyEdits:i,applyEditsFeatureService:a,editorItem:l,originalFeature:t,parent:n,sketchOptions:o,snappingManager:r,viewModel:s,...e});return await w(()=>!d.updating),d}async _drainWorkflowStack(t){const e=this._workflowStack,i=[];for(const a of e){const e=t(a).finally(()=>a.destroy());this._updatingHandles.addPromise(e),i.push(e)}await Promise.all(i),this._workflowStack.clear(),this._sketchStack.clear()}_makeRelatedRecordAttributes(t){const{parentFeature:e,relatedLayer:i,relationshipId:a}=t;if(!et(e))return;const o=i.relationships?.find(t=>t.id===a);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=e.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(t=>t.id===a);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=ot(r,s),l=e.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=ot(i,o);return{[d]:l}}_popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop()}async _popWorkflowAndReconcile(){this._popWorkflow();const t=await this._reconcileWorkflowStack();if(t.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",t)}async _pushWorkflowAndReconcile(t){const e=this._workflowRequiresSketchViewModel(t);this.activeWorkflow?.exit({removeSketchHandles:e});const i=this._sketchStack,o=await(t?.start()),r=i.peek();o?(r?.exit(),i.push(o)):i.push(this._cloneSketchController(r)),this._workflowStack.push(t);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 t=this._workflowStack,e=this._sketchStack;try{const i=t.peek();return await(i?.enter()),await(e.peek()?.enter()),{activeWorkflow:i,failureCount:0}}catch(i){t.pop().destroy(),e.pop();const{activeWorkflow:a,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:a,failureCount:o+1}}}_cloneSketchController(t){return{enter:t?.enter??(async()=>{}),exit:t?.exit??(async()=>{}),viewModel:t?.viewModel}}_workflowRequiresSketchViewModel(t){const{type:e}=t;return"update-feature"===e||"create-features"===e&&!C(t.data.creationInfo?.layer)}static _createWorkflowSteps(t,e="awaiting-feature-to-update"){const{data:i}=t;return $(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],e,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:e}=i.viewModel,a=i.viewModel.view;a.activeTool=null;let r=null;t.addHandles(o(()=>{r=s(r)}),this.id),i.rootFeatures.removeAll(),i.candidates=[];const n=a.on("immediate-click",async o=>{const s=l();t._updatingHandles.addPromise(s.promise);try{e.location=o.mapPoint,e.visible=!0,r?.abort();const{editorItems:s}=i.viewModel;r=new AbortController;const n=await o.defer(()=>new Promise((t,e)=>{d(r?.signal,()=>e(c())),t(B(s,a,o,r?.signal))}));if(p(r),i.candidates=n.filter(t=>"fulfilled"===t.status).flatMap(t=>t.value).filter(t=>!t.isAggregate),e.visible=1===i.candidates.length,0===i.candidates.length)return;if(o.stopPropagation(),1===i.candidates.length){const{rootFeatures:a}=i;a.removeAll(),a.add(i.candidates[0]),t.go("editing-existing-feature").catch(()=>{}).then(()=>e.visible=!1)}else t.next()}finally{s.resolve()}},E.TOOL),u=v(()=>null!=a.activeTool,()=>t.cancel({force:!0}),{once:!0});a.focus(),t.addHandles([n,u],this.id)},async tearDown(){0===i.candidates.length&&(i.viewModel.spinnerViewModel.visible=!1),t.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){i.rootFeatures.removeAll();const{view:e}=i.viewModel;if(!e)return;const a=new M({view:e,highlightName:I});t.addHandles([g(()=>i.rootFeatures,"change",({added:t,removed:e})=>{e.forEach(t=>a.remove(t)),t.forEach(t=>a.add(t))},f),o(()=>a.removeAll())],this.id)},async tearDown(){t.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){await st(t);const{data:e}=t;e.viewModel.spinnerViewModel.visible=!1;const i=n(async()=>{await w(()=>!t.updating),t.previous()});t.addHandles([h(()=>t.nestedWorkflowCount,(t,e)=>{0===t&&0!==e&&i()},f)],this.id)},async tearDown(){await t.cancelAll(),t.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}})})}_logContinuingWithoutRelationshipWarning(t,e){r.getLogger(this).warn(`editor:${t}`,e,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature.")}};function ot(t,{keyField:e}){return t.getField(e)?.name??e}function rt(t){if(t.pendingSubtypeChoice)return!0;const e=t.getValues();return t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0}async function st(t){const{data:e}=t,{rootWorkflowOptions:i}=e;if(J(i)){const{rootFeatureInfos:o}=e,r=o.length>0?o:K(e.rootFeatures.toArray());if(0===r.length)throw new a("editing:invalid-parameter","Must supply `rootFeatureInfos` or `rootFeatures` when root workflow type is 'update-multiple'");return await t.startUpdatingMultiple(r,i.props)}const{rootFeatures:o}=e,r=o.getItemAt(0);if(!r)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until one or more root features are provided");X(i)?await t.startMergingFeatures(o.toArray(),i.props):Y(i)?await t.startSplittingFeature(r,i.props):await t.startUpdatingSingle(r)}t([m()],at.prototype,"activeFormViewModel",null),t([m()],at.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),t([m()],at.prototype,"activeSketchViewModel",null),t([m()],at.prototype,"canDeleteAssociation",null),t([m()],at.prototype,"activeWorkflow",null),t([m()],at.prototype,"updating",null),t([m()],at.prototype,"data",void 0),t([m()],at.prototype,"hasPreviousStep",null),t([m()],at.prototype,"hasUpdatableCandidates",null),t([m()],at.prototype,"nestedWorkflowCount",null),t([m()],at.prototype,"shouldShowAttachments",null),t([m()],at.prototype,"shouldAllowAttachmentEditing",null),t([m()],at.prototype,"hasPendingEdits",null),t([m()],at.prototype,"helpMessage",null),t([m()],at.prototype,"reliesOnOwnerAdminPrivileges",null),t([m()],at.prototype,"hasInvalidFormTemplate",null),at=it=t([y("esri.widgets.Editor.UpdateWorkflow")],at);const nt=at;export{nt 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import o from"../../core/Accessor.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import s from"../../views/interactive/sketch/SketchOptions.js";let p=class extends o{constructor(t){super(t),this.addAttachmentsCallback=null,this.applyEditsCallback=null,this.applyEditsFeatureServiceCallback=null,this.candidates=[],this.rootFeature=null,this.rootWorkflowOptions={type:"update"},this.sketchOptions=new s,this.snappingManager=null,this.viewModel=null}};t([e()],p.prototype,"addAttachmentsCallback",void 0),t([e()],p.prototype,"applyEditsCallback",void 0),t([e()],p.prototype,"applyEditsFeatureServiceCallback",void 0),t([e()],p.prototype,"candidates",void 0),t([e()],p.prototype,"rootFeature",void 0),t([e()],p.prototype,"rootWorkflowOptions",void 0),t([e({constructOnly:!0})],p.prototype,"sketchOptions",void 0),t([e()],p.prototype,"snappingManager",void 0),t([e()],p.prototype,"viewModel",void 0),p=t([r("esri.widgets.Editor.UpdateWorkflowData")],p);const i=p;export{i as default};
5
+ import{__decorate as o}from"tslib";import t from"../../core/Accessor.js";import e from"../../core/Collection.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 p from"../../views/interactive/sketch/SketchOptions.js";let i=class extends t{constructor(o){super(o),this.addAttachmentsCallback=null,this.applyEditsCallback=null,this.applyEditsFeatureServiceCallback=null,this.candidates=[],this.rootFeatures=new e,this.rootFeatureInfos=[],this.rootWorkflowOptions={type:"update-single"},this.sketchOptions=new p,this.snappingManager=null,this.viewModel=null}};o([r()],i.prototype,"addAttachmentsCallback",void 0),o([r()],i.prototype,"applyEditsCallback",void 0),o([r()],i.prototype,"applyEditsFeatureServiceCallback",void 0),o([r()],i.prototype,"candidates",void 0),o([r()],i.prototype,"rootFeatures",void 0),o([r()],i.prototype,"rootFeatureInfos",void 0),o([r()],i.prototype,"rootWorkflowOptions",void 0),o([r({constructOnly:!0})],i.prototype,"sketchOptions",void 0),o([r()],i.prototype,"snappingManager",void 0),o([r()],i.prototype,"viewModel",void 0),i=o([s("esri.widgets.Editor.UpdateWorkflowData")],i);const a=i;export{a 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{isSome as i}from"../../../core/arrayUtils.js";import{abortHandle as s}from"../../../core/handleUtils.js";import{debounce as a}from"../../../core/promiseUtils.js";import{whenOnce as r,watch as o}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as c}from"../../../core/support/UpdatingHandles.js";import p from"../../../layers/GraphicsLayer.js";import d from"../../../views/interactive/sketch/SketchOptions.js";import{getVisualVariablesForLayer as h,updateGraphicSymbolWhenRequired as u,setVisualVariablesAndElevationInfoForUpdate as y,swapForEditingSession as m,visualVariableInteractiveUpdate as w,getSizeVariableAttribute as g,getRotationVariableAttribute as v}from"../workflowUtils.js";import f from"../../Sketch/SketchViewModel.js";const _=Symbol();let b=class extends t{constructor(e){super(e),this.features=[],this.sketchOptions=new d,this.snappingManager=null,this.sourceLayer=null,this.view=null,this.viewModel=null,this._sketchGraphicsMap=new Map,this._sketchLayer=null,this._updatingHandles=new c,this._visualVariableAttributes=new Map,this._visualVariablesForLayer=null,this._webStyleCache=new Map}async initialize(){this._visualVariablesForLayer=h(this.sourceLayer),this._initializeSketchGraphics(),this._initializeSketchLayer(),await this._updatingHandles.addPromise(this._initializeSketchViewModel())}destroy(){const{_sketchLayer:e,view:t}=this;t?.destroyed||t?.map.remove(e),e.destroy(),this.viewModel.destroy()}get updating(){return this._updatingHandles.updating}async enter(){throw new Error("enter() not implemented")}async exit(){throw new Error("exit() not implemented")}notifyAttributesChanged({features:e,fieldName:t}){const i=this._webStyleCache,s=this.view.scale,a=this._updatingHandles;for(const r of e){const e=this._sketchGraphicsMap.get(r),o=r.getAttribute(t);if(!e||e.getAttribute(t)===o)continue;e.setAttribute(t,o);const n=this._visualVariableAttributes.get(r);null==n?.size||n.size.isUpdatingInteractively||n.size.field!==t||n.size.setInitialValue(o),null==n?.rotation||n.rotation.isUpdatingInteractively||n.rotation.field!==t||n.rotation.setInitialValue(o),a.addPromise(u(e,i,s))}}async startUpdatingFeatures(e,t,a){const{_sketchGraphicsMap:o,_sketchLayer:n,sourceLayer:l,view:c,viewModel:p,_webStyleCache:d}=this,h=e.map(e=>o.get(e)).filter(i),m={};this.removeHandles(_),p.complete();let g=null;if(1===e.length){const t=e[0],i=this._visualVariableAttributes.get(t);!(!i?.rotation&&!i?.size)&&(await y({graphic:h[0],sketchLayer:n,sketchViewModel:p,sourceLayer:l,visualVariables:i,webStyleCache:d}),"point"===l.geometryType&&(m.enableRotation=null!=i.rotation,m.enableScaling=null!=i.size,g=async e=>{const s=e.graphics[0];w(c,s,e,i)&&(a?.([{feature:t,attributes:s.attributes}],e),this._updatingHandles.addPromise(u(s,d,"2d"===c.type?c.scale:null)))}))}else m.tool="move";const v=()=>p.update(h,m),f=p.on("update",a=>{if("complete"===a.state){if(null===c.activeTool)return void v();const e=new AbortController,t=s(e);return this.addHandles(t,_),void this._updatingHandles.addPromise(r(()=>null===c.activeTool,e.signal).then(async()=>{e.signal.aborted||(e.abort(),await v())}))}const n=e.map(e=>{const t=o.get(e);return t?{feature:e,geometry:t.geometry}:null}).filter(i);t(n,a),g?.(a)});await v(),this.addHandles(f,_),p.addHandles(f)}_initializeSketchGraphics(){const{features:e,_sketchGraphicsMap:t,sourceLayer:i,_visualVariableAttributes:s}=this,a=this._visualVariablesForLayer,r=a.rotation?.field,o=a.size?.field,n={rotation:r?i.getField(r):null,size:o?i.getField(o):null},l=!(!n.rotation&&!n.size);for(const c of e)t.set(c,c.clone()),l&&s.set(c,k(a,n))}_initializeSketchLayer(){const{view:e}=this,t=new p({elevationInfo:this.sourceLayer.elevationInfo,internal:!0,listMode:"hide",title:"SketchController layer"});this._sketchLayer=t,e.map.add(t),this._updatingHandles.addPromise(e.whenLayerView(t))}async _initializeSketchViewModel(){const{_sketchGraphicsMap:e,_sketchLayer:t,view:i,_webStyleCache:s}=this,r=Array.from(e.entries()),n=new f({allowDeleteKey:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},layer:t,sketchOptions:this.sketchOptions,snappingManager:this.snappingManager,updateOnGraphicClick:!1,view:i});this.viewModel=n;const l=a(e=>Promise.all(r.map(([,t])=>u(t,s,e))));await l("2d"===i.type?i.scale:null),"2d"===i.type&&this.addHandles(o(()=>i.scale,e=>l(e))),this.addHandles(await Promise.all(r.map(([e,s])=>m(t,i,e,s))))}};function k({rotation:e,size:t},i){return{rotation:e?v(e,i.rotation):null,size:t?g(t,i.size):null}}e([n()],b.prototype,"features",void 0),e([n()],b.prototype,"sketchOptions",void 0),e([n()],b.prototype,"snappingManager",void 0),e([n()],b.prototype,"sourceLayer",void 0),e([n()],b.prototype,"updating",null),e([n()],b.prototype,"view",void 0),e([n()],b.prototype,"viewModel",void 0),e([n()],b.prototype,"_sketchGraphicsMap",void 0),e([n()],b.prototype,"_sketchLayer",void 0),e([n()],b.prototype,"_visualVariablesForLayer",void 0),b=e([l("esri.widgets.Editor.support.SketchController")],b);export{b as SketchController};
5
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{isSome as i}from"../../../core/arrayUtils.js";import{abortHandle as s}from"../../../core/handleUtils.js";import{debounce as a}from"../../../core/promiseUtils.js";import{whenOnce as o,watch as r}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as p}from"../../../core/support/UpdatingHandles.js";import d from"../../../layers/GraphicsLayer.js";import c from"../../../views/interactive/sketch/SketchOptions.js";import{getVisualVariablesForLayer as h,updateGraphicSymbolWhenRequired as u,setVisualVariablesAndElevationInfoForUpdate as y,swapForEditingSession as m,visualVariableInteractiveUpdate as v,getSizeVariableAttribute as g,getRotationVariableAttribute as w}from"../workflowUtils.js";import _ from"../../Sketch/SketchViewModel.js";const b=Symbol();let f=class extends t{constructor(e){super(e),this.features=[],this.onGeometriesUpdated=()=>{},this.onVisualVariableAttributesUpdated=()=>{},this.sketchOptions=new c,this.snappingManager=null,this.sourceLayer=null,this.view=null,this.viewModel=null,this._nextUpdateSubset=[],this._sketchGraphicsMap=new Map,this._sketchLayer=null,this._updatingHandles=new p,this._visualVariableAttributes=new Map,this._visualVariablesForLayer=null,this._webStyleCache=new Map}async initialize(){this._visualVariablesForLayer=h(this.sourceLayer),this._nextUpdateSubset=this.features,this._initializeSketchGraphics(),this._initializeSketchLayer(),await this._updatingHandles.addPromise(this._initializeSketchViewModel())}destroy(){const{_sketchLayer:e,view:t}=this;t?.destroyed||t?.map.remove(e),e.destroy(),this.viewModel.destroy()}get updating(){return this._updatingHandles.updating}async enter(){await this.startUpdatingFeatures(this._nextUpdateSubset)}async exit(){this._completeCurrentOperation()}notifyAttributesChanged({features:e,fieldName:t}){const i=this._webStyleCache,s=this.view.scale,a=this._updatingHandles;for(const o of e){const e=this._sketchGraphicsMap.get(o),r=o.getAttribute(t);if(!e||e.getAttribute(t)===r)continue;e.setAttribute(t,r);const n=this._visualVariableAttributes.get(o);null==n?.size||n.size.isUpdatingInteractively||n.size.field!==t||n.size.setInitialValue(r),null==n?.rotation||n.rotation.isUpdatingInteractively||n.rotation.field!==t||n.rotation.setInitialValue(r),a.addPromise(u(e,i,s))}}async startUpdatingFeatures(e){const{onGeometriesUpdated:t,onVisualVariableAttributesUpdated:a,_sketchGraphicsMap:r,_sketchLayer:n,sourceLayer:l,view:p,viewModel:d,_webStyleCache:c}=this,h=e.map(e=>r.get(e)).filter(i),m={};this._completeCurrentOperation();let g=null;if(1===e.length){const t=e[0],i=this._visualVariableAttributes.get(t);!(!i?.rotation&&!i?.size)&&(await y({graphic:h[0],sketchLayer:n,sketchViewModel:d,sourceLayer:l,visualVariables:i,webStyleCache:c}),"point"===l.geometryType&&(m.enableRotation=null!=i.rotation,m.enableScaling=null!=i.size,g=async e=>{const s=e.graphics[0];v(p,s,e,i)&&(a?.([{feature:t,attributes:s.attributes}],e),this._updatingHandles.addPromise(u(s,c,"2d"===p.type?p.scale:null)))}))}else m.tool="move";const w=()=>d.update(h,m),_=d.on("update",a=>{if("complete"===a.state){if(null===p.activeTool)return void w();const e=new AbortController,t=s(e);return this.addHandles(t,b),void this._updatingHandles.addPromise(o(()=>null===p.activeTool,e.signal).then(async()=>{e.signal.aborted||(e.abort(),await w())}))}const n=e.map(e=>{const t=r.get(e);return t?{feature:e,geometry:t.geometry}:null}).filter(i);t(n,a),g?.(a)});await w(),this._nextUpdateSubset=this.features,this.addHandles(_,b),d.addHandles(_)}_completeCurrentOperation(){this.removeHandles(b),this.viewModel.complete()}_initializeSketchGraphics(){const{features:e,_sketchGraphicsMap:t,sourceLayer:i,_visualVariableAttributes:s}=this,a=this._visualVariablesForLayer,o=a.rotation?.field,r=a.size?.field,n={rotation:o?i.getField(o):null,size:r?i.getField(r):null},l=!(!n.rotation&&!n.size);for(const p of e)t.set(p,p.clone()),l&&s.set(p,k(a,n))}_initializeSketchLayer(){const{view:e}=this,t=new d({elevationInfo:this.sourceLayer.elevationInfo,internal:!0,listMode:"hide",title:"SketchController layer"});this._sketchLayer=t,e.map.add(t),this._updatingHandles.addPromise(e.whenLayerView(t))}async _initializeSketchViewModel(){const{_sketchGraphicsMap:e,_sketchLayer:t,view:i,_webStyleCache:s}=this,o=Array.from(e.entries()),n=new _({allowDeleteKey:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},layer:t,sketchOptions:this.sketchOptions,snappingManager:this.snappingManager,updateOnGraphicClick:!1,view:i});this.viewModel=n;const l=a(e=>Promise.all(o.map(([,t])=>u(t,s,e))));await l("2d"===i.type?i.scale:null),"2d"===i.type&&this.addHandles(r(()=>i.scale,e=>l(e))),this.addHandles(await Promise.all(o.map(([e,s])=>m(t,i,e,s))))}};function k({rotation:e,size:t},i){return{rotation:e?w(e,i.rotation):null,size:t?g(t,i.size):null}}e([n()],f.prototype,"features",void 0),e([n()],f.prototype,"onGeometriesUpdated",void 0),e([n()],f.prototype,"onVisualVariableAttributesUpdated",void 0),e([n()],f.prototype,"sketchOptions",void 0),e([n()],f.prototype,"snappingManager",void 0),e([n()],f.prototype,"sourceLayer",void 0),e([n()],f.prototype,"updating",null),e([n()],f.prototype,"view",void 0),e([n()],f.prototype,"viewModel",void 0),e([n()],f.prototype,"_nextUpdateSubset",void 0),e([n()],f.prototype,"_sketchGraphicsMap",void 0),e([n()],f.prototype,"_sketchLayer",void 0),e([n()],f.prototype,"_visualVariablesForLayer",void 0),f=e([l("esri.widgets.Editor.support.SketchController")],f);export{f as SketchController};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
+ */
5
+ import{unique as e}from"../../../core/arrayUtils.js";import t from"../../../core/Error.js";import{getGraphicLayer as r}from"../../../graphic/graphicOriginUtils.js";class s extends t{constructor(e=!1){super("editing:fetch-feature",`Failed to fetch the full ${e?"features":"feature"} from the service.`)}}class o extends t{constructor(e){super("editing:not-enough-features",`At least ${e} ${1===e?"feature is":"features are"} required to perform this operation.`)}}class a extends t{constructor(){super("editing:invalid-argument","Key feature must be one of the features being merged")}}class i extends t{constructor(){super("editing:multiple-layers-not-supported","Features must belong to the same layer.")}}class n extends t{constructor(){super("editing:layer-required","The feature must be associated with a layer to start a split feature workflow.")}}function u(t){if(e(t.map(e=>r(e))).length>1)throw new i}function c(e,t){if(e.length<t)throw new o(t)}export{s as FetchFullFeatureError,o as InsufficientFeatureCountError,a as InvalidKeyFeatureError,n as MissingOriginLayerError,i as MultipleSourceLayersError,u as assertFeaturesAreFromSameLayer,c as assertMinimumFeatureCount};