@arcgis/core 4.28.0-next.20230911 → 4.28.0-next.20230913

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 (136) hide show
  1. package/arcade/Feature.js +1 -1
  2. package/arcade/arcadeTimeUtils.js +1 -1
  3. package/arcade/executionError.js +1 -1
  4. package/arcade/featureSetUtils.js +1 -1
  5. package/arcade/featureset/actions/Adapted.js +1 -1
  6. package/arcade/featureset/actions/GroupBy.js +1 -1
  7. package/arcade/featureset/support/FeatureSet.js +1 -1
  8. package/arcade/featureset/support/errorsupport.js +1 -1
  9. package/arcade/functions/featuresetbase.js +1 -1
  10. package/arcade/functions/featuresetstats.js +1 -1
  11. package/arcade/functions/string.js +1 -1
  12. package/arcade.js +1 -1
  13. package/assets/esri/core/workers/RemoteClient.js +1 -1
  14. package/assets/esri/core/workers/chunks/0920312e3c7b63c2e253.js +1 -0
  15. package/assets/esri/core/workers/chunks/0cb007ab5db0a2a598ec.js +1 -0
  16. package/assets/esri/core/workers/chunks/0cc61f1b2c0473ded5c2.js +1 -0
  17. package/assets/esri/core/workers/chunks/0f804e3f888cb4998f46.js +1 -0
  18. package/assets/esri/core/workers/chunks/189dd81cf95bd8417ee3.js +1 -0
  19. package/assets/esri/core/workers/chunks/1a723bb4a341f645e5fe.js +1 -0
  20. package/assets/esri/core/workers/chunks/24c717492ea1b35310d8.js +1 -0
  21. package/assets/esri/core/workers/chunks/{3ce73dd4113dbc7d11de.js → 2eb58dc339b2bb03d9e3.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{38c07a8574352a7f2f6d.js → 2ff0dbd5eb7ca57bb7fc.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{768f3db2705fa9e57641.js → 49dfdc0463450491df9d.js} +1 -1
  24. package/assets/esri/core/workers/chunks/650a317b6dc245a7060f.js +1 -0
  25. package/assets/esri/core/workers/chunks/{56ed099745360888604e.js → 67f01c71280fa0759742.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{f62842807744bdfaced7.js → 67fab13f56b340076763.js} +1 -1
  27. package/assets/esri/core/workers/chunks/6d94b358e8d1cf79bba3.js +1 -0
  28. package/assets/esri/core/workers/chunks/718607d7a3b33fc33b0a.js +1 -0
  29. package/assets/esri/core/workers/chunks/{4c63d6b9460aa6ae9843.js → 860417f4138f53d315ba.js} +2 -2
  30. package/assets/esri/core/workers/chunks/8aa7e994b74f66522c37.js +1 -0
  31. package/assets/esri/core/workers/chunks/9fa485b04b997b0a5509.js +1 -0
  32. package/assets/esri/core/workers/chunks/a047fcf3c7307a69b63c.js +1 -0
  33. package/assets/esri/core/workers/chunks/a753d9874801cd448946.js +1 -0
  34. package/assets/esri/core/workers/chunks/c51233ad51823cb98c35.js +1 -0
  35. package/assets/esri/core/workers/chunks/c61f20d91a5c432b07dc.js +1 -0
  36. package/assets/esri/core/workers/chunks/d3d11242e5af57ba77f4.js +1 -0
  37. package/assets/esri/core/workers/chunks/dbf343d1fb746f99bb6e.js +1 -0
  38. package/assets/esri/core/workers/chunks/{271ec1d1666bf6dc3dda.js → dc74b4ec85e8e3de5b27.js} +1 -1
  39. package/assets/esri/core/workers/chunks/e8a8791d765ab6c450dd.js +1 -0
  40. package/assets/esri/core/workers/chunks/{5fe7b5665710ec6d3046.js → eb0d1c5c96f735c162d3.js} +1 -1
  41. package/assets/esri/themes/base/widgets/_Sketch.scss +0 -5
  42. package/assets/esri/themes/base/widgets/_SketchTooltipControls.scss +0 -5
  43. package/assets/esri/themes/dark/main.css +1 -1
  44. package/assets/esri/themes/light/main.css +1 -1
  45. package/assets/esri/themes/light/view.css +1 -1
  46. package/chunks/HUDMaterial.glsl.js +38 -45
  47. package/chunks/languageUtils.js +1 -1
  48. package/core/promiseUtils.js +1 -1
  49. package/core/sql/AggregateFunctions.js +1 -1
  50. package/core/sql/DateOnly.js +1 -1
  51. package/core/sql/SqlTimestampOffset.js +1 -1
  52. package/core/sql/TimeOnly.js +1 -1
  53. package/core/sql/WhereClause.js +1 -1
  54. package/core/sql/WhereGrammar.js +1 -1
  55. package/core/sql/sqlCompareUtils.js +1 -1
  56. package/geometry/GeometryCursor.js +1 -1
  57. package/geometry/Mesh.js +1 -1
  58. package/geometry/support/labelPoint.js +1 -1
  59. package/geometry/support/meshUtils/bounds.js +1 -1
  60. package/geometry/support/meshUtils/georeference.js +1 -1
  61. package/interfaces.d.ts +190 -144
  62. package/layers/ImageryLayer.js +1 -1
  63. package/layers/SceneLayer.js +1 -1
  64. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  65. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  66. package/layers/graphics/sources/csv/csv.js +1 -1
  67. package/layers/support/FetchAssociatedFeatureLayer.js +1 -1
  68. package/layers/support/TilemapCache.js +1 -1
  69. package/layers/support/fieldUtils.js +1 -1
  70. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  71. package/layers/support/wmsUtils.js +1 -1
  72. package/layers/video/VideoController.js +1 -1
  73. package/package.json +3 -3
  74. package/smartMapping/heuristics/sizeRange.js +1 -1
  75. package/smartMapping/labels/bins.js +1 -1
  76. package/smartMapping/labels/clusters.js +1 -1
  77. package/smartMapping/labels/support/utils.js +1 -1
  78. package/smartMapping/popup/support/clusterUtils.js +1 -1
  79. package/smartMapping/support/clusterUtils.js +1 -1
  80. package/support/revision.js +1 -1
  81. package/views/2d/engine/webgl/DisplayId.js +1 -1
  82. package/views/2d/engine/webgl/Utils.js +1 -1
  83. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
  84. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  85. package/views/3d/analysis/Dimension/DimensionVisualization.js +1 -1
  86. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  87. package/views/3d/analysis/Dimension/LengthDimensionVisualization.js +1 -1
  88. package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
  89. package/views/3d/analysis/Dimension/settings.js +1 -1
  90. package/views/3d/interactive/Manipulator3D.js +1 -1
  91. package/views/3d/interactive/editingTools/originGraphicVisualElementUtils.js +1 -1
  92. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  93. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  94. package/views/3d/layers/I3SMeshView3D.js +1 -1
  95. package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
  96. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  97. package/views/3d/layers/SceneLayerWorker.js +1 -1
  98. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  99. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  100. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  101. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  102. package/views/3d/webgl-engine/shaders/HUDMaterialTechniqueConfiguration.js +1 -1
  103. package/views/ToolViewManager.js +1 -1
  104. package/views/View.js +1 -1
  105. package/views/animation/easing.js +1 -1
  106. package/views/webgl/FramebufferObject.js +1 -1
  107. package/views/webgl/RenderingContext.js +1 -1
  108. package/views/webgl/enums.js +1 -1
  109. package/views/webgl/renderState.js +1 -1
  110. package/widgets/BasemapGallery/BasemapGalleryViewModel.js +1 -1
  111. package/widgets/Feature/FeatureMedia.js +1 -1
  112. package/widgets/FeatureForm.js +1 -1
  113. package/widgets/Features.js +1 -1
  114. package/widgets/Search/SearchViewModel.js +1 -1
  115. package/widgets/support/SketchTooltipControls/SketchTooltipControlsViewModel.js +1 -1
  116. package/widgets/support/SketchTooltipControls.js +1 -1
  117. package/widgets/support/SnappingControls.js +1 -1
  118. package/assets/esri/core/workers/chunks/055575ed2ab78be0bdb2.js +0 -1
  119. package/assets/esri/core/workers/chunks/0ee90a0b4d09a56c0d48.js +0 -1
  120. package/assets/esri/core/workers/chunks/15056f91d87f11b00bcc.js +0 -1
  121. package/assets/esri/core/workers/chunks/344e40934c98d6fe66ae.js +0 -1
  122. package/assets/esri/core/workers/chunks/558049fcac3a82a093fc.js +0 -1
  123. package/assets/esri/core/workers/chunks/5c41eb67d19b8710118a.js +0 -1
  124. package/assets/esri/core/workers/chunks/5d183ac1a8b68ba9c656.js +0 -1
  125. package/assets/esri/core/workers/chunks/610d4a5d2511fa81460e.js +0 -1
  126. package/assets/esri/core/workers/chunks/6755bb1f2a6575a8e082.js +0 -1
  127. package/assets/esri/core/workers/chunks/84173936b309712ba9b3.js +0 -1
  128. package/assets/esri/core/workers/chunks/877302d6e39a0d530aab.js +0 -1
  129. package/assets/esri/core/workers/chunks/a07dc782e69111e2eeaf.js +0 -1
  130. package/assets/esri/core/workers/chunks/b825019841247d173072.js +0 -1
  131. package/assets/esri/core/workers/chunks/bed1bc13b168fae46404.js +0 -1
  132. package/assets/esri/core/workers/chunks/c8dd21a332559c99815c.js +0 -1
  133. package/assets/esri/core/workers/chunks/ccc3564e76c0ec5c0228.js +0 -1
  134. package/assets/esri/core/workers/chunks/d0a81c7ec8a84eeadd31.js +0 -1
  135. package/assets/esri/core/workers/chunks/e7a852b319c1d89eddc5.js +0 -1
  136. package/assets/esri/core/workers/chunks/ebde11fdccb437954ce7.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{ShaderOutput as o}from"../core/shaderLibrary/ShaderOutput.js";import{HUDSpace as t}from"../core/shaderLibrary/hud/HUD.glsl.js";import{parameter as i}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{TransparencyPassType as s}from"../lib/TransparencyPassType.js";import{DefaultTechniqueConfiguration as r}from"../materials/DefaultTechniqueConfiguration.js";class p extends r{constructor(){super(...arguments),this.output=o.Color,this.screenCenterOffsetUnitsEnabled=t.World,this.transparencyPassType=s.NONE,this.spherical=!1,this.occlusionTestEnabled=!0,this.signedDistanceFieldEnabled=!1,this.sampleSignedDistanceFieldTexelCenter=!1,this.vvSize=!1,this.vvColor=!1,this.hasVerticalOffset=!1,this.hasScreenSizePerspective=!1,this.debugDrawLabelBorder=!1,this.binaryHighlightOcclusionEnabled=!0,this.hasSlicePlane=!1,this.hasPolygonOffset=!1,this.depthEnabled=!0,this.pixelSnappingEnabled=!0,this.draped=!1,this.multipassEnabled=!1,this.cullAboveGround=!1,this.occlusionPass=!1,this.objectAndLayerIdColorInstanced=!1}}e([i({count:o.COUNT})],p.prototype,"output",void 0),e([i({count:t.COUNT})],p.prototype,"screenCenterOffsetUnitsEnabled",void 0),e([i({count:s.COUNT})],p.prototype,"transparencyPassType",void 0),e([i()],p.prototype,"spherical",void 0),e([i()],p.prototype,"occlusionTestEnabled",void 0),e([i()],p.prototype,"signedDistanceFieldEnabled",void 0),e([i()],p.prototype,"sampleSignedDistanceFieldTexelCenter",void 0),e([i()],p.prototype,"vvSize",void 0),e([i()],p.prototype,"vvColor",void 0),e([i()],p.prototype,"hasVerticalOffset",void 0),e([i()],p.prototype,"hasScreenSizePerspective",void 0),e([i()],p.prototype,"debugDrawLabelBorder",void 0),e([i()],p.prototype,"binaryHighlightOcclusionEnabled",void 0),e([i()],p.prototype,"hasSlicePlane",void 0),e([i()],p.prototype,"hasPolygonOffset",void 0),e([i()],p.prototype,"depthEnabled",void 0),e([i()],p.prototype,"pixelSnappingEnabled",void 0),e([i()],p.prototype,"draped",void 0),e([i()],p.prototype,"multipassEnabled",void 0),e([i()],p.prototype,"cullAboveGround",void 0),e([i()],p.prototype,"occlusionPass",void 0),e([i()],p.prototype,"objectAndLayerIdColorInstanced",void 0),e([i({constValue:!0})],p.prototype,"hasSliceInVertexProgram",void 0),e([i({constValue:!1})],p.prototype,"hasVvInstancing",void 0);export{p as HUDMaterialTechniqueConfiguration};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import{ShaderOutput as o}from"../core/shaderLibrary/ShaderOutput.js";import{HUDSpace as t}from"../core/shaderLibrary/hud/HUD.glsl.js";import{parameter as s}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{TransparencyPassType as i}from"../lib/TransparencyPassType.js";import{DefaultTechniqueConfiguration as r}from"../materials/DefaultTechniqueConfiguration.js";class p extends r{constructor(){super(...arguments),this.output=o.Color,this.screenCenterOffsetUnitsEnabled=t.World,this.transparencyPassType=i.NONE,this.spherical=!1,this.occlusionTestEnabled=!0,this.signedDistanceFieldEnabled=!1,this.sampleSignedDistanceFieldTexelCenter=!1,this.vvSize=!1,this.vvColor=!1,this.hasVerticalOffset=!1,this.hasScreenSizePerspective=!1,this.debugDrawLabelBorder=!1,this.hasSlicePlane=!1,this.hasPolygonOffset=!1,this.depthEnabled=!0,this.pixelSnappingEnabled=!0,this.draped=!1,this.multipassEnabled=!1,this.cullAboveGround=!1,this.occlusionPass=!1,this.objectAndLayerIdColorInstanced=!1}}e([s({count:o.COUNT})],p.prototype,"output",void 0),e([s({count:t.COUNT})],p.prototype,"screenCenterOffsetUnitsEnabled",void 0),e([s({count:i.COUNT})],p.prototype,"transparencyPassType",void 0),e([s()],p.prototype,"spherical",void 0),e([s()],p.prototype,"occlusionTestEnabled",void 0),e([s()],p.prototype,"signedDistanceFieldEnabled",void 0),e([s()],p.prototype,"sampleSignedDistanceFieldTexelCenter",void 0),e([s()],p.prototype,"vvSize",void 0),e([s()],p.prototype,"vvColor",void 0),e([s()],p.prototype,"hasVerticalOffset",void 0),e([s()],p.prototype,"hasScreenSizePerspective",void 0),e([s()],p.prototype,"debugDrawLabelBorder",void 0),e([s()],p.prototype,"hasSlicePlane",void 0),e([s()],p.prototype,"hasPolygonOffset",void 0),e([s()],p.prototype,"depthEnabled",void 0),e([s()],p.prototype,"pixelSnappingEnabled",void 0),e([s()],p.prototype,"draped",void 0),e([s()],p.prototype,"multipassEnabled",void 0),e([s()],p.prototype,"cullAboveGround",void 0),e([s()],p.prototype,"occlusionPass",void 0),e([s()],p.prototype,"objectAndLayerIdColorInstanced",void 0),e([s({constValue:!0})],p.prototype,"hasSliceInVertexProgram",void 0),e([s({constValue:!1})],p.prototype,"hasVvInstancing",void 0);export{p as HUDMaterialTechniqueConfiguration};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../chunks/tslib.es6.js";import e from"../core/Accessor.js";import{clock as o}from"../core/clock.js";import i from"../core/Collection.js";import{makeHandle as r}from"../core/handleUtils.js";import"../core/has.js";import a from"../core/Logger.js";import{removeMaybe as s,destroyMaybe as n}from"../core/maybe.js";import{watch as l}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../core/support/UpdatingHandles.js";import{TextureCollection as p}from"./3d/support/TextureCollection.js";import{ViewEventPriorities as m}from"./input/InputManager.js";import{eventTypes as d}from"./input/ViewEvents.js";import{getToolCollectionHandles as v,areToolManipulatorsEditable as _}from"./interactive/interactiveToolUtils.js";import{EditableFlag as g}from"./interactive/interfaces.js";import{ToolViewManagerManipulatorState as T}from"./interactive/ToolViewManagerManipulatorState.js";const f="attached",E="tools",y=1e3;let w=class extends e{constructor(t){super(t),this._updatingHandles=new u,this._clock=o,this._manipulatorState=new T,this.tools=new i,this.cursor=null,this._interacting=!1,this._interactingTimeout=null,this._forEachTool=t=>{for(const e of this.tools.items)if(t(e))return}}initialize(){this.addHandles([this.view.on(d,(t=>{this._handleInputEvent(t)}),m.TOOL),...v(this.tools),this.tools.on("before-add",(({item:t})=>{this._updateToolEditableFlag(t)})),this.tools.on("before-remove",(({item:t})=>{this._manipulatorState.clearPointers(t,this._manipulatorStateEventArgs),this._updateCursor()})),this.tools.on("change",(()=>{this._refreshToolWatchers()}))])}destroy(){this.detach(),this._updatingHandles.destroy()}get _manipulatorStateEventArgs(){return{forEachTool:this._forEachTool,activeTool:this.activeTool,setActiveTool:t=>{this.activeTool=t},view:this.view}}set activeTool(t){if(null!=t&&!this.view.ready)return void a.getLogger(this).error("Cannot set active tool while view is not ready.");if(t===this.activeTool)return;const e=this.activeTool;this._set("activeTool",t),null!=e&&e.deactivate(),null!=t&&t.activate(),this._removeIncompleteTools(t);for(const o of this.tools){this._updateToolEditableFlag(o);const t=_(o);null!=this.activeTool&&t||this._manipulatorState.clearPointers(o,this._manipulatorStateEventArgs,!t)}this._updateCursor()}get updating(){return this._updatingHandles.updating||this.tools.some((t=>t.updating))||(this.textures?.updating??!1)}get interacting(){return this._interacting}_clearInteractingTimeout(){this._interactingTimeout=s(this._interactingTimeout)}_startInteractingTimeout(){this._clearInteractingTimeout(),this._interactingTimeout=this._clock.setTimeout((()=>this._interacting=!1),y)}attach(){"3d"===this.view.type?(this._set("textures",new p(this.view._stage,this.view.resourceController.scheduler)),this.addHandles([l((()=>{const{state:t}=this.view;return"camera"in t&&t.camera}),(()=>this._forEachManipulator((t=>t.onViewChange())))),this.view.elevationProvider?.on("elevation-change",(t=>this._forEachManipulator((e=>e.onElevationChange(t))))),r((()=>this._set("textures",n(this.textures))))],f)):this.addHandles(l((()=>this.view.extent),(()=>this._forEachManipulator((t=>t.onViewChange())))))}detach(){this.activeTool=null,this.tools.removeAll(),this.removeHandles(f),this._clearInteractingTimeout(),this._interacting=!1}_forEachManipulator(t){this._forEachTool((e=>{e.manipulators&&e.manipulators.forEach((({manipulator:o})=>t(o,e)))}))}_handleInputEvent(t){let e=!1;const o={...t,stopPropagation:()=>{e=!0,t.stopPropagation()}};null!=this.activeTool?this.activeTool.handleInputEvent&&this.activeTool.handleInputEvent(o):this._forEachTool((t=>{!e&&t.visible&&t.handleInputEvent(o)})),!e&&"key-down"===t.type&&"Escape"===t.key&&this.activeTool&&(t.stopPropagation(),this.activeTool=null),this._manipulatorState.handleInputEvent(o,this._manipulatorStateEventArgs),e||null==this.activeTool||this.activeTool.handleInputEventAfter(o),this._manipulatorState.handleHoverEvent(o,this._forEachTool),this._updateCursor(),"pointer-move"===t.type&&(this._manipulatorState.hasFocusedManipulators()||this.activeTool)&&(this._interacting=!0,this._startInteractingTimeout())}_refreshToolWatchers(){this.removeHandles(E),this._forEachTool((t=>{if(t instanceof e){const e=l((()=>[t.cursor,t.visible,t.editable]),(()=>{_(t)||this._manipulatorState.clearPointers(t,this._manipulatorStateEventArgs),this._updateCursor()}));this.addHandles(e,E)}t.manipulators&&this.addHandles([t.manipulators.on("after-remove",(e=>{this._manipulatorState.clearPointers(t,this._manipulatorStateEventArgs,!0,e.item.manipulator)})),t.manipulators.on("change",(()=>{this._manipulatorState.updateHoveredStateFromKnownPointers(this._forEachTool),this._updateCursor()}))],E)})),this._manipulatorState.updateHoveredStateFromKnownPointers(this._forEachTool),this._updateCursor()}_updateToolEditableFlag(t){t.setEditableFlag?.(g.MANAGER,null==this.activeTool||t===this.activeTool)}_updateCursor(){let t=this._manipulatorState.cursor;null==t&&this._forEachTool((e=>!(null==e.cursor||!e.visible)&&(t=e.cursor,!0))),this._get("cursor")!==t&&this._set("cursor",t)}_removeIncompleteTools(t){this.tools.filter((e=>(null==t||e!==t)&&!e.created&&e.removeIncompleteOnCancel)).forEach((t=>{this.tools.remove(t)}))}get test(){return{setClock:t=>this._clock=t}}};t([h({constructOnly:!0,nonNullable:!0})],w.prototype,"view",void 0),t([h({readOnly:!0,nonNullable:!0})],w.prototype,"textures",void 0),t([h({value:null})],w.prototype,"activeTool",null),t([h({readOnly:!0,type:i})],w.prototype,"tools",void 0),t([h({readOnly:!0})],w.prototype,"cursor",void 0),t([h({readOnly:!0})],w.prototype,"updating",null),t([h()],w.prototype,"_interacting",void 0),t([h({readOnly:!0})],w.prototype,"interacting",null),w=t([c("esri.views.ToolViewManager")],w);export{w as ToolViewManager,y as interactingTimeout};
5
+ import{_ as t}from"../chunks/tslib.es6.js";import e from"../core/Accessor.js";import{clock as o}from"../core/clock.js";import i from"../core/Collection.js";import{makeHandle as r}from"../core/handleUtils.js";import"../core/has.js";import a from"../core/Logger.js";import{removeMaybe as s,destroyMaybe as n}from"../core/maybe.js";import{watch as l}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../core/support/UpdatingHandles.js";import{TextureCollection as p}from"./3d/support/TextureCollection.js";import{ViewEventPriorities as m}from"./input/InputManager.js";import{eventTypes as d}from"./input/ViewEvents.js";import{getToolCollectionHandles as v,areToolManipulatorsEditable as _}from"./interactive/interactiveToolUtils.js";import{EditableFlag as g}from"./interactive/interfaces.js";import{ToolViewManagerManipulatorState as T}from"./interactive/ToolViewManagerManipulatorState.js";const f="attached",E="tools",y=1e3;let w=class extends e{constructor(t){super(t),this._updatingHandles=new u,this._clock=o,this._manipulatorState=new T,this.tools=new i,this.cursor=null,this._interacting=!1,this._interactingTimeout=null,this._forEachTool=t=>{for(const e of this.tools.items)if(t(e))return}}initialize(){this.addHandles([this.view.on(d,(t=>{this._handleInputEvent(t)}),m.TOOL),...v(this.tools),this.tools.on("before-add",(({item:t})=>{this._updateToolEditableFlag(t)})),this.tools.on("before-remove",(({item:t})=>{this._manipulatorState.clearPointers(t,this._manipulatorStateEventArgs),this._updateCursor()})),this.tools.on("change",(()=>{this._refreshToolWatchers()}))])}destroy(){this.activeTool=null,this.tools.drain((t=>t.destroy())),this._clearInteractingTimeout(),this._interacting=!1,this._updatingHandles.destroy()}get _manipulatorStateEventArgs(){return{forEachTool:this._forEachTool,activeTool:this.activeTool,setActiveTool:t=>{this.activeTool=t},view:this.view}}set activeTool(t){if(null!=t&&!this.view.ready)return void a.getLogger(this).error("Cannot set active tool while view is not ready.");if(t===this.activeTool)return;const e=this.activeTool;this._set("activeTool",t),null!=e&&e.deactivate(),null!=t&&t.activate(),this._removeIncompleteTools(t);for(const o of this.tools){this._updateToolEditableFlag(o);const t=_(o);null!=this.activeTool&&t||this._manipulatorState.clearPointers(o,this._manipulatorStateEventArgs,!t)}this._updateCursor()}get updating(){return this._updatingHandles.updating||this.tools.some((t=>t.updating))||(this.textures?.updating??!1)}get interacting(){return this._interacting}_clearInteractingTimeout(){this._interactingTimeout=s(this._interactingTimeout)}_startInteractingTimeout(){this._clearInteractingTimeout(),this._interactingTimeout=this._clock.setTimeout((()=>this._interacting=!1),y)}attach(){"3d"===this.view.type?(this._set("textures",new p(this.view._stage,this.view.resourceController.scheduler)),this.addHandles([l((()=>{const{state:t}=this.view;return"camera"in t&&t.camera}),(()=>this._forEachManipulator((t=>t.onViewChange())))),this.view.elevationProvider?.on("elevation-change",(t=>this._forEachManipulator((e=>e.onElevationChange(t))))),r((()=>this._set("textures",n(this.textures))))],f)):this.addHandles(l((()=>this.view.extent),(()=>this._forEachManipulator((t=>t.onViewChange())))))}detach(){this.activeTool=null,this.tools.removeAll(),this.removeHandles(f),this._clearInteractingTimeout(),this._interacting=!1}_forEachManipulator(t){this._forEachTool((e=>{e.manipulators&&e.manipulators.forEach((({manipulator:o})=>t(o,e)))}))}_handleInputEvent(t){let e=!1;const o={...t,stopPropagation:()=>{e=!0,t.stopPropagation()}};null!=this.activeTool?this.activeTool.handleInputEvent&&this.activeTool.handleInputEvent(o):this._forEachTool((t=>{!e&&t.visible&&t.handleInputEvent(o)})),!e&&"key-down"===t.type&&"Escape"===t.key&&this.activeTool&&(t.stopPropagation(),this.activeTool=null),this._manipulatorState.handleInputEvent(o,this._manipulatorStateEventArgs),e||null==this.activeTool||this.activeTool.handleInputEventAfter(o),this._manipulatorState.handleHoverEvent(o,this._forEachTool),this._updateCursor(),"pointer-move"===t.type&&(this._manipulatorState.hasFocusedManipulators()||this.activeTool)&&(this._interacting=!0,this._startInteractingTimeout())}_refreshToolWatchers(){this.removeHandles(E),this._forEachTool((t=>{if(t instanceof e){const e=l((()=>[t.cursor,t.visible,t.editable]),(()=>{_(t)||this._manipulatorState.clearPointers(t,this._manipulatorStateEventArgs),this._updateCursor()}));this.addHandles(e,E)}t.manipulators&&this.addHandles([t.manipulators.on("after-remove",(e=>{this._manipulatorState.clearPointers(t,this._manipulatorStateEventArgs,!0,e.item.manipulator)})),t.manipulators.on("change",(()=>{this._manipulatorState.updateHoveredStateFromKnownPointers(this._forEachTool),this._updateCursor()}))],E)})),this._manipulatorState.updateHoveredStateFromKnownPointers(this._forEachTool),this._updateCursor()}_updateToolEditableFlag(t){t.setEditableFlag?.(g.MANAGER,null==this.activeTool||t===this.activeTool)}_updateCursor(){let t=this._manipulatorState.cursor;null==t&&this._forEachTool((e=>!(null==e.cursor||!e.visible)&&(t=e.cursor,!0))),this._get("cursor")!==t&&this._set("cursor",t)}_removeIncompleteTools(t){this.tools.filter((e=>(null==t||e!==t)&&!e.created&&e.removeIncompleteOnCancel)).forEach((t=>{this.tools.remove(t)}))}get test(){return{setClock:t=>this._clock=t}}};t([h({constructOnly:!0,nonNullable:!0})],w.prototype,"view",void 0),t([h({readOnly:!0,nonNullable:!0})],w.prototype,"textures",void 0),t([h({value:null})],w.prototype,"activeTool",null),t([h({readOnly:!0,type:i})],w.prototype,"tools",void 0),t([h({readOnly:!0})],w.prototype,"cursor",void 0),t([h({readOnly:!0})],w.prototype,"updating",null),t([h()],w.prototype,"_interacting",void 0),t([h({readOnly:!0})],w.prototype,"interacting",null),w=t([c("esri.views.ToolViewManager")],w);export{w as ToolViewManager,y as interactingTimeout};
package/views/View.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.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Map.js";import i from"../TimeExtent.js";import r from"../core/Accessor.js";import{createTask as a}from"../core/asyncUtils.js";import o from"../core/Collection.js";import s from"../core/CollectionFlattener.js";import n from"../core/Error.js";import l from"../core/Evented.js";import{HandleOwnerMixin as p}from"../core/HandleOwner.js";import{makeHandle as h}from"../core/handleUtils.js";import d from"../core/Loadable.js";import y from"../core/Logger.js";import{destroyMaybe as u,abortMaybe as c}from"../core/maybe.js";import{EsriPromiseMixin as m}from"../core/Promise.js";import{after as f}from"../core/promiseUtils.js";import{watch as g,whenOnce as w,when as v,sync as V}from"../core/reactiveUtils.js";import{property as M}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as R}from"../core/accessorSupport/decorators/subclass.js";import{owningCollectionProperty as _}from"../core/support/OwningCollection.js";import S from"../geometry/Extent.js";import j from"../geometry/HeightModelInfo.js";import F from"../geometry/SpatialReference.js";import{equals as L}from"../geometry/support/spatialReferenceUtils.js";import{AnalysesCollection as O}from"../support/AnalysesCollection.js";import{GraphicsCollection as T}from"../support/GraphicsCollection.js";import{SYSTEM as E,UNKNOWN as b}from"../time/timeZoneUtils.js";import{BasemapView as k}from"./BasemapView.js";import x from"./LayerViewManager.js";import C from"./Magnifier.js";import Z from"./Theme.js";import{ToolViewManager as I}from"./ToolViewManager.js";import D from"./input/Input.js";import{ViewEvents as A}from"./input/ViewEvents.js";import P from"./navigation/Navigation.js";import{DefaultsFromMap as U}from"./support/DefaultsFromMap.js";var q;let z=q=class extends(p(l.EventedMixin(m(r)))){constructor(e){super(e),this._userSpatialReference=null,this._cursor=null,this.allLayerViews=new s({getCollections:()=>[this.basemapView?.baseLayerViews,this.groundView?.layerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:N}),this.groundView=null,this.basemapView=null,this.fatalError=null,this.graphics=new T,this.analyses=new O,this.typeSpecificPreconditionsReady=!0,this.layerViews=new o,this.magnifier=new C,this.padding={left:0,top:0,right:0,bottom:0},this.ready=!1,this.spatialReferenceWarningDelay=1e3,this.supportsGround=!0,this.timeExtent=null,this.type=null,this.scale=null,this.updating=!1,this.initialExtentRequired=!0,this.input=new D,this.navigation=new P,this.layerViewManager=null,this.analysisViewManager=null,this.isHeightModelInfoRequired=!1,this.width=null,this.height=null,this.resizing=!1,this.suspended=!1,this.viewEvents=new A(this),this.persistableViewModels=new o,this._isValid=!1,this._readyCycleForced=!1,this._lockedSpatialReference=null,this._userTimeZone=null,this._lockedTimeZone=null,this.theme=null,this.handles.add(g((()=>this.preconditionsReady),(e=>{e?(this._lockedSpatialReference=this.spatialReference,this._lockedTimeZone=this.timeZone,q.views.add(this)):(this._lockedSpatialReference=null,q.views.remove(this)),this.notifyChange("spatialReference"),!e&&this.ready?(this.toolViewManager?.detach(),null!=this.analysisViewManager&&this.analysisViewManager.detach(),this.layerViewManager?.clear(),this._teardown()):e&&!this.ready&&(this._startup(),null!=this.analysisViewManager&&this.analysisViewManager.attach(),this.toolViewManager.attach())}),V))}initialize(){this.addResolvingPromise(Promise.all([this.loadAsyncDependencies(),this.validate()]).then((()=>(this._isValid=!0,w((()=>this.ready)))))),this.basemapView=new k({view:this}),this.layerViewManager=new x({view:this,layerViewImporter:{importLayerView:e=>this.importLayerView(e),hasLayerViewModule:e=>this.hasLayerViewModule(e)},supportsGround:this.supportsGround}),this.toolViewManager=new I({view:this}),this._setupSpatialReferenceLogger(),this.handles.add([g((()=>this.initialExtentRequired),(e=>this.defaultsFromMap.required={...this.defaultsFromMap.required,extent:e}),{sync:!0,initial:!0}),g((()=>this.ready),(e=>{this.defaultsFromMap&&(this.defaultsFromMap.suspended=e,this.defaultsFromMap.userSpatialReference=e?this.spatialReference:this._userSpatialReference)}),{sync:!0}),g((()=>this._userSpatialReference),(e=>{this.defaultsFromMap&&(this.defaultsFromMap.userSpatialReference=e)}),{sync:!0,initial:!0})])}_setupSpatialReferenceLogger(){let e=null;this.handles.add([g((()=>this.defaultsFromMap?.ready),(t=>{const i=this.map?.allLayers.length>0;if(t&&!this.spatialReference&&i){if(null!=e)return;const t=h((()=>e=c(e)));e=a((async t=>{try{await f(this.spatialReferenceWarningDelay,null,t)}catch{return}finally{e=null}y.getLogger(this).warn("#spatialReference","no spatial reference could be derived from the currently added map layers")})),this.handles.add(t,"spatial-reference-logger-task")}else this.handles.remove("spatial-reference-logger-task")}),{sync:!0})])}destroy(){this.destroyed||(q.views.remove(this),this.viewEvents.destroy(),this.allLayerViews.destroy(),this.navigation&&(this.navigation.destroy(),this._set("navigation",null)),this.graphics=u(this.graphics),this.analyses=u(this.analyses),this.handles.remove("defaultsFromMap"),this.defaultsFromMap.destroy(),this._set("defaultsFromMap",null),u(this.analysisViewManager),this.toolViewManager=u(this.toolViewManager),this.layerViewManager=u(this.layerViewManager),this.basemapView=u(this.basemapView),this.groundView?.destroy(),this.layerViews?.forEach((e=>e.destroy())),this.layerViews.length=0,this.invalidate(),this._emitter.clear(),this.handles.removeAll(),this.map=u(this.map))}_startup(){this._set("ready",!0)}_teardown(){this._set("ready",!1)}whenReady(){return Promise.resolve(this)}toMap(){return y.getLogger(this).error("#toMap()","Not implemented on this instance of View"),null}get activeTool(){return this.toolViewManager?.activeTool}set activeTool(e){this.toolViewManager&&(this.toolViewManager.activeTool=e)}get animation(){return this._get("animation")}set animation(e){this._set("animation",e)}get center(){return null}get _defaultsFromMapSettings(){return{}}get defaultsFromMap(){return new U({required:{tileInfo:!1,heightModelInfo:!1,extent:!1},map:()=>this.map,getSpatialReferenceSupport:e=>this.getSpatialReferenceSupport(e),...this._defaultsFromMapSettings})}get extent(){return this._get("extent")}set extent(e){this._set("extent",e)}get heightModelInfo(){return this.getDefaultHeightModelInfo()}get interacting(){return this.navigating}get navigating(){return!1}get preconditionsReady(){return!(this.fatalError||!this._isValid||this._readyCycleForced||!this.map||d.isLoadable(this.map)&&!this.map.loaded||0===this.width||0===this.height||!this.spatialReference||!this._validateSpatialReference(this.spatialReference)||!this._lockedSpatialReference&&!this.defaultsFromMap?.ready||!this.typeSpecificPreconditionsReady)}get resolution(){return 0}set map(e){e!==this._get("map")&&(e?.destroyed&&(y.getLogger(this).warn("#map","The provided map is already destroyed",{map:e}),e=null),d.isLoadable(e)&&e.load().catch((()=>{})),this.constructed&&!this.destroyed&&(this.forceReadyCycle(),this._lockedSpatialReference=null),this._set("map",e))}get spatialReference(){let e=this._userSpatialReference||this._lockedSpatialReference||this.getDefaultSpatialReference()||null;return e&&this.defaultsFromMap?.required?.heightModelInfo&&(e=e.clone(),e.vcsWkid=this.defaultsFromMap.vcsWkid,e.latestVcsWkid=this.defaultsFromMap.latestVcsWkid),e}set spatialReference(e){const t=!L(e,this._get("spatialReference"));this._set("_userSpatialReference",e),t&&(this._set("spatialReference",e),this._spatialReferenceChanged(e))}_spatialReferenceChanged(e){}get stationary(){return!this.animation&&!this.navigating&&!this.resizing}get timeZone(){return this._userTimeZone??this._lockedTimeZone??this.getDefaultTimeZone()??E}set timeZone(e){Intl.supportedValuesOf("timeZone").includes(e)||e===E||e===b?this._userTimeZone=e:y.getLogger(this).error("#timeZone",`the parsed value '${e}' is not a valid IANA time zone or the keywords '${E}' and '${b}'`)}get tools(){return this.toolViewManager?.tools}get initialExtent(){return this.defaultsFromMap?.extent}get cursor(){const e=this.toolViewManager?this.toolViewManager.cursor:null;return null!=e?e:this._cursor||"default"}set cursor(e){this._cursor=e,this.notifyChange("cursor")}get size(){return[this.width,this.height]}get effectiveTheme(){return this.theme??new Z}whenLayerView(e){return this.layerViewManager?.whenLayerView(e)??Promise.reject()}getDefaultSpatialReference(){return this.defaultsFromMap?.spatialReference}getDefaultHeightModelInfo(){return(this.map&&"heightModelInfo"in this.map?this.map.heightModelInfo:void 0)??this.defaultsFromMap?.heightModelInfo??null}getDefaultTimeZone(){return null}importLayerView(e){throw new n("importLayerView() not implemented")}hasLayerViewModule(e){return!1}async validate(){}async loadAsyncDependencies(){}invalidate(){this._isValid=!1}getSpatialReferenceSupport(){return{constraints:null}}_validateSpatialReference(e){return null!=this.getSpatialReferenceSupport({spatialReference:e})}when(e,t){return this.isResolved()&&!this.ready&&y.getLogger(this).warn("#when()","Calling view.when() while the view is no longer ready but was already resolved once will resolve immediately. Use reactiveUtils.whenOnce(() => view.ready).then(...) instead."),super.when(e,t)}forceReadyCycle(){this.ready&&(v((()=>this.destroyed||!1===this.preconditionsReady),(()=>this._readyCycleForced=!1),{once:!0}),this._readyCycleForced=!0)}addAndActivateTool(e){this.toolViewManager.tools.add(e),this.activeTool=e}tryFatalErrorRecovery(){this.fatalError=null}};z.views=new o,e([M()],z.prototype,"_userSpatialReference",void 0),e([M()],z.prototype,"activeTool",null),e([M({readOnly:!0})],z.prototype,"allLayerViews",void 0),e([M()],z.prototype,"groundView",void 0),e([M()],z.prototype,"animation",null),e([M()],z.prototype,"basemapView",void 0),e([M()],z.prototype,"center",null),e([M({readOnly:!0})],z.prototype,"_defaultsFromMapSettings",null),e([M()],z.prototype,"defaultsFromMap",null),e([M()],z.prototype,"fatalError",void 0),e([M({type:S})],z.prototype,"extent",null),e([M(_(T,"graphics"))],z.prototype,"graphics",void 0),e([M(_(O,"analyses"))],z.prototype,"analyses",void 0),e([M({readOnly:!0,type:j})],z.prototype,"heightModelInfo",null),e([M({readOnly:!0})],z.prototype,"interacting",null),e([M({readOnly:!0})],z.prototype,"navigating",null),e([M({readOnly:!0,dependsOn:["fatalError","_isValid","_readyCycleForced","map","map.loaded?","width","height","spatialReference","_lockedSpatialReference","defaultsFromMap.ready","typeSpecificPreconditionsReady"]})],z.prototype,"preconditionsReady",null),e([M({readOnly:!0})],z.prototype,"typeSpecificPreconditionsReady",void 0),e([M({type:o,readOnly:!0})],z.prototype,"layerViews",void 0),e([M()],z.prototype,"resolution",null),e([M({type:C})],z.prototype,"magnifier",void 0),e([M({value:null,type:t})],z.prototype,"map",null),e([M()],z.prototype,"padding",void 0),e([M({readOnly:!0})],z.prototype,"ready",void 0),e([M({type:F})],z.prototype,"spatialReference",null),e([M()],z.prototype,"spatialReferenceWarningDelay",void 0),e([M()],z.prototype,"stationary",null),e([M({readOnly:!0})],z.prototype,"supportsGround",void 0),e([M({type:i})],z.prototype,"timeExtent",void 0),e([M({nonNullable:!0})],z.prototype,"timeZone",null),e([M()],z.prototype,"tools",null),e([M()],z.prototype,"toolViewManager",void 0),e([M({readOnly:!0})],z.prototype,"type",void 0),e([M({type:Number})],z.prototype,"scale",void 0),e([M({readOnly:!0})],z.prototype,"updating",void 0),e([M({readOnly:!0})],z.prototype,"initialExtentRequired",void 0),e([M({readOnly:!0})],z.prototype,"initialExtent",null),e([M()],z.prototype,"cursor",null),e([M({readOnly:!0})],z.prototype,"input",void 0),e([M({type:P,nonNullable:!0})],z.prototype,"navigation",void 0),e([M()],z.prototype,"layerViewManager",void 0),e([M()],z.prototype,"analysisViewManager",void 0),e([M()],z.prototype,"width",void 0),e([M()],z.prototype,"height",void 0),e([M({readOnly:!0})],z.prototype,"resizing",void 0),e([M({value:null,readOnly:!0})],z.prototype,"size",null),e([M({readOnly:!0})],z.prototype,"suspended",void 0),e([M({readOnly:!0})],z.prototype,"viewEvents",void 0),e([M({readOnly:!0})],z.prototype,"persistableViewModels",void 0),e([M()],z.prototype,"_isValid",void 0),e([M()],z.prototype,"_readyCycleForced",void 0),e([M()],z.prototype,"_lockedSpatialReference",void 0),e([M()],z.prototype,"_userTimeZone",void 0),e([M()],z.prototype,"_lockedTimeZone",void 0),e([M({type:Z})],z.prototype,"theme",void 0),e([M({readOnly:!0,type:Z})],z.prototype,"effectiveTheme",null),z=q=e([R("esri.views.View")],z);const W=z;function N(e){return e.layerViews}export{W as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Map.js";import i from"../TimeExtent.js";import r from"../core/Accessor.js";import{createTask as a}from"../core/asyncUtils.js";import o from"../core/Collection.js";import s from"../core/CollectionFlattener.js";import n from"../core/Error.js";import l from"../core/Evented.js";import{HandleOwnerMixin as p}from"../core/HandleOwner.js";import{makeHandle as h}from"../core/handleUtils.js";import d from"../core/Loadable.js";import y from"../core/Logger.js";import{destroyMaybe as c,abortMaybe as u}from"../core/maybe.js";import{EsriPromiseMixin as m}from"../core/Promise.js";import{after as f}from"../core/promiseUtils.js";import{watch as g,whenOnce as w,when as v,sync as V}from"../core/reactiveUtils.js";import{property as M}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as R}from"../core/accessorSupport/decorators/subclass.js";import{owningCollectionProperty as _}from"../core/support/OwningCollection.js";import S from"../geometry/Extent.js";import j from"../geometry/HeightModelInfo.js";import F from"../geometry/SpatialReference.js";import{equals as L}from"../geometry/support/spatialReferenceUtils.js";import{AnalysesCollection as O}from"../support/AnalysesCollection.js";import{GraphicsCollection as T}from"../support/GraphicsCollection.js";import{SYSTEM as E,UNKNOWN as b}from"../time/timeZoneUtils.js";import{BasemapView as k}from"./BasemapView.js";import x from"./LayerViewManager.js";import C from"./Magnifier.js";import Z from"./Theme.js";import{ToolViewManager as I}from"./ToolViewManager.js";import D from"./input/Input.js";import{ViewEvents as A}from"./input/ViewEvents.js";import P from"./navigation/Navigation.js";import{DefaultsFromMap as U}from"./support/DefaultsFromMap.js";var q;let z=q=class extends(p(l.EventedMixin(m(r)))){constructor(e){super(e),this._userSpatialReference=null,this._cursor=null,this.allLayerViews=new s({getCollections:()=>[this.basemapView?.baseLayerViews,this.groundView?.layerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:N}),this.groundView=null,this.basemapView=null,this.fatalError=null,this.graphics=new T,this.analyses=new O,this.typeSpecificPreconditionsReady=!0,this.layerViews=new o,this.magnifier=new C,this.padding={left:0,top:0,right:0,bottom:0},this.ready=!1,this.spatialReferenceWarningDelay=1e3,this.supportsGround=!0,this.timeExtent=null,this.type=null,this.scale=null,this.updating=!1,this.initialExtentRequired=!0,this.input=new D,this.navigation=new P,this.layerViewManager=null,this.analysisViewManager=null,this.isHeightModelInfoRequired=!1,this.width=null,this.height=null,this.resizing=!1,this.suspended=!1,this.viewEvents=new A(this),this.persistableViewModels=new o,this._isValid=!1,this._readyCycleForced=!1,this._lockedSpatialReference=null,this._userTimeZone=null,this._lockedTimeZone=null,this.theme=null,this.handles.add(g((()=>this.preconditionsReady),(e=>{e?(this._lockedSpatialReference=this.spatialReference,this._lockedTimeZone=this.timeZone,q.views.add(this)):(this._lockedSpatialReference=null,q.views.remove(this)),this.notifyChange("spatialReference"),!e&&this.ready?(this.toolViewManager?.detach(),null!=this.analysisViewManager&&this.analysisViewManager.detach(),this.layerViewManager?.clear(),this._teardown()):e&&!this.ready&&(this._startup(),null!=this.analysisViewManager&&this.analysisViewManager.attach(),this.toolViewManager.attach())}),V))}initialize(){this.addResolvingPromise(Promise.all([this.loadAsyncDependencies(),this.validate()]).then((()=>(this._isValid=!0,w((()=>this.ready)))))),this.basemapView=new k({view:this}),this.layerViewManager=new x({view:this,layerViewImporter:{importLayerView:e=>this.importLayerView(e),hasLayerViewModule:e=>this.hasLayerViewModule(e)},supportsGround:this.supportsGround}),this.toolViewManager=new I({view:this}),this._setupSpatialReferenceLogger(),this.handles.add([g((()=>this.initialExtentRequired),(e=>this.defaultsFromMap.required={...this.defaultsFromMap.required,extent:e}),{sync:!0,initial:!0}),g((()=>this.ready),(e=>{this.defaultsFromMap&&(this.defaultsFromMap.suspended=e,this.defaultsFromMap.userSpatialReference=e?this.spatialReference:this._userSpatialReference)}),{sync:!0}),g((()=>this._userSpatialReference),(e=>{this.defaultsFromMap&&(this.defaultsFromMap.userSpatialReference=e)}),{sync:!0,initial:!0})])}_setupSpatialReferenceLogger(){let e=null;this.handles.add([g((()=>this.defaultsFromMap?.ready),(t=>{const i=this.map?.allLayers.length>0;if(t&&!this.spatialReference&&i){if(null!=e)return;const t=h((()=>e=u(e)));e=a((async t=>{try{await f(this.spatialReferenceWarningDelay,null,t)}catch{return}finally{e=null}y.getLogger(this).warn("#spatialReference","no spatial reference could be derived from the currently added map layers")})),this.handles.add(t,"spatial-reference-logger-task")}else this.handles.remove("spatial-reference-logger-task")}),{sync:!0})])}destroy(){this.destroyed||(q.views.remove(this),this.viewEvents.destroy(),this.allLayerViews.destroy(),this.navigation&&(this.navigation.destroy(),this._set("navigation",null)),this.graphics=c(this.graphics),this.analyses=c(this.analyses),this.handles.remove("defaultsFromMap"),this.defaultsFromMap.destroy(),this._set("defaultsFromMap",null),c(this.analysisViewManager),this.toolViewManager=c(this.toolViewManager),this.layerViewManager=c(this.layerViewManager),this.basemapView=c(this.basemapView),this.groundView?.destroy(),this.layerViews?.forEach((e=>e.destroy())),this.layerViews.length=0,this.invalidate(),this._emitter.clear(),this.handles.removeAll(),this.map=c(this.map))}_startup(){this._set("ready",!0)}_teardown(){this._set("ready",!1)}whenReady(){return Promise.resolve(this)}toMap(){return y.getLogger(this).error("#toMap()","Not implemented on this instance of View"),null}get activeTool(){return this.toolViewManager?.activeTool}set activeTool(e){this.toolViewManager&&(this.toolViewManager.activeTool=e)}get animation(){return this._get("animation")}set animation(e){this._set("animation",e)}get center(){return null}get _defaultsFromMapSettings(){return{}}get defaultsFromMap(){return new U({required:{tileInfo:!1,heightModelInfo:!1,extent:!1},map:()=>this.map,getSpatialReferenceSupport:e=>this.getSpatialReferenceSupport(e),...this._defaultsFromMapSettings})}get extent(){return this._get("extent")}set extent(e){this._set("extent",e)}get heightModelInfo(){return this.getDefaultHeightModelInfo()}get interacting(){return this.navigating}get navigating(){return!1}get preconditionsReady(){return!(this.fatalError||!this._isValid||this._readyCycleForced||!this.map||d.isLoadable(this.map)&&!this.map.loaded||0===this.width||0===this.height||!this.spatialReference||!this._validateSpatialReference(this.spatialReference)||!this._lockedSpatialReference&&!this.defaultsFromMap?.ready||!this.typeSpecificPreconditionsReady)}get resolution(){return 0}set map(e){e!==this._get("map")&&(e?.destroyed&&(y.getLogger(this).warn("#map","The provided map is already destroyed",{map:e}),e=null),d.isLoadable(e)&&e.load().catch((()=>{})),this.constructed&&!this.destroyed&&(this.forceReadyCycle(),this._lockedSpatialReference=null),this._set("map",e))}get spatialReference(){let e=this._userSpatialReference||this._lockedSpatialReference||this.getDefaultSpatialReference()||null;return e&&this.defaultsFromMap?.required?.heightModelInfo&&(e=e.clone(),e.vcsWkid=this.defaultsFromMap.vcsWkid,e.latestVcsWkid=this.defaultsFromMap.latestVcsWkid),e}set spatialReference(e){const t=!L(e,this._get("spatialReference"));this._set("_userSpatialReference",e),t&&(this._set("spatialReference",e),this._spatialReferenceChanged(e))}_spatialReferenceChanged(e){}get stationary(){return!this.animation&&!this.navigating&&!this.resizing}get timeZone(){return this._userTimeZone??this._lockedTimeZone??this.getDefaultTimeZone()??E}set timeZone(e){Intl.supportedValuesOf("timeZone").includes(e)||e===E||e===b?this._userTimeZone=e:y.getLogger(this).error("#timeZone",`the parsed value '${e}' is not a valid IANA time zone or the keywords '${E}' and '${b}'`)}get tools(){return this.toolViewManager?.tools}get initialExtent(){return this.defaultsFromMap?.extent}get cursor(){return this.toolViewManager?.cursor??this._cursor??"default"}set cursor(e){this._cursor=e,this.notifyChange("cursor")}get size(){return[this.width,this.height]}get effectiveTheme(){return this.theme??new Z}whenLayerView(e){return this.layerViewManager?.whenLayerView(e)??Promise.reject()}getDefaultSpatialReference(){return this.defaultsFromMap?.spatialReference}getDefaultHeightModelInfo(){return(this.map&&"heightModelInfo"in this.map?this.map.heightModelInfo:void 0)??this.defaultsFromMap?.heightModelInfo??null}getDefaultTimeZone(){return null}importLayerView(e){throw new n("importLayerView() not implemented")}hasLayerViewModule(e){return!1}async validate(){}async loadAsyncDependencies(){}invalidate(){this._isValid=!1}getSpatialReferenceSupport(){return{constraints:null}}_validateSpatialReference(e){return null!=this.getSpatialReferenceSupport({spatialReference:e})}when(e,t){return this.isResolved()&&!this.ready&&y.getLogger(this).warn("#when()","Calling view.when() while the view is no longer ready but was already resolved once will resolve immediately. Use reactiveUtils.whenOnce(() => view.ready).then(...) instead."),super.when(e,t)}forceReadyCycle(){this.ready&&(v((()=>this.destroyed||!1===this.preconditionsReady),(()=>this._readyCycleForced=!1),{once:!0}),this._readyCycleForced=!0)}addAndActivateTool(e){this.toolViewManager.tools.add(e),this.activeTool=e}tryFatalErrorRecovery(){this.fatalError=null}};z.views=new o,e([M()],z.prototype,"_userSpatialReference",void 0),e([M()],z.prototype,"activeTool",null),e([M({readOnly:!0})],z.prototype,"allLayerViews",void 0),e([M()],z.prototype,"groundView",void 0),e([M()],z.prototype,"animation",null),e([M()],z.prototype,"basemapView",void 0),e([M()],z.prototype,"center",null),e([M({readOnly:!0})],z.prototype,"_defaultsFromMapSettings",null),e([M()],z.prototype,"defaultsFromMap",null),e([M()],z.prototype,"fatalError",void 0),e([M({type:S})],z.prototype,"extent",null),e([M(_(T,"graphics"))],z.prototype,"graphics",void 0),e([M(_(O,"analyses"))],z.prototype,"analyses",void 0),e([M({readOnly:!0,type:j})],z.prototype,"heightModelInfo",null),e([M({readOnly:!0})],z.prototype,"interacting",null),e([M({readOnly:!0})],z.prototype,"navigating",null),e([M({readOnly:!0,dependsOn:["fatalError","_isValid","_readyCycleForced","map","map.loaded?","width","height","spatialReference","_lockedSpatialReference","defaultsFromMap.ready","typeSpecificPreconditionsReady"]})],z.prototype,"preconditionsReady",null),e([M({readOnly:!0})],z.prototype,"typeSpecificPreconditionsReady",void 0),e([M({type:o,readOnly:!0})],z.prototype,"layerViews",void 0),e([M()],z.prototype,"resolution",null),e([M({type:C})],z.prototype,"magnifier",void 0),e([M({value:null,type:t})],z.prototype,"map",null),e([M()],z.prototype,"padding",void 0),e([M({readOnly:!0})],z.prototype,"ready",void 0),e([M({type:F})],z.prototype,"spatialReference",null),e([M()],z.prototype,"spatialReferenceWarningDelay",void 0),e([M()],z.prototype,"stationary",null),e([M({readOnly:!0})],z.prototype,"supportsGround",void 0),e([M({type:i})],z.prototype,"timeExtent",void 0),e([M({nonNullable:!0})],z.prototype,"timeZone",null),e([M()],z.prototype,"tools",null),e([M()],z.prototype,"toolViewManager",void 0),e([M({readOnly:!0})],z.prototype,"type",void 0),e([M({type:Number})],z.prototype,"scale",void 0),e([M({readOnly:!0})],z.prototype,"updating",void 0),e([M({readOnly:!0})],z.prototype,"initialExtentRequired",void 0),e([M({readOnly:!0})],z.prototype,"initialExtent",null),e([M()],z.prototype,"cursor",null),e([M({readOnly:!0})],z.prototype,"input",void 0),e([M({type:P,nonNullable:!0})],z.prototype,"navigation",void 0),e([M()],z.prototype,"layerViewManager",void 0),e([M()],z.prototype,"analysisViewManager",void 0),e([M()],z.prototype,"width",void 0),e([M()],z.prototype,"height",void 0),e([M({readOnly:!0})],z.prototype,"resizing",void 0),e([M({value:null,readOnly:!0})],z.prototype,"size",null),e([M({readOnly:!0})],z.prototype,"suspended",void 0),e([M({readOnly:!0})],z.prototype,"viewEvents",void 0),e([M({readOnly:!0})],z.prototype,"persistableViewModels",void 0),e([M()],z.prototype,"_isValid",void 0),e([M()],z.prototype,"_readyCycleForced",void 0),e([M()],z.prototype,"_lockedSpatialReference",void 0),e([M()],z.prototype,"_userTimeZone",void 0),e([M()],z.prototype,"_lockedTimeZone",void 0),e([M({type:Z})],z.prototype,"theme",void 0),e([M({readOnly:!0,type:Z})],z.prototype,"effectiveTheme",null),z=q=e([R("esri.views.View")],z);const W=z;function N(e){return e.layerViews}export{W 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.28/esri/copyright.txt for details.
4
4
  */
5
- function t(t){return t}const u=t=>t*t,o=t=>1-u(1-t),i=t=>t<.5?u(2*t)/2:(o(2*(t-.5))+1)/2,n=t=>t*t*t,c=t=>1-n(1-t),a=t=>t<.5?n(2*t)/2:(c(2*(t-.5))+1)/2,s=t=>t*t*t*t,q=t=>1-s(1-t),r=t=>t<.5?s(2*t)/2:(q(2*(t-.5))+1)/2,e=t=>t*t*t*t*t,b=t=>1-e(1-t),d=t=>t<.5?e(2*t)/2:(b(2*(t-.5))+1)/2,h=t=>1-Math.cos(t*Math.PI/2),p=t=>1-h(1-t),x=t=>t<.5?h(2*t)/2:(p(2*(t-.5))+1)/2,M=t=>2**(10*(t-1)),f=t=>1-M(1-t),l=t=>t<.5?M(2*t)/2:(f(2*(t-.5))+1)/2,I=t=>-(Math.sqrt(1-t*t)-1),P=t=>1-I(1-t),g=t=>t<.5?I(2*t)/2:(P(2*(t-.5))+1)/2;function j(t){const u=2*(t-Math.sqrt((t-1)*t)),o=u/2/t;return i=>i<o?t*i*i:u*i-u+1}function k(t,u){return(o,i)=>o<u?u*t(o/u,i):1-t((1-o)/(1-u),i)*(1-u)}const m=k(j(1),1),v=k(j(1),0),w=k(j(1),.5),y=k(j(2),1),z=k(j(2),0),A=k(j(2),.5),B=k(j(3),1),C=k(j(3),0),D=k(j(3),.5),E=k(j(4),1),F=k(j(4),0),G=k(j(4),.5),H={linear:t,"in-quad":u,"out-quad":o,"in-out-quad":i,"in-coast-quad":m,"out-coast-quad":v,"in-out-coast-quad":w,"in-cubic":n,"out-cubic":c,"in-out-cubic":a,"in-coast-cubic":y,"out-coast-cubic":z,"in-out-coast-cubic":A,"in-quart":s,"out-quart":q,"in-out-quart":r,"in-coast-quart":B,"out-coast-quart":C,"in-out-coast-quart":D,"in-quint":e,"out-quint":b,"in-out-quint":d,"in-coast-quint":E,"out-coast-quint":F,"in-out-coast-quint":G,"in-sine":h,"out-sine":p,"in-out-sine":x,"in-expo":M,"out-expo":f,"in-out-expo":l,"in-circ":I,"out-circ":P,"in-out-circ":g};export{H as EasingFunctions,I as inCirc,y as inCoastCubic,m as inCoastQuad,B as inCoastQuart,E as inCoastQuint,n as inCubic,M as inExpo,g as inOutCirc,A as inOutCoastCubic,w as inOutCoastQuad,D as inOutCoastQuart,G as inOutCoastQuint,a as inOutCubic,l as inOutExpo,i as inOutQuad,r as inOutQuart,d as inOutQuint,x as inOutSine,u as inQuad,s as inQuart,e as inQuint,h as inSine,t as linear,P as outCirc,z as outCoastCubic,v as outCoastQuad,C as outCoastQuart,F as outCoastQuint,c as outCubic,f as outExpo,o as outQuad,q as outQuart,b as outQuint,p as outSine};
5
+ const t=t=>t,u=t=>t*t,o=t=>1-u(1-t),i=t=>t<.5?u(2*t)/2:(o(2*(t-.5))+1)/2,n=t=>t*t*t,c=t=>1-n(1-t),a=t=>t<.5?n(2*t)/2:(c(2*(t-.5))+1)/2,s=t=>t*t*t*t,q=t=>1-s(1-t),r=t=>t<.5?s(2*t)/2:(q(2*(t-.5))+1)/2,e=t=>t*t*t*t*t,b=t=>1-e(1-t),d=t=>t<.5?e(2*t)/2:(b(2*(t-.5))+1)/2,h=t=>1-Math.cos(t*Math.PI/2),p=t=>1-h(1-t),x=t=>t<.5?h(2*t)/2:(p(2*(t-.5))+1)/2,M=t=>2**(10*(t-1)),f=t=>1-M(1-t),l=t=>t<.5?M(2*t)/2:(f(2*(t-.5))+1)/2,I=t=>-(Math.sqrt(1-t*t)-1),P=t=>1-I(1-t),g=t=>t<.5?I(2*t)/2:(P(2*(t-.5))+1)/2;function j(t){const u=2*(t-Math.sqrt((t-1)*t)),o=u/2/t;return i=>i<o?t*i*i:u*i-u+1}function k(t,u){return(o,i)=>o<u?u*t(o/u,i):1-t((1-o)/(1-u),i)*(1-u)}const m=k(j(1),1),v=k(j(1),0),w=k(j(1),.5),y=k(j(2),1),z=k(j(2),0),A=k(j(2),.5),B=k(j(3),1),C=k(j(3),0),D=k(j(3),.5),E=k(j(4),1),F=k(j(4),0),G=k(j(4),.5),H={linear:t,"in-quad":u,"out-quad":o,"in-out-quad":i,"in-coast-quad":m,"out-coast-quad":v,"in-out-coast-quad":w,"in-cubic":n,"out-cubic":c,"in-out-cubic":a,"in-coast-cubic":y,"out-coast-cubic":z,"in-out-coast-cubic":A,"in-quart":s,"out-quart":q,"in-out-quart":r,"in-coast-quart":B,"out-coast-quart":C,"in-out-coast-quart":D,"in-quint":e,"out-quint":b,"in-out-quint":d,"in-coast-quint":E,"out-coast-quint":F,"in-out-coast-quint":G,"in-sine":h,"out-sine":p,"in-out-sine":x,"in-expo":M,"out-expo":f,"in-out-expo":l,"in-circ":I,"out-circ":P,"in-out-circ":g};export{H as EasingFunctions,I as inCirc,y as inCoastCubic,m as inCoastQuad,B as inCoastQuart,E as inCoastQuint,n as inCubic,M as inExpo,g as inOutCirc,A as inOutCoastCubic,w as inOutCoastQuad,D as inOutCoastQuart,G as inOutCoastQuint,a as inOutCubic,l as inOutExpo,i as inOutQuad,r as inOutQuart,d as inOutQuint,x as inOutSine,u as inQuad,s as inQuart,e as inQuint,h as inSine,t as linear,P as outCirc,z as outCoastCubic,v as outCoastQuad,C as outCoastQuart,F as outCoastQuint,c as outCubic,f as outExpo,o as outQuad,q as outQuart,b as outQuint,p as outSine};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../core/has.js";import t from"../../core/Logger.js";import{disposeMaybe as e}from"../../core/maybe.js";import{BufferObject as i}from"./BufferObject.js";import{webglDebugEnabled as r}from"./checkWebGLError.js";import{ContextType as s}from"./contextUtils.js";import{ResourceType as h,ColorAttachment as n,PixelFormat as o,PixelType as c,DepthStencilAttachment as a,FramebufferTarget as u,TextureType as _,Usage as l,BufferType as f,RenderbufferFormat as T}from"./enums.js";import{GLObjectType as d}from"./GLObjectType.js";import{Renderbuffer as m}from"./Renderbuffer.js";import{Texture as p}from"./Texture.js";const x=t.getLogger("esri.views.webgl.FramebufferObject");class E{constructor(t,e,i=null){this._context=t,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,this._initialized=!1,t.instanceCounter.increment(h.FramebufferObject,this);const r=g(e)?e:new p(this._context,e);if(this._colorAttachments.set(n.COLOR_ATTACHMENT0,r),this._validateTextureDescriptor(r.descriptor),this._validateColorAttachmentPoint(n.COLOR_ATTACHMENT0),null!=i)if(b(i))this._context.capabilities.depthTexture||console.error("Setting the depth/stencil texture as an attachment requires WEBGL_depth_texture or WebGL2"),this._depthStencilTexture=g(i)?i:new p(this._context,i),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=A(i)?i:new m(this._context,i);this._depthStencilBuffer=t,this._validateRenderBufferDescriptor(t.descriptor)}}dispose(){if(0===this._colorAttachments.size&&!this._glName)return;const t=this._context.getBoundFramebufferObject();if(this._colorAttachments.forEach(((t,e)=>this.detachColorTexture(e)?.dispose())),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),this._glName){this._context.gl.deleteFramebuffer(this._glName),this._glName=null}this._context.bindFramebuffer(t),this._context.instanceCounter.decrement(h.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(n.COLOR_ATTACHMENT0)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(n.COLOR_ATTACHMENT0);return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(n.COLOR_ATTACHMENT0);return t?.descriptor?.height??0}get gpuMemoryUsage(){return[...this._colorAttachments].reduce(((t,[e,i])=>t+i.gpuMemoryUsage),this.depthStencil?.gpuMemoryUsage??0)}getColorTexture(t){const e=this._colorAttachments.get(t);return e&&g(e)?e:null}attachColorTexture(t,e=n.COLOR_ATTACHMENT0){if(!t)return;this._validateColorAttachmentPoint(e);const i=t.descriptor;this._validateTextureDescriptor(i),this.detachColorTexture(e)?.dispose(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,e)),this._colorAttachments.set(e,t)}detachColorTexture(t=n.COLOR_ATTACHMENT0){const e=this._colorAttachments.get(t);if(e)return this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t)),this._colorAttachments.delete(t),e}setColorTextureTarget(t,e=n.COLOR_ATTACHMENT0){const i=this._colorAttachments.get(e);i&&this._framebufferTexture2D(i.glName,e,t)}attachDepthStencil(t){if(t)switch(t.type){case d.Texture:return this._attachDepthStencilTexture(t);case d.RenderBuffer:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const e=t.descriptor;e.pixelFormat!==o.DEPTH_STENCIL&&e.pixelFormat!==o.DEPTH24_STENCIL8&&console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"),e.dataType!==c.UNSIGNED_INT_24_8&&console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"),this._context.capabilities.depthTexture||console.error("Extension WEBGL_depth_texture isn't supported therefore it is no possible to set the depth/stencil texture!"),this._validateTextureDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,a)),this._depthStencilTexture?.dispose(),this._depthStencilTexture=t}detachDepthStencilTexture(){const t=this._depthStencilTexture;return t&&this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,a)),this._depthStencilTexture=null,t}_attachDepthStencilBuffer(t){if(null==t)return;const e=t.descriptor;if(this._validateRenderBufferDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized){this._context.bindFramebuffer(this);const i=this._context.gl,r=this._getGLAttachmentPoint(e);i.framebufferRenderbuffer(u.FRAMEBUFFER,r,i.RENDERBUFFER,t.glName)}this._depthStencilBuffer?.dispose(),this._depthStencilBuffer=t}detachDepthStencilBuffer(){const t=this._depthStencilBuffer;if(t&&this._initialized){this._context.bindFramebuffer(this);const e=this._context.gl,i=this._getGLAttachmentPoint(t.descriptor);e.framebufferRenderbuffer(u.FRAMEBUFFER,i,e.RENDERBUFFER,null)}return this._depthStencilBuffer=null,t}copyToTexture(t,e,i,r,s,h,n){(t<0||e<0||s<0||h<0)&&console.error("Offsets cannot be negative!"),(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!");const o=n.descriptor;n.descriptor.target!==_.TEXTURE_2D&&console.error("Texture target must be TEXTURE_2D!"),(null==o?.width||null==o?.height||t+i>this.width||e+r>this.height||s+i>o.width||h+r>o.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const c=this._context,a=c.bindTexture(n,p.TEXTURE_UNIT_FOR_UPDATES);c.setActiveTexture(p.TEXTURE_UNIT_FOR_UPDATES),c.bindFramebuffer(this),c.gl.copyTexSubImage2D(_.TEXTURE_2D,0,s,h,t,e,i,r),c.bindTexture(a,p.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,i,r,s,h,n){(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!"),n||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(t,e,i,r,s,h,n)}async readPixelsAsync(t,e,h,n,o,c,a){if(this._context.type!==s.WEBGL2)return r()&&console.warn("Attempting to read pixels using pixel buffer object without WebGL2"),void this.readPixels(t,e,h,n,o,c,a);const u=this._context.gl,_=i.createPixelPack(this._context,l.STREAM_READ,a.byteLength);this._context.bindBuffer(_),this._context.bindFramebuffer(this),u.readPixels(t,e,h,n,o,c,0),this._context.unbindBuffer(f.PIXEL_PACK_BUFFER),await _.getSubDataAsync(a),_.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const i={width:t,height:e};S(i,this._context.parameters.maxTextureSize),this._colorAttachments.forEach((t=>t.resize(i.width,i.height))),this._depthStencilTexture?.resize(i.width,i.height),this._initialized&&(S(i,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(i.width,i.height),this._context.getBoundFramebufferObject()===this&&this._context.bindFramebuffer(null),this._initialized=!1)}initializeAndBind(t=u.FRAMEBUFFER){const e=this._context.gl;if(this._initialized)return void e.bindFramebuffer(t,this.glName);this._glName&&e.deleteFramebuffer(this._glName);const i=e.createFramebuffer();e.bindFramebuffer(t,i),this._colorAttachments.forEach(((e,i)=>this._framebufferTexture2D(e.glName,i,R(e),t)));const s=this._depthStencilBuffer;if(s){const i=this._getGLAttachmentPoint(s.descriptor);e.framebufferRenderbuffer(t,i,e.RENDERBUFFER,s.glName)}else this._depthStencilTexture&&this._framebufferTexture2D(this._depthStencilTexture.glName,e.DEPTH_STENCIL_ATTACHMENT,R(this._depthStencilTexture),t);if(r()){e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!")}this._glName=i,this._initialized=!0}_framebufferTexture2D(t,e=n.COLOR_ATTACHMENT0,i=_.TEXTURE_2D,r=u.FRAMEBUFFER,s=0){this._context.gl.framebufferTexture2D(r,e,i,t,s)}_disposeDepthStencilAttachments(){const t=this._context.gl;if(this._depthStencilBuffer){if(this._initialized){this._context.bindFramebuffer(this);const e=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(u.FRAMEBUFFER,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=e(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t.DEPTH_STENCIL_ATTACHMENT)),this._depthStencilTexture=e(this._depthStencilTexture))}_validateTextureDescriptor(t){t.target!==_.TEXTURE_2D&&t.target!==_.TEXTURE_CUBE_MAP&&console.error("Texture type must be TEXTURE_2D or TEXTURE_CUBE_MAP!"),S(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderBufferDescriptor(t){S(t,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(t)}_validateBufferDimensions(t){t.width<=0&&(t.width=this.width),t.height<=0&&(t.height=this.height),this.width>0&&this.height>0&&(this.width===t.width&&this.height===t.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(t){switch(t.internalFormat){case T.DEPTH_COMPONENT16:case T.DEPTH_COMPONENT24:case T.DEPTH_COMPONENT32F:return this._context.gl.DEPTH_ATTACHMENT;case T.DEPTH24_STENCIL8:case T.DEPTH32F_STENCIL8:case T.DEPTH_STENCIL:return this._context.gl.DEPTH_STENCIL_ATTACHMENT;case T.STENCIL_INDEX8:return this._context.gl.STENCIL_ATTACHMENT}}_validateColorAttachmentPoint(e){if(-1===E._MAX_COLOR_ATTACHMENTS){const t=this._context.capabilities.drawBuffers;if(t){const e=this._context.gl;E._MAX_COLOR_ATTACHMENTS=e.getParameter(t.MAX_COLOR_ATTACHMENTS)}else E._MAX_COLOR_ATTACHMENTS=1}const i=e-n.COLOR_ATTACHMENT0;i+1>E._MAX_COLOR_ATTACHMENTS&&t.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${i+1}. Implementation supports up to ${E._MAX_COLOR_ATTACHMENTS} color attachments`)}}function g(t){return null!=t&&"type"in t&&t.type===d.Texture}function A(t){return null!=t&&"type"in t&&t.type===d.RenderBuffer}function b(t){return g(t)||null!=t&&"pixelFormat"in t}function S(t,e){const i=Math.max(t.width,t.height);if(i>e){x.warn(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const r=e/i;return t.width=Math.round(t.width*r),t.height=Math.round(t.height*r),!1}return!0}function R(t){return t.descriptor.target===_.TEXTURE_CUBE_MAP?_.TEXTURE_CUBE_MAP_POSITIVE_X:_.TEXTURE_2D}E._MAX_COLOR_ATTACHMENTS=-1;export{E as FramebufferObject,S as ensureAttachmentMaxSize};
5
+ import"../../core/has.js";import t from"../../core/Logger.js";import{disposeMaybe as e}from"../../core/maybe.js";import{BufferObject as i}from"./BufferObject.js";import{webglDebugEnabled as r}from"./checkWebGLError.js";import{ContextType as s}from"./contextUtils.js";import{ResourceType as h,ColorAttachment as n,PixelFormat as o,PixelType as c,DepthStencilAttachment as a,FramebufferTarget as u,TextureType as _,Usage as l,BufferType as f,RenderbufferFormat as T}from"./enums.js";import{GLObjectType as d}from"./GLObjectType.js";import{Renderbuffer as m}from"./Renderbuffer.js";import{Texture as p}from"./Texture.js";const x=t.getLogger("esri.views.webgl.FramebufferObject");class E{constructor(t,e,i=null){this._context=t,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,this._initialized=!1,t.instanceCounter.increment(h.FramebufferObject,this);const r=g(e)?e:new p(this._context,e);if(this._colorAttachments.set(n.COLOR_ATTACHMENT0,r),this._validateTextureDescriptor(r.descriptor),this._validateColorAttachmentPoint(n.COLOR_ATTACHMENT0),null!=i)if(b(i))this._context.capabilities.depthTexture||console.error("Setting the depth/stencil texture as an attachment requires WEBGL_depth_texture or WebGL2"),this._depthStencilTexture=g(i)?i:new p(this._context,i),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=A(i)?i:new m(this._context,i);this._depthStencilBuffer=t,this._validateRenderBufferDescriptor(t.descriptor)}}dispose(){if(0===this._colorAttachments.size&&!this._glName)return;const t=this._context.getBoundFramebufferObject();if(this._colorAttachments.forEach(((t,e)=>this.detachColorTexture(e)?.dispose())),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),this._glName){this._context.gl.deleteFramebuffer(this._glName),this._glName=null}this._context.bindFramebuffer(t),this._context.instanceCounter.decrement(h.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(n.COLOR_ATTACHMENT0)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(n.COLOR_ATTACHMENT0);return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(n.COLOR_ATTACHMENT0);return t?.descriptor?.height??0}get gpuMemoryUsage(){return[...this._colorAttachments].reduce(((t,[e,i])=>t+i.gpuMemoryUsage),this.depthStencil?.gpuMemoryUsage??0)}getColorTexture(t){const e=this._colorAttachments.get(t);return e&&g(e)?e:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(t,e=n.COLOR_ATTACHMENT0){if(!t)return;this._validateColorAttachmentPoint(e);const i=t.descriptor;this._validateTextureDescriptor(i),this.detachColorTexture(e)?.dispose(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,e)),this._colorAttachments.set(e,t)}detachColorTexture(t=n.COLOR_ATTACHMENT0){const e=this._colorAttachments.get(t);if(e)return this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t)),this._colorAttachments.delete(t),e}setColorTextureTarget(t,e=n.COLOR_ATTACHMENT0){const i=this._colorAttachments.get(e);i&&this._framebufferTexture2D(i.glName,e,t)}attachDepthStencil(t){if(t)switch(t.type){case d.Texture:return this._attachDepthStencilTexture(t);case d.RenderBuffer:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const e=t.descriptor;e.pixelFormat!==o.DEPTH_STENCIL&&e.pixelFormat!==o.DEPTH24_STENCIL8&&console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"),e.dataType!==c.UNSIGNED_INT_24_8&&console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"),this._context.capabilities.depthTexture||console.error("Extension WEBGL_depth_texture isn't supported therefore it is no possible to set the depth/stencil texture!"),this._validateTextureDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,a)),this._depthStencilTexture?.dispose(),this._depthStencilTexture=t}detachDepthStencilTexture(){const t=this._depthStencilTexture;return t&&this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,a)),this._depthStencilTexture=null,t}_attachDepthStencilBuffer(t){if(null==t)return;const e=t.descriptor;if(this._validateRenderBufferDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized){this._context.bindFramebuffer(this);const i=this._context.gl,r=this._getGLAttachmentPoint(e);i.framebufferRenderbuffer(u.FRAMEBUFFER,r,i.RENDERBUFFER,t.glName)}this._depthStencilBuffer?.dispose(),this._depthStencilBuffer=t}detachDepthStencilBuffer(){const t=this._depthStencilBuffer;if(t&&this._initialized){this._context.bindFramebuffer(this);const e=this._context.gl,i=this._getGLAttachmentPoint(t.descriptor);e.framebufferRenderbuffer(u.FRAMEBUFFER,i,e.RENDERBUFFER,null)}return this._depthStencilBuffer=null,t}copyToTexture(t,e,i,r,s,h,n){(t<0||e<0||s<0||h<0)&&console.error("Offsets cannot be negative!"),(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!");const o=n.descriptor;n.descriptor.target!==_.TEXTURE_2D&&console.error("Texture target must be TEXTURE_2D!"),(null==o?.width||null==o?.height||t+i>this.width||e+r>this.height||s+i>o.width||h+r>o.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const c=this._context,a=c.bindTexture(n,p.TEXTURE_UNIT_FOR_UPDATES);c.setActiveTexture(p.TEXTURE_UNIT_FOR_UPDATES),c.bindFramebuffer(this),c.gl.copyTexSubImage2D(_.TEXTURE_2D,0,s,h,t,e,i,r),c.bindTexture(a,p.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,i,r,s,h,n){(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!"),n||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(t,e,i,r,s,h,n)}async readPixelsAsync(t,e,h,n,o,c,a){if(this._context.type!==s.WEBGL2)return r()&&console.warn("Attempting to read pixels using pixel buffer object without WebGL2"),void this.readPixels(t,e,h,n,o,c,a);const u=this._context.gl,_=i.createPixelPack(this._context,l.STREAM_READ,a.byteLength);this._context.bindBuffer(_),this._context.bindFramebuffer(this),u.readPixels(t,e,h,n,o,c,0),this._context.unbindBuffer(f.PIXEL_PACK_BUFFER),await _.getSubDataAsync(a),_.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const i={width:t,height:e};S(i,this._context.parameters.maxTextureSize),this._colorAttachments.forEach((t=>t.resize(i.width,i.height))),this._depthStencilTexture?.resize(i.width,i.height),this._initialized&&(S(i,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(i.width,i.height),this._context.getBoundFramebufferObject()===this&&this._context.bindFramebuffer(null),this._initialized=!1)}initializeAndBind(t=u.FRAMEBUFFER){const e=this._context.gl;if(this._initialized)return void e.bindFramebuffer(t,this.glName);this._glName&&e.deleteFramebuffer(this._glName);const i=e.createFramebuffer();e.bindFramebuffer(t,i),this._colorAttachments.forEach(((e,i)=>this._framebufferTexture2D(e.glName,i,R(e),t)));const s=this._depthStencilBuffer;if(s){const i=this._getGLAttachmentPoint(s.descriptor);e.framebufferRenderbuffer(t,i,e.RENDERBUFFER,s.glName)}else this._depthStencilTexture&&this._framebufferTexture2D(this._depthStencilTexture.glName,e.DEPTH_STENCIL_ATTACHMENT,R(this._depthStencilTexture),t);if(r()){e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!")}this._glName=i,this._initialized=!0}_framebufferTexture2D(t,e=n.COLOR_ATTACHMENT0,i=_.TEXTURE_2D,r=u.FRAMEBUFFER,s=0){this._context.gl.framebufferTexture2D(r,e,i,t,s)}_disposeDepthStencilAttachments(){const t=this._context.gl;if(this._depthStencilBuffer){if(this._initialized){this._context.bindFramebuffer(this);const e=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(u.FRAMEBUFFER,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=e(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t.DEPTH_STENCIL_ATTACHMENT)),this._depthStencilTexture=e(this._depthStencilTexture))}_validateTextureDescriptor(t){t.target!==_.TEXTURE_2D&&t.target!==_.TEXTURE_CUBE_MAP&&console.error("Texture type must be TEXTURE_2D or TEXTURE_CUBE_MAP!"),S(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderBufferDescriptor(t){S(t,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(t)}_validateBufferDimensions(t){t.width<=0&&(t.width=this.width),t.height<=0&&(t.height=this.height),this.width>0&&this.height>0&&(this.width===t.width&&this.height===t.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(t){switch(t.internalFormat){case T.DEPTH_COMPONENT16:case T.DEPTH_COMPONENT24:case T.DEPTH_COMPONENT32F:return this._context.gl.DEPTH_ATTACHMENT;case T.DEPTH24_STENCIL8:case T.DEPTH32F_STENCIL8:case T.DEPTH_STENCIL:return this._context.gl.DEPTH_STENCIL_ATTACHMENT;case T.STENCIL_INDEX8:return this._context.gl.STENCIL_ATTACHMENT}}_validateColorAttachmentPoint(e){if(-1===E._MAX_COLOR_ATTACHMENTS){const t=this._context.capabilities.drawBuffers;if(t){const e=this._context.gl;E._MAX_COLOR_ATTACHMENTS=e.getParameter(t.MAX_COLOR_ATTACHMENTS)}else E._MAX_COLOR_ATTACHMENTS=1}const i=e-n.COLOR_ATTACHMENT0;i+1>E._MAX_COLOR_ATTACHMENTS&&t.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${i+1}. Implementation supports up to ${E._MAX_COLOR_ATTACHMENTS} color attachments`)}}function g(t){return null!=t&&"type"in t&&t.type===d.Texture}function A(t){return null!=t&&"type"in t&&t.type===d.RenderBuffer}function b(t){return g(t)||null!=t&&"pixelFormat"in t}function S(t,e){const i=Math.max(t.width,t.height);if(i>e){x.warn(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const r=e/i;return t.width=Math.round(t.width*r),t.height=Math.round(t.height*r),!1}return!0}function R(t){return t.descriptor.target===_.TEXTURE_CUBE_MAP?_.TEXTURE_CUBE_MAP_POSITIVE_X:_.TEXTURE_2D}E._MAX_COLOR_ATTACHMENTS=-1;export{E as FramebufferObject,S as ensureAttachmentMaxSize};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- 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{ContextType as n}from"./contextUtils.js";import{BufferType as l,Face as h,baseTextureUnit as f,ClearBufferBit as o,FramebufferTarget as u,TextureSamplingMode as c,SyncCondition as _,ResourceType as d,ClientWaitSyncStatus as b,BlendFactor as F,BlendOperation as g,CullMode as p,CompareFunction as B,StencilOperation as E,ColorAttachment as R,TextureType as m,PrimitiveType as T}from"./enums.js";import{InstanceCounter as A}from"./InstanceCounter.js";import{Parameters as O}from"./Parameters.js";import{ProgramCache as x}from"./ProgramCache.js";import{StateTracker as C}from"./renderState.js";import{Texture as U}from"./Texture.js";import{getErrorString as S}from"./Util.js";import{WebGLDriverTest as y}from"./WebGLDriverTest.js";import{Capabilities as k}from"./capabilities/Capabilities.js";import P from"./capabilities/isWebGL2Context.js";let v=class{constructor(t,e){this.gl=t,this.instanceCounter=new A,this.programCache=new x(this),this._state=new r,this._numOfDrawCalls=0,this._numOfTriangles=0,this.type=P(t)?n.WEBGL2:n.WEBGL1,this._loadExtensions(),this.configure(e)}get gl2(){return this.type===n.WEBGL1?null:this.gl}configure(e){this._capabilities=new k(this.gl,e),this._parameters=new O(this.gl,this._capabilities,e),U.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 C({setBlending:t=>{if(t){this.setBlendingEnabled(!0),this.setBlendEquationSeparate(t.opRgb,t.opAlpha),this.setBlendFunctionSeparate(t.srcRgb,t.dstRgb,t.srcAlpha,t.dstAlpha);const e=t.color;this.setBlendColor(e.r,e.g,e.b,e.a)}else this.setBlendingEnabled(!1)},setCulling:t=>{t?(this.setFaceCullingEnabled(!0),this.setCullFace(t.face),this.setFrontFace(t.mode)):this.setFaceCullingEnabled(!1)},setPolygonOffset:t=>{t?(this.setPolygonOffsetFillEnabled(!0),this.setPolygonOffset(t.factor,t.units)):this.setPolygonOffsetFillEnabled(!1)},setDepthTest:t=>{t?(this.setDepthTestEnabled(!0),this.setDepthFunction(t.func)):this.setDepthTestEnabled(!1)},setStencilTest:t=>{if(t){this.setStencilTestEnabled(!0);const e=t.function;this.setStencilFunction(e.func,e.ref,e.mask);const s=t.operation;this.setStencilOp(s.fail,s.zFail,s.zPass)}else this.setStencilTestEnabled(!1)},setDepthWrite:t=>{t?(this.setDepthWriteEnabled(!0),this.setDepthRange(t.zNear,t.zFar)):this.setDepthWriteEnabled(!1)},setColorWrite:t=>{t?this.setColorMask(t.r,t.g,t.b,t.a):this.setColorMask(!1,!1,!1,!1)},setStencilWrite:t=>{t?this.setStencilWriteMask(t.mask):this.setStencilWriteMask(0)}}),this.enforceState(),t(this._driverTest),this._driverTest=new y(this)}dispose(){t(this._driverTest),this.programCache.dispose(),this.bindVAO(null),this.unbindBuffer(l.ARRAY_BUFFER),this.unbindBuffer(l.ELEMENT_ARRAY_BUFFER),this.type===n.WEBGL2&&(this.unbindBuffer(l.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(l.PIXEL_PACK_BUFFER),this.unbindBuffer(l.PIXEL_UNPACK_BUFFER),this.unbindBuffer(l.COPY_READ_BUFFER),this.unbindBuffer(l.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(){const t=this.capabilities.vao;t&&(t.bindVertexArray(null),this._state.vertexArrayObject=null),this._state.vertexBuffer=null,this._state.indexBuffer=null}externalVertexBufferUpdate(){this._state.vertexBuffer=null}externalIndexBufferUpdate(){this._state.indexBuffer=null}setBlendColor(t,e,s,i){t===this._state.blendColor.r&&e===this._state.blendColor.g&&s===this._state.blendColor.b&&i===this._state.blendColor.a||(this.gl.blendColor(t,e,s,i),this._state.blendColor.r=t,this._state.blendColor.g=e,this._state.blendColor.b=s,this._state.blendColor.a=i,this._stateTracker.invalidateBlending())}setBlendFunction(t,e){t===this._state.blendFunction.srcRGB&&e===this._state.blendFunction.dstRGB||(this.gl.blendFunc(t,e),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=t,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=e,this._stateTracker.invalidateBlending())}setBlendFunctionSeparate(t,e,s,i){this._state.blendFunction.srcRGB===t&&this._state.blendFunction.srcAlpha===s&&this._state.blendFunction.dstRGB===e&&this._state.blendFunction.dstAlpha===i||(this.gl.blendFuncSeparate(t,e,s,i),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=s,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=i,this._stateTracker.invalidateBlending())}setBlendEquation(t){this._state.blendEquation.mode!==t&&(this.gl.blendEquation(t),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=t,this._stateTracker.invalidateBlending())}setBlendEquationSeparate(t,e){this._state.blendEquation.mode===t&&this._state.blendEquation.modeAlpha===e||(this.gl.blendEquationSeparate(t,e),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=e,this._stateTracker.invalidateBlending())}setColorMask(t,e,s,i){this._state.colorMask.r===t&&this._state.colorMask.g===e&&this._state.colorMask.b===s&&this._state.colorMask.a===i||(this.gl.colorMask(t,e,s,i),this._state.colorMask.r=t,this._state.colorMask.g=e,this._state.colorMask.b=s,this._state.colorMask.a=i,this._stateTracker.invalidateColorWrite())}setClearColor(t,e,s,i){this._state.clearColor.r===t&&this._state.clearColor.g===e&&this._state.clearColor.b===s&&this._state.clearColor.a===i||(this.gl.clearColor(t,e,s,i),this._state.clearColor.r=t,this._state.clearColor.g=e,this._state.clearColor.b=s,this._state.clearColor.a=i)}setFaceCullingEnabled(t){this._state.faceCulling!==t&&(!0===t?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this._state.faceCulling=t,this._stateTracker.invalidateCulling())}setPolygonOffsetFillEnabled(t){this._state.polygonOffsetFill!==t&&(!0===t?this.gl.enable(this.gl.POLYGON_OFFSET_FILL):this.gl.disable(this.gl.POLYGON_OFFSET_FILL),this._state.polygonOffsetFill=t,this._stateTracker.invalidatePolygonOffset())}setPolygonOffset(t,e){this._state.polygonOffset[0]===t&&this._state.polygonOffset[1]===e||(this._state.polygonOffset[0]=t,this._state.polygonOffset[1]=e,this.gl.polygonOffset(t,e),this._stateTracker.invalidatePolygonOffset())}setCullFace(t){this._state.cullFace!==t&&(this.gl.cullFace(t),this._state.cullFace=t,this._stateTracker.invalidateCulling())}setFrontFace(t){this._state.frontFace!==t&&(this.gl.frontFace(t),this._state.frontFace=t,this._stateTracker.invalidateCulling())}setScissorTestEnabled(t){this._state.scissorTest!==t&&(!0===t?this.gl.enable(this.gl.SCISSOR_TEST):this.gl.disable(this.gl.SCISSOR_TEST),this._state.scissorTest=t)}setScissorRect(t,e,s,i){this._state.scissorRect.x===t&&this._state.scissorRect.y===e&&this._state.scissorRect.width===s&&this._state.scissorRect.height===i||(this.gl.scissor(t,e,s,i),this._state.scissorRect.x=t,this._state.scissorRect.y=e,this._state.scissorRect.width=s,this._state.scissorRect.height=i)}setDepthTestEnabled(t){this._state.depthTest!==t&&(!0===t?this.gl.enable(this.gl.DEPTH_TEST):this.gl.disable(this.gl.DEPTH_TEST),this._state.depthTest=t,this._stateTracker.invalidateDepthTest())}setClearDepth(t){this._state.clearDepth!==t&&(this.gl.clearDepth(t),this._state.clearDepth=t)}setDepthFunction(t){this._state.depthFunction!==t&&(this.gl.depthFunc(t),this._state.depthFunction=t,this._stateTracker.invalidateDepthTest())}setDepthWriteEnabled(t){this._state.depthWrite!==t&&(this.gl.depthMask(t),this._state.depthWrite=t,this._stateTracker.invalidateDepthWrite())}setDepthRange(t,e){this._state.depthRange.zNear===t&&this._state.depthRange.zFar===e||(this.gl.depthRange(t,e),this._state.depthRange.zNear=t,this._state.depthRange.zFar=e,this._stateTracker.invalidateDepthWrite())}setStencilTestEnabled(t){this._state.stencilTest!==t&&(!0===t?this.gl.enable(this.gl.STENCIL_TEST):this.gl.disable(this.gl.STENCIL_TEST),this._state.stencilTest=t,this._stateTracker.invalidateStencilTest())}setClearStencil(t){t!==this._state.clearStencil&&(this.gl.clearStencil(t),this._state.clearStencil=t)}setStencilFunction(t,e,s){this._state.stencilFunction.func===t&&this._state.stencilFunction.ref===e&&this._state.stencilFunction.mask===s||(this.gl.stencilFunc(t,e,s),this._state.stencilFunction.face=h.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===h.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=h.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(f+t),this._state.activeTexture=t),s}clear(t){t&&this.gl.clear(t)}clearSafe(t,e=255){t&&(t&o.COLOR_BUFFER_BIT&&this.setColorMask(!0,!0,!0,!0),t&o.DEPTH_BUFFER_BIT&&this.setDepthWriteEnabled(!0),t&o.STENCIL_BUFFER_BIT&&this.setStencilWriteMask(e),this.gl.clear(t))}drawArrays(t,e,s){i()&&(this._numOfDrawCalls++,this._numOfTriangles+=M(t,s)),this.gl.drawArrays(t,e,s),a(this.gl)}drawArraysInstanced(t,e,s,i){this.gl2?.drawArraysInstanced(t,e,s,i),a(this.gl)}drawElements(t,e,s,a){if(i()&&(this._numOfDrawCalls++,this._numOfTriangles+=M(t,e)),this.gl.drawElements(t,e,s,a),i()){const i=S(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})}}}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])}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||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(null==t)return this.gl.bindFramebuffer(u.FRAMEBUFFER,null),this._state.readFramebuffer=null,void(this._state.drawFramebuffer=null);t.initializeAndBind(u.FRAMEBUFFER),this._state.readFramebuffer=t,this._state.drawFramebuffer=t}}bindFramebufferSeparate(t,e,s=!1){const i=e===u.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._state.drawFramebuffer=t??null)}blitFramebuffer(t,e,s=0,i=0,a=t.width,r=t.height,n=0,l=0,h=e.width,f=e.height,_=o.COLOR_BUFFER_BIT,d=c.NEAREST){this.bindFramebufferSeparate(t,u.READ_FRAMEBUFFER),this.bindFramebufferSeparate(e,u.DRAW_FRAMEBUFFER);this.gl.blitFramebuffer(s,i,a,r,n,l,h,f,_,d)}bindBuffer(t,e){if(t)switch(e??=t.bufferType,e){case l.ARRAY_BUFFER:this._state.vertexBuffer=N(this.gl,t,e,this._state.vertexBuffer);break;case l.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=N(this.gl,t,e,this._state.indexBuffer);break;case l.UNIFORM_BUFFER:this._state.uniformBuffer=N(this.gl,t,e,this._state.uniformBuffer);break;case l.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=N(this.gl,t,e,this._state.pixelPackBuffer);break;case l.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=N(this.gl,t,e,this._state.pixelUnpackBuffer);break;case l.COPY_READ_BUFFER:this._state.copyReadBuffer=N(this.gl,t,e,this._state.copyReadBuffer);break;case l.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=N(this.gl,t,e,this._state.copyWriteBuffer)}}bindRenderbuffer(t){const e=this.gl;t||(e.bindRenderbuffer(e.RENDERBUFFER,null),this._state.renderbuffer=null),this._state.renderbuffer!==t&&(e.bindRenderbuffer(e.RENDERBUFFER,t.glName),this._state.renderbuffer=t)}_getBufferBinding(t,e){if(e>=this.parameters.maxUniformBufferBindings||e<0)return console.error("Uniform buffer binding point is out of range!"),null;const s=this._state.uniformBufferBindingPoints;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);if(null==i)return;if(i.buffer===s&&0===i.offset&&0===i.size)return;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);if(null==r)return;if(r.buffer===s&&r.offset===i&&r.size===a)return;if(i%this._parameters.uniformBufferOffsetAlignment!=0)return void console.error("Uniform buffer binding offset is not a multiple of the context offset alignment");this.gl.bindBufferRange(t,e,s.glName,i,a),r.buffer=s,r.offset=i,r.size=a}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(l.UNIFORM_BUFFER,t,e.buffer,s,a):this.bindBufferBase(l.UNIFORM_BUFFER,t,e.buffer)):this.bindBufferBase(l.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(l.UNIFORM_BUFFER,e,null)}}unbindBuffer(t){switch(t){case l.ARRAY_BUFFER:this._state.vertexBuffer=N(this.gl,null,t,this._state.vertexBuffer);break;case l.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=N(this.gl,null,t,this._state.indexBuffer);break;case l.UNIFORM_BUFFER:this._state.uniformBuffer=N(this.gl,null,t,this._state.uniformBuffer);break;case l.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=N(this.gl,null,t,this._state.pixelPackBuffer);break;case l.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=N(this.gl,null,t,this._state.pixelUnpackBuffer);break;case l.COPY_READ_BUFFER:this._state.copyReadBuffer=N(this.gl,null,t,this._state.copyReadBuffer);break;case l.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)}async clientWaitAsync(t=s(10)){const i=this.gl,a=i.fenceSync(_.SYNC_GPU_COMMANDS_COMPLETE,0);if(!a)throw new Error("Client wait failed, could not create sync object");let r;this.instanceCounter.increment(d.Sync,a),i.flush();do{await e(t),r=i.clientWaitSync(a,0,0)}while(r===b.TIMEOUT_EXPIRED);if(this.instanceCounter.decrement(d.Sync,a),i.deleteSync(a),r===b.WAIT_FAILED)throw new Error("Client wait failed")}getBoundFramebufferObject(t=u.FRAMEBUFFER){return t===u.READ_FRAMEBUFFER?this._state.readFramebuffer:this._state.drawFramebuffer}getBoundVAO(){return this._state.vertexArrayObject}resetState(){this.useProgram(null),this.bindVAO(null),this.bindFramebuffer(null,!0),this.unbindBuffer(l.ARRAY_BUFFER),this.unbindBuffer(l.ELEMENT_ARRAY_BUFFER),this.type===n.WEBGL2&&(this.unbindBuffer(l.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(l.PIXEL_PACK_BUFFER),this.unbindBuffer(l.PIXEL_UNPACK_BUFFER),this.unbindBuffer(l.COPY_READ_BUFFER),this.unbindBuffer(l.COPY_WRITE_BUFFER));for(let t=0;t<this.parameters.maxTextureImageUnits;++t)this.bindTexture(null,t);this.setBlendingEnabled(!1),this.setBlendFunction(F.ONE,F.ZERO),this.setBlendEquation(g.ADD),this.setBlendColor(0,0,0,0),this.setFaceCullingEnabled(!1),this.setCullFace(h.BACK),this.setFrontFace(p.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(B.LESS),this.setDepthRange(0,1),this.setStencilTestEnabled(!1),this.setStencilFunction(B.ALWAYS,0,0),this.setStencilOp(E.KEEP,E.KEEP,E.KEEP),this.setClearColor(0,0,0,0),this.setClearDepth(1),this.setClearStencil(0),this.setColorMask(!0,!0,!0,!0),this.setStencilWriteMask(4294967295),this.setDepthWriteEnabled(!0),this.setViewport(0,0,this.gl.canvas.width,this.gl.canvas.height)}enforceState(){const t=this.capabilities.vao;t&&t.bindVertexArray(null);const{gl:e,gl2:s}=this;for(let a=0;a<this.parameters.maxVertexAttributes;a++)e.disableVertexAttribArray(a);if(this._state.vertexBuffer?e.bindBuffer(this._state.vertexBuffer.bufferType,this._state.vertexBuffer.glName):e.bindBuffer(l.ARRAY_BUFFER,null),this._state.indexBuffer?e.bindBuffer(this._state.indexBuffer.bufferType,this._state.indexBuffer.glName):e.bindBuffer(l.ELEMENT_ARRAY_BUFFER,null),null!=s){this._state.uniformBuffer?s.bindBuffer(this._state.uniformBuffer.bufferType,this._state.uniformBuffer.glName):s.bindBuffer(l.UNIFORM_BUFFER,null);for(let t=0;t<this._parameters.maxUniformBufferBindings;t++){const e=this._state.uniformBufferBindingPoints[t];if(null!=e){const{buffer:i,offset:a,size:r}=e;null!==i?0===a&&0===r?s.bindBufferBase(l.UNIFORM_BUFFER,t,i.glName):s.bindBufferRange(l.UNIFORM_BUFFER,t,i.glName,a,r):s.bindBufferBase(l.UNIFORM_BUFFER,t,null)}}this._state.pixelPackBuffer?s.bindBuffer(this._state.pixelPackBuffer.bufferType,this._state.pixelPackBuffer.glName):s.bindBuffer(l.PIXEL_PACK_BUFFER,null),this._state.pixelUnpackBuffer?s.bindBuffer(this._state.pixelUnpackBuffer.bufferType,this._state.pixelUnpackBuffer.glName):s.bindBuffer(l.PIXEL_UNPACK_BUFFER,null),this._state.copyReadBuffer?s.bindBuffer(this._state.copyReadBuffer.bufferType,this._state.copyReadBuffer.glName):s.bindBuffer(l.COPY_READ_BUFFER,null),this._state.copyWriteBuffer?s.bindBuffer(this._state.copyWriteBuffer.bufferType,this._state.copyWriteBuffer.glName):s.bindBuffer(l.COPY_WRITE_BUFFER,null),s.bindFramebuffer(u.READ_FRAMEBUFFER,null),s.readBuffer(s.BACK),this._state.readFramebuffer&&(s.bindFramebuffer(u.READ_FRAMEBUFFER,this._state.readFramebuffer.glName),s.readBuffer(R.COLOR_ATTACHMENT0)),s.bindFramebuffer(u.DRAW_FRAMEBUFFER,this._state.drawFramebuffer?.glName??null)}else this._state.readFramebuffer=this._state.drawFramebuffer,e.bindFramebuffer(u.FRAMEBUFFER,this._state.drawFramebuffer?.glName??null);if(t&&this._state.vertexArrayObject){const t=this._state.vertexArrayObject;this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null),this.bindVAO(t)}e.useProgram(this._state.program?.glName??null),e.blendColor(this._state.blendColor.r,this._state.blendColor.g,this._state.blendColor.b,this._state.blendColor.a),e.bindRenderbuffer(e.RENDERBUFFER,this._state.renderbuffer?this._state.renderbuffer.glName:null),!0===this._state.blend?e.enable(this.gl.BLEND):e.disable(this.gl.BLEND),e.blendEquationSeparate(this._state.blendEquation.mode,this._state.blendEquation.modeAlpha),e.blendFuncSeparate(this._state.blendFunction.srcRGB,this._state.blendFunction.dstRGB,this._state.blendFunction.srcAlpha,this._state.blendFunction.dstAlpha),e.clearColor(this._state.clearColor.r,this._state.clearColor.g,this._state.clearColor.b,this._state.clearColor.a),e.clearDepth(this._state.clearDepth),e.clearStencil(this._state.clearStencil),e.colorMask(this._state.colorMask.r,this._state.colorMask.g,this._state.colorMask.b,this._state.colorMask.a),e.cullFace(this._state.cullFace),e.depthFunc(this._state.depthFunction),e.depthRange(this._state.depthRange.zNear,this._state.depthRange.zFar),!0===this._state.depthTest?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),e.depthMask(this._state.depthWrite),e.frontFace(this._state.frontFace),e.lineWidth(1),!0===this._state.faceCulling?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),e.polygonOffset(this._state.polygonOffset[0],this._state.polygonOffset[1]),!0===this._state.polygonOffsetFill?e.enable(e.POLYGON_OFFSET_FILL):e.disable(e.POLYGON_OFFSET_FILL),e.scissor(this._state.scissorRect.x,this._state.scissorRect.y,this._state.scissorRect.width,this._state.scissorRect.height),!0===this._state.scissorTest?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST),e.stencilFunc(this._state.stencilFunction.func,this._state.stencilFunction.ref,this._state.stencilFunction.mask),e.stencilOpSeparate(this._state.stencilOperation.face,this._state.stencilOperation.fail,this._state.stencilOperation.zFail,this._state.stencilOperation.zPass),!0===this._state.stencilTest?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),e.stencilMask(this._state.stencilWriteMask);for(let a=0;a<this.parameters.maxTextureImageUnits;a++){e.activeTexture(f+a),e.bindTexture(m.TEXTURE_2D,null),e.bindTexture(m.TEXTURE_CUBE_MAP,null),this.type===n.WEBGL2&&(e.bindTexture(m.TEXTURE_3D,null),e.bindTexture(m.TEXTURE_2D_ARRAY,null));const t=this._state.textureUnitMap[a];null!=t&&e.bindTexture(t.descriptor.target,t.glName)}e.activeTexture(f+this._state.activeTexture);const i=this._state.viewport;e.viewport(i.x,i.y,i.width,i.height),this.resetInfo()}_loadExtensions(){this.type===n.WEBGL1&&this.gl.getExtension("OES_element_index_uint"),this.gl.getExtension("KHR_parallel_shader_compile")}};function N(t,e,s,i){return e?i!==e&&t.bindBuffer(s,e.glName):t.bindBuffer(s,null),e}function M(t,e){switch(t){case T.POINTS:return 2*e;case T.TRIANGLES:return e/3;case T.TRIANGLE_STRIP:case T.TRIANGLE_FAN:return e-2;default:return 0}}export{v as RenderingContext};
5
+ 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{ContextType as n}from"./contextUtils.js";import{SpecialDrawBuffers as l,ColorAttachment as h,BufferType as f,Face as o,baseTextureUnit as u,ClearBufferBit as c,FramebufferTarget as _,TextureSamplingMode as d,SyncCondition as b,ResourceType as F,ClientWaitSyncStatus as g,BlendFactor as p,BlendOperation as B,CullMode as E,CompareFunction as R,StencilOperation as m,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 S}from"./Texture.js";import{getErrorString as k}from"./Util.js";import{WebGLDriverTest as y}from"./WebGLDriverTest.js";import{Capabilities as P}from"./capabilities/Capabilities.js";import v from"./capabilities/isWebGL2Context.js";let N=class{constructor(t,e){this.gl=t,this.instanceCounter=new O,this.programCache=new x(this),this._state=new r,this._numOfDrawCalls=0,this._numOfTriangles=0,this.type=v(t)?n.WEBGL2:n.WEBGL1,this._loadExtensions(),this.configure(e)}get gl2(){return this.type===n.WEBGL1?null:this.gl}configure(e){this._capabilities=new P(this.gl,e),this._parameters=new C(this.gl,this._capabilities,e),S.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=>{const{drawBuffers:e}=this._capabilities;if(t)e?.drawBuffers(t.buffers);else{const{drawFramebuffer:t}=this._state;null===t||0===t.colorAttachments.length?e?.drawBuffers([l.BACK]):e?.drawBuffers([h.COLOR_ATTACHMENT0])}}}),this.enforceState(),t(this._driverTest),this._driverTest=new y(this)}dispose(){t(this._driverTest),this.programCache.dispose(),this.bindVAO(null),this.unbindBuffer(f.ARRAY_BUFFER),this.unbindBuffer(f.ELEMENT_ARRAY_BUFFER),this.type===n.WEBGL2&&(this.unbindBuffer(f.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(f.PIXEL_PACK_BUFFER),this.unbindBuffer(f.PIXEL_UNPACK_BUFFER),this.unbindBuffer(f.COPY_READ_BUFFER),this.unbindBuffer(f.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(){const t=this.capabilities.vao;t&&(t.bindVertexArray(null),this._state.vertexArrayObject=null),this._state.vertexBuffer=null,this._state.indexBuffer=null}externalVertexBufferUpdate(){this._state.vertexBuffer=null}externalIndexBufferUpdate(){this._state.indexBuffer=null}setBlendColor(t,e,s,i){t===this._state.blendColor.r&&e===this._state.blendColor.g&&s===this._state.blendColor.b&&i===this._state.blendColor.a||(this.gl.blendColor(t,e,s,i),this._state.blendColor.r=t,this._state.blendColor.g=e,this._state.blendColor.b=s,this._state.blendColor.a=i,this._stateTracker.invalidateBlending())}setBlendFunction(t,e){t===this._state.blendFunction.srcRGB&&e===this._state.blendFunction.dstRGB||(this.gl.blendFunc(t,e),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=t,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=e,this._stateTracker.invalidateBlending())}setBlendFunctionSeparate(t,e,s,i){this._state.blendFunction.srcRGB===t&&this._state.blendFunction.srcAlpha===s&&this._state.blendFunction.dstRGB===e&&this._state.blendFunction.dstAlpha===i||(this.gl.blendFuncSeparate(t,e,s,i),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=s,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=i,this._stateTracker.invalidateBlending())}setBlendEquation(t){this._state.blendEquation.mode!==t&&(this.gl.blendEquation(t),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=t,this._stateTracker.invalidateBlending())}setBlendEquationSeparate(t,e){this._state.blendEquation.mode===t&&this._state.blendEquation.modeAlpha===e||(this.gl.blendEquationSeparate(t,e),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=e,this._stateTracker.invalidateBlending())}setColorMask(t,e,s,i){this._state.colorMask.r===t&&this._state.colorMask.g===e&&this._state.colorMask.b===s&&this._state.colorMask.a===i||(this.gl.colorMask(t,e,s,i),this._state.colorMask.r=t,this._state.colorMask.g=e,this._state.colorMask.b=s,this._state.colorMask.a=i,this._stateTracker.invalidateColorWrite())}setClearColor(t,e,s,i){this._state.clearColor.r===t&&this._state.clearColor.g===e&&this._state.clearColor.b===s&&this._state.clearColor.a===i||(this.gl.clearColor(t,e,s,i),this._state.clearColor.r=t,this._state.clearColor.g=e,this._state.clearColor.b=s,this._state.clearColor.a=i)}setFaceCullingEnabled(t){this._state.faceCulling!==t&&(!0===t?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this._state.faceCulling=t,this._stateTracker.invalidateCulling())}setPolygonOffsetFillEnabled(t){this._state.polygonOffsetFill!==t&&(!0===t?this.gl.enable(this.gl.POLYGON_OFFSET_FILL):this.gl.disable(this.gl.POLYGON_OFFSET_FILL),this._state.polygonOffsetFill=t,this._stateTracker.invalidatePolygonOffset())}setPolygonOffset(t,e){this._state.polygonOffset[0]===t&&this._state.polygonOffset[1]===e||(this._state.polygonOffset[0]=t,this._state.polygonOffset[1]=e,this.gl.polygonOffset(t,e),this._stateTracker.invalidatePolygonOffset())}setCullFace(t){this._state.cullFace!==t&&(this.gl.cullFace(t),this._state.cullFace=t,this._stateTracker.invalidateCulling())}setFrontFace(t){this._state.frontFace!==t&&(this.gl.frontFace(t),this._state.frontFace=t,this._stateTracker.invalidateCulling())}setScissorTestEnabled(t){this._state.scissorTest!==t&&(!0===t?this.gl.enable(this.gl.SCISSOR_TEST):this.gl.disable(this.gl.SCISSOR_TEST),this._state.scissorTest=t)}setScissorRect(t,e,s,i){this._state.scissorRect.x===t&&this._state.scissorRect.y===e&&this._state.scissorRect.width===s&&this._state.scissorRect.height===i||(this.gl.scissor(t,e,s,i),this._state.scissorRect.x=t,this._state.scissorRect.y=e,this._state.scissorRect.width=s,this._state.scissorRect.height=i)}setDepthTestEnabled(t){this._state.depthTest!==t&&(!0===t?this.gl.enable(this.gl.DEPTH_TEST):this.gl.disable(this.gl.DEPTH_TEST),this._state.depthTest=t,this._stateTracker.invalidateDepthTest())}setClearDepth(t){this._state.clearDepth!==t&&(this.gl.clearDepth(t),this._state.clearDepth=t)}setDepthFunction(t){this._state.depthFunction!==t&&(this.gl.depthFunc(t),this._state.depthFunction=t,this._stateTracker.invalidateDepthTest())}setDepthWriteEnabled(t){this._state.depthWrite!==t&&(this.gl.depthMask(t),this._state.depthWrite=t,this._stateTracker.invalidateDepthWrite())}setDepthRange(t,e){this._state.depthRange.zNear===t&&this._state.depthRange.zFar===e||(this.gl.depthRange(t,e),this._state.depthRange.zNear=t,this._state.depthRange.zFar=e,this._stateTracker.invalidateDepthWrite())}setStencilTestEnabled(t){this._state.stencilTest!==t&&(!0===t?this.gl.enable(this.gl.STENCIL_TEST):this.gl.disable(this.gl.STENCIL_TEST),this._state.stencilTest=t,this._stateTracker.invalidateStencilTest())}setClearStencil(t){t!==this._state.clearStencil&&(this.gl.clearStencil(t),this._state.clearStencil=t)}setStencilFunction(t,e,s){this._state.stencilFunction.func===t&&this._state.stencilFunction.ref===e&&this._state.stencilFunction.mask===s||(this.gl.stencilFunc(t,e,s),this._state.stencilFunction.face=o.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===o.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=o.FRONT_AND_BACK,this._state.stencilOperation.fail=t,this._state.stencilOperation.zFail=e,this._state.stencilOperation.zPass=s,this._stateTracker.invalidateStencilTest())}setStencilOpSeparate(t,e,s,i){this._state.stencilOperation.face===t&&this._state.stencilOperation.fail===e&&this._state.stencilOperation.zFail===s&&this._state.stencilOperation.zPass===i||(this.gl.stencilOpSeparate(t,e,s,i),this._state.stencilOperation.face=t,this._state.stencilOperation.fail=e,this._state.stencilOperation.zFail=s,this._state.stencilOperation.zPass=i,this._stateTracker.invalidateStencilTest())}setActiveTexture(t,e=!1){const s=this._state.activeTexture;return t>=0&&(e||t!==this._state.activeTexture)&&(this.gl.activeTexture(u+t),this._state.activeTexture=t),s}clear(t){t&&this.gl.clear(t)}clearSafe(t,e=255){t&&(t&c.COLOR_BUFFER_BIT&&this.setColorMask(!0,!0,!0,!0),t&c.DEPTH_BUFFER_BIT&&this.setDepthWriteEnabled(!0),t&c.STENCIL_BUFFER_BIT&&this.setStencilWriteMask(e),this.gl.clear(t))}drawArrays(t,e,s){i()&&(this._numOfDrawCalls++,this._numOfTriangles+=D(t,s)),this.gl.drawArrays(t,e,s),a(this.gl)}drawArraysInstanced(t,e,s,i){this.gl2?.drawArraysInstanced(t,e,s,i),a(this.gl)}drawElements(t,e,s,a){if(i()&&(this._numOfDrawCalls++,this._numOfTriangles+=D(t,e)),this.gl.drawElements(t,e,s,a),i()){const i=k(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})}}}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])}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||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),this._state.readFramebuffer=null,void(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._state.drawFramebuffer=t??null)}blitFramebuffer(t,e,s=0,i=0,a=t.width,r=t.height,n=0,l=0,h=e.width,f=e.height,o=c.COLOR_BUFFER_BIT,u=d.NEAREST){this.bindFramebufferSeparate(t,_.READ_FRAMEBUFFER),this.bindFramebufferSeparate(e,_.DRAW_FRAMEBUFFER);this.gl.blitFramebuffer(s,i,a,r,n,l,h,f,o,u)}bindBuffer(t,e){if(t)switch(e??=t.bufferType,e){case f.ARRAY_BUFFER:this._state.vertexBuffer=M(this.gl,t,e,this._state.vertexBuffer);break;case f.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=M(this.gl,t,e,this._state.indexBuffer);break;case f.UNIFORM_BUFFER:this._state.uniformBuffer=M(this.gl,t,e,this._state.uniformBuffer);break;case f.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=M(this.gl,t,e,this._state.pixelPackBuffer);break;case f.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=M(this.gl,t,e,this._state.pixelUnpackBuffer);break;case f.COPY_READ_BUFFER:this._state.copyReadBuffer=M(this.gl,t,e,this._state.copyReadBuffer);break;case f.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=M(this.gl,t,e,this._state.copyWriteBuffer)}}bindRenderbuffer(t){const e=this.gl;t||(e.bindRenderbuffer(e.RENDERBUFFER,null),this._state.renderbuffer=null),this._state.renderbuffer!==t&&(e.bindRenderbuffer(e.RENDERBUFFER,t.glName),this._state.renderbuffer=t)}_getBufferBinding(t,e){if(e>=this.parameters.maxUniformBufferBindings||e<0)return console.error("Uniform buffer binding point is out of range!"),null;const s=this._state.uniformBufferBindingPoints;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);if(null==i)return;if(i.buffer===s&&0===i.offset&&0===i.size)return;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);if(null==r)return;if(r.buffer===s&&r.offset===i&&r.size===a)return;if(i%this._parameters.uniformBufferOffsetAlignment!=0)return void console.error("Uniform buffer binding offset is not a multiple of the context offset alignment");this.gl.bindBufferRange(t,e,s.glName,i,a),r.buffer=s,r.offset=i,r.size=a}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(f.UNIFORM_BUFFER,t,e.buffer,s,a):this.bindBufferBase(f.UNIFORM_BUFFER,t,e.buffer)):this.bindBufferBase(f.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(f.UNIFORM_BUFFER,e,null)}}unbindBuffer(t){switch(t){case f.ARRAY_BUFFER:this._state.vertexBuffer=M(this.gl,null,t,this._state.vertexBuffer);break;case f.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=M(this.gl,null,t,this._state.indexBuffer);break;case f.UNIFORM_BUFFER:this._state.uniformBuffer=M(this.gl,null,t,this._state.uniformBuffer);break;case f.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=M(this.gl,null,t,this._state.pixelPackBuffer);break;case f.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=M(this.gl,null,t,this._state.pixelUnpackBuffer);break;case f.COPY_READ_BUFFER:this._state.copyReadBuffer=M(this.gl,null,t,this._state.copyReadBuffer);break;case f.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=M(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)}async clientWaitAsync(t=s(10)){const i=this.gl,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}getBoundVAO(){return this._state.vertexArrayObject}resetState(){this.useProgram(null),this.bindVAO(null),this.bindFramebuffer(null,!0),this.unbindBuffer(f.ARRAY_BUFFER),this.unbindBuffer(f.ELEMENT_ARRAY_BUFFER),this.type===n.WEBGL2&&(this.unbindBuffer(f.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(f.PIXEL_PACK_BUFFER),this.unbindBuffer(f.PIXEL_UNPACK_BUFFER),this.unbindBuffer(f.COPY_READ_BUFFER),this.unbindBuffer(f.COPY_WRITE_BUFFER));for(let t=0;t<this.parameters.maxTextureImageUnits;++t)this.bindTexture(null,t);this.setBlendingEnabled(!1),this.setBlendFunction(p.ONE,p.ZERO),this.setBlendEquation(B.ADD),this.setBlendColor(0,0,0,0),this.setFaceCullingEnabled(!1),this.setCullFace(o.BACK),this.setFrontFace(E.CCW),this.setPolygonOffsetFillEnabled(!1),this.setPolygonOffset(0,0),this.setScissorTestEnabled(!1),this.setScissorRect(0,0,this.gl.canvas.width,this.gl.canvas.height),this.setDepthTestEnabled(!1),this.setDepthFunction(R.LESS),this.setDepthRange(0,1),this.setStencilTestEnabled(!1),this.setStencilFunction(R.ALWAYS,0,0),this.setStencilOp(m.KEEP,m.KEEP,m.KEEP),this.setClearColor(0,0,0,0),this.setClearDepth(1),this.setClearStencil(0),this.setColorMask(!0,!0,!0,!0),this.setStencilWriteMask(4294967295),this.setDepthWriteEnabled(!0),this.setViewport(0,0,this.gl.canvas.width,this.gl.canvas.height)}enforceState(){const t=this.capabilities.vao;t&&t.bindVertexArray(null);const{gl:e,gl2:s}=this;for(let a=0;a<this.parameters.maxVertexAttributes;a++)e.disableVertexAttribArray(a);if(this._state.vertexBuffer?e.bindBuffer(this._state.vertexBuffer.bufferType,this._state.vertexBuffer.glName):e.bindBuffer(f.ARRAY_BUFFER,null),this._state.indexBuffer?e.bindBuffer(this._state.indexBuffer.bufferType,this._state.indexBuffer.glName):e.bindBuffer(f.ELEMENT_ARRAY_BUFFER,null),null!=s){this._state.uniformBuffer?s.bindBuffer(this._state.uniformBuffer.bufferType,this._state.uniformBuffer.glName):s.bindBuffer(f.UNIFORM_BUFFER,null);for(let t=0;t<this._parameters.maxUniformBufferBindings;t++){const e=this._state.uniformBufferBindingPoints[t];if(null!=e){const{buffer:i,offset:a,size:r}=e;null!==i?0===a&&0===r?s.bindBufferBase(f.UNIFORM_BUFFER,t,i.glName):s.bindBufferRange(f.UNIFORM_BUFFER,t,i.glName,a,r):s.bindBufferBase(f.UNIFORM_BUFFER,t,null)}}this._state.pixelPackBuffer?s.bindBuffer(this._state.pixelPackBuffer.bufferType,this._state.pixelPackBuffer.glName):s.bindBuffer(f.PIXEL_PACK_BUFFER,null),this._state.pixelUnpackBuffer?s.bindBuffer(this._state.pixelUnpackBuffer.bufferType,this._state.pixelUnpackBuffer.glName):s.bindBuffer(f.PIXEL_UNPACK_BUFFER,null),this._state.copyReadBuffer?s.bindBuffer(this._state.copyReadBuffer.bufferType,this._state.copyReadBuffer.glName):s.bindBuffer(f.COPY_READ_BUFFER,null),this._state.copyWriteBuffer?s.bindBuffer(this._state.copyWriteBuffer.bufferType,this._state.copyWriteBuffer.glName):s.bindBuffer(f.COPY_WRITE_BUFFER,null),s.bindFramebuffer(_.READ_FRAMEBUFFER,null),s.readBuffer(s.BACK),this._state.readFramebuffer&&(s.bindFramebuffer(_.READ_FRAMEBUFFER,this._state.readFramebuffer.glName),s.readBuffer(h.COLOR_ATTACHMENT0)),s.bindFramebuffer(_.DRAW_FRAMEBUFFER,this._state.drawFramebuffer?.glName??null)}else this._state.readFramebuffer=this._state.drawFramebuffer,e.bindFramebuffer(_.FRAMEBUFFER,this._state.drawFramebuffer?.glName??null);if(t&&this._state.vertexArrayObject){const t=this._state.vertexArrayObject;this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null),this.bindVAO(t)}e.useProgram(this._state.program?.glName??null),e.blendColor(this._state.blendColor.r,this._state.blendColor.g,this._state.blendColor.b,this._state.blendColor.a),e.bindRenderbuffer(e.RENDERBUFFER,this._state.renderbuffer?this._state.renderbuffer.glName:null),!0===this._state.blend?e.enable(this.gl.BLEND):e.disable(this.gl.BLEND),e.blendEquationSeparate(this._state.blendEquation.mode,this._state.blendEquation.modeAlpha),e.blendFuncSeparate(this._state.blendFunction.srcRGB,this._state.blendFunction.dstRGB,this._state.blendFunction.srcAlpha,this._state.blendFunction.dstAlpha),e.clearColor(this._state.clearColor.r,this._state.clearColor.g,this._state.clearColor.b,this._state.clearColor.a),e.clearDepth(this._state.clearDepth),e.clearStencil(this._state.clearStencil),e.colorMask(this._state.colorMask.r,this._state.colorMask.g,this._state.colorMask.b,this._state.colorMask.a),e.cullFace(this._state.cullFace),e.depthFunc(this._state.depthFunction),e.depthRange(this._state.depthRange.zNear,this._state.depthRange.zFar),!0===this._state.depthTest?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),e.depthMask(this._state.depthWrite),e.frontFace(this._state.frontFace),e.lineWidth(1),!0===this._state.faceCulling?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),e.polygonOffset(this._state.polygonOffset[0],this._state.polygonOffset[1]),!0===this._state.polygonOffsetFill?e.enable(e.POLYGON_OFFSET_FILL):e.disable(e.POLYGON_OFFSET_FILL),e.scissor(this._state.scissorRect.x,this._state.scissorRect.y,this._state.scissorRect.width,this._state.scissorRect.height),!0===this._state.scissorTest?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST),e.stencilFunc(this._state.stencilFunction.func,this._state.stencilFunction.ref,this._state.stencilFunction.mask),e.stencilOpSeparate(this._state.stencilOperation.face,this._state.stencilOperation.fail,this._state.stencilOperation.zFail,this._state.stencilOperation.zPass),!0===this._state.stencilTest?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),e.stencilMask(this._state.stencilWriteMask);for(let a=0;a<this.parameters.maxTextureImageUnits;a++){e.activeTexture(u+a),e.bindTexture(T.TEXTURE_2D,null),e.bindTexture(T.TEXTURE_CUBE_MAP,null),this.type===n.WEBGL2&&(e.bindTexture(T.TEXTURE_3D,null),e.bindTexture(T.TEXTURE_2D_ARRAY,null));const t=this._state.textureUnitMap[a];null!=t&&e.bindTexture(t.descriptor.target,t.glName)}e.activeTexture(u+this._state.activeTexture);const i=this._state.viewport;e.viewport(i.x,i.y,i.width,i.height),this.resetInfo()}_loadExtensions(){this.type===n.WEBGL1&&this.gl.getExtension("OES_element_index_uint"),this.gl.getExtension("KHR_parallel_shader_compile")}};function M(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{N 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.28/esri/copyright.txt for details.
4
4
  */
5
- var _,E,R,T,A,N,S,C,I,O,L,D,M,G,P,U,B,F,H,n;!function(_){_[_.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",_[_.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",_[_.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT"}(_||(_={})),function(_){_[_.POINTS=0]="POINTS",_[_.LINES=1]="LINES",_[_.LINE_LOOP=2]="LINE_LOOP",_[_.LINE_STRIP=3]="LINE_STRIP",_[_.TRIANGLES=4]="TRIANGLES",_[_.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",_[_.TRIANGLE_FAN=6]="TRIANGLE_FAN"}(E||(E={})),function(_){_[_.ZERO=0]="ZERO",_[_.ONE=1]="ONE",_[_.SRC_COLOR=768]="SRC_COLOR",_[_.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",_[_.SRC_ALPHA=770]="SRC_ALPHA",_[_.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",_[_.DST_ALPHA=772]="DST_ALPHA",_[_.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",_[_.DST_COLOR=774]="DST_COLOR",_[_.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",_[_.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",_[_.CONSTANT_COLOR=32769]="CONSTANT_COLOR",_[_.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",_[_.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",_[_.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA"}(R||(R={})),function(_){_[_.ADD=32774]="ADD",_[_.MIN=32775]="MIN",_[_.MAX=32776]="MAX",_[_.SUBTRACT=32778]="SUBTRACT",_[_.REVERSE_SUBTRACT=32779]="REVERSE_SUBTRACT"}(T||(T={})),function(_){_[_.ARRAY_BUFFER=34962]="ARRAY_BUFFER",_[_.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",_[_.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",_[_.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",_[_.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",_[_.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",_[_.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER"}(A||(A={})),function(_){_[_.FRONT=1028]="FRONT",_[_.BACK=1029]="BACK",_[_.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(N||(N={})),function(_){_[_.CW=2304]="CW",_[_.CCW=2305]="CCW"}(S||(S={})),function(_){_[_.BYTE=5120]="BYTE",_[_.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",_[_.SHORT=5122]="SHORT",_[_.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",_[_.INT=5124]="INT",_[_.UNSIGNED_INT=5125]="UNSIGNED_INT",_[_.FLOAT=5126]="FLOAT"}(C||(C={})),function(_){_[_.NEVER=512]="NEVER",_[_.LESS=513]="LESS",_[_.EQUAL=514]="EQUAL",_[_.LEQUAL=515]="LEQUAL",_[_.GREATER=516]="GREATER",_[_.NOTEQUAL=517]="NOTEQUAL",_[_.GEQUAL=518]="GEQUAL",_[_.ALWAYS=519]="ALWAYS"}(I||(I={})),function(_){_[_.ZERO=0]="ZERO",_[_.KEEP=7680]="KEEP",_[_.REPLACE=7681]="REPLACE",_[_.INCR=7682]="INCR",_[_.DECR=7683]="DECR",_[_.INVERT=5386]="INVERT",_[_.INCR_WRAP=34055]="INCR_WRAP",_[_.DECR_WRAP=34056]="DECR_WRAP"}(O||(O={})),function(_){_[_.NEAREST=9728]="NEAREST",_[_.LINEAR=9729]="LINEAR",_[_.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",_[_.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",_[_.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",_[_.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"}(L||(L={})),function(_){_[_.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",_[_.REPEAT=10497]="REPEAT",_[_.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"}(D||(D={})),function(_){_[_.TEXTURE_2D=3553]="TEXTURE_2D",_[_.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",_[_.TEXTURE_3D=32879]="TEXTURE_3D",_[_.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",_[_.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",_[_.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",_[_.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",_[_.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",_[_.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",_[_.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY"}(M||(M={})),function(_){_[_.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",_[_.DEPTH_STENCIL=34041]="DEPTH_STENCIL",_[_.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",_[_.ALPHA=6406]="ALPHA",_[_.RGB=6407]="RGB",_[_.RGBA=6408]="RGBA",_[_.LUMINANCE=6409]="LUMINANCE",_[_.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",_[_.RED=6403]="RED",_[_.RG=33319]="RG",_[_.RED_INTEGER=36244]="RED_INTEGER",_[_.RG_INTEGER=33320]="RG_INTEGER",_[_.RGB_INTEGER=36248]="RGB_INTEGER",_[_.RGBA_INTEGER=36249]="RGBA_INTEGER"}(G||(G={})),function(_){_[_.RGBA4=32854]="RGBA4",_[_.R16F=33325]="R16F",_[_.RG16F=33327]="RG16F",_[_.RGB32F=34837]="RGB32F",_[_.RGBA16F=34842]="RGBA16F",_[_.R32F=33326]="R32F",_[_.RG32F=33328]="RG32F",_[_.RGBA32F=34836]="RGBA32F",_[_.R11F_G11F_B10F=35898]="R11F_G11F_B10F",_[_.RGB8=32849]="RGB8",_[_.RGBA8=32856]="RGBA8",_[_.RGB5_A1=32855]="RGB5_A1",_[_.R8=33321]="R8",_[_.RG8=33323]="RG8",_[_.R8I=33329]="R8I",_[_.R8UI=33330]="R8UI",_[_.R16I=33331]="R16I",_[_.R16UI=33332]="R16UI",_[_.R32I=33333]="R32I",_[_.R32UI=33334]="R32UI",_[_.RG8I=33335]="RG8I",_[_.RG8UI=33336]="RG8UI",_[_.RG16I=33337]="RG16I",_[_.RG16UI=33338]="RG16UI",_[_.RG32I=33339]="RG32I",_[_.RG32UI=33340]="RG32UI",_[_.RGB16F=34843]="RGB16F",_[_.RGB9_E5=35901]="RGB9_E5",_[_.SRGB8=35905]="SRGB8",_[_.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",_[_.RGB565=36194]="RGB565",_[_.RGBA32UI=36208]="RGBA32UI",_[_.RGB32UI=36209]="RGB32UI",_[_.RGBA16UI=36214]="RGBA16UI",_[_.RGB16UI=36215]="RGB16UI",_[_.RGBA8UI=36220]="RGBA8UI",_[_.RGB8UI=36221]="RGB8UI",_[_.RGBA32I=36226]="RGBA32I",_[_.RGB32I=36227]="RGB32I",_[_.RGBA16I=36232]="RGBA16I",_[_.RGB16I=36233]="RGB16I",_[_.RGBA8I=36238]="RGBA8I",_[_.RGB8I=36239]="RGB8I",_[_.R8_SNORM=36756]="R8_SNORM",_[_.RG8_SNORM=36757]="RG8_SNORM",_[_.RGB8_SNORM=36758]="RGB8_SNORM",_[_.RGBA8_SNORM=36759]="RGBA8_SNORM",_[_.RGB10_A2=32857]="RGB10_A2",_[_.RGB10_A2UI=36975]="RGB10_A2UI"}(P||(P={})),function(_){_[_.FLOAT=5126]="FLOAT",_[_.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",_[_.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",_[_.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",_[_.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",_[_.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",_[_.BYTE=5120]="BYTE",_[_.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",_[_.SHORT=5122]="SHORT",_[_.UNSIGNED_INT=5125]="UNSIGNED_INT",_[_.INT=5124]="INT",_[_.HALF_FLOAT=5131]="HALF_FLOAT",_[_.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",_[_.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",_[_.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",_[_.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV"}(U||(U={})),function(_){_[_.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",_[_.STENCIL_INDEX8=36168]="STENCIL_INDEX8",_[_.DEPTH_STENCIL=34041]="DEPTH_STENCIL",_[_.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",_[_.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",_[_.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",_[_.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8"}(B||(B={})),function(_){_[_.STATIC_DRAW=35044]="STATIC_DRAW",_[_.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",_[_.STREAM_DRAW=35040]="STREAM_DRAW",_[_.STATIC_READ=35045]="STATIC_READ",_[_.DYNAMIC_READ=35049]="DYNAMIC_READ",_[_.STREAM_READ=35041]="STREAM_READ",_[_.STATIC_COPY=35046]="STATIC_COPY",_[_.DYNAMIC_COPY=35050]="DYNAMIC_COPY",_[_.STREAM_COPY=35042]="STREAM_COPY"}(F||(F={})),function(_){_[_.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",_[_.VERTEX_SHADER=35633]="VERTEX_SHADER"}(H||(H={})),function(_){_[_.FRAMEBUFFER=36160]="FRAMEBUFFER",_[_.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",_[_.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER"}(n||(n={}));const Y=33984;var V,X;!function(_){_[_.Texture=0]="Texture",_[_.BufferObject=1]="BufferObject",_[_.VertexArrayObject=2]="VertexArrayObject",_[_.Shader=3]="Shader",_[_.Program=4]="Program",_[_.FramebufferObject=5]="FramebufferObject",_[_.Renderbuffer=6]="Renderbuffer",_[_.Sync=7]="Sync",_[_.COUNT=8]="COUNT"}(V||(V={})),function(_){_[_.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",_[_.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",_[_.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",_[_.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",_[_.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",_[_.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",_[_.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",_[_.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",_[_.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",_[_.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",_[_.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",_[_.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",_[_.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",_[_.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",_[_.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",_[_.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15"}(X||(X={}));const t=33306;var f,c,u,o,e,i,r;!function(_){_[_.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",_[_.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",_[_.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",_[_.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",_[_.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",_[_.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",_[_.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",_[_.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",_[_.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",_[_.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",_[_.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",_[_.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",_[_.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",_[_.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"}(f||(f={})),function(_){_[_.FLOAT=5126]="FLOAT",_[_.FLOAT_VEC2=35664]="FLOAT_VEC2",_[_.FLOAT_VEC3=35665]="FLOAT_VEC3",_[_.FLOAT_VEC4=35666]="FLOAT_VEC4",_[_.INT=5124]="INT",_[_.INT_VEC2=35667]="INT_VEC2",_[_.INT_VEC3=35668]="INT_VEC3",_[_.INT_VEC4=35669]="INT_VEC4",_[_.BOOL=35670]="BOOL",_[_.BOOL_VEC2=35671]="BOOL_VEC2",_[_.BOOL_VEC3=35672]="BOOL_VEC3",_[_.BOOL_VEC4=35673]="BOOL_VEC4",_[_.FLOAT_MAT2=35674]="FLOAT_MAT2",_[_.FLOAT_MAT3=35675]="FLOAT_MAT3",_[_.FLOAT_MAT4=35676]="FLOAT_MAT4",_[_.SAMPLER_2D=35678]="SAMPLER_2D",_[_.SAMPLER_CUBE=35680]="SAMPLER_CUBE",_[_.UNSIGNED_INT=5125]="UNSIGNED_INT",_[_.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",_[_.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",_[_.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",_[_.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",_[_.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",_[_.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",_[_.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",_[_.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",_[_.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",_[_.SAMPLER_3D=35679]="SAMPLER_3D",_[_.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",_[_.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",_[_.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",_[_.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",_[_.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",_[_.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",_[_.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",_[_.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",_[_.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",_[_.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",_[_.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",_[_.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY"}(c||(c={})),function(_){_[_.OBJECT_TYPE=37138]="OBJECT_TYPE",_[_.SYNC_CONDITION=37139]="SYNC_CONDITION",_[_.SYNC_STATUS=37140]="SYNC_STATUS",_[_.SYNC_FLAGS=37141]="SYNC_FLAGS"}(u||(u={})),function(_){_[_.UNSIGNALED=37144]="UNSIGNALED",_[_.SIGNALED=37145]="SIGNALED"}(o||(o={})),function(_){_[_.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",_[_.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",_[_.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",_[_.WAIT_FAILED=37149]="WAIT_FAILED"}(e||(e={})),function(_){_[_.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE"}(i||(i={})),function(_){_[_.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT"}(r||(r={}));export{R as BlendFactor,T as BlendOperation,A as BufferType,_ as ClearBufferBit,e as ClientWaitSyncStatus,X as ColorAttachment,I as CompareFunction,f as CompressedTextureFormat,S as CullMode,C as DataType,t as DepthStencilAttachment,N as Face,n as FramebufferTarget,G as PixelFormat,U as PixelType,E as PrimitiveType,B as RenderbufferFormat,V as ResourceType,H as ShaderType,P as SizedPixelFormat,O as StencilOperation,i as SyncCondition,r as SyncFlag,u as SyncParameter,o as SyncStatus,L as TextureSamplingMode,M as TextureType,D as TextureWrapMode,c as UniformType,F as Usage,Y as baseTextureUnit};
5
+ var _,E,R,T,A,N,S,C,I,O,L,D,M,G,P,U,B,F,H,n;!function(_){_[_.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",_[_.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",_[_.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT"}(_||(_={})),function(_){_[_.POINTS=0]="POINTS",_[_.LINES=1]="LINES",_[_.LINE_LOOP=2]="LINE_LOOP",_[_.LINE_STRIP=3]="LINE_STRIP",_[_.TRIANGLES=4]="TRIANGLES",_[_.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",_[_.TRIANGLE_FAN=6]="TRIANGLE_FAN"}(E||(E={})),function(_){_[_.ZERO=0]="ZERO",_[_.ONE=1]="ONE",_[_.SRC_COLOR=768]="SRC_COLOR",_[_.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",_[_.SRC_ALPHA=770]="SRC_ALPHA",_[_.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",_[_.DST_ALPHA=772]="DST_ALPHA",_[_.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",_[_.DST_COLOR=774]="DST_COLOR",_[_.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",_[_.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",_[_.CONSTANT_COLOR=32769]="CONSTANT_COLOR",_[_.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",_[_.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",_[_.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA"}(R||(R={})),function(_){_[_.ADD=32774]="ADD",_[_.MIN=32775]="MIN",_[_.MAX=32776]="MAX",_[_.SUBTRACT=32778]="SUBTRACT",_[_.REVERSE_SUBTRACT=32779]="REVERSE_SUBTRACT"}(T||(T={})),function(_){_[_.ARRAY_BUFFER=34962]="ARRAY_BUFFER",_[_.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",_[_.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",_[_.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",_[_.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",_[_.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",_[_.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER"}(A||(A={})),function(_){_[_.FRONT=1028]="FRONT",_[_.BACK=1029]="BACK",_[_.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(N||(N={})),function(_){_[_.CW=2304]="CW",_[_.CCW=2305]="CCW"}(S||(S={})),function(_){_[_.BYTE=5120]="BYTE",_[_.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",_[_.SHORT=5122]="SHORT",_[_.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",_[_.INT=5124]="INT",_[_.UNSIGNED_INT=5125]="UNSIGNED_INT",_[_.FLOAT=5126]="FLOAT"}(C||(C={})),function(_){_[_.NEVER=512]="NEVER",_[_.LESS=513]="LESS",_[_.EQUAL=514]="EQUAL",_[_.LEQUAL=515]="LEQUAL",_[_.GREATER=516]="GREATER",_[_.NOTEQUAL=517]="NOTEQUAL",_[_.GEQUAL=518]="GEQUAL",_[_.ALWAYS=519]="ALWAYS"}(I||(I={})),function(_){_[_.ZERO=0]="ZERO",_[_.KEEP=7680]="KEEP",_[_.REPLACE=7681]="REPLACE",_[_.INCR=7682]="INCR",_[_.DECR=7683]="DECR",_[_.INVERT=5386]="INVERT",_[_.INCR_WRAP=34055]="INCR_WRAP",_[_.DECR_WRAP=34056]="DECR_WRAP"}(O||(O={})),function(_){_[_.NEAREST=9728]="NEAREST",_[_.LINEAR=9729]="LINEAR",_[_.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",_[_.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",_[_.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",_[_.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"}(L||(L={})),function(_){_[_.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",_[_.REPEAT=10497]="REPEAT",_[_.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"}(D||(D={})),function(_){_[_.TEXTURE_2D=3553]="TEXTURE_2D",_[_.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",_[_.TEXTURE_3D=32879]="TEXTURE_3D",_[_.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",_[_.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",_[_.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",_[_.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",_[_.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",_[_.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",_[_.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY"}(M||(M={})),function(_){_[_.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",_[_.DEPTH_STENCIL=34041]="DEPTH_STENCIL",_[_.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",_[_.ALPHA=6406]="ALPHA",_[_.RGB=6407]="RGB",_[_.RGBA=6408]="RGBA",_[_.LUMINANCE=6409]="LUMINANCE",_[_.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",_[_.RED=6403]="RED",_[_.RG=33319]="RG",_[_.RED_INTEGER=36244]="RED_INTEGER",_[_.RG_INTEGER=33320]="RG_INTEGER",_[_.RGB_INTEGER=36248]="RGB_INTEGER",_[_.RGBA_INTEGER=36249]="RGBA_INTEGER"}(G||(G={})),function(_){_[_.RGBA4=32854]="RGBA4",_[_.R16F=33325]="R16F",_[_.RG16F=33327]="RG16F",_[_.RGB32F=34837]="RGB32F",_[_.RGBA16F=34842]="RGBA16F",_[_.R32F=33326]="R32F",_[_.RG32F=33328]="RG32F",_[_.RGBA32F=34836]="RGBA32F",_[_.R11F_G11F_B10F=35898]="R11F_G11F_B10F",_[_.RGB8=32849]="RGB8",_[_.RGBA8=32856]="RGBA8",_[_.RGB5_A1=32855]="RGB5_A1",_[_.R8=33321]="R8",_[_.RG8=33323]="RG8",_[_.R8I=33329]="R8I",_[_.R8UI=33330]="R8UI",_[_.R16I=33331]="R16I",_[_.R16UI=33332]="R16UI",_[_.R32I=33333]="R32I",_[_.R32UI=33334]="R32UI",_[_.RG8I=33335]="RG8I",_[_.RG8UI=33336]="RG8UI",_[_.RG16I=33337]="RG16I",_[_.RG16UI=33338]="RG16UI",_[_.RG32I=33339]="RG32I",_[_.RG32UI=33340]="RG32UI",_[_.RGB16F=34843]="RGB16F",_[_.RGB9_E5=35901]="RGB9_E5",_[_.SRGB8=35905]="SRGB8",_[_.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",_[_.RGB565=36194]="RGB565",_[_.RGBA32UI=36208]="RGBA32UI",_[_.RGB32UI=36209]="RGB32UI",_[_.RGBA16UI=36214]="RGBA16UI",_[_.RGB16UI=36215]="RGB16UI",_[_.RGBA8UI=36220]="RGBA8UI",_[_.RGB8UI=36221]="RGB8UI",_[_.RGBA32I=36226]="RGBA32I",_[_.RGB32I=36227]="RGB32I",_[_.RGBA16I=36232]="RGBA16I",_[_.RGB16I=36233]="RGB16I",_[_.RGBA8I=36238]="RGBA8I",_[_.RGB8I=36239]="RGB8I",_[_.R8_SNORM=36756]="R8_SNORM",_[_.RG8_SNORM=36757]="RG8_SNORM",_[_.RGB8_SNORM=36758]="RGB8_SNORM",_[_.RGBA8_SNORM=36759]="RGBA8_SNORM",_[_.RGB10_A2=32857]="RGB10_A2",_[_.RGB10_A2UI=36975]="RGB10_A2UI"}(P||(P={})),function(_){_[_.FLOAT=5126]="FLOAT",_[_.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",_[_.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",_[_.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",_[_.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",_[_.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",_[_.BYTE=5120]="BYTE",_[_.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",_[_.SHORT=5122]="SHORT",_[_.UNSIGNED_INT=5125]="UNSIGNED_INT",_[_.INT=5124]="INT",_[_.HALF_FLOAT=5131]="HALF_FLOAT",_[_.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",_[_.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",_[_.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",_[_.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV"}(U||(U={})),function(_){_[_.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",_[_.STENCIL_INDEX8=36168]="STENCIL_INDEX8",_[_.DEPTH_STENCIL=34041]="DEPTH_STENCIL",_[_.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",_[_.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",_[_.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",_[_.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8"}(B||(B={})),function(_){_[_.STATIC_DRAW=35044]="STATIC_DRAW",_[_.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",_[_.STREAM_DRAW=35040]="STREAM_DRAW",_[_.STATIC_READ=35045]="STATIC_READ",_[_.DYNAMIC_READ=35049]="DYNAMIC_READ",_[_.STREAM_READ=35041]="STREAM_READ",_[_.STATIC_COPY=35046]="STATIC_COPY",_[_.DYNAMIC_COPY=35050]="DYNAMIC_COPY",_[_.STREAM_COPY=35042]="STREAM_COPY"}(F||(F={})),function(_){_[_.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",_[_.VERTEX_SHADER=35633]="VERTEX_SHADER"}(H||(H={})),function(_){_[_.FRAMEBUFFER=36160]="FRAMEBUFFER",_[_.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",_[_.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER"}(n||(n={}));const Y=33984;var V,X,t;!function(_){_[_.Texture=0]="Texture",_[_.BufferObject=1]="BufferObject",_[_.VertexArrayObject=2]="VertexArrayObject",_[_.Shader=3]="Shader",_[_.Program=4]="Program",_[_.FramebufferObject=5]="FramebufferObject",_[_.Renderbuffer=6]="Renderbuffer",_[_.Sync=7]="Sync",_[_.COUNT=8]="COUNT"}(V||(V={})),function(_){_[_.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",_[_.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",_[_.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",_[_.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",_[_.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",_[_.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",_[_.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",_[_.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",_[_.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",_[_.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",_[_.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",_[_.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",_[_.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",_[_.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",_[_.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",_[_.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15"}(X||(X={})),function(_){_[_.NONE=0]="NONE",_[_.BACK=1029]="BACK"}(t||(t={}));const f=33306;var c,u,o,i,e,r,W;!function(_){_[_.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",_[_.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",_[_.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",_[_.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",_[_.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",_[_.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",_[_.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",_[_.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",_[_.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",_[_.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",_[_.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",_[_.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",_[_.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",_[_.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"}(c||(c={})),function(_){_[_.FLOAT=5126]="FLOAT",_[_.FLOAT_VEC2=35664]="FLOAT_VEC2",_[_.FLOAT_VEC3=35665]="FLOAT_VEC3",_[_.FLOAT_VEC4=35666]="FLOAT_VEC4",_[_.INT=5124]="INT",_[_.INT_VEC2=35667]="INT_VEC2",_[_.INT_VEC3=35668]="INT_VEC3",_[_.INT_VEC4=35669]="INT_VEC4",_[_.BOOL=35670]="BOOL",_[_.BOOL_VEC2=35671]="BOOL_VEC2",_[_.BOOL_VEC3=35672]="BOOL_VEC3",_[_.BOOL_VEC4=35673]="BOOL_VEC4",_[_.FLOAT_MAT2=35674]="FLOAT_MAT2",_[_.FLOAT_MAT3=35675]="FLOAT_MAT3",_[_.FLOAT_MAT4=35676]="FLOAT_MAT4",_[_.SAMPLER_2D=35678]="SAMPLER_2D",_[_.SAMPLER_CUBE=35680]="SAMPLER_CUBE",_[_.UNSIGNED_INT=5125]="UNSIGNED_INT",_[_.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",_[_.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",_[_.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",_[_.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",_[_.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",_[_.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",_[_.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",_[_.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",_[_.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",_[_.SAMPLER_3D=35679]="SAMPLER_3D",_[_.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",_[_.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",_[_.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",_[_.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",_[_.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",_[_.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",_[_.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",_[_.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",_[_.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",_[_.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",_[_.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",_[_.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY"}(u||(u={})),function(_){_[_.OBJECT_TYPE=37138]="OBJECT_TYPE",_[_.SYNC_CONDITION=37139]="SYNC_CONDITION",_[_.SYNC_STATUS=37140]="SYNC_STATUS",_[_.SYNC_FLAGS=37141]="SYNC_FLAGS"}(o||(o={})),function(_){_[_.UNSIGNALED=37144]="UNSIGNALED",_[_.SIGNALED=37145]="SIGNALED"}(i||(i={})),function(_){_[_.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",_[_.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",_[_.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",_[_.WAIT_FAILED=37149]="WAIT_FAILED"}(e||(e={})),function(_){_[_.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE"}(r||(r={})),function(_){_[_.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT"}(W||(W={}));export{R as BlendFactor,T as BlendOperation,A as BufferType,_ as ClearBufferBit,e as ClientWaitSyncStatus,X as ColorAttachment,I as CompareFunction,c as CompressedTextureFormat,S as CullMode,C as DataType,f as DepthStencilAttachment,N as Face,n as FramebufferTarget,G as PixelFormat,U as PixelType,E as PrimitiveType,B as RenderbufferFormat,V as ResourceType,H as ShaderType,P as SizedPixelFormat,t as SpecialDrawBuffers,O as StencilOperation,r as SyncCondition,W as SyncFlag,o as SyncParameter,i as SyncStatus,L as TextureSamplingMode,M as TextureType,D as TextureWrapMode,u as UniformType,F as Usage,Y as baseTextureUnit};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{CullFaceOptions as t}from"../3d/webgl-engine/lib/basicInterfaces.js";import{Face as e,CullMode as i,BlendOperation as n}from"./enums.js";function s(t,e,i=n.ADD,s=[0,0,0,0]){return{srcRgb:t,srcAlpha:t,dstRgb:e,dstAlpha:e,opRgb:i,opAlpha:i,color:{r:s[0],g:s[1],b:s[2],a:s[3]}}}function l(t,e,i,s,l=n.ADD,r=n.ADD,o=[0,0,0,0]){return{srcRgb:t,srcAlpha:e,dstRgb:i,dstAlpha:s,opRgb:l,opAlpha:r,color:{r:o[0],g:o[1],b:o[2],a:o[3]}}}const r={face:e.BACK,mode:i.CCW},o={face:e.FRONT,mode:i.CCW},h=e=>e===t.Back?r:e===t.Front?o:null,a={zNear:0,zFar:1},_={r:!0,g:!0,b:!0,a:!0};function c(t){return T.intern(t)}function d(t){return D.intern(t)}function p(t){return C.intern(t)}function u(t){return A.intern(t)}function g(t){return w.intern(t)}function f(t){return B.intern(t)}function v(t){return z.intern(t)}function I(t){return j.intern(t)}function W(t){return N.intern(t)}class S{constructor(t,e){this._makeKey=t,this._makeRef=e,this._interns=new Map}intern(t){if(!t)return null;const e=this._makeKey(t),i=this._interns;return i.has(e)||i.set(e,this._makeRef(t)),i.get(e)??null}}function b(t){return"["+t.join(",")+"]"}const T=new S(y,(t=>({__tag:"Blending",...t})));function y(t){return t?b([t.srcRgb,t.srcAlpha,t.dstRgb,t.dstAlpha,t.opRgb,t.opAlpha,t.color.r,t.color.g,t.color.b,t.color.a]):null}const D=new S(O,(t=>({__tag:"Culling",...t})));function O(t){return t?b([t.face,t.mode]):null}const C=new S(m,(t=>({__tag:"PolygonOffset",...t})));function m(t){return t?b([t.factor,t.units]):null}const A=new S(R,(t=>({__tag:"DepthTest",...t})));function R(t){return t?b([t.func]):null}const w=new S(k,(t=>({__tag:"StencilTest",...t})));function k(t){return t?b([t.function.func,t.function.ref,t.function.mask,t.operation.fail,t.operation.zFail,t.operation.zPass]):null}const B=new S(P,(t=>({__tag:"DepthWrite",...t})));function P(t){return t?b([t.zNear,t.zFar]):null}const z=new S(F,(t=>({__tag:"ColorWrite",...t})));function F(t){return t?b([t.r,t.g,t.b,t.a]):null}const j=new S(K,(t=>({__tag:"StencilWrite",...t})));function K(t){return t?b([t.mask]):null}const N=new S(x,(t=>({blending:c(t.blending),culling:d(t.culling),polygonOffset:p(t.polygonOffset),depthTest:u(t.depthTest),stencilTest:g(t.stencilTest),depthWrite:f(t.depthWrite),colorWrite:v(t.colorWrite),stencilWrite:I(t.stencilWrite)})));function x(t){return t?b([y(t.blending),O(t.culling),m(t.polygonOffset),R(t.depthTest),k(t.stencilTest),P(t.depthWrite),F(t.colorWrite),K(t.stencilWrite)]):null}class M{constructor(t){this._pipelineInvalid=!0,this._blendingInvalid=!0,this._cullingInvalid=!0,this._polygonOffsetInvalid=!0,this._depthTestInvalid=!0,this._stencilTestInvalid=!0,this._depthWriteInvalid=!0,this._colorWriteInvalid=!0,this._stencilWriteInvalid=!0,this._stateSetters=t}setPipeline(t){(this._pipelineInvalid||t!==this._pipeline)&&(this._setBlending(t.blending),this._setCulling(t.culling),this._setPolygonOffset(t.polygonOffset),this._setDepthTest(t.depthTest),this._setStencilTest(t.stencilTest),this._setDepthWrite(t.depthWrite),this._setColorWrite(t.colorWrite),this._setStencilWrite(t.stencilWrite),this._pipeline=t),this._pipelineInvalid=!1}invalidateBlending(){this._blendingInvalid=!0,this._pipelineInvalid=!0}invalidateCulling(){this._cullingInvalid=!0,this._pipelineInvalid=!0}invalidatePolygonOffset(){this._polygonOffsetInvalid=!0,this._pipelineInvalid=!0}invalidateDepthTest(){this._depthTestInvalid=!0,this._pipelineInvalid=!0}invalidateStencilTest(){this._stencilTestInvalid=!0,this._pipelineInvalid=!0}invalidateDepthWrite(){this._depthWriteInvalid=!0,this._pipelineInvalid=!0}invalidateColorWrite(){this._colorWriteInvalid=!0,this._pipelineInvalid=!0}invalidateStencilWrite(){this._stencilTestInvalid=!0,this._pipelineInvalid=!0}_setBlending(t){this._blending=this._setSubState(t,this._blending,this._blendingInvalid,this._stateSetters.setBlending),this._blendingInvalid=!1}_setCulling(t){this._culling=this._setSubState(t,this._culling,this._cullingInvalid,this._stateSetters.setCulling),this._cullingInvalid=!1}_setPolygonOffset(t){this._polygonOffset=this._setSubState(t,this._polygonOffset,this._polygonOffsetInvalid,this._stateSetters.setPolygonOffset),this._polygonOffsetInvalid=!1}_setDepthTest(t){this._depthTest=this._setSubState(t,this._depthTest,this._depthTestInvalid,this._stateSetters.setDepthTest),this._depthTestInvalid=!1}_setStencilTest(t){this._stencilTest=this._setSubState(t,this._stencilTest,this._stencilTestInvalid,this._stateSetters.setStencilTest),this._stencilTestInvalid=!1}_setDepthWrite(t){this._depthWrite=this._setSubState(t,this._depthWrite,this._depthWriteInvalid,this._stateSetters.setDepthWrite),this._depthWriteInvalid=!1}_setColorWrite(t){this._colorWrite=this._setSubState(t,this._colorWrite,this._colorWriteInvalid,this._stateSetters.setColorWrite),this._colorWriteInvalid=!1}_setStencilWrite(t){this._stencilWrite=this._setSubState(t,this._stencilWrite,this._stencilWriteInvalid,this._stateSetters.setStencilWrite),this._stencilTestInvalid=!1}_setSubState(t,e,i,n){return(i||t!==e)&&(n(t),this._pipelineInvalid=!0),t}}export{M as StateTracker,r as backFaceCullingParams,h as cullingParams,_ as defaultColorWriteParams,a as defaultDepthWriteParams,o as frontFaceCullingParams,c as makeBlending,v as makeColorWrite,d as makeCulling,u as makeDepthTest,f as makeDepthWrite,W as makePipelineState,p as makePolygonOffset,g as makeStencilTest,I as makeStencilWrite,l as separateBlendingParams,s as simpleBlendingParams};
5
+ import{CullFaceOptions as t}from"../3d/webgl-engine/lib/basicInterfaces.js";import{Face as e,CullMode as i,BlendOperation as n}from"./enums.js";function s(t,e,i=n.ADD,s=[0,0,0,0]){return{srcRgb:t,srcAlpha:t,dstRgb:e,dstAlpha:e,opRgb:i,opAlpha:i,color:{r:s[0],g:s[1],b:s[2],a:s[3]}}}function l(t,e,i,s,l=n.ADD,r=n.ADD,a=[0,0,0,0]){return{srcRgb:t,srcAlpha:e,dstRgb:i,dstAlpha:s,opRgb:l,opAlpha:r,color:{r:a[0],g:a[1],b:a[2],a:a[3]}}}const r={face:e.BACK,mode:i.CCW},a={face:e.FRONT,mode:i.CCW},h=e=>e===t.Back?r:e===t.Front?a:null,o={zNear:0,zFar:1},_={r:!0,g:!0,b:!0,a:!0};function c(t){return w.intern(t)}function d(t){return D.intern(t)}function u(t){return O.intern(t)}function f(t){return m.intern(t)}function p(t){return R.intern(t)}function g(t){return P.intern(t)}function v(t){return F.intern(t)}function I(t){return K.intern(t)}function W(t){return x.intern(t)}function S(t){return q.intern(t)}class b{constructor(t,e){this._makeKey=t,this._makeRef=e,this._interns=new Map}intern(t){if(!t)return null;const e=this._makeKey(t),i=this._interns;return i.has(e)||i.set(e,this._makeRef(t)),i.get(e)??null}}function T(t){return"["+t.join(",")+"]"}const w=new b(B,(t=>({__tag:"Blending",...t})));function B(t){return t?T([t.srcRgb,t.srcAlpha,t.dstRgb,t.dstAlpha,t.opRgb,t.opAlpha,t.color.r,t.color.g,t.color.b,t.color.a]):null}const D=new b(y,(t=>({__tag:"Culling",...t})));function y(t){return t?T([t.face,t.mode]):null}const O=new b(C,(t=>({__tag:"PolygonOffset",...t})));function C(t){return t?T([t.factor,t.units]):null}const m=new b(A,(t=>({__tag:"DepthTest",...t})));function A(t){return t?T([t.func]):null}const R=new b(k,(t=>({__tag:"StencilTest",...t})));function k(t){return t?T([t.function.func,t.function.ref,t.function.mask,t.operation.fail,t.operation.zFail,t.operation.zPass]):null}const P=new b(z,(t=>({__tag:"DepthWrite",...t})));function z(t){return t?T([t.zNear,t.zFar]):null}const F=new b(j,(t=>({__tag:"ColorWrite",...t})));function j(t){return t?T([t.r,t.g,t.b,t.a]):null}const K=new b(N,(t=>({__tag:"StencilWrite",...t})));function N(t){return t?T([t.mask]):null}const x=new b(M,(t=>({__tag:"DrawBuffers",...t})));function M(t){return t?T(t.buffers):null}const q=new b(E,(t=>({blending:c(t.blending),culling:d(t.culling),polygonOffset:u(t.polygonOffset),depthTest:f(t.depthTest),stencilTest:p(t.stencilTest),depthWrite:g(t.depthWrite),colorWrite:v(t.colorWrite),stencilWrite:I(t.stencilWrite),drawBuffers:W(t.drawBuffers)})));function E(t){return t?T([B(t.blending),y(t.culling),C(t.polygonOffset),A(t.depthTest),k(t.stencilTest),z(t.depthWrite),j(t.colorWrite),N(t.stencilWrite),M(t.drawBuffers)]):null}class G{constructor(t){this._pipelineInvalid=!0,this._blendingInvalid=!0,this._cullingInvalid=!0,this._polygonOffsetInvalid=!0,this._depthTestInvalid=!0,this._stencilTestInvalid=!0,this._depthWriteInvalid=!0,this._colorWriteInvalid=!0,this._stencilWriteInvalid=!0,this._drawBuffersInvalid=!0,this._stateSetters=t}setPipeline(t){(this._pipelineInvalid||t!==this._pipeline)&&(this._setBlending(t.blending),this._setCulling(t.culling),this._setPolygonOffset(t.polygonOffset),this._setDepthTest(t.depthTest),this._setStencilTest(t.stencilTest),this._setDepthWrite(t.depthWrite),this._setColorWrite(t.colorWrite),this._setStencilWrite(t.stencilWrite),this._setDrawBuffers(t.drawBuffers),this._pipeline=t),this._pipelineInvalid=!1}invalidateBlending(){this._blendingInvalid=!0,this._pipelineInvalid=!0}invalidateCulling(){this._cullingInvalid=!0,this._pipelineInvalid=!0}invalidatePolygonOffset(){this._polygonOffsetInvalid=!0,this._pipelineInvalid=!0}invalidateDepthTest(){this._depthTestInvalid=!0,this._pipelineInvalid=!0}invalidateStencilTest(){this._stencilTestInvalid=!0,this._pipelineInvalid=!0}invalidateDepthWrite(){this._depthWriteInvalid=!0,this._pipelineInvalid=!0}invalidateColorWrite(){this._colorWriteInvalid=!0,this._pipelineInvalid=!0}invalidateStencilWrite(){this._stencilTestInvalid=!0,this._pipelineInvalid=!0}invalidateDrawBuffers(){this._drawBuffersInvalid=!0,this._pipelineInvalid=!0}_setBlending(t){this._blending=this._setSubState(t,this._blending,this._blendingInvalid,this._stateSetters.setBlending),this._blendingInvalid=!1}_setCulling(t){this._culling=this._setSubState(t,this._culling,this._cullingInvalid,this._stateSetters.setCulling),this._cullingInvalid=!1}_setPolygonOffset(t){this._polygonOffset=this._setSubState(t,this._polygonOffset,this._polygonOffsetInvalid,this._stateSetters.setPolygonOffset),this._polygonOffsetInvalid=!1}_setDepthTest(t){this._depthTest=this._setSubState(t,this._depthTest,this._depthTestInvalid,this._stateSetters.setDepthTest),this._depthTestInvalid=!1}_setStencilTest(t){this._stencilTest=this._setSubState(t,this._stencilTest,this._stencilTestInvalid,this._stateSetters.setStencilTest),this._stencilTestInvalid=!1}_setDepthWrite(t){this._depthWrite=this._setSubState(t,this._depthWrite,this._depthWriteInvalid,this._stateSetters.setDepthWrite),this._depthWriteInvalid=!1}_setColorWrite(t){this._colorWrite=this._setSubState(t,this._colorWrite,this._colorWriteInvalid,this._stateSetters.setColorWrite),this._colorWriteInvalid=!1}_setStencilWrite(t){this._stencilWrite=this._setSubState(t,this._stencilWrite,this._stencilWriteInvalid,this._stateSetters.setStencilWrite),this._stencilTestInvalid=!1}_setDrawBuffers(t){this._drawBuffers=this._setSubState(t,this._drawBuffers,this._drawBuffersInvalid,this._stateSetters.setDrawBuffers),this._drawBuffersInvalid=!1}_setSubState(t,e,i,n){return(i||t!==e)&&(n(t),this._pipelineInvalid=!0),t}}export{G as StateTracker,r as backFaceCullingParams,h as cullingParams,_ as defaultColorWriteParams,o as defaultDepthWriteParams,a as frontFaceCullingParams,c as makeBlending,v as makeColorWrite,d as makeCulling,f as makeDepthTest,g as makeDepthWrite,W as makeDrawBuffers,S as makePipelineState,u as makePolygonOffset,p as makeStencilTest,I as makeStencilWrite,l as separateBlendingParams,s as simpleBlendingParams};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/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 n}from"../../core/accessorSupport/decorators/property.js";import{cast as p}from"../../core/accessorSupport/decorators/cast.js";import"../../core/arrayUtils.js";import"../../core/has.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{contentEquals as h}from"../../support/basemapUtils.js";import{default3DCompatibility as f,default2DCompatibility as y}from"./support/basemapCompatibilityUtils.js";import v from"./support/BasemapGalleryItem.js";import b from"./support/LocalBasemapsSource.js";import B from"./support/PortalBasemapsSource.js";const g=s.ofType(v);function j(e){return e&&"esri.portal.Portal"===e.declaredClass}function w(e){return e&&!(e instanceof B)&&(!!e.portal||!!e.query)}function _(e){return e&&"basemaps"in e&&"state"in e&&"refresh"in e}let I=class extends i{constructor(e){super(e),this._loadingProjectionEngine=!1,this.includeCurrentBasemap=!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}),a((()=>this.includeCurrentBasemap),e),o((()=>this.items.every((e=>"loading"!==e.state))),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 s=this.view;if(!s?.map)return;const i="string"==typeof e?t.fromId(e):e;if(!i||!s.ready)return s.map.basemap=i,void this._clearOverride("activeBasemap");const a=i.spatialReference||this.items?.find((e=>this.basemapEquals(i,e.basemap)))?.spatialReference;if(a&&"spatialReferenceLocked"in s&&!s.spatialReferenceLocked){const t=s.spatialReference;if(null!=a&&!d(t,a)&&!m(s.spatialReference,a)&&!l())return this._override("activeBasemap",i),this._loadingProjectionEngine=!0,void u().then((()=>{this._get("activeBasemap")===e&&(s.map.basemap=e,s.spatialReference=a,this._clearOverride("activeBasemap"))}),(()=>{})).then((()=>{this._loadingProjectionEngine=!1}));s.map.basemap=i,this._clearOverride("activeBasemap"),null==a||d(s.spatialReference,a)||(s.spatialReference=a)}else s.map.basemap=i,this._clearOverride("activeBasemap")}get activeBasemapIndex(){const{state:e,items:t,activeBasemap:s}=this;if("ready"!==e)return-1;const i=t.findIndex((e=>e.basemap===s));return-1===i?t.findIndex((e=>this.basemapEquals(e.basemap,s))):i}get compatibilityFunction(){return"3d"===this.view?.type?f:y}set compatibilityFunction(e){this._overrideIfSome("compatibilityFunction",e)}castSource(e){return Array.isArray(e)||s.isCollection(e)?new b({basemaps:e}):j(e)?new B({portal:e}):w(e)?new B(e):_(e)?e:null}get state(){return this.view?.ready&&this.source?this._loadingProjectionEngine?"loading":"ready":"disabled"}basemapEquals(e,t){return h(e,t)}refresh(){this._recreateItems()}load(e){return this.addResolvingPromise(i.isLoadable(this.source)?this.source.load(e):null),Promise.resolve(this)}_recreateItems(){const e=this.source?.basemaps,{view:t,compatibilityFunction:s}=this,i=new Map(this.items.map((e=>[e.basemap,e])));function a(e){const a=i.get(e);return a?(i.delete(e),a):new v({basemap:e,compatibilityFunction:s,view:t})}this.items.removeAll(),e&&this.items.addMany(e.map(a));const r=-1!==this.activeBasemapIndex;this.includeCurrentBasemap&&!r&&null!==this.activeBasemap&&this.items.unshift(a(this.activeBasemap)),i.forEach((e=>e.destroy()))}_updateItems(){for(const e of this.items)e.compatibilityFunction=this.compatibilityFunction,e.view=this.view}};e([n()],I.prototype,"_loadingProjectionEngine",void 0),e([n()],I.prototype,"activeBasemap",null),e([n({readOnly:!0})],I.prototype,"activeBasemapIndex",null),e([n()],I.prototype,"compatibilityFunction",null),e([n()],I.prototype,"includeCurrentBasemap",void 0),e([n({readOnly:!0,type:g})],I.prototype,"items",void 0),e([n()],I.prototype,"source",void 0),e([p("source")],I.prototype,"castSource",null),e([n({readOnly:!0})],I.prototype,"state",null),e([n()],I.prototype,"view",void 0),I=e([c("esri.widgets.BasemapGallery.BasemapGalleryViewModel")],I);const R=I;export{R as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Basemap.js";import i from"../../core/Collection.js";import s from"../../core/Loadable.js";import{watch as a,on as r,when as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import{cast as p}from"../../core/accessorSupport/decorators/cast.js";import"../../core/arrayUtils.js";import"../../core/has.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{contentEquals as h}from"../../support/basemapUtils.js";import{default3DCompatibility as f,default2DCompatibility as v}from"./support/basemapCompatibilityUtils.js";import y from"./support/BasemapGalleryItem.js";import b from"./support/LocalBasemapsSource.js";import B from"./support/PortalBasemapsSource.js";const g=i.ofType(y);function _(e){return e&&"esri.portal.Portal"===e.declaredClass}function j(e){return e&&!(e instanceof B)&&(!!e.portal||!!e.query)}function w(e){return e&&"basemaps"in e&&"state"in e&&"refresh"in e}let I=class extends s{constructor(e){super(e),this._loadingProjectionEngine=!1,this._originalActiveBasemap=null,this.includeCurrentBasemap=!1,this.items=new g,this.source=new B,this.view=null}initialize(){const e=()=>this._recreateItems();this.addHandles([a((()=>this.view),(()=>{this._originalActiveBasemap=this.activeBasemap}),{initial:!0}),a((()=>"ready"===this.state?this.compatibilityFunction:null),(()=>this._updateItems())),r((()=>this.source?.basemaps),"change",e,{onListenerAdd:e}),a((()=>this.includeCurrentBasemap),e),o((()=>this.items.every((e=>"loading"!==e.state))),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 i=this.view;if(!i?.map)return;const s="string"==typeof e?t.fromId(e):e;if(!s||!i.ready)return i.map.basemap=s,void this._clearOverride("activeBasemap");const a=s.spatialReference||this.items?.find((e=>this.basemapEquals(s,e.basemap)))?.spatialReference;if(a&&"spatialReferenceLocked"in i&&!i.spatialReferenceLocked){const t=i.spatialReference;if(null!=a&&!d(t,a)&&!m(i.spatialReference,a)&&!l())return this._override("activeBasemap",s),this._loadingProjectionEngine=!0,void u().then((()=>{this._get("activeBasemap")===e&&(i.map.basemap=e,i.spatialReference=a,this._clearOverride("activeBasemap"))}),(()=>{})).then((()=>{this._loadingProjectionEngine=!1}));i.map.basemap=s,this._clearOverride("activeBasemap"),null==a||d(i.spatialReference,a)||(i.spatialReference=a)}else i.map.basemap=s,this._clearOverride("activeBasemap")}get activeBasemapIndex(){const{state:e,activeBasemap:t}=this;return"ready"!==e?-1:this._findBasemapIndex(t)}get compatibilityFunction(){return"3d"===this.view?.type?f:v}set compatibilityFunction(e){this._overrideIfSome("compatibilityFunction",e)}castSource(e){return Array.isArray(e)||i.isCollection(e)?new b({basemaps:e}):_(e)?new B({portal:e}):j(e)?new B(e):w(e)?e:null}get state(){return this.view?.ready&&this.source?this._loadingProjectionEngine?"loading":"ready":"disabled"}basemapEquals(e,t){return h(e,t)}refresh(){this._recreateItems()}load(e){return this.addResolvingPromise(s.isLoadable(this.source)?this.source.load(e):null),Promise.resolve(this)}_findBasemapIndex(e){const{items:t}=this,i=t.findIndex((t=>t.basemap===e));return-1===i?t.findIndex((t=>this.basemapEquals(t.basemap,e))):i}_recreateItems(){const e=this.source?.basemaps,{view:t,compatibilityFunction:i}=this,s=new Map(this.items.map((e=>[e.basemap,e])));function a(e){const a=s.get(e);return a?(s.delete(e),a):new y({basemap:e,compatibilityFunction:i,view:t})}this.items.removeAll(),e&&this.items.addMany(e.map(a));const r=-1!==this._findBasemapIndex(this._originalActiveBasemap);this.includeCurrentBasemap&&!r&&null!=this._originalActiveBasemap&&this.items.unshift(a(this._originalActiveBasemap)),s.forEach((e=>e.destroy()))}_updateItems(){for(const e of this.items)e.compatibilityFunction=this.compatibilityFunction,e.view=this.view}};e([n()],I.prototype,"_loadingProjectionEngine",void 0),e([n()],I.prototype,"activeBasemap",null),e([n({readOnly:!0})],I.prototype,"activeBasemapIndex",null),e([n()],I.prototype,"compatibilityFunction",null),e([n()],I.prototype,"includeCurrentBasemap",void 0),e([n({readOnly:!0,type:g})],I.prototype,"items",void 0),e([n()],I.prototype,"source",void 0),e([p("source")],I.prototype,"castSource",null),e([n({readOnly:!0})],I.prototype,"state",null),e([n()],I.prototype,"view",void 0),I=e([c("esri.widgets.BasemapGallery.BasemapGalleryViewModel")],I);const R=I;export{R 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{prefersReducedMotion as t}from"../../core/a11yUtils.js";import{eventKey as i}from"../../core/events.js";import{watch as r,initial as a}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{getColorsFromRenderer as n}from"../../renderers/support/utils.js";import l from"../Widget.js";import d from"./FeatureMedia/FeatureMediaViewModel.js";import m from"./support/FeatureElementInfo.js";import{shouldOpenInNewTab as c}from"./support/featureUtils.js";import{loadCalciteComponents as p}from"../support/componentsUtils.js";import{isRTL as h}from"../support/widgetUtils.js";import{messageBundle as u}from"../support/decorators/messageBundle.js";import{tsx as f}from"../support/jsxFactory.js";import{isDarkTheme as _}from"../../support/themeUtils.js";import{substitute as v}from"../../intl/substitute.js";const M="esri-feature-media",g={base:M,mediaContainer:`${M}__container`,mediaItemContainer:`${M}__item-container`,mediaItem:`${M}__item`,mediaItemText:`${M}__item-text`,mediaItemTitle:`${M}__item-title`,mediaItemCaption:`${M}__item-caption`,mediaNavigation:`${M}__item-navigation`,mediaPagination:`${M}__pagination`,mediaPaginationText:`${M}__pagination-text`,mediaPrevious:`${M}__previous`,mediaPreviousIconLTR:`${M}__previous-icon`,mediaPreviousIconRTL:`${M}__previous-icon--rtl`,mediaNext:`${M}__next`,mediaNextIconLTR:`${M}__next-icon`,mediaNextIconRTL:`${M}__next-icon--rtl`,mediaChart:`${M}__chart`,mediaPaginationButton:`${M}__pagination-button`,mediaPaginationIcon:`${M}__pagination-icon`,mediaChartRendered:`${M}__chart--rendered`},w=15,I="category",A="value",y="rgba(50, 50, 50, 1)",C=250,x=500,T=200;let b=class extends l{constructor(e,t){super(e,t),this._refreshTimer=null,this._refreshIntervalInfo=null,this._featureElementInfo=null,this._chartRootMap=new WeakMap,this.viewModel=new d,this.messages=null,this._disposeChart=e=>{this._chartRootMap.get(e)?.dispose(),this._chartRootMap.delete(e)},this._createChart=async e=>{const{destroyed:t,viewModel:i}=this;if(t||!i||!e)return;const{createRoot:r}=await import("../support/chartUtilsAm5.js"),a=await r(e);this._chartRootMap.set(e,a),this._renderChart({mediaInfo:i.activeMediaInfo,root:a})}}initialize(){this._featureElementInfo=new m,this.addHandles([r((()=>[this.viewModel?.activeMediaInfo,this.viewModel?.activeMediaInfoIndex]),(()=>this._setupMediaRefreshTimer()),a),r((()=>[this.viewModel?.description,this.viewModel?.title]),(()=>this._setupFeatureElementInfo()),a)])}loadDependencies(){return p({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js")})}destroy(){this._clearMediaRefreshTimer(),this._featureElementInfo?.destroy()}get attributes(){return this.viewModel.attributes}set attributes(e){this.viewModel.attributes=e}get activeMediaInfoIndex(){return this.viewModel.activeMediaInfoIndex}set activeMediaInfoIndex(e){this.viewModel.activeMediaInfoIndex=e}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get fieldInfoMap(){return this.viewModel.fieldInfoMap}set fieldInfoMap(e){this.viewModel.fieldInfoMap=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get mediaInfos(){return this.viewModel.mediaInfos}set mediaInfos(e){this.viewModel.mediaInfos=e}get popupTemplate(){return this.viewModel.popupTemplate}set popupTemplate(e){this.viewModel.popupTemplate=e}get relatedInfos(){return this.viewModel.relatedInfos}set relatedInfos(e){this.viewModel.relatedInfos=e}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}render(){return f("div",{bind:this,class:g.base,onkeyup:this._handleMediaKeyup},this._featureElementInfo?.render(),this._renderMedia())}_renderMedia(){const{formattedMediaInfoCount:e,activeMediaInfoIndex:t}=this.viewModel,i=this._renderMediaText();return e?f("div",{key:"media-element-container",class:g.mediaContainer},this._renderMediaInfo(),f("div",{class:g.mediaNavigation},i,e>1?f("div",{class:g.mediaPagination},this._renderMediaPageButton("previous"),f("span",{class:g.mediaPaginationText},v(this.messages.pageText,{index:t+1,total:e})),this._renderMediaPageButton("next")):null)):null}_renderMediaText(){const{activeMediaInfo:e}=this.viewModel;if(!e)return null;const t=e&&e.title?f("div",{key:"media-title",class:g.mediaItemTitle,innerHTML:e.title}):null,i=e&&e.caption?f("div",{key:"media-caption",class:g.mediaItemCaption,innerHTML:e.caption}):null;return t||i?f("div",{key:"media-text",class:g.mediaItemText},t,i):null}_renderImageMediaInfo(e){const{_refreshIntervalInfo:t}=this,{activeMediaInfoIndex:i,formattedMediaInfoCount:r}=this.viewModel,{value:a,refreshInterval:s,altText:o,title:n,type:l}=e,{sourceURL:d,linkURL:m}=a,p=c(m??void 0)?"_blank":"_self",h="_blank"===p?"noreferrer":"",u=s?t:null,_=u?u.timestamp:0,v=u?u.sourceURL:d,M=f("img",{alt:o||n,key:`media-${l}-${i}-${r}-${_}`,src:v??void 0});return(m?f("a",{title:n,href:m,rel:h,target:p},M):null)??M}_renderChartMediaInfo(e){const{activeMediaInfoIndex:t,formattedMediaInfoCount:i}=this.viewModel;return f("div",{key:`media-${e.type}-${t}-${i}`,bind:this,class:g.mediaChart,afterCreate:this._createChart,afterRemoved:this._disposeChart})}_renderMediaInfoType(){const{activeMediaInfo:e}=this.viewModel;return e?"image"===e.type?this._renderImageMediaInfo(e):e.type.includes("chart")?this._renderChartMediaInfo(e):null:null}_renderMediaInfo(){const{activeMediaInfo:e}=this.viewModel;return e?f("div",{key:"media-container",class:g.mediaItemContainer},f("div",{key:"media-item-container",class:g.mediaItem},this._renderMediaInfoType())):null}_renderMediaPageButton(e){if(this.viewModel.formattedMediaInfoCount<2)return null;const t="previous"===e,i=t?this.messages.previous:this.messages.next,r=t?"chevron-left":"chevron-right",a=t?"media-previous":"media-next",s=t?this._previous:this._next;return f("button",{type:"button",key:a,title:i,"aria-label":i,tabIndex:0,class:g.mediaPaginationButton,bind:this,onclick:s},f("calcite-icon",{class:g.mediaPaginationIcon,scale:"s",icon:r}))}_setupFeatureElementInfo(){const{description:e,title:t}=this;this._featureElementInfo?.set({description:e,title:t})}_next(){this.viewModel.next()}_previous(){this.viewModel.previous()}_getRenderer(){if(!this.viewModel)return;const{isAggregate:e,layer:t}=this.viewModel;return e&&t?.featureReduction&&"renderer"in t.featureReduction?t.featureReduction.renderer:t?.renderer}async _getSeriesColors(e){const{colorAm5:t}=await import("./FeatureMedia/chartCommon.js"),i=new Map;return e.forEach((e=>{e.color&&i.set(e,t(e.color.toCss(!0)))})),i}async _getRendererColors(){const{colorAm5:e}=await import("./FeatureMedia/chartCommon.js"),t=new Map,i=this._getRenderer(),r="default";if(!i)return t;const a=await n(i);a.delete(r);return Array.from(a.values()).every((e=>1===e?.length))?(Array.from(a.keys()).forEach((i=>{const r=a.get(i)?.[0]?.toCss(!0);r&&t.set(i,e(r))})),t):t}_handleMediaKeyup(e){const t=i(e);"ArrowLeft"===t&&(e.stopPropagation(),this.viewModel.previous()),"ArrowRight"===t&&(e.stopPropagation(),this.viewModel.next())}_canAnimateChart(){return!!this.viewModel&&(!!this.viewModel.abilities.chartAnimation&&!t())}_getChartAnimationMS(){return this._canAnimateChart()?C:0}_getChartSeriesAnimationMS(){return this._canAnimateChart()?x:0}async _renderChart(e){const{root:t,mediaInfo:i}=e,{value:r,type:a}=i,{ResponsiveThemeAm5:s,DarkThemeAm5:o,AnimatedThemeAm5:n,ColorSetAm5:l,ThemeAm5:d,esriChartColorSet:m}=await import("./FeatureMedia/chartCommon.js"),c=d.new(t);c.rule("ColorSet").set("colors",m);const p=[s.new(t),c];_()&&p.push(o.new(t)),this._canAnimateChart()&&p.push(n.new(t)),t.setThemes(p);const h=await this._getRendererColors(),u=await this._getSeriesColors(r.series),f=l.new(t,{}),v=u.get(r.series[0]),M=v?{lineSettings:{stroke:v}}:void 0,g=r.series.map(((e,t)=>{const i=u.get(e)||h.get(e.fieldName)||f.getIndex(t);return{[I]:e.tooltip,[A]:e.value,columnSettings:{fill:i,stroke:i},...M}})).filter((e=>"pie-chart"!==a||null!=e.value&&e.value>0));"pie-chart"===a?this._createPieChart(e,g):this._createXYChart(e,g)}_getDirection(){return h(this.container)?"rtl":"ltr"}_isInversed(){return!!h(this.container)}async _customizeChartTooltip(e,t="horizontal"){const{colorAm5:i}=await import("./FeatureMedia/chartCommon.js");e.setAll({pointerOrientation:t}),e.get("background")?.setAll({stroke:i(y)}),e.label.setAll({direction:this._getDirection(),oversizedBehavior:"wrap",maxWidth:T})}async _createPieChart(e,t){const{TooltipAm5:i}=await import("./FeatureMedia/chartCommon.js"),{PieChartAm5:r,PieSeriesAm5:a}=await import("./FeatureMedia/pieChart.js"),{mediaInfo:s,root:o}=e,{title:n}=s,l=5,d=s?.altText||s?.title||"",m=o.container.children.push(r.new(o,{ariaLabel:d,focusable:!0,paddingBottom:l,paddingTop:l,paddingLeft:l,paddingRight:l})),c="{category}: {valuePercentTotal.formatNumber('0.00')}%\n ({value})",p=i.new(o,{labelText:c}),h=m.series.push(a.new(o,{name:n,valueField:A,categoryField:I,tooltip:p}));h.ticks.template.set("forceHidden",!0),h.labels.template.set("forceHidden",!0),h.slices.template.states.create("active",{shiftRadius:l}),this._customizeChartTooltip(p),h.slices.template.setAll({ariaLabel:c,focusable:!0,templateField:"columnSettings"}),h.data.setAll(t),h.appear(this._getChartSeriesAnimationMS()),m.appear(this._getChartAnimationMS()),m.root.dom.classList.toggle(g.mediaChartRendered,!0)}_getMinSeriesValue(e){let t=0;return e.forEach((e=>t=Math.min(e.value,t))),t}async _createColumnChart(e,t,i){const{TooltipAm5:r,ScrollbarAm5:a}=await import("./FeatureMedia/chartCommon.js"),{CategoryAxisAm5:s,AxisRendererXAm5:o,ValueAxisAm5:n,AxisRendererYAm5:l,ColumnSeriesAm5:d}=await import("./FeatureMedia/xyChart.js"),{mediaInfo:m,root:c}=t,{value:p,title:h}=m;e.setAll({wheelX:"panX",wheelY:"zoomX"});const u=e.xAxes.push(s.new(c,{renderer:o.new(c,{inversed:this._isInversed()}),categoryField:I}));u.get("renderer").labels.template.setAll({forceHidden:!0});const f=e.yAxes.push(n.new(c,{renderer:l.new(c,{inside:!1}),min:this._getMinSeriesValue(p.series)}));f.get("renderer").labels.template.setAll({direction:this._getDirection()});const _="{categoryX}",v=r.new(c,{labelText:_}),M=e.series.push(d.new(c,{name:h,xAxis:u,yAxis:f,valueYField:A,categoryXField:I,tooltip:v}));this._customizeChartTooltip(v),M.columns.template.setAll({ariaLabel:_,focusable:!0,templateField:"columnSettings"}),p.series.length>w&&e.set("scrollbarX",a.new(c,{orientation:"horizontal"})),u.data.setAll(i),M.data.setAll(i),M.appear(this._getChartSeriesAnimationMS()),e.appear(this._getChartAnimationMS())}async _createBarChart(e,t,i){const{TooltipAm5:r,ScrollbarAm5:a}=await import("./FeatureMedia/chartCommon.js"),{CategoryAxisAm5:s,AxisRendererXAm5:o,ValueAxisAm5:n,AxisRendererYAm5:l,ColumnSeriesAm5:d}=await import("./FeatureMedia/xyChart.js"),{mediaInfo:m,root:c}=t,{value:p,title:h}=m;e.setAll({wheelX:"panY",wheelY:"zoomY"});const u=e.yAxes.push(s.new(c,{renderer:l.new(c,{inversed:!0}),categoryField:I}));u.get("renderer").labels.template.setAll({forceHidden:!0});const f=e.xAxes.push(n.new(c,{renderer:o.new(c,{inside:!1,inversed:this._isInversed()}),min:this._getMinSeriesValue(p.series)}));f.get("renderer").labels.template.setAll({direction:this._getDirection()});const _="{categoryY}",v=r.new(c,{labelText:_}),M=e.series.push(d.new(c,{name:h,xAxis:f,yAxis:u,valueXField:A,categoryYField:I,tooltip:v}));this._customizeChartTooltip(v,"vertical"),M.columns.template.setAll({ariaLabel:_,focusable:!0,templateField:"columnSettings"}),p.series.length>w&&e.set("scrollbarY",a.new(c,{orientation:"vertical"})),u.data.setAll(i),M.data.setAll(i),M.appear(this._getChartSeriesAnimationMS()),e.appear(this._getChartAnimationMS())}async _createLineChart(e,t,i){const{TooltipAm5:r,ScrollbarAm5:a}=await import("./FeatureMedia/chartCommon.js"),{CategoryAxisAm5:s,AxisRendererXAm5:o,ValueAxisAm5:n,AxisRendererYAm5:l,LineSeriesAm5:d}=await import("./FeatureMedia/xyChart.js"),{root:m,mediaInfo:c}=t,{value:p,title:h}=c;e.setAll({wheelX:"panX",wheelY:"zoomX"});const u=e.xAxes.push(s.new(m,{renderer:o.new(m,{inversed:this._isInversed()}),categoryField:I}));u.get("renderer").labels.template.setAll({forceHidden:!0});const f=e.yAxes.push(n.new(m,{renderer:l.new(m,{inside:!1}),min:this._getMinSeriesValue(p.series)}));f.get("renderer").labels.template.setAll({direction:this._getDirection()});const _="{categoryX}",v=r.new(m,{labelText:_}),M=e.series.push(d.new(m,{name:h,xAxis:u,yAxis:f,valueYField:A,categoryXField:I,tooltip:v}));M.strokes.template.setAll({templateField:"lineSettings"}),this._customizeChartTooltip(v,"vertical"),p.series.length>w&&e.set("scrollbarX",a.new(m,{orientation:"horizontal"})),u.data.setAll(i),M.data.setAll(i),M.appear(this._getChartSeriesAnimationMS()),e.appear(this._getChartAnimationMS())}async _createXYChart(e,t){const{XYChartAm5:i,XYCursorAm5:r}=await import("./FeatureMedia/xyChart.js"),{root:a,mediaInfo:s}=e,{type:o}=s,n=s?.altText||s?.title||"",l=a.container.children.push(i.new(a,{ariaLabel:n,focusable:!0,panX:!0,panY:!0}));l.set("cursor",r.new(a,{})),"column-chart"===o&&await this._createColumnChart(l,e,t),"bar-chart"===o&&await this._createBarChart(l,e,t),"line-chart"===o&&await this._createLineChart(l,e,t),l.root.dom.classList.toggle(g.mediaChartRendered,!0)}_clearMediaRefreshTimer(){const{_refreshTimer:e}=this;e&&(clearTimeout(e),this._refreshTimer=null)}_updateMediaInfoTimestamp(e){const t=Date.now();this._refreshIntervalInfo={timestamp:t,sourceURL:e&&this._getImageSource(e,t)}}_setupMediaRefreshTimer(){this._clearMediaRefreshTimer();const{activeMediaInfo:e}=this.viewModel;e&&"image"===e.type&&e.refreshInterval&&this._setRefreshTimeout(e)}_setRefreshTimeout(e){const{refreshInterval:t,value:i}=e;if(!t)return;const r=6e4*t;this._updateMediaInfoTimestamp(i.sourceURL);const a=setInterval((()=>{this._updateMediaInfoTimestamp(i.sourceURL)}),r);this._refreshTimer=a}_getImageSource(e,t){const i=e.includes("?")?"&":"?",[r,a=""]=e.split("#");return`${r}${i}timestamp=${t}${a?"#":""}${a}`}};e([s()],b.prototype,"_refreshIntervalInfo",void 0),e([s()],b.prototype,"attributes",null),e([s()],b.prototype,"activeMediaInfoIndex",null),e([s()],b.prototype,"description",null),e([s()],b.prototype,"fieldInfoMap",null),e([s()],b.prototype,"layer",null),e([s()],b.prototype,"mediaInfos",null),e([s()],b.prototype,"popupTemplate",null),e([s()],b.prototype,"relatedInfos",null),e([s()],b.prototype,"title",null),e([s({type:d})],b.prototype,"viewModel",void 0),e([s(),u("esri/widgets/Feature/t9n/Feature")],b.prototype,"messages",void 0),b=e([o("esri.widgets.Feature.FeatureMedia")],b);const R=b;export{R as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{prefersReducedMotion as t}from"../../core/a11yUtils.js";import{eventKey as i}from"../../core/events.js";import{watch as r,initial as a}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{getColorsFromRenderer as n}from"../../renderers/support/utils.js";import l from"../Widget.js";import d from"./FeatureMedia/FeatureMediaViewModel.js";import m from"./support/FeatureElementInfo.js";import{shouldOpenInNewTab as c}from"./support/featureUtils.js";import{loadCalciteComponents as p}from"../support/componentsUtils.js";import{isRTL as h}from"../support/widgetUtils.js";import{messageBundle as u}from"../support/decorators/messageBundle.js";import{tsx as f}from"../support/jsxFactory.js";import{isDarkTheme as _}from"../../support/themeUtils.js";import{substitute as v}from"../../intl/substitute.js";const M="esri-feature-media",g={base:M,mediaContainer:`${M}__container`,mediaItemContainer:`${M}__item-container`,mediaItem:`${M}__item`,mediaItemText:`${M}__item-text`,mediaItemTitle:`${M}__item-title`,mediaItemCaption:`${M}__item-caption`,mediaNavigation:`${M}__item-navigation`,mediaPagination:`${M}__pagination`,mediaPaginationText:`${M}__pagination-text`,mediaPrevious:`${M}__previous`,mediaPreviousIconLTR:`${M}__previous-icon`,mediaPreviousIconRTL:`${M}__previous-icon--rtl`,mediaNext:`${M}__next`,mediaNextIconLTR:`${M}__next-icon`,mediaNextIconRTL:`${M}__next-icon--rtl`,mediaChart:`${M}__chart`,mediaPaginationButton:`${M}__pagination-button`,mediaPaginationIcon:`${M}__pagination-icon`,mediaChartRendered:`${M}__chart--rendered`},w=15,I="category",A="value",y="rgba(50, 50, 50, 1)",C=250,x=500,T=200;let b=class extends l{constructor(e,t){super(e,t),this._refreshTimer=null,this._refreshIntervalInfo=null,this._featureElementInfo=null,this._chartRootMap=new WeakMap,this.viewModel=new d,this.messages=null,this._disposeChart=e=>{this._chartRootMap.get(e)?.dispose(),this._chartRootMap.delete(e)},this._createChart=async e=>{const{destroyed:t,viewModel:i}=this;if(t||!i||!e)return;const{createRoot:r}=await import("../support/chartUtilsAm5.js"),a=await r(e);this._chartRootMap.set(e,a),this._renderChart({mediaInfo:i.activeMediaInfo,root:a})}}initialize(){this._featureElementInfo=new m,this.addHandles([r((()=>[this.viewModel?.activeMediaInfo,this.viewModel?.activeMediaInfoIndex]),(()=>this._setupMediaRefreshTimer()),a),r((()=>[this.viewModel?.description,this.viewModel?.title]),(()=>this._setupFeatureElementInfo()),a)])}loadDependencies(){return p({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js")})}destroy(){this._clearMediaRefreshTimer(),this._featureElementInfo?.destroy()}get attributes(){return this.viewModel.attributes}set attributes(e){this.viewModel.attributes=e}get activeMediaInfoIndex(){return this.viewModel.activeMediaInfoIndex}set activeMediaInfoIndex(e){this.viewModel.activeMediaInfoIndex=e}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get fieldInfoMap(){return this.viewModel.fieldInfoMap}set fieldInfoMap(e){this.viewModel.fieldInfoMap=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get mediaInfos(){return this.viewModel.mediaInfos}set mediaInfos(e){this.viewModel.mediaInfos=e}get popupTemplate(){return this.viewModel.popupTemplate}set popupTemplate(e){this.viewModel.popupTemplate=e}get relatedInfos(){return this.viewModel.relatedInfos}set relatedInfos(e){this.viewModel.relatedInfos=e}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}render(){return f("div",{bind:this,class:g.base,onkeyup:this._handleMediaKeyup},this._featureElementInfo?.render(),this._renderMedia())}_renderMedia(){const{formattedMediaInfoCount:e,activeMediaInfoIndex:t}=this.viewModel,i=this._renderMediaText();return e?f("div",{key:"media-element-container",class:g.mediaContainer},this._renderMediaInfo(),f("div",{class:g.mediaNavigation},i,e>1?f("div",{class:g.mediaPagination},this._renderMediaPageButton("previous"),f("span",{class:g.mediaPaginationText},v(this.messages.pageText,{index:t+1,total:e})),this._renderMediaPageButton("next")):null)):null}_renderMediaText(){const{activeMediaInfo:e}=this.viewModel;if(!e)return null;const t=e&&e.title?f("div",{key:"media-title",class:g.mediaItemTitle,innerHTML:e.title}):null,i=e&&e.caption?f("div",{key:"media-caption",class:g.mediaItemCaption,innerHTML:e.caption}):null;return t||i?f("div",{key:"media-text",class:g.mediaItemText},t,i):null}_renderImageMediaInfo(e){const{_refreshIntervalInfo:t}=this,{activeMediaInfoIndex:i,formattedMediaInfoCount:r}=this.viewModel,{value:a,refreshInterval:s,altText:o,title:n,type:l}=e,{sourceURL:d,linkURL:m}=a,p=c(m??void 0)?"_blank":"_self",h="_blank"===p?"noreferrer":"",u=s?t:null,_=u?u.timestamp:0,v=u?u.sourceURL:d,M=f("img",{alt:o||n,key:`media-${l}-${i}-${r}-${_}`,src:v??void 0});return(m?f("a",{title:n,href:m,rel:h,target:p},M):null)??M}_renderChartMediaInfo(e){const{activeMediaInfoIndex:t,formattedMediaInfoCount:i}=this.viewModel;return f("div",{key:`media-${e.type}-${t}-${i}`,bind:this,class:g.mediaChart,afterCreate:this._createChart,afterRemoved:this._disposeChart})}_renderMediaInfoType(){const{activeMediaInfo:e}=this.viewModel;return e?"image"===e.type?this._renderImageMediaInfo(e):e.type.includes("chart")?this._renderChartMediaInfo(e):null:null}_renderMediaInfo(){const{activeMediaInfo:e}=this.viewModel;return e?f("div",{key:"media-container",class:g.mediaItemContainer},f("div",{key:"media-item-container",class:g.mediaItem},this._renderMediaInfoType())):null}_renderMediaPageButton(e){if(this.viewModel.formattedMediaInfoCount<2)return null;const t="previous"===e,i=t?this.messages.previous:this.messages.next,r=t?"chevron-left":"chevron-right",a=t?"media-previous":"media-next",s=t?this._previous:this._next;return f("button",{type:"button",key:a,title:i,"aria-label":i,tabIndex:0,class:g.mediaPaginationButton,bind:this,onclick:s},f("calcite-icon",{class:g.mediaPaginationIcon,scale:"s",icon:r}))}_setupFeatureElementInfo(){const{description:e,title:t}=this;this._featureElementInfo?.set({description:e,title:t})}_next(){this.viewModel.next()}_previous(){this.viewModel.previous()}_getRenderer(){if(!this.viewModel)return;const{isAggregate:e,layer:t}=this.viewModel;return e&&t?.featureReduction&&"renderer"in t.featureReduction?t.featureReduction.renderer:t?.renderer}async _getSeriesColors(e){const{colorAm5:t}=await import("./FeatureMedia/chartCommon.js"),i=new Map;return e.forEach((e=>{e.color&&i.set(e,t(e.color.toCss(!0)))})),i}async _getRendererColors(){const{colorAm5:e}=await import("./FeatureMedia/chartCommon.js"),t=new Map,i=this._getRenderer(),r="default";if(!i)return t;const a=await n(i);a.delete(r);return Array.from(a.values()).every((e=>1===e?.length))?(Array.from(a.keys()).forEach((i=>{const r=a.get(i)?.[0]?.toCss(!0);r&&t.set(i,e(r))})),t):t}_handleMediaKeyup(e){const t=i(e);"ArrowLeft"===t&&(e.stopPropagation(),this.viewModel.previous()),"ArrowRight"===t&&(e.stopPropagation(),this.viewModel.next())}_canAnimateChart(){return!!this.viewModel&&(!!this.viewModel.abilities.chartAnimation&&!t())}_getChartAnimationMS(){return this._canAnimateChart()?C:0}_getChartSeriesAnimationMS(){return this._canAnimateChart()?x:0}async _renderChart(e){const{root:t,mediaInfo:i}=e,{value:r,type:a}=i,{ResponsiveThemeAm5:s,DarkThemeAm5:o,AnimatedThemeAm5:n,ColorSetAm5:l,ThemeAm5:d,esriChartColorSet:m}=await import("./FeatureMedia/chartCommon.js"),c=d.new(t);c.rule("ColorSet").set("colors",m),c.rule("ColorSet").set("reuse",!0);const p=[s.new(t),c];_()&&p.push(o.new(t)),this._canAnimateChart()&&p.push(n.new(t)),t.setThemes(p);const h=await this._getRendererColors(),u=await this._getSeriesColors(r.series),f=l.new(t,{}),v=u.get(r.series[0]),M=v?{lineSettings:{stroke:v}}:void 0,g=r.series.map(((e,t)=>{const i=u.get(e)||h.get(e.fieldName)||f.getIndex(t);return{[I]:e.tooltip,[A]:e.value,columnSettings:{fill:i,stroke:i},...M}})).filter((e=>"pie-chart"!==a||null!=e.value&&e.value>0));"pie-chart"===a?this._createPieChart(e,g):this._createXYChart(e,g)}_getDirection(){return h(this.container)?"rtl":"ltr"}_isInversed(){return!!h(this.container)}async _customizeChartTooltip(e,t="horizontal"){const{colorAm5:i}=await import("./FeatureMedia/chartCommon.js");e.setAll({pointerOrientation:t}),e.get("background")?.setAll({stroke:i(y)}),e.label.setAll({direction:this._getDirection(),oversizedBehavior:"wrap",maxWidth:T})}async _createPieChart(e,t){const{TooltipAm5:i}=await import("./FeatureMedia/chartCommon.js"),{PieChartAm5:r,PieSeriesAm5:a}=await import("./FeatureMedia/pieChart.js"),{mediaInfo:s,root:o}=e,{title:n}=s,l=5,d=s?.altText||s?.title||"",m=o.container.children.push(r.new(o,{ariaLabel:d,focusable:!0,paddingBottom:l,paddingTop:l,paddingLeft:l,paddingRight:l})),c="{category}: {valuePercentTotal.formatNumber('0.00')}%\n ({value})",p=i.new(o,{labelText:c}),h=m.series.push(a.new(o,{name:n,valueField:A,categoryField:I,tooltip:p}));h.ticks.template.set("forceHidden",!0),h.labels.template.set("forceHidden",!0),h.slices.template.states.create("active",{shiftRadius:l}),this._customizeChartTooltip(p),h.slices.template.setAll({ariaLabel:c,focusable:!0,templateField:"columnSettings"}),h.data.setAll(t),h.appear(this._getChartSeriesAnimationMS()),m.appear(this._getChartAnimationMS()),m.root.dom.classList.toggle(g.mediaChartRendered,!0)}_getMinSeriesValue(e){let t=0;return e.forEach((e=>t=Math.min(e.value,t))),t}async _createColumnChart(e,t,i){const{TooltipAm5:r,ScrollbarAm5:a}=await import("./FeatureMedia/chartCommon.js"),{CategoryAxisAm5:s,AxisRendererXAm5:o,ValueAxisAm5:n,AxisRendererYAm5:l,ColumnSeriesAm5:d}=await import("./FeatureMedia/xyChart.js"),{mediaInfo:m,root:c}=t,{value:p,title:h}=m;e.setAll({wheelX:"panX",wheelY:"zoomX"});const u=e.xAxes.push(s.new(c,{renderer:o.new(c,{inversed:this._isInversed()}),categoryField:I}));u.get("renderer").labels.template.setAll({forceHidden:!0});const f=e.yAxes.push(n.new(c,{renderer:l.new(c,{inside:!1}),min:this._getMinSeriesValue(p.series)}));f.get("renderer").labels.template.setAll({direction:this._getDirection()});const _="{categoryX}",v=r.new(c,{labelText:_}),M=e.series.push(d.new(c,{name:h,xAxis:u,yAxis:f,valueYField:A,categoryXField:I,tooltip:v}));this._customizeChartTooltip(v),M.columns.template.setAll({ariaLabel:_,focusable:!0,templateField:"columnSettings"}),p.series.length>w&&e.set("scrollbarX",a.new(c,{orientation:"horizontal"})),u.data.setAll(i),M.data.setAll(i),M.appear(this._getChartSeriesAnimationMS()),e.appear(this._getChartAnimationMS())}async _createBarChart(e,t,i){const{TooltipAm5:r,ScrollbarAm5:a}=await import("./FeatureMedia/chartCommon.js"),{CategoryAxisAm5:s,AxisRendererXAm5:o,ValueAxisAm5:n,AxisRendererYAm5:l,ColumnSeriesAm5:d}=await import("./FeatureMedia/xyChart.js"),{mediaInfo:m,root:c}=t,{value:p,title:h}=m;e.setAll({wheelX:"panY",wheelY:"zoomY"});const u=e.yAxes.push(s.new(c,{renderer:l.new(c,{inversed:!0}),categoryField:I}));u.get("renderer").labels.template.setAll({forceHidden:!0});const f=e.xAxes.push(n.new(c,{renderer:o.new(c,{inside:!1,inversed:this._isInversed()}),min:this._getMinSeriesValue(p.series)}));f.get("renderer").labels.template.setAll({direction:this._getDirection()});const _="{categoryY}",v=r.new(c,{labelText:_}),M=e.series.push(d.new(c,{name:h,xAxis:f,yAxis:u,valueXField:A,categoryYField:I,tooltip:v}));this._customizeChartTooltip(v,"vertical"),M.columns.template.setAll({ariaLabel:_,focusable:!0,templateField:"columnSettings"}),p.series.length>w&&e.set("scrollbarY",a.new(c,{orientation:"vertical"})),u.data.setAll(i),M.data.setAll(i),M.appear(this._getChartSeriesAnimationMS()),e.appear(this._getChartAnimationMS())}async _createLineChart(e,t,i){const{TooltipAm5:r,ScrollbarAm5:a}=await import("./FeatureMedia/chartCommon.js"),{CategoryAxisAm5:s,AxisRendererXAm5:o,ValueAxisAm5:n,AxisRendererYAm5:l,LineSeriesAm5:d}=await import("./FeatureMedia/xyChart.js"),{root:m,mediaInfo:c}=t,{value:p,title:h}=c;e.setAll({wheelX:"panX",wheelY:"zoomX"});const u=e.xAxes.push(s.new(m,{renderer:o.new(m,{inversed:this._isInversed()}),categoryField:I}));u.get("renderer").labels.template.setAll({forceHidden:!0});const f=e.yAxes.push(n.new(m,{renderer:l.new(m,{inside:!1}),min:this._getMinSeriesValue(p.series)}));f.get("renderer").labels.template.setAll({direction:this._getDirection()});const _="{categoryX}",v=r.new(m,{labelText:_}),M=e.series.push(d.new(m,{name:h,xAxis:u,yAxis:f,valueYField:A,categoryXField:I,tooltip:v}));M.strokes.template.setAll({templateField:"lineSettings"}),this._customizeChartTooltip(v,"vertical"),p.series.length>w&&e.set("scrollbarX",a.new(m,{orientation:"horizontal"})),u.data.setAll(i),M.data.setAll(i),M.appear(this._getChartSeriesAnimationMS()),e.appear(this._getChartAnimationMS())}async _createXYChart(e,t){const{XYChartAm5:i,XYCursorAm5:r}=await import("./FeatureMedia/xyChart.js"),{root:a,mediaInfo:s}=e,{type:o}=s,n=s?.altText||s?.title||"",l=a.container.children.push(i.new(a,{ariaLabel:n,focusable:!0,panX:!0,panY:!0}));l.set("cursor",r.new(a,{})),"column-chart"===o&&await this._createColumnChart(l,e,t),"bar-chart"===o&&await this._createBarChart(l,e,t),"line-chart"===o&&await this._createLineChart(l,e,t),l.root.dom.classList.toggle(g.mediaChartRendered,!0)}_clearMediaRefreshTimer(){const{_refreshTimer:e}=this;e&&(clearTimeout(e),this._refreshTimer=null)}_updateMediaInfoTimestamp(e){const t=Date.now();this._refreshIntervalInfo={timestamp:t,sourceURL:e&&this._getImageSource(e,t)}}_setupMediaRefreshTimer(){this._clearMediaRefreshTimer();const{activeMediaInfo:e}=this.viewModel;e&&"image"===e.type&&e.refreshInterval&&this._setRefreshTimeout(e)}_setRefreshTimeout(e){const{refreshInterval:t,value:i}=e;if(!t)return;const r=6e4*t;this._updateMediaInfoTimestamp(i.sourceURL);const a=setInterval((()=>{this._updateMediaInfoTimestamp(i.sourceURL)}),r);this._refreshTimer=a}_getImageSource(e,t){const i=e.includes("?")?"&":"?",[r,a=""]=e.split("#");return`${r}${i}timestamp=${t}${a?"#":""}${a}`}};e([s()],b.prototype,"_refreshIntervalInfo",void 0),e([s()],b.prototype,"attributes",null),e([s()],b.prototype,"activeMediaInfoIndex",null),e([s()],b.prototype,"description",null),e([s()],b.prototype,"fieldInfoMap",null),e([s()],b.prototype,"layer",null),e([s()],b.prototype,"mediaInfos",null),e([s()],b.prototype,"popupTemplate",null),e([s()],b.prototype,"relatedInfos",null),e([s()],b.prototype,"title",null),e([s({type:d})],b.prototype,"viewModel",void 0),e([s(),u("esri/widgets/Feature/t9n/Feature")],b.prototype,"messages",void 0),b=e([o("esri.widgets.Feature.FeatureMedia")],b);const R=b;export{R as default};