@arcgis/core 5.2.0-next.73 → 5.2.0-next.75

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 (339) hide show
  1. package/analysis/ViewshedAnalysis.js +1 -1
  2. package/arcgisGlobal.d.ts +1 -0
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/0502641d9a214b37ff29.js +1 -0
  5. package/assets/esri/core/workers/chunks/{d3be4d914fc99a1d686c.js → 075e65cc4275ac886f08.js} +1 -1
  6. package/assets/esri/core/workers/chunks/087bd698b80ca0cea71e.js +1 -0
  7. package/assets/esri/core/workers/chunks/{b6c7b7b7f87dce5de811.js → 0bf644f93c180a2bc2f8.js} +1 -1
  8. package/assets/esri/core/workers/chunks/0d3b2d9a19383bb63f0a.js +1 -0
  9. package/assets/esri/core/workers/chunks/0d9fe49812554e7d7ba7.js +1 -0
  10. package/assets/esri/core/workers/chunks/0daaa89de339e8ea4b81.js +1 -0
  11. package/assets/esri/core/workers/chunks/{1ca04ecf010e68863014.js → 0eb35e09765fd74eb698.js} +1 -1
  12. package/assets/esri/core/workers/chunks/12234a63d3fa4bc25e7e.js +1 -0
  13. package/assets/esri/core/workers/chunks/18e0e993c0c39c962e61.js +1 -0
  14. package/assets/esri/core/workers/chunks/1c49c9472167a2e0c923.js +1 -0
  15. package/assets/esri/core/workers/chunks/{cf360767310fb45660a8.js → 1cf8fb704c48ac3d3b15.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{2e44978ee677aa23163d.js → 2435ef7d11f8dbb920b7.js} +1 -1
  17. package/assets/esri/core/workers/chunks/2501d9459f6d14c797e5.js +1 -0
  18. package/assets/esri/core/workers/chunks/2740f755c3a322cbd477.js +1 -0
  19. package/assets/esri/core/workers/chunks/27f574acf52f2c8bc2c9.js +1 -0
  20. package/assets/esri/core/workers/chunks/28f87daaba1ae3441364.js +1 -0
  21. package/assets/esri/core/workers/chunks/2b93888e61ca638490cf.js +1 -0
  22. package/assets/esri/core/workers/chunks/2c31648a4b95275516ee.js +1 -0
  23. package/assets/esri/core/workers/chunks/2f4ed8a63d57636a4ebe.js +1 -0
  24. package/assets/esri/core/workers/chunks/2f81047790c4890ae625.js +1 -0
  25. package/assets/esri/core/workers/chunks/305eea9c1fc4aee3309e.js +1 -0
  26. package/assets/esri/core/workers/chunks/30818b5ff0ce51b25d6f.js +1 -0
  27. package/assets/esri/core/workers/chunks/3235e14fedb19dd94807.js +1 -0
  28. package/assets/esri/core/workers/chunks/36ec5b84e551ab08b24a.js +1 -0
  29. package/assets/esri/core/workers/chunks/3c28e2040cb4fb716eaa.js +1 -0
  30. package/assets/esri/core/workers/chunks/3c32471785bc8570e41c.js +1 -0
  31. package/assets/esri/core/workers/chunks/4046bd65d7d0677f4600.js +1 -0
  32. package/assets/esri/core/workers/chunks/4295822fa6ef743c76f1.js +1 -0
  33. package/assets/esri/core/workers/chunks/{35fd2f765d2cb3f59a22.js → 42d5ed44111bea77ec71.js} +115 -115
  34. package/assets/esri/core/workers/chunks/43713bc6f7eea07259d0.js +1 -0
  35. package/assets/esri/core/workers/chunks/{36171c72a3c04b0d13ef.js → 43a65cab888d43954564.js} +1 -1
  36. package/assets/esri/core/workers/chunks/44a786aba84918f2b247.js +1 -0
  37. package/assets/esri/core/workers/chunks/46873badbd6ce8ff4e1e.js +1 -0
  38. package/assets/esri/core/workers/chunks/495f90fe3d0ad32bb82d.js +1 -0
  39. package/assets/esri/core/workers/chunks/4b5bd0c9a55ea2998601.js +1 -0
  40. package/assets/esri/core/workers/chunks/4d7a3b3aaf876da0891b.js +1 -0
  41. package/assets/esri/core/workers/chunks/4fe2cca405180af23364.js +1 -0
  42. package/assets/esri/core/workers/chunks/50b08415e072a49bc572.js +1 -0
  43. package/assets/esri/core/workers/chunks/519af918050b47f93516.js +1 -0
  44. package/assets/esri/core/workers/chunks/{bd311c85437743cf7d2f.js → 53d165b4f30fd64e5d8a.js} +1 -1
  45. package/assets/esri/core/workers/chunks/552d6aecc7d88d16227b.js +1 -0
  46. package/assets/esri/core/workers/chunks/5627f562dea8bae2f346.js +1 -0
  47. package/assets/esri/core/workers/chunks/5ba3a30b7cbfa9e3aa62.js +1 -0
  48. package/assets/esri/core/workers/chunks/5e1d84e97de0e662aaa9.js +1 -0
  49. package/assets/esri/core/workers/chunks/64a1ffc221e5b63b43fb.js +1 -0
  50. package/assets/esri/core/workers/chunks/{31669511cfddf116d991.js → 66e60351aacbd162775f.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{c203df41f9d2e4b80889.js → 6743d726e45e7b660505.js} +1 -1
  52. package/assets/esri/core/workers/chunks/69b0dcd7bcd8ec42e2c3.js +1 -0
  53. package/assets/esri/core/workers/chunks/6b783f440c4a5d36e879.js +1 -0
  54. package/assets/esri/core/workers/chunks/6dddd3df31961b9fda12.js +1 -0
  55. package/assets/esri/core/workers/chunks/6fc3553c52af6ace926d.js +1 -0
  56. package/assets/esri/core/workers/chunks/702b2381acf4d1f90094.js +1 -0
  57. package/assets/esri/core/workers/chunks/762be5d3e6aeaea33f74.js +29 -0
  58. package/assets/esri/core/workers/chunks/792303e4090c0c70c4ff.js +1 -0
  59. package/assets/esri/core/workers/chunks/7a24cc0f3b4eff2bdb8e.js +1 -0
  60. package/assets/esri/core/workers/chunks/7aaa051b51a8e34bbfb0.js +1 -0
  61. package/assets/esri/core/workers/chunks/7dc5aedc964eacd1be5a.js +1 -0
  62. package/assets/esri/core/workers/chunks/81130dbcb738d40f723b.js +1 -0
  63. package/assets/esri/core/workers/chunks/835af7b4fd92cb4e7af0.js +1 -0
  64. package/assets/esri/core/workers/chunks/841c81c280114412c95b.js +1 -0
  65. package/assets/esri/core/workers/chunks/{96d861265566854760cd.js → 88fd698b940dadcc6dc5.js} +1 -1
  66. package/assets/esri/core/workers/chunks/8a36b999cbd65dd2f16c.js +1 -0
  67. package/assets/esri/core/workers/chunks/8ae3a6ddc87bf8315583.js +1 -0
  68. package/assets/esri/core/workers/chunks/8f0d4aec8bd3cbfefc40.js +1 -0
  69. package/assets/esri/core/workers/chunks/{7f208ef75ef2ce0d7cf9.js → 910c93bbbf8113a4a51f.js} +1 -1
  70. package/assets/esri/core/workers/chunks/92c4464b67fce6cea134.js +1 -0
  71. package/assets/esri/core/workers/chunks/{509cfac9e5d86a8ee449.js → 936d44c7bc3a181e64a3.js} +1 -1
  72. package/assets/esri/core/workers/chunks/947f1ea4dbc3e3419ecc.js +1 -0
  73. package/assets/esri/core/workers/chunks/9b76c8974424a1908e86.js +1 -0
  74. package/assets/esri/core/workers/chunks/9cff18e6f751d1b3085e.js +1 -0
  75. package/assets/esri/core/workers/chunks/a101152066dd56259619.js +1 -0
  76. package/assets/esri/core/workers/chunks/a2a2c7e274fb32fecffa.js +1 -0
  77. package/assets/esri/core/workers/chunks/a50421fe79f264ae3619.js +1 -0
  78. package/assets/esri/core/workers/chunks/a6a2a4a2bae0d327d7ed.js +1 -0
  79. package/assets/esri/core/workers/chunks/a7a7d3289d4ca95f545f.js +1 -0
  80. package/assets/esri/core/workers/chunks/abb6c76d5dba3559a68e.js +1 -0
  81. package/assets/esri/core/workers/chunks/aca5c524bd3c955e9243.js +1 -0
  82. package/assets/esri/core/workers/chunks/b14961a9f1f40028f141.js +1 -0
  83. package/assets/esri/core/workers/chunks/b1a175b3b2d1a7ddde8e.js +1 -0
  84. package/assets/esri/core/workers/chunks/b6cd165d0e58598f28a5.js +1 -0
  85. package/assets/esri/core/workers/chunks/b78f509fd8e95f728178.js +1 -0
  86. package/assets/esri/core/workers/chunks/b9c61b20bbc91cb63036.js +1 -0
  87. package/assets/esri/core/workers/chunks/b9d1bb106737a05290e1.js +1 -0
  88. package/assets/esri/core/workers/chunks/{faa55265020591fd2224.js → bc0395777c5c1adb1ddb.js} +1 -1
  89. package/assets/esri/core/workers/chunks/bf3dc3ad8df8488da3f0.js +1 -0
  90. package/assets/esri/core/workers/chunks/c1568bcd3f04014152e1.js +1 -0
  91. package/assets/esri/core/workers/chunks/c374e5d5980db74c4aca.js +1 -0
  92. package/assets/esri/core/workers/chunks/{b9953277d0cd4a01bdc6.js → c37b28f200b704ae6002.js} +1 -1
  93. package/assets/esri/core/workers/chunks/c67e4a848d41038367b8.js +1 -0
  94. package/assets/esri/core/workers/chunks/cff6390b863361eaeeed.js +1 -0
  95. package/assets/esri/core/workers/chunks/d1c7c877edc6948f3801.js +1 -0
  96. package/assets/esri/core/workers/chunks/d2172583ee6e481a66aa.js +1 -0
  97. package/assets/esri/core/workers/chunks/d633e98b0dfa0490e4de.js +1 -0
  98. package/assets/esri/core/workers/chunks/d8eca13c127b443141b7.js +1 -0
  99. package/assets/esri/core/workers/chunks/ddd8f6154e265dbb6f9f.js +1 -0
  100. package/assets/esri/core/workers/chunks/de5013f89f0eae93978f.js +1 -0
  101. package/assets/esri/core/workers/chunks/de601f0d5a2a282d2efd.js +1 -0
  102. package/assets/esri/core/workers/chunks/e557043f90c051e93925.js +1 -0
  103. package/assets/esri/core/workers/chunks/e59101f1d060d0a30a65.js +1 -0
  104. package/assets/esri/core/workers/chunks/{bee5e738ecf8680909c4.js → eaf26c1cc938789d5336.js} +1 -1
  105. package/assets/esri/core/workers/chunks/eb1a86159dbc098f06fe.js +1 -0
  106. package/assets/esri/core/workers/chunks/ee9eb381e675d2d01260.js +1 -0
  107. package/assets/esri/core/workers/chunks/{014f9fd2818e2c9d9a3b.js → f43a0edf58941e2ac78e.js} +1 -1
  108. package/assets/esri/core/workers/chunks/f4bc563c71c478d3912f.js +1 -0
  109. package/assets/esri/core/workers/chunks/{4abd54518e35050feb90.js → f78acff510ca615d42e4.js} +1 -1
  110. package/assets/esri/core/workers/chunks/{01c92e68fb17cf2d0e08.js → f7a5c4d22a24e1ac433c.js} +1 -1
  111. package/assets/esri/core/workers/chunks/fb0b89bbb4f8607d5f20.js +1 -0
  112. package/assets/esri/core/workers/chunks/ff890167ff2baabfc4ce.js +1 -0
  113. package/chunks/GaussianSplat.glsl.js +8 -8
  114. package/chunks/GaussianSplatShadow.glsl.js +4 -5
  115. package/chunks/OccludedGeometryDepth.glsl.js +5 -0
  116. package/chunks/ShadowCastVisualize.glsl.js +2 -2
  117. package/config.js +1 -1
  118. package/core/importUtils.js +2 -0
  119. package/geometry/operators/importUtils.js +2 -0
  120. package/geometry/support/curves/densifyCurvedGeometry.js +1 -1
  121. package/geometry/support/normalizeUtils.d.ts +17 -15
  122. package/geometry/support/normalizeUtils.js +1 -1
  123. package/kernel.js +1 -1
  124. package/layers/DimensionFeatureLayer.d.ts +22 -0
  125. package/layers/DimensionFeatureLayer.js +1 -1
  126. package/layers/FeatureLayer.d.ts +1 -1
  127. package/layers/graphics/data/QueryEngine.js +1 -1
  128. package/layers/graphics/data/queryUtils.js +1 -1
  129. package/layers/graphics/hydratedFeatures.js +1 -1
  130. package/layers/save/featureLayerUtils.js +1 -1
  131. package/layers/support/layerUtils.js +1 -1
  132. package/layers/support/layersMapping.js +1 -1
  133. package/package.json +1 -1
  134. package/portal/schemas/definitions.js +1 -1
  135. package/rest/geoprocessor/utils.js +1 -1
  136. package/rest/identify.js +1 -1
  137. package/rest/imageService.js +1 -1
  138. package/rest/query/operations/query.js +1 -1
  139. package/rest/query/operations/queryAttributeBins.js +1 -1
  140. package/rest/query/operations/queryPivot.js +1 -1
  141. package/rest/query/operations/queryTopFeatures.js +1 -1
  142. package/support/revision.js +1 -1
  143. package/symbols/cim/CIMEffects.js +1 -1
  144. package/symbols/cim/utils.js +1 -1
  145. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  146. package/views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js +1 -1
  147. package/views/2d/layers/support/RouteLayerInteraction.js +1 -1
  148. package/views/2d/viewpointUtils.js +1 -1
  149. package/views/3d/analysis/LineOfSight/LineOfSightReshapeTool3D.js +1 -1
  150. package/views/3d/analysis/LineOfSight/lineOfSightPlacementUtils.js +1 -1
  151. package/views/3d/analysis/Viewshed/ViewshedEditTool.js +1 -1
  152. package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
  153. package/views/3d/analysis/Viewshed/placementUtils.js +1 -1
  154. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  155. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementShiftTool.js +1 -1
  156. package/views/3d/environment/EnvironmentManager.js +1 -1
  157. package/views/3d/interactive/Manipulator3D.js +1 -1
  158. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  159. package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
  160. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  161. package/views/3d/interactive/editingTools/reshape/ReshapeTool3D.js +1 -1
  162. package/views/3d/interactive/editingTools/reshape/reshapeTooltipUtils3D.js +1 -1
  163. package/views/3d/interactive/editingTools/tooltipUtils3D.js +1 -1
  164. package/views/3d/interactive/editingTools/transform/ExtentTransformTool.js +1 -1
  165. package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
  166. package/views/3d/interactive/editingTools/transform/TransformTool3D.js +1 -1
  167. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentMove.js +1 -1
  168. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentRotate.js +1 -1
  169. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
  170. package/views/3d/interactive/manipulatorUtils.js +1 -1
  171. package/views/3d/interactive/visualElements/VerticesVisualElement.js +1 -1
  172. package/views/3d/layers/graphics/tessellationUtils.js +1 -1
  173. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  174. package/views/3d/layers/support/MediaLayerInteraction.js +1 -1
  175. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  176. package/views/3d/support/hitTest.js +1 -1
  177. package/views/3d/support/renderInfoUtils/polygon.js +1 -1
  178. package/views/3d/webgl-engine/core/shaderLibrary/util/GaussianSplatCovariance.glsl.js +8 -3
  179. package/views/3d/webgl-engine/core/shaderLibrary/util/GaussianSplatEvaluation.glsl.js +8 -2
  180. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowAccumulator.js +2 -0
  181. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowCastAccumulate.glsl.js +2 -0
  182. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowCastAccumulateTechnique.js +2 -0
  183. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowCastAccumulateTechniqueConfiguration.js +2 -0
  184. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowCastClear.glsl.js +2 -0
  185. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowCastClearTechnique.js +2 -0
  186. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowCastMaskTechnique.js +2 -0
  187. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowCastRenderer.js +2 -0
  188. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowCastVisualize.glsl.js +2 -0
  189. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowCastVisualizeTechnique.js +2 -0
  190. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowCastVisualizeTechniqueConfiguration.js +2 -0
  191. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  192. package/views/3d/webgl-engine/lib/CutFillVisualization.js +1 -1
  193. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  194. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  195. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  196. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  197. package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
  198. package/views/3d/webgl-engine/shaders/GaussianSplatPass.glsl.js +28 -21
  199. package/views/3d/webgl-engine/shaders/OccludedGeometryDepth.glsl.js +2 -0
  200. package/views/3d/webgl-engine/shaders/OccludedGeometryDepthTechnique.js +2 -0
  201. package/views/draw/DrawGraphicTool.js +1 -1
  202. package/views/draw/DrawTool.js +1 -1
  203. package/views/draw/plugins/PolylinePlugin.js +1 -1
  204. package/views/draw/support/Box.js +1 -1
  205. package/views/draw/support/InteractiveHandle.js +1 -1
  206. package/views/draw/support/Reshape.js +1 -1
  207. package/views/draw/support/drawToolUtils.js +1 -1
  208. package/views/draw/support/managers/InteractiveHandleManager.js +1 -1
  209. package/views/draw/support/managers/TooltipManager.js +1 -1
  210. package/views/draw/support/reshapeTooltipUtils.js +1 -1
  211. package/views/draw/support/tooltipUtils.js +1 -1
  212. package/views/interactive/options/InteractiveToolOptions.d.ts +36 -0
  213. package/views/interactive/options/InteractiveToolOptions.js +2 -0
  214. package/views/interactive/sketch/SketchOptions.d.ts +4 -3
  215. package/views/interactive/sketch/SketchOptions.js +1 -1
  216. package/views/interactive/tooltip/components/DrawHeaderActions.js +1 -1
  217. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  218. package/views/interactive/tooltip/content/TooltipContentDrawPolygon.js +1 -1
  219. package/views/interactive/tooltip/content/TooltipContentDrawPolyline.js +1 -1
  220. package/views/interactive/tooltip/content/TooltipContentDynamic.js +1 -1
  221. package/views/interactive/tooltip/fields/fields.js +1 -1
  222. package/views/interactive/tooltip/infos/DynamicTooltipInfo.js +1 -1
  223. package/views/interactive/tooltip/infos/SketchTooltipInfo.js +1 -1
  224. package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
  225. package/views/selection/SelectionOperation.js +1 -1
  226. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  227. package/widgets/Sketch/SketchViewModel.js +1 -1
  228. package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
  229. package/widgets/support/SelectionList/GroupLayerItem.d.ts +8 -1
  230. package/widgets/support/SelectionList/GroupLayerItem.js +1 -1
  231. package/widgets/support/SelectionList/LayerItem.d.ts +8 -1
  232. package/widgets/support/SelectionList/LayerItem.js +1 -1
  233. package/widgets/support/SelectionList/SelectionListViewModel.d.ts +29 -1
  234. package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
  235. package/widgets/support/SelectionList.js +1 -1
  236. package/widgets/support/SelectionToolbar.js +1 -1
  237. package/assets/esri/core/workers/chunks/00cbff0b785e24e87d97.js +0 -1
  238. package/assets/esri/core/workers/chunks/0623acb2bd14a61b65c9.js +0 -29
  239. package/assets/esri/core/workers/chunks/06c9aac75a01d3af6d54.js +0 -1
  240. package/assets/esri/core/workers/chunks/089f8c60e96d920a2cb2.js +0 -1
  241. package/assets/esri/core/workers/chunks/0c3c311400ee352187ea.js +0 -1
  242. package/assets/esri/core/workers/chunks/0dbf31a663b5220a3136.js +0 -1
  243. package/assets/esri/core/workers/chunks/0df660dfd941cff3ea1d.js +0 -1
  244. package/assets/esri/core/workers/chunks/1418c03c4ab87f7ab5f4.js +0 -1
  245. package/assets/esri/core/workers/chunks/158d2ac0333d53556e33.js +0 -1
  246. package/assets/esri/core/workers/chunks/160b204cbf5bda2a29e9.js +0 -1
  247. package/assets/esri/core/workers/chunks/16cade1c2ddf44e336ee.js +0 -1
  248. package/assets/esri/core/workers/chunks/1b130af7d14eaae69d96.js +0 -1
  249. package/assets/esri/core/workers/chunks/1cc063aa2ddf44bbd515.js +0 -1
  250. package/assets/esri/core/workers/chunks/1e0140556c2e3fa72545.js +0 -1
  251. package/assets/esri/core/workers/chunks/1e5cb72830c7f32f2961.js +0 -1
  252. package/assets/esri/core/workers/chunks/259bdacfb7b0f866a8d0.js +0 -1
  253. package/assets/esri/core/workers/chunks/2a2ed7bd44010f24c2dd.js +0 -1
  254. package/assets/esri/core/workers/chunks/2bdb9b5365869081c936.js +0 -1
  255. package/assets/esri/core/workers/chunks/2f58e1f64df2da8259a2.js +0 -1
  256. package/assets/esri/core/workers/chunks/383304d33b496c5d8baa.js +0 -1
  257. package/assets/esri/core/workers/chunks/3aacb935d632834d4154.js +0 -1
  258. package/assets/esri/core/workers/chunks/3c8e98cf23ad8ef12fcb.js +0 -1
  259. package/assets/esri/core/workers/chunks/3d6b2d5ae647e140abaf.js +0 -1
  260. package/assets/esri/core/workers/chunks/3dc71e03a630dd50b28e.js +0 -1
  261. package/assets/esri/core/workers/chunks/3fd022df127af32782ce.js +0 -1
  262. package/assets/esri/core/workers/chunks/4344ab1250a1c550bf8b.js +0 -1
  263. package/assets/esri/core/workers/chunks/43de723f765ec8f268ac.js +0 -1
  264. package/assets/esri/core/workers/chunks/44b50d4716a2567ab6f1.js +0 -1
  265. package/assets/esri/core/workers/chunks/44e8cd4b3dad777ab0c9.js +0 -1
  266. package/assets/esri/core/workers/chunks/4695cd6120f60b234d5c.js +0 -1
  267. package/assets/esri/core/workers/chunks/4cf2b0558a4acc141429.js +0 -1
  268. package/assets/esri/core/workers/chunks/4e129b9f5772a06e580c.js +0 -1
  269. package/assets/esri/core/workers/chunks/5441f96cdd0660229efe.js +0 -1
  270. package/assets/esri/core/workers/chunks/56bbde1dff96b423fbb9.js +0 -1
  271. package/assets/esri/core/workers/chunks/582a1d468089b9986416.js +0 -1
  272. package/assets/esri/core/workers/chunks/5f201c77a09ae0df29d6.js +0 -1
  273. package/assets/esri/core/workers/chunks/6080e46fc79127500283.js +0 -1
  274. package/assets/esri/core/workers/chunks/613e799377bdb767c955.js +0 -1
  275. package/assets/esri/core/workers/chunks/623d5518bca227f643bd.js +0 -1
  276. package/assets/esri/core/workers/chunks/62811bca7ad2100c023c.js +0 -1
  277. package/assets/esri/core/workers/chunks/64176f7ae719289a2f79.js +0 -1
  278. package/assets/esri/core/workers/chunks/67d3ff7fcefaa7d5d27f.js +0 -1
  279. package/assets/esri/core/workers/chunks/6a9002fcba11e2cf3f2e.js +0 -1
  280. package/assets/esri/core/workers/chunks/72dcd4bd1a28bf8605c5.js +0 -1
  281. package/assets/esri/core/workers/chunks/73f228d966b89c73c9e9.js +0 -1
  282. package/assets/esri/core/workers/chunks/73f77f5a6907cb8d9a35.js +0 -1
  283. package/assets/esri/core/workers/chunks/77df0bb35d2688729479.js +0 -1
  284. package/assets/esri/core/workers/chunks/7a143ca61c0a70306185.js +0 -1
  285. package/assets/esri/core/workers/chunks/7e373d9c98ce910db9d2.js +0 -1
  286. package/assets/esri/core/workers/chunks/869d292a60747c93dc84.js +0 -1
  287. package/assets/esri/core/workers/chunks/86a4057572755b403548.js +0 -1
  288. package/assets/esri/core/workers/chunks/8c76f31a363dd0c3354d.js +0 -1
  289. package/assets/esri/core/workers/chunks/98e6c1d035755a074d24.js +0 -1
  290. package/assets/esri/core/workers/chunks/9c57161ad48d8d546dc7.js +0 -1
  291. package/assets/esri/core/workers/chunks/a27cdf4c29dd50a6dab1.js +0 -1
  292. package/assets/esri/core/workers/chunks/a294dd12b5c708ce04af.js +0 -1
  293. package/assets/esri/core/workers/chunks/a7f42ada0aa69873a938.js +0 -1
  294. package/assets/esri/core/workers/chunks/a988fd54912969b812ce.js +0 -1
  295. package/assets/esri/core/workers/chunks/aff0e7761276036e029d.js +0 -1
  296. package/assets/esri/core/workers/chunks/b33d870cbfa238762c5e.js +0 -1
  297. package/assets/esri/core/workers/chunks/b599b7dadce8b8bc88f6.js +0 -1
  298. package/assets/esri/core/workers/chunks/b7d8817018b3d277c454.js +0 -1
  299. package/assets/esri/core/workers/chunks/b984b808d383974ca3d8.js +0 -1
  300. package/assets/esri/core/workers/chunks/ba4f419f46be09a9a55c.js +0 -1
  301. package/assets/esri/core/workers/chunks/bfb6566c27c09deb0929.js +0 -1
  302. package/assets/esri/core/workers/chunks/c25dc9073e73d6b44d88.js +0 -1
  303. package/assets/esri/core/workers/chunks/c45a5bcf26659daf02a1.js +0 -1
  304. package/assets/esri/core/workers/chunks/c715c585c42d8c2b86f5.js +0 -1
  305. package/assets/esri/core/workers/chunks/c7e9513f75b8ec205562.js +0 -1
  306. package/assets/esri/core/workers/chunks/c838cc1c786368b78598.js +0 -1
  307. package/assets/esri/core/workers/chunks/c866b66ba72d96453899.js +0 -1
  308. package/assets/esri/core/workers/chunks/c873383e7dae35dc1a61.js +0 -1
  309. package/assets/esri/core/workers/chunks/cd4e5c948d1bfa9b9a2d.js +0 -1
  310. package/assets/esri/core/workers/chunks/cfe31b7d1c6c05fbd268.js +0 -1
  311. package/assets/esri/core/workers/chunks/d08f81d545930a79fb2e.js +0 -1
  312. package/assets/esri/core/workers/chunks/d0c1bc90e474f706211c.js +0 -1
  313. package/assets/esri/core/workers/chunks/d607cf154218d20e4114.js +0 -1
  314. package/assets/esri/core/workers/chunks/d901f8503a73277cfa58.js +0 -1
  315. package/assets/esri/core/workers/chunks/da484787bd9fd3b13d15.js +0 -1
  316. package/assets/esri/core/workers/chunks/da6134c7883531f21afe.js +0 -1
  317. package/assets/esri/core/workers/chunks/e21b3490bfce75405e55.js +0 -1
  318. package/assets/esri/core/workers/chunks/e4353f0792f45aa6a62f.js +0 -1
  319. package/assets/esri/core/workers/chunks/e4a2eefffe16cd5bb20f.js +0 -1
  320. package/assets/esri/core/workers/chunks/e602b91d8fdc36a92530.js +0 -1
  321. package/assets/esri/core/workers/chunks/e702abaeccef20b64a81.js +0 -1
  322. package/assets/esri/core/workers/chunks/ebd619533be077059494.js +0 -1
  323. package/assets/esri/core/workers/chunks/f475672ff4c2ec9367c2.js +0 -1
  324. package/assets/esri/core/workers/chunks/f69329b85b362b349a8c.js +0 -1
  325. package/assets/esri/core/workers/chunks/f721756a6c1593f96409.js +0 -1
  326. package/assets/esri/core/workers/chunks/fb51f823b25c827c6b29.js +0 -1
  327. package/assets/esri/core/workers/chunks/fba8065a3a6fbd877e23.js +0 -1
  328. package/assets/esri/core/workers/chunks/fec07a16b72cdcafc641.js +0 -1
  329. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +0 -2
  330. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +0 -2
  331. package/views/3d/webgl-engine/shaders/ShadowCastAccumulate.glsl.js +0 -2
  332. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechnique.js +0 -2
  333. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechniqueConfiguration.js +0 -2
  334. package/views/3d/webgl-engine/shaders/ShadowCastClear.glsl.js +0 -2
  335. package/views/3d/webgl-engine/shaders/ShadowCastClearTechnique.js +0 -2
  336. package/views/3d/webgl-engine/shaders/ShadowCastMaskTechnique.js +0 -2
  337. package/views/3d/webgl-engine/shaders/ShadowCastVisualize.glsl.js +0 -2
  338. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechnique.js +0 -2
  339. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechniqueConfiguration.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import a from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import{makeHandle as s,drainHandles as n,destroyHandle as p}from"../../core/handleUtils.js";import"../../core/has.js";import l from"../../core/Logger.js";import{destroyMaybe as h,abortMaybe as d}from"../../core/maybe.js";import{createAbortError as c,ignoreAbortErrors as u,whenOrAbort as m}from"../../core/promiseUtils.js";import{watch as g,syncAndInitial as y,on as v,when as f,whenOnce as _}from"../../core/reactiveUtils.js";import{property as b,subclass as w}from"../../core/accessorSupport/decorators.js";import{trackAccess as T}from"../../core/accessorSupport/tracking.js";import{SimpleObservable as G}from"../../core/accessorSupport/tracking/SimpleObservable.js";import{UpdatingHandles as O}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as S}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as C,isLoaded as A,load as E,project as k}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as M}from"../../geometry/support/coordsUtils.js";import{equals as H}from"../../geometry/support/spatialReferenceUtils.js";import P from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as D}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as I}from"../../support/elevationInfoUtils.js";import U from"../../symbols/FillSymbol3DLayer.js";import j from"../../symbols/MeshSymbol3D.js";import R from"../../symbols/SimpleFillSymbol.js";import x from"../../symbols/SimpleLineSymbol.js";import L from"../../symbols/SimpleMarkerSymbol.js";import F from"../../symbols/TextSymbol.js";import{symbolTypes as V}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as W}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as K}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as Z}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as q}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as N}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as z}from"../../views/input/InputManager.js";import{sketchKeys as B}from"../../views/interactive/keybindings.js";import $ from"../../views/interactive/sketch/SketchLabelOptions.js";import Y from"../../views/interactive/sketch/SketchOptions.js";import J from"../../views/interactive/sketch/SketchTooltipOptions.js";import Q from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as X}from"../../views/interactive/snapping/SnappingManager.js";import ee from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as te}from"../../views/interactive/snapping/snappingUtils.js";import{GeometryWorkerHandle as oe}from"../../views/support/GeometryWorkerHandle.js";import{defaultHighlightName as ie}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as ae}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as re}from"../../views/support/screenUtils.js";import se from"./adapters/layer/GraphicsLayerAdapter.js";import ne from"./adapters/layer/MapNotesLayerAdapter.js";import{CreateOperationHandle as pe,DrawToolOperationHandle as le,UpdateOperationHandle as he}from"./support/OperationHandle.js";import{PluginManager as de}from"./support/PluginManager.js";import{SettingsManager as ce}from"./support/SettingsManager.js";import{getLegacyTool as ue,isCompletelyDegenerate as me,graphicsHaveTooFewVerticesForBox as ge,getModeFromCreateOptions as ye,getDrawToolGeometryTypeFromCreateTool as ve}from"./support/sketchUtils.js";const fe={defaultZ:0},_e={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move",enableCreateCurveFromStraightEdge:!0},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0,name:ie},tool:"transform"},be=Symbol(),we=Symbol();let Te=class extends r{constructor(e){super(e),this._defaultSnappingManager=null,this._internalGraphicsLayer=new P({listMode:"hide",internal:!0,title:"SVM Internal"}),this._pluginManager=new de({sketchViewModel:this}),this.settingsManager=new ce({availablePlugins:()=>this.pluginManager.visiblePluginsFlat}),this._operationHandle=null,this._updatingHandles=new O,this._toolTransitionHandles=new O,this._drawToolSimplifyAbortController=null,this._geometryWorkerHandle=new oe,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.activeUpdateOptions=null,this.layer=null,this.pointSymbol=new L({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new R({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new x({color:[130,130,130,1],width:2}),this.meshSymbol=new j({symbolLayers:new i([new U])}),this.updateGraphics=new i,this.updateOnGraphicClick=!0,this.cancelUpdateOnClickAway=!0,this.creationMode="single",this.vertexSymbol=new L({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new Y,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{const{_layerAdapter:e}=this;if(this.removeHandles(we),!e)return;const t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),g(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},y)].filter(o);this.addHandles(t,we)},this._originalPopupEnabled=null,this.defaultCreateOptions=fe,this.defaultUpdateOptions=_e,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new ee,this.textSymbol=new F({text:"text"})}initialize(){this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([v(()=>this.view?.map?.layers,"change",e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),g(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),y),g(()=>this.view,e=>{this._defaultSnappingManager=h(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new X({view:e,options:this.snappingOptions})),"2d"===e.type?(import("../../views/2d/interactive/editingTools.js"),this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe())):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))},y),g(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),te(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=h(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this._toolTransitionHandles.destroy(),this._drawToolSimplifyAbortController=d(this._drawToolSimplifyAbortController),this._geometryWorkerHandle.destroy(),this._pluginManager?.destroy(),this.emit("destroy")}get _layerAdapter(){const{layer:e}=this;switch(e?.type){case"graphics":return new se(e);case"map-notes":return new ne(e);default:return null}}get activeTool(){return this._operationHandle?.tool??null}get geometrySimplificationInProgress(){return!!this._drawToolSimplifyAbortController}get activeCreateToolDrawMode(){const e=this._operationHandle;if("create"===e?.type&&e.activeComponent&&"mode"in e.activeComponent)return e.activeComponent.mode;if("draw-2.0"===e?.activeComponent?.type){const t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(o).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){const{activeComponent:e,destroyed:t}=this,o=!t&&e&&"tooltip"in e?e.tooltip:null;return o?.visible?o:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return null==this.activeComponent||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):this.activeComponent.graphic}get defaultCreateOptions(){return this._get("defaultCreateOptions")}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...fe,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{..._e,...e,reshapeOptions:{..._e.reshapeOptions,...e?.reshapeOptions},highlightOptions:{..._e.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get textSymbol(){return this._get("textSymbol")}set textSymbol(e){this._set("textSymbol",e)}get snappingOptions(){return this.snappingManager?.options??this._get("snappingOptions")}set snappingOptions(e){null!=this._defaultSnappingManager&&(this._defaultSnappingManager.options=e),this._set("snappingOptions",e)}get snappingManager(){return this._isOverridden("snappingManager")&&this._get("snappingManager"),this._defaultSnappingManager}set snappingManager(e){if(e)this._isOverridden("snappingManager")||(this._defaultSnappingManager=h(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new X({options:this.snappingOptions,view:e})),this._clearOverride("snappingManager")}}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get toolTransitionInProgress(){return this._toolTransitionHandles.updating||!!this.drawTool?.lifecycleManager.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return this.toolTransitionInProgress||this.activeComponent&&"updating"in this.activeComponent&&this.activeComponent.updating||!!(this._updatingHandles.updating||this._drawToolSimplifyAbortController||this.snappingManager?.updating||this.drawTool?.updating)}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&this._clearCursor(),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(f(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},y),o),this._set("view",e),this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}get pluginManager(){return this._pluginManager}get drawTool(){return"draw-2.0"!==this.activeComponent?.type?null:this.activeComponent}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome("rootPlugins",e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;const e=this.view?.type??"2d",{firstPluginWithSwappableLeaf:t}=this;return t?t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e)):this.rootPlugins?.filter(t=>!t.excludedViews?.includes(e)).filter(o)??[]}get firstPluginWithSwappableLeaf(){const e=this.view?.type??"2d",t=this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>null!=t&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1);return t}get multiplePluginsActive(){return!!this.drawTool&&this.drawTool.pluginStack.length>1}addGraphic(e){this._layerAdapter?.add(e)}addGraphics(e){this._layerAdapter?.addMany(e)}hasGraphic(e){return!!this._layerAdapter?.has(e)}removeGraphic(e){this._layerAdapter?.remove(e)}removeGraphics(e){this._layerAdapter?.removeMany(e)}removeAllGraphics(){this._layerAdapter?.removeAll()}cancel(){this._moduleLoaderAbortController=d(this._moduleLoaderAbortController),this._viewReadyAbortController=d(this._viewReadyAbortController),this._drawToolSimplifyAbortController=d(this._drawToolSimplifyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e}=this,o=t.toArray();this.removeGraphics(o),this.cancel(),this._emitDeleteEvent({graphics:o,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map(e=>e.clone()).toArray();return this.addGraphics(e),this.emit("duplicate",{graphics:e,type:"duplicate"}),e}return[]}async create(e,t){return this._toolTransitionHandles.addPromise(this._create(e,t))}async _create(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());const{view:o,layer:i}=this;if(!o||"disabled"===this.state)throw i||this._logMissingLayer(),c();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");N(o,this._internalGraphicsLayer);const a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t));if(null==a||this.destroyed)return void o.map?.remove(this._internalGraphicsLayer);const r=ue(e),s=()=>{if(a===this._operationHandle){const o=this.createGraphic,i=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map?.remove(this._internalGraphicsLayer),a.cancelled||null==o||this.addGraphic(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:i?"cancel":"complete",tool:r??"point",toolEventInfo:null,type:"create"}),i||this._sketchContinuationFlag)return;const{creationMode:s}=this;if("continuous"===s){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(u(this.create(e,t)))}else"update"===s&&o&&this._updatingHandles.consumePromise(u(this.update([o])))}};a.on("complete",s),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return await e.load(),this.create("mesh",{mode:"click",hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){return this._toolTransitionHandles.addPromise(this._update(e,t))}async _update(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());const{layer:o,view:i,state:a}=this;if(!i||"disabled"===a)throw o||this._logMissingLayer(),c();null!=i.activeTool&&(i.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some(e=>this.hasGraphic(e)?null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0):(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0)))return;const s=await this._updatingHandles.addPromise(this._setupUpdateOperation(r,t));this.destroyed||null==s||Pe(s)||(N(i,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit("update",{graphics:r,state:"start",aborted:!1,tool:s.tool,toolEventInfo:null,type:"update"}))}async _updateSpatialReference(e){const t=this.view;if(t){e=Array.isArray(e)?e:[e];for(const o of e)null==o.geometry||"mesh"===o.geometry.type||H(o.geometry.spatialReference,t.spatialReference)||(C(o.geometry.spatialReference,t.spatialReference)||A()||await E(),o.geometry=k(o.geometry,t.spatialReference))}else this._logMissingView()}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._updatingHandles.consumePromise(this._operationHandle?.toggleTool())}async _getFirstHit(e){const t=this.view;if(!t)return this._logMissingView(),null;if("2d"===t.type){const o=[];t.map.allLayers.forEach(e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)});const i=await t.hitTest(e,{exclude:o});return ae(i.results)}const o=[t.map.ground];t.map.allLayers.forEach(e=>{D(e)&&o.push(e)});const i=await t.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!i.ground.mapPoint||t.map.ground.opacity<1||i.ground.distance-(e.distance??0)>-Math.min(3*i.ground.distance,"global"===t.viewingMode?S(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY)))return e}return null}_generateViewHandles(e){return[e.on("immediate-click",async e=>{const t="active"===this.state&&"create"===this._operationHandle?.type;"disabled"!==this.state&&!t&&this.updateOnGraphicClick&&await this._updatingHandles.addPromise(this._handleImmediateClick(e))},z.WIDGET)]}async _handleImmediateClick(e){const t=await e.defer(()=>this._getFirstHit(re(e)));let o=null;if(null!=t){const i=t.graphic;this.updateGraphics.includes(i)||this.hasGraphic(i)?(e.stopPropagation(),o=i):"2d"!==this.view?.type||this._isComponentGraphic(i)||"active"!==this.state||this.cancel()}else"active"===this.state&&this.cancelUpdateOnClickAway&&this.cancel();null==o||this.updateGraphics.includes(o)||await this.update([o],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){const o=this.view;if(!o)return this._logMissingView(),null;const i={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},a="string"==typeof e?this.pluginManager?.getPluginsEquivalentToCreateTool(e,i.mode):e,r=ue(e);if(a&&!this.isUsingLegacyCreateTools){const e=await this._setupDrawTool(a,i,r??"polyline");if(e)return this._setupDrawToolOperationHandle(e,r??"point")}if(!r)return null;const s=await this._setupDrawGraphicTool(r,o,i);return null==s?null:(o.tools.add(s),o.activeTool=s,this._setupCreateOperationHandle(s,r))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView."),null;if(!t)return this._logMissingView(),null;const{cursor:i,defaultZ:a,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=ye(p,e),d=ve(e),c=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=c?.preserveAspectRatio??l??"rectangle"!==e,m={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:i,defaultZ:a,forceUniformSize:u,graphicProperties:{...n,attributes:{...n?.attributes}},geometryToPlace:s,geometryType:d,mode:h,graphicSymbol:o.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:r,snappingManager:this.snappingManager,snapToScene:!1,view:t,...c};return"2d"===t.type?this._makeDrawGraphicTool2D(m):this._makeDrawGraphicTool3D(m)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return Pe(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:Se(e.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));return Pe(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,sketchOptions:this.sketchOptions})}_setupCreateOperationHandle(e,t){const o=this.view;if(!o)return this._logMissingView(),null;let i=null;const a=e.forceUniformSize,r=e.centered,p=new G,l=[s(()=>p.destroy()),o.on("key-down",t=>{if(t.key===B.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===B.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==B.vertexAdd||t.repeat)t.key===B.undo?(t.stopPropagation(),h.undo()):t.key===B.redo?(t.stopPropagation(),h.redo()):t.key!==B.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===B.center&&(t.repeat||(e.centered=!r,t.stopPropagation())):(e.forceUniformSize=!a,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}},z.WIDGET),o.on("key-up",t=>{t.key===B.pan?e.enabled=!0:t.key!==B.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===B.center&&(e.centered=r,t.stopPropagation()):(e.forceUniformSize=a,t.stopPropagation())},z.WIDGET),e.on("vertex-update",()=>{p.notify()}),e.on("vertex-add",t=>{switch(p.notify(),i=null==i?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:i,tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("cursor-update",t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("vertex-remove",t=>{switch(p.notify(),t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("complete",e=>{this._set("createGraphic",e.graphic),i="complete",e.aborted?h&&h.cancel():h&&h.complete()}),g(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],h=new pe({activeComponent:e,type:"create",onEnd:()=>{n(l),o.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>(T(p),e.canUndo),canRedo:()=>(T(p),e.canRedo)});return h}_setupDrawToolOperationHandle(e,t){const i=this.view;if(!i)return this._logMissingView(),null;let a=null;const r=[i.on("key-down",t=>{t.key===B.pan&&(t.stopPropagation(),t.repeat||(e.editable=!1))},z.WIDGET),i.on("key-up",t=>{t.key===B.pan&&(e.editable=!0)},z.WIDGET),e.on("before-vertex-add",t=>{const o=e.mostUpstreamPlugin?.configuration;if(o&&"legacyCreateTool"in o&&("point"===o?.legacyCreateTool||"text"===o.legacyCreateTool)){const e=t.detail.originalEvent;return void(e&&"key"in e&&e.key===B.vertexAdd&&t.preventDefault())}}),e.on("before-complete",t=>{const o=e.getGeometryIfCompleted();(!o||me(o))&&t.preventDefault()}),e.on(["vertex-add","vertex-remove"],i=>{switch(this.createGraphic&&(this.createGraphic.geometry=e.getGeometryIfCompleted()),a=null==a&&"vertex-remove"!==i.type?"start":"active",i.operation){case"apply":this.emit("create",{graphic:this.createGraphic,state:a,tool:this.activeTool,toolEventInfo:i,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[this.createGraphic].filter(o),tool:t});break;case"redo":this._emitRedoEvent({graphics:[this.createGraphic].filter(o),tool:t})}}),e.on("cursor-update",t=>{this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),(t.vertices[0]?.vertexIndex>0||t.vertices[0]?.componentIndex>0)&&this.emit("create",{graphic:this.createGraphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("complete",async({geometry:t,isSimple:o})=>{const i=this.createGraphic,a=!!t&&"mesh"!==t.type&&"extent"!==t.type&&!o;if(i&&(i.geometry=o?t:e.unprocessedGeometry??t),a&&i){this._internalGraphicsLayer.add(this.createGraphic);const e=new AbortController;this._drawToolSimplifyAbortController?.abort(),this._drawToolSimplifyAbortController=e,await this._updatingHandles.addPromise(u(this._finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:i,handle:s})))}else s.complete()})],s=new le({activeComponent:e,type:"create",onEnd:()=>{n(r),i.tools.remove(e)},undo:()=>e.undo(),redo:()=>e.redo(),canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return r.push(e.on("cancel",()=>{this._drawToolSimplifyAbortController=d(this._drawToolSimplifyAbortController),s.cancel()})),s}async _finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:o,handle:i}){const a=this.view?.acquireCursor("progress","high");a&&this.addHandles(a);const r=()=>!!e.signal.aborted&&(o&&(this._layerAdapter?.remove(o),this._internalGraphicsLayer?.remove(o)),this._set("createGraphic",null),!0);try{const a=await this._geometryWorkerHandle.simplify(t,e.signal);if(r())return;o.geometry=a??t,this._internalGraphicsLayer?.remove(o),i.complete()}finally{a?.remove(),this._drawToolSimplifyAbortController===e&&(this._drawToolSimplifyAbortController=null)}}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":case"freehandPolyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":case"freehandPolygon":return this.polygonSymbol;case"mesh":return this.meshSymbol;case"text":return this.textSymbol}}async _setupUpdateOperation(e,t){const{view:o}=this;if(!o)return this._logMissingView(),null;const i={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};this.activeUpdateOptions=i;let a=i.tool??_e.tool;if(this.removeGraphics(e),this.addGraphics(e),"3d"===o.type){if(0===e.length)return null;switch(a){case"move":return this._setupMove3DOperation(e,i,o,a);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],i,o);case"transform":return this._setupGraphicTransform3DOperation(e,i,o)}}switch(a){case"move":return this._setupMove2DOperation(e,i,o);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,a,i,o);case"transform":return ge(e)&&(a="reshape"),this._setupTransformOrReshape2DOperation(e,a,i,o)}}async _setupMove3DOperation(e,t,o,i,a=!1){const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Pe(r))return r;const{ManipulatedObject3DGraphic:s,MoveTool3D:p}=r.module,l=new Map,h=()=>{l.forEach(e=>e.destroy()),l.clear()};for(const n of e){const e=new s({view:o,graphic:n}),t=K(e);if(0!==t)return h(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${W(t)}).`),null;l.set(n,e)}const d=new p({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),d.objects.addMany(Array.from(l.values())),a||this.updateGraphics.addMany(e);const c=[],u=new he({activeComponent:d,tool:i,type:"update",onEnd:()=>{n(c),He(o,d),h()},undo:()=>{ke(this.view,d),Ce(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ae(u,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.push(e);const t=new s({view:o,graphic:e});l.set(e,t),d.objects.push(t),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:async e=>{const t=this.updateGraphics.indexOf(e);if(u.history.undo.forEach(e=>e.updates.splice(t,1)),u.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0===this.updateGraphics.length)return void u.complete();const o=l.get(e);o&&(d.objects.remove(o),o.destroy(),l.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.at(0),a=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));a&&!Pe(a)&&(u.onEnd(),u.destroy(),this._setUpdateOperationHandle(a,t))}});return c.push(...this._getHandlesForComponent(u,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(u,e,t),z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)},z.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&0===q(e[0])){const a=e[0],r=a.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=r&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(a,t,o,i)}return this._setupMove3DOperation(e,t,o,"transform",i)}async _setupPointTransform3DOperation(e,t,o){const i="transform",{enableRotation:a,enableScaling:r,enableZ:s}=t,p=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Pe(p))return p;const{TransformTool3D:l,ManipulatedObject3DGraphic:h}=p.module,d=new h({graphic:e,view:o}),c=new l({object:d,view:o,enableRotation:a,enableScaling:r,enableZ:s,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(c),this.updateGraphics.add(e);const u=[],m=new he({activeComponent:c,tool:i,type:"update",onEnd:()=>{n(u),He(o,c),d.destroy()},undo:()=>{ke(this.view,c),Ce(m,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ae(m,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),m.onEnd(),m.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Pe(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:async e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),m.complete()},toggleTool:async()=>{}});return u.push(...this._getHandlesForComponent(m,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(m,e,t),z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},z.WIDGET)),m}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:r,enableScaling:s,enableZ:p,preserveAspectRatio:l}=t,h=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Pe(h))return h;const{ManipulatedObject3DGraphic:d,ExtentTransformTool:c}=h.module,u=this.view?.inputManager?.isModifierKeyDown(B.constraint),m=new d({view:o,graphic:e}),g=new c({object:m,view:o,enableRotation:r,enableScaling:s,enableZ:p,preserveAspectRatio:!!l!=!!u,sketchOptions:this.sketchOptions});o.tools.add(g),i||this.updateGraphics.add(e);const y=[],v=new he({activeComponent:g,tool:a,type:"update",onEnd:()=>{n(y),He(o,g),m.destroy()},canUndo:()=>!g.destroyed&&g.canUndo,undo:()=>{g.destroyed||(g.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!g.destroyed&&g.canRedo,redo:()=>{g.destroyed||(g.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),v.onEnd(),v.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Pe(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:async e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),v.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));i&&!Pe(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return y.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(v,e,t),z.WIDGET),o.on("key-down",e=>this._getCommonUpdateOperationKeyDownHandlers(v,e),z.WIDGET),o.on("key-down",e=>{e.key!==B.constraint||e.repeat||(g.preserveAspectRatio=!g.preserveAspectRatio,e.stopPropagation())},z.WIDGET),o.on("key-up",e=>{e.key===B.constraint&&(g.preserveAspectRatio=!g.preserveAspectRatio,e.stopPropagation())},z.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,o));if(Pe(a))return a;const r=new he({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._clearCursor(),n(l),n(p),a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();Ce(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();Ae(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),a.graphics=this.updateGraphics.toArray(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:async e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?a.graphics=o:r.complete()}});let s=!1;const p=[o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,t),z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==B.constraint||e.repeat||(s=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},z.WIDGET),o.on("key-up",e=>{e.key===B.constraint&&s&&(s=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},z.WIDGET)],l=this._getHandlesForComponent(r,t);return r}async _setupReshape3DOperation(e,t,o,i=!1){const a="reshape",r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Pe(r))return r;const{ManipulatedObject3DGraphic:s,ReshapeTool3D:p}=r.module,l=new s({view:o,graphic:e}),h=Z(l);if(0!==h)return l.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${W(h)}).`),null;const d=t.reshapeOptions,c=new p({view:o,object:l,enableZVertex:t.enableZ&&"move"===d?.vertexOperation,enableZShape:t.enableZ&&"move"===d?.shapeOperation,enableMoveObject:"move"===d?.shapeOperation||"move-xy"===d?.shapeOperation,enableMidpoints:"split"===d?.edgeOperation,enableEdgeOffset:"offset"===d?.edgeOperation,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(c),i||this.updateGraphics.add(l.graphic);const u=[],m=new he({activeComponent:c,tool:a,type:"update",onEnd:()=>{n(u),He(o,c),l.destroy()},canUndo:()=>!c.destroyed&&c.canUndo,undo:()=>{c.destroyed||(c.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!c.destroyed&&c.canRedo,redo:()=>{c.destroyed||(c.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),m.onEnd(),m.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Pe(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:async e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),m.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;m.onEnd(),m.destroy();const e=await this._updatingHandles.addPromise(this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0));Pe(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(m,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(m,e,t),z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},z.WIDGET)),m}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise("transform"===t?this._getBox(e,o,i):this._getReshape(e,o,i));if(Pe(a))return a;const r=new he({activeComponent:a,type:"update",onEnd:()=>{n(p),n(s),r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{Ce(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{Ae(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},addToSelection:async e=>{let t=r.activeComponent;if("reshape"===t?.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll(),r.onEnd(),r.destroy();const a=await this._updatingHandles.addPromise(this._setupTransformOrReshape2DOperation(t,"transform",o,i));if(Pe(a))return;this._setUpdateOperationHandle(a,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),r.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:async e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();0===o.length?r.complete():ge(o)?await r.toggleTool():r.activeComponent.graphics=o,this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;const e=this.updateGraphics.at(0),t=e.geometry;if(null!=t&&("reshape"===r.tool&&"point"===t.type||"transform"===r.tool&&"extent"===t.type))return;let a=null;const s={...this.defaultUpdateOptions,...o,...this.activeUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...o?.reshapeOptions,...this.activeUpdateOptions?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...o?.highlightOptions,...this.activeUpdateOptions?.highlightOptions}};"transform"===r.tool?a=await this._updatingHandles.addPromise(this._getReshape([e],s,i)):"reshape"===r.tool&&(a=await this._updatingHandles.addPromise(this._getBox([e],s,i))),Pe(a)||(r.activeComponent?.destroy(),r.activeComponent=a,r.activeComponent&&(n(p),p=this._getHandlesForComponent(r,s)))}}),s=[i.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,o),z.WIDGET),i.on("key-down",e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key===B.constraint&&!e.repeat&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},z.WIDGET),i.on("key-up",e=>{if(e.key===B.constraint&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},z.WIDGET)];let p=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return Pe(r)?r:new r.module.default({enableMoveAllGraphics:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayCursor("grabbing"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayCursor("pointer"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayCursor("move"),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:r,preserveAspectRatio:s}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(Pe(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(B.constraint),l=new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightName:r?.name,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!p,layer:this._internalGraphicsLayer,view:o,sketchOptions:this.sketchOptions,callbacks:{onMoveStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMove:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMoveStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScale:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotate:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"})}});return l.addHandles(g(()=>[this.activeUpdateOptions?.enableRotation,this.activeUpdateOptions?.enableScaling],([e,o])=>{l.enableRotation=e??t.enableRotation??!0,l.enableScaling=o??t.enableScaling??!0,l.refresh()},y)),l}async _getReshape(e,t,o){const{highlightOptions:i,reshapeOptions:a}=t,r="split"===a?.edgeOperation,s="move"===a?.shapeOperation,n=!!a?.enableCreateCurveFromStraightEdge,p=await this._requireModule(import("../../views/draw/support/Reshape.js"));return Pe(p)?p:new p.module.default({enableMidpoints:r,enableMovement:s,enableCurveOnMidpoint:n,graphic:e[0],highlightName:i?.name,highlightsEnabled:!!i?.enabled,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,view:o,callbacks:{onReshapeStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshape:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshapeStop:({mover:e,type:t})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e,type:t},type:"update"}),onMoveStart:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const i=e.map(e=>M(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:i,vertices:o,type:t},type:"update"})},onVertexRemove:({removed:e,type:t,vertices:o})=>{const i=e.map(e=>M(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:i,vertices:o,type:t},type:"update"})}}})}_getHandlesForComponent(e,t){const o=e.activeComponent;if(!o)return[];switch(o.type){case"graphic-mover":return[o.on("graphic-click",({graphic:o,viewEvent:i})=>{i.native?.shiftKey&&t.multipleSelectionEnabled&&(i.stopPropagation(),this._updatingHandles.consumePromise(e.removeFromSelection(o)))}),o.on("graphic-move-start",t=>e.addToHistory(Me(t.allGraphics)))];case"box":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Me(t.graphics))),o.on("rotate-start",t=>e.addToHistory(Me(t.graphics))),o.on("scale-start",t=>e.addToHistory(Me(t.graphics)))];case"reshape":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Me([t.mover]))),o.on("reshape-start",t=>e.addToHistory(Me([t.graphic]))),o.on("vertex-add",t=>e.addToHistory(Me([t.oldGraphic]))),o.on("vertex-remove",t=>e.addToHistory(Me([t.oldGraphic])))];case"move-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("move-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-start"},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e.dx,dy:e.dy,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move"},type:"update"})}),o.events.on("move-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-stop"},type:"update"})}),o.events.on("immediate-click",o=>{this._updatingHandles.consumePromise(o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool())})];case"transform-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("translate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})}),o.events.on("translate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})}),o.events.on("rotate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-start"},type:"update"})}),o.events.on("rotate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})}),o.events.on("scale-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})}),o.events.on("scale-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})}),o.events.on("translate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})}),o.events.on("rotate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate"},type:"update"})}),o.events.on("scale",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})}),o.events.on("immediate-click",o=>{this._updatingHandles.consumePromise(o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool())})];case"reshape-3d":return[o.events.on("reshape",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("vertex-add",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("vertex-remove",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("immediate-click",o=>{this._updatingHandles.consumePromise(o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool())})]}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;if(a.native?.shiftKey&&this.hasGraphic(i))return a.stopPropagation(),void this._updatingHandles.consumePromise(e.removeFromSelection(i));t.toggleToolOnClick&&(a.stopPropagation(),this._updatingHandles.consumePromise(e.toggleTool()))}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view?.map;this._disablePopup(t);const i=()=>{if(e===this._operationHandle){const i=this.updateGraphics.toArray(),a=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),o&&o.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit("update",{graphics:i,state:"complete",aborted:e.cancelled,tool:a,toolEventInfo:null,type:"update"})}};e.on("complete",i)}_getCommonUpdateOperationClickHandlers(e,t,o){return this._updatingHandles.addPromise(this._handleCommonUpdateOperationClick(e,t,o))}async _handleCommonUpdateOperationClick(e,t,o){const i=re(t),a=await t.defer(()=>this._getFirstHit(i));if(null==a)return void(this.cancelUpdateOnClickAway&&e.complete());const r=t.native.shiftKey?this._toggleSelection([a.graphic],e,o):null;if(r)return t.stopPropagation(),void await r;this.updateGraphics.includes(a.graphic)?this._shouldTemporarilyDisablePopup(o)&&t.stopPropagation():e.complete()}async _toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;for(const a of e)if(null!=a&&i&&this.hasGraphic(a))return this.updateGraphics.includes(a)?await t.removeFromSelection(a):await t.addToSelection(a)}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===B.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===B.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===B.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&B.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){this._operationHandle&&"update"===this._operationHandle.type&&null!=this.activeComponent&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view?.map?.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=h(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||null==t)&&(e.attributes?.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_clearCursor(){this.removeHandles(be)}_displayCursor(e){this.removeHandles(be),this.view?.container&&null!=e&&this.addHandles(this.view.acquireCursor(e,"high"),be)}_logError(e,t,o){l.getLogger(this).error(new a(e,t,o))}async _requireModule(e){const t=new AbortController;this._moduleLoaderAbortController=t;const o=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:"aborted"}:{module:o}}_emitUndoEvent(e){this.emit("undo",{...e,type:"undo"})}_emitRedoEvent(e){this.emit("redo",{...e,type:"redo"})}_emitDeleteEvent(e){this.emit("delete",{...e,type:"delete"})}_onLayerGraphicsChangeCallback(e){if(null!=this._operationHandle){const{updateGraphics:t}=this;for(const o of e.removed)if(t.includes(o)){if(!(t.length>1)){this._operationHandle.cancel();break}this._updatingHandles.consumePromise(this._operationHandle.removeFromSelection(o))}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,o,i){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;const a=this.view,r=await(import("../../views/draw/DrawTool.js"));await this.pluginManager.loadPlugins();const s=await this.pluginManager.makeRenderer({customSymbol:o.graphicSymbol,useTextSymbol:"text"===i}),n=new r.DrawTool({view:a,elevationInfo:this._layerAdapter?.elevationInfo??I("3d"===a.type),hasZ:!!o.hasZ,sketchOptions:this.sketchOptions,renderer:s,defaultZ:o.defaultZ??0,directionOptions:o.directionOptions,snappingManager:this.snappingManager,enableVertexVisuals:"rectangle"!==i&&"circle"!==i,readPluginSetting:(e,t)=>this.settingsManager.getValue(t)});n.addHandles(p(s));const l=new t({...o.graphicProperties,attributes:{...o.graphicProperties?.attributes},symbol:o.graphicSymbol??this._getGraphicSymbolFromTool(i)});return o.graphicSymbol||n.addHandles(g(()=>this._getGraphicSymbolFromTool(i),e=>l.symbol=e)),this._set("createGraphic",l),a.addAndActivateTool(n),n.begin(e),n}get test(){}wait(){return _(()=>!this.updating)}_shouldTemporarilyDisablePopup(e){return this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._shouldTemporarilyDisablePopup(e)&&this.view&&null==this._originalPopupEnabled&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._shouldTemporarilyDisablePopup(e)&&this.view&&null!=this._originalPopupEnabled&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){const e=this.view;e?(d(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await m(_(()=>e?.ready),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",Oe("view"))}_logMissingLayer(){this._logError(Ge,Oe("layer"))}};e([b()],Te.prototype,"_defaultSnappingManager",void 0),e([b()],Te.prototype,"_layerAdapter",null),e([b()],Te.prototype,"_pluginManager",void 0),e([b({readOnly:!0})],Te.prototype,"settingsManager",void 0),e([b()],Te.prototype,"_operationHandle",void 0),e([b({readOnly:!0})],Te.prototype,"_updatingHandles",void 0),e([b({readOnly:!0})],Te.prototype,"_toolTransitionHandles",void 0),e([b()],Te.prototype,"_drawToolSimplifyAbortController",void 0),e([b({readOnly:!0})],Te.prototype,"activeTool",null),e([b()],Te.prototype,"geometrySimplificationInProgress",null),e([b({readOnly:!0})],Te.prototype,"activeCreateToolDrawMode",null),e([b()],Te.prototype,"activeTooltip",null),e([b({types:V})],Te.prototype,"activeFillSymbol",void 0),e([b()],Te.prototype,"activeLineSymbol",void 0),e([b()],Te.prototype,"activeVertexSymbol",void 0),e([b()],Te.prototype,"allowDeleteKey",void 0),e([b({readOnly:!0})],Te.prototype,"createGraphic",null),e([b()],Te.prototype,"defaultCreateOptions",null),e([b()],Te.prototype,"defaultUpdateOptions",null),e([b()],Te.prototype,"activeUpdateOptions",void 0),e([b({type:$,nonNullable:!0})],Te.prototype,"labelOptions",null),e([b()],Te.prototype,"layer",void 0),e([b({types:V})],Te.prototype,"pointSymbol",void 0),e([b({types:V})],Te.prototype,"polygonSymbol",void 0),e([b({types:V})],Te.prototype,"polylineSymbol",void 0),e([b()],Te.prototype,"meshSymbol",void 0),e([b({type:F})],Te.prototype,"textSymbol",null),e([b({type:ee,nonNullable:!0})],Te.prototype,"snappingOptions",null),e([b()],Te.prototype,"snappingManager",null),e([b({readOnly:!0})],Te.prototype,"state",null),e([b()],Te.prototype,"toolTransitionInProgress",null),e([b({type:J,nonNullable:!0})],Te.prototype,"tooltipOptions",null),e([b({readOnly:!0})],Te.prototype,"updateGraphics",void 0),e([b()],Te.prototype,"updateOnGraphicClick",void 0),e([b()],Te.prototype,"cancelUpdateOnClickAway",void 0),e([b()],Te.prototype,"updating",null),e([b()],Te.prototype,"creationMode",void 0),e([b({type:Q,nonNullable:!0})],Te.prototype,"valueOptions",null),e([b({types:V})],Te.prototype,"vertexSymbol",void 0),e([b({value:null})],Te.prototype,"view",null),e([b({constructOnly:!0,type:Y})],Te.prototype,"sketchOptions",void 0),e([b()],Te.prototype,"useLegacyCreateTools",void 0),e([b()],Te.prototype,"isUsingLegacyCreateTools",null),e([b()],Te.prototype,"pluginManager",null),e([b()],Te.prototype,"drawTool",null),e([b()],Te.prototype,"rootPlugins",null),e([b()],Te.prototype,"effectiveAvailablePlugins",null),e([b()],Te.prototype,"firstPluginWithSwappableLeaf",null),e([b()],Te.prototype,"multiplePluginsActive",null),Te=e([w("esri.widgets.Sketch.SketchViewModel")],Te);const Ge="sketch:missing-property",Oe=e=>`Property '${e}' is missing on SketchViewModel.`;function Se(e){return"polygon"===e||"rectangle"===e||"circle"===e}function Ce(e,t){Ee("undo",e.history.undo,e.history.redo,t)}function Ae(e,t){Ee("redo",e.history.redo,e.history.undo,t)}function Ee(e,t,o,i){const a=t.pop();if(!a)return;const r=a.updates,s=[];i.forEach((t,o)=>{const i=r[o];null!=i&&("geometry"in i&&null!=i.geometry&&(s.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(s.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(s.push(i),i[e](t)))}),o.push({updates:s})}function ke(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function Me(e){return{updates:e.map(({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e})}}function He(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function Pe(e){return"requireError"in e&&"aborted"===e.requireError}export{Te as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import a from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import{makeHandle as s,drainHandles as n,destroyHandle as p}from"../../core/handleUtils.js";import"../../core/has.js";import l from"../../core/Logger.js";import{destroyMaybe as h,abortMaybe as d}from"../../core/maybe.js";import{createAbortError as c,ignoreAbortErrors as u,whenOrAbort as m}from"../../core/promiseUtils.js";import{watch as g,syncAndInitial as y,on as v,when as f,whenOnce as _}from"../../core/reactiveUtils.js";import{property as b,subclass as w}from"../../core/accessorSupport/decorators.js";import{trackAccess as T}from"../../core/accessorSupport/tracking.js";import{SimpleObservable as G}from"../../core/accessorSupport/tracking/SimpleObservable.js";import{UpdatingHandles as O}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as S}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as C,isLoaded as A,load as E,project as M}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as H}from"../../geometry/support/coordsUtils.js";import{equals as k}from"../../geometry/support/spatialReferenceUtils.js";import P from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as D}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as I}from"../../support/elevationInfoUtils.js";import U from"../../symbols/FillSymbol3DLayer.js";import j from"../../symbols/MeshSymbol3D.js";import R from"../../symbols/SimpleFillSymbol.js";import x from"../../symbols/SimpleLineSymbol.js";import L from"../../symbols/SimpleMarkerSymbol.js";import F from"../../symbols/TextSymbol.js";import{symbolTypes as V}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as W}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as K}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as Z}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as q}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as N}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as z}from"../../views/input/InputManager.js";import{sketchKeys as B}from"../../views/interactive/keybindings.js";import $ from"../../views/interactive/sketch/SketchLabelOptions.js";import Y from"../../views/interactive/sketch/SketchOptions.js";import J from"../../views/interactive/sketch/SketchTooltipOptions.js";import Q from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as X}from"../../views/interactive/snapping/SnappingManager.js";import ee from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as te}from"../../views/interactive/snapping/snappingUtils.js";import{GeometryWorkerHandle as oe}from"../../views/support/GeometryWorkerHandle.js";import{defaultHighlightName as ie}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as ae}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as re}from"../../views/support/screenUtils.js";import se from"./adapters/layer/GraphicsLayerAdapter.js";import ne from"./adapters/layer/MapNotesLayerAdapter.js";import{CreateOperationHandle as pe,DrawToolOperationHandle as le,UpdateOperationHandle as he}from"./support/OperationHandle.js";import{PluginManager as de}from"./support/PluginManager.js";import{SettingsManager as ce}from"./support/SettingsManager.js";import{getLegacyTool as ue,isCompletelyDegenerate as me,graphicsHaveTooFewVerticesForBox as ge,getModeFromCreateOptions as ye,getDrawToolGeometryTypeFromCreateTool as ve}from"./support/sketchUtils.js";const fe={defaultZ:0},_e={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move",enableCreateCurveFromStraightEdge:!0},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0,name:ie},tool:"transform"},be=Symbol(),we=Symbol();let Te=class extends r{constructor(e){super(e),this._defaultSnappingManager=null,this._internalGraphicsLayer=new P({listMode:"hide",internal:!0,title:"SVM Internal"}),this._pluginManager=new de({sketchViewModel:this}),this.settingsManager=new ce({availablePlugins:()=>this.pluginManager.visiblePluginsFlat}),this._operationHandle=null,this._updatingHandles=new O,this._toolTransitionHandles=new O,this._drawToolSimplifyAbortController=null,this._geometryWorkerHandle=new oe,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.activeUpdateOptions=null,this.layer=null,this.pointSymbol=new L({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new R({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new x({color:[130,130,130,1],width:2}),this.meshSymbol=new j({symbolLayers:new i([new U])}),this.updateGraphics=new i,this.updateOnGraphicClick=!0,this.cancelUpdateOnClickAway=!0,this.creationMode="single",this.vertexSymbol=new L({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new Y,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{const{_layerAdapter:e}=this;if(this.removeHandles(we),!e)return;const t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),g(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},y)].filter(o);this.addHandles(t,we)},this._originalPopupEnabled=null,this.defaultCreateOptions=fe,this.defaultUpdateOptions=_e,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new ee,this.textSymbol=new F({text:"text"})}initialize(){this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([v(()=>this.view?.map?.layers,"change",e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),g(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),y),g(()=>this.view,e=>{this._defaultSnappingManager=h(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new X({view:e,options:this.snappingOptions})),"2d"===e.type?(import("../../views/2d/interactive/editingTools.js"),this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe())):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))},y),g(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),te(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=h(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this._toolTransitionHandles.destroy(),this._drawToolSimplifyAbortController=d(this._drawToolSimplifyAbortController),this._geometryWorkerHandle.destroy(),this._pluginManager?.destroy(),this.emit("destroy")}get _layerAdapter(){const{layer:e}=this;switch(e?.type){case"graphics":return new se(e);case"map-notes":return new ne(e);default:return null}}get activeTool(){return this._operationHandle?.tool??null}get geometrySimplificationInProgress(){return!!this._drawToolSimplifyAbortController}get activeCreateToolDrawMode(){const e=this._operationHandle;if("create"===e?.type&&e.activeComponent&&"mode"in e.activeComponent)return e.activeComponent.mode;if("draw-2.0"===e?.activeComponent?.type){const t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(o).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){const{activeComponent:e,destroyed:t}=this,o=!t&&e&&"tooltip"in e?e.tooltip:null;return o?.visible?o:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return null==this.activeComponent||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):this.activeComponent.graphic}get defaultCreateOptions(){return this._get("defaultCreateOptions")}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...fe,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{..._e,...e,reshapeOptions:{..._e.reshapeOptions,...e?.reshapeOptions},highlightOptions:{..._e.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get textSymbol(){return this._get("textSymbol")}set textSymbol(e){this._set("textSymbol",e)}get snappingOptions(){return this.snappingManager?.options??this._get("snappingOptions")}set snappingOptions(e){null!=this._defaultSnappingManager&&(this._defaultSnappingManager.options=e),this._set("snappingOptions",e)}get snappingManager(){return this._isOverridden("snappingManager")&&this._get("snappingManager"),this._defaultSnappingManager}set snappingManager(e){if(e)this._isOverridden("snappingManager")||(this._defaultSnappingManager=h(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new X({options:this.snappingOptions,view:e})),this._clearOverride("snappingManager")}}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get toolTransitionInProgress(){return this._toolTransitionHandles.updating||!!this.drawTool?.lifecycleManager.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return this.toolTransitionInProgress||this.activeComponent&&"updating"in this.activeComponent&&this.activeComponent.updating||!!(this._updatingHandles.updating||this._drawToolSimplifyAbortController||this.snappingManager?.updating||this.drawTool?.updating)}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&this._clearCursor(),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(f(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},y),o),this._set("view",e),this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}get pluginManager(){return this._pluginManager}get drawTool(){return"draw-2.0"!==this.activeComponent?.type?null:this.activeComponent}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome("rootPlugins",e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;const e=this.view?.type??"2d",{firstPluginWithSwappableLeaf:t}=this;return t?t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e)):this.rootPlugins?.filter(t=>!t.excludedViews?.includes(e)).filter(o)??[]}get firstPluginWithSwappableLeaf(){const e=this.view?.type??"2d",t=this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>null!=t&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1);return t}get multiplePluginsActive(){return!!this.drawTool&&this.drawTool.pluginStack.length>1}addGraphic(e){this._layerAdapter?.add(e)}addGraphics(e){this._layerAdapter?.addMany(e)}hasGraphic(e){return!!this._layerAdapter?.has(e)}removeGraphic(e){this._layerAdapter?.remove(e)}removeGraphics(e){this._layerAdapter?.removeMany(e)}removeAllGraphics(){this._layerAdapter?.removeAll()}cancel(){this._moduleLoaderAbortController=d(this._moduleLoaderAbortController),this._viewReadyAbortController=d(this._viewReadyAbortController),this._drawToolSimplifyAbortController=d(this._drawToolSimplifyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e}=this,o=t.toArray();this.removeGraphics(o),this.cancel(),this._emitDeleteEvent({graphics:o,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map(e=>e.clone()).toArray();return this.addGraphics(e),this.emit("duplicate",{graphics:e,type:"duplicate"}),e}return[]}async create(e,t){return this._toolTransitionHandles.addPromise(this._create(e,t))}async _create(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());const{view:o,layer:i}=this;if(!o||"disabled"===this.state)throw i||this._logMissingLayer(),c();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");N(o,this._internalGraphicsLayer);const a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t));if(null==a||this.destroyed)return void o.map?.remove(this._internalGraphicsLayer);const r=ue(e),s=()=>{if(a===this._operationHandle){const o=this.createGraphic,i=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map?.remove(this._internalGraphicsLayer),a.cancelled||null==o||this.addGraphic(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:i?"cancel":"complete",tool:r??"point",toolEventInfo:null,type:"create"}),i||this._sketchContinuationFlag)return;const{creationMode:s}=this;if("continuous"===s){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(u(this.create(e,t)))}else"update"===s&&o&&this._updatingHandles.consumePromise(u(this.update([o])))}};a.on("complete",s),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return await e.load(),this.create("mesh",{mode:"click",hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){return this._toolTransitionHandles.addPromise(this._update(e,t))}async _update(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());const{layer:o,view:i,state:a}=this;if(!i||"disabled"===a)throw o||this._logMissingLayer(),c();null!=i.activeTool&&(i.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some(e=>this.hasGraphic(e)?null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0):(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0)))return;const s=await this._updatingHandles.addPromise(this._setupUpdateOperation(r,t));this.destroyed||null==s||Pe(s)||(N(i,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit("update",{graphics:r,state:"start",aborted:!1,tool:s.tool,toolEventInfo:null,type:"update"}))}async _updateSpatialReference(e){const t=this.view;if(t){e=Array.isArray(e)?e:[e];for(const o of e)null==o.geometry||"mesh"===o.geometry.type||k(o.geometry.spatialReference,t.spatialReference)||(C(o.geometry.spatialReference,t.spatialReference)||A()||await E(),o.geometry=M(o.geometry,t.spatialReference))}else this._logMissingView()}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._updatingHandles.consumePromise(this._operationHandle?.toggleTool())}async _getFirstHit(e){const t=this.view;if(!t)return this._logMissingView(),null;if("2d"===t.type){const o=[];t.map.allLayers.forEach(e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)});const i=await t.hitTest(e,{exclude:o});return ae(i.results)}const o=[t.map.ground];t.map.allLayers.forEach(e=>{D(e)&&o.push(e)});const i=await t.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!i.ground.mapPoint||t.map.ground.opacity<1||i.ground.distance-(e.distance??0)>-Math.min(3*i.ground.distance,"global"===t.viewingMode?S(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY)))return e}return null}_generateViewHandles(e){return[e.on("immediate-click",async e=>{const t="active"===this.state&&"create"===this._operationHandle?.type;"disabled"!==this.state&&!t&&this.updateOnGraphicClick&&await this._updatingHandles.addPromise(this._handleImmediateClick(e))},z.WIDGET)]}async _handleImmediateClick(e){const t=await e.defer(()=>this._getFirstHit(re(e)));let o=null;if(null!=t){const i=t.graphic;this.updateGraphics.includes(i)||this.hasGraphic(i)?(e.stopPropagation(),o=i):"2d"!==this.view?.type||this._isComponentGraphic(i)||"active"!==this.state||this.cancel()}else"active"===this.state&&this.cancelUpdateOnClickAway&&this.cancel();null==o||this.updateGraphics.includes(o)||await this.update([o],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){const o=this.view;if(!o)return this._logMissingView(),null;const i={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},a="string"==typeof e?this.pluginManager?.getPluginsEquivalentToCreateTool(e,i.mode):e,r=ue(e);if(a&&!this.isUsingLegacyCreateTools){const e=await this._setupDrawTool(a,i,r??"polyline");if(e)return this._setupDrawToolOperationHandle(e,r??"point")}if(!r)return null;const s=await this._setupDrawGraphicTool(r,o,i);return null==s?null:(o.tools.add(s),o.activeTool=s,this._setupCreateOperationHandle(s,r))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView."),null;if(!t)return this._logMissingView(),null;const{cursor:i,defaultZ:a,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=ye(p,e),d=ve(e),c=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=c?.preserveAspectRatio??l??"rectangle"!==e,m={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:i,defaultZ:a,forceUniformSize:u,graphicProperties:{...n,attributes:{...n?.attributes}},geometryToPlace:s,geometryType:d,mode:h,graphicSymbol:o.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:r,snappingManager:this.snappingManager,snapToScene:!1,view:t,...c};return"2d"===t.type?this._makeDrawGraphicTool2D(m):this._makeDrawGraphicTool3D(m)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return Pe(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:Se(e.geometryType)?this.activeFillSymbol:null,toolOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));return Pe(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,toolOptions:this.sketchOptions})}_setupCreateOperationHandle(e,t){const o=this.view;if(!o)return this._logMissingView(),null;let i=null;const a=e.forceUniformSize,r=e.centered,p=new G,l=[s(()=>p.destroy()),o.on("key-down",t=>{if(t.key===B.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===B.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==B.vertexAdd||t.repeat)t.key===B.undo?(t.stopPropagation(),h.undo()):t.key===B.redo?(t.stopPropagation(),h.redo()):t.key!==B.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===B.center&&(t.repeat||(e.centered=!r,t.stopPropagation())):(e.forceUniformSize=!a,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}},z.WIDGET),o.on("key-up",t=>{t.key===B.pan?e.enabled=!0:t.key!==B.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===B.center&&(e.centered=r,t.stopPropagation()):(e.forceUniformSize=a,t.stopPropagation())},z.WIDGET),e.on("vertex-update",()=>{p.notify()}),e.on("vertex-add",t=>{switch(p.notify(),i=null==i?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:i,tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("cursor-update",t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("vertex-remove",t=>{switch(p.notify(),t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("complete",e=>{this._set("createGraphic",e.graphic),i="complete",e.aborted?h&&h.cancel():h&&h.complete()}),g(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],h=new pe({activeComponent:e,type:"create",onEnd:()=>{n(l),o.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>(T(p),e.canUndo),canRedo:()=>(T(p),e.canRedo)});return h}_setupDrawToolOperationHandle(e,t){const i=this.view;if(!i)return this._logMissingView(),null;let a=null;const r=[i.on("key-down",t=>{t.key===B.pan&&(t.stopPropagation(),t.repeat||(e.editable=!1))},z.WIDGET),i.on("key-up",t=>{t.key===B.pan&&(e.editable=!0)},z.WIDGET),e.on("before-vertex-add",t=>{const o=e.mostUpstreamPlugin?.configuration;if(o&&"legacyCreateTool"in o&&("point"===o?.legacyCreateTool||"text"===o.legacyCreateTool)){const e=t.detail.originalEvent;return void(e&&"key"in e&&e.key===B.vertexAdd&&t.preventDefault())}}),e.on("before-complete",t=>{const o=e.getGeometryIfCompleted();(!o||me(o))&&t.preventDefault()}),e.on(["vertex-add","vertex-remove"],i=>{switch(this.createGraphic&&(this.createGraphic.geometry=e.getGeometryIfCompleted()),a=null==a&&"vertex-remove"!==i.type?"start":"active",i.operation){case"apply":this.emit("create",{graphic:this.createGraphic,state:a,tool:this.activeTool,toolEventInfo:i,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[this.createGraphic].filter(o),tool:t});break;case"redo":this._emitRedoEvent({graphics:[this.createGraphic].filter(o),tool:t})}}),e.on("cursor-update",t=>{this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),(t.vertices[0]?.vertexIndex>0||t.vertices[0]?.componentIndex>0)&&this.emit("create",{graphic:this.createGraphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("complete",async({geometry:t,isSimple:o})=>{const i=this.createGraphic,a=!!t&&"mesh"!==t.type&&"extent"!==t.type&&!o;if(i&&(i.geometry=o?t:e.unprocessedGeometry??t),a&&i){this._internalGraphicsLayer.add(this.createGraphic);const e=new AbortController;this._drawToolSimplifyAbortController?.abort(),this._drawToolSimplifyAbortController=e,await this._updatingHandles.addPromise(u(this._finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:i,handle:s})))}else s.complete()})],s=new le({activeComponent:e,type:"create",onEnd:()=>{n(r),i.tools.remove(e)},undo:()=>e.undo(),redo:()=>e.redo(),canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return r.push(e.on("cancel",()=>{this._drawToolSimplifyAbortController=d(this._drawToolSimplifyAbortController),s.cancel()})),s}async _finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:o,handle:i}){const a=this.view?.acquireCursor("progress","high");a&&this.addHandles(a);const r=()=>!!e.signal.aborted&&(o&&(this._layerAdapter?.remove(o),this._internalGraphicsLayer?.remove(o)),this._set("createGraphic",null),!0);try{const a=await this._geometryWorkerHandle.simplify(t,e.signal);if(r())return;o.geometry=a??t,this._internalGraphicsLayer?.remove(o),i.complete()}finally{a?.remove(),this._drawToolSimplifyAbortController===e&&(this._drawToolSimplifyAbortController=null)}}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":case"freehandPolyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":case"freehandPolygon":return this.polygonSymbol;case"mesh":return this.meshSymbol;case"text":return this.textSymbol}}async _setupUpdateOperation(e,t){const{view:o}=this;if(!o)return this._logMissingView(),null;const i={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};this.activeUpdateOptions=i;let a=i.tool??_e.tool;if(this.removeGraphics(e),this.addGraphics(e),"3d"===o.type){if(0===e.length)return null;switch(a){case"move":return this._setupMove3DOperation(e,i,o,a);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],i,o);case"transform":return this._setupGraphicTransform3DOperation(e,i,o)}}switch(a){case"move":return this._setupMove2DOperation(e,i,o);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,a,i,o);case"transform":return ge(e)&&(a="reshape"),this._setupTransformOrReshape2DOperation(e,a,i,o)}}async _setupMove3DOperation(e,t,o,i,a=!1){const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Pe(r))return r;const{ManipulatedObject3DGraphic:s,MoveTool3D:p}=r.module,l=new Map,h=()=>{l.forEach(e=>e.destroy()),l.clear()};for(const n of e){const e=new s({view:o,graphic:n}),t=K(e);if(0!==t)return h(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${W(t)}).`),null;l.set(n,e)}const d=new p({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,toolOptions:this.sketchOptions});o.tools.add(d),d.objects.addMany(Array.from(l.values())),a||this.updateGraphics.addMany(e);const c=[],u=new he({activeComponent:d,tool:i,type:"update",onEnd:()=>{n(c),ke(o,d),h()},undo:()=>{Me(this.view,d),Ce(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ae(u,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.push(e);const t=new s({view:o,graphic:e});l.set(e,t),d.objects.push(t),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:async e=>{const t=this.updateGraphics.indexOf(e);if(u.history.undo.forEach(e=>e.updates.splice(t,1)),u.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0===this.updateGraphics.length)return void u.complete();const o=l.get(e);o&&(d.objects.remove(o),o.destroy(),l.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.at(0),a=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));a&&!Pe(a)&&(u.onEnd(),u.destroy(),this._setUpdateOperationHandle(a,t))}});return c.push(...this._getHandlesForComponent(u,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(u,e,t),z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)},z.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&0===q(e[0])){const a=e[0],r=a.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=r&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(a,t,o,i)}return this._setupMove3DOperation(e,t,o,"transform",i)}async _setupPointTransform3DOperation(e,t,o){const i="transform",{enableRotation:a,enableScaling:r,enableZ:s}=t,p=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Pe(p))return p;const{TransformTool3D:l,ManipulatedObject3DGraphic:h}=p.module,d=new h({graphic:e,view:o}),c=new l({object:d,view:o,enableRotation:a,enableScaling:r,enableZ:s,snappingManager:this.snappingManager,toolOptions:this.sketchOptions});o.tools.add(c),this.updateGraphics.add(e);const u=[],m=new he({activeComponent:c,tool:i,type:"update",onEnd:()=>{n(u),ke(o,c),d.destroy()},undo:()=>{Me(this.view,c),Ce(m,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ae(m,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),m.onEnd(),m.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Pe(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:async e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),m.complete()},toggleTool:async()=>{}});return u.push(...this._getHandlesForComponent(m,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(m,e,t),z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},z.WIDGET)),m}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:r,enableScaling:s,enableZ:p,preserveAspectRatio:l}=t,h=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Pe(h))return h;const{ManipulatedObject3DGraphic:d,ExtentTransformTool:c}=h.module,u=this.view?.inputManager?.isModifierKeyDown(B.constraint),m=new d({view:o,graphic:e}),g=new c({object:m,view:o,enableRotation:r,enableScaling:s,enableZ:p,preserveAspectRatio:!!l!=!!u,toolOptions:this.sketchOptions});o.tools.add(g),i||this.updateGraphics.add(e);const y=[],v=new he({activeComponent:g,tool:a,type:"update",onEnd:()=>{n(y),ke(o,g),m.destroy()},canUndo:()=>!g.destroyed&&g.canUndo,undo:()=>{g.destroyed||(g.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!g.destroyed&&g.canRedo,redo:()=>{g.destroyed||(g.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),v.onEnd(),v.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Pe(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:async e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),v.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));i&&!Pe(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return y.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(v,e,t),z.WIDGET),o.on("key-down",e=>this._getCommonUpdateOperationKeyDownHandlers(v,e),z.WIDGET),o.on("key-down",e=>{e.key!==B.constraint||e.repeat||(g.preserveAspectRatio=!g.preserveAspectRatio,e.stopPropagation())},z.WIDGET),o.on("key-up",e=>{e.key===B.constraint&&(g.preserveAspectRatio=!g.preserveAspectRatio,e.stopPropagation())},z.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,o));if(Pe(a))return a;const r=new he({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._clearCursor(),n(l),n(p),a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();Ce(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();Ae(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),a.graphics=this.updateGraphics.toArray(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:async e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?a.graphics=o:r.complete()}});let s=!1;const p=[o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,t),z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==B.constraint||e.repeat||(s=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},z.WIDGET),o.on("key-up",e=>{e.key===B.constraint&&s&&(s=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},z.WIDGET)],l=this._getHandlesForComponent(r,t);return r}async _setupReshape3DOperation(e,t,o,i=!1){const a="reshape",r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Pe(r))return r;const{ManipulatedObject3DGraphic:s,ReshapeTool3D:p}=r.module,l=new s({view:o,graphic:e}),h=Z(l);if(0!==h)return l.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${W(h)}).`),null;const d=t.reshapeOptions,c=new p({view:o,object:l,enableZVertex:t.enableZ&&"move"===d?.vertexOperation,enableZShape:t.enableZ&&"move"===d?.shapeOperation,enableMoveObject:"move"===d?.shapeOperation||"move-xy"===d?.shapeOperation,enableMidpoints:"split"===d?.edgeOperation,enableEdgeOffset:"offset"===d?.edgeOperation,snappingManager:this.snappingManager,toolOptions:this.sketchOptions});o.tools.add(c),i||this.updateGraphics.add(l.graphic);const u=[],m=new he({activeComponent:c,tool:a,type:"update",onEnd:()=>{n(u),ke(o,c),l.destroy()},canUndo:()=>!c.destroyed&&c.canUndo,undo:()=>{c.destroyed||(c.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!c.destroyed&&c.canRedo,redo:()=>{c.destroyed||(c.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),m.onEnd(),m.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Pe(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:async e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),m.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;m.onEnd(),m.destroy();const e=await this._updatingHandles.addPromise(this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0));Pe(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(m,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(m,e,t),z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},z.WIDGET)),m}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise("transform"===t?this._getBox(e,o,i):this._getReshape(e,o,i));if(Pe(a))return a;const r=new he({activeComponent:a,type:"update",onEnd:()=>{n(p),n(s),r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{Ce(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{Ae(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},addToSelection:async e=>{let t=r.activeComponent;if("reshape"===t?.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll(),r.onEnd(),r.destroy();const a=await this._updatingHandles.addPromise(this._setupTransformOrReshape2DOperation(t,"transform",o,i));if(Pe(a))return;this._setUpdateOperationHandle(a,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),r.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:async e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();0===o.length?r.complete():ge(o)?await r.toggleTool():r.activeComponent.graphics=o,this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;const e=this.updateGraphics.at(0),t=e.geometry;if(null!=t&&("reshape"===r.tool&&"point"===t.type||"transform"===r.tool&&"extent"===t.type))return;let a=null;const s={...this.defaultUpdateOptions,...o,...this.activeUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...o?.reshapeOptions,...this.activeUpdateOptions?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...o?.highlightOptions,...this.activeUpdateOptions?.highlightOptions}};"transform"===r.tool?a=await this._updatingHandles.addPromise(this._getReshape([e],s,i)):"reshape"===r.tool&&(a=await this._updatingHandles.addPromise(this._getBox([e],s,i))),Pe(a)||(r.activeComponent?.destroy(),r.activeComponent=a,r.activeComponent&&(n(p),p=this._getHandlesForComponent(r,s)))}}),s=[i.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,o),z.WIDGET),i.on("key-down",e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key===B.constraint&&!e.repeat&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},z.WIDGET),i.on("key-up",e=>{if(e.key===B.constraint&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},z.WIDGET)];let p=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return Pe(r)?r:new r.module.default({enableMoveAllGraphics:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayCursor("grabbing"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayCursor("pointer"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayCursor("move"),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:r,preserveAspectRatio:s}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(Pe(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(B.constraint),l=new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightName:r?.name,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!p,layer:this._internalGraphicsLayer,view:o,toolOptions:this.sketchOptions,callbacks:{onMoveStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMove:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMoveStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScale:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotate:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"})}});return l.addHandles(g(()=>[this.activeUpdateOptions?.enableRotation,this.activeUpdateOptions?.enableScaling],([e,o])=>{l.enableRotation=e??t.enableRotation??!0,l.enableScaling=o??t.enableScaling??!0,l.refresh()},y)),l}async _getReshape(e,t,o){const{highlightOptions:i,reshapeOptions:a}=t,r="split"===a?.edgeOperation,s="move"===a?.shapeOperation,n=!!a?.enableCreateCurveFromStraightEdge,p=await this._requireModule(import("../../views/draw/support/Reshape.js"));return Pe(p)?p:new p.module.default({enableMidpoints:r,enableMovement:s,enableCurveOnMidpoint:n,graphic:e[0],highlightName:i?.name,highlightsEnabled:!!i?.enabled,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,toolOptions:this.sketchOptions,view:o,callbacks:{onReshapeStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshape:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshapeStop:({mover:e,type:t})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e,type:t},type:"update"}),onMoveStart:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const i=e.map(e=>H(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:i,vertices:o,type:t},type:"update"})},onVertexRemove:({removed:e,type:t,vertices:o})=>{const i=e.map(e=>H(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:i,vertices:o,type:t},type:"update"})}}})}_getHandlesForComponent(e,t){const o=e.activeComponent;if(!o)return[];switch(o.type){case"graphic-mover":return[o.on("graphic-click",({graphic:o,viewEvent:i})=>{i.native?.shiftKey&&t.multipleSelectionEnabled&&(i.stopPropagation(),this._updatingHandles.consumePromise(e.removeFromSelection(o)))}),o.on("graphic-move-start",t=>e.addToHistory(He(t.allGraphics)))];case"box":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(He(t.graphics))),o.on("rotate-start",t=>e.addToHistory(He(t.graphics))),o.on("scale-start",t=>e.addToHistory(He(t.graphics)))];case"reshape":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(He([t.mover]))),o.on("reshape-start",t=>e.addToHistory(He([t.graphic]))),o.on("vertex-add",t=>e.addToHistory(He([t.oldGraphic]))),o.on("vertex-remove",t=>e.addToHistory(He([t.oldGraphic])))];case"move-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("move-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-start"},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e.dx,dy:e.dy,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move"},type:"update"})}),o.events.on("move-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-stop"},type:"update"})}),o.events.on("immediate-click",o=>{this._updatingHandles.consumePromise(o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool())})];case"transform-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("translate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})}),o.events.on("translate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})}),o.events.on("rotate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-start"},type:"update"})}),o.events.on("rotate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})}),o.events.on("scale-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})}),o.events.on("scale-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})}),o.events.on("translate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})}),o.events.on("rotate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate"},type:"update"})}),o.events.on("scale",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})}),o.events.on("immediate-click",o=>{this._updatingHandles.consumePromise(o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool())})];case"reshape-3d":return[o.events.on("reshape",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("vertex-add",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("vertex-remove",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("immediate-click",o=>{this._updatingHandles.consumePromise(o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool())})]}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;if(a.native?.shiftKey&&this.hasGraphic(i))return a.stopPropagation(),void this._updatingHandles.consumePromise(e.removeFromSelection(i));t.toggleToolOnClick&&(a.stopPropagation(),this._updatingHandles.consumePromise(e.toggleTool()))}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view?.map;this._disablePopup(t);const i=()=>{if(e===this._operationHandle){const i=this.updateGraphics.toArray(),a=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),o&&o.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit("update",{graphics:i,state:"complete",aborted:e.cancelled,tool:a,toolEventInfo:null,type:"update"})}};e.on("complete",i)}_getCommonUpdateOperationClickHandlers(e,t,o){return this._updatingHandles.addPromise(this._handleCommonUpdateOperationClick(e,t,o))}async _handleCommonUpdateOperationClick(e,t,o){const i=re(t),a=await t.defer(()=>this._getFirstHit(i));if(null==a)return void(this.cancelUpdateOnClickAway&&e.complete());const r=t.native.shiftKey?this._toggleSelection([a.graphic],e,o):null;if(r)return t.stopPropagation(),void await r;this.updateGraphics.includes(a.graphic)?this._shouldTemporarilyDisablePopup(o)&&t.stopPropagation():e.complete()}async _toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;for(const a of e)if(null!=a&&i&&this.hasGraphic(a))return this.updateGraphics.includes(a)?await t.removeFromSelection(a):await t.addToSelection(a)}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===B.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===B.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===B.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&B.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){this._operationHandle&&"update"===this._operationHandle.type&&null!=this.activeComponent&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view?.map?.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=h(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||null==t)&&(e.attributes?.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_clearCursor(){this.removeHandles(be)}_displayCursor(e){this.removeHandles(be),this.view?.container&&null!=e&&this.addHandles(this.view.acquireCursor(e,"high"),be)}_logError(e,t,o){l.getLogger(this).error(new a(e,t,o))}async _requireModule(e){const t=new AbortController;this._moduleLoaderAbortController=t;const o=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:"aborted"}:{module:o}}_emitUndoEvent(e){this.emit("undo",{...e,type:"undo"})}_emitRedoEvent(e){this.emit("redo",{...e,type:"redo"})}_emitDeleteEvent(e){this.emit("delete",{...e,type:"delete"})}_onLayerGraphicsChangeCallback(e){if(null!=this._operationHandle){const{updateGraphics:t}=this;for(const o of e.removed)if(t.includes(o)){if(!(t.length>1)){this._operationHandle.cancel();break}this._updatingHandles.consumePromise(this._operationHandle.removeFromSelection(o))}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,o,i){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;const a=this.view,r=await(import("../../views/draw/DrawTool.js"));await this.pluginManager.loadPlugins();const s=await this.pluginManager.makeRenderer({customSymbol:o.graphicSymbol,useTextSymbol:"text"===i}),n=new r.DrawTool({view:a,elevationInfo:this._layerAdapter?.elevationInfo??I("3d"===a.type),hasZ:!!o.hasZ,toolOptions:this.sketchOptions,renderer:s,defaultZ:o.defaultZ??0,directionOptions:o.directionOptions,snappingManager:this.snappingManager,enableVertexVisuals:"rectangle"!==i&&"circle"!==i,readPluginSetting:(e,t)=>this.settingsManager.getValue(t)});n.addHandles(p(s));const l=new t({...o.graphicProperties,attributes:{...o.graphicProperties?.attributes},symbol:o.graphicSymbol??this._getGraphicSymbolFromTool(i)});return o.graphicSymbol||n.addHandles(g(()=>this._getGraphicSymbolFromTool(i),e=>l.symbol=e)),this._set("createGraphic",l),a.addAndActivateTool(n),n.begin(e),n}get test(){}wait(){return _(()=>!this.updating)}_shouldTemporarilyDisablePopup(e){return this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._shouldTemporarilyDisablePopup(e)&&this.view&&null==this._originalPopupEnabled&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._shouldTemporarilyDisablePopup(e)&&this.view&&null!=this._originalPopupEnabled&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){const e=this.view;e?(d(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await m(_(()=>e?.ready),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",Oe("view"))}_logMissingLayer(){this._logError(Ge,Oe("layer"))}};e([b()],Te.prototype,"_defaultSnappingManager",void 0),e([b()],Te.prototype,"_layerAdapter",null),e([b()],Te.prototype,"_pluginManager",void 0),e([b({readOnly:!0})],Te.prototype,"settingsManager",void 0),e([b()],Te.prototype,"_operationHandle",void 0),e([b({readOnly:!0})],Te.prototype,"_updatingHandles",void 0),e([b({readOnly:!0})],Te.prototype,"_toolTransitionHandles",void 0),e([b()],Te.prototype,"_drawToolSimplifyAbortController",void 0),e([b({readOnly:!0})],Te.prototype,"activeTool",null),e([b()],Te.prototype,"geometrySimplificationInProgress",null),e([b({readOnly:!0})],Te.prototype,"activeCreateToolDrawMode",null),e([b()],Te.prototype,"activeTooltip",null),e([b({types:V})],Te.prototype,"activeFillSymbol",void 0),e([b()],Te.prototype,"activeLineSymbol",void 0),e([b()],Te.prototype,"activeVertexSymbol",void 0),e([b()],Te.prototype,"allowDeleteKey",void 0),e([b({readOnly:!0})],Te.prototype,"createGraphic",null),e([b()],Te.prototype,"defaultCreateOptions",null),e([b()],Te.prototype,"defaultUpdateOptions",null),e([b()],Te.prototype,"activeUpdateOptions",void 0),e([b({type:$,nonNullable:!0})],Te.prototype,"labelOptions",null),e([b()],Te.prototype,"layer",void 0),e([b({types:V})],Te.prototype,"pointSymbol",void 0),e([b({types:V})],Te.prototype,"polygonSymbol",void 0),e([b({types:V})],Te.prototype,"polylineSymbol",void 0),e([b()],Te.prototype,"meshSymbol",void 0),e([b({type:F})],Te.prototype,"textSymbol",null),e([b({type:ee,nonNullable:!0})],Te.prototype,"snappingOptions",null),e([b()],Te.prototype,"snappingManager",null),e([b({readOnly:!0})],Te.prototype,"state",null),e([b()],Te.prototype,"toolTransitionInProgress",null),e([b({type:J,nonNullable:!0})],Te.prototype,"tooltipOptions",null),e([b({readOnly:!0})],Te.prototype,"updateGraphics",void 0),e([b()],Te.prototype,"updateOnGraphicClick",void 0),e([b()],Te.prototype,"cancelUpdateOnClickAway",void 0),e([b()],Te.prototype,"updating",null),e([b()],Te.prototype,"creationMode",void 0),e([b({type:Q,nonNullable:!0})],Te.prototype,"valueOptions",null),e([b({types:V})],Te.prototype,"vertexSymbol",void 0),e([b({value:null})],Te.prototype,"view",null),e([b({constructOnly:!0,type:Y})],Te.prototype,"sketchOptions",void 0),e([b()],Te.prototype,"useLegacyCreateTools",void 0),e([b()],Te.prototype,"isUsingLegacyCreateTools",null),e([b()],Te.prototype,"pluginManager",null),e([b()],Te.prototype,"drawTool",null),e([b()],Te.prototype,"rootPlugins",null),e([b()],Te.prototype,"effectiveAvailablePlugins",null),e([b()],Te.prototype,"firstPluginWithSwappableLeaf",null),e([b()],Te.prototype,"multiplePluginsActive",null),Te=e([w("esri.widgets.Sketch.SketchViewModel")],Te);const Ge="sketch:missing-property",Oe=e=>`Property '${e}' is missing on SketchViewModel.`;function Se(e){return"polygon"===e||"rectangle"===e||"circle"===e}function Ce(e,t){Ee("undo",e.history.undo,e.history.redo,t)}function Ae(e,t){Ee("redo",e.history.redo,e.history.undo,t)}function Ee(e,t,o,i){const a=t.pop();if(!a)return;const r=a.updates,s=[];i.forEach((t,o)=>{const i=r[o];null!=i&&("geometry"in i&&null!=i.geometry&&(s.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(s.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(s.push(i),i[e](t)))}),o.push({updates:s})}function Me(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function He(e){return{updates:e.map(({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e})}}function ke(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function Pe(e){return"requireError"in e&&"aborted"===e.requireError}export{Te as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../../Color.js";import{EventedAccessor as i}from"../../../core/Evented.js";import r from"../../../core/Logger.js";import{rad2deg as s}from"../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../core/maybe.js";import{when as o,watch as a}from"../../../core/reactiveUtils.js";import{convertUnit as l}from"../../../core/units.js";import{property as c,subclass as h}from"../../../core/accessorSupport/decorators.js";import d from"../../../geometry/Point.js";import{isLoadedOrLoadFor as p,project as m}from"../../../geometry/projectionUtils.js";import{getResolutionForScale as g}from"../../../geometry/support/scaleUtils.js";import{MeasuredGrid as u}from"../../../grids/MeasuredGrid.js";import{makeDehydratedPoint as v}from"../../../layers/graphics/dehydratedPoint.js";import{defaultUnitPropertyMetadata as y}from"../../../properties/defaultUnit.js";import _ from"../../../symbols/SimpleLineSymbol.js";import w from"../../../symbols/SimpleMarkerSymbol.js";import{minimumPixelsPerStrideForDisplayWhenScalingOff as f}from"../../../views/2d/grid/constants.js";import{getScaleFactor as S,shouldUsePlanar as b,measureMetersPerUnitAtReferencePoint as P}from"../../../views/2d/grid/gridUtils.js";import{DrawGraphicTool2D as T}from"../../../views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js";import"../../../views/2d/interactive/editingTools/ControlPointsTransformTool.js";import"../../../views/2d/interactive/editingTools/TransformTool.js";import"../../../views/2d/interactive/editingTools/MediaTransformToolsWrapper.js";import{ViewEventPriorities as C}from"../../../views/input/InputManager.js";import{KeyBindings as j,sketchKeys as x}from"../../../views/interactive/keybindings.js";import G from"../../../views/interactive/snapping/SnappingOptions.js";import{gridPlacementGraphicSymbol as O}from"../../../views/interactive/snapping/snappingUtils.js";import R from"../../../views/overlay/CrosshairOverlayItem.js";import I from"../../../views/overlay/TextOverlayItem.js";import{degreeSymbol as L}from"../../CoordinateConversion/support/formatUtils.js";import{applyColorToGrid as M,gridRotationToDegrees as k}from"./gridUtils.js";const E=Symbol("grid-interactivity");let V=class extends i{constructor(t){super(t),this._drawGraphicTool=null,this._keybindings=null,this._crosshairLabel=null,this._crosshairItem=null,this.snappingManager=null,this.snappingOptions=null,this.view=null,this.placementDisabled=!1,this._mostRecentlyShownGrid=null,this._sketchedVertexCount=0}initialize(){this.addHandles([o(()=>!this.displayEnabled,()=>{this.interactivePlacementState=null}),a(()=>this.view?.viewpoint,()=>{this._renderOverlays()}),a(()=>this.snappingOptions?.gridEnabled,t=>{null!=t&&this.trySetDisplayEnabled(t)}),a(()=>this.view?.grid,(t,e)=>{this._mostRecentlyShownGrid=!t&&e?e:null})])}destroy(){this._resetGridPlacementState(),this._crosshairItem&&(this.view?.overlay?.removeItem(this._crosshairItem),this._crosshairItem=n(this._crosshairItem)),this._crosshairLabel&&(this.view?.overlay?.removeItem(this._crosshairLabel),this._crosshairLabel=n(this._crosshairLabel))}get displayEnabled(){return!!this.view?.grid}get dynamicScaling(){return this.grid?.dynamicScaling??!1}set dynamicScaling(t){this.grid&&(this.grid.dynamicScaling=t)}get grid(){return this.view?.grid??this._mostRecentlyShownGrid}set gridColor(t){if(t?.equals(this.grid?.majorLineColor))return;if(!t)return;const[e,i,r,s]=t.toArray();M(this.grid,[e,i,r,s/255])}get gridColor(){return this.grid?.majorLineColor}get gridControlsEnabled(){return this.displayEnabled&&!this.interactivePlacementState}set interactivePlacementState(t){this._set("interactivePlacementState",t),this._resetGridPlacementState(),t&&this._startGridManipulation(t)}get majorLineInterval(){return this.grid?.majorLineInterval??10}set majorLineInterval(t){this.grid&&(this.grid.majorLineInterval=t<1?1:t>15?15:t)}get rotateWithMap(){return this.grid?.rotateWithMap??!1}set rotateWithMap(t){this.grid&&(this.grid.rotateWithMap=t)}get rotation(){return this.grid?.rotation??-180}set rotation(t){this.grid&&(this.grid.rotation=t)}get snappingEnabled(){return(this.grid&&this.snappingOptions?.gridEnabled)??!1}set snappingEnabled(t){const{snappingOptions:e}=this;e&&(e.gridEnabled=t)}get spacing(){return this.grid?.spacing??1}set spacing(t){this.grid&&t>0&&(this.grid.spacing=t)}get unit(){return this.grid?.units}set unit(t){this.grid&&(this.grid.units=t)}get gridOutOfScale(){return!this.dynamicScaling&&null!=this._pixelsPerStride&&this._pixelsPerStride<f}get effectiveSpacingAfterDynamicScaling(){return this.majorLineInterval<1||!this.dynamicScaling||!this.view||null==this._pixelsPerStride||!this.grid?.spacing?null:this.grid.spacing*S(this.majorLineInterval,this._pixelsPerStride,this.dynamicScaling)}get numericSpacingInputShouldBeVisible(){return!!this.view?.spatialReference&&b(this.view.spatialReference)}get _metersPerSRUnit(){if(!(this.view&&this.displayEnabled&&this.grid&&p(this.grid.center.spatialReference,this.view.spatialReference)))return null;const t=m(this.grid.center,this.view.spatialReference);return P(t)}get _pixelsPerStride(){if(!this.view?.scale||!this.displayEnabled||!this.grid||null==this._metersPerSRUnit)return null;const t=this.grid,{scale:e,spatialReference:i}=this.view;return l(t.spacing,t.units,"meters")/(this._metersPerSRUnit*g(e,i))}get _isPlacing(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"place"===t||"interactive"===t&&0===this._sketchedVertexCount}get _isRotating(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"rotate"===t||"interactive"===t&&1===this._sketchedVertexCount}get _isScaling(){if(!this._drawGraphicTool)return!1;return"interactive"===this.interactivePlacementState&&1===this._sketchedVertexCount}togglePlacementState(t){this.interactivePlacementState=this.interactivePlacementState===t?null:t}trySetDisplayEnabled(t){const{view:e}=this;if(e?.ready)if(!e.grid&&t)if(this._mostRecentlyShownGrid)e.grid=this._mostRecentlyShownGrid;else{const t="imperial"===this.defaultUnit?"feet":"meters";e.grid=new u({units:t,center:e.center??new d,rotateWithMap:!0}),M(this.grid,[115,115,115])}else t||(e.grid=null);else r.getLogger(this).warn("Attempting to enable grid display while view is not ready")}async startPlacement(t){const{view:e,snappingManager:i}=this;if(!e)return;this._set("interactivePlacementState",t),this._sketchedVertexCount=0;const r=new T({view:e,graphicProperties:{attributes:{[O]:O}},sketchOptions:{tooltips:{enabled:!0,visibleElements:{direction:!1,rotation:!1,totalLength:!1,elevation:!1,distance:!1,area:!1}}},geometryType:"polyline",mode:"click",snapToScene:!1,snappingManager:i,forceUniformSize:!0,centered:!1,cursor:"interactive"===this.interactivePlacementState||"place"===this.interactivePlacementState?"none":null,regularVerticesSymbol:void 0,activeVertexSymbol:D,activeLineSymbol:U,graphicSymbol:U});if(this._drawGraphicTool=r,e.addAndActivateTool(r),this._renderOverlays(),!this._keybindings){const t=new j;t.add(x.complete,()=>this._onDrawComplete()),t.add(x.vertexAdd,()=>this._drawGraphicTool?.drawOperation.commitStagedVertex()),this._keybindings=t}this.addHandles([r.on("cursor-update",t=>this._onCursorUpdate(t)),r.on("complete",()=>this._onDrawComplete()),r.on("vertex-add",e=>this._onVertexAdd(e,t)),this._keybindings.register(e,C.WIDGET)],E)}async _startGridManipulation(t){const{view:e}=this;if(!e)return void(this.interactivePlacementState=null);const i=new CustomEvent("before-placement",{cancelable:!0});this.emit("before-placement",i),i.defaultPrevented||await this.startPlacement(t)}_onCursorUpdate(t){try{if(this._isPlacing){const e=t.vertices[0].coordinates;return void this._handlePlace(e)}if(this._drawGraphicTool.cursor=null,this._isRotating&&this._handleRotate(t.vertices[0].coordinates),this._isScaling){const t=this._drawGraphicTool?.drawOperation.cursorVertex;this._handleScale(t)}}finally{this._renderOverlays()}}_onDrawComplete(){this._drawGraphicTool.cursor=null,this.interactivePlacementState=null}_onVertexAdd(t,e){const i=t.vertices[0].coordinates;this._isPlacing&&this._handlePlace(i),this._isRotating&&this._sketchedVertexCount>0&&this._handleRotate(i),this._isScaling&&this._sketchedVertexCount>0&&this._handleScale(v(i[0],i[1],void 0,this.view.spatialReference)),this._sketchedVertexCount++,this._drawGraphicTool.cursor=null,2!==this._sketchedVertexCount&&"interactive"===e||(this.interactivePlacementState=null),this._renderOverlays()}_handlePlace(t){const{grid:e,view:i}=this;e&&i&&(e.center=new d({x:t[0],y:t[1],spatialReference:i.spatialReference}))}_handleRotate(t){const{grid:e,view:i}=this;if(!e||!i)return;this._drawGraphicTool?.sketchOptions.tooltips.set("enabled",!1);const{x:r,y:n}=e.center,[o,a]=t,l=i.toScreen(e.center,{pickClosestTarget:!0}),c=l&&i.toMap(l),h=i.toScreen(v(o,a,void 0,i.spatialReference),{pickClosestTarget:!0}),d=h&&i.toMap(h),p=c?c.x:r,m=c?c.y:n,g=p-(d?d.x:o),u=m-(d?d.y:a);if(0===g&&0===u)return;const y=Math.atan2(u,g),_=s(y),w=e.rotateWithMap,f=i.viewpoint.rotation??0,S=w?_:_-f;e.rotation=Math.fround(S)%360}_handleScale(t){const{view:e,grid:i,_drawGraphicTool:r,interactivePlacementState:s,_metersPerSRUnit:n}=this;if(!(t&&e&&i&&r&&n))return;r.sketchOptions.tooltips.enabled=!1;const o="interactive"===s?i.center:r.drawOperation.firstVertex;if(!o||!t)return;const a=e?.toScreen(o),c=a&&e.toMap(a),h=e?.toScreen(t),d=c??o,p=(h&&e.toMap(h))??t,m=Math.sqrt((d.x-p.x)**2+(d.y-p.y)**2),g=l(m*n,"meters",i.units);this.spacing=g}_renderOverlays(){this._renderCrosshairOverlay(),this._renderTextOverlay()}_renderTextOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this,r=this._getCrosshairLabel();if(!(t&&e?.overlay&&i&&r))return;const s=e.toScreen(t.center,{pickClosestTarget:!0});s&&(r.position=[s.x+12,s.y+12]),this._isRotating?(r.text=`${k(t.rotation)}${L}`,r.visible=!0):r.visible=!1}_renderCrosshairOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this;if(!t||!e?.overlay||!i)return;const r=this._getCrosshair();if(!r)return;const s=e.toScreen(t.center);s&&(r.x=s.x,r.y=s.y,r.rotation=t.rotateWithMap?e.viewpoint.rotation-t.rotation:-t.rotation,r.visible=!!i)}_getCrosshairLabel(){if(this._crosshairLabel)return this._crosshairLabel;const{grid:t,view:i,_drawGraphicTool:r}=this;if(!t||!i?.overlay||!r)return null;const s=new I({anchor:"top-left",fontSize:10,textColor:new e([21,21,21]),backgroundColor:new e([248,248,248]),padding:8,borderRadius:20});return i.overlay.addItem(s),this._crosshairLabel=s,s}_getCrosshair(){const{_crosshairItem:t,view:e}=this;return e?.overlay?t&&e.overlay.items.includes(t)?t:(this._crosshairItem=new R({color:e.effectiveTheme.accentColor,thickness:4,length:36,visible:!0}),e.overlay?.addItem(this._crosshairItem),this._crosshairItem):null}_resetGridPlacementState(){this.removeHandles(E),this._crosshairItem&&(this._crosshairItem.visible=!1),this._crosshairLabel&&(this._crosshairLabel.visible=!1),this._drawGraphicTool&&(this.view?.activeTool===this._drawGraphicTool&&(this.view.activeTool=null),this.view?.tools.remove(this._drawGraphicTool)),this._drawGraphicTool=n(this._drawGraphicTool)}};t([c(y)],V.prototype,"defaultUnit",void 0),t([c({readOnly:!0})],V.prototype,"displayEnabled",null),t([c()],V.prototype,"dynamicScaling",null),t([c()],V.prototype,"grid",null),t([c()],V.prototype,"gridColor",null),t([c({readOnly:!0})],V.prototype,"gridControlsEnabled",null),t([c()],V.prototype,"interactivePlacementState",null),t([c()],V.prototype,"majorLineInterval",null),t([c()],V.prototype,"rotateWithMap",null),t([c()],V.prototype,"rotation",null),t([c()],V.prototype,"snappingEnabled",null),t([c()],V.prototype,"snappingManager",void 0),t([c({type:G})],V.prototype,"snappingOptions",void 0),t([c()],V.prototype,"spacing",null),t([c()],V.prototype,"unit",null),t([c()],V.prototype,"view",void 0),t([c({readOnly:!0})],V.prototype,"gridOutOfScale",null),t([c({readOnly:!0})],V.prototype,"effectiveSpacingAfterDynamicScaling",null),t([c({readOnly:!0})],V.prototype,"numericSpacingInputShouldBeVisible",null),t([c()],V.prototype,"placementDisabled",void 0),t([c()],V.prototype,"_metersPerSRUnit",null),t([c()],V.prototype,"_pixelsPerStride",null),t([c()],V.prototype,"_isPlacing",null),t([c()],V.prototype,"_isRotating",null),t([c()],V.prototype,"_isScaling",null),t([c()],V.prototype,"_mostRecentlyShownGrid",void 0),t([c()],V.prototype,"_sketchedVertexCount",void 0),V=t([h("esri.widgets.support.GridControls.GridControlsViewModel")],V);const U=new _({width:0}),D=new w({color:e.fromArray([0,0,0,0]),outline:new _({color:e.fromArray([0,0,0,0])})});export{V as default};
2
+ import{__decorate as t}from"tslib";import e from"../../../Color.js";import{EventedAccessor as i}from"../../../core/Evented.js";import r from"../../../core/Logger.js";import{rad2deg as s}from"../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../core/maybe.js";import{when as o,watch as a}from"../../../core/reactiveUtils.js";import{convertUnit as l}from"../../../core/units.js";import{property as c,subclass as h}from"../../../core/accessorSupport/decorators.js";import d from"../../../geometry/Point.js";import{isLoadedOrLoadFor as p,project as m}from"../../../geometry/projectionUtils.js";import{getResolutionForScale as g}from"../../../geometry/support/scaleUtils.js";import{MeasuredGrid as u}from"../../../grids/MeasuredGrid.js";import{makeDehydratedPoint as v}from"../../../layers/graphics/dehydratedPoint.js";import{defaultUnitPropertyMetadata as y}from"../../../properties/defaultUnit.js";import _ from"../../../symbols/SimpleLineSymbol.js";import w from"../../../symbols/SimpleMarkerSymbol.js";import{minimumPixelsPerStrideForDisplayWhenScalingOff as f}from"../../../views/2d/grid/constants.js";import{getScaleFactor as S,shouldUsePlanar as b,measureMetersPerUnitAtReferencePoint as P}from"../../../views/2d/grid/gridUtils.js";import{DrawGraphicTool2D as T}from"../../../views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js";import"../../../views/2d/interactive/editingTools/ControlPointsTransformTool.js";import"../../../views/2d/interactive/editingTools/TransformTool.js";import"../../../views/2d/interactive/editingTools/MediaTransformToolsWrapper.js";import{ViewEventPriorities as C}from"../../../views/input/InputManager.js";import{KeyBindings as j,sketchKeys as x}from"../../../views/interactive/keybindings.js";import G from"../../../views/interactive/snapping/SnappingOptions.js";import{gridPlacementGraphicSymbol as O}from"../../../views/interactive/snapping/snappingUtils.js";import R from"../../../views/overlay/CrosshairOverlayItem.js";import I from"../../../views/overlay/TextOverlayItem.js";import{degreeSymbol as L}from"../../CoordinateConversion/support/formatUtils.js";import{applyColorToGrid as M,gridRotationToDegrees as k}from"./gridUtils.js";const E=Symbol("grid-interactivity");let V=class extends i{constructor(t){super(t),this._drawGraphicTool=null,this._keybindings=null,this._crosshairLabel=null,this._crosshairItem=null,this.snappingManager=null,this.snappingOptions=null,this.view=null,this.placementDisabled=!1,this._mostRecentlyShownGrid=null,this._sketchedVertexCount=0}initialize(){this.addHandles([o(()=>!this.displayEnabled,()=>{this.interactivePlacementState=null}),a(()=>this.view?.viewpoint,()=>{this._renderOverlays()}),a(()=>this.snappingOptions?.gridEnabled,t=>{null!=t&&this.trySetDisplayEnabled(t)}),a(()=>this.view?.grid,(t,e)=>{this._mostRecentlyShownGrid=!t&&e?e:null})])}destroy(){this._resetGridPlacementState(),this._crosshairItem&&(this.view?.overlay?.removeItem(this._crosshairItem),this._crosshairItem=n(this._crosshairItem)),this._crosshairLabel&&(this.view?.overlay?.removeItem(this._crosshairLabel),this._crosshairLabel=n(this._crosshairLabel))}get displayEnabled(){return!!this.view?.grid}get dynamicScaling(){return this.grid?.dynamicScaling??!1}set dynamicScaling(t){this.grid&&(this.grid.dynamicScaling=t)}get grid(){return this.view?.grid??this._mostRecentlyShownGrid}set gridColor(t){if(t?.equals(this.grid?.majorLineColor))return;if(!t)return;const[e,i,r,s]=t.toArray();M(this.grid,[e,i,r,s/255])}get gridColor(){return this.grid?.majorLineColor}get gridControlsEnabled(){return this.displayEnabled&&!this.interactivePlacementState}set interactivePlacementState(t){this._set("interactivePlacementState",t),this._resetGridPlacementState(),t&&this._startGridManipulation(t)}get majorLineInterval(){return this.grid?.majorLineInterval??10}set majorLineInterval(t){this.grid&&(this.grid.majorLineInterval=t<1?1:t>15?15:t)}get rotateWithMap(){return this.grid?.rotateWithMap??!1}set rotateWithMap(t){this.grid&&(this.grid.rotateWithMap=t)}get rotation(){return this.grid?.rotation??-180}set rotation(t){this.grid&&(this.grid.rotation=t)}get snappingEnabled(){return(this.grid&&this.snappingOptions?.gridEnabled)??!1}set snappingEnabled(t){const{snappingOptions:e}=this;e&&(e.gridEnabled=t)}get spacing(){return this.grid?.spacing??1}set spacing(t){this.grid&&t>0&&(this.grid.spacing=t)}get unit(){return this.grid?.units}set unit(t){this.grid&&(this.grid.units=t)}get gridOutOfScale(){return!this.dynamicScaling&&null!=this._pixelsPerStride&&this._pixelsPerStride<f}get effectiveSpacingAfterDynamicScaling(){return this.majorLineInterval<1||!this.dynamicScaling||!this.view||null==this._pixelsPerStride||!this.grid?.spacing?null:this.grid.spacing*S(this.majorLineInterval,this._pixelsPerStride,this.dynamicScaling)}get numericSpacingInputShouldBeVisible(){return!!this.view?.spatialReference&&b(this.view.spatialReference)}get _metersPerSRUnit(){if(!(this.view&&this.displayEnabled&&this.grid&&p(this.grid.center.spatialReference,this.view.spatialReference)))return null;const t=m(this.grid.center,this.view.spatialReference);return P(t)}get _pixelsPerStride(){if(!this.view?.scale||!this.displayEnabled||!this.grid||null==this._metersPerSRUnit)return null;const t=this.grid,{scale:e,spatialReference:i}=this.view;return l(t.spacing,t.units,"meters")/(this._metersPerSRUnit*g(e,i))}get _isPlacing(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"place"===t||"interactive"===t&&0===this._sketchedVertexCount}get _isRotating(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"rotate"===t||"interactive"===t&&1===this._sketchedVertexCount}get _isScaling(){if(!this._drawGraphicTool)return!1;return"interactive"===this.interactivePlacementState&&1===this._sketchedVertexCount}togglePlacementState(t){this.interactivePlacementState=this.interactivePlacementState===t?null:t}trySetDisplayEnabled(t){const{view:e}=this;if(e?.ready)if(!e.grid&&t)if(this._mostRecentlyShownGrid)e.grid=this._mostRecentlyShownGrid;else{const t="imperial"===this.defaultUnit?"feet":"meters";e.grid=new u({units:t,center:e.center??new d,rotateWithMap:!0}),M(this.grid,[115,115,115])}else t||(e.grid=null);else r.getLogger(this).warn("Attempting to enable grid display while view is not ready")}async startPlacement(t){const{view:e,snappingManager:i}=this;if(!e)return;this._set("interactivePlacementState",t),this._sketchedVertexCount=0;const r=new T({view:e,graphicProperties:{attributes:{[O]:O}},toolOptions:{tooltips:{enabled:!0,visibleElements:{direction:!1,rotation:!1,totalLength:!1,elevation:!1,distance:!1,area:!1}}},geometryType:"polyline",mode:"click",snapToScene:!1,snappingManager:i,forceUniformSize:!0,centered:!1,cursor:"interactive"===this.interactivePlacementState||"place"===this.interactivePlacementState?"none":null,regularVerticesSymbol:void 0,activeVertexSymbol:D,activeLineSymbol:U,graphicSymbol:U});if(this._drawGraphicTool=r,e.addAndActivateTool(r),this._renderOverlays(),!this._keybindings){const t=new j;t.add(x.complete,()=>this._onDrawComplete()),t.add(x.vertexAdd,()=>this._drawGraphicTool?.drawOperation.commitStagedVertex()),this._keybindings=t}this.addHandles([r.on("cursor-update",t=>this._onCursorUpdate(t)),r.on("complete",()=>this._onDrawComplete()),r.on("vertex-add",e=>this._onVertexAdd(e,t)),this._keybindings.register(e,C.WIDGET)],E)}async _startGridManipulation(t){const{view:e}=this;if(!e)return void(this.interactivePlacementState=null);const i=new CustomEvent("before-placement",{cancelable:!0});this.emit("before-placement",i),i.defaultPrevented||await this.startPlacement(t)}_onCursorUpdate(t){try{if(this._isPlacing){const e=t.vertices[0].coordinates;return void this._handlePlace(e)}if(this._drawGraphicTool.cursor=null,this._isRotating&&this._handleRotate(t.vertices[0].coordinates),this._isScaling){const t=this._drawGraphicTool?.drawOperation.cursorVertex;this._handleScale(t)}}finally{this._renderOverlays()}}_onDrawComplete(){this._drawGraphicTool.cursor=null,this.interactivePlacementState=null}_onVertexAdd(t,e){const i=t.vertices[0].coordinates;this._isPlacing&&this._handlePlace(i),this._isRotating&&this._sketchedVertexCount>0&&this._handleRotate(i),this._isScaling&&this._sketchedVertexCount>0&&this._handleScale(v(i[0],i[1],void 0,this.view.spatialReference)),this._sketchedVertexCount++,this._drawGraphicTool.cursor=null,2!==this._sketchedVertexCount&&"interactive"===e||(this.interactivePlacementState=null),this._renderOverlays()}_handlePlace(t){const{grid:e,view:i}=this;e&&i&&(e.center=new d({x:t[0],y:t[1],spatialReference:i.spatialReference}))}_handleRotate(t){const{grid:e,view:i}=this;if(!e||!i)return;this._drawGraphicTool?.toolOptions.tooltips.set("enabled",!1);const{x:r,y:n}=e.center,[o,a]=t,l=i.toScreen(e.center,{pickClosestTarget:!0}),c=l&&i.toMap(l),h=i.toScreen(v(o,a,void 0,i.spatialReference),{pickClosestTarget:!0}),d=h&&i.toMap(h),p=c?c.x:r,m=c?c.y:n,g=p-(d?d.x:o),u=m-(d?d.y:a);if(0===g&&0===u)return;const y=Math.atan2(u,g),_=s(y),w=e.rotateWithMap,f=i.viewpoint.rotation??0,S=w?_:_-f;e.rotation=Math.fround(S)%360}_handleScale(t){const{view:e,grid:i,_drawGraphicTool:r,interactivePlacementState:s,_metersPerSRUnit:n}=this;if(!(t&&e&&i&&r&&n))return;r.toolOptions.tooltips.enabled=!1;const o="interactive"===s?i.center:r.drawOperation.firstVertex;if(!o||!t)return;const a=e?.toScreen(o),c=a&&e.toMap(a),h=e?.toScreen(t),d=c??o,p=(h&&e.toMap(h))??t,m=Math.sqrt((d.x-p.x)**2+(d.y-p.y)**2),g=l(m*n,"meters",i.units);this.spacing=g}_renderOverlays(){this._renderCrosshairOverlay(),this._renderTextOverlay()}_renderTextOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this,r=this._getCrosshairLabel();if(!(t&&e?.overlay&&i&&r))return;const s=e.toScreen(t.center,{pickClosestTarget:!0});s&&(r.position=[s.x+12,s.y+12]),this._isRotating?(r.text=`${k(t.rotation)}${L}`,r.visible=!0):r.visible=!1}_renderCrosshairOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this;if(!t||!e?.overlay||!i)return;const r=this._getCrosshair();if(!r)return;const s=e.toScreen(t.center);s&&(r.x=s.x,r.y=s.y,r.rotation=t.rotateWithMap?e.viewpoint.rotation-t.rotation:-t.rotation,r.visible=!!i)}_getCrosshairLabel(){if(this._crosshairLabel)return this._crosshairLabel;const{grid:t,view:i,_drawGraphicTool:r}=this;if(!t||!i?.overlay||!r)return null;const s=new I({anchor:"top-left",fontSize:10,textColor:new e([21,21,21]),backgroundColor:new e([248,248,248]),padding:8,borderRadius:20});return i.overlay.addItem(s),this._crosshairLabel=s,s}_getCrosshair(){const{_crosshairItem:t,view:e}=this;return e?.overlay?t&&e.overlay.items.includes(t)?t:(this._crosshairItem=new R({color:e.effectiveTheme.accentColor,thickness:4,length:36,visible:!0}),e.overlay?.addItem(this._crosshairItem),this._crosshairItem):null}_resetGridPlacementState(){this.removeHandles(E),this._crosshairItem&&(this._crosshairItem.visible=!1),this._crosshairLabel&&(this._crosshairLabel.visible=!1),this._drawGraphicTool&&(this.view?.activeTool===this._drawGraphicTool&&(this.view.activeTool=null),this.view?.tools.remove(this._drawGraphicTool)),this._drawGraphicTool=n(this._drawGraphicTool)}};t([c(y)],V.prototype,"defaultUnit",void 0),t([c({readOnly:!0})],V.prototype,"displayEnabled",null),t([c()],V.prototype,"dynamicScaling",null),t([c()],V.prototype,"grid",null),t([c()],V.prototype,"gridColor",null),t([c({readOnly:!0})],V.prototype,"gridControlsEnabled",null),t([c()],V.prototype,"interactivePlacementState",null),t([c()],V.prototype,"majorLineInterval",null),t([c()],V.prototype,"rotateWithMap",null),t([c()],V.prototype,"rotation",null),t([c()],V.prototype,"snappingEnabled",null),t([c()],V.prototype,"snappingManager",void 0),t([c({type:G})],V.prototype,"snappingOptions",void 0),t([c()],V.prototype,"spacing",null),t([c()],V.prototype,"unit",null),t([c()],V.prototype,"view",void 0),t([c({readOnly:!0})],V.prototype,"gridOutOfScale",null),t([c({readOnly:!0})],V.prototype,"effectiveSpacingAfterDynamicScaling",null),t([c({readOnly:!0})],V.prototype,"numericSpacingInputShouldBeVisible",null),t([c()],V.prototype,"placementDisabled",void 0),t([c()],V.prototype,"_metersPerSRUnit",null),t([c()],V.prototype,"_pixelsPerStride",null),t([c()],V.prototype,"_isPlacing",null),t([c()],V.prototype,"_isRotating",null),t([c()],V.prototype,"_isScaling",null),t([c()],V.prototype,"_mostRecentlyShownGrid",void 0),t([c()],V.prototype,"_sketchedVertexCount",void 0),V=t([h("esri.widgets.support.GridControls.GridControlsViewModel")],V);const U=new _({width:0}),D=new w({color:e.fromArray([0,0,0,0]),outline:new _({color:e.fromArray([0,0,0,0])})});export{V as default};
@@ -9,7 +9,7 @@ import type { ParentItem, SelectionListParentLayer, SyncOptions } from "./types.
9
9
  *
10
10
  * @internal
11
11
  */
12
- export interface GroupLayerItemProperties extends ItemBaseProperties, Partial<Pick<GroupLayerItem, "items">> {
12
+ export interface GroupLayerItemProperties extends ItemBaseProperties, Partial<Pick<GroupLayerItem, "expanded" | "items">> {
13
13
  /**
14
14
  * Layer containing the sublayer that contains the selected features.
15
15
  *
@@ -33,6 +33,13 @@ export type RequiredConstructProperties = Pick<GroupLayerItem, "layer">;
33
33
  export default class GroupLayerItem extends ItemBase {
34
34
  /** @internal */
35
35
  constructor(properties: GroupLayerItemProperties);
36
+ /**
37
+ * Indicates the item is expanded in the selection list.
38
+ *
39
+ * @default true
40
+ * @internal
41
+ */
42
+ accessor expanded: boolean;
36
43
  /**
37
44
  * Set of child layer items. Can also be another GroupLayerItem in the case of SubtypeGroupLayer or KnowledgeGraphLayer.
38
45
  *
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{property as t,subclass as r}from"../../../core/accessorSupport/decorators.js";import s from"./ItemBase.js";let o=class extends s{constructor(e){super(e),this.items=[],this.layer=null}get layers(){const{layer:e}=this;return"group"===e.type||"knowledge-graph"===e.type?e.layers.toArray().reverse():"subtype-group"===e.type?e.sublayers.toArray().reverse():[]}get maxVisibleFeatureCountExceeded(){return this.items.some(e=>e.maxVisibleFeatureCountExceeded)}get total(){return this.items.reduce((e,t)=>e+t.total,0)}get visible(){return this.items.some(e=>e.visible)}get visibleTotal(){return this.items.reduce((e,t)=>e+t.visibleTotal,0)}reset(){this.items.forEach(e=>e.reset())}async sync({controller:e,promises:t}){const{layers:r,viewModel:s}=this;this.items=s.layersToItems({controller:e,groupLayerItem:this,layers:r,promises:t})}};e([t()],o.prototype,"items",void 0),e([t()],o.prototype,"layer",void 0),e([t()],o.prototype,"layers",null),e([t()],o.prototype,"maxVisibleFeatureCountExceeded",null),e([t()],o.prototype,"total",null),e([t()],o.prototype,"visible",null),e([t()],o.prototype,"visibleTotal",null),o=e([r("esri.widgets.support.SelectionList.GroupLayerItem")],o);const i=o;export{i as default};
2
+ import{__decorate as e}from"tslib";import{property as t,subclass as r}from"../../../core/accessorSupport/decorators.js";import s from"./ItemBase.js";let o=class extends s{constructor(e){super(e),this.expanded=!0,this.items=[],this.layer=null}get layers(){const{layer:e}=this;return"group"===e.type||"knowledge-graph"===e.type?e.layers.toArray().reverse():"subtype-group"===e.type?e.sublayers.toArray().reverse():[]}get maxVisibleFeatureCountExceeded(){return this.items.some(e=>e.maxVisibleFeatureCountExceeded)}get total(){return this.items.reduce((e,t)=>e+t.total,0)}get visible(){return this.items.some(e=>e.visible)}get visibleTotal(){return this.items.reduce((e,t)=>e+t.visibleTotal,0)}reset(){this.items.forEach(e=>e.reset())}async sync({controller:e,promises:t}){const{layers:r,viewModel:s}=this;this.items=s.layersToItems({controller:e,groupLayerItem:this,layers:r,promises:t})}};e([t()],o.prototype,"expanded",void 0),e([t()],o.prototype,"items",void 0),e([t()],o.prototype,"layer",void 0),e([t()],o.prototype,"layers",null),e([t()],o.prototype,"maxVisibleFeatureCountExceeded",null),e([t()],o.prototype,"total",null),e([t()],o.prototype,"visible",null),e([t()],o.prototype,"visibleTotal",null),o=e([r("esri.widgets.support.SelectionList.GroupLayerItem")],o);const i=o;export{i as default};
@@ -7,7 +7,7 @@ import type { ItemBaseProperties } from "./ItemBase.js";
7
7
  import type { SyncOptions } from "./types.js";
8
8
 
9
9
  /** @internal */
10
- export interface LayerItemProperties extends ItemBaseProperties, Partial<Pick<LayerItem, "featureItems" | "groupLayerItem">> {
10
+ export interface LayerItemProperties extends ItemBaseProperties, Partial<Pick<LayerItem, "expanded" | "featureItems" | "groupLayerItem">> {
11
11
  /**
12
12
  * Companion layer view of the associated layer.
13
13
  *
@@ -40,6 +40,13 @@ export default class LayerItem extends ItemBase {
40
40
  * @internal
41
41
  */
42
42
  get effectiveSelection(): SelectionIdentifier[];
43
+ /**
44
+ * Indicates the item is expanded in the selection list.
45
+ *
46
+ * @default true
47
+ * @internal
48
+ */
49
+ accessor expanded: boolean;
43
50
  /**
44
51
  * Set of items representing individual selected features. This will only contain a maximum number of
45
52
  * features based on the value of 'maxVisibleFeatureCountExceeded'.
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{countIf as t,addMany as r,isSome as s}from"../../../core/arrayUtils.js";import i from"../../../core/ReactiveMap.js";import{property as o,subclass as a}from"../../../core/accessorSupport/decorators.js";import{getDisplayFieldNameFromFields as l}from"../../../layers/support/fieldUtils.js";import{isSelectableLayerWithObjectIds as n,isSelectableLayerViewWithObjectIds as c}from"../../../views/support/selectionUtils.js";import u from"./FeatureItem.js";import p from"./ItemBase.js";import{getSuggestedQueryOutFields as f}from"../Selector2D/selectorUtils.js";let m=class extends p{constructor(e){super(e),this._onChangeController=null,this.featureItems=[],this.featureTitleMap=new i,this.groupLayerItem=null,this.layer=null}get effectiveObjectIds(){return this.objectIds.slice(0,this.maxVisibleFeatureCountPerLayer)}get effectiveSelection(){return this.selection.slice(0,this.maxVisibleFeatureCountPerLayer)}get maxVisibleFeatureCountExceeded(){const{viewModel:e}=this;return this.selection.length>e.maxVisibleFeatureCountPerLayer&&this.visibleTotal===e.maxVisibleFeatureCountPerLayer}get maxVisibleFeatureCountPerLayer(){return this.viewModel.maxVisibleFeatureCountPerLayer}get objectIds(){const e=this.layer;return n(e)?this.selection:[]}get selection(){return this.viewModel.effectiveSelectionManager?.getSelection(this.layer)??[]}get total(){return this.selection.length}get visible(){return this.featureItems.some(e=>e.visible)}get visibleTotal(){return t(this.featureItems,e=>e.visible)}cancel(){this._onChangeController?.abort()}reset(){this.featureItems.forEach(e=>e.destroy()),this.featureItems=[]}async sync({controller:e,promises:t}){const{effectiveSelection:i,layer:o}=this;this.cancel();const a=new Map(this.featureItems.map(e=>[e.identifier,e])),l=new Map,c=[],u=[];for(const r of i){const e=a.get(r);e?l.set(r,e):(c.push(r),l.set(r,null))}if(this._onChangeController=e,c.length>0){n(o)?r(u,await this._createFeatureItemsFromIds(o,c,e)):r(u,this._createFeatureItemsFromGraphics(c));for(const e of u)null!=e.identifier&&l.set(e.identifier,e)}e.signal.aborted||(this.featureItems=Array.from(l.values()).filter(s),t.push(this.syncTitles(u)))}async syncTitles(e){const{layer:t}=this,r=(e??this.featureItems).map(e=>e.graphic);if("getFeatureTitles"in t&&t.getFeatureTitles){(await t.getFeatureTitles(r,{fetchMissingFields:!0,removeHTML:!0})).forEach((e,t)=>this.featureTitleMap.set(t,e))}else if(n(t)){const e=t.displayField||l(t.fields);e&&r.forEach(t=>{const r=t.getObjectId(),s=t.attributes[e];null!=r&&s&&this.featureTitleMap.set(r,s)})}}_createFeatureItemsFromGraphics(e){const{layer:t,viewModel:r}=this;return e.map(e=>new u({graphic:e,layer:t,layerItem:this,viewModel:r}))}async _createFeatureItemsFromIds(e,t,r){const{layerView:s,viewModel:i}=this,o=new Map;if(c(s)){const e=s.createQuery();e.objectIds=t,e.outFields=["*"],e.returnGeometry=!0;const i=await s.queryFeatures(e,r);for(const t of i.features){const e=t.getObjectId();null!=e&&o.set(e,t)}}if(r.signal.aborted)return[];const a=t.filter(e=>!o.has(e));if(a.length){const{view:t}=this,s=e.createQuery();s.objectIds=a,s.outSpatialReference=t?.spatialReference,s.outFields=t?f(e,t,!0):["*"],s.returnGeometry=!0;const i=await e.queryFeatures(s,r);for(const e of i.features){const t=e.getObjectId();null!=t&&o.set(t,e)}}return Array.from(o.values()).map(t=>new u({graphic:t,layer:e,layerItem:this,viewModel:i}))}};e([o()],m.prototype,"_onChangeController",void 0),e([o()],m.prototype,"effectiveObjectIds",null),e([o()],m.prototype,"effectiveSelection",null),e([o()],m.prototype,"featureItems",void 0),e([o()],m.prototype,"featureTitleMap",void 0),e([o()],m.prototype,"groupLayerItem",void 0),e([o()],m.prototype,"layer",void 0),e([o()],m.prototype,"maxVisibleFeatureCountExceeded",null),e([o()],m.prototype,"maxVisibleFeatureCountPerLayer",null),e([o()],m.prototype,"objectIds",null),e([o()],m.prototype,"selection",null),e([o()],m.prototype,"total",null),e([o()],m.prototype,"visible",null),e([o()],m.prototype,"visibleTotal",null),m=e([a("esri.widgets.support.SelectionList.LayerItem")],m);const h=m;export{h as default};
2
+ import{__decorate as e}from"tslib";import{countIf as t,addMany as r,isSome as s}from"../../../core/arrayUtils.js";import i from"../../../core/ReactiveMap.js";import{property as o,subclass as a}from"../../../core/accessorSupport/decorators.js";import{getDisplayFieldNameFromFields as l}from"../../../layers/support/fieldUtils.js";import{isSelectableLayerWithObjectIds as n,isSelectableLayerViewWithObjectIds as c}from"../../../views/support/selectionUtils.js";import u from"./FeatureItem.js";import p from"./ItemBase.js";import{getSuggestedQueryOutFields as f}from"../Selector2D/selectorUtils.js";let m=class extends p{constructor(e){super(e),this._onChangeController=null,this.expanded=!0,this.featureItems=[],this.featureTitleMap=new i,this.groupLayerItem=null,this.layer=null}get effectiveObjectIds(){return this.objectIds.slice(0,this.maxVisibleFeatureCountPerLayer)}get effectiveSelection(){return this.selection.slice(0,this.maxVisibleFeatureCountPerLayer)}get maxVisibleFeatureCountExceeded(){const{viewModel:e}=this;return this.selection.length>e.maxVisibleFeatureCountPerLayer&&this.visibleTotal===e.maxVisibleFeatureCountPerLayer}get maxVisibleFeatureCountPerLayer(){return this.viewModel.maxVisibleFeatureCountPerLayer}get objectIds(){const e=this.layer;return n(e)?this.selection:[]}get selection(){return this.viewModel.effectiveSelectionManager?.getSelection(this.layer)??[]}get total(){return this.selection.length}get visible(){return this.featureItems.some(e=>e.visible)}get visibleTotal(){return t(this.featureItems,e=>e.visible)}cancel(){this._onChangeController?.abort()}reset(){this.featureItems.forEach(e=>e.destroy()),this.featureItems=[]}async sync({controller:e,promises:t}){const{effectiveSelection:i,layer:o}=this;this.cancel();const a=new Map(this.featureItems.map(e=>[e.identifier,e])),l=new Map,c=[],u=[];for(const r of i){const e=a.get(r);e?l.set(r,e):(c.push(r),l.set(r,null))}if(this._onChangeController=e,c.length>0){n(o)?r(u,await this._createFeatureItemsFromIds(o,c,e)):r(u,this._createFeatureItemsFromGraphics(c));for(const e of u)null!=e.identifier&&l.set(e.identifier,e)}e.signal.aborted||(this.featureItems=Array.from(l.values()).filter(s),t.push(this.syncTitles(u)))}async syncTitles(e){const{layer:t}=this,r=(e??this.featureItems).map(e=>e.graphic);if("getFeatureTitles"in t&&t.getFeatureTitles){(await t.getFeatureTitles(r,{fetchMissingFields:!0,removeHTML:!0})).forEach((e,t)=>this.featureTitleMap.set(t,e))}else if(n(t)){const e=t.displayField||l(t.fields);e&&r.forEach(t=>{const r=t.getObjectId(),s=t.attributes[e];null!=r&&s&&this.featureTitleMap.set(r,s)})}}_createFeatureItemsFromGraphics(e){const{layer:t,viewModel:r}=this;return e.map(e=>new u({graphic:e,layer:t,layerItem:this,viewModel:r}))}async _createFeatureItemsFromIds(e,t,r){const{layerView:s,viewModel:i}=this,o=new Map;if(c(s)){const e=s.createQuery();e.objectIds=t,e.outFields=["*"],e.returnGeometry=!0;const i=await s.queryFeatures(e,r);for(const t of i.features){const e=t.getObjectId();null!=e&&o.set(e,t)}}if(r.signal.aborted)return[];const a=t.filter(e=>!o.has(e));if(a.length){const{view:t}=this,s=e.createQuery();s.objectIds=a,s.outSpatialReference=t?.spatialReference,s.outFields=t?f(e,t,!0):["*"],s.returnGeometry=!0;const i=await e.queryFeatures(s,r);for(const e of i.features){const t=e.getObjectId();null!=t&&o.set(t,e)}}return Array.from(o.values()).map(t=>new u({graphic:t,layer:e,layerItem:this,viewModel:i}))}};e([o()],m.prototype,"_onChangeController",void 0),e([o()],m.prototype,"effectiveObjectIds",null),e([o()],m.prototype,"effectiveSelection",null),e([o()],m.prototype,"expanded",void 0),e([o()],m.prototype,"featureItems",void 0),e([o()],m.prototype,"featureTitleMap",void 0),e([o()],m.prototype,"groupLayerItem",void 0),e([o()],m.prototype,"layer",void 0),e([o()],m.prototype,"maxVisibleFeatureCountExceeded",null),e([o()],m.prototype,"maxVisibleFeatureCountPerLayer",null),e([o()],m.prototype,"objectIds",null),e([o()],m.prototype,"selection",null),e([o()],m.prototype,"total",null),e([o()],m.prototype,"visible",null),e([o()],m.prototype,"visibleTotal",null),m=e([a("esri.widgets.support.SelectionList.LayerItem")],m);const h=m;export{h as default};
@@ -6,7 +6,7 @@ import type FeatureItem from "./FeatureItem.js";
6
6
  import type GroupLayerItem from "./GroupLayerItem.js";
7
7
  import type LayerItem from "./LayerItem.js";
8
8
  import type { SelectableLayer, SelectableLayerView, SelectableViewUnion, SelectionIdentifier } from "../../../views/selection/types.js";
9
- import type { ListItem, ParentItem, State } from "./types.js";
9
+ import type { ListItem, ParentItem, SelectionListParentLayer, State } from "./types.js";
10
10
 
11
11
  /** @internal */
12
12
  export interface SelectionListViewModelProperties extends Partial<Pick<SelectionListViewModel, "filterText" | "layer" | "maxVisibleFeatureCountPerLayer" | "selectionManager" | "view">> {}
@@ -152,6 +152,12 @@ export default class SelectionListViewModel extends Accessor {
152
152
  * @internal
153
153
  */
154
154
  clear(): void;
155
+ /**
156
+ * Utility method for collapsing all parent list items.
157
+ *
158
+ * @internal
159
+ */
160
+ collapseAll(): void;
155
161
  /**
156
162
  * Removes a specific feature from the overall selection.
157
163
  *
@@ -183,6 +189,28 @@ export default class SelectionListViewModel extends Accessor {
183
189
  deselectLayerItem(item: LayerItem): void;
184
190
  /** @internal */
185
191
  destroy(): void;
192
+ /**
193
+ * Utility method for expanding all parent list items.
194
+ *
195
+ * @internal
196
+ */
197
+ expandAll(): void;
198
+ /**
199
+ * Utility method for finding the layer item associated with a specific layer.
200
+ *
201
+ * @param layer - The layer to find the associated layer item for.
202
+ * @returns The layer item associated with the provided layer, or null if not found.
203
+ * @internal
204
+ */
205
+ findLayerItem(layer: SelectableLayer): LayerItem | null | undefined;
206
+ /**
207
+ * Utility method for finding the parent item associated with a specific layer.
208
+ *
209
+ * @param layer - The layer to find the associated parent item for.
210
+ * @returns The parent item associated with the provided layer, or null if not found.
211
+ * @internal
212
+ */
213
+ findParentItem(layer: SelectableLayer | SelectionListParentLayer): ParentItem | null | undefined;
186
214
  /**
187
215
  * Repositions the view to center based on the chosen item.
188
216
  *
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import r from"../../../core/Collection.js";import i from"../../../core/Logger.js";import{removeMaybe as o,abortMaybe as s}from"../../../core/maybe.js";import{ignoreAbortErrors as a,debounce as l,whenOrTimeout as n}from"../../../core/promiseUtils.js";import{watch as c,on as h,whenOnce as p}from"../../../core/reactiveUtils.js";import{property as y,subclass as g}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as d}from"../../../core/support/UpdatingHandles.js";import{isSubtypeGroupLayer as u,isSubtypeSublayer as m}from"../../../layers/support/layerUtils.js";import{isSelectableLayerViewWithHighlights as f,isSelectableLayerWithObjectIds as v,isSelectableLayerWithGraphics as _,isSelectableLayer as C,isSelectableLayerBaseWithEditing as I}from"../../../views/support/selectionUtils.js";import{goTo as b}from"../goToUtils.js";import L from"./GroupLayerItem.js";import S from"./LayerItem.js";import{computeEffectiveCount as w,getNestedLayerItems as M,isLayerItem as H,isGroupLayerItem as E,getNestedFeatureItems as A}from"./selectionListUtils.js";const F=100;let T=class extends t{constructor(e){super(e),this._allLayerItems=null,this._groupItemCache=new Map,this._hoverHighlightHandle=null,this._layerEditAbortControllers=new Map,this._layerEditHandles=new r,this._layerItemCache=new Map,this._onChangeAbortController=null,this._updatingHandles=new d,this.filterText=void 0,this.layer=null,this.maxVisibleFeatureCountPerLayer=500,this.selectionManager=null,this._onSelectionChangeController=async()=>{this._cancelOnSelectionChange();const e=new AbortController;this._onChangeAbortController=e,await this._updatingHandles.addPromise(a(this._generateListItems(e))),this._onChangeAbortController===e&&(this._onChangeAbortController=null);const t=this.layer&&this.effectiveSelectionManager?.getSelection(this.layer);t?.length||(this.layer=null)},this._cancelOnSelectionChange=()=>this._onChangeAbortController?.abort(),this._onSelectionChangeDebounced=l(this._onSelectionChangeController,F),this._cancelOnLayerEdit=e=>this._layerEditAbortControllers.get(e)?.abort()}initialize(){this.addHandles([c(()=>[this.view,this.effectiveSelectionManager,...this._sources],()=>{this._onSelectionChange(),this._refreshLayerEditHandles()}),h(()=>this.effectiveSelectionManager?.sources,"change",()=>{this._onSelectionChange(),this._refreshLayerEditHandles()}),h(()=>this.effectiveSelectionManager,"selection-change",()=>this._onSelectionChange())])}destroy(){this._cancelOnSelectionChange(),this.removeTemporaryHighlight(),this._updatingHandles.destroy(),this._layerEditHandles.drain(o),this._layerEditAbortControllers.forEach(s)}get _sources(){return this.effectiveSelectionManager?.sources.toArray()??[]}get activeLayerItem(){const{layer:e}=this;return e&&this.layerItems.find(t=>t.layer===e)}get allLayerItems(){return this._allLayerItems??[]}get effectiveCount(){return w(this.allLayerItems)}get effectiveSelectionManager(){return this.selectionManager??this.view?.selectionManager}get isUpdating(){return!(!this._onChangeAbortController&&!this._updatingHandles.updating)}get layerItems(){return M(this.allLayerItems)}get layerViewMap(){const e=new Map,{view:t}=this;if(!t)return e;for(const r of t.allLayerViews)if(e.set(r.layer.id,r),u(r.layer))for(const t of r.layer.sublayers)e.set(t.id,r);return e}get maxVisibleFeatureCountExceeded(){return this.allLayerItems.some(e=>e.maxVisibleFeatureCountExceeded)}get state(){const{view:e}=this;return e?e.ready?this.effectiveSelectionManager?"ready":"error":"loading":"disabled"}get viewLayersAndTables(){const{view:e}=this;return e?.map?[...e.map.layers.toArray().reverse(),...e.map.tables.toArray().reverse()]:[]}get visibleFeatureCount(){return this.activeLayerItem?.visibleTotal??this.visibleFeatureItems.length}get visibleFeatureItems(){return this.layerItems.flatMap(e=>e.featureItems.filter(e=>e.visible))}get visibleLayerCount(){const{effectiveSelectionManager:e}=this;return e&&0!==e.count?1===e.count||this.activeLayerItem?1:this.layerItems.filter(e=>e.visible).length:0}addTemporaryHighlight(e){const{graphic:t,layerView:r}=e;this.removeTemporaryHighlight(),r&&t&&f(r)&&(this._hoverHighlightHandle=r.highlight(t,{name:"temporary"}))}clear(){this.effectiveSelectionManager?.clear()}deselectFeatureItem(e){const{layer:t,graphic:r,objectId:i}=e;v(t)&&null!=i?this.effectiveSelectionManager?.remove(t,[i]):_(t)&&this.effectiveSelectionManager?.remove(t,[r])}deselectGroupItem(e){e.items.forEach(e=>{H(e)?this.deselectLayerItem(e):this.deselectGroupItem(e)})}deselectLayerItem(e){const{layer:t}=e;this.replace({layer:t,selection:[]})}deselectItem(e){E(e)?this.deselectGroupItem(e):H(e)?this.deselectLayerItem(e):this.deselectFeatureItem(e)}goToItem(e){H(e)||E(e)?this._goTo(A([e]).map(e=>e.graphic)):this._goTo(e.graphic)}layersToItems(e){const{controller:t,groupLayerItem:r,layers:i,promises:o}=e,{_groupItemCache:s,_layerItemCache:a,effectiveSelectionManager:l,viewLayersAndTables:n}=this,c=i??n;if(!l||0===l.count)return[];const h=[];for(const p of c)switch(p.type){case"subtype-group":case"knowledge-graph":case"group":{const e=s.get(p),r=e??new L({layer:p,viewModel:this});e||s.set(p,r),o.push(r.sync({controller:t,promises:o})),h.push(r)}break;default:if(C(p)){const e=l.getSelection(p);if(!e?.length)continue;const i=a.get(p),s=i??new S({groupLayerItem:r,layer:p,viewModel:this});i||a.set(p,s),o.push(s.sync({controller:t,promises:o})),h.push(s)}}return h}removeFromSelection(e){const{layer:t,selection:r}=e;(v(t)||_(t))&&this.effectiveSelectionManager?.remove(t,r)}removeTemporaryHighlight(){this._hoverHighlightHandle=o(this._hoverHighlightHandle)}selectSingleFeatureItem(e){const t=e.identifier;if(this.effectiveSelectionManager)for(const{layer:r}of this.effectiveSelectionManager.selections)this.replace({layer:r,selection:r===e.layer?[t]:[]})}selectSingleGroupItem(e){if(this.effectiveSelectionManager)for(const{layer:t,selection:r}of this.effectiveSelectionManager.selections)this.replace({layer:t,selection:t.parent===e.layer?r:[]})}selectSingleItem(e){E(e)?this.selectSingleGroupItem(e):H(e)?this.selectSingleLayerItem(e):this.selectSingleFeatureItem(e)}selectSingleLayerItem(e){if(this.effectiveSelectionManager)for(const{layer:t,selection:r}of this.effectiveSelectionManager.selections)this.replace({layer:t,selection:t===e.layer?r:[]})}replace(e){const{layer:t,selection:r}=e;(v(t)||_(t))&&this.effectiveSelectionManager?.replace(t,r)}async _goTo(e){const{view:t}=this;if(t)try{await b(t,e)}catch(r){"AbortError"!==r.name&&i.getLogger(this).warn("Failed to go to feature(s)",r)}}async _generateListItems(e){try{this.removeTemporaryHighlight();const t=[],r=this.layersToItems({controller:e,promises:t});t.length>0&&await Promise.all(t),this._onChangeAbortController===e&&(this._allLayerItems=r)}catch(t){i.getLogger(this).warn("Failed updating selection",t)}}_onSelectionChange(){a(this._onSelectionChangeDebounced())}_refreshLayerEditHandles(){const{effectiveSelectionManager:e}=this;if(this._layerEditHandles.drain(o),!e?.sources.length)return;const t=new Set(e.sources.map(e=>m(e)?e.parent:e));for(const r of t)C(r)&&(_(r)?this._layerEditHandles.push(r.graphics.on("change",()=>{this._onLayerEdit(r)})):I(r)&&this._layerEditHandles.push(r.on("edits",e=>{this._onLayerEdit(r,e)})))}async _onLayerEdit(e,t){try{if(this.removeTemporaryHighlight(),this._cancelOnLayerEdit(e),t&&!t.updatedFeatures.some(e=>null!=e.objectId&&!e.error))return;const r=new AbortController;this._layerEditAbortControllers.set(e,r);const i="subtype-group"===e.type||"knowledge-graph"===e.type?this.allLayerItems.find(t=>t.layer===e):this.layerItems.find(t=>t.layer===e);if(i?.layerView){const e=i.layerView;if(await this._onLayerViewUpdate(e),r.signal.aborted)return;i.reset(),this._onSelectionChange()}this._layerEditAbortControllers.get(e)===r&&this._layerEditAbortControllers.delete(e)}catch(r){i.getLogger(this).warn("Failed updating selected features",r)}}async _onLayerViewUpdate(e){await n(p(()=>e.updating),2e3),await p(()=>!e.updating)}};e([y()],T.prototype,"_allLayerItems",void 0),e([y()],T.prototype,"_groupItemCache",void 0),e([y()],T.prototype,"_hoverHighlightHandle",void 0),e([y()],T.prototype,"_layerEditAbortControllers",void 0),e([y()],T.prototype,"_layerEditHandles",void 0),e([y()],T.prototype,"_layerItemCache",void 0),e([y()],T.prototype,"_onChangeAbortController",void 0),e([y()],T.prototype,"_sources",null),e([y()],T.prototype,"_updatingHandles",void 0),e([y()],T.prototype,"activeLayerItem",null),e([y()],T.prototype,"allLayerItems",null),e([y()],T.prototype,"effectiveCount",null),e([y()],T.prototype,"effectiveSelectionManager",null),e([y()],T.prototype,"filterText",void 0),e([y()],T.prototype,"isUpdating",null),e([y()],T.prototype,"layer",void 0),e([y()],T.prototype,"layerItems",null),e([y()],T.prototype,"layerViewMap",null),e([y()],T.prototype,"maxVisibleFeatureCountExceeded",null),e([y()],T.prototype,"maxVisibleFeatureCountPerLayer",void 0),e([y()],T.prototype,"selectionManager",void 0),e([y()],T.prototype,"state",null),e([y()],T.prototype,"view",void 0),e([y()],T.prototype,"viewLayersAndTables",null),e([y()],T.prototype,"visibleFeatureCount",null),e([y()],T.prototype,"visibleFeatureItems",null),e([y()],T.prototype,"visibleLayerCount",null),T=e([g("esri.widgets.support.SelectionList.SelectionListViewModel")],T);const j=T;export{j as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import r from"../../../core/Collection.js";import i from"../../../core/Logger.js";import{removeMaybe as o,abortMaybe as a}from"../../../core/maybe.js";import{ignoreAbortErrors as s,debounce as n,whenOrTimeout as l}from"../../../core/promiseUtils.js";import{watch as c,on as h,sync as p,whenOnce as g}from"../../../core/reactiveUtils.js";import{property as y,subclass as d}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as m}from"../../../core/support/UpdatingHandles.js";import{isSubtypeGroupLayer as u,isGroupLayer as f,isSubtypeSublayer as v}from"../../../layers/support/layerUtils.js";import{isSelectableLayerViewWithHighlights as _,isSelectableLayerWithObjectIds as I,isSelectableLayerWithGraphics as C,isSelectableLayer as L,isSelectableLayerBaseWithEditing as S}from"../../../views/support/selectionUtils.js";import{goTo as b}from"../goToUtils.js";import w from"./GroupLayerItem.js";import M from"./LayerItem.js";import{computeEffectiveCount as H,getNestedLayerItems as E,isLayerItem as A,isGroupLayerItem as x,getNestedFeatureItems as F}from"./selectionListUtils.js";const T=100;let j=class extends t{constructor(e){super(e),this._allLayerItems=null,this._groupItemCache=new Map,this._hoverHighlightHandle=null,this._layerEditAbortControllers=new Map,this._layerEditHandles=new r,this._layerItemCache=new Map,this._onChangeAbortController=null,this._updatingHandles=new m,this.filterText=void 0,this.layer=null,this.maxVisibleFeatureCountPerLayer=500,this.selectionManager=null,this._onSelectionChangeController=async()=>{this._cancelOnSelectionChange();const e=new AbortController;this._onChangeAbortController=e,await this._updatingHandles.addPromise(s(this._generateListItems(e))),this._onChangeAbortController===e&&(this._onChangeAbortController=null);const t=this.layer&&this.effectiveSelectionManager?.getSelection(this.layer);t?.length||(this.layer=null)},this._cancelOnSelectionChange=()=>this._onChangeAbortController?.abort(),this._onSelectionChangeDebounced=n(this._onSelectionChangeController,T),this._cancelOnLayerEdit=e=>this._layerEditAbortControllers.get(e)?.abort()}initialize(){this.addHandles([c(()=>[this.view,this.effectiveSelectionManager,...this._sources],()=>{this._onSelectionChange(),this._refreshLayerEditHandles()}),h(()=>this.effectiveSelectionManager?.sources,"change",()=>{this._onSelectionChange(),this._refreshLayerEditHandles()}),h(()=>this.effectiveSelectionManager,"selection-change",e=>{this._onSelectionManagerSelectionChange(e),this._onSelectionChange()},p)])}destroy(){this._cancelOnSelectionChange(),this.removeTemporaryHighlight(),this._updatingHandles.destroy(),this._layerEditHandles.drain(o),this._layerEditAbortControllers.forEach(a)}get _sources(){return this.effectiveSelectionManager?.sources.toArray()??[]}get activeLayerItem(){const{layer:e}=this;return e&&this.findLayerItem(e)}get allLayerItems(){return this._allLayerItems??[]}get effectiveCount(){return H(this.allLayerItems)}get effectiveSelectionManager(){return this.selectionManager??this.view?.selectionManager}get isUpdating(){return!(!this._onChangeAbortController&&!this._updatingHandles.updating)}get layerItems(){return E(this.allLayerItems)}get layerViewMap(){const e=new Map,{view:t}=this;if(!t)return e;for(const r of t.allLayerViews)if(e.set(r.layer.id,r),u(r.layer))for(const t of r.layer.sublayers)e.set(t.id,r);return e}get maxVisibleFeatureCountExceeded(){return this.allLayerItems.some(e=>e.maxVisibleFeatureCountExceeded)}get state(){const{view:e}=this;return e?e.ready?this.effectiveSelectionManager?"ready":"error":"loading":"disabled"}get viewLayersAndTables(){const{view:e}=this;return e?.map?[...e.map.layers.toArray().reverse(),...e.map.tables.toArray().reverse()]:[]}get visibleFeatureCount(){return this.activeLayerItem?.visibleTotal??this.visibleFeatureItems.length}get visibleFeatureItems(){return this.layerItems.flatMap(e=>e.featureItems.filter(e=>e.visible))}get visibleLayerCount(){const{effectiveSelectionManager:e}=this;return e&&0!==e.count?1===e.count||this.activeLayerItem?1:this.layerItems.filter(e=>e.visible).length:0}addTemporaryHighlight(e){const{graphic:t,layerView:r}=e;this.removeTemporaryHighlight(),r&&t&&_(r)&&(this._hoverHighlightHandle=r.highlight(t,{name:"temporary"}))}collapseAll(){this._allLayerItems?.forEach(e=>e.expanded=!1)}clear(){this.effectiveSelectionManager?.clear()}deselectFeatureItem(e){const{layer:t,graphic:r,objectId:i}=e;I(t)&&null!=i?this.effectiveSelectionManager?.remove(t,[i]):C(t)&&this.effectiveSelectionManager?.remove(t,[r])}deselectGroupItem(e){e.items.forEach(e=>{A(e)?this.deselectLayerItem(e):this.deselectGroupItem(e)})}deselectLayerItem(e){const{layer:t}=e;this.replace({layer:t,selection:[]})}deselectItem(e){x(e)?this.deselectGroupItem(e):A(e)?this.deselectLayerItem(e):this.deselectFeatureItem(e)}expandAll(){this._allLayerItems?.forEach(e=>e.expanded=!0)}findLayerItem(e){return this.layerItems.find(t=>t.layer===e)}findParentItem(e){return this.allLayerItems.find(t=>t.layer===e)}goToItem(e){A(e)||x(e)?this._goTo(F([e]).map(e=>e.graphic)):this._goTo(e.graphic)}layersToItems(e){const{controller:t,groupLayerItem:r,layers:i,promises:o}=e,{_groupItemCache:a,_layerItemCache:s,effectiveSelectionManager:n,viewLayersAndTables:l}=this,c=i??l;if(!n||0===n.count)return[];const h=[];for(const p of c)switch(p.type){case"subtype-group":case"knowledge-graph":case"group":{const e=a.get(p),r=e??new w({layer:p,viewModel:this});e||a.set(p,r),o.push(r.sync({controller:t,promises:o})),h.push(r)}break;default:if(L(p)){const e=n.getSelection(p);if(!e?.length)continue;const i=s.get(p),a=i??new M({groupLayerItem:r,layer:p,viewModel:this});i||s.set(p,a),o.push(a.sync({controller:t,promises:o})),h.push(a)}}return h}removeFromSelection(e){const{layer:t,selection:r}=e;(I(t)||C(t))&&this.effectiveSelectionManager?.remove(t,r)}removeTemporaryHighlight(){this._hoverHighlightHandle=o(this._hoverHighlightHandle)}selectSingleFeatureItem(e){const t=e.identifier;if(this.effectiveSelectionManager)for(const{layer:r}of this.effectiveSelectionManager.selections)this.replace({layer:r,selection:r===e.layer?[t]:[]})}selectSingleGroupItem(e){if(this.effectiveSelectionManager)for(const{layer:t,selection:r}of this.effectiveSelectionManager.selections)this.replace({layer:t,selection:t.parent===e.layer?r:[]})}selectSingleItem(e){x(e)?this.selectSingleGroupItem(e):A(e)?this.selectSingleLayerItem(e):this.selectSingleFeatureItem(e)}selectSingleLayerItem(e){if(this.effectiveSelectionManager)for(const{layer:t,selection:r}of this.effectiveSelectionManager.selections)this.replace({layer:t,selection:t===e.layer?r:[]})}replace(e){const{layer:t,selection:r}=e;(I(t)||C(t))&&this.effectiveSelectionManager?.replace(t,r)}async _goTo(e){const{view:t}=this;if(t)try{await b(t,e)}catch(r){"AbortError"!==r.name&&i.getLogger(this).warn("Failed to go to feature(s)",r)}}_onSelectionManagerSelectionChange(e){const{changes:t}=e,r=this.effectiveSelectionManager;r&&t.forEach(({layer:e})=>{const t=r.getSelection(e);t&&0!==t.length||this._expandParentItems(e)})}_expandParentItems(e){const t=this._layerItemCache.get(e);if(t&&(t.expanded=!0),f(e.parent)){const t=this._groupItemCache.get(e.parent);t&&(t.expanded=!0)}}async _generateListItems(e){try{this.removeTemporaryHighlight();const t=[],r=this.layersToItems({controller:e,promises:t});t.length>0&&await Promise.all(t),this._onChangeAbortController===e&&(this._allLayerItems=r)}catch(t){i.getLogger(this).warn("Failed updating selection",t)}}_onSelectionChange(){s(this._onSelectionChangeDebounced())}_refreshLayerEditHandles(){const{effectiveSelectionManager:e}=this;if(this._layerEditHandles.drain(o),!e?.sources.length)return;const t=new Set(e.sources.map(e=>v(e)?e.parent:e));for(const r of t)L(r)&&(C(r)?this._layerEditHandles.push(r.graphics.on("change",()=>{this._onLayerEdit(r)})):S(r)&&this._layerEditHandles.push(r.on("edits",e=>{this._onLayerEdit(r,e)})))}async _onLayerEdit(e,t){try{if(this.removeTemporaryHighlight(),this._cancelOnLayerEdit(e),t&&!t.updatedFeatures.some(e=>null!=e.objectId&&!e.error))return;const r=new AbortController;this._layerEditAbortControllers.set(e,r);const i="subtype-group"===e.type||"knowledge-graph"===e.type?this.findParentItem(e):this.findLayerItem(e);if(i?.layerView){const e=i.layerView;if(await this._onLayerViewUpdate(e),r.signal.aborted)return;i.reset(),this._onSelectionChange()}this._layerEditAbortControllers.get(e)===r&&this._layerEditAbortControllers.delete(e)}catch(r){i.getLogger(this).warn("Failed updating selected features",r)}}async _onLayerViewUpdate(e){await l(g(()=>e.updating),2e3),await g(()=>!e.updating)}};e([y()],j.prototype,"_allLayerItems",void 0),e([y()],j.prototype,"_groupItemCache",void 0),e([y()],j.prototype,"_hoverHighlightHandle",void 0),e([y()],j.prototype,"_layerEditAbortControllers",void 0),e([y()],j.prototype,"_layerEditHandles",void 0),e([y()],j.prototype,"_layerItemCache",void 0),e([y()],j.prototype,"_onChangeAbortController",void 0),e([y()],j.prototype,"_sources",null),e([y()],j.prototype,"_updatingHandles",void 0),e([y()],j.prototype,"activeLayerItem",null),e([y()],j.prototype,"allLayerItems",null),e([y()],j.prototype,"effectiveCount",null),e([y()],j.prototype,"effectiveSelectionManager",null),e([y()],j.prototype,"filterText",void 0),e([y()],j.prototype,"isUpdating",null),e([y()],j.prototype,"layer",void 0),e([y()],j.prototype,"layerItems",null),e([y()],j.prototype,"layerViewMap",null),e([y()],j.prototype,"maxVisibleFeatureCountExceeded",null),e([y()],j.prototype,"maxVisibleFeatureCountPerLayer",void 0),e([y()],j.prototype,"selectionManager",void 0),e([y()],j.prototype,"state",null),e([y()],j.prototype,"view",void 0),e([y()],j.prototype,"viewLayersAndTables",null),e([y()],j.prototype,"visibleFeatureCount",null),e([y()],j.prototype,"visibleFeatureItems",null),e([y()],j.prototype,"visibleLayerCount",null),j=e([d("esri.widgets.support.SelectionList.SelectionListViewModel")],j);const V=j;export{V as default};