'use strict'; var d="",h="object",I="array",g="set",v="map";var b="object",_="array",x="set",N="map",w="null";function l(s){if(s===null)return w;let e=typeof s;return e===b?s instanceof Array?_:s instanceof Set?x:s instanceof Map?N:b:e}var c="";function y(s){if(c=typeof s.value,c==="object")return !1;switch(c){case"string":case"number":case"boolean":case"symbol":case"bigint":case"undefined":case"null":return !0;default:return !1}}var u=class{constructor(e,r,t,i){this._storage=[];this._filter=new Set;if(this._root=e,this._depth=r,this._isInfinity=r===-1,typeof i=="string"?this._rootName=i||"root":this._rootName="root",t==="depth")this._algorithm=!0;else if(t==="breadth")this._algorithm=!1;else throw new Error("Incorrect algorithm name");this._storage.push({value:e,level:0,key:this._rootName,type:l(e),empty:!1});}has(){return this._storage.length>0}get(){return this._current}next(){let e=!1,r;do{if(r=this._getNextNode(),this._current=r,r===void 0)return;y(r)?e=!1:e=this._handler(r);}while(e);return r}nextLiaf(){let e;do{if(e=this.next(),e===void 0)return;if(y(e))return e}while(this.has())}reset(){this._filter.clear(),this._storage=[],this._handler({value:this._root,level:0,type:d,key:this._rootName,empty:!1});}_handler(e){let r=e.level+1;if(!(this._isInfinity||this._depth>e.level))return !0;if(typeof e.value===h&&!this._filter.has(e.value))if(this._filter.add(e.value),e.value instanceof Array)if(e.type=I,e.value.length>0){let i=e.value.length-1;do this._storage.push({value:e.value[i],level:r,type:l(e.value[i]),key:`${i}`,empty:!1});while(i--)}else e.empty=!0;else if(e.value instanceof Set)e.type=g,e.value.size>0?e.value.forEach(i=>{this._storage.push({value:i,level:r,type:l(i),key:i,empty:!1});}):e.empty=!0;else if(e.value instanceof Map)e.type=v,e.value.size>0?e.value.forEach((i,n)=>{this._storage.push({value:i,level:r,type:l(i),key:n,empty:!1});}):e.empty=!0;else if(e.value instanceof Function)e.type="function",e.value="Function()",e.empty=!0;else if(e.value instanceof Date)e.type="date",e.value=String(e.value);else {e.type=h;let i=Object.keys(e.value);if(i.length>0)for(let n=i.length-1;n>=0;n--)Object.prototype.hasOwnProperty.call(e.value,i[n])&&this._storage.push({value:e.value[i[n]],key:i[n],level:r,type:l(e.value[i[n]]),empty:!1});else e.empty=!0;}else e.value="ref *",e.type="ref",e.empty=!0;return !1}_getNextNode(){return this._algorithm?this._storage.pop():this._storage.shift()}};var f=class extends u{constructor(e,r,t){super(e,r,"depth",t);}};var p=class extends u{constructor(e,r,t){super(e,r,"breadth",t);}};var m=class s{static createDepthFirstIterator(e,r="Infinity",t){if(r==="Infinity")return new f(e,-1,typeof t=="string"&&t.length>0?t:"root");if(typeof r=="number"&&r>0)return new f(e,r,typeof t=="string"&&t.length>0?t:"root");throw new Error("Depth parameter must be a positive number")}static createBreadthFirstIterator(e,r="Infinity",t){if(r==="Infinity")return new p(e,-1,typeof t=="string"&&t.length>0?t:"root");if(typeof r=="number"&&r>0)return new p(e,r,typeof t=="string"&&t.length>0?t:"root");throw new Error("Depth parameter must be a positive number")}static createDepthFirstSequenceNode(e,r="Infinity",t){let i=s.createDepthFirstIterator(e,r,typeof t=="string"&&t.length>0?t:"root"),n=[],a;for(;a=i.next();)n.push(a);return n}static createBreadthFirstSequenceNode(e,r="Infinity",t){let i=s.createBreadthFirstIterator(e,r,typeof t=="string"&&t.length>0?t:"root"),n=[],a;for(;a=i.next();)n.push(a);return n}static createDepthFirstSequenceLiaf(e,r="Infinity",t){let i=s.createDepthFirstIterator(e,r,typeof t=="string"&&t.length>0?t:"root"),n=[],a;for(;a=i.nextLiaf();)n.push(a);return n}static createBreadthFirstSequenceLiaf(e,r="Infinity",t){let i=s.createBreadthFirstIterator(e,r,typeof t=="string"&&t.length>0?t:"root"),n=[],a;for(;a=i.nextLiaf();)n.push(a);return n}}; module.exports = m; //# sourceMappingURL=out.js.map //# sourceMappingURL=index.cjs.map