/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import has from"../../../../core/has.js";import e from"./WGLContainer.js";import{TileDebugInfoTechnique as t}from"./shaderGraph/techniques/tile/TileDebugInfoTechnique.js";import{TileStencilTechnique as i}from"./shaderGraph/techniques/tile/TileStencilTechnique.js";const r=(e,t)=>e.key.level-t.key.level!==0?e.key.level-t.key.level:e.key.row-t.key.row!==0?e.key.row-t.key.row:e.key.col-t.key.col;class n extends e{constructor(e){super(),this.tilingScheme=e,this._tileStencilTechnique=new i,this._tileDebugInfoTechnique=new t,this.sortFunction=r}renderChildren(e){this.setStencilReference(e),super.renderChildren(e);for(const t of this.getStencilTarget())this._tileStencilTechnique.render(e,t);if(has("esri-tiles-debug"))for(const t of this.children)this._tileDebugInfoTechnique.render(e,t)}createRenderParams(e){const{state:t}=e,i=super.createRenderParams(e);return i.requiredLevel=this.tilingScheme.getClosestInfoForScale(t.scale).level,i.displayLevel=this.tilingScheme.scaleToZoom(t.scale),i}onDetach(){super.onDetach(),this._tileStencilTechnique.shutdown(),this._tileDebugInfoTechnique.shutdown()}getStencilTarget(){return this.children}setStencilReference(e){let t=1;for(const i of this.children)i.stencilRef=t++}}export{n as default};
