import{aH as W}from"./index-b5c8f851.js";import{J,C as L,r as q}from"./rasterProjectionHelper-68eba0c9.js";class F{constructor(n=15e3,e=5e3){this._timer=null,this._cachedBlocks=new Map,this._size=-1,this._duration=n,this._interval=Math.min(n,e)}decreaseRefCount(n,e){const t=n+"/"+e,r=this._cachedBlocks;if(r.has(t)){const l=r.get(t);return l.refCount--,l.refCount<=0&&(r.delete(t),l.controller&&l.controller.abort()),l.refCount}return 0}getBlock(n,e){const t=n+"/"+e,r=this._cachedBlocks;if(r.has(t)){const l=r.get(t);return l.ts=Date.now(),l.refCount++,r.delete(t),r.set(t,l),l.block}return null}putBlock(n,e,t,r){const l=this._cachedBlocks,i=n+"/"+e;if(l.has(i)){const c=l.get(i);c.ts=Date.now(),c.refCount++}else l.set(i,{block:t,ts:Date.now(),refCount:1,controller:r});this._trim(),this._updateTimer()}deleteBlock(n,e){const t=this._cachedBlocks,r=n+"/"+e;t.has(r)&&t.delete(r)}updateMaxSize(n){this._size=n,this._trim()}empty(){this._cachedBlocks.clear(),this._clearTimer()}getCurrentSize(){return this._cachedBlocks.size}_updateTimer(){if(this._timer!=null)return;const n=this._cachedBlocks;this._timer=setInterval(()=>{const e=Array.from(n),t=Date.now();for(let r=0;r=n.size)return;const e=Array.from(n);for(let t=0;tt!=null)||f.delete(o))}function U(o,n,e){var i,c;const t=f.get(o);if(!t)return n==null?d.decreaseRefCount(o,e):0;if(n==null||t[n]==null)return d.decreaseRefCount(o,e);const r=(i=t[n])==null?void 0:i.cache,l=r==null?void 0:r.get(e);if(r&&l){if(l.refCount--,l.refCount===0){r.delete(e);for(let s=0;si.isResolved=!0).catch(()=>i.isRejected=!0),(c=l[n])==null||c.cache.set(e,i)}function Y(o,n,e){var r;const t=f.get(o);t?n!=null&&t[n]!=null?(r=t[n])==null||r.cache.delete(e):d.deleteBlock(o,e):n==null&&d.deleteBlock(o,e)}function G(o,n){const e=f.get(o);return e?e[n]??null:null}function Z(o,n,e,t,r,l,i=null){const c=G(o,n);if(!c)return;const s=c.extent,{cache:a,rasterInfo:m}=c;if(s&&s.xmin===e.xmin&&s.xmax===e.xmax&&s.ymin===e.ymin&&s.ymax===e.ymax)return;t=t??0;const M=e.clone().normalize(),{spatialReference:R,transform:v}=m,b=new Set;for(let g=0;g0?x.pyramidBlockWidth:x.blockWidth,$=p>0?x.pyramidBlockHeight:x.blockHeight,y=1,H=Math.max(0,Math.floor(k.x/z)-y),S=Math.max(0,Math.floor(k.y/$)-y),A=Math.floor((k.x+j-1)/z)+y,E=Math.floor((k.y+D-1)/$)+y;for(let B=S;B<=E;B++)for(let C=H;C<=A;C++)b.add(`${p}/${B}/${C}`)}a.forEach((g,h)=>{if(!b.has(h)){const u=a.get(h);(u==null||u.isResolved||u.isRejected)&&a.delete(h)}}),c.extent={xmin:e.xmin,ymin:e.ymin,xmax:e.xmax,ymax:e.ymax}}export{Q as a,Z as g,Y as h,O as i,V as m,U as s,P as u,X as x};