@arcgis/core 5.0.0-next.68 → 5.0.0-next.69

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 (336) hide show
  1. package/Ground.d.ts +3 -4
  2. package/WebDocument2D.d.ts +1 -1
  3. package/WebLinkChart.d.ts +2 -0
  4. package/analysis/ElevationProfile/ElevationProfileLineQuery.d.ts +3 -4
  5. package/analysis/types.d.ts +1 -0
  6. package/applications/Components/analysisUtils.d.ts +1 -3
  7. package/applications/Components/arcadeFeatureUtils.d.ts +1 -1
  8. package/applications/ExperienceBuilder/sketchUtils.d.ts +2 -2
  9. package/applications/KnowledgeStudio/reshape.d.ts +2 -2
  10. package/applications/SceneViewer/sceneViewerUtils.d.ts +11 -0
  11. package/applications/SceneViewer/sceneViewerUtils.js +1 -1
  12. package/assets/esri/core/libs/libtess/libtess-f32.wasm +0 -0
  13. package/assets/esri/core/libs/libtess/libtess-f64.wasm +0 -0
  14. package/assets/esri/core/workers/RemoteClient.js +1 -1
  15. package/assets/esri/core/workers/chunks/{c623918e289a09905cd1.js → 01d7542d85a453384cf1.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{168ec8fca2702617a543.js → 09dfec3e097ebbef6a89.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{794960ec36e11f4416c2.js → 1d1e25bb61eeeee8ee94.js} +1 -1
  18. package/assets/esri/core/workers/chunks/2e2c47f8a80ee9234350.js +1 -0
  19. package/assets/esri/core/workers/chunks/{b2a1e5e9182b643909eb.js → 4c04c54330b693892cfc.js} +47 -49
  20. package/assets/esri/core/workers/chunks/563933a84fc9b0e021f6.js +1 -0
  21. package/assets/esri/core/workers/chunks/58b3a776ef129f7f86dc.js +1 -0
  22. package/assets/esri/core/workers/chunks/58e8d41dcc450e6427c9.js +1 -0
  23. package/assets/esri/core/workers/chunks/6c9dac4a869742cc2718.js +1 -0
  24. package/assets/esri/core/workers/chunks/{e5aac523c37d906eece6.js → 827277e5da652bcecaf2.js} +1 -1
  25. package/assets/esri/core/workers/chunks/9f34cf024231f574009c.js +1 -0
  26. package/assets/esri/core/workers/chunks/a10c6dd3bb8b3602de68.js +1 -0
  27. package/assets/esri/core/workers/chunks/a64cd02ca959d511101c.js +1 -0
  28. package/assets/esri/core/workers/chunks/{0f8149fdcf0adeca268e.js → b28e0b89603d8b03f9e1.js} +1 -1
  29. package/assets/esri/core/workers/chunks/b5e4a36784d598ae6679.js +1 -0
  30. package/assets/esri/core/workers/chunks/{204d738c8b651314ae64.js → b899b4e7979c13b99526.js} +1 -1
  31. package/assets/esri/core/workers/chunks/bf05164b7a3e4f31e9db.js +1 -0
  32. package/assets/esri/core/workers/chunks/d0ae8752419d5b761190.js +1 -0
  33. package/assets/esri/core/workers/chunks/dbfb00fb28b8b9f687a1.js +1 -0
  34. package/assets/esri/core/workers/chunks/e071b912539304564b69.js +1 -0
  35. package/assets/esri/core/workers/chunks/{ab71865b94022e78035c.js → f92845eb7df1804fcd6d.js} +1 -1
  36. package/assets/esri/themes/base/widgets/_BatchAttributeForm.scss +108 -0
  37. package/assets/esri/themes/dark/main.css +1 -1
  38. package/assets/esri/themes/light/main.css +1 -1
  39. package/assets/esri/themes/light/view.css +1 -1
  40. package/chunks/GaussianSplat.glsl.js +2 -2
  41. package/chunks/GaussianSplatDepthComposition.glsl.js +4 -5
  42. package/chunks/HUDMaterial.glsl.js +45 -47
  43. package/chunks/LineMarker.glsl.js +33 -34
  44. package/chunks/PointRenderer.glsl.js +6 -6
  45. package/chunks/RibbonLine.glsl.js +62 -54
  46. package/chunks/libtess-f32.js +1 -1
  47. package/chunks/libtess-f64.js +1 -1
  48. package/config.js +1 -1
  49. package/core/Collection.d.ts +3 -2
  50. package/core/Identifiable.d.ts +1 -3
  51. package/core/accessorSupport/types.d.ts +0 -8
  52. package/core/promiseUtils.d.ts +1 -1
  53. package/core/reactiveUtils.d.ts +2 -2
  54. package/core/units.d.ts +8 -2
  55. package/geometry/HeightModelInfo.d.ts +3 -3
  56. package/geometry/SpatialReference.d.ts +2 -2
  57. package/geometry/libtess.js +1 -1
  58. package/geometry/support/meshUtils/types.d.ts +2 -2
  59. package/geometry/types.d.ts +2 -0
  60. package/identity/IdentityManagerBase.d.ts +4 -4
  61. package/interfaces.d.ts +2937 -2954
  62. package/kernel.js +1 -1
  63. package/layers/BaseElevationLayer.d.ts +3 -4
  64. package/layers/ElevationLayer.d.ts +3 -4
  65. package/layers/FeatureLayer.d.ts +12 -11
  66. package/layers/FeatureLayer.js +1 -1
  67. package/layers/GroupLayer.d.ts +3 -3
  68. package/layers/ImageryLayer.d.ts +3 -3
  69. package/layers/ImageryTileLayer.d.ts +3 -4
  70. package/layers/Layer.d.ts +4 -4
  71. package/layers/LineOfSightLayer.d.ts +1 -1
  72. package/layers/LinkChartLayer.js +1 -1
  73. package/layers/MapImageLayer.d.ts +7 -8
  74. package/layers/MediaLayer.d.ts +3 -3
  75. package/layers/OrientedImageryLayer.d.ts +3 -3
  76. package/layers/ParquetLayer.d.ts +1 -1
  77. package/layers/ParquetLayer.js +1 -1
  78. package/layers/RouteLayer.d.ts +2 -3
  79. package/layers/SceneLayer.d.ts +167 -3
  80. package/layers/SceneLayer.js +1 -1
  81. package/layers/StreamLayer.d.ts +3 -3
  82. package/layers/SubtypeGroupLayer.d.ts +3 -3
  83. package/layers/WCSLayer.d.ts +3 -3
  84. package/layers/graphics/sources/ParquetSource.d.ts +1 -1
  85. package/layers/graphics/sources/support/QueryTask.js +1 -1
  86. package/layers/mixins/SceneService.d.ts +2 -2
  87. package/layers/orientedImagery/queries.js +1 -1
  88. package/layers/orientedImagery/transformations/imageToWorld.d.ts +2 -2
  89. package/layers/orientedImagery/transformations/types.d.ts +1 -1
  90. package/layers/raster/datasets/pixelReader.d.ts +1 -7
  91. package/layers/raster/functions/creators/createBandIndexFunctions.d.ts +29 -29
  92. package/layers/support/BuildingFilterMode.d.ts +3 -1
  93. package/layers/support/BuildingFilterMode.js +1 -1
  94. package/layers/support/BuildingFilterModeSolid.js +1 -1
  95. package/layers/support/BuildingFilterModeWireFrame.js +1 -1
  96. package/layers/support/BuildingFilterModeXRay.js +1 -1
  97. package/layers/support/CodedValue.d.ts +1 -1
  98. package/layers/support/ControlPoint.d.ts +6 -20
  99. package/layers/support/ControlPointsGeoreference.d.ts +2 -1
  100. package/layers/support/ElevationSampler.d.ts +2 -2
  101. package/layers/support/FeatureReductionBinning.d.ts +4 -4
  102. package/layers/support/FeatureReductionBinning.js +1 -1
  103. package/layers/support/FeatureReductionSelection.d.ts +3 -3
  104. package/layers/support/FeatureReductionSelection.js +1 -1
  105. package/layers/support/Field.d.ts +1 -2
  106. package/layers/support/ParquetGeometryEncodingLocation.d.ts +6 -4
  107. package/layers/support/ParquetGeometryEncodingLocation.js +1 -1
  108. package/layers/support/ParquetGeometryEncodingWkb.d.ts +6 -4
  109. package/layers/support/ParquetGeometryEncodingWkb.js +1 -1
  110. package/layers/support/PixelBlock.d.ts +11 -3
  111. package/layers/support/RangeDomain.d.ts +2 -1
  112. package/layers/support/SceneServiceTimeInfo.js +5 -0
  113. package/layers/support/SpriteSource.d.ts +1 -0
  114. package/layers/support/Sublayer.d.ts +17 -16
  115. package/layers/support/Sublayer.js +1 -1
  116. package/layers/support/featureReductionUtils.js +1 -1
  117. package/layers/support/rasterFunctionUtils.d.ts +30 -30
  118. package/layers/support/types.d.ts +101 -1
  119. package/layers/types.d.ts +12 -1
  120. package/layers/wms/types.d.ts +0 -4
  121. package/networks/CircuitManager.d.ts +5 -5
  122. package/networks/Network.d.ts +5 -5
  123. package/networks/UtilityNetwork.d.ts +2 -2
  124. package/package.json +2 -2
  125. package/popup/content/types.d.ts +1 -3
  126. package/portal/PortalItem.d.ts +8 -8
  127. package/portal/PortalItemResource.d.ts +2 -2
  128. package/portal/PortalUser.d.ts +3 -3
  129. package/portal/support/resourceUtils.d.ts +3 -3
  130. package/portal/types.d.ts +6 -6
  131. package/renderers/support/pointCloud/types.d.ts +1 -0
  132. package/renderers/support/raster/types.d.ts +1 -0
  133. package/renderers/types.d.ts +2 -0
  134. package/rest/knowledgeGraph/wasmInterface/WasmDataModelWrapperInterfaces.d.ts +0 -2
  135. package/rest/layerSources/DynamicDataLayer.d.ts +102 -0
  136. package/rest/layerSources/DynamicDataLayer.js +5 -0
  137. package/{layers/support/source/MapLayerSource.d.ts → rest/layerSources/DynamicMapLayer.d.ts} +4 -4
  138. package/rest/layerSources/DynamicMapLayer.js +5 -0
  139. package/rest/layerSources/JoinTableDataSource.d.ts +75 -0
  140. package/rest/layerSources/JoinTableDataSource.js +5 -0
  141. package/{layers/support/source → rest/layerSources}/QueryTableDataSource.d.ts +8 -7
  142. package/rest/layerSources/QueryTableDataSource.js +5 -0
  143. package/{layers/support/source → rest/layerSources}/RasterDataSource.d.ts +2 -2
  144. package/rest/layerSources/RasterDataSource.js +5 -0
  145. package/{layers/support/source → rest/layerSources}/TableDataSource.d.ts +2 -2
  146. package/rest/layerSources/TableDataSource.js +5 -0
  147. package/rest/layerSources/utils.js +5 -0
  148. package/rest/print.js +1 -1
  149. package/rest/query/executeQuery.js +1 -1
  150. package/rest/support/Query.js +1 -1
  151. package/rest/support/RelationshipQuery.js +1 -1
  152. package/rest/support/types.d.ts +0 -4
  153. package/smartMapping/heuristics/binLevel.d.ts +2 -2
  154. package/smartMapping/heuristics/scaleRange.d.ts +2 -2
  155. package/smartMapping/heuristics/sizeRange.d.ts +2 -2
  156. package/smartMapping/heuristics/types.d.ts +3 -3
  157. package/smartMapping/labels/bins.d.ts +2 -2
  158. package/smartMapping/labels/clusters.d.ts +2 -2
  159. package/smartMapping/renderers/color.d.ts +14 -14
  160. package/smartMapping/renderers/dotDensity.d.ts +2 -2
  161. package/smartMapping/renderers/heatmap.d.ts +4 -4
  162. package/smartMapping/renderers/location.d.ts +2 -2
  163. package/smartMapping/renderers/opacity.d.ts +2 -2
  164. package/smartMapping/renderers/pieChart.d.ts +4 -4
  165. package/smartMapping/renderers/predominance.d.ts +2 -2
  166. package/smartMapping/renderers/relationship.d.ts +4 -4
  167. package/smartMapping/renderers/size.d.ts +15 -15
  168. package/smartMapping/renderers/support/rendererUtils.d.ts +2 -2
  169. package/smartMapping/renderers/type.d.ts +4 -4
  170. package/smartMapping/renderers/univariateColorSize.d.ts +4 -4
  171. package/smartMapping/statistics/classBreaks.d.ts +2 -2
  172. package/smartMapping/statistics/heatmapStatistics.d.ts +2 -2
  173. package/smartMapping/statistics/histogram.d.ts +2 -2
  174. package/smartMapping/statistics/predominantCategories.d.ts +2 -2
  175. package/smartMapping/statistics/summaryStatistics.d.ts +2 -2
  176. package/smartMapping/statistics/summaryStatisticsForAge.d.ts +2 -2
  177. package/smartMapping/statistics/support/ageUtils.d.ts +2 -2
  178. package/smartMapping/statistics/types.d.ts +7 -7
  179. package/smartMapping/statistics/uniqueValues.d.ts +2 -2
  180. package/smartMapping/symbology/color.d.ts +8 -8
  181. package/smartMapping/symbology/dotDensity.d.ts +6 -6
  182. package/smartMapping/symbology/flow.d.ts +6 -6
  183. package/smartMapping/symbology/heatmap.d.ts +6 -6
  184. package/smartMapping/symbology/location.d.ts +2 -2
  185. package/smartMapping/symbology/pieChart.d.ts +6 -6
  186. package/smartMapping/symbology/predominance.d.ts +6 -6
  187. package/smartMapping/symbology/relationship.d.ts +6 -6
  188. package/smartMapping/symbology/size.d.ts +2 -2
  189. package/smartMapping/symbology/support/colorRamps.d.ts +2 -2
  190. package/smartMapping/symbology/type.d.ts +6 -6
  191. package/support/popupUtils.d.ts +2 -2
  192. package/support/revision.js +1 -1
  193. package/symbols/LineSymbol3D.d.ts +2 -2
  194. package/symbols/PointSymbol3D.d.ts +2 -2
  195. package/symbols/PolygonSymbol3D.d.ts +2 -2
  196. package/symbols/patterns/LinePattern3D.d.ts +8 -0
  197. package/symbols/patterns/LineStylePattern3D.d.ts +1 -2
  198. package/symbols/patterns/Pattern3D.d.ts +9 -0
  199. package/symbols/patterns/StylePattern3D.d.ts +1 -2
  200. package/symbols/types.d.ts +7 -0
  201. package/unionTypes.d.ts +13 -13
  202. package/views/2d/analysis/types.d.ts +1 -0
  203. package/views/2d/engine/vectorTiles/shaders/sources/shaderRepository.js +1 -1
  204. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  205. package/views/2d/layers/BaseLayerView2D.d.ts +0 -5
  206. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  207. package/views/2d/layers/StreamLayerView2D.js +1 -1
  208. package/views/2d/layers/features/Processor.js +1 -1
  209. package/views/2d/layers/support/MediaLayerInteractionOptions.js +1 -1
  210. package/views/3d/analysis/LineOfSightAnalysisView3D.d.ts +0 -2
  211. package/views/3d/analysis/types.d.ts +1 -0
  212. package/views/3d/environment/SunLighting.d.ts +1 -3
  213. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  214. package/views/3d/layers/support/MediaLayerInteractionOptions.d.ts +4 -0
  215. package/views/3d/support/QualityProfile.js +1 -1
  216. package/views/3d/support/QualitySettings.js +1 -1
  217. package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
  218. package/views/3d/support/gaussianSplatting/GaussianSplatFadeTexture.js +1 -1
  219. package/views/3d/webgl-engine/collections/Component/Transform.js +1 -1
  220. package/views/3d/webgl-engine/core/shaderLibrary/shading/PositionOutsideClipSpace.js +5 -0
  221. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  222. package/views/3d/webgl-engine/lib/LocalOriginManager.js +1 -1
  223. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  224. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  225. package/views/3d/webgl-engine/lib/edgeRendering/LegacyTransform.js +5 -0
  226. package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
  227. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  228. package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
  229. package/views/3d/webgl-engine/shaders/LineMarker.glsl.js +1 -1
  230. package/views/3d/webgl-engine/shaders/PointRenderer.glsl.js +1 -1
  231. package/views/3d/webgl-engine/shaders/RibbonLine.glsl.js +1 -1
  232. package/views/SceneView.js +1 -1
  233. package/views/View.js +1 -1
  234. package/views/View2D.js +1 -1
  235. package/views/analysis/types.d.ts +4 -0
  236. package/views/input/types.d.ts +2 -4
  237. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
  238. package/views/layers/CatalogLayerView.d.ts +1 -4
  239. package/views/layers/DimensionLayerView.d.ts +4 -6
  240. package/views/layers/DimensionLayerViewMixin.d.ts +0 -97
  241. package/views/layers/LineOfSightLayerView.d.ts +4 -6
  242. package/views/layers/LineOfSightLayerViewMixin.d.ts +0 -77
  243. package/views/layers/StreamLayerView.d.ts +31 -2
  244. package/views/support/WebAssemblyRequirements.js +5 -0
  245. package/views/support/WebGLRequirements.js +1 -1
  246. package/webdoc/support/SlideThumbnail.d.ts +6 -3
  247. package/webdoc/support/SlideThumbnail.js +1 -1
  248. package/webscene/spec-certification/api.js +1 -1
  249. package/widgets/AreaMeasurement2D/AreaMeasurement2DViewModel.d.ts +2 -2
  250. package/widgets/AreaMeasurement2D/AreaMeasurement2DViewModel.js +1 -1
  251. package/widgets/AreaMeasurement3D/AreaMeasurement3DViewModel.d.ts +2 -2
  252. package/widgets/AreaMeasurement3D/AreaMeasurement3DViewModel.js +1 -1
  253. package/widgets/BatchAttributeForm/inputs/InputBase.js +1 -1
  254. package/widgets/BatchAttributeForm/inputs/TextElementInput.d.ts +7 -0
  255. package/widgets/BatchAttributeForm/inputs/TextElementInput.js +1 -1
  256. package/widgets/BatchAttributeForm/inputs/support/textInputElementUtils.js +5 -0
  257. package/widgets/BatchAttributeForm/templates/TextElementTemplate.js +1 -1
  258. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  259. package/widgets/BatchAttributeForm/templates/support/hashElementTemplate.js +1 -1
  260. package/widgets/BatchAttributeForm.js +1 -1
  261. package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.d.ts +2 -2
  262. package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js +1 -1
  263. package/widgets/Directions/DirectionsViewModel.d.ts +20 -4
  264. package/widgets/Directions/DirectionsViewModel.js +1 -1
  265. package/widgets/Directions.d.ts +2 -3
  266. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DViewModel.d.ts +2 -2
  267. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DViewModel.js +1 -1
  268. package/widgets/Editor/EditorViewModel.d.ts +2 -2
  269. package/widgets/Editor.d.ts +2 -2
  270. package/widgets/ElevationProfile/support/HoveredPoints.js +1 -1
  271. package/widgets/ElevationProfile/types.d.ts +3 -4
  272. package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
  273. package/widgets/Feature/types.d.ts +1 -5
  274. package/widgets/FeatureTable/Grid/types.d.ts +0 -2
  275. package/widgets/FeatureTable/support/types.d.ts +8 -8
  276. package/widgets/Features/FeaturesViewModel.d.ts +3 -3
  277. package/widgets/Features/FeaturesViewModel.js +1 -1
  278. package/widgets/LineOfSight/LineOfSightViewModel.d.ts +2 -2
  279. package/widgets/LineOfSight/LineOfSightViewModel.js +1 -1
  280. package/widgets/OrientedImageryViewer/navigation/queries.js +1 -1
  281. package/widgets/Popup/types.d.ts +0 -2
  282. package/widgets/ShadowCast/ShadowCastVisibleElements.d.ts +2 -0
  283. package/widgets/Sketch/SketchViewModel.js +1 -1
  284. package/widgets/Sketch/types.d.ts +2 -2
  285. package/widgets/Slice/SliceViewModel.d.ts +2 -2
  286. package/widgets/Slice/SliceViewModel.js +1 -1
  287. package/widgets/Spinner/SpinnerViewModel.js +1 -1
  288. package/widgets/support/AnalysisViewModelMixin.js +5 -0
  289. package/widgets/support/AnchorElementViewModel.js +1 -1
  290. package/widgets/support/InteractiveToolViewModelMixin.js +5 -0
  291. package/assets/esri/core/workers/chunks/3c3d311b88f5400951ef.js +0 -1
  292. package/assets/esri/core/workers/chunks/4a060147d25929680ec8.js +0 -1
  293. package/assets/esri/core/workers/chunks/4d0eaeb4cd6cd55e25fd.js +0 -1
  294. package/assets/esri/core/workers/chunks/61801bb8c7be8fe77086.js +0 -1
  295. package/assets/esri/core/workers/chunks/62b28f73f814413c10fc.js +0 -1
  296. package/assets/esri/core/workers/chunks/6925f09d44cc38480d53.js +0 -1
  297. package/assets/esri/core/workers/chunks/98f4b44eca91c42ca08e.js +0 -1
  298. package/assets/esri/core/workers/chunks/990341f7c47bd656c782.js +0 -1
  299. package/assets/esri/core/workers/chunks/ba7f57788847cc0f68df.js +0 -1
  300. package/assets/esri/core/workers/chunks/bf06250be7a7a36306b1.js +0 -1
  301. package/assets/esri/core/workers/chunks/cd2708fb7636b3ace229.js +0 -1
  302. package/assets/esri/core/workers/chunks/f7d93aae350796b88562.js +0 -1
  303. package/assets/esri/core/workers/chunks/f95e488d2b86e320624f.js +0 -1
  304. package/layers/mixins/TemporalSceneLayer.d.ts +0 -177
  305. package/layers/mixins/TemporalSceneLayer.js +0 -5
  306. package/layers/mixins/properties/ILayerWithSave.d.ts +0 -11
  307. package/layers/support/ContingencyConstraintViolation.d.ts +0 -2
  308. package/layers/support/ContingentValue.d.ts +0 -2
  309. package/layers/support/ContingentValuesResult.d.ts +0 -2
  310. package/layers/support/ElevationQuery.d.ts +0 -35
  311. package/layers/support/ElevationQueryContext.d.ts +0 -37
  312. package/layers/support/FeatureReduction.d.ts +0 -3
  313. package/layers/support/FeatureReduction.js +0 -5
  314. package/layers/support/FieldGroup.d.ts +0 -2
  315. package/layers/support/FieldValueType.d.ts +0 -2
  316. package/layers/support/I3SLayer.d.ts +0 -9
  317. package/layers/support/ParquetGeometryEncodingBase.d.ts +0 -9
  318. package/layers/support/ParquetGeometryEncodingBase.js +0 -5
  319. package/layers/support/SimpleBandStatistics.d.ts +0 -10
  320. package/layers/support/source/DataLayerSource.d.ts +0 -171
  321. package/layers/support/source/DataLayerSource.js +0 -5
  322. package/layers/support/source/MapLayerSource.js +0 -5
  323. package/layers/support/source/QueryTableDataSource.js +0 -5
  324. package/layers/support/source/RasterDataSource.js +0 -5
  325. package/layers/support/source/TableDataSource.js +0 -5
  326. package/layers/support/source/types.d.ts +0 -4
  327. package/views/2d/layers/features/FeaturePipelineWorkerProxy.d.ts +0 -32
  328. package/views/3d/webgl-engine/shaders/GaussianSplatColorTechnique.js +0 -5
  329. package/views/3d/webgl-engine/shaders/GaussianSplatCompositionTechniqueConfiguration.js +0 -5
  330. package/views/3d/webgl-engine/shaders/GaussianSplatDepthTechnique.js +0 -5
  331. package/widgets/support/AnalysisViewModel.d.ts +0 -5
  332. package/widgets/support/AnalysisViewModel.js +0 -5
  333. package/widgets/support/AnchorElementViewModel.d.ts +0 -3
  334. package/widgets/support/InteractiveToolViewModel.d.ts +0 -4
  335. package/widgets/support/InteractiveToolViewModel.js +0 -5
  336. /package/webdoc/support/{thumbnailUtils.d.ts → types.d.ts} +0 -0
@@ -12,8 +12,6 @@ export type GridSupportedColumns = Column;
12
12
 
13
13
  export type GridMultiSortPriority = "append" | "prepend";
14
14
 
15
- export type GridInteractionEventType = "cell-click" | "cell-dblclick" | "cell-pointerover" | "cell-pointerout" | "cell-keydown" | "column-reorder";
16
-
17
15
  export interface TableInteractionEvent {
18
16
  /** The feature associated with the cell. */
19
17
  feature?: Graphic;
@@ -24,9 +24,9 @@ import type { FieldValue } from "../../../layers/support/fieldUtils.js";
24
24
  import type { ObjectId } from "../../../views/types.js";
25
25
  import type { CellValue, Direction } from "../Grid/types.js";
26
26
 
27
- export interface FieldValueFormatFunctionParams extends FormatFunctionParams {}
27
+ export interface FieldValueFormatFunctionParameters extends FormatFunctionParameters {}
28
28
 
29
- export interface FormatFunctionParams {
29
+ export interface FormatFunctionParameters {
30
30
  /** _(Since 4.31)_ A reference to attachments for the associated feature. */
31
31
  attachments?: AttachmentInfo[] | null;
32
32
  /** A reference to this specific Column. */
@@ -55,7 +55,7 @@ export type FeatureTableSupportedColumn = Column;
55
55
  * @param params - An object containing information about the associated row and feature.
56
56
  * @returns Formatted content to be displayed in the cell.
57
57
  */
58
- export type FormatFunction = (params: FormatFunctionParams) => CellValue | HTMLElement;
58
+ export type FormatFunction = (params: FormatFunctionParameters) => CellValue | HTMLElement;
59
59
 
60
60
  /**
61
61
  * Custom function for rendering cell content. Accepts a string, number, an HTML element or equivalent node type (e.g. a [Calcite component](https://developers.arcgis.com/calcite-design-system/components/)).
@@ -63,7 +63,7 @@ export type FormatFunction = (params: FormatFunctionParams) => CellValue | HTMLE
63
63
  * @param params - An object containing information about the associated row and feature.
64
64
  * @returns Formatted content to be displayed in the cell.
65
65
  */
66
- export type FieldValueFormatFunction = (params: FieldValueFormatFunctionParams) => FieldValue | HTMLElement;
66
+ export type FieldValueFormatFunction = (params: FieldValueFormatFunctionParameters) => FieldValue | HTMLElement;
67
67
 
68
68
  export type FeatureTableSupportedFilters = GeometryFilter | SelectionFilter;
69
69
 
@@ -119,7 +119,7 @@ export interface ColumnSortOrder {
119
119
  fieldName: string;
120
120
  }
121
121
 
122
- export interface ActionColumnCallbackParams {
122
+ export interface ActionColumnCallbackParameters {
123
123
  /** A reference to the associated feature. */
124
124
  feature: Graphic;
125
125
  /** The index of the associated row. */
@@ -133,7 +133,7 @@ export interface ActionColumnCallbackParams {
133
133
  *
134
134
  * @param params - An object containing information about the associated row and feature.
135
135
  */
136
- export type ActionColumnCallback = (params: ActionColumnCallbackParams) => void;
136
+ export type ActionColumnCallback = (params: ActionColumnCallbackParameters) => void;
137
137
 
138
138
  /**
139
139
  * Configuration for the [FeatureTable's actionColumn](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable.html#actionColumn).
@@ -161,7 +161,7 @@ export interface ActionColumnConfig {
161
161
  label: string;
162
162
  }
163
163
 
164
- export interface ActionColumnDisabledParams {
164
+ export interface ActionColumnDisabledParameters {
165
165
  /** The feature to use when determining if the action should be disabled. */
166
166
  feature: Graphic;
167
167
  /** The row's index position when determining if the action should be disabled. */
@@ -174,7 +174,7 @@ export interface ActionColumnDisabledParams {
174
174
  * @param params - An object containing information about an associated row and feature.
175
175
  * @returns Indicates whether the action should be disabled.
176
176
  */
177
- export type ActionColumnDisabledFunction = (params: ActionColumnDisabledParams) => boolean;
177
+ export type ActionColumnDisabledFunction = (params: ActionColumnDisabledParameters) => boolean;
178
178
 
179
179
  /** The related records for the associated feature used in the [Columns's](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable-Grid-Column.html#formatFunction) and [FieldColumn's](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable-support-types.html#FieldValueFormatFunction) `formatFunction`. */
180
180
  export interface RelatedRecordInfo {
@@ -5,7 +5,7 @@ import type Point from "../../geometry/Point.js";
5
5
  import type SpatialReference from "../../geometry/SpatialReference.js";
6
6
  import type Widget from "../Widget.js";
7
7
  import type FeatureViewModel from "../Feature/FeatureViewModel.js";
8
- import type AnchorElementViewModel from "../support/AnchorElementViewModel.js";
8
+ import type { EventedAccessor, EventedMixinProperties } from "../../core/Evented.js";
9
9
  import type { ScreenPoint } from "../../core/types.js";
10
10
  import type { SpatialReferenceProperties } from "../../geometry/SpatialReference.js";
11
11
  import type { TimeZone } from "../../time/types.js";
@@ -20,7 +20,7 @@ import type { ActionButtonProperties } from "../../support/actions/ActionButton.
20
20
  import type { ReadonlyArrayOrCollection } from "../../core/Collection.js";
21
21
  import type { PointProperties } from "../../geometry/Point.js";
22
22
 
23
- export interface FeaturesViewModelProperties extends GoToProperties, Partial<Pick<FeaturesViewModel, "activeFeature" | "autoCloseEnabled" | "browseClusterEnabled" | "content" | "defaultPopupTemplateEnabled" | "featureMenuOpen" | "featureMenuTitle" | "featurePage" | "features" | "featuresPerPage" | "featureViewModelAbilities" | "highlightEnabled" | "includeDefaultActions" | "initialDisplayMode" | "map" | "promises" | "screenLocationEnabled" | "selectedFeatureIndex" | "title" | "updateLocationEnabled" | "view" | "visible" | "zoomFactor">> {
23
+ export interface FeaturesViewModelProperties extends EventedMixinProperties, GoToProperties, Partial<Pick<FeaturesViewModel, "activeFeature" | "autoCloseEnabled" | "browseClusterEnabled" | "content" | "defaultPopupTemplateEnabled" | "featureMenuOpen" | "featureMenuTitle" | "featurePage" | "features" | "featuresPerPage" | "featureViewModelAbilities" | "highlightEnabled" | "includeDefaultActions" | "initialDisplayMode" | "map" | "promises" | "screenLocationEnabled" | "selectedFeatureIndex" | "title" | "updateLocationEnabled" | "view" | "visible" | "zoomFactor">> {
24
24
  /**
25
25
  * [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of [action](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-actions-ActionButton.html) or [action toggle](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-actions-ActionToggle.html) objects.
26
26
  * Each action may be executed by clicking the icon or image symbolizing them.
@@ -754,4 +754,4 @@ export default class FeaturesViewModel extends FeaturesViewModelSuperclass {
754
754
  */
755
755
  zoomTo(params: GoToParameters): Promise<void>;
756
756
  }
757
- declare const FeaturesViewModelSuperclass: typeof AnchorElementViewModel & typeof GoTo
757
+ declare const FeaturesViewModelSuperclass: typeof EventedAccessor & typeof GoTo
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import r from"../../core/Logger.js";import{debounce as o,isAbortError as a}from"../../core/promiseUtils.js";import n from"../../core/ReactiveSet.js";import{watch as l,when as u,sync as h}from"../../core/reactiveUtils.js";import{property as c,subclass as d}from"../../core/accessorSupport/decorators.js";import p from"../../geometry/Point.js";import{project as g,initializeProjection as f}from"../../geometry/projectionUtils.js";import m from"../../geometry/SpatialReference.js";import{getPointFromGeometry as y}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as w}from"../../geometry/support/webMercatorUtils.js";import{fallbackObjectIDAttribute as F}from"../../layers/LayerConstants.js";import v from"../../symbols/SimpleFillSymbol.js";import{getDisplayedSymbol as _}from"../../symbols/support/symbolUtils.js";import{system as b}from"../../time/constants.js";import{highlightsSupported as C}from"../../views/support/layerViewUtils.js";import P from"../Feature/FeatureViewModel.js";import{ActionsCollection as M,zoomToClusteredFeatures as E,browseClusteredFeatures as L,zoomToFeature as V}from"../Popup/actions.js";import{triggerAction as j,isClusterFeature as A,getSelectedTarget as I,removeClusteredFeaturesForBrowsing as R,displayClusterExtent as x,browseAggregateFeatures as O}from"../Popup/actionUtils.js";import T from"../support/AnchorElementViewModel.js";import{GoTo as S}from"../support/GoTo.js";const B="location-scale-handle",H=()=>[V.clone()],U=()=>[E.clone(),L.clone()];let G=null;function Z(e,t){return"building-scene"===e||"map-image"===e||"tile"===e||"imagery"===e||"2d"===t&&"imagery-tile"===e}let z=class extends(S(T)){constructor(e){super(e),this._pendingPromises=new n,this._fetchFeaturesController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._selectedClusterFeature=null,this.actions=new M,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureMenuTitle=null,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.initialDisplayMode="feature",this.selectedClusterBoundaryFeature=new t({symbol:new v({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=o(async e=>{const{spatialReference:t}=this,i=this.selectedFeature?.geometry?.type,s=this.location??e;if(i&&"mesh"!==i&&t&&s&&this.selectedFeature)if("point"!==i)try{const e=this.selectedFeature;let i=e.geometry;const r=this._getHighlightLayer(e),o=e.getObjectId();if(!r||!this.view)return;if(o){const e=this.view?.allLayerViews.find(e=>e.layer.uid===r.uid);if(!e||!("queryFeatures"in e))return;const s=e.createQuery();s.outSpatialReference=t,s.objectIds=[o],s.returnGeometry=!0;const{features:a}=await e.queryFeatures(s);i=a[0]?.geometry}if(!i||"mesh"===i.type)return;i=g(i,t),G||(G=await Promise.all([import("../../geometry/operators/intersectsOperator.js"),import("../../geometry/operators/proximityOperator.js")]));const[a,n]=G;if(!a.execute(i,s)){const t=n.getNearestCoordinate(i,s).coordinate??s;this.selectedFeature===e&&(this.location=t)}}catch(o){a(o)||r.getLogger(this).error(o)}else this.location=y(this.selectedFeature.geometry)??s})}initialize(){this.addHandles([this.on("view-change",()=>this._autoClose()),l(()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view],()=>this._highlightSelectedFeature()),l(()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view],()=>this._highlightActiveFeature()),l(()=>this.view?.animation?.state,e=>this._animationStateChange(e)),l(()=>this.location,e=>this._locationChange(e)),l(()=>this.selectedFeature,e=>this._selectedFeatureChange(e)),l(()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage],()=>this._selectedFeatureIndexChange()),l(()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels],()=>this._setGraphicOnFeatureViewModels()),l(()=>this.featureViewModels,()=>this._featureViewModelsChange()),this.on("trigger-action",e=>j({event:e,viewModel:this,view:this.view})),u(()=>!this.waitingForResult,()=>this._waitingForResultChange(),h),l(()=>[this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureVMs()),l(()=>this.view?.scale,()=>this._viewScaleChange()),u(()=>!this.visible,()=>this.browseClusterEnabled=!1),l(()=>this.browseClusterEnabled,e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing())])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new M;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,u=n?.overwriteActions?l:l?.concat(a)??a;return u?.filter(Boolean).forEach(t=>e.add(t)),e}get defaultActions(){const e=this._get("defaultActions")||new M;return e.removeAll(),e.addMany(A(this.selectedFeature)?U():H()),e}get featureCount(){return this.features.length}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;"list"!==this.initialDisplayMode?o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1):(!o||o&&i===s)&&(this.selectedFeatureIndex=-1)}set location(e){let t=e;const i=this.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=w(e)),this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice()).forEach(e=>this._pendingPromises.add(e)),e.reduce((e,t)=>e.finally(()=>t.then(e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)}).finally(()=>this._pendingPromises.delete(t)).catch(()=>{})),Promise.resolve())):this._set("promises",[])}get screenLocation(){return super.screenLocation}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){const{view:e,map:t}=this;return e?e.ready?"ready":"disabled":t?"ready":"disabled"}get timeZone(){return this.view?.timeZone??b}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureViewModels.some(e=>e.waitingForContent)}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=I(this);return t&&e?this.callGoTo({target:{target:t,scale:e.scale}}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount),this}previous(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount),this}disableClusterBrowsing(){R(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?A(t)?(await x(this),await O(this)):r.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):r.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}async handleViewClick(e){return this._fetchFeaturesAndOpen(e)}_getRoundRobinIndex(e,t){return(e+t)%t}_animationStateChange(e){this.zoomToLocation||(V.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(A(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:s}=this;s&&i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>0?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>0?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null==i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach((t,i)=>{t&&(t.graphic??=e[o+i])})}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(!e||!s)return;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),A(e))return;return e.symbol=await _(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}const r=e.sourceLayer?.type;if("map-image"!==r&&"imagery"!==r&&"imagery-tile"!==r||(e.symbol=await _(e)),!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=y(e.geometry)}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s,spatialReference:r,map:o,timeZone:a,location:n}=this;if(A(t[0])||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const l=i.slice(),u=[];t.forEach((t,i)=>{if(!t)return;let h=null;if(l.some((e,i)=>(e&&e.graphic===t&&(h=e,l.splice(i,1)),!!h)),h)u[i]=h;else{const l=new P({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:r,graphic:t===e?t:null,location:n,map:o,view:s,timeZone:a});u[i]=l}}),l.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",u)}async _getScreenPoint(e,t){const{spatialReference:i,view:s}=this;if(!s)return null;await(s?.when());const r=e?.spatialReference;return r&&i?(await f(r,i,null,t),s.toScreen(e)):null}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch(()=>{}).then(()=>{this._fetchFeaturesController=null}),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e;this.removeHandles(B),this.addHandles([l(()=>this.view?.scale,()=>this._debouncedLocationUpdate(t).catch(e=>{a(e)||r.getLogger(this).error(e)})),u(()=>!this.visible,()=>{this.removeHandles(B)},{once:!0})],B);const{pendingFeatures:s}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});return{location:t??void 0,promises:s}}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t??i}_getHighlightLayerView(e,t){return"subtype-sublayer"===t.type&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,i){if(Z(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||F:null,o=e.attributes;return o&&r&&o[r]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);const i=this[t];if(!i)return;const{highlightEnabled:s,view:r,visible:o}=this;if(!r||!s||!o)return;const a=this._getHighlightLayer(i);if(!a)return;const n=this._getHighlightLayerView(r,a);if(!n)return;this._highlightPromises[e]=n;const l=await n;if(!(l&&C(l)&&this._highlightPromises[e]===n&&this[t]&&this.highlightEnabled))return;const u=l.highlight(this._getHighlightTarget(i,a,r.type));this.addHandles(u,e)}async _highlightActiveFeature(){return this._highlightFeature("highlight-active-feature","activeFeature")}async _highlightSelectedFeature(){return this._highlightFeature("highlight-selected-feature","selectedFeature")}_updateFeatures(e){const{features:t}=this,i=e.filter(e=>!t.includes(e));i?.length&&(this.features=t.concat(i))}};e([c()],z.prototype,"_fetchFeaturesController",void 0),e([c({type:M})],z.prototype,"actions",void 0),e([c({readOnly:!0})],z.prototype,"active",null),e([c()],z.prototype,"activeFeature",void 0),e([c({readOnly:!0})],z.prototype,"allActions",null),e([c()],z.prototype,"autoCloseEnabled",void 0),e([c()],z.prototype,"browseClusterEnabled",void 0),e([c()],z.prototype,"content",void 0),e([c({type:M,readOnly:!0})],z.prototype,"defaultActions",null),e([c({type:Boolean})],z.prototype,"defaultPopupTemplateEnabled",void 0),e([c({readOnly:!0})],z.prototype,"featureCount",null),e([c()],z.prototype,"featurePage",void 0),e([c({value:[]})],z.prototype,"features",null),e([c()],z.prototype,"featuresPerPage",void 0),e([c()],z.prototype,"featureMenuOpen",void 0),e([c()],z.prototype,"featureMenuTitle",void 0),e([c()],z.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],z.prototype,"featureViewModels",void 0),e([c()],z.prototype,"highlightEnabled",void 0),e([c()],z.prototype,"includeDefaultActions",void 0),e([c()],z.prototype,"initialDisplayMode",void 0),e([c({type:p})],z.prototype,"location",null),e([c()],z.prototype,"map",null),e([c({readOnly:!0})],z.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],z.prototype,"promiseCount",null),e([c()],z.prototype,"promises",null),e([c({readOnly:!0})],z.prototype,"selectedClusterBoundaryFeature",void 0),e([c({value:null,readOnly:!0})],z.prototype,"selectedFeature",null),e([c({value:-1})],z.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],z.prototype,"selectedFeatureViewModel",null),e([c({type:m})],z.prototype,"spatialReference",null),e([c({readOnly:!0})],z.prototype,"state",null),e([c()],z.prototype,"timeZone",null),e([c()],z.prototype,"title",void 0),e([c()],z.prototype,"updateLocationEnabled",void 0),e([c()],z.prototype,"view",void 0),e([c()],z.prototype,"visible",void 0),e([c({readOnly:!0})],z.prototype,"waitingForContents",null),e([c({readOnly:!0})],z.prototype,"waitingForResult",null),e([c()],z.prototype,"zoomFactor",void 0),e([c()],z.prototype,"zoomToLocation",void 0),e([c()],z.prototype,"centerAtLocation",null),z=e([d("esri.widgets.Features.FeaturesViewModel")],z);export{z as default};
5
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import o from"../../core/Logger.js";import{debounce as a,isAbortError as n}from"../../core/promiseUtils.js";import l from"../../core/ReactiveSet.js";import{watch as u,when as h,sync as c}from"../../core/reactiveUtils.js";import{property as d,subclass as p}from"../../core/accessorSupport/decorators.js";import g from"../../geometry/Point.js";import{project as f,initializeProjection as m}from"../../geometry/projectionUtils.js";import y from"../../geometry/SpatialReference.js";import{getPointFromGeometry as w}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as F}from"../../geometry/support/webMercatorUtils.js";import{fallbackObjectIDAttribute as v}from"../../layers/LayerConstants.js";import _ from"../../symbols/SimpleFillSymbol.js";import{getDisplayedSymbol as b}from"../../symbols/support/symbolUtils.js";import{system as C}from"../../time/constants.js";import{highlightsSupported as P}from"../../views/support/layerViewUtils.js";import M from"../Feature/FeatureViewModel.js";import{ActionsCollection as E,zoomToClusteredFeatures as L,browseClusteredFeatures as V,zoomToFeature as j}from"../Popup/actions.js";import{triggerAction as A,isClusterFeature as I,getSelectedTarget as R,removeClusteredFeaturesForBrowsing as x,displayClusterExtent as O,browseAggregateFeatures as T}from"../Popup/actionUtils.js";import{AnchorElementViewModelMixin as S}from"../support/AnchorElementViewModel.js";import{GoTo as B}from"../support/GoTo.js";const H="location-scale-handle",U=()=>[j.clone()],G=()=>[L.clone(),V.clone()];let Z=null;function z(e,t){return"building-scene"===e||"map-image"===e||"tile"===e||"imagery"===e||"2d"===t&&"imagery-tile"===e}let D=class extends(B(S(r))){constructor(e){super(e),this._pendingPromises=new l,this._fetchFeaturesController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._selectedClusterFeature=null,this.actions=new E,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureMenuTitle=null,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.initialDisplayMode="feature",this.selectedClusterBoundaryFeature=new t({symbol:new _({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=a(async e=>{const{spatialReference:t}=this,i=this.selectedFeature?.geometry?.type,s=this.location??e;if(i&&"mesh"!==i&&t&&s&&this.selectedFeature)if("point"!==i)try{const e=this.selectedFeature;let i=e.geometry;const r=this._getHighlightLayer(e),o=e.getObjectId();if(!r||!this.view)return;if(o){const e=this.view?.allLayerViews.find(e=>e.layer.uid===r.uid);if(!e||!("queryFeatures"in e))return;const s=e.createQuery();s.outSpatialReference=t,s.objectIds=[o],s.returnGeometry=!0;const{features:a}=await e.queryFeatures(s);i=a[0]?.geometry}if(!i||"mesh"===i.type)return;i=f(i,t),Z||(Z=await Promise.all([import("../../geometry/operators/intersectsOperator.js"),import("../../geometry/operators/proximityOperator.js")]));const[a,n]=Z;if(!a.execute(i,s)){const t=n.getNearestCoordinate(i,s).coordinate??s;this.selectedFeature===e&&(this.location=t)}}catch(r){n(r)||o.getLogger(this).error(r)}else this.location=w(this.selectedFeature.geometry)??s})}initialize(){this.addHandles([this.on("view-change",()=>this._autoClose()),u(()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view],()=>this._highlightSelectedFeature()),u(()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view],()=>this._highlightActiveFeature()),u(()=>this.view?.animation?.state,e=>this._animationStateChange(e)),u(()=>this.location,e=>this._locationChange(e)),u(()=>this.selectedFeature,e=>this._selectedFeatureChange(e)),u(()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage],()=>this._selectedFeatureIndexChange()),u(()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels],()=>this._setGraphicOnFeatureViewModels()),u(()=>this.featureViewModels,()=>this._featureViewModelsChange()),this.on("trigger-action",e=>A({event:e,viewModel:this,view:this.view})),h(()=>!this.waitingForResult,()=>this._waitingForResultChange(),c),u(()=>[this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureVMs()),u(()=>this.view?.scale,()=>this._viewScaleChange()),h(()=>!this.visible,()=>this.browseClusterEnabled=!1),u(()=>this.browseClusterEnabled,e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing())])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new E;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,u=n?.overwriteActions?l:l?.concat(a)??a;return u?.filter(Boolean).forEach(t=>e.add(t)),e}get defaultActions(){const e=this._get("defaultActions")||new E;return e.removeAll(),e.addMany(I(this.selectedFeature)?G():U()),e}get featureCount(){return this.features.length}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;"list"!==this.initialDisplayMode?o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1):(!o||o&&i===s)&&(this.selectedFeatureIndex=-1)}set location(e){let t=e;const i=this.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=F(e)),this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice()).forEach(e=>this._pendingPromises.add(e)),e.reduce((e,t)=>e.finally(()=>t.then(e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)}).finally(()=>this._pendingPromises.delete(t)).catch(()=>{})),Promise.resolve())):this._set("promises",[])}get screenLocation(){return super.screenLocation}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){const{view:e,map:t}=this;return e?e.ready?"ready":"disabled":t?"ready":"disabled"}get timeZone(){return this.view?.timeZone??C}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureViewModels.some(e=>e.waitingForContent)}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=R(this);return t&&e?this.callGoTo({target:{target:t,scale:e.scale}}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount),this}previous(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount),this}disableClusterBrowsing(){x(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?I(t)?(await O(this),await T(this)):o.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):o.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}async handleViewClick(e){return this._fetchFeaturesAndOpen(e)}_getRoundRobinIndex(e,t){return(e+t)%t}_animationStateChange(e){this.zoomToLocation||(j.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(I(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:s}=this;s&&i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>0?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>0?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null==i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach((t,i)=>{t&&(t.graphic??=e[o+i])})}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(!e||!s)return;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),I(e))return;return e.symbol=await b(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}const r=e.sourceLayer?.type;if("map-image"!==r&&"imagery"!==r&&"imagery-tile"!==r||(e.symbol=await b(e)),!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=w(e.geometry)}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s,spatialReference:r,map:o,timeZone:a,location:n}=this;if(I(t[0])||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const l=i.slice(),u=[];t.forEach((t,i)=>{if(!t)return;let h=null;if(l.some((e,i)=>(e&&e.graphic===t&&(h=e,l.splice(i,1)),!!h)),h)u[i]=h;else{const l=new M({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:r,graphic:t===e?t:null,location:n,map:o,view:s,timeZone:a});u[i]=l}}),l.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",u)}async _getScreenPoint(e,t){const{spatialReference:i,view:s}=this;if(!s)return null;await(s?.when());const r=e?.spatialReference;return r&&i?(await m(r,i,null,t),s.toScreen(e)):null}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch(()=>{}).then(()=>{this._fetchFeaturesController=null}),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e;this.removeHandles(H),this.addHandles([u(()=>this.view?.scale,()=>this._debouncedLocationUpdate(t).catch(e=>{n(e)||o.getLogger(this).error(e)})),h(()=>!this.visible,()=>{this.removeHandles(H)},{once:!0})],H);const{pendingFeatures:s}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});return{location:t??void 0,promises:s}}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t??i}_getHighlightLayerView(e,t){return"subtype-sublayer"===t.type&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,i){if(z(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||v:null,o=e.attributes;return o&&r&&o[r]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);const i=this[t];if(!i)return;const{highlightEnabled:s,view:r,visible:o}=this;if(!r||!s||!o)return;const a=this._getHighlightLayer(i);if(!a)return;const n=this._getHighlightLayerView(r,a);if(!n)return;this._highlightPromises[e]=n;const l=await n;if(!(l&&P(l)&&this._highlightPromises[e]===n&&this[t]&&this.highlightEnabled))return;const u=l.highlight(this._getHighlightTarget(i,a,r.type));this.addHandles(u,e)}async _highlightActiveFeature(){return this._highlightFeature("highlight-active-feature","activeFeature")}async _highlightSelectedFeature(){return this._highlightFeature("highlight-selected-feature","selectedFeature")}_updateFeatures(e){const{features:t}=this,i=e.filter(e=>!t.includes(e));i?.length&&(this.features=t.concat(i))}};e([d()],D.prototype,"_fetchFeaturesController",void 0),e([d({type:E})],D.prototype,"actions",void 0),e([d({readOnly:!0})],D.prototype,"active",null),e([d()],D.prototype,"activeFeature",void 0),e([d({readOnly:!0})],D.prototype,"allActions",null),e([d()],D.prototype,"autoCloseEnabled",void 0),e([d()],D.prototype,"browseClusterEnabled",void 0),e([d()],D.prototype,"content",void 0),e([d({type:E,readOnly:!0})],D.prototype,"defaultActions",null),e([d({type:Boolean})],D.prototype,"defaultPopupTemplateEnabled",void 0),e([d({readOnly:!0})],D.prototype,"featureCount",null),e([d()],D.prototype,"featurePage",void 0),e([d({value:[]})],D.prototype,"features",null),e([d()],D.prototype,"featuresPerPage",void 0),e([d()],D.prototype,"featureMenuOpen",void 0),e([d()],D.prototype,"featureMenuTitle",void 0),e([d()],D.prototype,"featureViewModelAbilities",void 0),e([d({readOnly:!0})],D.prototype,"featureViewModels",void 0),e([d()],D.prototype,"highlightEnabled",void 0),e([d()],D.prototype,"includeDefaultActions",void 0),e([d()],D.prototype,"initialDisplayMode",void 0),e([d({type:g})],D.prototype,"location",null),e([d()],D.prototype,"map",null),e([d({readOnly:!0})],D.prototype,"pendingPromisesCount",null),e([d({readOnly:!0})],D.prototype,"promiseCount",null),e([d()],D.prototype,"promises",null),e([d({readOnly:!0})],D.prototype,"selectedClusterBoundaryFeature",void 0),e([d({value:null,readOnly:!0})],D.prototype,"selectedFeature",null),e([d({value:-1})],D.prototype,"selectedFeatureIndex",null),e([d({readOnly:!0})],D.prototype,"selectedFeatureViewModel",null),e([d({type:y})],D.prototype,"spatialReference",null),e([d({readOnly:!0})],D.prototype,"state",null),e([d()],D.prototype,"timeZone",null),e([d()],D.prototype,"title",void 0),e([d()],D.prototype,"updateLocationEnabled",void 0),e([d()],D.prototype,"view",void 0),e([d()],D.prototype,"visible",void 0),e([d({readOnly:!0})],D.prototype,"waitingForContents",null),e([d({readOnly:!0})],D.prototype,"waitingForResult",null),e([d()],D.prototype,"zoomFactor",void 0),e([d()],D.prototype,"zoomToLocation",void 0),e([d()],D.prototype,"centerAtLocation",null),D=e([p("esri.widgets.Features.FeaturesViewModel")],D);export{D as default};
@@ -1,9 +1,9 @@
1
1
  import type LineOfSightAnalysis from "../../analysis/LineOfSightAnalysis.js";
2
+ import type Accessor from "../../core/Accessor.js";
2
3
  import type Collection from "../../core/Collection.js";
3
4
  import type Point from "../../geometry/Point.js";
4
5
  import type SceneView from "../../views/SceneView.js";
5
6
  import type LineOfSightTarget from "./LineOfSightTarget.js";
6
- import type AnalysisViewModel from "../support/AnalysisViewModel.js";
7
7
  import type { LineOfSightAnalysisProperties } from "../../analysis/LineOfSightAnalysis.js";
8
8
  import type { PointProperties } from "../../geometry/Point.js";
9
9
  import type { LineOfSightTargetProperties } from "./LineOfSightTarget.js";
@@ -158,7 +158,7 @@ export interface LineOfSightViewModelProperties extends Partial<Pick<LineOfSight
158
158
  * @see [Sample - Line of sight widget](https://developers.arcgis.com/javascript/latest/sample-code/widgets-line-of-sight/)
159
159
  * @see [Programming patterns: Widget viewModel pattern](https://developers.arcgis.com/javascript/latest/programming-patterns/#widget-viewmodel-pattern)
160
160
  */
161
- export default class LineOfSightViewModel extends AnalysisViewModel<SceneView, LineOfSightAnalysis> {
161
+ export default class LineOfSightViewModel extends Accessor {
162
162
  constructor(properties?: LineOfSightViewModelProperties);
163
163
  /**
164
164
  * The line of sight analysis object being created or modified by the view model.
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../analysis/LineOfSightAnalysis.js";import s from"../../analysis/LineOfSightAnalysisObserver.js";import o from"../../analysis/LineOfSightAnalysisTarget.js";import i from"../../core/Collection.js";import{castForReferenceSetter as n,referenceSetter as r}from"../../core/collectionUtils.js";import{deprecateUnnecessaryViewModel as a}from"../../core/deprecate.js";import{handlesGroup as l}from"../../core/handleUtils.js";import"../../core/has.js";import g from"../../core/Logger.js";import{watch as d,syncAndInitial as h,sync as c}from"../../core/reactiveUtils.js";import{property as p,subclass as y}from"../../core/accessorSupport/decorators.js";import m from"../../geometry/Point.js";import{getEffectiveElevationInfo as v,getConvertedElevation as T,absoluteHeightElevationInfo as u}from"../../support/elevationInfoUtils.js";import f from"./LineOfSightTarget.js";import w from"../support/AnalysisViewModel.js";const _=i.ofType(f);let A=class extends w{constructor(e){super(e),this.analysis=null,this.supportedViewType="3d",this.unsupportedErrorMessage="LineOfSightViewModel is only supported in 3D views.",this._vmTargetsToConnection=new Map,this._analysisTargetsToConnection=new Map,e?.isDefaultViewModel||a(g.getLogger(this),"Line Of Sight","arcgis-line-of-sight",{version:"4.33"})}initialize(){this.addHandles([this.targets.on("after-add",e=>this._onViewModelTargetAdded(e.item)),this.targets.on("after-remove",e=>this._onViewModelTargetRemoved(e.item)),d(()=>this.analysis,e=>this._onAnalysisChange(e),h)])}destroy(){this._analysisTargetsToConnection.forEach(e=>e.remove())}get state(){return this.disabled||!this.ready?"disabled":null==this.tool?"ready":this.tool.state}get observer(){const{observer:e}=this.analysis;return null==e?.position?null:this._convertAnalysisPointToAbsoluteHeight(e.position,e.elevationInfo)}set observer(e){let t=null;e&&(t=e.clone(),t.hasZ||(t.z=0)),this.analysis.observer=new s({position:t})}get targets(){return this._get("targets")||new _}set targets(e){this._set("targets",r(e,this.targets,_))}continue(){null!=this.tool&&this.tool.continue()}stop(){null!=this.tool&&this.tool.stop()}get testInfo(){}constructAnalysis(){return new t}async onConnectToAnalysisView(e){this.addHandles([e.on("result-changed",e=>{const t=this._analysisTargetsToConnection.get(e.target);t&&(null!=e.result?(t.viewModelTarget.intersectedGraphic=e.result.intersectedGraphic,t.viewModelTarget.intersectedLocation=e.result.intersectedLocation,t.viewModelTarget.visible=e.result.visible):(t.viewModelTarget.intersectedGraphic=null,t.viewModelTarget.intersectedLocation=null,t.viewModelTarget.visible=void 0))})],"view")}onDisconnectFromAnalysisView(){this.removeHandles("view")}_onViewModelTargetAdded(e){if(this._vmTargetsToConnection.get(e))return;const t=new o({position:e.location});this._connectViewModelWithAnalysisTarget(e,t),this.analysis.targets.add(t)}_onViewModelTargetRemoved(e){const t=this._vmTargetsToConnection.get(e);t&&(t.remove(),this.analysis.targets.remove(t.analysisTarget))}_onAnalysisTargetAdded(e){if(this._analysisTargetsToConnection.get(e))return;const{position:t}=e,s=new f({location:t?this._convertAnalysisPointToAbsoluteHeight(t,e.elevationInfo):null});this._connectViewModelWithAnalysisTarget(s,e),this.targets.add(s)}_onAnalysisTargetRemoved(e){const t=this._analysisTargetsToConnection.get(e);t&&(t.remove(),this.targets.remove(t.viewModelTarget))}_connectViewModelWithAnalysisTarget(e,t){let s=!1;const o=l([d(()=>({position:t.position,elevationInfo:t.elevationInfo}),({position:t,elevationInfo:o})=>{s||(s=!0,e.location=t?this._convertAnalysisPointToAbsoluteHeight(t,o):null,s=!1)},c),d(()=>e.location,e=>{if(!s){s=!0;let o=null;e&&(o=e.clone(),o.hasZ||(o.z=0)),t.position=o,t.elevationInfo=null,s=!1}},c)]),i={analysisTarget:t,viewModelTarget:e,remove:()=>{o.remove(),this._vmTargetsToConnection.delete(e),this._analysisTargetsToConnection.delete(t)}};this._vmTargetsToConnection.set(e,i),this._analysisTargetsToConnection.set(t,i)}_onAnalysisChange(e){const t="analysis";this.removeHandles(t),this.addHandles([this.analysis.targets.on("after-add",e=>this._onAnalysisTargetAdded(e.item)),this.analysis.targets.on("after-remove",e=>this._onAnalysisTargetRemoved(e.item))],t),this.targets.removeAll(),e.targets.forEach(e=>{this._onAnalysisTargetAdded(e)})}_convertAnalysisPointToAbsoluteHeight(e,t){const s=e.clone();if(null!=this.view){const o=v(e.hasZ,t);s.z=T(this.view,e,o,u)}return s}};e([p({type:t})],A.prototype,"analysis",void 0),e([p({readOnly:!0})],A.prototype,"state",null),e([p({type:m})],A.prototype,"observer",null),e([p({type:_,cast:n,nonNullable:!0})],A.prototype,"targets",null),A=e([y("esri.widgets.LineOfSight.LineOfSightViewModel")],A);const M=A;export{M as default};
5
+ import{__decorate as e}from"tslib";import t from"../../analysis/LineOfSightAnalysis.js";import s from"../../analysis/LineOfSightAnalysisObserver.js";import o from"../../analysis/LineOfSightAnalysisTarget.js";import i from"../../core/Accessor.js";import n from"../../core/Collection.js";import{referenceSetter as r,castForReferenceSetter as a}from"../../core/collectionUtils.js";import{deprecateUnnecessaryViewModel as l}from"../../core/deprecate.js";import{handlesGroup as c}from"../../core/handleUtils.js";import"../../core/has.js";import g from"../../core/Logger.js";import{watch as d,syncAndInitial as h,sync as p}from"../../core/reactiveUtils.js";import{property as m,subclass as y}from"../../core/accessorSupport/decorators.js";import v from"../../geometry/Point.js";import{getEffectiveElevationInfo as T,getConvertedElevation as u,absoluteHeightElevationInfo as f}from"../../support/elevationInfoUtils.js";import w from"./LineOfSightTarget.js";import{AnalysisViewModelMixin as A}from"../support/AnalysisViewModelMixin.js";const _=n.ofType(w);let M=class extends(A(i)){constructor(e){super(e),this.analysis=null,this.supportedViewType="3d",this.unsupportedErrorMessage="LineOfSightViewModel is only supported in 3D views.",this._vmTargetsToConnection=new Map,this._analysisTargetsToConnection=new Map,e?.isDefaultViewModel||l(g.getLogger(this),"Line Of Sight","arcgis-line-of-sight",{version:"4.33"})}initialize(){this.addHandles([this.targets.on("after-add",e=>this._onViewModelTargetAdded(e.item)),this.targets.on("after-remove",e=>this._onViewModelTargetRemoved(e.item)),d(()=>this.analysis,e=>this._onAnalysisChange(e),h)])}destroy(){this._analysisTargetsToConnection.forEach(e=>e.remove())}get state(){return this.disabled||!this.ready?"disabled":null==this.tool?"ready":this.tool.state}get observer(){const{observer:e}=this.analysis;return null==e?.position?null:this._convertAnalysisPointToAbsoluteHeight(e.position,e.elevationInfo)}set observer(e){let t=null;e&&(t=e.clone(),t.hasZ||(t.z=0)),this.analysis.observer=new s({position:t})}get targets(){return this._get("targets")||new _}set targets(e){this._set("targets",r(e,this.targets,_))}continue(){null!=this.tool&&this.tool.continue()}stop(){null!=this.tool&&this.tool.stop()}get testInfo(){}constructAnalysis(){return new t}async onConnectToAnalysisView(e){this.addHandles([e.on("result-changed",e=>{const t=this._analysisTargetsToConnection.get(e.target);t&&(null!=e.result?(t.viewModelTarget.intersectedGraphic=e.result.intersectedGraphic,t.viewModelTarget.intersectedLocation=e.result.intersectedLocation,t.viewModelTarget.visible=e.result.visible):(t.viewModelTarget.intersectedGraphic=null,t.viewModelTarget.intersectedLocation=null,t.viewModelTarget.visible=void 0))})],"view")}onDisconnectFromAnalysisView(){this.removeHandles("view")}_onViewModelTargetAdded(e){if(this._vmTargetsToConnection.get(e))return;const t=new o({position:e.location});this._connectViewModelWithAnalysisTarget(e,t),this.analysis.targets.add(t)}_onViewModelTargetRemoved(e){const t=this._vmTargetsToConnection.get(e);t&&(t.remove(),this.analysis.targets.remove(t.analysisTarget))}_onAnalysisTargetAdded(e){if(this._analysisTargetsToConnection.get(e))return;const{position:t}=e,s=new w({location:t?this._convertAnalysisPointToAbsoluteHeight(t,e.elevationInfo):null});this._connectViewModelWithAnalysisTarget(s,e),this.targets.add(s)}_onAnalysisTargetRemoved(e){const t=this._analysisTargetsToConnection.get(e);t&&(t.remove(),this.targets.remove(t.viewModelTarget))}_connectViewModelWithAnalysisTarget(e,t){let s=!1;const o=c([d(()=>({position:t.position,elevationInfo:t.elevationInfo}),({position:t,elevationInfo:o})=>{s||(s=!0,e.location=t?this._convertAnalysisPointToAbsoluteHeight(t,o):null,s=!1)},p),d(()=>e.location,e=>{if(!s){s=!0;let o=null;e&&(o=e.clone(),o.hasZ||(o.z=0)),t.position=o,t.elevationInfo=null,s=!1}},p)]),i={analysisTarget:t,viewModelTarget:e,remove:()=>{o.remove(),this._vmTargetsToConnection.delete(e),this._analysisTargetsToConnection.delete(t)}};this._vmTargetsToConnection.set(e,i),this._analysisTargetsToConnection.set(t,i)}_onAnalysisChange(e){const t="analysis";this.removeHandles(t),this.addHandles([this.analysis.targets.on("after-add",e=>this._onAnalysisTargetAdded(e.item)),this.analysis.targets.on("after-remove",e=>this._onAnalysisTargetRemoved(e.item))],t),this.targets.removeAll(),e.targets.forEach(e=>{this._onAnalysisTargetAdded(e)})}_convertAnalysisPointToAbsoluteHeight(e,t){const s=e.clone();if(null!=this.view){const o=T(e.hasZ,t);s.z=u(this.view,e,o,f)}return s}};e([m({type:t})],M.prototype,"analysis",void 0),e([m({readOnly:!0})],M.prototype,"state",null),e([m({type:v})],M.prototype,"observer",null),e([m({type:_,cast:a,nonNullable:!0})],M.prototype,"targets",null),M=e([y("esri.widgets.LineOfSight.LineOfSightViewModel")],M);const b=M;export{b 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{sqlAnd as e}from"../../../core/sql.js";import r from"../../../geometry/Point.js";import{polygonCentroidPoint as t}from"../../../geometry/support/centroid.js";import{searchImages as n}from"../../../layers/orientedImagery/queries.js";import{createCoveragePolygon as o}from"../../../layers/orientedImagery/core/coverageUtils.js";async function i(e,i,s,c){const{polygon:a}=o(i.attributes),u=r.fromJSON(t(a));u.z=void 0;const d=p(e.definitionExpression,s);let y,l;try{y=await n({layerInstanceOrURL:e,point:u,queryParams:{where:d}},c)}catch(m){l=m}return new f(u,y,l)}async function s(e,r,t,o){const i=e.sequenceOrderField??"SequenceOrder",s=p(e.definitionExpression,t,`${i} IS NOT NULL`);let c,a;try{c=await n({layerInstanceOrURL:e,point:r,queryParams:{where:s,orderByFields:[`${i}`],returnGeometry:!0,outFields:["*"]}},o)}catch(u){a=u}return new f(r,c,a)}function c(e,r,t){const n=e.sequenceOrderField,o=p(e.definitionExpression,r,`${n} IS NOT NULL`);return e.queryFeatureCount({where:o},t)}async function a(r,t,n,o="ASC",i,s){const c=r.sequenceOrderField??"SequenceOrder";let a=p(r.definitionExpression,i,`${c} IS NOT NULL`);const u="number"==typeof t?t-1:void 0;"string"===t&&(a=e(a,`${c} = ${t}`));try{const e=await r.queryFeatures({where:a,returnGeometry:!0,orderByFields:[`${c} ${o}`],outFields:["*"],start:u,num:n},s);return await w(e,r),new y(e)}catch(d){return new y(void 0,d)}}async function u(e,r,t=0,n=1,o,i){const s=e.sequenceOrderField??"SequenceOrder",c=m(s,t),a=p(e.definitionExpression,o,l(t,r,s));try{const r=await e.queryFeatures({where:a,orderByFields:c,num:n,outFields:["*"],returnGeometry:!0},i);return await w(r,e),new y(r)}catch(u){return new y(void 0,u)}}async function d(e,r,t,n){const o=Array.isArray(r)?r:[r],i=p(e.definitionExpression,t,`${e.objectIdField} IN (${o.join(",")})`);try{const r=await e.queryFeatures({where:i,outFields:["*"],returnGeometry:!0},n);return await w(r,e),new y(r)}catch(s){return new y(void 0,s)}}class y{constructor(e,r){this.response=e,this.error=r}}class f{constructor(e,r,t){this.nextLocation=e,this.response=r,this.error=t}}function l(e,r,t){return e>0?`${t} IS NOT NULL AND ${t} > ${r}`:`${t} IS NOT NULL AND ${t} < ${r}`}function m(e,r){return r>0?[`${e}`]:[`${e} DESC`]}async function w(e,r){const t=await import("../../../layers/orientedImagery/core/ExposurePoint.js").then(e=>e.default);e.features.forEach(e=>{const n=t.fromJSON({...e.toJSON(),layer:r});n&&(e.attributes=n)})}function p(...r){let t="1=1";return r.forEach(r=>{t=e(t,r)}),t}export{f as QueryNextLocationFeaturesResponse,y as QueryOrientedImageryFeaturesResponse,u as queryAfterSequenceField,d as queryFeatureByObjectIds,i as queryNextLocationFeatures,a as queryOffsetSequenceFeatures,c as querySequenceCount,s as querySequenceFeaturesAroundPoint};
5
+ import{sqlAnd as e}from"../../../core/sql.js";import r from"../../../geometry/Point.js";import t from"../../../geometry/SpatialReference.js";import{polygonCentroidPoint as n}from"../../../geometry/support/centroid.js";import{searchImages as o}from"../../../layers/orientedImagery/queries.js";import{createCoveragePolygon as i}from"../../../layers/orientedImagery/core/coverageUtils.js";async function s(e,t,s,a){const{polygon:c}=i(t.attributes),u=r.fromJSON(n(c));u.z=void 0;const y=h(e.definitionExpression,s);let d,f;try{d=await o({layerInstanceOrURL:e,point:u,queryParams:{where:y}},a)}catch(l){f=l}return new p(u,d,f)}async function a(e,r,t,n){const i=e.sequenceOrderField??"SequenceOrder",s=h(e.definitionExpression,t,`${i} IS NOT NULL`);let a,c;try{a=await o({layerInstanceOrURL:e,point:r,queryParams:{where:s,orderByFields:[`${i}`],returnGeometry:!0,outFields:["*"]}},n)}catch(u){c=u}return new p(r,a,c)}function c(e,r,t){const n=e.sequenceOrderField,o=h(e.definitionExpression,r,`${n} IS NOT NULL`);return e.queryFeatureCount({where:o},t)}async function u(r,n,o,i="ASC",s,a){const c=r.sequenceOrderField??"SequenceOrder";let u=h(r.definitionExpression,s,`${c} IS NOT NULL`);const y="number"==typeof n?n-1:void 0;"string"===n&&(u=e(u,`${c} = ${n}`));const d=r.createQuery();d.where=u,d.start=y,d.num=o,d.orderByFields=[`${c} ${i}`],r.spatialReference.isGeographic&&(d.outSpatialReference=t.WebMercator);try{const e=await r.queryFeatures(d,a);return await w(e,r),new f(e)}catch(p){return new f(void 0,p)}}async function y(e,r,n=0,o=1,i,s){const a=e.sequenceOrderField??"SequenceOrder",c=m(a,n),u=h(e.definitionExpression,i,l(n,r,a)),y=e.createQuery();y.where=u,y.num=o,y.orderByFields=c,e.spatialReference.isGeographic&&(y.outSpatialReference=t.WebMercator);try{const r=await e.queryFeatures(y,s);return await w(r,e),new f(r)}catch(d){return new f(void 0,d)}}async function d(e,r,n,o){const i=Array.isArray(r)?r:[r],s=h(e.definitionExpression,n,`${e.objectIdField} IN (${i.join(",")})`),a=e.createQuery();a.where=s,e.spatialReference.isGeographic&&(a.outSpatialReference=t.WebMercator);try{const r=await e.queryFeatures(a,o);return await w(r,e),new f(r)}catch(c){return new f(void 0,c)}}class f{constructor(e,r){this.response=e,this.error=r}}class p{constructor(e,r,t){this.nextLocation=e,this.response=r,this.error=t}}function l(e,r,t){return e>0?`${t} IS NOT NULL AND ${t} > ${r}`:`${t} IS NOT NULL AND ${t} < ${r}`}function m(e,r){return r>0?[`${e}`]:[`${e} DESC`]}async function w(e,r){const t=await import("../../../layers/orientedImagery/core/ExposurePoint.js").then(e=>e.default);e.features.forEach(e=>{const n=t.fromJSON({...e.toJSON(),layer:r});n&&(e.attributes=n)})}function h(...r){let t="1=1";return r.forEach(r=>{t=e(t,r)}),t}export{p as QueryNextLocationFeaturesResponse,f as QueryOrientedImageryFeaturesResponse,y as queryAfterSequenceField,d as queryFeatureByObjectIds,s as queryNextLocationFeatures,u as queryOffsetSequenceFeatures,c as querySequenceCount,a as querySequenceFeaturesAroundPoint};
@@ -83,8 +83,6 @@ export interface DockOptions {
83
83
 
84
84
  export type InitialDisplayOptions = "list" | "feature";
85
85
 
86
- export type Action = ActionButton | ActionToggle;
87
-
88
86
  export interface PopupOpenOptions {
89
87
  /**
90
88
  * This property allows you to specify a collection of [actions](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-actions-ActionButton.html)
@@ -6,6 +6,8 @@ export interface ShadowCastVisibleElementsProperties extends Partial<Pick<Shadow
6
6
  /**
7
7
  * The visible elements that are displayed within the widget.
8
8
  * This provides the ability to turn individual elements of the widget's display on/off.
9
+ *
10
+ * @deprecated since 5.0. Use the [ShadowCastAnalysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-ShadowCastAnalysis.html) or [Shadow Cast component](https://developers.arcgis.com/javascript/latest/references/map-components/arcgis-shadow-cast/) instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/).
9
11
  */
10
12
  export default abstract class ShadowCastVisibleElements extends Accessor {
11
13
  /**
@@ -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.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,this.textSymbol=new D({text:"text"})}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 textSymbol(){return this._get("textSymbol")}set textSymbol(e){this._set("textSymbol",e)}get snappingOptions(){return this.snappingManager?.options??this._get("snappingOptions")}set snappingOptions(e){null!=this._defaultSnappingManager&&(this._defaultSnappingManager.options=e),this._set("snappingOptions",e)}get snappingManager(){return this._isOverridden("snappingManager")&&this._get("snappingManager"),this._defaultSnappingManager}set snappingManager(e){if(e)this._isOverridden("snappingManager")||(this._defaultSnappingManager=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",null),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 s}from"../../core/handleUtils.js";import"../../core/has.js";import r from"../../core/Logger.js";import{destroyMaybe as n,abortMaybe as p}from"../../core/maybe.js";import{createAbortError as l,whenOrAbort as h,ignoreAbortErrors as d}from"../../core/promiseUtils.js";import{watch as c,syncAndInitial as u,on as m,when as y,whenOnce as g}from"../../core/reactiveUtils.js";import{property as v,subclass as _}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as f}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 P}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as x}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 se,getDrawToolGeometryTypeFromCreateTool as re,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(),de=Symbol();let ce=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 f,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.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(de),!e)return;const o=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),c(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},u)].filter(t);this.addHandles(o,de)},this._originalPopupEnabled=null,this.defaultCreateOptions=pe,this.defaultUpdateOptions=le,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new B,this.textSymbol=new D({text:"text"})}initialize(){this.addHandles([m(()=>this.view?.map?.layers,"change",e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),c(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),u),c(()=>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),c(()=>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 textSymbol(){return this._get("textSymbol")}set textSymbol(e){this._set("textSymbol",e)}get snappingOptions(){return this.snappingManager?.options??this._get("snappingOptions")}set snappingOptions(e){null!=this._defaultSnappingManager&&(this._defaultSnappingManager.options=e),this._set("snappingOptions",e)}get snappingManager(){return this._isOverridden("snappingManager")&&this._get("snappingManager"),this._defaultSnappingManager}set snappingManager(e){if(e)this._isOverridden("snappingManager")||(this._defaultSnappingManager=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 s=()=>{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:s}=this;if("continuous"===s){if(t?.geometryToPlace)return;this._updatingHandles.addPromise(d(this.create(e,t)))}else"update"===s&&o&&this._updatingHandles.addPromise(d(this.update([o])))}};i.on("complete",s),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 s=Array.isArray(e)?e:[e];if(null==e||!s?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(s.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 r=await this._updatingHandles.addPromise(this._setupUpdateOperation(s,t));this.destroyed||null==r||Ge(r)||(F(a,this._internalGraphicsLayer),this._setUpdateOperationHandle(r,t),this.emit("update",{graphics:s,state:"start",aborted:!1,tool:r.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:s,geometryToPlace:r,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=se(p,e),d=re(e),c=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=c?.preserveAspectRatio??l??"rectangle"!==e,m={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:a,defaultZ:i,forceUniformSize:u,graphicProperties:{...n,attributes:{...n?.attributes}},geometryToPlace:r,geometryType:d,mode:h,graphicSymbol:o.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:s,snappingManager:this.snappingManager,snapToScene:!1,view:t,...c};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,r=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=!r,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=r,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()}),c(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],p=new ae({activeComponent:e,type:"create",onEnd:()=>{s(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[r,n]=await Promise.all([this._requireModule(import("../../views/3d/interactive/editingTools.js")),J()]);if(Ge(r))return r;const{ManipulatedObject3DGraphic:p,MoveTool3D:l}=r.module,h=new Map,d=()=>{h.forEach(e=>e.destroy()),h.clear()};for(const s of e){const e=new p({view:o,graphic:s}),t=P(e);if(0!==t)return d(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${R(t)}).`),null;h.set(s,e)}const c=new l({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,autoLengthMeasurementUtils:n});o.tools.add(c),c.objects.addMany(Array.from(h.values())),i||this.updateGraphics.addMany(e);const u=[],m=new ie({activeComponent:c,tool:a,type:"update",onEnd:()=>{s(u),we(o,c),d()},undo:()=>{fe(this.view,c),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),c.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&&(c.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._updatingHandles.addPromise(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],s=i.geometry;if(null!=s&&("point"===s.type||"mesh"===s.type))return this._setupPointTransform3DOperation(i,t,o);if(null!=s&&("polygon"===s.type||"polyline"===s.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:r,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,d=new h({graphic:e,view:o}),c=new l({object:d,view:o,enableRotation:i,enableScaling:r,enableZ:n,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(c),this.updateGraphics.add(e);const u=[],m=new ie({activeComponent:c,tool:a,type:"update",onEnd:()=>{s(u),we(o,c),d.destroy()},undo:()=>{fe(this.view,c),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._updatingHandles.addPromise(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:r,enableScaling:n,enableZ:p,preserveAspectRatio:l}=t,[h,d]=await Promise.all([this._requireModule(import("../../views/3d/interactive/editingTools.js")),J()]);if(Ge(h))return h;const{ManipulatedObject3DGraphic:c,ExtentTransformTool:u}=h.module,m=this.view?.inputManager?.isModifierKeyDown(K.constraint),y=new c({view:o,graphic:e}),g=new u({object:y,view:o,enableRotation:r,enableScaling:n,enableZ:p,preserveAspectRatio:!!l!=!!m,sketchOptions:this.sketchOptions,automaticLengthMeasurementUtils:d});o.tools.add(g),a||this.updateGraphics.add(e);const v=[],_=new ie({activeComponent:g,tool:i,type:"update",onEnd:()=>{s(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"}),_.onEnd(),_.destroy();const a=await this._updatingHandles.addPromise(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"}),_.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const a=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));a&&!Ge(a)&&(_.onEnd(),_.destroy(),this._setUpdateOperationHandle(a,t))}});return v.push(...this._getHandlesForComponent(_,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(_,e,t),V.WIDGET),o.on("key-down",e=>this._getCommonUpdateOperationKeyDownHandlers(_,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)),_}async _setupMove2DOperation(e,t,o){const a="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const i=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,o));if(Ge(i))return i;const r=new ie({activeComponent:i,tool:a,type:"update",onEnd:()=>{this._clearCursor(),s(l),s(p),i.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();ge(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:a})},redo:()=>{const e=this.updateGraphics.toArray();ve(r,e),r.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);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?i.graphics=o:r.complete()}});let n=!1;const p=[o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,t),V.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(r,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(r,t);return r}async _setupReshape3DOperation(e,t,o,a=!1){const i="reshape",[r,n,p]=await Promise.all([this._requireModule(import("../../views/3d/interactive/editingTools.js")),Y(),J()]);if(Ge(r))return r;const{ManipulatedObject3DGraphic:l,ReshapeTool3D:h}=r.module,d=new l({view:o,graphic:e}),c=x(d);if(0!==c)return d.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${R(c)}).`),null;const u=t.reshapeOptions,m=new h({view:o,object:d,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(d.graphic);const y=[],g=new ie({activeComponent:m,tool:i,type:"update",onEnd:()=>{s(y),we(o,m),d.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._updatingHandles.addPromise(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._updatingHandles.addPromise(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=await this._updatingHandles.addPromise("transform"===t?this._getBox(e,o,a):this._getReshape(e,o,a));if(Ge(i))return i;const r=new ie({activeComponent:i,type:"update",onEnd:()=>{s(p),s(n),r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{ge(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{ve(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},addToSelection:async e=>{let t=r.activeComponent;if("reshape"===t?.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll(),r.onEnd(),r.destroy();const i=await this._updatingHandles.addPromise(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(),r.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();0===o.length?r.complete():ne(o)?r.toggleTool():r.activeComponent.graphics=o,this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;const e=this.updateGraphics.at(0),t=e.geometry;if(null!=t&&("reshape"===r.tool&&"point"===t.type||"transform"===r.tool&&"extent"===t.type))return;let i=null;"transform"===r.tool?i=await this._updatingHandles.addPromise(this._getReshape([e],o,a)):"reshape"===r.tool&&(i=await this._updatingHandles.addPromise(this._getBox([e],o,a))),Ge(i)||(r.activeComponent?.destroy(),r.activeComponent=i,r.activeComponent&&(s(p),p=this._getHandlesForComponent(r,o)))}}),n=[a.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,o),V.WIDGET),a.on("key-down",e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key===K.constraint&&!e.repeat&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},V.WIDGET),a.on("key-up",e=>{if(e.key===K.constraint&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},V.WIDGET)];let p=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:a,highlightOptions:i}=t,s=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return Ge(s)?s:new s.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:s,preserveAspectRatio:r}=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:s?.name,highlightsEnabled:!!s?.enabled,preserveAspectRatio:!!r!=!!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,s="split"===i?.edgeOperation,r="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:s,enableMovement:r,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){r.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()],ce.prototype,"_defaultSnappingManager",void 0),e([v()],ce.prototype,"_layerAdapter",null),e([v()],ce.prototype,"_operationHandle",void 0),e([v({readOnly:!0})],ce.prototype,"_updatingHandles",void 0),e([v({readOnly:!0})],ce.prototype,"activeTool",null),e([v({readOnly:!0})],ce.prototype,"activeCreateToolDrawMode",null),e([v()],ce.prototype,"activeTooltip",null),e([v({types:I})],ce.prototype,"activeFillSymbol",void 0),e([v()],ce.prototype,"activeLineSymbol",void 0),e([v()],ce.prototype,"activeVertexSymbol",void 0),e([v()],ce.prototype,"allowDeleteKey",void 0),e([v({readOnly:!0})],ce.prototype,"createGraphic",null),e([v()],ce.prototype,"defaultCreateOptions",null),e([v()],ce.prototype,"defaultUpdateOptions",null),e([v({type:W,nonNullable:!0})],ce.prototype,"labelOptions",null),e([v()],ce.prototype,"layer",void 0),e([v({types:I})],ce.prototype,"pointSymbol",void 0),e([v({types:I})],ce.prototype,"polygonSymbol",void 0),e([v({types:I})],ce.prototype,"polylineSymbol",void 0),e([v()],ce.prototype,"meshSymbol",void 0),e([v({type:D})],ce.prototype,"textSymbol",null),e([v({type:B,nonNullable:!0})],ce.prototype,"snappingOptions",null),e([v()],ce.prototype,"snappingManager",null),e([v({readOnly:!0})],ce.prototype,"state",null),e([v({type:q,nonNullable:!0})],ce.prototype,"tooltipOptions",null),e([v({readOnly:!0})],ce.prototype,"updateGraphics",void 0),e([v()],ce.prototype,"updateOnGraphicClick",void 0),e([v()],ce.prototype,"updating",null),e([v()],ce.prototype,"creationMode",void 0),e([v({type:N,nonNullable:!0})],ce.prototype,"valueOptions",null),e([v({types:I})],ce.prototype,"vertexSymbol",void 0),e([v({value:null})],ce.prototype,"view",null),e([v({constructOnly:!0,type:Z})],ce.prototype,"sketchOptions",void 0),ce=e([_("esri.widgets.Sketch.SketchViewModel")],ce);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){_e("undo",e.history.undo,e.history.redo,t)}function ve(e,t){_e("redo",e.history.redo,e.history.undo,t)}function _e(e,t,o,a){const i=t.pop();if(!i)return;const s=i.updates,r=[];a.forEach((t,o)=>{const a=s[o];null!=a&&("geometry"in a&&null!=a.geometry&&(r.push({geometry:t.geometry}),t.geometry=a.geometry),"symbol"in a&&null!=a.symbol&&(r.push({symbol:t.symbol}),t.symbol=a.symbol),"undo"in a&&(r.push(a),a[e](t)))}),o.push({updates:r})}function fe(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{ce as default};
@@ -532,7 +532,7 @@ export interface CustomToolOptions {
532
532
  toolName: CreateTool;
533
533
  }
534
534
 
535
- export interface ActionProps {
535
+ export interface ActionProperties {
536
536
  /** Controls if the action is rendered with an "active"/pressed appearance */
537
537
  active?: boolean;
538
538
  /** Optional callback called with the HTML element for the action after it is first rendered */
@@ -553,7 +553,7 @@ export interface ActionProps {
553
553
  text: string;
554
554
  }
555
555
 
556
- export interface CustomActionProps extends ActionProps {
556
+ export interface CustomActionProperties extends ActionProperties {
557
557
  /** Controls where the action will be placed. */
558
558
  position: "before-selection-set" | "after-selection-set" | "selection-toolbar" | "settings-before" | "settings-after";
559
559
  }