Module 824120

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