@arcgis/core 5.0.0-next.43 → 5.0.0-next.44

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 (305) hide show
  1. package/applications/Components/imageryUtils.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{f97a7cb367634353177d.js → 001a7a4cf6fe74432ed6.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{324d66962aeec17d3e28.js → 1e0e7cef7ef947894bbe.js} +1 -1
  5. package/assets/esri/core/workers/chunks/20ad34f9d45c64392022.js +1 -0
  6. package/assets/esri/core/workers/chunks/23396a6318edf9264c1f.js +1 -0
  7. package/assets/esri/core/workers/chunks/{ad891ac388fa6c1c9b94.js → 2b34a010f76e5f289868.js} +1 -1
  8. package/assets/esri/core/workers/chunks/2ef4c0092c59a98a5532.js +1 -0
  9. package/assets/esri/core/workers/chunks/35272810c2ed04eb403d.js +1 -0
  10. package/assets/esri/core/workers/chunks/{d1f4152b2b8d47cbf586.js → 72fbee59d5d909615408.js} +1 -1
  11. package/assets/esri/core/workers/chunks/75c66e38bdc1c786c599.js +1 -0
  12. package/assets/esri/core/workers/chunks/7d3c2a063598bdd015e2.js +1 -0
  13. package/assets/esri/core/workers/chunks/897ce6fc9cefb1e14a64.js +1 -0
  14. package/assets/esri/core/workers/chunks/992e9bbdf9d3787ddb0e.js +1 -0
  15. package/assets/esri/core/workers/chunks/a2442549c5daf3653eb4.js +1 -0
  16. package/assets/esri/core/workers/chunks/a7cd795042ebb8585906.js +1 -0
  17. package/assets/esri/core/workers/chunks/{385cfd3087f00dbd1146.js → ca1c65eb7f5900c60170.js} +1 -1
  18. package/assets/esri/core/workers/chunks/cddce67919e13e2f365e.js +1 -0
  19. package/assets/esri/core/workers/chunks/e6784251bbb8b71ead93.js +1 -0
  20. package/assets/esri/core/workers/chunks/{96f798ee286b59396131.js → ea3cba01c60d9bc72719.js} +1 -1
  21. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  22. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  23. package/config.js +1 -1
  24. package/interfaces.d.ts +78 -2
  25. package/kernel.js +1 -1
  26. package/layers/ImageryTileLayer.js +1 -1
  27. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  28. package/layers/WCSLayer.js +1 -1
  29. package/layers/mixins/ArcGISImageService.js +1 -1
  30. package/layers/mixins/ImageryTileMixin.js +1 -1
  31. package/layers/mixins/RasterJobHandlerMixin.js +1 -1
  32. package/layers/ogc/wcsUtils.js +1 -1
  33. package/layers/raster/datasets/BaseRaster.js +5 -0
  34. package/layers/raster/datasets/CovJSONRaster.js +5 -0
  35. package/layers/raster/datasets/FunctionRaster.js +5 -0
  36. package/layers/raster/datasets/ImageAuxRaster.js +5 -0
  37. package/layers/raster/datasets/ImageServerRaster.js +5 -0
  38. package/layers/raster/datasets/InMemoryRaster.js +5 -0
  39. package/layers/raster/datasets/MRFRaster.js +5 -0
  40. package/layers/raster/datasets/RawBlockCache.js +5 -0
  41. package/layers/raster/datasets/TIFFRaster.js +5 -0
  42. package/layers/raster/datasets/WCSRaster.js +5 -0
  43. package/layers/raster/datasets/covJSONParser.js +5 -0
  44. package/layers/raster/datasets/multidimensionalUtils.js +5 -0
  45. package/layers/raster/datasets/pamParser.js +5 -0
  46. package/layers/raster/datasets/pixelReader.js +5 -0
  47. package/layers/raster/datasets/wcsCoverageParser.js +5 -0
  48. package/layers/raster/formats/Lerc.js +5 -0
  49. package/layers/raster/formats/Qb3.js +5 -0
  50. package/layers/raster/formats/RasterCodec.js +5 -0
  51. package/layers/raster/formats/TiffDecoder.js +5 -0
  52. package/layers/raster/functions/ArithmeticFunction.js +5 -0
  53. package/layers/{support/rasterFunctions → raster/functions}/ArithmeticFunctionArguments.js +1 -1
  54. package/layers/{support/rasterFunctions → raster/functions}/AspectFunction.js +1 -1
  55. package/layers/{support/rasterFunctions → raster/functions}/AspectFunctionArguments.js +1 -1
  56. package/layers/raster/functions/BandArithmeticFunction.js +5 -0
  57. package/layers/{support/rasterFunctions → raster/functions}/BandArithmeticFunctionArguments.js +1 -1
  58. package/layers/{support/rasterFunctions → raster/functions}/BaseFunctionArguments.js +1 -1
  59. package/layers/raster/functions/BaseRasterFunction.js +5 -0
  60. package/layers/{support/rasterFunctions → raster/functions}/ClipFunction.js +1 -1
  61. package/layers/{support/rasterFunctions → raster/functions}/ClipFunctionArguments.js +1 -1
  62. package/layers/raster/functions/ColormapFunction.js +5 -0
  63. package/layers/{support/rasterFunctions → raster/functions}/ColormapFunctionArguments.js +1 -1
  64. package/layers/raster/functions/ColormapToRGBFunction.js +5 -0
  65. package/layers/{support/rasterFunctions → raster/functions}/ColormapToRGBFunctionArguments.js +1 -1
  66. package/layers/raster/functions/CompositeBandFunction.js +5 -0
  67. package/layers/raster/functions/CompositeBandFunctionArguments.js +5 -0
  68. package/layers/raster/functions/ComputeChangeFunction.js +5 -0
  69. package/layers/{support/rasterFunctions → raster/functions}/ComputeChangeFunctionArguments.js +1 -1
  70. package/layers/{support/rasterFunctions → raster/functions}/ContrastBrightnessFunction.js +1 -1
  71. package/layers/{support/rasterFunctions → raster/functions}/ContrastBrightnessFunctionArguments.js +1 -1
  72. package/layers/raster/functions/ConvolutionFunction.js +5 -0
  73. package/layers/raster/functions/ConvolutionFunctionArguments.js +5 -0
  74. package/layers/{support/rasterFunctions → raster/functions}/CurvatureFunction.js +1 -1
  75. package/layers/{support/rasterFunctions → raster/functions}/CurvatureFunctionArguments.js +1 -1
  76. package/layers/{support/rasterFunctions → raster/functions}/ExtractBandFunction.js +1 -1
  77. package/layers/{support/rasterFunctions → raster/functions}/ExtractBandFunctionArguments.js +1 -1
  78. package/layers/{support/rasterFunctions → raster/functions}/GrayscaleFunction.js +1 -1
  79. package/layers/{support/rasterFunctions → raster/functions}/GrayscaleFunctionArguments.js +1 -1
  80. package/layers/raster/functions/HillshadeFunction.js +5 -0
  81. package/layers/{support/rasterFunctions → raster/functions}/HillshadeFunctionArguments.js +1 -1
  82. package/layers/raster/functions/LocalFunction.js +5 -0
  83. package/layers/{support/rasterFunctions → raster/functions}/LocalFunctionArguments.js +1 -1
  84. package/layers/{support/rasterFunctions → raster/functions}/MaskFunction.js +1 -1
  85. package/layers/{support/rasterFunctions → raster/functions}/MaskFunctionArguments.js +1 -1
  86. package/layers/{support/rasterFunctions → raster/functions}/NDVIFunction.js +1 -1
  87. package/layers/{support/rasterFunctions → raster/functions}/NDVIFunctionArguments.js +1 -1
  88. package/layers/raster/functions/RemapFunction.js +5 -0
  89. package/layers/{support/rasterFunctions → raster/functions}/RemapFunctionArguments.js +1 -1
  90. package/layers/raster/functions/ShadedReliefFunction.js +5 -0
  91. package/layers/{support/rasterFunctions → raster/functions}/ShadedReliefFunctionArguments.js +1 -1
  92. package/layers/raster/functions/SlopeFunction.js +5 -0
  93. package/layers/{support/rasterFunctions → raster/functions}/SlopeFunctionArguments.js +1 -1
  94. package/layers/raster/functions/StatisticsFunction.js +5 -0
  95. package/layers/{support/rasterFunctions → raster/functions}/StatisticsFunctionArguments.js +1 -1
  96. package/layers/{support/rasterFunctions → raster/functions}/StatisticsHistogramFunction.js +1 -1
  97. package/layers/{support/rasterFunctions → raster/functions}/StatisticsHistogramFunctionArguments.js +1 -1
  98. package/layers/raster/functions/StretchFunction.js +5 -0
  99. package/layers/{support/rasterFunctions → raster/functions}/StretchFunctionArguments.js +1 -1
  100. package/layers/{support/rasterFunctions → raster/functions}/TableFunction.js +1 -1
  101. package/layers/{support/rasterFunctions → raster/functions}/TableFunctionArguments.js +1 -1
  102. package/layers/raster/functions/bandIndexUtils.js +5 -0
  103. package/layers/raster/functions/changeDetectionUtils.js +5 -0
  104. package/layers/raster/functions/clipUtils.js +5 -0
  105. package/layers/raster/functions/conversionUtils.js +5 -0
  106. package/layers/raster/functions/convolutionUtils.js +5 -0
  107. package/layers/raster/functions/creators/createDataManagementFunctions.js +5 -0
  108. package/layers/raster/functions/creators/utils.js +5 -0
  109. package/layers/raster/functions/focalStatUtils.js +5 -0
  110. package/layers/raster/functions/localUtils.js +5 -0
  111. package/layers/raster/functions/pixelTransformUtils.js +5 -0
  112. package/layers/raster/functions/pixelUtils.js +5 -0
  113. package/layers/raster/functions/stretchUtils.js +5 -0
  114. package/layers/raster/functions/surfaceUtils.js +5 -0
  115. package/layers/raster/functions/vectorFieldUtils.js +5 -0
  116. package/layers/raster/transforms/BaseRasterTransform.js +5 -0
  117. package/layers/{support/rasterTransforms → raster/transforms}/GCSShiftTransform.js +1 -1
  118. package/layers/{support/rasterTransforms → raster/transforms}/IdentityTransform.js +1 -1
  119. package/layers/{support/rasterTransforms → raster/transforms}/PolynomialTransform.js +1 -1
  120. package/layers/save/imageryUtils.js +1 -1
  121. package/layers/support/PixelBlock.js +1 -1
  122. package/layers/support/RasterWorker.js +1 -1
  123. package/layers/support/imageryRendererUtils.js +1 -1
  124. package/layers/support/rasterFunctionUtils.js +1 -1
  125. package/package.json +1 -1
  126. package/renderers/VectorFieldRenderer.js +1 -1
  127. package/renderers/support/RasterSymbolizer.js +1 -1
  128. package/renderers/support/rasterRendererHelper.js +1 -1
  129. package/rest/locator/addressToLocations.js +1 -1
  130. package/rest/locator/addressesToLocations.js +1 -1
  131. package/rest/locator/suggestLocations.js +1 -1
  132. package/rest/networks/support/Association.js +1 -1
  133. package/smartMapping/raster/support/adapters/ImageryLayerAdapter.js +1 -1
  134. package/smartMapping/raster/support/adapters/ImageryTileLayerAdapter.js +1 -1
  135. package/support/revision.js +1 -1
  136. package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
  137. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterRangeHighlightShader.js +1 -1
  138. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/MaskShader.js +1 -1
  139. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/RemapShader.js +1 -1
  140. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/math.js +1 -1
  141. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  142. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  143. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  144. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  145. package/views/2d/layers/imagery/ImageryView2D.js +1 -1
  146. package/views/2d/layers/imagery/VectorFieldTileView2D.js +1 -1
  147. package/views/2d/layers/imagery/VectorFieldView2D.js +1 -1
  148. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  149. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  150. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  151. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  152. package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
  153. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayout.js +1 -1
  154. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBufferView.js +1 -1
  155. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  156. package/views/3d/webgl-engine/materials/DrawParameters.js +1 -1
  157. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  158. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  159. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  160. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  161. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  162. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  163. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  164. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  165. package/views/3d/webgl-engine/materials/renderers/Instance.js +1 -1
  166. package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +1 -1
  167. package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
  168. package/views/3d/webgl-engine/materials/renderers/PerOriginData.js +1 -1
  169. package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
  170. package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
  171. package/views/DOMContainer.js +1 -1
  172. package/views/GroundView.js +1 -1
  173. package/views/layers/ImageryLayerViewMixin.js +1 -1
  174. package/views/layers/ImageryTileLayerViewMixin.js +1 -1
  175. package/views/support/imageReprojection.js +1 -1
  176. package/widgets/BatchAttributeForm.js +1 -1
  177. package/widgets/BuildingExplorer/BuildingExplorerViewModel.js +1 -1
  178. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  179. package/widgets/CoordinateConversion.js +1 -1
  180. package/widgets/DirectLineMeasurement3D.js +1 -1
  181. package/widgets/DistanceMeasurement2D.js +1 -1
  182. package/widgets/Editor/EditorViewModel.js +1 -1
  183. package/widgets/Editor.js +1 -1
  184. package/widgets/ElevationProfile.js +1 -1
  185. package/widgets/Feature.js +1 -1
  186. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  187. package/widgets/FeatureForm.js +1 -1
  188. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  189. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  190. package/widgets/FeatureTable/support/GroupColumnTemplate.js +1 -1
  191. package/widgets/FeatureTable/support/TableTemplate.js +1 -1
  192. package/widgets/FeatureTable.js +1 -1
  193. package/widgets/FeatureTemplates.js +1 -1
  194. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  195. package/widgets/Legend.js +1 -1
  196. package/widgets/LineOfSight.js +1 -1
  197. package/widgets/Locate.js +1 -1
  198. package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
  199. package/widgets/OrientedImageryViewer/services/DepthImageService.js +1 -1
  200. package/widgets/PanoramicViewer/support/importUtils.js +1 -1
  201. package/widgets/Print.js +1 -1
  202. package/widgets/ScaleBar.js +1 -1
  203. package/widgets/ScaleRangeSlider.js +1 -1
  204. package/widgets/Search/SearchResultRenderer.js +1 -1
  205. package/widgets/Search/SearchViewModel.js +1 -1
  206. package/widgets/Search/types.js +1 -1
  207. package/widgets/Search.js +1 -1
  208. package/widgets/ShadowCast.js +1 -1
  209. package/widgets/Sketch/SketchViewModel.js +1 -1
  210. package/widgets/Sketch.js +1 -1
  211. package/assets/esri/core/workers/chunks/1f6ead46b723630db897.js +0 -1
  212. package/assets/esri/core/workers/chunks/3a16347e17312556e02c.js +0 -1
  213. package/assets/esri/core/workers/chunks/478def691ae6763686f3.js +0 -1
  214. package/assets/esri/core/workers/chunks/4c4a55be41ba105c091c.js +0 -1
  215. package/assets/esri/core/workers/chunks/4cbf5a97b2b3c6553f6f.js +0 -1
  216. package/assets/esri/core/workers/chunks/646f58b69d2354f1ef27.js +0 -1
  217. package/assets/esri/core/workers/chunks/93d11075f65a5b6625ea.js +0 -1
  218. package/assets/esri/core/workers/chunks/9f2a8445a5848502c7e7.js +0 -1
  219. package/assets/esri/core/workers/chunks/a1b08aab73747f4e7e25.js +0 -1
  220. package/assets/esri/core/workers/chunks/ba59568e748f0ba53b78.js +0 -1
  221. package/assets/esri/core/workers/chunks/f21cb5b34d4d1e3af1a9.js +0 -1
  222. package/assets/esri/core/workers/chunks/f93f0586ce10cb5d98b3.js +0 -1
  223. package/layers/support/rasterDatasets/BaseRaster.js +0 -5
  224. package/layers/support/rasterDatasets/CovJSONRaster.js +0 -5
  225. package/layers/support/rasterDatasets/FunctionRaster.js +0 -5
  226. package/layers/support/rasterDatasets/ImageAuxRaster.js +0 -5
  227. package/layers/support/rasterDatasets/ImageServerRaster.js +0 -5
  228. package/layers/support/rasterDatasets/InMemoryRaster.js +0 -5
  229. package/layers/support/rasterDatasets/MRFRaster.js +0 -5
  230. package/layers/support/rasterDatasets/RawBlockCache.js +0 -5
  231. package/layers/support/rasterDatasets/TIFFRaster.js +0 -5
  232. package/layers/support/rasterDatasets/WCSRaster.js +0 -5
  233. package/layers/support/rasterDatasets/covJSONParser.js +0 -5
  234. package/layers/support/rasterDatasets/multidimensionalUtils.js +0 -5
  235. package/layers/support/rasterDatasets/pamParser.js +0 -5
  236. package/layers/support/rasterDatasets/pixelReader.js +0 -5
  237. package/layers/support/rasterDatasets/wcsCoverageParser.js +0 -5
  238. package/layers/support/rasterFormats/Lerc.js +0 -5
  239. package/layers/support/rasterFormats/Qb3.js +0 -5
  240. package/layers/support/rasterFormats/RasterCodec.js +0 -5
  241. package/layers/support/rasterFormats/TiffDecoder.js +0 -5
  242. package/layers/support/rasterFunctions/ArithmeticFunction.js +0 -5
  243. package/layers/support/rasterFunctions/BandArithmeticFunction.js +0 -5
  244. package/layers/support/rasterFunctions/BaseRasterFunction.js +0 -5
  245. package/layers/support/rasterFunctions/ColormapFunction.js +0 -5
  246. package/layers/support/rasterFunctions/ColormapToRGBFunction.js +0 -5
  247. package/layers/support/rasterFunctions/CompositeBandFunction.js +0 -5
  248. package/layers/support/rasterFunctions/CompositeBandFunctionArguments.js +0 -5
  249. package/layers/support/rasterFunctions/ComputeChangeFunction.js +0 -5
  250. package/layers/support/rasterFunctions/ConvolutionFunction.js +0 -5
  251. package/layers/support/rasterFunctions/ConvolutionFunctionArguments.js +0 -5
  252. package/layers/support/rasterFunctions/HillshadeFunction.js +0 -5
  253. package/layers/support/rasterFunctions/LocalFunction.js +0 -5
  254. package/layers/support/rasterFunctions/RemapFunction.js +0 -5
  255. package/layers/support/rasterFunctions/ShadedReliefFunction.js +0 -5
  256. package/layers/support/rasterFunctions/SlopeFunction.js +0 -5
  257. package/layers/support/rasterFunctions/StatisticsFunction.js +0 -5
  258. package/layers/support/rasterFunctions/StretchFunction.js +0 -5
  259. package/layers/support/rasterFunctions/bandIndexUtils.js +0 -5
  260. package/layers/support/rasterFunctions/changeDetectionUtils.js +0 -5
  261. package/layers/support/rasterFunctions/clipUtils.js +0 -5
  262. package/layers/support/rasterFunctions/conversionUtils.js +0 -5
  263. package/layers/support/rasterFunctions/convolutionUtils.js +0 -5
  264. package/layers/support/rasterFunctions/creators/createDataManagementFunctions.js +0 -5
  265. package/layers/support/rasterFunctions/creators/utils.js +0 -5
  266. package/layers/support/rasterFunctions/focalStatUtils.js +0 -5
  267. package/layers/support/rasterFunctions/localUtils.js +0 -5
  268. package/layers/support/rasterFunctions/pixelTransformUtils.js +0 -5
  269. package/layers/support/rasterFunctions/pixelUtils.js +0 -5
  270. package/layers/support/rasterFunctions/stretchUtils.js +0 -5
  271. package/layers/support/rasterFunctions/surfaceUtils.js +0 -5
  272. package/layers/support/rasterFunctions/vectorFieldUtils.js +0 -5
  273. package/layers/support/rasterTransforms/BaseRasterTransform.js +0 -5
  274. /package/assets/esri/layers/{support/rasterFormats → raster/formats}/lerc-wasm.wasm +0 -0
  275. /package/assets/esri/layers/{support/rasterFormats → raster/formats}/qb3-wasm.wasm +0 -0
  276. /package/layers/{support/rasterDatasets → raster/datasets}/DBFParser.js +0 -0
  277. /package/layers/{support/rasterDatasets → raster/datasets}/EphemeralBlockCache.js +0 -0
  278. /package/layers/{support/rasterDatasets → raster/datasets}/RasterFactory.js +0 -0
  279. /package/layers/{support/rasterDatasets → raster/datasets}/byteStreamUtils.js +0 -0
  280. /package/layers/{support/rasterDatasets → raster/datasets}/datasetUtils.js +0 -0
  281. /package/layers/{support/rasterDatasets → raster/datasets}/multipartParser.js +0 -0
  282. /package/layers/{support/rasterDatasets → raster/datasets}/wcsCapabilitiesParser.js +0 -0
  283. /package/layers/{support/rasterDatasets → raster/datasets}/xmlUtilities.js +0 -0
  284. /package/layers/{support/rasterFormats → raster/formats}/ImageCanvasDecoder.js +0 -0
  285. /package/layers/{support/rasterFormats → raster/formats}/JpgPlus.js +0 -0
  286. /package/layers/{support/rasterFormats → raster/formats}/Lzw.js +0 -0
  287. /package/layers/{support/rasterFormats → raster/formats}/Raw.js +0 -0
  288. /package/layers/{support/rasterFormats → raster/formats}/pixelRangeUtils.js +0 -0
  289. /package/layers/{support/rasterFormats → raster/formats}/tiffTag.js +0 -0
  290. /package/layers/{support/rasterFormats → raster/formats}/utils.js +0 -0
  291. /package/layers/{support/rasterFunctions → raster/functions}/colormaps.js +0 -0
  292. /package/layers/{support/rasterFunctions → raster/functions}/creators/createAppearenceFunctions.js +0 -0
  293. /package/layers/{support/rasterFunctions → raster/functions}/creators/createBandIndexFunctions.js +0 -0
  294. /package/layers/{support/rasterFunctions → raster/functions}/creators/createChangeFunctions.js +0 -0
  295. /package/layers/{support/rasterFunctions → raster/functions}/creators/createConversionFunctions.js +0 -0
  296. /package/layers/{support/rasterFunctions → raster/functions}/creators/createLocalFunctions.js +0 -0
  297. /package/layers/{support/rasterFunctions → raster/functions}/creators/createMultiRasterAnalysisFunctions.js +0 -0
  298. /package/layers/{support/rasterFunctions → raster/functions}/creators/createStatisticsFunctions.js +0 -0
  299. /package/layers/{support/rasterFunctions → raster/functions}/creators/createSurfaceFunctions.js +0 -0
  300. /package/layers/{support/rasterFunctions → raster/functions}/customBandIndexUtils.js +0 -0
  301. /package/layers/{support/rasterFunctions → raster/functions}/mirror.js +0 -0
  302. /package/layers/{support/rasterFunctions → raster/functions}/rasterFunctionHelper.js +0 -0
  303. /package/layers/{support/rasterFunctions → raster/functions}/rasterFunctionSchema.js +0 -0
  304. /package/layers/{support/rasterFunctions → raster/functions}/rasterProjectionHelper.js +0 -0
  305. /package/layers/{support/rasterTransforms → raster/transforms}/utils.js +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{isSome as t}from"../../core/arrayUtils.js";import o from"../../core/Collection.js";import a from"../../core/Error.js";import{EventedAccessor as i}from"../../core/Evented.js";import{drainHandles as r}from"../../core/handleUtils.js";import"../../core/has.js";import s from"../../core/Logger.js";import{destroyMaybe as n,abortMaybe as p}from"../../core/maybe.js";import{createAbortError as l,whenOrAbort as h,ignoreAbortErrors as c}from"../../core/promiseUtils.js";import{watch as d,syncAndInitial as u,on as m,when as y,whenOnce as g}from"../../core/reactiveUtils.js";import{property as v,subclass as f}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as _}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as b}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as w,isLoaded as G,load as O,project as T}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as S}from"../../geometry/support/coordsUtils.js";import{equals as E}from"../../geometry/support/spatialReferenceUtils.js";import A from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as M}from"../../layers/support/layerUtils.js";import C from"../../symbols/FillSymbol3DLayer.js";import k from"../../symbols/MeshSymbol3D.js";import H from"../../symbols/SimpleFillSymbol.js";import j from"../../symbols/SimpleLineSymbol.js";import U from"../../symbols/SimpleMarkerSymbol.js";import D from"../../symbols/TextSymbol.js";import{symbolTypes as I}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as R}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as x}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as P}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as L}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as F}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as V}from"../../views/input/InputManager.js";import{sketchKeys as K}from"../../views/interactive/keybindings.js";import W from"../../views/interactive/sketch/SketchLabelOptions.js";import Z from"../../views/interactive/sketch/SketchOptions.js";import q from"../../views/interactive/sketch/SketchTooltipOptions.js";import N from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as z}from"../../views/interactive/snapping/SnappingManager.js";import B from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as $}from"../../views/interactive/snapping/snappingUtils.js";import{loadAutomaticAreaMeasurementUtils as Y}from"../../views/support/automaticAreaMeasurementUtils.js";import{loadAutomaticLengthMeasurementUtils as J}from"../../views/support/automaticLengthMeasurementUtils.js";import{defaultHighlightName as Q}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as X}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as ee}from"../../views/support/screenUtils.js";import te from"./adapters/layer/GraphicsLayerAdapter.js";import oe from"./adapters/layer/MapNotesLayerAdapter.js";import{CreateOperationHandle as ae,UpdateOperationHandle as ie}from"./support/OperationHandle.js";import{getModeFromCreateOptions as re,getDrawToolGeometryTypeFromCreateTool as se,graphicsHaveTooFewVerticesForBox as ne}from"./support/sketchUtils.js";const pe={defaultZ:0},le={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:Q},tool:"transform"},he=Symbol(),ce=Symbol();let de=class extends i{constructor(e){super(e),this._defaultSnappingManager=null,this._internalGraphicsLayer=new A({listMode:"hide",internal:!0,title:"SVM Internal"}),this._operationHandle=null,this._updatingHandles=new _,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.layer=null,this.pointSymbol=new U({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new H({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new j({color:[130,130,130,1],width:2}),this.meshSymbol=new k({symbolLayers:new o([new C])}),this.textSymbol=new D({text:"text"}),this.updateGraphics=new o,this.updateOnGraphicClick=!0,this.creationMode="single",this.vertexSymbol=new U({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new Z,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{const{_layerAdapter:e}=this;if(this.removeHandles(ce),!e)return;const o=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),d(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},u)].filter(t);this.addHandles(o,ce)},this._originalPopupEnabled=null,this.defaultCreateOptions=pe,this.defaultUpdateOptions=le,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new B}initialize(){this.addHandles([m(()=>this.view?.map?.layers,"change",e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),d(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),u),d(()=>this.view,e=>{this._defaultSnappingManager=n(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new z({view:e,options:this.snappingOptions})),"2d"===e.type?import("../../views/2d/interactive/editingTools.js"):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))},u),d(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),$(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=n(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this.emit("destroy")}get _layerAdapter(){const{layer:e}=this;switch(e?.type){case"graphics":return new te(e);case"map-notes":return new oe(e);default:return null}}get activeTool(){return this._operationHandle?.tool??null}get activeCreateToolDrawMode(){return"create"===this._operationHandle?.type&&this._operationHandle.activeComponent&&"mode"in this._operationHandle.activeComponent?this._operationHandle.activeComponent.mode: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",{...pe,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...le,...e,reshapeOptions:{...le.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...le.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=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=n(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new z({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 tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return!(!this._updatingHandles.updating&&!this.snappingManager?.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(y(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},u),o),this._set("view",e)}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=p(this._moduleLoaderAbortController),this._viewReadyAbortController=p(this._viewReadyAbortController),this._sketchContinuationFlag=!0,this._operationHandle&&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){this.cancel(),await this._waitViewReady();const{view:o,layer:a}=this;if(!o||"disabled"===this.state)throw a||this._logMissingLayer(),l();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");F(o,this._internalGraphicsLayer);const i=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t));if(null==i||this.destroyed)return void o.map?.remove(this._internalGraphicsLayer);const r=()=>{if(i===this._operationHandle){const o=this.createGraphic,a=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map?.remove(this._internalGraphicsLayer),i.cancelled||null==o||this.addGraphic(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:a?"cancel":"complete",tool:e,toolEventInfo:null,type:"create"}),a||this._sketchContinuationFlag)return;const{creationMode:r}=this;if("continuous"===r){if(t?.geometryToPlace)return;this._updatingHandles.addPromise(c(this.create(e,t)))}else"update"===r&&o&&this._updatingHandles.addPromise(c(this.update([o])))}};i.on("complete",r),this._operationHandle=i,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){this.cancel(),await this._waitViewReady();const{layer:o,view:a,state:i}=this;if(!a||"disabled"===i)throw o||this._logMissingLayer(),l();null!=a.activeTool&&(a.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||Ge(s)||(F(a,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||E(o.geometry.spatialReference,t.spatialReference)||(w(o.geometry.spatialReference,t.spatialReference)||G()||await O(),o.geometry=T(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._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 a=await t.hitTest(e,{exclude:o});return X(a.results)}const o=[t.map.ground];t.map.allLayers.forEach(e=>{M(e)&&o.push(e)});const a=await t.hitTest(e,{exclude:o});if(a.results.length>0){const e=a.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!a.ground.mapPoint||t.map.ground.opacity<1||a.ground.distance-(e.distance??0)>-Math.min(3*a.ground.distance,"global"===t.viewingMode?b(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))},V.WIDGET)]}async _handleImmediateClick(e){const t=await e.defer(()=>this._getFirstHit(ee(e)));let o=null;if(null!=t){const a=t.graphic;this.updateGraphics.includes(a)||this.hasGraphic(a)?(e.stopPropagation(),o=a):"2d"!==this.view?.type||this._isComponentGraphic(a)||"active"!==this.state||this.cancel()}else"active"===this.state&&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 a={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},i=await this._setupDrawGraphicTool(e,o,a);return null==i?null:(o.tools.add(i),o.activeTool=i,this._setupCreateOperationHandle(i,e))}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:a,defaultZ:i,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=re(p,e),c=se(e),d=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=d?.preserveAspectRatio??l??"rectangle"!==e,m={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:a,defaultZ:i,forceUniformSize:u,graphicProperties:{...n,attributes:{...n?.attributes}},geometryToPlace:s,geometryType:c,mode:h,graphicSymbol:this._getGraphicSymbolFromTool(e),hasZ:r,snappingManager:this.snappingManager,snapToScene:!1,view:t,...d};return"2d"===t.type?this._makeDrawGraphicTool2D(m):this._makeDrawGraphicTool3D(m)}async _makeDrawGraphicTool2D(e){const[t,o,a]=await Promise.all([this._requireModule(import("../../views/2d/interactive/editingTools.js")),Y(),J()]);return Ge(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:ye(e.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions,automaticAreaMeasurementUtils:o,automaticLengthMeasurementUtils:a})}async _makeDrawGraphicTool3D(e){const[t,o,a]=await Promise.all([this._requireModule(import("../../views/3d/interactive/editingTools.js")),Y(),J()]);return Ge(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,sketchOptions:this.sketchOptions,automaticAreaMeasurementUtils:o,automaticLengthMeasurementUtils:a})}_setupCreateOperationHandle(e,t){const o=this.view;if(!o)return this._logMissingView(),null;let a=null;const i=e.forceUniformSize,s=e.centered,n=[o.on("key-down",t=>{if(t.key===K.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===K.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==K.vertexAdd||t.repeat)t.key===K.undo?(t.stopPropagation(),p.undo()):t.key===K.redo?(t.stopPropagation(),p.redo()):t.key!==K.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===K.center&&(t.repeat||(e.centered=!s,t.stopPropagation())):(e.forceUniformSize=!i,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}},V.WIDGET),o.on("key-up",t=>{t.key===K.pan?e.enabled=!0:t.key!==K.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===K.center&&(e.centered=s,t.stopPropagation()):(e.forceUniformSize=i,t.stopPropagation())},V.WIDGET),e.on("vertex-add",t=>{switch(a=null==a?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:a,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(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),a="complete",e.aborted?p&&p.cancel():p&&p.complete()}),d(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],p=new ae({activeComponent:e,type:"create",onEnd:()=>{r(n),o.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return p}_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 a={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};let i=a.tool??le.tool;if(this.removeGraphics(e),this.addGraphics(e),"3d"===o.type){if(0===e.length)return null;switch(i){case"move":return this._setupMove3DOperation(e,a,o,i);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],a,o);case"transform":return this._setupGraphicTransform3DOperation(e,a,o)}}switch(i){case"move":return this._setupMove2DOperation(e,a,o);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,i,a,o);case"transform":return ne(e)&&(i="reshape"),this._setupTransformOrReshape2DOperation(e,i,a,o)}}async _setupMove3DOperation(e,t,o,a,i=!1){const[s,n]=await Promise.all([this._requireModule(import("../../views/3d/interactive/editingTools.js")),J()]);if(Ge(s))return s;const{ManipulatedObject3DGraphic:p,MoveTool3D:l}=s.module,h=new Map,c=()=>{h.forEach(e=>e.destroy()),h.clear()};for(const r of e){const e=new p({view:o,graphic:r}),t=x(e);if(0!==t)return c(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${R(t)}).`),null;h.set(r,e)}const d=new l({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,autoLengthMeasurementUtils:n});o.tools.add(d),d.objects.addMany(Array.from(h.values())),i||this.updateGraphics.addMany(e);const u=[],m=new ie({activeComponent:d,tool:a,type:"update",onEnd:()=>{r(u),we(o,d),c()},undo:()=>{_e(this.view,d),ge(m,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a})},redo:()=>{ve(m,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a})},addToSelection:e=>{this.updateGraphics.push(e);const t=new p({view:o,graphic:e});h.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:e=>{const t=this.updateGraphics.indexOf(e);if(m.history.undo.forEach(e=>e.updates.splice(t,1)),m.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 m.complete();const o=h.get(e);o&&(d.objects.remove(o),o.destroy(),h.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==a)return;const e=this.updateGraphics.at(0),i=await this._setupReshape3DOperation(e,t,o,!0);i&&!Ge(i)&&(m.onEnd(),m.destroy(),this._setUpdateOperationHandle(i,t))}});return u.push(...this._getHandlesForComponent(m,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(m,e,t),V.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},V.WIDGET)),m}_setupGraphicTransform3DOperation(e,t,o,a=!1){if(1===e.length&&0===L(e[0])){const i=e[0],r=i.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(i,t,o);if(null!=r&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(i,t,o,a)}return this._setupMove3DOperation(e,t,o,"transform",a)}async _setupPointTransform3DOperation(e,t,o){const a="transform",{enableRotation:i,enableScaling:s,enableZ:n}=t,p=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ge(p))return p;const{TransformTool3D:l,ManipulatedObject3DGraphic:h}=p.module,c=new h({graphic:e,view:o}),d=new l({object:c,view:o,enableRotation:i,enableScaling:s,enableZ:n,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),this.updateGraphics.add(e);const u=[],m=new ie({activeComponent:d,tool:a,type:"update",onEnd:()=>{r(u),we(o,d),c.destroy()},undo:()=>{_e(this.view,d),ge(m,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a})},redo:()=>{ve(m,this.updateGraphics.toArray()),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 a=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);Ge(a)||this._setUpdateOperationHandle(a,t)},removeFromSelection: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:()=>{}});return u.push(...this._getHandlesForComponent(m,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(m,e,t),V.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},V.WIDGET)),m}async _setupPolyTransform3DOperation(e,t,o,a=!1){const i="transform",{enableRotation:s,enableScaling:n,enableZ:p,preserveAspectRatio:l}=t,[h,c]=await Promise.all([this._requireModule(import("../../views/3d/interactive/editingTools.js")),J()]);if(Ge(h))return h;const{ManipulatedObject3DGraphic:d,ExtentTransformTool:u}=h.module,m=this.view?.inputManager?.isModifierKeyDown(K.constraint),y=new d({view:o,graphic:e}),g=new u({object:y,view:o,enableRotation:s,enableScaling:n,enableZ:p,preserveAspectRatio:!!l!=!!m,sketchOptions:this.sketchOptions,automaticLengthMeasurementUtils:c});o.tools.add(g),a||this.updateGraphics.add(e);const v=[],f=new ie({activeComponent:g,tool:i,type:"update",onEnd:()=>{r(v),we(o,g),y.destroy()},canUndo:()=>!g.destroyed&&g.canUndo,undo:()=>{g.destroyed||(g.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i}))},canRedo:()=>!g.destroyed&&g.canRedo,redo:()=>{g.destroyed||(g.redo(),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"}),f.onEnd(),f.destroy();const a=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);Ge(a)||this._setUpdateOperationHandle(a,t)},removeFromSelection: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"}),f.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const a=await this._setupReshape3DOperation(e,t,o,!0);a&&!Ge(a)&&(f.onEnd(),f.destroy(),this._setUpdateOperationHandle(a,t))}});return v.push(...this._getHandlesForComponent(f,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(f,e,t),V.WIDGET),o.on("key-down",e=>this._getCommonUpdateOperationKeyDownHandlers(f,e),V.WIDGET),o.on("key-down",e=>{e.key!==K.constraint||e.repeat||(g.preserveAspectRatio=!g.preserveAspectRatio,e.stopPropagation())},V.WIDGET),o.on("key-up",e=>{e.key===K.constraint&&(g.preserveAspectRatio=!g.preserveAspectRatio,e.stopPropagation())},V.WIDGET)),f}async _setupMove2DOperation(e,t,o){const a="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const i=await this._getGraphicMover(e,t,o);if(Ge(i))return i;const s=new ie({activeComponent:i,tool:a,type:"update",onEnd:()=>{this._clearCursor(),r(l),r(p),i.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();ge(s,e),s.refreshComponent(),this._emitUndoEvent({graphics:e,tool:a})},redo:()=>{const e=this.updateGraphics.toArray();ve(s,e),s.refreshComponent(),this._emitRedoEvent({graphics:e,tool:a})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),i.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:e=>{const t=this.updateGraphics.indexOf(e);s.history.undo.forEach(e=>e.updates.splice(t,1)),s.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?i.graphics=o:s.complete()}});let n=!1;const p=[o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(s,e,t),V.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(s,e),e.key!==K.constraint||e.repeat||(n=!0,i.enableMoveAllGraphics=!i.enableMoveAllGraphics)},V.WIDGET),o.on("key-up",e=>{e.key===K.constraint&&n&&(n=!1,i.enableMoveAllGraphics=!i.enableMoveAllGraphics)},V.WIDGET)],l=this._getHandlesForComponent(s,t);return s}async _setupReshape3DOperation(e,t,o,a=!1){const i="reshape",[s,n,p]=await Promise.all([this._requireModule(import("../../views/3d/interactive/editingTools.js")),Y(),J()]);if(Ge(s))return s;const{ManipulatedObject3DGraphic:l,ReshapeTool3D:h}=s.module,c=new l({view:o,graphic:e}),d=P(c);if(0!==d)return c.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${R(d)}).`),null;const u=t.reshapeOptions,m=new h({view:o,object:c,enableZVertex:t.enableZ&&"move"===u?.vertexOperation,enableZShape:t.enableZ&&"move"===u?.shapeOperation,enableMoveObject:"move"===u?.shapeOperation||"move-xy"===u?.shapeOperation,enableMidpoints:"split"===u?.edgeOperation,enableEdgeOffset:"offset"===u?.edgeOperation,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,automaticAreaMeasurementUtils:n,automaticLengthMeasurementUtils:p});o.tools.add(m),a||this.updateGraphics.add(c.graphic);const y=[],g=new ie({activeComponent:m,tool:i,type:"update",onEnd:()=>{r(y),we(o,m),c.destroy()},canUndo:()=>!m.destroyed&&m.canUndo,undo:()=>{m.destroyed||(m.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i}))},canRedo:()=>!m.destroyed&&m.canRedo,redo:()=>{m.destroyed||(m.redo(),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"}),g.onEnd(),g.destroy();const a=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);Ge(a)||this._setUpdateOperationHandle(a,t)},removeFromSelection: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"}),g.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;g.onEnd(),g.destroy();const e=await this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0);Ge(e)||this._setUpdateOperationHandle(e,t)}});return y.push(...this._getHandlesForComponent(g,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(g,e,t),V.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(g,e)},V.WIDGET)),g}async _setupTransformOrReshape2DOperation(e,t,o,a){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const i="transform"===t?await this._getBox(e,o,a):await this._getReshape(e,o,a);if(Ge(i))return i;const s=new ie({activeComponent:i,type:"update",onEnd:()=>{r(p),r(n),s.activeComponent&&!s.activeComponent.destroyed&&s.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{ge(s,this.updateGraphics.toArray()),s.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:s.tool})},redo:()=>{ve(s,this.updateGraphics.toArray()),s.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:s.tool})},addToSelection:async e=>{let t=s.activeComponent;if("reshape"===t?.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll(),s.onEnd(),s.destroy();const i=await this._setupTransformOrReshape2DOperation(t,"transform",o,a);if(Ge(i))return;this._setUpdateOperationHandle(i,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),s.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:e=>{const t=this.updateGraphics.indexOf(e);s.history.undo.forEach(e=>e.updates.splice(t,1)),s.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();0===o.length?s.complete():ne(o)?s.toggleTool():s.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"===s.tool&&"point"===t.type||"transform"===s.tool&&"extent"===t.type))return;let i=null;"transform"===s.tool?i=await this._getReshape([e],o,a):"reshape"===s.tool&&(i=await this._getBox([e],o,a)),Ge(i)||(s.activeComponent?.destroy(),s.activeComponent=i,s.activeComponent&&(r(p),p=this._getHandlesForComponent(s,o)))}}),n=[a.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(s,e,o),V.WIDGET),a.on("key-down",e=>{if(this._getCommonUpdateOperationKeyDownHandlers(s,e),e.key===K.constraint&&!e.repeat&&s){const e=s.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},V.WIDGET),a.on("key-up",e=>{if(e.key===K.constraint&&s){const e=s.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},V.WIDGET)];let p=this._getHandlesForComponent(s,o);return s}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:a,highlightOptions:i}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return Ge(r)?r:new r.module.default({enableMoveAllGraphics:a,highlightName:i?.name,highlightsEnabled:!!i?.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:a,enableScaling:i,highlightOptions:r,preserveAspectRatio:s}=t,[n,p]=await Promise.all([this._requireModule(import("../../views/draw/support/Box.js")),J()]);if(Ge(n))return n;const l=this.view?.inputManager?.isModifierKeyDown(K.constraint);return new n.module.default({graphics:e,enableRotation:a,enableScaling:i,highlightName:r?.name,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!l,layer:this._internalGraphicsLayer,view:o,sketchOptions:this.sketchOptions,automaticLengthMeasurementUtils:p,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"})}})}async _getReshape(e,t,o){const{highlightOptions:a,reshapeOptions:i}=t,r="split"===i?.edgeOperation,s="move"===i?.shapeOperation,n=!!i?.enableCreateCurveFromStraightEdge,[p,l,h]=await Promise.all([this._requireModule(import("../../views/draw/support/Reshape.js")),Y(),J()]);return Ge(p)?p:new p.module.default({enableMidpoints:r,enableMovement:s,enableCurveOnMidpoint:n,graphic:e[0],highlightName:a?.name,highlightsEnabled:!!a?.enabled,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,automaticAreaMeasurementUtils:l,automaticLengthMeasurementUtils:h,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:a})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:a},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:a})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:a},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:a})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:a},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const a=e.map(e=>S(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:a,vertices:o,type:t},type:"update"})},onVertexRemove:({removed:e,type:t,vertices:o})=>{const a=e.map(e=>S(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:a,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:a})=>{a.native?.shiftKey&&t.multipleSelectionEnabled&&(a.stopPropagation(),e.removeFromSelection(o))}),o.on("graphic-move-start",t=>e.addToHistory(be(t.allGraphics)))];case"box":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(be(t.graphics))),o.on("rotate-start",t=>e.addToHistory(be(t.graphics))),o.on("scale-start",t=>e.addToHistory(be(t.graphics)))];case"reshape":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(be([t.mover]))),o.on("reshape-start",t=>e.addToHistory(be([t.graphic]))),o.on("vertex-add",t=>e.addToHistory(be([t.oldGraphic]))),o.on("vertex-remove",t=>e.addToHistory(be([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=>{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=>{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=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})]}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:a,viewEvent:i}=o;return i.native?.shiftKey&&this.hasGraphic(a)?(i.stopPropagation(),e.removeFromSelection(a)):t.toggleToolOnClick?(i.stopPropagation(),e.toggleTool()):void 0}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view?.map;this._disablePopup(t);const a=()=>{if(e===this._operationHandle){const a=this.updateGraphics.toArray(),i=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:a,state:"complete",aborted:e.cancelled,tool:i,toolEventInfo:null,type:"update"})}};e.on("complete",a)}async _getCommonUpdateOperationClickHandlers(e,t,o){const a=ee(t),i=await t.defer(()=>this._getFirstHit(a));if(null==i)return void e.complete();if(t.native.shiftKey&&this._toggleSelection([i.graphic],e,o))return void t.stopPropagation();this.updateGraphics.includes(i.graphic)?t.stopPropagation():e.complete()}_toggleSelection(e,t,o){const a=!!o.multipleSelectionEnabled;return e.some(e=>null!=e&&(!(!a||!this.hasGraphic(e))&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0)))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===K.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===K.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===K.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&K.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=n(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(he)}_displayCursor(e){this.removeHandles(he),this.view?.container&&null!=e&&this.addHandles(this.view.acquireCursor(e,"high"),he)}_logError(e,t,o){s.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._operationHandle.removeFromSelection(o)}}}get test(){}wait(){return g(()=>!this.updating)}_disablePopupEnabled(e){return"3d"!==this.view?.type||this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._disablePopupEnabled(e)&&this.view&&null==this._originalPopupEnabled&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._disablePopupEnabled(e)&&this.view&&null!=this._originalPopupEnabled&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){const e=this.view;e?(p(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await h(g(()=>e?.ready),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",me("view"))}_logMissingLayer(){this._logError(ue,me("layer"))}};e([v()],de.prototype,"_defaultSnappingManager",void 0),e([v()],de.prototype,"_layerAdapter",null),e([v()],de.prototype,"_operationHandle",void 0),e([v({readOnly:!0})],de.prototype,"_updatingHandles",void 0),e([v({readOnly:!0})],de.prototype,"activeTool",null),e([v({readOnly:!0})],de.prototype,"activeCreateToolDrawMode",null),e([v()],de.prototype,"activeTooltip",null),e([v({types:I})],de.prototype,"activeFillSymbol",void 0),e([v()],de.prototype,"activeLineSymbol",void 0),e([v()],de.prototype,"activeVertexSymbol",void 0),e([v()],de.prototype,"allowDeleteKey",void 0),e([v({readOnly:!0})],de.prototype,"createGraphic",null),e([v()],de.prototype,"defaultCreateOptions",null),e([v()],de.prototype,"defaultUpdateOptions",null),e([v({type:W,nonNullable:!0})],de.prototype,"labelOptions",null),e([v()],de.prototype,"layer",void 0),e([v({types:I})],de.prototype,"pointSymbol",void 0),e([v({types:I})],de.prototype,"polygonSymbol",void 0),e([v({types:I})],de.prototype,"polylineSymbol",void 0),e([v()],de.prototype,"meshSymbol",void 0),e([v()],de.prototype,"textSymbol",void 0),e([v({type:B,nonNullable:!0})],de.prototype,"snappingOptions",null),e([v()],de.prototype,"snappingManager",null),e([v({readOnly:!0})],de.prototype,"state",null),e([v({type:q,nonNullable:!0})],de.prototype,"tooltipOptions",null),e([v({readOnly:!0})],de.prototype,"updateGraphics",void 0),e([v()],de.prototype,"updateOnGraphicClick",void 0),e([v()],de.prototype,"updating",null),e([v()],de.prototype,"creationMode",void 0),e([v({type:N,nonNullable:!0})],de.prototype,"valueOptions",null),e([v({types:I})],de.prototype,"vertexSymbol",void 0),e([v({value:null})],de.prototype,"view",null),e([v({constructOnly:!0,type:Z})],de.prototype,"sketchOptions",void 0),de=e([f("esri.widgets.Sketch.SketchViewModel")],de);const ue="sketch:missing-property",me=e=>`Property '${e}' is missing on SketchViewModel.`;function ye(e){return"polygon"===e||"rectangle"===e||"circle"===e}function ge(e,t){fe("undo",e.history.undo,e.history.redo,t)}function ve(e,t){fe("redo",e.history.redo,e.history.undo,t)}function fe(e,t,o,a){const i=t.pop();if(!i)return;const r=i.updates,s=[];a.forEach((t,o)=>{const a=r[o];null!=a&&("geometry"in a&&null!=a.geometry&&(s.push({geometry:t.geometry}),t.geometry=a.geometry),"symbol"in a&&null!=a.symbol&&(s.push({symbol:t.symbol}),t.symbol=a.symbol),"undo"in a&&(s.push(a),a[e](t)))}),o.push({updates:s})}function _e(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function be(e){return{updates:e.map(({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e})}}function we(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function Ge(e){return"requireError"in e&&"aborted"===e.requireError}export{de as default};
5
+ import{__decorate as e}from"tslib";import{isSome as t}from"../../core/arrayUtils.js";import o from"../../core/Collection.js";import a from"../../core/Error.js";import{EventedAccessor as i}from"../../core/Evented.js";import{drainHandles as r}from"../../core/handleUtils.js";import"../../core/has.js";import s from"../../core/Logger.js";import{destroyMaybe as n,abortMaybe as p}from"../../core/maybe.js";import{createAbortError as l,whenOrAbort as h,ignoreAbortErrors as c}from"../../core/promiseUtils.js";import{watch as d,syncAndInitial as u,on as m,when as y,whenOnce as g}from"../../core/reactiveUtils.js";import{property as v,subclass as f}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as _}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as b}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as w,isLoaded as G,load as O,project as T}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as S}from"../../geometry/support/coordsUtils.js";import{equals as E}from"../../geometry/support/spatialReferenceUtils.js";import A from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as M}from"../../layers/support/layerUtils.js";import C from"../../symbols/FillSymbol3DLayer.js";import k from"../../symbols/MeshSymbol3D.js";import H from"../../symbols/SimpleFillSymbol.js";import j from"../../symbols/SimpleLineSymbol.js";import U from"../../symbols/SimpleMarkerSymbol.js";import D from"../../symbols/TextSymbol.js";import{symbolTypes as I}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as R}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as x}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as P}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as L}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as F}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as V}from"../../views/input/InputManager.js";import{sketchKeys as K}from"../../views/interactive/keybindings.js";import W from"../../views/interactive/sketch/SketchLabelOptions.js";import Z from"../../views/interactive/sketch/SketchOptions.js";import q from"../../views/interactive/sketch/SketchTooltipOptions.js";import N from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as z}from"../../views/interactive/snapping/SnappingManager.js";import B from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as $}from"../../views/interactive/snapping/snappingUtils.js";import{loadAutomaticAreaMeasurementUtils as Y}from"../../views/support/automaticAreaMeasurementUtils.js";import{loadAutomaticLengthMeasurementUtils as J}from"../../views/support/automaticLengthMeasurementUtils.js";import{defaultHighlightName as Q}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as X}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as ee}from"../../views/support/screenUtils.js";import te from"./adapters/layer/GraphicsLayerAdapter.js";import oe from"./adapters/layer/MapNotesLayerAdapter.js";import{CreateOperationHandle as ae,UpdateOperationHandle as ie}from"./support/OperationHandle.js";import{getModeFromCreateOptions as re,getDrawToolGeometryTypeFromCreateTool as se,graphicsHaveTooFewVerticesForBox as ne}from"./support/sketchUtils.js";const pe={defaultZ:0},le={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:Q},tool:"transform"},he=Symbol(),ce=Symbol();let de=class extends i{constructor(e){super(e),this._defaultSnappingManager=null,this._internalGraphicsLayer=new A({listMode:"hide",internal:!0,title:"SVM Internal"}),this._operationHandle=null,this._updatingHandles=new _,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.layer=null,this.pointSymbol=new U({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new H({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new j({color:[130,130,130,1],width:2}),this.meshSymbol=new k({symbolLayers:new o([new C])}),this.textSymbol=new D({text:"text"}),this.updateGraphics=new o,this.updateOnGraphicClick=!0,this.creationMode="single",this.vertexSymbol=new U({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new Z,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{const{_layerAdapter:e}=this;if(this.removeHandles(ce),!e)return;const o=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),d(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},u)].filter(t);this.addHandles(o,ce)},this._originalPopupEnabled=null,this.defaultCreateOptions=pe,this.defaultUpdateOptions=le,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new B}initialize(){this.addHandles([m(()=>this.view?.map?.layers,"change",e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),d(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),u),d(()=>this.view,e=>{this._defaultSnappingManager=n(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new z({view:e,options:this.snappingOptions})),"2d"===e.type?import("../../views/2d/interactive/editingTools.js"):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))},u),d(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),$(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=n(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this.emit("destroy")}get _layerAdapter(){const{layer:e}=this;switch(e?.type){case"graphics":return new te(e);case"map-notes":return new oe(e);default:return null}}get activeTool(){return this._operationHandle?.tool??null}get activeCreateToolDrawMode(){return"create"===this._operationHandle?.type&&this._operationHandle.activeComponent&&"mode"in this._operationHandle.activeComponent?this._operationHandle.activeComponent.mode: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",{...pe,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...le,...e,reshapeOptions:{...le.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...le.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=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=n(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new z({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 tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return!(!this._updatingHandles.updating&&!this.snappingManager?.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(y(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},u),o),this._set("view",e)}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=p(this._moduleLoaderAbortController),this._viewReadyAbortController=p(this._viewReadyAbortController),this._sketchContinuationFlag=!0,this._operationHandle&&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){this.cancel(),await this._waitViewReady();const{view:o,layer:a}=this;if(!o||"disabled"===this.state)throw a||this._logMissingLayer(),l();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");F(o,this._internalGraphicsLayer);const i=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t));if(null==i||this.destroyed)return void o.map?.remove(this._internalGraphicsLayer);const r=()=>{if(i===this._operationHandle){const o=this.createGraphic,a=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map?.remove(this._internalGraphicsLayer),i.cancelled||null==o||this.addGraphic(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:a?"cancel":"complete",tool:e,toolEventInfo:null,type:"create"}),a||this._sketchContinuationFlag)return;const{creationMode:r}=this;if("continuous"===r){if(t?.geometryToPlace)return;this._updatingHandles.addPromise(c(this.create(e,t)))}else"update"===r&&o&&this._updatingHandles.addPromise(c(this.update([o])))}};i.on("complete",r),this._operationHandle=i,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){this.cancel(),await this._waitViewReady();const{layer:o,view:a,state:i}=this;if(!a||"disabled"===i)throw o||this._logMissingLayer(),l();null!=a.activeTool&&(a.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||Ge(s)||(F(a,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||E(o.geometry.spatialReference,t.spatialReference)||(w(o.geometry.spatialReference,t.spatialReference)||G()||await O(),o.geometry=T(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._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 a=await t.hitTest(e,{exclude:o});return X(a.results)}const o=[t.map.ground];t.map.allLayers.forEach(e=>{M(e)&&o.push(e)});const a=await t.hitTest(e,{exclude:o});if(a.results.length>0){const e=a.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!a.ground.mapPoint||t.map.ground.opacity<1||a.ground.distance-(e.distance??0)>-Math.min(3*a.ground.distance,"global"===t.viewingMode?b(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))},V.WIDGET)]}async _handleImmediateClick(e){const t=await e.defer(()=>this._getFirstHit(ee(e)));let o=null;if(null!=t){const a=t.graphic;this.updateGraphics.includes(a)||this.hasGraphic(a)?(e.stopPropagation(),o=a):"2d"!==this.view?.type||this._isComponentGraphic(a)||"active"!==this.state||this.cancel()}else"active"===this.state&&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 a={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},i=await this._setupDrawGraphicTool(e,o,a);return null==i?null:(o.tools.add(i),o.activeTool=i,this._setupCreateOperationHandle(i,e))}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:a,defaultZ:i,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=re(p,e),c=se(e),d=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=d?.preserveAspectRatio??l??"rectangle"!==e,m={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:a,defaultZ:i,forceUniformSize:u,graphicProperties:{...n,attributes:{...n?.attributes}},geometryToPlace:s,geometryType:c,mode:h,graphicSymbol:o.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:r,snappingManager:this.snappingManager,snapToScene:!1,view:t,...d};return"2d"===t.type?this._makeDrawGraphicTool2D(m):this._makeDrawGraphicTool3D(m)}async _makeDrawGraphicTool2D(e){const[t,o,a]=await Promise.all([this._requireModule(import("../../views/2d/interactive/editingTools.js")),Y(),J()]);return Ge(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:ye(e.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions,automaticAreaMeasurementUtils:o,automaticLengthMeasurementUtils:a})}async _makeDrawGraphicTool3D(e){const[t,o,a]=await Promise.all([this._requireModule(import("../../views/3d/interactive/editingTools.js")),Y(),J()]);return Ge(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,sketchOptions:this.sketchOptions,automaticAreaMeasurementUtils:o,automaticLengthMeasurementUtils:a})}_setupCreateOperationHandle(e,t){const o=this.view;if(!o)return this._logMissingView(),null;let a=null;const i=e.forceUniformSize,s=e.centered,n=[o.on("key-down",t=>{if(t.key===K.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===K.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==K.vertexAdd||t.repeat)t.key===K.undo?(t.stopPropagation(),p.undo()):t.key===K.redo?(t.stopPropagation(),p.redo()):t.key!==K.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===K.center&&(t.repeat||(e.centered=!s,t.stopPropagation())):(e.forceUniformSize=!i,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}},V.WIDGET),o.on("key-up",t=>{t.key===K.pan?e.enabled=!0:t.key!==K.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===K.center&&(e.centered=s,t.stopPropagation()):(e.forceUniformSize=i,t.stopPropagation())},V.WIDGET),e.on("vertex-add",t=>{switch(a=null==a?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:a,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(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),a="complete",e.aborted?p&&p.cancel():p&&p.complete()}),d(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],p=new ae({activeComponent:e,type:"create",onEnd:()=>{r(n),o.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return p}_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 a={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};let i=a.tool??le.tool;if(this.removeGraphics(e),this.addGraphics(e),"3d"===o.type){if(0===e.length)return null;switch(i){case"move":return this._setupMove3DOperation(e,a,o,i);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],a,o);case"transform":return this._setupGraphicTransform3DOperation(e,a,o)}}switch(i){case"move":return this._setupMove2DOperation(e,a,o);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,i,a,o);case"transform":return ne(e)&&(i="reshape"),this._setupTransformOrReshape2DOperation(e,i,a,o)}}async _setupMove3DOperation(e,t,o,a,i=!1){const[s,n]=await Promise.all([this._requireModule(import("../../views/3d/interactive/editingTools.js")),J()]);if(Ge(s))return s;const{ManipulatedObject3DGraphic:p,MoveTool3D:l}=s.module,h=new Map,c=()=>{h.forEach(e=>e.destroy()),h.clear()};for(const r of e){const e=new p({view:o,graphic:r}),t=x(e);if(0!==t)return c(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${R(t)}).`),null;h.set(r,e)}const d=new l({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,autoLengthMeasurementUtils:n});o.tools.add(d),d.objects.addMany(Array.from(h.values())),i||this.updateGraphics.addMany(e);const u=[],m=new ie({activeComponent:d,tool:a,type:"update",onEnd:()=>{r(u),we(o,d),c()},undo:()=>{_e(this.view,d),ge(m,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a})},redo:()=>{ve(m,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a})},addToSelection:e=>{this.updateGraphics.push(e);const t=new p({view:o,graphic:e});h.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:e=>{const t=this.updateGraphics.indexOf(e);if(m.history.undo.forEach(e=>e.updates.splice(t,1)),m.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 m.complete();const o=h.get(e);o&&(d.objects.remove(o),o.destroy(),h.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==a)return;const e=this.updateGraphics.at(0),i=await this._setupReshape3DOperation(e,t,o,!0);i&&!Ge(i)&&(m.onEnd(),m.destroy(),this._setUpdateOperationHandle(i,t))}});return u.push(...this._getHandlesForComponent(m,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(m,e,t),V.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},V.WIDGET)),m}_setupGraphicTransform3DOperation(e,t,o,a=!1){if(1===e.length&&0===L(e[0])){const i=e[0],r=i.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(i,t,o);if(null!=r&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(i,t,o,a)}return this._setupMove3DOperation(e,t,o,"transform",a)}async _setupPointTransform3DOperation(e,t,o){const a="transform",{enableRotation:i,enableScaling:s,enableZ:n}=t,p=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ge(p))return p;const{TransformTool3D:l,ManipulatedObject3DGraphic:h}=p.module,c=new h({graphic:e,view:o}),d=new l({object:c,view:o,enableRotation:i,enableScaling:s,enableZ:n,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),this.updateGraphics.add(e);const u=[],m=new ie({activeComponent:d,tool:a,type:"update",onEnd:()=>{r(u),we(o,d),c.destroy()},undo:()=>{_e(this.view,d),ge(m,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a})},redo:()=>{ve(m,this.updateGraphics.toArray()),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 a=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);Ge(a)||this._setUpdateOperationHandle(a,t)},removeFromSelection: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:()=>{}});return u.push(...this._getHandlesForComponent(m,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(m,e,t),V.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},V.WIDGET)),m}async _setupPolyTransform3DOperation(e,t,o,a=!1){const i="transform",{enableRotation:s,enableScaling:n,enableZ:p,preserveAspectRatio:l}=t,[h,c]=await Promise.all([this._requireModule(import("../../views/3d/interactive/editingTools.js")),J()]);if(Ge(h))return h;const{ManipulatedObject3DGraphic:d,ExtentTransformTool:u}=h.module,m=this.view?.inputManager?.isModifierKeyDown(K.constraint),y=new d({view:o,graphic:e}),g=new u({object:y,view:o,enableRotation:s,enableScaling:n,enableZ:p,preserveAspectRatio:!!l!=!!m,sketchOptions:this.sketchOptions,automaticLengthMeasurementUtils:c});o.tools.add(g),a||this.updateGraphics.add(e);const v=[],f=new ie({activeComponent:g,tool:i,type:"update",onEnd:()=>{r(v),we(o,g),y.destroy()},canUndo:()=>!g.destroyed&&g.canUndo,undo:()=>{g.destroyed||(g.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i}))},canRedo:()=>!g.destroyed&&g.canRedo,redo:()=>{g.destroyed||(g.redo(),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"}),f.onEnd(),f.destroy();const a=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);Ge(a)||this._setUpdateOperationHandle(a,t)},removeFromSelection: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"}),f.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const a=await this._setupReshape3DOperation(e,t,o,!0);a&&!Ge(a)&&(f.onEnd(),f.destroy(),this._setUpdateOperationHandle(a,t))}});return v.push(...this._getHandlesForComponent(f,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(f,e,t),V.WIDGET),o.on("key-down",e=>this._getCommonUpdateOperationKeyDownHandlers(f,e),V.WIDGET),o.on("key-down",e=>{e.key!==K.constraint||e.repeat||(g.preserveAspectRatio=!g.preserveAspectRatio,e.stopPropagation())},V.WIDGET),o.on("key-up",e=>{e.key===K.constraint&&(g.preserveAspectRatio=!g.preserveAspectRatio,e.stopPropagation())},V.WIDGET)),f}async _setupMove2DOperation(e,t,o){const a="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const i=await this._getGraphicMover(e,t,o);if(Ge(i))return i;const s=new ie({activeComponent:i,tool:a,type:"update",onEnd:()=>{this._clearCursor(),r(l),r(p),i.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();ge(s,e),s.refreshComponent(),this._emitUndoEvent({graphics:e,tool:a})},redo:()=>{const e=this.updateGraphics.toArray();ve(s,e),s.refreshComponent(),this._emitRedoEvent({graphics:e,tool:a})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),i.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:e=>{const t=this.updateGraphics.indexOf(e);s.history.undo.forEach(e=>e.updates.splice(t,1)),s.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?i.graphics=o:s.complete()}});let n=!1;const p=[o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(s,e,t),V.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(s,e),e.key!==K.constraint||e.repeat||(n=!0,i.enableMoveAllGraphics=!i.enableMoveAllGraphics)},V.WIDGET),o.on("key-up",e=>{e.key===K.constraint&&n&&(n=!1,i.enableMoveAllGraphics=!i.enableMoveAllGraphics)},V.WIDGET)],l=this._getHandlesForComponent(s,t);return s}async _setupReshape3DOperation(e,t,o,a=!1){const i="reshape",[s,n,p]=await Promise.all([this._requireModule(import("../../views/3d/interactive/editingTools.js")),Y(),J()]);if(Ge(s))return s;const{ManipulatedObject3DGraphic:l,ReshapeTool3D:h}=s.module,c=new l({view:o,graphic:e}),d=P(c);if(0!==d)return c.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${R(d)}).`),null;const u=t.reshapeOptions,m=new h({view:o,object:c,enableZVertex:t.enableZ&&"move"===u?.vertexOperation,enableZShape:t.enableZ&&"move"===u?.shapeOperation,enableMoveObject:"move"===u?.shapeOperation||"move-xy"===u?.shapeOperation,enableMidpoints:"split"===u?.edgeOperation,enableEdgeOffset:"offset"===u?.edgeOperation,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,automaticAreaMeasurementUtils:n,automaticLengthMeasurementUtils:p});o.tools.add(m),a||this.updateGraphics.add(c.graphic);const y=[],g=new ie({activeComponent:m,tool:i,type:"update",onEnd:()=>{r(y),we(o,m),c.destroy()},canUndo:()=>!m.destroyed&&m.canUndo,undo:()=>{m.destroyed||(m.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i}))},canRedo:()=>!m.destroyed&&m.canRedo,redo:()=>{m.destroyed||(m.redo(),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"}),g.onEnd(),g.destroy();const a=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);Ge(a)||this._setUpdateOperationHandle(a,t)},removeFromSelection: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"}),g.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;g.onEnd(),g.destroy();const e=await this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0);Ge(e)||this._setUpdateOperationHandle(e,t)}});return y.push(...this._getHandlesForComponent(g,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(g,e,t),V.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(g,e)},V.WIDGET)),g}async _setupTransformOrReshape2DOperation(e,t,o,a){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const i="transform"===t?await this._getBox(e,o,a):await this._getReshape(e,o,a);if(Ge(i))return i;const s=new ie({activeComponent:i,type:"update",onEnd:()=>{r(p),r(n),s.activeComponent&&!s.activeComponent.destroyed&&s.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{ge(s,this.updateGraphics.toArray()),s.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:s.tool})},redo:()=>{ve(s,this.updateGraphics.toArray()),s.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:s.tool})},addToSelection:async e=>{let t=s.activeComponent;if("reshape"===t?.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll(),s.onEnd(),s.destroy();const i=await this._setupTransformOrReshape2DOperation(t,"transform",o,a);if(Ge(i))return;this._setUpdateOperationHandle(i,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),s.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:e=>{const t=this.updateGraphics.indexOf(e);s.history.undo.forEach(e=>e.updates.splice(t,1)),s.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();0===o.length?s.complete():ne(o)?s.toggleTool():s.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"===s.tool&&"point"===t.type||"transform"===s.tool&&"extent"===t.type))return;let i=null;"transform"===s.tool?i=await this._getReshape([e],o,a):"reshape"===s.tool&&(i=await this._getBox([e],o,a)),Ge(i)||(s.activeComponent?.destroy(),s.activeComponent=i,s.activeComponent&&(r(p),p=this._getHandlesForComponent(s,o)))}}),n=[a.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(s,e,o),V.WIDGET),a.on("key-down",e=>{if(this._getCommonUpdateOperationKeyDownHandlers(s,e),e.key===K.constraint&&!e.repeat&&s){const e=s.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},V.WIDGET),a.on("key-up",e=>{if(e.key===K.constraint&&s){const e=s.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},V.WIDGET)];let p=this._getHandlesForComponent(s,o);return s}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:a,highlightOptions:i}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return Ge(r)?r:new r.module.default({enableMoveAllGraphics:a,highlightName:i?.name,highlightsEnabled:!!i?.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:a,enableScaling:i,highlightOptions:r,preserveAspectRatio:s}=t,[n,p]=await Promise.all([this._requireModule(import("../../views/draw/support/Box.js")),J()]);if(Ge(n))return n;const l=this.view?.inputManager?.isModifierKeyDown(K.constraint);return new n.module.default({graphics:e,enableRotation:a,enableScaling:i,highlightName:r?.name,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!l,layer:this._internalGraphicsLayer,view:o,sketchOptions:this.sketchOptions,automaticLengthMeasurementUtils:p,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"})}})}async _getReshape(e,t,o){const{highlightOptions:a,reshapeOptions:i}=t,r="split"===i?.edgeOperation,s="move"===i?.shapeOperation,n=!!i?.enableCreateCurveFromStraightEdge,[p,l,h]=await Promise.all([this._requireModule(import("../../views/draw/support/Reshape.js")),Y(),J()]);return Ge(p)?p:new p.module.default({enableMidpoints:r,enableMovement:s,enableCurveOnMidpoint:n,graphic:e[0],highlightName:a?.name,highlightsEnabled:!!a?.enabled,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,automaticAreaMeasurementUtils:l,automaticLengthMeasurementUtils:h,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:a})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:a},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:a})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:a},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:a})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:a},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const a=e.map(e=>S(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:a,vertices:o,type:t},type:"update"})},onVertexRemove:({removed:e,type:t,vertices:o})=>{const a=e.map(e=>S(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:a,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:a})=>{a.native?.shiftKey&&t.multipleSelectionEnabled&&(a.stopPropagation(),e.removeFromSelection(o))}),o.on("graphic-move-start",t=>e.addToHistory(be(t.allGraphics)))];case"box":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(be(t.graphics))),o.on("rotate-start",t=>e.addToHistory(be(t.graphics))),o.on("scale-start",t=>e.addToHistory(be(t.graphics)))];case"reshape":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(be([t.mover]))),o.on("reshape-start",t=>e.addToHistory(be([t.graphic]))),o.on("vertex-add",t=>e.addToHistory(be([t.oldGraphic]))),o.on("vertex-remove",t=>e.addToHistory(be([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=>{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=>{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=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})]}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:a,viewEvent:i}=o;return i.native?.shiftKey&&this.hasGraphic(a)?(i.stopPropagation(),e.removeFromSelection(a)):t.toggleToolOnClick?(i.stopPropagation(),e.toggleTool()):void 0}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view?.map;this._disablePopup(t);const a=()=>{if(e===this._operationHandle){const a=this.updateGraphics.toArray(),i=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:a,state:"complete",aborted:e.cancelled,tool:i,toolEventInfo:null,type:"update"})}};e.on("complete",a)}async _getCommonUpdateOperationClickHandlers(e,t,o){const a=ee(t),i=await t.defer(()=>this._getFirstHit(a));if(null==i)return void e.complete();if(t.native.shiftKey&&this._toggleSelection([i.graphic],e,o))return void t.stopPropagation();this.updateGraphics.includes(i.graphic)?t.stopPropagation():e.complete()}_toggleSelection(e,t,o){const a=!!o.multipleSelectionEnabled;return e.some(e=>null!=e&&(!(!a||!this.hasGraphic(e))&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0)))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===K.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===K.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===K.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&K.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=n(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(he)}_displayCursor(e){this.removeHandles(he),this.view?.container&&null!=e&&this.addHandles(this.view.acquireCursor(e,"high"),he)}_logError(e,t,o){s.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._operationHandle.removeFromSelection(o)}}}get test(){}wait(){return g(()=>!this.updating)}_disablePopupEnabled(e){return"3d"!==this.view?.type||this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._disablePopupEnabled(e)&&this.view&&null==this._originalPopupEnabled&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._disablePopupEnabled(e)&&this.view&&null!=this._originalPopupEnabled&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){const e=this.view;e?(p(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await h(g(()=>e?.ready),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",me("view"))}_logMissingLayer(){this._logError(ue,me("layer"))}};e([v()],de.prototype,"_defaultSnappingManager",void 0),e([v()],de.prototype,"_layerAdapter",null),e([v()],de.prototype,"_operationHandle",void 0),e([v({readOnly:!0})],de.prototype,"_updatingHandles",void 0),e([v({readOnly:!0})],de.prototype,"activeTool",null),e([v({readOnly:!0})],de.prototype,"activeCreateToolDrawMode",null),e([v()],de.prototype,"activeTooltip",null),e([v({types:I})],de.prototype,"activeFillSymbol",void 0),e([v()],de.prototype,"activeLineSymbol",void 0),e([v()],de.prototype,"activeVertexSymbol",void 0),e([v()],de.prototype,"allowDeleteKey",void 0),e([v({readOnly:!0})],de.prototype,"createGraphic",null),e([v()],de.prototype,"defaultCreateOptions",null),e([v()],de.prototype,"defaultUpdateOptions",null),e([v({type:W,nonNullable:!0})],de.prototype,"labelOptions",null),e([v()],de.prototype,"layer",void 0),e([v({types:I})],de.prototype,"pointSymbol",void 0),e([v({types:I})],de.prototype,"polygonSymbol",void 0),e([v({types:I})],de.prototype,"polylineSymbol",void 0),e([v()],de.prototype,"meshSymbol",void 0),e([v({type:D})],de.prototype,"textSymbol",void 0),e([v({type:B,nonNullable:!0})],de.prototype,"snappingOptions",null),e([v()],de.prototype,"snappingManager",null),e([v({readOnly:!0})],de.prototype,"state",null),e([v({type:q,nonNullable:!0})],de.prototype,"tooltipOptions",null),e([v({readOnly:!0})],de.prototype,"updateGraphics",void 0),e([v()],de.prototype,"updateOnGraphicClick",void 0),e([v()],de.prototype,"updating",null),e([v()],de.prototype,"creationMode",void 0),e([v({type:N,nonNullable:!0})],de.prototype,"valueOptions",null),e([v({types:I})],de.prototype,"vertexSymbol",void 0),e([v({value:null})],de.prototype,"view",null),e([v({constructOnly:!0,type:Z})],de.prototype,"sketchOptions",void 0),de=e([f("esri.widgets.Sketch.SketchViewModel")],de);const ue="sketch:missing-property",me=e=>`Property '${e}' is missing on SketchViewModel.`;function ye(e){return"polygon"===e||"rectangle"===e||"circle"===e}function ge(e,t){fe("undo",e.history.undo,e.history.redo,t)}function ve(e,t){fe("redo",e.history.redo,e.history.undo,t)}function fe(e,t,o,a){const i=t.pop();if(!i)return;const r=i.updates,s=[];a.forEach((t,o)=>{const a=r[o];null!=a&&("geometry"in a&&null!=a.geometry&&(s.push({geometry:t.geometry}),t.geometry=a.geometry),"symbol"in a&&null!=a.symbol&&(s.push({symbol:t.symbol}),t.symbol=a.symbol),"undo"in a&&(s.push(a),a[e](t)))}),o.push({updates:s})}function _e(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function be(e){return{updates:e.map(({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e})}}function we(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function Ge(e){return"requireError"in e&&"aborted"===e.requireError}export{de as default};
package/widgets/Sketch.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{isSome as o}from"../core/arrayUtils.js";import{handlesGroup as i}from"../core/handleUtils.js";import s from"../core/Logger.js";import{removeMaybe as l,destroyMaybe as n}from"../core/maybe.js";import{ignoreAbortErrors as r}from"../core/promiseUtils.js";import{watch as a,when as p,syncAndInitial as c}from"../core/reactiveUtils.js";import{property as d,subclass as h}from"../core/accessorSupport/decorators.js";import u from"../views/interactive/sketch/SketchValueOptions.js";import v from"./Widget.js";import m from"./Sketch/SketchViewModel.js";import{VisibleElements as g}from"./Sketch/VisibleElements.js";import f from"./Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js";import{loadCalciteComponents as _}from"./support/componentsUtils.js";import y from"./support/SelectionToolbar.js";import b from"./support/SketchTooltipControls.js";import w from"./support/SnappingControls.js";import{tsx as T,messageBundle as M,vmEvent as C}from"./support/widget.js";import O from"./support/SelectionToolbar/VisibleElements.js";import S from"./support/SketchTooltipControls/VisibleElements.js";const k="esri-sketch",P={base:k,vertical:`${k}--vertical`,docked:`${k}-bar`,floating:`${k}-pad`,chipHorizontal:`${k}__selection-count-chip--horizontal`,chipVertical:`${k}__selection-count-chip--vertical`,chipVerticalSmall:`${k}__selection-count-chip--vertical--s`,popoverWrapper:`${k}__popover-wrapper`},E={point:"pin",polyline:"line",polygon:"polygon",rectangle:"rectangle",circle:"circle",multipoint:"pins",mesh:"i3d-building",freehandPolygon:"freehand-area",freehandPolyline:"freehand",text:"add-text"};let I=class extends v{constructor(e,t){super(e,t),this._selectionToolbar=null,this._viewModelHandlesGroup=null,this._popoverElement=null,this.availableCreateTools=["point","polyline","polygon","rectangle","circle"],this.customToolOptions=null,this.customActions=null,this.toolbarKind="floating",this.contextualToolLocation="separate",this.groupCollapsePriorities=null,this.groupAllowCollapseOptions=null,this.messages=null,this.messagesCommon=null,this.visibleElements=new g,this._defaultViewModel=null,this._activeCustomToolOptions=null,this._calcitePopoverReferenceElement=null,this._relativeLocation="top",this._popoverOpen=!1,this._activateCreateTool=this._activateCreateTool.bind(this),this.viewModel=e?.viewModel||(this._defaultViewModel=new m({creationMode:e?.creationMode??"continuous"}))}initialize(){const{layer:e,view:t}=this,o="2d"===t?.type,s=new y({persistSelection:!1,visibleElements:new O({chip:!1,lassoTool:o,operationTypeControls:!1,pan:!1,pointTool:!1,rectangleTool:o}),view:t,sources:e?[e]:null,scale:this.scale});this.addHandles([a(()=>this.viewModel,e=>{this._viewModelHandlesGroup=l(this._viewModelHandlesGroup),e&&(this._viewModelHandlesGroup=i([e.on("create",()=>this.scheduleRender()),e.on("update",()=>this.scheduleRender()),e.on("delete",e=>this.emit("delete",e)),e.on("undo",()=>this.scheduleRender()),e.on("redo",()=>this.scheduleRender()),a(()=>e.layer,e=>{this._selectionToolbar&&(this._selectionToolbar.sources=e?[e]:null)}),a(()=>e.view,e=>{this._selectionToolbar&&(this._selectionToolbar.view=e)}),a(()=>e.state,()=>this.notifyChange("state"))]))},c),p(()=>s.activeOperation,()=>this.viewModel.cancel()),s.on("complete",e=>this._onSelectionOperationComplete(e)),a(()=>{const{view:e,visibleElements:{selectionTools:t}}=this;return{lassoTool:"3d"!==e?.type&&!!t?.["lasso-selection"],rectangleTool:"3d"!==e?.type&&!!t?.["rectangle-selection"]}},e=>{Object.assign(s.visibleElements,e)},c)]),this._selectionToolbar=s}loadDependencies(){return _({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._selectionToolbar?.destroy(),this._viewModelHandlesGroup=l(this._viewModelHandlesGroup)}get activeTool(){const e=this._selectionToolbar?.activeOperation;if(e)switch(e.toolName){case"lasso":return"lasso-selection";case"rectangle":return"rectangle-selection";case"default":return"custom-selection"}const t=this._effectiveAvailableCreateTools,{activeTool:o,activeCreateToolDrawMode:i}=this.viewModel;return"polygon"===o&&"freehand"===i&&t?.includes("freehandPolygon")?"freehandPolygon":"polyline"===o&&"freehand"===i&&t?.includes("freehandPolyline")?"freehandPolyline":this.viewModel.activeTool}get activeTooltip(){return this.viewModel.activeTooltip}get createGraphic(){return this.viewModel.createGraphic}get creationMode(){return this.viewModel.creationMode}set creationMode(e){this.viewModel.creationMode=e}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultUpdateOptions(){return this.viewModel.defaultUpdateOptions}set defaultUpdateOptions(e){this.viewModel.defaultUpdateOptions=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}set layout(e){this._set("layout",e),this._selectionToolbar&&(this._selectionToolbar.layout=e)}set scale(e){this._set("scale",e),this._selectionToolbar&&(this._selectionToolbar.scale=e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get state(){return this._selectionToolbar?.activeOperation?"active":this.viewModel.state}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get updateGraphics(){return this.viewModel.updateGraphics}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){const t=this._get("viewModel");e!==t&&(t&&t===this._defaultViewModel&&n(t),this._set("viewModel",e))}get _effectiveAvailableCreateTools(){const{availableCreateTools:e,view:t,visibleElements:o}=this,i=e?.filter(e=>!!o.createTools?.[e]);return"3d"===t?.type?i?.filter(e=>"multipoint"!==e):i}create(e,t,o){const i=o?.createOptions??t;return this._activeCustomToolOptions=o,r(this.viewModel.create(e,i))}update(e,t){return r(this.viewModel.update(e,t))}complete(){this.viewModel.complete()}cancel(){this._selectionToolbar?.cancel(),this.viewModel.cancel(),this._activeCustomToolOptions=null}undo(){this.viewModel.undo(),this.view?.focus()}redo(){this.viewModel.redo(),this.view?.focus()}delete(){this.viewModel.delete()}duplicate(){return this.viewModel.duplicate()}dismissFloatingElements(){this._popoverOpen=!1}render(){const{toolbarKind:e,layout:t,scale:o}=this,i=this.customActions?.filter(e=>"selection-toolbar"===e.position);return T("div",null,T("div",{classes:{[P.base]:!0,[P.floating]:"floating"===e,[P.docked]:"docked"===e,[P.vertical]:"vertical"===t}},T(f,{barStyle:e,layout:t,scale:o},this._renderSelectionSetItemGroupInline(),T("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionTools")??!0,"group-kind":"split-button",key:"selection-split-button",priority:this.groupCollapsePriorities?.get("selectionTools")??0},this._renderDefaultSelectionButton(),this._selectionToolbar?.render(),i?.map(e=>this._renderToolbarItem(e))),this._renderCreateToolActionGroup(),this._renderUndoRedoMenuItemGroup(),this._renderSettingsMenuItemGroup()),this._renderSelectionSetToolbar(),this._renderSettingsMenuPopover()))}_renderSettingsMenuPopover(){const{messagesCommon:e,snappingOptions:t,view:o,viewModel:i,visibleElements:s}=this;if(!this._calcitePopoverReferenceElement)return;const l={directionModePicker:s.directionModePicker,labelsToggle:s.labelsToggle,tooltipsToggle:s.tooltipsToggle},n="horizontal"===this.layout?"top"===this._relativeLocation?"bottom-end":"top-end":"right-end";return T("calcite-popover",{afterCreate:e=>this._popoverElement=e,closable:!0,heading:e.settings,label:e.settings,open:this._popoverOpen,overlayPositioning:"fixed",placement:n,referenceElement:this._calcitePopoverReferenceElement,scale:this.scale,onCalcitePopoverBeforeClose:e=>this._beforePopoverClose(e.target),onCalcitePopoverBeforeOpen:e=>this._remeasurePopoverSizes(e.currentTarget),onCalcitePopoverClose:e=>this._refocusOnView(e.target)},T("div",{class:P.popoverWrapper},Object.values(l).includes(!0)?T(b,{sketchOptions:i.sketchOptions,visibleElements:new S(l)}):void 0,s.snappingControls&&o&&t?T(w,{snappingManager:this.viewModel.snappingManager,snappingOptions:t,view:o,visibleElements:s.snappingControlsElements}):void 0))}_beforePopoverClose(e){e===this._popoverElement&&(this._popoverOpen=!1)}_renderSelectionSetToolbar(){if("separate"!==this.contextualToolLocation)return;const e=this._renderSelectionSetItemGroup();return e?.length?T(f,{barStyle:this.toolbarKind,layout:this.layout,scale:this.scale},e):void 0}_renderSelectionSetItemGroupInline(){return"separate"===this.contextualToolLocation?[]:this._renderSelectionSetItemGroup()}_renderUndoRedoMenuItemGroup(){return T("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("undoRedo")??!0,"group-kind":"split-button",key:"undo-redo-menu",priority:this.groupCollapsePriorities?.get("undoRedo")??10,slot:"actions-end"},this._renderUndoButton(),this._renderRedoButton())}_renderSettingsMenuItemGroup(){const e=[],t=[];this.customActions?.forEach(o=>{"settings-before"===o.position?t.push(o):"settings-after"===o.position&&e.push(o)});const i=[...t.map(e=>this._renderToolbarItem(e)),this._renderSettingsMenuButton(),...e.map(e=>this._renderToolbarItem(e))].filter(o);if(i.length)return T("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("settings")??!1,"group-kind":"overflow-group",key:"settings-menu",priority:this.groupCollapsePriorities?.get("settings")??1e3,slot:"actions-end"},i)}_renderSelectionSetItemGroup(){if(!this.updateGraphics.length)return[];const e="inline-end"===this.contextualToolLocation?"actions-end":void 0,t=this.customActions?.filter(e=>"before-selection-set"===e.position),o=this.customActions?.filter(e=>"after-selection-set"===e.position),i=this.groupCollapsePriorities?.get("selectionSet")??100;return[T("div",{"group-kind":"measured-content",key:"selection-count-chip-group",priority:i,slot:e},this._renderFeatureCountChip()),T("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionSet")??!1,"group-kind":"overflow-group",key:"selection-set-tool-group",priority:i,slot:e},t?.map(e=>this._renderToolbarItem(e)),this._renderDuplicateButton(),this._renderDeleteButton(),o?.map(e=>this._renderToolbarItem(e)))]}_renderDefaultSelectionButton(){if(!this.viewModel.updateOnGraphicClick)return[];const{messages:e,state:t}=this;return this._renderToolbarItem({id:"pointer-select",text:e.selectFeature,icon:"cursor",onclick:this._activateDefaultSelectTool,active:"ready"===t})}_renderCreateToolActionGroup(){const e=this._effectiveAvailableCreateTools?.flatMap(e=>this._renderBuiltInCreateToolItem(e))??[],t=this.customToolOptions?.flatMap(e=>this._renderCustomToolItem(e))??[];return T("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("createTools")??!0,"group-kind":"overflow-group",key:"create-tools-group",priority:this.groupCollapsePriorities?.get("createTools")??100},e,t)}_renderBuiltInCreateToolItem(e){return this._renderToolbarItem({id:`${e}-button`,text:this.messages.draw[e],icon:E[e],onclick:()=>this._activateCreateTool(e),active:this.activeTool===e&&!this._activeCustomToolOptions})}_renderCustomToolItem(e){const{toolKey:t}=e;return this._renderToolbarItem({id:`custom-${e.toolKey}`,text:e.label,icon:e.icon,onclick:()=>this._activateCreateTool(e.toolName,null,e),active:this._activeCustomToolOptions?.toolKey===t})}_renderUndoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"undo-button",text:this.messages.undo,icon:"undo",disabled:!this.viewModel.canUndo(),onclick:this.undo,flipRTL:!0}):[]}_renderRedoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"redo-button",text:this.messages.redo,icon:"redo",disabled:!this.viewModel.canRedo(),onclick:this.redo,flipRTL:!0}):[]}_renderSettingsMenuButton(){return this.visibleElements.settingsMenu?this._renderToolbarItem({id:"settings-menu-action",text:this.messagesCommon.settings,icon:"gear",active:this._popoverOpen,onclick:()=>this._popoverOpen=!this._popoverOpen,afterCreate:e=>this._calcitePopoverReferenceElement=e,afterUpdate:e=>this._calcitePopoverReferenceElement=e,afterRemoved:()=>this._calcitePopoverReferenceElement=null}):[]}_renderFeatureCountChip(){if(!this.visibleElements.selectionCountLabel)return[];const{layout:e,messages:o,scale:i,id:s,updateGraphics:{length:l}}=this,n=t(o.selectedCount,{count:l}),r="s"===i?99:999,a=l>r?t(o.selectedCountTruncated,{truncated:r}):l,p="s"===i&&"vertical"===e,c=p?`${s}-selection-chip-small`:`${s}-selection-chip`;return[p?T("span",{classes:{[P.chipVertical]:!0,[P.chipVerticalSmall]:"s"===this.scale},id:c,tabIndex:0,title:n},a):T("calcite-chip",{appearance:"outline",class:"horizontal"===e?P.chipHorizontal:P.chipVertical,id:c,kind:"brand",label:n,scale:"l"===i?"m":"s",tabIndex:0,title:"vertical"===e?n:void 0},"vertical"===e?a:n)]}_renderDuplicateButton(){if(!this.visibleElements.duplicateButton)return[];const{messages:e}=this;return this._renderToolbarItem({id:"duplicate",text:this.updateGraphics.length>1?e.duplicateFeatures:e.duplicateFeature,icon:"copy",onclick:this._onDuplicateSelect})}_renderDeleteButton(){if(!this.visibleElements.deleteButton)return[];const{messages:e}=this,t=this.updateGraphics.length>1?e.deleteFeatures:e.deleteFeature;return this._renderToolbarItem({id:"delete",text:t,icon:"trash",onclick:this.delete})}_renderToolbarItem({id:e,text:t,icon:o,disabled:i,onclick:s,active:l,flipRTL:n,afterCreate:r,afterUpdate:a,afterRemoved:p}){const c=`${this.id}-${e}`;return[T("calcite-action",{active:l,afterCreate:r,afterRemoved:p,afterUpdate:a,bind:this,"data-testid":e,disabled:i||"disabled"===this.state,icon:o,iconFlipRtl:n??!1,id:c,key:e,onclick:s,scale:this.scale,text:t,title:t})]}_remeasurePopoverSizes(e){try{const t=e.parentElement,o=this?.view?.container?.getBoundingClientRect(),i=t?.style;if(!(t&&o&&i&&this.view?.container?.contains(t)))return;const s=this._calcitePopoverReferenceElement;if(!s)return;const{bottom:l,top:n}=s.getBoundingClientRect();if("horizontal"===this.layout){const e=l<o.height/2;e!==("top"===this._relativeLocation)&&(this._relativeLocation=e?"top":"bottom"),e?(i?.setProperty("--sketch-view-height-offset",l-o.top+"px"),i?.setProperty("--sketch-view-margin-offset","30px")):(i?.setProperty("--sketch-view-height-offset",o.bottom-n+"px"),i?.setProperty("--sketch-view-margin-offset","15px"))}else"vertical"===this.layout&&(i.setProperty("--sketch-view-height-offset","15px"),i.setProperty("--sketch-view-margin-offset","15px"));const r=e.shadowRoot?.querySelector("div.header")?.getBoundingClientRect().height;i.setProperty("--sketch-popover-header-offset",`${r}px`)}catch(t){s.getLogger(this.declaredClass).warnOnce("Sketch failed to lay out settings menu.",t)}}_activateCreateTool(e,t,o){const i=this._activeCustomToolOptions;if(o||i){if(o?.toolKey===i?.toolKey)return void this.cancel()}else if(this.activeTool===e)return void this.cancel();this._selectionToolbar?.cancel(),this.create(e,t,o)}_onDuplicateSelect(){const e=this.duplicate(),t=this.viewModel.activeTool;"transform"!==t&&"reshape"!==t||this.update(e,{tool:t})}_onSelectionOperationComplete(e){const{viewModel:{defaultUpdateOptions:t}}=this,{selection:o}=e;if(!e.aborted&&o.length){const e=t.tool,i=o.length>1&&"reshape"===e?"transform":e;this.update(o,{...t,tool:i})}this.notifyChange("state")}_activateDefaultSelectTool(){this.cancel(),this.view?.focus()}_refocusOnView(e){this.activeTool&&e===this._popoverElement&&this.view?.focus()}};e([d()],I.prototype,"activeTool",null),e([d({readOnly:!0})],I.prototype,"activeTooltip",null),e([d({cast:e=>{if(!e?.length)return null;const t=new Set(["point","polyline","polygon","rectangle","circle","multipoint","freehandPolyline","freehandPolygon","mesh","text"]);return e.filter(e=>t.has(e))}})],I.prototype,"availableCreateTools",void 0),e([d({readOnly:!0})],I.prototype,"createGraphic",null),e([d()],I.prototype,"creationMode",null),e([d()],I.prototype,"customToolOptions",void 0),e([d()],I.prototype,"customActions",void 0),e([d()],I.prototype,"defaultCreateOptions",null),e([d()],I.prototype,"defaultUpdateOptions",null),e([d()],I.prototype,"icon",null),e([d()],I.prototype,"label",null),e([d()],I.prototype,"labelOptions",null),e([d()],I.prototype,"layer",null),e([d({type:["horizontal","vertical"],value:"horizontal"})],I.prototype,"layout",null),e([d({value:"m"})],I.prototype,"scale",null),e([d()],I.prototype,"toolbarKind",void 0),e([d()],I.prototype,"contextualToolLocation",void 0),e([d()],I.prototype,"groupCollapsePriorities",void 0),e([d()],I.prototype,"groupAllowCollapseOptions",void 0),e([d(),M("esri/widgets/Sketch/t9n/Sketch")],I.prototype,"messages",void 0),e([d(),M("esri/t9n/common")],I.prototype,"messagesCommon",void 0),e([d()],I.prototype,"snappingOptions",null),e([d()],I.prototype,"state",null),e([d()],I.prototype,"tooltipOptions",null),e([d({readOnly:!0})],I.prototype,"updateGraphics",null),e([d({type:u,nonNullable:!0})],I.prototype,"valueOptions",null),e([d()],I.prototype,"view",null),e([d({type:m}),C(["create","update","undo","redo"])],I.prototype,"viewModel",null),e([d({type:g,nonNullable:!0})],I.prototype,"visibleElements",void 0),e([d()],I.prototype,"_effectiveAvailableCreateTools",null),e([d()],I.prototype,"_defaultViewModel",void 0),e([d()],I.prototype,"_activeCustomToolOptions",void 0),e([d()],I.prototype,"_calcitePopoverReferenceElement",void 0),e([d()],I.prototype,"_relativeLocation",void 0),e([d()],I.prototype,"_popoverOpen",void 0),I=e([h("esri.widgets.Sketch")],I);const R=I;export{R as default};
5
+ import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{isSome as o}from"../core/arrayUtils.js";import{handlesGroup as i}from"../core/handleUtils.js";import l from"../core/Logger.js";import{removeMaybe as s,destroyMaybe as n}from"../core/maybe.js";import{ignoreAbortErrors as r}from"../core/promiseUtils.js";import{watch as a,when as p,syncAndInitial as c}from"../core/reactiveUtils.js";import{property as d,subclass as h}from"../core/accessorSupport/decorators.js";import{symbolTypes as u}from"../symbols/support/typeUtils.js";import v from"../views/interactive/sketch/SketchLabelOptions.js";import m from"../views/interactive/sketch/SketchTooltipOptions.js";import g from"../views/interactive/sketch/SketchValueOptions.js";import y from"./Widget.js";import f from"./Sketch/SketchViewModel.js";import{VisibleElements as b}from"./Sketch/VisibleElements.js";import _ from"./Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js";import{loadCalciteComponents as w}from"./support/componentsUtils.js";import T from"./support/SelectionToolbar.js";import M from"./support/SketchTooltipControls.js";import C from"./support/SnappingControls.js";import{tsx as O,messageBundle as S,vmEvent as k}from"./support/widget.js";import P from"./support/SelectionToolbar/VisibleElements.js";import x from"./support/SketchTooltipControls/VisibleElements.js";const E="esri-sketch",I={base:E,vertical:`${E}--vertical`,docked:`${E}-bar`,floating:`${E}-pad`,chipHorizontal:`${E}__selection-count-chip--horizontal`,chipVertical:`${E}__selection-count-chip--vertical`,chipVerticalSmall:`${E}__selection-count-chip--vertical--s`,popoverWrapper:`${E}__popover-wrapper`},R={point:"pin",polyline:"line",polygon:"polygon",rectangle:"rectangle",circle:"circle",multipoint:"pins",mesh:"i3d-building",freehandPolygon:"freehand-area",freehandPolyline:"freehand",text:"add-text"};let G=class extends y{constructor(e,t){super(e,t),this._selectionToolbar=null,this._viewModelHandlesGroup=null,this._popoverElement=null,this.availableCreateTools=["point","polyline","polygon","rectangle","circle"],this.customToolOptions=null,this.customActions=null,this.toolbarKind="floating",this.contextualToolLocation="separate",this.groupCollapsePriorities=null,this.groupAllowCollapseOptions=null,this.messages=null,this.messagesCommon=null,this.visibleElements=new b,this._defaultViewModel=null,this._activeCustomToolOptions=null,this._calcitePopoverReferenceElement=null,this._relativeLocation="top",this._popoverOpen=!1,this._activateCreateTool=this._activateCreateTool.bind(this),this.viewModel=e?.viewModel||(this._defaultViewModel=new f({creationMode:e?.creationMode??"continuous"}))}initialize(){const{layer:e,view:t}=this,o="2d"===t?.type,l=new T({persistSelection:!1,visibleElements:new P({chip:!1,lassoTool:o,operationTypeControls:!1,pan:!1,pointTool:!1,rectangleTool:o}),view:t,sources:e?[e]:null,scale:this.scale});this.addHandles([a(()=>this.viewModel,e=>{this._viewModelHandlesGroup=s(this._viewModelHandlesGroup),e&&(this._viewModelHandlesGroup=i([e.on("create",()=>this.scheduleRender()),e.on("update",()=>this.scheduleRender()),e.on("delete",e=>this.emit("delete",e)),e.on("undo",()=>this.scheduleRender()),e.on("redo",()=>this.scheduleRender()),a(()=>e.layer,e=>{this._selectionToolbar&&(this._selectionToolbar.sources=e?[e]:null)}),a(()=>e.view,e=>{this._selectionToolbar&&(this._selectionToolbar.view=e)}),a(()=>e.state,()=>this.notifyChange("state"))]))},c),p(()=>l.activeOperation,()=>this.viewModel.cancel()),l.on("complete",e=>this._onSelectionOperationComplete(e)),a(()=>{const{view:e,visibleElements:{selectionTools:t}}=this;return{lassoTool:"3d"!==e?.type&&!!t?.["lasso-selection"],rectangleTool:"3d"!==e?.type&&!!t?.["rectangle-selection"]}},e=>{Object.assign(l.visibleElements,e)},c)]),this._selectionToolbar=l}loadDependencies(){return w({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._selectionToolbar?.destroy(),this._viewModelHandlesGroup=s(this._viewModelHandlesGroup)}get activeTool(){const e=this._selectionToolbar?.activeOperation;if(e)switch(e.toolName){case"lasso":return"lasso-selection";case"rectangle":return"rectangle-selection";case"default":return"custom-selection"}const t=this._effectiveAvailableCreateTools,{activeTool:o,activeCreateToolDrawMode:i}=this.viewModel;return"polygon"===o&&"freehand"===i&&t?.includes("freehandPolygon")?"freehandPolygon":"polyline"===o&&"freehand"===i&&t?.includes("freehandPolyline")?"freehandPolyline":this.viewModel.activeTool}get activeTooltip(){return this.viewModel.activeTooltip}get createGraphic(){return this.viewModel.createGraphic}get creationMode(){return this.viewModel.creationMode}set creationMode(e){this.viewModel.creationMode=e}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultUpdateOptions(){return this.viewModel.defaultUpdateOptions}set defaultUpdateOptions(e){this.viewModel.defaultUpdateOptions=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}set layout(e){this._set("layout",e),this._selectionToolbar&&(this._selectionToolbar.layout=e)}get pointSymbol(){return this.viewModel.pointSymbol}set pointSymbol(e){this.viewModel.pointSymbol=e}get polygonSymbol(){return this.viewModel.polygonSymbol}set polygonSymbol(e){this.viewModel.polygonSymbol=e}get polylineSymbol(){return this.viewModel.polylineSymbol}set polylineSymbol(e){this.viewModel.polylineSymbol=e}get textSymbol(){return this.viewModel.textSymbol}set textSymbol(e){this.viewModel.textSymbol=e}set scale(e){this._set("scale",e),this._selectionToolbar&&(this._selectionToolbar.scale=e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get state(){return this._selectionToolbar?.activeOperation?"active":this.viewModel.state}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get updateGraphics(){return this.viewModel.updateGraphics}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){const t=this._get("viewModel");e!==t&&(t&&t===this._defaultViewModel&&n(t),this._set("viewModel",e))}get _effectiveAvailableCreateTools(){const{availableCreateTools:e,view:t,visibleElements:o}=this,i=e?.filter(e=>!!o.createTools?.[e]);return"3d"===t?.type?i?.filter(e=>"multipoint"!==e):i}create(e,t,o){const i=o?.createOptions??t;return this._activeCustomToolOptions=o,r(this.viewModel.create(e,i))}update(e,t){return r(this.viewModel.update(e,t))}complete(){this.viewModel.complete()}cancel(){this._selectionToolbar?.cancel(),this.viewModel.cancel(),this._activeCustomToolOptions=null}undo(){this.viewModel.undo(),this.view?.focus()}redo(){this.viewModel.redo(),this.view?.focus()}delete(){this.viewModel.delete()}duplicate(){return this.viewModel.duplicate()}dismissFloatingElements(){this._popoverOpen=!1}render(){const{toolbarKind:e,layout:t,scale:o}=this,i=this.customActions?.filter(e=>"selection-toolbar"===e.position);return O("div",null,O("div",{classes:{[I.base]:!0,[I.floating]:"floating"===e,[I.docked]:"docked"===e,[I.vertical]:"vertical"===t}},O(_,{barStyle:e,layout:t,scale:o},this._renderSelectionSetItemGroupInline(),O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionTools")??!0,"group-kind":"split-button",key:"selection-split-button",priority:this.groupCollapsePriorities?.get("selectionTools")??0},this._renderDefaultSelectionButton(),this._selectionToolbar?.render(),i?.map(e=>this._renderToolbarItem(e))),this._renderCreateToolActionGroup(),this._renderUndoRedoMenuItemGroup(),this._renderSettingsMenuItemGroup()),this._renderSelectionSetToolbar(),this._renderSettingsMenuPopover()))}_renderSettingsMenuPopover(){const{messagesCommon:e,snappingOptions:t,view:o,viewModel:i,visibleElements:l}=this;if(!this._calcitePopoverReferenceElement)return;const s={directionModePicker:l.directionModePicker,labelsToggle:l.labelsToggle,tooltipsToggle:l.tooltipsToggle},n="horizontal"===this.layout?"top"===this._relativeLocation?"bottom-end":"top-end":"right-end";return O("calcite-popover",{afterCreate:e=>this._popoverElement=e,closable:!0,heading:e.settings,label:e.settings,open:this._popoverOpen,overlayPositioning:"fixed",placement:n,referenceElement:this._calcitePopoverReferenceElement,scale:this.scale,onCalcitePopoverBeforeClose:e=>this._beforePopoverClose(e.target),onCalcitePopoverBeforeOpen:e=>this._remeasurePopoverSizes(e.currentTarget),onCalcitePopoverClose:e=>this._refocusOnView(e.target)},O("div",{class:I.popoverWrapper},Object.values(s).includes(!0)?O(M,{sketchOptions:i.sketchOptions,visibleElements:new x(s)}):void 0,l.snappingControls&&o&&t?O(C,{snappingManager:this.viewModel.snappingManager,snappingOptions:t,view:o,visibleElements:l.snappingControlsElements}):void 0))}_beforePopoverClose(e){e===this._popoverElement&&(this._popoverOpen=!1)}_renderSelectionSetToolbar(){if("separate"!==this.contextualToolLocation)return;const e=this._renderSelectionSetItemGroup();return e?.length?O(_,{barStyle:this.toolbarKind,layout:this.layout,scale:this.scale},e):void 0}_renderSelectionSetItemGroupInline(){return"separate"===this.contextualToolLocation?[]:this._renderSelectionSetItemGroup()}_renderUndoRedoMenuItemGroup(){return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("undoRedo")??!0,"group-kind":"split-button",key:"undo-redo-menu",priority:this.groupCollapsePriorities?.get("undoRedo")??10,slot:"actions-end"},this._renderUndoButton(),this._renderRedoButton())}_renderSettingsMenuItemGroup(){const e=[],t=[];this.customActions?.forEach(o=>{"settings-before"===o.position?t.push(o):"settings-after"===o.position&&e.push(o)});const i=[...t.map(e=>this._renderToolbarItem(e)),this._renderSettingsMenuButton(),...e.map(e=>this._renderToolbarItem(e))].filter(o);if(i.length)return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("settings")??!1,"group-kind":"overflow-group",key:"settings-menu",priority:this.groupCollapsePriorities?.get("settings")??1e3,slot:"actions-end"},i)}_renderSelectionSetItemGroup(){if(!this.updateGraphics.length)return[];const e="inline-end"===this.contextualToolLocation?"actions-end":void 0,t=this.customActions?.filter(e=>"before-selection-set"===e.position),o=this.customActions?.filter(e=>"after-selection-set"===e.position),i=this.groupCollapsePriorities?.get("selectionSet")??100;return[O("div",{"group-kind":"measured-content",key:"selection-count-chip-group",priority:i,slot:e},this._renderFeatureCountChip()),O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionSet")??!1,"group-kind":"overflow-group",key:"selection-set-tool-group",priority:i,slot:e},t?.map(e=>this._renderToolbarItem(e)),this._renderDuplicateButton(),this._renderDeleteButton(),o?.map(e=>this._renderToolbarItem(e)))]}_renderDefaultSelectionButton(){if(!this.viewModel.updateOnGraphicClick)return[];const{messages:e,state:t}=this;return this._renderToolbarItem({id:"pointer-select",text:e.selectFeature,icon:"cursor",onclick:this._activateDefaultSelectTool,active:"ready"===t})}_renderCreateToolActionGroup(){const e=this._effectiveAvailableCreateTools?.flatMap(e=>this._renderBuiltInCreateToolItem(e))??[],t=this.customToolOptions?.flatMap(e=>this._renderCustomToolItem(e))??[];return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("createTools")??!0,"group-kind":"overflow-group",key:"create-tools-group",priority:this.groupCollapsePriorities?.get("createTools")??100},e,t)}_renderBuiltInCreateToolItem(e){return this._renderToolbarItem({id:`${e}-button`,text:this.messages.draw[e],icon:R[e],onclick:()=>this._activateCreateTool(e),active:this.activeTool===e&&!this._activeCustomToolOptions})}_renderCustomToolItem(e){const{toolKey:t}=e;return this._renderToolbarItem({id:`custom-${e.toolKey}`,text:e.label,icon:e.icon,onclick:()=>this._activateCreateTool(e.toolName,null,e),active:this._activeCustomToolOptions?.toolKey===t})}_renderUndoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"undo-button",text:this.messages.undo,icon:"undo",disabled:!this.viewModel.canUndo(),onclick:this.undo,flipRTL:!0}):[]}_renderRedoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"redo-button",text:this.messages.redo,icon:"redo",disabled:!this.viewModel.canRedo(),onclick:this.redo,flipRTL:!0}):[]}_renderSettingsMenuButton(){return this.visibleElements.settingsMenu?this._renderToolbarItem({id:"settings-menu-action",text:this.messagesCommon.settings,icon:"gear",active:this._popoverOpen,onclick:()=>this._popoverOpen=!this._popoverOpen,afterCreate:e=>this._calcitePopoverReferenceElement=e,afterUpdate:e=>this._calcitePopoverReferenceElement=e,afterRemoved:()=>this._calcitePopoverReferenceElement=null}):[]}_renderFeatureCountChip(){if(!this.visibleElements.selectionCountLabel)return[];const{layout:e,messages:o,scale:i,id:l,updateGraphics:{length:s}}=this,n=t(o.selectedCount,{count:s}),r="s"===i?99:999,a=s>r?t(o.selectedCountTruncated,{truncated:r}):s,p="s"===i&&"vertical"===e,c=p?`${l}-selection-chip-small`:`${l}-selection-chip`;return[p?O("span",{classes:{[I.chipVertical]:!0,[I.chipVerticalSmall]:"s"===this.scale},id:c,tabIndex:0,title:n},a):O("calcite-chip",{appearance:"outline",class:"horizontal"===e?I.chipHorizontal:I.chipVertical,id:c,kind:"brand",label:n,scale:"l"===i?"m":"s",tabIndex:0,title:"vertical"===e?n:void 0},"vertical"===e?a:n)]}_renderDuplicateButton(){if(!this.visibleElements.duplicateButton)return[];const{messages:e}=this;return this._renderToolbarItem({id:"duplicate",text:this.updateGraphics.length>1?e.duplicateFeatures:e.duplicateFeature,icon:"copy",onclick:this._onDuplicateSelect})}_renderDeleteButton(){if(!this.visibleElements.deleteButton)return[];const{messages:e}=this,t=this.updateGraphics.length>1?e.deleteFeatures:e.deleteFeature;return this._renderToolbarItem({id:"delete",text:t,icon:"trash",onclick:this.delete})}_renderToolbarItem({id:e,text:t,icon:o,disabled:i,onclick:l,active:s,flipRTL:n,afterCreate:r,afterUpdate:a,afterRemoved:p}){const c=`${this.id}-${e}`;return[O("calcite-action",{active:s,afterCreate:r,afterRemoved:p,afterUpdate:a,bind:this,"data-testid":e,disabled:i||"disabled"===this.state,icon:o,iconFlipRtl:n??!1,id:c,key:e,onclick:l,scale:this.scale,text:t,title:t})]}_remeasurePopoverSizes(e){try{const t=e.parentElement,o=this?.view?.container?.getBoundingClientRect(),i=t?.style;if(!(t&&o&&i&&this.view?.container?.contains(t)))return;const l=this._calcitePopoverReferenceElement;if(!l)return;const{bottom:s,top:n}=l.getBoundingClientRect();if("horizontal"===this.layout){const e=s<o.height/2;e!==("top"===this._relativeLocation)&&(this._relativeLocation=e?"top":"bottom"),e?(i?.setProperty("--sketch-view-height-offset",s-o.top+"px"),i?.setProperty("--sketch-view-margin-offset","30px")):(i?.setProperty("--sketch-view-height-offset",o.bottom-n+"px"),i?.setProperty("--sketch-view-margin-offset","15px"))}else"vertical"===this.layout&&(i.setProperty("--sketch-view-height-offset","15px"),i.setProperty("--sketch-view-margin-offset","15px"));const r=e.shadowRoot?.querySelector("div.header")?.getBoundingClientRect().height;i.setProperty("--sketch-popover-header-offset",`${r}px`)}catch(t){l.getLogger(this.declaredClass).warnOnce("Sketch failed to lay out settings menu.",t)}}_activateCreateTool(e,t,o){const i=this._activeCustomToolOptions;if(o||i){if(o?.toolKey===i?.toolKey)return void this.cancel()}else if(this.activeTool===e)return void this.cancel();this._selectionToolbar?.cancel(),this.create(e,t,o)}_onDuplicateSelect(){const e=this.duplicate(),t=this.viewModel.activeTool;"transform"!==t&&"reshape"!==t||this.update(e,{tool:t})}_onSelectionOperationComplete(e){const{viewModel:{defaultUpdateOptions:t}}=this,{selection:o}=e;if(!e.aborted&&o.length){const e=t.tool,i=o.length>1&&"reshape"===e?"transform":e;this.update(o,{...t,tool:i})}this.notifyChange("state")}_activateDefaultSelectTool(){this.cancel(),this.view?.focus()}_refocusOnView(e){this.activeTool&&e===this._popoverElement&&this.view?.focus()}};e([d()],G.prototype,"activeTool",null),e([d({readOnly:!0})],G.prototype,"activeTooltip",null),e([d({cast:e=>{if(!e?.length)return null;const t=new Set(["point","polyline","polygon","rectangle","circle","multipoint","freehandPolyline","freehandPolygon","mesh","text"]);return e.filter(e=>t.has(e))}})],G.prototype,"availableCreateTools",void 0),e([d({readOnly:!0})],G.prototype,"createGraphic",null),e([d()],G.prototype,"creationMode",null),e([d()],G.prototype,"customToolOptions",void 0),e([d()],G.prototype,"customActions",void 0),e([d()],G.prototype,"defaultCreateOptions",null),e([d()],G.prototype,"defaultUpdateOptions",null),e([d()],G.prototype,"icon",null),e([d()],G.prototype,"label",null),e([d({type:v})],G.prototype,"labelOptions",null),e([d()],G.prototype,"layer",null),e([d({type:["horizontal","vertical"],value:"horizontal"})],G.prototype,"layout",null),e([d({types:u})],G.prototype,"pointSymbol",null),e([d({types:u})],G.prototype,"polygonSymbol",null),e([d({types:u})],G.prototype,"polylineSymbol",null),e([d()],G.prototype,"textSymbol",null),e([d({value:"m"})],G.prototype,"scale",null),e([d()],G.prototype,"toolbarKind",void 0),e([d()],G.prototype,"contextualToolLocation",void 0),e([d()],G.prototype,"groupCollapsePriorities",void 0),e([d()],G.prototype,"groupAllowCollapseOptions",void 0),e([d(),S("esri/widgets/Sketch/t9n/Sketch")],G.prototype,"messages",void 0),e([d(),S("esri/t9n/common")],G.prototype,"messagesCommon",void 0),e([d()],G.prototype,"snappingOptions",null),e([d()],G.prototype,"state",null),e([d({type:m})],G.prototype,"tooltipOptions",null),e([d({readOnly:!0})],G.prototype,"updateGraphics",null),e([d({type:g,nonNullable:!0})],G.prototype,"valueOptions",null),e([d()],G.prototype,"view",null),e([d({type:f}),k(["create","update","undo","redo"])],G.prototype,"viewModel",null),e([d({type:b,nonNullable:!0})],G.prototype,"visibleElements",void 0),e([d()],G.prototype,"_effectiveAvailableCreateTools",null),e([d()],G.prototype,"_defaultViewModel",void 0),e([d()],G.prototype,"_activeCustomToolOptions",void 0),e([d()],G.prototype,"_calcitePopoverReferenceElement",void 0),e([d()],G.prototype,"_relativeLocation",void 0),e([d()],G.prototype,"_popoverOpen",void 0),G=e([h("esri.widgets.Sketch")],G);const j=G;export{j as default};