/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../chunks/_rollupPluginBabelHelpers","../../../../core/PooledArray","../../../../geometry/support/aaBoundingRect","../../../support/Scheduler"],(function(t,e,n,r,o){"use strict";const s=.05;let i=function(){function t(){this._extents=new n({allocator:t=>t||r.create()}),this._tmpExtent=r.create(),this._dirty=!1}var i=t.prototype;return i.clear=function(){this._extents.clear()},i.add=function(t){this._contains(t)||(this._removeContained(t),r.copy(this._extents.pushNew(),t),this._dirty=!0)},i.pop=function(){return this._dirty&&this._mergeTight(),this._extents.pop()},i.merge=function(t){return this._mergeTight(t),t.hasProgressed},i._mergeTight=function(t=o.noBudget){const e=this._extents,n=new Set;let i=0;for(;i!==e.length;){e.sort(((t,e)=>t[0]-e[0])),i=e.length,n.clear();for(let o=0;o<e.length;++o){if(t.done)return;const i=e.getItemAt(o);for(let t=o+1;t<e.length;++t){const r=e.getItemAt(t);if(r[0]>=i[2])break;n.add(r)}n.forEach((o=>{if(i===o)return;if(o[2]<=i[0])return void n.delete(o);const c=r.area(i),a=r.area(o),u=this._tmpExtent;r.expand(i,o,u);const h=c+a;(r.area(u)-h)/h<s&&(r.copy(i,u),n.delete(o),e.remove(o),t.madeProgress())})),n.add(i)}}this._dirty=!1},i._contains=function(t){return this._extents.some((e=>r.contains(e,t)))},i._removeContained=function(t){this._extents.filterInPlace((e=>!r.contains(t,e)))},e._createClass(t,[{key:"empty",get:function(){return 0===this._extents.length}},{key:"size",get:function(){return this._extents.length}},{key:"test",get:function(){const t=this;return{containsPoint:e=>t._extents.some((t=>r.containsPoint(t,e)))}}}]),t}();t.ExtentSet=i,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
