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

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 (329) 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/bf5f9da0837ed09729c6.js +316 -0
  18. package/assets/esri/core/workers/chunks/{385cfd3087f00dbd1146.js → ca1c65eb7f5900c60170.js} +1 -1
  19. package/assets/esri/core/workers/chunks/cddce67919e13e2f365e.js +1 -0
  20. package/assets/esri/core/workers/chunks/{7c08c0824ad354177787.js → d7878fba02814adaf19f.js} +1 -1
  21. package/assets/esri/core/workers/chunks/e6784251bbb8b71ead93.js +1 -0
  22. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  23. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  24. package/chunks/GaussianSplat.glsl.js +2 -2
  25. package/config.js +1 -1
  26. package/core/urlUtils.d.ts +1 -0
  27. package/core/workers/workerFactory.js +1 -1
  28. package/interfaces.d.ts +104 -9
  29. package/kernel.js +1 -1
  30. package/layers/ImageryTileLayer.js +1 -1
  31. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  32. package/layers/WCSLayer.js +1 -1
  33. package/layers/mixins/ArcGISImageService.js +1 -1
  34. package/layers/mixins/ImageryTileMixin.js +1 -1
  35. package/layers/mixins/RasterJobHandlerMixin.js +1 -1
  36. package/layers/ogc/wcsUtils.js +1 -1
  37. package/layers/raster/datasets/BaseRaster.js +5 -0
  38. package/layers/raster/datasets/CovJSONRaster.js +5 -0
  39. package/layers/raster/datasets/FunctionRaster.js +5 -0
  40. package/layers/raster/datasets/ImageAuxRaster.js +5 -0
  41. package/layers/raster/datasets/ImageServerRaster.js +5 -0
  42. package/layers/raster/datasets/InMemoryRaster.js +5 -0
  43. package/layers/raster/datasets/MRFRaster.js +5 -0
  44. package/layers/raster/datasets/RawBlockCache.js +5 -0
  45. package/layers/raster/datasets/TIFFRaster.js +5 -0
  46. package/layers/raster/datasets/WCSRaster.js +5 -0
  47. package/layers/raster/datasets/covJSONParser.js +5 -0
  48. package/layers/raster/datasets/multidimensionalUtils.js +5 -0
  49. package/layers/raster/datasets/pamParser.js +5 -0
  50. package/layers/raster/datasets/pixelReader.js +5 -0
  51. package/layers/raster/datasets/wcsCoverageParser.js +5 -0
  52. package/layers/raster/formats/Lerc.js +5 -0
  53. package/layers/raster/formats/Qb3.js +5 -0
  54. package/layers/raster/formats/RasterCodec.js +5 -0
  55. package/layers/raster/formats/TiffDecoder.js +5 -0
  56. package/layers/raster/functions/ArithmeticFunction.js +5 -0
  57. package/layers/{support/rasterFunctions → raster/functions}/ArithmeticFunctionArguments.js +1 -1
  58. package/layers/{support/rasterFunctions → raster/functions}/AspectFunction.js +1 -1
  59. package/layers/{support/rasterFunctions → raster/functions}/AspectFunctionArguments.js +1 -1
  60. package/layers/raster/functions/BandArithmeticFunction.js +5 -0
  61. package/layers/{support/rasterFunctions → raster/functions}/BandArithmeticFunctionArguments.js +1 -1
  62. package/layers/{support/rasterFunctions → raster/functions}/BaseFunctionArguments.js +1 -1
  63. package/layers/raster/functions/BaseRasterFunction.js +5 -0
  64. package/layers/{support/rasterFunctions → raster/functions}/ClipFunction.js +1 -1
  65. package/layers/{support/rasterFunctions → raster/functions}/ClipFunctionArguments.js +1 -1
  66. package/layers/raster/functions/ColormapFunction.js +5 -0
  67. package/layers/{support/rasterFunctions → raster/functions}/ColormapFunctionArguments.js +1 -1
  68. package/layers/raster/functions/ColormapToRGBFunction.js +5 -0
  69. package/layers/{support/rasterFunctions → raster/functions}/ColormapToRGBFunctionArguments.js +1 -1
  70. package/layers/raster/functions/CompositeBandFunction.js +5 -0
  71. package/layers/raster/functions/CompositeBandFunctionArguments.js +5 -0
  72. package/layers/raster/functions/ComputeChangeFunction.js +5 -0
  73. package/layers/{support/rasterFunctions → raster/functions}/ComputeChangeFunctionArguments.js +1 -1
  74. package/layers/{support/rasterFunctions → raster/functions}/ContrastBrightnessFunction.js +1 -1
  75. package/layers/{support/rasterFunctions → raster/functions}/ContrastBrightnessFunctionArguments.js +1 -1
  76. package/layers/raster/functions/ConvolutionFunction.js +5 -0
  77. package/layers/raster/functions/ConvolutionFunctionArguments.js +5 -0
  78. package/layers/{support/rasterFunctions → raster/functions}/CurvatureFunction.js +1 -1
  79. package/layers/{support/rasterFunctions → raster/functions}/CurvatureFunctionArguments.js +1 -1
  80. package/layers/{support/rasterFunctions → raster/functions}/ExtractBandFunction.js +1 -1
  81. package/layers/{support/rasterFunctions → raster/functions}/ExtractBandFunctionArguments.js +1 -1
  82. package/layers/{support/rasterFunctions → raster/functions}/GrayscaleFunction.js +1 -1
  83. package/layers/{support/rasterFunctions → raster/functions}/GrayscaleFunctionArguments.js +1 -1
  84. package/layers/raster/functions/HillshadeFunction.js +5 -0
  85. package/layers/{support/rasterFunctions → raster/functions}/HillshadeFunctionArguments.js +1 -1
  86. package/layers/raster/functions/LocalFunction.js +5 -0
  87. package/layers/{support/rasterFunctions → raster/functions}/LocalFunctionArguments.js +1 -1
  88. package/layers/{support/rasterFunctions → raster/functions}/MaskFunction.js +1 -1
  89. package/layers/{support/rasterFunctions → raster/functions}/MaskFunctionArguments.js +1 -1
  90. package/layers/{support/rasterFunctions → raster/functions}/NDVIFunction.js +1 -1
  91. package/layers/{support/rasterFunctions → raster/functions}/NDVIFunctionArguments.js +1 -1
  92. package/layers/raster/functions/RemapFunction.js +5 -0
  93. package/layers/{support/rasterFunctions → raster/functions}/RemapFunctionArguments.js +1 -1
  94. package/layers/raster/functions/ShadedReliefFunction.js +5 -0
  95. package/layers/{support/rasterFunctions → raster/functions}/ShadedReliefFunctionArguments.js +1 -1
  96. package/layers/raster/functions/SlopeFunction.js +5 -0
  97. package/layers/{support/rasterFunctions → raster/functions}/SlopeFunctionArguments.js +1 -1
  98. package/layers/raster/functions/StatisticsFunction.js +5 -0
  99. package/layers/{support/rasterFunctions → raster/functions}/StatisticsFunctionArguments.js +1 -1
  100. package/layers/{support/rasterFunctions → raster/functions}/StatisticsHistogramFunction.js +1 -1
  101. package/layers/{support/rasterFunctions → raster/functions}/StatisticsHistogramFunctionArguments.js +1 -1
  102. package/layers/raster/functions/StretchFunction.js +5 -0
  103. package/layers/{support/rasterFunctions → raster/functions}/StretchFunctionArguments.js +1 -1
  104. package/layers/{support/rasterFunctions → raster/functions}/TableFunction.js +1 -1
  105. package/layers/{support/rasterFunctions → raster/functions}/TableFunctionArguments.js +1 -1
  106. package/layers/raster/functions/bandIndexUtils.js +5 -0
  107. package/layers/raster/functions/changeDetectionUtils.js +5 -0
  108. package/layers/raster/functions/clipUtils.js +5 -0
  109. package/layers/raster/functions/conversionUtils.js +5 -0
  110. package/layers/raster/functions/convolutionUtils.js +5 -0
  111. package/layers/raster/functions/creators/createDataManagementFunctions.js +5 -0
  112. package/layers/raster/functions/creators/utils.js +5 -0
  113. package/layers/raster/functions/focalStatUtils.js +5 -0
  114. package/layers/raster/functions/localUtils.js +5 -0
  115. package/layers/raster/functions/pixelTransformUtils.js +5 -0
  116. package/layers/raster/functions/pixelUtils.js +5 -0
  117. package/layers/raster/functions/stretchUtils.js +5 -0
  118. package/layers/raster/functions/surfaceUtils.js +5 -0
  119. package/layers/raster/functions/vectorFieldUtils.js +5 -0
  120. package/layers/raster/transforms/BaseRasterTransform.js +5 -0
  121. package/layers/{support/rasterTransforms → raster/transforms}/GCSShiftTransform.js +1 -1
  122. package/layers/{support/rasterTransforms → raster/transforms}/IdentityTransform.js +1 -1
  123. package/layers/{support/rasterTransforms → raster/transforms}/PolynomialTransform.js +1 -1
  124. package/layers/save/imageryUtils.js +1 -1
  125. package/layers/support/PixelBlock.js +1 -1
  126. package/layers/support/RasterWorker.js +1 -1
  127. package/layers/support/imageryRendererUtils.js +1 -1
  128. package/layers/support/rasterFunctionUtils.js +1 -1
  129. package/package.json +2 -2
  130. package/renderers/VectorFieldRenderer.js +1 -1
  131. package/renderers/support/RasterSymbolizer.js +1 -1
  132. package/renderers/support/rasterRendererHelper.js +1 -1
  133. package/rest/locator/addressToLocations.js +1 -1
  134. package/rest/locator/addressesToLocations.js +1 -1
  135. package/rest/locator/suggestLocations.js +1 -1
  136. package/rest/networks/support/Association.js +1 -1
  137. package/rest/print.js +1 -1
  138. package/rest/support/LegendLayer.js +1 -1
  139. package/smartMapping/raster/support/adapters/ImageryLayerAdapter.js +1 -1
  140. package/smartMapping/raster/support/adapters/ImageryTileLayerAdapter.js +1 -1
  141. package/support/revision.js +1 -1
  142. package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
  143. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterRangeHighlightShader.js +1 -1
  144. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/MaskShader.js +1 -1
  145. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/RemapShader.js +1 -1
  146. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/math.js +1 -1
  147. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  148. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  149. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  150. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  151. package/views/2d/layers/imagery/ImageryView2D.js +1 -1
  152. package/views/2d/layers/imagery/VectorFieldTileView2D.js +1 -1
  153. package/views/2d/layers/imagery/VectorFieldView2D.js +1 -1
  154. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  155. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  156. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  157. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  158. package/views/3d/layers/graphics/pipeline/rendering/DirectRenderer.js +1 -1
  159. package/views/3d/layers/graphics/pipeline/rendering/RenderCommandContext.js +1 -1
  160. package/views/3d/layers/graphics/pipeline/symbolization/IconSymbolLayerRenderer.js +1 -1
  161. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  162. package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
  163. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  164. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayout.js +1 -1
  165. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBufferView.js +1 -1
  166. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  167. package/views/3d/webgl-engine/materials/DrawParameters.js +1 -1
  168. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  169. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  170. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  171. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  172. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  173. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  174. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  175. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  176. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  177. package/views/3d/webgl-engine/materials/renderers/Instance.js +1 -1
  178. package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +1 -1
  179. package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
  180. package/views/3d/webgl-engine/materials/renderers/PerOriginData.js +1 -1
  181. package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
  182. package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
  183. package/views/3d/webgl-engine/shaders/GaussianSplatColorTechnique.js +5 -0
  184. package/views/3d/webgl-engine/shaders/GaussianSplatDepthTechnique.js +5 -0
  185. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  186. package/views/DOMContainer.js +1 -1
  187. package/views/GroundView.js +1 -1
  188. package/views/layers/ImageryLayerViewMixin.js +1 -1
  189. package/views/layers/ImageryTileLayerViewMixin.js +1 -1
  190. package/views/support/imageReprojection.js +1 -1
  191. package/widgets/BatchAttributeForm.js +1 -1
  192. package/widgets/BuildingExplorer/BuildingExplorerViewModel.js +1 -1
  193. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  194. package/widgets/CoordinateConversion.js +1 -1
  195. package/widgets/DirectLineMeasurement3D.js +1 -1
  196. package/widgets/DistanceMeasurement2D.js +1 -1
  197. package/widgets/Editor/EditorViewModel.js +1 -1
  198. package/widgets/Editor.js +1 -1
  199. package/widgets/ElevationProfile.js +1 -1
  200. package/widgets/Feature.js +1 -1
  201. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  202. package/widgets/FeatureForm.js +1 -1
  203. package/widgets/FeatureTable/AttachmentsColumn.js +1 -1
  204. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  205. package/widgets/FeatureTable/Grid/Column.js +1 -1
  206. package/widgets/FeatureTable/Grid/EditorColumn.js +1 -1
  207. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  208. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  209. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  210. package/widgets/FeatureTable/support/GroupColumnTemplate.js +1 -1
  211. package/widgets/FeatureTable/support/TableTemplate.js +1 -1
  212. package/widgets/FeatureTable.js +1 -1
  213. package/widgets/FeatureTemplates.js +1 -1
  214. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  215. package/widgets/Legend.js +1 -1
  216. package/widgets/LineOfSight.js +1 -1
  217. package/widgets/Locate.js +1 -1
  218. package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
  219. package/widgets/OrientedImageryViewer/services/DepthImageService.js +1 -1
  220. package/widgets/PanoramicViewer/support/importUtils.js +1 -1
  221. package/widgets/Print/CustomTemplate.js +1 -1
  222. package/widgets/Print/PrintViewModel.js +1 -1
  223. package/widgets/Print/TemplateOptions.js +1 -1
  224. package/widgets/Print.js +1 -1
  225. package/widgets/ScaleBar.js +1 -1
  226. package/widgets/ScaleRangeSlider.js +1 -1
  227. package/widgets/Search/SearchResultRenderer.js +1 -1
  228. package/widgets/Search/SearchViewModel.js +1 -1
  229. package/widgets/Search/types.js +1 -1
  230. package/widgets/Search.js +1 -1
  231. package/widgets/ShadowCast.js +1 -1
  232. package/widgets/Sketch/SketchViewModel.js +1 -1
  233. package/widgets/Sketch.js +1 -1
  234. package/assets/esri/core/workers/chunks/1f6ead46b723630db897.js +0 -1
  235. package/assets/esri/core/workers/chunks/3a16347e17312556e02c.js +0 -1
  236. package/assets/esri/core/workers/chunks/478def691ae6763686f3.js +0 -1
  237. package/assets/esri/core/workers/chunks/4c4a55be41ba105c091c.js +0 -1
  238. package/assets/esri/core/workers/chunks/4cbf5a97b2b3c6553f6f.js +0 -1
  239. package/assets/esri/core/workers/chunks/646f58b69d2354f1ef27.js +0 -1
  240. package/assets/esri/core/workers/chunks/93d11075f65a5b6625ea.js +0 -1
  241. package/assets/esri/core/workers/chunks/96f798ee286b59396131.js +0 -316
  242. package/assets/esri/core/workers/chunks/9f2a8445a5848502c7e7.js +0 -1
  243. package/assets/esri/core/workers/chunks/a1b08aab73747f4e7e25.js +0 -1
  244. package/assets/esri/core/workers/chunks/ba59568e748f0ba53b78.js +0 -1
  245. package/assets/esri/core/workers/chunks/f21cb5b34d4d1e3af1a9.js +0 -1
  246. package/assets/esri/core/workers/chunks/f93f0586ce10cb5d98b3.js +0 -1
  247. package/layers/support/rasterDatasets/BaseRaster.js +0 -5
  248. package/layers/support/rasterDatasets/CovJSONRaster.js +0 -5
  249. package/layers/support/rasterDatasets/FunctionRaster.js +0 -5
  250. package/layers/support/rasterDatasets/ImageAuxRaster.js +0 -5
  251. package/layers/support/rasterDatasets/ImageServerRaster.js +0 -5
  252. package/layers/support/rasterDatasets/InMemoryRaster.js +0 -5
  253. package/layers/support/rasterDatasets/MRFRaster.js +0 -5
  254. package/layers/support/rasterDatasets/RawBlockCache.js +0 -5
  255. package/layers/support/rasterDatasets/TIFFRaster.js +0 -5
  256. package/layers/support/rasterDatasets/WCSRaster.js +0 -5
  257. package/layers/support/rasterDatasets/covJSONParser.js +0 -5
  258. package/layers/support/rasterDatasets/multidimensionalUtils.js +0 -5
  259. package/layers/support/rasterDatasets/pamParser.js +0 -5
  260. package/layers/support/rasterDatasets/pixelReader.js +0 -5
  261. package/layers/support/rasterDatasets/wcsCoverageParser.js +0 -5
  262. package/layers/support/rasterFormats/Lerc.js +0 -5
  263. package/layers/support/rasterFormats/Qb3.js +0 -5
  264. package/layers/support/rasterFormats/RasterCodec.js +0 -5
  265. package/layers/support/rasterFormats/TiffDecoder.js +0 -5
  266. package/layers/support/rasterFunctions/ArithmeticFunction.js +0 -5
  267. package/layers/support/rasterFunctions/BandArithmeticFunction.js +0 -5
  268. package/layers/support/rasterFunctions/BaseRasterFunction.js +0 -5
  269. package/layers/support/rasterFunctions/ColormapFunction.js +0 -5
  270. package/layers/support/rasterFunctions/ColormapToRGBFunction.js +0 -5
  271. package/layers/support/rasterFunctions/CompositeBandFunction.js +0 -5
  272. package/layers/support/rasterFunctions/CompositeBandFunctionArguments.js +0 -5
  273. package/layers/support/rasterFunctions/ComputeChangeFunction.js +0 -5
  274. package/layers/support/rasterFunctions/ConvolutionFunction.js +0 -5
  275. package/layers/support/rasterFunctions/ConvolutionFunctionArguments.js +0 -5
  276. package/layers/support/rasterFunctions/HillshadeFunction.js +0 -5
  277. package/layers/support/rasterFunctions/LocalFunction.js +0 -5
  278. package/layers/support/rasterFunctions/RemapFunction.js +0 -5
  279. package/layers/support/rasterFunctions/ShadedReliefFunction.js +0 -5
  280. package/layers/support/rasterFunctions/SlopeFunction.js +0 -5
  281. package/layers/support/rasterFunctions/StatisticsFunction.js +0 -5
  282. package/layers/support/rasterFunctions/StretchFunction.js +0 -5
  283. package/layers/support/rasterFunctions/bandIndexUtils.js +0 -5
  284. package/layers/support/rasterFunctions/changeDetectionUtils.js +0 -5
  285. package/layers/support/rasterFunctions/clipUtils.js +0 -5
  286. package/layers/support/rasterFunctions/conversionUtils.js +0 -5
  287. package/layers/support/rasterFunctions/convolutionUtils.js +0 -5
  288. package/layers/support/rasterFunctions/creators/createDataManagementFunctions.js +0 -5
  289. package/layers/support/rasterFunctions/creators/utils.js +0 -5
  290. package/layers/support/rasterFunctions/focalStatUtils.js +0 -5
  291. package/layers/support/rasterFunctions/localUtils.js +0 -5
  292. package/layers/support/rasterFunctions/pixelTransformUtils.js +0 -5
  293. package/layers/support/rasterFunctions/pixelUtils.js +0 -5
  294. package/layers/support/rasterFunctions/stretchUtils.js +0 -5
  295. package/layers/support/rasterFunctions/surfaceUtils.js +0 -5
  296. package/layers/support/rasterFunctions/vectorFieldUtils.js +0 -5
  297. package/layers/support/rasterTransforms/BaseRasterTransform.js +0 -5
  298. /package/assets/esri/layers/{support/rasterFormats → raster/formats}/lerc-wasm.wasm +0 -0
  299. /package/assets/esri/layers/{support/rasterFormats → raster/formats}/qb3-wasm.wasm +0 -0
  300. /package/layers/{support/rasterDatasets → raster/datasets}/DBFParser.js +0 -0
  301. /package/layers/{support/rasterDatasets → raster/datasets}/EphemeralBlockCache.js +0 -0
  302. /package/layers/{support/rasterDatasets → raster/datasets}/RasterFactory.js +0 -0
  303. /package/layers/{support/rasterDatasets → raster/datasets}/byteStreamUtils.js +0 -0
  304. /package/layers/{support/rasterDatasets → raster/datasets}/datasetUtils.js +0 -0
  305. /package/layers/{support/rasterDatasets → raster/datasets}/multipartParser.js +0 -0
  306. /package/layers/{support/rasterDatasets → raster/datasets}/wcsCapabilitiesParser.js +0 -0
  307. /package/layers/{support/rasterDatasets → raster/datasets}/xmlUtilities.js +0 -0
  308. /package/layers/{support/rasterFormats → raster/formats}/ImageCanvasDecoder.js +0 -0
  309. /package/layers/{support/rasterFormats → raster/formats}/JpgPlus.js +0 -0
  310. /package/layers/{support/rasterFormats → raster/formats}/Lzw.js +0 -0
  311. /package/layers/{support/rasterFormats → raster/formats}/Raw.js +0 -0
  312. /package/layers/{support/rasterFormats → raster/formats}/pixelRangeUtils.js +0 -0
  313. /package/layers/{support/rasterFormats → raster/formats}/tiffTag.js +0 -0
  314. /package/layers/{support/rasterFormats → raster/formats}/utils.js +0 -0
  315. /package/layers/{support/rasterFunctions → raster/functions}/colormaps.js +0 -0
  316. /package/layers/{support/rasterFunctions → raster/functions}/creators/createAppearenceFunctions.js +0 -0
  317. /package/layers/{support/rasterFunctions → raster/functions}/creators/createBandIndexFunctions.js +0 -0
  318. /package/layers/{support/rasterFunctions → raster/functions}/creators/createChangeFunctions.js +0 -0
  319. /package/layers/{support/rasterFunctions → raster/functions}/creators/createConversionFunctions.js +0 -0
  320. /package/layers/{support/rasterFunctions → raster/functions}/creators/createLocalFunctions.js +0 -0
  321. /package/layers/{support/rasterFunctions → raster/functions}/creators/createMultiRasterAnalysisFunctions.js +0 -0
  322. /package/layers/{support/rasterFunctions → raster/functions}/creators/createStatisticsFunctions.js +0 -0
  323. /package/layers/{support/rasterFunctions → raster/functions}/creators/createSurfaceFunctions.js +0 -0
  324. /package/layers/{support/rasterFunctions → raster/functions}/customBandIndexUtils.js +0 -0
  325. /package/layers/{support/rasterFunctions → raster/functions}/mirror.js +0 -0
  326. /package/layers/{support/rasterFunctions → raster/functions}/rasterFunctionHelper.js +0 -0
  327. /package/layers/{support/rasterFunctions → raster/functions}/rasterFunctionSchema.js +0 -0
  328. /package/layers/{support/rasterFunctions → raster/functions}/rasterProjectionHelper.js +0 -0
  329. /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{getAssetUrl as t}from"../../assets.js";import r from"../../Graphic.js";import s from"../../PopupTemplate.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import l from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import n from"../../core/Logger.js";import{mappedFind as u}from"../../core/maybe.js";import{eachAlways as c,after as h}from"../../core/promiseUtils.js";import{watch as p,initial as g,whenOnce as d}from"../../core/reactiveUtils.js";import{property as m,subclass as y}from"../../core/accessorSupport/decorators.js";import f from"../../geometry/Point.js";import S from"../../geometry/SpatialReference.js";import{getPointFromGeometry as _,getPointWithElevation as v}from"../../geometry/support/geometryUtils.js";import w from"../../portal/Portal.js";import{isApiKeyApplicable as b}from"../../support/apiKeyUtils.js";import x from"../../symbols/PictureMarkerSymbol.js";import L from"../../symbols/SimpleFillSymbol.js";import I from"../../symbols/SimpleLineSymbol.js";import T from"../../symbols/TextSymbol.js";import{popupFromView as E,closePopup as R}from"../../views/popupAdapter.js";import{highlightsSupported as F}from"../../views/support/layerViewUtils.js";import P from"./LayerSearchSource.js";import j from"./LocatorSearchSource.js";import C from"./SearchSource.js";import{isArcGISWorldGeocoder as G,meteredArcGISLocatorUrl as O,isProxiedArcGISWorldGeocoder as A,isMeteredArcGISWorldGeocoder as N}from"./support/locatorUtils.js";import{supported as D,getCurrentPosition as M,positionToPoint as V}from"../support/geolocationUtils.js";import{GoTo as J}from"../support/GoTo.js";function U(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const k="highlight",H=i.ofType({key:e=>e.layer?"layer":"locator",base:C,typeMap:{layer:P,locator:j}}),B=S.WGS84,Q="esri/images/search/search-symbol-32.png",Z=/<[\s\S]*?>/g,q=-1;let z=class extends(J(a)){constructor(e){super(e),this._defaultPopupTemplate=new s({content:"{Match_addr}"}),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultSources=new H,this.defaultSymbols={point:new x({url:t(Q),size:24,width:24,height:24}),polyline:new I({color:[130,130,130,1],width:2}),polygon:new L({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=w.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new H,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){this.addHandles([p(()=>[this.includeDefaultSources,this.view,this.portal],()=>this._update(),g),p(()=>this.messages,()=>{this._defaultPopupTemplate.title=this.messages?.searchResult??"",this._update()},g)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}static{this.ALL_INDEX=q}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:q}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:r}=this,s="function"==typeof r?r.call(null,{sources:e,defaultSources:t}):r?t.concat(e):e,o=this._get("allSources")||new H;return o.removeAll(),o.addMany(s.filter(Boolean)),o}get defaultPopupTemplate(){return this._defaultPopupTemplate}set defaultPopupTemplate(e){this._overrideIfSome("defaultPopupTemplate",e)}get locationEnabled(){return this._get("locationEnabled")||D()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=D();if(e&&!t){const e=new l("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});n.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:r}=this;if(t===q)return r??"";const s=e.at(t);return s?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const r=this._createSuggestionForSearch(e),s=(async()=>{try{await this.when();const e=await this._getResultsFromSources(r,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:r.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(s,e,r);const o=this._getFirstResult(s.results),i=r.location&&o?o.name:r.text,l=i?.replaceAll(Z,"");return this._set("searchTerm",l),(r.key&&"number"==typeof r.sourceIndex||r.location)&&this._set("selectedSuggestion",r),this._set("results",s.results),this._set("resultCount",s.results.reduce((e,t)=>e+(t.results?.length??0),0)),this.emit("search-complete",s),await this._selectFirstResult(o),s}finally{this._clearSearching()}})();return this._searching=s,s}async searchNearby(e){if(!this.locationEnabled){const e=new l("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw n.getLogger(this).error(e),e}const t=(async()=>{try{const t=await M(),r=await V({position:t,view:this.view},e);return await this.search(r,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new l("select:missing-parameter","Cannot select without a searchResult.",{value:e});throw n.getLogger(this).error(t),t}const{view:t}=this,s=U(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=s?this.allSources.at(s):null;if(!o){const e=new l("select:missing-source","Cannot select without a source.",{source:o});throw n.getLogger(this).error(e),e}const i=o instanceof P?this._getLayerSourcePopupTemplate(o):o.popupTemplate,a=o.resultSymbol||this._getDefaultSymbol(e),u=U(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,h=U(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,p=U(o,"popupEnabled")?o.popupEnabled:this.popupEnabled,g=p?i||this.popupTemplate||this.defaultPopupTemplate:null,{feature:d}=e;if(!d){const e=new l("select:missing-feature","Cannot select without a feature.",{feature:d});throw n.getLogger(this).error(e),e}const{attributes:m,geometry:y,layer:f,sourceLayer:S}=d,w=y?_(y):null,b={layerViewQuery:this._getLayerView(d),elevationQuery:t&&null!=w?v(w,t):Promise.resolve(w)},x=await c(b),L=x.layerViewQuery.value,I=x.elevationQuery.value;a instanceof T&&(a.text=e.name);const R=t&&h?e.target||e.extent:null,j=null!=R?this._goToSearchResult(R):Promise.resolve();await j;const C=L?d:new r({geometry:y,symbol:a,attributes:m,layer:f,sourceLayer:S,popupTemplate:g}),G=E(t),O=G&&p&&C.getEffectivePopupTemplate(G.defaultPopupTemplateEnabled);return O&&await(t?.openPopup({features:[C],location:I})),L&&F(L)&&!O&&this._highlightFeature({graphic:C,layerView:L}),!L&&u&&t&&t.graphics.push(C),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",C),this.emit("select-result",{result:e,source:o,sourceIndex:s}),e}async suggest(e,t,r){const s=e||this.searchTerm;this.emit("suggest-start",{searchTerm:s}),await this._suggestTimer(t,r);const o=await this._suggestImmediate(s,r);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce((e,t)=>e+(t.results?.length??0),0)??null),this.emit("suggest-complete",o),o}async when(){await d(()=>!this.updating)}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const r=this._updatingPromise=c([e?.load(),t?.when()]);if(this.destroyed)return;if(await r,r!==this._updatingPromise)return}this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map(e=>{if(!1===e.placefinding)return;const t=G(e.url)&&b(e.url)?{url:O}:null,r=j.fromJSON({...e,...t}),s=r.url;if(G(s)||A(s)||N(s)){const e=r.outFields??["Addr_type","Match_addr","StAddr","City"],t=(r.placeholder||this.messages?.placeholder)??"",s="number"==typeof r.defaultZoomScale?r.defaultZoomScale:2500;r.singleLineFieldName="SingleLine",r.outFields=e,r.placeholder=t,r.defaultZoomScale=s}return r.singleLineFieldName?r:void 0}).filter(o)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach(e=>e?.destroy()),this._createdFeatureLayers=[]}_getLayerSources(e,t){const r=this.view?.map;return e.map(e=>{const s=r.findLayerById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_getTableSources(e,t){const r=this.view?.map;return e.map(e=>{if(!e.id)return;const s=r.findTableById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:r,hintText:s,layers:o,tables:i}=t;if(!r)return[];return[...this._getLayerSources(o,s),...this._getTableSources(i,s)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const r=e.allSublayers.find(e=>e.id===t.subLayer);if(!r)throw new Error;const s=await(r.createFeatureLayer?.());if(!s)throw new Error;return this._createdFeatureLayers.push(s),s}async _getBuildingSubLayer(e,t){await e.load();const r=e.allSublayers.find(e=>e.id===t.subLayer);if("building-component"!==r?.type)throw new Error;if(await r.load(),null==r.associatedLayer)throw new Error;return await r.associatedLayer.load(),r}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(r){const t=new l("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return n.getLogger(this).error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=E(this.view),{resultGraphic:t}=this;if(!e||!t)return;const r="selectedFeature"in e,s=r?e.selectedFeature:null;r&&(s&&s===t)&&R(this.view?.popup,this.view?.popupElement)}_suggestTimer(e,t){const r=null!=e?e:this.suggestionDelay;return h(r,null,t?.signal)}_createLocationForSearch(e){return e instanceof r&&e.geometry?_(e.geometry):e instanceof f?e:Array.isArray(e)&&2===e.length?new f({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&U(e,"key")&&U(e,"text")&&U(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),r="string"==typeof e?e:this.searchTerm,{selectedSuggestion:s,selectedResult:o}=this,i=!e&&s&&o,l=i&&s.key===o.key&&s.sourceIndex===o.sourceIndex,a=i&&s.location;return l||a?s:{location:t,text:t?"":r,sourceIndex:null,key:null}}_getFirstResult(e){return u(e,({results:e})=>e?.[0])??null}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const r=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(s,r),s}_formatSourceResponse(e,t,r){const s=t?.value||[],o=t?.error,i=this.allSources.at(r);if(o){const t={sourceIndex:r,source:i,error:o};e.errors.push(t),n.getLogger(this).error(o),e.numErrors++}else{const t={sourceIndex:r,source:i,results:s};e.results.push(t),e.numResults+=s.length}}_formatResponse(e,t,r){if(t)if(e.activeSourceIndex===q){const s=r&&U(r,"sourceIndex")&&-1!==r.sourceIndex?r.sourceIndex:void 0;t.forEach((t,r)=>{const o=void 0!==s?s:r;this._formatSourceResponse(e,t,o)})}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:r}=this,s=!e.location&&U(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!r.length){const e=new l("search:no-sources-defined","At least one source is required.",{allSources:r});throw n.getLogger(this).error(e),e}return s===q?r.forEach((r,s)=>{o.push(this._getResultsFromSource(e,s,t))}):o.push(this._getResultsFromSource(e,s,t)),c(o)}async _getSuggestionsFromSources(e,t){const{allSources:r,activeSourceIndex:s}=this,o=[];if(!r.length){const e=new l("suggest:no-sources-defined","At least one source is required.",{allSources:r});throw n.getLogger(this).error(e),e}return s===q?r.forEach((r,s)=>{o.push(this._getSuggestionsFromSource(e,s,t))}):o.push(this._getSuggestionsFromSource(e,s,t)),c(o)}async _getResultsFromSource(e,t,r){const s=null!=t?this.allSources.at(t):null;if(!s)return null;const{location:o=null}=e,i=this.view?.spatialReference??B,l=U(s,"maxResults")?s.maxResults:this.maxResults,a=!!(s instanceof P&&U(s,"exactMatch"))&&s.exactMatch,{view:n}=this;return s.getResults?.({exactMatch:a,location:o,maxResults:l,sourceIndex:t,spatialReference:i,suggestResult:e,view:n},r)}async _getSuggestionsFromSource(e,t,r){const s=this.allSources.at(t);if(!s)return null;e??="";const o=U(s,"suggestionsEnabled")?s.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=U(s,"minSuggestCharacters")?s.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||B,i=U(s,"maxSuggestions")?s.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(s instanceof P&&U(s,"exactMatch"))&&s.exactMatch;return s.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},r)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return U(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){return u(this.results??[],({results:t,sourceIndex:r})=>{const s=t?.includes(e);return s?r:null})??null}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const r={target:{target:e},options:{signal:t.signal}};e||(r.options.animate=!1),await this.callGoTo(r),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,r=e.feature?.geometry;if(null==r)return null;switch(r.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(k)}async _getLayerView(e){const{view:t}=this;if(!e||!t)return null;const{layer:r,sourceLayer:s}=e,o=r??s;return o&&"building-component"!==o.type&&"subtype-sublayer"!==o.type?(await t.when(),t.whenLayerView(o)):null}_highlightFeature(e){const{graphic:t,layerView:r}=e,{attributes:s,layer:o,sourceLayer:i}=t,l=o??i,{objectIdField:a}=l,n=(a&&s?.[a])??null,u=r.highlight(n??t);this.addHandles(u,k)}_setResultFloor(e){const{view:t}=this,r=e.feature?.attributes,s=e.feature?.sourceLayer;if(s&&"floorInfo"in s&&s?.floorInfo?.floorField&&r){const e=r[s.floorInfo.floorField];t?.emit("select-result-floor",e)}}};e([m()],z.prototype,"_searching",void 0),e([m()],z.prototype,"_updatingPromise",void 0),e([m({readOnly:!0,value:null})],z.prototype,"activeSource",null),e([m()],z.prototype,"activeSourceIndex",null),e([m()],z.prototype,"allPlaceholder",null),e([m({readOnly:!0})],z.prototype,"allSources",null),e([m()],z.prototype,"autoNavigate",void 0),e([m()],z.prototype,"autoSelect",void 0),e([m({type:s})],z.prototype,"defaultPopupTemplate",null),e([m({readOnly:!0})],z.prototype,"defaultSources",void 0),e([m()],z.prototype,"defaultSymbols",void 0),e([m()],z.prototype,"includeDefaultSources",void 0),e([m()],z.prototype,"locationEnabled",null),e([m()],z.prototype,"maxInputLength",void 0),e([m()],z.prototype,"maxResults",void 0),e([m()],z.prototype,"maxSuggestions",void 0),e([m()],z.prototype,"messages",void 0),e([m()],z.prototype,"minSuggestCharacters",void 0),e([m({readOnly:!0})],z.prototype,"placeholder",null),e([m()],z.prototype,"popupEnabled",void 0),e([m({type:s})],z.prototype,"popupTemplate",void 0),e([m({type:w})],z.prototype,"portal",void 0),e([m()],z.prototype,"resultCount",void 0),e([m()],z.prototype,"resultGraphicEnabled",void 0),e([m({readOnly:!0})],z.prototype,"resultGraphic",void 0),e([m({readOnly:!0})],z.prototype,"results",void 0),e([m({readOnly:!0})],z.prototype,"selectedSuggestion",void 0),e([m()],z.prototype,"searchAllEnabled",void 0),e([m({readOnly:!0})],z.prototype,"selectedResult",void 0),e([m()],z.prototype,"searchTerm",null),e([m({type:H})],z.prototype,"sources",void 0),e([m({readOnly:!0})],z.prototype,"state",null),e([m()],z.prototype,"suggestionDelay",void 0),e([m()],z.prototype,"suggestionCount",void 0),e([m({readOnly:!0})],z.prototype,"suggestions",void 0),e([m()],z.prototype,"suggestionsEnabled",void 0),e([m({readOnly:!0})],z.prototype,"updating",null),e([m()],z.prototype,"view",void 0),e([m()],z.prototype,"clear",null),z=e([y("esri.widgets.Search.SearchViewModel")],z);const K=z;export{K as default};
5
+ import{__decorate as e}from"tslib";import{getAssetUrl as t}from"../../assets.js";import s from"../../Graphic.js";import r from"../../PopupTemplate.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Error.js";import{EventedAccessor as l}from"../../core/Evented.js";import a from"../../core/Logger.js";import{mappedFind as n}from"../../core/maybe.js";import{eachAlways as u,after as c}from"../../core/promiseUtils.js";import{watch as h,initial as p,whenOnce as g}from"../../core/reactiveUtils.js";import{property as d,subclass as m}from"../../core/accessorSupport/decorators.js";import y from"../../geometry/Point.js";import f from"../../geometry/SpatialReference.js";import{getPointFromGeometry as S,getPointWithElevation as _}from"../../geometry/support/geometryUtils.js";import v from"../../portal/Portal.js";import{isApiKeyApplicable as w}from"../../support/apiKeyUtils.js";import b from"../../symbols/PictureMarkerSymbol.js";import x from"../../symbols/SimpleFillSymbol.js";import L from"../../symbols/SimpleLineSymbol.js";import I from"../../symbols/TextSymbol.js";import{popupFromView as T,closePopup as E}from"../../views/popupAdapter.js";import{highlightsSupported as R}from"../../views/support/layerViewUtils.js";import F from"./LayerSearchSource.js";import P from"./LocatorSearchSource.js";import{SourceCollection as j}from"./types.js";import{isArcGISWorldGeocoder as G,meteredArcGISLocatorUrl as C,isProxiedArcGISWorldGeocoder as O,isMeteredArcGISWorldGeocoder as A}from"./support/locatorUtils.js";import{supported as N,getCurrentPosition as D,positionToPoint as M}from"../support/geolocationUtils.js";import{GoTo as V}from"../support/GoTo.js";function J(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const U="highlight",H=f.WGS84,k="esri/images/search/search-symbol-32.png",B=/<[\s\S]*?>/g,Q=-1;let Z=class extends(V(l)){constructor(e){super(e),this._defaultPopupTemplate=new r({content:"{Match_addr}"}),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultSources=new j,this.defaultSymbols={point:new b({url:t(k),size:24,width:24,height:24}),polyline:new L({color:[130,130,130,1],width:2}),polygon:new x({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=v.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new j,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){this.addHandles([h(()=>[this.includeDefaultSources,this.view,this.portal],()=>this._update(),p),h(()=>this.messages,()=>{this._defaultPopupTemplate.title=this.messages?.searchResult??"",this._update()},p)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}static{this.ALL_INDEX=Q}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:Q}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:s}=this,r="function"==typeof s?s.call(null,{sources:e,defaultSources:t}):s?t.concat(e):e,o=this._get("allSources")||new j;return o.removeAll(),o.addMany(r.filter(Boolean)),o}get defaultPopupTemplate(){return this._defaultPopupTemplate}set defaultPopupTemplate(e){this._overrideIfSome("defaultPopupTemplate",e)}get locationEnabled(){return this._get("locationEnabled")||N()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=N();if(e&&!t){const e=new i("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});a.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:s}=this;if(t===Q)return s??"";const r=e.at(t);return r?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const s=this._createSuggestionForSearch(e),r=(async()=>{try{await this.when();const e=await this._getResultsFromSources(s,t);if(t?.signal?.aborted)return null;const r={activeSourceIndex:this.activeSourceIndex,searchTerm:s.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(r,e,s);const o=this._getFirstResult(r.results),i=s.location&&o?o.name:s.text,l=i?.replaceAll(B,"");return this._set("searchTerm",l),(s.key&&"number"==typeof s.sourceIndex||s.location)&&this._set("selectedSuggestion",s),this._set("results",r.results),this._set("resultCount",r.results.reduce((e,t)=>e+(t.results?.length??0),0)),this.emit("search-complete",r),await this._selectFirstResult(o),r}finally{this._clearSearching()}})();return this._searching=r,r}async searchNearby(e){if(!this.locationEnabled){const e=new i("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw a.getLogger(this).error(e),e}const t=(async()=>{try{const t=await D(),s=await M({position:t,view:this.view},e);return await this.search(s,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new i("select:missing-parameter","Cannot select without a searchResult.",{value:e});throw a.getLogger(this).error(t),t}const{view:t}=this,r=J(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=r?this.allSources.at(r):null;if(!o){const e=new i("select:missing-source","Cannot select without a source.",{source:o});throw a.getLogger(this).error(e),e}const l=o instanceof F?this._getLayerSourcePopupTemplate(o):o.popupTemplate,n=o.resultSymbol||this._getDefaultSymbol(e),c=J(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,h=J(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,p=J(o,"popupEnabled")?o.popupEnabled:this.popupEnabled,g=p?l||this.popupTemplate||this.defaultPopupTemplate:null,{feature:d}=e;if(!d){const e=new i("select:missing-feature","Cannot select without a feature.",{feature:d});throw a.getLogger(this).error(e),e}const{attributes:m,geometry:y,layer:f,sourceLayer:v}=d,w=y?S(y):null,b={layerViewQuery:this._getLayerView(d),elevationQuery:t&&null!=w?_(w,t):Promise.resolve(w)},x=await u(b),L=x.layerViewQuery.value,E=x.elevationQuery.value;n instanceof I&&(n.text=e.name);const P=t&&h?e.target||e.extent:null,j=null!=P?this._goToSearchResult(P):Promise.resolve();await j;const G=L?d:new s({geometry:y,symbol:n,attributes:m,layer:f,sourceLayer:v,popupTemplate:g}),C=T(t),O=C&&p&&G.getEffectivePopupTemplate(C.defaultPopupTemplateEnabled);return O&&await(t?.openPopup({features:[G],location:E})),L&&R(L)&&!O&&this._highlightFeature({graphic:G,layerView:L}),!L&&c&&t&&t.graphics.push(G),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",G),this.emit("select-result",{result:e,source:o,sourceIndex:r}),e}async suggest(e,t,s){const r=e||this.searchTerm;this.emit("suggest-start",{searchTerm:r}),await this._suggestTimer(t,s);const o=await this._suggestImmediate(r,s);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce((e,t)=>e+(t.results?.length??0),0)??null),this.emit("suggest-complete",o),o}async when(){await g(()=>!this.updating)}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const s=this._updatingPromise=u([e?.load(),t?.when()]);if(this.destroyed)return;if(await s,s!==this._updatingPromise)return}this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map(e=>{if(!1===e.placefinding)return;const t=G(e.url)&&w(e.url)?{url:C}:null,s=P.fromJSON({...e,...t}),r=s.url;if(G(r)||O(r)||A(r)){const e=s.outFields??["Addr_type","Match_addr","StAddr","City"],t=(s.placeholder||this.messages?.placeholder)??"",r="number"==typeof s.defaultZoomScale?s.defaultZoomScale:2500;s.singleLineFieldName="SingleLine",s.outFields=e,s.placeholder=t,s.defaultZoomScale=r}return s.singleLineFieldName?s:void 0}).filter(o)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach(e=>e?.destroy()),this._createdFeatureLayers=[]}_getLayerSources(e,t){const s=this.view?.map;return e.map(e=>{const r=s.findLayerById(e.id);if(!r)return;const o=this._getLayerJSON(e),i=F.fromJSON(o);return i.placeholder=t,this._getLayer(r,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_getTableSources(e,t){const s=this.view?.map;return e.map(e=>{if(!e.id)return;const r=s.findTableById(e.id);if(!r)return;const o=this._getLayerJSON(e),i=F.fromJSON(o);return i.placeholder=t,this._getLayer(r,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:s,hintText:r,layers:o,tables:i}=t;if(!s)return[];return[...this._getLayerSources(o,r),...this._getTableSources(i,r)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const s=e.allSublayers.find(e=>e.id===t.subLayer);if(!s)throw new Error;const r=await(s.createFeatureLayer?.());if(!r)throw new Error;return this._createdFeatureLayers.push(r),r}async _getBuildingSubLayer(e,t){await e.load();const s=e.allSublayers.find(e=>e.id===t.subLayer);if("building-component"!==s?.type)throw new Error;if(await s.load(),null==s.associatedLayer)throw new Error;return await s.associatedLayer.load(),s}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(s){const t=new i("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return a.getLogger(this).error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=T(this.view),{resultGraphic:t}=this;if(!e||!t)return;const s="selectedFeature"in e,r=s?e.selectedFeature:null;s&&(r&&r===t)&&E(this.view?.popup,this.view?.popupElement)}_suggestTimer(e,t){const s=null!=e?e:this.suggestionDelay;return c(s,null,t?.signal)}_createLocationForSearch(e){return e instanceof s&&e.geometry?S(e.geometry):e instanceof y?e:Array.isArray(e)&&2===e.length?new y({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&J(e,"key")&&J(e,"text")&&J(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),s="string"==typeof e?e:this.searchTerm,{selectedSuggestion:r,selectedResult:o}=this,i=!e&&r&&o,l=i&&r.key===o.key&&r.sourceIndex===o.sourceIndex,a=i&&r.location;return l||a?r:{location:t,text:t?"":s,sourceIndex:null,key:null}}_getFirstResult(e){return n(e,({results:e})=>e?.[0])??null}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const s=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const r={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(r,s),r}_formatSourceResponse(e,t,s){const r=t?.value||[],o=t?.error,i=this.allSources.at(s);if(o){const t={sourceIndex:s,source:i,error:o};e.errors.push(t),a.getLogger(this).error(o),e.numErrors++}else{const t={sourceIndex:s,source:i,results:r};e.results.push(t),e.numResults+=r.length}}_formatResponse(e,t,s){if(t)if(e.activeSourceIndex===Q){const r=s&&J(s,"sourceIndex")&&-1!==s.sourceIndex?s.sourceIndex:void 0;t.forEach((t,s)=>{const o=void 0!==r?r:s;this._formatSourceResponse(e,t,o)})}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:s}=this,r=!e.location&&J(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!s.length){const e=new i("search:no-sources-defined","At least one source is required.",{allSources:s});throw a.getLogger(this).error(e),e}return r===Q?s.forEach((s,r)=>{o.push(this._getResultsFromSource(e,r,t))}):o.push(this._getResultsFromSource(e,r,t)),u(o)}async _getSuggestionsFromSources(e,t){const{allSources:s,activeSourceIndex:r}=this,o=[];if(!s.length){const e=new i("suggest:no-sources-defined","At least one source is required.",{allSources:s});throw a.getLogger(this).error(e),e}return r===Q?s.forEach((s,r)=>{o.push(this._getSuggestionsFromSource(e,r,t))}):o.push(this._getSuggestionsFromSource(e,r,t)),u(o)}async _getResultsFromSource(e,t,s){const r=null!=t?this.allSources.at(t):null;if(!r)return null;const{location:o=null}=e,i=this.view?.spatialReference??H,l=J(r,"maxResults")?r.maxResults:this.maxResults,a=!!(r instanceof F&&J(r,"exactMatch"))&&r.exactMatch,{view:n}=this;return r.getResults?.({exactMatch:a,location:o,maxResults:l,sourceIndex:t,spatialReference:i,suggestResult:e,view:n},s)}async _getSuggestionsFromSource(e,t,s){const r=this.allSources.at(t);if(!r)return null;e??="";const o=J(r,"suggestionsEnabled")?r.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=J(r,"minSuggestCharacters")?r.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||H,i=J(r,"maxSuggestions")?r.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(r instanceof F&&J(r,"exactMatch"))&&r.exactMatch;return r.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},s)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return J(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){return n(this.results??[],({results:t,sourceIndex:s})=>{const r=t?.includes(e);return r?s:null})??null}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const s={target:{target:e},options:{signal:t.signal}};e||(s.options.animate=!1),await this.callGoTo(s),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,s=e.feature?.geometry;if(null==s)return null;switch(s.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(U)}async _getLayerView(e){const{view:t}=this;if(!e||!t)return null;const{layer:s,sourceLayer:r}=e,o=s??r;return o&&"building-component"!==o.type&&"subtype-sublayer"!==o.type?(await t.when(),t.whenLayerView(o)):null}_highlightFeature(e){const{graphic:t,layerView:s}=e,{attributes:r,layer:o,sourceLayer:i}=t,l=o??i,{objectIdField:a}=l,n=(a&&r?.[a])??null,u=s.highlight(n??t);this.addHandles(u,U)}_setResultFloor(e){const{view:t}=this,s=e.feature?.attributes,r=e.feature?.sourceLayer;if(r&&"floorInfo"in r&&r?.floorInfo?.floorField&&s){const e=s[r.floorInfo.floorField];t?.emit("select-result-floor",e)}}};e([d()],Z.prototype,"_searching",void 0),e([d()],Z.prototype,"_updatingPromise",void 0),e([d({readOnly:!0,value:null})],Z.prototype,"activeSource",null),e([d()],Z.prototype,"activeSourceIndex",null),e([d()],Z.prototype,"allPlaceholder",null),e([d({readOnly:!0})],Z.prototype,"allSources",null),e([d()],Z.prototype,"autoNavigate",void 0),e([d()],Z.prototype,"autoSelect",void 0),e([d({type:r})],Z.prototype,"defaultPopupTemplate",null),e([d({readOnly:!0})],Z.prototype,"defaultSources",void 0),e([d()],Z.prototype,"defaultSymbols",void 0),e([d()],Z.prototype,"includeDefaultSources",void 0),e([d()],Z.prototype,"locationEnabled",null),e([d()],Z.prototype,"maxInputLength",void 0),e([d()],Z.prototype,"maxResults",void 0),e([d()],Z.prototype,"maxSuggestions",void 0),e([d()],Z.prototype,"messages",void 0),e([d()],Z.prototype,"minSuggestCharacters",void 0),e([d({readOnly:!0})],Z.prototype,"placeholder",null),e([d()],Z.prototype,"popupEnabled",void 0),e([d({type:r})],Z.prototype,"popupTemplate",void 0),e([d({type:v})],Z.prototype,"portal",void 0),e([d()],Z.prototype,"resultCount",void 0),e([d()],Z.prototype,"resultGraphicEnabled",void 0),e([d({readOnly:!0})],Z.prototype,"resultGraphic",void 0),e([d({readOnly:!0})],Z.prototype,"results",void 0),e([d({readOnly:!0})],Z.prototype,"selectedSuggestion",void 0),e([d()],Z.prototype,"searchAllEnabled",void 0),e([d({readOnly:!0})],Z.prototype,"selectedResult",void 0),e([d()],Z.prototype,"searchTerm",null),e([d({type:j})],Z.prototype,"sources",void 0),e([d({readOnly:!0})],Z.prototype,"state",null),e([d()],Z.prototype,"suggestionDelay",void 0),e([d()],Z.prototype,"suggestionCount",void 0),e([d({readOnly:!0})],Z.prototype,"suggestions",void 0),e([d()],Z.prototype,"suggestionsEnabled",void 0),e([d({readOnly:!0})],Z.prototype,"updating",null),e([d()],Z.prototype,"view",void 0),e([d()],Z.prototype,"clear",null),Z=e([m("esri.widgets.Search.SearchViewModel")],Z);const q=Z;export{q as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- function n(){}export{n as __exported__};
5
+ import o from"../../core/Collection.js";import r from"./LayerSearchSource.js";import e from"./LocatorSearchSource.js";import c from"./SearchSource.js";function a(){}const t=o.ofType({key:o=>o.layer?"layer":"locator",base:c,typeMap:{layer:r,locator:e}});export{t as SourceCollection,a as __exported__};
package/widgets/Search.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{deprecateWidget as s,deprecatedPropertyValue as o}from"../core/deprecate.js";import r from"../core/Logger.js";import{destroyMaybe as i,abortMaybe as l}from"../core/maybe.js";import{ignoreAbortErrors as n,isAbortError as a}from"../core/promiseUtils.js";import{watch as c,initial as u}from"../core/reactiveUtils.js";import{waitAnimationFrame as h}from"../core/scheduling.js";import{property as d,subclass as p}from"../core/accessorSupport/decorators.js";import g from"./Widget.js";import{css as m}from"./Search/css.js";import v from"./Search/SearchResultRenderer.js";import _ from"./Search/SearchViewModel.js";import{loadCalciteComponents as w}from"./support/componentsUtils.js";import{globalCss as M}from"./support/globalCss.js";import{messageBundle as S,vmEvent as b,tsx as y}from"./support/widget.js";let C=class extends g{constructor(e,t){super(e,t),this._currentLocationValue=`${this.id}-search-use-current-location`,this._autocompleteNode=null,this._focusAbortController=null,this._searchResultRenderer=new v,this._suggestController=null,this._searchController=null,this._lastSearchTerm="",this._locateFailed=!1,this._showNoResults=!1,this.disabled=!1,this.messages=null,this.messagesCommon=null,this.viewModel=new _,this._renderSearchResultsContent=()=>this._searchResultRenderer,s(r.getLogger(this),"Search","arcgis-search",{version:"4.33"}),this.addHandles([c(()=>this.viewModel,e=>this._searchResultRenderer.viewModel=e,u),c(()=>this.viewModel.results,()=>this._searchResultRenderer.showMoreResultsOpen=!1),c(()=>this.messages,e=>this.viewModel.messages=e),c(()=>this.viewModel?.defaultPopupTemplate,e=>{e&&(e.content=this._renderSearchResultsContent)},u),c(()=>this.viewModel?.view?.popupElement&&this.viewModel?.defaultPopupTemplate,()=>{if(this.viewModel?.defaultPopupTemplate&&this.viewModel?.view?.popupElement){const e=document.createElement("arcgis-search-result-renderer");e.viewModel=this.viewModel,e.messages=this.messages,this.viewModel.defaultPopupTemplate.content=e}},u)])}loadDependencies(){return w({autocomplete:()=>import("@esri/calcite-components/dist/components/calcite-autocomplete"),"autocomplete-item-group":()=>import("@esri/calcite-components/dist/components/calcite-autocomplete-item-group"),"autocomplete-item":()=>import("@esri/calcite-components/dist/components/calcite-autocomplete-item"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}destroy(){this._cancelQueries(),this._searchResultRenderer=i(this._searchResultRenderer),this._focusAbortController?.abort()}get _isDisabled(){const{state:e}=this.viewModel;return"disabled"===e||"loading"===e||this.disabled}get _showCurrentLocation(){return this.locationEnabled&&!this.searchTerm?.trim()}get _effectiveActiveMenu(){const{activeMenu:e}=this;return this._isDisabled?"none":"warning"===e?"suggestion":e}get activeMenu(){return"none"}set activeMenu(e){"warning"===e&&o(r.getLogger(this),"activeMenu","warning",{replacement:"Use the value 'suggestion' instead",version:"4.32",warnOnce:!0}),this._overrideIfSome("activeMenu",e)}get activeSource(){return this.viewModel?.activeSource}get activeSourceIndex(){return this.viewModel.activeSourceIndex}set activeSourceIndex(e){this.viewModel.activeSourceIndex=e}get allPlaceholder(){return this.viewModel.allPlaceholder}set allPlaceholder(e){this.viewModel.allPlaceholder=e}get allSources(){return this.viewModel.allSources}get autoNavigate(){return this.viewModel.autoNavigate}set autoNavigate(e){this.viewModel.autoNavigate=e}get autoSelect(){return this.viewModel.autoSelect}set autoSelect(e){this.viewModel.autoSelect=e}get defaultSources(){return this.viewModel.defaultSources}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"search"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultSources(){return this.viewModel.includeDefaultSources}set includeDefaultSources(e){this.viewModel.includeDefaultSources=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get locationEnabled(){return this.viewModel.locationEnabled}set locationEnabled(e){this.viewModel.locationEnabled=e}get maxResults(){return this.viewModel.maxResults}set maxResults(e){this.viewModel.maxResults=e}get maxSuggestions(){return this.viewModel.maxSuggestions}set maxSuggestions(e){this.viewModel.maxSuggestions=e}get minSuggestCharacters(){return this.viewModel.minSuggestCharacters}set minSuggestCharacters(e){this.viewModel.minSuggestCharacters=e}get popupEnabled(){return this.viewModel.popupEnabled}set popupEnabled(e){this.viewModel.popupEnabled=e}get popupTemplate(){return this.viewModel.popupTemplate}set popupTemplate(e){this.viewModel.popupTemplate=e}get portal(){return this.viewModel?.portal}set portal(e){this.viewModel&&(this.viewModel.portal=e)}get resultGraphic(){return this.viewModel.resultGraphic}set resultGraphic(e){this.viewModel.resultGraphic=e}get resultGraphicEnabled(){return this.viewModel.resultGraphicEnabled}set resultGraphicEnabled(e){this.viewModel.resultGraphicEnabled=e}get results(){return this.viewModel.results}get searchAllEnabled(){return this.viewModel.searchAllEnabled}set searchAllEnabled(e){this.viewModel.searchAllEnabled=e}get searchTerm(){return this.viewModel.searchTerm}set searchTerm(e){this.viewModel.searchTerm=e}get selectedResult(){return this.viewModel.selectedResult}get sources(){return this.viewModel.sources}set sources(e){this.viewModel.sources=e}get suggestions(){return this.viewModel.suggestions}get suggestionsEnabled(){return this.viewModel.suggestionsEnabled}set suggestionsEnabled(e){this.viewModel.suggestionsEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}clear(){this._locateFailed=!1,this.viewModel.clear()}focus(){this._handleFocus(),this._emitFocus()}blur(){this._autocompleteNode?.blur(),this._emitBlur()}async search(e){this._cancelQueries();const t=new AbortController,{signal:s}=t;this._searchController=t;try{const o=await this.viewModel.search(e,{signal:s});if(this._searchController!==t)return;return o?.numResults||(this._showNoResults=!0,this.activeMenu="suggestion"),this._searchController=null,o}catch(o){if(this._searchController!==t)return;return void(this._searchController=null)}}async suggest(e){this._cancelSuggest();const t=new AbortController,{signal:s}=t;this._suggestController=t;try{const o=await this.viewModel.suggest(e,null,{signal:s});if(this._suggestController!==t)return;return this._suggestController=null,o?.numResults&&(this.activeMenu="suggestion",this._scrollToTopSuggestion()),o}catch(o){return this._suggestController!==t||(this._suggestController=null),null}}render(){return y("div",{class:this.classes(m.base,M.widget)},y("div",{class:m.container},this._renderSourcesMenu(),this._renderForm()))}_handleInputKeydown(e){"Tab"===e.key&&this._cancelSuggest()}_emitFocus(){this.emit("search-focus")}_emitBlur(){this.emit("search-blur")}async _handleFocus(){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const e=this._focusAbortController.signal;await n(h(e)),this._autocompleteNode?.setFocus()}_renderSourcesMenu(){const{messages:e,_isDisabled:t,_effectiveActiveMenu:s}=this,{allSources:o,searchAllEnabled:r}=this.viewModel;return o.length>1?y("calcite-dropdown",{bind:this,class:m.dropdown,disabled:t,open:"source"===s,overlayPositioning:"fixed",onCalciteDropdownClose:this._handleSourceClose,onCalciteDropdownOpen:this._handleSourceOpen,onCalciteDropdownSelect:this._handleSourceSelect},y("calcite-button",{appearance:"outline-fill",iconStart:"caret-down",kind:"neutral",label:e.searchIn,slot:"trigger"}),y("calcite-dropdown-group",{groupTitle:e.searchIn},r?this._renderSource(_.ALL_INDEX):null,o.map((e,t)=>this._renderSource(t)).toArray())):null}_renderUseCurrentLocation(){const{_currentLocationValue:e}=this;return y("calcite-autocomplete-item",{heading:this.messages.useCurrentLocation,iconStart:"gps-on",key:e,value:e})}_handleAutocompleteCreate(e){this._autocompleteNode=e}_handleCalciteAutocompleteTextInput(e){const t=e.target.inputValue;t!==this.viewModel.searchTerm&&(this.viewModel.searchTerm=t,t||this.clear(),this.suggest())}_handleAutocompleteOpen(){this.activeMenu="suggestion"}_handleAutocompleteClose(){"suggestion"===this.activeMenu&&(this.activeMenu="none")}_handleCalciteAutocompleteChange(e){const t=e.target.value;if(t===this._currentLocationValue)return void this._useCurrentLocation();const s=JSON.parse(t),o=this.viewModel.suggestions?.find(({sourceIndex:e})=>e===s.sourceIndex)?.results?.find(({key:e})=>`${e}`==`${s.key}`);o&&this.search(o)}_renderAutocomplete(){const{_effectiveActiveMenu:e,messages:t,_isDisabled:s}=this,{maxInputLength:o,placeholder:r,searchTerm:i,state:l}=this.viewModel,n=this.label??t.searchButtonTitle??"";return y("calcite-autocomplete",{afterCreate:this._handleAutocompleteCreate,autocomplete:"off",bind:this,class:m.autocomplete,disabled:s,icon:this.icon||!1,inputValue:i,label:n,loading:"searching"===l,maxLength:o,name:this.id,onblur:this._emitBlur,onfocus:this._emitFocus,onkeydown:this._handleInputKeydown,open:"suggestion"===e,overlayPositioning:"fixed",placeholder:r,title:i?"":r,onCalciteAutocompleteChange:this._handleCalciteAutocompleteChange,onCalciteAutocompleteClose:this._handleAutocompleteClose,onCalciteAutocompleteOpen:this._handleAutocompleteOpen,onCalciteAutocompleteTextChange:this._handleCalciteAutocompleteTextInput,onCalciteAutocompleteTextInput:this._handleCalciteAutocompleteTextInput},this._renderSuggestions(),this._renderNotices())}_renderForm(){return y("form",{bind:this,class:m.form,disabled:this._isDisabled,key:m.form,onsubmit:this._formSubmit,role:"search"},this._renderAutocomplete(),y("button",{class:m.submitButton,type:"submit"},this.label??this.messages.searchButtonTitle??""))}_renderSuggestGroup(e){return e.results?.map(e=>this._renderSuggestion(e))}_renderSuggestions(){const{suggestions:e}=this.viewModel;return this._showNoResults?null:this._showCurrentLocation?this._renderUseCurrentLocation():e?.map(e=>this._renderSuggestResults(e))}_renderSuggestResults(e){const{allSources:t,activeSourceIndex:s}=this.viewModel,{sourceIndex:o}=e,r=e.results?.length,i=t.length>1&&s===_.ALL_INDEX,l=this._getSourceName(o);return r&&i?y("calcite-autocomplete-item-group",{heading:l,key:`suggestion-group-${l}-${o}`},this._renderSuggestGroup(e)):this._renderSuggestGroup(e)}_renderSuggestion({key:e,sourceIndex:t,text:s}){const o={key:e,sourceIndex:t};return y("calcite-autocomplete-item",{heading:s??this.messages.untitledResult,key:`suggestion_${e}`,value:JSON.stringify(o)})}_renderSource(e){const t=this._getSourceName(e);return y("calcite-dropdown-item",{"data-source-index":`${e}`,key:`source-${t}-${e}`,selected:e===this.viewModel.activeSourceIndex},t)}_renderNoResultsWarning(e){const{messages:s}=this,o=e?t(s.noResultsFoundForValue,{value:`"${e}"`}):s.noResultsFound;return y("calcite-notice",{icon:"exclamation-mark-triangle",key:"no-results-warning",kind:"warning",open:!0,slot:"content-bottom"},y("div",{slot:"title"},s.noResults),y("div",{slot:"message"},o))}_renderLocateError(){return y("calcite-notice",{icon:"exclamation-mark-circle",key:"locate-warning",kind:"danger",open:!0,slot:"content-bottom"},y("div",{slot:"message"},this.messages.locateError))}_renderNotices(){return this._locateFailed?this._renderLocateError():this._showNoResults?this._renderNoResultsWarning(this._lastSearchTerm??this.viewModel.searchTerm):null}async _useCurrentLocation(){this._cancelQueries();const e=new AbortController,{signal:t}=e;this._searchController=e;try{await this.viewModel.searchNearby({signal:t})}catch(s){a(s)||(this._locateFailed=!0,this.activeMenu="suggestion")}finally{this._searchController=null}}_handleSourceOpen(){this.activeMenu="source"}_handleSourceClose(){"source"===this.activeMenu&&(this.activeMenu="none")}_handleSourceSelect(e){const t=e.target.selectedItems[0].getAttribute("data-source-index");t&&(this.viewModel.activeSourceIndex=parseInt(t,10))}_cancelSuggest(){this.activeMenu="none",this._locateFailed=!1,this._showNoResults=!1,this._suggestController=l(this._suggestController)}_cancelQueries(){this._cancelSuggest(),this._searchController=l(this._searchController)}_scrollToTopSuggestion(){this._autocompleteNode?.scrollContentTo({top:0})}_formSubmit(e){e.preventDefault(),this.activeMenu="none",this._lastSearchTerm=this.searchTerm,this.searchTerm&&this.search()}_getSourceName(e){const{messages:t}=this,{allSources:s}=this.viewModel,o=s.at(e);return e===_.ALL_INDEX?t.all:o?.name||t.untitledSource}};e([d()],C.prototype,"_locateFailed",void 0),e([d()],C.prototype,"_showNoResults",void 0),e([d()],C.prototype,"_isDisabled",null),e([d()],C.prototype,"_showCurrentLocation",null),e([d()],C.prototype,"_effectiveActiveMenu",null),e([d()],C.prototype,"activeMenu",null),e([d({readOnly:!0})],C.prototype,"activeSource",null),e([d()],C.prototype,"activeSourceIndex",null),e([d()],C.prototype,"allPlaceholder",null),e([d({readOnly:!0})],C.prototype,"allSources",null),e([d()],C.prototype,"autoNavigate",null),e([d()],C.prototype,"autoSelect",null),e([d({readOnly:!0})],C.prototype,"defaultSources",null),e([d()],C.prototype,"disabled",void 0),e([d()],C.prototype,"goToOverride",null),e([d()],C.prototype,"icon",null),e([d()],C.prototype,"includeDefaultSources",null),e([d()],C.prototype,"label",null),e([d()],C.prototype,"locationEnabled",null),e([d()],C.prototype,"maxResults",null),e([d()],C.prototype,"maxSuggestions",null),e([d(),S("esri/widgets/Search/t9n/Search")],C.prototype,"messages",void 0),e([d(),S("esri/t9n/common")],C.prototype,"messagesCommon",void 0),e([d()],C.prototype,"minSuggestCharacters",null),e([d()],C.prototype,"popupEnabled",null),e([d()],C.prototype,"popupTemplate",null),e([d()],C.prototype,"portal",null),e([d()],C.prototype,"resultGraphic",null),e([d()],C.prototype,"resultGraphicEnabled",null),e([d({readOnly:!0})],C.prototype,"results",null),e([d()],C.prototype,"searchAllEnabled",null),e([d()],C.prototype,"searchTerm",null),e([d({readOnly:!0})],C.prototype,"selectedResult",null),e([d()],C.prototype,"sources",null),e([d({readOnly:!0})],C.prototype,"suggestions",null),e([d()],C.prototype,"suggestionsEnabled",null),e([d()],C.prototype,"view",null),e([b(["search-complete","search-clear","search-start","select-result","suggest-start","suggest-complete"]),d({type:_})],C.prototype,"viewModel",void 0),C=e([p("esri.widgets.Search")],C);const f=C;export{f as default};
5
+ import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import s from"../PopupTemplate.js";import{deprecateWidget as o,deprecatedPropertyValue as r}from"../core/deprecate.js";import i from"../core/Logger.js";import{destroyMaybe as l,abortMaybe as n}from"../core/maybe.js";import{ignoreAbortErrors as a,isAbortError as c}from"../core/promiseUtils.js";import{watch as u,initial as h}from"../core/reactiveUtils.js";import{waitAnimationFrame as d}from"../core/scheduling.js";import{property as p,subclass as g}from"../core/accessorSupport/decorators.js";import m from"../portal/Portal.js";import v from"./Widget.js";import{css as _}from"./Search/css.js";import w from"./Search/SearchResultRenderer.js";import M from"./Search/SearchViewModel.js";import{SourceCollection as S}from"./Search/types.js";import{loadCalciteComponents as b}from"./support/componentsUtils.js";import{globalCss as y}from"./support/globalCss.js";import{messageBundle as f,vmEvent as C,tsx as T}from"./support/widget.js";let A=class extends v{constructor(e,t){super(e,t),this._currentLocationValue=`${this.id}-search-use-current-location`,this._autocompleteNode=null,this._focusAbortController=null,this._searchResultRenderer=new w,this._suggestController=null,this._searchController=null,this._lastSearchTerm="",this._locateFailed=!1,this._showNoResults=!1,this.disabled=!1,this.messages=null,this.messagesCommon=null,this.viewModel=new M,this._renderSearchResultsContent=()=>this._searchResultRenderer,o(i.getLogger(this),"Search","arcgis-search",{version:"4.33"}),this.addHandles([u(()=>this.viewModel,e=>this._searchResultRenderer.viewModel=e,h),u(()=>this.viewModel.results,()=>this._searchResultRenderer.showMoreResultsOpen=!1),u(()=>this.messages,e=>this.viewModel.messages=e),u(()=>this.viewModel?.defaultPopupTemplate,e=>{e&&(e.content=this._renderSearchResultsContent)},h),u(()=>this.viewModel?.view?.popupElement&&this.viewModel?.defaultPopupTemplate,()=>{if(this.viewModel?.defaultPopupTemplate&&this.viewModel?.view?.popupElement){const e=document.createElement("arcgis-search-result-renderer");e.viewModel=this.viewModel,e.messages=this.messages,this.viewModel.defaultPopupTemplate.content=e}},h)])}loadDependencies(){return b({autocomplete:()=>import("@esri/calcite-components/dist/components/calcite-autocomplete"),"autocomplete-item-group":()=>import("@esri/calcite-components/dist/components/calcite-autocomplete-item-group"),"autocomplete-item":()=>import("@esri/calcite-components/dist/components/calcite-autocomplete-item"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}destroy(){this._cancelQueries(),this._searchResultRenderer=l(this._searchResultRenderer),this._focusAbortController?.abort()}get _isDisabled(){const{state:e}=this.viewModel;return"disabled"===e||"loading"===e||this.disabled}get _showCurrentLocation(){return this.locationEnabled&&!this.searchTerm?.trim()}get _effectiveActiveMenu(){const{activeMenu:e}=this;return this._isDisabled?"none":"warning"===e?"suggestion":e}get activeMenu(){return"none"}set activeMenu(e){"warning"===e&&r(i.getLogger(this),"activeMenu","warning",{replacement:"Use the value 'suggestion' instead",version:"4.32",warnOnce:!0}),this._overrideIfSome("activeMenu",e)}get activeSource(){return this.viewModel?.activeSource}get activeSourceIndex(){return this.viewModel.activeSourceIndex}set activeSourceIndex(e){this.viewModel.activeSourceIndex=e}get allPlaceholder(){return this.viewModel.allPlaceholder}set allPlaceholder(e){this.viewModel.allPlaceholder=e}get allSources(){return this.viewModel.allSources}get autoNavigate(){return this.viewModel.autoNavigate}set autoNavigate(e){this.viewModel.autoNavigate=e}get autoSelect(){return this.viewModel.autoSelect}set autoSelect(e){this.viewModel.autoSelect=e}get defaultSources(){return this.viewModel.defaultSources}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"search"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultSources(){return this.viewModel.includeDefaultSources}set includeDefaultSources(e){this.viewModel.includeDefaultSources=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get locationEnabled(){return this.viewModel.locationEnabled}set locationEnabled(e){this.viewModel.locationEnabled=e}get maxResults(){return this.viewModel.maxResults}set maxResults(e){this.viewModel.maxResults=e}get maxSuggestions(){return this.viewModel.maxSuggestions}set maxSuggestions(e){this.viewModel.maxSuggestions=e}get minSuggestCharacters(){return this.viewModel.minSuggestCharacters}set minSuggestCharacters(e){this.viewModel.minSuggestCharacters=e}get popupEnabled(){return this.viewModel.popupEnabled}set popupEnabled(e){this.viewModel.popupEnabled=e}get popupTemplate(){return this.viewModel.popupTemplate}set popupTemplate(e){this.viewModel.popupTemplate=e}get portal(){return this.viewModel?.portal}set portal(e){this.viewModel&&(this.viewModel.portal=e)}get resultGraphic(){return this.viewModel.resultGraphic}set resultGraphic(e){this.viewModel.resultGraphic=e}get resultGraphicEnabled(){return this.viewModel.resultGraphicEnabled}set resultGraphicEnabled(e){this.viewModel.resultGraphicEnabled=e}get results(){return this.viewModel.results}get searchAllEnabled(){return this.viewModel.searchAllEnabled}set searchAllEnabled(e){this.viewModel.searchAllEnabled=e}get searchTerm(){return this.viewModel.searchTerm}set searchTerm(e){this.viewModel.searchTerm=e}get selectedResult(){return this.viewModel.selectedResult}get sources(){return this.viewModel.sources}set sources(e){this.viewModel.sources=e}get suggestions(){return this.viewModel.suggestions}get suggestionsEnabled(){return this.viewModel.suggestionsEnabled}set suggestionsEnabled(e){this.viewModel.suggestionsEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}clear(){this._locateFailed=!1,this.viewModel.clear()}focus(){this._handleFocus(),this._emitFocus()}blur(){this._autocompleteNode?.blur(),this._emitBlur()}async search(e){this._cancelQueries();const t=new AbortController,{signal:s}=t;this._searchController=t;try{const o=await this.viewModel.search(e,{signal:s});if(this._searchController!==t)return;return o?.numResults||(this._showNoResults=!0,this.activeMenu="suggestion"),this._searchController=null,o}catch(o){if(this._searchController!==t)return;return void(this._searchController=null)}}async suggest(e){this._cancelSuggest();const t=new AbortController,{signal:s}=t;this._suggestController=t;try{const o=await this.viewModel.suggest(e,null,{signal:s});if(this._suggestController!==t)return;return this._suggestController=null,o?.numResults&&(this.activeMenu="suggestion",this._scrollToTopSuggestion()),o}catch(o){return this._suggestController!==t||(this._suggestController=null),null}}render(){return T("div",{class:this.classes(_.base,y.widget)},T("div",{class:_.container},this._renderSourcesMenu(),this._renderForm()))}_handleInputKeydown(e){"Tab"===e.key&&this._cancelSuggest()}_emitFocus(){this.emit("search-focus")}_emitBlur(){this.emit("search-blur")}async _handleFocus(){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const e=this._focusAbortController.signal;await a(d(e)),this._autocompleteNode?.setFocus()}_renderSourcesMenu(){const{messages:e,_isDisabled:t,_effectiveActiveMenu:s}=this,{allSources:o,searchAllEnabled:r}=this.viewModel;return o.length>1?T("calcite-dropdown",{bind:this,class:_.dropdown,disabled:t,open:"source"===s,overlayPositioning:"fixed",onCalciteDropdownClose:this._handleSourceClose,onCalciteDropdownOpen:this._handleSourceOpen,onCalciteDropdownSelect:this._handleSourceSelect},T("calcite-button",{appearance:"outline-fill",iconStart:"caret-down",kind:"neutral",label:e.searchIn,slot:"trigger"}),T("calcite-dropdown-group",{groupTitle:e.searchIn},r?this._renderSource(M.ALL_INDEX):null,o.map((e,t)=>this._renderSource(t)).toArray())):null}_renderUseCurrentLocation(){const{_currentLocationValue:e}=this;return T("calcite-autocomplete-item",{heading:this.messages.useCurrentLocation,iconStart:"gps-on",key:e,value:e})}_handleAutocompleteCreate(e){this._autocompleteNode=e}_handleCalciteAutocompleteTextInput(e){const t=e.target.inputValue;t!==this.viewModel.searchTerm&&(this.viewModel.searchTerm=t,t||this.clear(),this.suggest())}_handleAutocompleteOpen(){this.activeMenu="suggestion"}_handleAutocompleteClose(){"suggestion"===this.activeMenu&&(this.activeMenu="none")}_handleCalciteAutocompleteChange(e){const t=e.target.value;if(t===this._currentLocationValue)return void this._useCurrentLocation();const s=JSON.parse(t),o=this.viewModel.suggestions?.find(({sourceIndex:e})=>e===s.sourceIndex)?.results?.find(({key:e})=>`${e}`==`${s.key}`);o&&this.search(o)}_renderAutocomplete(){const{_effectiveActiveMenu:e,messages:t,_isDisabled:s}=this,{maxInputLength:o,placeholder:r,searchTerm:i,state:l}=this.viewModel,n=this.label??t.searchButtonTitle??"";return T("calcite-autocomplete",{afterCreate:this._handleAutocompleteCreate,autocomplete:"off",bind:this,class:_.autocomplete,disabled:s,icon:this.icon||!1,inputValue:i,label:n,loading:"searching"===l,maxLength:o,name:this.id,onblur:this._emitBlur,onfocus:this._emitFocus,onkeydown:this._handleInputKeydown,open:"suggestion"===e,overlayPositioning:"fixed",placeholder:r,title:i?"":r,onCalciteAutocompleteChange:this._handleCalciteAutocompleteChange,onCalciteAutocompleteClose:this._handleAutocompleteClose,onCalciteAutocompleteOpen:this._handleAutocompleteOpen,onCalciteAutocompleteTextChange:this._handleCalciteAutocompleteTextInput,onCalciteAutocompleteTextInput:this._handleCalciteAutocompleteTextInput},this._renderSuggestions(),this._renderNotices())}_renderForm(){return T("form",{bind:this,class:_.form,disabled:this._isDisabled,key:_.form,onsubmit:this._formSubmit,role:"search"},this._renderAutocomplete(),T("button",{class:_.submitButton,type:"submit"},this.label??this.messages.searchButtonTitle??""))}_renderSuggestGroup(e){return e.results?.map(e=>this._renderSuggestion(e))}_renderSuggestions(){const{suggestions:e}=this.viewModel;return this._showNoResults?null:this._showCurrentLocation?this._renderUseCurrentLocation():e?.map(e=>this._renderSuggestResults(e))}_renderSuggestResults(e){const{allSources:t,activeSourceIndex:s}=this.viewModel,{sourceIndex:o}=e,r=e.results?.length,i=t.length>1&&s===M.ALL_INDEX,l=this._getSourceName(o);return r&&i?T("calcite-autocomplete-item-group",{heading:l,key:`suggestion-group-${l}-${o}`},this._renderSuggestGroup(e)):this._renderSuggestGroup(e)}_renderSuggestion({key:e,sourceIndex:t,text:s}){const o={key:e,sourceIndex:t};return T("calcite-autocomplete-item",{heading:s??this.messages.untitledResult,key:`suggestion_${e}`,value:JSON.stringify(o)})}_renderSource(e){const t=this._getSourceName(e);return T("calcite-dropdown-item",{"data-source-index":`${e}`,key:`source-${t}-${e}`,selected:e===this.viewModel.activeSourceIndex},t)}_renderNoResultsWarning(e){const{messages:s}=this,o=e?t(s.noResultsFoundForValue,{value:`"${e}"`}):s.noResultsFound;return T("calcite-notice",{icon:"exclamation-mark-triangle",key:"no-results-warning",kind:"warning",open:!0,slot:"content-bottom"},T("div",{slot:"title"},s.noResults),T("div",{slot:"message"},o))}_renderLocateError(){return T("calcite-notice",{icon:"exclamation-mark-circle",key:"locate-warning",kind:"danger",open:!0,slot:"content-bottom"},T("div",{slot:"message"},this.messages.locateError))}_renderNotices(){return this._locateFailed?this._renderLocateError():this._showNoResults?this._renderNoResultsWarning(this._lastSearchTerm??this.viewModel.searchTerm):null}async _useCurrentLocation(){this._cancelQueries();const e=new AbortController,{signal:t}=e;this._searchController=e;try{await this.viewModel.searchNearby({signal:t})}catch(s){c(s)||(this._locateFailed=!0,this.activeMenu="suggestion")}finally{this._searchController=null}}_handleSourceOpen(){this.activeMenu="source"}_handleSourceClose(){"source"===this.activeMenu&&(this.activeMenu="none")}_handleSourceSelect(e){const t=e.target.selectedItems[0].getAttribute("data-source-index");t&&(this.viewModel.activeSourceIndex=parseInt(t,10))}_cancelSuggest(){this.activeMenu="none",this._locateFailed=!1,this._showNoResults=!1,this._suggestController=n(this._suggestController)}_cancelQueries(){this._cancelSuggest(),this._searchController=n(this._searchController)}_scrollToTopSuggestion(){this._autocompleteNode?.scrollContentTo({top:0})}_formSubmit(e){e.preventDefault(),this.activeMenu="none",this._lastSearchTerm=this.searchTerm,this.searchTerm&&this.search()}_getSourceName(e){const{messages:t}=this,{allSources:s}=this.viewModel,o=s.at(e);return e===M.ALL_INDEX?t.all:o?.name||t.untitledSource}};e([p()],A.prototype,"_locateFailed",void 0),e([p()],A.prototype,"_showNoResults",void 0),e([p()],A.prototype,"_isDisabled",null),e([p()],A.prototype,"_showCurrentLocation",null),e([p()],A.prototype,"_effectiveActiveMenu",null),e([p()],A.prototype,"activeMenu",null),e([p({readOnly:!0})],A.prototype,"activeSource",null),e([p()],A.prototype,"activeSourceIndex",null),e([p()],A.prototype,"allPlaceholder",null),e([p({readOnly:!0})],A.prototype,"allSources",null),e([p()],A.prototype,"autoNavigate",null),e([p()],A.prototype,"autoSelect",null),e([p({readOnly:!0})],A.prototype,"defaultSources",null),e([p()],A.prototype,"disabled",void 0),e([p()],A.prototype,"goToOverride",null),e([p()],A.prototype,"icon",null),e([p()],A.prototype,"includeDefaultSources",null),e([p()],A.prototype,"label",null),e([p()],A.prototype,"locationEnabled",null),e([p()],A.prototype,"maxResults",null),e([p()],A.prototype,"maxSuggestions",null),e([p(),f("esri/widgets/Search/t9n/Search")],A.prototype,"messages",void 0),e([p(),f("esri/t9n/common")],A.prototype,"messagesCommon",void 0),e([p()],A.prototype,"minSuggestCharacters",null),e([p()],A.prototype,"popupEnabled",null),e([p({type:s})],A.prototype,"popupTemplate",null),e([p({type:m})],A.prototype,"portal",null),e([p()],A.prototype,"resultGraphic",null),e([p()],A.prototype,"resultGraphicEnabled",null),e([p({readOnly:!0})],A.prototype,"results",null),e([p()],A.prototype,"searchAllEnabled",null),e([p()],A.prototype,"searchTerm",null),e([p({readOnly:!0})],A.prototype,"selectedResult",null),e([p({type:S})],A.prototype,"sources",null),e([p({readOnly:!0})],A.prototype,"suggestions",null),e([p()],A.prototype,"suggestionsEnabled",null),e([p()],A.prototype,"view",null),e([C(["search-complete","search-clear","search-start","select-result","suggest-start","suggest-complete"]),p({type:M})],A.prototype,"viewModel",void 0),A=e([g("esri.widgets.Search")],A);const R=A;export{R as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{onLocaleChange as i,formatDate as t}from"../intl.js";import{deprecateWidget as o}from"../core/deprecate.js";import"../core/has.js";import s from"../core/Logger.js";import{destroyMaybe as l}from"../core/maybe.js";import{watch as n,syncAndInitial as r}from"../core/reactiveUtils.js";import{convertTime as a}from"../core/timeUtils.js";import{property as d,subclass as c}from"../core/accessorSupport/decorators.js";import{substitute as m}from"../intl/substitute.js";import p from"./Slider.js";import h from"./Widget.js";import{css as u}from"./ShadowCast/css.js";import v from"./ShadowCast/ShadowCastViewModel.js";import g from"./ShadowCast/ShadowCastVisibleElements.js";import{DiscreteConfigurator as w}from"./ShadowCast/components/DiscreteConfigurator.js";import{DurationConfigurator as f}from"./ShadowCast/components/DurationConfigurator.js";import{ShadowTooltip as b}from"./ShadowCast/components/ShadowTooltip.js";import{ThresholdConfigurator as C}from"./ShadowCast/components/ThresholdConfigurator.js";import{loadCalciteComponents as _}from"./support/componentsUtils.js";import{globalCss as y}from"./support/globalCss.js";import{Heading as S}from"./support/Heading.js";import{onPrimaryTickCreated as k,onSecondaryTickCreated as M,formatSliderLabel as T,adjustTimeSliderForLocale as V,timeStringFormattingOptions as j}from"./support/timeWidgetUtils.js";import{TimezonePicker as z}from"./support/TimezonePicker.js";import{messageBundle as D,tsx as O}from"./support/widget.js";const P={labelFormatFunction:T,min:0,max:1439,steps:15,rangeLabelInputsEnabled:!1,visibleElements:{labels:!1,rangeLabels:!1},tickConfigs:[{mode:"position",values:[0,360,720,1080,1439],labelsVisible:!0,tickCreatedFunction:(e,i,t)=>k({tickElement:i,labelElement:t})},{mode:"position",values:[120,240,480,600,840,960,1200,1320],tickCreatedFunction:(e,i)=>M({tickElement:i})}]};let E=class extends h{constructor(e,i){super(e,i),this.viewModel=null,this.headingLevel=4,this.visibleElements=new g,this._defaultViewModel=null,this._timeSlider=new p({...P,container:document.createElement("div")}),this._tooltip=null,this._onTimezoneChange=e=>{this.viewModel.utcOffset=e},this._onDateChange=e=>{const i=e.currentTarget.valueAsDate;this.viewModel.date=Array.isArray(i)?i[0]:i},o(s.getLogger(this),"Shadow Cast","arcgis-shadow-cast",{version:"5.0"}),e?.viewModel||(this._defaultViewModel=new v({view:e?.view,isDefaultViewModel:!0}),this.viewModel=this._defaultViewModel)}initialize(){this.addHandles([n(()=>({viewModel:this.viewModel,slider:this._timeSlider}),e=>this._connectTimeSlider(e),r),n(()=>({container:this.view?.surface,viewModel:this.viewModel,tooltipVisible:this.visibleElements.tooltip}),({container:e,viewModel:i,tooltipVisible:t})=>{this._tooltip=l(this._tooltip),null!=e&&t&&(this._tooltip=new b({viewModel:i,container:e}))},r),n(()=>({viewModel:this.viewModel,visible:this.visible}),({viewModel:e,visible:i})=>e.setRunning(i),r)])}destroy(){this._timeSlider=l(this._timeSlider),this._tooltip=l(this._tooltip),null!=this._defaultViewModel&&this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy()}loadDependencies(){return _({"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),option:()=>import("@esri/calcite-components/dist/components/calcite-option"),select:()=>import("@esri/calcite-components/dist/components/calcite-select")})}render(){const{visibleElements:e,viewModel:i}=this,t="disabled"===i.state;return O("div",{class:this.classes(u.base,y.widget,y.panel,{[y.widgetDisabled]:t}),key:this},this._renderTimeRangeSection(),e.visualizationOptions?this._renderVisualizationOptionsSection():null)}get view(){return this.viewModel?.view}set view(e){this.viewModel&&(this.viewModel.view=e)}get icon(){return"measure-building-height-shadow"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get testData(){}_connectTimeSlider({viewModel:e,slider:t}){if(this.removeHandles("slider"),null==t)return;const o=e=>a(e,"milliseconds","minutes"),s=e=>a(e,"minutes","milliseconds"),l=({index:i,value:t})=>{0===i?e.startTimeOfDay=s(t):e.endTimeOfDay=s(t)},d=()=>V(t.domNode);d(),this.addHandles([n(()=>[e.startTimeOfDay,e.endTimeOfDay],e=>{t.values=e.map(o)},r),t.on("thumb-change",l),t.on("thumb-drag",l),t.on("segment-drag",()=>{[e.startTimeOfDay,e.endTimeOfDay]=t.values.map(s)}),i(d)],"slider")}_renderTimeRangeSection(){const{visibleElements:e}=this;return e.timeRangeSlider||e.datePicker?O("section",{class:u.timeRange,key:"time-range"},O(S,{level:this.headingLevel},this.messages.timeLabel),e.timeRangeSlider?this._renderTimeRange():null,e.datePicker?this._renderDatePicker():null):null}_renderTimeRange(){const{messages:e,viewModel:i,visibleElements:o}=this,{startTimeOfDay:s,endTimeOfDay:l}=i,[n,r]=[s,l].map(e=>t(new Date(e),j));return[O("div",{class:u.timeRangeIndicator,key:"time-range-indicator"},m(e.timeRange,{start:n,end:r}),o.timezone?O(z,{disabled:this._timeSlider?.disabled,value:i.utcOffset,onChange:this._onTimezoneChange}):null),O("div",{afterCreate:this._timeSliderContainerAfterCreate,afterRemoved:this._timeSliderContainerAfterRemoved,bind:this,key:"time-slider-container"})]}_timeSliderContainerAfterCreate(e){const i=this._timeSlider?.container;i&&e.appendChild(i)}_timeSliderContainerAfterRemoved(e){const i=this._timeSlider?.container;i&&e.removeChild(i)}_renderDatePicker(){return O("div",{class:u.datePickerContainer,key:u.datePickerContainer},O("calcite-input-date-picker",{class:u.datePicker,"data-testid":"date-picker",key:u.datePicker,overlayPositioning:"fixed",placement:"bottom",scale:"s",valueAsDate:this.viewModel.date,onCalciteInputDatePickerChange:this._onDateChange}))}_renderVisualizationOptionsSection(){const{headingLevel:e,messages:i,viewModel:t,visibleElements:o}=this,{colorPicker:s,thresholdContext:l,thresholdContextToggle:n,thresholdContextTimeInterval:r,thresholdContextColor:a}=o,d=e=>this.classes(t.visualizationType===e?null:u.visualizationConfigHidden);return O("section",{class:u.visualization,key:"visualization"},O(S,{level:e},i.visualizationLabel),this._renderVisualizationSelect(),O("div",{class:d("threshold"),key:"threshold-configurator"},O(C,{colorPickerVisible:s,contextColorPickerVisible:a,contextTimeIntervalVisible:r,contextToggleVisible:n,contextVisible:l,options:t.thresholdOptions})),O("div",{class:d("duration"),key:"duration-configurator"},O(f,{colorPickerVisible:s,options:t.durationOptions})),O("div",{class:d("discrete"),key:"discrete-configurator"},O(w,{colorPickerVisible:s,options:t.discreteOptions})))}_renderVisualizationSelect(){const e=this.messages,i=this.viewModel.visualizationType;return O("calcite-select",{bind:this,class:u.visualizationSelect,key:"visualization-select",label:e.visualizationLabel,scale:"s",onCalciteSelectChange:this._onVisualizationTypeChange},[{type:"threshold",label:e.threshold.label},{type:"duration",label:e.duration.label},{type:"discrete",label:e.discrete.label}].map(({type:e,label:t})=>O("calcite-option",{selected:e===i,value:e},t)))}_onVisualizationTypeChange(e){const i=e.currentTarget.selectedOption?.value;this.viewModel.visualizationType=i??"threshold"}};e([d()],E.prototype,"viewModel",void 0),e([d()],E.prototype,"view",null),e([d()],E.prototype,"headingLevel",void 0),e([d()],E.prototype,"icon",null),e([d()],E.prototype,"label",null),e([d({type:g,nonNullable:!0})],E.prototype,"visibleElements",void 0),e([d(),D("esri/widgets/ShadowCast/t9n/ShadowCast")],E.prototype,"messages",void 0),e([d()],E.prototype,"_defaultViewModel",void 0),e([d()],E.prototype,"_timeSlider",void 0),e([d()],E.prototype,"_tooltip",void 0),E=e([c("esri.widgets.ShadowCast")],E);const x=E;export{x as default};
5
+ import{__decorate as e}from"tslib";import{onLocaleChange as i,formatDate as t}from"../intl.js";import{deprecateWidget as o}from"../core/deprecate.js";import"../core/has.js";import s from"../core/Logger.js";import{destroyMaybe as l}from"../core/maybe.js";import{watch as n,syncAndInitial as r}from"../core/reactiveUtils.js";import{convertTime as a}from"../core/timeUtils.js";import{property as d,subclass as c}from"../core/accessorSupport/decorators.js";import{substitute as m}from"../intl/substitute.js";import p from"./Slider.js";import h from"./Widget.js";import{css as u}from"./ShadowCast/css.js";import v from"./ShadowCast/ShadowCastViewModel.js";import g from"./ShadowCast/ShadowCastVisibleElements.js";import{DiscreteConfigurator as w}from"./ShadowCast/components/DiscreteConfigurator.js";import{DurationConfigurator as f}from"./ShadowCast/components/DurationConfigurator.js";import{ShadowTooltip as b}from"./ShadowCast/components/ShadowTooltip.js";import{ThresholdConfigurator as C}from"./ShadowCast/components/ThresholdConfigurator.js";import{loadCalciteComponents as y}from"./support/componentsUtils.js";import{globalCss as _}from"./support/globalCss.js";import{Heading as S}from"./support/Heading.js";import{onPrimaryTickCreated as k,onSecondaryTickCreated as M,formatSliderLabel as T,adjustTimeSliderForLocale as V,timeStringFormattingOptions as j}from"./support/timeWidgetUtils.js";import{TimezonePicker as z}from"./support/TimezonePicker.js";import{messageBundle as D,tsx as O}from"./support/widget.js";const P={labelFormatFunction:T,min:0,max:1439,steps:15,rangeLabelInputsEnabled:!1,visibleElements:{labels:!1,rangeLabels:!1},tickConfigs:[{mode:"position",values:[0,360,720,1080,1439],labelsVisible:!0,tickCreatedFunction:(e,i,t)=>k({tickElement:i,labelElement:t})},{mode:"position",values:[120,240,480,600,840,960,1200,1320],tickCreatedFunction:(e,i)=>M({tickElement:i})}]};let E=class extends h{constructor(e,i){super(e,i),this.viewModel=null,this.headingLevel=4,this.visibleElements=new g,this._defaultViewModel=null,this._timeSlider=new p({...P,container:document.createElement("div")}),this._tooltip=null,this._onTimezoneChange=e=>{this.viewModel.utcOffset=e},this._onDateChange=e=>{const i=e.currentTarget.valueAsDate;this.viewModel.date=Array.isArray(i)?i[0]:i},o(s.getLogger(this),"Shadow Cast","arcgis-shadow-cast",{version:"5.0"}),e?.viewModel||(this._defaultViewModel=new v({view:e?.view,isDefaultViewModel:!0}),this.viewModel=this._defaultViewModel)}initialize(){this.addHandles([n(()=>({viewModel:this.viewModel,slider:this._timeSlider}),e=>this._connectTimeSlider(e),r),n(()=>({container:this.view?.surface,viewModel:this.viewModel,tooltipVisible:this.visibleElements.tooltip}),({container:e,viewModel:i,tooltipVisible:t})=>{this._tooltip=l(this._tooltip),null!=e&&t&&(this._tooltip=new b({viewModel:i,container:e}))},r),n(()=>({viewModel:this.viewModel,visible:this.visible}),({viewModel:e,visible:i})=>e.setRunning(i),r)])}destroy(){this._timeSlider=l(this._timeSlider),this._tooltip=l(this._tooltip),null!=this._defaultViewModel&&this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy()}loadDependencies(){return y({"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),option:()=>import("@esri/calcite-components/dist/components/calcite-option"),select:()=>import("@esri/calcite-components/dist/components/calcite-select")})}render(){const{visibleElements:e,viewModel:i}=this,t="disabled"===i.state;return O("div",{class:this.classes(u.base,_.widget,_.panel,{[_.widgetDisabled]:t}),key:this},this._renderTimeRangeSection(),e.visualizationOptions?this._renderVisualizationOptionsSection():null)}get view(){return this.viewModel?.view}set view(e){this.viewModel&&(this.viewModel.view=e)}get icon(){return"measure-building-height-shadow"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get testData(){}_connectTimeSlider({viewModel:e,slider:t}){if(this.removeHandles("slider"),null==t)return;const o=e=>a(e,"milliseconds","minutes"),s=e=>a(e,"minutes","milliseconds"),l=({index:i,value:t})=>{0===i?e.startTimeOfDay=s(t):e.endTimeOfDay=s(t)},d=()=>V(t.domNode);d(),this.addHandles([n(()=>[e.startTimeOfDay,e.endTimeOfDay],e=>{t.values=e.map(o)},r),t.on("thumb-change",l),t.on("thumb-drag",l),t.on("segment-drag",()=>{[e.startTimeOfDay,e.endTimeOfDay]=t.values.map(s)}),i(d)],"slider")}_renderTimeRangeSection(){const{visibleElements:e}=this;return e.timeRangeSlider||e.datePicker?O("section",{class:u.timeRange,key:"time-range"},O(S,{level:this.headingLevel},this.messages.timeLabel),e.timeRangeSlider?this._renderTimeRange():null,e.datePicker?this._renderDatePicker():null):null}_renderTimeRange(){const{messages:e,viewModel:i,visibleElements:o}=this,{startTimeOfDay:s,endTimeOfDay:l}=i,[n,r]=[s,l].map(e=>t(new Date(e),j));return[O("div",{class:u.timeRangeIndicator,key:"time-range-indicator"},m(e.timeRange,{start:n,end:r}),o.timezone?O(z,{disabled:this._timeSlider?.disabled,value:i.utcOffset,onChange:this._onTimezoneChange}):null),O("div",{afterCreate:this._timeSliderContainerAfterCreate,afterRemoved:this._timeSliderContainerAfterRemoved,bind:this,key:"time-slider-container"})]}_timeSliderContainerAfterCreate(e){const i=this._timeSlider?.container;i&&e.appendChild(i)}_timeSliderContainerAfterRemoved(e){const i=this._timeSlider?.container;i&&e.removeChild(i)}_renderDatePicker(){return O("div",{class:u.datePickerContainer,key:u.datePickerContainer},O("calcite-input-date-picker",{class:u.datePicker,"data-testid":"date-picker",key:u.datePicker,overlayPositioning:"fixed",placement:"bottom",scale:"s",valueAsDate:this.viewModel.date,onCalciteInputDatePickerChange:this._onDateChange}))}_renderVisualizationOptionsSection(){const{headingLevel:e,messages:i,viewModel:t,visibleElements:o}=this,{colorPicker:s,thresholdContext:l,thresholdContextToggle:n,thresholdContextTimeInterval:r,thresholdContextColor:a}=o,d=e=>this.classes(t.visualizationType===e?null:u.visualizationConfigHidden);return O("section",{class:u.visualization,key:"visualization"},O(S,{level:e},i.visualizationLabel),this._renderVisualizationSelect(),O("div",{class:d("threshold"),key:"threshold-configurator"},O(C,{colorPickerVisible:s,contextColorPickerVisible:a,contextTimeIntervalVisible:r,contextToggleVisible:n,contextVisible:l,options:t.thresholdOptions})),O("div",{class:d("duration"),key:"duration-configurator"},O(f,{colorPickerVisible:s,options:t.durationOptions})),O("div",{class:d("discrete"),key:"discrete-configurator"},O(w,{colorPickerVisible:s,options:t.discreteOptions})))}_renderVisualizationSelect(){const e=this.messages,i=this.viewModel.visualizationType;return O("calcite-select",{bind:this,class:u.visualizationSelect,key:"visualization-select",label:e.visualizationLabel,scale:"s",onCalciteSelectChange:this._onVisualizationTypeChange},[{type:"threshold",label:e.threshold.label},{type:"duration",label:e.duration.label},{type:"discrete",label:e.discrete.label}].map(({type:e,label:t})=>O("calcite-option",{selected:e===i,value:e},t)))}_onVisualizationTypeChange(e){const i=e.currentTarget.selectedOption?.value;this.viewModel.visualizationType=i??"threshold"}};e([d({type:v})],E.prototype,"viewModel",void 0),e([d()],E.prototype,"view",null),e([d()],E.prototype,"headingLevel",void 0),e([d()],E.prototype,"icon",null),e([d()],E.prototype,"label",null),e([d({type:g,nonNullable:!0})],E.prototype,"visibleElements",void 0),e([d(),D("esri/widgets/ShadowCast/t9n/ShadowCast")],E.prototype,"messages",void 0),e([d()],E.prototype,"_defaultViewModel",void 0),e([d()],E.prototype,"_timeSlider",void 0),e([d()],E.prototype,"_tooltip",void 0),E=e([c("esri.widgets.ShadowCast")],E);const x=E;export{x as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{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};