@arcgis/core 4.34.0-next.1 → 4.34.0-next.3

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 (391) hide show
  1. package/Map.js +1 -1
  2. package/WebScene.js +1 -1
  3. package/analysis/DimensionAnalysis.js +1 -1
  4. package/analysis/LineOfSightAnalysis.js +1 -1
  5. package/analysis/ViewshedAnalysis.js +1 -1
  6. package/arcade/Voxel.js +1 -1
  7. package/arcade/functions/knowledgegraph.js +1 -1
  8. package/assets/esri/core/workers/RemoteClient.js +1 -1
  9. package/assets/esri/core/workers/chunks/{253bcc3cc7bc4c2dc6ea.js → 03db109e9b695528c35d.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{fc61d02286b6ff5447cc.js → 09da6b3085fc84cd69d5.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{bf3555f91492a1a3b613.js → 09f76ca9b47b465c934f.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{42d9989b2aad3ac28d4d.js → 0d78fc2c2bc1152f84db.js} +1 -1
  13. package/assets/esri/core/workers/chunks/0fd826e7f64a37aaaa1e.js +1 -0
  14. package/assets/esri/core/workers/chunks/{ead5d4e271effc04def3.js → 1415d4e2f5f3193be004.js} +1 -1
  15. package/assets/esri/core/workers/chunks/17e43a050fbf8dc87588.js +1 -0
  16. package/assets/esri/core/workers/chunks/1ee6e9a88f0676032e91.js +1 -0
  17. package/assets/esri/core/workers/chunks/{1c86aa3802d9ae0230ae.js → 28e31ac00dc95a1318e9.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{ece68a25651ef03fc95d.js → 342f61e784c9364a493b.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{0d23610475c85385fbff.js → 355e6bcdb401ada71f39.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{bba6d7615d8f3862fe70.js → 36f0046ff6b46adce7b7.js} +1 -1
  21. package/assets/esri/core/workers/chunks/3adcf78ed1e7cd82666d.js +1 -0
  22. package/assets/esri/core/workers/chunks/{b0522dffa5600345c07e.js → 3e85e63148b5e93d3074.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{d2ebb72a43d995ed368a.js → 42bb9bb6fe44a47d9b81.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{6ee41e9c92ed8ba4c763.js → 4dd0a5f327fa5fc7249d.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{36b0d6b4089a96475201.js → 51ba7345c31e6eb79060.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{66e79aa02b3aa12b3778.js → 5200be8bce60fa831026.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{6b23ca6570357f9fb724.js → 52a57106a41b8c9483d7.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{fa63b0f7fa799cb2f81d.js → 562800b0af52a38a311b.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{585c7b485c42555ec554.js → 61f9747c960d959b571b.js} +2 -2
  30. package/assets/esri/core/workers/chunks/{9fc35ec8185beba96715.js → 632d1a1287dde980479e.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{1d043965dcdc11b3aeaa.js → 63852887b3f07d50f7c9.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{32ee2708edd307954125.js → 7174150bf7595c22f976.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{e77371ddbaf4b2d9be8d.js → 74c0db9e3a62e9839b23.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{6ecc3a3737ae8622dfa4.js → 7b12607633bbdc318936.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{06eb4832b6c86744e52e.js → 8008f5479f4d16964088.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{d839a237d5edc243d645.js → 8aa8f9986b966ccb64e2.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{67338948e470c1251d8a.js → 8d14e957219364a81d5f.js} +3 -3
  38. package/assets/esri/core/workers/chunks/92a5dccb328229a9336b.js +1 -0
  39. package/assets/esri/core/workers/chunks/{631205dc4d73d49ec9ed.js → 95507ff0a243e451b99e.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{1051a5a57b2fb843a555.js → 9cd55043f3d789f41815.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{40f54c4f8ae63c6f3df9.js → a32dcd5bc4680374d30c.js} +1 -1
  42. package/assets/esri/core/workers/chunks/ad4f65d764654c70a117.js +1 -0
  43. package/assets/esri/core/workers/chunks/b2a6afa0cd537805b4b8.js +1 -0
  44. package/assets/esri/core/workers/chunks/{ac2607f1e8cd2e99907c.js → b70f65ccee01d48a610e.js} +2 -2
  45. package/assets/esri/core/workers/chunks/{571252c9822d73cf7b01.js → b845586219f284a215b2.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{d7b640f7a181bd26c7c7.js → bac5e1d50b69f0d94694.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{9ca480eb8b2312381ccf.js → bcadcb709e622f2aaaf9.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{c16e0da7a19310c71e8b.js → c6cd8784a3e222eb2d4a.js} +1 -1
  49. package/assets/esri/core/workers/chunks/{97c148adf0347c69a79c.js → c9604f8df909ec4fad46.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{b87fec1753f164c845c5.js → ca76950d81ab4ebb65e1.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{faa40ef04604c7cce706.js → cb63ea6a53d3c2fc3179.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{54f4a1131f99468db076.js → d33a5d79f2163ad62b1d.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{55f087bca75c3f2a4515.js → d3c0d7799c92c6f0e7d3.js} +1 -1
  54. package/assets/esri/core/workers/chunks/{ca60b34c3e1ed2ff5934.js → dd2b316baae02bbdddac.js} +1 -1
  55. package/assets/esri/core/workers/chunks/{e3c1aea34ece8336dae1.js → e9aa1d9ded8a52a40c57.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{80b596496800e8d60eb8.js → ed75e0962358523f4439.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{0cf979a093e9744d1e80.js → ef7955a2509be0f03ca2.js} +1 -1
  58. package/assets/esri/core/workers/chunks/{b5d68d8460b7c15001dd.js → f1c6df5cf2ccb6ac47a1.js} +1 -1
  59. package/assets/esri/core/workers/chunks/f2aa8090827086c62dde.js +1 -0
  60. package/assets/esri/core/workers/chunks/{523046e04679e301797d.js → f3d97a4c4f433adbdab5.js} +1 -1
  61. package/assets/esri/core/workers/chunks/fd4c020297badcb81947.js +1 -0
  62. package/assets/esri/core/workers/chunks/{9a06476b834584d00d5c.js → feaf79b69d2e2a1f2aa2.js} +1 -1
  63. package/assets/esri/widgets/Editor/t9n/Editor.json +1 -1
  64. package/assets/esri/widgets/Editor/t9n/Editor_ar.json +1 -1
  65. package/assets/esri/widgets/Editor/t9n/Editor_bg.json +1 -1
  66. package/assets/esri/widgets/Editor/t9n/Editor_bs.json +1 -1
  67. package/assets/esri/widgets/Editor/t9n/Editor_ca.json +1 -1
  68. package/assets/esri/widgets/Editor/t9n/Editor_cs.json +1 -1
  69. package/assets/esri/widgets/Editor/t9n/Editor_da.json +1 -1
  70. package/assets/esri/widgets/Editor/t9n/Editor_de.json +1 -1
  71. package/assets/esri/widgets/Editor/t9n/Editor_el.json +1 -1
  72. package/assets/esri/widgets/Editor/t9n/Editor_en.json +1 -1
  73. package/assets/esri/widgets/Editor/t9n/Editor_es.json +1 -1
  74. package/assets/esri/widgets/Editor/t9n/Editor_et.json +1 -1
  75. package/assets/esri/widgets/Editor/t9n/Editor_fi.json +1 -1
  76. package/assets/esri/widgets/Editor/t9n/Editor_fr.json +1 -1
  77. package/assets/esri/widgets/Editor/t9n/Editor_he.json +1 -1
  78. package/assets/esri/widgets/Editor/t9n/Editor_hr.json +1 -1
  79. package/assets/esri/widgets/Editor/t9n/Editor_hu.json +1 -1
  80. package/assets/esri/widgets/Editor/t9n/Editor_id.json +1 -1
  81. package/assets/esri/widgets/Editor/t9n/Editor_it.json +1 -1
  82. package/assets/esri/widgets/Editor/t9n/Editor_ja.json +1 -1
  83. package/assets/esri/widgets/Editor/t9n/Editor_ko.json +1 -1
  84. package/assets/esri/widgets/Editor/t9n/Editor_lt.json +1 -1
  85. package/assets/esri/widgets/Editor/t9n/Editor_lv.json +1 -1
  86. package/assets/esri/widgets/Editor/t9n/Editor_nl.json +1 -1
  87. package/assets/esri/widgets/Editor/t9n/Editor_no.json +1 -1
  88. package/assets/esri/widgets/Editor/t9n/Editor_pl.json +1 -1
  89. package/assets/esri/widgets/Editor/t9n/Editor_pt-BR.json +1 -1
  90. package/assets/esri/widgets/Editor/t9n/Editor_pt-PT.json +1 -1
  91. package/assets/esri/widgets/Editor/t9n/Editor_ro.json +1 -1
  92. package/assets/esri/widgets/Editor/t9n/Editor_ru.json +1 -1
  93. package/assets/esri/widgets/Editor/t9n/Editor_sk.json +1 -1
  94. package/assets/esri/widgets/Editor/t9n/Editor_sl.json +1 -1
  95. package/assets/esri/widgets/Editor/t9n/Editor_sr.json +1 -1
  96. package/assets/esri/widgets/Editor/t9n/Editor_sv.json +1 -1
  97. package/assets/esri/widgets/Editor/t9n/Editor_th.json +1 -1
  98. package/assets/esri/widgets/Editor/t9n/Editor_tr.json +1 -1
  99. package/assets/esri/widgets/Editor/t9n/Editor_uk.json +1 -1
  100. package/assets/esri/widgets/Editor/t9n/Editor_vi.json +1 -1
  101. package/assets/esri/widgets/Editor/t9n/Editor_zh-CN.json +1 -1
  102. package/assets/esri/widgets/Editor/t9n/Editor_zh-HK.json +1 -1
  103. package/assets/esri/widgets/Editor/t9n/Editor_zh-TW.json +1 -1
  104. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable.json +1 -1
  105. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ar.json +1 -1
  106. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_bg.json +1 -1
  107. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_bs.json +1 -1
  108. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ca.json +1 -1
  109. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_cs.json +1 -1
  110. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_da.json +1 -1
  111. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_de.json +1 -1
  112. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_el.json +1 -1
  113. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_en.json +1 -1
  114. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_es.json +1 -1
  115. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_et.json +1 -1
  116. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_fi.json +1 -1
  117. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_fr.json +1 -1
  118. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_he.json +1 -1
  119. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_hr.json +1 -1
  120. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_hu.json +1 -1
  121. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_id.json +1 -1
  122. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_it.json +1 -1
  123. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ja.json +1 -1
  124. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ko.json +1 -1
  125. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_lt.json +1 -1
  126. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_lv.json +1 -1
  127. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_nl.json +1 -1
  128. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_no.json +1 -1
  129. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pl.json +1 -1
  130. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pt-BR.json +1 -1
  131. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pt-PT.json +1 -1
  132. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ro.json +1 -1
  133. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ru.json +1 -1
  134. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sk.json +1 -1
  135. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sl.json +1 -1
  136. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sr.json +1 -1
  137. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sv.json +1 -1
  138. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_th.json +1 -1
  139. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_tr.json +1 -1
  140. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_uk.json +1 -1
  141. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_vi.json +1 -1
  142. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-CN.json +1 -1
  143. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-HK.json +1 -1
  144. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-TW.json +1 -1
  145. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ar.json +1 -1
  146. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bg.json +1 -1
  147. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bs.json +1 -1
  148. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ca.json +1 -1
  149. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_cs.json +1 -1
  150. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_da.json +1 -1
  151. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_de.json +1 -1
  152. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_el.json +1 -1
  153. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_es.json +1 -1
  154. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_et.json +1 -1
  155. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fi.json +1 -1
  156. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fr.json +1 -1
  157. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_he.json +1 -1
  158. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hr.json +1 -1
  159. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hu.json +1 -1
  160. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_id.json +1 -1
  161. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_it.json +1 -1
  162. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ja.json +1 -1
  163. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ko.json +1 -1
  164. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lt.json +1 -1
  165. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lv.json +1 -1
  166. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_nl.json +1 -1
  167. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_no.json +1 -1
  168. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pl.json +1 -1
  169. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-BR.json +1 -1
  170. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-PT.json +1 -1
  171. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ro.json +1 -1
  172. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ru.json +1 -1
  173. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sk.json +1 -1
  174. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sl.json +1 -1
  175. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sr.json +1 -1
  176. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sv.json +1 -1
  177. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_th.json +1 -1
  178. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_tr.json +1 -1
  179. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_uk.json +1 -1
  180. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_vi.json +1 -1
  181. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-CN.json +1 -1
  182. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-HK.json +1 -1
  183. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-TW.json +1 -1
  184. package/chunks/FocusAreaColor.glsl.js +10 -8
  185. package/chunks/Laserlines.glsl.js +2 -2
  186. package/chunks/cameraUtilsSpherical.js +1 -1
  187. package/chunks/persistableUrlUtils.js +1 -1
  188. package/chunks/sphere.js +1 -1
  189. package/chunks/vec42.js +1 -1
  190. package/config.js +1 -1
  191. package/core/accessorSupport/decorators/persistable.js +1 -1
  192. package/core/accessorSupport/ensureType.js +1 -1
  193. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  194. package/core/libs/gl-matrix-2/math/vec4.js +1 -1
  195. package/effects/FocusArea.js +5 -0
  196. package/effects/FocusAreaOutline.js +5 -0
  197. package/effects/FocusAreas.js +5 -0
  198. package/geometry/projection/projectPointToVector.js +1 -1
  199. package/geometry/projection/projectVectorToPoint.js +1 -1
  200. package/geometry/projection/projectVectorToVector.js +1 -1
  201. package/geometry/projection.js +1 -1
  202. package/geometry/projectionUtils.js +5 -0
  203. package/geometry/support/frustum.js +1 -1
  204. package/geometry/support/meshUtils/elevation.js +1 -1
  205. package/geometry/support/meshUtils/extent.js +1 -1
  206. package/geometry/support/sphere.js +1 -1
  207. package/interfaces.d.ts +171 -68
  208. package/kernel.js +1 -1
  209. package/layers/MapNotesLayer.js +1 -1
  210. package/layers/RouteLayer.js +1 -1
  211. package/layers/VideoLayer.js +1 -1
  212. package/layers/graphics/applyEditsUtils.js +1 -1
  213. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  214. package/layers/graphics/data/QueryEngine.js +1 -1
  215. package/layers/graphics/data/projectionSupport.js +1 -1
  216. package/layers/graphics/data/queryUtils.js +1 -1
  217. package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
  218. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  219. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  220. package/layers/ogc/wfsUtils.js +1 -1
  221. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  222. package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
  223. package/layers/orientedImagery/transformations/updateElevationUtils.js +1 -1
  224. package/layers/orientedImagery/transformations/utils.js +1 -1
  225. package/layers/support/ControlPointsGeoreference.js +1 -1
  226. package/layers/support/CornersGeoreference.js +1 -1
  227. package/layers/support/ElevationQuery.js +1 -1
  228. package/layers/support/ExtentAndRotationGeoreference.js +1 -1
  229. package/layers/support/GeoreferenceBase.js +1 -1
  230. package/layers/support/LocalMediaElementSource.js +1 -1
  231. package/layers/support/MediaElementView.js +1 -1
  232. package/layers/support/PolygonCollection.js +1 -1
  233. package/layers/support/SceneModification.js +1 -1
  234. package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
  235. package/layers/video/VideoController.js +1 -1
  236. package/networks/support/UNTraceConfiguration.js +1 -1
  237. package/networks/support/typeUtils.js +1 -1
  238. package/package.json +1 -1
  239. package/portal/schemas/definitions.js +1 -1
  240. package/portal/schemas/webScene.js +1 -1
  241. package/portal/support/portalItemUtils.js +1 -1
  242. package/renderers/support/AuthoringInfoVisualVariable.js +1 -1
  243. package/rest/knowledgeGraph/GraphAddFieldIndexResult.js +5 -0
  244. package/rest/knowledgeGraph/GraphAddNamedTypesResult.js +1 -1
  245. package/rest/knowledgeGraph/GraphAddPropertyResult.js +1 -1
  246. package/rest/knowledgeGraph/GraphDataModelOperationResult.js +5 -0
  247. package/rest/knowledgeGraph/GraphDeleteFieldIndexResult.js +5 -0
  248. package/rest/knowledgeGraph/GraphDeleteNamedTypeResult.js +1 -1
  249. package/rest/knowledgeGraph/GraphDeletePropertyResult.js +1 -1
  250. package/rest/knowledgeGraph/GraphUpdateNamedTypesResult.js +1 -1
  251. package/rest/knowledgeGraph/GraphUpdatePropertyResult.js +1 -1
  252. package/rest/knowledgeGraph/GraphUpdateSearchIndexResult.js +1 -1
  253. package/rest/knowledgeGraph/wasmInterface/updateToWasmEncodedFactories.js +1 -1
  254. package/rest/knowledgeGraph/wasmInterface/wasmToDataModelChangeResponseFactories.js +1 -1
  255. package/rest/knowledgeGraphService.js +1 -1
  256. package/rest/networks/support/CircuitPath.js +5 -0
  257. package/rest/networks/support/CircuitPathConnectivityElement.js +5 -0
  258. package/rest/networks/support/TraceLocation.js +1 -1
  259. package/rest/networks/support/TraceResult.js +1 -1
  260. package/smartMapping/renderers/pieChart.js +1 -1
  261. package/smartMapping/renderers/predominance.js +1 -1
  262. package/smartMapping/renderers/size.js +1 -1
  263. package/smartMapping/renderers/support/rendererUtils.js +1 -1
  264. package/smartMapping/renderers/support/spikeUtils.d.ts +4 -0
  265. package/smartMapping/renderers/support/spikeUtils.js +1 -1
  266. package/smartMapping/statistics/histogram.js +1 -1
  267. package/smartMapping/statistics/summaryStatistics.js +1 -1
  268. package/support/persistableUrlUtils.js +1 -1
  269. package/support/revision.js +1 -1
  270. package/views/2d/ViewStateManager.js +1 -1
  271. package/views/2d/constraints/GeometryConstraint.js +1 -1
  272. package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
  273. package/views/2d/grid/GridView2D.js +1 -1
  274. package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
  275. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  276. package/views/2d/layers/KMLLayerView2D.js +1 -1
  277. package/views/2d/layers/VideoLayerView2D.js +1 -1
  278. package/views/2d/viewpointUtils.js +1 -1
  279. package/views/3d/FocusAreasView.js +1 -1
  280. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
  281. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  282. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  283. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  284. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  285. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  286. package/views/3d/analysis/support/projectionUtils.js +1 -1
  287. package/views/3d/camera/constraintUtils/distance.js +1 -1
  288. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  289. package/views/3d/environment/EnvironmentManager.js +1 -1
  290. package/views/3d/interactive/Manipulator3D.js +1 -1
  291. package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
  292. package/views/3d/interactive/editingTools/media/MediaElementControllerControlPoints.js +1 -1
  293. package/views/3d/interactive/editingTools/media/MediaElementControllerShape.js +1 -1
  294. package/views/3d/interactive/editingTools/reshape/edgeOffsetUtils.js +1 -1
  295. package/views/3d/interactive/visualElements/DrapedVisualElementResources.js +1 -1
  296. package/views/3d/interactive/visualElements/support/Segment.js +1 -1
  297. package/views/3d/layers/FeatureLayerView3D.js +1 -1
  298. package/views/3d/layers/FlowSubView3D.js +1 -1
  299. package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
  300. package/views/3d/layers/SceneLayerWorker.js +1 -1
  301. package/views/3d/layers/TileLayerView3D.js +1 -1
  302. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  303. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  304. package/views/3d/layers/graphics/Graphics3DFeatureStore.js +1 -1
  305. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  306. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  307. package/views/3d/layers/graphics/focusAreaStyle.js +1 -1
  308. package/views/3d/layers/graphics/graphicUtils.js +1 -1
  309. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
  310. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  311. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  312. package/views/3d/layers/support/ImageHighlightHelper3D.js +1 -1
  313. package/views/3d/state/NearFarHeuristic.js +1 -1
  314. package/views/3d/state/ViewStateManager.js +1 -1
  315. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  316. package/views/3d/state/utils/navigationUtils.js +1 -1
  317. package/views/3d/support/cameraUtils.js +1 -1
  318. package/views/3d/support/geometryUtils/sphere.js +1 -1
  319. package/views/3d/support/sunUtils.js +1 -1
  320. package/views/3d/support/viewpointUtils.js +1 -1
  321. package/views/3d/terrain/ExtentHelper.js +1 -1
  322. package/views/3d/terrain/OverlayManager.js +1 -1
  323. package/views/3d/terrain/OverlayRenderer.js +1 -1
  324. package/views/3d/webgl/RenderCamera.js +1 -1
  325. package/views/3d/webgl/RenderNode.js +1 -1
  326. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  327. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorNode.js +1 -1
  328. package/views/3d/webgl-engine/effects/focusArea/FocusAreaEffect.js +5 -0
  329. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  330. package/views/3d/webgl-engine/effects/focusArea/FocusAreaOutlineItem.js +5 -0
  331. package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
  332. package/views/3d/webgl-engine/effects/laserlines/LaserlinePathTechniqueConfiguration.js +1 -1
  333. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  334. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  335. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  336. package/views/3d/webgl-engine/shaders/CompositingTechniqueConfiguration.js +1 -1
  337. package/views/3d/webgl-engine/shaders/FocusAreaColor.glsl.js +1 -1
  338. package/views/SceneView.js +1 -1
  339. package/views/VideoView.js +1 -1
  340. package/views/View2D.js +1 -1
  341. package/views/interactive/GraphicManipulator.js +1 -1
  342. package/views/interactive/dragEventPipeline.js +1 -1
  343. package/views/interactive/snapping/GridSnappingEngine.js +1 -1
  344. package/views/interactive/snapping/SnappingManager.js +1 -1
  345. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  346. package/views/layers/SceneLayerView.js +1 -1
  347. package/views/support/projectionUtils.js +1 -1
  348. package/views/webgl/RenderingContext.js +1 -1
  349. package/views/webgl/Texture.js +1 -1
  350. package/webscene/Slide.js +1 -1
  351. package/widgets/BasemapGallery/BasemapGalleryViewModel.js +1 -1
  352. package/widgets/BasemapToggle/BasemapToggleViewModel.js +1 -1
  353. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  354. package/widgets/CoordinateConversion/support/Format.js +1 -1
  355. package/widgets/Daylight/DaylightViewModel.js +1 -1
  356. package/widgets/Editor/EditorViewModel.js +1 -1
  357. package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
  358. package/widgets/Editor/UpdateFeaturesWorkflowData.js +1 -1
  359. package/widgets/Editor/UpdateWorkflow.js +1 -1
  360. package/widgets/Editor/Upload.js +1 -1
  361. package/widgets/Editor/components/Notices.js +1 -1
  362. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  363. package/widgets/Editor/workflowUtils.js +1 -1
  364. package/widgets/Editor.js +1 -1
  365. package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
  366. package/widgets/FeatureTable/FieldColumn.js +1 -1
  367. package/widgets/FeatureTable/Grid/EditorColumn.js +1 -1
  368. package/widgets/Features/FeaturesViewModel.js +1 -1
  369. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  370. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  371. package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
  372. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  373. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  374. package/widgets/Sketch/SketchViewModel.js +1 -1
  375. package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
  376. package/widgets/support/AnchorElementViewModel.js +1 -1
  377. package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
  378. package/widgets/support/tests.js +1 -1
  379. package/assets/esri/core/workers/chunks/094e8aae6dada24c8115.js +0 -1
  380. package/assets/esri/core/workers/chunks/24327d01cb2c5c55a4b7.js +0 -1
  381. package/assets/esri/core/workers/chunks/2b1486a466760d2152f5.js +0 -1
  382. package/assets/esri/core/workers/chunks/3a743653b786b010a57f.js +0 -1
  383. package/assets/esri/core/workers/chunks/62b2d3720693c93a60f2.js +0 -1
  384. package/assets/esri/core/workers/chunks/6d1e1a4fcb90ea8b6848.js +0 -1
  385. package/assets/esri/core/workers/chunks/87fc7b6c3e2d4f7775e2.js +0 -1
  386. package/assets/esri/core/workers/chunks/b06cb23048c32940f5de.js +0 -1
  387. package/assets/esri/core/workers/chunks/d3d98ea5b5e56fc60a31.js +0 -1
  388. package/views/FocusArea.js +0 -5
  389. package/views/FocusAreaOutline.js +0 -5
  390. package/views/FocusAreaOutlineItem.js +0 -5
  391. package/views/FocusAreas.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.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{createTask as n}from"../../../core/asyncUtils.js";import i from"../../../core/Evented.js";import"../../../core/has.js";import{throwIfAborted as s,isAborted as a}from"../../../core/promiseUtils.js";import{watch as r,syncAndInitial as o,sync as p}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{project as h,initializeProjection as l}from"../../../geometry/projection.js";import{absoluteHeightElevationInfo as u}from"../../../support/elevationInfoUtils.js";import{fromPoint as f,markAsTarget as g,toElevationAlignedDehydratedPoint as _}from"../sketch/normalizedPoint.js";import{defaults as S}from"./Settings.js";import{SnappingDomain as m}from"./SnappingDomain.js";import v from"./SnappingOptions.js";import{sortCandidatesInPlace as y,squaredScreenDistance as C}from"./snappingUtils.js";import{DrapedEdgeSnappingCandidate as w}from"./candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as E}from"./candidates/EdgeSnappingCandidate.js";import{IntersectionSnappingCandidate as P}from"./candidates/IntersectionSnappingCandidate.js";import{LineSnappingCandidate as T}from"./candidates/LineSnappingCandidate.js";import{ParallelLineSnappingCandidate as j}from"./candidates/ParallelLineSnappingCandidate.js";import{RightAngleSnappingCandidate as M,SelfSnappingRightAngleType as R}from"./candidates/RightAngleSnappingCandidate.js";import{RightAngleTriangleSnappingCandidate as q}from"./candidates/RightAngleTriangleSnappingCandidate.js";import{vectorToScreenPoint as A}from"../support/viewUtils.js";import{loadGeodesicLengthMeasurementUtils as I}from"../../support/geodesicLengthMeasurementUtils.js";let x=class extends(i.EventedMixin(t)){constructor(e){super(e),this.options=new v,this._engineCache=new Map,this._loadTask=null,this._engines=[],this._currentMainCandidate=null,this._currentOtherActiveCandidates=[],this._currentSnappedType=b.MAIN}initialize(){this.addHandles([r((()=>{const{distance:e,touchSensitivityMultiplier:t,effectiveSelfEnabled:n,effectiveFeatureEnabled:i,effectiveGridEnabled:s}=this.options;return{selfEnabled:n,featureEnabled:i,gridEnabled:"2d"===this.view.type&&s,viewReady:this.view.ready,viewSpatialReference:this.view.spatialReference,distance:e,touchSensitivityMultiplier:t}}),((e,t)=>{t&&(this.doneSnapping(),this.emit("changed")),this._loadTask?.abort(),this._loadTask=n((n=>this._updateEngines(e,t,n)))}),o),r((()=>this.options),(e=>{for(const t of this._engines)t.options=e}),p)])}destroy(){this._loadTask?.abort(),this._destroyEngines()}get updating(){return this._engines.some((e=>e.updating))||!this._loadTask?.finished}_destroyEngines(){this._engineCache.forEach((e=>e.destroy())),this._engineCache.clear(),this._engines=[]}async _updateEngines(e,t,n){if(!e.viewReady)return void this._destroyEngines();t?.viewSpatialReference!==e.viewSpatialReference&&this._destroyEngines();const i=this._engineCache,s=await Promise.allSettled([e.featureEnabled&&!i.has("feature")?this._createFeatureSnappingEngine(n):void 0,e.selfEnabled&&!i.has("self")?this._createSelfSnappingEngine(n):void 0,e.gridEnabled&&!i.has("grid")?this._createGridSnappingEngine(n):void 0]);if(n.aborted)for(const a of s)"fulfilled"===a.status&&a.value?.engine.destroy();else{for(const e of s)"fulfilled"===e.status&&e.value&&i.set(e.value.type,e.value.engine);this._engines=Array.from(i.values())}}async _createSelfSnappingEngine(e){const[{SelfSnappingEngine:t},n]=await Promise.all([import("./SelfSnappingEngine.js"),I()]);return s(e),{type:"self",engine:new t({view:this.view,options:this.options,geodesicLengthMeasurementUtils:n})}}async _createGridSnappingEngine(e){const{view:t}=this;if("2d"!==t.type)return;const{GridSnappingEngine:n}=await import("./GridSnappingEngine.js");return s(e),{type:"grid",engine:new n({view:t,options:this.options})}}async _createFeatureSnappingEngine(e){const{FeatureSnappingEngine:t}=await import("./FeatureSnappingEngine.js");s(e);const{view:n,options:i}=this,{spatialReference:a}=n;return{type:"feature",engine:new t({view:n,options:i,spatialReference:a})}}get _squaredMouseProximityThreshold(){return this.options.distance*this.options.distance}get _squaredTouchProximityThreshold(){const{distance:e,touchSensitivityMultiplier:t}=this.options,n=e*t;return n*n}snap(e){return k(e)?this._snapMultiPoint(e):this._snapSinglePoint(e)}update(e){const{point:t,context:n}=e;this._removeVisualization();const i=this._currentMainCandidate;if(null==i)return t;const s=this._selectUpdateInput(e);if(null==s)return t;const{spatialReference:a}=n,r=h(s,a);if(null==r)return t;const{view:o}=this,{elevationInfo:p,visualizer:d}=n,c=[],l=f(r,o,p),u=i.constraint.closestTo(l);if(!this._arePointsWithinScreenThreshold(l,u,n)||!N(i,n.drawConstraints))return this._resetSnappingState(),t;i.targetPoint=g(u),c.push(...i.hints);for(const h of this._currentOtherActiveCandidates)N(h,n.drawConstraints)&&(h.targetPoint=g(u),c.push(...h.hints));return null!=d&&this.addHandles(d.draw(c,{spatialReference:a,elevationInfo:H(n),view:o,selfSnappingZ:n.selfSnappingZ}),z),_(u,o,t,n)}doneSnapping(){this._removeVisualization(),this._resetSnappingState()}_selectUpdateInput({point:e,scenePoint:t}){switch(this._currentSnappedType){case b.MAIN:return e;case b.SCENE:return t}}_resetSnappingState(){this._currentMainCandidate=null,this._currentOtherActiveCandidates=[],this._currentSnappedType=b.MAIN}_removeVisualization(){this.removeHandles(z)}async _snapSinglePoint({point:e,context:t,signal:n}){const{view:i}=this,{elevationInfo:s}=t,a=f(e,i,s),r=await this._fetchCandidates(a,m.ALL,t,n);return this._createSnapResult(a,b.MAIN,r,i,e,t,n)}async _snapMultiPoint({point:e,scenePoint:t,context:n,signal:i}){const{view:s}=this,{coordinateHelper:a,elevationInfo:r,spatialReference:o}=n;await l(t.spatialReference,o);const p=h(t,o),d=f(p,s,r),c=await this._fetchCandidates(d,m.FEATURE,n,i);if(c.length>0){const e=await this._fetchCandidates(d,m.SELF,n,i);return this._createSnapResult(d,b.SCENE,[...c,...e],s,p,n,i)}const u=f(e,s,r),g=await this._fetchCandidates(u,m.SELF,n,i);return this._createSnapResult(u,b.MAIN,g,s,{z:a.hasZ()&&e.hasZ?e.z??0:void 0,m:a.hasM()&&e.hasM?e.m??0:void 0},n,i)}async _fetchCandidates(e,t,n,i){return(await Promise.all(this._engines.map((s=>s.fetchCandidates(e,t,n,i))))).flat()}_createSnapResult(e,t,n,i,s,r,o){return{get valid(){return!a(o)},apply:()=>{const{spatialReference:a}=r,{snappedPoint:o,hints:p}=this._processCandidates(e,t,n,r);return this._removeVisualization(),null!=r.visualizer&&this.addHandles(r.visualizer.draw(p,{spatialReference:a,elevationInfo:u,view:i,selfSnappingZ:r.selfSnappingZ}),z),_(o,i,s,r)}}}_processCandidates(e,t,n,i){if(n.length<1)return this.doneSnapping(),{snappedPoint:e,hints:[]};this._currentSnappedType!==t&&this._resetSnappingState(),y(e,n);const s=this._currentMainCandidate;if(null!=s){const a=U(s,n);if(a>=0){if(!(n[a]instanceof P))return this._intersectWithOtherCandidates(a,n,e,t,i);if(this._arePointsWithinScreenThreshold(e,s.targetPoint,i))return this._updateSnappingCandidate(s,t,n,i)}}return this._intersectWithOtherCandidates(0,n,e,t,i)}_intersectWithOtherCandidates(e,t,n,i,s){const{coordinateHelper:a}=s,r=t[e],o=[];for(let p=0;p<t.length;++p){if(p===e)continue;const i=t[p],s=r.constraint.intersect(i.constraint);if(s)for(const e of s.closestPoints(r.targetPoint))o.push([new P(g(e),r,i,i.isDraped),this._squaredScreenDistance(n,e,a)])}return o.length>0&&(o.sort(((e,t)=>e[1]-t[1])),o[0][1]<this._squaredPointProximityThreshold(s.pointer))?this._updateSnappingCandidate(o[0][0],i,t,s):N(r,s.drawConstraints)?this._updateSnappingCandidate(r,i,t,s):{snappedPoint:n,hints:[]}}_updateSnappingCandidate(e,t,n,i){this.doneSnapping(),this._currentMainCandidate=e,this._currentSnappedType=t;const s=this._currentMainCandidate.targetPoint,a=[];a.push(...e.hints);for(const r of n){if(e instanceof P){if(r.constraint.equals(e.first.constraint)||r.constraint.equals(e.second.constraint))continue}else if(r.constraint.equals(e.constraint))continue;const t=r.constraint.closestTo(s);this._squaredScreenDistance(t,s,i.coordinateHelper)<L()&&(r.targetPoint=s,this._currentOtherActiveCandidates.push(r),a.push(...r.hints))}return{snappedPoint:s,hints:a}}_squaredPointProximityThreshold(e){return"touch"===e?this._squaredTouchProximityThreshold:this._squaredMouseProximityThreshold}_arePointsWithinScreenThreshold(e,t,n){return this._squaredScreenDistance(e,t,n.coordinateHelper)<this._squaredPointProximityThreshold(n.pointer)}_squaredScreenDistance(e,t,n){return C(this._toScreen(e,n),this._toScreen(t,n))}_toScreen(e,t){return A(e,t.spatialReference,u,this.view)}get test(){}};var b;e([d({constructOnly:!0})],x.prototype,"view",void 0),e([d()],x.prototype,"options",void 0),e([d({readOnly:!0})],x.prototype,"updating",null),e([d()],x.prototype,"_loadTask",void 0),e([d()],x.prototype,"_engines",void 0),e([d()],x.prototype,"_squaredMouseProximityThreshold",null),e([d()],x.prototype,"_squaredTouchProximityThreshold",null),x=e([c("esri.views.interactive.snapping.SnappingManager")],x),function(e){e[e.MAIN=0]="MAIN",e[e.SCENE=1]="SCENE"}(b||(b={}));const z="visualization-handle";function L(){return S.satisfiesConstraintScreenThreshold*S.satisfiesConstraintScreenThreshold}function N(e,t){return!t||null==t.direction&&null==t.distance||!(e instanceof w||e instanceof E||e instanceof T||e instanceof j||e instanceof q)&&(!(e instanceof M)||null==t.direction&&e.selfSnappingType===R.LastVertex)}function U(e,t){return e instanceof P?O(t,e.first)>=0&&O(t,e.second)>=0?0:-1:O(t,e)}function O(e,t){let n=-1;for(let i=0;i<e.length;++i)if(t.constraint.equals(e[i].constraint)){n=i;break}return n}function k(e){return null!=e.scenePoint}function H({coordinateHelper:e,elevationInfo:t}){return e.hasZ()?u:t}export{x as SnappingManager};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{createTask as n}from"../../../core/asyncUtils.js";import i from"../../../core/Evented.js";import"../../../core/has.js";import{throwIfAborted as s,isAborted as a}from"../../../core/promiseUtils.js";import{watch as r,syncAndInitial as o,sync as p}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{project as h,initializeProjection as l}from"../../../geometry/projectionUtils.js";import{absoluteHeightElevationInfo as u}from"../../../support/elevationInfoUtils.js";import{fromPoint as f,markAsTarget as g,toElevationAlignedDehydratedPoint as _}from"../sketch/normalizedPoint.js";import{defaults as S}from"./Settings.js";import{SnappingDomain as m}from"./SnappingDomain.js";import v from"./SnappingOptions.js";import{sortCandidatesInPlace as y,squaredScreenDistance as C}from"./snappingUtils.js";import{DrapedEdgeSnappingCandidate as w}from"./candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as E}from"./candidates/EdgeSnappingCandidate.js";import{IntersectionSnappingCandidate as P}from"./candidates/IntersectionSnappingCandidate.js";import{LineSnappingCandidate as T}from"./candidates/LineSnappingCandidate.js";import{ParallelLineSnappingCandidate as j}from"./candidates/ParallelLineSnappingCandidate.js";import{RightAngleSnappingCandidate as M,SelfSnappingRightAngleType as R}from"./candidates/RightAngleSnappingCandidate.js";import{RightAngleTriangleSnappingCandidate as q}from"./candidates/RightAngleTriangleSnappingCandidate.js";import{vectorToScreenPoint as A}from"../support/viewUtils.js";import{loadGeodesicLengthMeasurementUtils as I}from"../../support/geodesicLengthMeasurementUtils.js";let x=class extends(i.EventedMixin(t)){constructor(e){super(e),this.options=new v,this._engineCache=new Map,this._loadTask=null,this._engines=[],this._currentMainCandidate=null,this._currentOtherActiveCandidates=[],this._currentSnappedType=b.MAIN}initialize(){this.addHandles([r((()=>{const{distance:e,touchSensitivityMultiplier:t,effectiveSelfEnabled:n,effectiveFeatureEnabled:i,effectiveGridEnabled:s}=this.options;return{selfEnabled:n,featureEnabled:i,gridEnabled:"2d"===this.view.type&&s,viewReady:this.view.ready,viewSpatialReference:this.view.spatialReference,distance:e,touchSensitivityMultiplier:t}}),((e,t)=>{t&&(this.doneSnapping(),this.emit("changed")),this._loadTask?.abort(),this._loadTask=n((n=>this._updateEngines(e,t,n)))}),o),r((()=>this.options),(e=>{for(const t of this._engines)t.options=e}),p)])}destroy(){this._loadTask?.abort(),this._destroyEngines()}get updating(){return this._engines.some((e=>e.updating))||!this._loadTask?.finished}_destroyEngines(){this._engineCache.forEach((e=>e.destroy())),this._engineCache.clear(),this._engines=[]}async _updateEngines(e,t,n){if(!e.viewReady)return void this._destroyEngines();t?.viewSpatialReference!==e.viewSpatialReference&&this._destroyEngines();const i=this._engineCache,s=await Promise.allSettled([e.featureEnabled&&!i.has("feature")?this._createFeatureSnappingEngine(n):void 0,e.selfEnabled&&!i.has("self")?this._createSelfSnappingEngine(n):void 0,e.gridEnabled&&!i.has("grid")?this._createGridSnappingEngine(n):void 0]);if(n.aborted)for(const a of s)"fulfilled"===a.status&&a.value?.engine.destroy();else{for(const e of s)"fulfilled"===e.status&&e.value&&i.set(e.value.type,e.value.engine);this._engines=Array.from(i.values())}}async _createSelfSnappingEngine(e){const[{SelfSnappingEngine:t},n]=await Promise.all([import("./SelfSnappingEngine.js"),I()]);return s(e),{type:"self",engine:new t({view:this.view,options:this.options,geodesicLengthMeasurementUtils:n})}}async _createGridSnappingEngine(e){const{view:t}=this;if("2d"!==t.type)return;const{GridSnappingEngine:n}=await import("./GridSnappingEngine.js");return s(e),{type:"grid",engine:new n({view:t,options:this.options})}}async _createFeatureSnappingEngine(e){const{FeatureSnappingEngine:t}=await import("./FeatureSnappingEngine.js");s(e);const{view:n,options:i}=this,{spatialReference:a}=n;return{type:"feature",engine:new t({view:n,options:i,spatialReference:a})}}get _squaredMouseProximityThreshold(){return this.options.distance*this.options.distance}get _squaredTouchProximityThreshold(){const{distance:e,touchSensitivityMultiplier:t}=this.options,n=e*t;return n*n}snap(e){return k(e)?this._snapMultiPoint(e):this._snapSinglePoint(e)}update(e){const{point:t,context:n}=e;this._removeVisualization();const i=this._currentMainCandidate;if(null==i)return t;const s=this._selectUpdateInput(e);if(null==s)return t;const{spatialReference:a}=n,r=h(s,a);if(null==r)return t;const{view:o}=this,{elevationInfo:p,visualizer:d}=n,c=[],l=f(r,o,p),u=i.constraint.closestTo(l);if(!this._arePointsWithinScreenThreshold(l,u,n)||!L(i,n.drawConstraints))return this._resetSnappingState(),t;i.targetPoint=g(u),c.push(...i.hints);for(const h of this._currentOtherActiveCandidates)L(h,n.drawConstraints)&&(h.targetPoint=g(u),c.push(...h.hints));return null!=d&&this.addHandles(d.draw(c,{spatialReference:a,elevationInfo:H(n),view:o,selfSnappingZ:n.selfSnappingZ}),z),_(u,o,t,n)}doneSnapping(){this._removeVisualization(),this._resetSnappingState()}_selectUpdateInput({point:e,scenePoint:t}){switch(this._currentSnappedType){case b.MAIN:return e;case b.SCENE:return t}}_resetSnappingState(){this._currentMainCandidate=null,this._currentOtherActiveCandidates=[],this._currentSnappedType=b.MAIN}_removeVisualization(){this.removeHandles(z)}async _snapSinglePoint({point:e,context:t,signal:n}){const{view:i}=this,{elevationInfo:s}=t,a=f(e,i,s),r=await this._fetchCandidates(a,m.ALL,t,n);return this._createSnapResult(a,b.MAIN,r,i,e,t,n)}async _snapMultiPoint({point:e,scenePoint:t,context:n,signal:i}){const{view:s}=this,{coordinateHelper:a,elevationInfo:r,spatialReference:o}=n;await l(t.spatialReference,o);const p=h(t,o),d=f(p,s,r),c=await this._fetchCandidates(d,m.FEATURE,n,i);if(c.length>0){const e=await this._fetchCandidates(d,m.SELF,n,i);return this._createSnapResult(d,b.SCENE,[...c,...e],s,p,n,i)}const u=f(e,s,r),g=await this._fetchCandidates(u,m.SELF,n,i);return this._createSnapResult(u,b.MAIN,g,s,{z:a.hasZ()&&e.hasZ?e.z??0:void 0,m:a.hasM()&&e.hasM?e.m??0:void 0},n,i)}async _fetchCandidates(e,t,n,i){return(await Promise.all(this._engines.map((s=>s.fetchCandidates(e,t,n,i))))).flat()}_createSnapResult(e,t,n,i,s,r,o){return{get valid(){return!a(o)},apply:()=>{const{spatialReference:a}=r,{snappedPoint:o,hints:p}=this._processCandidates(e,t,n,r);return this._removeVisualization(),null!=r.visualizer&&this.addHandles(r.visualizer.draw(p,{spatialReference:a,elevationInfo:u,view:i,selfSnappingZ:r.selfSnappingZ}),z),_(o,i,s,r)}}}_processCandidates(e,t,n,i){if(n.length<1)return this.doneSnapping(),{snappedPoint:e,hints:[]};this._currentSnappedType!==t&&this._resetSnappingState(),y(e,n);const s=this._currentMainCandidate;if(null!=s){const a=N(s,n);if(a>=0){if(!(n[a]instanceof P))return this._intersectWithOtherCandidates(a,n,e,t,i);if(this._arePointsWithinScreenThreshold(e,s.targetPoint,i))return this._updateSnappingCandidate(s,t,n,i)}}return this._intersectWithOtherCandidates(0,n,e,t,i)}_intersectWithOtherCandidates(e,t,n,i,s){const{coordinateHelper:a}=s,r=t[e],o=[];for(let p=0;p<t.length;++p){if(p===e)continue;const i=t[p],s=r.constraint.intersect(i.constraint);if(s)for(const e of s.closestPoints(r.targetPoint))o.push([new P(g(e),r,i,i.isDraped),this._squaredScreenDistance(n,e,a)])}return o.length>0&&(o.sort(((e,t)=>e[1]-t[1])),o[0][1]<this._squaredPointProximityThreshold(s.pointer))?this._updateSnappingCandidate(o[0][0],i,t,s):L(r,s.drawConstraints)?this._updateSnappingCandidate(r,i,t,s):{snappedPoint:n,hints:[]}}_updateSnappingCandidate(e,t,n,i){this.doneSnapping(),this._currentMainCandidate=e,this._currentSnappedType=t;const s=this._currentMainCandidate.targetPoint,a=[];a.push(...e.hints);for(const r of n){if(e instanceof P){if(r.constraint.equals(e.first.constraint)||r.constraint.equals(e.second.constraint))continue}else if(r.constraint.equals(e.constraint))continue;const t=r.constraint.closestTo(s);this._squaredScreenDistance(t,s,i.coordinateHelper)<U()&&(r.targetPoint=s,this._currentOtherActiveCandidates.push(r),a.push(...r.hints))}return{snappedPoint:s,hints:a}}_squaredPointProximityThreshold(e){return"touch"===e?this._squaredTouchProximityThreshold:this._squaredMouseProximityThreshold}_arePointsWithinScreenThreshold(e,t,n){return this._squaredScreenDistance(e,t,n.coordinateHelper)<this._squaredPointProximityThreshold(n.pointer)}_squaredScreenDistance(e,t,n){return C(this._toScreen(e,n),this._toScreen(t,n))}_toScreen(e,t){return A(e,t.spatialReference,u,this.view)}get test(){}};var b;e([d({constructOnly:!0})],x.prototype,"view",void 0),e([d()],x.prototype,"options",void 0),e([d({readOnly:!0})],x.prototype,"updating",null),e([d()],x.prototype,"_loadTask",void 0),e([d()],x.prototype,"_engines",void 0),e([d()],x.prototype,"_squaredMouseProximityThreshold",null),e([d()],x.prototype,"_squaredTouchProximityThreshold",null),x=e([c("esri.views.interactive.snapping.SnappingManager")],x),function(e){e[e.MAIN=0]="MAIN",e[e.SCENE=1]="SCENE"}(b||(b={}));const z="visualization-handle";function U(){return S.satisfiesConstraintScreenThreshold*S.satisfiesConstraintScreenThreshold}function L(e,t){return!t||null==t.direction&&null==t.distance||!(e instanceof w||e instanceof E||e instanceof T||e instanceof j||e instanceof q)&&(!(e instanceof M)||null==t.direction&&e.selfSnappingType===R.LastVertex)}function N(e,t){return e instanceof P?O(t,e.first)>=0&&O(t,e.second)>=0?0:-1:O(t,e)}function O(e,t){let n=-1;for(let i=0;i<e.length;++i)if(t.constraint.equals(e[i].constraint)){n=i;break}return n}function k(e){return null!=e.scenePoint}function H({coordinateHelper:e,elevationInfo:t}){return e.hasZ()?u:t}export{x as SnappingManager};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{removeUnordered as o}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{memoize as s}from"../../../../core/memoize.js";import{throwIfAborted as i,allSettledValues as n,whenOrAbort as a}from"../../../../core/promiseUtils.js";import{initial as p,watch as l,on as d}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../../../core/support/UpdatingHandles.js";import y from"../../../../geometry/Polygon.js";import{initializeProjection as m,canProjectWithoutEngine as g,project as f}from"../../../../geometry/projection.js";import{normalizeCentralMeridianForDisplay as _}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as v}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as S}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as w}from"../../../../layers/graphics/OptimizedFeature.js";import{executeQueryForSnapping as j}from"../../../../layers/graphics/data/executeQueryForSnapping.js";import b from"../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as E}from"../../../../layers/graphics/data/QueryEngine.js";import k from"../../../../layers/support/FieldsIndex.js";import{elevationContextAffectsAlignment as C}from"../../../../support/elevationInfoUtils.js";import{symbolHasExtrudeSymbolLayer as F}from"../../../../symbols/support/utils.js";import{sortCandidatesInPlace as A,makeSnappingQuery as I}from"../snappingUtils.js";import{convertSnappingCandidate as P,makeGetGroundElevation as G}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as H}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as R}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as x}from"./symbologySnappingCandidates.js";import{TaskPriority as z}from"../../../support/Scheduler.js";const O="graphics-collections";let U=class extends t{get updating(){return this._updatingHandles.updating}get _hasZ(){const e=this.view;return null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,o=null!=e&&"3d"===e.type;if(!o||"map-notes"===t.type)return H();const r=async(o,r)=>(await a(e.whenLayerView(t),r)).elevationAlignPointsInFeatures(o,r);return H(o,{elevationInfo:t.elevationInfo,alignPointsInFeatures:r})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type;return R(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource,o=null!=e&&"3d"===e.type,r=this._extrudedPolygonSymbolsCount>0;return o&&"map-notes"!==t.type&&r?x(r,(async(o,r)=>{const s=await e.whenLayerView(t);return i(r),s.queryForSymbologySnapping({candidates:o,spatialReference:e.spatialReference},r)})):x()}constructor(e){super(e),this.availability=1,this._sources={multipoint:null,point:null,polygon:null,polyline:null},this._loadedWkids=new Set,this._loadedWkts=new Set,this._pendingAdds=[],this._extrudedPolygonSymbolsCount=0,this._updatingHandles=new h,this._memoizedMakeGetGroundElevation=s(G)}destroy(){for(const e of this._pendingAdds)e.task.abort();this._pendingAdds.length=0,this._mapSources((e=>this._destroySource(e))),this._updatingHandles.destroy()}initialize(){this._updatingHandles.add((()=>this.getGraphicsLayers()),(e=>{this._updatingHandles.removeHandles(O);for(const t of e)this._addMany(t.graphics.toArray()),this.addHandles([t.on("graphic-update",(e=>this._onGraphicUpdate(e))),this._updatingHandles.addOnCollectionChange((()=>t.graphics),(e=>this._onGraphicsChanged(e)))],O)}),p);const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"map-notes"!==t.type&&e.elevationProvider&&this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{C(e,t.elevationInfo)&&this._snappingElevationAligner.notifyElevationSourceChange()})),l((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),p),d((()=>t),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))])}async fetchCandidates(e,t){const{point:o,coordinateHelper:{spatialReference:r}}=e,s=await n(this._mapSources((o=>this._fetchCandidatesForSource(o,e,t))));i(t);const a=this._memoizedMakeGetGroundElevation(this.view,r),p=s.flat().map((e=>P(e,a)));return A(o,p),p}async _fetchCandidatesForSource(e,t,o){const r=I({parameters:t,mode:this.view?.type??"2d"}),s=await j(e.queryEngine,r,o);i(o);const n=await this._snappingElevationAligner.alignCandidates(s.candidates,t.coordinateHelper.spatialReference,o);i(o);const a=await this._symbologySnappingFetcher.fetch(n,o);i(o);const p=0===a.length?n:[...n,...a];return this._snappingElevationFilter.filter(r,p)}refresh(){}_onGraphicUpdate(e){if(this.getGraphicsLayers().some((t=>t.graphics.includes(e.graphic))))switch(e.property){case"geometry":case"visible":this._remove(e.graphic),this._addMany([e.graphic])}}_onGraphicsChanged(e){for(const t of e.removed)this._remove(t);this._addMany(e.added)}_addMany(e){const t=[],o=new Map;for(const r of e)null!=r.geometry&&(this._needsInitializeProjection(r.geometry.spatialReference)?(t.push(r.geometry.spatialReference),o.set(r.uid,r)):this._add(r));this._createPendingAdd(t,o)}_createPendingAdd(e,t){if(!e.length)return;const s=r((async o=>{await m(e.map((e=>({source:e,dest:this.spatialReference}))),{signal:o}),this._markLoadedSpatialReferences(e);for(const e of t.values())this._add(e)}));this._updatingHandles.addPromise(s.promise);const i={task:s,graphics:t},n=()=>o(this._pendingAdds,i);s.promise.then(n,n),this._pendingAdds.push(i)}_markLoadedSpatialReferences(e){for(const t of e){null!=t.wkid&&this._loadedWkids.add(t.wkid);const e=t.wkt2||t.wkt;e&&this._loadedWkts.add(e)}}_add(e){if(null==e.geometry||!e.visible)return;let t=e.geometry;if("mesh"===t.type)return;"extent"===t.type&&(t=y.fromExtent(t));const o=this._ensureSource(t.type);if(null==o)return;const r=this._createOptimizedFeature(e.uid,t);null!=r&&(o.featureStore.add(r),F(e.symbol)&&this._extrudedPolygonSymbolsCount++)}_needsInitializeProjection(e){if(null!=e.wkid&&this._loadedWkids.has(e.wkid))return!1;const t=e.wkt2||e.wkt;return(!t||!this._loadedWkts.has(t))&&!g(e,this.spatialReference)}_createOptimizedFeature(e,t){const o=f(_(t),this.spatialReference);if(!o)return null;const r=this._ensureGeometryHasZ(o),s=S(r,this._hasZ,!1);return new w(s,{[Z]:e},null,e)}_ensureGeometryHasZ(e){if(!this._hasZ)return e;const t=e=>{for(;e.length<3;)e.push(0)},o=e.clone();switch(o.hasZ=!0,o.type){case"point":o.z=o.z??0;break;case"multipoint":o.points.forEach(t);break;case"polyline":o.paths.forEach((e=>e.forEach(t)));break;case"polygon":o.rings.forEach((e=>e.forEach(t)))}return o}_ensureSource(e){const t=this._sources[e];if(null!=t)return t;const o=this._createSource(e);return this._sources[e]=o,o}_createSource(e){const t=v.toJSON(e),o=this._hasZ,r=new b({geometryType:t,hasZ:o,hasM:!1});return{featureStore:r,queryEngine:new E({featureStore:r,fieldsIndex:k.fromLayerJSON({fields:[{name:Z,type:"esriFieldTypeOID",alias:Z}]}),geometryType:t,hasM:!1,hasZ:o,featureIdInfo:{type:"object-id",fieldName:Z},spatialReference:this.spatialReference,priority:z.SNAPPING,scheduler:null!=this.view&&"3d"===this.view.type?this.view.resourceController.scheduler:null}),type:e}}_remove(e){this._mapSources((t=>this._removeFromSource(t,e)));for(const t of this._pendingAdds)t.graphics.delete(e.uid),0===t.graphics.size&&t.task.abort()}_removeFromSource(e,t){const o=t.uid;e.featureStore.has(o)&&(e.featureStore.removeById(t.uid),F(t.symbol)&&this._extrudedPolygonSymbolsCount--)}_destroySource(e){e.queryEngine.destroy(),this._sources[e.type]=null}_mapSources(e){const{point:t,polygon:o,polyline:r,multipoint:s}=this._sources,i=[];return null!=t&&i.push(e(t)),null!=o&&i.push(e(o)),null!=r&&i.push(e(r)),null!=s&&i.push(e(s)),i}};e([c()],U.prototype,"getGraphicsLayers",void 0),e([c({constructOnly:!0})],U.prototype,"layerSource",void 0),e([c({constructOnly:!0})],U.prototype,"spatialReference",void 0),e([c({constructOnly:!0})],U.prototype,"view",void 0),e([c({readOnly:!0})],U.prototype,"updating",null),e([c({readOnly:!0})],U.prototype,"availability",void 0),e([c()],U.prototype,"_hasZ",null),e([c()],U.prototype,"_snappingElevationAligner",null),e([c()],U.prototype,"_snappingElevationFilter",null),e([c()],U.prototype,"_symbologySnappingFetcher",null),e([c()],U.prototype,"_extrudedPolygonSymbolsCount",void 0),U=e([u("esri.views.interactive.snapping.featureSources.GraphicsSnappingSource")],U);const Z="OBJECTID";export{U as GraphicsSnappingSource};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{removeUnordered as o}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{memoize as s}from"../../../../core/memoize.js";import{throwIfAborted as i,allSettledValues as n,whenOrAbort as a}from"../../../../core/promiseUtils.js";import{initial as p,watch as l,on as d}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../../../core/support/UpdatingHandles.js";import y from"../../../../geometry/Polygon.js";import{initializeProjection as m,canProjectWithoutEngine as g,project as f}from"../../../../geometry/projectionUtils.js";import{normalizeCentralMeridianForDisplay as _}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as v}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as S}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as w}from"../../../../layers/graphics/OptimizedFeature.js";import{executeQueryForSnapping as j}from"../../../../layers/graphics/data/executeQueryForSnapping.js";import b from"../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as E}from"../../../../layers/graphics/data/QueryEngine.js";import k from"../../../../layers/support/FieldsIndex.js";import{elevationContextAffectsAlignment as C}from"../../../../support/elevationInfoUtils.js";import{symbolHasExtrudeSymbolLayer as F}from"../../../../symbols/support/utils.js";import{sortCandidatesInPlace as A,makeSnappingQuery as I}from"../snappingUtils.js";import{convertSnappingCandidate as P,makeGetGroundElevation as G}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as H}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as R}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as U}from"./symbologySnappingCandidates.js";import{TaskPriority as x}from"../../../support/Scheduler.js";const z="graphics-collections";let O=class extends t{get updating(){return this._updatingHandles.updating}get _hasZ(){const e=this.view;return null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,o=null!=e&&"3d"===e.type;if(!o||"map-notes"===t.type)return H();const r=async(o,r)=>(await a(e.whenLayerView(t),r)).elevationAlignPointsInFeatures(o,r);return H(o,{elevationInfo:t.elevationInfo,alignPointsInFeatures:r})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type;return R(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource,o=null!=e&&"3d"===e.type,r=this._extrudedPolygonSymbolsCount>0;return o&&"map-notes"!==t.type&&r?U(r,(async(o,r)=>{const s=await e.whenLayerView(t);return i(r),s.queryForSymbologySnapping({candidates:o,spatialReference:e.spatialReference},r)})):U()}constructor(e){super(e),this.availability=1,this._sources={multipoint:null,point:null,polygon:null,polyline:null},this._loadedWkids=new Set,this._loadedWkts=new Set,this._pendingAdds=[],this._extrudedPolygonSymbolsCount=0,this._updatingHandles=new h,this._memoizedMakeGetGroundElevation=s(G)}destroy(){for(const e of this._pendingAdds)e.task.abort();this._pendingAdds.length=0,this._mapSources((e=>this._destroySource(e))),this._updatingHandles.destroy()}initialize(){this._updatingHandles.add((()=>this.getGraphicsLayers()),(e=>{this._updatingHandles.removeHandles(z);for(const t of e)this._addMany(t.graphics.toArray()),this.addHandles([t.on("graphic-update",(e=>this._onGraphicUpdate(e))),this._updatingHandles.addOnCollectionChange((()=>t.graphics),(e=>this._onGraphicsChanged(e)))],z)}),p);const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"map-notes"!==t.type&&e.elevationProvider&&this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{C(e,t.elevationInfo)&&this._snappingElevationAligner.notifyElevationSourceChange()})),l((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),p),d((()=>t),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))])}async fetchCandidates(e,t){const{point:o,coordinateHelper:{spatialReference:r}}=e,s=await n(this._mapSources((o=>this._fetchCandidatesForSource(o,e,t))));i(t);const a=this._memoizedMakeGetGroundElevation(this.view,r),p=s.flat().map((e=>P(e,a)));return A(o,p),p}async _fetchCandidatesForSource(e,t,o){const r=I({parameters:t,mode:this.view?.type??"2d"}),s=await j(e.queryEngine,r,o);i(o);const n=await this._snappingElevationAligner.alignCandidates(s.candidates,t.coordinateHelper.spatialReference,o);i(o);const a=await this._symbologySnappingFetcher.fetch(n,o);i(o);const p=0===a.length?n:[...n,...a];return this._snappingElevationFilter.filter(r,p)}refresh(){}_onGraphicUpdate(e){if(this.getGraphicsLayers().some((t=>t.graphics.includes(e.graphic))))switch(e.property){case"geometry":case"visible":this._remove(e.graphic),this._addMany([e.graphic])}}_onGraphicsChanged(e){for(const t of e.removed)this._remove(t);this._addMany(e.added)}_addMany(e){const t=[],o=new Map;for(const r of e)null!=r.geometry&&(this._needsInitializeProjection(r.geometry.spatialReference)?(t.push(r.geometry.spatialReference),o.set(r.uid,r)):this._add(r));this._createPendingAdd(t,o)}_createPendingAdd(e,t){if(!e.length)return;const s=r((async o=>{await m(e.map((e=>({source:e,dest:this.spatialReference}))),{signal:o}),this._markLoadedSpatialReferences(e);for(const e of t.values())this._add(e)}));this._updatingHandles.addPromise(s.promise);const i={task:s,graphics:t},n=()=>o(this._pendingAdds,i);s.promise.then(n,n),this._pendingAdds.push(i)}_markLoadedSpatialReferences(e){for(const t of e){null!=t.wkid&&this._loadedWkids.add(t.wkid);const e=t.wkt2||t.wkt;e&&this._loadedWkts.add(e)}}_add(e){if(null==e.geometry||!e.visible)return;let t=e.geometry;if("mesh"===t.type)return;"extent"===t.type&&(t=y.fromExtent(t));const o=this._ensureSource(t.type);if(null==o)return;const r=this._createOptimizedFeature(e.uid,t);null!=r&&(o.featureStore.add(r),F(e.symbol)&&this._extrudedPolygonSymbolsCount++)}_needsInitializeProjection(e){if(null!=e.wkid&&this._loadedWkids.has(e.wkid))return!1;const t=e.wkt2||e.wkt;return(!t||!this._loadedWkts.has(t))&&!g(e,this.spatialReference)}_createOptimizedFeature(e,t){const o=f(_(t),this.spatialReference);if(!o)return null;const r=this._ensureGeometryHasZ(o),s=S(r,this._hasZ,!1);return new w(s,{[Z]:e},null,e)}_ensureGeometryHasZ(e){if(!this._hasZ)return e;const t=e=>{for(;e.length<3;)e.push(0)},o=e.clone();switch(o.hasZ=!0,o.type){case"point":o.z=o.z??0;break;case"multipoint":o.points.forEach(t);break;case"polyline":o.paths.forEach((e=>e.forEach(t)));break;case"polygon":o.rings.forEach((e=>e.forEach(t)))}return o}_ensureSource(e){const t=this._sources[e];if(null!=t)return t;const o=this._createSource(e);return this._sources[e]=o,o}_createSource(e){const t=v.toJSON(e),o=this._hasZ,r=new b({geometryType:t,hasZ:o,hasM:!1});return{featureStore:r,queryEngine:new E({featureStore:r,fieldsIndex:k.fromLayerJSON({fields:[{name:Z,type:"esriFieldTypeOID",alias:Z}]}),geometryType:t,hasM:!1,hasZ:o,featureIdInfo:{type:"object-id",fieldName:Z},spatialReference:this.spatialReference,priority:x.SNAPPING,scheduler:null!=this.view&&"3d"===this.view.type?this.view.resourceController.scheduler:null}),type:e}}_remove(e){this._mapSources((t=>this._removeFromSource(t,e)));for(const t of this._pendingAdds)t.graphics.delete(e.uid),0===t.graphics.size&&t.task.abort()}_removeFromSource(e,t){const o=t.uid;e.featureStore.has(o)&&(e.featureStore.removeById(t.uid),F(t.symbol)&&this._extrudedPolygonSymbolsCount--)}_destroySource(e){e.queryEngine.destroy(),this._sources[e.type]=null}_mapSources(e){const{point:t,polygon:o,polyline:r,multipoint:s}=this._sources,i=[];return null!=t&&i.push(e(t)),null!=o&&i.push(e(o)),null!=r&&i.push(e(r)),null!=s&&i.push(e(s)),i}};e([c()],O.prototype,"getGraphicsLayers",void 0),e([c({constructOnly:!0})],O.prototype,"layerSource",void 0),e([c({constructOnly:!0})],O.prototype,"spatialReference",void 0),e([c({constructOnly:!0})],O.prototype,"view",void 0),e([c({readOnly:!0})],O.prototype,"updating",null),e([c({readOnly:!0})],O.prototype,"availability",void 0),e([c()],O.prototype,"_hasZ",null),e([c()],O.prototype,"_snappingElevationAligner",null),e([c()],O.prototype,"_snappingElevationFilter",null),e([c()],O.prototype,"_symbologySnappingFetcher",null),e([c()],O.prototype,"_extrudedPolygonSymbolsCount",void 0),O=e([u("esri.views.interactive.snapping.featureSources.GraphicsSnappingSource")],O);const Z="OBJECTID";export{O as GraphicsSnappingSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{isSome as t}from"../../core/arrayUtils.js";import r from"../../core/Logger.js";import{abortMaybe as o}from"../../core/maybe.js";import{unwrapUpdating as i,updating as n,isUpdating as l}from"../../core/maybeUpdating.js";import{throwIfAbortError as s,throwIfNotAbortError as a}from"../../core/promiseUtils.js";import{whenOnce as m}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{project as u,canProjectWithoutEngine as g,isLoaded as y,load as h}from"../../geometry/projection.js";import d from"./LayerView.js";let f=class extends d{constructor(){super(...arguments),this.layer=null,this.filter=null,this._geometryEngine=null,this._projectionEngineLoaded=!1,this._abortController=new AbortController}get availableFields(){return[]}get maximumNumberOfFeatures(){return 0}set maximumNumberOfFeatures(e){throw new Error("Not implemented")}get maximumNumberOfFeaturesExceeded(){return!1}get layerFilter(){return i(this._layerFilter)}get _layerFilter(){const e=this.layer?.filter;if(null==e||e.geometries.length<1)return null;const o=this._geometryEngine;if(null==o||!this._projectionEngineLoaded&&this._filterNeedsProjectionEngine)return n;const i=e.geometries.at(0).spatialReference,l=e.geometries.toArray().map((e=>{try{e=o.simplify(e)}catch(t){return r.getLogger(this).warnOncePerTick("Failed to simplify scene filter mask polygon. Polygon will be ignored."),null}if(null==e)return null;if(e.spatialReference.equals(i))return e;try{return u(e,i)}catch(t){return r.getLogger(this).warnOncePerTick("Failed to project scene filter mask polygon. Polygon will be ignored."),null}})).filter(t).sort(((e,t)=>e.extent.xmin-t.extent.xmin)),s=new Set,a=new Array,m=new Array;for(let t of l){const e=t.extent.xmin;if(a.length=0,s.forEach((r=>{if(e>=r.extent.xmax)return m.push(r),void s.delete(r);t.extent.ymin<=r.extent.ymax&&t.extent.ymax>=r.extent.ymin&&o.intersects(t,r)&&a.push(r)})),a.length>0){a.push(t);try{t=o.union(a)}catch(p){r.getLogger(this).warnOncePerTick("Failed to unify filter mask polygons. Polygon will be ignored.");continue}a.pop(),a.forEach((e=>s.delete(e)))}s.add(t)}return s.forEach((e=>m.push(e))),m.length>0?{spatialRelationship:e.spatialRelationship,geometries:m}:null}get _filterNeedsProjectionEngine(){const e=this.layer.filter;if(null==e||e.geometries.length<=1)return!1;const t=e.geometries.at(0).spatialReference;return e.geometries.some((({spatialReference:e})=>!e.equals(t)&&!g(e,t)))}get layerFilterUpdating(){return l(this._layerFilter)}initialize(){const{signal:e}=this._abortController;m((()=>this.destroyed||!this._geometryEngine&&this.layer?.filter?.geometries?.length),e).then((async()=>{s(e),this._geometryEngine=await import("../../geometry/geometryEngine.js")})).catch(a),this._projectionEngineLoaded=y(),m((()=>this.destroyed||!this._projectionEngineLoaded&&this._filterNeedsProjectionEngine),e).then((async()=>{s(e),await h(),this._projectionEngineLoaded=!0})).catch(a)}destroy(){this._abortController=o(this._abortController)}highlight(e){throw new Error("Not implemented")}queryFeatures(e,t){throw new Error("Not implemented")}queryObjectIds(e,t){throw new Error("Not implemented")}queryFeatureCount(e,t){throw new Error("Not implemented")}createQuery(){throw new Error("Not implemented")}queryExtent(e,t){throw new Error("Not implemented")}};e([p()],f.prototype,"layer",void 0),e([p()],f.prototype,"availableFields",null),e([p()],f.prototype,"maximumNumberOfFeatures",null),e([p({readOnly:!0})],f.prototype,"maximumNumberOfFeaturesExceeded",null),e([p()],f.prototype,"filter",void 0),e([p({readOnly:!0})],f.prototype,"layerFilter",null),e([p({readOnly:!0})],f.prototype,"_layerFilter",null),e([p()],f.prototype,"_geometryEngine",void 0),e([p()],f.prototype,"_projectionEngineLoaded",void 0),e([p()],f.prototype,"_filterNeedsProjectionEngine",null),e([p()],f.prototype,"layerFilterUpdating",null),f=e([c("esri.views.layers.SceneLayerView")],f);export{f as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{isSome as t}from"../../core/arrayUtils.js";import r from"../../core/Logger.js";import{abortMaybe as o}from"../../core/maybe.js";import{unwrapUpdating as i,updating as n,isUpdating as l}from"../../core/maybeUpdating.js";import{throwIfAbortError as s,throwIfNotAbortError as a}from"../../core/promiseUtils.js";import{whenOnce as m}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{project as u,canProjectWithoutEngine as g,isLoaded as y,load as h}from"../../geometry/projectionUtils.js";import d from"./LayerView.js";let f=class extends d{constructor(){super(...arguments),this.layer=null,this.filter=null,this._geometryEngine=null,this._projectionEngineLoaded=!1,this._abortController=new AbortController}get availableFields(){return[]}get maximumNumberOfFeatures(){return 0}set maximumNumberOfFeatures(e){throw new Error("Not implemented")}get maximumNumberOfFeaturesExceeded(){return!1}get layerFilter(){return i(this._layerFilter)}get _layerFilter(){const e=this.layer?.filter;if(null==e||e.geometries.length<1)return null;const o=this._geometryEngine;if(null==o||!this._projectionEngineLoaded&&this._filterNeedsProjectionEngine)return n;const i=e.geometries.at(0).spatialReference,l=e.geometries.toArray().map((e=>{try{e=o.simplify(e)}catch(t){return r.getLogger(this).warnOncePerTick("Failed to simplify scene filter mask polygon. Polygon will be ignored."),null}if(null==e)return null;if(e.spatialReference.equals(i))return e;try{return u(e,i)}catch(t){return r.getLogger(this).warnOncePerTick("Failed to project scene filter mask polygon. Polygon will be ignored."),null}})).filter(t).sort(((e,t)=>e.extent.xmin-t.extent.xmin)),s=new Set,a=new Array,m=new Array;for(let t of l){const e=t.extent.xmin;if(a.length=0,s.forEach((r=>{if(e>=r.extent.xmax)return m.push(r),void s.delete(r);t.extent.ymin<=r.extent.ymax&&t.extent.ymax>=r.extent.ymin&&o.intersects(t,r)&&a.push(r)})),a.length>0){a.push(t);try{t=o.union(a)}catch(p){r.getLogger(this).warnOncePerTick("Failed to unify filter mask polygons. Polygon will be ignored.");continue}a.pop(),a.forEach((e=>s.delete(e)))}s.add(t)}return s.forEach((e=>m.push(e))),m.length>0?{spatialRelationship:e.spatialRelationship,geometries:m}:null}get _filterNeedsProjectionEngine(){const e=this.layer.filter;if(null==e||e.geometries.length<=1)return!1;const t=e.geometries.at(0).spatialReference;return e.geometries.some((({spatialReference:e})=>!e.equals(t)&&!g(e,t)))}get layerFilterUpdating(){return l(this._layerFilter)}initialize(){const{signal:e}=this._abortController;m((()=>this.destroyed||!this._geometryEngine&&this.layer?.filter?.geometries?.length),e).then((async()=>{s(e),this._geometryEngine=await import("../../geometry/geometryEngine.js")})).catch(a),this._projectionEngineLoaded=y(),m((()=>this.destroyed||!this._projectionEngineLoaded&&this._filterNeedsProjectionEngine),e).then((async()=>{s(e),await h(),this._projectionEngineLoaded=!0})).catch(a)}destroy(){this._abortController=o(this._abortController)}highlight(e){throw new Error("Not implemented")}queryFeatures(e,t){throw new Error("Not implemented")}queryObjectIds(e,t){throw new Error("Not implemented")}queryFeatureCount(e,t){throw new Error("Not implemented")}createQuery(){throw new Error("Not implemented")}queryExtent(e,t){throw new Error("Not implemented")}};e([p()],f.prototype,"layer",void 0),e([p()],f.prototype,"availableFields",null),e([p()],f.prototype,"maximumNumberOfFeatures",null),e([p({readOnly:!0})],f.prototype,"maximumNumberOfFeaturesExceeded",null),e([p()],f.prototype,"filter",void 0),e([p({readOnly:!0})],f.prototype,"layerFilter",null),e([p({readOnly:!0})],f.prototype,"_layerFilter",null),e([p()],f.prototype,"_geometryEngine",void 0),e([p()],f.prototype,"_projectionEngineLoaded",void 0),e([p()],f.prototype,"_filterNeedsProjectionEngine",null),e([p()],f.prototype,"layerFilterUpdating",null),f=e([c("esri.views.layers.SceneLayerView")],f);export{f 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{throwIfAborted as t}from"../../core/promiseUtils.js";import{isLoaded as e,canProjectWithoutEngine as r,project as n,load as o,projectWithZConversion as i}from"../../geometry/projection.js";let a,c=null;async function l(e){c||(c=import("../../portal/support/geometryServiceUtils.js").then((t=>a=t))),await c,t(e)}async function s(t,i,c,p){if(!t)return null;const u=t.spatialReference;return e()||r(u,i)?n(t,i):a?a.projectGeometry(t,i,c,p):(await Promise.race([l(p),o(p)]),s(t,i,c,p))}async function p(t,e){try{return t?.spatialReference?await i(t,e):null}catch{return null}}export{s as projectWithEngineOrService,p as projectWithZConversionSilent};
5
+ import{throwIfAborted as t}from"../../core/promiseUtils.js";import{isLoaded as e,canProjectWithoutEngine as r,project as n,load as o,projectWithZConversion as i}from"../../geometry/projectionUtils.js";let a,c=null;async function l(e){c||(c=import("../../portal/support/geometryServiceUtils.js").then((t=>a=t))),await c,t(e)}async function s(t,i,c,p){if(!t)return null;const u=t.spatialReference;return e()||r(u,i)?n(t,i):a?a.projectGeometry(t,i,c,p):(await Promise.race([l(p),o(p)]),s(t,i,c,p))}async function p(t,e){try{return t?.spatialReference?await i(t,e):null}catch{return null}}export{s as projectWithEngineOrService,p as projectWithZConversionSilent};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../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),has("enable-feature:webgl-debug:textureReadWrite"))){const t=this._state.textureUnitMap;for(let e=0;e<t.length;e++){const s=t[e];if(null!=s&&s===this._state.drawFramebuffer?.colorTexture)throw new Error(`Detected readWrite. Texture already bound at index ${e}`)}}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=u.COLOR,i=d.NEAREST,a=0,r=0,n=t.width,l=t.height,h=0,f=0,o=e.width,c=e.height){this.bindFramebufferSeparate(t,_.READ_FRAMEBUFFER,!0),this.bindFramebufferSeparate(e,_.DRAW_FRAMEBUFFER,!0),this.gl.blitFramebuffer(a,r,n,l,h,f,o,c,s,i)}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,s=!1){const i=this.getBoundFramebufferObject();try{t&&this.bindFramebuffer(t,s),e()}finally{this.bindFramebuffer(i,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 has from"../../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),has("enable-feature:webgl-debug:textureReadWrite"))){const t=this._state.textureUnitMap;for(let e=0;e<t.length;e++){const s=t[e];if(null!=s&&s===this._state.drawFramebuffer?.colorTexture)throw new Error(`Detected readWrite. Texture already bound at index ${e}`)}}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=u.COLOR,i=d.NEAREST,a=0,r=0,n=t.width,l=t.height,h=0,f=0,o=e.width,c=e.height){this.bindFramebufferSeparate(t,_.READ_FRAMEBUFFER,!0),this.bindFramebufferSeparate(e,_.DRAW_FRAMEBUFFER,!0),this.gl.blitFramebuffer(a,r,n,l,h,f,o,c,s,i)}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,s=!1){const i=this.getBoundFramebufferObject();try{this.bindFramebuffer(t,s),e()}finally{this.bindFramebuffer(i,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.34/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{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,PixelFormat as m}from"./enums.js";import{FBOAttachmentType as d}from"./FBOAttachmentType.js";import{estimateMemory as c}from"./TextureDescriptor.js";import{isCompressedData as _,deriveInternalFormat as u,isTexImageSource as g,is3DTarget as T,validateTexture as x,isCompressedFormat as E,getDimensions as M,calcMipmapLevels as A,isSizedPixelFormat as b,isSizedDepthFormat as f,isSizedDepthStencilFormat as w}from"./textureUtils.js";import{ValidatedTextureDescriptor as I}from"./ValidatedTextureDescriptor.js";const R=null,D=()=>e.getLogger("esri/views/webgl/Texture");let S=class e{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(e,i=null,r=null){if(this.type=d.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=I.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 c(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(),!_(t)&&this._descriptor.internalFormat&&this._descriptor.internalFormat in p&&(this._descriptor.internalFormat=void 0),this._setData(t),!_(t)&&this._descriptor.compressionHandle&&this._compressOnWorker(t)}updateData(i,r,s,o,a,n,p=0){n||D().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||D().error("An attempt to update uninitialized texture!");const l=this._descriptor;l.internalFormat=u(l);const{context:h,pixelFormat:m,dataType:d,target:c,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)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:E}=h;p&&(o&&a||D().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),E.pixelStorei(E.UNPACK_SKIP_ROWS,p)),g(n)?E.texSubImage2D(c,i,r,s,o,a,m,d,n):_(n)?E.compressedTexSubImage2D(c,i,r,s,o,a,l.internalFormat,n.levels[i]):E.texSubImage2D(c,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||D().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||D().error("An attempt to update an uninitialized texture!");const h=this._descriptor;h.internalFormat=u(h);const{context:m,pixelFormat:d,dataType:c,isImmutable:g,target:x}=h;if(g&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");T(x)||D().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)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:M}=m;if(_(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,c,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,x(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,x(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,x(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),x(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)),x(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=T(l);if(g(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=u(s),s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(l,s.internalFormat,s.hasMipmap,e,r,n),_(i)){if(!E(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=u(r);const s=T(e),{width:a,height:n,depth:p}=M(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=A(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(!b(i)&&!f(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?A(e,s,o,a):1;if(T(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=T(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=T(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{width:i,height:o,context:a,compressionHandle:n,compressionCallback:p,flipped:l,preMultiplyAlpha:h,hasMipmap:d}=this._descriptor,{compressedTextureETC:c,compressedTextureS3TC:_}=a.capabilities;if(!e.compressionWorkerHandle?.isCompressible(t,this._descriptor)||!c&&!_)return;this.abortCompression();const u=new AbortController;this._compressionAbortController=u,n.increment();try{let s;t instanceof Uint8Array?s=t.buffer:(s=await createImageBitmap(t,{imageOrientation:l?"flipY":"none"}),r(u));const a={data:s,width:i,height:o,needsFlip:t instanceof Uint8Array&&this.descriptor.flipped,components:this._descriptor.pixelFormat===m.RGBA?4:3,preMultiplyAlpha:h,hasMipmap:d,hasETC:!!c,hasS3TC:!!_},n=await e.compressionWorkerHandle.invoke(a,u.signal);if(r(u),n.compressedTexture&&this.hasWebGLTextureObject){const t=this.usedMemory;this._descriptor.internalFormat=n.internalFormat,this._setData(n.compressedTexture),p?.(t-this.usedMemory)}}catch(g){s(g)||D().error("Texture compression failed!")}finally{n.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{S as Texture,R 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,PixelFormat as m}from"./enums.js";import{FBOAttachmentType as d}from"./FBOAttachmentType.js";import{estimateMemory as c}from"./TextureDescriptor.js";import{isCompressedData as _,deriveInternalFormat as u,isTexImageSource as g,is3DTarget as T,validateTexture as x,isCompressedFormat as E,getDimensions as M,calcMipmapLevels as A,isSizedPixelFormat as b,isSizedDepthFormat as f,isSizedDepthStencilFormat as w}from"./textureUtils.js";import{ValidatedTextureDescriptor as I}from"./ValidatedTextureDescriptor.js";const R=null,D=()=>e.getLogger("esri/views/webgl/Texture");let S=class e{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(e,i=null,r=null){if(this.type=d.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=I.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 c(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(),!_(t)&&this._descriptor.internalFormat&&this._descriptor.internalFormat in p&&(this._descriptor.internalFormat=void 0),this._setData(t),!_(t)&&this._descriptor.compressionHandle&&this._compressOnWorker(t)}updateData(i,r,s,o,a,n,p=0){n||D().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||D().error("An attempt to update uninitialized texture!");const l=this._descriptor;l.internalFormat=u(l);const{context:h,pixelFormat:m,dataType:d,target:c,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)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:E}=h;p&&(o&&a||D().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),E.pixelStorei(E.UNPACK_SKIP_ROWS,p)),g(n)?E.texSubImage2D(c,i,r,s,o,a,m,d,n):_(n)?E.compressedTexSubImage2D(c,i,r,s,o,a,l.internalFormat,n.levels[i]):E.texSubImage2D(c,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||D().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||D().error("An attempt to update an uninitialized texture!");const h=this._descriptor;h.internalFormat=u(h);const{context:m,pixelFormat:d,dataType:c,isImmutable:g,target:x}=h;if(g&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");T(x)||D().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)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:M}=m;if(_(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,c,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,x(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,x(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,x(this._descriptor),this._wrapModeDirty=!0)}setShadowFiltering(t){t!==this._descriptor.linearFilterDepth&&(this._descriptor.linearFilterDepth=this._descriptor.compareEnabled=t,this.setSamplingMode(t?l.LINEAR:l.NEAREST),x(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)),x(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=T(l);if(g(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=u(s),s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(l,s.internalFormat,s.hasMipmap,e,r,n),_(i)){if(!E(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=u(r);const s=T(e),{width:a,height:n,depth:p}=M(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=A(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(!b(i)&&!f(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?A(e,s,o,a):1;if(T(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=T(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=T(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{width:i,height:o,context:a,compressionHandle:n,compressionCallback:p,flipped:l,preMultiplyAlpha:h,hasMipmap:d}=this._descriptor,{compressedTextureETC:c,compressedTextureS3TC:_}=a.capabilities;if(!e.compressionWorkerHandle?.isCompressible(t,this._descriptor)||!c&&!_)return;this.abortCompression();const u=new AbortController;this._compressionAbortController=u,n.increment();try{let s;t instanceof Uint8Array?s=t.buffer:(s=await createImageBitmap(t,{imageOrientation:l?"flipY":"none"}),r(u));const a={data:s,width:i,height:o,needsFlip:t instanceof Uint8Array&&this.descriptor.flipped,components:this._descriptor.pixelFormat===m.RGBA?4:3,preMultiplyAlpha:h,hasMipmap:d,hasETC:!!c,hasS3TC:!!_},n=await e.compressionWorkerHandle.invoke(a,u.signal);if(r(u),n.compressedTexture&&this.hasWebGLTextureObject){const t=this.usedMemory;this._descriptor.internalFormat=n.internalFormat,this._setData(n.compressedTexture),p?.(t-this.usedMemory)}}catch(g){s(g)||D().error("Texture compression failed!")}finally{n.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{S as Texture,R as tracer};
package/webscene/Slide.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Basemap.js";import i from"../Viewpoint.js";import{result as n}from"../core/asyncUtils.js";import r from"../core/Clonable.js";import s from"../core/Collection.js";import{referenceSetter as o}from"../core/collectionUtils.js";import a from"../core/JSONSupport.js";import l from"../core/Logger.js";import{moduloPositive as p}from"../core/mathUtils.js";import{destroyMaybe as m,removeMaybe as c}from"../core/maybe.js";import{onAbortOrThrow as h,createAbortError as d,isAbortError as u}from"../core/promiseUtils.js";import{whenOnce as y,when as g}from"../core/reactiveUtils.js";import{Milliseconds as b,Seconds as v}from"../core/time.js";import{property as w}from"../core/accessorSupport/decorators/property.js";import{cast as f}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as T}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as j}from"../core/accessorSupport/ensureType.js";import{s as L}from"../chunks/vec32.js";import{create as C}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import _ from"../layers/Layer.js";import{basemapEnsureType as E,clonePreservingTiledLayers as S}from"../support/basemapEnsureType.js";import{TaskPriority as A}from"../views/support/Scheduler.js";import{SlideThumbnail as k}from"../webdoc/support/SlideThumbnail.js";import{timeExtent as V}from"../webdoc/support/timeProperties.js";import U from"./SunLighting.js";import x from"./VirtualLighting.js";import F from"./support/Description.js";import I from"./support/SlideElements.js";import{SlideEnvironment as D}from"./support/SlideEnvironment.js";import R from"./support/SlideGround.js";import{SlideVisibleLayer as M}from"./support/SlideVisibleLayer.js";import O from"./support/Title.js";let P=0;const q=s.ofType(M),B=["caption","cover","none"];let G=class extends(r.ClonableMixin(a)){constructor(e){super(e),this.id=Date.now().toString(16)+"-slide-"+P++,this.title=new O,this.description=new F,this.hidden=!1,this.thumbnail=new k,this.viewpoint=null,this.basemap=null,this.ground=null,this.layout="caption",this.environment=new D,this.timeExtent=null,this.elements=new I,this.visibleLayers=new q,this.enabledFocusAreas=new s}destroy(){this.visibleLayers.removeAll(),this.enabledFocusAreas?.removeAll(),this.basemap=null,this.thumbnail=m(this.thumbnail),this.description=null,this.title=null,this.thumbnail=null,this.elements=null}castTitle(e){return"string"==typeof e?new O({text:e}):j(O,e)}castDescription(e){return"string"==typeof e?new F({text:e}):j(F,e)}castThumbnail(e){return"string"==typeof e?new k({url:e}):j(k,e)}castBasemap(e){return E(e)}set visibleLayers(e){this._set("visibleLayers",o(e,this._get("visibleLayers"),q))}castVisibleLayers(e){return e&&"function"==typeof e.map?e.map((e=>{if("string"==typeof e)return{id:e};if(e instanceof _){const t=H(e);return{id:e.id,sublayerIds:t}}return e.id?{id:e.id,sublayerIds:"sublayerIds"in e?e.sublayerIds:void 0}:(l.getLogger(this).warn('Invalid visible layer, expected { id }, Layer or "id"'),e)})):null}async _updateVisibleLayers(e){const t=[];await Promise.allSettled(this._getLayers(e.map).map((i=>e.whenLayerView(i).then((e=>{if(e.visible){const n=H(i);t.push(new M({id:e.layer.id,sublayerIds:n}))}})))).toArray()),this.visibleLayers.removeAll(),this.visibleLayers.addMany(t)}async updateFrom(e,t){const i={format:"png",quality:80,width:120,height:75,disableDecorations:!0,...t?.screenshot};await e.when(),this.viewpoint=e.viewpoint.clone(),this.environment.lighting="virtual"===e.environment.lighting.type?x.prototype.clone.apply(e.environment.lighting):U.prototype.clone.apply(e.environment.lighting),this.environment.weather=e.environment.weather.clone(),this.enabledFocusAreas=e.focusAreasView?.enabledAreas?new s(e.focusAreasView?.enabledAreas.map((({id:e})=>e))):null,this.basemap=e.map.basemap?.clone()||null,this.ground=e.map.ground?R.fromGround(e.map.ground):null,this.timeExtent=e.timeExtent?.clone()??null,this.elements.analyses.updateFrom(e),await this._updateVisibleLayers(e);const n=await e.takeScreenshot(i);return this.thumbnail=new k({url:n.dataUrl}),this}async applyTo(e,t){null!=this._applyToController&&this._applyToController.abort();let i=new AbortController;this._applyToController=i;const r=h(t,(()=>i?.abort())),s=()=>{this._applyToController===i&&(this._applyToController=null),i=null,r?.remove()};try{await y((()=>e.ready),i.signal)}catch(c){throw s(),c}if(i.signal.aborted)throw s(),d();const o=e.resourceController.scheduler.registerTask(A.SLIDE);let a=!1;const l={animate:!0,...t,signal:this._applyToController.signal},p=async()=>{await Promise.all([o.schedule((async()=>a=await this._setViewpointOfInterest(e,l))),o.schedule((()=>this._applyBasemap(e,l)),l.signal),o.schedule((()=>this._loadLayersWithSublayerVisibility(e)))]),await Promise.all([o.schedule((()=>this._applyLayerVisibility(e)),l.signal),o.schedule((()=>this._applyFocusAreaEnabled(e.map?.focusAreas.areas))),o.schedule((()=>this._applyGround(e)),l.signal),o.schedule((()=>this.elements.analyses.applyTo(e)),l.signal),o.schedule((()=>this._applyViewpoint(e,l)),l.signal),o.schedule((()=>e.timeExtent=this.timeExtent?.clone()??null),l.signal),o.schedule((()=>e.environment.weather=this.environment.weather.clone()))])},m=await n(e.addUpdatingPromise(p()));if(a&&(e.contentCamera=null),o.remove(),s(),!1===m.ok)throw m.error;return this}async _applyBasemap(e,t){if(this.basemap){try{await this.basemap.load(t)}catch(i){if(u(i))throw i}e.map.basemap=S(this.basemap,e.map.basemap)}}_applyGround(e){this.ground&&(e.map.ground=this.ground.cloneAndApplyTo(e.map.ground))}_applyFocusAreaEnabled(e){if(e&&this.enabledFocusAreas)for(const t of e)t.enabled=this.enabledFocusAreas.includes(t.id)}_getLayers(e){const t=new s;return this._collectLayers(e,t),this._collectLayers(e.ground,t),t}_collectLayers(e,t){e.layers.forEach((e=>{e.persistenceEnabled&&(t.add(e),"layers"in e&&this._collectLayers(e,t))}))}async _loadLayersWithSublayerVisibility(e){this.visibleLayers&&await Promise.allSettled(this._getLayers(e.map).items.map((e=>{const t=this.visibleLayers.find((t=>t.id===e.id))?.sublayerIds;return t?e.load():null})))}_applyLayerVisibility(e){if(!this.visibleLayers)return;this._getLayers(e.map).forEach((e=>{const t=this.visibleLayers.find((t=>t.id===e.id));e.visible=null!=t;const i=t?.sublayerIds,n=W(e);i&&n&&n.forEach((e=>e.visible=i.includes(e.id)))}))}async _setViewpointOfInterest(e,t){if(e.state.fixedContentCamera||!this.viewpoint||t?.ignoreViewpoint||!t?.useDestinationCamera)return!1;const{toCameraAsync:i}=await import("../views/3d/support/viewpointUtils.js"),n=await i(e,this.viewpoint);return e.contentCamera=n,null!=n}async _applyViewpoint(e,t){if(this._applyCachedCameraTrackingEnabled(e),this.viewpoint&&!t.ignoreViewpoint){const i=this.environment.lighting;if(t.animate&&"sun"===i.type&&i.date)return this._animateToLighting(e,t);t.animate&&(e.environment.applyLighting(i.clone()),await e.goTo(this.viewpoint,t)),e.viewpoint=this.viewpoint}e.environment.applyLighting(this.environment.lighting.clone())}async _animateToLighting(e,t){let i=null;"virtual"!==e.environment.lighting.type&&"virtual"!==this.environment.lighting.type&&("global"===e.viewingMode&&(i=this._animateLightingWithCamera(e,e.environment.lighting,this.environment.lighting)),e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1),e.environment.lighting.directShadowsEnabled=this.environment.lighting.directShadowsEnabled,"virtual"===this.environment.lighting.type||"virtual"===e.environment.lighting.type?(e.environment.applyLighting(this.environment.lighting.clone()),"virtual"!==e.environment.lighting.type&&(e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1)):null!=this.environment.lighting.displayUTCOffset&&(e.environment.lighting.displayUTCOffset=this.environment.lighting.displayUTCOffset);return e.goTo(this.viewpoint,t).then((()=>{this._applyCachedCameraTrackingEnabled(e),e.environment.applyLighting(this.environment.lighting.clone())})).catch((t=>{throw null==e.animation&&this._applyCachedCameraTrackingEnabled(e),t})).finally((()=>{c(i)}))}_applyCachedCameraTrackingEnabled(e){null!=e.environment.cachedCameraTrackingEnabled&&(e.environment.lighting.cameraTrackingEnabled=e.environment.cachedCameraTrackingEnabled,e.environment.cachedCameraTrackingEnabled=null)}_getTime(e){return[b(e.getTime()),v(3600*e.getUTCHours()+60*e.getUTCMinutes()+e.getUTCSeconds())]}_setTime(e,t,i){return e.setTime(t),e.setUTCHours(i/3600),e.setUTCMinutes(i%3600/60),e.setUTCSeconds(i%3600%60),e}_animateLightingWithCamera(e,t,i){const n=new Date(t.date.toString()),[r,s]=this._getTime(n),[o,a]=this._getTime(i.date),l=K(s,a),p=e.renderCoordsHelper,m=C();p.toRenderCoords(e.camera.position,m);const c=C(),h=C();null!=this.viewpoint.camera&&p.toRenderCoords(this.viewpoint.camera.position,c);const d=new Date;return g((()=>e.camera),(e=>{p.toRenderCoords(e.position,h);const i=L(m,h),n=L(c,h);let a=0;i+n!==0&&(a=i/(i+n));const u=r+(o-r)*a,y=Q(s,v(l*a));t.date=this._setTime(d,u,y)}))}write(e,t){const i=super.write(e,t);return i?.elements&&0===Object.keys(i.elements).length&&delete i.elements,i}static createFrom(e,t){return(new this).updateFrom(e,t)}};e([w({type:String,json:{write:{isRequired:!0}}})],G.prototype,"id",void 0),e([w({type:O,json:{default:()=>new O({text:""}),write:{isRequired:!0}}})],G.prototype,"title",void 0),e([f("title")],G.prototype,"castTitle",null),e([w({type:F,json:{write:{overridePolicy:e=>({enabled:!(!e||!e.text)})}}})],G.prototype,"description",void 0),e([f("description")],G.prototype,"castDescription",null),e([w({type:Boolean,nonNullable:!0,json:{write:!0,default:!1}})],G.prototype,"hidden",void 0),e([w({type:k,json:{default:()=>new k({url:""}),write:{isRequired:!0}}})],G.prototype,"thumbnail",void 0),e([f("thumbnail")],G.prototype,"castThumbnail",null),e([w({type:i,nonNullable:!0,json:{write:{isRequired:!0}}})],G.prototype,"viewpoint",void 0),e([w({type:t,json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],G.prototype,"basemap",void 0),e([f("basemap")],G.prototype,"castBasemap",null),e([w({type:R,json:{write:!0}})],G.prototype,"ground",void 0),e([w({type:B,json:{write:!0,default:"caption"},nonNullable:!0})],G.prototype,"layout",void 0),e([w({type:q,json:{write:{isRequired:!0}}})],G.prototype,"visibleLayers",null),e([f("visibleLayers")],G.prototype,"castVisibleLayers",null),e([w({type:D,json:{write:!0}})],G.prototype,"environment",void 0),e([w({type:s,json:{write:!1}})],G.prototype,"enabledFocusAreas",void 0),e([w(V)],G.prototype,"timeExtent",void 0),e([w({type:I,nonNullable:!0,json:{write:!0}})],G.prototype,"elements",void 0),G=e([T("esri.webscene.Slide")],G);const N=G;function W(e){if("building-scene"===e.type||"map-image"===e.type)return e.allSublayers.toArray()}function H(e){const t=W(e);if(t)return t.filter((e=>e.visible)).map((e=>e.id))}const J=v(86400),z=v(43200);function K(e,t){let i=t-e;return i>z&&(i-=J),i<-z&&(i+=J),v(i)}function Q(e,t){return v(p(e+t,J))}export{N as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Basemap.js";import i from"../Viewpoint.js";import{result as n}from"../core/asyncUtils.js";import r from"../core/Clonable.js";import s from"../core/Collection.js";import{referenceSetter as o}from"../core/collectionUtils.js";import a from"../core/JSONSupport.js";import l from"../core/Logger.js";import{moduloPositive as p}from"../core/mathUtils.js";import{destroyMaybe as m,removeMaybe as c}from"../core/maybe.js";import{onAbortOrThrow as h,createAbortError as d,isAbortError as u}from"../core/promiseUtils.js";import{whenOnce as y,when as g}from"../core/reactiveUtils.js";import{Milliseconds as b,Seconds as v}from"../core/time.js";import{property as w}from"../core/accessorSupport/decorators/property.js";import{cast as f}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as T}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as j}from"../core/accessorSupport/ensureType.js";import{s as L}from"../chunks/vec32.js";import{create as C}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import _ from"../layers/Layer.js";import{basemapEnsureType as E,clonePreservingTiledLayers as S}from"../support/basemapEnsureType.js";import{TaskPriority as A}from"../views/support/Scheduler.js";import{SlideThumbnail as k}from"../webdoc/support/SlideThumbnail.js";import{timeExtent as V}from"../webdoc/support/timeProperties.js";import U from"./SunLighting.js";import x from"./VirtualLighting.js";import F from"./support/Description.js";import I from"./support/SlideElements.js";import{SlideEnvironment as D}from"./support/SlideEnvironment.js";import R from"./support/SlideGround.js";import{SlideVisibleLayer as M}from"./support/SlideVisibleLayer.js";import O from"./support/Title.js";let P=0;const q=s.ofType(M),B=["caption","cover","none"];let G=class extends(r.ClonableMixin(a)){constructor(e){super(e),this.id=Date.now().toString(16)+"-slide-"+P++,this.title=new O,this.description=new F,this.hidden=!1,this.thumbnail=new k,this.viewpoint=null,this.basemap=null,this.ground=null,this.layout="caption",this.environment=new D,this.timeExtent=null,this.elements=new I,this.visibleLayers=new q,this.enabledFocusAreas=new s}destroy(){this.visibleLayers.removeAll(),this.enabledFocusAreas?.removeAll(),this.basemap=null,this.thumbnail=m(this.thumbnail),this.description=null,this.title=null,this.thumbnail=null,this.elements=null}castTitle(e){return"string"==typeof e?new O({text:e}):j(O,e)}castDescription(e){return"string"==typeof e?new F({text:e}):j(F,e)}castThumbnail(e){return"string"==typeof e?new k({url:e}):j(k,e)}castBasemap(e){return E(e)}set visibleLayers(e){this._set("visibleLayers",o(e,this._get("visibleLayers"),q))}castVisibleLayers(e){return e&&"function"==typeof e.map?e.map((e=>{if("string"==typeof e)return{id:e};if(e instanceof _){const t=H(e);return{id:e.id,sublayerIds:t}}return e.id?{id:e.id,sublayerIds:"sublayerIds"in e?e.sublayerIds:void 0}:(l.getLogger(this).warn('Invalid visible layer, expected { id }, Layer or "id"'),e)})):null}async _updateVisibleLayers(e){const t=[];await Promise.allSettled(this._getLayers(e.map).map((i=>e.whenLayerView(i).then((e=>{if(e.visible){const n=H(i);t.push(new M({id:e.layer.id,sublayerIds:n}))}})))).toArray()),this.visibleLayers.removeAll(),this.visibleLayers.addMany(t)}async updateFrom(e,t){const i={format:"png",quality:80,width:120,height:75,disableDecorations:!0,...t?.screenshot};await e.when(),this.viewpoint=e.viewpoint.clone(),this.environment.lighting="virtual"===e.environment.lighting.type?x.prototype.clone.apply(e.environment.lighting):U.prototype.clone.apply(e.environment.lighting),this.environment.weather=e.environment.weather.clone(),this.enabledFocusAreas=e.focusAreasView?.enabledAreas?new s(e.focusAreasView?.enabledAreas.map((({id:e})=>e))):null,this.basemap=e.map.basemap?.clone()||null,this.ground=e.map.ground?R.fromGround(e.map.ground):null,this.timeExtent=e.timeExtent?.clone()??null,this.elements.analyses.updateFrom(e),await this._updateVisibleLayers(e);const n=await e.takeScreenshot(i);return this.thumbnail=new k({url:n.dataUrl}),this}async applyTo(e,t){null!=this._applyToController&&this._applyToController.abort();let i=new AbortController;this._applyToController=i;const r=h(t,(()=>i?.abort())),s=()=>{this._applyToController===i&&(this._applyToController=null),i=null,r?.remove()};try{await y((()=>e.ready),i.signal)}catch(c){throw s(),c}if(i.signal.aborted)throw s(),d();const o=e.resourceController.scheduler.registerTask(A.SLIDE);let a=!1;const l={animate:!0,...t,signal:this._applyToController.signal},p=async()=>{await Promise.all([o.schedule((async()=>a=await this._setViewpointOfInterest(e,l))),o.schedule((()=>this._applyBasemap(e,l)),l.signal),o.schedule((()=>this._loadLayersWithSublayerVisibility(e)))]),await Promise.all([o.schedule((()=>this._applyLayerVisibility(e)),l.signal),o.schedule((()=>this._applyFocusAreaEnabled(e.map?.focusAreas.areas))),o.schedule((()=>this._applyGround(e)),l.signal),o.schedule((()=>this.elements.analyses.applyTo(e)),l.signal),o.schedule((()=>this._applyViewpoint(e,l)),l.signal),o.schedule((()=>e.timeExtent=this.timeExtent?.clone()??null),l.signal),o.schedule((()=>e.environment.weather=this.environment.weather.clone()))])},m=await n(e.addUpdatingPromise(p()));if(a&&(e.contentCamera=null),o.remove(),s(),!1===m.ok)throw m.error;return this}async _applyBasemap(e,t){if(this.basemap){try{await this.basemap.load(t)}catch(i){if(u(i))throw i}e.map.basemap=S(this.basemap,e.map.basemap)}}_applyGround(e){this.ground&&(e.map.ground=this.ground.cloneAndApplyTo(e.map.ground))}_applyFocusAreaEnabled(e){if(e&&this.enabledFocusAreas)for(const t of e)t.enabled=this.enabledFocusAreas.includes(t.id)}_getLayers(e){const t=new s;return this._collectLayers(e,t),this._collectLayers(e.ground,t),t}_collectLayers(e,t){e.layers.forEach((e=>{e.persistenceEnabled&&(t.add(e),"layers"in e&&this._collectLayers(e,t))}))}async _loadLayersWithSublayerVisibility(e){this.visibleLayers&&await Promise.allSettled(this._getLayers(e.map).items.map((e=>{const t=this.visibleLayers.find((t=>t.id===e.id))?.sublayerIds;return t?e.load():null})))}_applyLayerVisibility(e){if(!this.visibleLayers)return;this._getLayers(e.map).forEach((e=>{const t=this.visibleLayers.find((t=>t.id===e.id));e.visible=null!=t;const i=t?.sublayerIds,n=W(e);i&&n&&n.forEach((e=>e.visible=i.includes(e.id)))}))}async _setViewpointOfInterest(e,t){if(e.state.fixedContentCamera||!this.viewpoint||t?.ignoreViewpoint||!t?.useDestinationCamera)return!1;const{toCameraAsync:i}=await import("../views/3d/support/viewpointUtils.js"),n=await i(e,this.viewpoint);return e.contentCamera=n,null!=n}async _applyViewpoint(e,t){if(this._applyCachedCameraTrackingEnabled(e),this.viewpoint&&!t.ignoreViewpoint){const i=this.environment.lighting;if(t.animate&&"sun"===i.type&&i.date)return this._animateToLighting(e,t);t.animate&&(e.environment.applyLighting(i.clone()),await e.goTo(this.viewpoint,t)),e.viewpoint=this.viewpoint}e.environment.applyLighting(this.environment.lighting.clone())}async _animateToLighting(e,t){let i=null;"virtual"!==e.environment.lighting.type&&"virtual"!==this.environment.lighting.type&&("global"===e.viewingMode&&(i=this._animateLightingWithCamera(e,e.environment.lighting,this.environment.lighting)),e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1),e.environment.lighting.directShadowsEnabled=this.environment.lighting.directShadowsEnabled,"virtual"===this.environment.lighting.type||"virtual"===e.environment.lighting.type?(e.environment.applyLighting(this.environment.lighting.clone()),"virtual"!==e.environment.lighting.type&&(e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1)):null!=this.environment.lighting.displayUTCOffset&&(e.environment.lighting.displayUTCOffset=this.environment.lighting.displayUTCOffset);return e.goTo(this.viewpoint,t).then((()=>{this._applyCachedCameraTrackingEnabled(e),e.environment.applyLighting(this.environment.lighting.clone())})).catch((t=>{throw null==e.animation&&this._applyCachedCameraTrackingEnabled(e),t})).finally((()=>{c(i)}))}_applyCachedCameraTrackingEnabled(e){null!=e.environment.cachedCameraTrackingEnabled&&(e.environment.lighting.cameraTrackingEnabled=e.environment.cachedCameraTrackingEnabled,e.environment.cachedCameraTrackingEnabled=null)}_getTime(e){return[b(e.getTime()),v(3600*e.getUTCHours()+60*e.getUTCMinutes()+e.getUTCSeconds())]}_setTime(e,t,i){return e.setTime(t),e.setUTCHours(i/3600),e.setUTCMinutes(i%3600/60),e.setUTCSeconds(i%3600%60),e}_animateLightingWithCamera(e,t,i){const n=new Date(t.date.toString()),[r,s]=this._getTime(n),[o,a]=this._getTime(i.date),l=K(s,a),p=e.renderCoordsHelper,m=C();p.toRenderCoords(e.camera.position,m);const c=C(),h=C();null!=this.viewpoint.camera&&p.toRenderCoords(this.viewpoint.camera.position,c);const d=new Date;return g((()=>e.camera),(e=>{p.toRenderCoords(e.position,h);const i=L(m,h),n=L(c,h);let a=0;i+n!==0&&(a=i/(i+n));const u=r+(o-r)*a,y=Q(s,v(l*a));t.date=this._setTime(d,u,y)}))}write(e,t){const i=super.write(e,t);return i?.elements&&0===Object.keys(i.elements).length&&delete i.elements,i}static createFrom(e,t){return(new this).updateFrom(e,t)}};e([w({type:String,json:{write:{isRequired:!0}}})],G.prototype,"id",void 0),e([w({type:O,json:{default:()=>new O({text:""}),write:{isRequired:!0}}})],G.prototype,"title",void 0),e([f("title")],G.prototype,"castTitle",null),e([w({type:F,json:{write:{overridePolicy:e=>({enabled:!(!e||!e.text)})}}})],G.prototype,"description",void 0),e([f("description")],G.prototype,"castDescription",null),e([w({type:Boolean,nonNullable:!0,json:{write:!0,default:!1}})],G.prototype,"hidden",void 0),e([w({type:k,json:{default:()=>new k({url:""}),write:{isRequired:!0}}})],G.prototype,"thumbnail",void 0),e([f("thumbnail")],G.prototype,"castThumbnail",null),e([w({type:i,nonNullable:!0,json:{write:{isRequired:!0}}})],G.prototype,"viewpoint",void 0),e([w({type:t,json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],G.prototype,"basemap",void 0),e([f("basemap")],G.prototype,"castBasemap",null),e([w({type:R,json:{write:!0}})],G.prototype,"ground",void 0),e([w({type:B,json:{write:!0,default:"caption"},nonNullable:!0})],G.prototype,"layout",void 0),e([w({type:q,json:{write:{isRequired:!0}}})],G.prototype,"visibleLayers",null),e([f("visibleLayers")],G.prototype,"castVisibleLayers",null),e([w({type:s.ofType(String),json:{write:!0},clonable:e=>new s(e.items)})],G.prototype,"enabledFocusAreas",void 0),e([w({type:D,json:{write:!0}})],G.prototype,"environment",void 0),e([w(V)],G.prototype,"timeExtent",void 0),e([w({type:I,nonNullable:!0,json:{write:!0}})],G.prototype,"elements",void 0),G=e([T("esri.webscene.Slide")],G);const N=G;function W(e){if("building-scene"===e.type||"map-image"===e.type)return e.allSublayers.toArray()}function H(e){const t=W(e);if(t)return t.filter((e=>e.visible)).map((e=>e.id))}const J=v(86400),z=v(43200);function K(e,t){let i=t-e;return i>z&&(i-=J),i<-z&&(i+=J),v(i)}function Q(e,t){return v(p(e+t,J))}export{N 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Basemap.js";import s from"../../core/Collection.js";import i from"../../core/Loadable.js";import{watch as a,on as r,when as o}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import{cast as n}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{canProjectWithoutEngine as m,isLoaded as l,load as u}from"../../geometry/projection.js";import{equals as d}from"../../geometry/support/spatialReferenceUtils.js";import{isLinkChartView as h}from"../../linkChart/utils.js";import{basemapEnsureType as y}from"../../support/basemapEnsureType.js";import{contentEquals as f}from"../../support/basemapUtils.js";import{default3DCompatibility as v,default2DCompatibility as b}from"./support/basemapCompatibilityUtils.js";import j from"./support/BasemapGalleryItem.js";import w from"./support/LocalBasemapsSource.js";import B from"./support/PortalBasemapsSource.js";const g=s.ofType(j);function _(e){return e&&"esri.portal.Portal"===e.declaredClass}function I(e){return e&&!(e instanceof B)&&(!!e.portal||!!e.query)}function R(e){return e&&"basemaps"in e&&"state"in e&&"refresh"in e}let E=class extends i{constructor(e){super(e),this._loadingProjectionEngine=!1,this.items=new g,this.source=new B,this.view=null}initialize(){const e=()=>this._recreateItems();this.addHandles([a((()=>"ready"===this.state?this.compatibilityFunction:null),(()=>this._updateItems())),r((()=>this.source?.basemaps),"change",e,{onListenerAdd:e}),o((()=>this.view),(()=>{this.source instanceof B&&(this.source.viewType=this.view?.type)}),{once:!0})])}destroy(){const e=this.source.basemaps.find((e=>e===this.activeBasemap));e&&this.source.basemaps.remove(e),this.source?.destroy()}get activeBasemap(){return this.view?.map?.basemap??null}set activeBasemap(e){const t=this.view;if(!t?.map)return;if(!e||!t.ready)return t.map.basemap=e,void this._clearOverride("activeBasemap");const s=e.spatialReference||this.items?.find((t=>this.basemapEquals(e,t.basemap)))?.spatialReference;if(s&&"spatialReferenceLocked"in t&&!t.spatialReferenceLocked){const i=t.spatialReference;if(null!=s&&!d(i,s)&&!m(t.spatialReference,s)&&!l())return this._override("activeBasemap",e),this._loadingProjectionEngine=!0,void u().then((()=>{this._get("activeBasemap")===e&&(t.map.basemap=e,t.spatialReference=s,this._clearOverride("activeBasemap"))}),(()=>{})).then((()=>{this._loadingProjectionEngine=!1}));t.map.basemap=e,this._clearOverride("activeBasemap"),null==s||d(t.spatialReference,s)||(t.spatialReference=s)}else t.map.basemap=e,this._clearOverride("activeBasemap")}castActiveBasemap(e){return y(e)}get activeBasemapIndex(){const{state:e,activeBasemap:t}=this;return"ready"!==e?-1:this._findBasemapIndex(t)}get compatibilityFunction(){return"3d"===this.view?.type?v:b}set compatibilityFunction(e){this._overrideIfSome("compatibilityFunction",e)}castSource(e){return Array.isArray(e)||s.isCollection(e)?new w({basemaps:Array.isArray(e)?new s(e):e}):_(e)?new B({portal:e}):I(e)?new B(e):R(e)?e:null}get state(){return this.view?.ready&&this.source?h(this.view)&&!this.view.inGeographicLayout?"unsupported":this._loadingProjectionEngine?"loading":"ready":"disabled"}basemapEquals(e,t){return f(e,t)}refresh(){this._recreateItems()}load(){return this.loadSource()}loadSource(e){return this.addResolvingPromise(i.isLoadable(this.source)?this.source.load(e):null),Promise.resolve(this)}_findBasemapIndex(e){const{items:t}=this,s=t.findIndex((t=>t.basemap===e));return-1===s?t.findIndex((t=>this.basemapEquals(t.basemap,e))):s}_recreateItems(){const e=this.source?.basemaps??[],{view:t,compatibilityFunction:s}=this,i=new Map(this.items.map((e=>[e.basemap,e]))),a=e.map((e=>{const a=i.get(e);return a?(i.delete(e),a):new j({basemap:e,compatibilityFunction:s,view:t})}));this.items.removeAll(),this.items.addMany(a),i.forEach((e=>e.destroy()))}_updateItems(){for(const e of this.items)e.compatibilityFunction=this.compatibilityFunction,e.view=this.view}};e([p()],E.prototype,"_loadingProjectionEngine",void 0),e([p({type:t})],E.prototype,"activeBasemap",null),e([n("activeBasemap")],E.prototype,"castActiveBasemap",null),e([p({readOnly:!0})],E.prototype,"activeBasemapIndex",null),e([p()],E.prototype,"compatibilityFunction",null),e([p({readOnly:!0,type:g})],E.prototype,"items",void 0),e([p()],E.prototype,"source",void 0),e([n("source")],E.prototype,"castSource",null),e([p({readOnly:!0})],E.prototype,"state",null),e([p()],E.prototype,"view",void 0),E=e([c("esri.widgets.BasemapGallery.BasemapGalleryViewModel")],E);const S=E;export{S as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Basemap.js";import s from"../../core/Collection.js";import i from"../../core/Loadable.js";import{watch as a,on as r,when as o}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import{cast as n}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{canProjectWithoutEngine as m,isLoaded as l,load as u}from"../../geometry/projectionUtils.js";import{equals as d}from"../../geometry/support/spatialReferenceUtils.js";import{isLinkChartView as h}from"../../linkChart/utils.js";import{basemapEnsureType as y}from"../../support/basemapEnsureType.js";import{contentEquals as f}from"../../support/basemapUtils.js";import{default3DCompatibility as v,default2DCompatibility as b}from"./support/basemapCompatibilityUtils.js";import j from"./support/BasemapGalleryItem.js";import w from"./support/LocalBasemapsSource.js";import B from"./support/PortalBasemapsSource.js";const g=s.ofType(j);function _(e){return e&&"esri.portal.Portal"===e.declaredClass}function I(e){return e&&!(e instanceof B)&&(!!e.portal||!!e.query)}function R(e){return e&&"basemaps"in e&&"state"in e&&"refresh"in e}let E=class extends i{constructor(e){super(e),this._loadingProjectionEngine=!1,this.items=new g,this.source=new B,this.view=null}initialize(){const e=()=>this._recreateItems();this.addHandles([a((()=>"ready"===this.state?this.compatibilityFunction:null),(()=>this._updateItems())),r((()=>this.source?.basemaps),"change",e,{onListenerAdd:e}),o((()=>this.view),(()=>{this.source instanceof B&&(this.source.viewType=this.view?.type)}),{once:!0})])}destroy(){const e=this.source.basemaps.find((e=>e===this.activeBasemap));e&&this.source.basemaps.remove(e),this.source?.destroy()}get activeBasemap(){return this.view?.map?.basemap??null}set activeBasemap(e){const t=this.view;if(!t?.map)return;if(!e||!t.ready)return t.map.basemap=e,void this._clearOverride("activeBasemap");const s=e.spatialReference||this.items?.find((t=>this.basemapEquals(e,t.basemap)))?.spatialReference;if(s&&"spatialReferenceLocked"in t&&!t.spatialReferenceLocked){const i=t.spatialReference;if(null!=s&&!d(i,s)&&!m(t.spatialReference,s)&&!l())return this._override("activeBasemap",e),this._loadingProjectionEngine=!0,void u().then((()=>{this._get("activeBasemap")===e&&(t.map.basemap=e,t.spatialReference=s,this._clearOverride("activeBasemap"))}),(()=>{})).then((()=>{this._loadingProjectionEngine=!1}));t.map.basemap=e,this._clearOverride("activeBasemap"),null==s||d(t.spatialReference,s)||(t.spatialReference=s)}else t.map.basemap=e,this._clearOverride("activeBasemap")}castActiveBasemap(e){return y(e)}get activeBasemapIndex(){const{state:e,activeBasemap:t}=this;return"ready"!==e?-1:this._findBasemapIndex(t)}get compatibilityFunction(){return"3d"===this.view?.type?v:b}set compatibilityFunction(e){this._overrideIfSome("compatibilityFunction",e)}castSource(e){return Array.isArray(e)||s.isCollection(e)?new w({basemaps:Array.isArray(e)?new s(e):e}):_(e)?new B({portal:e}):I(e)?new B(e):R(e)?e:null}get state(){return this.view?.ready&&this.source?h(this.view)&&!this.view.inGeographicLayout?"unsupported":this._loadingProjectionEngine?"loading":"ready":"disabled"}basemapEquals(e,t){return f(e,t)}refresh(){this._recreateItems()}load(){return this.loadSource()}loadSource(e){return this.addResolvingPromise(i.isLoadable(this.source)?this.source.load(e):null),Promise.resolve(this)}_findBasemapIndex(e){const{items:t}=this,s=t.findIndex((t=>t.basemap===e));return-1===s?t.findIndex((t=>this.basemapEquals(t.basemap,e))):s}_recreateItems(){const e=this.source?.basemaps??[],{view:t,compatibilityFunction:s}=this,i=new Map(this.items.map((e=>[e.basemap,e]))),a=e.map((e=>{const a=i.get(e);return a?(i.delete(e),a):new j({basemap:e,compatibilityFunction:s,view:t})}));this.items.removeAll(),this.items.addMany(a),i.forEach((e=>e.destroy()))}_updateItems(){for(const e of this.items)e.compatibilityFunction=this.compatibilityFunction,e.view=this.view}};e([p()],E.prototype,"_loadingProjectionEngine",void 0),e([p({type:t})],E.prototype,"activeBasemap",null),e([n("activeBasemap")],E.prototype,"castActiveBasemap",null),e([p({readOnly:!0})],E.prototype,"activeBasemapIndex",null),e([p()],E.prototype,"compatibilityFunction",null),e([p({readOnly:!0,type:g})],E.prototype,"items",void 0),e([p()],E.prototype,"source",void 0),e([n("source")],E.prototype,"castSource",null),e([p({readOnly:!0})],E.prototype,"state",null),e([p()],E.prototype,"view",void 0),E=e([c("esri.widgets.BasemapGallery.BasemapGalleryViewModel")],E);const S=E;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.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import a from"../../core/Accessor.js";import{watch as t,initial as s,whenOnce as i}from"../../core/reactiveUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import{cast as p}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{isLoaded as n,canProjectWithoutEngine as c,load as l}from"../../geometry/projection.js";import{equals as m}from"../../geometry/support/spatialReferenceUtils.js";import{basemapEnsureType as h,destroyCache as f}from"../../support/basemapEnsureType.js";import{findSpatialReference as d,getBasemapThumbnailUrl as u}from"../../support/basemapUtils.js";let g=class extends a{constructor(e){super(e),this._basemapCache={},this._loadingProjectionEngine=!1,this.nextBasemap=h("hybrid",this._basemapCache),this.view=null}initialize(){t((()=>this.nextBasemap),(e=>{e&&!e.loaded&&e.load().catch((()=>{}))}),s)}destroy(){this.view=null,f(this._basemapCache),this._basemapCache=null}get _nextBasemapSpatialReferenceTask(){return d(this.view,this.nextBasemap)}get _viewSpatialReferenceLocked(){const{view:e}=this;return!e||!("spatialReferenceLocked"in e)||e.spatialReferenceLocked}get activeBasemap(){return h(this.view?.map?.basemap??"topo-vector",this._basemapCache)}castNextBasemap(e){return h(e,this._basemapCache)}get state(){const{view:e}=this;if(!e?.ready)return"disabled";if(this._nextBasemapSpatialReferenceTask.updating)return"disabled";const{spatialReference:a}=this._nextBasemapSpatialReferenceTask;return this._viewSpatialReferenceLocked&&null!=a&&!e.spatialReference.equals(a)?"incompatible-next-basemap":this._loadingProjectionEngine?"loading":"ready"}async toggle(){const{activeBasemap:e,nextBasemap:a,state:t,view:s}=this;if(!s||"disabled"===t||"incompatible-next-basemap"===t)return;const r=this._viewSpatialReferenceLocked;if(!r){if(await i((()=>!this._nextBasemapSpatialReferenceTask.updating)),a!==this.nextBasemap||e!==this.activeBasemap)return;const{spatialReference:t}=this._nextBasemapSpatialReferenceTask;if(null==t||m(s.spatialReference,t)||n()||c(s.spatialReference,t)||(this._loadingProjectionEngine=!0,await l(),this._loadingProjectionEngine=!1),a!==this.nextBasemap||e!==this.activeBasemap)return}s.map.basemap=a,r||null==this._nextBasemapSpatialReferenceTask.spatialReference||m(s.spatialReference,this._nextBasemapSpatialReferenceTask.spatialReference)||(s.spatialReference=this._nextBasemapSpatialReferenceTask.spatialReference),this.nextBasemap=e}static getThumbnailUrl(e){return u(e)}};e([r()],g.prototype,"_loadingProjectionEngine",void 0),e([r({readOnly:!0})],g.prototype,"_nextBasemapSpatialReferenceTask",null),e([r({readOnly:!0})],g.prototype,"_viewSpatialReferenceLocked",null),e([r({readOnly:!0})],g.prototype,"activeBasemap",null),e([r()],g.prototype,"nextBasemap",void 0),e([p("nextBasemap")],g.prototype,"castNextBasemap",null),e([r({readOnly:!0})],g.prototype,"state",null),e([r()],g.prototype,"view",void 0),e([r()],g.prototype,"toggle",null),g=e([o("esri.widgets.BasemapToggle.BasemapToggleViewModel")],g);const B=g;export{B as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import a from"../../core/Accessor.js";import{watch as t,initial as s,whenOnce as i}from"../../core/reactiveUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import{cast as p}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{isLoaded as n,canProjectWithoutEngine as c,load as l}from"../../geometry/projectionUtils.js";import{equals as m}from"../../geometry/support/spatialReferenceUtils.js";import{basemapEnsureType as h,destroyCache as f}from"../../support/basemapEnsureType.js";import{findSpatialReference as d,getBasemapThumbnailUrl as u}from"../../support/basemapUtils.js";let g=class extends a{constructor(e){super(e),this._basemapCache={},this._loadingProjectionEngine=!1,this.nextBasemap=h("hybrid",this._basemapCache),this.view=null}initialize(){t((()=>this.nextBasemap),(e=>{e&&!e.loaded&&e.load().catch((()=>{}))}),s)}destroy(){this.view=null,f(this._basemapCache),this._basemapCache=null}get _nextBasemapSpatialReferenceTask(){return d(this.view,this.nextBasemap)}get _viewSpatialReferenceLocked(){const{view:e}=this;return!e||!("spatialReferenceLocked"in e)||e.spatialReferenceLocked}get activeBasemap(){return h(this.view?.map?.basemap??"topo-vector",this._basemapCache)}castNextBasemap(e){return h(e,this._basemapCache)}get state(){const{view:e}=this;if(!e?.ready)return"disabled";if(this._nextBasemapSpatialReferenceTask.updating)return"disabled";const{spatialReference:a}=this._nextBasemapSpatialReferenceTask;return this._viewSpatialReferenceLocked&&null!=a&&!e.spatialReference.equals(a)?"incompatible-next-basemap":this._loadingProjectionEngine?"loading":"ready"}async toggle(){const{activeBasemap:e,nextBasemap:a,state:t,view:s}=this;if(!s||"disabled"===t||"incompatible-next-basemap"===t)return;const r=this._viewSpatialReferenceLocked;if(!r){if(await i((()=>!this._nextBasemapSpatialReferenceTask.updating)),a!==this.nextBasemap||e!==this.activeBasemap)return;const{spatialReference:t}=this._nextBasemapSpatialReferenceTask;if(null==t||m(s.spatialReference,t)||n()||c(s.spatialReference,t)||(this._loadingProjectionEngine=!0,await l(),this._loadingProjectionEngine=!1),a!==this.nextBasemap||e!==this.activeBasemap)return}s.map.basemap=a,r||null==this._nextBasemapSpatialReferenceTask.spatialReference||m(s.spatialReference,this._nextBasemapSpatialReferenceTask.spatialReference)||(s.spatialReference=this._nextBasemapSpatialReferenceTask.spatialReference),this.nextBasemap=e}static getThumbnailUrl(e){return u(e)}};e([r()],g.prototype,"_loadingProjectionEngine",void 0),e([r({readOnly:!0})],g.prototype,"_nextBasemapSpatialReferenceTask",null),e([r({readOnly:!0})],g.prototype,"_viewSpatialReferenceLocked",null),e([r({readOnly:!0})],g.prototype,"activeBasemap",null),e([r()],g.prototype,"nextBasemap",void 0),e([p("nextBasemap")],g.prototype,"castNextBasemap",null),e([r({readOnly:!0})],g.prototype,"state",null),e([r()],g.prototype,"view",void 0),e([r()],g.prototype,"toggle",null),g=e([o("esri.widgets.BasemapToggle.BasemapToggleViewModel")],g);const B=g;export{B as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{getAssetUrl as e}from"../../assets.js";import o from"../../Graphic.js";import"../../intl.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import r from"../../core/Evented.js";import n from"../../core/Logger.js";import{watch as a,initial as h,when as c}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../geometry/Point.js";import{load as v}from"../../geometry/projection.js";import u from"../../symbols/PictureMarkerSymbol.js";import{pointSymbolTypes as f}from"../../symbols/support/typeUtils.js";import g from"./support/Conversion.js";import{isValidPoint as w,isSupportedNotation as _}from"./support/coordinateConversionUtils.js";import y from"./support/Format.js";import{generateDefaultFormats as C,setDefaultPatterns as b}from"./support/formatUtils.js";import L from"../support/GoTo.js";import{fetchMessageBundle as M}from"../../intl/messages.js";import{onLocaleChange as j,getLocale as P}from"../../intl/locale.js";const S={default:"default",crosshair:"crosshair"},F=new p([0,0,500]),G="xy",H=["mgrs","utm","usng","dd","dms","ddm"],E="esri__coordinateConversionWidgetState",x={conversions:"conversions",formats:"formats",view:"view",viewChange:"view-change"},T="esri/images/search/search-symbol-32.png";let W=class extends(L(r.EventedAccessor)){constructor(t){super(t),this._conversionPromise=null,this._locationGraphic=null,this._pointerCount=0,this.conversions=new i,this.formats=new i,this.formatterAvailable=!1,this.messages=null,this.filteredFormats=new i,this.locationSymbol=new u({url:e(T),width:24,height:24}),this.storageEnabled=!0,this.storageType="session",this.view=null,this._saveWidgetState=this._saveWidgetState.bind(this),this._handleFormatChange=this._handleFormatChange.bind(this),this._handleConversionChange=this._handleConversionChange.bind(this),this._handleViewChange=this._handleViewChange.bind(this),this._onClick=this._onClick.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this)}initialize(){const t=async()=>this.messages=await M("esri/widgets/CoordinateConversion/t9n/CoordinateConversion");this.formats.addMany(C()),t().then((()=>{if(!this.destroyed&&(b(this.messages,this.formats),this.storageEnabled&&this._loadWidgetState(),this.formats.forEach((t=>{t.viewModel=this,this.addHandles(a((()=>t.currentPattern),this._saveWidgetState),t.name??"unnamed-format")})),this.addHandles(this.conversions.on("change",this._handleConversionChange),x.conversions),this.addHandles(this.formats.on("change",this._handleFormatChange),x.formats),this.addHandles(j((()=>{t().then((()=>{b(this.messages,this.formats)}))}))),v().then((()=>{this.formatterAvailable=!0})).catch((t=>{n.getLogger(this).error(new s("coordinate-conversion:projection-load-failed","Failed to load the projection module.",{error:t})),this.formatterAvailable=!1,this._filterFormatsAndConversions()})).then((()=>this.addHandles(a((()=>this.view),this._handleViewChange,h),x.viewChange))),0===this.conversions.length)){const t=this.formats.find((t=>t.name===G))||this.formats.at(0);this.conversions.add(new g({format:t}))}}))}destroy(){this.removeHandles(),this._cleanUpView(this.view),this.view=null}castConversions(t){return this._castToConversions(t)}set currentLocation(t){this._set("currentLocation",t),this._updateConversions()}get currentLocation(){return this._get("currentLocation")||null}set mode(t){switch(t){case"capture":this.currentLocation=null,this._startCaptureMode(),this._set("mode",t);break;case"live":this._startLiveMode(),this._set("mode",t)}}get mode(){return this._get("mode")||"live"}get state(){const{messages:t,view:e}=this,o=e?.ready;return t?o?"ready":e?"loading":"disabled":"disabled"}get storage(){const{storageType:t}=this;return"session"===t?sessionStorage:localStorage}get waitingForConversions(){return null!=this._conversionPromise}setLocation(t){if(this._locationGraphic&&this.view?.graphics.remove(this._locationGraphic),!t)return;const e=t.clone();e.hasZ&&(e.z=void 0),this._locationGraphic=new o({geometry:e,symbol:this.locationSymbol}),this.view?.graphics.add(this._locationGraphic)}async convert(t,e){if(!w(e))throw new s("coordinate-conversion:invalid-point","Invalid point cannot be converted.",{point:e});return Promise.resolve().then((()=>t.convert(e)))}async goToLocation(t){const{view:e}=this;if(!e)throw new s("coordinate-conversion:go-to-failed","no view");const o="3d"===e.type?e.clippingArea:null,i=e.map?.basemap?.baseLayers;if(o||(i?.length??0)>0){const e=o??i?.at(0)?.fullExtent;if(null!=e&&!e.contains(t))throw new s("coordinate-conversion:go-to-failed","Point outside basemap extent.",{point:t})}return this.callGoTo({target:t})}pause(){this.currentLocation=null,this.removeHandles(x.view),this.view&&(this.view.cursor=S.default,this._locationGraphic&&this.view.graphics.remove(this._locationGraphic))}async previewConversion(t,e=this.currentLocation||F){return(await A(t,e)).displayCoordinate}resume(){"capture"===this.mode?this._startCaptureMode():this._startLiveMode()}reverseConvert(t,e){return e.reverseConvert(t)}async updateConversions(t,e){if("point"!==e?.type)throw this._clearConversions(this.conversions),new s("coordinate-conversion:invalid-input-point","Point is invalid, conversions cannot be updated.",{point:e});return this._convertMany(t,e)}_castToConversions(t){const e=new i;return t.forEach((t=>{let o=null;if(t instanceof g)o=t;else if("string"==typeof t){const e=this.formats.find((e=>e.name===t));e&&(o=new g({format:e}))}o&&e.add(o)})),e}_cleanUpView(t){t&&(this._locationGraphic&&t.graphics.remove(this._locationGraphic),this.removeHandles(x.view),t.cursor=S.default)}_clearConversions(t){t.forEach((t=>{t.position={location:null,coordinate:null}}))}async _convertMany(t,e){return Promise.all(t.map((t=>A(t,e))))}_handleConversionChange(t){for(const e of t.added){const{format:t}=e;t&&(t.viewModel=this,this.currentLocation&&(this._set("waitingForConversions",!0),this.convert(t,this.currentLocation).then((t=>{e.position=t,this._set("waitingForConversions",!1)}))))}this._saveWidgetState()}_handleFormatChange(t){t.added.forEach((t=>{this.addHandles(a((()=>t.currentPattern),this._saveWidgetState),t.name??"unnamed-format"),t.viewModel=this})),t.removed.forEach((t=>{t.viewModel=null;const e=this.conversions.filter((e=>e.format===t));this.conversions.removeMany(e),t.name&&this.removeHandles(t.name)}))}_loadWidgetState(){try{const t=JSON.parse(this.storage.getItem(E));t&&this._setWidgetState(t)}catch(t){n.getLogger(this).error(new s("coordinate-conversion:invalid-session-storage-json","Could not read from storage.",{error:t}))}}_startCaptureMode(){this.removeHandles(x.view),this.view&&(this.view.cursor=S.crosshair,this.currentLocation&&this.setLocation(this.currentLocation),this.addHandles(this.view.on("click",this._onClick),x.view))}_startLiveMode(){this._pointerCount=0,this.removeHandles(x.view),this.view&&(this.view.cursor=S.default,this._locationGraphic&&this.view.graphics.remove(this._locationGraphic),this.addHandles([this.view.on("pointer-down",this._onPointerDown),this.view.on("pointer-up",this._onPointerUp),this.view.on("pointer-move",this._onPointerMove)],x.view))}_handleViewChange(t,e){e&&e!==t&&this._cleanUpView(e),t&&("capture"===this.mode?this._startCaptureMode():this._startLiveMode(),e&&this._filterFormatsAndConversions())}_onClick(t){if(0===t.button){const e=this.view?.toMap(t),o=e?.normalize();this.setLocation(o),this.currentLocation=o}}_onPointerDown(t){const{pointerType:e}=t;if(this._pointerCount++,("touch"===e||"pen"===e)&&1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerMove(t){const{pointerType:e}=t;if("mouse"===e||1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerUp(){this._pointerCount--}_setWidgetState(t){try{t.formats.forEach((e=>{const o=this.formats.find((t=>t.name===e.name));o&&t.locale===P()&&e.currentPattern&&(o.currentPattern=e.currentPattern),o&&e.index>=0&&this.conversions.add(new g({format:o}))}))}catch(e){n.getLogger(this).warn(new s("coordinate-conversion:session-storage-read-error","Could not get widget state from stored JSON.",{error:e}))}}_saveWidgetState(){if(!this.storageEnabled)return;const t=this._toJSON();try{this.storage.setItem(E,JSON.stringify({formats:t,locale:P()}))}catch(e){n.getLogger(this).error(new s("coordinate-conversion:local-storage-write-error","Could not write to localStorage.",{error:e}))}}async _updateConversions(){try{await this.updateConversions(this.conversions.toArray(),this.currentLocation)}catch{}}_toJSON(){return this.formats.filter((t=>{const e=t.name;return"xy"===e||"basemap"===e||_(e)})).map((t=>({name:t.name,currentPattern:t.currentPattern,defaultPattern:t.defaultPattern,index:this.conversions.findIndex((e=>e.format===t))}))).sort(((t,e)=>t.index-e.index)).toArray()}_filterFormatsAndConversions(){const{formatterAvailable:t,conversions:e,formats:o}=this;t||this.addHandles(c((()=>this.view?.spatialReference),(t=>{const i=t.isWebMercator||t.isWGS84,s=o.filter((t=>{const{name:e}=t;return!!U(e)||"xy"===e&&!i})),r=this.filteredFormats.filter((t=>"xy"===t.name&&i&&!this.formats.includes(t))),n=e.filter((t=>s.includes(t.format)));o.removeMany(s),e.removeMany(n),this.filteredFormats.addMany(s.filter((t=>!this.filteredFormats.includes(t)))),o.addMany(r)}),{once:!0,initial:!0}),x.view)}};async function A(t,e){try{t.position=await(t.format?.convert(e))}catch(o){t.position=null}return t}function U(t){return H.includes(t)}t([d({type:i.ofType(g)})],W.prototype,"conversions",void 0),t([l("conversions")],W.prototype,"castConversions",null),t([d({type:p})],W.prototype,"currentLocation",null),t([d({type:i.ofType(y)})],W.prototype,"formats",void 0),t([d()],W.prototype,"messages",void 0),t([d()],W.prototype,"mode",null),t([d()],W.prototype,"filteredFormats",void 0),t([d({readOnly:!0})],W.prototype,"state",null),t([d({types:f})],W.prototype,"locationSymbol",void 0),t([d({readOnly:!0,dependsOn:["storageType"]})],W.prototype,"storage",null),t([d()],W.prototype,"storageEnabled",void 0),t([d()],W.prototype,"storageType",void 0),t([d({readOnly:!0})],W.prototype,"waitingForConversions",null),t([d()],W.prototype,"view",void 0),W=t([m("esri.widgets.CoordinateConversion.CoordinateConversionViewModel")],W);const O=W;export{O as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{getAssetUrl as e}from"../../assets.js";import o from"../../Graphic.js";import"../../intl.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import r from"../../core/Evented.js";import n from"../../core/Logger.js";import{watch as a,initial as h,when as c}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../geometry/Point.js";import{load as v}from"../../geometry/projectionUtils.js";import u from"../../symbols/PictureMarkerSymbol.js";import{pointSymbolTypes as f}from"../../symbols/support/typeUtils.js";import g from"./support/Conversion.js";import{isValidPoint as w,isSupportedNotation as _}from"./support/coordinateConversionUtils.js";import y from"./support/Format.js";import{generateDefaultFormats as C,setDefaultPatterns as b}from"./support/formatUtils.js";import L from"../support/GoTo.js";import{fetchMessageBundle as M}from"../../intl/messages.js";import{onLocaleChange as j,getLocale as P}from"../../intl/locale.js";const S={default:"default",crosshair:"crosshair"},F=new p([0,0,500]),G="xy",H=["mgrs","utm","usng","dd","dms","ddm"],E="esri__coordinateConversionWidgetState",x={conversions:"conversions",formats:"formats",view:"view",viewChange:"view-change"},T="esri/images/search/search-symbol-32.png";let W=class extends(L(r.EventedAccessor)){constructor(t){super(t),this._conversionPromise=null,this._locationGraphic=null,this._pointerCount=0,this.conversions=new i,this.formats=new i,this.formatterAvailable=!1,this.messages=null,this.filteredFormats=new i,this.locationSymbol=new u({url:e(T),width:24,height:24}),this.storageEnabled=!0,this.storageType="session",this.view=null,this._saveWidgetState=this._saveWidgetState.bind(this),this._handleFormatChange=this._handleFormatChange.bind(this),this._handleConversionChange=this._handleConversionChange.bind(this),this._handleViewChange=this._handleViewChange.bind(this),this._onClick=this._onClick.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this)}initialize(){const t=async()=>this.messages=await M("esri/widgets/CoordinateConversion/t9n/CoordinateConversion");this.formats.addMany(C()),t().then((()=>{if(!this.destroyed&&(b(this.messages,this.formats),this.storageEnabled&&this._loadWidgetState(),this.formats.forEach((t=>{t.viewModel=this,this.addHandles(a((()=>t.currentPattern),this._saveWidgetState),t.name??"unnamed-format")})),this.addHandles(this.conversions.on("change",this._handleConversionChange),x.conversions),this.addHandles(this.formats.on("change",this._handleFormatChange),x.formats),this.addHandles(j((()=>{t().then((()=>{b(this.messages,this.formats)}))}))),v().then((()=>{this.formatterAvailable=!0})).catch((t=>{n.getLogger(this).error(new s("coordinate-conversion:projection-load-failed","Failed to load the projection module.",{error:t})),this.formatterAvailable=!1,this._filterFormatsAndConversions()})).then((()=>this.addHandles(a((()=>this.view),this._handleViewChange,h),x.viewChange))),0===this.conversions.length)){const t=this.formats.find((t=>t.name===G))||this.formats.at(0);this.conversions.add(new g({format:t}))}}))}destroy(){this.removeHandles(),this._cleanUpView(this.view),this.view=null}castConversions(t){return this._castToConversions(t)}set currentLocation(t){this._set("currentLocation",t),this._updateConversions()}get currentLocation(){return this._get("currentLocation")||null}set mode(t){switch(t){case"capture":this.currentLocation=null,this._startCaptureMode(),this._set("mode",t);break;case"live":this._startLiveMode(),this._set("mode",t)}}get mode(){return this._get("mode")||"live"}get state(){const{messages:t,view:e}=this,o=e?.ready;return t?o?"ready":e?"loading":"disabled":"disabled"}get storage(){const{storageType:t}=this;return"session"===t?sessionStorage:localStorage}get waitingForConversions(){return null!=this._conversionPromise}setLocation(t){if(this._locationGraphic&&this.view?.graphics.remove(this._locationGraphic),!t)return;const e=t.clone();e.hasZ&&(e.z=void 0),this._locationGraphic=new o({geometry:e,symbol:this.locationSymbol}),this.view?.graphics.add(this._locationGraphic)}async convert(t,e){if(!w(e))throw new s("coordinate-conversion:invalid-point","Invalid point cannot be converted.",{point:e});return Promise.resolve().then((()=>t.convert(e)))}async goToLocation(t){const{view:e}=this;if(!e)throw new s("coordinate-conversion:go-to-failed","no view");const o="3d"===e.type?e.clippingArea:null,i=e.map?.basemap?.baseLayers;if(o||(i?.length??0)>0){const e=o??i?.at(0)?.fullExtent;if(null!=e&&!e.contains(t))throw new s("coordinate-conversion:go-to-failed","Point outside basemap extent.",{point:t})}return this.callGoTo({target:t})}pause(){this.currentLocation=null,this.removeHandles(x.view),this.view&&(this.view.cursor=S.default,this._locationGraphic&&this.view.graphics.remove(this._locationGraphic))}async previewConversion(t,e=this.currentLocation||F){return(await U(t,e)).displayCoordinate}resume(){"capture"===this.mode?this._startCaptureMode():this._startLiveMode()}reverseConvert(t,e){return e.reverseConvert(t)}async updateConversions(t,e){if("point"!==e?.type)throw this._clearConversions(this.conversions),new s("coordinate-conversion:invalid-input-point","Point is invalid, conversions cannot be updated.",{point:e});return this._convertMany(t,e)}_castToConversions(t){const e=new i;return t.forEach((t=>{let o=null;if(t instanceof g)o=t;else if("string"==typeof t){const e=this.formats.find((e=>e.name===t));e&&(o=new g({format:e}))}o&&e.add(o)})),e}_cleanUpView(t){t&&(this._locationGraphic&&t.graphics.remove(this._locationGraphic),this.removeHandles(x.view),t.cursor=S.default)}_clearConversions(t){t.forEach((t=>{t.position={location:null,coordinate:null}}))}async _convertMany(t,e){return Promise.all(t.map((t=>U(t,e))))}_handleConversionChange(t){for(const e of t.added){const{format:t}=e;t&&(t.viewModel=this,this.currentLocation&&(this._set("waitingForConversions",!0),this.convert(t,this.currentLocation).then((t=>{e.position=t,this._set("waitingForConversions",!1)}))))}this._saveWidgetState()}_handleFormatChange(t){t.added.forEach((t=>{this.addHandles(a((()=>t.currentPattern),this._saveWidgetState),t.name??"unnamed-format"),t.viewModel=this})),t.removed.forEach((t=>{t.viewModel=null;const e=this.conversions.filter((e=>e.format===t));this.conversions.removeMany(e),t.name&&this.removeHandles(t.name)}))}_loadWidgetState(){try{const t=JSON.parse(this.storage.getItem(E));t&&this._setWidgetState(t)}catch(t){n.getLogger(this).error(new s("coordinate-conversion:invalid-session-storage-json","Could not read from storage.",{error:t}))}}_startCaptureMode(){this.removeHandles(x.view),this.view&&(this.view.cursor=S.crosshair,this.currentLocation&&this.setLocation(this.currentLocation),this.addHandles(this.view.on("click",this._onClick),x.view))}_startLiveMode(){this._pointerCount=0,this.removeHandles(x.view),this.view&&(this.view.cursor=S.default,this._locationGraphic&&this.view.graphics.remove(this._locationGraphic),this.addHandles([this.view.on("pointer-down",this._onPointerDown),this.view.on("pointer-up",this._onPointerUp),this.view.on("pointer-move",this._onPointerMove)],x.view))}_handleViewChange(t,e){e&&e!==t&&this._cleanUpView(e),t&&("capture"===this.mode?this._startCaptureMode():this._startLiveMode(),e&&this._filterFormatsAndConversions())}_onClick(t){if(0===t.button){const e=this.view?.toMap(t),o=e?.normalize();this.setLocation(o),this.currentLocation=o}}_onPointerDown(t){const{pointerType:e}=t;if(this._pointerCount++,("touch"===e||"pen"===e)&&1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerMove(t){const{pointerType:e}=t;if("mouse"===e||1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerUp(){this._pointerCount--}_setWidgetState(t){try{t.formats.forEach((e=>{const o=this.formats.find((t=>t.name===e.name));o&&t.locale===P()&&e.currentPattern&&(o.currentPattern=e.currentPattern),o&&e.index>=0&&this.conversions.add(new g({format:o}))}))}catch(e){n.getLogger(this).warn(new s("coordinate-conversion:session-storage-read-error","Could not get widget state from stored JSON.",{error:e}))}}_saveWidgetState(){if(!this.storageEnabled)return;const t=this._toJSON();try{this.storage.setItem(E,JSON.stringify({formats:t,locale:P()}))}catch(e){n.getLogger(this).error(new s("coordinate-conversion:local-storage-write-error","Could not write to localStorage.",{error:e}))}}async _updateConversions(){try{await this.updateConversions(this.conversions.toArray(),this.currentLocation)}catch{}}_toJSON(){return this.formats.filter((t=>{const e=t.name;return"xy"===e||"basemap"===e||_(e)})).map((t=>({name:t.name,currentPattern:t.currentPattern,defaultPattern:t.defaultPattern,index:this.conversions.findIndex((e=>e.format===t))}))).sort(((t,e)=>t.index-e.index)).toArray()}_filterFormatsAndConversions(){const{formatterAvailable:t,conversions:e,formats:o}=this;t||this.addHandles(c((()=>this.view?.spatialReference),(t=>{const i=t.isWebMercator||t.isWGS84,s=o.filter((t=>{const{name:e}=t;return!!A(e)||"xy"===e&&!i})),r=this.filteredFormats.filter((t=>"xy"===t.name&&i&&!this.formats.includes(t))),n=e.filter((t=>s.includes(t.format)));o.removeMany(s),e.removeMany(n),this.filteredFormats.addMany(s.filter((t=>!this.filteredFormats.includes(t)))),o.addMany(r)}),{once:!0,initial:!0}),x.view)}};async function U(t,e){try{t.position=await(t.format?.convert(e))}catch(o){t.position=null}return t}function A(t){return H.includes(t)}t([d({type:i.ofType(g)})],W.prototype,"conversions",void 0),t([l("conversions")],W.prototype,"castConversions",null),t([d({type:p})],W.prototype,"currentLocation",null),t([d({type:i.ofType(y)})],W.prototype,"formats",void 0),t([d()],W.prototype,"messages",void 0),t([d()],W.prototype,"mode",null),t([d()],W.prototype,"filteredFormats",void 0),t([d({readOnly:!0})],W.prototype,"state",null),t([d({types:f})],W.prototype,"locationSymbol",void 0),t([d({readOnly:!0,dependsOn:["storageType"]})],W.prototype,"storage",null),t([d()],W.prototype,"storageEnabled",void 0),t([d()],W.prototype,"storageType",void 0),t([d({readOnly:!0})],W.prototype,"waitingForConversions",null),t([d()],W.prototype,"view",void 0),W=t([m("esri.widgets.CoordinateConversion.CoordinateConversionViewModel")],W);const O=W;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.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/Error.js";import"../../../core/has.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{fromUsng as i,fromUtm as s,fromMgrs as a,fromLatitudeLongitude as l,toUtm as c,toUsng as p,toMgrs as u,toLatitudeLongitude as m}from"../../../geometry/coordinateFormatter.js";import{isLoaded as h,project as d}from"../../../geometry/projection.js";import f from"../../../geometry/SpatialReference.js";import{equals as v}from"../../../geometry/support/spatialReferenceUtils.js";import{project as g}from"../../../geometry/support/webMercatorUtils.js";import{isValidPoint as y,fromXY as w,pointToCoordinate as b,getDegreePrecision as S}from"./coordinateConversionUtils.js";let _=class extends t{constructor(e){super(e),this.conversionInfo=null,this.coordinateSegments=null,this._currentPattern=void 0,this.defaultPattern=null,this.name=null,this.viewModel=null}get currentPattern(){return(this._currentPattern||this.defaultPattern)??""}set currentPattern(e){this._currentPattern=e}get label(){return this.name??""}set label(e){this._overrideIfSome("label",e)}get hasDisplayProperties(){return!(!this.defaultPattern||!this.coordinateSegments)}get spatialReference(){return"basemap"===this.name?this._viewSpatialReference:this.conversionInfo?.spatialReference??f.WGS84}set spatialReference(e){this._overrideIfSome("spatialReference",e)}get _viewSpatialReference(){return this.viewModel?.view?.spatialReference??f.WGS84}get _additionalCharactersPattern(){const e=this.coordinateSegments;if(!e)return null;const t=e.map((e=>e.alias)),r=this.currentPattern.replaceAll(new RegExp(`["nsew${t.join()}]`,"gi"),"").replaceAll(" ","");return new RegExp(`[${r}]`,"g")}get test(){}async convert(e){if(!y(e))throw new r("format:invalid-point","Could not convert invalid point.",{point:e});const t=this.conversionInfo?.convert;if(t)return Promise.resolve().then((()=>t(e)));const n=await this._project(e,this.spatialReference);return{location:n,coordinate:await this._getCoordinate(n)}}getConversionStrategy(){const e=this._viewSpatialReference;return this.conversionInfo?.convert||this.viewModel?.formatterAvailable||"xy"===this.name&&(e.isWebMercator||e.isWGS84)||"basemap"===this.name?"client":"server"}getDisplayCoordinate(e){if(!e)return null;if(!this.coordinateSegments||!this.currentPattern)return e;let t=this.currentPattern;const r=this._getSegmentMatches(e,!1);for(let n=this.coordinateSegments.length-1;n>=0;n--){const e=this.coordinateSegments[n];t=t.replace(e.alias,r[n])}return t}_parseUserInput(e){const{defaultPattern:t,_additionalCharactersPattern:r,coordinateSegments:n}=this;if(!t||!r)return"";let o=t.replace(r,"");e=e.replace(r,"");const i=this._getSegmentMatches(e,!0);if(n)for(let s=n.length-1;s>=0;s--){const e=n[s];o=o.replace(e.alias,i[s])}return o}_getSegmentMatches(e,t){const r=new Array,{coordinateSegments:n}=this;if(!n)return r;for(let o=0;o<n.length;o++){const i=n[o],s=e.match(i.searchPattern);if(!s){r.push("");continue}let a=s[0];if(e=e.replace(a,"").trim(),i.substitution){const e=t?i.substitution.input(a):i.substitution.output(a);e&&(a=`${e}`)}r.push(a)}return r}async reverseConvert(e){const t=this._parseUserInput(e),n=this.conversionInfo?.reverseConvert;let o;if(n)o=n(t);else if("xy"===this.name||"basemap"===this.name)o=w(t,this.spatialReference);else if(this.viewModel?.formatterAvailable)switch(this.name){case"dd":case"ddm":case"dms":o=l(t,this.spatialReference);break;case"mgrs":{const e="automatic";o=a(t,this.spatialReference,e);break}case"utm":{const e="latitude-band-indicators";o=s(t,this.spatialReference,e);break}case"usng":o=i(t,this.spatialReference);break;default:o=null}if(!o)throw new r("format:invalid-input","Could not parse input into point.",{userInput:e});return this._project(o,this._viewSpatialReference)}async _getCoordinate(e){const t=this.viewModel?.view?.scale??0;if(!y(e))throw new r("format:invalid-point","Could not transform invalid point into coordinate.",{point:e});if(this.viewModel?.formatterAvailable||"basemap"===this.name||"xy"===this.name)switch(this.name){case"dd":case"ddm":case"dms":{const r=S(t);return m(e,this.name,r)}case"mgrs":return u(e,"automatic",5,!1);case"usng":return p(e,5,!1);case"utm":return c(e,"latitude-band-indicators",!0);default:return b(e,t)}return b(e,t)}async _project(e,t){if(v(e.spatialReference,t)||!t)return e;if(this.viewModel?.formatterAvailable&&h())return d(e,t);if(!this.viewModel?.formatterAvailable){const r=g(e,t);if(null!=r)return r}return null}};e([n()],_.prototype,"conversionInfo",void 0),e([n()],_.prototype,"coordinateSegments",void 0),e([n()],_.prototype,"currentPattern",null),e([n()],_.prototype,"_currentPattern",void 0),e([n()],_.prototype,"label",null),e([n()],_.prototype,"defaultPattern",void 0),e([n({readOnly:!0})],_.prototype,"hasDisplayProperties",null),e([n()],_.prototype,"name",void 0),e([n({type:f})],_.prototype,"spatialReference",null),e([n()],_.prototype,"viewModel",void 0),e([n({readOnly:!0})],_.prototype,"_viewSpatialReference",null),e([n({readOnly:!0})],_.prototype,"_additionalCharactersPattern",null),_=e([o("esri.widgets.CoordinateConversion.support.Format")],_);const R=_;export{R as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/Error.js";import"../../../core/has.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{fromUsng as i,fromUtm as s,fromMgrs as a,fromLatitudeLongitude as l,toUtm as c,toUsng as p,toMgrs as u,toLatitudeLongitude as m}from"../../../geometry/coordinateFormatter.js";import{isLoaded as h,project as d}from"../../../geometry/projectionUtils.js";import f from"../../../geometry/SpatialReference.js";import{equals as v}from"../../../geometry/support/spatialReferenceUtils.js";import{project as g}from"../../../geometry/support/webMercatorUtils.js";import{isValidPoint as y,fromXY as w,pointToCoordinate as b,getDegreePrecision as S}from"./coordinateConversionUtils.js";let _=class extends t{constructor(e){super(e),this.conversionInfo=null,this.coordinateSegments=null,this._currentPattern=void 0,this.defaultPattern=null,this.name=null,this.viewModel=null}get currentPattern(){return(this._currentPattern||this.defaultPattern)??""}set currentPattern(e){this._currentPattern=e}get label(){return this.name??""}set label(e){this._overrideIfSome("label",e)}get hasDisplayProperties(){return!(!this.defaultPattern||!this.coordinateSegments)}get spatialReference(){return"basemap"===this.name?this._viewSpatialReference:this.conversionInfo?.spatialReference??f.WGS84}set spatialReference(e){this._overrideIfSome("spatialReference",e)}get _viewSpatialReference(){return this.viewModel?.view?.spatialReference??f.WGS84}get _additionalCharactersPattern(){const e=this.coordinateSegments;if(!e)return null;const t=e.map((e=>e.alias)),r=this.currentPattern.replaceAll(new RegExp(`["nsew${t.join()}]`,"gi"),"").replaceAll(" ","");return new RegExp(`[${r}]`,"g")}get test(){}async convert(e){if(!y(e))throw new r("format:invalid-point","Could not convert invalid point.",{point:e});const t=this.conversionInfo?.convert;if(t)return Promise.resolve().then((()=>t(e)));const n=await this._project(e,this.spatialReference);return{location:n,coordinate:await this._getCoordinate(n)}}getConversionStrategy(){const e=this._viewSpatialReference;return this.conversionInfo?.convert||this.viewModel?.formatterAvailable||"xy"===this.name&&(e.isWebMercator||e.isWGS84)||"basemap"===this.name?"client":"server"}getDisplayCoordinate(e){if(!e)return null;if(!this.coordinateSegments||!this.currentPattern)return e;let t=this.currentPattern;const r=this._getSegmentMatches(e,!1);for(let n=this.coordinateSegments.length-1;n>=0;n--){const e=this.coordinateSegments[n];t=t.replace(e.alias,r[n])}return t}_parseUserInput(e){const{defaultPattern:t,_additionalCharactersPattern:r,coordinateSegments:n}=this;if(!t||!r)return"";let o=t.replace(r,"");e=e.replace(r,"");const i=this._getSegmentMatches(e,!0);if(n)for(let s=n.length-1;s>=0;s--){const e=n[s];o=o.replace(e.alias,i[s])}return o}_getSegmentMatches(e,t){const r=new Array,{coordinateSegments:n}=this;if(!n)return r;for(let o=0;o<n.length;o++){const i=n[o],s=e.match(i.searchPattern);if(!s){r.push("");continue}let a=s[0];if(e=e.replace(a,"").trim(),i.substitution){const e=t?i.substitution.input(a):i.substitution.output(a);e&&(a=`${e}`)}r.push(a)}return r}async reverseConvert(e){const t=this._parseUserInput(e),n=this.conversionInfo?.reverseConvert;let o;if(n)o=n(t);else if("xy"===this.name||"basemap"===this.name)o=w(t,this.spatialReference);else if(this.viewModel?.formatterAvailable)switch(this.name){case"dd":case"ddm":case"dms":o=l(t,this.spatialReference);break;case"mgrs":{const e="automatic";o=a(t,this.spatialReference,e);break}case"utm":{const e="latitude-band-indicators";o=s(t,this.spatialReference,e);break}case"usng":o=i(t,this.spatialReference);break;default:o=null}if(!o)throw new r("format:invalid-input","Could not parse input into point.",{userInput:e});return this._project(o,this._viewSpatialReference)}async _getCoordinate(e){const t=this.viewModel?.view?.scale??0;if(!y(e))throw new r("format:invalid-point","Could not transform invalid point into coordinate.",{point:e});if(this.viewModel?.formatterAvailable||"basemap"===this.name||"xy"===this.name)switch(this.name){case"dd":case"ddm":case"dms":{const r=S(t);return m(e,this.name,r)}case"mgrs":return u(e,"automatic",5,!1);case"usng":return p(e,5,!1);case"utm":return c(e,"latitude-band-indicators",!0);default:return b(e,t)}return b(e,t)}async _project(e,t){if(v(e.spatialReference,t)||!t)return e;if(this.viewModel?.formatterAvailable&&h())return d(e,t);if(!this.viewModel?.formatterAvailable){const r=g(e,t);if(null!=r)return r}return null}};e([n()],_.prototype,"conversionInfo",void 0),e([n()],_.prototype,"coordinateSegments",void 0),e([n()],_.prototype,"currentPattern",null),e([n()],_.prototype,"_currentPattern",void 0),e([n()],_.prototype,"label",null),e([n()],_.prototype,"defaultPattern",void 0),e([n({readOnly:!0})],_.prototype,"hasDisplayProperties",null),e([n()],_.prototype,"name",void 0),e([n({type:f})],_.prototype,"spatialReference",null),e([n()],_.prototype,"viewModel",void 0),e([n({readOnly:!0})],_.prototype,"_viewSpatialReference",null),e([n({readOnly:!0})],_.prototype,"_additionalCharactersPattern",null),_=e([o("esri.widgets.CoordinateConversion.support.Format")],_);const R=_;export{R as default};