/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import{makeHandle as t}from"../../../../core/handleUtils.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import s from"../../../../geometry/Polygon.js";import{toExtent as i}from"../../../../geometry/support/aaBoundingRect.js";import{TileKey as n}from"../../../../layers/support/TileKey.js";import{TileTreeDebugger as l}from"../../../support/TileTreeDebugger.js";let a=class extends l{constructor(e){super(e)}initialize(){const e=setInterval(()=>this._fetchDebugInfo(),2e3);this.addHandles(t(()=>clearInterval(e)))}getTiles(){if(!this._debugInfo)return[];const e=new Map,t=new Map;this._debugInfo.storedTiles.forEach(t=>e.set(n.fromJSON(t.key).id,t.featureCount)),this._debugInfo.pendingTiles.forEach(r=>{e.set(r.key.id,r.featureCount),t.set(r.key.id,r.state)});const r=r=>{const o=t.get(r),s=e.get(r)??"?";return o?`${o}:${s}\n${r}`:`store:${s}\n${r}`},o=new Map;return this._debugInfo.storedTiles.forEach(e=>{const t=n.fromJSON(e.key);o.set(t.id,t)}),this._debugInfo.pendingTiles.forEach(e=>{o.set(e.key.id,e.key)}),Array.from(o.values()).map(e=>({lij:[e.level,e.row,e.col],level:e.level,geometry:s.fromExtent(i(e.extent,this.view.spatialReference)),label:r(e.id)}))}_fetchDebugInfo(){this.handle.getDebugInfo(null).then(e=>{this._debugInfo=e,this.update()})}};e([r({constructOnly:!0})],a.prototype,"handle",void 0),a=e([o("esri.views.interactive.snapping.featureSources.WorkerTileTreeDebugger")],a);export{a as WorkerTileTreeDebugger};
