function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=new Array(e);n=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n=function(t){return null!=t},a=function(t){return"object"==typeof t};module.exports=/*#__PURE__*/function(){function t(t,e,n){void 0===t&&(t=[]),void 0===e&&(e=[]),this.dataMap=void 0,this.indexMap=new Map,this.default=void 0,this.indexMap=new Map(t.map(function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("[N-INDEX-MAP ERROR] index key must be a string or number");return[t,new Map]})),this.dataMap=new Map(e.map(function(t,e){if(!a(t))throw new Error("[N-INDEX-MAP ERROR] cannot set item as it is not an object");return[e,t]})),this.seedIndexMap.apply(this,t),this.default=n}var r=t.prototype;return r.has=function(t,e){var a=this.indexMap.get(t);return n(a)?a.has(e):[].concat(this.dataMap.values()).some(function(n){return n[t]===e})},r.get=function(t,e){var a=this.indexMap.get(t);if(n(a)){var r=a.get(e);if(n(r))return this.dataMap.get(r)}return[].concat(this.dataMap.values()).find(function(n){return n[t]===e})},r.getOrDefault=function(t,e){var n;return null!=(n=this.get(t,e))?n:this.default},r.getDefault=function(){return this.default},r.set=function(){for(var t,n=e([].slice.call(arguments));!(t=n()).done;){var a=t.value;this.validateDataItem(a);var r=this.dataMap.size;this.dataMap.set(r,a);for(var i,o=e(this.indexMap);!(i=o()).done;){var s=i.value,u=s[0],d=s[1];d.set(a[u],r)}}return this},r.setDefault=function(t){if(!a(t))throw new Error("[N-INDEX-MAP ERROR] cannot set item as it is not an object");return this.default=t,this},r.delete=function(t,a){var r=this.indexMap.get(t);if(n(r)){var i=r.get(a);if(n(i)){var o=this.dataMap.get(i);if(n(o)){this.dataMap.delete(i);for(var s,u=e(this.indexMap);!(s=u()).done;){var d=s.value;d[1].delete(o[d[0]])}return this}}}for(var f,h=e(this.dataMap);!(f=h()).done;){var c=f.value;c[1][t]===a&&this.dataMap.delete(c[0])}return this},r.addIndex=function(t){return this.indexMap.has(t)||this.seedIndexMap(t),this},r.removeIndex=function(t){return this.indexMap.has(t)&&this.indexMap.delete(t),this},r.size=function(){return this.dataMap.size},r.indexes=function(){return this.indexMap.size},r.values=function(){return this.dataMap.values()},r.list=function(){return Array.from(this.dataMap.values())},r.entries=function(){return this.dataMap.entries()},r.find=function(t){return[].concat(this.values()).find(t)},r.clear=function(){return this.dataMap.clear(),this.indexMap.clear(),this},r.seedIndexMap=function(){for(var t,n=e([].slice.call(arguments));!(t=n()).done;){for(var a,r=t.value,i=new Map,o=e(this.dataMap);!(a=o()).done;){var s=a.value,u=s[0],d=s[1];if(!d.hasOwnProperty(r))throw new Error("[N-INDEX-MAP ERROR] cannot create index for property that does not exist on data");i.set(d[r],u)}this.indexMap.set(r,i)}},r.validateDataItem=function(t){if(!a(t))throw new Error("[N-INDEX-MAP ERROR] cannot set item as it is not an object");for(var n,r=e(this.indexMap.keys());!(n=r()).done;){var i=n.value;if(!t.hasOwnProperty(i))throw new Error("[N-INDEX-MAP ERROR] cannot set item as does not contain indexed properties");if(this.has(i,t[i]))throw new Error("[N-INDEX-MAP ERROR] cannot set item as indexed prop values are not unique")}},t}(); //# sourceMappingURL=index.cjs.map