@arcgis/core 5.1.0-next.30 → 5.1.0-next.31

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 (244) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{dcdddbc02b7d7febc56d.js → 005fe95c3329cfe74219.js} +1 -1
  3. package/assets/esri/core/workers/chunks/00947268b6de12329146.js +1 -0
  4. package/assets/esri/core/workers/chunks/{2563ce0f18eb84a9971a.js → 0337138d3702a1a52ce0.js} +1 -1
  5. package/assets/esri/core/workers/chunks/0554f310066937098099.js +1 -0
  6. package/assets/esri/core/workers/chunks/087403b53f15eb4d375c.js +1 -0
  7. package/assets/esri/core/workers/chunks/0d156e14fc34d0600fd5.js +1 -0
  8. package/assets/esri/core/workers/chunks/{eb4934d3a3b82316c7c6.js → 0d196cf72cd8bef8d91d.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{764d080f77dec5e7a02c.js → 0e7d3f3479fcb366cc6f.js} +1 -1
  10. package/assets/esri/core/workers/chunks/0efe90bd43ab29dab8ae.js +1 -0
  11. package/assets/esri/core/workers/chunks/122ff8d0d428f31fc5d1.js +1 -0
  12. package/assets/esri/core/workers/chunks/{37d943d3f2c40468438c.js → 144acac9bb1aa78f1170.js} +1 -1
  13. package/assets/esri/core/workers/chunks/14e05d37e10ebba8cf10.js +1 -0
  14. package/assets/esri/core/workers/chunks/19722dfef06028ab399b.js +1 -0
  15. package/assets/esri/core/workers/chunks/1ff40e6057916e8482b3.js +1 -0
  16. package/assets/esri/core/workers/chunks/209d8ee81cc3ebb18b27.js +1 -0
  17. package/assets/esri/core/workers/chunks/22aeab5c363645c04806.js +1 -0
  18. package/assets/esri/core/workers/chunks/283ce37403c5e7a76e95.js +1 -0
  19. package/assets/esri/core/workers/chunks/29687aae97dc01f33fa6.js +1 -0
  20. package/assets/esri/core/workers/chunks/2d6165796af522858e56.js +1 -0
  21. package/assets/esri/core/workers/chunks/2f0e850ebea0ffd2708f.js +1 -0
  22. package/assets/esri/core/workers/chunks/34cdcee6d0ea595d7aed.js +1 -0
  23. package/assets/esri/core/workers/chunks/34f2e9d7466abc0919e7.js +1 -0
  24. package/assets/esri/core/workers/chunks/36f91b5c4345a179b8b1.js +1 -0
  25. package/assets/esri/core/workers/chunks/380bb57bccc266d6442a.js +1 -0
  26. package/assets/esri/core/workers/chunks/3b86e8eb553122d3b68d.js +1 -0
  27. package/assets/esri/core/workers/chunks/3b9de873f87f0feeb20b.js +1 -0
  28. package/assets/esri/core/workers/chunks/{f0bb986dce9cf75c890c.js → 3c597d8ef898627b8f93.js} +1 -1
  29. package/assets/esri/core/workers/chunks/3ca7f5cedf3cb747c0cf.js +1 -0
  30. package/assets/esri/core/workers/chunks/3dcb4ee8b862689a141b.js +1 -0
  31. package/assets/esri/core/workers/chunks/{c814abf3e67d9eadbc6b.js → 414a802b6365688d31cb.js} +1 -1
  32. package/assets/esri/core/workers/chunks/446bc8461403ed1ac7b2.js +1 -0
  33. package/assets/esri/core/workers/chunks/{84073653ff50e5d3c47a.js → 4a9596bb70690b673a1b.js} +17 -7
  34. package/assets/esri/core/workers/chunks/4bfc6f8c2d13ca4d2082.js +1 -0
  35. package/assets/esri/core/workers/chunks/4ceba469398ef55de8ea.js +1 -0
  36. package/assets/esri/core/workers/chunks/54c1d31e1efab765ee7a.js +1 -0
  37. package/assets/esri/core/workers/chunks/582d45a41e29005f6c63.js +1 -0
  38. package/assets/esri/core/workers/chunks/586bc903e2c285649bf2.js +1 -0
  39. package/assets/esri/core/workers/chunks/{aa3bdfd00f666c6cc521.js → 5b12865ac53d984d8149.js} +1 -1
  40. package/assets/esri/core/workers/chunks/5e5b358e603b13b4d7d7.js +1 -0
  41. package/assets/esri/core/workers/chunks/5f3b25b30acd7a07f5c0.js +1 -0
  42. package/assets/esri/core/workers/chunks/620965d2e1a9ccf81d43.js +1 -0
  43. package/assets/esri/core/workers/chunks/623bfacf4b9c9a5387cc.js +1 -0
  44. package/assets/esri/core/workers/chunks/63722607fbf8d411188d.js +1 -0
  45. package/assets/esri/core/workers/chunks/64870f555fefa85a5c59.js +1 -0
  46. package/assets/esri/core/workers/chunks/{0df585420c9cec6a7265.js → 666db81085bc97831b18.js} +1 -1
  47. package/assets/esri/core/workers/chunks/67de5225b2c66c9c7bc9.js +1 -0
  48. package/assets/esri/core/workers/chunks/696f645349249f26090c.js +1 -0
  49. package/assets/esri/core/workers/chunks/{57e375d8a8db9fa57193.js → 6e8cfe69617876ee0dac.js} +1 -1
  50. package/assets/esri/core/workers/chunks/6f3f7f785241edacdb8b.js +1 -0
  51. package/assets/esri/core/workers/chunks/{ee6f7c5d3c2f187645ff.js → 7411ca5e1876aaa0228e.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{94563b007647a9c4ad76.js → 75cde632887a95ea20f2.js} +1 -1
  53. package/assets/esri/core/workers/chunks/776a7179d32fe62a37e3.js +1 -0
  54. package/assets/esri/core/workers/chunks/7ddb11a127b9458e9eac.js +1 -0
  55. package/assets/esri/core/workers/chunks/7ebd836b98d14c7d3ecf.js +1 -0
  56. package/assets/esri/core/workers/chunks/80f0810527743833b4b7.js +1 -0
  57. package/assets/esri/core/workers/chunks/828998d33a48be161782.js +1 -0
  58. package/assets/esri/core/workers/chunks/8bd24534ed185afcb124.js +1 -0
  59. package/assets/esri/core/workers/chunks/8d4ddaace906dd09de2c.js +1 -0
  60. package/assets/esri/core/workers/chunks/8e10e4c25869af9da5ba.js +1 -0
  61. package/assets/esri/core/workers/chunks/8eed5b6cac937099102c.js +1 -0
  62. package/assets/esri/core/workers/chunks/{71be4833a260714d3b2c.js → 917474f9dd2039b82e9d.js} +1 -1
  63. package/assets/esri/core/workers/chunks/{c3a0b38abf0a12a466fa.js → 965b8fa54d0cfafd4a70.js} +1 -1
  64. package/assets/esri/core/workers/chunks/9813f25192ea27084754.js +1 -0
  65. package/assets/esri/core/workers/chunks/9a3e5053e95db36f26dc.js +1 -0
  66. package/assets/esri/core/workers/chunks/9cc1b44c5a325a840307.js +1 -0
  67. package/assets/esri/core/workers/chunks/9cd548ea00b641d8e65d.js +1 -0
  68. package/assets/esri/core/workers/chunks/a2d045217a42ecc36308.js +1 -0
  69. package/assets/esri/core/workers/chunks/a52a8254577840a23aba.js +1 -0
  70. package/assets/esri/core/workers/chunks/{1cbe564cfc9eb0723827.js → aa367ca7f8326fd67881.js} +1 -1
  71. package/assets/esri/core/workers/chunks/aa742f847d77bb03ff60.js +1 -0
  72. package/assets/esri/core/workers/chunks/ad9194335902c687bb96.js +1 -0
  73. package/assets/esri/core/workers/chunks/ae72c530d52a6d4461be.js +1 -0
  74. package/assets/esri/core/workers/chunks/af601eb8c938c0720406.js +1 -0
  75. package/assets/esri/core/workers/chunks/b2cf19a28aa5c32a99e3.js +1 -0
  76. package/assets/esri/core/workers/chunks/b2f497339493926d4c9e.js +1 -0
  77. package/assets/esri/core/workers/chunks/b7a3a7f7fb747f9689d7.js +1 -0
  78. package/assets/esri/core/workers/chunks/b81780e5e7cd9a1a010a.js +1 -0
  79. package/assets/esri/core/workers/chunks/bb7e0334f438daa665da.js +1 -0
  80. package/assets/esri/core/workers/chunks/{5690b49f355a5e2083a9.js → c17c3453d014dc73fe0b.js} +1 -1
  81. package/assets/esri/core/workers/chunks/c1be9c4e59925a897a91.js +1 -0
  82. package/assets/esri/core/workers/chunks/{0389ebb63510dd7024de.js → c24ce19ab8580364c703.js} +2 -2
  83. package/assets/esri/core/workers/chunks/c2882a9e67124b7c18be.js +1 -0
  84. package/assets/esri/core/workers/chunks/c6112dcd6b36e256d7b5.js +1 -0
  85. package/assets/esri/core/workers/chunks/c8ae8d1b456ace0b383b.js +1 -0
  86. package/assets/esri/core/workers/chunks/{3a018c78859b5edec4fd.js → ca700e9e1bced9f99899.js} +1 -1
  87. package/assets/esri/core/workers/chunks/cc8e6d1eb90221103023.js +1 -0
  88. package/assets/esri/core/workers/chunks/d0d836502321e7a80e61.js +1 -0
  89. package/assets/esri/core/workers/chunks/d2fa8bd3f4cd3cf6b436.js +1 -0
  90. package/assets/esri/core/workers/chunks/d4b97ca16d79809ed6f2.js +1 -0
  91. package/assets/esri/core/workers/chunks/e00000468fb8ec2b3d43.js +1 -0
  92. package/assets/esri/core/workers/chunks/e0d6292aaa3f8a796de3.js +1 -0
  93. package/assets/esri/core/workers/chunks/ee582bbe7365b678ec54.js +1 -0
  94. package/assets/esri/core/workers/chunks/f4053e4e2d6e678db48a.js +1 -0
  95. package/assets/esri/core/workers/chunks/f5dbda08d7fd4bed1c62.js +1 -0
  96. package/assets/esri/core/workers/chunks/{a7dbd38bc216713044fc.js → fe21b2d31fbf83224e6b.js} +1 -1
  97. package/assets/esri/core/workers/chunks/ff8de370abf661768380.js +1 -0
  98. package/config.js +1 -1
  99. package/core/timeUtils.js +1 -1
  100. package/editing/sharedTemplates/executor/support/createFeatureServiceEdit.js +1 -1
  101. package/kernel.js +1 -1
  102. package/layers/VoxelWasmPerSceneView.js +1 -1
  103. package/package.json +2 -2
  104. package/rest/query/operations/pbfFeatureServiceParser.js +1 -1
  105. package/support/revision.js +1 -1
  106. package/symbols/CIMSymbol.d.ts +3 -3
  107. package/symbols/ExtrudeSymbol3DLayer.d.ts +1 -1
  108. package/symbols/FillSymbol.d.ts +1 -1
  109. package/symbols/FillSymbol3DLayer.d.ts +1 -1
  110. package/symbols/IconSymbol3DLayer.d.ts +1 -1
  111. package/symbols/LabelSymbol3D.d.ts +1 -1
  112. package/symbols/LineSymbol.d.ts +1 -1
  113. package/symbols/LineSymbol3D.d.ts +1 -1
  114. package/symbols/LineSymbol3DLayer.d.ts +1 -1
  115. package/symbols/LineSymbolMarker.d.ts +1 -1
  116. package/symbols/MarkerSymbol.d.ts +1 -1
  117. package/symbols/MeshSymbol3D.d.ts +1 -1
  118. package/symbols/ObjectSymbol3DLayer.d.ts +1 -1
  119. package/symbols/PathSymbol3DLayer.d.ts +1 -1
  120. package/symbols/PictureFillSymbol.d.ts +1 -1
  121. package/symbols/PictureMarkerSymbol.d.ts +1 -1
  122. package/symbols/PointSymbol3D.d.ts +1 -1
  123. package/symbols/PolygonSymbol3D.d.ts +1 -1
  124. package/symbols/SimpleFillSymbol.d.ts +1 -1
  125. package/symbols/SimpleLineSymbol.d.ts +1 -1
  126. package/symbols/SimpleMarkerSymbol.d.ts +1 -1
  127. package/symbols/Symbol.d.ts +1 -1
  128. package/symbols/Symbol3D.d.ts +1 -1
  129. package/symbols/Symbol3DLayer.d.ts +1 -1
  130. package/symbols/TextSymbol.d.ts +1 -1
  131. package/symbols/TextSymbol3DLayer.d.ts +1 -1
  132. package/symbols/WebStyleSymbol.d.ts +1 -1
  133. package/time/TimeExtent.js +1 -1
  134. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueFill.js +1 -1
  135. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueLine.js +1 -1
  136. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  137. package/views/3d/layers/IntegratedMeshNormals.js +1 -1
  138. package/views/3d/layers/VoxelLayerView3D.js +1 -1
  139. package/views/3d/webgl/RenderNode.js +1 -1
  140. package/views/3d/webgl-engine/collections/Component/ComponentDrawParameters.js +1 -1
  141. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  142. package/views/3d/webgl-engine/core/renderPasses/AllRenderPasses.js +1 -1
  143. package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
  144. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  145. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexNormal.glsl.js +13 -3
  146. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexPosition.glsl.js +27 -9
  147. package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
  148. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  149. package/views/3d/webgl-engine/effects/highlight/HighlightApplyTechnique.js +1 -1
  150. package/views/3d/webgl-engine/effects/highlight/HighlightBlurTechnique.js +1 -1
  151. package/views/3d/webgl-engine/effects/highlight/HighlightDownsampleTechnique.js +1 -1
  152. package/views/3d/webgl-engine/effects/highlight/HighlightToSingleTechnique.js +1 -1
  153. package/views/3d/webgl-engine/effects/ssao/SSAOBlurTechnique.js +1 -1
  154. package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
  155. package/views/3d/webgl-engine/effects/transparency/OITBlendTechnique.js +1 -1
  156. package/views/3d/webgl-engine/effects/transparency/OITDimTechnique.js +1 -1
  157. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  158. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  159. package/views/3d/webgl-engine/statistics/RendererPerformanceInfo.js +1 -1
  160. package/views/3d/webgl.js +1 -1
  161. package/views/draw/DrawTool.js +1 -1
  162. package/views/webgl/RenderingContext.js +1 -1
  163. package/widgets/ElevationProfile/ElevationProfileInteraction.js +1 -1
  164. package/widgets/ElevationProfile/ElevationProfileViewModel.js +1 -1
  165. package/widgets/OrientedImageryViewer/support/geometryUtils.js +1 -1
  166. package/widgets/Sketch/SketchViewModel.js +1 -1
  167. package/widgets/TimeSlider/TimeSliderViewModel.js +1 -1
  168. package/widgets/TimeSlider.js +1 -1
  169. package/assets/esri/core/workers/chunks/011b31df019b3ce2277e.js +0 -1
  170. package/assets/esri/core/workers/chunks/018859b79f9ce7528ac7.js +0 -1
  171. package/assets/esri/core/workers/chunks/05e5b9082c0a396df7e5.js +0 -1
  172. package/assets/esri/core/workers/chunks/0711c856144cd8700e7e.js +0 -1
  173. package/assets/esri/core/workers/chunks/0ca9953afaea7c7e11e0.js +0 -1
  174. package/assets/esri/core/workers/chunks/1482262d0788ee65ddf7.js +0 -1
  175. package/assets/esri/core/workers/chunks/15d7c9f5a55985ed00b4.js +0 -1
  176. package/assets/esri/core/workers/chunks/16b9ac49d13057b3aff5.js +0 -1
  177. package/assets/esri/core/workers/chunks/172137cc98be03de1436.js +0 -1
  178. package/assets/esri/core/workers/chunks/179b3385c24ad8a05e1d.js +0 -1
  179. package/assets/esri/core/workers/chunks/18a40606e4c39f244ecd.js +0 -1
  180. package/assets/esri/core/workers/chunks/19cb4720e92ac3c0478c.js +0 -1
  181. package/assets/esri/core/workers/chunks/1d697642fb2a6332b7f9.js +0 -1
  182. package/assets/esri/core/workers/chunks/2003dae2d7f6d52ea643.js +0 -1
  183. package/assets/esri/core/workers/chunks/209acb3ad16c99bb506c.js +0 -1
  184. package/assets/esri/core/workers/chunks/2e06baf6469820697f17.js +0 -1
  185. package/assets/esri/core/workers/chunks/2ecfd6edab796194bf88.js +0 -1
  186. package/assets/esri/core/workers/chunks/2f3aeaa25a76ab94b8e5.js +0 -1
  187. package/assets/esri/core/workers/chunks/33de1d899a4fa9ab6ab1.js +0 -1
  188. package/assets/esri/core/workers/chunks/359d3ba9d6e3b1de05d1.js +0 -1
  189. package/assets/esri/core/workers/chunks/36fd18a05ba503e6f3b5.js +0 -1
  190. package/assets/esri/core/workers/chunks/38d5dd4d457428244302.js +0 -1
  191. package/assets/esri/core/workers/chunks/3a8f2f6ac3c3e7e71c00.js +0 -1
  192. package/assets/esri/core/workers/chunks/3ad1edf199e7159f3cc2.js +0 -1
  193. package/assets/esri/core/workers/chunks/452d71789a1b77cff48d.js +0 -1
  194. package/assets/esri/core/workers/chunks/48a56b19bf825f05cc6e.js +0 -1
  195. package/assets/esri/core/workers/chunks/48e66b78274b82478bae.js +0 -1
  196. package/assets/esri/core/workers/chunks/48fb1520cb8c5ce248d9.js +0 -1
  197. package/assets/esri/core/workers/chunks/4e9b3b4b3dcce94c99a5.js +0 -1
  198. package/assets/esri/core/workers/chunks/5028de543cc1b8e60e65.js +0 -1
  199. package/assets/esri/core/workers/chunks/544bfa97837770a8792f.js +0 -1
  200. package/assets/esri/core/workers/chunks/55d4483b1862077e3732.js +0 -1
  201. package/assets/esri/core/workers/chunks/561484ab6ed564e4b90f.js +0 -1
  202. package/assets/esri/core/workers/chunks/592f6bf0283152481f21.js +0 -1
  203. package/assets/esri/core/workers/chunks/5b70ee8122262de5bbdf.js +0 -1
  204. package/assets/esri/core/workers/chunks/6138a528c3820af81bc6.js +0 -1
  205. package/assets/esri/core/workers/chunks/72cd450b24fdfcef6547.js +0 -1
  206. package/assets/esri/core/workers/chunks/75fd96fd9557ac1f8e10.js +0 -1
  207. package/assets/esri/core/workers/chunks/777b0e07f72c42470d36.js +0 -1
  208. package/assets/esri/core/workers/chunks/7b297a2f712361bfae2e.js +0 -1
  209. package/assets/esri/core/workers/chunks/7d274a077bdfa8c485e8.js +0 -1
  210. package/assets/esri/core/workers/chunks/7dd1e93469d0b1d652bc.js +0 -1
  211. package/assets/esri/core/workers/chunks/835a929e37811d0f82cb.js +0 -1
  212. package/assets/esri/core/workers/chunks/843c505148ed728d3c30.js +0 -1
  213. package/assets/esri/core/workers/chunks/8dcc8df5925f66e45b8c.js +0 -1
  214. package/assets/esri/core/workers/chunks/8eae33c4d8932b7a6bc1.js +0 -1
  215. package/assets/esri/core/workers/chunks/91e56959b2fddf1a9743.js +0 -1
  216. package/assets/esri/core/workers/chunks/925980d26d71987ac80c.js +0 -1
  217. package/assets/esri/core/workers/chunks/9bd5c56f879eb935d906.js +0 -1
  218. package/assets/esri/core/workers/chunks/aa9c11f25d95372998a3.js +0 -1
  219. package/assets/esri/core/workers/chunks/aec33bdb355bd04f28ae.js +0 -1
  220. package/assets/esri/core/workers/chunks/af618a1c55c15e17189b.js +0 -1
  221. package/assets/esri/core/workers/chunks/b35ea099334c867bde02.js +0 -1
  222. package/assets/esri/core/workers/chunks/b4254fcb2051c873f2ba.js +0 -1
  223. package/assets/esri/core/workers/chunks/b730131e52f9220db031.js +0 -1
  224. package/assets/esri/core/workers/chunks/b81824d62be92ab595f7.js +0 -1
  225. package/assets/esri/core/workers/chunks/b9d68a5dcb50999d3a90.js +0 -1
  226. package/assets/esri/core/workers/chunks/bae7376b554cac4a8f96.js +0 -1
  227. package/assets/esri/core/workers/chunks/bcd701892ee120e13a18.js +0 -1
  228. package/assets/esri/core/workers/chunks/c1c006c86cf31f934684.js +0 -1
  229. package/assets/esri/core/workers/chunks/cb6a7ca4ba2cf0b5ced7.js +0 -1
  230. package/assets/esri/core/workers/chunks/d70678598f4080adfb39.js +0 -1
  231. package/assets/esri/core/workers/chunks/d72d5031887373d35610.js +0 -1
  232. package/assets/esri/core/workers/chunks/d8896c57a414f2450190.js +0 -1
  233. package/assets/esri/core/workers/chunks/da780342f16e65b55ac8.js +0 -1
  234. package/assets/esri/core/workers/chunks/db005d9419bb718b3962.js +0 -1
  235. package/assets/esri/core/workers/chunks/e063cce778944fe97dd3.js +0 -1
  236. package/assets/esri/core/workers/chunks/e2bdb0e87422e222646e.js +0 -1
  237. package/assets/esri/core/workers/chunks/e4faccd48060349b8da1.js +0 -1
  238. package/assets/esri/core/workers/chunks/ea245d3a6fd601fffd88.js +0 -1
  239. package/assets/esri/core/workers/chunks/efb2a8879011d2d77a81.js +0 -1
  240. package/assets/esri/core/workers/chunks/f6c9742691ccdaed44a2.js +0 -1
  241. package/assets/esri/core/workers/chunks/f82a95c46f0d579d5bf5.js +0 -1
  242. package/assets/esri/core/workers/chunks/fd9ef90e2ebb7fed62b1.js +0 -1
  243. package/assets/esri/core/workers/chunks/feac196493ccd087de35.js +0 -1
  244. /package/assets/esri/core/workers/chunks/{0389ebb63510dd7024de.js.LICENSE.txt → c24ce19ab8580364c703.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import a from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import{drainHandles as s,destroyHandle as n}from"../../core/handleUtils.js";import"../../core/has.js";import p from"../../core/Logger.js";import{destroyMaybe as l,abortMaybe as h}from"../../core/maybe.js";import{createAbortError as c,whenOrAbort as d,ignoreAbortErrors as u}from"../../core/promiseUtils.js";import{watch as g,syncAndInitial as m,on as y,when as v,whenOnce as f}from"../../core/reactiveUtils.js";import{property as _,subclass as b}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as w}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as G}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as T,isLoaded as O,load as S,project as E}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as C}from"../../geometry/support/coordsUtils.js";import{equals as M}from"../../geometry/support/spatialReferenceUtils.js";import A from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as k}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as H}from"../../support/elevationInfoUtils.js";import D from"../../symbols/FillSymbol3DLayer.js";import I from"../../symbols/MeshSymbol3D.js";import P from"../../symbols/SimpleFillSymbol.js";import j from"../../symbols/SimpleLineSymbol.js";import R from"../../symbols/SimpleMarkerSymbol.js";import U from"../../symbols/TextSymbol.js";import{symbolTypes as x}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as L}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as F}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as V}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as K}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as W}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as Z}from"../../views/input/InputManager.js";import{sketchKeys as q}from"../../views/interactive/keybindings.js";import N from"../../views/interactive/sketch/SketchLabelOptions.js";import z from"../../views/interactive/sketch/SketchOptions.js";import B from"../../views/interactive/sketch/SketchTooltipOptions.js";import $ from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as Y}from"../../views/interactive/snapping/SnappingManager.js";import J from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as Q}from"../../views/interactive/snapping/snappingUtils.js";import{defaultHighlightName as X}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as ee}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as te}from"../../views/support/screenUtils.js";import oe from"./adapters/layer/GraphicsLayerAdapter.js";import ie from"./adapters/layer/MapNotesLayerAdapter.js";import{CreateOperationHandle as ae,DrawToolOperationHandle as re,UpdateOperationHandle as se}from"./support/OperationHandle.js";import{PluginManager as ne}from"./support/PluginManager.js";import{getLegacyTool as pe,isCompletelyDegenerate as le,graphicsHaveTooFewVerticesForBox as he,getModeFromCreateOptions as ce,getDrawToolGeometryTypeFromCreateTool as de}from"./support/sketchUtils.js";const ue={defaultZ:0},ge={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:X},tool:"transform"},me=Symbol(),ye=Symbol();let ve=class extends r{constructor(e){super(e),this._defaultSnappingManager=null,this._internalGraphicsLayer=new A({listMode:"hide",internal:!0,title:"SVM Internal"}),this._pluginManager=new ne({sketchViewModel:this}),this._operationHandle=null,this._updatingHandles=new w,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.layer=null,this.pointSymbol=new R({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new P({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 I({symbolLayers:new i([new D])}),this.updateGraphics=new i,this.updateOnGraphicClick=!0,this.creationMode="single",this.vertexSymbol=new R({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new z,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{const{_layerAdapter:e}=this;if(this.removeHandles(ye),!e)return;const t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),g(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},m)].filter(o);this.addHandles(t,ye)},this._originalPopupEnabled=null,this.defaultCreateOptions=ue,this.defaultUpdateOptions=ge,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new J,this.textSymbol=new U({text:"text"})}initialize(){this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([y(()=>this.view?.map?.layers,"change",e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),g(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),m),g(()=>this.view,e=>{this._defaultSnappingManager=l(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new Y({view:e,options:this.snappingOptions})),"2d"===e.type?(import("../../views/2d/interactive/editingTools.js"),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))},m),g(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),Q(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=l(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this._pluginManager?.destroy(),this.emit("destroy")}get _layerAdapter(){const{layer:e}=this;switch(e?.type){case"graphics":return new oe(e);case"map-notes":return new ie(e);default:return null}}get activeTool(){return this._operationHandle?.tool??null}get activeCreateToolDrawMode(){const e=this._operationHandle;if("create"===e?.type&&e.activeComponent&&"mode"in e.activeComponent)return e.activeComponent.mode;if("draw-2.0"===e?.activeComponent?.type){const t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(o).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){const{activeComponent:e,destroyed:t}=this,o=!t&&e&&"tooltip"in e?e.tooltip:null;return o?.visible?o:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return null==this.activeComponent||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):this.activeComponent.graphic}get defaultCreateOptions(){return this._get("defaultCreateOptions")}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...ue,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...ge,...e,reshapeOptions:{...ge.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...ge.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=l(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new Y({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.activeComponent&&"updating"in this.activeComponent&&this.activeComponent.updating||!!(this._updatingHandles.updating||this.snappingManager?.updating||this.drawTool?.updating)}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&this._clearCursor(),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(v(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},m),o),this._set("view",e),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}get pluginManager(){return this._pluginManager}get drawTool(){return"draw-2.0"!==this.activeComponent?.type?null:this.activeComponent}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome("rootPlugins",e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;const e=this.view?.type??"2d",{firstPluginWithSwappableLeaf:t}=this;return t?t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e)):this.rootPlugins?.filter(t=>!t.excludedViews?.includes(e)).filter(o)??[]}get firstPluginWithSwappableLeaf(){const e=this.view?.type??"2d",t=this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>null!=t&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1);return t}get multiplePluginsActive(){return!!this.drawTool&&this.drawTool.pluginStack.length>1}addGraphic(e){this._layerAdapter?.add(e)}addGraphics(e){this._layerAdapter?.addMany(e)}hasGraphic(e){return!!this._layerAdapter?.has(e)}removeGraphic(e){this._layerAdapter?.remove(e)}removeGraphics(e){this._layerAdapter?.removeMany(e)}removeAllGraphics(){this._layerAdapter?.removeAll()}cancel(){this._moduleLoaderAbortController=h(this._moduleLoaderAbortController),this._viewReadyAbortController=h(this._viewReadyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e}=this,o=t.toArray();this.removeGraphics(o),this.cancel(),this._emitDeleteEvent({graphics:o,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map(e=>e.clone()).toArray();return this.addGraphics(e),this.emit("duplicate",{graphics:e,type:"duplicate"}),e}return[]}async create(e,t){this.cancel(),await this._waitViewReady();const{view:o,layer:i}=this;if(!o||"disabled"===this.state)throw i||this._logMissingLayer(),c();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");W(o,this._internalGraphicsLayer);const a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t));if(null==a||this.destroyed)return void o.map?.remove(this._internalGraphicsLayer);const r=pe(e),s=()=>{if(a===this._operationHandle){const o=this.createGraphic,i=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map?.remove(this._internalGraphicsLayer),a.cancelled||null==o||this.addGraphic(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:i?"cancel":"complete",tool:r??"point",toolEventInfo:null,type:"create"}),i||this._sketchContinuationFlag)return;const{creationMode:s}=this;if("continuous"===s){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(u(this.create(e,t)))}else"update"===s&&o&&this._updatingHandles.consumePromise(u(this.update([o])))}};a.on("complete",s),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return await e.load(),this.create("mesh",{mode:"click",hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){this.cancel(),await this._waitViewReady();const{layer:o,view:i,state:a}=this;if(!i||"disabled"===a)throw o||this._logMissingLayer(),c();null!=i.activeTool&&(i.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some(e=>this.hasGraphic(e)?null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0):(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0)))return;const s=await this._updatingHandles.addPromise(this._setupUpdateOperation(r,t));this.destroyed||null==s||Ce(s)||(W(i,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit("update",{graphics:r,state:"start",aborted:!1,tool:s.tool,toolEventInfo:null,type:"update"}))}async _updateSpatialReference(e){const t=this.view;if(t){e=Array.isArray(e)?e:[e];for(const o of e)null==o.geometry||"mesh"===o.geometry.type||M(o.geometry.spatialReference,t.spatialReference)||(T(o.geometry.spatialReference,t.spatialReference)||O()||await S(),o.geometry=E(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 i=await t.hitTest(e,{exclude:o});return ee(i.results)}const o=[t.map.ground];t.map.allLayers.forEach(e=>{k(e)&&o.push(e)});const i=await t.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!i.ground.mapPoint||t.map.ground.opacity<1||i.ground.distance-(e.distance??0)>-Math.min(3*i.ground.distance,"global"===t.viewingMode?G(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY)))return e}return null}_generateViewHandles(e){return[e.on("immediate-click",async e=>{const t="active"===this.state&&"create"===this._operationHandle?.type;"disabled"!==this.state&&!t&&this.updateOnGraphicClick&&await this._updatingHandles.addPromise(this._handleImmediateClick(e))},Z.WIDGET)]}async _handleImmediateClick(e){const t=await e.defer(()=>this._getFirstHit(te(e)));let o=null;if(null!=t){const i=t.graphic;this.updateGraphics.includes(i)||this.hasGraphic(i)?(e.stopPropagation(),o=i):"2d"!==this.view?.type||this._isComponentGraphic(i)||"active"!==this.state||this.cancel()}else"active"===this.state&&this.cancel();null==o||this.updateGraphics.includes(o)||await this.update([o],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){const o=this.view;if(!o)return this._logMissingView(),null;const i={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},a="string"==typeof e?this.pluginManager?.getPluginsEquivalentToCreateTool(e,i.mode):e,r=pe(e);if(a&&!this.isUsingLegacyCreateTools){const e=await this._setupDrawTool(a,i,r??"polyline");if(e)return this._setupDrawToolOperationHandle(e,r??"point")}if(!r)return null;const s=await this._setupDrawGraphicTool(r,o,i);return null==s?null:(o.tools.add(s),o.activeTool=s,this._setupCreateOperationHandle(s,r))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView."),null;if(!t)return this._logMissingView(),null;const{cursor:i,defaultZ:a,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=ce(p,e),c=de(e),d=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=d?.preserveAspectRatio??l??"rectangle"!==e,g={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:i,defaultZ:a,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(g):this._makeDrawGraphicTool3D(g)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return Ce(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:be(e.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));return Ce(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,sketchOptions:this.sketchOptions})}_setupCreateOperationHandle(e,t){const o=this.view;if(!o)return this._logMissingView(),null;let i=null;const a=e.forceUniformSize,r=e.centered,n=[o.on("key-down",t=>{if(t.key===q.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===q.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==q.vertexAdd||t.repeat)t.key===q.undo?(t.stopPropagation(),p.undo()):t.key===q.redo?(t.stopPropagation(),p.redo()):t.key!==q.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===q.center&&(t.repeat||(e.centered=!r,t.stopPropagation())):(e.forceUniformSize=!a,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}},Z.WIDGET),o.on("key-up",t=>{t.key===q.pan?e.enabled=!0:t.key!==q.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===q.center&&(e.centered=r,t.stopPropagation()):(e.forceUniformSize=a,t.stopPropagation())},Z.WIDGET),e.on("vertex-add",t=>{switch(i=null==i?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:i,tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("cursor-update",t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("vertex-remove",t=>{switch(t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("complete",e=>{this._set("createGraphic",e.graphic),i="complete",e.aborted?p&&p.cancel():p&&p.complete()}),g(()=>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}_setupDrawToolOperationHandle(e,t){const i=this.view;if(!i)return this._logMissingView(),null;let a=null;const r=[i.on("key-down",t=>{t.key===q.pan&&(t.stopPropagation(),t.repeat||(e.editable=!1))},Z.WIDGET),i.on("key-up",t=>{t.key===q.pan&&(e.editable=!0)},Z.WIDGET),e.on("before-vertex-add",t=>{const o=e.mostUpstreamPlugin?.configuration;if(o&&"legacyCreateTool"in o&&("point"===o?.legacyCreateTool||"text"===o.legacyCreateTool)){const e=t.detail.originalEvent;return void(e&&"key"in e&&e.key===q.vertexAdd&&t.preventDefault())}}),e.on("before-complete",t=>{const o=e.getGeometryIfCompleted();(!o||le(o))&&t.preventDefault()}),e.on("vertex-add",i=>{switch(this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),a=null==a?"start":"active",i.operation){case"apply":this.emit("create",{graphic:this.createGraphic,state:a,tool:this.activeTool,toolEventInfo:i,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[this.createGraphic].filter(o),tool:t});break;case"redo":this._emitRedoEvent({graphics:[this.createGraphic].filter(o),tool:t})}}),e.on("cursor-update",t=>{this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),(t.vertices[0]?.vertexIndex>0||t.vertices[0]?.componentIndex>0)&&this.emit("create",{graphic:this.createGraphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("vertex-remove",i=>{switch(this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),i.operation){case"apply":this.emit("create",{graphic:this.createGraphic,state:"active",tool:this.activeTool,toolEventInfo:i,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[this.createGraphic].filter(o),tool:t});break;case"redo":this._emitRedoEvent({graphics:[this.createGraphic].filter(o),tool:t})}}),e.on("complete",({geometry:e})=>{const t=this.createGraphic;t&&e&&(t.geometry=e),n.complete()})],n=new re({activeComponent:e,type:"create",onEnd:()=>{s(r),i.tools.remove(e)},undo:()=>e.undo(),redo:()=>e.redo(),canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return r.push(e.on("cancel",()=>n.cancel())),n}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":case"freehandPolyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":case"freehandPolygon":return this.polygonSymbol;case"mesh":return this.meshSymbol;case"text":return this.textSymbol}}async _setupUpdateOperation(e,t){const{view:o}=this;if(!o)return this._logMissingView(),null;const i={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};let a=i.tool??ge.tool;if(this.removeGraphics(e),this.addGraphics(e),"3d"===o.type){if(0===e.length)return null;switch(a){case"move":return this._setupMove3DOperation(e,i,o,a);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],i,o);case"transform":return this._setupGraphicTransform3DOperation(e,i,o)}}switch(a){case"move":return this._setupMove2DOperation(e,i,o);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,a,i,o);case"transform":return he(e)&&(a="reshape"),this._setupTransformOrReshape2DOperation(e,a,i,o)}}async _setupMove3DOperation(e,t,o,i,a=!1){const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(r))return r;const{ManipulatedObject3DGraphic:n,MoveTool3D:p}=r.module,l=new Map,h=()=>{l.forEach(e=>e.destroy()),l.clear()};for(const s of e){const e=new n({view:o,graphic:s}),t=F(e);if(0!==t)return h(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${L(t)}).`),null;l.set(s,e)}const c=new p({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(c),c.objects.addMany(Array.from(l.values())),a||this.updateGraphics.addMany(e);const d=[],u=new se({activeComponent:c,tool:i,type:"update",onEnd:()=>{s(d),Ee(o,c),h()},undo:()=>{Oe(this.view,c),we(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ge(u,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:e=>{this.updateGraphics.push(e);const t=new n({view:o,graphic:e});l.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(u.history.undo.forEach(e=>e.updates.splice(t,1)),u.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0===this.updateGraphics.length)return void u.complete();const o=l.get(e);o&&(c.objects.remove(o),o.destroy(),l.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.at(0),a=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));a&&!Ce(a)&&(u.onEnd(),u.destroy(),this._setUpdateOperationHandle(a,t))}});return d.push(...this._getHandlesForComponent(u,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(u,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)},Z.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&0===K(e[0])){const a=e[0],r=a.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=r&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(a,t,o,i)}return this._setupMove3DOperation(e,t,o,"transform",i)}async _setupPointTransform3DOperation(e,t,o){const i="transform",{enableRotation:a,enableScaling:r,enableZ:n}=t,p=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(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:a,enableScaling:r,enableZ:n,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),this.updateGraphics.add(e);const u=[],g=new se({activeComponent:d,tool:i,type:"update",onEnd:()=>{s(u),Ee(o,d),c.destroy()},undo:()=>{Oe(this.view,d),we(g,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ge(g,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),g.onEnd(),g.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ce(i)||this._setUpdateOperationHandle(i,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:()=>{}});return u.push(...this._getHandlesForComponent(g,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(g,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(g,e)},Z.WIDGET)),g}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:r,enableScaling:n,enableZ:p,preserveAspectRatio:l}=t,h=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(h))return h;const{ManipulatedObject3DGraphic:c,ExtentTransformTool:d}=h.module,u=this.view?.inputManager?.isModifierKeyDown(q.constraint),g=new c({view:o,graphic:e}),m=new d({object:g,view:o,enableRotation:r,enableScaling:n,enableZ:p,preserveAspectRatio:!!l!=!!u,sketchOptions:this.sketchOptions});o.tools.add(m),i||this.updateGraphics.add(e);const y=[],v=new se({activeComponent:m,tool:a,type:"update",onEnd:()=>{s(y),Ee(o,m),g.destroy()},canUndo:()=>!m.destroyed&&m.canUndo,undo:()=>{m.destroyed||(m.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!m.destroyed&&m.canRedo,redo:()=>{m.destroyed||(m.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),v.onEnd(),v.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ce(i)||this._setUpdateOperationHandle(i,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"}),v.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));i&&!Ce(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return y.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(v,e,t),Z.WIDGET),o.on("key-down",e=>this._getCommonUpdateOperationKeyDownHandlers(v,e),Z.WIDGET),o.on("key-down",e=>{e.key!==q.constraint||e.repeat||(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())},Z.WIDGET),o.on("key-up",e=>{e.key===q.constraint&&(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())},Z.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,o));if(Ce(a))return a;const r=new se({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._clearCursor(),s(l),s(p),a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();we(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();Ge(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),a.graphics=this.updateGraphics.toArray(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?a.graphics=o:r.complete()}});let n=!1;const p=[o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==q.constraint||e.repeat||(n=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},Z.WIDGET),o.on("key-up",e=>{e.key===q.constraint&&n&&(n=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},Z.WIDGET)],l=this._getHandlesForComponent(r,t);return r}async _setupReshape3DOperation(e,t,o,i=!1){const a="reshape",r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(r))return r;const{ManipulatedObject3DGraphic:n,ReshapeTool3D:p}=r.module,l=new n({view:o,graphic:e}),h=V(l);if(0!==h)return l.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${L(h)}).`),null;const c=t.reshapeOptions,d=new p({view:o,object:l,enableZVertex:t.enableZ&&"move"===c?.vertexOperation,enableZShape:t.enableZ&&"move"===c?.shapeOperation,enableMoveObject:"move"===c?.shapeOperation||"move-xy"===c?.shapeOperation,enableMidpoints:"split"===c?.edgeOperation,enableEdgeOffset:"offset"===c?.edgeOperation,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),i||this.updateGraphics.add(l.graphic);const u=[],g=new se({activeComponent:d,tool:a,type:"update",onEnd:()=>{s(u),Ee(o,d),l.destroy()},canUndo:()=>!d.destroyed&&d.canUndo,undo:()=>{d.destroyed||(d.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!d.destroyed&&d.canRedo,redo:()=>{d.destroyed||(d.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),g.onEnd(),g.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ce(i)||this._setUpdateOperationHandle(i,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));Ce(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(g,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(g,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(g,e)},Z.WIDGET)),g}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise("transform"===t?this._getBox(e,o,i):this._getReshape(e,o,i));if(Ce(a))return a;const r=new se({activeComponent:a,type:"update",onEnd:()=>{s(p),s(n),r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{we(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{Ge(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},addToSelection:async e=>{let t=r.activeComponent;if("reshape"===t?.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll(),r.onEnd(),r.destroy();const a=await this._updatingHandles.addPromise(this._setupTransformOrReshape2DOperation(t,"transform",o,i));if(Ce(a))return;this._setUpdateOperationHandle(a,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),r.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection: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():he(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 a=null;"transform"===r.tool?a=await this._updatingHandles.addPromise(this._getReshape([e],o,i)):"reshape"===r.tool&&(a=await this._updatingHandles.addPromise(this._getBox([e],o,i))),Ce(a)||(r.activeComponent?.destroy(),r.activeComponent=a,r.activeComponent&&(s(p),p=this._getHandlesForComponent(r,o)))}}),n=[i.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,o),Z.WIDGET),i.on("key-down",e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key===q.constraint&&!e.repeat&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},Z.WIDGET),i.on("key-up",e=>{if(e.key===q.constraint&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},Z.WIDGET)];let p=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return Ce(r)?r:new r.module.default({enableMoveAllGraphics:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayCursor("grabbing"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayCursor("pointer"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayCursor("move"),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:r,preserveAspectRatio:s}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(Ce(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(q.constraint);return new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightName:r?.name,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!p,layer:this._internalGraphicsLayer,view:o,sketchOptions:this.sketchOptions,callbacks:{onMoveStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMove:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMoveStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScale:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotate:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"})}})}async _getReshape(e,t,o){const{highlightOptions:i,reshapeOptions:a}=t,r="split"===a?.edgeOperation,s="move"===a?.shapeOperation,n=!!a?.enableCreateCurveFromStraightEdge,p=await this._requireModule(import("../../views/draw/support/Reshape.js"));return Ce(p)?p:new p.module.default({enableMidpoints:r,enableMovement:s,enableCurveOnMidpoint:n,graphic:e[0],highlightName:i?.name,highlightsEnabled:!!i?.enabled,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,view:o,callbacks:{onReshapeStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshape:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshapeStop:({mover:e,type:t})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e,type:t},type:"update"}),onMoveStart:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const i=e.map(e=>C(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:i,vertices:o,type:t},type:"update"})},onVertexRemove:({removed:e,type:t,vertices:o})=>{const i=e.map(e=>C(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:i,vertices:o,type:t},type:"update"})}}})}_getHandlesForComponent(e,t){const o=e.activeComponent;if(!o)return[];switch(o.type){case"graphic-mover":return[o.on("graphic-click",({graphic:o,viewEvent:i})=>{i.native?.shiftKey&&t.multipleSelectionEnabled&&(i.stopPropagation(),e.removeFromSelection(o))}),o.on("graphic-move-start",t=>e.addToHistory(Se(t.allGraphics)))];case"box":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Se(t.graphics))),o.on("rotate-start",t=>e.addToHistory(Se(t.graphics))),o.on("scale-start",t=>e.addToHistory(Se(t.graphics)))];case"reshape":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Se([t.mover]))),o.on("reshape-start",t=>e.addToHistory(Se([t.graphic]))),o.on("vertex-add",t=>e.addToHistory(Se([t.oldGraphic]))),o.on("vertex-remove",t=>e.addToHistory(Se([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:i,viewEvent:a}=o;return a.native?.shiftKey&&this.hasGraphic(i)?(a.stopPropagation(),e.removeFromSelection(i)):t.toggleToolOnClick?(a.stopPropagation(),e.toggleTool()):void 0}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view?.map;this._disablePopup(t);const i=()=>{if(e===this._operationHandle){const i=this.updateGraphics.toArray(),a=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),o&&o.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit("update",{graphics:i,state:"complete",aborted:e.cancelled,tool:a,toolEventInfo:null,type:"update"})}};e.on("complete",i)}async _getCommonUpdateOperationClickHandlers(e,t,o){const i=te(t),a=await t.defer(()=>this._getFirstHit(i));if(null==a)return void e.complete();if(t.native.shiftKey&&this._toggleSelection([a.graphic],e,o))return void t.stopPropagation();this.updateGraphics.includes(a.graphic)?t.stopPropagation():e.complete()}_toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;return e.some(e=>null!=e&&(!(!i||!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===q.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===q.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===q.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&q.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=l(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(me)}_displayCursor(e){this.removeHandles(me),this.view?.container&&null!=e&&this.addHandles(this.view.acquireCursor(e,"high"),me)}_logError(e,t,o){p.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)}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,o,i){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;const a=this.view,r=await import("../../views/draw/DrawTool.js");await this.pluginManager.loadPlugins();const s=await this.pluginManager.makeRenderer({customSymbol:o.graphicSymbol,useTextSymbol:"text"===i}),p=new r.DrawTool({view:a,elevationInfo:this._layerAdapter?.elevationInfo??H("3d"===a.type),hasZ:!!o.hasZ,sketchOptions:this.sketchOptions,renderer:s,defaultZ:o.defaultZ??0,directionOptions:o.directionOptions,snappingManager:this.snappingManager});p.addHandles(n(s));const l=new t({...o.graphicProperties,attributes:{...o.graphicProperties?.attributes},symbol:o.graphicSymbol??this._getGraphicSymbolFromTool(i)});return o.graphicSymbol||p.addHandles(g(()=>this._getGraphicSymbolFromTool(i),e=>l.symbol=e)),this._set("createGraphic",l),a.addAndActivateTool(p),p.begin(e),p}get test(){}wait(){return f(()=>!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?(h(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await d(f(()=>e?.ready),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",_e("view"))}_logMissingLayer(){this._logError(fe,_e("layer"))}};e([_()],ve.prototype,"_defaultSnappingManager",void 0),e([_()],ve.prototype,"_layerAdapter",null),e([_()],ve.prototype,"_pluginManager",void 0),e([_()],ve.prototype,"_operationHandle",void 0),e([_({readOnly:!0})],ve.prototype,"_updatingHandles",void 0),e([_({readOnly:!0})],ve.prototype,"activeTool",null),e([_({readOnly:!0})],ve.prototype,"activeCreateToolDrawMode",null),e([_()],ve.prototype,"activeTooltip",null),e([_({types:x})],ve.prototype,"activeFillSymbol",void 0),e([_()],ve.prototype,"activeLineSymbol",void 0),e([_()],ve.prototype,"activeVertexSymbol",void 0),e([_()],ve.prototype,"allowDeleteKey",void 0),e([_({readOnly:!0})],ve.prototype,"createGraphic",null),e([_()],ve.prototype,"defaultCreateOptions",null),e([_()],ve.prototype,"defaultUpdateOptions",null),e([_({type:N,nonNullable:!0})],ve.prototype,"labelOptions",null),e([_()],ve.prototype,"layer",void 0),e([_({types:x})],ve.prototype,"pointSymbol",void 0),e([_({types:x})],ve.prototype,"polygonSymbol",void 0),e([_({types:x})],ve.prototype,"polylineSymbol",void 0),e([_()],ve.prototype,"meshSymbol",void 0),e([_({type:U})],ve.prototype,"textSymbol",null),e([_({type:J,nonNullable:!0})],ve.prototype,"snappingOptions",null),e([_()],ve.prototype,"snappingManager",null),e([_({readOnly:!0})],ve.prototype,"state",null),e([_({type:B,nonNullable:!0})],ve.prototype,"tooltipOptions",null),e([_({readOnly:!0})],ve.prototype,"updateGraphics",void 0),e([_()],ve.prototype,"updateOnGraphicClick",void 0),e([_()],ve.prototype,"updating",null),e([_()],ve.prototype,"creationMode",void 0),e([_({type:$,nonNullable:!0})],ve.prototype,"valueOptions",null),e([_({types:x})],ve.prototype,"vertexSymbol",void 0),e([_({value:null})],ve.prototype,"view",null),e([_({constructOnly:!0,type:z})],ve.prototype,"sketchOptions",void 0),e([_()],ve.prototype,"useLegacyCreateTools",void 0),e([_()],ve.prototype,"isUsingLegacyCreateTools",null),e([_()],ve.prototype,"pluginManager",null),e([_()],ve.prototype,"drawTool",null),e([_()],ve.prototype,"rootPlugins",null),e([_()],ve.prototype,"effectiveAvailablePlugins",null),e([_()],ve.prototype,"firstPluginWithSwappableLeaf",null),e([_()],ve.prototype,"multiplePluginsActive",null),ve=e([b("esri.widgets.Sketch.SketchViewModel")],ve);const fe="sketch:missing-property",_e=e=>`Property '${e}' is missing on SketchViewModel.`;function be(e){return"polygon"===e||"rectangle"===e||"circle"===e}function we(e,t){Te("undo",e.history.undo,e.history.redo,t)}function Ge(e,t){Te("redo",e.history.redo,e.history.undo,t)}function Te(e,t,o,i){const a=t.pop();if(!a)return;const r=a.updates,s=[];i.forEach((t,o)=>{const i=r[o];null!=i&&("geometry"in i&&null!=i.geometry&&(s.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(s.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(s.push(i),i[e](t)))}),o.push({updates:s})}function Oe(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function Se(e){return{updates:e.map(({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e})}}function Ee(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function Ce(e){return"requireError"in e&&"aborted"===e.requireError}export{ve as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import a from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import{drainHandles as s,destroyHandle as n}from"../../core/handleUtils.js";import"../../core/has.js";import p from"../../core/Logger.js";import{destroyMaybe as l,abortMaybe as h}from"../../core/maybe.js";import{createAbortError as c,whenOrAbort as d,ignoreAbortErrors as u}from"../../core/promiseUtils.js";import{watch as g,syncAndInitial as m,on as y,when as v,whenOnce as f}from"../../core/reactiveUtils.js";import{property as _,subclass as b}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as w}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as G}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as T,isLoaded as O,load as S,project as E}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as C}from"../../geometry/support/coordsUtils.js";import{equals as M}from"../../geometry/support/spatialReferenceUtils.js";import A from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as k}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as H}from"../../support/elevationInfoUtils.js";import D from"../../symbols/FillSymbol3DLayer.js";import I from"../../symbols/MeshSymbol3D.js";import P from"../../symbols/SimpleFillSymbol.js";import j from"../../symbols/SimpleLineSymbol.js";import R from"../../symbols/SimpleMarkerSymbol.js";import x from"../../symbols/TextSymbol.js";import{symbolTypes as U}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as L}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as F}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as V}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as K}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as W}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as Z}from"../../views/input/InputManager.js";import{sketchKeys as q}from"../../views/interactive/keybindings.js";import N from"../../views/interactive/sketch/SketchLabelOptions.js";import z from"../../views/interactive/sketch/SketchOptions.js";import B from"../../views/interactive/sketch/SketchTooltipOptions.js";import $ from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as Y}from"../../views/interactive/snapping/SnappingManager.js";import J from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as Q}from"../../views/interactive/snapping/snappingUtils.js";import{defaultHighlightName as X}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as ee}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as te}from"../../views/support/screenUtils.js";import oe from"./adapters/layer/GraphicsLayerAdapter.js";import ie from"./adapters/layer/MapNotesLayerAdapter.js";import{CreateOperationHandle as ae,DrawToolOperationHandle as re,UpdateOperationHandle as se}from"./support/OperationHandle.js";import{PluginManager as ne}from"./support/PluginManager.js";import{getLegacyTool as pe,isCompletelyDegenerate as le,graphicsHaveTooFewVerticesForBox as he,getModeFromCreateOptions as ce,getDrawToolGeometryTypeFromCreateTool as de}from"./support/sketchUtils.js";const ue={defaultZ:0},ge={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:X},tool:"transform"},me=Symbol(),ye=Symbol();let ve=class extends r{constructor(e){super(e),this._defaultSnappingManager=null,this._internalGraphicsLayer=new A({listMode:"hide",internal:!0,title:"SVM Internal"}),this._pluginManager=new ne({sketchViewModel:this}),this._operationHandle=null,this._updatingHandles=new w,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.layer=null,this.pointSymbol=new R({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new P({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 I({symbolLayers:new i([new D])}),this.updateGraphics=new i,this.updateOnGraphicClick=!0,this.creationMode="single",this.vertexSymbol=new R({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new z,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{const{_layerAdapter:e}=this;if(this.removeHandles(ye),!e)return;const t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),g(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},m)].filter(o);this.addHandles(t,ye)},this._originalPopupEnabled=null,this.defaultCreateOptions=ue,this.defaultUpdateOptions=ge,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new J,this.textSymbol=new x({text:"text"})}initialize(){this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([y(()=>this.view?.map?.layers,"change",e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),g(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),m),g(()=>this.view,e=>{this._defaultSnappingManager=l(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new Y({view:e,options:this.snappingOptions})),"2d"===e.type?(import("../../views/2d/interactive/editingTools.js"),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))},m),g(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),Q(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=l(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this._pluginManager?.destroy(),this.emit("destroy")}get _layerAdapter(){const{layer:e}=this;switch(e?.type){case"graphics":return new oe(e);case"map-notes":return new ie(e);default:return null}}get activeTool(){return this._operationHandle?.tool??null}get activeCreateToolDrawMode(){const e=this._operationHandle;if("create"===e?.type&&e.activeComponent&&"mode"in e.activeComponent)return e.activeComponent.mode;if("draw-2.0"===e?.activeComponent?.type){const t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(o).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){const{activeComponent:e,destroyed:t}=this,o=!t&&e&&"tooltip"in e?e.tooltip:null;return o?.visible?o:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return null==this.activeComponent||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):this.activeComponent.graphic}get defaultCreateOptions(){return this._get("defaultCreateOptions")}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...ue,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...ge,...e,reshapeOptions:{...ge.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...ge.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=l(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new Y({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.activeComponent&&"updating"in this.activeComponent&&this.activeComponent.updating||!!(this._updatingHandles.updating||this.snappingManager?.updating||this.drawTool?.updating)}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&this._clearCursor(),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(v(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},m),o),this._set("view",e),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}get pluginManager(){return this._pluginManager}get drawTool(){return"draw-2.0"!==this.activeComponent?.type?null:this.activeComponent}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome("rootPlugins",e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;const e=this.view?.type??"2d",{firstPluginWithSwappableLeaf:t}=this;return t?t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e)):this.rootPlugins?.filter(t=>!t.excludedViews?.includes(e)).filter(o)??[]}get firstPluginWithSwappableLeaf(){const e=this.view?.type??"2d",t=this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>null!=t&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1);return t}get multiplePluginsActive(){return!!this.drawTool&&this.drawTool.pluginStack.length>1}addGraphic(e){this._layerAdapter?.add(e)}addGraphics(e){this._layerAdapter?.addMany(e)}hasGraphic(e){return!!this._layerAdapter?.has(e)}removeGraphic(e){this._layerAdapter?.remove(e)}removeGraphics(e){this._layerAdapter?.removeMany(e)}removeAllGraphics(){this._layerAdapter?.removeAll()}cancel(){this._moduleLoaderAbortController=h(this._moduleLoaderAbortController),this._viewReadyAbortController=h(this._viewReadyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e}=this,o=t.toArray();this.removeGraphics(o),this.cancel(),this._emitDeleteEvent({graphics:o,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map(e=>e.clone()).toArray();return this.addGraphics(e),this.emit("duplicate",{graphics:e,type:"duplicate"}),e}return[]}async create(e,t){this.cancel(),await this._waitViewReady();const{view:o,layer:i}=this;if(!o||"disabled"===this.state)throw i||this._logMissingLayer(),c();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");W(o,this._internalGraphicsLayer);const a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t));if(null==a||this.destroyed)return void o.map?.remove(this._internalGraphicsLayer);const r=pe(e),s=()=>{if(a===this._operationHandle){const o=this.createGraphic,i=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map?.remove(this._internalGraphicsLayer),a.cancelled||null==o||this.addGraphic(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:i?"cancel":"complete",tool:r??"point",toolEventInfo:null,type:"create"}),i||this._sketchContinuationFlag)return;const{creationMode:s}=this;if("continuous"===s){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(u(this.create(e,t)))}else"update"===s&&o&&this._updatingHandles.consumePromise(u(this.update([o])))}};a.on("complete",s),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return await e.load(),this.create("mesh",{mode:"click",hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){this.cancel(),await this._waitViewReady();const{layer:o,view:i,state:a}=this;if(!i||"disabled"===a)throw o||this._logMissingLayer(),c();null!=i.activeTool&&(i.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some(e=>this.hasGraphic(e)?null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0):(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0)))return;const s=await this._updatingHandles.addPromise(this._setupUpdateOperation(r,t));this.destroyed||null==s||Ce(s)||(W(i,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit("update",{graphics:r,state:"start",aborted:!1,tool:s.tool,toolEventInfo:null,type:"update"}))}async _updateSpatialReference(e){const t=this.view;if(t){e=Array.isArray(e)?e:[e];for(const o of e)null==o.geometry||"mesh"===o.geometry.type||M(o.geometry.spatialReference,t.spatialReference)||(T(o.geometry.spatialReference,t.spatialReference)||O()||await S(),o.geometry=E(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 i=await t.hitTest(e,{exclude:o});return ee(i.results)}const o=[t.map.ground];t.map.allLayers.forEach(e=>{k(e)&&o.push(e)});const i=await t.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!i.ground.mapPoint||t.map.ground.opacity<1||i.ground.distance-(e.distance??0)>-Math.min(3*i.ground.distance,"global"===t.viewingMode?G(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY)))return e}return null}_generateViewHandles(e){return[e.on("immediate-click",async e=>{const t="active"===this.state&&"create"===this._operationHandle?.type;"disabled"!==this.state&&!t&&this.updateOnGraphicClick&&await this._updatingHandles.addPromise(this._handleImmediateClick(e))},Z.WIDGET)]}async _handleImmediateClick(e){const t=await e.defer(()=>this._getFirstHit(te(e)));let o=null;if(null!=t){const i=t.graphic;this.updateGraphics.includes(i)||this.hasGraphic(i)?(e.stopPropagation(),o=i):"2d"!==this.view?.type||this._isComponentGraphic(i)||"active"!==this.state||this.cancel()}else"active"===this.state&&this.cancel();null==o||this.updateGraphics.includes(o)||await this.update([o],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){const o=this.view;if(!o)return this._logMissingView(),null;const i={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},a="string"==typeof e?this.pluginManager?.getPluginsEquivalentToCreateTool(e,i.mode):e,r=pe(e);if(a&&!this.isUsingLegacyCreateTools){const e=await this._setupDrawTool(a,i,r??"polyline");if(e)return this._setupDrawToolOperationHandle(e,r??"point")}if(!r)return null;const s=await this._setupDrawGraphicTool(r,o,i);return null==s?null:(o.tools.add(s),o.activeTool=s,this._setupCreateOperationHandle(s,r))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView."),null;if(!t)return this._logMissingView(),null;const{cursor:i,defaultZ:a,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=ce(p,e),c=de(e),d=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=d?.preserveAspectRatio??l??"rectangle"!==e,g={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:i,defaultZ:a,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(g):this._makeDrawGraphicTool3D(g)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return Ce(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:be(e.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));return Ce(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,sketchOptions:this.sketchOptions})}_setupCreateOperationHandle(e,t){const o=this.view;if(!o)return this._logMissingView(),null;let i=null;const a=e.forceUniformSize,r=e.centered,n=[o.on("key-down",t=>{if(t.key===q.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===q.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==q.vertexAdd||t.repeat)t.key===q.undo?(t.stopPropagation(),p.undo()):t.key===q.redo?(t.stopPropagation(),p.redo()):t.key!==q.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===q.center&&(t.repeat||(e.centered=!r,t.stopPropagation())):(e.forceUniformSize=!a,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}},Z.WIDGET),o.on("key-up",t=>{t.key===q.pan?e.enabled=!0:t.key!==q.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===q.center&&(e.centered=r,t.stopPropagation()):(e.forceUniformSize=a,t.stopPropagation())},Z.WIDGET),e.on("vertex-add",t=>{switch(i=null==i?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:i,tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("cursor-update",t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("vertex-remove",t=>{switch(t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("complete",e=>{this._set("createGraphic",e.graphic),i="complete",e.aborted?p&&p.cancel():p&&p.complete()}),g(()=>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}_setupDrawToolOperationHandle(e,t){const i=this.view;if(!i)return this._logMissingView(),null;let a=null;const r=[i.on("key-down",t=>{t.key===q.pan&&(t.stopPropagation(),t.repeat||(e.editable=!1))},Z.WIDGET),i.on("key-up",t=>{t.key===q.pan&&(e.editable=!0)},Z.WIDGET),e.on("before-vertex-add",t=>{const o=e.mostUpstreamPlugin?.configuration;if(o&&"legacyCreateTool"in o&&("point"===o?.legacyCreateTool||"text"===o.legacyCreateTool)){const e=t.detail.originalEvent;return void(e&&"key"in e&&e.key===q.vertexAdd&&t.preventDefault())}}),e.on("before-complete",t=>{const o=e.getGeometryIfCompleted();(!o||le(o))&&t.preventDefault()}),e.on(["vertex-add","vertex-remove"],i=>{switch(this.createGraphic&&(this.createGraphic.geometry=e.getGeometryIfCompleted()),a=null==a&&"vertex-remove"!==i.type?"start":"active",i.operation){case"apply":this.emit("create",{graphic:this.createGraphic,state:a,tool:this.activeTool,toolEventInfo:i,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[this.createGraphic].filter(o),tool:t});break;case"redo":this._emitRedoEvent({graphics:[this.createGraphic].filter(o),tool:t})}}),e.on("cursor-update",t=>{this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),(t.vertices[0]?.vertexIndex>0||t.vertices[0]?.componentIndex>0)&&this.emit("create",{graphic:this.createGraphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("complete",({geometry:e})=>{const t=this.createGraphic;t&&e&&(t.geometry=e),n.complete()})],n=new re({activeComponent:e,type:"create",onEnd:()=>{s(r),i.tools.remove(e)},undo:()=>e.undo(),redo:()=>e.redo(),canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return r.push(e.on("cancel",()=>n.cancel())),n}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":case"freehandPolyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":case"freehandPolygon":return this.polygonSymbol;case"mesh":return this.meshSymbol;case"text":return this.textSymbol}}async _setupUpdateOperation(e,t){const{view:o}=this;if(!o)return this._logMissingView(),null;const i={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};let a=i.tool??ge.tool;if(this.removeGraphics(e),this.addGraphics(e),"3d"===o.type){if(0===e.length)return null;switch(a){case"move":return this._setupMove3DOperation(e,i,o,a);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],i,o);case"transform":return this._setupGraphicTransform3DOperation(e,i,o)}}switch(a){case"move":return this._setupMove2DOperation(e,i,o);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,a,i,o);case"transform":return he(e)&&(a="reshape"),this._setupTransformOrReshape2DOperation(e,a,i,o)}}async _setupMove3DOperation(e,t,o,i,a=!1){const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(r))return r;const{ManipulatedObject3DGraphic:n,MoveTool3D:p}=r.module,l=new Map,h=()=>{l.forEach(e=>e.destroy()),l.clear()};for(const s of e){const e=new n({view:o,graphic:s}),t=F(e);if(0!==t)return h(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${L(t)}).`),null;l.set(s,e)}const c=new p({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(c),c.objects.addMany(Array.from(l.values())),a||this.updateGraphics.addMany(e);const d=[],u=new se({activeComponent:c,tool:i,type:"update",onEnd:()=>{s(d),Ee(o,c),h()},undo:()=>{Oe(this.view,c),we(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ge(u,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:e=>{this.updateGraphics.push(e);const t=new n({view:o,graphic:e});l.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(u.history.undo.forEach(e=>e.updates.splice(t,1)),u.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0===this.updateGraphics.length)return void u.complete();const o=l.get(e);o&&(c.objects.remove(o),o.destroy(),l.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.at(0),a=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));a&&!Ce(a)&&(u.onEnd(),u.destroy(),this._setUpdateOperationHandle(a,t))}});return d.push(...this._getHandlesForComponent(u,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(u,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)},Z.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&0===K(e[0])){const a=e[0],r=a.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=r&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(a,t,o,i)}return this._setupMove3DOperation(e,t,o,"transform",i)}async _setupPointTransform3DOperation(e,t,o){const i="transform",{enableRotation:a,enableScaling:r,enableZ:n}=t,p=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(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:a,enableScaling:r,enableZ:n,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),this.updateGraphics.add(e);const u=[],g=new se({activeComponent:d,tool:i,type:"update",onEnd:()=>{s(u),Ee(o,d),c.destroy()},undo:()=>{Oe(this.view,d),we(g,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ge(g,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),g.onEnd(),g.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ce(i)||this._setUpdateOperationHandle(i,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:()=>{}});return u.push(...this._getHandlesForComponent(g,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(g,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(g,e)},Z.WIDGET)),g}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:r,enableScaling:n,enableZ:p,preserveAspectRatio:l}=t,h=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(h))return h;const{ManipulatedObject3DGraphic:c,ExtentTransformTool:d}=h.module,u=this.view?.inputManager?.isModifierKeyDown(q.constraint),g=new c({view:o,graphic:e}),m=new d({object:g,view:o,enableRotation:r,enableScaling:n,enableZ:p,preserveAspectRatio:!!l!=!!u,sketchOptions:this.sketchOptions});o.tools.add(m),i||this.updateGraphics.add(e);const y=[],v=new se({activeComponent:m,tool:a,type:"update",onEnd:()=>{s(y),Ee(o,m),g.destroy()},canUndo:()=>!m.destroyed&&m.canUndo,undo:()=>{m.destroyed||(m.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!m.destroyed&&m.canRedo,redo:()=>{m.destroyed||(m.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),v.onEnd(),v.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ce(i)||this._setUpdateOperationHandle(i,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"}),v.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));i&&!Ce(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return y.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(v,e,t),Z.WIDGET),o.on("key-down",e=>this._getCommonUpdateOperationKeyDownHandlers(v,e),Z.WIDGET),o.on("key-down",e=>{e.key!==q.constraint||e.repeat||(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())},Z.WIDGET),o.on("key-up",e=>{e.key===q.constraint&&(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())},Z.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,o));if(Ce(a))return a;const r=new se({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._clearCursor(),s(l),s(p),a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();we(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();Ge(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),a.graphics=this.updateGraphics.toArray(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?a.graphics=o:r.complete()}});let n=!1;const p=[o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==q.constraint||e.repeat||(n=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},Z.WIDGET),o.on("key-up",e=>{e.key===q.constraint&&n&&(n=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},Z.WIDGET)],l=this._getHandlesForComponent(r,t);return r}async _setupReshape3DOperation(e,t,o,i=!1){const a="reshape",r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(r))return r;const{ManipulatedObject3DGraphic:n,ReshapeTool3D:p}=r.module,l=new n({view:o,graphic:e}),h=V(l);if(0!==h)return l.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${L(h)}).`),null;const c=t.reshapeOptions,d=new p({view:o,object:l,enableZVertex:t.enableZ&&"move"===c?.vertexOperation,enableZShape:t.enableZ&&"move"===c?.shapeOperation,enableMoveObject:"move"===c?.shapeOperation||"move-xy"===c?.shapeOperation,enableMidpoints:"split"===c?.edgeOperation,enableEdgeOffset:"offset"===c?.edgeOperation,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),i||this.updateGraphics.add(l.graphic);const u=[],g=new se({activeComponent:d,tool:a,type:"update",onEnd:()=>{s(u),Ee(o,d),l.destroy()},canUndo:()=>!d.destroyed&&d.canUndo,undo:()=>{d.destroyed||(d.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!d.destroyed&&d.canRedo,redo:()=>{d.destroyed||(d.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),g.onEnd(),g.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ce(i)||this._setUpdateOperationHandle(i,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));Ce(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(g,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(g,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(g,e)},Z.WIDGET)),g}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise("transform"===t?this._getBox(e,o,i):this._getReshape(e,o,i));if(Ce(a))return a;const r=new se({activeComponent:a,type:"update",onEnd:()=>{s(p),s(n),r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{we(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{Ge(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},addToSelection:async e=>{let t=r.activeComponent;if("reshape"===t?.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll(),r.onEnd(),r.destroy();const a=await this._updatingHandles.addPromise(this._setupTransformOrReshape2DOperation(t,"transform",o,i));if(Ce(a))return;this._setUpdateOperationHandle(a,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),r.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection: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():he(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 a=null;"transform"===r.tool?a=await this._updatingHandles.addPromise(this._getReshape([e],o,i)):"reshape"===r.tool&&(a=await this._updatingHandles.addPromise(this._getBox([e],o,i))),Ce(a)||(r.activeComponent?.destroy(),r.activeComponent=a,r.activeComponent&&(s(p),p=this._getHandlesForComponent(r,o)))}}),n=[i.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,o),Z.WIDGET),i.on("key-down",e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key===q.constraint&&!e.repeat&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},Z.WIDGET),i.on("key-up",e=>{if(e.key===q.constraint&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},Z.WIDGET)];let p=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return Ce(r)?r:new r.module.default({enableMoveAllGraphics:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayCursor("grabbing"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayCursor("pointer"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayCursor("move"),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:r,preserveAspectRatio:s}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(Ce(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(q.constraint);return new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightName:r?.name,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!p,layer:this._internalGraphicsLayer,view:o,sketchOptions:this.sketchOptions,callbacks:{onMoveStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMove:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMoveStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScale:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotate:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"})}})}async _getReshape(e,t,o){const{highlightOptions:i,reshapeOptions:a}=t,r="split"===a?.edgeOperation,s="move"===a?.shapeOperation,n=!!a?.enableCreateCurveFromStraightEdge,p=await this._requireModule(import("../../views/draw/support/Reshape.js"));return Ce(p)?p:new p.module.default({enableMidpoints:r,enableMovement:s,enableCurveOnMidpoint:n,graphic:e[0],highlightName:i?.name,highlightsEnabled:!!i?.enabled,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,view:o,callbacks:{onReshapeStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshape:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshapeStop:({mover:e,type:t})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e,type:t},type:"update"}),onMoveStart:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const i=e.map(e=>C(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:i,vertices:o,type:t},type:"update"})},onVertexRemove:({removed:e,type:t,vertices:o})=>{const i=e.map(e=>C(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:i,vertices:o,type:t},type:"update"})}}})}_getHandlesForComponent(e,t){const o=e.activeComponent;if(!o)return[];switch(o.type){case"graphic-mover":return[o.on("graphic-click",({graphic:o,viewEvent:i})=>{i.native?.shiftKey&&t.multipleSelectionEnabled&&(i.stopPropagation(),e.removeFromSelection(o))}),o.on("graphic-move-start",t=>e.addToHistory(Se(t.allGraphics)))];case"box":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Se(t.graphics))),o.on("rotate-start",t=>e.addToHistory(Se(t.graphics))),o.on("scale-start",t=>e.addToHistory(Se(t.graphics)))];case"reshape":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Se([t.mover]))),o.on("reshape-start",t=>e.addToHistory(Se([t.graphic]))),o.on("vertex-add",t=>e.addToHistory(Se([t.oldGraphic]))),o.on("vertex-remove",t=>e.addToHistory(Se([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:i,viewEvent:a}=o;return a.native?.shiftKey&&this.hasGraphic(i)?(a.stopPropagation(),e.removeFromSelection(i)):t.toggleToolOnClick?(a.stopPropagation(),e.toggleTool()):void 0}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view?.map;this._disablePopup(t);const i=()=>{if(e===this._operationHandle){const i=this.updateGraphics.toArray(),a=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),o&&o.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit("update",{graphics:i,state:"complete",aborted:e.cancelled,tool:a,toolEventInfo:null,type:"update"})}};e.on("complete",i)}async _getCommonUpdateOperationClickHandlers(e,t,o){const i=te(t),a=await t.defer(()=>this._getFirstHit(i));if(null==a)return void e.complete();if(t.native.shiftKey&&this._toggleSelection([a.graphic],e,o))return void t.stopPropagation();this.updateGraphics.includes(a.graphic)?t.stopPropagation():e.complete()}_toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;return e.some(e=>null!=e&&(!(!i||!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===q.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===q.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===q.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&q.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=l(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(me)}_displayCursor(e){this.removeHandles(me),this.view?.container&&null!=e&&this.addHandles(this.view.acquireCursor(e,"high"),me)}_logError(e,t,o){p.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)}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,o,i){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;const a=this.view,r=await import("../../views/draw/DrawTool.js");await this.pluginManager.loadPlugins();const s=await this.pluginManager.makeRenderer({customSymbol:o.graphicSymbol,useTextSymbol:"text"===i}),p=new r.DrawTool({view:a,elevationInfo:this._layerAdapter?.elevationInfo??H("3d"===a.type),hasZ:!!o.hasZ,sketchOptions:this.sketchOptions,renderer:s,defaultZ:o.defaultZ??0,directionOptions:o.directionOptions,snappingManager:this.snappingManager,enableVertexVisuals:"rectangle"!==i&&"circle"!==i});p.addHandles(n(s));const l=new t({...o.graphicProperties,attributes:{...o.graphicProperties?.attributes},symbol:o.graphicSymbol??this._getGraphicSymbolFromTool(i)});return o.graphicSymbol||p.addHandles(g(()=>this._getGraphicSymbolFromTool(i),e=>l.symbol=e)),this._set("createGraphic",l),a.addAndActivateTool(p),p.begin(e),p}get test(){}wait(){return f(()=>!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?(h(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await d(f(()=>e?.ready),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",_e("view"))}_logMissingLayer(){this._logError(fe,_e("layer"))}};e([_()],ve.prototype,"_defaultSnappingManager",void 0),e([_()],ve.prototype,"_layerAdapter",null),e([_()],ve.prototype,"_pluginManager",void 0),e([_()],ve.prototype,"_operationHandle",void 0),e([_({readOnly:!0})],ve.prototype,"_updatingHandles",void 0),e([_({readOnly:!0})],ve.prototype,"activeTool",null),e([_({readOnly:!0})],ve.prototype,"activeCreateToolDrawMode",null),e([_()],ve.prototype,"activeTooltip",null),e([_({types:U})],ve.prototype,"activeFillSymbol",void 0),e([_()],ve.prototype,"activeLineSymbol",void 0),e([_()],ve.prototype,"activeVertexSymbol",void 0),e([_()],ve.prototype,"allowDeleteKey",void 0),e([_({readOnly:!0})],ve.prototype,"createGraphic",null),e([_()],ve.prototype,"defaultCreateOptions",null),e([_()],ve.prototype,"defaultUpdateOptions",null),e([_({type:N,nonNullable:!0})],ve.prototype,"labelOptions",null),e([_()],ve.prototype,"layer",void 0),e([_({types:U})],ve.prototype,"pointSymbol",void 0),e([_({types:U})],ve.prototype,"polygonSymbol",void 0),e([_({types:U})],ve.prototype,"polylineSymbol",void 0),e([_()],ve.prototype,"meshSymbol",void 0),e([_({type:x})],ve.prototype,"textSymbol",null),e([_({type:J,nonNullable:!0})],ve.prototype,"snappingOptions",null),e([_()],ve.prototype,"snappingManager",null),e([_({readOnly:!0})],ve.prototype,"state",null),e([_({type:B,nonNullable:!0})],ve.prototype,"tooltipOptions",null),e([_({readOnly:!0})],ve.prototype,"updateGraphics",void 0),e([_()],ve.prototype,"updateOnGraphicClick",void 0),e([_()],ve.prototype,"updating",null),e([_()],ve.prototype,"creationMode",void 0),e([_({type:$,nonNullable:!0})],ve.prototype,"valueOptions",null),e([_({types:U})],ve.prototype,"vertexSymbol",void 0),e([_({value:null})],ve.prototype,"view",null),e([_({constructOnly:!0,type:z})],ve.prototype,"sketchOptions",void 0),e([_()],ve.prototype,"useLegacyCreateTools",void 0),e([_()],ve.prototype,"isUsingLegacyCreateTools",null),e([_()],ve.prototype,"pluginManager",null),e([_()],ve.prototype,"drawTool",null),e([_()],ve.prototype,"rootPlugins",null),e([_()],ve.prototype,"effectiveAvailablePlugins",null),e([_()],ve.prototype,"firstPluginWithSwappableLeaf",null),e([_()],ve.prototype,"multiplePluginsActive",null),ve=e([b("esri.widgets.Sketch.SketchViewModel")],ve);const fe="sketch:missing-property",_e=e=>`Property '${e}' is missing on SketchViewModel.`;function be(e){return"polygon"===e||"rectangle"===e||"circle"===e}function we(e,t){Te("undo",e.history.undo,e.history.redo,t)}function Ge(e,t){Te("redo",e.history.redo,e.history.undo,t)}function Te(e,t,o,i){const a=t.pop();if(!a)return;const r=a.updates,s=[];i.forEach((t,o)=>{const i=r[o];null!=i&&("geometry"in i&&null!=i.geometry&&(s.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(s.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(s.push(i),i[e](t)))}),o.push({updates:s})}function Oe(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function Se(e){return{updates:e.map(({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e})}}function Ee(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function Ce(e){return"requireError"in e&&"aborted"===e.requireError}export{ve as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../core/Collection.js";import{EventedAccessor as i}from"../../core/Evented.js";import n from"../../core/Logger.js";import{after as s,isAbortError as r}from"../../core/promiseUtils.js";import{watch as o,initial as l,syncAndInitial as a,whenOnce as m}from"../../core/reactiveUtils.js";import{offsetDate as u}from"../../core/timeUtils.js";import{property as p,subclass as h}from"../../core/accessorSupport/decorators.js";import{ensureType as d}from"../../core/accessorSupport/ensureType.js";import c from"../../time/TimeExtent.js";import f from"../../time/TimeInterval.js";import w from"../../webdoc/Widgets.js";import g from"../../webdoc/widgets/TimeSlider.js";const v=1e4;function T(t){return null!=t&&void 0!==t.count}function x(t){return null!=t&&void 0!==t.interval}function E(t){return null!=t&&void 0!==t.dates}let _=class extends i{constructor(t){super(t),this._animationController=null,this._isViewTimeExtentInitialized=!1,this._timerId=null,this.actions=new e,this.fullTimeExtent=null,this.loop=!1,this.mode="time-window",this.stops={count:10},this.timeExtent=null,this.view=null}initialize(){this.addHandles([o(()=>this.effectiveStops,()=>{this.timeExtent??=this._getDefaultTimeExtent()},l),o(()=>this.view,(t,e)=>{this._unregisterWidget(e),this._registerWidget(t)},a),o(()=>this.timeExtent,t=>{if(!this.view)return;const e=this.view.timeExtent;(t&&!t.isAllTime||e&&!e.isAllTime)&&(t&&e&&t.equals(e)||(this.view.timeExtent=t))},l),o(()=>this.view?.timeExtent,t=>{this._isViewTimeExtentInitialized?(t&&!t.isAllTime||this.timeExtent&&!this.timeExtent.isAllTime)&&(t&&this.timeExtent&&t.equals(this.timeExtent)||(this.timeExtent=t)):this._isViewTimeExtentInitialized=!0})])}destroy(){null!=this._timerId&&(clearInterval(this._timerId),this._timerId=null),this._unregisterWidget(this.view),this.view=null,this._animationController&&(this._animationController.abort(),this._animationController=null)}get effectiveStops(){const{fullTimeExtent:t,stops:e}=this;if(E(e)){const{dates:i}=e;if(!i?.length)return null;const n=i.sort((t,e)=>t.getTime()-e.getTime());if(!t)return n;const{start:s,end:r}=t;if(!s||!r)return n;return n.filter(t=>!(t.getTime()<s.getTime()||t.getTime()>r.getTime()))}if(T(e)){const i=e.timeExtent??t;return this._divideTimeExtentByCount(i,e.count)}if(x(e)){const i=e.timeExtent??t;return this._divideTimeExtentByInterval(i,e.interval)}return[]}set playRate(t){t<=0||t>36e5||("playing"===this.state&&this._startAnimation(),this._set("playRate",t))}get state(){return this.fullTimeExtent?this._animationController?"playing":"ready":"disabled"}get timeExtentValues(){const{mode:t,timeExtent:e}=this;if(!e||e.isAllTime||e.isEmpty)return null;const{start:i,end:n}=e;switch(t){case"cumulative-from-end":case"instant":return i?[i.getTime()]:null;case"cumulative-from-start":return n?[n.getTime()]:null;case"time-window":return i&&n?[i.getTime(),n.getTime()]:null}}next(){this._step({forward:!0,allowRestart:!1})}play(){this._startAnimation()}previous(){this._step({forward:!1,allowRestart:!1})}stop(){this._stopAnimation()}triggerAction(t){this.emit("trigger-action",{action:t})}updateWebDocument(t){const e=new g({currentTimeExtent:this.timeExtent,fullTimeExtent:this.fullTimeExtent,loop:this.loop,numStops:T(this.stops)?this.stops.count:null,numThumbs:"time-window"===this.mode?2:1,stopDelay:this.playRate,stopInterval:x(this.stops)?this.stops.interval:null,stops:E(this.stops)?this.stops.dates:null});t.widgets?t.widgets.timeSlider=e:t.widgets=new w({timeSlider:e})}valuesToTimeExtent(t){if(!t)return null;const e=t.sort((t,e)=>t-e).map(t=>new Date(t)),i=e.length>0?e[0]:null,n=e.length>1?e[1]:null;switch(this.mode){case"time-window":return new c({start:i,end:n});case"instant":return new c({start:i,end:i});case"cumulative-from-start":return new c({start:null,end:i});case"cumulative-from-end":return new c({start:i,end:null});default:return c.allTime}}async _animate(){try{const t=this.view,e=this._animationController?.signal;await Promise.all([s(this.playRate,null,e),t&&m(()=>!t.updating,e)])}catch(t){return r(t)||n.getLogger(this).error(t),void(this._animationController=null)}this._step({forward:!0,allowRestart:!1}),this._animationController&&this._animate()}_divideTimeExtentByCount(t,e=10){if(!t||!e)return[];const{start:i,end:n}=t;if(!i||!n)return[];if(e>v)return this._divideTimeExtentByCount(t);const s=[],r=i.getTime(),o=n.getTime()-r;for(let l=0;l<=e;l++)s.push(new Date(r+l/e*o));return s}_divideTimeExtentByInterval(t,e,i=v){if(!t||!e)return[];const{start:n,end:s}=t;if(!n||!s)return[];const r=s.getTime()-n.getTime(),o=e.toMilliseconds();if(o<=0||r/o>i)return this._divideTimeExtentByCount(t);const l=[],{value:a,unit:m}=e;let p=n;for(;p.getTime()<=s.getTime();)l.push(new Date(p)),p=u(p,a,m);return l}_getDefaultTimeExtent(){const{effectiveStops:t,mode:e}=this;if(!t||!e)return null;switch(e){case"time-window":return t.length>1?new c({start:t[0],end:t[1]}):null;case"cumulative-from-start":return t.length>0?new c({start:null,end:t[0]}):null;case"cumulative-from-end":return t.length>0?new c({start:t[0],end:null}):null;case"instant":return t.length>0?new c({start:t[0],end:t[0]}):null;default:return null}}_registerWidget(t){if(t){t.persistableViewModels.includes(this)||t.persistableViewModels.add(this)}}_startAnimation(){this._stopAnimation(),this._animationController=new AbortController,this._step({forward:!0,allowRestart:!0}),this._animate()}_step(t){const{forward:e,allowRestart:i}=t,{effectiveStops:n}=this;if(!this.timeExtentValues||!n)return;const s=n.map(t=>t.getTime()),r=this.timeExtentValues.map(t=>{const e=s.indexOf(t);if(-1!==e)return e;const i=s.reduce((e,i)=>Math.abs(i-t)<Math.abs(e-t)?i:e);return s.indexOf(i)}),o=r.map(t=>t+(e?1:-1)),l=o.some(t=>t<0||t>s.length-1),{loop:a,state:m}=this;if(l)if(a||i){const t=Math.min(...r),i=Math.max(...r),n=(e?r.map(e=>e-t):r.map(t=>t+(s.length-1-i))).map(t=>s[t]);this.timeExtent=this.valuesToTimeExtent(n)}else"playing"===m&&this.stop();else{const t=o.map(t=>s[t]);this.timeExtent=this.valuesToTimeExtent(t)}}_stopAnimation(){null!=this._animationController&&(this._animationController.abort(),this._animationController=null)}_unregisterWidget(t){null!=t&&t.persistableViewModels.remove(this)}};t([p()],_.prototype,"_animationController",void 0),t([p({type:e})],_.prototype,"actions",void 0),t([p({readOnly:!0})],_.prototype,"effectiveStops",null),t([p({type:c})],_.prototype,"fullTimeExtent",void 0),t([p({nonNullable:!0})],_.prototype,"loop",void 0),t([p({nonNullable:!0})],_.prototype,"mode",void 0),t([p({nonNullable:!0,value:1e3})],_.prototype,"playRate",null),t([p({readOnly:!0})],_.prototype,"state",null),t([p({cast:t=>t?(x(t)&&(t.interval=d(f,t.interval)),(x(t)||T(t))&&(t.timeExtent=d(c,t.timeExtent)),t):null})],_.prototype,"stops",void 0),t([p({type:c})],_.prototype,"timeExtent",void 0),t([p({readOnly:!0})],_.prototype,"timeExtentValues",null),t([p()],_.prototype,"view",void 0),t([p()],_.prototype,"next",null),t([p()],_.prototype,"play",null),t([p()],_.prototype,"previous",null),t([p()],_.prototype,"stop",null),t([p()],_.prototype,"updateWebDocument",null),_=t([h("esri.widgets.TimeSlider.TimeSliderViewModel")],_);const y=_;export{y as default};
2
+ import{__decorate as t}from"tslib";import e from"../../core/Collection.js";import{EventedAccessor as i}from"../../core/Evented.js";import n from"../../core/Logger.js";import{after as s,isAbortError as r}from"../../core/promiseUtils.js";import{watch as o,initial as l,syncAndInitial as a,whenOnce as m}from"../../core/reactiveUtils.js";import{offsetDate as u}from"../../core/timeUtils.js";import{property as p,cast as h,subclass as d}from"../../core/accessorSupport/decorators.js";import{ensureType as c}from"../../core/accessorSupport/ensureType.js";import f from"../../time/TimeExtent.js";import w from"../../time/TimeInterval.js";import g from"../../webdoc/Widgets.js";import v from"../../webdoc/widgets/TimeSlider.js";const T=1e4;function x(t){return!!t&&"count"in t}function E(t){return!!t&&"interval"in t}function y(t){return!!t&&"dates"in t}let _=class extends i{constructor(t){super(t),this._animationController=null,this._isViewTimeExtentInitialized=!1,this._timerId=null,this.actions=new e,this.fullTimeExtent=null,this.loop=!1,this.mode="time-window",this.stops={count:10},this.timeExtent=null,this.view=null}initialize(){this.addHandles([o(()=>this.effectiveStops,()=>{this.timeExtent??=this._getDefaultTimeExtent()},l),o(()=>this.view,(t,e)=>{this._unregisterWidget(e),this._registerWidget(t)},a),o(()=>this.timeExtent,t=>{if(!this.view)return;const e=this.view.timeExtent;(t&&!t.isAllTime||e&&!e.isAllTime)&&(t&&e&&t.equals(e)||(this.view.timeExtent=t))},l),o(()=>this.view?.timeExtent,t=>{this._isViewTimeExtentInitialized?(t&&!t.isAllTime||this.timeExtent&&!this.timeExtent.isAllTime)&&(t&&this.timeExtent&&t.equals(this.timeExtent)||(this.timeExtent=t)):this._isViewTimeExtentInitialized=!0})])}destroy(){null!=this._timerId&&(clearInterval(this._timerId),this._timerId=null),this._unregisterWidget(this.view),this.view=null,this._animationController?.abort(),this._animationController=null}get effectiveStops(){const{fullTimeExtent:t,stops:e}=this;if(y(e)){const{dates:i}=e;if(!i?.length)return null;const n=i.sort((t,e)=>t.getTime()-e.getTime());if(!t)return n;const{start:s,end:r}=t;if(!s||!r)return n;return n.filter(t=>!(t.getTime()<s.getTime()||t.getTime()>r.getTime()))}if(x(e)){const i=e.timeExtent??t;return this._divideTimeExtentByCount(i,e.count)}if(E(e)){const i=e.timeExtent??t;return this._divideTimeExtentByInterval(i,e.interval)}return[]}get isPreCommonEra(){return(this.fullTimeExtent?.start?.getFullYear()??0)<0}set playRate(t){t<=0||t>36e5||("playing"===this.state&&this._startAnimation(),this._set("playRate",t))}get state(){return this.fullTimeExtent?this._animationController?"playing":"ready":"disabled"}castStops(t){if(!t)return null;if(E(t)){if("unknown"===t.interval.unit)return n.getLogger(this).warn('A stop interval with an "unknown" time units is not supported. The default stop definition will be used.'),{count:10};t.interval=c(w,t.interval)}return(E(t)||x(t))&&(t.timeExtent=c(f,t.timeExtent)),t}get timeExtentValues(){const{mode:t,timeExtent:e}=this;if(!e||e.isAllTime||e.isEmpty)return null;const{start:i,end:n}=e;switch(t){case"cumulative-from-end":case"instant":return i?[i.getTime()]:null;case"cumulative-from-start":return n?[n.getTime()]:null;case"time-window":return i&&n?[i.getTime(),n.getTime()]:null}}next(){this._step({forward:!0,allowRestart:!1})}play(){this._startAnimation()}previous(){this._step({forward:!1,allowRestart:!1})}stop(){this._stopAnimation()}triggerAction(t){this.emit("trigger-action",{action:t})}updateWebDocument(t){const e=new v({currentTimeExtent:this.timeExtent,fullTimeExtent:this.fullTimeExtent,loop:this.loop,numStops:x(this.stops)?this.stops.count:null,numThumbs:"time-window"===this.mode?2:1,stopDelay:this.playRate,stopInterval:E(this.stops)?this.stops.interval:null,stops:y(this.stops)?this.stops.dates:null});t.widgets?t.widgets.timeSlider=e:t.widgets=new g({timeSlider:e})}valuesToTimeExtent(t){if(!t)return null;const e=t.sort((t,e)=>t-e).map(t=>new Date(t)),i=e.length>0?e[0]:null,n=e.length>1?e[1]:null;switch(this.mode){case"time-window":return new f({start:i,end:n});case"instant":return new f({start:i,end:i});case"cumulative-from-start":return new f({start:null,end:i});case"cumulative-from-end":return new f({start:i,end:null});default:return f.allTime}}async _animate(){try{const t=this.view,e=this._animationController?.signal;await Promise.all([s(this.playRate,null,e),t&&m(()=>!t.updating,e)])}catch(t){return r(t)||n.getLogger(this).error(t),void(this._animationController=null)}this._step({forward:!0,allowRestart:!1}),this._animationController&&this._animate()}_divideTimeExtentByCount(t,e=10){if(!t||!e)return[];const{start:i,end:n}=t;if(!i||!n)return[];if(e>T)return this._divideTimeExtentByCount(t);const s=[],r=i.getTime(),o=n.getTime()-r;for(let l=0;l<=e;l++)s.push(new Date(r+l/e*o));return s}_divideTimeExtentByInterval(t,e,i=T){if(!t||!e)return[];const{start:n,end:s}=t;if(!n||!s)return[];const r=s.getTime()-n.getTime(),o=e.toMilliseconds();if(o<=0||r/o>i)return this._divideTimeExtentByCount(t);const l=[],{value:a,unit:m}=e;let p=n;for(;p.getTime()<=s.getTime();)l.push(new Date(p)),p=u(p,a,m);return l}_getDefaultTimeExtent(){const{effectiveStops:t,mode:e}=this;if(!t||!e)return null;switch(e){case"time-window":return t.length>1?new f({start:t[0],end:t[1]}):null;case"cumulative-from-start":return t.length>0?new f({start:null,end:t[0]}):null;case"cumulative-from-end":return t.length>0?new f({start:t[0],end:null}):null;case"instant":return t.length>0?new f({start:t[0],end:t[0]}):null;default:return null}}_registerWidget(t){if(t){t.persistableViewModels.includes(this)||t.persistableViewModels.add(this)}}_startAnimation(){this._stopAnimation(),this._animationController=new AbortController,this._step({forward:!0,allowRestart:!0}),this._animate()}_step(t){const{forward:e,allowRestart:i}=t,{effectiveStops:n}=this;if(!this.timeExtentValues||!n)return;const s=n.map(t=>t.getTime()),r=this.timeExtentValues.map(t=>{const e=s.indexOf(t);if(-1!==e)return e;const i=s.reduce((e,i)=>Math.abs(i-t)<Math.abs(e-t)?i:e);return s.indexOf(i)}),o=r.map(t=>t+(e?1:-1)),l=o.some(t=>t<0||t>s.length-1),{loop:a,state:m}=this;if(l)if(a||i){const t=Math.min(...r),i=Math.max(...r),n=(e?r.map(e=>e-t):r.map(t=>t+(s.length-1-i))).map(t=>s[t]);this.timeExtent=this.valuesToTimeExtent(n)}else"playing"===m&&this.stop();else{const t=o.map(t=>s[t]);this.timeExtent=this.valuesToTimeExtent(t)}}_stopAnimation(){null!=this._animationController&&(this._animationController.abort(),this._animationController=null)}_unregisterWidget(t){null!=t&&t.persistableViewModels.remove(this)}};t([p()],_.prototype,"_animationController",void 0),t([p({type:e})],_.prototype,"actions",void 0),t([p({readOnly:!0})],_.prototype,"effectiveStops",null),t([p({type:f})],_.prototype,"fullTimeExtent",void 0),t([p()],_.prototype,"isPreCommonEra",null),t([p({nonNullable:!0})],_.prototype,"loop",void 0),t([p({nonNullable:!0})],_.prototype,"mode",void 0),t([p({nonNullable:!0,value:1e3})],_.prototype,"playRate",null),t([p({readOnly:!0})],_.prototype,"state",null),t([p()],_.prototype,"stops",void 0),t([h("stops")],_.prototype,"castStops",null),t([p({type:f})],_.prototype,"timeExtent",void 0),t([p({readOnly:!0})],_.prototype,"timeExtentValues",null),t([p()],_.prototype,"view",void 0),t([p()],_.prototype,"next",null),t([p()],_.prototype,"play",null),t([p()],_.prototype,"previous",null),t([p()],_.prototype,"stop",null),t([p()],_.prototype,"updateWebDocument",null),_=t([d("esri.widgets.TimeSlider.TimeSliderViewModel")],_);const C=_;export{C as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{equals as e}from"../core/arrayUtils.js";import i from"../core/Collection.js";import{deprecateWidget as a}from"../core/deprecate.js";import r from"../core/Logger.js";import{watch as n,initial as s}from"../core/reactiveUtils.js";import{truncateDate as o,offsetDate as l}from"../core/timeUtils.js";import{property as m,subclass as u}from"../core/accessorSupport/decorators.js";import{formatDate as c,convertDateFormatToIntlOptions as d}from"../intl/date.js";import{getCalciteModeClass as p}from"../support/modeUtils.js";import{unknown as h,system as v}from"../time/constants.js";import f from"../time/TimeExtent.js";import y from"../time/TimeInterval.js";import g from"./Slider.js";import b from"./Widget.js";import{loadCalciteComponents as x}from"./support/componentsUtils.js";import{globalCss as w}from"./support/globalCss.js";import{messageBundle as E,vmEvent as k,tsx as j}from"./support/widget.js";import{onResize as T}from"./support/widgetUtils.js";import{css as _}from"./TimeSlider/css.js";import S from"./TimeSlider/TimeSliderViewModel.js";const M=3,F=858,D=[{minor:{value:100,unit:"milliseconds"},major:{value:1,unit:"seconds"},format:{second:"numeric"}},{minor:{value:500,unit:"milliseconds"},major:{value:5,unit:"seconds"},format:{second:"numeric"}},{minor:{value:1,unit:"seconds"},major:{value:20,unit:"seconds"},format:{minute:"numeric",second:"numeric"}},{minor:{value:2,unit:"seconds"},major:{value:30,unit:"seconds"},format:{minute:"numeric",second:"numeric"}},{minor:{value:10,unit:"seconds"},major:{value:1,unit:"minutes"},format:{minute:"numeric"}},{minor:{value:15,unit:"seconds"},major:{value:5,unit:"minutes"},format:{hour:"numeric",minute:"numeric"}},{minor:{value:1,unit:"minutes"},major:{value:20,unit:"minutes"},format:{hour:"numeric",minute:"numeric"}},{minor:{value:5,unit:"minutes"},major:{value:2,unit:"hours"},format:{hour:"numeric",minute:"numeric"}},{minor:{value:15,unit:"minutes"},major:{value:6,unit:"hours"},format:{hour:"numeric",minute:"numeric"}},{minor:{value:1,unit:"hours"},major:{value:1,unit:"days"},format:{day:"numeric",month:"short"}},{minor:{value:6,unit:"hours"},major:{value:1,unit:"weeks"},format:{day:"numeric",month:"short"}},{minor:{value:1,unit:"days"},major:{value:1,unit:"months"},format:{month:"long"}},{minor:{value:2,unit:"days"},major:{value:1,unit:"months"},format:{month:"short"}},{minor:{value:3,unit:"days"},major:{value:1,unit:"months"},format:{month:"short"}},{minor:{value:4,unit:"days"},major:{value:3,unit:"months"},format:{month:"short",year:"numeric"}},{minor:{value:1,unit:"weeks"},major:{value:1,unit:"years"},format:{year:"numeric"}},{minor:{value:1,unit:"months"},major:{value:1,unit:"years"},format:{year:"numeric"}},{minor:{value:2,unit:"months"},major:{value:2,unit:"years"},format:{year:"numeric"}},{minor:{value:5,unit:"months"},major:{value:5,unit:"years"},format:{year:"numeric"}},{minor:{value:1,unit:"years"},major:{value:20,unit:"years"},format:{year:"numeric"}},{minor:{value:2,unit:"years"},major:{value:50,unit:"years"},format:{year:"numeric"}},{minor:{value:5,unit:"years"},major:{value:100,unit:"years"},format:{year:"numeric"}},{minor:{value:10,unit:"years"},major:{value:200,unit:"years"},format:{era:"short",year:"numeric"}},{minor:{value:20,unit:"years"},major:{value:500,unit:"years"},format:{era:"short",year:"numeric"}},{minor:{value:50,unit:"years"},major:{value:1e3,unit:"years"},format:{era:"short",year:"numeric"}},{minor:{value:1,unit:"centuries"},major:{value:20,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:2,unit:"centuries"},major:{value:50,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:5,unit:"centuries"},major:{value:100,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:10,unit:"centuries"},major:{value:200,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:20,unit:"centuries"},major:{value:500,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:50,unit:"centuries"},major:{value:1e3,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:100,unit:"centuries"},major:{value:2e3,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:200,unit:"centuries"},major:{value:5e3,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:500,unit:"centuries"},major:{value:1e4,unit:"centuries"},format:{era:"short",year:"numeric"}},{minor:{value:1e3,unit:"centuries"},major:{value:2e4,unit:"centuries"},format:{era:"short",year:"numeric"}}];function C(t){return j("div",{class:_.warning},j("calcite-icon",{class:_.warningIcon,icon:"exclamation-mark-triangle"}),j("calcite-label",{alignment:"center",class:_.warningLabel,scale:"s"},t))}let L=class extends b{constructor(t,e){super(t,e),this._allLayouts=["auto","compact","wide"],this._ignoreNextSliderUpdate=!1,this._slider=new g({suppressDeprecationWarning:!0,precision:0,visibleElements:{rangeLabels:!1},rangeLabelInputsEnabled:!1,thumbsConstrained:!1}),this._tickFormat=null,this.disabled=!1,this.labelFormatFunction=null,this.messages=null,this.tickConfigs=null,this.timeVisible=!1,this.viewModel=new S,this.announceDeprecation=()=>{a(r.getLogger(this),"Time Slider","arcgis-time-slider",{version:"5.0"})}}initialize(){this.addHandles([n(()=>this._slider.values,t=>{if(this._ignoreNextSliderUpdate)return void(this._ignoreNextSliderUpdate=!1);const e=this.viewModel.valuesToTimeExtent(t);this.timeExtent?e?this.timeExtent.equals(e)||(this.timeExtent=e):this.timeExtent=null:e&&(this.timeExtent=e)}),n(()=>this.effectiveStops,()=>this._updateSliderSteps(),s)])}loadDependencies(){return x({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),label:()=>import("@esri/calcite-components/dist/components/calcite-label")})}destroy(){this._slider.destroy(),this._tickFormat=null}get _dateFormat(){return this._getIntlOptions("short-date")}get _timeFormat(){return this._getIntlOptions("long-time")}get actions(){return this.viewModel.actions}set actions(t){this.viewModel.actions=t}get effectiveStops(){return this.viewModel.effectiveStops}get fullTimeExtent(){return this.viewModel.fullTimeExtent}set fullTimeExtent(t){this.viewModel.fullTimeExtent=t}get icon(){return"clock"}set icon(t){this._overrideIfSome("icon",t)}get interactive(){return!(this.disabled||"disabled"===this.viewModel.state||this.timeZone===h)}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}set layout(t){this._set("layout",this._allLayouts.includes(t)?t:"auto")}get loop(){return this.viewModel.loop}set loop(t){this.viewModel.loop=t}get mode(){return this.viewModel.mode}set mode(t){this.viewModel.mode=t}get playRate(){return this.viewModel.playRate}set playRate(t){this.viewModel.playRate=t}get stops(){return this.viewModel.stops}set stops(t){this.viewModel.stops=t}get tickFormats(){const{timeZone:t}=this;return D.map(({minor:e,major:i,format:a})=>({minor:new y(e),major:new y(i),format:{...a,timeZone:t}}))}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(t){this.viewModel.timeExtent=t}get timeZone(){return this.viewModel.view?.timeZone??v}set timeZone(t){this._overrideIfSome("timeZone",t)}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}next(){return this.viewModel.next()}play(){return this.viewModel.play()}previous(){return this.viewModel.previous()}stop(){return this.viewModel.stop()}render(){const{_slider:t,actions:i,domNode:a,effectiveStops:r,fullTimeExtent:n,interactive:s,messages:o,mode:l,tickConfigs:m,timeExtent:u,timeVisible:d,viewModel:{state:h,timeExtentValues:v}}=this;if(n){const{start:e,end:i}=n;if(e&&i){const a=e.getTime(),r=i.getTime(),n=t.min!==a||t.max!==r;if(n&&(t.min=a,t.max=r),m)t.tickConfigs!==m&&(t.tickConfigs=m);else{const e=(r-a)/(t.trackElement?.offsetWidth||400),i=this.tickFormats.find(({minor:t})=>t.toMilliseconds()>M*e)??this.tickFormats.at(-1),s=i&&this._tickFormat!==i;if(s&&(this._tickFormat=i),n||s){const e={mode:"position",values:this._getTickPositions(i.minor),labelsVisible:!1,tickCreatedFunction:(t,e)=>{e?.classList.add(_.sliderMinorTick)}},a={mode:"position",values:this._getTickPositions(i.major),labelsVisible:!0,tickCreatedFunction:(t,e)=>{e?.classList.add(_.sliderMajorTick)},labelFormatFunction:t=>c(t,i.format)};t.tickConfigs=[e,a]}}}}const f=!this.fullTimeExtent?.start||!this.fullTimeExtent.end||!this.timeExtent||this.timeExtent.isAllTime||this.timeExtent.isEmpty||this.timeExtent.start&&(this.timeExtent.start<this.fullTimeExtent.start||this.timeExtent.start>this.fullTimeExtent.end)||this.timeExtent.end&&(this.timeExtent.end>this.fullTimeExtent.end||this.timeExtent.end<this.fullTimeExtent.start);if(f)switch(this._ignoreNextSliderUpdate=!0,l){case"time-window":t.values=[t.min,t.max];break;case"instant":case"cumulative-from-end":t.values=[t.min];break;case"cumulative-from-start":t.values=[t.max]}else v?e(t.values,v)||(t.values=v):t.values=null;t.disabled=!s;const y=f||!s||!r?.length,g="auto"===this.layout?a.clientWidth<F?"compact":"wide":this.layout,b=j("calcite-button",{appearance:"transparent",bind:this,class:_.play,disabled:y,iconStart:"playing"===h?"pause":"play",kind:"neutral",label:"playing"===h?o.control.stop:o.control.play,onclick:this._playOrStopClick,scale:"wide"===g?"l":"m",width:"full"}),x=this.labelFormatFunction?j("div",{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:_.timeExtentStartDate,"data-date":u?[u.start,u.end]:null,"data-layout":g,"data-type":"extent",key:_.timeExtentStartDate}):!u||u.isAllTime?C(o.noTimeExtent):u.isEmpty?C(o.emptyTimeExtent):[u?.start&&j("div",{class:_.timeExtentStartGroup,key:_.timeExtentStartGroup},j("calcite-label",{alignment:"center",class:_.timeExtentStartDate,key:_.timeExtentStartDate,scale:"s"},this._formatDate(u.start)),d?j("calcite-label",{alignment:"center",class:_.timeExtentStartTime,key:_.timeExtentStartTime,scale:"s"},this._formatTime(u.start)):null),u.start&&u.end&&u.start.getTime()!==u.end.getTime()&&j("div",{class:_.timeExtentSeparator,key:_.timeExtentSeparator}),u?.end&&(!u.start||u.start.getTime()!==u.end.getTime())&&j("div",{class:_.timeExtentEndGroup,key:_.timeExtentEndGroup},j("calcite-label",{alignment:"center",class:_.timeExtentEndDate,key:_.timeExtentEndDate,scale:"s"},this._formatDate(u.end)),d?j("calcite-label",{alignment:"center",class:_.timeExtentEndTime,key:_.timeExtentEndTime,scale:"s"},this._formatTime(u.end)):null)],E=j("div",{class:_.timeExtent},x),k=this.labelFormatFunction?j("div",{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:_.minDate,"data-date":n?.start,"data-layout":g,"data-type":"min",key:_.minDate}):n?.start&&[j("calcite-label",{class:_.minDate,key:_.minDate,scale:"s"},this._formatDate(n.start)),d&&j("calcite-label",{class:_.minTime,key:_.minTime,scale:"s"},this._formatTime(n.start))],S=j("div",{class:_.min},k),D=j("div",{class:_.slider},t.render()),L=this.labelFormatFunction?j("div",{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:_.maxDate,"data-date":n?.end,"data-layout":g,"data-type":"max",key:_.maxDate}):n?.end&&[j("calcite-label",{class:_.maxDate,key:_.maxDate,scale:"s"},this._formatDate(n.end)),d&&j("calcite-label",{class:_.maxTime,key:_.maxTime,scale:"s"},this._formatTime(n.end))],U=j("div",{class:_.max},L),Z=j("calcite-button",{appearance:"transparent",bind:this,class:_.previous,disabled:y||"playing"===h,iconStart:"reverse",kind:"neutral",label:o.pagination.previous,onclick:this._previousClick,scale:"wide"===g?"l":"m",width:"full"}),R=j("calcite-button",{appearance:"transparent",bind:this,class:_.next,disabled:y||"playing"===h,iconStart:"forward",kind:"neutral",label:o.pagination.next,onclick:this._nextClick,scale:"wide"===g?"l":"m",width:"full"}),I=i?.length>0,O=I&&j("calcite-action-menu",{class:_.actions,label:o.options},i.toArray().map(t=>j("calcite-action",{bind:this,icon:t.icon,id:t.id,onclick:()=>this.viewModel.triggerAction(t),text:t.title,textEnabled:!0})));return j("div",{afterCreate:t=>{this.addHandles(T(t,()=>this.scheduleRender()))},"aria-label":o.widgetLabel,class:this.classes(_.timeSlider,w.widget,`${_.timeSliderMode}${l}`,`${_.timeSliderLayout}${g}`,!s&&_.timeSliderDisabled,f&&_.timeSliderOutOfBounds,I&&_.hasActions,p(this.container))},"wide"===g&&j("div",{class:_.timeSliderRow},j("div",{class:_.playbackControls},[b,E,S,D,U,Z,R]),O),"compact"===g&&[j("div",{class:_.timeSliderRow,key:"time-slider-row-1"},[E,O]),j("div",{class:_.timeSliderRow,key:"time-slider-row-2"},[D]),j("div",{class:_.timeSliderRow,key:"time-slider-row-3"},[S,Z,b,R,U])])}updateWebDocument(t){this.viewModel?.updateWebDocument(t)}_createLabel(t){if(!this.labelFormatFunction)return;const e=t.getAttribute("data-type"),i=t.getAttribute("data-layout"),a=t["data-date"];this.labelFormatFunction(a,e,t,i)}_formatDate(t){return c(t,this._dateFormat)}_formatTime(t){return c(t,this._timeFormat)}_getIntlOptions(t){const{timeZone:e}=this;return{...d(t),timeZone:e}}_getTickPositions(t){const{fullTimeExtent:e}=this;if(!e?.start||!e.end)return[];const{start:i,end:a}=e,r=[],{value:n,unit:s}=t;let m=o(i,s,this.timeZone);for(;m.getTime()<=a.getTime();)m.getTime()>=i.getTime()&&r.push(m.getTime()),m=l(m,n,s,this.timeZone);return r}_updateSliderSteps(){this._slider.steps=this.effectiveStops&&this.effectiveStops.length>0?this.effectiveStops.map(t=>t.getTime()):null}_playOrStopClick(){switch(this.viewModel.state){case"ready":this.viewModel.play();break;case"playing":this.viewModel.stop();break;case"disabled":break;default:this.viewModel.state}}_previousClick(){this.viewModel.previous()}_nextClick(){this.viewModel.next()}};t([m()],L.prototype,"_dateFormat",null),t([m()],L.prototype,"_timeFormat",null),t([m({type:i})],L.prototype,"actions",null),t([m()],L.prototype,"disabled",void 0),t([m()],L.prototype,"effectiveStops",null),t([m({type:f})],L.prototype,"fullTimeExtent",null),t([m()],L.prototype,"icon",null),t([m({readOnly:!0})],L.prototype,"interactive",null),t([m()],L.prototype,"label",null),t([m()],L.prototype,"labelFormatFunction",void 0),t([m({value:"auto"})],L.prototype,"layout",null),t([m()],L.prototype,"loop",null),t([m(),E("esri/widgets/TimeSlider/t9n/TimeSlider")],L.prototype,"messages",void 0),t([m()],L.prototype,"mode",null),t([m()],L.prototype,"playRate",null),t([m()],L.prototype,"stops",null),t([m()],L.prototype,"tickConfigs",void 0),t([m()],L.prototype,"tickFormats",null),t([m({type:f})],L.prototype,"timeExtent",null),t([m({nonNullable:!0})],L.prototype,"timeVisible",void 0),t([m()],L.prototype,"timeZone",null),t([m()],L.prototype,"view",null),t([m({type:S}),k("trigger-action")],L.prototype,"viewModel",void 0),L=t([u("esri.widgets.TimeSlider")],L);const U=L;export{U as default};
2
+ import{__decorate as e}from"tslib";import{equals as t}from"../core/arrayUtils.js";import i from"../core/Collection.js";import{deprecateWidget as s}from"../core/deprecate.js";import a from"../core/Logger.js";import{watch as n,initial as l}from"../core/reactiveUtils.js";import{truncateDate as o,offsetDate as r}from"../core/timeUtils.js";import{property as u,subclass as m}from"../core/accessorSupport/decorators.js";import{formatDate as c,convertDateFormatToIntlOptions as d}from"../intl/date.js";import{getCalciteModeClass as p}from"../support/modeUtils.js";import{unknown as v,system as h}from"../time/constants.js";import y from"../time/TimeExtent.js";import f from"../time/TimeInterval.js";import g from"./Slider.js";import b from"./Widget.js";import{loadCalciteComponents as x}from"./support/componentsUtils.js";import{globalCss as w}from"./support/globalCss.js";import{messageBundle as E,vmEvent as k,tsx as T}from"./support/widget.js";import{onResize as _}from"./support/widgetUtils.js";import{css as S}from"./TimeSlider/css.js";import M from"./TimeSlider/TimeSliderViewModel.js";const F=3,D=858,j=(e,t,i)=>({minor:e,major:t,format:i}),C={sf:{second:"numeric",fractionalSecondDigits:3},s:{second:"numeric"},ms:{minute:"numeric",second:"numeric"},mi:{minute:"numeric"},hm:{hour:"numeric",minute:"numeric"},dm:{day:"numeric",month:"short"},m:{month:"short"},my:{month:"short",year:"numeric"},y:{year:"numeric"}},L=[j({value:1,unit:"milliseconds"},{value:20,unit:"milliseconds"},C.sf),j({value:2,unit:"milliseconds"},{value:50,unit:"milliseconds"},C.sf),j({value:5,unit:"milliseconds"},{value:100,unit:"milliseconds"},C.sf),j({value:10,unit:"milliseconds"},{value:200,unit:"milliseconds"},C.sf),j({value:20,unit:"milliseconds"},{value:500,unit:"milliseconds"},C.sf),j({value:50,unit:"milliseconds"},{value:1,unit:"seconds"},C.s),j({value:100,unit:"milliseconds"},{value:2,unit:"seconds"},C.s),j({value:200,unit:"milliseconds"},{value:5,unit:"seconds"},C.s),j({value:500,unit:"milliseconds"},{value:10,unit:"seconds"},C.s),j({value:1,unit:"seconds"},{value:20,unit:"seconds"},C.ms),j({value:2,unit:"seconds"},{value:30,unit:"seconds"},C.ms),j({value:5,unit:"seconds"},{value:1,unit:"minutes"},C.mi),j({value:10,unit:"seconds"},{value:2,unit:"minutes"},C.mi),j({value:20,unit:"seconds"},{value:5,unit:"minutes"},C.mi),j({value:40,unit:"seconds"},{value:10,unit:"minutes"},C.mi),j({value:1,unit:"minutes"},{value:30,unit:"minutes"},C.hm),j({value:2,unit:"minutes"},{value:1,unit:"hours"},C.hm),j({value:5,unit:"minutes"},{value:2,unit:"hours"},C.hm),j({value:10,unit:"minutes"},{value:4,unit:"hours"},C.hm),j({value:20,unit:"minutes"},{value:8,unit:"hours"},C.hm),j({value:40,unit:"minutes"},{value:12,unit:"hours"},C.hm),j({value:1,unit:"hours"},{value:1,unit:"days"},C.dm),j({value:2,unit:"hours"},{value:2,unit:"days"},C.dm),j({value:5,unit:"hours"},{value:4,unit:"days"},C.dm),j({value:10,unit:"hours"},{value:10,unit:"days"},C.dm),j({value:20,unit:"hours"},{value:15,unit:"days"},C.dm),j({value:1,unit:"days"},{value:20,unit:"days"},C.dm),j({value:2,unit:"days"},{value:1,unit:"months"},C.m),j({value:5,unit:"days"},{value:3,unit:"months"},C.m),j({value:10,unit:"days"},{value:6,unit:"months"},C.my),j({value:20,unit:"days"},{value:1,unit:"years"},C.y),j({value:1,unit:"months"},{value:2,unit:"years"},C.y),j({value:2,unit:"months"},{value:4,unit:"years"},C.y),j({value:5,unit:"months"},{value:10,unit:"years"},C.y),j({value:1,unit:"years"},{value:20,unit:"years"},C.y),j({value:2,unit:"years"},{value:50,unit:"years"},C.y),j({value:5,unit:"years"},{value:100,unit:"years"},C.y),j({value:10,unit:"years"},{value:200,unit:"years"},C.y),j({value:20,unit:"years"},{value:500,unit:"years"},C.y),j({value:50,unit:"years"},{value:1e3,unit:"years"},C.y),j({value:1,unit:"centuries"},{value:20,unit:"centuries"},C.y),j({value:2,unit:"centuries"},{value:50,unit:"centuries"},C.y),j({value:5,unit:"centuries"},{value:100,unit:"centuries"},C.y),j({value:10,unit:"centuries"},{value:200,unit:"centuries"},C.y),j({value:20,unit:"centuries"},{value:500,unit:"centuries"},C.y),j({value:50,unit:"centuries"},{value:1e3,unit:"centuries"},C.y),j({value:100,unit:"centuries"},{value:2e3,unit:"centuries"},C.y),j({value:200,unit:"centuries"},{value:5e3,unit:"centuries"},C.y),j({value:500,unit:"centuries"},{value:1e4,unit:"centuries"},C.y),j({value:1e3,unit:"centuries"},{value:2e4,unit:"centuries"},C.y)];function Z(e){return T("div",{class:S.warning},T("calcite-icon",{class:S.warningIcon,icon:"exclamation-mark-triangle"}),T("calcite-label",{alignment:"center",class:S.warningLabel,scale:"s"},e))}let U=class extends b{constructor(e,t){super(e,t),this._allLayouts=["auto","compact","wide"],this._ignoreNextSliderUpdate=!1,this._slider=new g({suppressDeprecationWarning:!0,precision:0,visibleElements:{rangeLabels:!1},rangeLabelInputsEnabled:!1,thumbsConstrained:!1}),this._tickFormat=null,this.disabled=!1,this.labelFormatFunction=null,this.messages=null,this.tickConfigs=null,this.timeVisible=!1,this.viewModel=new M,this.announceDeprecation=()=>{s(a.getLogger(this),"Time Slider","arcgis-time-slider",{version:"5.0"})}}initialize(){this.addHandles([n(()=>this._slider.values,e=>{if(this._ignoreNextSliderUpdate)return void(this._ignoreNextSliderUpdate=!1);const t=this.viewModel.valuesToTimeExtent(e);this.timeExtent?t?this.timeExtent.equals(t)||(this.timeExtent=t):this.timeExtent=null:t&&(this.timeExtent=t)}),n(()=>this.effectiveStops,()=>this._updateSliderSteps(),l)])}loadDependencies(){return x({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),label:()=>import("@esri/calcite-components/dist/components/calcite-label")})}destroy(){this._slider.destroy(),this._tickFormat=null}get _dateFormat(){const{timeZone:e,viewModel:t}=this,i=t.isPreCommonEra?"short":void 0;return this._getIntlOptions("short-date",{era:i,timeZone:e})}get _timeFormat(){const{timeZone:e}=this;return this._getIntlOptions("long-time",{timeZone:e})}get actions(){return this.viewModel.actions}set actions(e){this.viewModel.actions=e}get effectiveStops(){return this.viewModel.effectiveStops}get fullTimeExtent(){return this.viewModel.fullTimeExtent}set fullTimeExtent(e){this.viewModel.fullTimeExtent=e}get icon(){return"clock"}set icon(e){this._overrideIfSome("icon",e)}get interactive(){return!(this.disabled||"disabled"===this.viewModel.state||this.timeZone===v)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}set layout(e){this._set("layout",this._allLayouts.includes(e)?e:"auto")}get loop(){return this.viewModel.loop}set loop(e){this.viewModel.loop=e}get mode(){return this.viewModel.mode}set mode(e){this.viewModel.mode=e}get playRate(){return this.viewModel.playRate}set playRate(e){this.viewModel.playRate=e}get stops(){return this.viewModel.stops}set stops(e){this.viewModel.stops=e}get tickFormats(){const{timeZone:e}=this;return L.map(({minor:t,major:i,format:s})=>({minor:new f(t),major:new f(i),format:{...s,timeZone:e}}))}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.view?.timeZone??h}set timeZone(e){this._overrideIfSome("timeZone",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}next(){return this.viewModel.next()}play(){return this.viewModel.play()}previous(){return this.viewModel.previous()}stop(){return this.viewModel.stop()}render(){const{_slider:e,actions:i,domNode:s,effectiveStops:a,fullTimeExtent:n,interactive:l,messages:o,mode:r,tickConfigs:u,timeExtent:m,timeVisible:d,viewModel:{isPreCommonEra:v,state:h,timeExtentValues:y}}=this;if(n){const{start:t,end:i}=n;if(t&&i){const s=t.getTime(),a=i.getTime(),n=e.min!==s||e.max!==a;if(n&&(e.min=s,e.max=a),u)e.tickConfigs!==u&&(e.tickConfigs=u);else{const t=(a-s)/(e.trackElement?.offsetWidth||400),i=this.tickFormats.find(({minor:e})=>e.toMilliseconds()>F*t)??this.tickFormats.at(-1),l=i&&this._tickFormat!==i;if(l&&(this._tickFormat=i),n||l){const t={mode:"position",values:this._getTickPositions(i.minor),labelsVisible:!1,tickCreatedFunction:(e,t)=>{t?.classList.add(S.sliderMinorTick)}},s={...i.format,era:i.format.year&&v?"short":void 0},a={mode:"position",values:this._getTickPositions(i.major),labelsVisible:!0,tickCreatedFunction:(e,t)=>{t?.classList.add(S.sliderMajorTick)},labelFormatFunction:e=>c(e,s)};e.tickConfigs=[t,a]}}}}const f=!this.fullTimeExtent?.start||!this.fullTimeExtent.end||!this.timeExtent||this.timeExtent.isAllTime||this.timeExtent.isEmpty||this.timeExtent.start&&(this.timeExtent.start<this.fullTimeExtent.start||this.timeExtent.start>this.fullTimeExtent.end)||this.timeExtent.end&&(this.timeExtent.end>this.fullTimeExtent.end||this.timeExtent.end<this.fullTimeExtent.start);if(f)switch(this._ignoreNextSliderUpdate=!0,r){case"time-window":e.values=[e.min,e.max];break;case"instant":case"cumulative-from-end":e.values=[e.min];break;case"cumulative-from-start":e.values=[e.max]}else y?t(e.values,y)||(e.values=y):e.values=null;e.disabled=!l;const g=f||!l||!a?.length,b="auto"===this.layout?s.clientWidth<D?"compact":"wide":this.layout,x=T("calcite-button",{appearance:"transparent",bind:this,class:S.play,disabled:g,iconStart:"playing"===h?"pause":"play",kind:"neutral",label:"playing"===h?o.control.stop:o.control.play,onclick:this._playOrStopClick,scale:"wide"===b?"l":"m",width:"full"}),E=this.labelFormatFunction?T("div",{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:S.timeExtentStartDate,"data-date":m?[m.start,m.end]:null,"data-layout":b,"data-type":"extent",key:S.timeExtentStartDate}):!m||m.isAllTime?Z(o.noTimeExtent):m.isEmpty?Z(o.emptyTimeExtent):[m?.start&&T("div",{class:S.timeExtentStartGroup,key:S.timeExtentStartGroup},T("calcite-label",{alignment:"center",class:S.timeExtentStartDate,key:S.timeExtentStartDate,scale:"s"},this._formatDate(m.start)),d?T("calcite-label",{alignment:"center",class:S.timeExtentStartTime,key:S.timeExtentStartTime,scale:"s"},this._formatTime(m.start)):null),m.start&&m.end&&m.start.getTime()!==m.end.getTime()&&T("div",{class:S.timeExtentSeparator,key:S.timeExtentSeparator}),m?.end&&(!m.start||m.start.getTime()!==m.end.getTime())&&T("div",{class:S.timeExtentEndGroup,key:S.timeExtentEndGroup},T("calcite-label",{alignment:"center",class:S.timeExtentEndDate,key:S.timeExtentEndDate,scale:"s"},this._formatDate(m.end)),d?T("calcite-label",{alignment:"center",class:S.timeExtentEndTime,key:S.timeExtentEndTime,scale:"s"},this._formatTime(m.end)):null)],k=T("div",{class:S.timeExtent},E),M=this.labelFormatFunction?T("div",{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:S.minDate,"data-date":n?.start,"data-layout":b,"data-type":"min",key:S.minDate}):n?.start&&[T("calcite-label",{class:S.minDate,key:S.minDate,scale:"s"},this._formatDate(n.start)),d&&T("calcite-label",{class:S.minTime,key:S.minTime,scale:"s"},this._formatTime(n.start))],j=T("div",{class:S.min},M),C=T("div",{class:S.slider},e.render()),L=this.labelFormatFunction?T("div",{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:S.maxDate,"data-date":n?.end,"data-layout":b,"data-type":"max",key:S.maxDate}):n?.end&&[T("calcite-label",{class:S.maxDate,key:S.maxDate,scale:"s"},this._formatDate(n.end)),d&&T("calcite-label",{class:S.maxTime,key:S.maxTime,scale:"s"},this._formatTime(n.end))],U=T("div",{class:S.max},L),R=T("calcite-button",{appearance:"transparent",bind:this,class:S.previous,disabled:g||"playing"===h,iconStart:"reverse",kind:"neutral",label:o.pagination.previous,onclick:this._previousClick,scale:"wide"===b?"l":"m",width:"full"}),I=T("calcite-button",{appearance:"transparent",bind:this,class:S.next,disabled:g||"playing"===h,iconStart:"forward",kind:"neutral",label:o.pagination.next,onclick:this._nextClick,scale:"wide"===b?"l":"m",width:"full"}),O=i?.length>0,A=O&&T("calcite-action-menu",{class:S.actions,label:o.options},i.toArray().map(e=>T("calcite-action",{bind:this,icon:e.icon,id:e.id,onclick:()=>this.viewModel.triggerAction(e),text:e.title,textEnabled:!0})));return T("div",{afterCreate:e=>{this.addHandles(_(e,()=>this.scheduleRender()))},"aria-label":o.widgetLabel,class:this.classes(S.timeSlider,w.widget,`${S.timeSliderMode}${r}`,`${S.timeSliderLayout}${b}`,!l&&S.timeSliderDisabled,f&&S.timeSliderOutOfBounds,O&&S.hasActions,p(this.container))},"wide"===b&&T("div",{class:S.timeSliderRow},T("div",{class:S.playbackControls},[x,k,j,C,U,R,I]),A),"compact"===b&&[T("div",{class:S.timeSliderRow,key:"time-slider-row-1"},[k,A]),T("div",{class:S.timeSliderRow,key:"time-slider-row-2"},[C]),T("div",{class:S.timeSliderRow,key:"time-slider-row-3"},[j,R,x,I,U])])}updateWebDocument(e){this.viewModel?.updateWebDocument(e)}_createLabel(e){if(!this.labelFormatFunction)return;const t=e.getAttribute("data-type"),i=e.getAttribute("data-layout"),s=e["data-date"];this.labelFormatFunction(s,t,e,i)}_formatDate(e){return c(e,this._dateFormat)}_formatTime(e){return c(e,this._timeFormat)}_getIntlOptions(e,t){return{...d(e),...t}}_getTickPositions(e){const{fullTimeExtent:t}=this;if(!t?.start||!t.end)return[];const{start:i,end:s}=t,a=[],{value:n,unit:l}=e;let u=o(i,e,this.timeZone);for(;u.getTime()<=s.getTime();)u.getTime()>=i.getTime()&&a.push(u.getTime()),u=r(u,n,l,this.timeZone);return a}_updateSliderSteps(){this._slider.steps=this.effectiveStops&&this.effectiveStops.length>0?this.effectiveStops.map(e=>e.getTime()):null}_playOrStopClick(){switch(this.viewModel.state){case"ready":this.viewModel.play();break;case"playing":this.viewModel.stop();break;case"disabled":break;default:this.viewModel.state}}_previousClick(){this.viewModel.previous()}_nextClick(){this.viewModel.next()}};e([u()],U.prototype,"_dateFormat",null),e([u()],U.prototype,"_timeFormat",null),e([u({type:i})],U.prototype,"actions",null),e([u()],U.prototype,"disabled",void 0),e([u()],U.prototype,"effectiveStops",null),e([u({type:y})],U.prototype,"fullTimeExtent",null),e([u()],U.prototype,"icon",null),e([u({readOnly:!0})],U.prototype,"interactive",null),e([u()],U.prototype,"label",null),e([u()],U.prototype,"labelFormatFunction",void 0),e([u({value:"auto"})],U.prototype,"layout",null),e([u()],U.prototype,"loop",null),e([u(),E("esri/widgets/TimeSlider/t9n/TimeSlider")],U.prototype,"messages",void 0),e([u()],U.prototype,"mode",null),e([u()],U.prototype,"playRate",null),e([u()],U.prototype,"stops",null),e([u()],U.prototype,"tickConfigs",void 0),e([u()],U.prototype,"tickFormats",null),e([u({type:y})],U.prototype,"timeExtent",null),e([u({nonNullable:!0})],U.prototype,"timeVisible",void 0),e([u()],U.prototype,"timeZone",null),e([u()],U.prototype,"view",null),e([u({type:M}),k("trigger-action")],U.prototype,"viewModel",void 0),U=e([m("esri.widgets.TimeSlider")],U);const R=U;export{R as default};