"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function n(i,e){if(i.length!==e.length)return!1;for(let s=0;s<i.length;s++)if(i[s]!==e[s])return!1;return!0}class c{static MAX_CACHE_SIZE=20;static MAX_CACHE_OFFSET=5;cache;keys;cacheCallTimes;constructor(){this.cache=new Map,this.keys=[],this.cacheCallTimes=0}size(){return this.keys.length}internalGet(e,s=!1){let t={map:this.cache};return e.forEach(l=>{t?t=t?.map?.get(l):t=void 0}),t?.value&&s&&(t.value[1]=this.cacheCallTimes++),t?.value}get(e){return this.internalGet(e,!0)?.[0]}has(e){return!!this.internalGet(e)}set(e,s){if(!this.has(e)){if(this.size()+1>c.MAX_CACHE_SIZE+c.MAX_CACHE_OFFSET){const[l]=this.keys.reduce((h,a)=>{const[,u]=h;return this.internalGet(a)[1]<u?[a,this.internalGet(a)[1]]:h},[this.keys[0],this.cacheCallTimes]);this.delete(l)}this.keys.push(e)}let t=this.cache;e.forEach((l,h)=>{if(h===e.length-1)t.set(l,{value:[s,this.cacheCallTimes++]});else{const a=t.get(l);a?a.map||(a.map=new Map):t.set(l,{map:new Map}),t=t.get(l).map}})}deleteByPath(e,s){const t=e.get(s[0]);if(s.length===1)return t.map?e.set(s[0],{map:t.map}):e.delete(s[0]),t.value?.[0];const l=this.deleteByPath(t.map,s.slice(1));return(!t.map||t.map.size===0)&&!t.value&&e.delete(s[0]),l}delete(e){if(this.has(e))return this.keys=this.keys.filter(s=>!n(s,e)),this.deleteByPath(this.cache,e)}}exports.default=c;exports.sameDerivativeOption=n;
