/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../../chunks/_rollupPluginBabelHelpers","../../../layers/support/TileInfo","./TileInfoView","./TileKey"],(function(e,l,t,n){"use strict";let o=function(t){function o(){var e;return(e=t.apply(this,arguments)||this)._fullCacheLodInfos=null,e._levelByScale={},e}e._inheritsLoose(o,t);var s=o.prototype;return s.getTileParentId=function(e){const l=n.pool.acquire(e),t=0===l.level?null:n.getId(l.level-1,l.row>>1,l.col>>1,l.world);return n.pool.release(l),t},s.getTileCoverage=function(e,l,n){const o=t.prototype.getTileCoverage.call(this,e,l,n);if(!o)return o;const s=1<<o.lodInfo.level;return o.spans=o.spans.filter((e=>e.row>=0&&e.row<s)),o},s.scaleToLevel=function(e){if(this._fullCacheLodInfos||this._initializeFullCacheLODs(this._lodInfos),this._levelByScale[e])return this._levelByScale[e];{const l=this._fullCacheLodInfos;if(e>l[0].scale)return l[0].level;let t,n;for(let o=0;o<l.length-1;o++)if(n=l[o+1],e>n.scale)return t=l[o],t.level+(t.scale-e)/(t.scale-n.scale);return l[l.length-1].level}},s._initializeFullCacheLODs=function(e){let t;if(0===e[0].level)t=e.map((e=>({level:e.level,resolution:e.resolution,scale:e.scale})));else{const e=this.tileInfo.size[0],n=this.tileInfo.spatialReference;t=l.create({size:e,spatialReference:n}).lods.map((e=>({level:e.level,resolution:e.resolution,scale:e.scale})))}for(let l=0;l<t.length;l++)this._levelByScale[t[l].scale]=t[l].level;this._fullCacheLodInfos=t},o}(t);return o}));
