@arcgis/core 4.26.0-next.20230111 → 4.26.0-next.20230113

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 (296) hide show
  1. package/arcade/ArcadeDate.js +5 -0
  2. package/arcade/Dictionary.js +1 -1
  3. package/arcade/Feature.js +1 -1
  4. package/arcade/arcadeAsyncRuntime.js +1 -1
  5. package/arcade/arcadeCompiler.js +1 -1
  6. package/arcade/arcadeRuntime.js +1 -1
  7. package/arcade/arcadeTimeUtils.js +5 -0
  8. package/arcade/executionError.js +1 -1
  9. package/arcade/featureset/actions/Adapted.js +1 -1
  10. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  11. package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
  12. package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
  13. package/arcade/featureset/support/FeatureSet.js +1 -1
  14. package/arcade/featureset/support/shared.js +1 -1
  15. package/arcade/featureset/support/sqlUtils.js +1 -1
  16. package/arcade/functions/date.js +1 -1
  17. package/arcade/functions/featuresetbase.js +1 -1
  18. package/arcade/functions/featuresetstring.js +1 -1
  19. package/arcade/functions/geomasync.js +1 -1
  20. package/arcade/functions/geometry.js +1 -1
  21. package/arcade/functions/geomsync.js +1 -1
  22. package/arcade/functions/maths.js +1 -1
  23. package/arcade/functions/string.js +1 -1
  24. package/arcade/languageUtils.js +1 -1
  25. package/arcade/treeAnalysis.js +1 -1
  26. package/arcade.js +1 -1
  27. package/assets/esri/core/workers/RemoteClient.js +1 -1
  28. package/assets/esri/core/workers/chunks/{c9477250a5d5ebdef00c.js → 01cd5a9cd4cb1f13691c.js} +1 -1
  29. package/assets/esri/core/workers/chunks/028f9a133104e78e60d2.js +1 -0
  30. package/assets/esri/core/workers/chunks/033e6ae5da6afebd993c.js +1 -0
  31. package/assets/esri/core/workers/chunks/05ab092987251d4a1242.js +1 -0
  32. package/assets/esri/core/workers/chunks/1186a56dacaf269d5271.js +1 -0
  33. package/assets/esri/core/workers/chunks/264e1c00936bcafb9a36.js +1 -0
  34. package/assets/esri/core/workers/chunks/2680392cef77d98ad097.js +1 -0
  35. package/assets/esri/core/workers/chunks/27ba1889fe9f1812389a.js +1165 -0
  36. package/assets/esri/core/workers/chunks/2dfb17fa5b6a5d239942.js +1 -0
  37. package/assets/esri/core/workers/chunks/2e3962506c353b562a88.js +1 -0
  38. package/assets/esri/core/workers/chunks/30ae4c22f6b8aab9f841.js +1 -0
  39. package/assets/esri/core/workers/chunks/329e512f210cb3e904f1.js +1 -0
  40. package/assets/esri/core/workers/chunks/3878efe67f43962b46f8.js +1 -0
  41. package/assets/esri/core/workers/chunks/3b6748f414437cc6cfde.js +1 -0
  42. package/assets/esri/core/workers/chunks/41d25407888326c91566.js +1 -0
  43. package/assets/esri/core/workers/chunks/493e2b00133682748e62.js +1 -0
  44. package/assets/esri/core/workers/chunks/4b2edcb8ef7fae4f7d28.js +1 -0
  45. package/assets/esri/core/workers/chunks/{c11d857dca43de2229fc.js → 4c085cee22ff64ce6d1f.js} +1 -1
  46. package/assets/esri/core/workers/chunks/4d8c53e961275b6a4ee1.js +1 -0
  47. package/assets/esri/core/workers/chunks/5049771eeffe208a9cb8.js +1 -0
  48. package/assets/esri/core/workers/chunks/{58d219ffd9dcc45bb0d1.js → 5191f80f2413ee92c875.js} +1 -1
  49. package/assets/esri/core/workers/chunks/5dfed65b615b33588488.js +1 -0
  50. package/assets/esri/core/workers/chunks/5e9869849d999aac5756.js +1 -0
  51. package/assets/esri/core/workers/chunks/6216cd8134703fd9d9b4.js +1 -0
  52. package/assets/esri/core/workers/chunks/62c8e43741f2d6141f00.js +1 -0
  53. package/assets/esri/core/workers/chunks/64f137358100a1c818f0.js +1 -0
  54. package/assets/esri/core/workers/chunks/6f5f81855985db7c1936.js +1 -0
  55. package/assets/esri/core/workers/chunks/6fba07833345b2d8d373.js +1 -0
  56. package/assets/esri/core/workers/chunks/{80c7726743baf9f54079.js → 7747ee359d357f6e5858.js} +1 -1
  57. package/assets/esri/core/workers/chunks/78fd609f334a29ef39dc.js +1 -0
  58. package/assets/esri/core/workers/chunks/798cd875d64182741364.js +1 -0
  59. package/assets/esri/core/workers/chunks/{9d247a46e0cfdad26273.js → 8176286f8dd055c8ae05.js} +1 -1
  60. package/assets/esri/core/workers/chunks/8530ac02c840c89cc1df.js +1 -0
  61. package/assets/esri/core/workers/chunks/8a69a9b5a04e7321740d.js +1 -0
  62. package/assets/esri/core/workers/chunks/8bd26c71e78698c16778.js +1 -0
  63. package/assets/esri/core/workers/chunks/8c12b82612f050492fef.js +1 -0
  64. package/assets/esri/core/workers/chunks/90653ef5e718bafd6960.js +1 -0
  65. package/assets/esri/core/workers/chunks/{418922fd99e733df023f.js → 9070aa0a94a9204ded1c.js} +1 -1
  66. package/assets/esri/core/workers/chunks/{2ac0d2164a1b49e6f057.js → 94633a9bb5fa4f4ba4de.js} +1 -1
  67. package/assets/esri/core/workers/chunks/969bb94d5bdc9da114e2.js +1 -0
  68. package/assets/esri/core/workers/chunks/9785dba81a6af339e35a.js +1 -0
  69. package/assets/esri/core/workers/chunks/99e16173584702577b80.js +1 -0
  70. package/assets/esri/core/workers/chunks/9aee6f171d4fbac941d9.js +1 -0
  71. package/assets/esri/core/workers/chunks/a194f90ffe13b3d448b0.js +1 -0
  72. package/assets/esri/core/workers/chunks/a53d194e3eede703a6df.js +1 -0
  73. package/assets/esri/core/workers/chunks/a605bf8bc29099ae1b1a.js +1 -0
  74. package/assets/esri/core/workers/chunks/ba7239089a04098e3619.js +1 -0
  75. package/assets/esri/core/workers/chunks/bd2fe663a2b090b134e9.js +1 -0
  76. package/assets/esri/core/workers/chunks/c16003307aad2f84ac51.js +1 -0
  77. package/assets/esri/core/workers/chunks/c6eb6a97ecc6ed9ce713.js +1 -0
  78. package/assets/esri/core/workers/chunks/c81d898f4aef6ecacdb5.js +1 -0
  79. package/assets/esri/core/workers/chunks/cb83480d7074f6185e21.js +1 -0
  80. package/assets/esri/core/workers/chunks/cd0fa942d57a278b0a44.js +1 -0
  81. package/assets/esri/core/workers/chunks/d55332e4d7b8184fd718.js +1 -0
  82. package/assets/esri/core/workers/chunks/d6842acbfa7a39f3ca30.js +1 -0
  83. package/assets/esri/core/workers/chunks/d798bd544433e932f772.js +1 -0
  84. package/assets/esri/core/workers/chunks/e18851e915cb69f53032.js +1 -0
  85. package/assets/esri/core/workers/chunks/{54899827baea77776fc7.js → ea1054116ec842a4f813.js} +1 -1
  86. package/assets/esri/core/workers/chunks/ed1312c2627c0d7e654d.js +1 -0
  87. package/assets/esri/core/workers/chunks/f2750a7b44e8bc8b1e4c.js +1 -0
  88. package/assets/esri/themes/base/widgets/_Editor.scss +1 -11
  89. package/assets/esri/themes/base/widgets/_ItemList.scss +0 -13
  90. package/assets/esri/themes/dark/main.css +1 -1
  91. package/assets/esri/themes/light/main.css +1 -1
  92. package/assets/esri/themes/light/view.css +1 -1
  93. package/assets/esri/widgets/Sketch/t9n/Sketch_ar.json +1 -1
  94. package/assets/esri/widgets/Sketch/t9n/Sketch_bg.json +1 -1
  95. package/assets/esri/widgets/Sketch/t9n/Sketch_bs.json +1 -1
  96. package/assets/esri/widgets/Sketch/t9n/Sketch_ca.json +1 -1
  97. package/assets/esri/widgets/Sketch/t9n/Sketch_cs.json +1 -1
  98. package/assets/esri/widgets/Sketch/t9n/Sketch_da.json +1 -1
  99. package/assets/esri/widgets/Sketch/t9n/Sketch_de.json +1 -1
  100. package/assets/esri/widgets/Sketch/t9n/Sketch_el.json +1 -1
  101. package/assets/esri/widgets/Sketch/t9n/Sketch_es.json +1 -1
  102. package/assets/esri/widgets/Sketch/t9n/Sketch_et.json +1 -1
  103. package/assets/esri/widgets/Sketch/t9n/Sketch_fi.json +1 -1
  104. package/assets/esri/widgets/Sketch/t9n/Sketch_fr.json +1 -1
  105. package/assets/esri/widgets/Sketch/t9n/Sketch_he.json +1 -1
  106. package/assets/esri/widgets/Sketch/t9n/Sketch_hr.json +1 -1
  107. package/assets/esri/widgets/Sketch/t9n/Sketch_hu.json +1 -1
  108. package/assets/esri/widgets/Sketch/t9n/Sketch_id.json +1 -1
  109. package/assets/esri/widgets/Sketch/t9n/Sketch_it.json +1 -1
  110. package/assets/esri/widgets/Sketch/t9n/Sketch_ja.json +1 -1
  111. package/assets/esri/widgets/Sketch/t9n/Sketch_ko.json +1 -1
  112. package/assets/esri/widgets/Sketch/t9n/Sketch_lt.json +1 -1
  113. package/assets/esri/widgets/Sketch/t9n/Sketch_lv.json +1 -1
  114. package/assets/esri/widgets/Sketch/t9n/Sketch_nb.json +1 -1
  115. package/assets/esri/widgets/Sketch/t9n/Sketch_nl.json +1 -1
  116. package/assets/esri/widgets/Sketch/t9n/Sketch_pl.json +1 -1
  117. package/assets/esri/widgets/Sketch/t9n/Sketch_pt-BR.json +1 -1
  118. package/assets/esri/widgets/Sketch/t9n/Sketch_pt-PT.json +1 -1
  119. package/assets/esri/widgets/Sketch/t9n/Sketch_ro.json +1 -1
  120. package/assets/esri/widgets/Sketch/t9n/Sketch_ru.json +1 -1
  121. package/assets/esri/widgets/Sketch/t9n/Sketch_sk.json +1 -1
  122. package/assets/esri/widgets/Sketch/t9n/Sketch_sl.json +1 -1
  123. package/assets/esri/widgets/Sketch/t9n/Sketch_sr.json +1 -1
  124. package/assets/esri/widgets/Sketch/t9n/Sketch_sv.json +1 -1
  125. package/assets/esri/widgets/Sketch/t9n/Sketch_th.json +1 -1
  126. package/assets/esri/widgets/Sketch/t9n/Sketch_tr.json +1 -1
  127. package/assets/esri/widgets/Sketch/t9n/Sketch_uk.json +1 -1
  128. package/assets/esri/widgets/Sketch/t9n/Sketch_vi.json +1 -1
  129. package/assets/esri/widgets/Sketch/t9n/Sketch_zh-CN.json +1 -1
  130. package/assets/esri/widgets/Sketch/t9n/Sketch_zh-HK.json +1 -1
  131. package/assets/esri/widgets/Sketch/t9n/Sketch_zh-TW.json +1 -1
  132. package/chunks/ComponentShader.glsl.js +1 -1
  133. package/chunks/Path.glsl.js +1 -1
  134. package/chunks/Terrain.glsl.js +1 -1
  135. package/chunks/languageUtils.js +1 -1
  136. package/geometry/support/MeshTexture.js +1 -1
  137. package/geometry/support/aaBoundingBox.js +1 -1
  138. package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
  139. package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
  140. package/interfaces.d.ts +1400 -1314
  141. package/layers/ImageryTileLayer.js +1 -1
  142. package/layers/VoxelWasmPerSceneView.js +1 -1
  143. package/layers/graphics/data/FeatureStore.js +1 -1
  144. package/layers/graphics/data/QueryEngine.js +1 -1
  145. package/layers/graphics/data/timeSupport.js +1 -1
  146. package/layers/graphics/featureConversionUtils.js +1 -1
  147. package/layers/graphics/sources/WFSSourceWorker.js +1 -1
  148. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  149. package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
  150. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  151. package/layers/mixins/ArcGISImageService.js +1 -1
  152. package/layers/mixins/ImageryTileMixin.js +1 -1
  153. package/layers/support/layerOriginUtils.js +1 -1
  154. package/layers/support/rasterFormats/JpgPlus.js +1 -1
  155. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  156. package/layers/support/rasterFunctions/ConvolutionFunction.js +1 -1
  157. package/layers/support/rasterFunctions/ConvolutionFunctionArguments.js +1 -1
  158. package/layers/support/rasterFunctions/ExtractBandFunction.js +1 -1
  159. package/layers/support/rasterFunctions/ExtractBandFunctionArguments.js +1 -1
  160. package/layers/support/rasterFunctions/NDVIFunction.js +1 -1
  161. package/layers/support/rasterFunctions/NDVIFunctionArguments.js +1 -1
  162. package/layers/support/rasterFunctions/SlopeFunctionArguments.js +1 -1
  163. package/layers/support/rasterFunctions/StatisticsHistogramFunction.js +5 -0
  164. package/layers/support/rasterFunctions/{StatisticsHistogramsFunctionArguments.js → StatisticsHistogramFunctionArguments.js} +1 -1
  165. package/layers/support/rasterFunctions/rasterFunctionHelper.js +1 -1
  166. package/package.json +1 -1
  167. package/rest/imageService.js +1 -1
  168. package/rest/support/BaseImageMeasureResult.d.ts +4 -0
  169. package/rest/support/ImageAreaParameters.d.ts +4 -0
  170. package/rest/support/{ImageMeasureAreaAndPerimeterParameters.js → ImageAreaParameters.js} +1 -1
  171. package/rest/support/ImageAreaResult.d.ts +4 -0
  172. package/rest/support/{ImageMeasureAreaAndPerimeterResult.js → ImageAreaResult.js} +1 -1
  173. package/rest/support/ImageDistanceParameters.d.ts +4 -0
  174. package/rest/support/{ImageMeasureDistanceAndAngleParameters.js → ImageDistanceParameters.js} +1 -1
  175. package/rest/support/ImageDistanceResult.d.ts +4 -0
  176. package/rest/support/ImageDistanceResult.js +5 -0
  177. package/rest/support/ImageHeightParameters.d.ts +4 -0
  178. package/rest/support/{ImageMeasureHeightParameters.js → ImageHeightParameters.js} +1 -1
  179. package/rest/support/ImageHeightResult.d.ts +4 -0
  180. package/rest/support/{ImageMeasureHeightResult.js → ImageHeightResult.js} +1 -1
  181. package/rest/support/ImagePointParameters.d.ts +4 -0
  182. package/rest/support/{ImageMeasurePointParameters.js → ImagePointParameters.js} +1 -1
  183. package/rest/support/ImagePointResult.d.ts +4 -0
  184. package/rest/support/{ImageMeasurePointResult.js → ImagePointResult.js} +1 -1
  185. package/support/arcadeUtils.js +1 -1
  186. package/support/revision.js +1 -1
  187. package/time/timeReferenceUtils.js +1 -1
  188. package/views/2d/engine/webgl/Overlay.js +1 -1
  189. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  190. package/views/2d/layers/features/FeatureStore2D.js +1 -1
  191. package/views/2d/layers/features/Pipeline.js +1 -1
  192. package/views/2d/layers/features/support/BinStore.js +1 -1
  193. package/views/2d/layers/features/support/ClusterStore.js +1 -1
  194. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  195. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  196. package/views/3d/glTF/internal/Resource.js +1 -1
  197. package/views/3d/glTF/internal/resourceUtils.js +5 -0
  198. package/views/3d/layers/VectorTileLayerView3D.js +1 -1
  199. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  200. package/views/3d/layers/graphics/Graphics3DFeatureStore.js +1 -1
  201. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  202. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  203. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  204. package/views/3d/layers/graphics/Labeler.js +1 -1
  205. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  206. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  207. package/views/3d/layers/i3s/I3SQueryFeatureStore.js +1 -1
  208. package/views/3d/state/ViewState.js +1 -1
  209. package/views/3d/state/ViewStateManager.js +1 -1
  210. package/views/3d/terrain/Overlay.js +1 -1
  211. package/views/3d/terrain/OverlayManager.js +1 -1
  212. package/views/3d/terrain/TerrainRenderer.js +1 -1
  213. package/views/3d/terrain/TerrainSurface.js +1 -1
  214. package/views/3d/terrain/TileRenderer.js +1 -1
  215. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  216. package/views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js +1 -1
  217. package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
  218. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +1 -1
  219. package/views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js +1 -1
  220. package/views/3d/webgl-engine/lib/AnimationTimeStep.js +5 -0
  221. package/views/3d/webgl-engine/lib/AnimationTimer.js +1 -1
  222. package/views/3d/webgl-engine/lib/GLMaterial.js +1 -1
  223. package/views/3d/webgl-engine/lib/Material.js +1 -1
  224. package/views/3d/webgl-engine/lib/RenderFeature.js +5 -0
  225. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  226. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  227. package/views/3d/webgl-engine/lib/basicInterfaces.js +1 -1
  228. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  229. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  230. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  231. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  232. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  233. package/views/draw/support/layerUtils.js +1 -1
  234. package/views/webgl/RenderingContext.js +1 -1
  235. package/views/webgl/Texture.js +1 -1
  236. package/widgets/Editor/EditorViewModel.js +1 -1
  237. package/widgets/Editor.js +1 -1
  238. package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
  239. package/widgets/FeatureTemplates/ItemList.js +1 -1
  240. package/widgets/FeatureTemplates/TemplateItem.js +1 -1
  241. package/widgets/FeatureTemplates/TemplateItemGroup.js +1 -1
  242. package/widgets/FeatureTemplates.js +1 -1
  243. package/widgets/LineOfSight/LineOfSightViewModel.js +1 -1
  244. package/widgets/support/decorators/accessibleHandler.js +1 -1
  245. package/assets/esri/core/workers/chunks/038dc3f9ef06ef3c960c.js +0 -1
  246. package/assets/esri/core/workers/chunks/078a0b134210167b629d.js +0 -1
  247. package/assets/esri/core/workers/chunks/080a4be417be4943f6a0.js +0 -1
  248. package/assets/esri/core/workers/chunks/0877bab7c03a1de2e713.js +0 -1
  249. package/assets/esri/core/workers/chunks/0c9200ab19fd2f56f87f.js +0 -1
  250. package/assets/esri/core/workers/chunks/1cbffa96ea6683e5f3ec.js +0 -1
  251. package/assets/esri/core/workers/chunks/1f742c3b11c76814fa4d.js +0 -1
  252. package/assets/esri/core/workers/chunks/2eb2d49c549e53934b8b.js +0 -1
  253. package/assets/esri/core/workers/chunks/332494b96a47b378f4e0.js +0 -1
  254. package/assets/esri/core/workers/chunks/3326536d183a858a2a4d.js +0 -1
  255. package/assets/esri/core/workers/chunks/3f4fc8379fc11bc293cc.js +0 -1
  256. package/assets/esri/core/workers/chunks/43fecd621cd043f64828.js +0 -1165
  257. package/assets/esri/core/workers/chunks/47b0b660f5412097fe26.js +0 -1
  258. package/assets/esri/core/workers/chunks/4c0d7a074083aa9614bb.js +0 -1
  259. package/assets/esri/core/workers/chunks/594d7e871b648d5c9662.js +0 -1
  260. package/assets/esri/core/workers/chunks/680b90ac98e8d1ac0e33.js +0 -1
  261. package/assets/esri/core/workers/chunks/6b589f47cb4731df1639.js +0 -1
  262. package/assets/esri/core/workers/chunks/72557c4b1582aa18ad4d.js +0 -1
  263. package/assets/esri/core/workers/chunks/72b490ad371e0c2264f6.js +0 -1
  264. package/assets/esri/core/workers/chunks/75ce17cf13aab0440572.js +0 -1
  265. package/assets/esri/core/workers/chunks/75f4e884a1a0aedc0afd.js +0 -1
  266. package/assets/esri/core/workers/chunks/7b9ab3fb378172831c14.js +0 -1
  267. package/assets/esri/core/workers/chunks/7bef95b168303bdc4bf1.js +0 -1
  268. package/assets/esri/core/workers/chunks/803492088780e18de801.js +0 -1
  269. package/assets/esri/core/workers/chunks/89003e387684af5ebeac.js +0 -1
  270. package/assets/esri/core/workers/chunks/8f93026764a0cce0901b.js +0 -1
  271. package/assets/esri/core/workers/chunks/98350b6b95da62ef5f12.js +0 -1
  272. package/assets/esri/core/workers/chunks/a9cae0d386aa9c00f744.js +0 -1
  273. package/assets/esri/core/workers/chunks/ad65c24558098f21bbf3.js +0 -1
  274. package/assets/esri/core/workers/chunks/aef90ee3f0979a7acb38.js +0 -1
  275. package/assets/esri/core/workers/chunks/b68c7754b0220b194ecf.js +0 -1
  276. package/assets/esri/core/workers/chunks/c012317f045a74fdd79d.js +0 -1
  277. package/assets/esri/core/workers/chunks/cb42675e5b1c41634c63.js +0 -1
  278. package/assets/esri/core/workers/chunks/cb901033dd15b3b72025.js +0 -1
  279. package/assets/esri/core/workers/chunks/d398b6b8a6b0a95247de.js +0 -1
  280. package/assets/esri/core/workers/chunks/d447ebc944a9867f5a99.js +0 -1
  281. package/assets/esri/core/workers/chunks/daaabed988b6ea866350.js +0 -1
  282. package/assets/esri/core/workers/chunks/e048641971aef9dd4da9.js +0 -1
  283. package/assets/esri/core/workers/chunks/e3fd383aee378cbb0dae.js +0 -1
  284. package/assets/esri/core/workers/chunks/e967ffca641947212992.js +0 -1
  285. package/assets/esri/core/workers/chunks/e9c81eee503c1b112bad.js +0 -1
  286. package/assets/esri/core/workers/chunks/ea6cf948fe2de0242308.js +0 -1
  287. package/assets/esri/core/workers/chunks/ed5e71b45dfefcbb2da4.js +0 -1
  288. package/assets/esri/core/workers/chunks/ee50d5d0afe9bdccc84d.js +0 -1
  289. package/assets/esri/core/workers/chunks/ee91401507833875facc.js +0 -1
  290. package/assets/esri/core/workers/chunks/f7d40dd78ef116f5793b.js +0 -1
  291. package/assets/esri/core/workers/chunks/f8ab6e354834b9c0e857.js +0 -1
  292. package/assets/esri/core/workers/chunks/faea681c279486b7a5e7.js +0 -1
  293. package/layers/support/rasterFunctions/StatisticsHistogramsFunction.js +0 -5
  294. package/rest/support/ImageMeasureDistanceAndAngleResult.js +0 -5
  295. package/views/3d/support/animationUtils.js +0 -5
  296. package/views/3d/webgl-engine/lib/RenderStateFeature.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{disposeMaybe as t,applySome as e,isNone as s,isSome as i,unwrapOr as a}from"../../core/maybe.js";import{after as r}from"../../core/promiseUtils.js";import{Milliseconds as n}from"../../core/time.js";import{webglDebugEnabled as l}from"./checkWebGLError.js";import{ContextType as h}from"./context-util.js";import{ContextState as f}from"./ContextState.js";import{BufferType as o,Face as _,BASE_TEXTURE_UNIT as u,ClearBufferBit as c,FramebufferTarget as d,TextureSamplingMode as b,SyncCondition as F,ResourceType as g,ClientWaitSyncStatus as E,BlendFactor as B,BlendOperation as p,CullMode as m,CompareFunction as R,StencilOperation as T,ColorAttachment as A,TextureType as x,PrimitiveType as O}from"./enums.js";import{InstanceCounter as U}from"./InstanceCounter.js";import{ProgramCache as C}from"./ProgramCache.js";import{StateTracker as S}from"./renderState.js";import{Texture as P}from"./Texture.js";import{getErrorString as M}from"./Util.js";import{WebGLDriverTest as N}from"./WebGLDriverTest.js";import{Capabilities as k}from"./capabilities/Capabilities.js";import y from"./capabilities/isWebGL2Context.js";let I=class{constructor(t,e){this.gl=t,this.instanceCounter=new U,this.programCache=new C(this),this._state=new f,this._numOfDrawCalls=0,this._numOfTriangles=0,this.type=y(t)?h.WEBGL2:h.WEBGL1,this._loadExtensions(),this.configure(e)}configure(e){this._capabilities=new k(this.gl,e),this._parameters=this._loadParameters(e);const s=this.gl.getParameter(this.gl.VIEWPORT);this._state=new f,this._state.viewport={x:s[0],y:s[1],width:s[2],height:s[3]},this._stateTracker=new S({setBlending:t=>{if(t){this.setBlendingEnabled(!0),this.setBlendEquationSeparate(t.opRgb,t.opAlpha),this.setBlendFunctionSeparate(t.srcRgb,t.dstRgb,t.srcAlpha,t.dstAlpha);const e=t.color;this.setBlendColor(e.r,e.g,e.b,e.a)}else this.setBlendingEnabled(!1)},setCulling:t=>{t?(this.setFaceCullingEnabled(!0),this.setCullFace(t.face),this.setFrontFace(t.mode)):this.setFaceCullingEnabled(!1)},setPolygonOffset:t=>{t?(this.setPolygonOffsetFillEnabled(!0),this.setPolygonOffset(t.factor,t.units)):this.setPolygonOffsetFillEnabled(!1)},setDepthTest:t=>{t?(this.setDepthTestEnabled(!0),this.setDepthFunction(t.func)):this.setDepthTestEnabled(!1)},setStencilTest:t=>{if(t){this.setStencilTestEnabled(!0);const e=t.function;this.setStencilFunction(e.func,e.ref,e.mask);const s=t.operation;this.setStencilOp(s.fail,s.zFail,s.zPass)}else this.setStencilTestEnabled(!1)},setDepthWrite:t=>{t?(this.setDepthWriteEnabled(!0),this.setDepthRange(t.zNear,t.zFar)):this.setDepthWriteEnabled(!1)},setColorWrite:t=>{t?this.setColorMask(t.r,t.g,t.b,t.a):this.setColorMask(!1,!1,!1,!1)},setStencilWrite:t=>{t?this.setStencilWriteMask(t.mask):this.setStencilWriteMask(0)}}),this.enforceState(),t(this._driverTest),this._driverTest=new N(this)}dispose(){t(this._driverTest),this.programCache.dispose(),this.bindVAO(null),this.unbindBuffer(o.ARRAY_BUFFER),this.unbindBuffer(o.ELEMENT_ARRAY_BUFFER),y(this.gl)&&(this.unbindBuffer(o.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(o.PIXEL_PACK_BUFFER),this.unbindBuffer(o.PIXEL_UNPACK_BUFFER),this.unbindBuffer(o.COPY_READ_BUFFER),this.unbindBuffer(o.COPY_WRITE_BUFFER)),this._state.textureUnitMap.length=0,l()&&console.log(this.instanceCounter.resourceInformation)}get driverTest(){return this._driverTest}get contextAttributes(){return this.gl.getContextAttributes()}get parameters(){return this._parameters}setPipelineState(t){this._stateTracker.setPipeline(t)}setBlendingEnabled(t){this._state.blend!==t&&(!0===t?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this._state.blend=t,this._stateTracker.invalidateBlending())}externalProgramUpdate(){this._state.program?.stop(),this._state.program=null}externalTextureUnitUpdate(t,e){for(let s=0;s<t.length;++s)this._state.textureUnitMap[t[s]]=null;e>=0&&(this._state.activeTexture=e)}externalVertexArrayObjectUpdate(){const t=this.capabilities.vao;t&&(t.bindVertexArray(null),this._state.vertexArrayObject=null),this._state.vertexBuffer=null,this._state.indexBuffer=null}externalVertexBufferUpdate(){this._state.vertexBuffer=null}externalIndexBufferUpdate(){this._state.indexBuffer=null}setBlendColor(t,e,s,i){t===this._state.blendColor.r&&e===this._state.blendColor.g&&s===this._state.blendColor.b&&i===this._state.blendColor.a||(this.gl.blendColor(t,e,s,i),this._state.blendColor.r=t,this._state.blendColor.g=e,this._state.blendColor.b=s,this._state.blendColor.a=i,this._stateTracker.invalidateBlending())}setBlendFunction(t,e){t===this._state.blendFunction.srcRGB&&e===this._state.blendFunction.dstRGB||(this.gl.blendFunc(t,e),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=t,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=e,this._stateTracker.invalidateBlending())}setBlendFunctionSeparate(t,e,s,i){this._state.blendFunction.srcRGB===t&&this._state.blendFunction.srcAlpha===s&&this._state.blendFunction.dstRGB===e&&this._state.blendFunction.dstAlpha===i||(this.gl.blendFuncSeparate(t,e,s,i),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=s,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=i,this._stateTracker.invalidateBlending())}setBlendEquation(t){this._state.blendEquation.mode!==t&&(this.gl.blendEquation(t),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=t,this._stateTracker.invalidateBlending())}setBlendEquationSeparate(t,e){this._state.blendEquation.mode===t&&this._state.blendEquation.modeAlpha===e||(this.gl.blendEquationSeparate(t,e),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=e,this._stateTracker.invalidateBlending())}setColorMask(t,e,s,i){this._state.colorMask.r===t&&this._state.colorMask.g===e&&this._state.colorMask.b===s&&this._state.colorMask.a===i||(this.gl.colorMask(t,e,s,i),this._state.colorMask.r=t,this._state.colorMask.g=e,this._state.colorMask.b=s,this._state.colorMask.a=i,this._stateTracker.invalidateColorWrite())}setClearColor(t,e,s,i){this._state.clearColor.r===t&&this._state.clearColor.g===e&&this._state.clearColor.b===s&&this._state.clearColor.a===i||(this.gl.clearColor(t,e,s,i),this._state.clearColor.r=t,this._state.clearColor.g=e,this._state.clearColor.b=s,this._state.clearColor.a=i)}setFaceCullingEnabled(t){this._state.faceCulling!==t&&(!0===t?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this._state.faceCulling=t,this._stateTracker.invalidateCulling())}setPolygonOffsetFillEnabled(t){this._state.polygonOffsetFill!==t&&(!0===t?this.gl.enable(this.gl.POLYGON_OFFSET_FILL):this.gl.disable(this.gl.POLYGON_OFFSET_FILL),this._state.polygonOffsetFill=t,this._stateTracker.invalidatePolygonOffset())}setPolygonOffset(t,e){this._state.polygonOffset[0]===t&&this._state.polygonOffset[1]===e||(this._state.polygonOffset[0]=t,this._state.polygonOffset[1]=e,this.gl.polygonOffset(t,e),this._stateTracker.invalidatePolygonOffset())}setCullFace(t){this._state.cullFace!==t&&(this.gl.cullFace(t),this._state.cullFace=t,this._stateTracker.invalidateCulling())}setFrontFace(t){this._state.frontFace!==t&&(this.gl.frontFace(t),this._state.frontFace=t,this._stateTracker.invalidateCulling())}setScissorTestEnabled(t){this._state.scissorTest!==t&&(!0===t?this.gl.enable(this.gl.SCISSOR_TEST):this.gl.disable(this.gl.SCISSOR_TEST),this._state.scissorTest=t)}setScissorRect(t,e,s,i){this._state.scissorRect.x===t&&this._state.scissorRect.y===e&&this._state.scissorRect.width===s&&this._state.scissorRect.height===i||(this.gl.scissor(t,e,s,i),this._state.scissorRect.x=t,this._state.scissorRect.y=e,this._state.scissorRect.width=s,this._state.scissorRect.height=i)}setDepthTestEnabled(t){this._state.depthTest!==t&&(!0===t?this.gl.enable(this.gl.DEPTH_TEST):this.gl.disable(this.gl.DEPTH_TEST),this._state.depthTest=t,this._stateTracker.invalidateDepthTest())}setClearDepth(t){this._state.clearDepth!==t&&(this.gl.clearDepth(t),this._state.clearDepth=t)}setDepthFunction(t){this._state.depthFunction!==t&&(this.gl.depthFunc(t),this._state.depthFunction=t,this._stateTracker.invalidateDepthTest())}setDepthWriteEnabled(t){this._state.depthWrite!==t&&(this.gl.depthMask(t),this._state.depthWrite=t,this._stateTracker.invalidateDepthWrite())}setDepthRange(t,e){this._state.depthRange.zNear===t&&this._state.depthRange.zFar===e||(this.gl.depthRange(t,e),this._state.depthRange.zNear=t,this._state.depthRange.zFar=e,this._stateTracker.invalidateDepthWrite())}setStencilTestEnabled(t){this._state.stencilTest!==t&&(!0===t?this.gl.enable(this.gl.STENCIL_TEST):this.gl.disable(this.gl.STENCIL_TEST),this._state.stencilTest=t,this._stateTracker.invalidateStencilTest())}setClearStencil(t){t!==this._state.clearStencil&&(this.gl.clearStencil(t),this._state.clearStencil=t)}setStencilFunction(t,e,s){this._state.stencilFunction.func===t&&this._state.stencilFunction.ref===e&&this._state.stencilFunction.mask===s||(this.gl.stencilFunc(t,e,s),this._state.stencilFunction.face=_.FRONT_AND_BACK,this._state.stencilFunction.func=t,this._state.stencilFunction.ref=e,this._state.stencilFunction.mask=s,this._stateTracker.invalidateStencilTest())}setStencilFunctionSeparate(t,e,s,i){this._state.stencilFunction.face===t&&this._state.stencilFunction.func===e&&this._state.stencilFunction.ref===s&&this._state.stencilFunction.mask===i||(this.gl.stencilFuncSeparate(t,e,s,i),this._state.stencilFunction.face=t,this._state.stencilFunction.func=e,this._state.stencilFunction.ref=s,this._state.stencilFunction.mask=i,this._stateTracker.invalidateStencilTest())}setStencilWriteMask(t){this._state.stencilWriteMask!==t&&(this.gl.stencilMask(t),this._state.stencilWriteMask=t,this._stateTracker.invalidateStencilWrite())}setStencilOp(t,e,s){this._state.stencilOperation.face===_.FRONT_AND_BACK&&this._state.stencilOperation.fail===t&&this._state.stencilOperation.zFail===e&&this._state.stencilOperation.zPass===s||(this.gl.stencilOp(t,e,s),this._state.stencilOperation.face=_.FRONT_AND_BACK,this._state.stencilOperation.fail=t,this._state.stencilOperation.zFail=e,this._state.stencilOperation.zPass=s,this._stateTracker.invalidateStencilTest())}setStencilOpSeparate(t,e,s,i){this._state.stencilOperation.face===t&&this._state.stencilOperation.fail===e&&this._state.stencilOperation.zFail===s&&this._state.stencilOperation.zPass===i||(this.gl.stencilOpSeparate(t,e,s,i),this._state.stencilOperation.face=t,this._state.stencilOperation.fail=e,this._state.stencilOperation.zFail=s,this._state.stencilOperation.zPass=i,this._stateTracker.invalidateStencilTest())}setActiveTexture(t,e=!1){const s=this._state.activeTexture;return t>=0&&(e||t!==this._state.activeTexture)&&(this.gl.activeTexture(u+t),this._state.activeTexture=t),s}clear(t){t&&this.gl.clear(t)}clearSafe(t,e=255){t&&(t&c.COLOR_BUFFER_BIT&&this.setColorMask(!0,!0,!0,!0),t&c.DEPTH_BUFFER_BIT&&this.setDepthWriteEnabled(!0),t&c.STENCIL_BUFFER_BIT&&this.setStencilWriteMask(e),this.gl.clear(t))}drawArrays(t,e,s){if(l()&&(this._numOfDrawCalls++,this._numOfTriangles+=D(t,s)),this.gl.drawArrays(t,e,s),l()){const t=M(this);t&&console.error("drawArrays:",t)}}drawElements(t,s,i,a){if(l()&&(this._numOfDrawCalls++,this._numOfTriangles+=D(t,s)),this.gl.drawElements(t,s,i,a),l()){const r=M(this);if(r){const n=this.getBoundVAO(),l=n?.indexBuffer,h=n?.vertexBuffers,f={indexBuffer:l,vertexBuffers:h},o={mode:t,count:s,type:i,offset:a},_=e(l,(t=>t.size))??0,u=a+s,c=_<u?`. Buffer is too small. Attempted to draw index ${u} of ${_}`:"";console.error(`drawElements: ${r}${c}`,{args:o,vao:f})}}}logInfo(){l()&&console.log(`DrawCalls: ${this._numOfDrawCalls}, Triangles: ${this._numOfTriangles}`)}resetInfo(){l()&&(this._numOfDrawCalls=0,this._numOfTriangles=0)}get capabilities(){return this._capabilities}setViewport(t,e,s,i){s=Math.max(Math.round(s),1),i=Math.max(Math.round(i),1);const a=this._state.viewport;a.x===t&&a.y===e&&a.width===s&&a.height===i||(a.x=t,a.y=e,a.width=s,a.height=i,this.gl.viewport(t,e,s,i))}getViewport(){const t=this._state.viewport;return{x:t.x,y:t.y,width:t.width,height:t.height}}useProgram(t){this._state.program!==t&&(this._state.program?.stop(),this._state.program=t,this.gl.useProgram(t?.glName??null))}bindTexture(t,e,a=!1){(e>=this.parameters.maxTextureImageUnits||e<0)&&console.error("Input texture unit is out of range of available units!");const r=this._state.textureUnitMap[e];return s(t)||null==t.glName?(i(r)&&(this.setActiveTexture(e,a),this.gl.bindTexture(r.descriptor.target,null)),this._state.textureUnitMap[e]=null,r):a||r!==t?(this.setActiveTexture(e,a),this.gl.bindTexture(t.descriptor.target,t.glName),t.applyChanges(),this._state.textureUnitMap[e]=t,r):(t.isDirty&&(this.setActiveTexture(e,a),t.applyChanges()),r)}unbindTexture(t){if(!s(t))for(let e=0;e<this.parameters.maxTextureImageUnits;e++)this._state.textureUnitMap[e]===t&&(this.bindTexture(null,e),this._state.textureUnitMap[e]=null)}bindFramebuffer(t,e=!1){if(e||this._state.readFramebuffer!==t||this._state.drawFramebuffer!==t){if(s(t))return this.gl.bindFramebuffer(d.FRAMEBUFFER,null),this._state.readFramebuffer=null,void(this._state.drawFramebuffer=null);t.initializeAndBind(d.FRAMEBUFFER),this._state.readFramebuffer=t,this._state.drawFramebuffer=t}}bindFramebufferSeparate(t,e,i=!1){const r=e===d.READ_FRAMEBUFFER,n=r?this._state.readFramebuffer:this._state.drawFramebuffer;(i||n!==t)&&(s(t)?this.gl.bindFramebuffer(e,null):t.initializeAndBind(e),r?this._state.readFramebuffer=a(t,null):this._state.drawFramebuffer=a(t,null))}blitFramebuffer(t,e,s=0,i=0,a=t.width,r=t.height,n=0,l=0,h=e.width,f=e.height,o=c.COLOR_BUFFER_BIT,_=b.NEAREST){this.bindFramebufferSeparate(t,d.READ_FRAMEBUFFER),this.bindFramebufferSeparate(e,d.DRAW_FRAMEBUFFER);this.gl.blitFramebuffer(s,i,a,r,n,l,h,f,o,_)}bindBuffer(t,e){if(t)switch(e??(e=t.bufferType),e){case o.ARRAY_BUFFER:this._state.vertexBuffer=v(this.gl,t,e,this._state.vertexBuffer);break;case o.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=v(this.gl,t,e,this._state.indexBuffer);break;case o.UNIFORM_BUFFER:this._state.uniformBuffer=v(this.gl,t,e,this._state.uniformBuffer);break;case o.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=v(this.gl,t,e,this._state.pixelPackBuffer);break;case o.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=v(this.gl,t,e,this._state.pixelUnpackBuffer);break;case o.COPY_READ_BUFFER:this._state.copyReadBuffer=v(this.gl,t,e,this._state.copyReadBuffer);break;case o.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=v(this.gl,t,e,this._state.copyWriteBuffer)}}bindRenderbuffer(t){const e=this.gl;t||(e.bindRenderbuffer(e.RENDERBUFFER,null),this._state.renderbuffer=null),this._state.renderbuffer!==t&&(e.bindRenderbuffer(e.RENDERBUFFER,t.glName),this._state.renderbuffer=t)}_getBufferBinding(t,e){if(e>=this.parameters.maxUniformBufferBindings||e<0)return console.error("Uniform buffer binding point is out of range!"),null;const i=this._state.uniformBufferBindingPoints;let a=i[e];return s(a)&&(a={buffer:null,offset:0,size:0},i[e]=a),a}bindBufferBase(t,e,i){const a=this._getBufferBinding(t,e);if(s(a))return;if(a.buffer===i&&0===a.offset&&0===a.size)return;this.gl.bindBufferBase(t,e,i?i.glName:null),a.buffer=i,a.offset=0,a.size=0}bindBufferRange(t,e,i,a,r){const n=this._getBufferBinding(t,e);if(s(n))return;if(n.buffer===i&&n.offset===a&&n.size===r)return;if(a%this._parameters.uniformBufferOffsetAlignment!=0)return void console.error("Uniform buffer binding offset is not a multiple of the context offset alignment");this.gl.bindBufferRange(t,e,i.glName,a,r),n.buffer=i,n.offset=a,n.size=r}bindUBO(t,e,i,a){s(e)?this.bindBufferBase(o.UNIFORM_BUFFER,t,null):(l()&&(a??e.byteLength)>this._parameters.maxUniformBlockSize&&console.error("Attempting to bind more data than the maximum uniform block size"),e.initialize(),void 0!==i&&void 0!==a?this.bindBufferRange(o.UNIFORM_BUFFER,t,e.buffer,i,a):this.bindBufferBase(o.UNIFORM_BUFFER,t,e.buffer))}unbindUBO(t){for(let e=0,s=this._state.uniformBufferBindingPoints.length;e<s;e++){const s=this._state.uniformBufferBindingPoints[e];i(s)&&s.buffer===t.buffer&&this.bindBufferBase(o.UNIFORM_BUFFER,e,null)}}unbindBuffer(t){switch(t){case o.ARRAY_BUFFER:this._state.vertexBuffer=v(this.gl,null,t,this._state.vertexBuffer);break;case o.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=v(this.gl,null,t,this._state.indexBuffer);break;case o.UNIFORM_BUFFER:this._state.uniformBuffer=v(this.gl,null,t,this._state.uniformBuffer);break;case o.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=v(this.gl,null,t,this._state.pixelPackBuffer);break;case o.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=v(this.gl,null,t,this._state.pixelUnpackBuffer);break;case o.COPY_READ_BUFFER:this._state.copyReadBuffer=v(this.gl,null,t,this._state.copyReadBuffer);break;case o.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=v(this.gl,null,t,this._state.copyWriteBuffer)}}bindVAO(t=null){s(t)?this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null):this._state.vertexArrayObject!==t&&(t.bind(),this._state.vertexArrayObject=t)}async clientWaitAsync(t=n(10)){const e=this.gl,s=e.fenceSync(F.SYNC_GPU_COMMANDS_COMPLETE,0);if(!s)throw new Error("Client wait failed, could not create sync object");let i;this.instanceCounter.increment(g.Sync,s),e.flush();do{await r(t),i=e.clientWaitSync(s,0,0)}while(i===E.TIMEOUT_EXPIRED);if(this.instanceCounter.decrement(g.Sync,s),e.deleteSync(s),i===E.WAIT_FAILED)throw new Error("Client wait failed")}getBoundFramebufferObject(t=d.FRAMEBUFFER){return t===d.READ_FRAMEBUFFER?this._state.readFramebuffer:this._state.drawFramebuffer}getBoundVAO(){return this._state.vertexArrayObject}resetState(){this.useProgram(null),this.bindVAO(null),this.bindFramebuffer(null,!0),this.unbindBuffer(o.ARRAY_BUFFER),this.unbindBuffer(o.ELEMENT_ARRAY_BUFFER),y(this.gl)&&(this.unbindBuffer(o.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(o.PIXEL_PACK_BUFFER),this.unbindBuffer(o.PIXEL_UNPACK_BUFFER),this.unbindBuffer(o.COPY_READ_BUFFER),this.unbindBuffer(o.COPY_WRITE_BUFFER));for(let t=0;t<this.parameters.maxTextureImageUnits;++t)this.bindTexture(null,t);this.setBlendingEnabled(!1),this.setBlendFunction(B.ONE,B.ZERO),this.setBlendEquation(p.ADD),this.setBlendColor(0,0,0,0),this.setFaceCullingEnabled(!1),this.setCullFace(_.BACK),this.setFrontFace(m.CCW),this.setPolygonOffsetFillEnabled(!1),this.setPolygonOffset(0,0),this.setScissorTestEnabled(!1),this.setScissorRect(0,0,this.gl.canvas.width,this.gl.canvas.height),this.setDepthTestEnabled(!1),this.setDepthFunction(R.LESS),this.setDepthRange(0,1),this.setStencilTestEnabled(!1),this.setStencilFunction(R.ALWAYS,0,0),this.setStencilOp(T.KEEP,T.KEEP,T.KEEP),this.setClearColor(0,0,0,0),this.setClearDepth(1),this.setClearStencil(0),this.setColorMask(!0,!0,!0,!0),this.setStencilWriteMask(4294967295),this.setDepthWriteEnabled(!0),this.setViewport(0,0,this.gl.canvas.width,this.gl.canvas.height)}enforceState(){const t=this.gl,e=this.capabilities.vao;e&&e.bindVertexArray(null);for(let i=0;i<this.parameters.maxVertexAttributes;i++)t.disableVertexAttribArray(i);if(this._state.vertexBuffer?t.bindBuffer(this._state.vertexBuffer.bufferType,this._state.vertexBuffer.glName):t.bindBuffer(o.ARRAY_BUFFER,null),this._state.indexBuffer?t.bindBuffer(this._state.indexBuffer.bufferType,this._state.indexBuffer.glName):t.bindBuffer(o.ELEMENT_ARRAY_BUFFER,null),y(t)){this._state.uniformBuffer?t.bindBuffer(this._state.uniformBuffer.bufferType,this._state.uniformBuffer.glName):t.bindBuffer(o.UNIFORM_BUFFER,null);for(let e=0;e<this._parameters.maxUniformBufferBindings;e++){const s=this._state.uniformBufferBindingPoints[e];if(i(s)){const{buffer:i,offset:a,size:r}=s;null!==i?0===a&&0===r?t.bindBufferBase(o.UNIFORM_BUFFER,e,i.glName):t.bindBufferRange(o.UNIFORM_BUFFER,e,i.glName,a,r):t.bindBufferBase(o.UNIFORM_BUFFER,e,null)}}this._state.pixelPackBuffer?t.bindBuffer(this._state.pixelPackBuffer.bufferType,this._state.pixelPackBuffer.glName):t.bindBuffer(o.PIXEL_PACK_BUFFER,null),this._state.pixelUnpackBuffer?t.bindBuffer(this._state.pixelUnpackBuffer.bufferType,this._state.pixelUnpackBuffer.glName):t.bindBuffer(o.PIXEL_UNPACK_BUFFER,null),this._state.copyReadBuffer?t.bindBuffer(this._state.copyReadBuffer.bufferType,this._state.copyReadBuffer.glName):t.bindBuffer(o.COPY_READ_BUFFER,null),this._state.copyWriteBuffer?t.bindBuffer(this._state.copyWriteBuffer.bufferType,this._state.copyWriteBuffer.glName):t.bindBuffer(o.COPY_WRITE_BUFFER,null),t.bindFramebuffer(d.READ_FRAMEBUFFER,null),t.readBuffer(t.BACK),this._state.readFramebuffer&&(t.bindFramebuffer(d.READ_FRAMEBUFFER,this._state.readFramebuffer.glName),t.readBuffer(A.COLOR_ATTACHMENT0)),t.bindFramebuffer(d.DRAW_FRAMEBUFFER,this._state.drawFramebuffer?.glName??null)}else this._state.readFramebuffer=this._state.drawFramebuffer,t.bindFramebuffer(d.FRAMEBUFFER,this._state.drawFramebuffer?.glName??null);if(e&&this._state.vertexArrayObject){const t=this._state.vertexArrayObject;this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null),this.bindVAO(t)}t.useProgram(this._state.program?.glName??null),t.blendColor(this._state.blendColor.r,this._state.blendColor.g,this._state.blendColor.b,this._state.blendColor.a),t.bindRenderbuffer(t.RENDERBUFFER,this._state.renderbuffer?this._state.renderbuffer.glName:null),!0===this._state.blend?t.enable(this.gl.BLEND):t.disable(this.gl.BLEND),t.blendEquationSeparate(this._state.blendEquation.mode,this._state.blendEquation.modeAlpha),t.blendFuncSeparate(this._state.blendFunction.srcRGB,this._state.blendFunction.dstRGB,this._state.blendFunction.srcAlpha,this._state.blendFunction.dstAlpha),t.clearColor(this._state.clearColor.r,this._state.clearColor.g,this._state.clearColor.b,this._state.clearColor.a),t.clearDepth(this._state.clearDepth),t.clearStencil(this._state.clearStencil),t.colorMask(this._state.colorMask.r,this._state.colorMask.g,this._state.colorMask.b,this._state.colorMask.a),t.cullFace(this._state.cullFace),t.depthFunc(this._state.depthFunction),t.depthRange(this._state.depthRange.zNear,this._state.depthRange.zFar),!0===this._state.depthTest?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),t.depthMask(this._state.depthWrite),t.frontFace(this._state.frontFace),t.lineWidth(1),!0===this._state.faceCulling?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),t.polygonOffset(this._state.polygonOffset[0],this._state.polygonOffset[1]),!0===this._state.polygonOffsetFill?t.enable(t.POLYGON_OFFSET_FILL):t.disable(t.POLYGON_OFFSET_FILL),t.scissor(this._state.scissorRect.x,this._state.scissorRect.y,this._state.scissorRect.width,this._state.scissorRect.height),!0===this._state.scissorTest?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST),t.stencilFunc(this._state.stencilFunction.func,this._state.stencilFunction.ref,this._state.stencilFunction.mask),t.stencilOpSeparate(this._state.stencilOperation.face,this._state.stencilOperation.fail,this._state.stencilOperation.zFail,this._state.stencilOperation.zPass),!0===this._state.stencilTest?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),t.stencilMask(this._state.stencilWriteMask);for(let a=0;a<this.parameters.maxTextureImageUnits;a++){t.activeTexture(u+a),t.bindTexture(x.TEXTURE_2D,null),t.bindTexture(x.TEXTURE_CUBE_MAP,null),y(t)&&(t.bindTexture(x.TEXTURE_3D,null),t.bindTexture(x.TEXTURE_2D_ARRAY,null));const e=this._state.textureUnitMap[a];i(e)&&t.bindTexture(e.descriptor.target,e.glName)}t.activeTexture(u+this._state.activeTexture);const s=this._state.viewport;t.viewport(s.x,s.y,s.width,s.height),this.resetInfo()}_loadExtensions(){this.type===h.WEBGL1&&this.gl.getExtension("OES_element_index_uint"),this.gl.getExtension("KHR_parallel_shader_compile")}_loadParameters(t){const e=this.capabilities.textureFilterAnisotropic,s=t.maxAnisotropy??1/0,i=y(this.gl),a=this.gl,r={versionString:this.gl.getParameter(this.gl.VERSION),maxVertexTextureImageUnits:this.gl.getParameter(this.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxVertexAttributes:this.gl.getParameter(this.gl.MAX_VERTEX_ATTRIBS),maxMaxAnisotropy:e?Math.min(this.gl.getParameter(e.MAX_TEXTURE_MAX_ANISOTROPY),s):1,maxTextureImageUnits:this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),maxTextureSize:this.gl.getParameter(this.gl.MAX_TEXTURE_SIZE),maxUniformBufferBindings:i?a.getParameter(a.MAX_UNIFORM_BUFFER_BINDINGS):0,maxVertexUniformBlocks:i?a.getParameter(a.MAX_VERTEX_UNIFORM_BLOCKS):0,maxFragmentUniformBlocks:i?a.getParameter(a.MAX_FRAGMENT_UNIFORM_BLOCKS):0,maxUniformBlockSize:i?a.getParameter(a.MAX_UNIFORM_BLOCK_SIZE):0,uniformBufferOffsetAlignment:i?a.getParameter(a.UNIFORM_BUFFER_OFFSET_ALIGNMENT):1,maxArrayTextureLayers:i?a.getParameter(a.MAX_ARRAY_TEXTURE_LAYERS):1,maxSamples:i?a.getParameter(a.MAX_SAMPLES):1};return P.TEXTURE_UNIT_FOR_UPDATES=r.maxTextureImageUnits-1,r}};function v(t,e,s,i){return e?i!==e&&t.bindBuffer(s,e.glName):t.bindBuffer(s,null),e}function D(t,e){switch(t){case O.POINTS:return 2*e;case O.TRIANGLES:return e/3;case O.TRIANGLE_STRIP:case O.TRIANGLE_FAN:return e-2;default:return 0}}export{I as RenderingContext};
5
+ import{disposeMaybe as t,applySome as e,isNone as s,isSome as i,unwrapOr as a}from"../../core/maybe.js";import{after as r}from"../../core/promiseUtils.js";import{Milliseconds as n}from"../../core/time.js";import{webglDebugEnabled as l}from"./checkWebGLError.js";import{ContextType as h}from"./context-util.js";import{ContextState as f}from"./ContextState.js";import{BufferType as o,Face as _,BASE_TEXTURE_UNIT as u,ClearBufferBit as c,FramebufferTarget as d,TextureSamplingMode as b,SyncCondition as F,ResourceType as g,ClientWaitSyncStatus as E,BlendFactor as B,BlendOperation as p,CullMode as m,CompareFunction as R,StencilOperation as T,ColorAttachment as A,TextureType as x,PrimitiveType as O}from"./enums.js";import{InstanceCounter as U}from"./InstanceCounter.js";import{ProgramCache as C}from"./ProgramCache.js";import{StateTracker as S}from"./renderState.js";import{Texture as P}from"./Texture.js";import{getErrorString as M}from"./Util.js";import{WebGLDriverTest as y}from"./WebGLDriverTest.js";import{Capabilities as N}from"./capabilities/Capabilities.js";import k from"./capabilities/isWebGL2Context.js";let I=class{constructor(t,e){this.gl=t,this.instanceCounter=new U,this.programCache=new C(this),this._state=new f,this._numOfDrawCalls=0,this._numOfTriangles=0,this.type=k(t)?h.WEBGL2:h.WEBGL1,this._loadExtensions(),this.configure(e)}get gl2(){return this.type===h.WEBGL1?null:this.gl}configure(e){this._capabilities=new N(this.gl,e),this._parameters=this._loadParameters(e);const s=this.gl.getParameter(this.gl.VIEWPORT);this._state=new f,this._state.viewport={x:s[0],y:s[1],width:s[2],height:s[3]},this._stateTracker=new S({setBlending:t=>{if(t){this.setBlendingEnabled(!0),this.setBlendEquationSeparate(t.opRgb,t.opAlpha),this.setBlendFunctionSeparate(t.srcRgb,t.dstRgb,t.srcAlpha,t.dstAlpha);const e=t.color;this.setBlendColor(e.r,e.g,e.b,e.a)}else this.setBlendingEnabled(!1)},setCulling:t=>{t?(this.setFaceCullingEnabled(!0),this.setCullFace(t.face),this.setFrontFace(t.mode)):this.setFaceCullingEnabled(!1)},setPolygonOffset:t=>{t?(this.setPolygonOffsetFillEnabled(!0),this.setPolygonOffset(t.factor,t.units)):this.setPolygonOffsetFillEnabled(!1)},setDepthTest:t=>{t?(this.setDepthTestEnabled(!0),this.setDepthFunction(t.func)):this.setDepthTestEnabled(!1)},setStencilTest:t=>{if(t){this.setStencilTestEnabled(!0);const e=t.function;this.setStencilFunction(e.func,e.ref,e.mask);const s=t.operation;this.setStencilOp(s.fail,s.zFail,s.zPass)}else this.setStencilTestEnabled(!1)},setDepthWrite:t=>{t?(this.setDepthWriteEnabled(!0),this.setDepthRange(t.zNear,t.zFar)):this.setDepthWriteEnabled(!1)},setColorWrite:t=>{t?this.setColorMask(t.r,t.g,t.b,t.a):this.setColorMask(!1,!1,!1,!1)},setStencilWrite:t=>{t?this.setStencilWriteMask(t.mask):this.setStencilWriteMask(0)}}),this.enforceState(),t(this._driverTest),this._driverTest=new y(this)}dispose(){t(this._driverTest),this.programCache.dispose(),this.bindVAO(null),this.unbindBuffer(o.ARRAY_BUFFER),this.unbindBuffer(o.ELEMENT_ARRAY_BUFFER),this.type===h.WEBGL2&&(this.unbindBuffer(o.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(o.PIXEL_PACK_BUFFER),this.unbindBuffer(o.PIXEL_UNPACK_BUFFER),this.unbindBuffer(o.COPY_READ_BUFFER),this.unbindBuffer(o.COPY_WRITE_BUFFER)),this._state.textureUnitMap.length=0,l()&&console.log(this.instanceCounter.resourceInformation)}get driverTest(){return this._driverTest}get contextAttributes(){return this.gl.getContextAttributes()}get parameters(){return this._parameters}setPipelineState(t){this._stateTracker.setPipeline(t)}setBlendingEnabled(t){this._state.blend!==t&&(!0===t?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this._state.blend=t,this._stateTracker.invalidateBlending())}externalProgramUpdate(){this._state.program?.stop(),this._state.program=null}externalTextureUnitUpdate(t,e){for(let s=0;s<t.length;++s)this._state.textureUnitMap[t[s]]=null;e>=0&&(this._state.activeTexture=e)}externalVertexArrayObjectUpdate(){const t=this.capabilities.vao;t&&(t.bindVertexArray(null),this._state.vertexArrayObject=null),this._state.vertexBuffer=null,this._state.indexBuffer=null}externalVertexBufferUpdate(){this._state.vertexBuffer=null}externalIndexBufferUpdate(){this._state.indexBuffer=null}setBlendColor(t,e,s,i){t===this._state.blendColor.r&&e===this._state.blendColor.g&&s===this._state.blendColor.b&&i===this._state.blendColor.a||(this.gl.blendColor(t,e,s,i),this._state.blendColor.r=t,this._state.blendColor.g=e,this._state.blendColor.b=s,this._state.blendColor.a=i,this._stateTracker.invalidateBlending())}setBlendFunction(t,e){t===this._state.blendFunction.srcRGB&&e===this._state.blendFunction.dstRGB||(this.gl.blendFunc(t,e),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=t,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=e,this._stateTracker.invalidateBlending())}setBlendFunctionSeparate(t,e,s,i){this._state.blendFunction.srcRGB===t&&this._state.blendFunction.srcAlpha===s&&this._state.blendFunction.dstRGB===e&&this._state.blendFunction.dstAlpha===i||(this.gl.blendFuncSeparate(t,e,s,i),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=s,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=i,this._stateTracker.invalidateBlending())}setBlendEquation(t){this._state.blendEquation.mode!==t&&(this.gl.blendEquation(t),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=t,this._stateTracker.invalidateBlending())}setBlendEquationSeparate(t,e){this._state.blendEquation.mode===t&&this._state.blendEquation.modeAlpha===e||(this.gl.blendEquationSeparate(t,e),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=e,this._stateTracker.invalidateBlending())}setColorMask(t,e,s,i){this._state.colorMask.r===t&&this._state.colorMask.g===e&&this._state.colorMask.b===s&&this._state.colorMask.a===i||(this.gl.colorMask(t,e,s,i),this._state.colorMask.r=t,this._state.colorMask.g=e,this._state.colorMask.b=s,this._state.colorMask.a=i,this._stateTracker.invalidateColorWrite())}setClearColor(t,e,s,i){this._state.clearColor.r===t&&this._state.clearColor.g===e&&this._state.clearColor.b===s&&this._state.clearColor.a===i||(this.gl.clearColor(t,e,s,i),this._state.clearColor.r=t,this._state.clearColor.g=e,this._state.clearColor.b=s,this._state.clearColor.a=i)}setFaceCullingEnabled(t){this._state.faceCulling!==t&&(!0===t?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this._state.faceCulling=t,this._stateTracker.invalidateCulling())}setPolygonOffsetFillEnabled(t){this._state.polygonOffsetFill!==t&&(!0===t?this.gl.enable(this.gl.POLYGON_OFFSET_FILL):this.gl.disable(this.gl.POLYGON_OFFSET_FILL),this._state.polygonOffsetFill=t,this._stateTracker.invalidatePolygonOffset())}setPolygonOffset(t,e){this._state.polygonOffset[0]===t&&this._state.polygonOffset[1]===e||(this._state.polygonOffset[0]=t,this._state.polygonOffset[1]=e,this.gl.polygonOffset(t,e),this._stateTracker.invalidatePolygonOffset())}setCullFace(t){this._state.cullFace!==t&&(this.gl.cullFace(t),this._state.cullFace=t,this._stateTracker.invalidateCulling())}setFrontFace(t){this._state.frontFace!==t&&(this.gl.frontFace(t),this._state.frontFace=t,this._stateTracker.invalidateCulling())}setScissorTestEnabled(t){this._state.scissorTest!==t&&(!0===t?this.gl.enable(this.gl.SCISSOR_TEST):this.gl.disable(this.gl.SCISSOR_TEST),this._state.scissorTest=t)}setScissorRect(t,e,s,i){this._state.scissorRect.x===t&&this._state.scissorRect.y===e&&this._state.scissorRect.width===s&&this._state.scissorRect.height===i||(this.gl.scissor(t,e,s,i),this._state.scissorRect.x=t,this._state.scissorRect.y=e,this._state.scissorRect.width=s,this._state.scissorRect.height=i)}setDepthTestEnabled(t){this._state.depthTest!==t&&(!0===t?this.gl.enable(this.gl.DEPTH_TEST):this.gl.disable(this.gl.DEPTH_TEST),this._state.depthTest=t,this._stateTracker.invalidateDepthTest())}setClearDepth(t){this._state.clearDepth!==t&&(this.gl.clearDepth(t),this._state.clearDepth=t)}setDepthFunction(t){this._state.depthFunction!==t&&(this.gl.depthFunc(t),this._state.depthFunction=t,this._stateTracker.invalidateDepthTest())}setDepthWriteEnabled(t){this._state.depthWrite!==t&&(this.gl.depthMask(t),this._state.depthWrite=t,this._stateTracker.invalidateDepthWrite())}setDepthRange(t,e){this._state.depthRange.zNear===t&&this._state.depthRange.zFar===e||(this.gl.depthRange(t,e),this._state.depthRange.zNear=t,this._state.depthRange.zFar=e,this._stateTracker.invalidateDepthWrite())}setStencilTestEnabled(t){this._state.stencilTest!==t&&(!0===t?this.gl.enable(this.gl.STENCIL_TEST):this.gl.disable(this.gl.STENCIL_TEST),this._state.stencilTest=t,this._stateTracker.invalidateStencilTest())}setClearStencil(t){t!==this._state.clearStencil&&(this.gl.clearStencil(t),this._state.clearStencil=t)}setStencilFunction(t,e,s){this._state.stencilFunction.func===t&&this._state.stencilFunction.ref===e&&this._state.stencilFunction.mask===s||(this.gl.stencilFunc(t,e,s),this._state.stencilFunction.face=_.FRONT_AND_BACK,this._state.stencilFunction.func=t,this._state.stencilFunction.ref=e,this._state.stencilFunction.mask=s,this._stateTracker.invalidateStencilTest())}setStencilFunctionSeparate(t,e,s,i){this._state.stencilFunction.face===t&&this._state.stencilFunction.func===e&&this._state.stencilFunction.ref===s&&this._state.stencilFunction.mask===i||(this.gl.stencilFuncSeparate(t,e,s,i),this._state.stencilFunction.face=t,this._state.stencilFunction.func=e,this._state.stencilFunction.ref=s,this._state.stencilFunction.mask=i,this._stateTracker.invalidateStencilTest())}setStencilWriteMask(t){this._state.stencilWriteMask!==t&&(this.gl.stencilMask(t),this._state.stencilWriteMask=t,this._stateTracker.invalidateStencilWrite())}setStencilOp(t,e,s){this._state.stencilOperation.face===_.FRONT_AND_BACK&&this._state.stencilOperation.fail===t&&this._state.stencilOperation.zFail===e&&this._state.stencilOperation.zPass===s||(this.gl.stencilOp(t,e,s),this._state.stencilOperation.face=_.FRONT_AND_BACK,this._state.stencilOperation.fail=t,this._state.stencilOperation.zFail=e,this._state.stencilOperation.zPass=s,this._stateTracker.invalidateStencilTest())}setStencilOpSeparate(t,e,s,i){this._state.stencilOperation.face===t&&this._state.stencilOperation.fail===e&&this._state.stencilOperation.zFail===s&&this._state.stencilOperation.zPass===i||(this.gl.stencilOpSeparate(t,e,s,i),this._state.stencilOperation.face=t,this._state.stencilOperation.fail=e,this._state.stencilOperation.zFail=s,this._state.stencilOperation.zPass=i,this._stateTracker.invalidateStencilTest())}setActiveTexture(t,e=!1){const s=this._state.activeTexture;return t>=0&&(e||t!==this._state.activeTexture)&&(this.gl.activeTexture(u+t),this._state.activeTexture=t),s}clear(t){t&&this.gl.clear(t)}clearSafe(t,e=255){t&&(t&c.COLOR_BUFFER_BIT&&this.setColorMask(!0,!0,!0,!0),t&c.DEPTH_BUFFER_BIT&&this.setDepthWriteEnabled(!0),t&c.STENCIL_BUFFER_BIT&&this.setStencilWriteMask(e),this.gl.clear(t))}drawArrays(t,e,s){if(l()&&(this._numOfDrawCalls++,this._numOfTriangles+=D(t,s)),this.gl.drawArrays(t,e,s),l()){const t=M(this);t&&console.error("drawArrays:",t)}}drawElements(t,s,i,a){if(l()&&(this._numOfDrawCalls++,this._numOfTriangles+=D(t,s)),this.gl.drawElements(t,s,i,a),l()){const r=M(this);if(r){const n=this.getBoundVAO(),l=n?.indexBuffer,h=n?.vertexBuffers,f={indexBuffer:l,vertexBuffers:h},o={mode:t,count:s,type:i,offset:a},_=e(l,(t=>t.size))??0,u=a+s,c=_<u?`. Buffer is too small. Attempted to draw index ${u} of ${_}`:"";console.error(`drawElements: ${r}${c}`,{args:o,vao:f})}}}logInfo(){l()&&console.log(`DrawCalls: ${this._numOfDrawCalls}, Triangles: ${this._numOfTriangles}`)}resetInfo(){l()&&(this._numOfDrawCalls=0,this._numOfTriangles=0)}get capabilities(){return this._capabilities}setViewport(t,e,s,i){s=Math.max(Math.round(s),1),i=Math.max(Math.round(i),1);const a=this._state.viewport;a.x===t&&a.y===e&&a.width===s&&a.height===i||(a.x=t,a.y=e,a.width=s,a.height=i,this.gl.viewport(t,e,s,i))}getViewport(){const t=this._state.viewport;return{x:t.x,y:t.y,width:t.width,height:t.height}}useProgram(t){this._state.program!==t&&(this._state.program?.stop(),this._state.program=t,this.gl.useProgram(t?.glName??null))}bindTexture(t,e,a=!1){(e>=this.parameters.maxTextureImageUnits||e<0)&&console.error("Input texture unit is out of range of available units!");const r=this._state.textureUnitMap[e];return s(t)||null==t.glName?(i(r)&&(this.setActiveTexture(e,a),this.gl.bindTexture(r.descriptor.target,null)),this._state.textureUnitMap[e]=null,r):a||r!==t?(this.setActiveTexture(e,a),this.gl.bindTexture(t.descriptor.target,t.glName),t.applyChanges(),this._state.textureUnitMap[e]=t,r):(t.isDirty&&(this.setActiveTexture(e,a),t.applyChanges()),r)}unbindTexture(t){if(!s(t))for(let e=0;e<this.parameters.maxTextureImageUnits;e++)this._state.textureUnitMap[e]===t&&(this.bindTexture(null,e),this._state.textureUnitMap[e]=null)}bindFramebuffer(t,e=!1){if(e||this._state.readFramebuffer!==t||this._state.drawFramebuffer!==t){if(s(t))return this.gl.bindFramebuffer(d.FRAMEBUFFER,null),this._state.readFramebuffer=null,void(this._state.drawFramebuffer=null);t.initializeAndBind(d.FRAMEBUFFER),this._state.readFramebuffer=t,this._state.drawFramebuffer=t}}bindFramebufferSeparate(t,e,i=!1){const r=e===d.READ_FRAMEBUFFER,n=r?this._state.readFramebuffer:this._state.drawFramebuffer;(i||n!==t)&&(s(t)?this.gl.bindFramebuffer(e,null):t.initializeAndBind(e),r?this._state.readFramebuffer=a(t,null):this._state.drawFramebuffer=a(t,null))}blitFramebuffer(t,e,s=0,i=0,a=t.width,r=t.height,n=0,l=0,h=e.width,f=e.height,o=c.COLOR_BUFFER_BIT,_=b.NEAREST){this.bindFramebufferSeparate(t,d.READ_FRAMEBUFFER),this.bindFramebufferSeparate(e,d.DRAW_FRAMEBUFFER);this.gl.blitFramebuffer(s,i,a,r,n,l,h,f,o,_)}bindBuffer(t,e){if(t)switch(e??(e=t.bufferType),e){case o.ARRAY_BUFFER:this._state.vertexBuffer=v(this.gl,t,e,this._state.vertexBuffer);break;case o.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=v(this.gl,t,e,this._state.indexBuffer);break;case o.UNIFORM_BUFFER:this._state.uniformBuffer=v(this.gl,t,e,this._state.uniformBuffer);break;case o.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=v(this.gl,t,e,this._state.pixelPackBuffer);break;case o.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=v(this.gl,t,e,this._state.pixelUnpackBuffer);break;case o.COPY_READ_BUFFER:this._state.copyReadBuffer=v(this.gl,t,e,this._state.copyReadBuffer);break;case o.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=v(this.gl,t,e,this._state.copyWriteBuffer)}}bindRenderbuffer(t){const e=this.gl;t||(e.bindRenderbuffer(e.RENDERBUFFER,null),this._state.renderbuffer=null),this._state.renderbuffer!==t&&(e.bindRenderbuffer(e.RENDERBUFFER,t.glName),this._state.renderbuffer=t)}_getBufferBinding(t,e){if(e>=this.parameters.maxUniformBufferBindings||e<0)return console.error("Uniform buffer binding point is out of range!"),null;const i=this._state.uniformBufferBindingPoints;let a=i[e];return s(a)&&(a={buffer:null,offset:0,size:0},i[e]=a),a}bindBufferBase(t,e,i){const a=this._getBufferBinding(t,e);if(s(a))return;if(a.buffer===i&&0===a.offset&&0===a.size)return;this.gl.bindBufferBase(t,e,i?i.glName:null),a.buffer=i,a.offset=0,a.size=0}bindBufferRange(t,e,i,a,r){const n=this._getBufferBinding(t,e);if(s(n))return;if(n.buffer===i&&n.offset===a&&n.size===r)return;if(a%this._parameters.uniformBufferOffsetAlignment!=0)return void console.error("Uniform buffer binding offset is not a multiple of the context offset alignment");this.gl.bindBufferRange(t,e,i.glName,a,r),n.buffer=i,n.offset=a,n.size=r}bindUBO(t,e,i,a){s(e)?this.bindBufferBase(o.UNIFORM_BUFFER,t,null):(l()&&(a??e.byteLength)>this._parameters.maxUniformBlockSize&&console.error("Attempting to bind more data than the maximum uniform block size"),e.initialize(),void 0!==i&&void 0!==a?this.bindBufferRange(o.UNIFORM_BUFFER,t,e.buffer,i,a):this.bindBufferBase(o.UNIFORM_BUFFER,t,e.buffer))}unbindUBO(t){for(let e=0,s=this._state.uniformBufferBindingPoints.length;e<s;e++){const s=this._state.uniformBufferBindingPoints[e];i(s)&&s.buffer===t.buffer&&this.bindBufferBase(o.UNIFORM_BUFFER,e,null)}}unbindBuffer(t){switch(t){case o.ARRAY_BUFFER:this._state.vertexBuffer=v(this.gl,null,t,this._state.vertexBuffer);break;case o.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=v(this.gl,null,t,this._state.indexBuffer);break;case o.UNIFORM_BUFFER:this._state.uniformBuffer=v(this.gl,null,t,this._state.uniformBuffer);break;case o.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=v(this.gl,null,t,this._state.pixelPackBuffer);break;case o.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=v(this.gl,null,t,this._state.pixelUnpackBuffer);break;case o.COPY_READ_BUFFER:this._state.copyReadBuffer=v(this.gl,null,t,this._state.copyReadBuffer);break;case o.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=v(this.gl,null,t,this._state.copyWriteBuffer)}}bindVAO(t=null){s(t)?this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null):this._state.vertexArrayObject!==t&&(t.bind(),this._state.vertexArrayObject=t)}async clientWaitAsync(t=n(10)){const e=this.gl,s=e.fenceSync(F.SYNC_GPU_COMMANDS_COMPLETE,0);if(!s)throw new Error("Client wait failed, could not create sync object");let i;this.instanceCounter.increment(g.Sync,s),e.flush();do{await r(t),i=e.clientWaitSync(s,0,0)}while(i===E.TIMEOUT_EXPIRED);if(this.instanceCounter.decrement(g.Sync,s),e.deleteSync(s),i===E.WAIT_FAILED)throw new Error("Client wait failed")}getBoundFramebufferObject(t=d.FRAMEBUFFER){return t===d.READ_FRAMEBUFFER?this._state.readFramebuffer:this._state.drawFramebuffer}getBoundVAO(){return this._state.vertexArrayObject}resetState(){this.useProgram(null),this.bindVAO(null),this.bindFramebuffer(null,!0),this.unbindBuffer(o.ARRAY_BUFFER),this.unbindBuffer(o.ELEMENT_ARRAY_BUFFER),this.type===h.WEBGL2&&(this.unbindBuffer(o.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(o.PIXEL_PACK_BUFFER),this.unbindBuffer(o.PIXEL_UNPACK_BUFFER),this.unbindBuffer(o.COPY_READ_BUFFER),this.unbindBuffer(o.COPY_WRITE_BUFFER));for(let t=0;t<this.parameters.maxTextureImageUnits;++t)this.bindTexture(null,t);this.setBlendingEnabled(!1),this.setBlendFunction(B.ONE,B.ZERO),this.setBlendEquation(p.ADD),this.setBlendColor(0,0,0,0),this.setFaceCullingEnabled(!1),this.setCullFace(_.BACK),this.setFrontFace(m.CCW),this.setPolygonOffsetFillEnabled(!1),this.setPolygonOffset(0,0),this.setScissorTestEnabled(!1),this.setScissorRect(0,0,this.gl.canvas.width,this.gl.canvas.height),this.setDepthTestEnabled(!1),this.setDepthFunction(R.LESS),this.setDepthRange(0,1),this.setStencilTestEnabled(!1),this.setStencilFunction(R.ALWAYS,0,0),this.setStencilOp(T.KEEP,T.KEEP,T.KEEP),this.setClearColor(0,0,0,0),this.setClearDepth(1),this.setClearStencil(0),this.setColorMask(!0,!0,!0,!0),this.setStencilWriteMask(4294967295),this.setDepthWriteEnabled(!0),this.setViewport(0,0,this.gl.canvas.width,this.gl.canvas.height)}enforceState(){const t=this.capabilities.vao;t&&t.bindVertexArray(null);const{gl:e,gl2:s}=this;for(let i=0;i<this.parameters.maxVertexAttributes;i++)e.disableVertexAttribArray(i);if(this._state.vertexBuffer?e.bindBuffer(this._state.vertexBuffer.bufferType,this._state.vertexBuffer.glName):e.bindBuffer(o.ARRAY_BUFFER,null),this._state.indexBuffer?e.bindBuffer(this._state.indexBuffer.bufferType,this._state.indexBuffer.glName):e.bindBuffer(o.ELEMENT_ARRAY_BUFFER,null),i(s)){this._state.uniformBuffer?s.bindBuffer(this._state.uniformBuffer.bufferType,this._state.uniformBuffer.glName):s.bindBuffer(o.UNIFORM_BUFFER,null);for(let t=0;t<this._parameters.maxUniformBufferBindings;t++){const e=this._state.uniformBufferBindingPoints[t];if(i(e)){const{buffer:i,offset:a,size:r}=e;null!==i?0===a&&0===r?s.bindBufferBase(o.UNIFORM_BUFFER,t,i.glName):s.bindBufferRange(o.UNIFORM_BUFFER,t,i.glName,a,r):s.bindBufferBase(o.UNIFORM_BUFFER,t,null)}}this._state.pixelPackBuffer?s.bindBuffer(this._state.pixelPackBuffer.bufferType,this._state.pixelPackBuffer.glName):s.bindBuffer(o.PIXEL_PACK_BUFFER,null),this._state.pixelUnpackBuffer?s.bindBuffer(this._state.pixelUnpackBuffer.bufferType,this._state.pixelUnpackBuffer.glName):s.bindBuffer(o.PIXEL_UNPACK_BUFFER,null),this._state.copyReadBuffer?s.bindBuffer(this._state.copyReadBuffer.bufferType,this._state.copyReadBuffer.glName):s.bindBuffer(o.COPY_READ_BUFFER,null),this._state.copyWriteBuffer?s.bindBuffer(this._state.copyWriteBuffer.bufferType,this._state.copyWriteBuffer.glName):s.bindBuffer(o.COPY_WRITE_BUFFER,null),s.bindFramebuffer(d.READ_FRAMEBUFFER,null),s.readBuffer(s.BACK),this._state.readFramebuffer&&(s.bindFramebuffer(d.READ_FRAMEBUFFER,this._state.readFramebuffer.glName),s.readBuffer(A.COLOR_ATTACHMENT0)),s.bindFramebuffer(d.DRAW_FRAMEBUFFER,this._state.drawFramebuffer?.glName??null)}else this._state.readFramebuffer=this._state.drawFramebuffer,e.bindFramebuffer(d.FRAMEBUFFER,this._state.drawFramebuffer?.glName??null);if(t&&this._state.vertexArrayObject){const t=this._state.vertexArrayObject;this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null),this.bindVAO(t)}e.useProgram(this._state.program?.glName??null),e.blendColor(this._state.blendColor.r,this._state.blendColor.g,this._state.blendColor.b,this._state.blendColor.a),e.bindRenderbuffer(e.RENDERBUFFER,this._state.renderbuffer?this._state.renderbuffer.glName:null),!0===this._state.blend?e.enable(this.gl.BLEND):e.disable(this.gl.BLEND),e.blendEquationSeparate(this._state.blendEquation.mode,this._state.blendEquation.modeAlpha),e.blendFuncSeparate(this._state.blendFunction.srcRGB,this._state.blendFunction.dstRGB,this._state.blendFunction.srcAlpha,this._state.blendFunction.dstAlpha),e.clearColor(this._state.clearColor.r,this._state.clearColor.g,this._state.clearColor.b,this._state.clearColor.a),e.clearDepth(this._state.clearDepth),e.clearStencil(this._state.clearStencil),e.colorMask(this._state.colorMask.r,this._state.colorMask.g,this._state.colorMask.b,this._state.colorMask.a),e.cullFace(this._state.cullFace),e.depthFunc(this._state.depthFunction),e.depthRange(this._state.depthRange.zNear,this._state.depthRange.zFar),!0===this._state.depthTest?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),e.depthMask(this._state.depthWrite),e.frontFace(this._state.frontFace),e.lineWidth(1),!0===this._state.faceCulling?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),e.polygonOffset(this._state.polygonOffset[0],this._state.polygonOffset[1]),!0===this._state.polygonOffsetFill?e.enable(e.POLYGON_OFFSET_FILL):e.disable(e.POLYGON_OFFSET_FILL),e.scissor(this._state.scissorRect.x,this._state.scissorRect.y,this._state.scissorRect.width,this._state.scissorRect.height),!0===this._state.scissorTest?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST),e.stencilFunc(this._state.stencilFunction.func,this._state.stencilFunction.ref,this._state.stencilFunction.mask),e.stencilOpSeparate(this._state.stencilOperation.face,this._state.stencilOperation.fail,this._state.stencilOperation.zFail,this._state.stencilOperation.zPass),!0===this._state.stencilTest?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),e.stencilMask(this._state.stencilWriteMask);for(let r=0;r<this.parameters.maxTextureImageUnits;r++){e.activeTexture(u+r),e.bindTexture(x.TEXTURE_2D,null),e.bindTexture(x.TEXTURE_CUBE_MAP,null),this.type===h.WEBGL2&&(e.bindTexture(x.TEXTURE_3D,null),e.bindTexture(x.TEXTURE_2D_ARRAY,null));const t=this._state.textureUnitMap[r];i(t)&&e.bindTexture(t.descriptor.target,t.glName)}e.activeTexture(u+this._state.activeTexture);const a=this._state.viewport;e.viewport(a.x,a.y,a.width,a.height),this.resetInfo()}_loadExtensions(){this.type===h.WEBGL1&&this.gl.getExtension("OES_element_index_uint"),this.gl.getExtension("KHR_parallel_shader_compile")}_loadParameters(t){const e=this.capabilities.textureFilterAnisotropic,s=t.maxAnisotropy??1/0,i=this.type===h.WEBGL2,a=this.gl,r={versionString:this.gl.getParameter(this.gl.VERSION),maxVertexTextureImageUnits:this.gl.getParameter(this.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxVertexAttributes:this.gl.getParameter(this.gl.MAX_VERTEX_ATTRIBS),maxMaxAnisotropy:e?Math.min(this.gl.getParameter(e.MAX_TEXTURE_MAX_ANISOTROPY),s):1,maxTextureImageUnits:this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),maxTextureSize:this.gl.getParameter(this.gl.MAX_TEXTURE_SIZE),maxUniformBufferBindings:i?a.getParameter(a.MAX_UNIFORM_BUFFER_BINDINGS):0,maxVertexUniformBlocks:i?a.getParameter(a.MAX_VERTEX_UNIFORM_BLOCKS):0,maxFragmentUniformBlocks:i?a.getParameter(a.MAX_FRAGMENT_UNIFORM_BLOCKS):0,maxUniformBlockSize:i?a.getParameter(a.MAX_UNIFORM_BLOCK_SIZE):0,uniformBufferOffsetAlignment:i?a.getParameter(a.UNIFORM_BUFFER_OFFSET_ALIGNMENT):1,maxArrayTextureLayers:i?a.getParameter(a.MAX_ARRAY_TEXTURE_LAYERS):1,maxSamples:i?a.getParameter(a.MAX_SAMPLES):1};return P.TEXTURE_UNIT_FOR_UPDATES=r.maxTextureImageUnits-1,r}};function v(t,e,s,i){return e?i!==e&&t.bindBuffer(s,e.glName):t.bindBuffer(s,null),e}function D(t,e){switch(t){case O.POINTS:return 2*e;case O.TRIANGLES:return e/3;case O.TRIANGLE_STRIP:case O.TRIANGLE_FAN:return e-2;default:return 0}}export{I as RenderingContext};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import"../../core/has.js";import{isPowerOfTwo as t}from"../../core/mathUtils.js";import{isSome as e,unwrap as i}from"../../core/maybe.js";import{checkWebGLError as r}from"./checkWebGLError.js";import{ContextType as o}from"./context-util.js";import{TextureType as s,TextureSamplingMode as a,TextureWrapMode as n,ResourceType as l,PixelType as h,PixelFormat as p,SizedPixelFormat as _,CompressedTextureFormat as m}from"./enums.js";import d from"./capabilities/isWebGL2Context.js";const u={target:s.TEXTURE_2D,samplingMode:a.LINEAR,wrapMode:n.REPEAT,flipped:!1,hasMipmap:!1,isOpaque:!1,unpackAlignment:4,preMultiplyAlpha:!1,isImmutable:!1},c=4;let E=class{constructor(t,e,i=null){this._context=t,this.type="texture",this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,t.instanceCounter.increment(l.Texture,this),this._descriptor={...u,...e};for(const r in u){void 0===this._descriptor[r]&&(this._descriptor[r]=u[r])}if(t.type!==o.WEBGL2&&(this._descriptor.isImmutable&&(this._descriptor.isImmutable=!1),A(this._descriptor.target)))throw new Error("3D and array textures are not supported in WebGL1");this._descriptor.target===s.TEXTURE_CUBE_MAP?this._setDataCubeMap(i):this.setData(i)}get glName(){return this._glName}get descriptor(){return this._descriptor}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}dispose(){this._context.gl&&this._glName&&(this._context.unbindTexture(this),this._context.gl.deleteTexture(this._glName),this._glName=null,this._context.instanceCounter.decrement(l.Texture,this))}release(){this.dispose()}resize(t,e){const i=this._descriptor;if(i.width!==t||i.height!==e){if(this._wasImmutablyAllocated)throw new Error("Immutable textures can't be resized!");i.width=t,i.height=e,this._descriptor.target===s.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}_setDataCubeMap(t=null){for(let e=s.TEXTURE_CUBE_MAP_POSITIVE_X;e<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}setData(t){this._setData(t)}_setData(t,i){if(!this._context||!this._context.gl)return;const o=this._context.gl;this._glName||(this._glName=o.createTexture()),void 0===t&&(t=null);const s=this._descriptor,a=i??s.target,n=A(a);null===t&&(s.width=s.width||c,s.height=s.height||c,n&&(s.depth=s.depth??1));const l=this._context.bindTexture(this,E.TEXTURE_UNIT_FOR_UPDATES);this._context.setActiveTexture(E.TEXTURE_UNIT_FOR_UPDATES),E._validateTexture(this._context,s),this._configurePixelStorage(),r(o);const h=s.pixelFormat;let p=s.internalFormat??this._deriveInternalFormat(h,s.dataType);if(f(t)){let e=t.width,i=t.height;const l=1;t instanceof HTMLVideoElement&&(e=t.videoWidth,i=t.videoHeight),s.width&&s.height,n&&s.depth,s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(a,p,s.hasMipmap,e,i,l),this._texImage(a,0,p,e,i,l,t),r(o),s.hasMipmap&&this.generateMipmap(),void 0===s.width&&(s.width=e),void 0===s.height&&(s.height=i),n&&void 0===s.depth&&(s.depth=l)}else{const{width:i,height:l,depth:h}=s;if(null==i||null==l)throw new Error("Width and height must be specified!");if(n&&null==h)throw new Error("Depth must be specified!");if(s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(a,p,s.hasMipmap,i,l,h),o.DEPTH24_STENCIL8&&p===o.DEPTH_STENCIL&&(p=o.DEPTH24_STENCIL8),x(t)){const e=t.levels,r=w(a,i,l,h),n=Math.min(r-1,e.length-1);d(o)?o.texParameteri(s.target,o.TEXTURE_MAX_LEVEL,n):s.hasMipmap=s.hasMipmap&&r===e.length;const _=p;if(!g(_))throw new Error("Attempting to use compressed data with an umcompressed format!");this._forEachMipmapLevel(((t,i,r,o)=>{const s=e[Math.min(t,e.length-1)];this._compressedTexImage(a,t,_,i,r,o,s)}),n)}else e(t)?(this._texImage(a,0,p,i,l,h,t),r(o),s.hasMipmap&&this.generateMipmap()):this._forEachMipmapLevel(((t,e,i,s)=>{this._texImage(a,t,p,e,i,s,null),r(o)}))}E._applySamplingMode(o,this._descriptor),E._applyWrapMode(o,this._descriptor),E._applyAnisotropicFilteringParameters(this._context,this._descriptor),r(o),this._context.bindTexture(l,E.TEXTURE_UNIT_FOR_UPDATES)}updateData(t,e,i,r,o,s,a=0){s||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const n=this._context.gl,l=this._descriptor,{pixelFormat:h,dataType:p,target:_,isImmutable:m}=l,u=l.internalFormat??this._deriveInternalFormat(h,p);if(m&&!this._wasImmutablyAllocated)throw new Error("Cannot update immutable texture before allocation!");const c=this._context.bindTexture(this,E.TEXTURE_UNIT_FOR_UPDATES,!0);if((e<0||i<0||r>l.width||o>l.height||e+r>l.width||i+o>l.height)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage(),a){if(!d(n))return void console.error("Webgl2 must be enabled to use dataRowOffset!");n.pixelStorei(n.UNPACK_SKIP_ROWS,a)}if(f(s)?d(n)?n.texSubImage2D(_,t,e,i,r,o,h,p,s):n.texSubImage2D(_,t,e,i,h,p,s):x(s)?n.compressedTexSubImage2D(_,t,e,i,r,o,u,s.levels[t]):n.texSubImage2D(_,t,e,i,r,o,h,p,s),a){if(!d(n))return void console.error("Webgl2 must be enabled to use dataRowOffset!");n.pixelStorei(n.UNPACK_SKIP_ROWS,0)}this._context.bindTexture(c,E.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(t,e,i,r,o,s,a,n){n||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const l=this._context.gl;if(!d(l))throw new Error("3D textures are not supported in WebGL1");const h=this._descriptor,{pixelFormat:p,dataType:_,isImmutable:m,target:u}=h,c=h.internalFormat??this._deriveInternalFormat(p,_);if(m&&!this._wasImmutablyAllocated)throw new Error("Cannot update immutable texture before allocation!");A(u)||console.warn("Attempting to set 3D texture data on a non-3D texture");const T=this._context.bindTexture(this,E.TEXTURE_UNIT_FOR_UPDATES);if(this._context.setActiveTexture(E.TEXTURE_UNIT_FOR_UPDATES),(e<0||i<0||r<0||o>h.width||s>h.height||a>h.depth||e+o>h.width||i+s>h.height||r+a>h.depth)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage(),x(n))n=n.levels[t],l.compressedTexSubImage3D(u,t,e,i,r,o,s,a,c,n);else{const h=n;l.texSubImage3D(u,t,e,i,r,o,s,a,p,_,h)}this._context.bindTexture(T,E.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const t=this._descriptor;if(!t.hasMipmap){if(this._wasImmutablyAllocated)throw new Error("Cannot add mipmaps to immutable texture after allocation");t.hasMipmap=!0,this._samplingModeDirty=!0,E._validateTexture(this._context,t)}t.samplingMode===a.LINEAR?(this._samplingModeDirty=!0,t.samplingMode=a.LINEAR_MIPMAP_NEAREST):t.samplingMode===a.NEAREST&&(this._samplingModeDirty=!0,t.samplingMode=a.NEAREST_MIPMAP_NEAREST);const e=this._context.bindTexture(this,E.TEXTURE_UNIT_FOR_UPDATES);this._context.setActiveTexture(E.TEXTURE_UNIT_FOR_UPDATES);this._context.gl.generateMipmap(t.target),this._context.bindTexture(e,E.TEXTURE_UNIT_FOR_UPDATES)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,E._validateTexture(this._context,this._descriptor),this._wrapModeDirty=!0)}applyChanges(){const t=this._context.gl,e=this._descriptor;this._samplingModeDirty&&(E._applySamplingMode(t,e),this._samplingModeDirty=!1),this._wrapModeDirty&&(E._applyWrapMode(t,e),this._wrapModeDirty=!1)}_deriveInternalFormat(t,e){if(this._context.type===o.WEBGL1)return t;switch(e){case h.FLOAT:switch(t){case p.RGBA:return _.RGBA32F;case p.RGB:return _.RGB32F;default:throw new Error("Unable to derive format")}case h.UNSIGNED_BYTE:switch(t){case p.RGBA:return _.RGBA8;case p.RGB:return _.RGB8}default:return t}}_configurePixelStorage(){const t=this._context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_texStorage(t,e,i,r,o,s){const a=this._context.gl;if(!d(a))throw new Error("Immutable textures are not supported in WebGL1");if(!T(e))throw new Error("Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const n=i?w(t,r,o,s):1;if(A(t)){if(null==s)throw new Error("Missing depth dimension for 3D texture upload");a.texStorage3D(t,n,e,r,o,s)}else a.texStorage2D(t,n,e,r,o);this._wasImmutablyAllocated=!0}_texImage(t,r,s,a,n,l,h){const p=this._context.gl;let _=null;const m=this._context.type===o.WEBGL2,d=A(t),{isImmutable:u,pixelFormat:c,dataType:E}=this._descriptor;if(m&&(_=p),m||!f(h))if(u){if(e(h)){const e=h;if(d){if(null==l)throw new Error("Missing depth dimension for 3D texture upload");_.texSubImage3D(t,r,0,0,0,a,n,l,c,E,e)}else p.texSubImage2D(t,r,0,0,a,n,c,E,e)}}else{const e=i(h);if(d){if(null==l)throw new Error("Missing depth dimension for 3D texture upload");_.texImage3D(t,r,s,a,n,l,0,c,E,e)}else p.texImage2D(t,r,s,a,n,0,c,E,e)}else p.texImage2D(t,0,s,c,E,h)}_compressedTexImage(t,i,r,s,a,n,l){const h=this._context.gl;let p=null;const _=A(t),m=this._descriptor.isImmutable;if(_){if(this._context.type!==o.WEBGL2)throw new Error("3D textures are not supported in WebGL1");p=h}if(m){if(e(l))if(_){if(null==n)throw new Error("Missing depth dimension for 3D texture upload");p.compressedTexSubImage3D(t,i,0,0,0,s,a,n,r,l)}else h.compressedTexSubImage2D(t,i,0,0,s,a,r,l)}else if(_){if(null==n)throw new Error("Missing depth dimension for 3D texture upload");p.compressedTexImage3D(t,i,r,s,a,n,0,l)}else h.compressedTexImage2D(t,i,r,s,a,0,l)}_forEachMipmapLevel(t,e=1/0){let{width:i,height:r,depth:o,hasMipmap:a,target:n}=this._descriptor;const l=n===s.TEXTURE_3D;if(null==i||null==r||l&&null==o)throw new Error("Missing texture dimensions for mipmap calculation");for(let s=0;t(s,i,r,o),a&&(1!==i||1!==r||l&&1!==o)&&!(s>=e);++s)i=Math.max(1,i>>1),r=Math.max(1,r>>1),l&&(o=Math.max(1,o>>1))}static _validateTexture(e,i){(null!=i.width&&i.width<0||null!=i.height&&i.height<0||null!=i.depth&&i.depth<0)&&console.error("Negative dimension parameters are not allowed!");const r=d(e.gl),o=null!=i.width&&t(i.width)&&null!=i.height&&t(i.height);r||!i.isImmutable&&!A(i.target)||console.error("Immutable and 3D-like textures are not supported in WebGL1!"),r||o||("number"==typeof i.wrapMode?i.wrapMode!==n.CLAMP_TO_EDGE&&console.error("Non-power-of-two textures must have a wrap mode of CLAMP_TO_EDGE!"):i.wrapMode.s===n.CLAMP_TO_EDGE&&i.wrapMode.t===n.CLAMP_TO_EDGE||console.error("Non-power-of-two textures must have a wrap mode of CLAMP_TO_EDGE!"),i.hasMipmap&&console.error("Mipmapping requires power-of-two textures!"))}static _applySamplingMode(t,e){let i=e.samplingMode,r=e.samplingMode;i===a.LINEAR_MIPMAP_NEAREST||i===a.LINEAR_MIPMAP_LINEAR?(i=a.LINEAR,e.hasMipmap||(r=a.LINEAR)):i!==a.NEAREST_MIPMAP_NEAREST&&i!==a.NEAREST_MIPMAP_LINEAR||(i=a.NEAREST,e.hasMipmap||(r=a.NEAREST)),t.texParameteri(e.target,t.TEXTURE_MAG_FILTER,i),t.texParameteri(e.target,t.TEXTURE_MIN_FILTER,r)}static _applyWrapMode(t,e){"number"==typeof e.wrapMode?(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode)):(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode.s),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode.t))}static _applyAnisotropicFilteringParameters(t,e){const i=t.capabilities.textureFilterAnisotropic;if(!i)return;t.gl.texParameterf(e.target,i.TEXTURE_MAX_ANISOTROPY,e.maxAnisotropy??1)}};function T(t){return t in _}function g(t){return t in m}function x(t){return e(t)&&"type"in t&&"compressed"===t.type}function M(t){return e(t)&&"byteLength"in t}function f(t){return e(t)&&!x(t)&&!M(t)}function A(t){return t===s.TEXTURE_3D||t===s.TEXTURE_2D_ARRAY}function w(t,e,i,r=1){let o=Math.max(e,i);return t===s.TEXTURE_3D&&(o=Math.max(o,r)),Math.round(Math.log(o)/Math.LN2)+1}E.TEXTURE_UNIT_FOR_UPDATES=0;export{E as Texture};
5
+ import"../../core/has.js";import{isPowerOfTwo as t}from"../../core/mathUtils.js";import{isSome as e,isNone as i,unwrap as r}from"../../core/maybe.js";import{checkWebGLError as o}from"./checkWebGLError.js";import{ContextType as s}from"./context-util.js";import{TextureType as a,TextureSamplingMode as n,TextureWrapMode as l,ResourceType as h,PixelType as p,PixelFormat as _,SizedPixelFormat as m,CompressedTextureFormat as d}from"./enums.js";const u={target:a.TEXTURE_2D,samplingMode:n.LINEAR,wrapMode:l.REPEAT,flipped:!1,hasMipmap:!1,isOpaque:!1,unpackAlignment:4,preMultiplyAlpha:!1,isImmutable:!1},c=4;let E=class{constructor(t,e,i=null){this._context=t,this.type="texture",this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,t.instanceCounter.increment(h.Texture,this),this._descriptor={...u,...e};for(const r in u){void 0===this._descriptor[r]&&(this._descriptor[r]=u[r])}if(t.type!==s.WEBGL2&&(this._descriptor.isImmutable&&(this._descriptor.isImmutable=!1),A(this._descriptor.target)))throw new Error("3D and array textures are not supported in WebGL1");this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(i):this.setData(i)}get glName(){return this._glName}get descriptor(){return this._descriptor}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}dispose(){this._context.gl&&this._glName&&(this._context.unbindTexture(this),this._context.gl.deleteTexture(this._glName),this._glName=null,this._context.instanceCounter.decrement(h.Texture,this))}release(){this.dispose()}resize(t,e){const i=this._descriptor;if(i.width!==t||i.height!==e){if(this._wasImmutablyAllocated)throw new Error("Immutable textures can't be resized!");i.width=t,i.height=e,this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}_setDataCubeMap(t=null){for(let e=a.TEXTURE_CUBE_MAP_POSITIVE_X;e<=a.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}setData(t){this._setData(t)}_setData(t,i){if(!this._context||!this._context.gl)return;const r=this._context.gl;this._glName||(this._glName=r.createTexture()),void 0===t&&(t=null);const s=this._descriptor,a=i??s.target,n=A(a);null===t&&(s.width=s.width||c,s.height=s.height||c,n&&(s.depth=s.depth??1));const l=this._context.bindTexture(this,E.TEXTURE_UNIT_FOR_UPDATES);this._context.setActiveTexture(E.TEXTURE_UNIT_FOR_UPDATES),E._validateTexture(this._context,s),this._configurePixelStorage(),o(r);const h=s.pixelFormat;let p=s.internalFormat??this._deriveInternalFormat(h,s.dataType);if(f(t)){let e=t.width,i=t.height;const l=1;t instanceof HTMLVideoElement&&(e=t.videoWidth,i=t.videoHeight),s.width&&s.height,n&&s.depth,s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(a,p,s.hasMipmap,e,i,l),this._texImage(a,0,p,e,i,l,t),o(r),s.hasMipmap&&this.generateMipmap(),void 0===s.width&&(s.width=e),void 0===s.height&&(s.height=i),n&&void 0===s.depth&&(s.depth=l)}else{const{width:i,height:l,depth:h}=s;if(null==i||null==l)throw new Error("Width and height must be specified!");if(n&&null==h)throw new Error("Depth must be specified!");if(s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(a,p,s.hasMipmap,i,l,h),r.DEPTH24_STENCIL8&&p===r.DEPTH_STENCIL&&(p=r.DEPTH24_STENCIL8),x(t)){const o=t.levels,n=w(a,i,l,h),_=Math.min(n-1,o.length-1);e(this._context.gl2)?r.texParameteri(s.target,this._context.gl2.TEXTURE_MAX_LEVEL,_):s.hasMipmap=s.hasMipmap&&n===o.length;const m=p;if(!T(m))throw new Error("Attempting to use compressed data with an umcompressed format!");this._forEachMipmapLevel(((t,e,i,r)=>{const s=o[Math.min(t,o.length-1)];this._compressedTexImage(a,t,m,e,i,r,s)}),_)}else e(t)?(this._texImage(a,0,p,i,l,h,t),o(r),s.hasMipmap&&this.generateMipmap()):this._forEachMipmapLevel(((t,e,i,s)=>{this._texImage(a,t,p,e,i,s,null),o(r)}))}E._applySamplingMode(r,this._descriptor),E._applyWrapMode(r,this._descriptor),E._applyAnisotropicFilteringParameters(this._context,this._descriptor),o(r),this._context.bindTexture(l,E.TEXTURE_UNIT_FOR_UPDATES)}updateData(t,r,o,s,a,n,l=0){n||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const h=this._context.gl,p=this._descriptor,{pixelFormat:_,dataType:m,target:d,isImmutable:u}=p,c=p.internalFormat??this._deriveInternalFormat(_,m);if(u&&!this._wasImmutablyAllocated)throw new Error("Cannot update immutable texture before allocation!");const g=this._context.bindTexture(this,E.TEXTURE_UNIT_FOR_UPDATES,!0);if((r<0||o<0||s>p.width||a>p.height||r+s>p.width||o+a>p.height)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage(),l){if(i(this._context.gl2))return void console.error("Webgl2 must be enabled to use dataRowOffset!");h.pixelStorei(this._context.gl2.UNPACK_SKIP_ROWS,l)}if(f(n)?e(this._context.gl2)?this._context.gl2.texSubImage2D(d,t,r,o,s,a,_,m,n):h.texSubImage2D(d,t,r,o,_,m,n):x(n)?h.compressedTexSubImage2D(d,t,r,o,s,a,c,n.levels[t]):h.texSubImage2D(d,t,r,o,s,a,_,m,n),l){if(i(this._context.gl2))return void console.error("Webgl2 must be enabled to use dataRowOffset!");h.pixelStorei(this._context.gl2.UNPACK_SKIP_ROWS,0)}this._context.bindTexture(g,E.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(t,e,r,o,s,a,n,l){l||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const h=this._context.gl2;if(i(h))throw new Error("3D textures are not supported in WebGL1");const p=this._descriptor,{pixelFormat:_,dataType:m,isImmutable:d,target:u}=p,c=p.internalFormat??this._deriveInternalFormat(_,m);if(d&&!this._wasImmutablyAllocated)throw new Error("Cannot update immutable texture before allocation!");A(u)||console.warn("Attempting to set 3D texture data on a non-3D texture");const g=this._context.bindTexture(this,E.TEXTURE_UNIT_FOR_UPDATES);if(this._context.setActiveTexture(E.TEXTURE_UNIT_FOR_UPDATES),(e<0||r<0||o<0||s>p.width||a>p.height||n>p.depth||e+s>p.width||r+a>p.height||o+n>p.depth)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage(),x(l))l=l.levels[t],h.compressedTexSubImage3D(u,t,e,r,o,s,a,n,c,l);else{const i=l;h.texSubImage3D(u,t,e,r,o,s,a,n,_,m,i)}this._context.bindTexture(g,E.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const t=this._descriptor;if(!t.hasMipmap){if(this._wasImmutablyAllocated)throw new Error("Cannot add mipmaps to immutable texture after allocation");t.hasMipmap=!0,this._samplingModeDirty=!0,E._validateTexture(this._context,t)}t.samplingMode===n.LINEAR?(this._samplingModeDirty=!0,t.samplingMode=n.LINEAR_MIPMAP_NEAREST):t.samplingMode===n.NEAREST&&(this._samplingModeDirty=!0,t.samplingMode=n.NEAREST_MIPMAP_NEAREST);const e=this._context.bindTexture(this,E.TEXTURE_UNIT_FOR_UPDATES);this._context.setActiveTexture(E.TEXTURE_UNIT_FOR_UPDATES);this._context.gl.generateMipmap(t.target),this._context.bindTexture(e,E.TEXTURE_UNIT_FOR_UPDATES)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,E._validateTexture(this._context,this._descriptor),this._wrapModeDirty=!0)}applyChanges(){const t=this._context.gl,e=this._descriptor;this._samplingModeDirty&&(E._applySamplingMode(t,e),this._samplingModeDirty=!1),this._wrapModeDirty&&(E._applyWrapMode(t,e),this._wrapModeDirty=!1)}_deriveInternalFormat(t,e){if(this._context.type===s.WEBGL1)return t;switch(e){case p.FLOAT:switch(t){case _.RGBA:return m.RGBA32F;case _.RGB:return m.RGB32F;default:throw new Error("Unable to derive format")}case p.UNSIGNED_BYTE:switch(t){case _.RGBA:return m.RGBA8;case _.RGB:return m.RGB8}default:return t}}_configurePixelStorage(){const t=this._context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_texStorage(t,e,r,o,s,a){const n=this._context.gl2;if(i(n))throw new Error("Immutable textures are not supported in WebGL1");if(!g(e))throw new Error("Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const l=r?w(t,o,s,a):1;if(A(t)){if(null==a)throw new Error("Missing depth dimension for 3D texture upload");n.texStorage3D(t,l,e,o,s,a)}else n.texStorage2D(t,l,e,o,s);this._wasImmutablyAllocated=!0}_texImage(t,i,o,a,n,l,h){const p=this._context.gl;let _=null;const m=this._context.type===s.WEBGL2,d=A(t),{isImmutable:u,pixelFormat:c,dataType:E}=this._descriptor;if(m&&(_=p),m||!f(h))if(u){if(e(h)){const e=h;if(d){if(null==l)throw new Error("Missing depth dimension for 3D texture upload");_.texSubImage3D(t,i,0,0,0,a,n,l,c,E,e)}else p.texSubImage2D(t,i,0,0,a,n,c,E,e)}}else{const e=r(h);if(d){if(null==l)throw new Error("Missing depth dimension for 3D texture upload");_.texImage3D(t,i,o,a,n,l,0,c,E,e)}else p.texImage2D(t,i,o,a,n,0,c,E,e)}else p.texImage2D(t,0,o,c,E,h)}_compressedTexImage(t,i,r,o,a,n,l){const h=this._context.gl;let p=null;const _=A(t),m=this._descriptor.isImmutable;if(_){if(this._context.type!==s.WEBGL2)throw new Error("3D textures are not supported in WebGL1");p=h}if(m){if(e(l))if(_){if(null==n)throw new Error("Missing depth dimension for 3D texture upload");p.compressedTexSubImage3D(t,i,0,0,0,o,a,n,r,l)}else h.compressedTexSubImage2D(t,i,0,0,o,a,r,l)}else if(_){if(null==n)throw new Error("Missing depth dimension for 3D texture upload");p.compressedTexImage3D(t,i,r,o,a,n,0,l)}else h.compressedTexImage2D(t,i,r,o,a,0,l)}_forEachMipmapLevel(t,e=1/0){let{width:i,height:r,depth:o,hasMipmap:s,target:n}=this._descriptor;const l=n===a.TEXTURE_3D;if(null==i||null==r||l&&null==o)throw new Error("Missing texture dimensions for mipmap calculation");for(let a=0;t(a,i,r,o),s&&(1!==i||1!==r||l&&1!==o)&&!(a>=e);++a)i=Math.max(1,i>>1),r=Math.max(1,r>>1),l&&(o=Math.max(1,o>>1))}static _validateTexture(e,i){(null!=i.width&&i.width<0||null!=i.height&&i.height<0||null!=i.depth&&i.depth<0)&&console.error("Negative dimension parameters are not allowed!");const r=e.type===s.WEBGL2,o=null!=i.width&&t(i.width)&&null!=i.height&&t(i.height);r||!i.isImmutable&&!A(i.target)||console.error("Immutable and 3D-like textures are not supported in WebGL1!"),r||o||("number"==typeof i.wrapMode?i.wrapMode!==l.CLAMP_TO_EDGE&&console.error("Non-power-of-two textures must have a wrap mode of CLAMP_TO_EDGE!"):i.wrapMode.s===l.CLAMP_TO_EDGE&&i.wrapMode.t===l.CLAMP_TO_EDGE||console.error("Non-power-of-two textures must have a wrap mode of CLAMP_TO_EDGE!"),i.hasMipmap&&console.error("Mipmapping requires power-of-two textures!"))}static _applySamplingMode(t,e){let i=e.samplingMode,r=e.samplingMode;i===n.LINEAR_MIPMAP_NEAREST||i===n.LINEAR_MIPMAP_LINEAR?(i=n.LINEAR,e.hasMipmap||(r=n.LINEAR)):i!==n.NEAREST_MIPMAP_NEAREST&&i!==n.NEAREST_MIPMAP_LINEAR||(i=n.NEAREST,e.hasMipmap||(r=n.NEAREST)),t.texParameteri(e.target,t.TEXTURE_MAG_FILTER,i),t.texParameteri(e.target,t.TEXTURE_MIN_FILTER,r)}static _applyWrapMode(t,e){"number"==typeof e.wrapMode?(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode)):(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode.s),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode.t))}static _applyAnisotropicFilteringParameters(t,e){const i=t.capabilities.textureFilterAnisotropic;if(!i)return;t.gl.texParameterf(e.target,i.TEXTURE_MAX_ANISOTROPY,e.maxAnisotropy??1)}};function g(t){return t in m}function T(t){return t in d}function x(t){return e(t)&&"type"in t&&"compressed"===t.type}function M(t){return e(t)&&"byteLength"in t}function f(t){return e(t)&&!x(t)&&!M(t)}function A(t){return t===a.TEXTURE_3D||t===a.TEXTURE_2D_ARRAY}function w(t,e,i,r=1){let o=Math.max(e,i);return t===a.TEXTURE_3D&&(o=Math.max(o,r)),Math.round(Math.log(o)/Math.LN2)+1}E.TEXTURE_UNIT_FOR_UPDATES=0;export{E as Texture};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import a from"../../core/Error.js";import o from"../../core/Evented.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import s from"../../core/Logger.js";import{on as n,when as l,watch as d,whenOnce as c,initial as p}from"../../core/reactiveUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as w}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../layers/GraphicsLayer.js";import f from"../Attachments/AttachmentsViewModel.js";import m from"./CreateFeaturesWorkflow.js";import y from"./CreateWorkflow.js";import{workflowDeprecation as k}from"./deprecationUtils.js";import W from"./UpdateWorkflow.js";import _ from"../FeatureForm/FeatureFormViewModel.js";import g from"../FeatureTemplates/FeatureTemplatesViewModel.js";import v from"../Sketch/SketchViewModel.js";import b from"../Spinner/SpinnerViewModel.js";const C="esri.widgets.Editor.EditorViewModel",F=s.getLogger(C),E=["create","create-features","update"];function O(e,t,r){F.error(new a(e,t,r))}function A(e,t){return e?e.find((e=>e.layer===t)):void 0}let U=class extends(i(o.EventedAccessor)){constructor(e){super(e),this._sketchGraphicsLayer=new h({listMode:"hide",internal:!0}),this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new f({abilities:{editing:!0}}),this.featureFormViewModel=new _,this.featureTemplatesViewModel=new g,this.sketchViewModel=new v({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new b}initialize(){this.handles.add([n((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),n((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),l((()=>this.view?.map),(e=>{e.add(this._sketchGraphicsLayer)}),p),d((()=>this.editableItems.toArray()),(()=>{const{activeWorkflow:e}=this;if(this.refreshCreationTemplates(),!e)return;const{stepId:t}=e;"create"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdate||"awaiting-update-feature-candidate"===t&&!e.data.candidates.some((e=>{const t=this.editableItems.find((t=>t.layer===e.layer));return t&&t.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null}))}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(e){e&&0!==e.length||(e=[...E]),this._set("allowedWorkflows",e)}get canCreate(){return this.editableItems.some((e=>e.supports.includes("create")))}get canUpdate(){return this.editableItems.some((e=>e.supports.includes("update")||e.supports.includes("delete")||e.attachmentsOnUpdateEnabled))}get editableItems(){const e=this.view?.allLayerViews;if(!e)return new t;const r=this.view?.map?.editableLayers,a=new Set(r),o=r?.filter((e=>e.visible&&e.capabilities.operations.supportsAdd&&!e.capabilities.operations.supportsQuery)),i=e.filter((e=>a.has(e.layer))).map((({layer:e,suspended:t})=>this._getEditableItemFromLayer(e,t))).reverse();return o?.forEach((e=>i.push(this._getEditableItemFromLayer(e,!1)))),i}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(e){this.sketchViewModel.labelOptions=e}set layerInfos(e){e?.some((e=>{const t=!1!==e.allowAttachments;return t&&r(F,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),t})),this._set("layerInfos",e)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(e){this.sketchViewModel.snappingOptions=e}get state(){if(!this.get("view.ready")||0===this.editableItems.length)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this;return t?t.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(e){this.sketchViewModel.tooltipOptions=e}set view(e){this.sketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}async startCreateWorkflowAtFeatureTypeSelection(){if(k(F,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),!this.canCreate)return void O("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow();await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(e){if(k(F,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),!this.canCreate)return void O("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow("awaiting-feature-to-create");t.data.creationInfo=e,await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(!this.canCreate)throw new a("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const r=this._createCreateFeaturesWorkflow(e,t);await r.start(),this._set("activeWorkflow",r)}async startCreateWorkflowAtFeatureEdit(e){if(k(F,"startCreateWorkflowAtFeatureEdit"),!this.canCreate)return void O("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow("editing-new-feature");t.data.edits.feature=e,await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtFeatureSelection(){if(!this.canUpdate)return void O("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow();await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(!this.canUpdate)return void O("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtFeatureEdit(e){if(!this.canUpdate)return void O("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature");t.data.edits.feature=e,await t.start(),this._set("activeWorkflow",t)}async deleteFeatureFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?(await this._delete(e.data.edits.feature),await e.reset()):O("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warn:!0,...e})}refreshCreationTemplates(){const e=[];for(const{layer:t,supports:r}of this.editableItems)t.loaded&&r.includes("create")&&e.push(t);this.featureTemplatesViewModel.layers=e}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e&&e.warn&&O("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await t.cancel(e);await t.cancel(e),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(e,t){return m.create(this,e,t,((e,t,r)=>this._applyEdits(e,t,r)),((e,t)=>this._addAttachments(e,t)))}_createCreateWorkflow(e){return y.create(this,e,((e,t,r)=>this._applyEdits(e,t,r)))}_createUpdateWorkflow(e){return W.create(this,e,((e,t)=>this._applyEdits(e,t)))}async _delete(e){const t=e?.sourceLayer;t&&"applyEdits"in t&&await this._applyEdits(t,{deleteFeatures:[e]})}_addAttachments(e,t){const r=[];return t?.forEach((t=>r.push(this._addAttachment(e,t.feature,t.attachment)))),Promise.all(r)}async _addAttachment(e,t,r){let a=null;return await this._queueOperation((async()=>(a=await(e.addAttachment?.(t,r).catch((e=>{throw e?.error||e})))??null,a))),a}async _applyEdits(e,t,r){let a=null;return await this._queueOperation((async()=>{if(e.capabilities.operations.supportsQuery){const o=await this.view.whenLayerView(e);return a=await e.applyEdits(t,r),await c((()=>!o.updating)),a}return a=await e.applyEdits(t,r),a})),a}_queueOperation(e){this._activityQueue.push(e),this.notifyChange("syncing");const t=(e,t)=>{const r=t.indexOf(e);r>-1&&t.splice(r,1)};return e().then((e=>{if("error"in e&&e.error)throw e.error;if("addFeatureResults"in e){const{addFeatureResults:t,deleteFeatureResults:r,updateFeatureResults:a}=e,o=t.find((e=>!!e.error))||a.find((e=>!!e.error))||r.find((e=>!!e.error));if(o)throw o.error}return e})).catch((r=>{O("editing:operation-error","An error occurred.",{error:r});const a={error:r,retry:()=>(t(a,this.failures),this._queueOperation(e)),cancel:()=>{t(a,this.failures)}};this._set("failures",[...this.failures,a])})).then((()=>{t(e,this._activityQueue),this.notifyChange("syncing")}))}_getEditableItemFromLayer(e,t=!0){const{data:r,editing:{supportsGeometryUpdate:a},operations:o}=e.capabilities,i=A(this.layerInfos,e),s=this.allowedWorkflows,n=[];o.supportsAdd&&(s.includes("create")||s.includes("create-features"))&&(!i||!1!==i.enabled&&!1!==i.addEnabled)&&n.push("create");const l=o.supportsUpdate&&s.includes("update")&&(!i||!1!==i.enabled&&!1!==i.updateEnabled);l&&n.push("update"),o.supportsDelete&&s.includes("update")&&(!i||!1!==i.enabled&&!1!==i.deleteEnabled)&&n.push("delete");const d=l&&(!i||!1!==i.attributeUpdatesEnabled),c=l&&a&&(!i||!1!==i.geometryUpdatesEnabled),p=!!r.supportsAttachment&&(n.includes("create")||n.includes("update"))&&(!i||!1!==i.allowAttachments);return{layer:e,supports:t?[]:n,attributeUpdatesEnabled:d,geometryUpdatesEnabled:c,hasAttachments:p,attachmentsOnCreateEnabled:p&&(s.includes("create")||s.includes("create-features"))&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:p&&s.includes("update")&&(!i||!1!==i.attachmentsOnUpdateEnabled)}}};e([u({readOnly:!0})],U.prototype,"activeWorkflow",void 0),e([u({readOnly:!0})],U.prototype,"_activityQueue",void 0),e([u({value:[...E]})],U.prototype,"allowedWorkflows",null),e([u({readOnly:!0})],U.prototype,"canCreate",null),e([u({readOnly:!0})],U.prototype,"canUpdate",null),e([u({readOnly:!0})],U.prototype,"editableItems",null),e([u({readOnly:!0})],U.prototype,"failures",void 0),e([u()],U.prototype,"attachmentsViewModel",void 0),e([u()],U.prototype,"featureFormViewModel",void 0),e([u()],U.prototype,"featureTemplatesViewModel",void 0),e([u()],U.prototype,"labelOptions",null),e([u()],U.prototype,"layerInfos",null),e([u()],U.prototype,"sketchViewModel",void 0),e([u()],U.prototype,"snappingOptions",null),e([u()],U.prototype,"spinnerViewModel",void 0),e([u()],U.prototype,"state",null),e([u({readOnly:!0})],U.prototype,"syncing",null),e([u()],U.prototype,"tooltipOptions",null),e([u()],U.prototype,"view",null),U=e([w(C)],U);const M=U;export{M as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import a from"../../core/Error.js";import o from"../../core/Evented.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import s from"../../core/Logger.js";import{on as n,when as l,watch as d,whenOnce as p,initial as c}from"../../core/reactiveUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as w}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../layers/GraphicsLayer.js";import f from"../Attachments/AttachmentsViewModel.js";import m from"./CreateFeaturesWorkflow.js";import y from"./CreateWorkflow.js";import{workflowDeprecation as k}from"./deprecationUtils.js";import g from"./UpdateWorkflow.js";import W from"../FeatureForm/FeatureFormViewModel.js";import v from"../FeatureTemplates/FeatureTemplatesViewModel.js";import _ from"../Sketch/SketchViewModel.js";import b from"../Spinner/SpinnerViewModel.js";const C="esri.widgets.Editor.EditorViewModel",F=s.getLogger(C),O=["create","create-features","update"];function E(e,t,r){F.error(new a(e,t,r))}function A(e,t){return e?e.find((e=>e.layer===t)):void 0}let U=class extends(i(o.EventedAccessor)){constructor(e){super(e),this._sketchGraphicsLayer=new h({listMode:"hide",internal:!0}),this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new f({abilities:{editing:!0}}),this.featureFormViewModel=new W,this.featureTemplatesViewModel=new v,this.sketchViewModel=new _({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new b,this.pageStack=[]}initialize(){this.handles.add([n((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),n((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),l((()=>this.view?.map),(e=>{e.add(this._sketchGraphicsLayer)}),c),d((()=>this.editableItems.toArray()),(()=>{const{activeWorkflow:e}=this;if(this.refreshCreationTemplates(),!e)return;const{stepId:t}=e;"create"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdate||"awaiting-update-feature-candidate"===t&&!e.data.candidates.some((e=>{const t=this.editableItems.find((t=>t.layer===e.layer));return t&&t.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()})),d((()=>this.page),((e,t)=>{const r=this.pageStack.slice(),a=r.indexOf(e);-1===a&&t?r.push(t):r.splice(a),this.pageStack=r}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null}))}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(e){e&&0!==e.length||(e=[...O]),this._set("allowedWorkflows",e)}get canCreate(){return this.editableItems.some((e=>e.supports.includes("create")))}get canUpdate(){return this.editableItems.some((e=>e.supports.includes("update")||e.supports.includes("delete")||e.attachmentsOnUpdateEnabled))}get editableItems(){const e=this.view?.allLayerViews;if(!e)return new t;const r=this.view?.map?.editableLayers,a=new Set(r),o=r?.filter((e=>e.visible&&e.capabilities.operations.supportsAdd&&!e.capabilities.operations.supportsQuery)),i=e.filter((e=>a.has(e.layer))).map((({layer:e,suspended:t})=>this._getEditableItemFromLayer(e,t))).reverse();return o?.forEach((e=>i.push(this._getEditableItemFromLayer(e,!1)))),i}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(e){this.sketchViewModel.labelOptions=e}set layerInfos(e){e?.some((e=>{const t=!1!==e.allowAttachments;return t&&r(F,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),t})),this._set("layerInfos",e)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(e){this.sketchViewModel.snappingOptions=e}get state(){if(!this.get("view.ready")||0===this.editableItems.length)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this;return t?t.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(e){this.sketchViewModel.tooltipOptions=e}set view(e){this.sketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}get page(){const{activeWorkflow:e,state:t}=this;return"awaiting-feature-to-update"===t||"awaiting-feature-to-create"===t||e&&"create-features"===e.type&&e.pendingFeatures.length<1?"ready":t??"disabled"}async startCreateWorkflowAtFeatureTypeSelection(){if(k(F,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),!this.canCreate)return void E("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow();await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(e){if(k(F,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),!this.canCreate)return void E("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow("awaiting-feature-to-create");t.data.creationInfo=e,await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(!this.canCreate)throw new a("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const r=this._createCreateFeaturesWorkflow(e,t);await r.start(),this._set("activeWorkflow",r)}async startCreateWorkflowAtFeatureEdit(e){if(k(F,"startCreateWorkflowAtFeatureEdit"),!this.canCreate)return void E("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow("editing-new-feature");t.data.edits.feature=e,await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtFeatureSelection(){if(!this.canUpdate)return void E("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow();await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(!this.canUpdate)return void E("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtFeatureEdit(e){if(!this.canUpdate)return void E("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature");t.data.edits.feature=e,await t.start(),this._set("activeWorkflow",t)}async deleteFeatureFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?(await this._delete(e.data.edits.feature),await e.reset()):E("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warn:!0,...e})}refreshCreationTemplates(){const e=[];for(const{layer:t,supports:r}of this.editableItems)t.loaded&&r.includes("create")&&e.push(t);this.featureTemplatesViewModel.layers=e}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e&&e.warn&&E("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await t.cancel(e);await t.cancel(e),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(e,t){return m.create(this,e,t,((e,t,r)=>this._applyEdits(e,t,r)),((e,t)=>this._addAttachments(e,t)))}_createCreateWorkflow(e){return y.create(this,e,((e,t,r)=>this._applyEdits(e,t,r)))}_createUpdateWorkflow(e){return g.create(this,e,((e,t)=>this._applyEdits(e,t)))}async _delete(e){const t=e?.sourceLayer;t&&"applyEdits"in t&&await this._applyEdits(t,{deleteFeatures:[e]})}_addAttachments(e,t){const r=[];return t?.forEach((t=>r.push(this._addAttachment(e,t.feature,t.attachment)))),Promise.all(r)}async _addAttachment(e,t,r){let a=null;return await this._queueOperation((async()=>(a=await(e.addAttachment?.(t,r).catch((e=>{throw e?.error||e})))??null,a))),a}async _applyEdits(e,t,r){let a=null;return await this._queueOperation((async()=>{if(e.capabilities.operations.supportsQuery){const o=await this.view.whenLayerView(e);return a=await e.applyEdits(t,r),await p((()=>!o.updating)),a}return a=await e.applyEdits(t,r),a})),a}_queueOperation(e){this._activityQueue.push(e),this.notifyChange("syncing");const t=(e,t)=>{const r=t.indexOf(e);r>-1&&t.splice(r,1)};return e().then((e=>{if("error"in e&&e.error)throw e.error;if("addFeatureResults"in e){const{addFeatureResults:t,deleteFeatureResults:r,updateFeatureResults:a}=e,o=t.find((e=>!!e.error))||a.find((e=>!!e.error))||r.find((e=>!!e.error));if(o)throw o.error}return e})).catch((r=>{E("editing:operation-error","An error occurred.",{error:r});const a={error:r,retry:()=>(t(a,this.failures),this._queueOperation(e)),cancel:()=>{t(a,this.failures)}};this._set("failures",[...this.failures,a])})).then((()=>{t(e,this._activityQueue),this.notifyChange("syncing")}))}_getEditableItemFromLayer(e,t=!0){const{data:r,editing:{supportsGeometryUpdate:a},operations:o}=e.capabilities,i=A(this.layerInfos,e),s=this.allowedWorkflows,n=[];o.supportsAdd&&(s.includes("create")||s.includes("create-features"))&&(!i||!1!==i.enabled&&!1!==i.addEnabled)&&n.push("create");const l=o.supportsUpdate&&s.includes("update")&&(!i||!1!==i.enabled&&!1!==i.updateEnabled);l&&n.push("update"),o.supportsDelete&&s.includes("update")&&(!i||!1!==i.enabled&&!1!==i.deleteEnabled)&&n.push("delete");const d=l&&(!i||!1!==i.attributeUpdatesEnabled),p=l&&a&&(!i||!1!==i.geometryUpdatesEnabled),c=!!r.supportsAttachment&&(n.includes("create")||n.includes("update"))&&(!i||!1!==i.allowAttachments);return{layer:e,supports:t?[]:n,attributeUpdatesEnabled:d,geometryUpdatesEnabled:p,hasAttachments:c,attachmentsOnCreateEnabled:c&&(s.includes("create")||s.includes("create-features"))&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:c&&s.includes("update")&&(!i||!1!==i.attachmentsOnUpdateEnabled)}}};e([u({readOnly:!0})],U.prototype,"activeWorkflow",void 0),e([u({readOnly:!0})],U.prototype,"_activityQueue",void 0),e([u({value:[...O]})],U.prototype,"allowedWorkflows",null),e([u({readOnly:!0})],U.prototype,"canCreate",null),e([u({readOnly:!0})],U.prototype,"canUpdate",null),e([u({readOnly:!0})],U.prototype,"editableItems",null),e([u({readOnly:!0})],U.prototype,"failures",void 0),e([u()],U.prototype,"attachmentsViewModel",void 0),e([u()],U.prototype,"featureFormViewModel",void 0),e([u()],U.prototype,"featureTemplatesViewModel",void 0),e([u()],U.prototype,"labelOptions",null),e([u()],U.prototype,"layerInfos",null),e([u()],U.prototype,"sketchViewModel",void 0),e([u()],U.prototype,"snappingOptions",null),e([u()],U.prototype,"spinnerViewModel",void 0),e([u()],U.prototype,"state",null),e([u({readOnly:!0})],U.prototype,"syncing",null),e([u()],U.prototype,"tooltipOptions",null),e([u()],U.prototype,"view",null),e([u()],U.prototype,"pageStack",void 0),e([u()],U.prototype,"page",null),U=e([w(C)],U);const M=U;export{M as default};
package/widgets/Editor.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import s from"../core/Logger.js";import{isSome as a}from"../core/maybe.js";import{watch as i,on as n,when as o,initial as r}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as p}from"../layers/support/fieldUtils.js";import h from"./Attachments.js";import m from"./FeatureForm.js";import u from"./FeatureTemplates.js";import g from"./Spinner.js";import w from"./Widget.js";import{workflowDeprecation as f}from"./Editor/deprecationUtils.js";import v from"./Editor/EditorViewModel.js";import{ItemList as _}from"./FeatureTemplates/ItemList.js";import{Heading as k,incrementHeadingLevel as b}from"./support/Heading.js";import y from"./support/SnappingControls.js";import{accessibleHandler as C}from"./support/decorators/accessibleHandler.js";import{messageBundle as M}from"./support/decorators/messageBundle.js";import{vmEvent as F}from"./support/decorators/vmEvent.js";import{tsx as A}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import{substitute as W}from"../intl/substitute.js";const E="esri-editor",T=`${E}__panel`,S=`${E}__prompt`,L={base:`${E} esri-widget esri-widget--panel`,message:`${E}__message`,controls:`${E}__controls`,controlButton:`${E}__control-button`,progressBar:`${E}__progress-bar`,panelToolbar:`${T}-toolbar`,panelContent:`${T}-content`,panelContentMessage:`${T}-content__message`,panelContentSection:`${T}-content__section`,panelContentSectionGroup:`${T}-content__section__group`,snappingSettingsContainer:`${E}__snapping-settings`,updateFeaturesActionButtons:`${E}__update-features-action-buttons`,updateFeaturesActionButtonsButton:`${E}__update-features-action-buttons--button`,featureTemplatesContainer:`${E}__feature-templates-container`,promptContainer:S,promptHeader:`${S}__header`,promptHeading:`${S}__header__heading`,promptMessage:`${S}__message`,promptDivider:`${S}__divider`,promptActions:`${S}__actions`,warningIcon:"esri-icon-notice-triangle",widgetIcon:"esri-icon-edit",button:"esri-button",buttonDisabled:"esri-button--disabled",buttonSecondary:"esri-button--secondary",buttonTertiary:"esri-button--tertiary"},B={undoRedoButtons:!1,snappingControls:!0,snappingControlsElements:{header:!1,enabledToggle:!0,selfEnabledToggle:!0,featureEnabledToggle:!0,layerList:!0}};function j(e){e.focus()}const U="esri.widgets.Editor",P=s.getLogger(U);let V=class extends(t(w)){constructor(e,t){super(e,t),this._candidateCommitted=!1,this._featureForm=new m,this._stateStack=[],this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new u({enableListScroll:!1}),this._filterText="",this._prompt=null,this._spinner=new g,this.useDeprecatedCreateWorkflow=!1,this.headingLevel=4,this.iconClass=L.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new v,this.visibleElements={...B},this._setCandidateFeature=(e,t=!1)=>{if(this._candidateCommitted)return;const s=this._assertActiveUpdateWorkflow();s.data.edits.feature=e,t&&(s.next(),this._candidateCommitted=!0)},this._handleSave=this._handleSave.bind(this),this._handleBack=this._handleBack.bind(this),this._handleDone=this._handleDone.bind(this),this._handleDelete=this._handleDelete.bind(this),this._handleAdd=this._handleAdd.bind(this),this._handleEdit=this._handleEdit.bind(this),this._handleAttachmentAdd=this._handleAttachmentAdd.bind(this),this._handleAttachmentUpdate=this._handleAttachmentUpdate.bind(this),this._handleAttachmentDelete=this._handleAttachmentDelete.bind(this),this.EditorPanel=this.EditorPanel.bind(this)}initialize(){const{view:e,snappingOptions:t}=this;this._snappingControls=new y({layerListOpen:!1,snappingOptions:t,view:e,visibleElements:this.visibleElements.snappingControlsElements}),this.addHandles([i((()=>this.headingLevel),(e=>{this._featureForm.headingLevel=b(e),this._featureTemplates.headingLevel=b(e)}),r),this.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>{e&&(this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(e):this.startCreateFeaturesWorkflowAtFeatureCreation(e))})),i((()=>this.viewModel.state),((e,t)=>{const s=this._stateStack.indexOf(e);-1===s?this._stateStack.push(t):this._stateStack.splice(s)})),i((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?e.featureFormViewModel:null,this._attachments.viewModel=e?e.attachmentsViewModel:null,this._featureTemplates.viewModel=e?e.featureTemplatesViewModel:null,this._spinner.viewModel=e?e.spinnerViewModel:null}),r),i((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t&&t.ui.remove(this._spinner,s),e&&e.ui.add(this._spinner,{key:s,position:"manual"})}),r),n((()=>this.viewModel?.sketchViewModel),"create",(()=>{this.scheduleRender()})),n((()=>this.viewModel?.activeWorkflow),"cancel-request",(({controller:e})=>{const{messages:t,messagesCommon:s}=this;this._prompt={title:t.cancelRequestTitle,message:t.cancelRequestWarningMessage,context:"danger",actions:{primary:{label:s.form.yes,action:()=>{e.allow(),this._prompt=null}},secondary:{label:s.form.no,action:()=>(e.deny(),this._prompt=null)}}},this.scheduleRender()})),i((()=>this.supportingWidgetDefaults),(e=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch))}),r),i((()=>this._attachments?.error),(e=>{if(!e)return;const{messages:t,messagesCommon:s}=this;this._prompt={title:t.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:s.form.ok,action:()=>{this._prompt=null}}}}})),i((()=>this.viewModel?.failures),(e=>{if(!e)return;const{messages:t}=this,[{error:s,retry:a,cancel:i}]=e;this._prompt={title:t.errorWarningTitle,message:W(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{a(),this._prompt=null}},secondary:{label:t.ignore,action:()=>(i(),this._prompt=null)}}}})),i((()=>this.viewModel?.state),(e=>{if("awaiting-feature-to-update"===e&&(this._filterText=""),"awaiting-update-feature-candidate"===e&&(this._candidateCommitted=!1),"editing-existing-feature"===e){const{activeWorkflow:e}=this.viewModel;this._featureForm.disabled="update"===e?.type&&!1===e?.data.editableItem.attributeUpdatesEnabled}})),i((()=>[this._attachments?.selectedFile,this._attachments?.submitting]),(()=>this.scheduleRender())),i((()=>this.viewModel?.activeWorkflow),(()=>this._featureForm.disabled=!1)),o((()=>!this.viewModel?.activeWorkflow),(()=>this._featureTemplates.filterText="")),n((()=>this.view),"key-down",(e=>{"Escape"===e.key&&this.viewModel?.activeWorkflow&&this._handleBack()}))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._snappingControls.destroy()}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-flow.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-flow-item.js"),import("@esri/calcite-components/dist/components/calcite-scrim.js"),import("@esri/calcite-components/dist/components/calcite-accordion.js"),import("@esri/calcite-components/dist/components/calcite-accordion-item.js")])}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){this.viewModel.allowedWorkflows=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){const t={...B,...e,snappingControlsElements:{...B.snappingControlsElements,...e?.snappingControlsElements}};return a(this._snappingControls)&&(this._snappingControls.visibleElements=t.snappingControlsElements),t}startCreateWorkflowAtFeatureTypeSelection(){return f(P,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return f(P,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return f(P,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{_attachments:e,_prompt:t,viewModel:s}=this;if(!s)return A("div",{class:L.base});const{state:i}=s,n=a(t)?A("calcite-scrim",null,this.renderPrompt(t)):null;return A("div",{class:L.base},s.syncing||e.submitting?this.renderProgressBar():null,A("calcite-flow",null,this._stateStack.map((e=>this.renderState(e))),this.renderState(i)),n)}renderState(e){switch(e){case"disabled":break;case"ready":return this.renderLanding(e);case"awaiting-feature-creation-info":return this.renderTemplates(e);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this.renderAttributeEditing(e);case"awaiting-feature-to-update":return this.renderFeatureUpdating(e);case"awaiting-update-feature-candidate":return this.renderFeatureList(e);case"awaiting-feature-to-create":return this.renderFeatureCreation(e);case"adding-attachment":return this.renderAttachmentAdding(e);case"editing-attachment":return this.renderAttachmentEditing(e)}return A("div",null)}isPanelActive(e){return this.viewModel.state===e}renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:a,messagesCommon:i,_handleBack:n,_snappingControls:o,viewModel:{sketchViewModel:r}}=this;return A(t,{active:this.isPanelActive(e),key:"templates-panel",handleBack:n,heading:a.selectTemplate,headingLevel:s,messages:a,messagesCommon:i,sketchViewModel:r,snappingControls:o},A("div",{class:L.panelContent},this._featureTemplates.render()))}renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:a,messagesCommon:i,headingLevel:n,_handleBack:o,_snappingControls:r,viewModel:l}=this;if(!t)return null;const{sketchViewModel:d}=l,c=l.featureFormViewModel;if("create-features"===t.type&&t.pendingFeatures.length<1)return this.renderFeatureCreation(e);const p="update"===t.type&&!t.data.edits.modified||l.syncing||c.updating,h="update"===t.type?a.editFeature:a.createFeatures,m="update"===t.type?i.update:i.create,u="create-features"===t.type&&"create-new"===t.createFeatureState,g="update"===t.type&&t.data.editableItem.supports.includes("delete"),w=this._shouldShowAttachmentsForWorkflow(t),f=[{label:"create-features"===t.type&&t.numPendingFeatures>1?W(a.createFeaturesTemplate,{numFeatures:t.numPendingFeatures}):m,type:"primary",disabled:p,clickHandler:this._handleSave,width:g?"half":"full"}];g&&f.push({label:i.delete,type:"tertiary",clickHandler:this._handleDelete,disabled:l.syncing,appearance:"outline",width:"half"});const v=c.inputFields.every((e=>!e.visible))&&!w?this.renderMessage(W(a.clickToFinishTemplate,{button:m})):A("div",{class:L.panelContentSection},A("div",{class:L.panelContentSectionGroup},this._featureForm.render(),w?A("div",{key:"attachments"},A(k,{level:b(n)},a.attachments),this._attachments.render()):null));return A(s,{active:this.isPanelActive(e),key:"attribute-editing-panel",heading:h,headingLevel:n,handleBack:o,messages:a,messagesCommon:i,sketchViewModel:d,snappingControls:r},A("div",{class:L.panelContent},v,u?A("calcite-scrim",null):null),this.renderFooterActions(f))}renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_handleBack:a,headingLevel:i,messages:n,messagesCommon:o,_snappingControls:r,viewModel:{sketchViewModel:l}}=this,d=[{label:t.submitting?o.cancel:o.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentAdd,width:"full"}];return A(s,{active:this.isPanelActive(e),key:"attachment-adding-panel",heading:n.addAttachment,headingLevel:i,handleBack:a,messages:n,messagesCommon:o,sketchViewModel:l,snappingControls:r},A("div",{class:L.panelContent},t.render()),this.renderFooterActions(d))}renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_handleBack:a,headingLevel:i,messages:n,messagesCommon:o,_snappingControls:r,viewModel:{sketchViewModel:l}}=this,d=[{label:o.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentUpdate,width:"half"},{label:o.delete,disabled:t.submitting,type:"tertiary",clickHandler:this._handleAttachmentDelete,width:"half",appearance:"outline"}];return A(s,{active:this.isPanelActive(e),key:"attachment-editing-panel",heading:n.editAttachment,headingLevel:i,handleBack:a,messages:n,messagesCommon:o,sketchViewModel:l,snappingControls:r},A("div",{class:L.panelContent},t.render()),this.renderFooterActions(d))}renderFeatureUpdating(e){const{EditorPanel:t,_handleBack:s,headingLevel:a,messages:i,messagesCommon:n,_snappingControls:o,viewModel:{sketchViewModel:r}}=this;return A(t,{active:this.isPanelActive(e),key:"feature-updating-panel",heading:i.selectFeature,headingLevel:a,handleBack:s,messages:i,messagesCommon:n,sketchViewModel:r,snappingControls:o},A("div",{class:L.panelContent},this.renderMessage(i.selectFeatureToEdit)))}renderMessage(e){return A("div",{class:L.panelContentMessage},e)}renderFeatureCreation(e){const{EditorPanel:t,_handleBack:s,headingLevel:a,messages:i,messagesCommon:n,_snappingControls:o,viewModel:r}=this,{sketchViewModel:l}=r,d=r.sketchViewModel,c=this._assertActiveCreateWorkflow().data.creationInfo.layer,p=d.canUndo()&&d.createGraphic?d.createGraphic:null,h=this._getSketchingTip(c.geometryType,p);return A(t,{active:this.isPanelActive(e),key:"feature-creation-panel",heading:i.placeFeature,headingLevel:a,handleBack:s,messages:i,messagesCommon:n,sketchViewModel:l,snappingControls:o},A("div",{class:L.panelContent},this.renderMessage(h)))}renderFooterActions(e){return e.map((({type:e,disabled:t,class:s,...a},i)=>this.renderButton({class:this.classes(L.controlButton,"secondary"===e?L.buttonSecondary:"tertiary"===e?L.buttonTertiary:null,t?L.buttonDisabled:null,s),disabled:t??!1,key:i,slot:"footer-actions",...a})))}renderPrompt({title:e,message:t,context:s,actions:a}){const i=a.secondary,n=A("calcite-button",{appearance:"solid",kind:"danger"===s?"danger":"brand",width:i?"half":"full",onclick:a.primary.action,key:"prompt-primary-button",afterCreate:j},a.primary.label),o=i&&A("calcite-button",{appearance:"outline",kind:"danger"===s?"danger":"brand",width:"half",onclick:i.action,key:"prompt-secondary-button"},i.label);return A("div",{class:`${L.promptContainer}--${s}`},A("div",{class:L.promptHeader},A("calcite-icon",{icon:"exclamation-mark-triangle"}),A(k,{class:L.promptHeading,level:this.headingLevel},e)),A("div",{class:L.promptMessage},t),A("div",{class:L.promptDivider}),A("div",{class:L.promptActions},o,n))}renderProgressBar(){return A("div",{class:this.classes(L.progressBar),key:"progress-bar"})}renderButton(e){const{disabled:t,class:s,key:a,clickHandler:i,label:n,...o}=e;return A("calcite-button",{class:s,disabled:t,key:a,onclick:i,type:"button",...o},n)}renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:a,messagesCommon:i,_snappingControls:n,_featureTemplates:{viewModel:{numberOfFeatureTemplates:o}},viewModel:{canUpdate:r,sketchViewModel:l}}=this,d=!r&&0===o;return A(t,{active:this.isPanelActive(e),key:"landing-panel",heading:a.widgetLabel,headingLevel:s,messages:a,messagesCommon:i,sketchViewModel:l,snappingControls:n},A("div",{class:L.panelContent},r?A("div",{key:"edit-actions",class:L.panelContentSection},this.renderUpdateActions()):void 0,o>0?A("div",{key:"create-actions",class:L.panelContentSection},this.renderCreateActions()):void 0,d?A("div",{key:"no-content",class:L.panelContentMessage},a.noEditableLayers):void 0))}renderUpdateActions(){const{messages:e,messagesCommon:t}=this;return A("div",null,A(k,{level:b(this.headingLevel)},e.editFeatures),A("div",{class:L.updateFeaturesActionButtons},A("calcite-action",{text:t.select,textEnabled:!0,icon:"cursor",alignment:"start",class:L.updateFeaturesActionButtonsButton,onclick:this._handleEdit})))}renderCreateActions(){const{_featureTemplates:e,headingLevel:t,messages:s}=this;return A("div",null,A(k,{level:b(t)},s.createFeatures),A("div",{key:"templates",class:L.featureTemplatesContainer},e.render()))}renderFeatureList(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:n,messagesCommon:o,messagesTemplates:r,_snappingControls:l,viewModel:{editableItems:d,sketchViewModel:c}}=this,p=this._assertActiveUpdateWorkflow().data.candidates,h=W(n.multipleFeaturesTemplate,{total:p.length}),m=new Map;let u=0;p.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,a=this._filterText.toLowerCase(),{title:i}=s.layer,n=d.find((e=>e.layer===s.layer));if(!n)return null;const{attachmentsOnUpdateEnabled:o,supports:r}=n;return(r.includes("update")||r.includes("delete")||o)&&(!a||t?.toLowerCase().includes(a)||i?.toLowerCase().includes(a))})).filter(a).forEach((e=>{u++;const t=e.data.layer;m.has(t)?m.get(t)?.items.push(e):m.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})}));const g=d.toArray().map((({layer:e})=>m.get(e))).filter(a),w=u>10||this._filterText.length>0;return A(t,{active:this.isPanelActive(e),key:"feature-list",heading:h,headingLevel:i,handleBack:s,messages:n,messagesCommon:o,sketchViewModel:c,snappingControls:l},A("div",{class:L.panelContent},A("div",{class:L.panelContentSection},_({id:this.id,enableListScroll:!1,filterEnabled:w,filterText:this._filterText,items:g,messages:{filterPlaceholder:r.filterPlaceholder,noItems:r.noItems,noMatches:r.noMatches},onItemMouseEnter:({data:e})=>this._setCandidateFeature(e),onItemMouseLeave:()=>this._setCandidateFeature(null),onItemSelect:({data:e})=>this._setCandidateFeature(e,!0),onFilterChange:e=>this._filterText=e}))))}EditorPanel(e,...t){const{handleBack:s,heading:a,headingLevel:i,key:n,messages:o,messagesCommon:r,sketchViewModel:l,snappingControls:d}=e,{snappingControls:c,undoRedoButtons:p}=this.visibleElements;return A("calcite-flow-item",{bind:this,key:n,heading:a,headingLevel:i,closable:!1,onCalciteFlowItemBack:s??void 0},A("div",{class:L.panelToolbar},c?A("calcite-accordion",{class:L.snappingSettingsContainer,appearance:"transparent"},A("calcite-accordion-item",{heading:o?.snapping,iconStart:"vertex-gps"},d.render())):null,p?[A("calcite-button",{key:"undo-button",label:r.undo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"undo",scale:"l",disabled:!l.canUndo(),onclick:l.undo.bind(l)},r.undo),A("calcite-button",{key:"redo-button",label:r.redo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"redo",scale:"l",disabled:!l.canRedo(),onclick:l.redo.bind(l)},r.redo)]:null),t)}_getSketchingTip(e,t){const{messages:s}=this;if("point"===e)return s.tips.clickToAddPoint;if("polygon"===e||"polyline"===e){if(!t)return s.tips.clickToStart;const a=t.geometry,i="polygon"===e?"rings":"paths",[n]=a[i];return"polygon"===e&&n<4?s.tips.clickToContinue:s.tips.clickToContinueThenDoubleClickToEnd}return s.tips.clickToAddFeature}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:a}=e,i=p(t);return i&&a[i]&&`${a[i]}`||W(this.messages.untitledFeatureTemplate,{id:a[s]})}_handleDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.viewModel.deleteFeatureFromWorkflow(),this._prompt=null}},secondary:{label:e.keepFeature,action:()=>this._prompt=null}}}}_handleSave(){const{featureFormViewModel:e}=this.viewModel;e.submit(),!e.submittable||e.validateContingencyConstraints(e.getValues(),{includeIncompleteViolations:!0}).length>0||this.viewModel.activeWorkflow?.commit()}_handleAttachmentAdd(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.addFile(),e.previous()):this._attachments.addAttachment().then((()=>e.previous())))}_handleAttachmentUpdate(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.previous()):this._attachments.updateAttachment().then((()=>e.previous())))}_handleAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?(e.deleteFile(),t.previous(),this._prompt=null):e.deleteAttachment(e.viewModel.activeAttachmentInfo).then((()=>{t.previous(),this._prompt=null})))}},secondary:{label:e.keepAttachment,action:()=>this._prompt=null}}}}_handleAdd(){this.viewModel.canCreate}_handleEdit(){this.viewModel.canUpdate&&this.viewModel.startUpdateWorkflowAtFeatureSelection()}_handleDone(){this.viewModel.cancelWorkflow({force:!0})}async _handleBack(e){if(!this.activeWorkflow)return;const t=this.activeWorkflow;if(e?.stopPropagation(),this.viewModel.syncing)return;const s=()=>{t.hasPreviousStep?t.previous({cancelCurrentStep:!0}):this.viewModel.cancelWorkflow({force:!0})};if("create"===t.type||"create-features"===t.type&&t.numPendingFeatures>0||"editing-existing-feature"===t.stepId&&t.data.edits.modified){const{messages:e}=this,{type:a}=t,i="create"===a?e.cancelAddWarningMessage:e.cancelEditWarningMessage,n="create"===a?e.cancelAddTitle:e.cancelEditTitle,o="create"===a?e.continueAdding:e.continueEditing,r="create"===a?e.discardFeature:e.discardEdits;return this._prompt={title:n,message:i,context:"danger",actions:{primary:{label:r,action:()=>{this._prompt=null,s()}},secondary:{label:o,action:()=>this._prompt=null}}},void this.scheduleRender()}s()}_assertActiveCreateWorkflow(){const e=this.viewModel.activeWorkflow;if("create"===e?.type||"create-features"===e?.type)return e;throw new Error("Expected activeWorkflow to be instance of CreateWorkflow or CreateFeaturesWorkflow")}_assertActiveUpdateWorkflow(){const e=this.viewModel.activeWorkflow;if("update"===e?.type)return e;throw new Error("Expected activeWorkflow to be an UpdateWorkflow")}_shouldShowAttachmentsForWorkflow(e){if("update"===e.type)return e.data.editableItem.attachmentsOnUpdateEnabled;const t=e.data.creationInfo;if(t){const{layerInfos:e}=this,{layer:s}=t,a=this.viewModel.editableItems.find((e=>e.layer===s));if(a)return a.attachmentsOnCreateEnabled;const{data:i}=s.capabilities,n=e&&e.find((e=>e.layer===s));return"supportsAttachment"in i&&i.supportsAttachment&&(!n||!1!==n.allowAttachments&&!1!==n.attachmentsOnUpdateEnabled)}return!1}};e([l()],V.prototype,"_attachments",void 0),e([l({readOnly:!0})],V.prototype,"activeWorkflow",null),e([l()],V.prototype,"allowedWorkflows",null),e([l()],V.prototype,"useDeprecatedCreateWorkflow",void 0),e([l()],V.prototype,"headingLevel",void 0),e([l()],V.prototype,"iconClass",void 0),e([l()],V.prototype,"label",null),e([l()],V.prototype,"labelOptions",null),e([l()],V.prototype,"layerInfos",null),e([l(),M("esri/widgets/Editor/t9n/Editor")],V.prototype,"messages",void 0),e([l(),M("esri/t9n/common")],V.prototype,"messagesCommon",void 0),e([l(),M("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],V.prototype,"messagesTemplates",void 0),e([l()],V.prototype,"snappingOptions",null),e([l()],V.prototype,"tooltipOptions",null),e([l()],V.prototype,"supportingWidgetDefaults",void 0),e([l()],V.prototype,"view",null),e([l(),F(["workflow-cancel","workflow-commit"])],V.prototype,"viewModel",void 0),e([l()],V.prototype,"visibleElements",void 0),e([d("visibleElements")],V.prototype,"castVisibleElements",null),e([C()],V.prototype,"_handleDelete",null),e([C()],V.prototype,"_handleAttachmentAdd",null),e([C()],V.prototype,"_handleAttachmentUpdate",null),e([C()],V.prototype,"_handleAttachmentDelete",null),e([C()],V.prototype,"_handleAdd",null),e([C()],V.prototype,"_handleEdit",null),e([C()],V.prototype,"_handleDone",null),V=e([c(U)],V);const x=V;export{x as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import s from"../core/Logger.js";import{isSome as a}from"../core/maybe.js";import{createDeferred as i}from"../core/promiseUtils.js";import{watch as n,on as o,initial as r,sync as l}from"../core/reactiveUtils.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import{cast as c}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import h from"./Attachments.js";import u from"./FeatureForm.js";import g from"./FeatureTemplates.js";import _ from"./Spinner.js";import w from"./Widget.js";import{workflowDeprecation as f}from"./Editor/deprecationUtils.js";import v from"./Editor/EditorViewModel.js";import{ItemList as b}from"./FeatureTemplates/ItemList.js";import{Heading as y,incrementHeadingLevel as k}from"./support/Heading.js";import C from"./support/SnappingControls.js";import{accessibleHandler as M}from"./support/decorators/accessibleHandler.js";import{messageBundle as A}from"./support/decorators/messageBundle.js";import{vmEvent as F}from"./support/decorators/vmEvent.js";import{tsx as W}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import{substitute as E}from"../intl/substitute.js";const T="esri-editor",S=`${T}__panel`,P=`${T}__prompt`,L={base:`${T} esri-widget esri-widget--panel`,message:`${T}__message`,controls:`${T}__controls`,controlButton:`${T}__control-button`,progressBar:`${T}__progress-bar`,panelToolbar:`${S}-toolbar`,panelContent:`${S}-content`,panelContentMessage:`${S}-content__message`,panelContentSection:`${S}-content__section`,panelContentSectionGroup:`${S}-content__section__group`,snappingSettingsContainer:`${T}__snapping-settings`,updateFeaturesActionButtons:`${T}__update-features-action-buttons`,updateFeaturesActionButtonsButton:`${T}__update-features-action-buttons--button`,featureTemplatesContainer:`${T}__feature-templates-container`,promptContainer:P,promptHeader:`${P}__header`,promptHeading:`${P}__header__heading`,promptMessage:`${P}__message`,promptDivider:`${P}__divider`,promptActions:`${P}__actions`,warningIcon:"esri-icon-notice-triangle",widgetIcon:"esri-icon-edit",button:"esri-button",buttonDisabled:"esri-button--disabled",buttonSecondary:"esri-button--secondary",buttonTertiary:"esri-button--tertiary"},j={undoRedoButtons:!1,snappingControls:!0,snappingControlsElements:{header:!1,enabledToggle:!0,selfEnabledToggle:!0,featureEnabledToggle:!0,layerList:!0}};function B(e){e.focus()}const U="esri.widgets.Editor",I=s.getLogger(U);let V=class extends(t(w)){constructor(e,t){super(e,t),this._candidateCommitted=!1,this._featureForm=new u,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new g({enableListScroll:!1}),this._filterText="",this._prompt=null,this._spinner=new _,this.useDeprecatedCreateWorkflow=!1,this.headingLevel=4,this.iconClass=L.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new v,this.visibleElements={...j},this._setCandidateFeature=(e,t=!1)=>{if(this._candidateCommitted)return;const s=this._assertActiveUpdateWorkflow();s.data.edits.feature=e,t&&(s.next(),this._candidateCommitted=!0)},this._clearPrompt=()=>{this._prompt=null},this._handleSave=this._handleSave.bind(this),this._handleBack=this._handleBack.bind(this),this._handleDelete=this._handleDelete.bind(this),this._handleAdd=this._handleAdd.bind(this),this._handleEdit=this._handleEdit.bind(this),this._handleAttachmentAdd=this._handleAttachmentAdd.bind(this),this._handleAttachmentUpdate=this._handleAttachmentUpdate.bind(this),this._handleAttachmentDelete=this._handleAttachmentDelete.bind(this),this.EditorPanel=this.EditorPanel.bind(this)}initialize(){const{view:e,snappingOptions:t}=this;this._snappingControls=new C({layerListOpen:!1,snappingOptions:t,view:e,visibleElements:this.visibleElements.snappingControlsElements}),this.addHandles([n((()=>k(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),r),o((()=>this.viewModel.featureTemplatesViewModel),"select",(async({item:e,oldItem:t})=>{await this.viewModel.cancelWorkflow(),e&&e.id!==t?.id&&(this._featureTemplates.selectNoEmit(e),this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(e):this.startCreateFeaturesWorkflowAtFeatureCreation(e))})),n((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?.featureFormViewModel??null,this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null}),r),n((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"})}),r),o((()=>this.viewModel?.sketchViewModel),"create",(()=>{this.scheduleRender()})),o((()=>this.viewModel?.activeWorkflow),"cancel-request",(({controller:e})=>{const{messages:t,messagesCommon:s}=this;this._prompt={title:t.cancelRequestTitle,message:t.cancelRequestWarningMessage,context:"danger",actions:{primary:{label:s.form.yes,action:()=>{e.allow(),this._clearPrompt()}},secondary:{label:s.form.no,action:()=>{e.deny(),this._clearPrompt()}}}},this.scheduleRender()})),n((()=>this.supportingWidgetDefaults),(e=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch))}),r),n((()=>this._attachments?.error),(e=>{if(!e)return;const{messages:t,messagesCommon:s}=this;this._prompt={title:t.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:s.form.ok,action:this._clearPrompt}}}})),n((()=>this.viewModel?.failures),(e=>{if(!e)return;const{messages:t}=this,[{error:s,retry:a,cancel:i}]=e;this._prompt={title:t.errorWarningTitle,message:E(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{a(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{i(),this._clearPrompt()}}}}})),n((()=>this.viewModel?.state),(e=>{if("awaiting-feature-to-update"===e&&(this._featureTemplates.selectNoEmit(null),this._featureTemplates.filterText="",this._filterText=""),"awaiting-update-feature-candidate"===e&&(this._candidateCommitted=!1),"editing-existing-feature"===e){const{activeWorkflow:e}=this.viewModel;this._featureForm.disabled="update"===e?.type&&!1===e?.data.editableItem.attributeUpdatesEnabled}}),l),n((()=>[this._attachments?.selectedFile,this._attachments?.submitting]),(()=>this.scheduleRender())),n((()=>this.viewModel?.activeWorkflow),(e=>{this._featureForm.disabled=!1,e||(this._featureTemplates.selectNoEmit(null),this._featureTemplates.filterText="")}),l),o((()=>this.view),"key-down",(e=>{"Escape"===e.key&&this._handleBack()}))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._snappingControls.destroy()}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-accordion-item.js"),import("@esri/calcite-components/dist/components/calcite-accordion.js"),import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-flow-item.js"),import("@esri/calcite-components/dist/components/calcite-flow-item.js"),import("@esri/calcite-components/dist/components/calcite-flow.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-list.js"),import("@esri/calcite-components/dist/components/calcite-list-item.js"),import("@esri/calcite-components/dist/components/calcite-scrim.js")])}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){this.viewModel.allowedWorkflows=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){const t={...j,...e,snappingControlsElements:{...j.snappingControlsElements,...e?.snappingControlsElements}};return a(this._snappingControls)&&(this._snappingControls.visibleElements=t.snappingControlsElements),t}startCreateWorkflowAtFeatureTypeSelection(){return f(I,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return f(I,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return f(I,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{_attachments:e,_prompt:t,viewModel:s}=this;if(!s)return W("div",{class:L.base});const i=a(t)?W("calcite-scrim",null,this._renderPrompt(t)):null,{state:n}=s;return W("div",{class:L.base},s.syncing||e.submitting?this._renderProgressBar():null,W("calcite-flow",null,s.pageStack.map((e=>this._renderPage(e,n))),this._renderPage(s.page,n)),i)}_renderPage(e,t){switch(e){case"disabled":break;case"ready":return this._renderLanding(t);case"awaiting-feature-creation-info":return this._renderTemplates(t);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this._renderAttributeEditing(t);case"awaiting-update-feature-candidate":return this._renderFeatureList(t);case"adding-attachment":return this._renderAttachmentAdding(t);case"editing-attachment":return this._renderAttachmentEditing(t)}return W("div",null)}_isPanelActive(e){return this.viewModel.state===e}_renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:a,messagesCommon:i,_handleBack:n,_snappingControls:o,viewModel:{sketchViewModel:r}}=this;return W(t,{active:this._isPanelActive(e),key:"templates-panel",handleBack:n,heading:a.selectTemplate,headingLevel:s,messages:a,messagesCommon:i,sketchViewModel:r,snappingControls:o},W("div",{class:L.panelContent},this._featureTemplates.render()))}_renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:a,messagesCommon:i,headingLevel:n,_handleBack:o,_snappingControls:r,viewModel:l}=this;if(!t)return null;const d=t.type,c=l.featureFormViewModel,p="update"===d&&!t.data.edits.modified||l.syncing||c.updating,m="update"===d?a.editFeature:a.createFeatures,h="update"===d?i.update:i.create,u="create-features"===d&&"create-new"===t.createFeatureState,g=[{clickHandler:this._handleSave,disabled:p,label:"create-features"===d&&t.numPendingFeatures>1?E(a.createFeaturesTemplate,{numFeatures:t.numPendingFeatures}):h,type:"primary",width:"full"}];this._shouldShowDeleteButton&&g.push({appearance:"solid",clickHandler:this._handleDelete,disabled:l.syncing,kind:"danger",label:i.delete,type:"primary",width:"full"});const _=this._shouldShowAttachments,w=c.inputFields.every((e=>!e.visible))&&!_?this._renderMessage(E(a.clickToFinishTemplate,{button:h})):W("div",{key:"panel-content-section",class:L.panelContentSection},W("div",{class:L.panelContentSectionGroup},this._featureForm.render(),_?W("div",{key:"attachments"},W(y,{level:k(n)},a.attachments),this._attachments.render()):null));return W(s,{active:this._isPanelActive(e),key:"attribute-editing-panel",heading:m,headingLevel:n,handleBack:o,messages:a,messagesCommon:i,sketchViewModel:l.sketchViewModel,snappingControls:r},W("div",{key:"panel-content",class:L.panelContent},w,u?W("calcite-scrim",null):null),this._renderFooterActions(g))}_renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_handleBack:a,headingLevel:i,messages:n,messagesCommon:o,_snappingControls:r,viewModel:{sketchViewModel:l}}=this,d=[{label:t.submitting?o.cancel:o.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentAdd,width:"full"}];return W(s,{active:this._isPanelActive(e),key:"attachment-adding-panel",heading:n.addAttachment,headingLevel:i,handleBack:a,messages:n,messagesCommon:o,sketchViewModel:l,snappingControls:r},W("div",{class:L.panelContent},t.render()),this._renderFooterActions(d))}_renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_handleBack:a,headingLevel:i,messages:n,messagesCommon:o,_snappingControls:r,viewModel:{sketchViewModel:l}}=this,d=[{label:o.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentUpdate,width:"half"},{label:o.delete,disabled:t.submitting,type:"tertiary",clickHandler:this._handleAttachmentDelete,width:"half",appearance:"outline"}];return W(s,{active:this._isPanelActive(e),key:"attachment-editing-panel",heading:n.editAttachment,headingLevel:i,handleBack:a,messages:n,messagesCommon:o,sketchViewModel:l,snappingControls:r},W("div",{class:L.panelContent},t.render()),this._renderFooterActions(d))}_renderMessage(e){return W("div",{key:"panel-content-message",class:L.panelContentMessage},e)}_renderFooterActions(e){return e.filter(a).map((({type:e,disabled:t,class:s,...a},i)=>$({class:this.classes(s,L.controlButton,{[L.buttonSecondary]:"secondary"===e,[L.buttonTertiary]:"tertiary"===e,[L.buttonDisabled]:!!t}),key:`action-${i}`,slot:"footer-actions",disabled:t,...a})))}_renderPrompt({title:e,message:t,context:s,actions:a}){const i=a.secondary,n=W("calcite-button",{appearance:"solid",kind:"danger"===s?"danger":"brand",width:i?"half":"full",onclick:a.primary.action,key:"prompt-primary-button",afterCreate:B},a.primary.label),o=i&&W("calcite-button",{appearance:"outline",kind:"danger"===s?"danger":"brand",width:"half",onclick:i.action,key:"prompt-secondary-button"},i.label);return W("div",{class:`${L.promptContainer}--${s}`},W("div",{class:L.promptHeader},W("calcite-icon",{icon:"exclamation-mark-triangle"}),W(y,{class:L.promptHeading,level:this.headingLevel},e)),W("div",{class:L.promptMessage},t),W("div",{class:L.promptDivider}),W("div",{class:L.promptActions},o,n))}_renderProgressBar(){return W("div",{class:this.classes(L.progressBar),key:"progress-bar"})}_renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:a,messagesCommon:i,_snappingControls:n,_featureTemplates:{viewModel:{numberOfFeatureTemplates:o}},viewModel:{canUpdate:r,sketchViewModel:l}}=this,d=!r&&0===o;return W(t,{active:this._isPanelActive(e),key:"landing-panel",heading:a.widgetLabel,headingLevel:s,messages:a,messagesCommon:i,sketchViewModel:l,snappingControls:n},W("div",{class:L.panelContent},r?W("div",{key:"edit-actions",class:L.panelContentSection},this._renderUpdateActions(e)):void 0,o>0?W("div",{key:"create-actions",class:L.panelContentSection},this._renderCreateActions()):void 0,d?W("div",{key:"no-content",class:L.panelContentMessage},a.noEditableLayers):void 0))}_renderUpdateActions(e){const{messages:t,messagesCommon:s}=this;return W("div",{key:"update-actions"},W(y,{level:k(this.headingLevel)},t.editFeatures),W("calcite-list",{selectionMode:"single",selectionAppearance:"border"},W("calcite-list-item",{selected:"awaiting-feature-to-update"===e,label:s.select,onCalciteListItemSelect:this._handleEdit},W("calcite-icon",{icon:"cursor",slot:"content-start"}))))}_renderCreateActions(){const{_featureTemplates:e,headingLevel:t,messages:s}=this;return W("div",{key:"create-actions"},W(y,{level:k(t)},s.createFeatures),W("div",{key:"templates",class:L.featureTemplatesContainer},e.render()))}_renderFeatureList(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:n,messagesCommon:o,messagesTemplates:r,_snappingControls:l,viewModel:{editableItems:d,sketchViewModel:c}}=this,p=this._assertActiveUpdateWorkflow().data.candidates,m=E(n.multipleFeaturesTemplate,{total:p.length}),h=new Map;let u=0;p.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,a=this._filterText.toLowerCase(),{title:i}=s.layer,n=d.find((e=>e.layer===s.layer));if(!n)return null;const{attachmentsOnUpdateEnabled:o,supports:r}=n;return(r.includes("update")||r.includes("delete")||o)&&(!a||t?.toLowerCase().includes(a)||i?.toLowerCase().includes(a))})).filter(a).forEach((e=>{u++;const t=e.data.layer;h.has(t)?h.get(t)?.items.push(e):h.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})}));const g=d.toArray().map((({layer:e})=>h.get(e))).filter(a),_=u>10||this._filterText.length>0;return W(t,{active:this._isPanelActive(e),key:"feature-list",heading:m,headingLevel:i,handleBack:s,messages:n,messagesCommon:o,sketchViewModel:c,snappingControls:l},W("div",{class:L.panelContent},W("div",{class:L.panelContentSection},b({id:this.id,enableListScroll:!1,filterEnabled:_,filterText:this._filterText,items:g,messages:{filterPlaceholder:r.filterPlaceholder,noItems:r.noItems,noMatches:r.noMatches},onItemMouseEnter:e=>this._setCandidateFeature(e.data),onItemMouseLeave:()=>this._setCandidateFeature(null),onItemSelect:e=>this._setCandidateFeature(e.data,!0),onFilterChange:e=>this._filterText=e}))))}EditorPanel(e,...t){const{handleBack:s,heading:a,headingLevel:i,key:n,messages:o,messagesCommon:r,sketchViewModel:l,snappingControls:d}=e,{snappingControls:c,undoRedoButtons:p}=this.visibleElements;return W("calcite-flow-item",{bind:this,key:n,heading:a,headingLevel:i,closable:!1,onCalciteFlowItemBack:s??void 0},W("div",{key:"panel-toolbar",class:L.panelToolbar},c?W("calcite-accordion",{class:L.snappingSettingsContainer,appearance:"transparent"},W("calcite-accordion-item",{heading:o?.snapping,iconStart:"vertex-gps"},d.render())):null,p?[W("calcite-button",{key:"undo-button",label:r.undo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"undo",scale:"l",disabled:!l.canUndo(),onclick:l.undo.bind(l)},r.undo),W("calcite-button",{key:"redo-button",label:r.redo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"redo",scale:"l",disabled:!l.canRedo(),onclick:l.redo.bind(l)},r.redo)]:null),...t)}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:a}=e,i=m(t);return i&&a[i]&&`${a[i]}`||E(this.messages.untitledFeatureTemplate,{id:a[s]})}_handleDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.viewModel.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}}}_handleSave(){const{featureFormViewModel:e}=this.viewModel;e.submit(),!e.submittable||e.validateContingencyConstraints(e.getValues(),{includeIncompleteViolations:!0}).length>0||this.viewModel.activeWorkflow?.commit()}_handleAttachmentAdd(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.addFile(),e.previous()):this._attachments.addAttachment().then((()=>e.previous())))}_handleAttachmentUpdate(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.previous()):this._attachments.updateAttachment().then((()=>e.previous())))}_handleAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?(e.deleteFile(),t.previous(),this._clearPrompt()):e.deleteAttachment(e.viewModel.activeAttachmentInfo).then((()=>{t.previous(),this._clearPrompt()})))}},secondary:{label:e.keepAttachment,action:this._clearPrompt}}}}_handleAdd(){this.viewModel.canCreate}async _handleEdit(e){const{viewModel:t}=this;if(!t.canUpdate)return;e.target.selected?await t.startUpdateWorkflowAtFeatureSelection():t.cancelWorkflow()}async _handleBack(e){e?.stopPropagation();const t=this.activeWorkflow;if(!t||!this._canGoBack)return;const s=i(),a=async()=>{await(t.hasPreviousStep?t.previous({cancelCurrentStep:!0}):this.viewModel.cancelWorkflow({force:!0})),s.resolve()},n="create"===t.type;if(n||"create-features"===t.type&&t.numPendingFeatures>0||"editing-existing-feature"===t.stepId&&t.data.edits.modified){const{messages:e}=this;this._prompt={title:n?e.cancelAddTitle:e.cancelEditTitle,message:n?e.cancelAddWarningMessage:e.cancelEditWarningMessage,context:"danger",actions:{primary:{label:n?e.discardFeature:e.discardEdits,action:()=>{this._clearPrompt(),a()}},secondary:{label:n?e.continueAdding:e.continueEditing,action:this._clearPrompt}}}}else a();return s.promise}_assertActiveUpdateWorkflow(){const e=this.viewModel.activeWorkflow;if("update"===e?.type)return e;throw new Error("Expected activeWorkflow to be an UpdateWorkflow")}get _canGoBack(){return a(this.activeWorkflow)&&!this.viewModel.syncing}get _shouldShowDeleteButton(){const{activeWorkflow:e}=this;return!!e&&"update"===e.type&&e.data.editableItem.supports.includes("delete")}get _shouldShowAttachments(){const e=this.activeWorkflow;if(!e)return!1;if("update"===e.type)return e.data.editableItem.attachmentsOnUpdateEnabled;const t=e.data.creationInfo;if(!t)return!1;const{layerInfos:s}=this,{layer:a}=t,i=this.viewModel.editableItems.find((e=>e.layer===a));if(i)return i.attachmentsOnCreateEnabled;const{data:n}=a.capabilities,o=s&&s.find((e=>e.layer===a));return"supportsAttachment"in n&&n.supportsAttachment&&(!o||!1!==o.allowAttachments&&!1!==o.attachmentsOnUpdateEnabled)}};function $(e){const{disabled:t,class:s,key:a,clickHandler:i,label:n,...o}=e;return W("calcite-button",{class:s,disabled:t??!1,key:a,onclick:i,type:"button",...o},n)}e([d()],V.prototype,"_attachments",void 0),e([d({readOnly:!0})],V.prototype,"activeWorkflow",null),e([d()],V.prototype,"allowedWorkflows",null),e([d()],V.prototype,"useDeprecatedCreateWorkflow",void 0),e([d()],V.prototype,"headingLevel",void 0),e([d()],V.prototype,"iconClass",void 0),e([d()],V.prototype,"label",null),e([d()],V.prototype,"labelOptions",null),e([d()],V.prototype,"layerInfos",null),e([d(),A("esri/widgets/Editor/t9n/Editor")],V.prototype,"messages",void 0),e([d(),A("esri/t9n/common")],V.prototype,"messagesCommon",void 0),e([d(),A("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],V.prototype,"messagesTemplates",void 0),e([d()],V.prototype,"snappingOptions",null),e([d()],V.prototype,"tooltipOptions",null),e([d()],V.prototype,"supportingWidgetDefaults",void 0),e([d()],V.prototype,"view",null),e([d(),F(["workflow-cancel","workflow-commit"])],V.prototype,"viewModel",void 0),e([d()],V.prototype,"visibleElements",void 0),e([c("visibleElements")],V.prototype,"castVisibleElements",null),e([M()],V.prototype,"_handleDelete",null),e([M()],V.prototype,"_handleAttachmentAdd",null),e([M()],V.prototype,"_handleAttachmentUpdate",null),e([M()],V.prototype,"_handleAttachmentDelete",null),e([M()],V.prototype,"_handleAdd",null),e([M()],V.prototype,"_handleEdit",null),e([M()],V.prototype,"_handleBack",null),e([d()],V.prototype,"_canGoBack",null),e([d()],V.prototype,"_shouldShowDeleteButton",null),e([d()],V.prototype,"_shouldShowAttachments",null),V=e([p(U)],V);const x=V;export{x as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Evented.js";import{HandleOwnerMixin as r}from"../../core/HandleOwner.js";import{isSome as s,isNone as o}from"../../core/maybe.js";import l from"../../core/ObjectPool.js";import{when as a}from"../../core/reactiveUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import p from"./TemplateItem.js";import u from"./TemplateItemGroup.js";var m;const y=({layer:e})=>({key:e,label:e.title??""}),c=({layer:e})=>({key:e.geometryType,label:e.geometryType});let h=m=class extends(r(t.EventedAccessor)){constructor(e){super(e),this._itemPool=new l(p),this._groupPool=new l(u),this.filterFunction=null,this.selectedItem=null}initialize(){this._get("groupBy")||(this.groupBy="layer")}destroy(){this._templateToLayer.clear()}get _templateToLayer(){const e=new Map;for(const[t,r]of this._featureTemplatesByLayer)for(const s of r)e.set(s,t);return e}set groupBy(e){if(this._set("groupBy",e),"function"!=typeof e)switch(e){case"layer":this._groupByFunction=y;break;case"geometry":this._groupByFunction=c;break;default:this._groupByFunction=null}else this._groupByFunction=t=>this._ensureGroupByObject(e(t))}set layers(e){const t="layers";if(this.handles.remove(t),e){const t=()=>this.notifyChange("state");this.handles.add(e.map((e=>a((()=>e.loadStatus),t))),"layers")}this._set("layers",e)}get layers(){return this._get("layers")}get state(){const{layers:e}=this;return e&&0!==e.length?e.some((e=>"loading"===e.loadStatus||"not-loaded"===e.loadStatus))?"loading":"ready":"disabled"}get _featureTemplatesByLayer(){if(!this.layers)return new Map;const e=[];for(const t of this.layers){const r="templates"in t&&t.templates?t.templates:[],s="types"in t&&t.types?f(t.types):[];e.push([t,[...r,...s]])}return new Map(e)}get numberOfFeatureTemplates(){return Array.from(this._featureTemplatesByLayer.values()).reduce(((e,t)=>e+t.length),0)}get items(){if(0===this.numberOfFeatureTemplates)return this._releasePreviousItems(),[];const e=this._featureTemplatesByLayer,t=[],r=s(this.filterFunction)?this.filterFunction:m._nullFilterFunction;for(const[s,o]of e)if(s.loaded){const{capabilities:{operations:{supportsEditing:e,supportsAdd:l}}}=s;if(e&&l)for(const a of o)t.push({layer:s,template:a,matchesFilter:r({label:a.name})})}if(o(this._groupByFunction)){const e=t.filter((({matchesFilter:e})=>e)).map((({template:e,layer:t})=>this._createItem(e,t)));return this._releasePreviousItems(),e}const l=new Map;for(const o of t){const{template:e,layer:t}=o,r=this._groupByFunction({template:e,layer:t}),{key:a,label:i}=s(r.key)?r:m.nullGroupBy;l.has(a)||l.set(a,{label:i,templateItemInfos:[]}),l.get(a)?.templateItemInfos.push(o)}const a=[];for(const s of l.values()){const{label:e,templateItemInfos:t}=s,o=t.filter((({matchesFilter:e})=>e)),l=r({label:e})?t:t.length>0?o:[];if(l.length>0){const t=l.map((({template:e,layer:t})=>this._createItem(e,t)));a.push(this._createGroup(e,t))}}return 1===a.length&&a[0].label===m.nullGroupBy.label?(this._releasePreviousItems(),a[0].items):(this._releasePreviousItems(),a)}refresh(){this.notifyChange("items")}select(e){const t=e?.clone()||null;this._set("selectedItem",t),this.emit("select",{item:t,template:t?.template||null})}_createItem(e,t){const r=this._itemPool.acquire();return r.set({template:e,layer:t}),r}_createGroup(e,t){const r=this._groupPool.acquire();return r.set("label",e),r.items=t,r}_releasePreviousItems(){this._destroyItems(this._get("items"))}_destroyItems(e){if(!e)return;e[0]instanceof p?e.forEach((e=>this._destroyItem(e))):e.forEach((e=>this._destroyGroup(e)))}_destroyGroup(e){e.items.forEach((e=>this._destroyItem(e))),e.items.length=0,this._groupPool.release(e)}_destroyItem(e){e.layer=null,e.template=null,this._itemPool.release(e)}_ensureGroupByObject(e){return"string"==typeof e?{key:e,label:e}:e}};function f(e){return e.reduce(((e,t)=>[...e,...t.templates]),[])}h.nullGroupBy={key:Symbol(),label:"Other​"},h._nullFilterFunction=e=>!0,e([i()],h.prototype,"_groupByFunction",void 0),e([i({readOnly:!0})],h.prototype,"_templateToLayer",null),e([i()],h.prototype,"filterFunction",void 0),e([i()],h.prototype,"groupBy",null),e([i()],h.prototype,"layers",null),e([i()],h.prototype,"state",null),e([i({readOnly:!0})],h.prototype,"_featureTemplatesByLayer",null),e([i({readOnly:!0})],h.prototype,"numberOfFeatureTemplates",null),e([i({readOnly:!0})],h.prototype,"items",null),e([i({readOnly:!0})],h.prototype,"selectedItem",void 0),e([i()],h.prototype,"select",null),h=m=e([n("esri.widgets.FeatureTemplates.FeatureTemplatesViewModel")],h);const d=h;export{d as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Evented.js";import{HandleOwnerMixin as r}from"../../core/HandleOwner.js";import{isSome as s,isNone as o}from"../../core/maybe.js";import l from"../../core/ObjectPool.js";import{when as a}from"../../core/reactiveUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import p from"./TemplateItem.js";import u from"./TemplateItemGroup.js";var m;const c=({layer:e})=>({key:e,label:e.title??""}),y=({layer:e})=>({key:e.geometryType,label:e.geometryType});let h=m=class extends(r(t.EventedAccessor)){constructor(e){super(e),this._itemPool=new l(p),this._groupPool=new l(u),this.filterFunction=null,this.selectedItem=null}initialize(){this._get("groupBy")||(this.groupBy="layer")}destroy(){this._templateToLayer.clear()}get _templateToLayer(){const e=new Map;for(const[t,r]of this._featureTemplatesByLayer)for(const s of r)e.set(s,t);return e}set groupBy(e){if(this._set("groupBy",e),"function"!=typeof e)switch(e){case"layer":this._groupByFunction=c;break;case"geometry":this._groupByFunction=y;break;default:this._groupByFunction=null}else this._groupByFunction=t=>this._ensureGroupByObject(e(t))}set layers(e){const t="layers";if(this.handles.remove(t),e){const t=()=>this.notifyChange("state");this.handles.add(e.map((e=>a((()=>e.loadStatus),t))),"layers")}this._set("layers",e)}get layers(){return this._get("layers")}get state(){const{layers:e}=this;return e&&0!==e.length?e.some((e=>"loading"===e.loadStatus||"not-loaded"===e.loadStatus))?"loading":"ready":"disabled"}get _featureTemplatesByLayer(){if(!this.layers)return new Map;const e=[];for(const t of this.layers){const r="templates"in t&&t.templates?t.templates:[],s="types"in t&&t.types?f(t.types):[];e.push([t,[...r,...s]])}return new Map(e)}get numberOfFeatureTemplates(){return Array.from(this._featureTemplatesByLayer.values()).reduce(((e,t)=>e+t.length),0)}get items(){if(0===this.numberOfFeatureTemplates)return this._releasePreviousItems(),[];const e=this._featureTemplatesByLayer,t=[],r=s(this.filterFunction)?this.filterFunction:m._nullFilterFunction;for(const[s,o]of e)if(s.loaded){const{capabilities:{operations:{supportsEditing:e,supportsAdd:l}}}=s;if(e&&l)for(const a of o)t.push({layer:s,template:a,matchesFilter:r({label:a.name})})}if(o(this._groupByFunction)){const e=t.filter((({matchesFilter:e})=>e)).map((({template:e,layer:t})=>this._createItem(e,t)));return this._releasePreviousItems(),e}const l=new Map;for(const o of t){const{template:e,layer:t}=o,r=this._groupByFunction({template:e,layer:t}),{key:a,label:i}=s(r.key)?r:m.nullGroupBy;l.has(a)||l.set(a,{label:i,templateItemInfos:[]}),l.get(a)?.templateItemInfos.push(o)}const a=[];for(const s of l.values()){const{label:e,templateItemInfos:t}=s,o=t.filter((({matchesFilter:e})=>e)),l=r({label:e})?t:t.length>0?o:[];if(l.length>0){const t=l.map((({template:e,layer:t})=>this._createItem(e,t)));a.push(this._createGroup(e,t))}}return 1===a.length&&a[0].label===m.nullGroupBy.label?(this._releasePreviousItems(),a[0].items):(this._releasePreviousItems(),a)}refresh(){this.notifyChange("items")}select(e,t=!0){const r=this.selectedItem,s=e?.clone()||null;this._set("selectedItem",s),t&&this.emit("select",{item:s,oldItem:r,template:s?.template??null})}selectNoEmit(e){this.select(e,!1)}_createItem(e,t){const r=this._itemPool.acquire();return r.set({template:e,layer:t}),r}_createGroup(e,t){const r=this._groupPool.acquire();return r.set("label",e),r.items=t,r}_releasePreviousItems(){this._destroyItems(this._get("items"))}_destroyItems(e){if(!e)return;e[0]instanceof p?e.forEach((e=>this._destroyItem(e))):e.forEach((e=>this._destroyGroup(e)))}_destroyGroup(e){e.items.forEach((e=>this._destroyItem(e))),e.items.length=0,this._groupPool.release(e)}_destroyItem(e){e.layer=null,e.template=null,this._itemPool.release(e)}_ensureGroupByObject(e){return"string"==typeof e?{key:e,label:e}:e}};function f(e){return e.reduce(((e,t)=>[...e,...t.templates]),[])}h.nullGroupBy={key:Symbol(),label:"Other​"},h._nullFilterFunction=e=>!0,e([i()],h.prototype,"_groupByFunction",void 0),e([i({readOnly:!0})],h.prototype,"_templateToLayer",null),e([i()],h.prototype,"filterFunction",void 0),e([i()],h.prototype,"groupBy",null),e([i()],h.prototype,"layers",null),e([i()],h.prototype,"state",null),e([i({readOnly:!0})],h.prototype,"_featureTemplatesByLayer",null),e([i({readOnly:!0})],h.prototype,"numberOfFeatureTemplates",null),e([i({readOnly:!0})],h.prototype,"items",null),e([i({readOnly:!0})],h.prototype,"selectedItem",void 0),e([i()],h.prototype,"select",null),h=m=e([n("esri.widgets.FeatureTemplates.FeatureTemplatesViewModel")],h);const d=h;export{d as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{Heading as e}from"../support/Heading.js";import{classes as t,isActivationKey as n}from"../support/widgetUtils.js";import{tsx as i}from"../support/jsxFactory.js";const o="esri-item-list",r={base:o,list:`${o}__list`,group:`${o}__group`,scroller:`${o}__scroller`,groupHeader:`${o}__group__header`,item:`${o}__list-item`,itemSelected:`${o}__list-item--selected`,itemContainer:`${o}__list-item-container`,itemLabel:`${o}__list-item-label`,itemIcon:`${o}__list-item-icon`,noMatchesMessage:`${o}__no-matches-message`,noItemsMessage:`${o}__no-items-message`,filterContainer:`${o}__filter-container`,filterContainerSticky:`${o}__filter-container--sticky`,filterPlaceholder:`${o}__filter-placeholder`,filterInput:`${o}__filter-input`,filterPlaceholderText:`${o}__filter-placeholder-text`,searchIcon:"esri-icon-search",widget:"esri-widget",input:"esri-input"},l=4;function s(e){const{id:t,identify:n,filterEnabled:o=!0,headingLevel:r=l,items:s,selectedItem:a,messages:d,filterText:u="",onFilterChange:I,renderIcon:f,onItemMouseLeave:g,onItemMouseEnter:_,onItemSelect:p}=e,v=e.enableListScroll??!0;return i("div",{key:t},i("calcite-list",{selectionMode:"none"},o?m({filterText:u,messages:d,onFilterChange:I,id:t}):null,c({enableListScroll:v,identify:n,items:s,selectedItem:a,messages:d,filterText:u,headingLevel:r,renderIcon:f,onItemMouseLeave:g,onItemMouseEnter:_,onItemSelect:p})))}function a(e){return!!e.items}function c(e){const{headingLevel:t,identify:n,items:o,renderIcon:l,filterText:s,onItemMouseLeave:c,onItemMouseEnter:m,onItemSelect:I,selectedItem:f}=e,g=e.enableListScroll?r.scroller:void 0;return 0===o.length?i("div",{class:r.noMatchesMessage,key:"no-matches"},e.messages.noMatches):i("div",{class:g,key:"item-container"},o.map((e=>a(e)?u({group:e,filterText:s,headingLevel:t,identify:n,onItemMouseLeave:c,onItemMouseEnter:m,onItemSelect:I,renderIcon:l,selectedItem:f}):d({item:e,identify:n,grouped:!0,onItemMouseLeave:c,onItemMouseEnter:m,onItemSelect:I,renderIcon:l,filterText:s,selectedItem:f}))))}function m(e){const{messages:t,filterText:n,enableListScroll:o}=e;return i("div",{key:"filter",class:o?void 0:r.filterContainerSticky},i("calcite-input",{onCalciteInputInput:t=>{const n=t.currentTarget;e.onFilterChange&&e.onFilterChange(n.value)},placeholder:t.filterPlaceholder,value:n,type:"search"}))}function d(e){const{identify:o,item:l,selectedItem:s,grouped:a,onItemSelect:c,onItemMouseEnter:m,onItemMouseLeave:d,renderIcon:u}=e,I=`${o?.(l)||l.id}__${l.label}`,f=s?`${o?.(s)||s.id}__${s.label}`:"";return i("calcite-list-item",{"aria-level":a?"2":"","data-item":l,key:I,class:t(r.item,I===f?r.itemSelected:""),label:l.label,onCalciteListItemSelect:e=>{const t=e.currentTarget["data-item"];c&&c(t)},onmouseenter:e=>{const t=e.currentTarget["data-item"];m&&m(t)},onkeydown:e=>{if(!n(e.key))return;const t=e.currentTarget["data-item"];c&&c(t)},onmouseleave:e=>{const t=e.currentTarget["data-item"];d&&d(t)},tabIndex:0},i("div",{class:r.itemIcon,slot:"content-start"},u&&u({item:l})))}function u(t){const{group:n,identify:o,onItemMouseLeave:s,onItemMouseEnter:a,onItemSelect:c,filterText:m,renderIcon:u,selectedItem:I,headingLevel:f=l}=t;return i("div",{class:r.group,key:n.label},i(e,{level:f,class:r.groupHeader},n.label),n.items.map((e=>d({item:e,identify:o,grouped:!0,onItemMouseLeave:s,onItemMouseEnter:a,onItemSelect:c,renderIcon:u,filterText:m,selectedItem:I}))))}export{s as ItemList,u as renderGroup,d as renderItem};
5
+ import{Heading as e}from"../support/Heading.js";import{classes as t,isActivationKey as n}from"../support/widgetUtils.js";import{tsx as i}from"../support/jsxFactory.js";const o="esri-item-list",l={base:o,list:`${o}__list`,group:`${o}__group`,scroller:`${o}__scroller`,groupHeader:`${o}__group__header`,item:`${o}__list-item`,itemSelected:`${o}__list-item--selected`,itemContainer:`${o}__list-item-container`,itemLabel:`${o}__list-item-label`,itemIcon:`${o}__list-item-icon`,noMatchesMessage:`${o}__no-matches-message`,noItemsMessage:`${o}__no-items-message`,filterContainer:`${o}__filter-container`,filterContainerSticky:`${o}__filter-container--sticky`,filterPlaceholder:`${o}__filter-placeholder`,filterInput:`${o}__filter-input`,filterPlaceholderText:`${o}__filter-placeholder-text`,searchIcon:"esri-icon-search",widget:"esri-widget",input:"esri-input"},r=4;function s(e){const{filterEnabled:t=!0,filterText:n="",headingLevel:o=r,id:l,identify:s,items:a,messages:d,onFilterChange:u,onItemMouseEnter:I,onItemMouseLeave:f,onItemSelect:g,renderIcon:p,selectedItem:_,selectionMode:v="none"}=e,h=e.enableListScroll??!0;return i("div",{key:l},i("calcite-list",{selectionMode:v,selectionAppearance:"border"},t?m({filterText:n,messages:d,onFilterChange:u,id:l}):null,c({enableListScroll:h,identify:s,items:a,selectedItem:_,messages:d,filterText:n,headingLevel:o,renderIcon:p,onItemMouseLeave:f,onItemMouseEnter:I,onItemSelect:g})))}function a(e){return!!e.items}function c(e){const{headingLevel:t,identify:n,items:o,renderIcon:r,filterText:s,onItemMouseLeave:c,onItemMouseEnter:m,onItemSelect:u,selectedItem:I}=e,g=e.enableListScroll?l.scroller:void 0;return 0===o.length?i("div",{class:l.noMatchesMessage,key:"no-matches"},e.messages.noMatches):i("div",{class:g,key:"item-container"},o.map((e=>a(e)?f({group:e,filterText:s,headingLevel:t,identify:n,onItemMouseLeave:c,onItemMouseEnter:m,onItemSelect:u,renderIcon:r,selectedItem:I}):d({item:e,identify:n,grouped:!0,onItemMouseLeave:c,onItemMouseEnter:m,onItemSelect:u,renderIcon:r,filterText:s,selectedItem:I}))))}function m(e){const{messages:t,filterText:n,enableListScroll:o}=e;return i("div",{key:"filter",class:o?void 0:l.filterContainerSticky},i("calcite-input",{onCalciteInputInput:t=>{const n=t.currentTarget;e.onFilterChange&&e.onFilterChange(n.value)},placeholder:t.filterPlaceholder,value:n,type:"search"}))}function d({grouped:e,identify:o,item:r,onItemMouseEnter:s,onItemMouseLeave:a,onItemSelect:c,renderIcon:m,selectedItem:d}){const f=u(r,o),g=f===u(d,o);return i("calcite-list-item",{"aria-level":e?"2":"",class:t(l.item,g?l.itemSelected:""),"data-item":r,key:f,label:r.label??void 0,selected:g,tabIndex:0,onCalciteListItemSelect:e=>c?.(I(e)),onmouseenter:e=>s?.(I(e)),onkeydown:e=>n(e.key)&&c?.(I(e)),onmouseleave:e=>a?.(I(e))},i("div",{class:l.itemIcon,slot:"content-start"},m?.({item:r})))}function u(e,t){return e?`${t?.(e)||e.id}__${e.label}`:""}function I(e){return e.currentTarget["data-item"]}function f(t){const{group:n,headingLevel:o=r,...s}=t;return i("div",{class:l.group,key:n.label??void 0},i(e,{level:o,class:l.groupHeader},n.label),n.items.map((e=>d({...s,item:e,grouped:!0}))))}export{s as ItemList,f as renderGroup,d as renderItem};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import r from"../../core/Accessor.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import s from"../../core/Logger.js";import{isSome as i,isNone as l}from"../../core/maybe.js";import{watch as n,initial as a}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import{renderPreviewHTML as u}from"../../symbols/support/symbolUtils.js";var c;const y="esri.widgets.FeatureTemplates.TemplateItem";let h=c=class extends(o(r)){constructor(t){super(t),this._activeFetchInfo={id:null,request:null},this.layer=null,this.template=null,this.thumbnail=null}initialize(){this.handles.add(n((()=>{const{layer:t}=this;return[t&&"renderer"in t?t.renderer:null,this.template]}),(()=>{this._activeFetchInfo.id=null,this._activeFetchInfo.request=null,this._set("thumbnail",null)}),a))}get description(){return this.template?.description}set description(t){this.template&&(this.template.description=t)}get label(){return this.template?.name}set label(t){this.template&&(this.template.name=t)}clone(){const t=i(this.thumbnail)?this.thumbnail.cloneNode(!0):null,e=new c({layer:this.layer,template:this.template});return e._set("thumbnail",t),e}static async fetchThumbnail(t,e){if(f(t))return s.getLogger(y).warn("Thumbnails for sublayers of a SubtypeGroupLayer are not yet supported."),null;const r=await d(t,e);if(l(r))return null;const o={maxSize:36};"dictionary"===t.renderer?.type&&(o.fieldMap=t.renderer.fieldMap??void 0,o.feature={attributes:e.prototype.attributes??{}});return await u(r,o)}};async function d(t,r){const{renderer:o}=t;if(o){const t=new e({attributes:r.prototype.attributes}),s=await o.getSymbolAsync(t);if(s)return s}return b(t)}async function b(t){const{geometryType:e}=t,r="point"===e||"multipoint"===e?await import("../../symbols/SimpleMarkerSymbol.js"):"polyline"===e?await import("../../symbols/SimpleLineSymbol.js"):"polygon"===e||"mesh"===e||"multipatch"===e?await import("../../symbols/SimpleFillSymbol.js"):null;return r?new r.default:null}function f(t){return"subtype-group"===t.type}t([p()],h.prototype,"description",null),t([p()],h.prototype,"label",null),t([p()],h.prototype,"layer",void 0),t([p()],h.prototype,"template",void 0),t([p({readOnly:!0})],h.prototype,"thumbnail",void 0),h=c=t([m(y)],h);const j=h;export{j as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import r from"../../core/Accessor.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import i from"../../core/Logger.js";import{isSome as s,isNone as l}from"../../core/maybe.js";import{watch as n,initial as a}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import{renderPreviewHTML as u}from"../../symbols/support/symbolUtils.js";var c;const y="esri.widgets.FeatureTemplates.TemplateItem";let h=c=class extends(o(r)){constructor(t){super(t),this._activeFetchInfo={id:null,request:null},this.layer=null,this.template=null,this.thumbnail=null}initialize(){this.handles.add(n((()=>{const{layer:t}=this;return[t&&"renderer"in t?t.renderer:null,this.template]}),(()=>{this._activeFetchInfo.id=null,this._activeFetchInfo.request=null,this._set("thumbnail",null)}),a))}get description(){return this.template?.description}set description(t){this.template&&(this.template.description=t)}get label(){return this.template?.name}set label(t){this.template&&(this.template.name=t)}get id(){return`${this.label??""}–${this.layer?.id}`}clone(){const t=s(this.thumbnail)?this.thumbnail.cloneNode(!0):null,e=new c({layer:this.layer,template:this.template});return e._set("thumbnail",t),e}static async fetchThumbnail(t,e){if(f(t))return i.getLogger(y).warn("Thumbnails for sublayers of a SubtypeGroupLayer are not yet supported."),null;const r=await d(t,e);if(l(r))return null;const o={maxSize:36};"dictionary"===t.renderer?.type&&(o.fieldMap=t.renderer.fieldMap??void 0,o.feature={attributes:e.prototype.attributes??{}});return await u(r,o)}};async function d(t,r){const{renderer:o}=t;if(o){const t=new e({attributes:r.prototype.attributes}),i=await o.getSymbolAsync(t);if(i)return i}return b(t)}async function b(t){const{geometryType:e}=t,r="point"===e||"multipoint"===e?await import("../../symbols/SimpleMarkerSymbol.js"):"polyline"===e?await import("../../symbols/SimpleLineSymbol.js"):"polygon"===e||"mesh"===e||"multipatch"===e?await import("../../symbols/SimpleFillSymbol.js"):null;return r?new r.default:null}function f(t){return"subtype-group"===t.type}t([p()],h.prototype,"description",null),t([p()],h.prototype,"label",null),t([p()],h.prototype,"layer",void 0),t([p()],h.prototype,"template",void 0),t([p({readOnly:!0})],h.prototype,"thumbnail",void 0),t([p()],h.prototype,"id",null),h=c=t([m(y)],h);const j=h;export{j as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as r}from"../../chunks/tslib.es6.js";import o from"../../core/Accessor.js";import{IdentifiableMixin as e}from"../../core/Identifiable.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";let p=class extends(e(o)){constructor(r){super(r),this.items=null,this.label=null}};r([s()],p.prototype,"items",void 0),r([s()],p.prototype,"label",void 0),p=r([t("esri.widgets.FeatureTemplates.TemplateItemGroup")],p);const c=p;export{c as default};
5
+ import{_ as r}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{IdentifiableMixin as o}from"../../core/Identifiable.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";let p=class extends(o(e)){constructor(r){super(r),this.items=null,this.label=null}get id(){return this.label}};r([s()],p.prototype,"items",void 0),r([s()],p.prototype,"label",void 0),r([s()],p.prototype,"id",null),p=r([t("esri.widgets.FeatureTemplates.TemplateItemGroup")],p);const c=p;export{c as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import{isNone as r}from"../core/maybe.js";import{watch as s,initial as i}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import{cast as l}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import a from"./Widget.js";import c from"./FeatureTemplates/FeatureTemplatesViewModel.js";import{ItemList as d}from"./FeatureTemplates/ItemList.js";import m from"./FeatureTemplates/TemplateItem.js";import"./support/widgetUtils.js";import{messageBundle as p}from"./support/decorators/messageBundle.js";import{vmEvent as u}from"./support/decorators/vmEvent.js";import{tsx as h}from"./support/jsxFactory.js";const f="esri-feature-templates",v={base:f,loader:`${f}__loader`,widget:"esri-widget"};function b(e){return"items"in e}function I(e){return e.length>0&&b(e[0])}function y(e){const{label:t}=e;return b(e)?t:`${t}–${e.layer.id}`}const g={filter:!0};let w=class extends(t(a)){constructor(e,t){super(e,t),this._iconIntersectionObserver=new IntersectionObserver(((e,t)=>{e.forEach((async e=>{if(e.isIntersecting){const s=e.target;if(s["data-has-icon"])return void t.unobserve(s);const i=s["data-item"],{layer:o,template:l}=i;s["data-has-icon"]=!0;const n=await m.fetchThumbnail(o,l).catch((()=>(s["data-has-icon"]=!1,null)));if(r(n))return;s.appendChild(n)}}))})),this.enableListScroll=!0,this.filterText="",this.headingLevel=4,this.messages=null,this.viewModel=new c,this.visibleElements={...g},this.renderItemIcon=this.renderItemIcon.bind(this),this._afterItemCreateOrUpdate=this._afterItemCreateOrUpdate.bind(this),this._afterItemRemoved=this._afterItemRemoved.bind(this)}initialize(){const e=({label:e})=>!this.filterText||e.toLowerCase().includes(this.filterText.toLowerCase());this.addHandles(s((()=>this.viewModel),((t,r)=>{t&&!t.filterFunction&&(this.filterFunction=e),r&&r!==t&&r.filterFunction===e&&(r.filterFunction=null)}),i))}destroy(){this._iconIntersectionObserver&&(this._iconIntersectionObserver.disconnect(),this._iconIntersectionObserver=null)}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-input.js"),import("@esri/calcite-components/dist/components/calcite-list-item.js")])}get filterFunction(){return this.viewModel.filterFunction}set filterFunction(e){this.viewModel.filterFunction=e}get groupBy(){return this.viewModel.groupBy}set groupBy(e){this.viewModel.groupBy=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layers(){return this.viewModel.layers}set layers(e){this.viewModel.layers=e}get selectedItem(){return this.viewModel.selectedItem}castVisibleElements(e){return{...g,...e}}select(e){return this.viewModel.select(e)}render(){const{enableListScroll:e,filterText:t,headingLevel:r,messages:s,viewModel:{items:i,numberOfFeatureTemplates:o,selectedItem:l,state:n}}=this,a=this.visibleElements.filter&&o>1;if(I(i)){const e=i.find((e=>e.label===c.nullGroupBy.label));e&&(e.label=s.other)}return h("div",{class:this.classes(v.base,v.widget),"aria-label":s.widgetLabel},"loading"===n?this.renderLoader():"ready"===n?h(d,{id:this.id,identify:y,filterText:t,items:i,headingLevel:r,messages:{filterPlaceholder:s.filterPlaceholder,noItems:s.noItems,noMatches:s.noMatches},filterEnabled:a,onItemSelect:e=>{this.viewModel.select(e)},onFilterChange:e=>{this.filterText=e,this.viewModel.refresh()},renderIcon:this.renderItemIcon,selectedItem:l,enableListScroll:e}):null)}renderItemIcon({item:e}){return h("span",{key:"icon",afterCreate:this._afterItemCreateOrUpdate,afterUpdate:this._afterItemCreateOrUpdate,afterRemoved:this._afterItemRemoved,"data-item":e,"data-has-icon":!1})}renderLoader(){return h("div",{class:v.loader,key:"loader"})}_afterItemCreateOrUpdate(e){this._iconIntersectionObserver?.observe(e)}_afterItemRemoved(e){this._iconIntersectionObserver?.unobserve(e)}};e([o()],w.prototype,"enableListScroll",void 0),e([o()],w.prototype,"filterFunction",null),e([o()],w.prototype,"filterText",void 0),e([o()],w.prototype,"groupBy",null),e([o()],w.prototype,"headingLevel",void 0),e([o()],w.prototype,"label",null),e([o()],w.prototype,"layers",null),e([o(),p("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],w.prototype,"messages",void 0),e([o({readOnly:!0})],w.prototype,"selectedItem",null),e([o(),u("select")],w.prototype,"viewModel",void 0),e([o()],w.prototype,"visibleElements",void 0),e([l("visibleElements")],w.prototype,"castVisibleElements",null),w=e([n("esri.widgets.FeatureTemplates")],w);const j=w;export{j as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import{isNone as r}from"../core/maybe.js";import{watch as s,initial as i}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import{cast as l}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import a from"./Widget.js";import c from"./FeatureTemplates/FeatureTemplatesViewModel.js";import{ItemList as d}from"./FeatureTemplates/ItemList.js";import m from"./FeatureTemplates/TemplateItem.js";import"./support/widgetUtils.js";import{messageBundle as p}from"./support/decorators/messageBundle.js";import{vmEvent as u}from"./support/decorators/vmEvent.js";import{tsx as h}from"./support/jsxFactory.js";const f="esri-feature-templates",v={base:f,loader:`${f}__loader`,widget:"esri-widget"};function b(e){return"items"in e}function I(e){return e.length>0&&b(e[0])}function g(e){return e.id}const y={filter:!0};let w=class extends(t(a)){constructor(e,t){super(e,t),this._iconIntersectionObserver=new IntersectionObserver(((e,t)=>{e.forEach((async e=>{if(e.isIntersecting){const s=e.target;if(s["data-has-icon"])return void t.unobserve(s);const i=s["data-item"],{layer:o,template:l}=i;s["data-has-icon"]=!0;const n=await m.fetchThumbnail(o,l).catch((()=>(s["data-has-icon"]=!1,null)));if(r(n))return;s.appendChild(n)}}))})),this.enableListScroll=!0,this.filterText="",this.headingLevel=4,this.messages=null,this.viewModel=new c,this.visibleElements={...y},this.renderItemIcon=this.renderItemIcon.bind(this),this._afterItemCreateOrUpdate=this._afterItemCreateOrUpdate.bind(this),this._afterItemRemoved=this._afterItemRemoved.bind(this)}initialize(){const e=({label:e})=>!this.filterText||!!e?.toLowerCase().includes(this.filterText.toLowerCase());this.addHandles(s((()=>this.viewModel),((t,r)=>{t&&!t.filterFunction&&(this.filterFunction=e),r&&r!==t&&r.filterFunction===e&&(r.filterFunction=null)}),i))}destroy(){this._iconIntersectionObserver?.disconnect(),this._iconIntersectionObserver=null}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-input.js"),import("@esri/calcite-components/dist/components/calcite-list-item.js")])}get filterFunction(){return this.viewModel.filterFunction}set filterFunction(e){this.viewModel.filterFunction=e}get groupBy(){return this.viewModel.groupBy}set groupBy(e){this.viewModel.groupBy=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layers(){return this.viewModel.layers}set layers(e){this.viewModel.layers=e}get selectedItem(){return this.viewModel.selectedItem}castVisibleElements(e){return{...y,...e}}select(e){return this.viewModel.select(e)}selectNoEmit(e){this.viewModel.selectNoEmit(e)}render(){const{enableListScroll:e,filterText:t,headingLevel:r,messages:s,viewModel:{items:i,numberOfFeatureTemplates:o,selectedItem:l,state:n}}=this,a=this.visibleElements.filter&&o>1;if(I(i)){const e=i.find((e=>e.label===c.nullGroupBy.label));e&&(e.label=s.other)}return h("div",{class:this.classes(v.base,v.widget),"aria-label":s.widgetLabel},"loading"===n?this.renderLoader():"ready"===n?h(d,{id:this.id,identify:g,filterText:t,items:i,headingLevel:r,selectionMode:"single",messages:{filterPlaceholder:s.filterPlaceholder,noItems:s.noItems,noMatches:s.noMatches},filterEnabled:a,onItemSelect:e=>this.viewModel.select(e),onFilterChange:e=>{this.filterText=e,this.viewModel.refresh()},renderIcon:this.renderItemIcon,selectedItem:l??void 0,enableListScroll:e}):null)}renderItemIcon({item:e}){return h("span",{key:"icon",afterCreate:this._afterItemCreateOrUpdate,afterUpdate:this._afterItemCreateOrUpdate,afterRemoved:this._afterItemRemoved,"data-item":e,"data-has-icon":!1})}renderLoader(){return h("div",{class:v.loader,key:"loader"})}_afterItemCreateOrUpdate(e){this._iconIntersectionObserver?.observe(e)}_afterItemRemoved(e){this._iconIntersectionObserver?.unobserve(e)}};e([o()],w.prototype,"enableListScroll",void 0),e([o()],w.prototype,"filterFunction",null),e([o()],w.prototype,"filterText",void 0),e([o()],w.prototype,"groupBy",null),e([o()],w.prototype,"headingLevel",void 0),e([o()],w.prototype,"label",null),e([o()],w.prototype,"layers",null),e([o(),p("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],w.prototype,"messages",void 0),e([o({readOnly:!0})],w.prototype,"selectedItem",null),e([o(),u("select")],w.prototype,"viewModel",void 0),e([o()],w.prototype,"visibleElements",void 0),e([l("visibleElements")],w.prototype,"castVisibleElements",null),w=e([n("esri.widgets.FeatureTemplates")],w);const j=w;export{j as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../analysis/LineOfSightAnalysis.js";import s from"../../analysis/LineOfSightAnalysisObserver.js";import o from"../../analysis/LineOfSightAnalysisTarget.js";import i from"../../core/Collection.js";import{referenceSetter as n,castForReferenceSetter as r}from"../../core/collectionUtils.js";import a from"../../core/Handles.js";import{handlesGroup as l}from"../../core/handleUtils.js";import{destroyMaybe as d,isNone as h,isSome as c,applySome as g,unwrap as y}from"../../core/maybe.js";import{watch as p,syncAndInitial as m,sync as T}from"../../core/reactiveUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";import u from"./LineOfSightTarget.js";import{AnalysisViewModel as w}from"../support/AnalysisViewModel.js";const f=i.ofType(u);let A=class extends w{constructor(e){super(e),this.analysis=null,this.supportedViewType="3d",this.unsupportedErrorMessage="LineOfSightViewModel is only supported in 3D views.",this._handles=new a,this._vmTargetsToConnection=new Map,this._analysisTargetsToConnection=new Map}initialize(){this._handles.add([this.targets.on("after-add",(e=>this._onViewModelTargetAdded(e.item))),this.targets.on("after-remove",(e=>this._onViewModelTargetRemoved(e.item))),p((()=>this.analysis),(e=>this._onAnalysisChange(e)),m)])}destroy(){this._analysisTargetsToConnection.forEach((e=>e.remove())),this._handles=d(this._handles)}get state(){return this.disabled||!this.ready?"disabled":h(this.tool)?"ready":this.tool.state}get observer(){return c(this.analysis.observer)?this.analysis.observer.position:null}set observer(e){this.analysis.observer=new s({position:e})}get targets(){return this._get("targets")||new f}set targets(e){this._set("targets",n(e,this.targets,f))}continue(){c(this.tool)&&this.tool.continue()}stop(){c(this.tool)&&this.tool.stop()}get testInfo(){return{analysisView:this.analysisView,getAnalysisTargetFromViewModelTarget:e=>g(this._vmTargetsToConnection.get(e),(e=>e.analysisTarget))}}constructAnalysis(){return new t}async onConnectToAnalysisView(e){this._handles.add([e.on("result-changed",(e=>{const t=this._analysisTargetsToConnection.get(e.target);c(e.result)?(t.viewModelTarget.intersectedGraphic=e.result.intersectedGraphic,t.viewModelTarget.intersectedLocation=y(e.result.intersectedLocation),t.viewModelTarget.visible=e.result.visible):(t.viewModelTarget.intersectedGraphic=null,t.viewModelTarget.intersectedLocation=null,t.viewModelTarget.visible=void 0)}))],"view")}onDisconnectFromAnalysisView(){null!=this._handles&&this._handles.remove("view")}_onViewModelTargetAdded(e){if(this._vmTargetsToConnection.get(e))return;const t=new o({position:e.location});this._connectViewModelWithAnalysisTarget(e,t),this.analysis.targets.add(t)}_onViewModelTargetRemoved(e){const t=this._vmTargetsToConnection.get(e);t&&(t.remove(),this.analysis.targets.remove(t.analysisTarget))}_onAnalysisTargetAdded(e){if(this._analysisTargetsToConnection.get(e))return;const t=new u({location:g(e.position,(e=>e.clone()))});this._connectViewModelWithAnalysisTarget(t,e),this.targets.add(t)}_onAnalysisTargetRemoved(e){const t=this._analysisTargetsToConnection.get(e);t&&(t.remove(),this.targets.remove(t.viewModelTarget))}_connectViewModelWithAnalysisTarget(e,t){let s=!1;const o=l([p((()=>t.position),(t=>{s||(s=!0,e.location=g(t,(e=>e.clone())),s=!1)}),T),p((()=>e.location),(e=>{s||(s=!0,t.position=g(e,(e=>e.clone())),s=!1)}),T)]),i={analysisTarget:t,viewModelTarget:e,remove:()=>{o.remove(),this._vmTargetsToConnection.delete(e),this._analysisTargetsToConnection.delete(t)}};this._vmTargetsToConnection.set(e,i),this._analysisTargetsToConnection.set(t,i)}_onAnalysisChange(e){const t="analysis";this._handles.remove(t),this._handles.add([this.analysis.targets.on("after-add",(e=>this._onAnalysisTargetAdded(e.item))),this.analysis.targets.on("after-remove",(e=>this._onAnalysisTargetRemoved(e.item)))],t),this.targets.removeAll(),e.targets.forEach((e=>{this._onAnalysisTargetAdded(e)}))}};e([v({type:t})],A.prototype,"analysis",void 0),e([v({readOnly:!0})],A.prototype,"state",null),e([v()],A.prototype,"observer",null),e([v({type:f,cast:r,nonNullable:!0})],A.prototype,"targets",null),A=e([_("esri.widgets.lineOfSight.LineOfSightViewModel")],A);const M=A;export{M as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../analysis/LineOfSightAnalysis.js";import s from"../../analysis/LineOfSightAnalysisObserver.js";import o from"../../analysis/LineOfSightAnalysisTarget.js";import i from"../../core/Collection.js";import{referenceSetter as n,castForReferenceSetter as r}from"../../core/collectionUtils.js";import a from"../../core/Handles.js";import{handlesGroup as l}from"../../core/handleUtils.js";import{destroyMaybe as h,isNone as c,applySome as d,isSome as g,unwrap as p}from"../../core/maybe.js";import{watch as y,syncAndInitial as m,sync as T}from"../../core/reactiveUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveElevationInfo as _,getConvertedElevation as f,absoluteHeightElevationInfo as w}from"../../support/elevationInfoUtils.js";import A from"./LineOfSightTarget.js";import{AnalysisViewModel as M}from"../support/AnalysisViewModel.js";const b=i.ofType(A);let j=class extends M{constructor(e){super(e),this.analysis=null,this.supportedViewType="3d",this.unsupportedErrorMessage="LineOfSightViewModel is only supported in 3D views.",this._handles=new a,this._vmTargetsToConnection=new Map,this._analysisTargetsToConnection=new Map}initialize(){this._handles.add([this.targets.on("after-add",(e=>this._onViewModelTargetAdded(e.item))),this.targets.on("after-remove",(e=>this._onViewModelTargetRemoved(e.item))),y((()=>this.analysis),(e=>this._onAnalysisChange(e)),m)])}destroy(){this._analysisTargetsToConnection.forEach((e=>e.remove())),this._handles=h(this._handles)}get state(){return this.disabled||!this.ready?"disabled":c(this.tool)?"ready":this.tool.state}get observer(){const{observer:e}=this.analysis;return c(e)||c(e.position)?null:this._convertAnalysisPointToAbsoluteHeight(e.position,e.elevationInfo)}set observer(e){const t=d(e,(e=>{const t=e.clone();return t.hasZ||(t.z=0),t}));this.analysis.observer=new s({position:t})}get targets(){return this._get("targets")||new b}set targets(e){this._set("targets",n(e,this.targets,b))}continue(){g(this.tool)&&this.tool.continue()}stop(){g(this.tool)&&this.tool.stop()}get testInfo(){return{analysisView:this.analysisView,getAnalysisTargetFromViewModelTarget:e=>d(this._vmTargetsToConnection.get(e),(e=>e.analysisTarget))}}constructAnalysis(){return new t}async onConnectToAnalysisView(e){this._handles.add([e.on("result-changed",(e=>{const t=this._analysisTargetsToConnection.get(e.target);g(e.result)?(t.viewModelTarget.intersectedGraphic=e.result.intersectedGraphic,t.viewModelTarget.intersectedLocation=p(e.result.intersectedLocation),t.viewModelTarget.visible=e.result.visible):(t.viewModelTarget.intersectedGraphic=null,t.viewModelTarget.intersectedLocation=null,t.viewModelTarget.visible=void 0)}))],"view")}onDisconnectFromAnalysisView(){null!=this._handles&&this._handles.remove("view")}_onViewModelTargetAdded(e){if(this._vmTargetsToConnection.get(e))return;const t=new o({position:e.location});this._connectViewModelWithAnalysisTarget(e,t),this.analysis.targets.add(t)}_onViewModelTargetRemoved(e){const t=this._vmTargetsToConnection.get(e);t&&(t.remove(),this.analysis.targets.remove(t.analysisTarget))}_onAnalysisTargetAdded(e){if(this._analysisTargetsToConnection.get(e))return;const t=new A({location:d(e.position,(t=>this._convertAnalysisPointToAbsoluteHeight(t,e.elevationInfo)))});this._connectViewModelWithAnalysisTarget(t,e),this.targets.add(t)}_onAnalysisTargetRemoved(e){const t=this._analysisTargetsToConnection.get(e);t&&(t.remove(),this.targets.remove(t.viewModelTarget))}_connectViewModelWithAnalysisTarget(e,t){let s=!1;const o=l([y((()=>({position:t.position,elevationInfo:t.elevationInfo})),(({position:t,elevationInfo:o})=>{s||(s=!0,e.location=d(t,(e=>this._convertAnalysisPointToAbsoluteHeight(e,o))),s=!1)}),T),y((()=>e.location),(e=>{s||(s=!0,t.position=d(e,(e=>{const t=e.clone();return t.hasZ||(t.z=0),t})),t.elevationInfo=null,s=!1)}),T)]),i={analysisTarget:t,viewModelTarget:e,remove:()=>{o.remove(),this._vmTargetsToConnection.delete(e),this._analysisTargetsToConnection.delete(t)}};this._vmTargetsToConnection.set(e,i),this._analysisTargetsToConnection.set(t,i)}_onAnalysisChange(e){const t="analysis";this._handles.remove(t),this._handles.add([this.analysis.targets.on("after-add",(e=>this._onAnalysisTargetAdded(e.item))),this.analysis.targets.on("after-remove",(e=>this._onAnalysisTargetRemoved(e.item)))],t),this.targets.removeAll(),e.targets.forEach((e=>{this._onAnalysisTargetAdded(e)}))}_convertAnalysisPointToAbsoluteHeight(e,t){const s=e.clone();if(g(this.view)){const o=_(e.hasZ,t);s.z=f(this.view,e,o,w)}return s}};e([v({type:t})],j.prototype,"analysis",void 0),e([v({readOnly:!0})],j.prototype,"state",null),e([v()],j.prototype,"observer",null),e([v({type:b,cast:r,nonNullable:!0})],j.prototype,"targets",null),j=e([u("esri.widgets.lineOfSight.LineOfSightViewModel")],j);const C=j;export{C as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{isActivationKey as n}from"../widgetUtils.js";function t(){return function(n,t){if(!n[t])throw new TypeError(`Cannot auto bind undefined function '${t}'`);return{value:o(n[t])}}}function e(n){const{type:t}=n;return n instanceof KeyboardEvent||"keyup"===t||"keydown"===t||"keypress"===t}function o(t){return function(o,...r){e(o)?n(o.key)&&(o.preventDefault(),o.stopPropagation(),o.target.click()):t.call(this,o,...r)}}export{t as accessibleHandler};
5
+ import{isActivationKey as n}from"../widgetUtils.js";function t(){return function(n,t){if(!n[t])throw new TypeError(`Cannot auto bind undefined function '${t}'`);return{value:o(n[t])}}}function e(n){const t=n?.type;return n instanceof KeyboardEvent||"keyup"===t||"keydown"===t||"keypress"===t}function o(t){return function(o,...r){e(o)?n(o.key)&&(o.preventDefault(),o.stopPropagation(),o.target.click()):t.call(this,o,...r)}}export{t as accessibleHandler};
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[9070],{99070:(e,t,n)=>{n.r(t),n.d(t,{loadGLTFMesh:()=>$});var r=n(22303),o=n(3172),s=n(30175),a=n(22021),c=n(70586),i=n(21787),u=n(46521),l=n(65617),f=n(88669),p=n(62540),m=n(60746),g=n(91024),d=n(71630),x=n(56481),C=n(20773),T=n(11077),w=n(8323),h=n(66459),y=n(40270),b=n(88246),v=n(91911),A=n(54388),R=n(57758),E=n(35371),M=n(56067),S=n(75488),B=n(10816);async function $(e,t,n){const a=new y.C(function(e){const t=e?.resolveFile;return t?{busy:!1,request:async(e,n,r)=>{const s=t(e),a="image"===n?"image":"binary"===n?"array-buffer":"json";return(await(0,o.default)(s,{responseType:a,signal:(0,c.pC)(r)?r.signal:null})).data}}:null}(n)),i=(await(0,b.Q)(a,t,n,!0)).model,u=i.lods.shift(),p=new Map,C=new Map;i.textures.forEach(((e,t)=>p.set(t,function(e){return new g.Z({data:e.data,wrap:N(e.parameters.wrap)})}(e)))),i.materials.forEach(((e,t)=>C.set(t,function(e,t){const n=new r.Z(function(e,t){return(0,f.f)(W(e[0]),W(e[1]),W(e[2]),t)}(e.color,e.opacity)),o=e.emissiveFactor?new r.Z(function(e){return(0,l.f)(W(e[0]),W(e[1]),W(e[2]))}(e.emissiveFactor)):null;return new m.Z({color:n,colorTexture:(0,c.Wg)((0,c.yw)(e.textureColor,(e=>t.get(e)))),normalTexture:(0,c.Wg)((0,c.yw)(e.textureNormal,(e=>t.get(e)))),emissiveColor:o,emissiveTexture:(0,c.Wg)((0,c.yw)(e.textureEmissive,(e=>t.get(e)))),occlusionTexture:(0,c.Wg)((0,c.yw)(e.textureOcclusion,(e=>t.get(e)))),alphaMode:L(e.alphaMode),alphaCutoff:e.alphaCutoff,doubleSided:e.doubleSided,metallic:e.metallicFactor,roughness:e.roughnessFactor,metallicRoughnessTexture:(0,c.Wg)((0,c.yw)(e.textureMetallicRoughness,(e=>t.get(e)))),colorTextureTransform:e.colorTextureTransform,normalTextureTransform:e.normalTextureTransform,occlusionTextureTransform:e.occlusionTextureTransform,emissiveTextureTransform:e.emissiveTextureTransform,metallicRoughnessTextureTransform:e.metallicRoughnessTextureTransform})}(e,p))));const T=function(e){let t=0;const n={color:!1,tangent:!1,normal:!1,texCoord0:!1},r=new Map,o=new Map,a=[];for(const c of e.parts){const{attributes:{position:e,normal:i,color:u,tangent:l,texCoord0:f}}=c,p=`\n ${I(e,r)}/\n ${I(i,r)}/\n ${I(u,r)}/\n ${I(l,r)}/\n ${I(f,r)}/\n ${k(c.transform)}\n `;let m=!1;const g=(0,s.s1)(o,p,(()=>(m=!0,{start:t,length:e.count})));m&&(t+=e.count),i&&(n.normal=!0),u&&(n.color=!0),l&&(n.tangent=!0),f&&(n.texCoord0=!0),a.push({gltf:c,writeVertices:m,region:g})}return{vertexAttributes:{position:(0,w.gS)(x.fP,t),normal:n.normal?(0,w.gS)(x.ct,t):null,tangent:n.tangent?(0,w.gS)(x.ek,t):null,color:n.color?(0,w.gS)(x.mc,t):null,texCoord0:n.texCoord0?(0,w.gS)(x.Eu,t):null},parts:a,components:[]}}(u);for(const e of T.parts)F(T,e,C);const{position:v,normal:A,tangent:R,color:E,texCoord0:M}=T.vertexAttributes,S={position:v.typedBuffer,normal:(0,c.pC)(A)?A.typedBuffer:null,tangent:(0,c.pC)(R)?R.typedBuffer:null,uv:(0,c.pC)(M)?M.typedBuffer:null,color:(0,c.pC)(E)?E.typedBuffer:null},B=(0,h.w1)(S,e,n);return{transform:B.transform,components:T.components,spatialReference:e.spatialReference,vertexAttributes:new d.Q({position:B.vertexAttributes.position,normal:B.vertexAttributes.normal,tangent:B.vertexAttributes.tangent,color:S.color,uv:S.uv})}}function I(e,t){if((0,c.Wi)(e))return"-";const n=e.typedBuffer;return`${(0,s.s1)(t,n.buffer,(()=>t.size))}/${n.byteOffset}/${n.byteLength}`}function k(e){return(0,c.pC)(e)?e.toString():"-"}function F(e,t,n){t.writeVertices&&function(e,t){const{position:n,normal:r,tangent:o,color:s,texCoord0:l}=e.vertexAttributes,f=t.region.start,{attributes:p,transform:m}=t.gltf,g=p.position.count;if((0,C.t)(n.slice(f,g),p.position,m),(0,c.pC)(p.normal)&&(0,c.pC)(r)){const e=(0,i.b)((0,u.c)(),m),t=r.slice(f,g);(0,C.a)(t,p.normal,e),(0,a.oc)(e)&&(0,C.n)(t,t)}else(0,c.pC)(r)&&(0,M.f)(r,0,0,1,{dstIndex:f,count:g});if((0,c.pC)(p.tangent)&&(0,c.pC)(o)){const e=(0,i.b)((0,u.c)(),m),t=o.slice(f,g);(0,T.t)(t,p.tangent,e),(0,a.oc)(e)&&(0,T.n)(t,t)}else(0,c.pC)(o)&&(0,S.f)(o,0,0,1,1,{dstIndex:f,count:g});if((0,c.pC)(p.texCoord0)&&(0,c.pC)(l)?(0,B.n)(l.slice(f,g),p.texCoord0):(0,c.pC)(l)&&(0,B.f)(l,0,0,{dstIndex:f,count:g}),(0,c.pC)(p.color)&&(0,c.pC)(s)){const e=p.color,t=s.slice(f,g);if(4===e.elementCount)e instanceof x.ek?(0,T.s)(t,e,255):e instanceof x.mc?(0,S.c)(t,e):e instanceof x.v6&&(0,T.a)(t,e,8);else{(0,S.f)(t,255,255,255,255);const n=x.ne.fromTypedArray(t.typedBuffer,t.typedBufferStride);e instanceof x.ct?(0,C.s)(n,e,255):e instanceof x.ne?(0,M.c)(n,e):e instanceof x.mw&&(0,C.b)(n,e,8)}}else(0,c.pC)(s)&&(0,S.f)(s.slice(f,g),255,255,255,255)}(e,t);const r=t.gltf,o=function(e,t){switch(t){case E.MX.TRIANGLES:return(0,v.nh)(e,A.DX);case E.MX.TRIANGLE_STRIP:return(0,v.DA)(e);case E.MX.TRIANGLE_FAN:return(0,v.jX)(e)}}(r.indices||r.attributes.position.count,r.primitiveType),s=t.region.start;if(s)for(let e=0;e<o.length;e++)o[e]+=s;e.components.push(new p.Z({faces:o,material:n.get(r.material),trustSourceNormals:!0}))}function L(e){switch(e){case"OPAQUE":return"opaque";case"MASK":return"mask";case"BLEND":return"blend"}}function N(e){return{horizontal:P(e.s),vertical:P(e.t)}}function P(e){switch(e){case E.e8.CLAMP_TO_EDGE:return"clamp";case E.e8.MIRRORED_REPEAT:return"mirror";case E.e8.REPEAT:return"repeat"}}function W(e){return e**(1/R.K)*255}}}]);