Build 542549stable
Module 824120
21,251 characters · in no known chunkDependencies
Source Raw
function(e,t,n){e=n.nmd(e);var i=function(){"use strict";var e=u(0x20000000000000),t="0123456789abcdefghijklmnopqrstuvwxyz",n="function"==typeof BigInt;function r(e,t,n,i){return void 0===e?r[0]:void 0!==t&&(10!=+t||n)?G(e,t,n,i):j(e)}function s(e,t){this.value=e,this.sign=t,this.isSmall=!1}function a(e){this.value=e,this.sign=e<0,this.isSmall=!0}function o(e){this.value=e}function l(e){return -0x20000000000000<e&&e<0x20000000000000}function u(e){return e<1e7?[e]:e<1e14?[e%1e7,Math.floor(e/1e7)]:[e%1e7,Math.floor(e/1e7)%1e7,Math.floor(e/1e14)]}function c(t){d(t);var n=t.length;if(n<4&&0>v(t,e))switch(n){case 0:return 0;case 1:return t[0];case 2:return t[0]+1e7*t[1];default:return t[0]+(t[1]+1e7*t[2])*1e7}return t}function d(e){for(var t=e.length;0===e[--t];);e.length=t+1}function _(e){for(var t=Array(e),n=-1;++n<e;)t[n]=0;return t}function f(e){return e>0?Math.floor(e):Math.ceil(e)}function h(e,t){var n,i,r=e.length,s=t.length,a=Array(r),o=0;for(i=0;i<s;i++)o=+((n=e[i]+t[i]+o)>=1e7),a[i]=n-1e7*o;for(;i<r;)o=+(1e7===(n=e[i]+o)),a[i++]=n-1e7*o;return o>0&&a.push(o),a}function p(e,t){return e.length>=t.length?h(e,t):h(t,e)}function E(e,t){var n,i,r=e.length,s=Array(r);for(i=0;i<r;i++)t=Math.floor((n=e[i]-1e7+t)/1e7),s[i]=n-1e7*t,t+=1;for(;t>0;)s[i++]=t%1e7,t=Math.floor(t/1e7);return s}function m(e,t){var n,i,r=e.length,s=t.length,a=Array(r),o=0;for(n=0;n<s;n++)(i=e[n]-o-t[n])<0?(i+=1e7,o=1):o=0,a[n]=i;for(n=s;n<r;n++){if((i=e[n]-o)<0)i+=1e7;else{a[n++]=i;break}a[n]=i}for(;n<r;n++)a[n]=e[n];return d(a),a}function g(e,t,n){var i,r,o=e.length,l=Array(o),u=-t;for(i=0;i<o;i++)u=Math.floor((r=e[i]+u)/1e7),r%=1e7,l[i]=r<0?r+1e7:r;return"number"==typeof(l=c(l))?(n&&(l=-l),new a(l)):new s(l,n)}function A(e,t){var n,i,r,s,a=e.length,o=t.length,l=_(a+o);for(r=0;r<a;++r){s=e[r];for(var u=0;u<o;++u)i=Math.floor((n=s*t[u]+l[r+u])/1e7),l[r+u]=n-1e7*i,l[r+u+1]+=i}return d(l),l}function I(e,t){var n,i,r=e.length,s=Array(r),a=0;for(i=0;i<r;i++)a=Math.floor((n=e[i]*t+a)/1e7),s[i]=n-1e7*a;for(;a>0;)s[i++]=a%1e7,a=Math.floor(a/1e7);return s}function T(e,t){for(var n=[];t-- >0;)n.push(0);return n.concat(e)}function S(e,t,n){return e<1e7?new s(I(t,e),n):new s(A(t,u(e)),n)}function N(e){var t,n,i,r,s=e.length,a=_(s+s);for(i=0;i<s;i++){n=0-(r=e[i])*r;for(var o=i;o<s;o++)n=Math.floor((t=r*e[o]*2+a[i+o]+n)/1e7),a[i+o]=t-1e7*n;a[i+s]=n}return d(a),a}function y(e,t){var n,i,r,s,a=e.length,o=_(a);for(r=0,n=a-1;n>=0;--n)i=f((s=1e7*r+e[n])/t),r=s-i*t,o[n]=0|i;return[o,0|r]}function C(e,t){var i,l,h=j(t);if(n)return[new o(e.value/h.value),new o(e.value%h.value)];var p=e.value,E=h.value;if(0===E)throw Error("Cannot divide by zero");if(e.isSmall)return h.isSmall?[new a(f(p/E)),new a(p%E)]:[r[0],e];if(h.isSmall){if(1===E)return[e,r[0]];if(-1==E)return[e.negate(),r[0]];var g=Math.abs(E);if(g<1e7){i=c((l=y(p,g))[0]);var A=l[1];return(e.sign&&(A=-A),"number"==typeof i)?(e.sign!==h.sign&&(i=-i),[new a(i),new a(A)]):[new s(i,e.sign!==h.sign),new a(A)]}E=u(g)}var T=v(p,E);if(-1===T)return[r[0],e];if(0===T)return[r[e.sign===h.sign?1:-1],r[0]];i=(l=p.length+E.length<=200?function(e,t){var n,i,r,s,a,o,l,u=e.length,d=t.length,f=_(t.length),h=t[d-1],p=Math.ceil(1e7/(2*h)),E=I(e,p),m=I(t,p);for(E.length<=u&&E.push(0),m.push(0),h=m[d-1],i=u-d;i>=0;i--){for(n=1e7-1,E[i+d]!==h&&(n=Math.floor((1e7*E[i+d]+E[i+d-1])/h)),r=0,s=0,o=m.length,a=0;a<o;a++)r+=n*m[a],l=Math.floor(r/1e7),s+=E[i+a]-(r-1e7*l),r=l,s<0?(E[i+a]=s+1e7,s=-1):(E[i+a]=s,s=0);for(;0!==s;){for(n-=1,r=0,a=0;a<o;a++)(r+=E[i+a]-1e7+m[a])<0?(E[i+a]=r+1e7,r=0):(E[i+a]=r,r=1);s+=r}f[i]=n}return E=y(E,p)[0],[c(f),c(E)]}(p,E):function(e,t){for(var n,i,r,s,a,o=e.length,l=t.length,u=[],_=[];o;){if(_.unshift(e[--o]),d(_),0>v(_,t)){u.push(0);continue}i=_.length,r=1e7*_[i-1]+_[i-2],s=1e7*t[l-1]+t[l-2],i>l&&(r=(r+1)*1e7),n=Math.ceil(r/s);do{if(0>=v(a=I(t,n),_))break;n--}while(n);u.push(n),_=m(_,a)}return u.reverse(),[c(u),c(_)]}(p,E))[0];var S=e.sign!==h.sign,N=l[1],C=e.sign;return"number"==typeof i?(S&&(i=-i),i=new a(i)):i=new s(i,S),"number"==typeof N?(C&&(N=-N),N=new a(N)):N=new s(N,C),[i,N]}function v(e,t){if(e.length!==t.length)return e.length>t.length?1:-1;for(var n=e.length-1;n>=0;n--)if(e[n]!==t[n])return e[n]>t[n]?1:-1;return 0}function O(e){var t=e.abs();return!t.isUnit()&&(!!(t.equals(2)||t.equals(3)||t.equals(5))||!(t.isEven()||t.isDivisibleBy(3)||t.isDivisibleBy(5))&&(!!t.lesser(49)||void 0))}function R(e,t){for(var n,r,s,a=e.prev(),o=a,l=0;o.isEven();)o=o.divide(2),l++;t:for(r=0;r<t.length;r++)if(!e.lesser(t[r])&&!((s=i(t[r]).modPow(o,e)).isUnit()||s.equals(a))){for(n=l-1;0!=n&&!(s=s.square().mod(e)).isUnit();n--)if(s.equals(a))continue t;return!1}return!0}s.prototype=Object.create(r.prototype),a.prototype=Object.create(r.prototype),o.prototype=Object.create(r.prototype),s.prototype.add=function(e){var t=j(e);if(this.sign!==t.sign)return this.subtract(t.negate());var n=this.value,i=t.value;return t.isSmall?new s(E(n,Math.abs(i)),this.sign):new s(p(n,i),this.sign)},s.prototype.plus=s.prototype.add,a.prototype.add=function(e){var t=j(e),n=this.value;if(n<0!==t.sign)return this.subtract(t.negate());var i=t.value;if(t.isSmall){if(l(n+i))return new a(n+i);i=u(Math.abs(i))}return new s(E(i,Math.abs(n)),n<0)},a.prototype.plus=a.prototype.add,o.prototype.add=function(e){return new o(this.value+j(e).value)},o.prototype.plus=o.prototype.add,s.prototype.subtract=function(e){var t,n,i=j(e);if(this.sign!==i.sign)return this.add(i.negate());var r=this.value,o=i.value;return i.isSmall?g(r,Math.abs(o),this.sign):(t=this.sign,(v(r,o)>=0?n=m(r,o):(n=m(o,r),t=!t),"number"==typeof(n=c(n)))?(t&&(n=-n),new a(n)):new s(n,t))},s.prototype.minus=s.prototype.subtract,a.prototype.subtract=function(e){var t=j(e),n=this.value;if(n<0!==t.sign)return this.add(t.negate());var i=t.value;return t.isSmall?new a(n-i):g(i,Math.abs(n),n>=0)},a.prototype.minus=a.prototype.subtract,o.prototype.subtract=function(e){return new o(this.value-j(e).value)},o.prototype.minus=o.prototype.subtract,s.prototype.negate=function(){return new s(this.value,!this.sign)},a.prototype.negate=function(){var e=this.sign,t=new a(-this.value);return t.sign=!e,t},o.prototype.negate=function(){return new o(-this.value)},s.prototype.abs=function(){return new s(this.value,!1)},a.prototype.abs=function(){return new a(Math.abs(this.value))},o.prototype.abs=function(){return new o(this.value>=0?this.value:-this.value)},s.prototype.multiply=function(e){var t,n,i,a=j(e),o=this.value,l=a.value,c=this.sign!==a.sign;if(a.isSmall){if(0===l)return r[0];if(1===l)return this;if(-1===l)return this.negate();if((i=Math.abs(l))<1e7)return new s(I(o,i),c);l=u(i)}return -.012*(t=o.length)-.012*(n=l.length)+15e-6*t*n>0?new s(function e(t,n){var i=Math.max(t.length,n.length);if(i<=30)return A(t,n);i=Math.ceil(i/2);var r=t.slice(i),s=t.slice(0,i),a=n.slice(i),o=n.slice(0,i),l=e(s,o),u=e(r,a),c=e(p(s,r),p(o,a)),_=p(p(l,T(m(m(c,l),u),i)),T(u,2*i));return d(_),_}(o,l),c):new s(A(o,l),c)},s.prototype.times=s.prototype.multiply,a.prototype._multiplyBySmall=function(e){return l(e.value*this.value)?new a(e.value*this.value):S(Math.abs(e.value),u(Math.abs(this.value)),this.sign!==e.sign)},s.prototype._multiplyBySmall=function(e){return 0===e.value?r[0]:1===e.value?this:-1===e.value?this.negate():S(Math.abs(e.value),this.value,this.sign!==e.sign)},a.prototype.multiply=function(e){return j(e)._multiplyBySmall(this)},a.prototype.times=a.prototype.multiply,o.prototype.multiply=function(e){return new o(this.value*j(e).value)},o.prototype.times=o.prototype.multiply,s.prototype.square=function(){return new s(N(this.value),!1)},a.prototype.square=function(){var e=this.value*this.value;return l(e)?new a(e):new s(N(u(Math.abs(this.value))),!1)},o.prototype.square=function(e){return new o(this.value*this.value)},s.prototype.divmod=function(e){var t=C(this,e);return{quotient:t[0],remainder:t[1]}},o.prototype.divmod=a.prototype.divmod=s.prototype.divmod,s.prototype.divide=function(e){return C(this,e)[0]},o.prototype.over=o.prototype.divide=function(e){return new o(this.value/j(e).value)},a.prototype.over=a.prototype.divide=s.prototype.over=s.prototype.divide,s.prototype.mod=function(e){return C(this,e)[1]},o.prototype.mod=o.prototype.remainder=function(e){return new o(this.value%j(e).value)},a.prototype.remainder=a.prototype.mod=s.prototype.remainder=s.prototype.mod,s.prototype.pow=function(e){var t,n,i,s=j(e),o=this.value,u=s.value;if(0===u)return r[1];if(0===o)return r[0];if(1===o)return r[1];if(-1===o)return s.isEven()?r[1]:r[-1];if(s.sign)return r[0];if(!s.isSmall)throw Error("The exponent "+s.toString()+" is too large.");if(this.isSmall&&l(t=Math.pow(o,u)))return new a(f(t));for(n=this,i=r[1];!0&u&&(i=i.times(n),--u),0!==u;)u/=2,n=n.square();return i},a.prototype.pow=s.prototype.pow,o.prototype.pow=function(e){var t=j(e),n=this.value,i=t.value,s=BigInt(0),a=BigInt(1),l=BigInt(2);if(i===s)return r[1];if(n===s)return r[0];if(n===a)return r[1];if(n===BigInt(-1))return t.isEven()?r[1]:r[-1];if(t.isNegative())return new o(s);for(var u=this,c=r[1];(i&a)===a&&(c=c.times(u),--i),i!==s;)i/=l,u=u.square();return c},s.prototype.modPow=function(e,t){if(e=j(e),(t=j(t)).isZero())throw Error("Cannot take modPow with modulus 0");var n=r[1],i=this.mod(t);for(e.isNegative()&&(e=e.multiply(r[-1]),i=i.modInv(t));e.isPositive();){if(i.isZero())return r[0];e.isOdd()&&(n=n.multiply(i).mod(t)),e=e.divide(2),i=i.square().mod(t)}return n},o.prototype.modPow=a.prototype.modPow=s.prototype.modPow,s.prototype.compareAbs=function(e){var t=j(e),n=this.value,i=t.value;return t.isSmall?1:v(n,i)},a.prototype.compareAbs=function(e){var t=j(e),n=Math.abs(this.value),i=t.value;return t.isSmall?n===(i=Math.abs(i))?0:n>i?1:-1:-1},o.prototype.compareAbs=function(e){var t=this.value,n=j(e).value;return(t=t>=0?t:-t)===(n=n>=0?n:-n)?0:t>n?1:-1},s.prototype.compare=function(e){if(e===1/0)return -1;if(e===-1/0)return 1;var t=j(e),n=this.value,i=t.value;return this.sign!==t.sign?t.sign?1:-1:t.isSmall?this.sign?-1:1:v(n,i)*(this.sign?-1:1)},s.prototype.compareTo=s.prototype.compare,a.prototype.compare=function(e){if(e===1/0)return -1;if(e===-1/0)return 1;var t=j(e),n=this.value,i=t.value;return t.isSmall?n==i?0:n>i?1:-1:n<0!==t.sign?n<0?-1:1:n<0?1:-1},a.prototype.compareTo=a.prototype.compare,o.prototype.compare=function(e){if(e===1/0)return -1;if(e===-1/0)return 1;var t=this.value,n=j(e).value;return t===n?0:t>n?1:-1},o.prototype.compareTo=o.prototype.compare,s.prototype.equals=function(e){return 0===this.compare(e)},o.prototype.eq=o.prototype.equals=a.prototype.eq=a.prototype.equals=s.prototype.eq=s.prototype.equals,s.prototype.notEquals=function(e){return 0!==this.compare(e)},o.prototype.neq=o.prototype.notEquals=a.prototype.neq=a.prototype.notEquals=s.prototype.neq=s.prototype.notEquals,s.prototype.greater=function(e){return this.compare(e)>0},o.prototype.gt=o.prototype.greater=a.prototype.gt=a.prototype.greater=s.prototype.gt=s.prototype.greater,s.prototype.lesser=function(e){return 0>this.compare(e)},o.prototype.lt=o.prototype.lesser=a.prototype.lt=a.prototype.lesser=s.prototype.lt=s.prototype.lesser,s.prototype.greaterOrEquals=function(e){return this.compare(e)>=0},o.prototype.geq=o.prototype.greaterOrEquals=a.prototype.geq=a.prototype.greaterOrEquals=s.prototype.geq=s.prototype.greaterOrEquals,s.prototype.lesserOrEquals=function(e){return 0>=this.compare(e)},o.prototype.leq=o.prototype.lesserOrEquals=a.prototype.leq=a.prototype.lesserOrEquals=s.prototype.leq=s.prototype.lesserOrEquals,s.prototype.isEven=function(){return(1&this.value[0])==0},a.prototype.isEven=function(){return(1&this.value)==0},o.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},s.prototype.isOdd=function(){return(1&this.value[0])==1},a.prototype.isOdd=function(){return(1&this.value)==1},o.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},s.prototype.isPositive=function(){return!this.sign},a.prototype.isPositive=function(){return this.value>0},o.prototype.isPositive=a.prototype.isPositive,s.prototype.isNegative=function(){return this.sign},a.prototype.isNegative=function(){return this.value<0},o.prototype.isNegative=a.prototype.isNegative,s.prototype.isUnit=function(){return!1},a.prototype.isUnit=function(){return 1===Math.abs(this.value)},o.prototype.isUnit=function(){return this.abs().value===BigInt(1)},s.prototype.isZero=function(){return!1},a.prototype.isZero=function(){return 0===this.value},o.prototype.isZero=function(){return this.value===BigInt(0)},s.prototype.isDivisibleBy=function(e){var t=j(e);return!t.isZero()&&(!!t.isUnit()||(0===t.compareAbs(2)?this.isEven():this.mod(t).isZero()))},o.prototype.isDivisibleBy=a.prototype.isDivisibleBy=s.prototype.isDivisibleBy,s.prototype.isPrime=function(e){var t=O(this);if(void 0!==t)return t;var n=this.abs(),r=n.bitLength();if(r<=64)return R(n,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var s=Math.log(2)*r.toJSNumber(),a=Math.ceil(!0===e?2*Math.pow(s,2):s),o=[],l=0;l<a;l++)o.push(i(l+2));return R(n,o)},o.prototype.isPrime=a.prototype.isPrime=s.prototype.isPrime,s.prototype.isProbablePrime=function(e,t){var n=O(this);if(void 0!==n)return n;for(var r=this.abs(),s=void 0===e?5:e,a=[],o=0;o<s;o++)a.push(i.randBetween(2,r.minus(2),t));return R(r,a)},o.prototype.isProbablePrime=a.prototype.isProbablePrime=s.prototype.isProbablePrime,s.prototype.modInv=function(e){for(var t,n,r,s=i.zero,a=i.one,o=j(e),l=this.abs();!l.isZero();)t=o.divide(l),n=s,r=o,s=a,o=l,a=n.subtract(t.multiply(a)),l=r.subtract(t.multiply(l));if(!o.isUnit())throw Error(this.toString()+" and "+e.toString()+" are not co-prime");return(-1===s.compare(0)&&(s=s.add(e)),this.isNegative())?s.negate():s},o.prototype.modInv=a.prototype.modInv=s.prototype.modInv,s.prototype.next=function(){var e=this.value;return this.sign?g(e,1,this.sign):new s(E(e,1),this.sign)},a.prototype.next=function(){var t=this.value;return t+1<0x20000000000000?new a(t+1):new s(e,!1)},o.prototype.next=function(){return new o(this.value+BigInt(1))},s.prototype.prev=function(){var e=this.value;return this.sign?new s(E(e,1),!0):g(e,1,this.sign)},a.prototype.prev=function(){var t=this.value;return t-1>-0x20000000000000?new a(t-1):new s(e,!0)},o.prototype.prev=function(){return new o(this.value-BigInt(1))};for(var b=[1];2*b[b.length-1]<=1e7;)b.push(2*b[b.length-1]);var D=b.length,L=b[D-1];function w(e){return 1e7>=Math.abs(e)}function M(e,t,n){t=j(t);for(var r=e.isNegative(),s=t.isNegative(),a=r?e.not():e,o=s?t.not():t,l=0,u=0,c=null,d=null,_=[];!a.isZero()||!o.isZero();)l=(c=C(a,L))[1].toJSNumber(),r&&(l=L-1-l),u=(d=C(o,L))[1].toJSNumber(),s&&(u=L-1-u),a=c[0],o=d[0],_.push(n(l,u));for(var f=0!==n(+!!r,+!!s)?i(-1):i(0),h=_.length-1;h>=0;h-=1)f=f.multiply(L).add(i(_[h]));return f}s.prototype.shiftLeft=function(e){var t=j(e).toJSNumber();if(!w(t))throw Error(String(t)+" is too large for shifting.");if(t<0)return this.shiftRight(-t);var n=this;if(n.isZero())return n;for(;t>=D;)n=n.multiply(L),t-=D-1;return n.multiply(b[t])},o.prototype.shiftLeft=a.prototype.shiftLeft=s.prototype.shiftLeft,s.prototype.shiftRight=function(e){var t,n=j(e).toJSNumber();if(!w(n))throw Error(String(n)+" is too large for shifting.");if(n<0)return this.shiftLeft(-n);for(var i=this;n>=D;){if(i.isZero()||i.isNegative()&&i.isUnit())return i;i=(t=C(i,L))[1].isNegative()?t[0].prev():t[0],n-=D-1}return(t=C(i,b[n]))[1].isNegative()?t[0].prev():t[0]},o.prototype.shiftRight=a.prototype.shiftRight=s.prototype.shiftRight,s.prototype.not=function(){return this.negate().prev()},o.prototype.not=a.prototype.not=s.prototype.not,s.prototype.and=function(e){return M(this,e,function(e,t){return e&t})},o.prototype.and=a.prototype.and=s.prototype.and,s.prototype.or=function(e){return M(this,e,function(e,t){return e|t})},o.prototype.or=a.prototype.or=s.prototype.or,s.prototype.xor=function(e){return M(this,e,function(e,t){return e^t})},o.prototype.xor=a.prototype.xor=s.prototype.xor;function P(e){var t=e.value,n="number"==typeof t?0x40000000|t:"bigint"==typeof t?t|BigInt(0x40000000):t[0]+1e7*t[1]|0x40004000;return n&-n}function x(e,t){return e=j(e),t=j(t),e.greater(t)?e:t}function U(e,t){return e=j(e),t=j(t),e.lesser(t)?e:t}function k(e,t){if(e=j(e).abs(),t=j(t).abs(),e.equals(t))return e;if(e.isZero())return t;if(t.isZero())return e;for(var n,i,s=r[1];e.isEven()&&t.isEven();)n=U(P(e),P(t)),e=e.divide(n),t=t.divide(n),s=s.multiply(n);for(;e.isEven();)e=e.divide(P(e));do{for(;t.isEven();)t=t.divide(P(t));e.greater(t)&&(i=t,t=e,e=i),t=t.subtract(e)}while(!t.isZero());return s.isUnit()?e:e.multiply(s)}s.prototype.bitLength=function(){var e=this;return(0>e.compareTo(i(0))&&(e=e.negate().subtract(i(1))),0===e.compareTo(i(0)))?i(0):i(function e(t,n){if(0>=n.compareTo(t)){var r=e(t,n.square(n)),s=r.p,a=r.e,o=s.multiply(n);return 0>=o.compareTo(t)?{p:o,e:2*a+1}:{p:s,e:2*a}}return{p:i(1),e:0}}(e,i(2)).e).add(i(1))},o.prototype.bitLength=a.prototype.bitLength=s.prototype.bitLength;var G=function(e,n,i,r){i=i||t,e=String(e),r||(e=e.toLowerCase(),i=i.toLowerCase());var s,a=e.length,o=Math.abs(n),l={};for(s=0;s<i.length;s++)l[i[s]]=s;for(s=0;s<a;s++){var u=e[s];if("-"!==u&&u in l&&l[u]>=o){if("1"===u&&1===o)continue;throw Error(u+" is not a valid digit in base "+n+".")}}n=j(n);var c=[],d="-"===e[0];for(s=+!!d;s<e.length;s++){var u=e[s];if(u in l)c.push(j(l[u]));else if("<"===u){var _=s;do s++;while(">"!==e[s]&&s<e.length);c.push(j(e.slice(_+1,s)))}else throw Error(u+" is not a valid character")}return F(c,n,d)};function F(e,t,n){var i,s=r[0],a=r[1];for(i=e.length-1;i>=0;i--)s=s.add(e[i].times(a)),a=a.times(t);return n?s.negate():s}function V(e,t){if((t=i(t)).isZero()){if(e.isZero())return{value:[0],isNegative:!1};throw Error("Cannot convert nonzero numbers to base 0.")}if(t.equals(-1)){if(e.isZero())return{value:[0],isNegative:!1};if(e.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-e.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var n=Array.apply(null,Array(e.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return n.unshift([1]),{value:[].concat.apply([],n),isNegative:!1}}var r=!1;if(e.isNegative()&&t.isPositive()&&(r=!0,e=e.abs()),t.isUnit())return e.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(e.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:r};for(var s,a=[],o=e;o.isNegative()||o.compareAbs(t)>=0;){o=(s=o.divmod(t)).quotient;var l=s.remainder;l.isNegative()&&(l=t.minus(l).abs(),o=o.next()),a.push(l.toJSNumber())}return a.push(o.toJSNumber()),{value:a.reverse(),isNegative:r}}function B(e,n,i){var r=V(e,n);return(r.isNegative?"-":"")+r.value.map(function(e){var n;return e<(n=(n=i)||t).length?n[e]:"<"+e+">"}).join("")}function H(e){if(l(+e)){var t=+e;if(t===f(t))return n?new o(BigInt(t)):new a(t);throw Error("Invalid integer: "+e)}var i="-"===e[0];i&&(e=e.slice(1));var r=e.split(/e/i);if(r.length>2)throw Error("Invalid integer: "+r.join("e"));if(2===r.length){var u=r[1];if("+"===u[0]&&(u=u.slice(1)),(u*=1)!==f(u)||!l(u))throw Error("Invalid integer: "+u+" is not a valid exponent.");var c=r[0],_=c.indexOf(".");if(_>=0&&(u-=c.length-_-1,c=c.slice(0,_)+c.slice(_+1)),u<0)throw Error("Cannot include negative exponent part for integers");c+=Array(u+1).join("0"),e=c}if(!/^([0-9][0-9]*)$/.test(e))throw Error("Invalid integer: "+e);if(n)return new o(BigInt(i?"-"+e:e));for(var h=[],p=e.length,E=p-7;p>0;)h.push(+e.slice(E,p)),(E-=7)<0&&(E=0),p-=7;return d(h),new s(h,i)}function j(e){if("number"==typeof e){if(n)return new o(BigInt(e));if(l(e)){if(e!==f(e))throw Error(e+" is not an integer.");return new a(e)}return H(e.toString())}return"string"==typeof e?H(e):"bigint"==typeof e?new o(e):e}s.prototype.toArray=function(e){return V(this,e)},a.prototype.toArray=function(e){return V(this,e)},o.prototype.toArray=function(e){return V(this,e)},s.prototype.toString=function(e,t){if(void 0===e&&(e=10),10!==e)return B(this,e,t);for(var n,i=this.value,r=i.length,s=String(i[--r]);--r>=0;)n=String(i[r]),s+="0000000".slice(n.length)+n;return(this.sign?"-":"")+s},a.prototype.toString=function(e,t){return(void 0===e&&(e=10),10!=e)?B(this,e,t):String(this.value)},o.prototype.toString=a.prototype.toString,o.prototype.toJSON=s.prototype.toJSON=a.prototype.toJSON=function(){return this.toString()},s.prototype.valueOf=function(){return parseInt(this.toString(),10)},s.prototype.toJSNumber=s.prototype.valueOf,a.prototype.valueOf=function(){return this.value},a.prototype.toJSNumber=a.prototype.valueOf,o.prototype.valueOf=o.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};for(var Y=0;Y<1e3;Y++)r[Y]=j(Y),Y>0&&(r[-Y]=j(-Y));return r.one=r[1],r.zero=r[0],r.minusOne=r[-1],r.max=x,r.min=U,r.gcd=k,r.lcm=function(e,t){return e=j(e).abs(),t=j(t).abs(),e.divide(k(e,t)).multiply(t)},r.isInstance=function(e){return e instanceof s||e instanceof a||e instanceof o},r.randBetween=function(e,t,n){e=j(e);var i=n||Math.random,s=U(e,t=j(t)),a=x(e,t).subtract(s).add(1);if(a.isSmall)return s.add(Math.floor(i()*a));for(var o=V(a,1e7).value,l=[],u=!0,c=0;c<o.length;c++){var d=u?o[c]:1e7,_=f(i()*d);l.push(_),_<d&&(u=!1)}return s.add(r.fromArray(l,1e7,!1))},r.fromArray=function(e,t,n){return F(e.map(j),j(t||10),n)},r}();e.hasOwnProperty("exports")&&(e.exports=i),"function"==typeof define&&define.amd&&define(function(){return i})}