diff --git a/sssa-min.js b/sssa-min.js index b772229..574fed3 100644 --- a/sssa-min.js +++ b/sssa-min.js @@ -1,2 +1,2 @@ !function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;ovalue,this.isSmall=!0}function isPrecise(n){return n>-MAX_INT&&MAX_INT>n}function smallToArray(n){return 1e7>n?[n]:1e14>n?[n%1e7,Math.floor(n/1e7)]:[n%1e7,Math.floor(n/1e7)%1e7,Math.floor(n/1e14)]}function arrayToSmall(arr){trim(arr);var length=arr.length;if(4>length&&compareAbs(arr,MAX_INT_ARR)<0)switch(length){case 0:return 0;case 1:return arr[0];case 2:return arr[0]+arr[1]*BASE;default:return arr[0]+(arr[1]+arr[2]*BASE)*BASE}return arr}function trim(v){for(var i=v.length;0===v[--i];);v.length=i+1}function createArray(length){for(var x=new Array(length),i=-1;++i0?Math.floor(n):Math.ceil(n)}function add(a,b){var sum,i,l_a=a.length,l_b=b.length,r=new Array(l_a),carry=0,base=BASE;for(i=0;l_b>i;i++)sum=a[i]+b[i]+carry,carry=sum>=base?1:0,r[i]=sum-carry*base;for(;l_a>i;)sum=a[i]+carry,carry=sum===base?1:0,r[i++]=sum-carry*base;return carry>0&&r.push(carry),r}function addAny(a,b){return a.length>=b.length?add(a,b):add(b,a)}function addSmall(a,carry){var sum,i,l=a.length,r=new Array(l),base=BASE;for(i=0;l>i;i++)sum=a[i]-base+carry,carry=Math.floor(sum/base),r[i]=sum-carry*base,carry+=1;for(;carry>0;)r[i++]=carry%base,carry=Math.floor(carry/base);return r}function subtract(a,b){var i,difference,a_l=a.length,b_l=b.length,r=new Array(a_l),borrow=0,base=BASE;for(i=0;b_l>i;i++)difference=a[i]-borrow-b[i],0>difference?(difference+=base,borrow=1):borrow=0,r[i]=difference;for(i=b_l;a_l>i;i++){if(difference=a[i]-borrow,!(0>difference)){r[i++]=difference;break}difference+=base,r[i]=difference}for(;a_l>i;i++)r[i]=a[i];return trim(r),r}function subtractAny(a,b,sign){var value;return compareAbs(a,b)>=0?value=subtract(a,b):(value=subtract(b,a),sign=!sign),value=arrayToSmall(value),"number"==typeof value?(sign&&(value=-value),new SmallInteger(value)):new BigInteger(value,sign)}function subtractSmall(a,b,sign){var i,difference,l=a.length,r=new Array(l),carry=-b,base=BASE;for(i=0;l>i;i++)difference=a[i]+carry,carry=Math.floor(difference/base),difference%=base,r[i]=0>difference?difference+base:difference;return r=arrayToSmall(r),"number"==typeof r?(sign&&(r=-r),new SmallInteger(r)):new BigInteger(r,sign)}function multiplyLong(a,b){var product,carry,i,a_i,b_j,a_l=a.length,b_l=b.length,l=a_l+b_l,r=createArray(l),base=BASE;for(i=0;a_l>i;++i){a_i=a[i];for(var j=0;b_l>j;++j)b_j=b[j],product=a_i*b_j+r[i+j],carry=Math.floor(product/base),r[i+j]=product-carry*base,r[i+j+1]+=carry}return trim(r),r}function multiplySmall(a,b){var product,i,l=a.length,r=new Array(l),base=BASE,carry=0;for(i=0;l>i;i++)product=a[i]*b+carry,carry=Math.floor(product/base),r[i]=product-carry*base;for(;carry>0;)r[i++]=carry%base,carry=Math.floor(carry/base);return r}function shiftLeft(x,n){for(var r=[];n-- >0;)r.push(0);return r.concat(x)}function multiplyKaratsuba(x,y){var n=Math.max(x.length,y.length);if(400>=n)return multiplyLong(x,y);n=Math.ceil(n/2);var b=x.slice(n),a=x.slice(0,n),d=y.slice(n),c=y.slice(0,n),ac=multiplyKaratsuba(a,c),bd=multiplyKaratsuba(b,d),abcd=multiplyKaratsuba(addAny(a,b),addAny(c,d));return addAny(addAny(ac,shiftLeft(subtract(subtract(abcd,ac),bd),n)),shiftLeft(bd,2*n))}function multiplySmallAndArray(a,b,sign){return BASE>a?new BigInteger(multiplySmall(b,a),sign):new BigInteger(multiplyLong(b,smallToArray(a)),sign)}function square(a){var product,carry,i,a_i,a_j,l=a.length,r=createArray(l+l),base=BASE;for(i=0;l>i;i++){a_i=a[i];for(var j=0;l>j;j++)a_j=a[j],product=a_i*a_j+r[i+j],carry=Math.floor(product/base),r[i+j]=product-carry*base,r[i+j+1]+=carry}return trim(r),r}function divMod1(a,b){var quotientDigit,shift,carry,borrow,i,l,q,a_l=a.length,b_l=b.length,base=BASE,result=createArray(b.length),divisorMostSignificantDigit=b[b_l-1],lambda=Math.ceil(base/(2*divisorMostSignificantDigit)),remainder=multiplySmall(a,lambda),divisor=multiplySmall(b,lambda);for(remainder.length<=a_l&&remainder.push(0),divisor.push(0),divisorMostSignificantDigit=divisor[b_l-1],shift=a_l-b_l;shift>=0;shift--){for(quotientDigit=base-1,remainder[shift+b_l]!==divisorMostSignificantDigit&&(quotientDigit=Math.floor((remainder[shift+b_l]*base+remainder[shift+b_l-1])/divisorMostSignificantDigit)),carry=0,borrow=0,l=divisor.length,i=0;l>i;i++)carry+=quotientDigit*divisor[i],q=Math.floor(carry/base),borrow+=remainder[shift+i]-(carry-q*base),carry=q,0>borrow?(remainder[shift+i]=borrow+base,borrow=-1):(remainder[shift+i]=borrow,borrow=0);for(;0!==borrow;){for(quotientDigit-=1,carry=0,i=0;l>i;i++)carry+=remainder[shift+i]-base+divisor[i],0>carry?(remainder[shift+i]=carry+base,carry=0):(remainder[shift+i]=carry,carry=1);borrow+=carry}result[shift]=quotientDigit}return remainder=divModSmall(remainder,lambda)[0],[arrayToSmall(result),arrayToSmall(remainder)]}function divMod2(a,b){for(var guess,xlen,highx,highy,check,a_l=a.length,b_l=b.length,result=[],part=[],base=BASE;a_l;)if(part.unshift(a[--a_l]),compareAbs(part,b)<0)result.push(0);else{xlen=part.length,highx=part[xlen-1]*base+part[xlen-2],highy=b[b_l-1]*base+b[b_l-2],xlen>b_l&&(highx=(highx+1)*base),guess=Math.ceil(highx/highy);do{if(check=multiplySmall(b,guess),compareAbs(check,part)<=0)break;guess--}while(guess);result.push(guess),part=subtract(part,check)}return result.reverse(),[arrayToSmall(result),arrayToSmall(part)]}function divModSmall(value,lambda){var i,q,remainder,divisor,length=value.length,quotient=createArray(length),base=BASE;for(remainder=0,i=length-1;i>=0;--i)divisor=remainder*base+value[i],q=truncate(divisor/lambda),remainder=divisor-q*lambda,quotient[i]=0|q;return[quotient,0|remainder]}function divModAny(self,v){var value,quotient,n=parseValue(v),a=self.value,b=n.value;if(0===b)throw new Error("Cannot divide by zero");if(self.isSmall)return n.isSmall?[new SmallInteger(truncate(a/b)),new SmallInteger(a%b)]:[CACHE[0],self];if(n.isSmall){if(1===b)return[self,CACHE[0]];if(-1==b)return[self.negate(),CACHE[0]];var abs=Math.abs(b);if(BASE>abs){value=divModSmall(a,abs),quotient=arrayToSmall(value[0]);var remainder=value[1];return self.sign&&(remainder=-remainder),"number"==typeof quotient?(self.sign!==n.sign&&(quotient=-quotient),[new SmallInteger(quotient),new SmallInteger(remainder)]):[new BigInteger(quotient,self.sign!==n.sign),new SmallInteger(remainder)]}b=smallToArray(abs)}var comparison=compareAbs(a,b);if(-1===comparison)return[CACHE[0],self];if(0===comparison)return[CACHE[self.sign===n.sign?1:-1],CACHE[0]];value=a.length+b.length<=200?divMod1(a,b):divMod2(a,b),quotient=value[0];var qSign=self.sign!==n.sign,mod=value[1],mSign=self.sign;return"number"==typeof quotient?(qSign&&(quotient=-quotient),quotient=new SmallInteger(quotient)):quotient=new BigInteger(quotient,qSign),"number"==typeof mod?(mSign&&(mod=-mod),mod=new SmallInteger(mod)):mod=new BigInteger(mod,mSign),[quotient,mod]}function compareAbs(a,b){if(a.length!==b.length)return a.length>b.length?1:-1;for(var i=a.length-1;i>=0;i--)if(a[i]!==b[i])return a[i]>b[i]?1:-1;return 0}function isBasicPrime(v){var n=v.abs();return n.isUnit()?!1:n.equals(2)||n.equals(3)||n.equals(5)?!0:n.isEven()||n.isDivisibleBy(3)||n.isDivisibleBy(5)?!1:n.lesser(25)?!0:void 0}function shift_isSmall(n){return("number"==typeof n||"string"==typeof n)&&+Math.abs(n)<=BASE||n instanceof BigInteger&&n.value.length<=1}function bitwise(x,y,fn){y=parseValue(y);for(var xSign=x.isNegative(),ySign=y.isNegative(),xRem=xSign?x.not():x,yRem=ySign?y.not():y,xBits=[],yBits=[],xStop=!1,yStop=!1;!xStop||!yStop;)xRem.isZero()?(xStop=!0,xBits.push(xSign?1:0)):xSign?xBits.push(xRem.isEven()?1:0):xBits.push(xRem.isEven()?0:1),yRem.isZero()?(yStop=!0,yBits.push(ySign?1:0)):ySign?yBits.push(yRem.isEven()?1:0):yBits.push(yRem.isEven()?0:1),xRem=xRem.over(2),yRem=yRem.over(2);for(var result=[],i=0;i=0;i--){var top=restricted?range.value[i]:BASE,digit=truncate(Math.random()*top);result.unshift(digit),top>digit&&(restricted=!1)}return result=arrayToSmall(result),low.add("number"==typeof result?new SmallInteger(result):new BigInteger(result,!1))}function stringify(digit){var v=digit.value;return"number"==typeof v&&(v=[v]),1===v.length&&v[0]<=36?"0123456789abcdefghijklmnopqrstuvwxyz".charAt(v[0]):"<"+v+">"}function toBase(n,base){if(base=bigInt(base),base.isZero()){if(n.isZero())return"0";throw new Error("Cannot convert nonzero numbers to base 0.")}if(base.equals(-1))return n.isZero()?"0":n.isNegative()?new Array(1-n).join("10"):"1"+new Array(+n).join("01");var minusSign="";if(n.isNegative()&&base.isPositive()&&(minusSign="-",n=n.abs()),base.equals(1))return n.isZero()?"0":minusSign+new Array(+n+1).join(1);for(var divmod,out=[],left=n;left.isNegative()||left.compareAbs(base)>=0;){divmod=left.divmod(base),left=divmod.quotient;var digit=divmod.remainder;digit.isNegative()&&(digit=base.minus(digit).abs(),left=left.next()),out.push(stringify(digit))}return out.push(stringify(left)),minusSign+out.reverse().join("")}function parseStringValue(v){if(isPrecise(+v)){var x=+v;if(x===truncate(x))return new SmallInteger(x);throw"Invalid integer: "+v}var sign="-"===v[0];sign&&(v=v.slice(1));var split=v.split(/e/i);if(split.length>2)throw new Error("Invalid integer: "+text.join("e"));if(2===split.length){var exp=split[1];if("+"===exp[0]&&(exp=exp.slice(1)),exp=+exp,exp!==truncate(exp)||!isPrecise(exp))throw new Error("Invalid integer: "+exp+" is not a valid exponent.");var text=split[0],decimalPlace=text.indexOf(".");if(decimalPlace>=0&&(exp-=text.length-decimalPlace,text=text.slice(0,decimalPlace)+text.slice(decimalPlace+1)),0>exp)throw new Error("Cannot include negative exponent part for integers");text+=new Array(exp+1).join("0"),v=text}var isValid=/^([0-9][0-9]*)$/.test(v);if(!isValid)throw new Error("Invalid integer: "+v);for(var r=[],max=v.length,l=LOG_BASE,min=max-l;max>0;)r.push(+v.slice(min,max)),min-=l,0>min&&(min=0),max-=l;return trim(r),new BigInteger(r,sign)}function parseNumberValue(v){return isPrecise(v)?new SmallInteger(v):parseStringValue(v.toString())}function parseValue(v){return"number"==typeof v?parseNumberValue(v):"string"==typeof v?parseStringValue(v):v}var BASE=1e7,LOG_BASE=7,MAX_INT=9007199254740992,MAX_INT_ARR=smallToArray(MAX_INT),LOG_MAX_INT=Math.log(MAX_INT);BigInteger.prototype.add=function(v){var n=parseValue(v);if(this.sign!==n.sign)return this.subtract(n.negate());var a=this.value,b=n.value;return n.isSmall?new BigInteger(addSmall(a,Math.abs(b)),this.sign):new BigInteger(addAny(a,b),this.sign)},BigInteger.prototype.plus=BigInteger.prototype.add,SmallInteger.prototype.add=function(v){var n=parseValue(v),a=this.value;if(0>a!==n.sign)return this.subtract(n.negate());var b=n.value;if(n.isSmall){if(isPrecise(a+b))return new SmallInteger(a+b);b=smallToArray(Math.abs(b))}return new BigInteger(addSmall(b,Math.abs(a)),0>a)},SmallInteger.prototype.plus=SmallInteger.prototype.add,BigInteger.prototype.subtract=function(v){var n=parseValue(v);if(this.sign!==n.sign)return this.add(n.negate());var a=this.value,b=n.value;return n.isSmall?subtractSmall(a,Math.abs(b),this.sign):subtractAny(a,b,this.sign)},BigInteger.prototype.minus=BigInteger.prototype.subtract,SmallInteger.prototype.subtract=function(v){var n=parseValue(v),a=this.value;if(0>a!==n.sign)return this.add(n.negate());var b=n.value;return n.isSmall?new SmallInteger(a-b):subtractSmall(b,Math.abs(a),a>=0)},SmallInteger.prototype.minus=SmallInteger.prototype.subtract,BigInteger.prototype.negate=function(){return new BigInteger(this.value,!this.sign)},SmallInteger.prototype.negate=function(){var sign=this.sign,small=new SmallInteger(-this.value);return small.sign=!sign,small},BigInteger.prototype.abs=function(){return new BigInteger(this.value,!1)},SmallInteger.prototype.abs=function(){return new SmallInteger(Math.abs(this.value))},BigInteger.prototype.multiply=function(v){var abs,n=parseValue(v),a=this.value,b=n.value,sign=this.sign!==n.sign;if(n.isSmall){if(0===b)return CACHE[0];if(1===b)return this;if(-1===b)return this.negate();if(abs=Math.abs(b),BASE>abs)return new BigInteger(multiplySmall(a,abs),sign);b=smallToArray(abs)}return a.length+b.length>4e3?new BigInteger(multiplyKaratsuba(a,b),sign):new BigInteger(multiplyLong(a,b),sign)},BigInteger.prototype.times=BigInteger.prototype.multiply,SmallInteger.prototype._multiplyBySmall=function(a){return isPrecise(a.value*this.value)?new SmallInteger(a.value*this.value):multiplySmallAndArray(Math.abs(a.value),smallToArray(Math.abs(this.value)),this.sign!==a.sign)},BigInteger.prototype._multiplyBySmall=function(a){return 0===a.value?CACHE[0]:1===a.value?this:-1===a.value?this.negate():multiplySmallAndArray(Math.abs(a.value),this.value,this.sign!==a.sign)},SmallInteger.prototype.multiply=function(v){return parseValue(v)._multiplyBySmall(this)},SmallInteger.prototype.times=SmallInteger.prototype.multiply,BigInteger.prototype.square=function(){return new BigInteger(square(this.value),!1)},SmallInteger.prototype.square=function(){var value=this.value*this.value;return isPrecise(value)?new SmallInteger(value):new BigInteger(square(smallToArray(Math.abs(this.value))),!1)},BigInteger.prototype.divmod=function(v){var result=divModAny(this,v);return{quotient:result[0],remainder:result[1]}},SmallInteger.prototype.divmod=BigInteger.prototype.divmod,BigInteger.prototype.divide=function(v){return divModAny(this,v)[0]},SmallInteger.prototype.over=SmallInteger.prototype.divide=BigInteger.prototype.over=BigInteger.prototype.divide,BigInteger.prototype.mod=function(v){return divModAny(this,v)[1]},SmallInteger.prototype.remainder=SmallInteger.prototype.mod=BigInteger.prototype.remainder=BigInteger.prototype.mod,BigInteger.prototype.pow=function(v){var value,x,y,n=parseValue(v),a=this.value,b=n.value;if(0===b)return CACHE[1];if(0===a)return CACHE[0];if(1===a)return CACHE[1];if(-1===a)return n.isEven()?CACHE[1]:CACHE[-1];if(n.sign)return CACHE[0];if(!n.isSmall)throw new Error("The exponent "+n.toString()+" is too large.");if(this.isSmall&&isPrecise(value=Math.pow(a,b)))return new SmallInteger(truncate(value));for(x=this,y=CACHE[1];;){if(b&!0&&(y=y.times(x),--b),0===b)break;b/=2,x=x.square()}return y},SmallInteger.prototype.pow=BigInteger.prototype.pow,BigInteger.prototype.modPow=function(exp,mod){if(exp=parseValue(exp),mod=parseValue(mod),mod.isZero())throw new Error("Cannot take modPow with modulus 0");var r=CACHE[1],base=this.mod(mod);if(base.isZero())return CACHE[0];for(;exp.isPositive();)exp.isOdd()&&(r=r.multiply(base).mod(mod)),exp=exp.divide(2),base=base.square().mod(mod);return r},SmallInteger.prototype.modPow=BigInteger.prototype.modPow,BigInteger.prototype.compareAbs=function(v){var n=parseValue(v),a=this.value,b=n.value;return n.isSmall?1:compareAbs(a,b)},SmallInteger.prototype.compareAbs=function(v){var n=parseValue(v),a=Math.abs(this.value),b=n.value;return n.isSmall?(b=Math.abs(b),a===b?0:a>b?1:-1):-1},BigInteger.prototype.compare=function(v){var n=parseValue(v),a=this.value,b=n.value;return this.sign!==n.sign?n.sign?1:-1:n.isSmall?this.sign?-1:1:compareAbs(a,b)*(this.sign?-1:1)},BigInteger.prototype.compareTo=BigInteger.prototype.compare,SmallInteger.prototype.compare=function(v){var n=parseValue(v),a=this.value,b=n.value;return n.isSmall?a==b?0:a>b?1:-1:0>a!==n.sign?0>a?-1:1:0>a?1:-1},SmallInteger.prototype.compareTo=SmallInteger.prototype.compare,BigInteger.prototype.equals=function(v){return 0===this.compare(v)},SmallInteger.prototype.eq=SmallInteger.prototype.equals=BigInteger.prototype.eq=BigInteger.prototype.equals,BigInteger.prototype.notEquals=function(v){return 0!==this.compare(v)},SmallInteger.prototype.neq=SmallInteger.prototype.notEquals=BigInteger.prototype.neq=BigInteger.prototype.notEquals,BigInteger.prototype.greater=function(v){return this.compare(v)>0},SmallInteger.prototype.gt=SmallInteger.prototype.greater=BigInteger.prototype.gt=BigInteger.prototype.greater,BigInteger.prototype.lesser=function(v){return this.compare(v)<0},SmallInteger.prototype.lt=SmallInteger.prototype.lesser=BigInteger.prototype.lt=BigInteger.prototype.lesser,BigInteger.prototype.greaterOrEquals=function(v){return this.compare(v)>=0},SmallInteger.prototype.geq=SmallInteger.prototype.greaterOrEquals=BigInteger.prototype.geq=BigInteger.prototype.greaterOrEquals,BigInteger.prototype.lesserOrEquals=function(v){return this.compare(v)<=0},SmallInteger.prototype.leq=SmallInteger.prototype.lesserOrEquals=BigInteger.prototype.leq=BigInteger.prototype.lesserOrEquals,BigInteger.prototype.isEven=function(){return 0===(1&this.value[0])},SmallInteger.prototype.isEven=function(){return 0===(1&this.value)},BigInteger.prototype.isOdd=function(){return 1===(1&this.value[0])},SmallInteger.prototype.isOdd=function(){return 1===(1&this.value)},BigInteger.prototype.isPositive=function(){return!this.sign},SmallInteger.prototype.isPositive=function(){return this.value>0},BigInteger.prototype.isNegative=function(){return this.sign},SmallInteger.prototype.isNegative=function(){return this.value<0},BigInteger.prototype.isUnit=function(){return!1},SmallInteger.prototype.isUnit=function(){return 1===Math.abs(this.value)},BigInteger.prototype.isZero=function(){return!1},SmallInteger.prototype.isZero=function(){return 0===this.value},BigInteger.prototype.isDivisibleBy=function(v){var n=parseValue(v),value=n.value;return 0===value?!1:1===value?!0:2===value?this.isEven():this.mod(n).equals(CACHE[0])},SmallInteger.prototype.isDivisibleBy=BigInteger.prototype.isDivisibleBy,BigInteger.prototype.isPrime=function(){var isPrime=isBasicPrime(this);if(isPrime!==undefined)return isPrime;for(var d,t,i,x,n=this.abs(),nPrev=n.prev(),a=[2,3,5,7,11,13,17,19],b=nPrev;b.isEven();)b=b.divide(2);for(i=0;ii;i++){var a=bigInt.randBetween(2,n.minus(2));if(!a.modPow(n.prev(),n).isUnit())return!1}return!0},SmallInteger.prototype.isProbablePrime=BigInteger.prototype.isProbablePrime,BigInteger.prototype.next=function(){var value=this.value;return this.sign?subtractSmall(value,1,this.sign):new BigInteger(addSmall(value,1),this.sign)},SmallInteger.prototype.next=function(){var value=this.value;return MAX_INT>value+1?new SmallInteger(value+1):new BigInteger(MAX_INT_ARR,!1)},BigInteger.prototype.prev=function(){var value=this.value;return this.sign?new BigInteger(addSmall(value,1),!0):subtractSmall(value,1,this.sign)},SmallInteger.prototype.prev=function(){var value=this.value;return value-1>-MAX_INT?new SmallInteger(value-1):new BigInteger(MAX_INT_ARR,!0)};for(var powersOfTwo=[1];powersOfTwo[powersOfTwo.length-1]<=BASE;)powersOfTwo.push(2*powersOfTwo[powersOfTwo.length-1]);var powers2Length=powersOfTwo.length,highestPower2=powersOfTwo[powers2Length-1];BigInteger.prototype.shiftLeft=function(n){if(!shift_isSmall(n))return n.isNegative()?this.shiftRight(n.abs()):this.times(CACHE[2].pow(n));if(n=+n,0>n)return this.shiftRight(-n);for(var result=this;n>=powers2Length;)result=result.multiply(highestPower2),n-=powers2Length-1;return result.multiply(powersOfTwo[n])},SmallInteger.prototype.shiftLeft=BigInteger.prototype.shiftLeft,BigInteger.prototype.shiftRight=function(n){var remQuo;if(!shift_isSmall(n))return n.isNegative()?this.shiftLeft(n.abs()):(remQuo=this.divmod(CACHE[2].pow(n)),remQuo.remainder.isNegative()?remQuo.quotient.prev():remQuo.quotient);if(n=+n,0>n)return this.shiftLeft(-n);for(var result=this;n>=powers2Length;){if(result.isZero())return result;remQuo=divModAny(result,highestPower2),result=remQuo[1].isNegative()?remQuo[0].prev():remQuo[0],n-=powers2Length-1}return remQuo=divModAny(result,powersOfTwo[n]),remQuo[1].isNegative()?remQuo[0].prev():remQuo[0]},SmallInteger.prototype.shiftRight=BigInteger.prototype.shiftRight,BigInteger.prototype.not=function(){return this.negate().prev()},SmallInteger.prototype.not=BigInteger.prototype.not,BigInteger.prototype.and=function(n){return bitwise(this,n,function(a,b){return a&b})},SmallInteger.prototype.and=BigInteger.prototype.and,BigInteger.prototype.or=function(n){return bitwise(this,n,function(a,b){return a|b})},SmallInteger.prototype.or=BigInteger.prototype.or,BigInteger.prototype.xor=function(n){return bitwise(this,n,function(a,b){return a^b})},SmallInteger.prototype.xor=BigInteger.prototype.xor;var LOBMASK_I=1<<30,LOBMASK_BI=(BASE&-BASE)*(BASE&-BASE)|LOBMASK_I,parseBase=function(text,base){var val=CACHE[0],pow=CACHE[1],length=text.length;if(base>=2&&36>=base&&length<=LOG_MAX_INT/Math.log(base))return new SmallInteger(parseInt(text,base));base=parseValue(base);var i,digits=[],isNegative="-"===text[0];for(i=isNegative?1:0;i=48&&57>=charCode)digits.push(parseValue(c));else if(charCode>=97&&122>=charCode)digits.push(parseValue(c.charCodeAt(0)-87));else{if("<"!==c)throw new Error(c+" is not a valid character");var start=i;do i++;while(">"!==text[i]);digits.push(parseValue(text.slice(start+1,i)))}}for(digits.reverse(),i=0;i=0;)digit=String(v[l]),str+=zeros.slice(digit.length)+digit;var sign=this.sign?"-":"";return sign+str},SmallInteger.prototype.toString=function(radix){return radix===undefined&&(radix=10),10!=radix?toBase(this,radix):String(this.value)},BigInteger.prototype.valueOf=function(){return+this.toString()},BigInteger.prototype.toJSNumber=BigInteger.prototype.valueOf,SmallInteger.prototype.valueOf=function(){return this.value},SmallInteger.prototype.toJSNumber=SmallInteger.prototype.valueOf;for(var CACHE=function(v,radix){return"undefined"==typeof v?CACHE[0]:"undefined"!=typeof radix?10===+radix?parseValue(v):parseBase(v,radix):parseValue(v)},i=0;1e3>i;i++)CACHE[i]=new SmallInteger(i),i>0&&(CACHE[-i]=new SmallInteger(-i));return CACHE.one=CACHE[1],CACHE.zero=CACHE[0],CACHE.minusOne=CACHE[-1],CACHE.max=max,CACHE.min=min,CACHE.gcd=gcd,CACHE.lcm=lcm,CACHE.isInstance=function(x){return x instanceof BigInteger||x instanceof SmallInteger},CACHE.randBetween=randBetween,CACHE}();"undefined"!=typeof module&&module.hasOwnProperty("exports")&&(module.exports=bigInt)},{}],2:[function(require,module,exports){function getRandomValues(buf){if(window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(buf);else if("object"==typeof window.msCrypto&&"function"==typeof window.msCrypto.getRandomValues)window.msCrypto.getRandomValues(buf);else{if(!nodeCrypto.randomBytes)throw new Error("No secure random number generator available.");if(buf.length>65536){var e=new Error;throw e.code=22,e.message="Failed to execute 'getRandomValues' on 'Crypto': The ArrayBufferView's byte length ("+buf.length+") exceeds the number of bytes of entropy available via this API (65536).",e.name="QuotaExceededError",e}var bytes=nodeCrypto.randomBytes(buf.length);buf.set(bytes)}}var window=require("global/window"),nodeCrypto=require("crypto");module.exports=getRandomValues},{crypto:9,"global/window":3}],3:[function(require,module,exports){(function(global){"undefined"!=typeof window?module.exports=window:"undefined"!=typeof global?module.exports=global:"undefined"!=typeof self?module.exports=self:module.exports={}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(require,module,exports){arguments[4][3][0].apply(exports,arguments)},{dup:3}],5:[function(require,module,exports){String.fromCodePoint||!function(){var defineProperty=function(){try{var object={},$defineProperty=Object.defineProperty,result=$defineProperty(object,object,object)&&$defineProperty}catch(error){}return result}(),stringFromCharCode=String.fromCharCode,floor=Math.floor,fromCodePoint=function(_){var highSurrogate,lowSurrogate,MAX_SIZE=16384,codeUnits=[],index=-1,length=arguments.length;if(!length)return"";for(var result="";++indexcodePoint||codePoint>1114111||floor(codePoint)!=codePoint)throw RangeError("Invalid code point: "+codePoint);65535>=codePoint?codeUnits.push(codePoint):(codePoint-=65536,highSurrogate=(codePoint>>10)+55296,lowSurrogate=codePoint%1024+56320,codeUnits.push(highSurrogate,lowSurrogate)),(index+1==length||codeUnits.length>MAX_SIZE)&&(result+=stringFromCharCode.apply(null,codeUnits),codeUnits.length=0)}return result};defineProperty?defineProperty(String,"fromCodePoint",{value:fromCodePoint,configurable:!0,writable:!0}):String.fromCodePoint=fromCodePoint}()},{}],6:[function(require,module,exports){String.prototype.codePointAt||!function(){"use strict";var defineProperty=function(){try{var object={},$defineProperty=Object.defineProperty,result=$defineProperty(object,object,object)&&$defineProperty}catch(error){}return result}(),codePointAt=function(position){if(null==this)throw TypeError();var string=String(this),size=string.length,index=position?Number(position):0;if(index!=index&&(index=0),!(0>index||index>=size)){var second,first=string.charCodeAt(index);return first>=55296&&56319>=first&&size>index+1&&(second=string.charCodeAt(index+1),second>=56320&&57343>=second)?1024*(first-55296)+second-56320+65536:first}};defineProperty?defineProperty(String.prototype,"codePointAt",{value:codePointAt,configurable:!0,writable:!0}):String.prototype.codePointAt=codePointAt}()},{}],7:[function(require,module,exports){module.require&&(require("string.fromcodepoint"),require("string.prototype.codepointat"));var UTF8={isNotUTF8:function(bytes,byteOffset,byteLength){try{UTF8.getStringFromBytes(bytes,byteOffset,byteLength,!0)}catch(e){return!0}return!1},getCharLength:function(theByte){return 240==(240&theByte)?4:224==(224&theByte)?3:192==(192&theByte)?2:theByte==(127&theByte)?1:0},getCharCode:function(bytes,byteOffset,charLength){var charCode=0,mask="";if(byteOffset=byteOffset||0,charLength=charLength||UTF8.getCharLength(bytes[byteOffset]),0==charLength)throw new Error(bytes[byteOffset].toString(2)+" is not a significative byte (offset:"+byteOffset+").");if(1===charLength)return bytes[byteOffset];if(mask="00000000".slice(0,charLength)+1+"00000000".slice(charLength+1),bytes[byteOffset]&parseInt(mask,2))throw Error("Index "+byteOffset+": A "+charLength+" bytes encoded char cannot encode the "+(charLength+1)+"th rank bit to 1.");for(mask="0000".slice(0,charLength+1)+"11111111".slice(charLength+1),charCode+=(bytes[byteOffset]&parseInt(mask,2))<<6*--charLength;charLength;){if(128!==(128&bytes[byteOffset+1])||64===(64&bytes[byteOffset+1]))throw Error("Index "+(byteOffset+1)+': Next bytes of encoded char must begin with a "10" bit sequence.');charCode+=(63&bytes[++byteOffset])<<6*--charLength}return charCode},getStringFromBytes:function(bytes,byteOffset,byteLength,strict){var charLength,chars=[];for(byteOffset=0|byteOffset,byteLength="number"==typeof byteLength?byteLength:bytes.byteLength||bytes.length;byteLength>byteOffset;byteOffset++){if(charLength=UTF8.getCharLength(bytes[byteOffset]),byteOffset+charLength>byteLength){if(strict)throw Error("Index "+byteOffset+": Found a "+charLength+" bytes encoded char declaration but only "+(byteLength-byteOffset)+" bytes are available.")}else chars.push(String.fromCodePoint(UTF8.getCharCode(bytes,byteOffset,charLength,strict)));byteOffset+=charLength-1}return chars.join("")},getBytesForCharCode:function(charCode){if(128>charCode)return 1;if(2048>charCode)return 2;if(65536>charCode)return 3;if(2097152>charCode)return 4;throw new Error("CharCode "+charCode+" cannot be encoded with UTF8.")},setBytesFromCharCode:function(charCode,bytes,byteOffset,neededBytes){if(charCode=0|charCode,bytes=bytes||[],byteOffset=0|byteOffset,neededBytes=neededBytes||UTF8.getBytesForCharCode(charCode),1==neededBytes)bytes[byteOffset]=charCode;else for(bytes[byteOffset++]=(parseInt("1111".slice(0,neededBytes),2)<<8-neededBytes)+(charCode>>>6*--neededBytes);neededBytes>0;)bytes[byteOffset++]=charCode>>>6*--neededBytes&63|128;return bytes},setBytesFromString:function(string,bytes,byteOffset,byteLength,strict){string=string||"",bytes=bytes||[],byteOffset=0|byteOffset,byteLength="number"==typeof byteLength?byteLength:bytes.byteLength||1/0;for(var i=0,j=string.length;j>i;i++){var neededBytes=UTF8.getBytesForCharCode(string[i].codePointAt(0));if(strict&&byteOffset+neededBytes>byteLength)throw new Error('Not enought bytes to encode the char "'+string[i]+'" at the offset "'+byteOffset+'".');UTF8.setBytesFromCharCode(string[i].codePointAt(0),bytes,byteOffset,neededBytes,strict),byteOffset+=neededBytes}return bytes}};"undefined"!=typeof module&&(module.exports=UTF8)},{"string.fromcodepoint":5,"string.prototype.codepointat":6}],8:[function(require,module,exports){(function(global){if("function"==typeof require){var bigInt=require("big-integer"),getRandomValues=require("get-random-values"),UTF8=require("utf-8"),window=require("global/window");window.atob||window.btoa||!function(window){function _getbyte64(s,i){var idx=_ALPHA.indexOf(s.charAt(i));if(-1===idx)throw"Cannot decode base64";return idx}function _decode(s){var i,b10,pads=0,imax=s.length,x=[];if(s=String(s),0===imax)return s;if(imax%4!==0)throw"Cannot decode base64";for(s.charAt(imax-1)===_PADCHAR&&(pads=1,s.charAt(imax-2)===_PADCHAR&&(pads=2),imax-=4),i=0;imax>i;i+=4)b10=_getbyte64(s,i)<<18|_getbyte64(s,i+1)<<12|_getbyte64(s,i+2)<<6|_getbyte64(s,i+3),x.push(String.fromCharCode(b10>>16,b10>>8&255,255&b10));switch(pads){case 1:b10=_getbyte64(s,i)<<18|_getbyte64(s,i+1)<<12|_getbyte64(s,i+2)<<6,x.push(String.fromCharCode(b10>>16,b10>>8&255));break;case 2:b10=_getbyte64(s,i)<<18|_getbyte64(s,i+1)<<12,x.push(String.fromCharCode(b10>>16))}return x.join("")}function _getbyte(s,i){var x=s.charCodeAt(i); -if(x>255)throw"INVALID_CHARACTER_ERR: DOM Exception 5";return x}function _encode(s){if(1!==arguments.length)throw"SyntaxError: exactly one argument required";s=String(s);var i,b10,x=[],imax=s.length-s.length%3;if(0===s.length)return s;for(i=0;imax>i;i+=3)b10=_getbyte(s,i)<<16|_getbyte(s,i+1)<<8|_getbyte(s,i+2),x.push(_ALPHA.charAt(b10>>18)),x.push(_ALPHA.charAt(b10>>12&63)),x.push(_ALPHA.charAt(b10>>6&63)),x.push(_ALPHA.charAt(63&b10));switch(s.length-imax){case 1:b10=_getbyte(s,i)<<16,x.push(_ALPHA.charAt(b10>>18)+_ALPHA.charAt(b10>>12&63)+_PADCHAR+_PADCHAR);break;case 2:b10=_getbyte(s,i)<<16|_getbyte(s,i+1)<<8,x.push(_ALPHA.charAt(b10>>18)+_ALPHA.charAt(b10>>12&63)+_ALPHA.charAt(b10>>6&63)+_PADCHAR)}return x.join("")}var _PADCHAR="=",_ALPHA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";window.btoa=_encode,window.atob=_decode}(window)}var _sssa_utils=function(root){function random(){var bytes=new Uint8Array(32),string="",i=0;getRandomValues(bytes);for(i in bytes)string+=Array(2-bytes[i].toString(16).length+1).join(0)+bytes[i].toString(16);return bigInt(string,16)}function split_ints(secrets){var result=[],working=[],i=0,hex_data="";working=UTF8.setBytesFromString(secrets);for(i in working)hex_data+=Array(2-working[i].toString(16).length+1).join(0)+working[i].toString(16);for(i=0;ishares)){var secret=utils.split_ints(raw),numbers=[bigInt(0)],polynomial=[],result=[],i=0,j=1;for(i in secret)for(polynomial.push([secret[i]]),j=1;minimum>j;j++){for(value=utils.random();value in numbers;)value=utils.random();numbers.push(value),polynomial[i].push(value)}for(i=0;shares>i;i++)for(j in secret){for(value=utils.random();value in numbers;)value=utils.random();numbers.push(value),"string"!=typeof result[i]&&(result[i]=""),result[i]+=utils.to_base64(value),result[i]+=utils.to_base64(utils.evaluate_polynomial(polynomial[j],value))}return result}}function combine(shares){var secrets=[],share="",count=0,cshare="",secret=[],origin=bigInt(0),originy=bigInt(0),numerator=bigInt(1),denominator=bigInt(1),i=0,j=0,k=0;for(i in shares){if(shares[i].length%88!=0)return;for(share=shares[i],count=share.length/88,secrets[i]=[],j=0;count>j;j++)cshare=share.substring(88*j,88*(j+1)),secrets[i][j]=[utils.from_base64(cshare.substring(0,44)),utils.from_base64(cshare.substring(44))]}for(j=0;j255)throw"INVALID_CHARACTER_ERR: DOM Exception 5";return x}function _encode(s){if(1!==arguments.length)throw"SyntaxError: exactly one argument required";s=String(s);var i,b10,x=[],imax=s.length-s.length%3;if(0===s.length)return s;for(i=0;imax>i;i+=3)b10=_getbyte(s,i)<<16|_getbyte(s,i+1)<<8|_getbyte(s,i+2),x.push(_ALPHA.charAt(b10>>18)),x.push(_ALPHA.charAt(b10>>12&63)),x.push(_ALPHA.charAt(b10>>6&63)),x.push(_ALPHA.charAt(63&b10));switch(s.length-imax){case 1:b10=_getbyte(s,i)<<16,x.push(_ALPHA.charAt(b10>>18)+_ALPHA.charAt(b10>>12&63)+_PADCHAR+_PADCHAR);break;case 2:b10=_getbyte(s,i)<<16|_getbyte(s,i+1)<<8,x.push(_ALPHA.charAt(b10>>18)+_ALPHA.charAt(b10>>12&63)+_ALPHA.charAt(b10>>6&63)+_PADCHAR)}return x.join("")}var _PADCHAR="=",_ALPHA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";window.btoa=_encode,window.atob=_decode}(window)}var _sssa_utils=function(root){function random(){var bytes=new Uint8Array(32),string="",i=0;getRandomValues(bytes);for(i in bytes)string+=Array(2-bytes[i].toString(16).length+1).join(0)+bytes[i].toString(16);return bigInt(string,16)}function split_ints(secrets){var result=[],working=[],i=0,hex_data="";working=UTF8.setBytesFromString(secrets);for(i in working)hex_data+=Array(2-working[i].toString(16).length+1).join(0)+working[i].toString(16);for(i=0;ishares)){var secret=utils.split_ints(raw),numbers=[bigInt(0)],polynomial=[],result=[],i=0,j=1;for(i in secret)for(polynomial.push([secret[i]]),j=1;minimum>j;j++){for(let value=utils.random();value in numbers;)value=utils.random();numbers.push(value),polynomial[i].push(value)}for(i=0;shares>i;i++)for(j in secret){for(let value=utils.random();value in numbers;)value=utils.random();numbers.push(value),"string"!=typeof result[i]&&(result[i]=""),result[i]+=utils.to_base64(value),result[i]+=utils.to_base64(utils.evaluate_polynomial(polynomial[j],value))}return result}}function combine(shares){var secrets=[],share="",count=0,cshare="",secret=[],origin=bigInt(0),originy=bigInt(0),numerator=bigInt(1),denominator=bigInt(1),i=0,j=0,k=0;for(i in shares){if(shares[i].length%88!=0)return;for(share=shares[i],count=share.length/88,secrets[i]=[],j=0;count>j;j++)cshare=share.substring(88*j,88*(j+1)),secrets[i][j]=[utils.from_base64(cshare.substring(0,44)),utils.from_base64(cshare.substring(44))]}for(j=0;j