var l=200,p=function(){};p.prototype.append=function(t){return t.length?(t=p.from(t),!this.length&&t||t.length<l&&this.leafAppend(t)||this.length<l&&t.leafPrepend(this)||this.appendInner(t)):this};p.prototype.prepend=function(t){return t.length?p.from(t).append(this):this};p.prototype.appendInner=function(t){return new u(this,t)};p.prototype.slice=function(t,r){return t===void 0&&(t=0),r===void 0&&(r=this.length),t>=r?p.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,r))};p.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};p.prototype.forEach=function(t,r,e){r===void 0&&(r=0),e===void 0&&(e=this.length),r<=e?this.forEachInner(t,r,e,0):this.forEachInvertedInner(t,r,e,0)};p.prototype.map=function(t,r,e){r===void 0&&(r=0),e===void 0&&(e=this.length);var n=[];return this.forEach(function(i,s){return n.push(t(i,s))},r,e),n};p.from=function(t){return t instanceof p?t:t&&t.length?new o(t):p.empty};var o=(function(h){function t(e){h.call(this),this.values=e}h&&(t.__proto__=h),t.prototype=Object.create(h&&h.prototype),t.prototype.constructor=t;var r={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(n,i){return n==0&&i==this.length?this:new t(this.values.slice(n,i))},t.prototype.getInner=function(n){return this.values[n]},t.prototype.forEachInner=function(n,i,s,f){for(var a=i;a<s;a++)if(n(this.values[a],f+a)===!1)return!1},t.prototype.forEachInvertedInner=function(n,i,s,f){for(var a=i-1;a>=s;a--)if(n(this.values[a],f+a)===!1)return!1},t.prototype.leafAppend=function(n){if(this.length+n.length<=l)return new t(this.values.concat(n.flatten()))},t.prototype.leafPrepend=function(n){if(this.length+n.length<=l)return new t(n.flatten().concat(this.values))},r.length.get=function(){return this.values.length},r.depth.get=function(){return 0},Object.defineProperties(t.prototype,r),t})(p);p.empty=new o([]);var u=(function(h){function t(r,e){h.call(this),this.left=r,this.right=e,this.length=r.length+e.length,this.depth=Math.max(r.depth,e.depth)+1}return h&&(t.__proto__=h),t.prototype=Object.create(h&&h.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,n,i,s){var f=this.left.length;if(n<f&&this.left.forEachInner(e,n,Math.min(i,f),s)===!1||i>f&&this.right.forEachInner(e,Math.max(n-f,0),Math.min(this.length,i)-f,s+f)===!1)return!1},t.prototype.forEachInvertedInner=function(e,n,i,s){var f=this.left.length;if(n>f&&this.right.forEachInvertedInner(e,n-f,Math.max(i,f)-f,s+f)===!1||i<f&&this.left.forEachInvertedInner(e,Math.min(n,f),i,s)===!1)return!1},t.prototype.sliceInner=function(e,n){if(e==0&&n==this.length)return this;var i=this.left.length;return n<=i?this.left.slice(e,n):e>=i?this.right.slice(e-i,n-i):this.left.slice(e,i).append(this.right.slice(0,n-i))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t})(p);export{p as R};
