@arcgis/core 4.33.0-next.20250513 → 4.33.0-next.20250515

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 (540) hide show
  1. package/Graphic.js +1 -1
  2. package/Map.js +1 -1
  3. package/WebScene.js +1 -1
  4. package/applications/Components/SelectionOperation.js +1 -1
  5. package/arcade/functions/centroid.js +1 -1
  6. package/arcade/functions/featuresetbase.js +1 -1
  7. package/arcade/functions/geomasync.js +1 -1
  8. package/arcade/functions/geometry.js +1 -1
  9. package/arcade/functions/geomsync.js +1 -1
  10. package/arcade/geometry/operators.js +1 -1
  11. package/arcade/geometry/operatorsWorker.js +1 -1
  12. package/arcade/treeAnalysis.js +1 -1
  13. package/assets/components/assets/combobox/t9n/messages.en.json +1 -1
  14. package/assets/components/assets/combobox/t9n/messages.json +1 -1
  15. package/assets/components/assets/icon/calendarHeatChart16.json +1 -0
  16. package/assets/components/assets/icon/calendarHeatChart24.json +1 -0
  17. package/assets/components/assets/icon/calendarHeatChart32.json +1 -0
  18. package/assets/components/assets/icon/matrixHeatChart16.json +1 -0
  19. package/assets/components/assets/icon/matrixHeatChart24.json +1 -0
  20. package/assets/components/assets/icon/matrixHeatChart32.json +1 -0
  21. package/assets/components/assets/icon/progressBarChart16.json +1 -0
  22. package/assets/components/assets/icon/progressBarChart24.json +1 -0
  23. package/assets/components/assets/icon/progressBarChart32.json +1 -0
  24. package/assets/components/assets/icon/spikeDataVisualization16.json +1 -0
  25. package/assets/components/assets/icon/spikeDataVisualization24.json +1 -0
  26. package/assets/components/assets/icon/spikeDataVisualization32.json +1 -0
  27. package/assets/components/assets/icon/spikeDataVisualizationOpen16.json +1 -0
  28. package/assets/components/assets/icon/spikeDataVisualizationOpen24.json +1 -0
  29. package/assets/components/assets/icon/spikeDataVisualizationOpen32.json +1 -0
  30. package/assets/components/assets/icon/spikeDataVisualizationOutlined16F.json +1 -0
  31. package/assets/components/assets/icon/spikeDataVisualizationOutlined24F.json +1 -0
  32. package/assets/components/assets/icon/spikeDataVisualizationOutlined32F.json +1 -0
  33. package/assets/components/assets/icon/spikeDataVisualizationOutlinedColorLocked16.json +1 -0
  34. package/assets/components/assets/icon/spikeDataVisualizationOutlinedColorLocked24.json +1 -0
  35. package/assets/components/assets/icon/spikeDataVisualizationOutlinedColorLocked32.json +1 -0
  36. package/assets/components/assets/icon/spikeDataVisualizationOutlinedOpen16.json +1 -0
  37. package/assets/components/assets/icon/spikeDataVisualizationOutlinedOpen24.json +1 -0
  38. package/assets/components/assets/icon/spikeDataVisualizationOutlinedOpen32.json +1 -0
  39. package/assets/components/assets/icon/spikeDataVisualizationOutlinedOpenColorLocked16.json +1 -0
  40. package/assets/components/assets/icon/spikeDataVisualizationOutlinedOpenColorLocked24.json +1 -0
  41. package/assets/components/assets/icon/spikeDataVisualizationOutlinedOpenColorLocked32.json +1 -0
  42. package/assets/esri/core/workers/RemoteClient.js +1 -1
  43. package/assets/esri/core/workers/chunks/009730713ed9bc7c7388.js +1 -0
  44. package/assets/esri/core/workers/chunks/02853ab923245459b32e.js +1 -0
  45. package/assets/esri/core/workers/chunks/0624ae07d3af8d5f1ac8.js +1 -0
  46. package/assets/esri/core/workers/chunks/0817ddd885ce8b2459cb.js +1 -0
  47. package/assets/esri/core/workers/chunks/{69e8aabe5a1eb2d1e414.js → 0832bd5195b5791dd803.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{4deeeceb784e4390441d.js → 0a4cece5e96fb7e8a57b.js} +1 -1
  49. package/assets/esri/core/workers/chunks/0d23610475c85385fbff.js +1 -0
  50. package/assets/esri/core/workers/chunks/{b4f38fe9cc948a39ad87.js → 0fd6d80393722132e044.js} +2 -2
  51. package/assets/esri/core/workers/chunks/{0766ecb677d667e5fb83.js.LICENSE.txt → 0fd6d80393722132e044.js.LICENSE.txt} +1 -1
  52. package/assets/esri/core/workers/chunks/1051a5a57b2fb843a555.js +1 -0
  53. package/assets/esri/core/workers/chunks/12e99071f6582f6caeaf.js +1 -0
  54. package/assets/esri/core/workers/chunks/133e4bde346828d4510b.js +1 -0
  55. package/assets/esri/core/workers/chunks/1991f0d0f0a12175f849.js +1 -0
  56. package/assets/esri/core/workers/chunks/19a58adc75a34f84b0ef.js +1 -0
  57. package/assets/esri/core/workers/chunks/1d7f2abfccc54659d6f2.js +1 -0
  58. package/assets/esri/core/workers/chunks/{339e7a900e2bba9d3647.js → 1f19bd3ef795c6765384.js} +1 -1
  59. package/assets/esri/core/workers/chunks/{837f886f759fc6f0489d.js → 1f4fd9e3849f4e593375.js} +1 -1
  60. package/assets/esri/core/workers/chunks/1f9c6fbcd4d0eae1e574.js +1 -0
  61. package/assets/esri/core/workers/chunks/234117cc5cb7c6863313.js +1 -0
  62. package/assets/esri/core/workers/chunks/{07695960aa0344dbfbf3.js → 28d9e2ffc3059a55311e.js} +1 -1
  63. package/assets/esri/core/workers/chunks/{1c025beaaac5ec7c04fb.js → 2adf558cd8d8155d07d7.js} +1 -1
  64. package/assets/esri/core/workers/chunks/{47f64a340b5d56bf9e59.js → 2cf82d3645c75d311e99.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{f7ab3511f6627f467796.js → 377a7f0f7d304ff9fe5b.js} +1 -1
  66. package/assets/esri/core/workers/chunks/3b4b4f84d594db8945f9.js +1 -0
  67. package/assets/esri/core/workers/chunks/3bf1cf6c3cba172e2f6d.js +1 -0
  68. package/assets/esri/core/workers/chunks/{b3ca65d6112079fb1d00.js → 3ce5d7ad16e41eea05be.js} +1 -1
  69. package/assets/esri/core/workers/chunks/465f2db4ab8aa9c9f907.js +1 -0
  70. package/assets/esri/core/workers/chunks/{1e13e03aad422f9e871e.js → 47fe2379f2214bf50036.js} +1 -1
  71. package/assets/esri/core/workers/chunks/{3c45603af279ad7fed8c.js → 4954e0cf4a40e45d237f.js} +1 -1
  72. package/assets/esri/core/workers/chunks/4a362a35bcdb8405a53a.js +1 -0
  73. package/assets/esri/core/workers/chunks/4f8ebd9f0758b801835c.js +1 -0
  74. package/assets/esri/core/workers/chunks/5228d39c05d660a135b6.js +1 -0
  75. package/assets/esri/core/workers/chunks/{736cb9f74bf050b70f4c.js → 52a3d0e041717da7697e.js} +1 -1
  76. package/assets/esri/core/workers/chunks/54ea93f416ab52b413c1.js +1 -0
  77. package/assets/esri/core/workers/chunks/554a8bf4626336e68798.js +1 -0
  78. package/assets/esri/core/workers/chunks/55f087bca75c3f2a4515.js +1 -0
  79. package/assets/esri/core/workers/chunks/56569d0c2cf5c5167651.js +1 -0
  80. package/assets/esri/core/workers/chunks/{bbaadce582df7e20397b.js → 56d2a20c1b143697aa19.js} +1 -1
  81. package/assets/esri/core/workers/chunks/57211c35a9646f088d86.js +1 -0
  82. package/assets/esri/core/workers/chunks/58526def64536b6581ab.js +1 -0
  83. package/assets/esri/core/workers/chunks/5890740d5a761b038560.js +1 -0
  84. package/assets/esri/core/workers/chunks/{9a641fb94819574e48f6.js → 5a73d8b7b01758ed4fdd.js} +1 -1
  85. package/assets/esri/core/workers/chunks/{ba3193ea145960a50e87.js → 5c8d52b72a3bea4202ac.js} +1 -1
  86. package/assets/esri/core/workers/chunks/5dbd8d81d94cfda5bb32.js +1 -0
  87. package/assets/esri/core/workers/chunks/5e52c1c076a1502f9fe4.js +1 -0
  88. package/assets/esri/core/workers/chunks/609c7c9b7046b3a7acde.js +1 -0
  89. package/assets/esri/core/workers/chunks/{30f3014c0ac6e2bc14bf.js → 622c0552ca3cd674d46c.js} +1 -1
  90. package/assets/esri/core/workers/chunks/62798f66872dc32e77d6.js +346 -0
  91. package/assets/esri/core/workers/chunks/6409160d226a0bea5ac6.js +1 -0
  92. package/assets/esri/core/workers/chunks/65fd971d0574d69cbc26.js +1 -0
  93. package/assets/esri/core/workers/chunks/6993a59cbb78bc26f029.js +1 -0
  94. package/assets/esri/core/workers/chunks/6b23ca6570357f9fb724.js +1 -0
  95. package/assets/esri/core/workers/chunks/6c37a5bd00d255d1337a.js +1 -0
  96. package/assets/esri/core/workers/chunks/{2b01e3bce78541620a86.js → 6cbe8205a4e0f62da519.js} +1 -1
  97. package/assets/esri/core/workers/chunks/6ce4327f63e6eb92bba8.js +1 -0
  98. package/assets/esri/core/workers/chunks/6f9b8df290b0ce09beae.js +1 -0
  99. package/assets/esri/core/workers/chunks/{fef1a5f8a6fd3502b33b.js → 6fa1a5b7276a037dbd6a.js} +67 -89
  100. package/assets/esri/core/workers/chunks/7c819b3e6d69c526f4b2.js +1 -0
  101. package/assets/esri/core/workers/chunks/7df147da40474b028705.js +1 -0
  102. package/assets/esri/core/workers/chunks/{0766ecb677d667e5fb83.js → 7e1dc8e5e18f18dd21e2.js} +2 -2
  103. package/assets/esri/core/workers/chunks/{b4f38fe9cc948a39ad87.js.LICENSE.txt → 7e1dc8e5e18f18dd21e2.js.LICENSE.txt} +1 -1
  104. package/assets/esri/core/workers/chunks/{e662c86b8bafc5512d3d.js → 847e88e1d6da1e74cdc8.js} +1 -1
  105. package/assets/esri/core/workers/chunks/{6f5ec9bf7cf8a36d8e8b.js → 87eca6de502d18d8b7eb.js} +1 -1
  106. package/assets/esri/core/workers/chunks/{a73c6b4bc5baf440f85a.js → 88b7265270feede80e1d.js} +1 -1
  107. package/assets/esri/core/workers/chunks/{10e6dffa57aa1a626708.js → 8a6aac37b3133de74cce.js} +1 -1
  108. package/assets/esri/core/workers/chunks/8a87c181b85d0b86b9bb.js.LICENSE.txt +1 -1
  109. package/assets/esri/core/workers/chunks/{243dc74ec62891ba1ef7.js → 8e82acd1f730571680f4.js} +1 -1
  110. package/assets/esri/core/workers/chunks/8f1fbfdac04e694f621d.js +1 -0
  111. package/assets/esri/core/workers/chunks/91cd29f53f07bc38fe75.js +1 -0
  112. package/assets/esri/core/workers/chunks/{5583d18032ed8bc17c74.js → 938f1eebc48871be64e9.js} +1 -1
  113. package/assets/esri/core/workers/chunks/97c148adf0347c69a79c.js +1 -0
  114. package/assets/esri/core/workers/chunks/{029a118e6dfb3f544a5c.js → 98ef17d15517368d2383.js} +1 -1
  115. package/assets/esri/core/workers/chunks/9c8224ca29475556e5ea.js +1 -0
  116. package/assets/esri/core/workers/chunks/9d5eac3bd1526e2b33e3.js +1 -0
  117. package/assets/esri/core/workers/chunks/{38f5e6a202ce292edd9f.js → 9eb9c8db2510154c09cc.js} +1 -1
  118. package/assets/esri/core/workers/chunks/a036503087baa1f9fd00.js +1 -0
  119. package/assets/esri/core/workers/chunks/a09b5700c92bb76c3234.js +1 -0
  120. package/assets/esri/core/workers/chunks/a673128da9e6656ead2e.js +1 -0
  121. package/assets/esri/core/workers/chunks/{90ae15ce22a49bd84876.js → ab9614555a15f04396f6.js} +2 -2
  122. package/assets/esri/core/workers/chunks/{90ae15ce22a49bd84876.js.LICENSE.txt → ab9614555a15f04396f6.js.LICENSE.txt} +1 -1
  123. package/assets/esri/core/workers/chunks/ae733c963d61065faa54.js +1 -0
  124. package/assets/esri/core/workers/chunks/b0522dffa5600345c07e.js +1 -0
  125. package/assets/esri/core/workers/chunks/b06cb23048c32940f5de.js +1 -0
  126. package/assets/esri/core/workers/chunks/{079434fe765c53d304f2.js → b1e275607d9754079f60.js} +1 -1
  127. package/assets/esri/core/workers/chunks/{d1f7bfb8daf11ecada9f.js → b4273381dc069f4e1fa2.js} +1 -1
  128. package/assets/esri/core/workers/chunks/{fb2e28e6a87956267d1c.js → b92a34f88569c481ed10.js} +1 -1
  129. package/assets/esri/core/workers/chunks/{352b7dcd1633e0c98194.js → ba940ebdae84b174a7be.js} +1 -1
  130. package/assets/esri/core/workers/chunks/bf9b6b74654d303a6dae.js +1 -0
  131. package/assets/esri/core/workers/chunks/c07c1bb7ae09136dc1f6.js +1 -0
  132. package/assets/esri/core/workers/chunks/c938f5d269ba202d10ef.js +1 -0
  133. package/assets/esri/core/workers/chunks/cbbca011f8b176d4b5db.js +1 -0
  134. package/assets/esri/core/workers/chunks/ce321fd8fc5551e190ec.js +1 -0
  135. package/assets/esri/core/workers/chunks/ce53ddda04e09ba2f860.js +1 -0
  136. package/assets/esri/core/workers/chunks/d166f805990353578494.js +1 -0
  137. package/assets/esri/core/workers/chunks/{b816b608f31954128246.js → d21d9e8b8c8a2e0485d5.js} +1 -1
  138. package/assets/esri/core/workers/chunks/d9a23fb0c6c936d5e8ec.js +1 -0
  139. package/assets/esri/core/workers/chunks/da3c62a851a4332f6dda.js +1 -0
  140. package/assets/esri/core/workers/chunks/db3f710d770adf631b28.js +2 -0
  141. package/assets/esri/core/workers/chunks/{aa82925ffb00babb0543.js.LICENSE.txt → db3f710d770adf631b28.js.LICENSE.txt} +1 -1
  142. package/assets/esri/core/workers/chunks/{6805e7b43d6ecf3ea93c.js → dcf5719f38ad40b92941.js} +1 -1
  143. package/assets/esri/core/workers/chunks/e2cada6644c49b1b6e79.js +1 -0
  144. package/assets/esri/core/workers/chunks/e2fb4bebce3aee406efa.js +1 -0
  145. package/assets/esri/core/workers/chunks/e3638f9d4c0fda238f4b.js +1 -0
  146. package/assets/esri/core/workers/chunks/e85f892ea44d67d53ff0.js +2 -0
  147. package/assets/esri/core/workers/chunks/{3596540ef49e5330ceb2.js.LICENSE.txt → e85f892ea44d67d53ff0.js.LICENSE.txt} +1 -1
  148. package/assets/esri/core/workers/chunks/e89345c7af9d3d4d8452.js +1 -0
  149. package/assets/esri/core/workers/chunks/{a31658f544ac6e1801d6.js → ead5d4e271effc04def3.js} +1 -1
  150. package/assets/esri/core/workers/chunks/ece68a25651ef03fc95d.js +1 -0
  151. package/assets/esri/core/workers/chunks/f218a190015de1444018.js +1 -0
  152. package/assets/esri/core/workers/chunks/f229044615af3142bcb0.js +1 -0
  153. package/assets/esri/core/workers/chunks/f2692f25ef693cf12ce0.js +1 -0
  154. package/assets/esri/core/workers/chunks/f4c6ea630cecf0f260d7.js +2 -0
  155. package/assets/esri/core/workers/chunks/{e0dc8794343c2a949ffb.js.LICENSE.txt → f4c6ea630cecf0f260d7.js.LICENSE.txt} +1 -1
  156. package/assets/esri/core/workers/chunks/f718cb847c4eb1e43ad9.js +1 -0
  157. package/assets/esri/core/workers/chunks/f8fb0c7eaf73709bd855.js +1 -0
  158. package/assets/esri/core/workers/chunks/faa40ef04604c7cce706.js +1 -0
  159. package/assets/esri/core/workers/chunks/{218a66d53f7cf4f285aa.js → fbd2f45d5adce4ca323f.js} +2 -2
  160. package/assets/esri/core/workers/chunks/{218a66d53f7cf4f285aa.js.LICENSE.txt → fbd2f45d5adce4ca323f.js.LICENSE.txt} +1 -1
  161. package/assets/esri/core/workers/chunks/ffaa977cd97a2b7190c5.js +1 -0
  162. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  163. package/assets/esri/themes/base/widgets/_BuildingPhasePicker.scss +17 -10
  164. package/assets/esri/themes/base/widgets/_SelectionList.scss +7 -3
  165. package/assets/esri/themes/base/widgets/_SelectionToolbar.scss +5 -0
  166. package/assets/esri/themes/dark/main.css +1 -1
  167. package/assets/esri/themes/light/main.css +1 -1
  168. package/assets/esri/themes/light/view.css +1 -1
  169. package/chunks/Envelope.js +1 -1
  170. package/chunks/Jpg.js +1 -1
  171. package/chunks/LineSeries.js +1 -1
  172. package/chunks/OperatorCut.js +1 -1
  173. package/chunks/OperatorDefinitions.js +5 -0
  174. package/chunks/OperatorMultiPartToSinglePart.js +1 -1
  175. package/chunks/OperatorSimplifyOGC.js +1 -1
  176. package/chunks/ProjectionTransformation.js +1 -1
  177. package/chunks/QuadraticBezier.js +1 -1
  178. package/chunks/ShadowCastAccumulate.glsl.js +7 -5
  179. package/chunks/ShadowCastVisualize.glsl.js +1 -1
  180. package/chunks/ShadowHighlight.glsl.js +8 -7
  181. package/chunks/Transformation2D.js +1 -1
  182. package/chunks/arcade.js +1 -1
  183. package/chunks/arcgis-knowledge-client-core-simd.js +1 -1
  184. package/chunks/arcgis-knowledge-client-core.js +1 -1
  185. package/chunks/basis_encoder.js +1 -1
  186. package/chunks/basis_transcoder.js +1 -1
  187. package/chunks/bundle.js +1 -1
  188. package/chunks/chartUtilsAm5.js +1 -1
  189. package/chunks/dxt_encoder.js +1 -1
  190. package/chunks/geometryEngineBase.js +1 -1
  191. package/chunks/i3s.js +1 -1
  192. package/chunks/lclayout.js +1 -1
  193. package/chunks/libtess-asm.js +1 -1
  194. package/chunks/lyr3DMain.js +1 -1
  195. package/chunks/lyr3DWorker.js +1 -1
  196. package/chunks/vec4.js +1 -1
  197. package/chunks/vxlLayer.js +1 -1
  198. package/core/Accessor.js +1 -1
  199. package/core/accessorSupport/Lifecycle.js +5 -0
  200. package/core/accessorSupport/Properties.js +1 -1
  201. package/core/accessorSupport/decorators/subclass.js +1 -1
  202. package/core/accessorSupport/tracking/Flags.js +1 -1
  203. package/core/accessorSupport/watch.js +1 -1
  204. package/core/arrayUtils.js +1 -1
  205. package/core/image/apng.js +1 -1
  206. package/core/image/gif.js +1 -1
  207. package/core/mapCollectionUtils.js +1 -1
  208. package/core/mathUtils.js +1 -1
  209. package/core/urlUtils.js +1 -1
  210. package/core/workers/Connection.js +1 -1
  211. package/geometry/operators/densifyOperator.d.ts +0 -1
  212. package/geometry/operators/gx/operatorIntegrate.js +1 -1
  213. package/geometry/operators/gx/operatorOffset.js +1 -1
  214. package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
  215. package/geometry/operators/gx/operatorPolygonSlicer.js +1 -1
  216. package/geometry/operators/gx/operatorSimplifyOGC.js +1 -1
  217. package/geometry/operators/simplifyOGCOperator.js +1 -1
  218. package/geometry/support/meshProperties.js +1 -1
  219. package/geometry/support/normalizeUtilsSync.js +1 -1
  220. package/interfaces.d.ts +463 -2595
  221. package/intl/date.js +1 -1
  222. package/intl/number.js +1 -1
  223. package/layers/BingMapsLayer.js +1 -1
  224. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  225. package/layers/KnowledgeGraphLayer.js +1 -1
  226. package/layers/LinkChartLayer.js +1 -1
  227. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  228. package/layers/VideoLayer.js +1 -1
  229. package/layers/graphics/OptimizedFeatureSet.js +1 -1
  230. package/layers/graphics/controllers/StreamController.js +1 -1
  231. package/layers/graphics/data/FeatureIdInfo.js +5 -0
  232. package/layers/graphics/data/QueryEngine.js +1 -1
  233. package/layers/graphics/data/QueryEngineResult.js +1 -1
  234. package/layers/graphics/data/StreamFeatureManager.js +1 -1
  235. package/layers/graphics/data/createFeatureId.js +5 -0
  236. package/layers/graphics/featureConversionUtils.js +1 -1
  237. package/layers/graphics/sources/WFSSourceWorker.js +1 -1
  238. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  239. package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
  240. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  241. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  242. package/layers/ogc/ogcFeatureUtils.js +1 -1
  243. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  244. package/layers/orientedImagery/core/utils.js +1 -1
  245. package/layers/orientedImagery/queries.js +1 -1
  246. package/layers/orientedImagery/transformations/utils.js +1 -1
  247. package/layers/support/LercWorker.js +1 -1
  248. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  249. package/layers/support/rasterFunctions/pixelUtils.js +1 -1
  250. package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
  251. package/layers/support/rasterFunctions/stretchUtils.js +1 -1
  252. package/layers/support/serviceCapabilitiesUtils.js +1 -1
  253. package/layers/support/wmsUtils.js +1 -1
  254. package/layers/video/VideoController.js +1 -1
  255. package/package.json +1 -1
  256. package/rest/networks/support/Association.js +1 -1
  257. package/rest/networks/support/NetworkElement.js +1 -1
  258. package/rest/networks/support/QueryAssociationsParameters.js +1 -1
  259. package/rest/networks/support/TelecomNetworkElement.js +1 -1
  260. package/rest/networks/support/TraceResult.js +1 -1
  261. package/rest/query/operations/pbfDehydratedFeatureSet.js +1 -1
  262. package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
  263. package/rest/query/operations/queryRelatedRecords.js +1 -1
  264. package/smartMapping/statistics/uniqueValues.js +1 -1
  265. package/smartMapping/support/adapters/InMemoryLayerAdapter.js +1 -1
  266. package/smartMapping/support/adapters/support/layerUtils.js +1 -1
  267. package/statistics/utils.js +1 -1
  268. package/support/revision.js +1 -1
  269. package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
  270. package/symbols/cim/effects/EffectRadial.js +1 -1
  271. package/versionManagement/versionAdapters/FeatureLayerVersionAdapter.js +1 -1
  272. package/versionManagement/versionAdapters/NetworkVersionAdapter.js +1 -1
  273. package/versionManagement/versionAdapters/SubTypeGroupLayerVersionAdapter.js +1 -1
  274. package/views/2d/engine/ManagedCanvas.js +1 -1
  275. package/views/2d/engine/Stage.js +1 -1
  276. package/views/2d/engine/vectorTiles/VectorTile.js +1 -1
  277. package/views/2d/engine/webgl/TileContainer.js +1 -1
  278. package/views/2d/engine/webgl/grouping.js +1 -1
  279. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  280. package/views/2d/layers/MediaLayerView2D.js +1 -1
  281. package/views/2d/layers/TileLayerView2D.js +1 -1
  282. package/views/2d/layers/VideoLayerView2D.js +1 -1
  283. package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
  284. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
  285. package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
  286. package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
  287. package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
  288. package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
  289. package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
  290. package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
  291. package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
  292. package/views/2d/layers/features/layerAdapters/featureServiceUtils.js +1 -1
  293. package/views/2d/layers/features/processor/AAggregateStrategy.js +1 -1
  294. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  295. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  296. package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
  297. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  298. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  299. package/views/2d/layers/features/sources/strategies/StreamLoadStrategy.js +1 -1
  300. package/views/2d/layers/features/sources/strategies/support/queryAdapters.js +1 -1
  301. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  302. package/views/2d/layers/features/support/FeatureMetadata.js +1 -1
  303. package/views/2d/layers/features/support/FeatureSetReaderJSON.js +1 -1
  304. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  305. package/views/2d/layers/features/support/FeatureSetReaderPBFHeader.js +1 -1
  306. package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
  307. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  308. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  309. package/views/3d/FocusAreasView.js +5 -0
  310. package/views/3d/analysis/AnalysisViewManager3D.js +1 -1
  311. package/views/3d/analysis/DimensionAnalysisView3D.d.ts +4 -0
  312. package/views/3d/analysis/DimensionAnalysisView3D.js +1 -1
  313. package/views/3d/analysis/Viewshed/viewshedToolManipulatorUtils.js +1 -1
  314. package/views/3d/camera/constraintUtils/common.js +1 -1
  315. package/views/3d/interactive/Manipulator3D.js +1 -1
  316. package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
  317. package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
  318. package/views/3d/layers/DimensionLayerView3D.js +1 -1
  319. package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
  320. package/views/3d/layers/GraphicsLayerView3D.js +1 -1
  321. package/views/3d/layers/GraphicsView3D.js +1 -1
  322. package/views/3d/layers/I3SMeshView3D.js +1 -1
  323. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  324. package/views/3d/layers/LineOfSightLayerView3D.js +1 -1
  325. package/views/3d/layers/Lyr3DWasm.js +1 -1
  326. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  327. package/views/3d/layers/RouteLayerView3D.js +1 -1
  328. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  329. package/views/3d/layers/ViewshedLayerView3D.js +1 -1
  330. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  331. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  332. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  333. package/views/3d/layers/graphics/Graphics3DGraphic.js +1 -1
  334. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  335. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  336. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  337. package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
  338. package/views/3d/layers/graphics/GraphicsDeconflictor.js +1 -1
  339. package/views/3d/layers/graphics/GraphicsProcessor.js +1 -1
  340. package/views/3d/layers/graphics/Labeler.js +1 -1
  341. package/views/3d/layers/graphics/QueryEngine.js +1 -1
  342. package/views/3d/layers/graphics/focusAreaStyle.js +5 -0
  343. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
  344. package/views/3d/layers/graphics/pipeline/rendering/RenderCommandContext.js +1 -1
  345. package/views/3d/layers/graphics/pipeline/symbolization/IconSymbolLayerRenderer.js +1 -1
  346. package/views/3d/layers/i3s/I3SBinaryReader.js +1 -1
  347. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  348. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  349. package/views/3d/layers/i3s/I3SQueryEngine.js +1 -1
  350. package/views/3d/layers/i3s/I3SQueryResultGeometry.js +1 -1
  351. package/views/3d/layers/i3s/PagedNodeIndex.js +1 -1
  352. package/views/3d/layers/i3s/PointCloudWorkerUtil.js +1 -1
  353. package/views/3d/layers/i3s/meshUtils.js +5 -0
  354. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  355. package/views/3d/layers/support/LayerViewAnalysisViewManager.js +5 -0
  356. package/views/3d/support/hitTest.js +1 -1
  357. package/views/3d/terrain/PatchRenderData.js +1 -1
  358. package/views/3d/terrain/TerrainRenderer.js +1 -1
  359. package/views/3d/terrain/TerrainSurface.js +1 -1
  360. package/views/3d/terrain/TileAgent.js +1 -1
  361. package/views/3d/terrain/TileTexture.js +1 -1
  362. package/views/3d/webgl-engine/collections/Component/IndexRange/ComponentRange.js +1 -1
  363. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  364. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +3 -3
  365. package/views/3d/webgl-engine/core/shaderLibrary/shading/ShadowmapFiltering.glsl.js +3 -25
  366. package/views/3d/webgl-engine/core/shaderLibrary/shading/calculateUVZShadow.glsl.js +1 -1
  367. package/views/3d/webgl-engine/core/shaderModules/Texture2DShadowBindUniform.js +5 -0
  368. package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
  369. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +3 -3
  370. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  371. package/views/3d/webgl-engine/lib/BoundingInfo.js +1 -1
  372. package/views/3d/webgl-engine/lib/DepthRange.js +1 -1
  373. package/views/3d/webgl-engine/lib/GPUPointOcclusionQuery.js +1 -1
  374. package/views/3d/webgl-engine/lib/Geometry.js +1 -1
  375. package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
  376. package/views/3d/webgl-engine/lib/Material.js +1 -1
  377. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  378. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  379. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  380. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  381. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  382. package/views/3d/webgl-engine/lib/intersectorUtilsConversions.js +1 -1
  383. package/views/3d/webgl-engine/lib/lodRendering/InstanceData.js +1 -1
  384. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  385. package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
  386. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  387. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  388. package/views/3d/webgl-engine/shaders/ShadowCastAccumulate.glsl.js +1 -1
  389. package/views/3d/webgl-engine/shaders/ShadowHighlight.glsl.js +1 -1
  390. package/views/3d/webgl.js +1 -1
  391. package/views/FocusArea.js +1 -1
  392. package/views/FocusAreas.js +1 -1
  393. package/views/GroundView.js +1 -1
  394. package/views/SceneView.js +1 -1
  395. package/views/VideoView.js +1 -1
  396. package/views/View.js +1 -1
  397. package/views/draw/support/Box.js +1 -1
  398. package/views/draw/support/GraphicMover.js +1 -1
  399. package/views/draw/support/Reshape.js +1 -1
  400. package/views/input/InputManager.js +1 -1
  401. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  402. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  403. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
  404. package/views/layers/BuildingComponentSublayerView.js +1 -1
  405. package/views/layers/BuildingSceneLayerView.js +1 -1
  406. package/views/layers/FeatureLayerView.js +1 -1
  407. package/views/support/LayerViewManager.js +1 -1
  408. package/views/support/TextureCompressionWorker.js +1 -1
  409. package/views/support/TextureCompressionWorkerHandle.js +1 -1
  410. package/views/webgl/RenderingContext.js +1 -1
  411. package/views/webgl/ShaderBuilder.js +1 -1
  412. package/views/webgl/Texture.js +1 -1
  413. package/views/webgl/TextureDescriptor.js +1 -1
  414. package/views/webgl/textureUtils.js +1 -1
  415. package/webscene/Slide.js +1 -1
  416. package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
  417. package/widgets/AreaMeasurement2D/AreaMeasurement2DViewModel.js +1 -1
  418. package/widgets/BuildingExplorer/BuildingPhasePicker/BuildingPhasePicker.js +1 -1
  419. package/widgets/CoordinateConversion.js +1 -1
  420. package/widgets/Directions.js +1 -1
  421. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
  422. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DViewModel.js +1 -1
  423. package/widgets/ElevationProfile/support/profileUtils.js +1 -1
  424. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
  425. package/widgets/FeatureForm.js +1 -1
  426. package/widgets/FeatureTable/AttachmentsColumn.js +1 -1
  427. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  428. package/widgets/FeatureTable/Grid/Column.js +1 -1
  429. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  430. package/widgets/FeatureTable.js +1 -1
  431. package/widgets/LayerList/LayerListItem.js +1 -1
  432. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  433. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  434. package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
  435. package/widgets/OrientedImageryViewer/components/ImageViewer.js +1 -1
  436. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  437. package/widgets/OrientedImageryViewer/components/NavigationUI.js +1 -1
  438. package/widgets/OrientedImageryViewer/components/NavigationUIPanoramicViewModel.js +5 -0
  439. package/widgets/OrientedImageryViewer/components/NavigationUIViewModel.js +1 -1
  440. package/widgets/OrientedImageryViewer/components/imageNavigationUtils.js +1 -1
  441. package/widgets/OrientedImageryViewer/constants.js +1 -1
  442. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  443. package/widgets/OrientedImageryViewer/navigation/NavigationManager.js +5 -0
  444. package/widgets/OrientedImageryViewer/navigation/NavigationManagerPanoramic.js +5 -0
  445. package/widgets/OrientedImageryViewer/navigation/errors.js +5 -0
  446. package/widgets/OrientedImageryViewer/navigation/queries.js +5 -0
  447. package/widgets/OrientedImageryViewer/navigation/utils.js +5 -0
  448. package/widgets/OrientedImageryViewer.js +1 -1
  449. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  450. package/widgets/PanoramicViewer.js +1 -1
  451. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  452. package/widgets/Sketch/SketchViewModel.js +1 -1
  453. package/widgets/Sketch.js +1 -1
  454. package/widgets/VideoPlayer/VideoPlayerViewModel.js +1 -1
  455. package/widgets/VideoPlayer/components/SettingsButton.js +1 -1
  456. package/widgets/support/SelectionList.js +1 -1
  457. package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
  458. package/widgets/support/SelectionToolbar.js +1 -1
  459. package/widgets/support/Selector2D/SelectionOperation.js +1 -1
  460. package/widgets/support/SnappingControls.js +1 -1
  461. package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
  462. package/widgets/support/UtilityNetworkAssociations/utils/createAssociation.js +1 -1
  463. package/assets/esri/core/workers/chunks/009dbddfc6499e2cee4f.js +0 -1
  464. package/assets/esri/core/workers/chunks/0516bd18334d3af6c555.js +0 -1
  465. package/assets/esri/core/workers/chunks/0d8a635c1f9aeaf7564c.js +0 -1
  466. package/assets/esri/core/workers/chunks/0f57b6a3a85a47ebd9d0.js +0 -346
  467. package/assets/esri/core/workers/chunks/1abd026ed12c863e1d94.js +0 -1
  468. package/assets/esri/core/workers/chunks/1b8cc83aa1179245b2dc.js +0 -1
  469. package/assets/esri/core/workers/chunks/1c6542315390037053a6.js +0 -1
  470. package/assets/esri/core/workers/chunks/201db423e3c6f947b77c.js +0 -1
  471. package/assets/esri/core/workers/chunks/23de8aeed5b82c682cbe.js +0 -1
  472. package/assets/esri/core/workers/chunks/26ebb7816dd8c8cd4f3b.js +0 -1
  473. package/assets/esri/core/workers/chunks/2abce00d812c7f6b542d.js +0 -1
  474. package/assets/esri/core/workers/chunks/2e0af748eba93f3ea6cb.js +0 -1
  475. package/assets/esri/core/workers/chunks/3596540ef49e5330ceb2.js +0 -2
  476. package/assets/esri/core/workers/chunks/3604a77c93cf2927787b.js +0 -1
  477. package/assets/esri/core/workers/chunks/391b1c3e736a62befbaf.js +0 -1
  478. package/assets/esri/core/workers/chunks/40e556a0645af8658658.js +0 -1
  479. package/assets/esri/core/workers/chunks/4402336db7210cd583e0.js +0 -1
  480. package/assets/esri/core/workers/chunks/47cd99ab3ed11a931084.js +0 -1
  481. package/assets/esri/core/workers/chunks/4bd5cbf6e0be2fc7e84d.js +0 -1
  482. package/assets/esri/core/workers/chunks/4c8052e81916579841f4.js +0 -1
  483. package/assets/esri/core/workers/chunks/4c9aa1dafdc0d9537231.js +0 -1
  484. package/assets/esri/core/workers/chunks/4feb774f123da26e9f2a.js +0 -1
  485. package/assets/esri/core/workers/chunks/51b5dfc7085272d26b89.js +0 -1
  486. package/assets/esri/core/workers/chunks/51d9eaeeb781fd1d1162.js +0 -1
  487. package/assets/esri/core/workers/chunks/5228fc7fcdf57f44781e.js +0 -1
  488. package/assets/esri/core/workers/chunks/566c2ce50af225e556ac.js +0 -1
  489. package/assets/esri/core/workers/chunks/5ddf463c85c33428e807.js +0 -1
  490. package/assets/esri/core/workers/chunks/61032b5050464cb48056.js +0 -1
  491. package/assets/esri/core/workers/chunks/63dade3e1cc7f5b76846.js +0 -1
  492. package/assets/esri/core/workers/chunks/6e12900a9f4c3c9941ec.js +0 -1
  493. package/assets/esri/core/workers/chunks/6e5d8a6b29c06a27998c.js +0 -1
  494. package/assets/esri/core/workers/chunks/6f506303017903b9a06f.js +0 -1
  495. package/assets/esri/core/workers/chunks/71e46e866c23372b0b58.js +0 -1
  496. package/assets/esri/core/workers/chunks/75fa861b5757551f8fdc.js +0 -1
  497. package/assets/esri/core/workers/chunks/7c49a8877bd744daa3d5.js +0 -1
  498. package/assets/esri/core/workers/chunks/7ea5bbb52e84be9a608e.js +0 -1
  499. package/assets/esri/core/workers/chunks/83e13baab4b90a88d967.js +0 -1
  500. package/assets/esri/core/workers/chunks/86138c297095af1ac604.js +0 -1
  501. package/assets/esri/core/workers/chunks/8b74b609de4f70e1a75c.js +0 -1
  502. package/assets/esri/core/workers/chunks/8e6301006abdf47cc88d.js +0 -1
  503. package/assets/esri/core/workers/chunks/90f93091fe088875f80f.js +0 -1
  504. package/assets/esri/core/workers/chunks/91a02ee91f61cf841111.js +0 -1
  505. package/assets/esri/core/workers/chunks/93cc26e5636040fdc0b8.js +0 -1
  506. package/assets/esri/core/workers/chunks/9baeb3b5733acdda4e7c.js +0 -1
  507. package/assets/esri/core/workers/chunks/a1d697e2be1e892a666a.js +0 -1
  508. package/assets/esri/core/workers/chunks/a1f27c4f4b5ef3e359f7.js +0 -1
  509. package/assets/esri/core/workers/chunks/a348ff2dd936c6bf9399.js +0 -1
  510. package/assets/esri/core/workers/chunks/a8430e1e2142f1ce9b92.js +0 -1
  511. package/assets/esri/core/workers/chunks/aa82925ffb00babb0543.js +0 -2
  512. package/assets/esri/core/workers/chunks/b64f708f821dd2bb51cd.js +0 -1
  513. package/assets/esri/core/workers/chunks/bf453744067267e84d1b.js +0 -1
  514. package/assets/esri/core/workers/chunks/c1175477dfcdee90a453.js +0 -1
  515. package/assets/esri/core/workers/chunks/c17c269cc30e7e1d0bfb.js +0 -1
  516. package/assets/esri/core/workers/chunks/c3f144ca69995dca34a9.js +0 -1
  517. package/assets/esri/core/workers/chunks/c4e2b75b9135920babc3.js +0 -1
  518. package/assets/esri/core/workers/chunks/cb80b7ddc9acf625d754.js +0 -1
  519. package/assets/esri/core/workers/chunks/d22f91bc16a7641bcbef.js +0 -1
  520. package/assets/esri/core/workers/chunks/d52cf7b795ee52034f9e.js +0 -1
  521. package/assets/esri/core/workers/chunks/d551f70560a2b1ef5696.js +0 -1
  522. package/assets/esri/core/workers/chunks/d971571a957de70d5a8d.js +0 -1
  523. package/assets/esri/core/workers/chunks/d9d9d4f99140e579eabb.js +0 -1
  524. package/assets/esri/core/workers/chunks/dc3a6beb3028009b3c23.js +0 -1
  525. package/assets/esri/core/workers/chunks/e0dc8794343c2a949ffb.js +0 -2
  526. package/assets/esri/core/workers/chunks/e483d2f169e51a361742.js +0 -1
  527. package/assets/esri/core/workers/chunks/e613df03ceb39e29befa.js +0 -1
  528. package/assets/esri/core/workers/chunks/e697dd4508f02dcfe329.js +0 -1
  529. package/assets/esri/core/workers/chunks/e9b1349a2b3a3f300808.js +0 -1
  530. package/assets/esri/core/workers/chunks/eabfab23246d4a052ea3.js +0 -1
  531. package/assets/esri/core/workers/chunks/ec8e8048b3df2c92008d.js +0 -1
  532. package/assets/esri/core/workers/chunks/ed6d0fea159dea638c2f.js +0 -1
  533. package/assets/esri/core/workers/chunks/f5fcba6ca6f43bf1d65d.js +0 -1
  534. package/assets/esri/core/workers/chunks/f92d76b694ff0cdb212c.js +0 -1
  535. package/chunks/NetworkElement.js +0 -5
  536. package/core/accessorSupport/interfaces.js +0 -5
  537. package/views/FocusAreasUtils.js +0 -5
  538. package/views/FocusAreasView.js +0 -5
  539. package/views/analysis/DimensionAnalysisView.d.ts +0 -4
  540. package/views/analysis/DimensionAnalysisView.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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Evented.js";import{createResolver as i,throwIfAborted as r}from"../../../../../core/promiseUtils.js";import{watch as s,sync as a,whenOnce as n}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../../../../../core/support/UpdatingHandles.js";import d from"../../../../../geometry/SpatialReference.js";import{fromJSON as c}from"../../../../../geometry/support/jsonUtils.js";import{executeQueryForSnapping as h}from"../../../../../layers/graphics/data/executeQueryForSnapping.js";import p from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as f}from"../../../../../layers/graphics/data/QueryEngine.js";import m from"../../../../../layers/support/TileInfo.js";import g from"../../../../../rest/support/Query.js";import y from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as _}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as S}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as F}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as v}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as w}from"./FeatureServiceTileStore.js";let I=class extends t.EventedAccessor{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=i(),this._elevationAligner=_(),this._elevationFilter=S(),this._symbologyCandidatesFetcher=F(),this._updatingHandles=new u,this._alignPointsInFeatures=async(e,t)=>{const i={query:e},s=await this.remoteClient.invoke("alignElevation",i,{signal:t});return r(t),s},this._getSymbologyCandidates=async(e,t)=>{const i={candidates:e,spatialReference:this._spatialReference.toJSON()},s=await this.remoteClient.invoke("getSymbologyCandidates",i,{signal:t});return r(t),s}}get updating(){return this._isInitializing||this._updatingHandles.updating||this._featureFetcher.updating}destroy(){this._featureFetcher?.destroy(),this._queryEngine?.destroy(),this._featureStore?.clear()}async setup(e){if(this.destroyed)return{result:{}};const{geometryType:t,objectIdField:i,timeInfo:r,fieldsIndex:n}=e.serviceInfo,{hasZ:o}=e,l=d.fromJSON(e.spatialReference);this._spatialReference=l,this._featureStore=new p({...e.serviceInfo,hasZ:o,hasM:!1}),this._featureStore.estimateFeatureUsedMemory=e=>e.usedMemory,this._queryEngine=new f({spatialReference:e.spatialReference,featureStore:this._featureStore,geometryType:t,fieldsIndex:n,hasZ:o,hasM:!1,objectIdField:i,timeInfo:r}),this._featureFetcher=new v({store:new w({featureStore:this._featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:l,sourceSpatialReference:d.fromJSON(e.serviceInfo.spatialReference),customParameters:e.configuration.customParameters});const u="3d"===e.configuration.viewType;return this._elevationAligner=_(u,{elevationInfo:null!=e.elevationInfo?y.fromJSON(e.elevationInfo):null,alignPointsInFeatures:this._alignPointsInFeatures}),this._elevationFilter=S(u),this.addHandles([s((()=>this._featureFetcher.availability),(e=>this.emit("notify-availability",{availability:e})),a),s((()=>this.updating),(()=>this._notifyUpdating()))]),this._whenSetup.resolve(),this._isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this._updatingHandles.addPromise(this._whenSetup.promise),this._updateFeatureFetcherConfiguration(e),C}async setSuspended(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.suspended=e,C}async updateOutFields(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.outFields=new Set(e??[]),C}async fetchCandidates(e,t){await this._whenSetup.promise,r(t);const i=b(e,this._featureStore.hasZ),s=t?.signal,a=await h(this._queryEngine,i,s);r(s);const n=await this._elevationAligner.alignCandidates(a.candidates,d.fromJSON(e.point.spatialReference)??d.WGS84,s);r(s);const o=await this._symbologyCandidatesFetcher.fetch(n,s);r(s);const l=0===o.length?n:n.concat(o);return{result:{candidates:this._elevationFilter.filter(i,l)}}}async updateTiles(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.tileSize=e.tileSize,this._featureFetcher.tilesOfInterest=e.tiles,this._featureFetcher.tileInfo=null!=e.tileInfo?m.fromJSON(e.tileInfo):null,C}async refresh(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.refresh(),C}async whenNotUpdating(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),await n((()=>!this.updating),t),r(t),C}async getDebugInfo(e,t){return r(t),{result:this._featureFetcher.debugInfo}}async handleEdits(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),await this._updatingHandles.addPromise(this._featureFetcher.handleEdits(e)),r(t),C}async setHistoricMoment(e,t){return this._featureFetcher.setHistoricMoment(e.moment),C}async notifyElevationSourceChange(e,t){return this._elevationAligner.notifyElevationSourceChange(),C}async notifySymbologyChange(e,t){return this._symbologyCandidatesFetcher.notifySymbologyChange(),C}async setSymbologySnappingSupported(e){return this._symbologyCandidatesFetcher=F(e,this._getSymbologyCandidates),C}_updateFeatureFetcherConfiguration(e){this._featureFetcher.filter=null!=e.filter?g.fromJSON(e.filter):null,this._featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};e([o({readOnly:!0})],I.prototype,"updating",null),e([o()],I.prototype,"_isInitializing",void 0),I=e([l("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],I);const j=I;function b(e,t){const i=!!t||void 0;if(!e.filter)return{...e,query:{where:"1=1",returnZ:i}};const{distance:r,units:s,spatialRel:a,where:n,timeExtent:o,objectIds:l}=e.filter,u={geometry:e.filter.geometry?c(e.filter.geometry):void 0,distance:r,units:s,spatialRel:a,timeExtent:o,objectIds:l,returnZ:i,where:n??"1=1"};return{...e,query:u}}const C={result:{}};export{j as default};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Evented.js";import{createResolver as i,throwIfAborted as r}from"../../../../../core/promiseUtils.js";import{watch as s,sync as a,whenOnce as n}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../../../../../core/support/UpdatingHandles.js";import d from"../../../../../geometry/SpatialReference.js";import{fromJSON as c}from"../../../../../geometry/support/jsonUtils.js";import{executeQueryForSnapping as h}from"../../../../../layers/graphics/data/executeQueryForSnapping.js";import p from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as f}from"../../../../../layers/graphics/data/QueryEngine.js";import m from"../../../../../layers/support/TileInfo.js";import g from"../../../../../rest/support/Query.js";import y from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as _}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as S}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as F}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as v}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as I}from"./FeatureServiceTileStore.js";let w=class extends t.EventedAccessor{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=i(),this._elevationAligner=_(),this._elevationFilter=S(),this._symbologyCandidatesFetcher=F(),this._updatingHandles=new u,this._alignPointsInFeatures=async(e,t)=>{const i={query:e},s=await this.remoteClient.invoke("alignElevation",i,{signal:t});return r(t),s},this._getSymbologyCandidates=async(e,t)=>{const i={candidates:e,spatialReference:this._spatialReference.toJSON()},s=await this.remoteClient.invoke("getSymbologyCandidates",i,{signal:t});return r(t),s}}get updating(){return this._isInitializing||this._updatingHandles.updating||this._featureFetcher.updating}destroy(){this._featureFetcher?.destroy(),this._queryEngine?.destroy(),this._featureStore?.clear()}async setup(e){if(this.destroyed)return{result:{}};const{geometryType:t,objectIdField:i,timeInfo:r,fieldsIndex:n}=e.serviceInfo,{hasZ:o}=e,l=d.fromJSON(e.spatialReference);this._spatialReference=l,this._featureStore=new p({...e.serviceInfo,hasZ:o,hasM:!1}),this._featureStore.estimateFeatureUsedMemory=e=>e.usedMemory,this._queryEngine=new f({spatialReference:e.spatialReference,featureStore:this._featureStore,geometryType:t,fieldsIndex:n,hasZ:o,hasM:!1,featureIdInfo:{type:"object-id",fieldName:i},timeInfo:r}),this._featureFetcher=new v({store:new I({featureStore:this._featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:l,sourceSpatialReference:d.fromJSON(e.serviceInfo.spatialReference),customParameters:e.configuration.customParameters});const u="3d"===e.configuration.viewType;return this._elevationAligner=_(u,{elevationInfo:null!=e.elevationInfo?y.fromJSON(e.elevationInfo):null,alignPointsInFeatures:this._alignPointsInFeatures}),this._elevationFilter=S(u),this.addHandles([s((()=>this._featureFetcher.availability),(e=>this.emit("notify-availability",{availability:e})),a),s((()=>this.updating),(()=>this._notifyUpdating()))]),this._whenSetup.resolve(),this._isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this._updatingHandles.addPromise(this._whenSetup.promise),this._updateFeatureFetcherConfiguration(e),C}async setSuspended(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.suspended=e,C}async updateOutFields(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.outFields=new Set(e??[]),C}async fetchCandidates(e,t){await this._whenSetup.promise,r(t);const i=b(e,this._featureStore.hasZ),s=t?.signal,a=await h(this._queryEngine,i,s);r(s);const n=await this._elevationAligner.alignCandidates(a.candidates,d.fromJSON(e.point.spatialReference)??d.WGS84,s);r(s);const o=await this._symbologyCandidatesFetcher.fetch(n,s);r(s);const l=0===o.length?n:n.concat(o);return{result:{candidates:this._elevationFilter.filter(i,l)}}}async updateTiles(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.tileSize=e.tileSize,this._featureFetcher.tilesOfInterest=e.tiles,this._featureFetcher.tileInfo=null!=e.tileInfo?m.fromJSON(e.tileInfo):null,C}async refresh(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.refresh(),C}async whenNotUpdating(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),await n((()=>!this.updating),t),r(t),C}async getDebugInfo(e,t){return r(t),{result:this._featureFetcher.debugInfo}}async handleEdits(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),await this._updatingHandles.addPromise(this._featureFetcher.handleEdits(e)),r(t),C}async setHistoricMoment(e,t){return this._featureFetcher.setHistoricMoment(e.moment),C}async notifyElevationSourceChange(e,t){return this._elevationAligner.notifyElevationSourceChange(),C}async notifySymbologyChange(e,t){return this._symbologyCandidatesFetcher.notifySymbologyChange(),C}async setSymbologySnappingSupported(e){return this._symbologyCandidatesFetcher=F(e,this._getSymbologyCandidates),C}_updateFeatureFetcherConfiguration(e){this._featureFetcher.filter=null!=e.filter?g.fromJSON(e.filter):null,this._featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};e([o({readOnly:!0})],w.prototype,"updating",null),e([o()],w.prototype,"_isInitializing",void 0),w=e([l("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],w);const j=w;function b(e,t){const i=!!t||void 0;if(!e.filter)return{...e,query:{where:"1=1",returnZ:i}};const{distance:r,units:s,spatialRel:a,where:n,timeExtent:o,objectIds:l}=e.filter,u={geometry:e.filter.geometry?c(e.filter.geometry):void 0,distance:r,units:s,spatialRel:a,timeExtent:o,objectIds:l,returnZ:i,where:n??"1=1"};return{...e,query:u}}const C={result:{}};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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{equals as i}from"../../../../../core/arrayUtils.js";import{createTask as s}from"../../../../../core/asyncUtils.js";import r from"../../../../../core/Logger.js";import{throwIfAbortError as o}from"../../../../../core/promiseUtils.js";import{when as n}from"../../../../../core/reactiveUtils.js";import{union as a,equals as l,isSubsetOf as u,difference as d}from"../../../../../core/SetUtils.js";import{normalizeGlobalID as c}from"../../../../../core/uuid.js";import{property as h}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import{subclass as p}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as f}from"../../../../../core/support/UpdatingHandles.js";import y from"../../../../../geometry/Extent.js";import{toExtent as m}from"../../../../../geometry/support/aaBoundingRect.js";import{unquantizeOptimizedFeatureSet as _,convertFromFeatureSet as g}from"../../../../../layers/graphics/featureConversionUtils.js";import{isHostedAgolService as F}from"../../../../../layers/support/arcgisLayerUrl.js";import{OptimizedFeatureSetParserContext as T}from"../../../../../rest/query/operations/pbfOptimizedFeatureSet.js";import{executeQueryForExtent as b,executeQueryPBF as P,executeQuery as v}from"../../../../../rest/query/operations/query.js";import I from"../../../../../rest/support/Query.js";import{StateType as O,PendingFeatureTile as S}from"./PendingFeatureTile.js";let j=class extends t{get _minimumVerticesPerFeature(){switch(this.store?.featureStore.geometryType){case"esriGeometryPoint":case"esriGeometryMultipoint":return 1;case"esriGeometryPolygon":return 4;case"esriGeometryPolyline":return 2}}get _mandatoryOutFields(){const e=new Set;return this.objectIdField&&e.add(this.objectIdField),this.globalIdField&&e.add(this.globalIdField),e}set outFields(e){const t=this._get("outFields"),i=a(e,this._mandatoryOutFields);l(i,t)||(this._set("outFields",i),u(i,t)||this.refresh())}get outFields(){return this._get("outFields")??this._mandatoryOutFields}set filter(e){const t=this._get("filter"),i=this._filterProperties(e);JSON.stringify(t)!==JSON.stringify(i)&&this._set("filter",i)}set customParameters(e){const t=this._get("customParameters");JSON.stringify(t)!==JSON.stringify(e)&&this._set("customParameters",e)}get _configuration(){return{filter:this.filter,customParameters:this.customParameters,tileInfo:this.tileInfo,tileSize:this.tileSize}}set tileInfo(e){const t=this._get("tileInfo");t!==e&&(null!=e&&null!=t&&JSON.stringify(e)===JSON.stringify(t)||(this._set("tileInfo",e),this.store.tileInfo=e))}set tileSize(e){this._get("tileSize")!==e&&this._set("tileSize",e)}get updating(){return this._updatingHandles.updating}get hasZ(){return this.store.featureStore.hasZ}constructor(e){super(e),this.suspended=!0,this._historicMoment=null,this.tilesOfInterest=[],this.availability=0,this._pendingTiles=new Map,this._updatingHandles=new f}initialize(){this._initializeFetchExtent(),this._updatingHandles.add((()=>this._configuration),(()=>this.refresh())),this._updatingHandles.add((()=>this.tilesOfInterest),(()=>{this._updatePriorities(),this._process()}),{sync:!0,initial:!0,equals:(e,t)=>i(e,t,(({id:e},{id:t})=>e===t))}),this.addHandles(n((()=>!this.suspended),(()=>this._process())))}_updatePriorities(){this.store.setPriorityOrderByKey(this.tilesOfInterest.map((e=>e.id??""))??[])}destroy(){this._pendingTiles.forEach((e=>this._deletePendingTile(e))),this._pendingTiles.clear(),this.store.destroy(),this.tilesOfInterest.length=0,this._updatingHandles.destroy()}refresh(){this.store.refresh(),this._pendingTiles.forEach((e=>this._deletePendingTile(e))),this._process()}async handleEdits(e){if(e.historicMoment&&(this._historicMoment=e.historicMoment),!e.addedFeatures.length&&!e.updatedFeatures.length&&!e.deletedFeatures.length)return;for(const s of this._pendingTiles.values())s.reset();const t={...e,deletedFeatures:e.deletedFeatures.map((({objectId:e,globalId:t})=>e&&-1!==e?e:this._lookupObjectIdByGlobalId(t)))},i=s((async e=>{try{await this.store.processEdits(t,((e,t)=>this._queryFeaturesById(e,t)),e),this._processPendingTiles()}catch(i){o(i),r.getLogger(this).warn("Failed to apply edits",i)}}));this.addHandles(i),await this._updatingHandles.addPromise(i.promise)}setHistoricMoment(e){e?.getTime()!==this._historicMoment?.getTime()&&(this._historicMoment=e,this.refresh())}_initializeFetchExtent(){if(!this.capabilities.query.supportsExtent||!F(this.url))return;const e=s((async e=>{try{const t=await b(this.url,new I({where:"1=1",outSpatialReference:this.spatialReference,cacheHint:this.capabilities.query.supportsCacheHint??void 0}),{query:this._configuration.customParameters,signal:e});this.store.extent=y.fromJSON(t.data?.extent)}catch(t){o(t),r.getLogger(this).warn("Failed to fetch data extent",t)}}));this._updatingHandles.addPromise(e.promise.then((()=>this._process()))),this.addHandles(e)}get debugInfo(){return{numberOfFeatures:this.store.featureStore.numFeatures,tilesOfInterest:this.tilesOfInterest,pendingTiles:Array.from(this._pendingTiles.values()).map((e=>e.debugInfo)),storedTiles:this.store.debugInfo}}_process(){this._markTilesNotAlive(),this._createPendingTiles(),this._deletePendingTiles(),this._processPendingTiles()}_markTilesNotAlive(){for(const e of this._pendingTiles.values())e.alive=!1}_createPendingTiles(){if(this.suspended)return;const e=this._collectMissingTilesInfo();if(this._setAvailability(null==e?1:e.coveredArea/e.fullArea),null!=e)for(const{data:t,resolution:i}of e.missingTiles){const e=this._pendingTiles.get(t.id);e?(e.resolution=i,e.alive=!0):this._createPendingTile(t,i)}}_collectMissingTilesInfo(){let e=null;for(const t of this.tilesOfInterest){const i=this.store.process(t,((e,t)=>this._verifyTileComplexity(e,t)),this.outFields);null==e?e=i:e.prepend(i)}return e}_deletePendingTiles(){for(const e of this._pendingTiles.values())e.alive||this._deletePendingTile(e)}_processPendingTiles(){const e={fetchCount:(e,t)=>this._fetchCount(e,t),fetchFeatures:(e,t,i)=>this._fetchFeatures(e,t,i),finish:(e,t)=>this._finishPendingTile(e,t),resume:()=>this._processPendingTiles()};if(this._ensureFetchAllCounts(e))for(const t of this._pendingTiles.values())this._verifyTileComplexity(this.store.getFeatureCount(t.data),t.resolution)&&this._updatingHandles.addPromise(t.process(e))}_verifyTileComplexity(e,t){return this._verifyVertexComplexity(e)&&this._verifyFeatureDensity(e,t)}_verifyVertexComplexity(e){return e*this._minimumVerticesPerFeature<w}_verifyFeatureDensity(e,t){if(null==this.tileInfo)return!1;const i=this.tileSize*t;return e*(q/(i*i))<M}_ensureFetchAllCounts(e){let t=!0;for(const i of this._pendingTiles.values())i.state.type<O.FETCHED_COUNT&&this._updatingHandles.addPromise(i.process(e)),i.state.type<=O.FETCH_COUNT&&(t=!1);return t}_finishPendingTile(e,t){this.store.add(e.data,t),this._deletePendingTile(e),this._updateAvailability()}_updateAvailability(){const e=this._collectMissingTilesInfo();this._setAvailability(null==e?1:e.coveredArea/e.fullArea)}_setAvailability(e){this._set("availability",e)}_createPendingTile(e,t){const i=new S(e,t);return this._pendingTiles.set(e.id,i),i}_deletePendingTile(e){e.reset(),this._pendingTiles.delete(e.data.id)}async _fetchCount(e,t){return this.store.fetchCount(e.data,this.url,this._createCountQuery(e),{query:this.customParameters,timeout:x,signal:t})}async _fetchFeatures(e,t,i){let s=0;const r=[];let o=0,n=t;for(;;){const a=this._createFeaturesQuery(e),l=this._setPagingParameters(a,s,n),{features:u,exceededTransferLimit:d}=await this._queryFeatures(a,i);l&&(s+=a.num),o+=u.length;for(const e of u)r.push(e);if(n=t-o,!l||!d||n<=0)return r}}_filterProperties(e){return null==e?{where:"1=1",gdbVersion:void 0,timeExtent:void 0}:{where:e.where||"1=1",timeExtent:e.timeExtent,gdbVersion:e.gdbVersion}}_lookupObjectIdByGlobalId(e){const t=this.globalIdField,i=this.objectIdField;if(null==t)throw new Error("Expected globalIdField to be defined");let s=null;const r=e?c(e):e;if(this.store.featureStore.forEach((e=>{r===c(e.attributes[t])&&(s=e.objectId??e.attributes[i])})),null==s)throw new Error(`Expected to find a feature with globalId ${e}`);return s}_queryFeaturesById(e,t){const i=this._createFeaturesQuery();return i.objectIds=e,this._queryFeatures(i,t)}_queryFeatures(e,t){return this.capabilities.query.supportsFormatPBF?this._queryFeaturesPBF(e,t):this._queryFeaturesJSON(e,t)}async _queryFeaturesPBF(e,t){const{sourceSpatialReference:i}=this,{data:s}=await P(this.url,e,new T({sourceSpatialReference:i}),{query:this._configuration.customParameters,timeout:x,signal:t});return _(s)}async _queryFeaturesJSON(e,t){const{sourceSpatialReference:i}=this,{data:s}=await v(this.url,e,i,{query:this._configuration.customParameters,timeout:x,signal:t});return g(s,this.objectIdField)}_createCountQuery(e){const t=this._createBaseQuery(e);return this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0),t}_createFeaturesQuery(e=null){const t=this._createBaseQuery(e),i=null!=e?.data?this.store.getAttributesForTile(e?.data?.id):null,s=a(d(this.outFields,i??new Set),this._mandatoryOutFields);return t.outFields=Array.from(s),t.returnGeometry=!0,null!=e&&(this.capabilities.query.supportsResultType?t.resultType="tile":this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0)),t}_createBaseQuery(e){const t=new I({returnZ:this.hasZ,returnM:!1,historicMoment:this._historicMoment,geometry:null!=this.tileInfo&&null!=e?m(e.data.extent,this.tileInfo.spatialReference):void 0}),i=this._configuration.filter;return null!=i&&(t.where=i.where,t.gdbVersion=i.gdbVersion,t.timeExtent=i.timeExtent),t.outSpatialReference=this.spatialReference,t}_setPagingParameters(e,t,i){if(!this.capabilities.query.supportsPagination)return!1;const{supportsMaxRecordCountFactor:s,supportsCacheHint:r,tileMaxRecordCount:o,maxRecordCount:n,supportsResultType:a}=this.capabilities.query,l=s?I.MAX_MAX_RECORD_COUNT_FACTOR:1,u=l*((a||r)&&o?o:n||C);return e.start=t,s?(e.maxRecordCountFactor=Math.min(l,Math.ceil(i/u)),e.num=Math.min(i,e.maxRecordCountFactor*u)):e.num=Math.min(i,u),!0}};e([h({constructOnly:!0})],j.prototype,"url",void 0),e([h({constructOnly:!0})],j.prototype,"objectIdField",void 0),e([h({constructOnly:!0})],j.prototype,"globalIdField",void 0),e([h({constructOnly:!0})],j.prototype,"capabilities",void 0),e([h({constructOnly:!0})],j.prototype,"sourceSpatialReference",void 0),e([h({constructOnly:!0})],j.prototype,"spatialReference",void 0),e([h({constructOnly:!0})],j.prototype,"store",void 0),e([h({readOnly:!0})],j.prototype,"_minimumVerticesPerFeature",null),e([h()],j.prototype,"_mandatoryOutFields",null),e([h()],j.prototype,"outFields",null),e([h()],j.prototype,"suspended",void 0),e([h()],j.prototype,"_historicMoment",void 0),e([h()],j.prototype,"filter",null),e([h()],j.prototype,"customParameters",null),e([h({readOnly:!0})],j.prototype,"_configuration",null),e([h()],j.prototype,"tileInfo",null),e([h()],j.prototype,"tileSize",null),e([h()],j.prototype,"tilesOfInterest",void 0),e([h({readOnly:!0})],j.prototype,"updating",null),e([h({readOnly:!0})],j.prototype,"availability",void 0),e([h()],j.prototype,"hasZ",null),j=e([p("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTiledFetcher")],j);const C=2e3,x=6e5,w=1e6,q=25,M=1;export{j as FeatureServiceTiledFetcher};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{equals as i}from"../../../../../core/arrayUtils.js";import{createTask as s}from"../../../../../core/asyncUtils.js";import r from"../../../../../core/Logger.js";import{throwIfAbortError as o}from"../../../../../core/promiseUtils.js";import{when as n}from"../../../../../core/reactiveUtils.js";import{union as a,equals as l,isSubsetOf as u,difference as d}from"../../../../../core/SetUtils.js";import{normalizeGlobalID as c}from"../../../../../core/uuid.js";import{property as h}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import{subclass as p}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as f}from"../../../../../core/support/UpdatingHandles.js";import y from"../../../../../geometry/Extent.js";import{toExtent as m}from"../../../../../geometry/support/aaBoundingRect.js";import{unquantizeOptimizedFeatureSet as _,convertFromFeatureSet as g}from"../../../../../layers/graphics/featureConversionUtils.js";import{isHostedAgolService as F}from"../../../../../layers/support/arcgisLayerUrl.js";import{OptimizedFeatureSetParserContext as T}from"../../../../../rest/query/operations/pbfOptimizedFeatureSet.js";import{executeQueryForExtent as b,executeQueryPBF as P,executeQuery as v}from"../../../../../rest/query/operations/query.js";import I from"../../../../../rest/support/Query.js";import{StateType as O,PendingFeatureTile as S}from"./PendingFeatureTile.js";let j=class extends t{get _minimumVerticesPerFeature(){switch(this.store?.featureStore.geometryType){case"esriGeometryPoint":case"esriGeometryMultipoint":return 1;case"esriGeometryPolygon":return 4;case"esriGeometryPolyline":return 2}}get _mandatoryOutFields(){const e=new Set;return this.objectIdField&&e.add(this.objectIdField),this.globalIdField&&e.add(this.globalIdField),e}set outFields(e){const t=this._get("outFields"),i=a(e,this._mandatoryOutFields);l(i,t)||(this._set("outFields",i),u(i,t)||this.refresh())}get outFields(){return this._get("outFields")??this._mandatoryOutFields}set filter(e){const t=this._get("filter"),i=this._filterProperties(e);JSON.stringify(t)!==JSON.stringify(i)&&this._set("filter",i)}set customParameters(e){const t=this._get("customParameters");JSON.stringify(t)!==JSON.stringify(e)&&this._set("customParameters",e)}get _configuration(){return{filter:this.filter,customParameters:this.customParameters,tileInfo:this.tileInfo,tileSize:this.tileSize}}set tileInfo(e){const t=this._get("tileInfo");t!==e&&(null!=e&&null!=t&&JSON.stringify(e)===JSON.stringify(t)||(this._set("tileInfo",e),this.store.tileInfo=e))}set tileSize(e){this._get("tileSize")!==e&&this._set("tileSize",e)}get updating(){return this._updatingHandles.updating}get hasZ(){return this.store.featureStore.hasZ}constructor(e){super(e),this.suspended=!0,this._historicMoment=null,this.tilesOfInterest=[],this.availability=0,this._pendingTiles=new Map,this._updatingHandles=new f}initialize(){this._initializeFetchExtent(),this._updatingHandles.add((()=>this._configuration),(()=>this.refresh())),this._updatingHandles.add((()=>this.tilesOfInterest),(()=>{this._updatePriorities(),this._process()}),{sync:!0,initial:!0,equals:(e,t)=>i(e,t,(({id:e},{id:t})=>e===t))}),this.addHandles(n((()=>!this.suspended),(()=>this._process())))}_updatePriorities(){this.store.setPriorityOrderByKey(this.tilesOfInterest.map((e=>e.id??""))??[])}destroy(){this._pendingTiles.forEach((e=>this._deletePendingTile(e))),this._pendingTiles.clear(),this.store.destroy(),this.tilesOfInterest.length=0,this._updatingHandles.destroy()}refresh(){this.store.refresh(),this._pendingTiles.forEach((e=>this._deletePendingTile(e))),this._process()}async handleEdits(e){if(e.historicMoment&&(this._historicMoment=e.historicMoment),!e.addedFeatures.length&&!e.updatedFeatures.length&&!e.deletedFeatures.length)return;for(const s of this._pendingTiles.values())s.reset();const t={...e,deletedFeatures:e.deletedFeatures.map((({objectId:e,globalId:t})=>e&&-1!==e?e:this._lookupObjectIdByGlobalId(t)))},i=s((async e=>{try{await this.store.processEdits(t,((e,t)=>this._queryFeaturesById(e,t)),e),this._processPendingTiles()}catch(i){o(i),r.getLogger(this).warn("Failed to apply edits",i)}}));this.addHandles(i),await this._updatingHandles.addPromise(i.promise)}setHistoricMoment(e){e?.getTime()!==this._historicMoment?.getTime()&&(this._historicMoment=e,this.refresh())}_initializeFetchExtent(){if(!this.capabilities.query.supportsExtent||!F(this.url))return;const e=s((async e=>{try{const t=await b(this.url,new I({where:"1=1",outSpatialReference:this.spatialReference,cacheHint:this.capabilities.query.supportsCacheHint??void 0}),{query:this._configuration.customParameters,signal:e});this.store.extent=y.fromJSON(t.data?.extent)}catch(t){o(t),r.getLogger(this).warn("Failed to fetch data extent",t)}}));this._updatingHandles.addPromise(e.promise.then((()=>this._process()))),this.addHandles(e)}get debugInfo(){return{numberOfFeatures:this.store.featureStore.numFeatures,tilesOfInterest:this.tilesOfInterest,pendingTiles:Array.from(this._pendingTiles.values()).map((e=>e.debugInfo)),storedTiles:this.store.debugInfo}}_process(){this._markTilesNotAlive(),this._createPendingTiles(),this._deletePendingTiles(),this._processPendingTiles()}_markTilesNotAlive(){for(const e of this._pendingTiles.values())e.alive=!1}_createPendingTiles(){if(this.suspended)return;const e=this._collectMissingTilesInfo();if(this._setAvailability(null==e?1:e.coveredArea/e.fullArea),null!=e)for(const{data:t,resolution:i}of e.missingTiles){const e=this._pendingTiles.get(t.id);e?(e.resolution=i,e.alive=!0):this._createPendingTile(t,i)}}_collectMissingTilesInfo(){let e=null;for(const t of this.tilesOfInterest){const i=this.store.process(t,((e,t)=>this._verifyTileComplexity(e,t)),this.outFields);null==e?e=i:e.prepend(i)}return e}_deletePendingTiles(){for(const e of this._pendingTiles.values())e.alive||this._deletePendingTile(e)}_processPendingTiles(){const e={fetchCount:(e,t)=>this._fetchCount(e,t),fetchFeatures:(e,t,i)=>this._fetchFeatures(e,t,i),finish:(e,t)=>this._finishPendingTile(e,t),resume:()=>this._processPendingTiles()};if(this._ensureFetchAllCounts(e))for(const t of this._pendingTiles.values())this._verifyTileComplexity(this.store.getFeatureCount(t.data),t.resolution)&&this._updatingHandles.addPromise(t.process(e))}_verifyTileComplexity(e,t){return this._verifyVertexComplexity(e)&&this._verifyFeatureDensity(e,t)}_verifyVertexComplexity(e){return e*this._minimumVerticesPerFeature<w}_verifyFeatureDensity(e,t){if(null==this.tileInfo)return!1;const i=this.tileSize*t;return e*(q/(i*i))<M}_ensureFetchAllCounts(e){let t=!0;for(const i of this._pendingTiles.values())i.state.type<O.FETCHED_COUNT&&this._updatingHandles.addPromise(i.process(e)),i.state.type<=O.FETCH_COUNT&&(t=!1);return t}_finishPendingTile(e,t){this.store.add(e.data,t),this._deletePendingTile(e),this._updateAvailability()}_updateAvailability(){const e=this._collectMissingTilesInfo();this._setAvailability(null==e?1:e.coveredArea/e.fullArea)}_setAvailability(e){this._set("availability",e)}_createPendingTile(e,t){const i=new S(e,t);return this._pendingTiles.set(e.id,i),i}_deletePendingTile(e){e.reset(),this._pendingTiles.delete(e.data.id)}async _fetchCount(e,t){return this.store.fetchCount(e.data,this.url,this._createCountQuery(e),{query:this.customParameters,timeout:x,signal:t})}async _fetchFeatures(e,t,i){let s=0;const r=[];let o=0,n=t;for(;;){const a=this._createFeaturesQuery(e),l=this._setPagingParameters(a,s,n),{features:u,exceededTransferLimit:d}=await this._queryFeatures(a,i);l&&(s+=a.num),o+=u.length;for(const e of u)r.push(e);if(n=t-o,!l||!d||n<=0)return r}}_filterProperties(e){return null==e?{where:"1=1",gdbVersion:void 0,timeExtent:void 0}:{where:e.where||"1=1",timeExtent:e.timeExtent,gdbVersion:e.gdbVersion}}_lookupObjectIdByGlobalId(e){const t=this.globalIdField,i=this.objectIdField;if(null==t)throw new Error("Expected globalIdField to be defined");let s=null;const r=e?c(e):e;if(this.store.featureStore.forEach((e=>{r===c(e.attributes[t])&&(s=e.objectId??e.attributes[i])})),null==s)throw new Error(`Expected to find a feature with globalId ${e}`);return s}_queryFeaturesById(e,t){const i=this._createFeaturesQuery();return i.objectIds=e,this._queryFeatures(i,t)}_queryFeatures(e,t){return this.capabilities.query.supportsFormatPBF?this._queryFeaturesPBF(e,t):this._queryFeaturesJSON(e,t)}async _queryFeaturesPBF(e,t){const{sourceSpatialReference:i}=this,{data:s}=await P(this.url,e,new T({sourceSpatialReference:i}),{query:this._configuration.customParameters,timeout:x,signal:t});return _(s)}async _queryFeaturesJSON(e,t){const{sourceSpatialReference:i}=this,{data:s}=await v(this.url,e,i,{query:this._configuration.customParameters,timeout:x,signal:t});return g(s,{type:"object-id",fieldName:this.objectIdField})}_createCountQuery(e){const t=this._createBaseQuery(e);return this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0),t}_createFeaturesQuery(e=null){const t=this._createBaseQuery(e),i=null!=e?.data?this.store.getAttributesForTile(e?.data?.id):null,s=a(d(this.outFields,i??new Set),this._mandatoryOutFields);return t.outFields=Array.from(s),t.returnGeometry=!0,null!=e&&(this.capabilities.query.supportsResultType?t.resultType="tile":this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0)),t}_createBaseQuery(e){const t=new I({returnZ:this.hasZ,returnM:!1,historicMoment:this._historicMoment,geometry:null!=this.tileInfo&&null!=e?m(e.data.extent,this.tileInfo.spatialReference):void 0}),i=this._configuration.filter;return null!=i&&(t.where=i.where,t.gdbVersion=i.gdbVersion,t.timeExtent=i.timeExtent),t.outSpatialReference=this.spatialReference,t}_setPagingParameters(e,t,i){if(!this.capabilities.query.supportsPagination)return!1;const{supportsMaxRecordCountFactor:s,supportsCacheHint:r,tileMaxRecordCount:o,maxRecordCount:n,supportsResultType:a}=this.capabilities.query,l=s?I.MAX_MAX_RECORD_COUNT_FACTOR:1,u=l*((a||r)&&o?o:n||C);return e.start=t,s?(e.maxRecordCountFactor=Math.min(l,Math.ceil(i/u)),e.num=Math.min(i,e.maxRecordCountFactor*u)):e.num=Math.min(i,u),!0}};e([h({constructOnly:!0})],j.prototype,"url",void 0),e([h({constructOnly:!0})],j.prototype,"objectIdField",void 0),e([h({constructOnly:!0})],j.prototype,"globalIdField",void 0),e([h({constructOnly:!0})],j.prototype,"capabilities",void 0),e([h({constructOnly:!0})],j.prototype,"sourceSpatialReference",void 0),e([h({constructOnly:!0})],j.prototype,"spatialReference",void 0),e([h({constructOnly:!0})],j.prototype,"store",void 0),e([h({readOnly:!0})],j.prototype,"_minimumVerticesPerFeature",null),e([h()],j.prototype,"_mandatoryOutFields",null),e([h()],j.prototype,"outFields",null),e([h()],j.prototype,"suspended",void 0),e([h()],j.prototype,"_historicMoment",void 0),e([h()],j.prototype,"filter",null),e([h()],j.prototype,"customParameters",null),e([h({readOnly:!0})],j.prototype,"_configuration",null),e([h()],j.prototype,"tileInfo",null),e([h()],j.prototype,"tileSize",null),e([h()],j.prototype,"tilesOfInterest",void 0),e([h({readOnly:!0})],j.prototype,"updating",null),e([h({readOnly:!0})],j.prototype,"availability",void 0),e([h()],j.prototype,"hasZ",null),j=e([p("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTiledFetcher")],j);const C=2e3,x=6e5,w=1e6,q=25,M=1;export{j as FeatureServiceTiledFetcher};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as r}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import"../../core/accessorSupport/interfaces.js";import"../../core/accessorSupport/tracking/Flags.js";import"../../core/Warning.js";import"../../core/Error.js";class o extends e{constructor(){super(...arguments),this.sublayer=null}get updating(){return!1}get suspended(){return!1}get availableFields(){return[]}get filter(){return null}set filter(r){throw new Error("Not implemented")}queryFeatures(r,e){throw new Error("Not implemented")}queryObjectIds(r,e){throw new Error("Not implemented")}queryFeatureCount(r,e){throw new Error("Not implemented")}createQuery(){throw new Error("Not implemented")}queryExtent(r,e){throw new Error("Not implemented")}highlight(r){throw new Error("Not implemented")}}r([t()],o.prototype,"sublayer",void 0),r([t()],o.prototype,"availableFields",null),r([t()],o.prototype,"filter",null);export{o as default};
5
+ import{_ as r}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import"../../core/Warning.js";import"../../core/Error.js";class o extends e{constructor(){super(...arguments),this.sublayer=null}get updating(){return!1}get suspended(){return!1}get availableFields(){return[]}get filter(){return null}set filter(r){throw new Error("Not implemented")}queryFeatures(r,e){throw new Error("Not implemented")}queryObjectIds(r,e){throw new Error("Not implemented")}queryFeatureCount(r,e){throw new Error("Not implemented")}createQuery(){throw new Error("Not implemented")}queryExtent(r,e){throw new Error("Not implemented")}highlight(r){throw new Error("Not implemented")}}r([t()],o.prototype,"sublayer",void 0),r([t()],o.prototype,"availableFields",null),r([t()],o.prototype,"filter",null);export{o 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as r}from"../../chunks/tslib.es6.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import"../../core/accessorSupport/interfaces.js";import"../../core/accessorSupport/tracking/Flags.js";import"../../core/Warning.js";import"../../core/Error.js";import e from"./LayerView.js";class s extends e{constructor(r){super(r),this.layer=null,this.sublayerViews=null}highlight(r){throw new Error("Not implemented")}}r([o()],s.prototype,"layer",void 0),r([o()],s.prototype,"sublayerViews",void 0);export{s as default};
5
+ import{_ as r}from"../../chunks/tslib.es6.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import"../../core/Warning.js";import"../../core/Error.js";import e from"./LayerView.js";class s extends e{constructor(r){super(r),this.layer=null,this.sublayerViews=null}highlight(r){throw new Error("Not implemented")}}r([o()],s.prototype,"layer",void 0),r([o()],s.prototype,"sublayerViews",void 0);export{s 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../core/has.js";import t from"../../core/Logger.js";import{throwIfAborted as i}from"../../core/promiseUtils.js";import{watch as r,on as l,syncAndInitial as s}from"../../core/reactiveUtils.js";import{sqlAnd as n}from"../../core/sql.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{systemIsSpatialFieldName as u}from"../../layers/knowledgeGraph/constants.js";import{getEffectiveDisplayFilter as d}from"../../layers/support/displayFilterUtils.js";import p from"../../layers/support/FeatureEffect.js";import f from"../../layers/support/FeatureFilter.js";import{getSignedInUser as y}from"../../layers/support/featureLayerUtils.js";import{fixFields as h,unpackFieldNames as c,collectLabelingFields as m,collectElevationFields as F,collectFilterFields as g,collectFeatureReductionFields as I,collectOrderByInfos as b,collectFields as w,collectTrackInfoFields as E,collectDisplayFilterFields as v,collectField as x,featureHasFields as q}from"../../layers/support/fieldUtils.js";import{getFloorFilterClause as j}from"../../layers/support/floorFilterUtils.js";import{getUtilityNetworkFields as R}from"../../networks/support/networkFieldUtils.js";import _ from"../../rest/support/Query.js";import{loadArcade as C}from"../../support/loadArcade.js";import{getRequiredFields as O,getFetchPopupTemplate as k}from"./support/popupUtils.js";import{WhereClauseVisitor as P}from"./support/WhereClauseVisitor.js";const U=U=>{let T=class extends U{constructor(...e){super(...e),this._updatingRequiredPromise=null,this.filter=null,this.layer=null,this.requiresCurrentUser=!1,this.requiredFields=[],this.view=null}initialize(){this.addHandles([r((()=>{const e=this.layer,t=this.view;return[e&&"elevationInfo"in e?e.elevationInfo?.featureExpressionInfo:null,e&&"displayField"in e?e.displayField:null,e&&"timeInfo"in e&&e.timeInfo,e&&"renderer"in e&&e.renderer,e&&"labelingInfo"in e&&e.labelingInfo,e&&"floorInfo"in e&&e.floorInfo,t?.requiredFieldsOptions?.featureTitleFields&&e&&"featureTitleFields"in e&&e.featureTitleFields,t?.requiredFieldsOptions?.utilityNetworkFields&&R(t,e),e.displayFilterInfo,this.displayFilterEnabled,this.filter,this.featureEffect,this.timeExtent,"knowledge-graph-sublayer"===e?.type&&"link-chart"===e.parentCompositeLayer.type&&e.parentCompositeLayer.linkChart?.linkChartProperties.nonspatialDataDisplay?.mode,"parquet"===e?.type&&e.popupTemplate]}),(()=>this._handleChange()),s),l((()=>this.view?.floors),"change",(()=>this._handleChange())),l((()=>this.layer.displayFilterInfo?.filters),"change",(()=>this._handleChange())),l((()=>this.layer&&"sublayers"in this.layer?this.layer.sublayers:null),"change",(()=>this._handleChange()))])}get availableFields(){if(!this.layer)return[];const{layer:e,layer:{fieldsIndex:t},requiredFields:i}=this;return"outFields"in e&&e.outFields?h(t,[...c(t,e.outFields),...i]):h(t,i)}get displayFilterEnabled(){return(this.view?.displayFilterEnabled??!0)&&(!("displayFilterEnabled"in this.layer)||(this.layer?.displayFilterEnabled??!0))}get effectiveDisplayFilter(){const e=this.layer;return this.displayFilterEnabled&&e.displayFilterInfo?d(e.displayFilterInfo,this.view):null}get featureEffect(){return this.layer&&"featureEffect"in this.layer?this.layer.featureEffect:null}set featureEffect(e){this._override("featureEffect",e)}get maximumNumberOfFeatures(){return 0}set maximumNumberOfFeatures(e){t.getLogger(this).error("#maximumNumberOfFeatures=","Setting maximum number of features is not supported")}get maximumNumberOfFeaturesExceeded(){return!1}get signedInUser(){return this.layer?.url?y(this.layer.url):Promise.resolve(null)}highlight(e,t){throw new Error("missing implementation")}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference},t=null!=this.filter?this.filter.createQuery(e):new _(e);return"floorInfo"in this.layer&&this.layer.floorInfo&&(t.where=n(t.where,j(this))),this.displayFilterEnabled&&(t.where=n(t.where,this.effectiveDisplayFilter?.where)),null!=this.timeExtent&&(t.timeExtent=null!=t.timeExtent?t.timeExtent.intersection(this.timeExtent):this.timeExtent.clone()),t}createAggregateQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return new _(e)}queryFeatures(e,t){throw new Error("missing implementation")}queryObjectIds(e,t){throw new Error("missing implementation")}queryFeatureCount(e,t){throw new Error("missing implementation")}queryExtent(e,t){throw new Error("missing implementation")}async fetchPopupFeaturesFromGraphics(e,t){return this._fetchPopupFeatures(e,t)}_loadArcadeModules(e){return e.expressionInfos?.length||Array.isArray(e.content)&&e.content.some((e=>"expression"===e.type))?C():Promise.resolve()}_handleChange(){const e=Promise.all([this._updateRequiredFields(),this._updateClientWhereClauseRequirements()]).then((()=>{}));return this._set("_updatingRequiredPromise",e),e.then((()=>{this._updatingRequiredPromise===e&&this._set("_updatingRequiredPromise",null)})),e}async _updateClientWhereClauseRequirements(){if(!this.layer||!this.view)return;const{layer:e}=this,i=new P(e.fieldsIndex);if(i.visitFilter(this.filter),"featureReduction"in e&&i.visitFeatureReduction(e.featureReduction),"labelingInfo"in e&&i.visitLabelingInfo(e.labelsVisible,e.labelingInfo),"trackInfo"in e&&i.visitTrackInfo(e.trackInfo),"2d"===this.view.type&&(i.visitFilter(this.featureEffect?.filter),i.visitDisplayFilter(this.displayFilterEnabled,e.displayFilterInfo),"featureReduction"in e&&i.visitFeatureReduction(e.featureReduction)),"subtype-group"===e.type)for(const t of e.sublayers)i.visitLabelingInfo(t.labelsVisible,t.labelingInfo);try{const e=await i.finish();this._set("requiresCurrentUser",e.requiresCurrentUser)}catch(r){t.getLogger(this).error(r)}}async _updateRequiredFields(){if(!this.layer||!this.view)return;const e="3d"===this.view.type,{layer:i,layer:{fieldsIndex:r,objectIdField:l}}=this,s="renderer"in i&&i.renderer,n="orderBy"in i&&i.orderBy,o="featureReduction"in i?i.featureReduction:null,a=new Set,d=[s?s.collectRequiredFields(a,r):null,m(a,i),e&&"elevationInfo"in i?F(a,i):null,null!=this.filter?g(a,i,this.filter):null,e||null==this.featureEffect?null:g(a,i,this.featureEffect.filter),!e&&o?I(a,i,o):null,!e&&n?b(a,i,n):null];if("timeInfo"in i&&i.timeInfo&&this.timeExtent&&w(a,i.fieldsIndex,[i.timeInfo.startField,i.timeInfo.endField]),"timeInfo"in i&&i.timeInfo&&"trackInfo"in i&&i.trackInfo){const{trackInfo:e}=i;w(a,i.fieldsIndex,[i.timeInfo.trackIdField]),"feature"!==i.type&&"startTimeField"!==e.timeField||w(a,i.fieldsIndex,[i.timeInfo.startField]),"endTimeField"===e.timeField&&w(a,i.fieldsIndex,[i.timeInfo.endField]),await E(a,i)}if("floorInfo"in i&&i.floorInfo&&w(a,i.fieldsIndex,[i.floorInfo.floorField]),"featureTitleFields"in i&&this.view?.requiredFieldsOptions?.featureTitleFields&&i.featureTitleFields&&w(a,i.fieldsIndex,i.featureTitleFields),"feature"===i.type&&i.globalIdField&&this.view?.requiredFieldsOptions?.globalIdField&&w(a,i.fieldsIndex,[i.globalIdField]),this.displayFilterEnabled&&d.push(v(a,i,i.displayFilterInfo)),"feature"===i.type&&e&&null!=i.infoFor3D&&(null==i.globalIdField&&t.getLogger(this).error("globalIdField missing on 3DObjectFeatureLayer"),w(a,i.fieldsIndex,[i.globalIdField])),"subtype-group"===i.type){x(a,r,i.subtypeField);const e=i.sublayers.map((e=>Promise.all([e.renderer?.collectRequiredFields(a,r),m(a,e)])));d.push(Promise.all(e))}if("catalog-footprint"===i.type&&i.parent){const e=i.parent;w(a,r,[e.itemNameField,e.itemSourceField,e.itemTypeField,e.maxScaleField,e.minScaleField])}"knowledge-graph-sublayer"===i.type&&"link-chart"===i.parentCompositeLayer.type&&x(a,r,u),"parquet"===i.type&&d.push(O(i,i.popupTemplate).then((e=>{for(const t of e)a.add(t)})));const p=await Promise.allSettled(d);x(a,r,l),e&&"displayField"in i&&i.displayField&&x(a,r,i.displayField);for(const u of p)"rejected"===u.status&&t.getLogger(this).error(u.reason);const f=Array.from(a).sort();this._set("requiredFields",f)}_popupFeatureHasRequiredFields(e,t){return q(t,e)}async _fetchPopupFeatures(e,t){const r=new Array(e.length),l=new Map,s=new Map,o=await this._createPopupQuery(e.map((e=>e.origin?.layer??e.layer)),t),a="globalIdField"in this.layer?this.layer.globalIdField:null,u="objectIdField"in this.layer?this.layer.objectIdField:null;for(let n=0;n<e.length;n++){const d=e[n];if(d.isAggregate){r[n]=d;continue}const p=d.origin?.layer??d.layer;if(!p||!("popupEnabled"in p)||!p.popupEnabled)continue;const f=c(this.layer.fieldsIndex,o.outFields),y=k(p,t);if(null==y)continue;const h=await this._loadArcadeModules(y);i(t);if(h&&h.arcadeUtils.hasGeometryOperations(y)||!this._popupFeatureHasRequiredFields(d,f)){const e=d.getObjectId(),t=d.getGlobalId();if(null!=u&&null!=e){l.set(e,{graphic:d,index:n});continue}if(null!=a&&null!=t){s.set(t,{graphic:d,index:n});continue}}r[n]=d}if("stream"===this.layer.type||"parquet"===this.layer.type||0===l.size&&0===s.size)return r.filter(Boolean);const d=[];if(null!=u&&l.size>0){const e=o.clone();e.objectIds=Array.from(l.keys()),d.push({query:e,map:l,fieldName:u})}if(null!=a&&s.size>0){const e=o.clone();e.outFields??=[],e.outFields.push(a);const t=Array.from(s.keys());e.where=n(o.where,`${a} IN (${t.map((e=>`'${e}'`)).join(",")})`),d.push({query:e,map:s,fieldName:a})}for(const{query:i,map:n,fieldName:p}of d)try{const e=await this.layer.queryFeatures(i,t);for(const t of e.features){const e=t.getAttribute(p);if(null==e)continue;const i=n.get(e);if(!i)continue;const{graphic:{geometry:l,origin:s},index:o}=i;t.geometry||=l,t.origin=s,r[o]=t}}catch{}return r.filter(Boolean)}async _createPopupQuery(e,t){const r=this.layer.createQuery(),l=new Set;let s=!1;const o=e??[this.layer];for(const n of o){if(!("popupEnabled"in n))continue;const e=k(n,t);if(null==e)continue;const r=await this._loadArcadeModules(e);i(t);const o=r&&r.arcadeUtils.hasGeometryOperations(e);s=!("point"!==this.layer.geometryType&&!o);const a=await O(this.layer,e);i(t);for(const t of a)l.add(t)}return r.returnGeometry=s,r.returnZ=s,r.returnM=s,r.outFields=Array.from(l),r.outSpatialReference=this.view.spatialReference,"floorInfo"in this.layer&&this.layer.floorInfo&&(r.where=n(r.where,j(this))),r}canResume(){return!!super.canResume()&&(null==this.timeExtent||!this.timeExtent.isEmpty)}getTest(){}get test(){}};return e([o()],T.prototype,"_updatingRequiredPromise",void 0),e([o({readOnly:!0})],T.prototype,"availableFields",null),e([o({readOnly:!0})],T.prototype,"displayFilterEnabled",null),e([o({readOnly:!0})],T.prototype,"effectiveDisplayFilter",null),e([o({type:p})],T.prototype,"featureEffect",null),e([o({type:f})],T.prototype,"filter",void 0),e([o()],T.prototype,"layer",void 0),e([o({type:Number})],T.prototype,"maximumNumberOfFeatures",null),e([o({readOnly:!0,type:Boolean})],T.prototype,"maximumNumberOfFeaturesExceeded",null),e([o()],T.prototype,"requiresCurrentUser",void 0),e([o({readOnly:!0})],T.prototype,"requiredFields",void 0),e([o({readOnly:!0})],T.prototype,"signedInUser",null),e([o()],T.prototype,"suspended",void 0),e([o()],T.prototype,"view",void 0),T=e([a("esri.views.layers.FeatureLayerView")],T),T};export{U as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../core/has.js";import t from"../../core/Logger.js";import{throwIfAborted as i}from"../../core/promiseUtils.js";import{watch as r,on as s,syncAndInitial as l}from"../../core/reactiveUtils.js";import{sqlAnd as o}from"../../core/sql.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{getFeatureIdInfoFieldNames as u}from"../../layers/graphics/data/FeatureIdInfo.js";import{systemIsSpatialFieldName as d}from"../../layers/knowledgeGraph/constants.js";import{getEffectiveDisplayFilter as p}from"../../layers/support/displayFilterUtils.js";import f from"../../layers/support/FeatureEffect.js";import y from"../../layers/support/FeatureFilter.js";import{getSignedInUser as c}from"../../layers/support/featureLayerUtils.js";import{fixFields as h,unpackFieldNames as m,collectLabelingFields as F,collectElevationFields as g,collectFilterFields as I,collectFeatureReductionFields as b,collectOrderByInfos as w,collectFields as v,collectTrackInfoFields as E,collectDisplayFilterFields as x,collectField as q,featureHasFields as j}from"../../layers/support/fieldUtils.js";import{getFloorFilterClause as R}from"../../layers/support/floorFilterUtils.js";import{getUtilityNetworkFields as _}from"../../networks/support/networkFieldUtils.js";import O from"../../rest/support/Query.js";import{loadArcade as C}from"../../support/loadArcade.js";import{createFeatureIdInfo as k}from"../2d/layers/features/layerAdapters/featureServiceUtils.js";import{getRequiredFields as P,getFetchPopupTemplate as U}from"./support/popupUtils.js";import{WhereClauseVisitor as T}from"./support/WhereClauseVisitor.js";const A=A=>{let L=class extends A{constructor(...e){super(...e),this._updatingRequiredPromise=null,this.filter=null,this.layer=null,this.requiresCurrentUser=!1,this.requiredFields=[],this.view=null}initialize(){this.addHandles([r((()=>{const e=this.layer,t=this.view;return[e&&"elevationInfo"in e?e.elevationInfo?.featureExpressionInfo:null,e&&"displayField"in e?e.displayField:null,e&&"timeInfo"in e&&e.timeInfo,e&&"renderer"in e&&e.renderer,e&&"labelingInfo"in e&&e.labelingInfo,e&&"floorInfo"in e&&e.floorInfo,t?.requiredFieldsOptions?.featureTitleFields&&e&&"featureTitleFields"in e&&e.featureTitleFields,t?.requiredFieldsOptions?.utilityNetworkFields&&_(t,e),e.displayFilterInfo,this.displayFilterEnabled,this.filter,this.featureEffect,this.timeExtent,"knowledge-graph-sublayer"===e?.type&&"link-chart"===e.parentCompositeLayer.type&&e.parentCompositeLayer.linkChart?.linkChartProperties.nonspatialDataDisplay?.mode,"parquet"===e?.type&&e.popupTemplate]}),(()=>this._handleChange()),l),s((()=>this.view?.floors),"change",(()=>this._handleChange())),s((()=>this.layer.displayFilterInfo?.filters),"change",(()=>this._handleChange())),s((()=>this.layer&&"sublayers"in this.layer?this.layer.sublayers:null),"change",(()=>this._handleChange()))])}get availableFields(){if(!this.layer)return[];const{layer:e,layer:{fieldsIndex:t},requiredFields:i}=this;return"outFields"in e&&e.outFields?h(t,[...m(t,e.outFields),...i]):h(t,i)}get displayFilterEnabled(){return(this.view?.displayFilterEnabled??!0)&&(!("displayFilterEnabled"in this.layer)||(this.layer?.displayFilterEnabled??!0))}get effectiveDisplayFilter(){const e=this.layer;return this.displayFilterEnabled&&e.displayFilterInfo?p(e.displayFilterInfo,this.view):null}get featureEffect(){return this.layer&&"featureEffect"in this.layer?this.layer.featureEffect:null}set featureEffect(e){this._override("featureEffect",e)}get maximumNumberOfFeatures(){return 0}set maximumNumberOfFeatures(e){t.getLogger(this).error("#maximumNumberOfFeatures=","Setting maximum number of features is not supported")}get maximumNumberOfFeaturesExceeded(){return!1}get signedInUser(){return this.layer?.url?c(this.layer.url):Promise.resolve(null)}highlight(e,t){throw new Error("missing implementation")}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference},t=null!=this.filter?this.filter.createQuery(e):new O(e);return"floorInfo"in this.layer&&this.layer.floorInfo&&(t.where=o(t.where,R(this))),this.displayFilterEnabled&&(t.where=o(t.where,this.effectiveDisplayFilter?.where)),null!=this.timeExtent&&(t.timeExtent=null!=t.timeExtent?t.timeExtent.intersection(this.timeExtent):this.timeExtent.clone()),t}createAggregateQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return new O(e)}queryFeatures(e,t){throw new Error("missing implementation")}queryObjectIds(e,t){throw new Error("missing implementation")}queryFeatureCount(e,t){throw new Error("missing implementation")}queryExtent(e,t){throw new Error("missing implementation")}async fetchPopupFeaturesFromGraphics(e,t){return this._fetchPopupFeatures(e,t)}_loadArcadeModules(e){return e.expressionInfos?.length||Array.isArray(e.content)&&e.content.some((e=>"expression"===e.type))?C():Promise.resolve()}_handleChange(){const e=Promise.all([this._updateRequiredFields(),this._updateClientWhereClauseRequirements()]).then((()=>{}));return this._set("_updatingRequiredPromise",e),e.then((()=>{this._updatingRequiredPromise===e&&this._set("_updatingRequiredPromise",null)})),e}async _updateClientWhereClauseRequirements(){if(!this.layer||!this.view)return;const{layer:e}=this,i=new T(e.fieldsIndex);if(i.visitFilter(this.filter),"featureReduction"in e&&i.visitFeatureReduction(e.featureReduction),"labelingInfo"in e&&i.visitLabelingInfo(e.labelsVisible,e.labelingInfo),"trackInfo"in e&&i.visitTrackInfo(e.trackInfo),"2d"===this.view.type&&(i.visitFilter(this.featureEffect?.filter),i.visitDisplayFilter(this.displayFilterEnabled,e.displayFilterInfo),"featureReduction"in e&&i.visitFeatureReduction(e.featureReduction)),"subtype-group"===e.type)for(const t of e.sublayers)i.visitLabelingInfo(t.labelsVisible,t.labelingInfo);try{const e=await i.finish();this._set("requiresCurrentUser",e.requiresCurrentUser)}catch(r){t.getLogger(this).error(r)}}async _updateRequiredFields(){if(!this.layer||!this.view)return;const e="3d"===this.view.type,{layer:i,layer:{fieldsIndex:r}}=this,s="renderer"in i&&i.renderer,l="orderBy"in i&&i.orderBy,o="featureReduction"in i?i.featureReduction:null,n=new Set,a=[s?s.collectRequiredFields(n,r):null,F(n,i),e&&"elevationInfo"in i?g(n,i):null,null!=this.filter?I(n,i,this.filter):null,e||null==this.featureEffect?null:I(n,i,this.featureEffect.filter),!e&&o?b(n,i,o):null,!e&&l?w(n,i,l):null];if("timeInfo"in i&&i.timeInfo&&this.timeExtent&&v(n,i.fieldsIndex,[i.timeInfo.startField,i.timeInfo.endField]),"timeInfo"in i&&i.timeInfo&&"trackInfo"in i&&i.trackInfo){const{trackInfo:e}=i;v(n,i.fieldsIndex,[i.timeInfo.trackIdField]),"feature"!==i.type&&"startTimeField"!==e.timeField||v(n,i.fieldsIndex,[i.timeInfo.startField]),"endTimeField"===e.timeField&&v(n,i.fieldsIndex,[i.timeInfo.endField]),await E(n,i)}if("floorInfo"in i&&i.floorInfo&&v(n,i.fieldsIndex,[i.floorInfo.floorField]),"featureTitleFields"in i&&this.view?.requiredFieldsOptions?.featureTitleFields&&i.featureTitleFields&&v(n,i.fieldsIndex,i.featureTitleFields),"feature"===i.type&&i.globalIdField&&this.view?.requiredFieldsOptions?.globalIdField&&v(n,i.fieldsIndex,[i.globalIdField]),this.displayFilterEnabled&&a.push(x(n,i,i.displayFilterInfo)),"feature"===i.type&&e&&null!=i.infoFor3D&&(null==i.globalIdField&&t.getLogger(this).error("globalIdField missing on 3DObjectFeatureLayer"),v(n,i.fieldsIndex,[i.globalIdField])),"subtype-group"===i.type){q(n,r,i.subtypeField);const e=i.sublayers.map((e=>Promise.all([e.renderer?.collectRequiredFields(n,r),F(n,e)])));a.push(Promise.all(e))}if("catalog-footprint"===i.type&&i.parent){const e=i.parent;v(n,r,[e.itemNameField,e.itemSourceField,e.itemTypeField,e.maxScaleField,e.minScaleField])}"knowledge-graph-sublayer"===i.type&&"link-chart"===i.parentCompositeLayer.type&&q(n,r,d),"parquet"===i.type&&a.push(P(i,i.popupTemplate).then((e=>{for(const t of e)n.add(t)})));const p=await Promise.allSettled(a);if(e)q(n,r,i.objectIdField);else for(const t of u(k(i)))q(n,r,t);e&&"displayField"in i&&i.displayField&&q(n,r,i.displayField);for(const u of p)"rejected"===u.status&&t.getLogger(this).error(u.reason);const f=Array.from(n).sort();this._set("requiredFields",f)}_popupFeatureHasRequiredFields(e,t){return j(t,e)}async _fetchPopupFeatures(e,t){const r=new Array(e.length),s=new Map,l=new Map,n=await this._createPopupQuery(e.map((e=>e.origin?.layer??e.layer)),t);for(let o=0;o<e.length;o++){const a=e[o];if(a.isAggregate){r[o]=a;continue}const u=a.origin?.layer??a.layer;if(!u||!("popupEnabled"in u)||!u.popupEnabled)continue;const d=m(this.layer.fieldsIndex,n.outFields),p=U(u,t);if(null==p)continue;const f=await this._loadArcadeModules(p);i(t);if(f&&f.arcadeUtils.hasGeometryOperations(p)||!this._popupFeatureHasRequiredFields(a,d)){const e=a.getObjectId();if(null!=e){s.set(e,{graphic:a,index:o});continue}const t=a.getGlobalId();if(null!=t){l.set(t,{graphic:a,index:o});continue}}r[o]=a}if("stream"===this.layer.type||"parquet"===this.layer.type||0===s.size&&0===l.size)return r.filter(Boolean);const a=[];if(s.size>0){const e=n.clone();"uniqueIdFields"in this.layer&&this.layer.uniqueIdFields?.length&&(e.outFields??=[],e.outFields.push(...this.layer.uniqueIdFields)),e.objectIds=Array.from(s.keys()),a.push({type:"object-id",query:e,map:s})}const u="globalIdField"in this.layer?this.layer.globalIdField:null;if(null!=u&&l.size>0){const e=n.clone();e.outFields??=[],e.outFields.push(u);const t=Array.from(l.keys());e.where=o(n.where,`${u} IN (${t.map((e=>`'${e}'`)).join(",")})`),a.push({type:"global-id",query:e,map:l})}for(const{type:i,query:o,map:d}of a)try{const e=await this.layer.queryFeatures(o,t);for(const t of e.features){const e="object-id"===i?t.getObjectId():t.getGlobalId();if(null==e)continue;const s=d.get(e);if(!s)continue;const{graphic:{geometry:l,origin:o},index:n}=s;t.geometry||=l,t.origin=o,r[n]=t}}catch{}return r.filter(Boolean)}async _createPopupQuery(e,t){const r=this.layer.createQuery(),s=new Set;let l=!1;const n=e??[this.layer];for(const o of n){if(!("popupEnabled"in o))continue;const e=U(o,t);if(null==e)continue;const r=await this._loadArcadeModules(e);i(t);const n=r&&r.arcadeUtils.hasGeometryOperations(e);l=!("point"!==this.layer.geometryType&&!n);const a=await P(this.layer,e);i(t);for(const t of a)s.add(t)}return r.returnGeometry=l,r.returnZ=l,r.returnM=l,r.outFields=Array.from(s),r.outSpatialReference=this.view.spatialReference,"floorInfo"in this.layer&&this.layer.floorInfo&&(r.where=o(r.where,R(this))),r}canResume(){return!!super.canResume()&&(null==this.timeExtent||!this.timeExtent.isEmpty)}getTest(){}get test(){}};return e([n()],L.prototype,"_updatingRequiredPromise",void 0),e([n({readOnly:!0})],L.prototype,"availableFields",null),e([n({readOnly:!0})],L.prototype,"displayFilterEnabled",null),e([n({readOnly:!0})],L.prototype,"effectiveDisplayFilter",null),e([n({type:f})],L.prototype,"featureEffect",null),e([n({type:y})],L.prototype,"filter",void 0),e([n()],L.prototype,"layer",void 0),e([n({type:Number})],L.prototype,"maximumNumberOfFeatures",null),e([n({readOnly:!0,type:Boolean})],L.prototype,"maximumNumberOfFeaturesExceeded",null),e([n()],L.prototype,"requiresCurrentUser",void 0),e([n({readOnly:!0})],L.prototype,"requiredFields",void 0),e([n({readOnly:!0})],L.prototype,"signedInUser",null),e([n()],L.prototype,"suspended",void 0),e([n()],L.prototype,"view",void 0),L=e([a("esri.views.layers.FeatureLayerView")],L),L};export{A 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../core/Accessor.js";import i from"../../core/Error.js";import t from"../../core/Logger.js";import{someMap as s}from"../../core/MapUtils.js";import{createResolver as o,createAbortError as a,isAbortError as n}from"../../core/promiseUtils.js";import{on as l,watch as h,syncAndInitial as y}from"../../core/reactiveUtils.js";import{schedule as p}from"../../core/scheduling.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{get as w}from"../../core/accessorSupport/get.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import{destroyMap as m}from"../../support/collectionUtils.js";import{LayerLayerViewInfo as u}from"./LayerLayerViewInfo.js";function g(e){return null!=e&&"object"==typeof e&&"layerViews"in e}let _=class extends r{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._recyclingInfoMap=new Map,this._watchUpdatingTracking=new f,this.supportsGround=!0,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>this.destroyed?Promise.reject():(null==this._workPromise&&(this._workPromise=o(),this._workPromise.promise.catch((()=>{}))),this.removeHandles("reschedule"),this.addHandles(p(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{const e=this.view.map;if(this.destroyed||!e)return void this.clear();if(this._map!==e&&(this.clear(),this._map=e),null==this._workPromise)return void this.notifyChange("updating");this.removeHandles("reschedule"),this.removeHandles("collection-change");const r=new Set,i=[],t=this.view.ready,s=e=>{if(null!=e)for(const o of e)if(o){r.add(o);const e=this._layerLayerViewInfoMap.get(o);e&&t?e.start():e||this._recyclingInfoMap.has(o)||i.push(o),"layers"in o&&o.layers&&s(o.layers)}};for(const n of this._rootCollectionNames)s(w(this,n));const o=[];for(const[n,l]of this._layerLayerViewInfoMap)if(!r.has(n)){this._layerLayerViewInfoMap.delete(l.layer);const e=l.tryRecycle(i);e?(this._recyclingInfoMap.set(l.layer,l),this.notifyChange("updating"),e.then((()=>{this._recyclingInfoMap.delete(l.layer),this._layerLayerViewInfoMap.set(l.layer,l),this._reschedule(),this.notifyChange("updating")})).catch((()=>{this._recyclingInfoMap.delete(l.layer),l.destroy(),this._reschedule(),this.notifyChange("updating")}))):o.push(l)}for(const[n,l]of this._recyclingInfoMap)r.has(n)||(this.notifyChange("updating"),this._recyclingInfoMap.delete(l.layer),o.push(l));for(const n of i)this._createLayerView(n);this._refreshCollections(),o.forEach((e=>e.destroy()));const a=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.referenceLayers,e?.layers].filter((e=>!!e));r.forEach((e=>"layers"in e&&a.push(e.layers))),this.addHandles(a.map((e=>this._watchUpdatingTracking.addOnCollectionChange((()=>e),this._reschedule))),"collection-change"),this._workPromise.resolve(),this._workPromise=null}}initialize(){this.addHandles([l((()=>this.view?.map?.allLayers),"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),h((()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]}),(()=>this._reschedule()),y)]),this._preloadLayerViewModules(),this._reschedule()}destroy(){this.clear(),m(this._recyclingInfoMap),m(this._layerLayerViewInfoMap),this._watchUpdatingTracking.destroy(),this._map=null,null!=this._workPromise&&(this._workPromise.reject(a()),this._workPromise=null)}get _layersToLayerViews(){const e=[["view.map.basemap.baseLayers","view.basemapView.baseLayerViews"],["view.map.layers","view.layerViews"],["view.map.basemap.referenceLayers","view.basemapView.referenceLayerViews"]];return this.supportsGround&&e.push(["view.map.ground.layers","view.groundView.layerViews"]),new Map(e)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return null!=this._workPromise||this._watchUpdatingTracking.updating||s(this._layerLayerViewInfoMap,(e=>!e.done))||this._recyclingInfoMap.size>0}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){this.destroyed||(this._clearCollections(),m(this._layerLayerViewInfoMap))}async whenLayerView(e){if(await this._reschedule(),!this._layerLayerViewInfoMap.has(e)){if(this._recyclingInfoMap.has(e))return this._recyclingInfoMap.get(e).promise;throw new i("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e})}return this._layerLayerViewInfoMap.get(e).promise}isCreatingLayerViewsForLayer(e,r){this.commitProperty("updatingRemaining");const i=this._layerLayerViewInfoMap.get(e);if(!i?.done)return!0;const t=i.layerView;return!(!t||!r||t.parent===r)||!!(i.done&&t&&"layers"in e&&e.layers?.length)&&e.layers.some((e=>this.isCreatingLayerViewsForLayer(e,t)))}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(w(this,e),w(this,r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining")}_clearCollections(){for(const e of this._layersToLayerViews.values())w(this,e)?.removeAll()}_populateLayerViewsOwners(e,r,i){if(!e||!r)return void r?.removeAll();let t=0;for(const s of e){const e=this._layerLayerViewInfoMap.get(s);if(!e?.layerView)continue;const o=e.layerView;o.layer=s,o.parent=i,r.at(t)!==o&&r.splice(t,0,o),"layers"in s&&g(o)&&this._populateLayerViewsOwners(s.layers,o.layerViews,o),t+=1}t<r.length&&r.splice(t)}_createLayerView(e){e.load().catch((()=>{})),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new u(e,this.view,this.layerViewImporter);r.promise.then((()=>this._refreshCollections()),(r=>{r&&(n(r)||"cancelled:layerview-create"===r.name)||t.getLogger(this).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this._refreshCollections()})),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining")}};e([c()],_.prototype,"_workPromise",void 0),e([c({readOnly:!0})],_.prototype,"_watchUpdatingTracking",void 0),e([c({readOnly:!0})],_.prototype,"_layersToLayerViews",null),e([c({readOnly:!0})],_.prototype,"_rootCollectionNames",null),e([c()],_.prototype,"layerViewImporter",void 0),e([c()],_.prototype,"supportsGround",void 0),e([c({readOnly:!0})],_.prototype,"updating",null),e([c({readOnly:!0})],_.prototype,"updatingRemaining",null),e([c({constructOnly:!0})],_.prototype,"view",void 0),_=e([d("esri.views.support.LayerViewManager")],_);const V=_;export{V as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../core/Accessor.js";import i from"../../core/Error.js";import t from"../../core/Logger.js";import{someMap as s}from"../../core/MapUtils.js";import{createResolver as o,createAbortError as a,isAbortError as n}from"../../core/promiseUtils.js";import{on as l,watch as h,syncAndInitial as y}from"../../core/reactiveUtils.js";import{schedule as p}from"../../core/scheduling.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{get as w}from"../../core/accessorSupport/get.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import{destroyMap as m}from"../../support/collectionUtils.js";import{LayerLayerViewInfo as u}from"./LayerLayerViewInfo.js";function g(e){return null!=e&&"object"==typeof e&&"layerViews"in e}let _=class extends r{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._recyclingInfoMap=new Map,this._watchUpdatingTracking=new f,this.supportsGround=!0,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)!1!==this.layerViewFilter?.(r)&&this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>this.destroyed?Promise.reject():(null==this._workPromise&&(this._workPromise=o(),this._workPromise.promise.catch((()=>{}))),this.removeHandles("reschedule"),this.addHandles(p(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{const e=this.view.map;if(this.destroyed||!e)return void this.clear();if(this._map!==e&&(this.clear(),this._map=e),null==this._workPromise)return void this.notifyChange("updating");this.removeHandles("reschedule"),this.removeHandles("collection-change");const r=new Set,i=[],t=this.view.ready,s=e=>{if(null!=e)for(const o of e)if(o){if(!1===this.layerViewFilter?.(o))continue;r.add(o);const e=this._layerLayerViewInfoMap.get(o);e&&t?e.start():e||this._recyclingInfoMap.has(o)||i.push(o),"layers"in o&&o.layers&&s(o.layers)}};for(const n of this._rootCollectionNames)s(w(this,n));const o=[];for(const[n,l]of this._layerLayerViewInfoMap)if(!r.has(n)){this._layerLayerViewInfoMap.delete(l.layer);const e=l.tryRecycle(i);e?(this._recyclingInfoMap.set(l.layer,l),this.notifyChange("updating"),e.then((()=>{this._recyclingInfoMap.delete(l.layer),this._layerLayerViewInfoMap.set(l.layer,l),this._reschedule(),this.notifyChange("updating")})).catch((()=>{this._recyclingInfoMap.delete(l.layer),l.destroy(),this._reschedule(),this.notifyChange("updating")}))):o.push(l)}for(const[n,l]of this._recyclingInfoMap)r.has(n)||(this.notifyChange("updating"),this._recyclingInfoMap.delete(l.layer),o.push(l));for(const n of i)this._createLayerView(n);this._refreshCollections(),o.forEach((e=>e.destroy()));const a=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.referenceLayers,e?.layers].filter((e=>!!e));r.forEach((e=>"layers"in e&&a.push(e.layers))),this.addHandles(a.map((e=>this._watchUpdatingTracking.addOnCollectionChange((()=>e),this._reschedule))),"collection-change"),this._workPromise.resolve(),this._workPromise=null}}initialize(){this.addHandles([l((()=>this.view?.map?.allLayers),"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),h((()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]}),(()=>this._reschedule()),y)]),this._preloadLayerViewModules(),this._reschedule()}destroy(){this.clear(),m(this._recyclingInfoMap),m(this._layerLayerViewInfoMap),this._watchUpdatingTracking.destroy(),this._map=null,null!=this._workPromise&&(this._workPromise.reject(a()),this._workPromise=null)}get _layersToLayerViews(){const e=[["view.map.basemap.baseLayers","view.basemapView.baseLayerViews"],["view.map.layers","view.layerViews"],["view.map.basemap.referenceLayers","view.basemapView.referenceLayerViews"]];return this.supportsGround&&e.push(["view.map.ground.layers","view.groundView.layerViews"]),new Map(e)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return null!=this._workPromise||this._watchUpdatingTracking.updating||s(this._layerLayerViewInfoMap,(e=>!e.done))||this._recyclingInfoMap.size>0}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){this.destroyed||(this._clearCollections(),m(this._layerLayerViewInfoMap))}async whenLayerView(e){if(await this._reschedule(),!this._layerLayerViewInfoMap.has(e)){if(this._recyclingInfoMap.has(e))return this._recyclingInfoMap.get(e).promise;throw new i("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e})}return this._layerLayerViewInfoMap.get(e).promise}isCreatingLayerViewsForLayer(e,r){this.commitProperty("updatingRemaining");const i=this._layerLayerViewInfoMap.get(e);if(!i?.done)return!0;const t=i.layerView;return!(!t||!r||t.parent===r)||!!(i.done&&t&&"layers"in e&&e.layers?.length)&&e.layers.some((e=>this.isCreatingLayerViewsForLayer(e,t)))}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(w(this,e),w(this,r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining")}_clearCollections(){for(const e of this._layersToLayerViews.values())w(this,e)?.removeAll()}_populateLayerViewsOwners(e,r,i){if(!e||!r)return void r?.removeAll();let t=0;for(const s of e){const e=this._layerLayerViewInfoMap.get(s);if(!e?.layerView)continue;const o=e.layerView;o.layer=s,o.parent=i,r.at(t)!==o&&r.splice(t,0,o),"layers"in s&&g(o)&&this._populateLayerViewsOwners(s.layers,o.layerViews,o),t+=1}t<r.length&&r.splice(t)}_createLayerView(e){e.load().catch((()=>{})),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new u(e,this.view,this.layerViewImporter);r.promise.then((()=>this._refreshCollections()),(r=>{r&&(n(r)||"cancelled:layerview-create"===r.name)||t.getLogger(this).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this._refreshCollections()})),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining")}};e([c()],_.prototype,"_workPromise",void 0),e([c({readOnly:!0})],_.prototype,"_watchUpdatingTracking",void 0),e([c({readOnly:!0})],_.prototype,"_layersToLayerViews",null),e([c({readOnly:!0})],_.prototype,"_rootCollectionNames",null),e([c({constructOnly:!0})],_.prototype,"layerViewFilter",void 0),e([c()],_.prototype,"layerViewImporter",void 0),e([c()],_.prototype,"supportsGround",void 0),e([c({readOnly:!0})],_.prototype,"updating",null),e([c({readOnly:!0})],_.prototype,"updatingRemaining",null),e([c({constructOnly:!0})],_.prototype,"view",void 0),_=e([d("esri.views.support.LayerViewManager")],_);const V=_;export{V 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{getBasisEncoder as e}from"../../libs/basisu/BasisUEncoder.js";import{TextureFormat as t}from"../../libs/basisu/TextureFormat.js";import{getDXTEncoder as n}from"../../libs/dxtEncoder/DXTEncoder.js";import{CompressedTextureFormat as r}from"../webgl/enums.js";let a,s,l=null,i=null;class o{constructor(e,t){this.internalFormat=e,this.compressedTexture=t}}async function u(e){let t=m(e.data);if(e.hasS3TC){i||await h();const n=new Uint8Array(t.length);if(i?.encode(t,e.width,e.height,e.premultiplyAlpha,n)){const e=R(n,!0),t=[n.buffer];return{result:new o(e?.internalFormat??null,e?.textureData??null),transferList:t}}return{result:new o(null,null)}}if(e.hasETC){if(l||await c(),e.premultiplyAlpha&&!i&&await h(),e.premultiplyAlpha){const n=new Uint8ClampedArray(t.length);i?.premultiply(new Uint8Array(t),e.width,e.height,n),t=n}const n=await f(t,e.width,e.height,e.hasMipmap),r=n?await d(n):null,a=r?.compressedTexture?.levels.map((e=>e.buffer))||[];return{result:new o(r?.internalFormat??null,r?.compressedTexture??null),transferList:a}}return{result:new o(null,null)}}async function c(){l||(l=await(a??=e()))}async function h(){i||(i=await(s??=n()))}async function f(e,t,n,r,a=255,s=0,i=!1,o=!1){if(!l)return null;const u=new l.BasisEncoder;u.setPerceptual(!o),u.setCheckForAlpha(!0),u.setForceAlpha(!1),u.setRenormalize(o),u.setMipGen(r),u.setMipSRGB(!o),u.setCreateKTX2File(!0),u.setKTX2SRGBTransferFunc(!o),u.setQualityLevel(a),u.setCompressionLevel(s);const c=new Uint8Array(e.byteLength);u.setSliceSourceImage(0,new Uint8Array(e),t,n,i);const h=u.encode(c),f=new Uint8Array(c.buffer,0,h),d=new l.KTX2File(new Uint8Array(f));return d.isValid()?(u.delete(),f):(d.close(),d.delete(),u.delete(),null)}async function d(e){if(!l)return new o(null,null);const n=new l.KTX2File(new Uint8Array(e));n.startTranscoding();const[a,s]=n.getHasAlpha()?[t.ETC2_RGBA,r.COMPRESSED_RGBA8_ETC2_EAC]:[t.ETC1_RGB,r.COMPRESSED_RGB8_ETC2],i=n.getLevels(),u=[];for(let t=0;t<i;t++)u.push(new Uint8Array(n.getImageTranscodedSizeInBytes(t,0,0,a))),n.transcodeImage(u[t],t,0,0,a,0,-1,-1);return n.close(),n.delete(),{internalFormat:s,compressedTexture:{type:"compressed",levels:u}}}function m(e){const t=new OffscreenCanvas(e.width,e.height),n=t.getContext("2d");n.drawImage(e,0,0);return n.getImageData(0,0,t.width,t.height).data}const p=31,w=1,T=2,y=3,A=4,C=7,E=21,g=131072;function S(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}const _=S("DXT1"),b=S("DXT3"),D=S("DXT5");function R(e,t){const n=new Int32Array(e.buffer,e.byteOffset,p);let a,s;switch(n[E]){case _:a=8,s=r.COMPRESSED_RGB_S3TC_DXT1_EXT;break;case b:a=16,s=r.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case D:a=16,s=r.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return null}let l=1,i=n[A],o=n[y];(3&i||3&o)&&(i=i+3&-4,o=o+3&-4);const u=i,c=o;let h,f;n[T]&g&&!1!==t&&(l=Math.max(1,n[C]));let d=e.byteOffset+n[w]+4;const m=[];for(let r=0;r<l;++r)f=(i+3>>2)*(o+3>>2)*a,h=new Uint8Array(e.buffer,d,f),m.push(h),d+=f,i=Math.max(1,i>>1),o=Math.max(1,o>>1);return{textureData:{type:"compressed",levels:m},internalFormat:s,width:u,height:c}}export{o as TextureCompressionWorkerOutput,u as compress,f as compressRGBADataToKTX2,d as createTextureDataKTX2,c as initializeBasisEncoder,h as initializeDXTEncoder};
5
+ import{getBasisEncoder as e}from"../../libs/basisu/BasisUEncoder.js";import{TextureFormat as t}from"../../libs/basisu/TextureFormat.js";import{getDXTEncoder as n}from"../../libs/dxtEncoder/DXTEncoder.js";import{CompressedTextureFormat as r}from"../webgl/enums.js";let a,s,l=null,i=null;class o{constructor(e,t){this.internalFormat=e,this.compressedTexture=t}}async function u(e){let t=d(e.bitmap);if(e.hasS3TC){i||await h();const n=new Uint8Array(t.length);if(i?.encode(t,e.width,e.height,e.preMultiplyAlpha,n)){const e=R(n,!0),t=[n.buffer];return{result:new o(e?.internalFormat??null,e?.textureData??null),transferList:t}}return{result:new o(null,null)}}if(e.hasETC){if(l||await c(),e.preMultiplyAlpha&&!i&&await h(),e.preMultiplyAlpha){const n=new Uint8ClampedArray(t.length);i?.premultiply(new Uint8Array(t),e.width,e.height,n),t=n}const n=await f(t,e.width,e.height,e.hasMipmap),r=n?await p(n):null,a=r?.compressedTexture?.levels.map((e=>e.buffer))||[];return{result:new o(r?.internalFormat??null,r?.compressedTexture??null),transferList:a}}return{result:new o(null,null)}}async function c(){l||(l=await(a??=e()))}async function h(){i||(i=await(s??=n()))}async function f(e,t,n,r,a=255,s=0,i=!1,o=!1){if(!l)return null;const u=new l.BasisEncoder;u.setPerceptual(!o),u.setCheckForAlpha(!0),u.setForceAlpha(!1),u.setRenormalize(o),u.setMipGen(r),u.setMipSRGB(!o),u.setCreateKTX2File(!0),u.setKTX2SRGBTransferFunc(!o),u.setQualityLevel(a),u.setCompressionLevel(s);const c=new Uint8Array(e.byteLength);u.setSliceSourceImage(0,new Uint8Array(e),t,n,i);const h=u.encode(c),f=new Uint8Array(c.buffer,0,h),p=new l.KTX2File(new Uint8Array(f));return p.isValid()?(u.delete(),f):(p.close(),p.delete(),u.delete(),null)}async function p(e){if(!l)return new o(null,null);const n=new l.KTX2File(new Uint8Array(e));n.startTranscoding();const[a,s]=n.getHasAlpha()?[t.ETC2_RGBA,r.COMPRESSED_RGBA8_ETC2_EAC]:[t.ETC1_RGB,r.COMPRESSED_RGB8_ETC2],i=n.getLevels(),u=[];for(let t=0;t<i;t++)u.push(new Uint8Array(n.getImageTranscodedSizeInBytes(t,0,0,a))),n.transcodeImage(u[t],t,0,0,a,0,-1,-1);return n.close(),n.delete(),{internalFormat:s,compressedTexture:{type:"compressed",levels:u}}}function d(e){const t=new OffscreenCanvas(e.width,e.height),n=t.getContext("2d");n.drawImage(e,0,0);return n.getImageData(0,0,t.width,t.height).data}const m=31,w=1,T=2,y=3,A=4,C=7,E=21,g=131072;function S(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}const _=S("DXT1"),b=S("DXT3"),D=S("DXT5");function R(e,t){const n=new Int32Array(e.buffer,e.byteOffset,m);let a,s;switch(n[E]){case _:a=8,s=r.COMPRESSED_RGB_S3TC_DXT1_EXT;break;case b:a=16,s=r.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case D:a=16,s=r.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return null}let l=1,i=n[A],o=n[y];(3&i||3&o)&&(i=i+3&-4,o=o+3&-4);const u=i,c=o;let h,f;n[T]&g&&!1!==t&&(l=Math.max(1,n[C]));let p=e.byteOffset+n[w]+4;const d=[];for(let r=0;r<l;++r)f=(i+3>>2)*(o+3>>2)*a,h=new Uint8Array(e.buffer,p,f),d.push(h),p+=f,i=Math.max(1,i>>1),o=Math.max(1,o>>1);return{textureData:{type:"compressed",levels:d},internalFormat:s,width:u,height:c}}export{o as TextureCompressionWorkerOutput,u as compress,f as compressRGBADataToKTX2,p as createTextureDataKTX2,c as initializeBasisEncoder,h as initializeDXTEncoder};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{isPowerOfTwo as e}from"../../core/mathUtils.js";import{WorkerHandle as r}from"../../core/workers/WorkerHandle.js";function s(r){return(r instanceof HTMLImageElement||r instanceof HTMLCanvasElement)&&e(r.width)&&e(r.height)&&r.width>=16&&r.height>=16}class t extends r{constructor(e){super("TextureCompressionWorker","compress",{compress:e=>[e.data]},e)}isCompressible(e){return s(e)}}export{t as TextureCompressionWorkerHandle,s as isCompressible};
5
+ import{isPowerOfTwo as e}from"../../core/mathUtils.js";import{WorkerHandle as r}from"../../core/workers/WorkerHandle.js";function s(r){return(r instanceof HTMLImageElement||r instanceof HTMLCanvasElement)&&e(r.width)&&e(r.height)&&r.width>=16&&r.height>=16}class t extends r{constructor(e){super("TextureCompressionWorker","compress",{compress:e=>[e.bitmap]},e)}isCompressible(e){return s(e)}}export{t as TextureCompressionWorkerHandle,s as isCompressible};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import"../../core/has.js";import{disposeMaybe as t}from"../../core/maybe.js";import{after as e}from"../../core/promiseUtils.js";import{Milliseconds as s}from"../../core/time.js";import{webglDebugEnabled as i,checkWebGLError as a}from"./checkWebGLError.js";import{ContextState as r}from"./ContextState.js";import{SpecialDrawBuffers as n,ColorAttachment0 as l,BufferType as h,Face as f,baseTextureUnit as o,FramebufferBit as u,BufferContent as c,FramebufferTarget as _,TextureSamplingMode as d,SyncCondition as b,ResourceType as F,ClientWaitSyncStatus as g,BlendFactor as B,BlendOperation as p,CullMode as m,CompareFunction as E,StencilOperation as R,TextureType as T,PrimitiveType as A}from"./enums.js";import{InstanceCounter as O}from"./InstanceCounter.js";import{Parameters as C}from"./Parameters.js";import{ProgramCache as x}from"./ProgramCache.js";import{StateTracker as U}from"./renderState.js";import{Texture as k}from"./Texture.js";import{getErrorString as w}from"./Util.js";import{WebGLDriverTest as S}from"./WebGLDriverTest.js";import{Capabilities as y}from"./capabilities/Capabilities.js";let v=class{constructor(t,e){this.gl=t,this.instanceCounter=new O,this.programCache=new x(this),this._transformFeedbackRequestInfo=null,this._state=new r,this._numOfDrawCalls=0,this._numOfTriangles=0,this.configure(e)}configure(e){this._capabilities=new y(this.gl,e),this._parameters=new C(this.gl,this._capabilities,e),k.TEXTURE_UNIT_FOR_UPDATES=this._parameters.maxTextureImageUnits-1;const s=this.gl.getParameter(this.gl.VIEWPORT);this._state=new r,this._state.viewport={x:s[0],y:s[1],width:s[2],height:s[3]},this._stateTracker=new U({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)},setDrawBuffers:t=>{if(t)this.setDrawBuffers(t.buffers);else{const{drawFramebuffer:t}=this._state;null===t?this.setDrawBuffers([n.BACK]):0===t.colorAttachments.length?this.setDrawBuffers([n.NONE]):this.setDrawBuffers([l])}}}),this.enforceState(),t(this._driverTest),this._driverTest=new S(this)}updateOptions(t){this._parameters=new C(this.gl,this._capabilities,t)}dispose(){t(this._driverTest),this.programCache.dispose(),this.bindVAO(null),this.unbindBuffer(h.ARRAY_BUFFER),this.unbindBuffer(h.ELEMENT_ARRAY_BUFFER),this.unbindBuffer(h.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(h.PIXEL_PACK_BUFFER),this.unbindBuffer(h.PIXEL_UNPACK_BUFFER),this.unbindBuffer(h.COPY_READ_BUFFER),this.unbindBuffer(h.COPY_WRITE_BUFFER),this._state.textureUnitMap.length=0,i()&&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(){this.gl.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=f.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===f.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=f.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(o+t),this._state.activeTexture=t),s}setDrawBuffers(t){const{drawFramebuffer:e}=this._state,s=null===e,i=s?this._state.drawBuffers.defaultFramebuffer:this._state.drawBuffers.fbos.get(e);if(i?.length!==t.length||!i.every(((e,s)=>e===t[s])))if(t.length>this.parameters.maxDrawBuffers)console.error("Setting more active draw buffers than GL.MAX_DRAW_BUFFERS allows.");else{if(s){if(t.length>1)return void console.error("The default framebuffer can only have one active draw buffer.");if(t[0]!==n.BACK&&t[0]!==n.NONE)return void console.error("The default framebuffer can only use the constants GL.BACK or GL.NONE as draw buffers.")}s||!t.includes(n.BACK)?(this.gl.drawBuffers(t),s?this._state.drawBuffers.defaultFramebuffer=t:this._state.drawBuffers.fbos.set(e,t),this._stateTracker.invalidateDrawBuffers()):console.error("A framebuffer object can only use the constants GL.COLOR_ATTACHMENTi or GL.NONE as draw buffers.")}}clear(t,e=255){if(t){if(t&u.COLOR){const t=this._state.drawFramebuffer?.colorAttachments;t&&this.setDrawBuffers(t),this.setColorMask(!0,!0,!0,!0)}t&u.DEPTH&&this.setDepthWriteEnabled(!0),t&u.STENCIL&&this.setStencilWriteMask(e),this.gl.clear(t)}}clearFramebuffer(t,e=!1,s=!1){let i=0;if(t){const e=1e-13,s=Math.max(e,t[3]);this.setClearColor(t[0],t[1],t[2],s),i|=u.COLOR}e&&(i|=u.DEPTH),!1===s?s=0:(!0===s&&(s=255),i|=u.STENCIL),i&&this.clear(i,s)}clearBuffer(t,e,s=c.COLOR,i=void 0){this.gl.clearBufferfv(s,t,e,i)}clearBufferInteger(t,e,s=c.COLOR,i=void 0){this.gl.clearBufferiv(s,t,e,i)}clearBufferUnsignedInteger(t,e,s=c.COLOR,i=void 0){this.gl.clearBufferuiv(s,t,e,i)}drawArrays(t,e,s){if(this._transformFeedbackRequestInfo){if(t!==this._transformFeedbackRequestInfo.primitiveType)throw new Error("DrawArrays called during transform feedback, but primitiveType does not match that of the current transform feedback request");if(null==this._state.program?.hasTransformFeedbackVaryings)throw new Error("DrawArrays called during transform feedback, but the shader program was not linked with a transform feedback varying")}if(i()){this._numOfDrawCalls++,this._numOfTriangles+=D(t,s);const e=this._state.textureUnitMap;for(let t=0;t<e.length;t++){const s=e[t];if(null!=s&&s===this._state.drawFramebuffer?.colorTexture)throw new Error(`Detected readWrite. Texture already bound at index ${t}`)}}this.gl.drawArrays(t,e,s),a(this.gl)}drawArraysInstanced(t,e,s,i){this.gl.drawArraysInstanced(t,e,s,i),a(this.gl)}drawElements(t,e,s,a){if(this._transformFeedbackRequestInfo)throw new Error("Cannot called drawElements during a transform feedback request");if(i()&&(this._numOfDrawCalls++,this._numOfTriangles+=D(t,e)),this.gl.drawElements(t,e,s,a),i()){const i=w(this);if(i){const r=this.getBoundVAO(),n=r?.indexBuffer,l=r?.vertexBuffers,h={indexBuffer:n,vertexBuffers:l},f={mode:t,count:e,type:s,offset:a},o=n?.size??0,u=a+e,c=o<u?`. Buffer is too small. Attempted to draw index ${u} of ${o}`:"";console.error(`drawElements: ${i}${c}`,{args:f,vao:h})}}}drawElementsInstanced(t,e,s,i,r){this.gl.drawElementsInstanced(t,e,s,i,r),a(this.gl)}logInfo(){i()&&console.log(`DrawCalls: ${this._numOfDrawCalls}, Triangles: ${this._numOfTriangles}`)}resetInfo(){i()&&(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))}setViewport4fv(t){this.setViewport(t[0],t[1],t[2],t[3])}restoreViewport({x:t,y:e,width:s,height:i}){this.setViewport(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,s=!1){(e>=this.parameters.maxTextureImageUnits||e<0)&&console.error("Input texture unit is out of range of available units!");const i=this._state.textureUnitMap[e];return null==t?.glName?(null!=i&&(this.setActiveTexture(e,s),this.gl.bindTexture(i.descriptor.target,null)),this._state.textureUnitMap[e]=null,i):s||i!==t?(this.setActiveTexture(e,s),this.gl.bindTexture(t.descriptor.target,t.glName),t.applyChanges(),this._state.textureUnitMap[e]=t,i):(t.isDirty&&(this.setActiveTexture(e,s),t.applyChanges()),i)}unbindTexture(t){if(null!=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(this._stateTracker.invalidateDrawBuffers(),null==t)return this.gl.bindFramebuffer(_.FRAMEBUFFER,null),void(this._state.readFramebuffer=this._state.drawFramebuffer=null);t.initializeAndBind(_.FRAMEBUFFER),this._state.readFramebuffer=t,this._state.drawFramebuffer=t}}bindFramebufferSeparate(t,e,s=!1){const i=e===_.READ_FRAMEBUFFER,a=i?this._state.readFramebuffer:this._state.drawFramebuffer;(s||a!==t)&&(null==t?this.gl.bindFramebuffer(e,null):t.initializeAndBind(e),i?this._state.readFramebuffer=t??null:(this._stateTracker.invalidateDrawBuffers(),this._state.drawFramebuffer=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=u.COLOR,c=d.NEAREST){this.bindFramebufferSeparate(t,_.READ_FRAMEBUFFER,!0),this.bindFramebufferSeparate(e,_.DRAW_FRAMEBUFFER,!0),this.gl.blitFramebuffer(s,i,a,r,n,l,h,f,o,c)}bindBuffer(t,e){if(t)switch(e??=t.bufferType,e){case h.ARRAY_BUFFER:this._state.vertexBuffer=N(this.gl,t,e,this._state.vertexBuffer);break;case h.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=N(this.gl,t,e,this._state.indexBuffer);break;case h.UNIFORM_BUFFER:this._state.uniformBuffer=N(this.gl,t,e,this._state.uniformBuffer);break;case h.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=N(this.gl,t,e,this._state.pixelPackBuffer);break;case h.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=N(this.gl,t,e,this._state.pixelUnpackBuffer);break;case h.COPY_READ_BUFFER:this._state.copyReadBuffer=N(this.gl,t,e,this._state.copyReadBuffer);break;case h.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=N(this.gl,t,e,this._state.copyWriteBuffer);break;case h.TRANSFORM_FEEDBACK_BUFFER:this._state.transformFeedbackBuffer=N(this.gl,t,e,this._state.transformFeedbackBuffer)}}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 s=t===h.UNIFORM_BUFFER?this._state.uniformBufferBindingPoints:this._state.transformBufferBindingPoints;let i=s[e];return null==i&&(i={buffer:null,offset:0,size:0},s[e]=i),i}bindBufferBase(t,e,s){const i=this._getBufferBinding(t,e);null!=i&&(i.buffer===s&&0===i.offset&&0===i.size||(this.gl.bindBufferBase(t,e,s?s.glName:null),i.buffer=s,i.offset=0,i.size=0))}bindBufferRange(t,e,s,i,a){const r=this._getBufferBinding(t,e);null!=r&&(r.buffer===s&&r.offset===i&&r.size===a||(i%this._parameters.uniformBufferOffsetAlignment==0?(this.gl.bindBufferRange(t,e,s.glName,i,a),r.buffer=s,r.offset=i,r.size=a):console.error("Uniform buffer binding offset is not a multiple of the context offset alignment")))}bindUBO(t,e,s,a){null!=e?(i()&&(a??e.byteLength)>this._parameters.maxUniformBlockSize&&console.error("Attempting to bind more data than the maximum uniform block size"),e.initialize(),void 0!==s&&void 0!==a?this.bindBufferRange(h.UNIFORM_BUFFER,t,e.buffer,s,a):this.bindBufferBase(h.UNIFORM_BUFFER,t,e.buffer)):this.bindBufferBase(h.UNIFORM_BUFFER,t,null)}unbindUBO(t){for(let e=0,s=this._state.uniformBufferBindingPoints.length;e<s;e++){const s=this._state.uniformBufferBindingPoints[e];null!=s&&s.buffer===t.buffer&&this.bindBufferBase(h.UNIFORM_BUFFER,e,null)}}unbindBuffer(t){switch(t){case h.ARRAY_BUFFER:this._state.vertexBuffer=N(this.gl,null,t,this._state.vertexBuffer);break;case h.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=N(this.gl,null,t,this._state.indexBuffer);break;case h.UNIFORM_BUFFER:this._state.uniformBuffer=N(this.gl,null,t,this._state.uniformBuffer);break;case h.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=N(this.gl,null,t,this._state.pixelPackBuffer);break;case h.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=N(this.gl,null,t,this._state.pixelUnpackBuffer);break;case h.COPY_READ_BUFFER:this._state.copyReadBuffer=N(this.gl,null,t,this._state.copyReadBuffer);break;case h.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=N(this.gl,null,t,this._state.copyWriteBuffer)}}bindVAO(t=null){null!=t?this._state.vertexArrayObject!==t&&(t.bind(),this._state.vertexArrayObject=t):this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null)}bindTransformFeedback(t){const{gl:e}=this;e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,t.glName)}beginTransformFeedback(t,e){if(this._transformFeedbackRequestInfo)throw new Error("Already in a transform feedback request");const{gl:s}=this;s.bindTransformFeedback(s.TRANSFORM_FEEDBACK,t.glName),s.beginTransformFeedback(e),this._transformFeedbackRequestInfo={primitiveType:e}}endTransformFeedback(){if(!this._transformFeedbackRequestInfo)throw new Error("Not in a transform feedback request");const{gl:t}=this;t.endTransformFeedback(),t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null),this._transformFeedbackRequestInfo=null}async clientWaitAsync(t=s(10)){const{gl:i}=this,a=i.fenceSync(b.SYNC_GPU_COMMANDS_COMPLETE,0);if(!a)throw new Error("Client wait failed, could not create sync object");let r;this.instanceCounter.increment(F.Sync,a),i.flush();do{await e(t),r=i.clientWaitSync(a,0,0)}while(r===g.TIMEOUT_EXPIRED);if(this.instanceCounter.decrement(F.Sync,a),i.deleteSync(a),r===g.WAIT_FAILED)throw new Error("Client wait failed")}getBoundFramebufferObject(t=_.FRAMEBUFFER){return t===_.READ_FRAMEBUFFER?this._state.readFramebuffer:this._state.drawFramebuffer}temporaryBindFramebufferObject(t,e){const s=this.getBoundFramebufferObject();try{t&&this.bindFramebuffer(t),e()}finally{this.bindFramebuffer(s)}}getBoundVAO(){return this._state.vertexArrayObject}resetState(){this.useProgram(null),this.bindVAO(null),this.bindFramebuffer(null,!0),this.unbindBuffer(h.ARRAY_BUFFER),this.unbindBuffer(h.ELEMENT_ARRAY_BUFFER),this.unbindBuffer(h.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(h.PIXEL_PACK_BUFFER),this.unbindBuffer(h.PIXEL_UNPACK_BUFFER),this.unbindBuffer(h.COPY_READ_BUFFER),this.unbindBuffer(h.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(f.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(E.LESS),this.setDepthRange(0,1),this.setStencilTestEnabled(!1),this.setStencilFunction(E.ALWAYS,0,0),this.setStencilOp(R.KEEP,R.KEEP,R.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.setDrawBuffers([n.BACK]),this.setViewport(0,0,this.gl.canvas.width,this.gl.canvas.height)}enforceState(){const{gl:t}=this;t.bindVertexArray(null);for(let s=0;s<this.parameters.maxVertexAttributes;s++)t.disableVertexAttribArray(s);this._state.vertexBuffer?t.bindBuffer(this._state.vertexBuffer.bufferType,this._state.vertexBuffer.glName):t.bindBuffer(h.ARRAY_BUFFER,null),this._state.indexBuffer?t.bindBuffer(this._state.indexBuffer.bufferType,this._state.indexBuffer.glName):t.bindBuffer(h.ELEMENT_ARRAY_BUFFER,null),this._state.uniformBuffer?t.bindBuffer(this._state.uniformBuffer.bufferType,this._state.uniformBuffer.glName):t.bindBuffer(h.UNIFORM_BUFFER,null);for(let s=0;s<this._parameters.maxUniformBufferBindings;s++){const e=this._state.uniformBufferBindingPoints[s];if(null!=e){const{buffer:i,offset:a,size:r}=e;null!==i?0===a&&0===r?t.bindBufferBase(h.UNIFORM_BUFFER,s,i.glName):t.bindBufferRange(h.UNIFORM_BUFFER,s,i.glName,a,r):t.bindBufferBase(h.UNIFORM_BUFFER,s,null)}}if(this._state.pixelPackBuffer?t.bindBuffer(this._state.pixelPackBuffer.bufferType,this._state.pixelPackBuffer.glName):t.bindBuffer(h.PIXEL_PACK_BUFFER,null),this._state.pixelUnpackBuffer?t.bindBuffer(this._state.pixelUnpackBuffer.bufferType,this._state.pixelUnpackBuffer.glName):t.bindBuffer(h.PIXEL_UNPACK_BUFFER,null),this._state.copyReadBuffer?t.bindBuffer(this._state.copyReadBuffer.bufferType,this._state.copyReadBuffer.glName):t.bindBuffer(h.COPY_READ_BUFFER,null),this._state.copyWriteBuffer?t.bindBuffer(this._state.copyWriteBuffer.bufferType,this._state.copyWriteBuffer.glName):t.bindBuffer(h.COPY_WRITE_BUFFER,null),t.bindFramebuffer(_.READ_FRAMEBUFFER,null),t.readBuffer(t.BACK),this._state.readFramebuffer&&(t.bindFramebuffer(_.READ_FRAMEBUFFER,this._state.readFramebuffer.glName),t.readBuffer(l)),t.bindFramebuffer(_.DRAW_FRAMEBUFFER,this._state.drawFramebuffer?.glName??null),null===this._state.drawFramebuffer){const e=this._state.drawBuffers.defaultFramebuffer;t.drawBuffers(e??[n.BACK])}else{const e=this._state.drawBuffers.fbos.get(this._state.drawFramebuffer);t.drawBuffers(e??[l])}if(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?.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 s=0;s<this.parameters.maxTextureImageUnits;s++){t.activeTexture(o+s),t.bindTexture(T.TEXTURE_2D,null),t.bindTexture(T.TEXTURE_CUBE_MAP,null),t.bindTexture(T.TEXTURE_3D,null),t.bindTexture(T.TEXTURE_2D_ARRAY,null);const e=this._state.textureUnitMap[s];null!=e&&t.bindTexture(e.descriptor.target,e.glName)}t.activeTexture(o+this._state.activeTexture);const e=this._state.viewport;t.viewport(e.x,e.y,e.width,e.height),this.resetInfo()}};function N(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 A.POINTS:return 2*e;case A.TRIANGLES:return e/3;case A.TRIANGLE_STRIP:case A.TRIANGLE_FAN:return e-2;default:return 0}}export{v as RenderingContext};
5
+ import"../../core/has.js";import{disposeMaybe as t}from"../../core/maybe.js";import{after as e}from"../../core/promiseUtils.js";import{Milliseconds as s}from"../../core/time.js";import{webglDebugEnabled as i,checkWebGLError as a}from"./checkWebGLError.js";import{ContextState as r}from"./ContextState.js";import{SpecialDrawBuffers as n,ColorAttachment0 as l,BufferType as h,Face as f,baseTextureUnit as o,FramebufferBit as u,BufferContent as c,FramebufferTarget as _,TextureSamplingMode as d,SyncCondition as b,ResourceType as F,ClientWaitSyncStatus as g,BlendFactor as B,BlendOperation as p,CullMode as m,CompareFunction as E,StencilOperation as R,TextureType as T,PrimitiveType as A}from"./enums.js";import{InstanceCounter as O}from"./InstanceCounter.js";import{Parameters as C}from"./Parameters.js";import{ProgramCache as x}from"./ProgramCache.js";import{StateTracker as U}from"./renderState.js";import{Texture as k}from"./Texture.js";import{getErrorString as w}from"./Util.js";import{WebGLDriverTest as S}from"./WebGLDriverTest.js";import{Capabilities as y}from"./capabilities/Capabilities.js";let v=class{constructor(t,e){this.gl=t,this.instanceCounter=new O,this.programCache=new x(this),this._transformFeedbackRequestInfo=null,this._state=new r,this._numOfDrawCalls=0,this._numOfTriangles=0,this.configure(e)}configure(e){this._capabilities=new y(this.gl,e),this._parameters=new C(this.gl,this._capabilities,e),k.TEXTURE_UNIT_FOR_UPDATES=this._parameters.maxTextureImageUnits-1;const s=this.gl.getParameter(this.gl.VIEWPORT);this._state=new r,this._state.viewport={x:s[0],y:s[1],width:s[2],height:s[3]},this._stateTracker=new U({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)},setDrawBuffers:t=>{if(t)this.setDrawBuffers(t.buffers);else{const{drawFramebuffer:t}=this._state;null===t?this.setDrawBuffers([n.BACK]):0===t.colorAttachments.length?this.setDrawBuffers([n.NONE]):this.setDrawBuffers([l])}}}),this.enforceState(),t(this._driverTest),this._driverTest=new S(this)}updateOptions(t){this._parameters=new C(this.gl,this._capabilities,t)}dispose(){t(this._driverTest),this.programCache.dispose(),this.bindVAO(null),this.unbindBuffer(h.ARRAY_BUFFER),this.unbindBuffer(h.ELEMENT_ARRAY_BUFFER),this.unbindBuffer(h.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(h.PIXEL_PACK_BUFFER),this.unbindBuffer(h.PIXEL_UNPACK_BUFFER),this.unbindBuffer(h.COPY_READ_BUFFER),this.unbindBuffer(h.COPY_WRITE_BUFFER),this._state.textureUnitMap.length=0,i()&&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(){this.gl.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=f.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===f.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=f.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(o+t),this._state.activeTexture=t),s}setDrawBuffers(t){const{drawFramebuffer:e}=this._state,s=null===e,i=s?this._state.drawBuffers.defaultFramebuffer:this._state.drawBuffers.fbos.get(e);if(i?.length!==t.length||!i.every(((e,s)=>e===t[s])))if(t.length>this.parameters.maxDrawBuffers)console.error("Setting more active draw buffers than GL.MAX_DRAW_BUFFERS allows.");else{if(s){if(t.length>1)return void console.error("The default framebuffer can only have one active draw buffer.");if(t[0]!==n.BACK&&t[0]!==n.NONE)return void console.error("The default framebuffer can only use the constants GL.BACK or GL.NONE as draw buffers.")}s||!t.includes(n.BACK)?(this.gl.drawBuffers(t),s?this._state.drawBuffers.defaultFramebuffer=t:this._state.drawBuffers.fbos.set(e,t),this._stateTracker.invalidateDrawBuffers()):console.error("A framebuffer object can only use the constants GL.COLOR_ATTACHMENTi or GL.NONE as draw buffers.")}}clear(t,e=255){if(t){if(t&u.COLOR){const t=this._state.drawFramebuffer?.colorAttachments;t&&this.setDrawBuffers(t),this.setColorMask(!0,!0,!0,!0)}t&u.DEPTH&&this.setDepthWriteEnabled(!0),t&u.STENCIL&&this.setStencilWriteMask(e),this.gl.clear(t)}}clearFramebuffer(t,e=!1,s=!1){let i=0;if(t){const e=1e-13,s=Math.max(e,t[3]);this.setClearColor(t[0],t[1],t[2],s),i|=u.COLOR}e&&(i|=u.DEPTH),!1===s?s=0:(!0===s&&(s=255),i|=u.STENCIL),i&&this.clear(i,s)}clearBuffer(t,e,s=c.COLOR,i=void 0){this.gl.clearBufferfv(s,t,e,i)}clearBufferInteger(t,e,s=c.COLOR,i=void 0){this.gl.clearBufferiv(s,t,e,i)}clearBufferUnsignedInteger(t,e,s=c.COLOR,i=void 0){this.gl.clearBufferuiv(s,t,e,i)}drawArrays(t,e,s){if(this._transformFeedbackRequestInfo){if(t!==this._transformFeedbackRequestInfo.primitiveType)throw new Error("DrawArrays called during transform feedback, but primitiveType does not match that of the current transform feedback request");if(null==this._state.program?.hasTransformFeedbackVaryings)throw new Error("DrawArrays called during transform feedback, but the shader program was not linked with a transform feedback varying")}if(i()){this._numOfDrawCalls++,this._numOfTriangles+=D(t,s);const e=this._state.textureUnitMap;for(let t=0;t<e.length;t++){const s=e[t];if(null!=s&&s===this._state.drawFramebuffer?.colorTexture)throw new Error(`Detected readWrite. Texture already bound at index ${t}`)}}this.gl.drawArrays(t,e,s),a(this.gl)}drawArraysInstanced(t,e,s,i){this.gl.drawArraysInstanced(t,e,s,i),a(this.gl)}drawElements(t,e,s,a){if(this._transformFeedbackRequestInfo)throw new Error("Cannot called drawElements during a transform feedback request");if(i()&&(this._numOfDrawCalls++,this._numOfTriangles+=D(t,e)),this.gl.drawElements(t,e,s,a),i()){const i=w(this);if(i){const r=this.getBoundVAO(),n=r?.indexBuffer,l=r?.vertexBuffers,h={indexBuffer:n,vertexBuffers:l},f={mode:t,count:e,type:s,offset:a},o=n?.size??0,u=a+e,c=o<u?`. Buffer is too small. Attempted to draw index ${u} of ${o}`:"";console.error(`drawElements: ${i}${c}`,{args:f,vao:h})}}}drawElementsInstanced(t,e,s,i,r){this.gl.drawElementsInstanced(t,e,s,i,r),a(this.gl)}logInfo(){i()&&console.log(`DrawCalls: ${this._numOfDrawCalls}, Triangles: ${this._numOfTriangles}`)}resetInfo(){i()&&(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))}setViewport4fv(t){this.setViewport(t[0],t[1],t[2],t[3])}restoreViewport({x:t,y:e,width:s,height:i}){this.setViewport(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,s=!1){(e>=this.parameters.maxTextureImageUnits||e<0)&&console.error("Input texture unit is out of range of available units!");const i=this._state.textureUnitMap[e];return null==t?.glName?(null!=i&&(this.setActiveTexture(e,s),this.gl.bindTexture(i.descriptor.target,null)),this._state.textureUnitMap[e]=null,i):s||i!==t?(this.setActiveTexture(e,s),this.gl.bindTexture(t.descriptor.target,t.glName),t.applyChanges(),this._state.textureUnitMap[e]=t,i):(t.isDirty&&(this.setActiveTexture(e,s),t.applyChanges()),i)}unbindTexture(t){if(null!=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(this._stateTracker.invalidateDrawBuffers(),null==t)return this.gl.bindFramebuffer(_.FRAMEBUFFER,null),void(this._state.readFramebuffer=this._state.drawFramebuffer=null);t.initializeAndBind(_.FRAMEBUFFER),this._state.readFramebuffer=t,this._state.drawFramebuffer=t}}bindFramebufferSeparate(t,e,s=!1){const i=e===_.READ_FRAMEBUFFER,a=i?this._state.readFramebuffer:this._state.drawFramebuffer;(s||a!==t)&&(null==t?this.gl.bindFramebuffer(e,null):t.initializeAndBind(e),i?this._state.readFramebuffer=t??null:(this._stateTracker.invalidateDrawBuffers(),this._state.drawFramebuffer=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=u.COLOR,c=d.NEAREST){this.bindFramebufferSeparate(t,_.READ_FRAMEBUFFER,!0),this.bindFramebufferSeparate(e,_.DRAW_FRAMEBUFFER,!0),this.gl.blitFramebuffer(s,i,a,r,n,l,h,f,o,c)}bindBuffer(t,e){if(t)switch(e??=t.bufferType,e){case h.ARRAY_BUFFER:this._state.vertexBuffer=N(this.gl,t,e,this._state.vertexBuffer);break;case h.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=N(this.gl,t,e,this._state.indexBuffer);break;case h.UNIFORM_BUFFER:this._state.uniformBuffer=N(this.gl,t,e,this._state.uniformBuffer);break;case h.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=N(this.gl,t,e,this._state.pixelPackBuffer);break;case h.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=N(this.gl,t,e,this._state.pixelUnpackBuffer);break;case h.COPY_READ_BUFFER:this._state.copyReadBuffer=N(this.gl,t,e,this._state.copyReadBuffer);break;case h.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=N(this.gl,t,e,this._state.copyWriteBuffer);break;case h.TRANSFORM_FEEDBACK_BUFFER:this._state.transformFeedbackBuffer=N(this.gl,t,e,this._state.transformFeedbackBuffer)}}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 s=t===h.UNIFORM_BUFFER?this._state.uniformBufferBindingPoints:this._state.transformBufferBindingPoints;let i=s[e];return null==i&&(i={buffer:null,offset:0,size:0},s[e]=i),i}bindBufferBase(t,e,s){const i=this._getBufferBinding(t,e);null!=i&&(i.buffer===s&&0===i.offset&&0===i.size||(this.gl.bindBufferBase(t,e,s?s.glName:null),i.buffer=s,i.offset=0,i.size=0))}bindBufferRange(t,e,s,i,a){const r=this._getBufferBinding(t,e);null!=r&&(r.buffer===s&&r.offset===i&&r.size===a||(i%this._parameters.uniformBufferOffsetAlignment===0?(this.gl.bindBufferRange(t,e,s.glName,i,a),r.buffer=s,r.offset=i,r.size=a):console.error("Uniform buffer binding offset is not a multiple of the context offset alignment")))}bindUBO(t,e,s,a){null!=e?(i()&&(a??e.byteLength)>this._parameters.maxUniformBlockSize&&console.error("Attempting to bind more data than the maximum uniform block size"),e.initialize(),void 0!==s&&void 0!==a?this.bindBufferRange(h.UNIFORM_BUFFER,t,e.buffer,s,a):this.bindBufferBase(h.UNIFORM_BUFFER,t,e.buffer)):this.bindBufferBase(h.UNIFORM_BUFFER,t,null)}unbindUBO(t){for(let e=0,s=this._state.uniformBufferBindingPoints.length;e<s;e++){const s=this._state.uniformBufferBindingPoints[e];null!=s&&s.buffer===t.buffer&&this.bindBufferBase(h.UNIFORM_BUFFER,e,null)}}unbindBuffer(t){switch(t){case h.ARRAY_BUFFER:this._state.vertexBuffer=N(this.gl,null,t,this._state.vertexBuffer);break;case h.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=N(this.gl,null,t,this._state.indexBuffer);break;case h.UNIFORM_BUFFER:this._state.uniformBuffer=N(this.gl,null,t,this._state.uniformBuffer);break;case h.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=N(this.gl,null,t,this._state.pixelPackBuffer);break;case h.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=N(this.gl,null,t,this._state.pixelUnpackBuffer);break;case h.COPY_READ_BUFFER:this._state.copyReadBuffer=N(this.gl,null,t,this._state.copyReadBuffer);break;case h.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=N(this.gl,null,t,this._state.copyWriteBuffer)}}bindVAO(t=null){null!=t?this._state.vertexArrayObject!==t&&(t.bind(),this._state.vertexArrayObject=t):this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null)}bindTransformFeedback(t){const{gl:e}=this;e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,t.glName)}beginTransformFeedback(t,e){if(this._transformFeedbackRequestInfo)throw new Error("Already in a transform feedback request");const{gl:s}=this;s.bindTransformFeedback(s.TRANSFORM_FEEDBACK,t.glName),s.beginTransformFeedback(e),this._transformFeedbackRequestInfo={primitiveType:e}}endTransformFeedback(){if(!this._transformFeedbackRequestInfo)throw new Error("Not in a transform feedback request");const{gl:t}=this;t.endTransformFeedback(),t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null),this._transformFeedbackRequestInfo=null}async clientWaitAsync(t=s(10)){const{gl:i}=this,a=i.fenceSync(b.SYNC_GPU_COMMANDS_COMPLETE,0);if(!a)throw new Error("Client wait failed, could not create sync object");let r;this.instanceCounter.increment(F.Sync,a),i.flush();do{await e(t),r=i.clientWaitSync(a,0,0)}while(r===g.TIMEOUT_EXPIRED);if(this.instanceCounter.decrement(F.Sync,a),i.deleteSync(a),r===g.WAIT_FAILED)throw new Error("Client wait failed")}getBoundFramebufferObject(t=_.FRAMEBUFFER){return t===_.READ_FRAMEBUFFER?this._state.readFramebuffer:this._state.drawFramebuffer}temporaryBindFramebufferObject(t,e){const s=this.getBoundFramebufferObject();try{t&&this.bindFramebuffer(t),e()}finally{this.bindFramebuffer(s)}}getBoundVAO(){return this._state.vertexArrayObject}resetState(){this.useProgram(null),this.bindVAO(null),this.bindFramebuffer(null,!0),this.unbindBuffer(h.ARRAY_BUFFER),this.unbindBuffer(h.ELEMENT_ARRAY_BUFFER),this.unbindBuffer(h.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(h.PIXEL_PACK_BUFFER),this.unbindBuffer(h.PIXEL_UNPACK_BUFFER),this.unbindBuffer(h.COPY_READ_BUFFER),this.unbindBuffer(h.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(f.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(E.LESS),this.setDepthRange(0,1),this.setStencilTestEnabled(!1),this.setStencilFunction(E.ALWAYS,0,0),this.setStencilOp(R.KEEP,R.KEEP,R.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.setDrawBuffers([n.BACK]),this.setViewport(0,0,this.gl.canvas.width,this.gl.canvas.height)}enforceState(){const{gl:t}=this;t.bindVertexArray(null);for(let s=0;s<this.parameters.maxVertexAttributes;s++)t.disableVertexAttribArray(s);this._state.vertexBuffer?t.bindBuffer(this._state.vertexBuffer.bufferType,this._state.vertexBuffer.glName):t.bindBuffer(h.ARRAY_BUFFER,null),this._state.indexBuffer?t.bindBuffer(this._state.indexBuffer.bufferType,this._state.indexBuffer.glName):t.bindBuffer(h.ELEMENT_ARRAY_BUFFER,null),this._state.uniformBuffer?t.bindBuffer(this._state.uniformBuffer.bufferType,this._state.uniformBuffer.glName):t.bindBuffer(h.UNIFORM_BUFFER,null);for(let s=0;s<this._parameters.maxUniformBufferBindings;s++){const e=this._state.uniformBufferBindingPoints[s];if(null!=e){const{buffer:i,offset:a,size:r}=e;null!==i?0===a&&0===r?t.bindBufferBase(h.UNIFORM_BUFFER,s,i.glName):t.bindBufferRange(h.UNIFORM_BUFFER,s,i.glName,a,r):t.bindBufferBase(h.UNIFORM_BUFFER,s,null)}}if(this._state.pixelPackBuffer?t.bindBuffer(this._state.pixelPackBuffer.bufferType,this._state.pixelPackBuffer.glName):t.bindBuffer(h.PIXEL_PACK_BUFFER,null),this._state.pixelUnpackBuffer?t.bindBuffer(this._state.pixelUnpackBuffer.bufferType,this._state.pixelUnpackBuffer.glName):t.bindBuffer(h.PIXEL_UNPACK_BUFFER,null),this._state.copyReadBuffer?t.bindBuffer(this._state.copyReadBuffer.bufferType,this._state.copyReadBuffer.glName):t.bindBuffer(h.COPY_READ_BUFFER,null),this._state.copyWriteBuffer?t.bindBuffer(this._state.copyWriteBuffer.bufferType,this._state.copyWriteBuffer.glName):t.bindBuffer(h.COPY_WRITE_BUFFER,null),t.bindFramebuffer(_.READ_FRAMEBUFFER,null),t.readBuffer(t.BACK),this._state.readFramebuffer&&(t.bindFramebuffer(_.READ_FRAMEBUFFER,this._state.readFramebuffer.glName),t.readBuffer(l)),t.bindFramebuffer(_.DRAW_FRAMEBUFFER,this._state.drawFramebuffer?.glName??null),null===this._state.drawFramebuffer){const e=this._state.drawBuffers.defaultFramebuffer;t.drawBuffers(e??[n.BACK])}else{const e=this._state.drawBuffers.fbos.get(this._state.drawFramebuffer);t.drawBuffers(e??[l])}if(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?.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 s=0;s<this.parameters.maxTextureImageUnits;s++){t.activeTexture(o+s),t.bindTexture(T.TEXTURE_2D,null),t.bindTexture(T.TEXTURE_CUBE_MAP,null),t.bindTexture(T.TEXTURE_3D,null),t.bindTexture(T.TEXTURE_2D_ARRAY,null);const e=this._state.textureUnitMap[s];null!=e&&t.bindTexture(e.descriptor.target,e.glName)}t.activeTexture(o+this._state.activeTexture);const e=this._state.viewport;t.viewport(e.x,e.y,e.width,e.height),this.resetInfo()}};function N(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 A.POINTS:return 2*e;case A.TRIANGLES:return e/3;case A.TRIANGLE_STRIP:case A.TRIANGLE_FAN:return e-2;default:return 0}}export{v 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.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../core/Error.js";import"../../core/has.js";import t from"../../core/Logger.js";import{BindType as r}from"./BindType.js";const n=()=>t.getLogger("esri.views.3d.webgl-engine.core.shaderModules.shaderBuilder");class s{constructor(){this._includedModules=new Map}include(e,t){this._includedModules.has(e)?this._includedModules.get(e):(this._includedModules.set(e,t),e(this.builder,t))}}class i extends s{constructor(){super(...arguments),this.vertex=new c,this.fragment=new c,this.attributes=new h,this.varyings=new m,this.extensions=new _,this.outputs=new d}get fragmentUniforms(){return this.fragment.uniforms.entries}get builder(){return this}generate(e,t=!1){const r=this.extensions.generateSource(e),n=this.attributes.generateSource(e),s=this.varyings.generateSource(e),i="vertex"===e?this.vertex:this.fragment,o=i.uniforms.generateSource(),a=i.code.generateSource(),u=i.main.generateSource(t),c="vertex"===e?p:g,h=i.constants.generateSource(),m=this.outputs.generateSource(e);return`#version 300 es\n${r.join("\n")}\n${c}\n${h.join("\n")}\n${o.join("\n")}\n${n.join("\n")}\n${s.join("\n")}\n${m.join("\n")}\n${a.join("\n")}\n${u.join("\n")}`}generateBind(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Bind];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Bind];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return t=>{for(let r=0;r<s;++r)n[r](e,t)}}generateBindPass(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Pass];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Pass];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return(t,r)=>{for(let i=0;i<s;++i)n[i](e,t,r)}}generateBindDraw(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Draw];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Draw];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return(t,r,i)=>{for(let o=0;o<s;++o)n[o](e,i,t,r)}}}class o{constructor(e){this._stage=e,this._entries=new Map}add(...e){for(const t of e)this._add(t);return this._stage}get(e){return this._entries.get(e)}_add(t){if(null!=t){if(this._entries.has(t.name)&&!this._entries.get(t.name).equals(t))throw new e("shaderbuilder:duplicate-uniform",`Duplicate uniform name ${t.name} for different uniform type`);this._entries.set(t.name,t)}else n().error(`Trying to add null Uniform from ${(new Error).stack}.`)}generateSource(){return Array.from(this._entries.values()).map((({name:e,arraySize:t,type:r})=>null!=t?`uniform ${r} ${e}[${t}];`:`uniform ${r} ${e};`))}get entries(){return Array.from(this._entries.values())}}class a{constructor(e){this._stage=e,this._bodies=new Array}add(e){return this._bodies.push(e),this._stage}generateSource(t){if(this._bodies.length>0)return[`void main() {\n ${this._bodies.join("\n")||""} \n}`];if(t)throw new e("shaderbuilder:missing-main","Shader does not contain main function body.");return[]}}class u{constructor(e){this._stage=e,this._entries=new Array}add(e){return this._entries.push(e),this._stage}generateSource(){return this._entries}}class c extends s{constructor(){super(...arguments),this.uniforms=new o(this),this.main=new a(this),this.code=new u(this),this.constants=new l(this)}get builder(){return this}}class h{constructor(){this._entries=new Array}add(e,t){this._entries.push([e,t])}generateSource(e){return"fragment"===e?[]:this._entries.map((e=>`in ${e[1]} ${e[0]};`))}}class m{constructor(){this._entries=new Map}add(e,t,r){this._entries.has(e)?n().warn(`Ignoring duplicate varying ${t} ${e}`):this._entries.set(e,{type:t,invariant:r?.invariant??!1})}generateSource(e){const t=new Array;return this._entries.forEach(((r,n)=>t.push((r.invariant&&"vertex"===e?"invariant ":"")+("vertex"===e?"out":"in")+` ${r.type} ${n};`))),t}}class _{constructor(){this._entries=new Set}add(e){this._entries.add(e)}generateSource(e){const t="vertex"===e?_.ALLOWLIST_VERTEX:_.ALLOWLIST_FRAGMENT;return Array.from(this._entries).filter((e=>t.includes(e))).map((e=>`#extension ${e} : enable`))}static{this.ALLOWLIST_FRAGMENT=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives"]}static{this.ALLOWLIST_VERTEX=[]}}class d{constructor(){this._entries=new Map}add(e,t,r=0){const s=this._entries.get(r);s?.name!==e||s?.type!==t?this._entries.set(r,{name:e,type:t}):n().warn(`Fragment shader output location ${r} occupied`)}static{this.DEFAULT_TYPE="vec4"}static{this.DEFAULT_NAME="fragColor"}generateSource(e){if("vertex"===e)return[];0===this._entries.size&&this._entries.set(0,{name:d.DEFAULT_NAME,type:d.DEFAULT_TYPE});const t=new Array;return this._entries.forEach(((e,r)=>t.push(`layout(location = ${r}) out ${e.type} ${e.name};`))),t}}class l{constructor(e){this._stage=e,this._entries=new Set}add(e,t,r){let n="ERROR_CONSTRUCTOR_STRING";switch(t){case"float":n=l._numberToFloatStr(r);break;case"int":n=l._numberToIntStr(r);break;case"bool":n=r.toString();break;case"vec2":n=`vec2(${l._numberToFloatStr(r[0])}, ${l._numberToFloatStr(r[1])})`;break;case"vec3":n=`vec3(${l._numberToFloatStr(r[0])}, ${l._numberToFloatStr(r[1])}, ${l._numberToFloatStr(r[2])})`;break;case"vec4":n=`vec4(${l._numberToFloatStr(r[0])}, ${l._numberToFloatStr(r[1])}, ${l._numberToFloatStr(r[2])}, ${l._numberToFloatStr(r[3])})`;break;case"ivec2":n=`ivec2(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])})`;break;case"ivec3":n=`ivec3(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])}, ${l._numberToIntStr(r[2])})`;break;case"ivec4":n=`ivec4(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])}, ${l._numberToIntStr(r[2])}, ${l._numberToIntStr(r[3])})`;break;case"uvec2":n=`uvec2(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])})`;break;case"uvec3":n=`uvec3(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])}, ${l._numberToIntStr(r[2])})`;break;case"uvec4":n=`uvec4(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])}, ${l._numberToIntStr(r[2])}, ${l._numberToIntStr(r[3])})`;break;case"mat2":case"mat3":case"mat4":n=`${t}(${Array.prototype.map.call(r,(e=>l._numberToFloatStr(e))).join(", ")})`}return this._entries.add(`const ${t} ${e} = ${n};`),this._stage}static _numberToIntStr(e){return e.toFixed(0)}static _numberToFloatStr(e){return Number.isInteger(e)?e.toFixed(1):e.toString()}generateSource(){return Array.from(this._entries)}}const g="#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n precision highp usampler2D;\n precision highp sampler2DArray;\n#else\n precision mediump float;\n precision mediump int;\n precision mediump sampler2D;\n precision mediump usampler2D;\n precision mediump sampler2DArray;\n#endif",p="precision highp float;\n precision highp sampler2D;\n precision highp usampler2D;\n precision highp sampler2DArray;\n\n invariant gl_Position;\n ";export{u as Code,s as Includes,a as Main,i as ShaderBuilder,c as Stage,o as Uniforms};
5
+ import e from"../../core/Error.js";import"../../core/has.js";import t from"../../core/Logger.js";import{BindType as r}from"./BindType.js";const n=()=>t.getLogger("esri.views.3d.webgl-engine.core.shaderModules.shaderBuilder");class s{constructor(){this._includedModules=new Map}include(e,t){this._includedModules.has(e)?this._includedModules.get(e):(this._includedModules.set(e,t),e(this.builder,t))}}class i extends s{constructor(){super(...arguments),this.vertex=new c,this.fragment=new c,this.attributes=new h,this.varyings=new m,this.extensions=new _,this.outputs=new d}get fragmentUniforms(){return this.fragment.uniforms.entries}get builder(){return this}generate(e,t=!1){const r=this.extensions.generateSource(e),n=this.attributes.generateSource(e),s=this.varyings.generateSource(e),i="vertex"===e?this.vertex:this.fragment,o=i.uniforms.generateSource(),a=i.code.generateSource(),u=i.main.generateSource(t),c="vertex"===e?g:p,h=i.constants.generateSource(),m=this.outputs.generateSource(e);return`#version 300 es\n${r.join("\n")}\n${c}\n${h.join("\n")}\n${o.join("\n")}\n${n.join("\n")}\n${s.join("\n")}\n${m.join("\n")}\n${a.join("\n")}\n${u.join("\n")}`}generateBind(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Bind];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Bind];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return t=>{for(let r=0;r<s;++r)n[r](e,t)}}generateBindPass(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Pass];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Pass];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return(t,r)=>{for(let i=0;i<s;++i)n[i](e,t,r)}}generateBindDraw(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Draw];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Draw];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return(t,r,i)=>{for(let o=0;o<s;++o)n[o](e,i,t,r)}}}class o{constructor(e){this._stage=e,this._entries=new Map}add(...e){for(const t of e)this._add(t);return this._stage}get(e){return this._entries.get(e)}_add(t){if(null!=t){if(this._entries.has(t.name)&&!this._entries.get(t.name).equals(t))throw new e("shaderbuilder:duplicate-uniform",`Duplicate uniform name ${t.name} for different uniform type`);this._entries.set(t.name,t)}else n().error(`Trying to add null Uniform from ${(new Error).stack}.`)}generateSource(){return Array.from(this._entries.values()).map((({name:e,arraySize:t,type:r})=>null!=t?`uniform ${r} ${e}[${t}];`:`uniform ${r} ${e};`))}get entries(){return Array.from(this._entries.values())}}class a{constructor(e){this._stage=e,this._bodies=new Array}add(e){return this._bodies.push(e),this._stage}generateSource(t){if(this._bodies.length>0)return[`void main() {\n ${this._bodies.join("\n")||""} \n}`];if(t)throw new e("shaderbuilder:missing-main","Shader does not contain main function body.");return[]}}class u{constructor(e){this._stage=e,this._entries=new Array}add(e){return this._entries.push(e),this._stage}generateSource(){return this._entries}}class c extends s{constructor(){super(...arguments),this.uniforms=new o(this),this.main=new a(this),this.code=new u(this),this.constants=new l(this)}get builder(){return this}}class h{constructor(){this._entries=new Array}add(e,t){this._entries.push([e,t])}generateSource(e){return"fragment"===e?[]:this._entries.map((e=>`in ${e[1]} ${e[0]};`))}}class m{constructor(){this._entries=new Map}add(e,t,r){this._entries.has(e)?n().warn(`Ignoring duplicate varying ${t} ${e}`):this._entries.set(e,{type:t,invariant:r?.invariant??!1})}generateSource(e){const t=new Array;return this._entries.forEach(((r,n)=>t.push((r.invariant&&"vertex"===e?"invariant ":"")+("vertex"===e?"out":"in")+` ${r.type} ${n};`))),t}}class _{constructor(){this._entries=new Set}add(e){this._entries.add(e)}generateSource(e){const t="vertex"===e?_.ALLOWLIST_VERTEX:_.ALLOWLIST_FRAGMENT;return Array.from(this._entries).filter((e=>t.includes(e))).map((e=>`#extension ${e} : enable`))}static{this.ALLOWLIST_FRAGMENT=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives"]}static{this.ALLOWLIST_VERTEX=[]}}class d{constructor(){this._entries=new Map}add(e,t,r=0){const s=this._entries.get(r);s?.name!==e||s?.type!==t?this._entries.set(r,{name:e,type:t}):n().warn(`Fragment shader output location ${r} occupied`)}static{this.DEFAULT_TYPE="vec4"}static{this.DEFAULT_NAME="fragColor"}generateSource(e){if("vertex"===e)return[];0===this._entries.size&&this._entries.set(0,{name:d.DEFAULT_NAME,type:d.DEFAULT_TYPE});const t=new Array;return this._entries.forEach(((e,r)=>t.push(`layout(location = ${r}) out ${e.type} ${e.name};`))),t}}class l{constructor(e){this._stage=e,this._entries=new Set}add(e,t,r){let n="ERROR_CONSTRUCTOR_STRING";switch(t){case"float":n=l._numberToFloatStr(r);break;case"int":n=l._numberToIntStr(r);break;case"bool":n=r.toString();break;case"vec2":n=`vec2(${l._numberToFloatStr(r[0])}, ${l._numberToFloatStr(r[1])})`;break;case"vec3":n=`vec3(${l._numberToFloatStr(r[0])}, ${l._numberToFloatStr(r[1])}, ${l._numberToFloatStr(r[2])})`;break;case"vec4":n=`vec4(${l._numberToFloatStr(r[0])}, ${l._numberToFloatStr(r[1])}, ${l._numberToFloatStr(r[2])}, ${l._numberToFloatStr(r[3])})`;break;case"ivec2":n=`ivec2(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])})`;break;case"ivec3":n=`ivec3(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])}, ${l._numberToIntStr(r[2])})`;break;case"ivec4":n=`ivec4(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])}, ${l._numberToIntStr(r[2])}, ${l._numberToIntStr(r[3])})`;break;case"uvec2":n=`uvec2(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])})`;break;case"uvec3":n=`uvec3(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])}, ${l._numberToIntStr(r[2])})`;break;case"uvec4":n=`uvec4(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])}, ${l._numberToIntStr(r[2])}, ${l._numberToIntStr(r[3])})`;break;case"mat2":case"mat3":case"mat4":n=`${t}(${Array.prototype.map.call(r,(e=>l._numberToFloatStr(e))).join(", ")})`}return this._entries.add(`const ${t} ${e} = ${n};`),this._stage}static _numberToIntStr(e){return e.toFixed(0)}static _numberToFloatStr(e){return Number.isInteger(e)?e.toFixed(1):e.toString()}generateSource(){return Array.from(this._entries)}}const p="#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n precision highp usampler2D;\n precision highp sampler2DArray;\n precision highp sampler2DShadow;\n#else\n precision mediump float;\n precision mediump int;\n precision mediump sampler2D;\n precision mediump usampler2D;\n precision mediump sampler2DArray;\n precision mediump sampler2DShadow;\n#endif",g="precision highp float;\n precision highp sampler2D;\n precision highp usampler2D;\n precision highp sampler2DArray;\n precision highp sampler2DShadow;\n\n\n invariant gl_Position;\n ";export{u as Code,s as Includes,a as Main,i as ShaderBuilder,c as Stage,o as Uniforms};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../core/Error.js";import"../../core/has.js";import e from"../../core/Logger.js";import{abortMaybe as i}from"../../core/maybe.js";import{isAbortError as r}from"../../core/promiseUtils.js";import{checkWebGLError as s}from"./checkWebGLError.js";import{TextureType as o,ResourceType as a,CompressedTextureFormat as n,TextureSamplingMode as p,TextureConstants as l}from"./enums.js";import{FBOAttachmentType as m}from"./FBOAttachmentType.js";import{estimateMemory as h}from"./TextureDescriptor.js";import{isCompressedData as d,deriveInternalFormat as c,isTexImageSource as _,is3DTarget as u,validateTexture as g,isCompressedFormat as x,getDimensions as T,calcMipmapLevels as E,isSizedPixelFormat as M,isSizedDepthFormat as A,isSizedDepthStencilFormat as f}from"./textureUtils.js";import{ValidatedTextureDescriptor as I}from"./ValidatedTextureDescriptor.js";const b=null,w=()=>e.getLogger("esri/views/webgl/Texture");let D=class e{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(e,i=null,r=null){if(this.type=m.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,"context"in e)this._descriptor=e,r=i;else{const r=I.validate(e,i);if(!r)throw new t("texture:invalid-descriptor","Texture descriptor invalid");this._descriptor=r}this._descriptor.target===o.TEXTURE_CUBE_MAP?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return h(this._descriptor)}get cachedMemory(){return this.usedMemory}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}get isCompressing(){return null!==this._compressionAbortController}dispose(){this.abortCompression(),this._descriptor.context.gl&&this._glName&&(this._descriptor.context.instanceCounter.decrement(a.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("texture:immutable-resize","Immutable textures can't be resized!");r.width=e,r.height=i,this._descriptor.target===o.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}enableCompression(t,e){this._descriptor.compressionHandle=t,this._descriptor.compressionCallback=e}disableCompression(){this._descriptor.compressionHandle=null,this._descriptor.compressionCallback=null}setData(t){this.abortCompression(),!d(t)&&this._descriptor.internalFormat&&this._descriptor.internalFormat in n&&(this._descriptor.internalFormat=void 0),this._setData(t),!d(t)&&this._descriptor.compressionHandle&&this._compressOnWorker(t)}updateData(i,r,s,o,a,n,p=0){n||w().error("An attempt to use uninitialized data!"),this._glName||w().error("An attempt to update uninitialized texture!");const l=this._descriptor;l.internalFormat=c(l);const{context:m,pixelFormat:h,dataType:u,target:g,isImmutable:x}=l;if(x&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");const T=m.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES,!0);(r<0||s<0||r+o>l.width||s+a>l.height)&&w().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:E}=m;p&&(o&&a||w().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),E.pixelStorei(E.UNPACK_SKIP_ROWS,p)),_(n)?E.texSubImage2D(g,i,r,s,o,a,h,u,n):d(n)?E.compressedTexSubImage2D(g,i,r,s,o,a,l.internalFormat,n.levels[i]):E.texSubImage2D(g,i,r,s,o,a,h,u,n),p&&E.pixelStorei(E.UNPACK_SKIP_ROWS,0),m.bindTexture(T,e.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(i,r,s,o,a,n,p,l){l||w().error("An attempt to use uninitialized data!"),this._glName||w().error("An attempt to update an uninitialized texture!");const m=this._descriptor;m.internalFormat=c(m);const{context:h,pixelFormat:_,dataType:g,isImmutable:x,target:T}=m;if(x&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");u(T)||w().warn("Attempting to set 3D texture data on a non-3D texture");const E=h.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);h.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),(r<0||s<0||o<0||r+a>m.width||s+n>m.height||o+p>m.depth)&&w().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:M}=h;if(d(l))l=l.levels[i],M.compressedTexSubImage3D(T,i,r,s,o,a,n,p,m.internalFormat,l);else{const t=l;M.texSubImage3D(T,i,r,s,o,a,n,p,_,g,t)}h.bindTexture(E,e.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const i=this._descriptor;if(0===i.width||0===i.height)return;if(!i.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot add mipmaps to immutable texture after allocation");i.hasMipmap=!0,this._samplingModeDirty=!0,g(i)}i.samplingMode===p.LINEAR?(this._samplingModeDirty=!0,i.samplingMode=p.LINEAR_MIPMAP_NEAREST):i.samplingMode===p.NEAREST&&(this._samplingModeDirty=!0,i.samplingMode=p.NEAREST_MIPMAP_NEAREST);const r=this._descriptor.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(i.target),this._descriptor.context.bindTexture(r,e.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,g(e)}e.samplingMode===p.LINEAR_MIPMAP_NEAREST?(this._samplingModeDirty=!0,e.samplingMode=p.LINEAR):e.samplingMode===p.NEAREST_MIPMAP_NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=p.NEAREST)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,g(this._descriptor),this._wrapModeDirty=!0)}applyChanges(){this._samplingModeDirty&&(this._applySamplingMode(),this._samplingModeDirty=!1),this._wrapModeDirty&&(this._applyWrapMode(),this._wrapModeDirty=!1)}abortCompression(){this.isCompressing&&(this._compressionAbortController=i(this._compressionAbortController))}_setData(i,r){const o=this._descriptor,n=o.context?.gl;if(!n)return;s(n),this._glName||(this._glName=n.createTexture(),o.context.instanceCounter.increment(a.Texture,this)),g(o);const p=o.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);o.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),s(n);const l=r??o.target,m=u(l);if(_(i))this._setDataFromTexImageSource(i,l);else{const{width:e,height:r,depth:a}=o;if(null==e||null==r)throw new t("texture:missing-size","Width and height must be specified!");if(m&&null==a)throw new t("texture:missing-depth","Depth must be specified!");if(o.internalFormat=c(o),o.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(l,o.internalFormat,o.hasMipmap,e,r,a),d(i)){if(!x(o.internalFormat))throw new t("texture:format-mismatch","Attempting to use compressed data with an uncompressed format!");this._setDataFromCompressedSource(i,o.internalFormat,l)}else this._texImage(l,0,o.internalFormat,e,r,a,i),s(n),o.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),s(n),o.context.bindTexture(p,e.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(t=null){for(let e=o.TEXTURE_CUBE_MAP_POSITIVE_X;e<=o.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}_configurePixelStorage(){const t=this._descriptor.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)}_setDataFromTexImageSource(t,e){const{gl:i}=this._descriptor.context,r=this._descriptor;r.internalFormat=c(r);const o=u(e),{width:a,height:n,depth:p}=T(t);r.width&&r.height,r.width||(r.width=a),r.height||(r.height=n),o&&r.depth,o&&(r.depth=p),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(e,r.internalFormat,r.hasMipmap,a,n,p),this._texImage(e,0,r.internalFormat,a,n,p,t),s(i),r.hasMipmap&&(this.generateMipmap(),s(i))}_setDataFromCompressedSource(t,e,i){const r=this._descriptor,{width:s,height:o,depth:a}=r,n=t.levels,p=E(i,s,o,a),m=Math.min(p,n.length)-1;this._descriptor.context.gl.texParameteri(r.target,l.MAX_LEVEL,m),this._forEachMipmapLevel(((t,r,s,o)=>{const a=n[Math.min(t,n.length-1)];this._compressedTexImage(i,t,e,r,s,o,a)}),m)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!M(i)&&!A(i)&&!f(i))throw new t("texture:missing-format","Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const p=r?E(e,s,o,a):1;if(u(e)){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");n.texStorage3D(e,p,i,s,o,a)}else n.texStorage2D(e,p,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=u(e),{isImmutable:m,pixelFormat:h,dataType:d}=this._descriptor;if(m){if(null!=n){const r=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texSubImage3D(e,i,0,0,0,s,o,a,h,d,r)}else p.texSubImage2D(e,i,0,0,s,o,h,d,r)}}else{const m=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texImage3D(e,i,r,s,o,a,0,h,d,m)}else p.texImage2D(e,i,r,s,o,0,h,d,m)}}_compressedTexImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=u(e);if(this._descriptor.isImmutable){if(null!=n)if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else p.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexImage3D(e,i,r,s,o,a,0,n)}else p.compressedTexImage2D(e,i,r,s,o,0,n)}async _compressOnWorker(t){if(!e.compressionWorkerHandle||!e.compressionWorkerHandle.isCompressible(t))return;const i=!!this._descriptor.context.capabilities.compressedTextureETC,s=!!this._descriptor.context.capabilities.compressedTextureS3TC;if(i||s){const o=new AbortController;this._compressionAbortController=o;const a=this._descriptor.compressionHandle;a.increment();const n=this._descriptor.compressionCallback,p={data:await createImageBitmap(t,{imageOrientation:this.descriptor.flipped?"flipY":"none"}),width:t.width,height:t.height,premultiplyAlpha:this._descriptor.preMultiplyAlpha,hasMipmap:this._descriptor.hasMipmap,hasETC:!!i,hasS3TC:!!s};e.compressionWorkerHandle.invoke(p,this._compressionAbortController.signal).then((t=>{t&&this.isCompressing&&this.glName&&(this._descriptor.internalFormat=t.internalFormat,this._setData(t.compressedTexture),n?.()),o===this._compressionAbortController&&(this._compressionAbortController=null),a.decrement()})).catch((t=>{r(t)||o!==this._compressionAbortController||(this._compressionAbortController=null),a.decrement()}))}}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:a,hasMipmap:n,target:p}=this._descriptor;const l=p===o.TEXTURE_3D;if(null==r||null==s||l&&null==a)throw new t("texture:missing-size","Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,a),n&&(1!==r||1!==s||l&&1!==a)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),l&&(a=Math.max(1,a>>1))}_applySamplingMode(){const t=this._descriptor,e=t.context?.gl;let i=t.samplingMode,r=t.samplingMode;i===p.LINEAR_MIPMAP_NEAREST||i===p.LINEAR_MIPMAP_LINEAR?(i=p.LINEAR,t.hasMipmap||(r=p.LINEAR)):i!==p.NEAREST_MIPMAP_NEAREST&&i!==p.NEAREST_MIPMAP_LINEAR||(i=p.NEAREST,t.hasMipmap||(r=p.NEAREST)),e.texParameteri(t.target,e.TEXTURE_MAG_FILTER,i),e.texParameteri(t.target,e.TEXTURE_MIN_FILTER,r)}_applyWrapMode(){const t=this._descriptor,e=t.context?.gl;"number"==typeof t.wrapMode?(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode)):(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode.s),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode.t))}_applyAnisotropicFilteringParameters(){const t=this._descriptor,e=t.context.capabilities.textureFilterAnisotropic;if(!e)return;t.context.gl.texParameterf(t.target,e.TEXTURE_MAX_ANISOTROPY,t.maxAnisotropy??1)}};export{D as Texture,b as tracer};
5
+ import t from"../../core/Error.js";import"../../core/has.js";import e from"../../core/Logger.js";import{abortMaybe as i}from"../../core/maybe.js";import{throwIfAborted as r,isAbortError as s}from"../../core/promiseUtils.js";import{checkWebGLError as o}from"./checkWebGLError.js";import{TextureType as a,ResourceType as n,CompressedTextureFormat as p,TextureSamplingMode as l,TextureConstants as h}from"./enums.js";import{FBOAttachmentType as m}from"./FBOAttachmentType.js";import{estimateMemory as d}from"./TextureDescriptor.js";import{isCompressedData as c,deriveInternalFormat as _,isTexImageSource as u,is3DTarget as g,validateTexture as T,isCompressedFormat as x,getDimensions as E,calcMipmapLevels as M,isSizedPixelFormat as A,isSizedDepthFormat as b,isSizedDepthStencilFormat as w}from"./textureUtils.js";import{ValidatedTextureDescriptor as f}from"./ValidatedTextureDescriptor.js";const I=null,R=()=>e.getLogger("esri/views/webgl/Texture");let D=class e{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(e,i=null,r=null){if(this.type=m.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._shadowFilterDirty=!1,this._wasImmutablyAllocated=!1,"context"in e)this._descriptor=e,r=i;else{const r=f.validate(e,i);if(!r)throw new t("texture:invalid-descriptor","Texture descriptor invalid");this._descriptor=r}this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return d(this._descriptor)}get cachedMemory(){return this.usedMemory}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty||this._shadowFilterDirty}get hasWebGLTextureObject(){return!!this._glName}dispose(){this.abortCompression(),this._descriptor.context.gl&&this.hasWebGLTextureObject&&(this._descriptor.context.instanceCounter.decrement(n.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("texture:immutable-resize","Immutable textures can't be resized!");r.width=e,r.height=i,this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}enableCompression(t,e){this._descriptor.compressionHandle=t,this._descriptor.compressionCallback=e}disableCompression(){this._descriptor.compressionHandle=null,this._descriptor.compressionCallback=null}setData(t){this.abortCompression(),!c(t)&&this._descriptor.internalFormat&&this._descriptor.internalFormat in p&&(this._descriptor.internalFormat=void 0),this._setData(t),!c(t)&&this._descriptor.compressionHandle&&this._compressOnWorker(t)}updateData(i,r,s,o,a,n,p=0){n||R().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||R().error("An attempt to update uninitialized texture!");const l=this._descriptor;l.internalFormat=_(l);const{context:h,pixelFormat:m,dataType:d,target:g,isImmutable:T}=l;if(T&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");const x=h.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES,!0);(r<0||s<0||r+o>l.width||s+a>l.height)&&R().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:E}=h;p&&(o&&a||R().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),E.pixelStorei(E.UNPACK_SKIP_ROWS,p)),u(n)?E.texSubImage2D(g,i,r,s,o,a,m,d,n):c(n)?E.compressedTexSubImage2D(g,i,r,s,o,a,l.internalFormat,n.levels[i]):E.texSubImage2D(g,i,r,s,o,a,m,d,n),p&&E.pixelStorei(E.UNPACK_SKIP_ROWS,0),h.bindTexture(x,e.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(i,r,s,o,a,n,p,l){l||R().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||R().error("An attempt to update an uninitialized texture!");const h=this._descriptor;h.internalFormat=_(h);const{context:m,pixelFormat:d,dataType:u,isImmutable:T,target:x}=h;if(T&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");g(x)||R().warn("Attempting to set 3D texture data on a non-3D texture");const E=m.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);m.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),(r<0||s<0||o<0||r+a>h.width||s+n>h.height||o+p>h.depth)&&R().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:M}=m;if(c(l))l=l.levels[i],M.compressedTexSubImage3D(x,i,r,s,o,a,n,p,h.internalFormat,l);else{const t=l;M.texSubImage3D(x,i,r,s,o,a,n,p,d,u,t)}m.bindTexture(E,e.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const i=this._descriptor;if(0===i.width||0===i.height)return;if(!i.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot add mipmaps to immutable texture after allocation");i.hasMipmap=!0,this._samplingModeDirty=!0,T(i)}i.samplingMode===l.LINEAR?(this._samplingModeDirty=!0,i.samplingMode=l.LINEAR_MIPMAP_NEAREST):i.samplingMode===l.NEAREST&&(this._samplingModeDirty=!0,i.samplingMode=l.NEAREST_MIPMAP_NEAREST);const r=this._descriptor.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(i.target),this._descriptor.context.bindTexture(r,e.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,T(e)}e.samplingMode===l.LINEAR_MIPMAP_NEAREST?(this._samplingModeDirty=!0,e.samplingMode=l.LINEAR):e.samplingMode===l.NEAREST_MIPMAP_NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=l.NEAREST)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,T(this._descriptor),this._wrapModeDirty=!0)}setShadowFiltering(t){t!==this._descriptor.linearFilterDepth&&(this._descriptor.linearFilterDepth=t,this._descriptor.compareEnabled=t,this.setSamplingMode(t?l.LINEAR:l.NEAREST),T(this._descriptor),this._shadowFilterDirty=!0)}applyChanges(){this._samplingModeDirty&&(this._applySamplingMode(),this._samplingModeDirty=!1),this._wrapModeDirty&&(this._applyWrapMode(),this._wrapModeDirty=!1),this._shadowFilterDirty&&(this._applyShadowMode(),this._shadowFilterDirty=!1)}abortCompression(){this._compressionAbortController=i(this._compressionAbortController)}_setData(i,r){const s=this._descriptor,a=s.context?.gl;if(!a)return;o(a),this.hasWebGLTextureObject||(this._glName=a.createTexture(),s.context.instanceCounter.increment(n.Texture,this)),T(s);const p=s.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);s.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),o(a);const l=r??s.target,h=g(l);if(u(i))this._setDataFromTexImageSource(i,l);else{const{width:e,height:r,depth:n}=s;if(null==e||null==r)throw new t("texture:missing-size","Width and height must be specified!");if(h&&null==n)throw new t("texture:missing-depth","Depth must be specified!");if(s.internalFormat=_(s),s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(l,s.internalFormat,s.hasMipmap,e,r,n),c(i)){if(!x(s.internalFormat))throw new t("texture:format-mismatch","Attempting to use compressed data with an uncompressed format!");this._setDataFromCompressedSource(i,s.internalFormat,l)}else this._texImage(l,0,s.internalFormat,e,r,n,i),o(a),s.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),this._applyShadowMode(),o(a),s.context.bindTexture(p,e.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(t=null){for(let e=a.TEXTURE_CUBE_MAP_POSITIVE_X;e<=a.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}_configurePixelStorage(){const t=this._descriptor.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)}_setDataFromTexImageSource(t,e){const{gl:i}=this._descriptor.context,r=this._descriptor;r.internalFormat=_(r);const s=g(e),{width:a,height:n,depth:p}=E(t);r.width&&r.height,r.width||(r.width=a),r.height||(r.height=n),s&&r.depth,s&&(r.depth=p),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(e,r.internalFormat,r.hasMipmap,a,n,p),this._texImage(e,0,r.internalFormat,a,n,p,t),o(i),r.hasMipmap&&(this.generateMipmap(),o(i))}_setDataFromCompressedSource(t,e,i){const r=this._descriptor,{width:s,height:o,depth:a}=r,n=t.levels,p=M(i,s,o,a),l=Math.min(p,n.length)-1;this._descriptor.context.gl.texParameteri(r.target,h.MAX_LEVEL,l),this._forEachMipmapLevel(((t,r,s,o)=>{const a=n[Math.min(t,n.length-1)];this._compressedTexImage(i,t,e,r,s,o,a)}),l)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!A(i)&&!b(i)&&!w(i))throw new t("texture:missing-format","Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const p=r?M(e,s,o,a):1;if(g(e)){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");n.texStorage3D(e,p,i,s,o,a)}else n.texStorage2D(e,p,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=g(e),{isImmutable:h,pixelFormat:m,dataType:d}=this._descriptor;if(h){if(null!=n){const r=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texSubImage3D(e,i,0,0,0,s,o,a,m,d,r)}else p.texSubImage2D(e,i,0,0,s,o,m,d,r)}}else{const h=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texImage3D(e,i,r,s,o,a,0,m,d,h)}else p.texImage2D(e,i,r,s,o,0,m,d,h)}}_compressedTexImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=g(e);if(this._descriptor.isImmutable){if(null!=n)if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else p.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexImage3D(e,i,r,s,o,a,0,n)}else p.compressedTexImage2D(e,i,r,s,o,0,n)}async _compressOnWorker(t){const{context:i,compressionHandle:o,compressionCallback:a,flipped:n,preMultiplyAlpha:p,hasMipmap:l}=this._descriptor,{compressedTextureETC:h,compressedTextureS3TC:m}=i.capabilities;if(!e.compressionWorkerHandle?.isCompressible(t)||!h&&!m)return;this.abortCompression();const d=new AbortController;this._compressionAbortController=d,o.increment();try{const i=await createImageBitmap(t,{imageOrientation:n?"flipY":"none"});r(d);const s={bitmap:i,width:t.width,height:t.height,preMultiplyAlpha:p,hasMipmap:l,hasETC:!!h,hasS3TC:!!m},o=await e.compressionWorkerHandle.invoke(s,d.signal);r(d),o&&this.hasWebGLTextureObject&&(this._descriptor.internalFormat=o.internalFormat,this._setData(o.compressedTexture),a?.())}catch(c){s(c)||R().error("Texture compression failed!")}finally{o.decrement(),this._compressionAbortController?.signal.aborted&&(this._compressionAbortController=null)}}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:o,hasMipmap:n,target:p}=this._descriptor;const l=p===a.TEXTURE_3D;if(null==r||null==s||l&&null==o)throw new t("texture:missing-size","Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,o),n&&(1!==r||1!==s||l&&1!==o)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),l&&(o=Math.max(1,o>>1))}_applySamplingMode(){const t=this._descriptor,e=t.context?.gl;let i=t.samplingMode,r=t.samplingMode;i===l.LINEAR_MIPMAP_NEAREST||i===l.LINEAR_MIPMAP_LINEAR?(i=l.LINEAR,t.hasMipmap||(r=l.LINEAR)):i!==l.NEAREST_MIPMAP_NEAREST&&i!==l.NEAREST_MIPMAP_LINEAR||(i=l.NEAREST,t.hasMipmap||(r=l.NEAREST)),e.texParameteri(t.target,e.TEXTURE_MAG_FILTER,i),e.texParameteri(t.target,e.TEXTURE_MIN_FILTER,r)}_applyWrapMode(){const t=this._descriptor,e=t.context?.gl;"number"==typeof t.wrapMode?(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode)):(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode.s),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode.t))}_applyShadowMode(){const t=this._descriptor,e=t.context?.gl,i=t.compareEnabled?e.COMPARE_REF_TO_TEXTURE:e.NONE;e.texParameteri(t.target,e.TEXTURE_COMPARE_MODE,i),t.compareEnabled&&e.texParameteri(t.target,e.TEXTURE_COMPARE_FUNC,e.GREATER),o(e)}_applyAnisotropicFilteringParameters(){const t=this._descriptor,e=t.context.capabilities.textureFilterAnisotropic;if(!e)return;t.context.gl.texParameterf(t.target,e.TEXTURE_MAX_ANISOTROPY,t.maxAnisotropy??1)}};export{D as Texture,I as tracer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{TextureType as t,PixelFormat as i,PixelType as h,TextureSamplingMode as s,TextureWrapMode as e}from"./enums.js";import{FBOAttachmentType as p}from"./FBOAttachmentType.js";import{getBytesPerElementFormat as r}from"./Util.js";class a{constructor(r=0,a=r){this.width=r,this.height=a,this.type=p.TextureDescriptor,this.target=t.TEXTURE_2D,this.pixelFormat=i.RGBA,this.dataType=h.UNSIGNED_BYTE,this.samplingMode=s.LINEAR,this.wrapMode=e.REPEAT,this.maxAnisotropy=1,this.flipped=!1,this.hasMipmap=!1,this.isOpaque=!1,this.unpackAlignment=4,this.preMultiplyAlpha=!1,this.depth=1,this.isImmutable=!1}}function o(i){return i.width<=0||i.height<=0||i.depth<=0?0:Math.round(i.width*i.height*i.depth*(i.hasMipmap?4/3:1)*(null==i.internalFormat?4:r(i.internalFormat))*(i.target===t.TEXTURE_CUBE_MAP?6:1))}export{a as TextureDescriptor,o as estimateMemory};
5
+ import{TextureType as t,PixelFormat as i,PixelType as h,TextureSamplingMode as e,TextureWrapMode as s}from"./enums.js";import{FBOAttachmentType as p}from"./FBOAttachmentType.js";import{getBytesPerElementFormat as r}from"./Util.js";class a{constructor(r=0,a=r){this.width=r,this.height=a,this.type=p.TextureDescriptor,this.target=t.TEXTURE_2D,this.pixelFormat=i.RGBA,this.dataType=h.UNSIGNED_BYTE,this.samplingMode=e.LINEAR,this.wrapMode=s.REPEAT,this.maxAnisotropy=1,this.flipped=!1,this.hasMipmap=!1,this.isOpaque=!1,this.unpackAlignment=4,this.preMultiplyAlpha=!1,this.compareEnabled=!1,this.linearFilterDepth=!1,this.depth=1,this.isImmutable=!1}}function o(i){return i.width<=0||i.height<=0||i.depth<=0?0:Math.round(i.width*i.height*i.depth*(i.hasMipmap?4/3:1)*(null==i.internalFormat?4:r(i.internalFormat))*(i.target===t.TEXTURE_CUBE_MAP?6:1))}export{a as TextureDescriptor,o as estimateMemory};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../core/Error.js";import e from"../../core/Logger.js";import{PixelType as n,PixelFormat as r,SizedPixelFormat as i,SizedDepthStencilFormat as o,SizedDepthFormat as u,UnsizedDepthFormat as a,TextureType as l,CompressedTextureFormat as c}from"./enums.js";const h=()=>e.getLogger("esri/views/webgl/textureUtils");function s(t){(null!=t.width&&t.width<0||null!=t.height&&t.height<0||null!=t.depth&&t.depth<0)&&h().error("Negative dimension parameters are not allowed!")}function d(t){return t in i}function m(t){return t in u}function f(t){return t in o}function E(t){return null!=t&&t in c}function T(t){return null!=t&&"type"in t&&"compressed"===t.type}function g(t){return E(t.descriptor.internalFormat)}function p(t){return null!=t&&"byteLength"in t}function w(t){return null!=t&&!T(t)&&!p(t)}function R(t){return t===l.TEXTURE_3D||t===l.TEXTURE_2D_ARRAY}function F(t,e,n,r=1){let i=Math.max(e,n);return t===l.TEXTURE_3D&&(i=Math.max(i,r)),Math.floor(Math.log2(i))+1}function B(e){if(null!=e.internalFormat)return e.internalFormat;switch(e.dataType){case n.FLOAT:switch(e.pixelFormat){case r.RGBA:return i.RGBA32F;case r.RGB:return i.RGB32F;default:throw new t("texture:unknown-format","Unable to derive format")}case n.UNSIGNED_BYTE:switch(e.pixelFormat){case r.RGBA:return i.RGBA8;case r.RGB:return i.RGB8}}const{pixelFormat:l}=e;return e.internalFormat=l===a.DEPTH_STENCIL?o.DEPTH24_STENCIL8:l===a.DEPTH_COMPONENT?u.DEPTH_COMPONENT24:l,e.internalFormat}function G(t){let e="width"in t?t.width:t.codedWidth,n="height"in t?t.height:t.codedHeight;const r=1;return t instanceof HTMLVideoElement&&(e=t.videoWidth,n=t.videoHeight),{width:e,height:n,depth:r}}export{F as calcMipmapLevels,B as deriveInternalFormat,G as getDimensions,R as is3DTarget,p as isArrayBufferView,T as isCompressedData,E as isCompressedFormat,g as isCompressedTexture,m as isSizedDepthFormat,f as isSizedDepthStencilFormat,d as isSizedPixelFormat,w as isTexImageSource,s as validateTexture};
5
+ import t from"../../core/Error.js";import e from"../../core/Logger.js";import{PixelType as n,PixelFormat as r,SizedPixelFormat as i,SizedDepthStencilFormat as o,SizedDepthFormat as a,UnsizedDepthFormat as u,TextureType as l,TextureSamplingMode as c,CompressedTextureFormat as s}from"./enums.js";const h=()=>e.getLogger("esri/views/webgl/textureUtils");function m(t){const{width:e,height:n,depth:r}=t;(null!=e&&e<0||null!=n&&n<0||null!=r&&r<0)&&h().error("Negative dimension parameters are not allowed!");const{internalFormat:i}=t;if(i&&(f(i)||E(i))){const{linearFilterDepth:e,compareEnabled:n,samplingMode:r,hasMipmap:i}=t;i&&h().error("Depth textures cannot have mipmaps"),e?r!==c.LINEAR&&r!==c.NEAREST&&h().error("Depth textures cannot sample mipmaps"):(r!==c.NEAREST&&h().error("Depth textures without filtering must use NEAREST filtering"),n&&h().error("Depth textures without filtering cannot use compare function"))}}function p(t){return t in i}function f(t){return t in a}function E(t){return t in o}function d(t){return null!=t&&t in s}function T(t){return null!=t&&"type"in t&&"compressed"===t.type}function g(t){return d(t.descriptor.internalFormat)}function R(t){return null!=t&&"byteLength"in t}function w(t){return null!=t&&!T(t)&&!R(t)}function D(t){return t===l.TEXTURE_3D||t===l.TEXTURE_2D_ARRAY}function F(t,e,n,r=1){let i=Math.max(e,n);return t===l.TEXTURE_3D&&(i=Math.max(i,r)),Math.floor(Math.log2(i))+1}function N(e){if(null!=e.internalFormat)return e.internalFormat;switch(e.dataType){case n.FLOAT:switch(e.pixelFormat){case r.RGBA:return i.RGBA32F;case r.RGB:return i.RGB32F;default:throw new t("texture:unknown-format","Unable to derive format")}case n.UNSIGNED_BYTE:switch(e.pixelFormat){case r.RGBA:return i.RGBA8;case r.RGB:return i.RGB8}}const{pixelFormat:l}=e;return e.internalFormat=l===u.DEPTH_STENCIL?o.DEPTH24_STENCIL8:l===u.DEPTH_COMPONENT?a.DEPTH_COMPONENT24:l,e.internalFormat}function x(t){let e="width"in t?t.width:t.codedWidth,n="height"in t?t.height:t.codedHeight;const r=1;return t instanceof HTMLVideoElement&&(e=t.videoWidth,n=t.videoHeight),{width:e,height:n,depth:r}}export{F as calcMipmapLevels,N as deriveInternalFormat,x as getDimensions,D as is3DTarget,R as isArrayBufferView,T as isCompressedData,d as isCompressedFormat,g as isCompressedTexture,f as isSizedDepthFormat,E as isSizedDepthStencilFormat,p as isSizedPixelFormat,w as isTexImageSource,m as validateTexture};