dtl-js
Version:
Data Transformation Language - JSON templates and data transformation
1 lines • 256 kB
JavaScript
require=function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);throw(f=new Error("Cannot find module '"+i+"'")).code="MODULE_NOT_FOUND",f}c=n[i]={exports:{}},e[i][0].call(c.exports,function(r){return o(e[i][1][r]||r)},c,c.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}({"./dtl-crypto-helpers.js":[function(require,module,exports){const md5=require("./md5.js");let crypto_helper_list={hash:{meta:{syntax:"hash( $method $data )",returns:"A hash of the provided data using $method",description:["Returns a hash of the provided $data using $method. Supported methods are ","MD5. Note that by default the browser version only includes md5. See ","https://gitlab.com/jk0ne/DTL/-/issues/9 for details."]},"*":function(method,data){try{return function(method,data){if("md5"==method)return md5(data);throw new Error("This DTL build does not include hash methods apart from md5. rebuild with crypto enabled.")}(method,data)}catch(e){return console.warn("Failed creating hash: "+e),""}}}};module.exports=function(){return crypto_helper_list}},{"./md5.js":36}],1:[function(require,module,exports){"use strict";exports.byteLength=function(b64){var b64=getLens(b64),validLen=b64[0],b64=b64[1];return 3*(validLen+b64)/4-b64},exports.toByteArray=function(b64){var tmp,i,lens=getLens(b64),validLen=lens[0],lens=lens[1],arr=new Arr(function(validLen,placeHoldersLen){return 3*(validLen+placeHoldersLen)/4-placeHoldersLen}(validLen,lens)),curByte=0,len=0<lens?validLen-4:validLen;for(i=0;i<len;i+=4)tmp=revLookup[b64.charCodeAt(i)]<<18|revLookup[b64.charCodeAt(i+1)]<<12|revLookup[b64.charCodeAt(i+2)]<<6|revLookup[b64.charCodeAt(i+3)],arr[curByte++]=tmp>>16&255,arr[curByte++]=tmp>>8&255,arr[curByte++]=255&tmp;2===lens&&(tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4,arr[curByte++]=255&tmp);1===lens&&(tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2,arr[curByte++]=tmp>>8&255,arr[curByte++]=255&tmp);return arr},exports.fromByteArray=function(uint8){for(var tmp,len=uint8.length,extraBytes=len%3,parts=[],i=0,len2=len-extraBytes;i<len2;i+=16383)parts.push(function(uint8,start,end){for(var tmp,output=[],i=start;i<end;i+=3)tmp=(uint8[i]<<16&16711680)+(uint8[i+1]<<8&65280)+(255&uint8[i+2]),output.push(function(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[63&num]}(tmp));return output.join("")}(uint8,i,len2<i+16383?len2:i+16383));1==extraBytes?(tmp=uint8[len-1],parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")):2==extraBytes&&(tmp=(uint8[len-2]<<8)+uint8[len-1],parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"="));return parts.join("")};for(var lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function getLens(b64){var len=b64.length;if(0<len%4)throw new Error("Invalid string. Length must be a multiple of 4");b64=b64.indexOf("="),len=(b64=-1===b64?len:b64)===len?0:4-b64%4;return[b64,len]}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63},{}],2:[function(require,module,exports){!function(globalObject){"use strict";var BigNumber,isNumeric=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,mathceil=Math.ceil,mathfloor=Math.floor,bignumberError="[BigNumber Error] ",tooManyDigits=bignumberError+"Number primitive has more than 15 significant digits: ",LOG_BASE=14,POWS_TEN=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13];function bitFloor(n){var i=0|n;return 0<n||n===i?i:i-1}function coeffToString(a){for(var s,z,i=1,j=a.length,r=a[0]+"";i<j;){for(s=a[i++]+"",z=LOG_BASE-s.length;z--;s="0"+s);r+=s}for(j=r.length;48===r.charCodeAt(--j););return r.slice(0,j+1||1)}function compare(x,y){var a,b,xc=x.c,yc=y.c,i=x.s,j=y.s,x=x.e,y=y.e;if(!i||!j)return null;if(a=xc&&!xc[0],b=yc&&!yc[0],a||b)return a?b?0:-j:i;if(i!=j)return i;if(a=i<0,b=x==y,!xc||!yc)return b?0:!xc^a?1:-1;if(!b)return y<x^a?1:-1;for(j=(x=xc.length)<(y=yc.length)?x:y,i=0;i<j;i++)if(xc[i]!=yc[i])return xc[i]>yc[i]^a?1:-1;return x==y?0:y<x^a?1:-1}function intCheck(n,min,max,name){if(n<min||max<n||n!==mathfloor(n))throw Error(bignumberError+(name||"Argument")+("number"==typeof n?n<min||max<n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(n))}function isOdd(n){var k=n.c.length-1;return bitFloor(n.e/LOG_BASE)==k&&n.c[k]%2!=0}function toExponential(str,e){return(1<str.length?str.charAt(0)+"."+str.slice(1):str)+(e<0?"e":"e+")+e}function toFixedPoint(str,e,z){var len,zs;if(e<0){for(zs=z+".";++e;zs+=z);str=zs+str}else if(++e>(len=str.length)){for(zs=z,e-=len;--e;zs+=z);str+=zs}else e<len&&(str=str.slice(0,e)+"."+str.slice(e));return str}(BigNumber=function clone(configObject){var div,convertBase,parseNumeric,random53bitInt,basePrefix,dotAfter,dotBefore,isInfinityOrNaN,whitespaceOrPlus,P=BigNumber.prototype={constructor:BigNumber,toString:null,valueOf:null},ONE=new BigNumber(1),DECIMAL_PLACES=20,ROUNDING_MODE=4,TO_EXP_NEG=-7,TO_EXP_POS=21,MIN_EXP=-1e7,MAX_EXP=1e7,CRYPTO=!1,MODULO_MODE=1,POW_PRECISION=0,FORMAT={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},ALPHABET="0123456789abcdefghijklmnopqrstuvwxyz",alphabetHasNormalDecimalDigits=!0;function BigNumber(v,b){var alphabet,c,caseChanged,e,i,isNum,len,str,x=this;if(!(x instanceof BigNumber))return new BigNumber(v,b);if(null==b){if(v&&!0===v._isBigNumber)return x.s=v.s,void(!v.c||v.e>MAX_EXP?x.c=x.e=null:v.e<MIN_EXP?x.c=[x.e=0]:(x.e=v.e,x.c=v.c.slice()));if((isNum="number"==typeof v)&&0*v==0){if(x.s=1/v<0?(v=-v,-1):1,v===~~v){for(e=0,i=v;10<=i;i/=10,e++);return void(MAX_EXP<e?x.c=x.e=null:(x.e=e,x.c=[v]))}str=String(v)}else{if(!isNumeric.test(str=String(v)))return parseNumeric(x,str,isNum);x.s=45==str.charCodeAt(0)?(str=str.slice(1),-1):1}0<(i=(str=-1<(e=str.indexOf("."))?str.replace(".",""):str).search(/e/i))?(e<0&&(e=i),e+=+str.slice(i+1),str=str.substring(0,i)):e<0&&(e=str.length)}else{if(intCheck(b,2,ALPHABET.length,"Base"),10==b&&alphabetHasNormalDecimalDigits)return round(x=new BigNumber(v),DECIMAL_PLACES+x.e+1,ROUNDING_MODE);if(str=String(v),isNum="number"==typeof v){if(0*v!=0)return parseNumeric(x,str,isNum,b);if(x.s=1/v<0?(str=str.slice(1),-1):1,BigNumber.DEBUG&&15<str.replace(/^0\.0*|\./,"").length)throw Error(tooManyDigits+v)}else x.s=45===str.charCodeAt(0)?(str=str.slice(1),-1):1;for(alphabet=ALPHABET.slice(0,b),e=i=0,len=str.length;i<len;i++)if(alphabet.indexOf(c=str.charAt(i))<0){if("."==c){if(e<i){e=len;continue}}else if(!caseChanged&&(str==str.toUpperCase()&&(str=str.toLowerCase())||str==str.toLowerCase()&&(str=str.toUpperCase()))){caseChanged=!0,i=-1,e=0;continue}return parseNumeric(x,String(v),isNum,b)}isNum=!1,-1<(e=(str=convertBase(str,b,10,x.s)).indexOf("."))?str=str.replace(".",""):e=str.length}for(i=0;48===str.charCodeAt(i);i++);for(len=str.length;48===str.charCodeAt(--len););if(str=str.slice(i,++len)){if(len-=i,isNum&&BigNumber.DEBUG&&15<len&&(9007199254740991<v||v!==mathfloor(v)))throw Error(tooManyDigits+x.s*v);if((e=e-i-1)>MAX_EXP)x.c=x.e=null;else if(e<MIN_EXP)x.c=[x.e=0];else{if(x.e=e,x.c=[],i=(e+1)%LOG_BASE,e<0&&(i+=LOG_BASE),i<len){for(i&&x.c.push(+str.slice(0,i)),len-=LOG_BASE;i<len;)x.c.push(+str.slice(i,i+=LOG_BASE));i=LOG_BASE-(str=str.slice(i)).length}else i-=len;for(;i--;str+="0");x.c.push(+str)}}else x.c=[x.e=0]}function toBaseOut(str,baseIn,baseOut,alphabet){for(var j,arrL,arr=[0],i=0,len=str.length;i<len;){for(arrL=arr.length;arrL--;arr[arrL]*=baseIn);for(arr[0]+=alphabet.indexOf(str.charAt(i++)),j=0;j<arr.length;j++)baseOut-1<arr[j]&&(null==arr[j+1]&&(arr[j+1]=0),arr[j+1]+=arr[j]/baseOut|0,arr[j]%=baseOut)}return arr.reverse()}function format(n,i,rm,id){var c0,ne,len,str;if(null==rm?rm=ROUNDING_MODE:intCheck(rm,0,8),!n.c)return n.toString();if(c0=n.c[0],ne=n.e,null==i)str=coeffToString(n.c),str=1==id||2==id&&(ne<=TO_EXP_NEG||TO_EXP_POS<=ne)?toExponential(str,ne):toFixedPoint(str,ne,"0");else if(rm=(n=round(new BigNumber(n),i,rm)).e,len=(str=coeffToString(n.c)).length,1==id||2==id&&(i<=rm||rm<=TO_EXP_NEG)){for(;len<i;str+="0",len++);str=toExponential(str,rm)}else if(i-=ne,str=toFixedPoint(str,rm,"0"),len<rm+1){if(0<--i)for(str+=".";i--;str+="0");}else if(0<(i+=rm-len))for(rm+1==len&&(str+=".");i--;str+="0");return n.s<0&&c0?"-"+str:str}function maxOrMin(args,n){for(var k,y,i=1,x=new BigNumber(args[0]);i<args.length;i++)(y=new BigNumber(args[i])).s&&(k=compare(x,y))!==n&&(0!==k||x.s!==n)||(x=y);return x}function normalise(n,c,e){for(var i=1,j=c.length;!c[--j];c.pop());for(j=c[0];10<=j;j/=10,i++);return(e=i+e*LOG_BASE-1)>MAX_EXP?n.c=n.e=null:e<MIN_EXP?n.c=[n.e=0]:(n.e=e,n.c=c),n}function round(x,sd,rm,r){var d,i,j,k,n,ni,rd,xc=x.c,pows10=POWS_TEN;if(xc){out:{for(d=1,k=xc[0];10<=k;k/=10,d++);if((i=sd-d)<0)i+=LOG_BASE,j=sd,n=xc[ni=0],rd=mathfloor(n/pows10[d-j-1]%10);else if((ni=mathceil((i+1)/LOG_BASE))>=xc.length){if(!r)break out;for(;xc.length<=ni;xc.push(0));n=rd=0,j=(i%=LOG_BASE)-LOG_BASE+(d=1)}else{for(n=k=xc[ni],d=1;10<=k;k/=10,d++);rd=(j=(i%=LOG_BASE)-LOG_BASE+d)<0?0:mathfloor(n/pows10[d-j-1]%10)}if(r=r||sd<0||null!=xc[ni+1]||(j<0?n:n%pows10[d-j-1]),r=rm<4?(rd||r)&&(0==rm||rm==(x.s<0?3:2)):5<rd||5==rd&&(4==rm||r||6==rm&&(0<i?0<j?n/pows10[d-j]:0:xc[ni-1])%10&1||rm==(x.s<0?8:7)),sd<1||!xc[0])return xc.length=0,r?(sd-=x.e+1,xc[0]=pows10[(LOG_BASE-sd%LOG_BASE)%LOG_BASE],x.e=-sd||0):xc[0]=x.e=0,x;if(0==i?(xc.length=ni,k=1,ni--):(xc.length=ni+1,k=pows10[LOG_BASE-i],xc[ni]=0<j?mathfloor(n/pows10[d-j]%pows10[j])*k:0),r)for(;;){if(0==ni){for(i=1,j=xc[0];10<=j;j/=10,i++);for(j=xc[0]+=k,k=1;10<=j;j/=10,k++);i!=k&&(x.e++,1e14==xc[0])&&(xc[0]=1);break}if(xc[ni]+=k,1e14!=xc[ni])break;xc[ni--]=0,k=1}for(i=xc.length;0===xc[--i];xc.pop());}x.e>MAX_EXP?x.c=x.e=null:x.e<MIN_EXP&&(x.c=[x.e=0])}return x}function valueOf(n){var str,e=n.e;return null===e?n.toString():(str=coeffToString(n.c),str=e<=TO_EXP_NEG||TO_EXP_POS<=e?toExponential(str,e):toFixedPoint(str,e,"0"),n.s<0?"-"+str:str)}return BigNumber.clone=clone,BigNumber.ROUND_UP=0,BigNumber.ROUND_DOWN=1,BigNumber.ROUND_CEIL=2,BigNumber.ROUND_FLOOR=3,BigNumber.ROUND_HALF_UP=4,BigNumber.ROUND_HALF_DOWN=5,BigNumber.ROUND_HALF_EVEN=6,BigNumber.ROUND_HALF_CEIL=7,BigNumber.ROUND_HALF_FLOOR=8,BigNumber.EUCLID=9,BigNumber.config=BigNumber.set=function(obj){var p,v;if(null!=obj){if("object"!=typeof obj)throw Error(bignumberError+"Object expected: "+obj);if(obj.hasOwnProperty(p="DECIMAL_PLACES")&&(intCheck(v=obj[p],0,1e9,p),DECIMAL_PLACES=v),obj.hasOwnProperty(p="ROUNDING_MODE")&&(intCheck(v=obj[p],0,8,p),ROUNDING_MODE=v),obj.hasOwnProperty(p="EXPONENTIAL_AT")&&((v=obj[p])&&v.pop?(intCheck(v[0],-1e9,0,p),intCheck(v[1],0,1e9,p),TO_EXP_NEG=v[0],TO_EXP_POS=v[1]):(intCheck(v,-1e9,1e9,p),TO_EXP_NEG=-(TO_EXP_POS=v<0?-v:v))),obj.hasOwnProperty(p="RANGE"))if((v=obj[p])&&v.pop)intCheck(v[0],-1e9,-1,p),intCheck(v[1],1,1e9,p),MIN_EXP=v[0],MAX_EXP=v[1];else{if(intCheck(v,-1e9,1e9,p),!v)throw Error(bignumberError+p+" cannot be zero: "+v);MIN_EXP=-(MAX_EXP=v<0?-v:v)}if(obj.hasOwnProperty(p="CRYPTO")){if((v=obj[p])!==!!v)throw Error(bignumberError+p+" not true or false: "+v);if(v&&("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes))throw CRYPTO=!v,Error(bignumberError+"crypto unavailable");CRYPTO=v}if(obj.hasOwnProperty(p="MODULO_MODE")&&(intCheck(v=obj[p],0,9,p),MODULO_MODE=v),obj.hasOwnProperty(p="POW_PRECISION")&&(intCheck(v=obj[p],0,1e9,p),POW_PRECISION=v),obj.hasOwnProperty(p="FORMAT")){if("object"!=typeof(v=obj[p]))throw Error(bignumberError+p+" not an object: "+v);FORMAT=v}if(obj.hasOwnProperty(p="ALPHABET")){if("string"!=typeof(v=obj[p])||/^.?$|[+\-.\s]|(.).*\1/.test(v))throw Error(bignumberError+p+" invalid: "+v);alphabetHasNormalDecimalDigits="0123456789"==v.slice(0,10),ALPHABET=v}}return{DECIMAL_PLACES:DECIMAL_PLACES,ROUNDING_MODE:ROUNDING_MODE,EXPONENTIAL_AT:[TO_EXP_NEG,TO_EXP_POS],RANGE:[MIN_EXP,MAX_EXP],CRYPTO:CRYPTO,MODULO_MODE:MODULO_MODE,POW_PRECISION:POW_PRECISION,FORMAT:FORMAT,ALPHABET:ALPHABET}},BigNumber.isBigNumber=function(v){if(!v||!0!==v._isBigNumber)return!1;if(!BigNumber.DEBUG)return!0;var i,n,c=v.c,e=v.e,s=v.s;out:if("[object Array]"=={}.toString.call(c)){if((1===s||-1===s)&&-1e9<=e&&e<=1e9&&e===mathfloor(e))if(0===c[0]){if(0===e&&1===c.length)return!0}else if((i=(e+1)%LOG_BASE)<1&&(i+=LOG_BASE),String(c[0]).length==i){for(i=0;i<c.length;i++)if((n=c[i])<0||1e14<=n||n!==mathfloor(n))break out;if(0!==n)return!0}}else if(null===c&&null===e&&(null===s||1===s||-1===s))return!0;throw Error(bignumberError+"Invalid BigNumber: "+v)},BigNumber.maximum=BigNumber.max=function(){return maxOrMin(arguments,-1)},BigNumber.minimum=BigNumber.min=function(){return maxOrMin(arguments,1)},BigNumber.random=(random53bitInt=9007199254740992*Math.random()&2097151?function(){return mathfloor(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(dp){var a,b,e,k,v,i=0,c=[],rand=new BigNumber(ONE);if(null==dp?dp=DECIMAL_PLACES:intCheck(dp,0,1e9),k=mathceil(dp/LOG_BASE),CRYPTO)if(crypto.getRandomValues){for(a=crypto.getRandomValues(new Uint32Array(k*=2));i<k;)9e15<=(v=131072*a[i]+(a[i+1]>>>11))?(b=crypto.getRandomValues(new Uint32Array(2)),a[i]=b[0],a[i+1]=b[1]):(c.push(v%1e14),i+=2);i=k/2}else{if(!crypto.randomBytes)throw CRYPTO=!1,Error(bignumberError+"crypto unavailable");for(a=crypto.randomBytes(k*=7);i<k;)9e15<=(v=281474976710656*(31&a[i])+1099511627776*a[i+1]+4294967296*a[i+2]+16777216*a[i+3]+(a[i+4]<<16)+(a[i+5]<<8)+a[i+6])?crypto.randomBytes(7).copy(a,i):(c.push(v%1e14),i+=7);i=k/7}if(!CRYPTO)for(;i<k;)(v=random53bitInt())<9e15&&(c[i++]=v%1e14);for(k=c[--i],dp%=LOG_BASE,k&&dp&&(c[i]=mathfloor(k/(v=POWS_TEN[LOG_BASE-dp]))*v);0===c[i];c.pop(),i--);if(i<0)c=[e=0];else{for(e=-1;0===c[0];c.splice(0,1),e-=LOG_BASE);for(i=1,v=c[0];10<=v;v/=10,i++);i<LOG_BASE&&(e-=LOG_BASE-i)}return rand.e=e,rand.c=c,rand}),BigNumber.sum=function(){for(var i=1,args=arguments,sum=new BigNumber(args[0]);i<args.length;)sum=sum.plus(args[i++]);return sum},convertBase=function(str,baseIn,baseOut,sign,callerIsToString){var alphabet,d,e,k,r,x,xc,y,i=str.indexOf("."),dp=DECIMAL_PLACES,rm=ROUNDING_MODE;for(0<=i&&(k=POW_PRECISION,POW_PRECISION=0,str=str.replace(".",""),x=(y=new BigNumber(baseIn)).pow(str.length-i),POW_PRECISION=k,y.c=toBaseOut(toFixedPoint(coeffToString(x.c),x.e,"0"),10,baseOut,"0123456789"),y.e=y.c.length),e=k=(xc=toBaseOut(str,baseIn,baseOut,callerIsToString?(alphabet=ALPHABET,"0123456789"):(alphabet="0123456789",ALPHABET))).length;0==xc[--k];xc.pop());if(!xc[0])return alphabet.charAt(0);if(i<0?--e:(x.c=xc,x.e=e,x.s=sign,xc=(x=div(x,y,dp,rm,baseOut)).c,r=x.r,e=x.e),i=xc[d=e+dp+1],k=baseOut/2,r=r||d<0||null!=xc[d+1],r=rm<4?(null!=i||r)&&(0==rm||rm==(x.s<0?3:2)):k<i||i==k&&(4==rm||r||6==rm&&1&xc[d-1]||rm==(x.s<0?8:7)),d<1||!xc[0])str=r?toFixedPoint(alphabet.charAt(1),-dp,alphabet.charAt(0)):alphabet.charAt(0);else{if(xc.length=d,r)for(--baseOut;++xc[--d]>baseOut;)xc[d]=0,d||(++e,xc=[1].concat(xc));for(k=xc.length;!xc[--k];);for(i=0,str="";i<=k;str+=alphabet.charAt(xc[i++]));str=toFixedPoint(str,e,alphabet.charAt(0))}return str},div=function(){function multiply(x,k,base){var m,temp,xlo,carry=0,i=x.length,klo=k%1e7,khi=k/1e7|0;for(x=x.slice();i--;)carry=((temp=klo*(xlo=x[i]%1e7)+(m=khi*xlo+(xlo=x[i]/1e7|0)*klo)%1e7*1e7+carry)/base|0)+(m/1e7|0)+khi*xlo,x[i]=temp%base;return x=carry?[carry].concat(x):x}function compare(a,b,aL,bL){var i,cmp;if(aL!=bL)cmp=bL<aL?1:-1;else for(i=cmp=0;i<aL;i++)if(a[i]!=b[i]){cmp=a[i]>b[i]?1:-1;break}return cmp}function subtract(a,b,aL,base){for(var i=0;aL--;)a[aL]-=i,i=a[aL]<b[aL]?1:0,a[aL]=i*base+a[aL]-b[aL];for(;!a[0]&&1<a.length;a.splice(0,1));}return function(x,y,dp,rm,base){var cmp,e,i,more,n,prod,prodL,q,qc,rem,remL,rem0,xi,xL,yc0,yL,yz,s=x.s==y.s?1:-1,xc=x.c,yc=y.c;if(!(xc&&xc[0]&&yc&&yc[0]))return new BigNumber(x.s&&y.s&&(xc?!yc||xc[0]!=yc[0]:yc)?xc&&0==xc[0]||!yc?0*s:s/0:NaN);for(qc=(q=new BigNumber(s)).c=[],s=dp+(e=x.e-y.e)+1,base||(base=1e14,e=bitFloor(x.e/LOG_BASE)-bitFloor(y.e/LOG_BASE),s=s/LOG_BASE|0),i=0;yc[i]==(xc[i]||0);i++);if(yc[i]>(xc[i]||0)&&e--,s<0)qc.push(1),more=!0;else{for(xL=xc.length,yL=yc.length,s+=2,1<(n=mathfloor(base/(yc[i=0]+1)))&&(yc=multiply(yc,n,base),xc=multiply(xc,n,base),yL=yc.length,xL=xc.length),xi=yL,remL=(rem=xc.slice(0,yL)).length;remL<yL;rem[remL++]=0);yz=yc.slice(),yz=[0].concat(yz),yc0=yc[0],yc[1]>=base/2&&yc0++;do{if(n=0,(cmp=compare(yc,rem,yL,remL))<0){if(rem0=rem[0],yL!=remL&&(rem0=rem0*base+(rem[1]||0)),1<(n=mathfloor(rem0/yc0)))for(prodL=(prod=multiply(yc,n=base<=n?base-1:n,base)).length,remL=rem.length;1==compare(prod,rem,prodL,remL);)n--,subtract(prod,yL<prodL?yz:yc,prodL,base),prodL=prod.length,cmp=1;else 0==n&&(cmp=n=1),prodL=(prod=yc.slice()).length;if(subtract(rem,prod=prodL<remL?[0].concat(prod):prod,remL,base),remL=rem.length,-1==cmp)for(;compare(yc,rem,yL,remL)<1;)n++,subtract(rem,yL<remL?yz:yc,remL,base),remL=rem.length}else 0===cmp&&(n++,rem=[0])}while(qc[i++]=n,rem[0]?rem[remL++]=xc[xi]||0:(rem=[xc[xi]],remL=1),(xi++<xL||null!=rem[0])&&s--);more=null!=rem[0],qc[0]||qc.splice(0,1)}if(1e14==base){for(i=1,s=qc[0];10<=s;s/=10,i++);round(q,dp+(q.e=i+e*LOG_BASE-1)+1,rm,more)}else q.e=e,q.r=+more;return q}}(),basePrefix=/^(-?)0([xbo])(?=\w[\w.]*$)/i,dotAfter=/^([^.]+)\.$/,dotBefore=/^\.([^.]+)$/,isInfinityOrNaN=/^-?(Infinity|NaN)$/,whitespaceOrPlus=/^\s*\+(?=[\w.])|^\s+|\s+$/g,parseNumeric=function(x,str,isNum,b){var base,s=isNum?str:str.replace(whitespaceOrPlus,"");if(isInfinityOrNaN.test(s))x.s=isNaN(s)?null:s<0?-1:1;else{if(!isNum&&(s=s.replace(basePrefix,function(m,p1,p2){return base="x"==(p2=p2.toLowerCase())?16:"b"==p2?2:8,b&&b!=base?m:p1}),b&&(base=b,s=s.replace(dotAfter,"$1").replace(dotBefore,"0.$1")),str!=s))return new BigNumber(s,base);if(BigNumber.DEBUG)throw Error(bignumberError+"Not a"+(b?" base "+b:"")+" number: "+str);x.s=null}x.c=x.e=null},P.absoluteValue=P.abs=function(){var x=new BigNumber(this);return x.s<0&&(x.s=1),x},P.comparedTo=function(y,b){return compare(this,new BigNumber(y,b))},P.decimalPlaces=P.dp=function(dp,rm){var n,v,x=this;if(null!=dp)return intCheck(dp,0,1e9),null==rm?rm=ROUNDING_MODE:intCheck(rm,0,8),round(new BigNumber(x),dp+x.e+1,rm);if(!(dp=x.c))return null;if(n=((v=dp.length-1)-bitFloor(this.e/LOG_BASE))*LOG_BASE,v=dp[v])for(;v%10==0;v/=10,n--);return n=n<0?0:n},P.dividedBy=P.div=function(y,b){return div(this,new BigNumber(y,b),DECIMAL_PLACES,ROUNDING_MODE)},P.dividedToIntegerBy=P.idiv=function(y,b){return div(this,new BigNumber(y,b),0,1)},P.exponentiatedBy=P.pow=function(n,m){var half,isModExp,i,k,nIsBig,nIsNeg,nIsOdd,y,x=this;if((n=new BigNumber(n)).c&&!n.isInteger())throw Error(bignumberError+"Exponent not an integer: "+valueOf(n));if(null!=m&&(m=new BigNumber(m)),nIsBig=14<n.e,!x.c||!x.c[0]||1==x.c[0]&&!x.e&&1==x.c.length||!n.c||!n.c[0])return y=new BigNumber(Math.pow(+valueOf(x),nIsBig?n.s*(2-isOdd(n)):+valueOf(n))),m?y.mod(m):y;if(nIsNeg=n.s<0,m){if(m.c?!m.c[0]:!m.s)return new BigNumber(NaN);(isModExp=!nIsNeg&&x.isInteger()&&m.isInteger())&&(x=x.mod(m))}else{if(9<n.e&&(0<x.e||x.e<-1||(0==x.e?1<x.c[0]||nIsBig&&24e7<=x.c[1]:x.c[0]<8e13||nIsBig&&x.c[0]<=9999975e7)))return k=x.s<0&&isOdd(n)?-0:0,-1<x.e&&(k=1/k),new BigNumber(nIsNeg?1/k:k);POW_PRECISION&&(k=mathceil(POW_PRECISION/LOG_BASE+2))}for(nIsOdd=nIsBig?(half=new BigNumber(.5),nIsNeg&&(n.s=1),isOdd(n)):(i=Math.abs(+valueOf(n)))%2,y=new BigNumber(ONE);;){if(nIsOdd){if(!(y=y.times(x)).c)break;k?y.c.length>k&&(y.c.length=k):isModExp&&(y=y.mod(m))}if(i){if(0===(i=mathfloor(i/2)))break;nIsOdd=i%2}else if(round(n=n.times(half),n.e+1,1),14<n.e)nIsOdd=isOdd(n);else{if(0==(i=+valueOf(n)))break;nIsOdd=i%2}x=x.times(x),k?x.c&&x.c.length>k&&(x.c.length=k):isModExp&&(x=x.mod(m))}return isModExp?y:(nIsNeg&&(y=ONE.div(y)),m?y.mod(m):k?round(y,POW_PRECISION,ROUNDING_MODE,void 0):y)},P.integerValue=function(rm){var n=new BigNumber(this);return null==rm?rm=ROUNDING_MODE:intCheck(rm,0,8),round(n,n.e+1,rm)},P.isEqualTo=P.eq=function(y,b){return 0===compare(this,new BigNumber(y,b))},P.isFinite=function(){return!!this.c},P.isGreaterThan=P.gt=function(y,b){return 0<compare(this,new BigNumber(y,b))},P.isGreaterThanOrEqualTo=P.gte=function(y,b){return 1===(b=compare(this,new BigNumber(y,b)))||0===b},P.isInteger=function(){return!!this.c&&bitFloor(this.e/LOG_BASE)>this.c.length-2},P.isLessThan=P.lt=function(y,b){return compare(this,new BigNumber(y,b))<0},P.isLessThanOrEqualTo=P.lte=function(y,b){return-1===(b=compare(this,new BigNumber(y,b)))||0===b},P.isNaN=function(){return!this.s},P.isNegative=function(){return this.s<0},P.isPositive=function(){return 0<this.s},P.isZero=function(){return!!this.c&&0==this.c[0]},P.minus=function(y,b){var i,j,t,xLTy,x=this,a=x.s;if(b=(y=new BigNumber(y,b)).s,!a||!b)return new BigNumber(NaN);if(a!=b)return y.s=-b,x.plus(y);var xe=x.e/LOG_BASE,ye=y.e/LOG_BASE,xc=x.c,yc=y.c;if(!xe||!ye){if(!xc||!yc)return xc?(y.s=-b,y):new BigNumber(yc?x:NaN);if(!xc[0]||!yc[0])return yc[0]?(y.s=-b,y):new BigNumber(xc[0]?x:3==ROUNDING_MODE?-0:0)}if(xe=bitFloor(xe),ye=bitFloor(ye),xc=xc.slice(),a=xe-ye){for((t=(xLTy=a<0)?(a=-a,xc):(ye=xe,yc)).reverse(),b=a;b--;t.push(0));t.reverse()}else for(j=(xLTy=(a=xc.length)<(b=yc.length))?a:b,a=b=0;b<j;b++)if(xc[b]!=yc[b]){xLTy=xc[b]<yc[b];break}if(xLTy&&(t=xc,xc=yc,yc=t,y.s=-y.s),0<(b=(j=yc.length)-(i=xc.length)))for(;b--;xc[i++]=0);for(b=1e14-1;a<j;){if(xc[--j]<yc[j]){for(i=j;i&&!xc[--i];xc[i]=b);--xc[i],xc[j]+=1e14}xc[j]-=yc[j]}for(;0==xc[0];xc.splice(0,1),--ye);return xc[0]?normalise(y,xc,ye):(y.s=3==ROUNDING_MODE?-1:1,y.c=[y.e=0],y)},P.modulo=P.mod=function(y,b){var q,x=this;return y=new BigNumber(y,b),!x.c||!y.s||y.c&&!y.c[0]?new BigNumber(NaN):!y.c||x.c&&!x.c[0]?new BigNumber(x):(9==MODULO_MODE?(b=y.s,y.s=1,q=div(x,y,0,3),y.s=b,q.s*=b):q=div(x,y,0,MODULO_MODE),(y=x.minus(q.times(y))).c[0]||1!=MODULO_MODE||(y.s=x.s),y)},P.multipliedBy=P.times=function(y,b){var c,i,j,k,m,xcL,xlo,xhi,ylo,yhi,zc,x=this,xc=x.c,yc=(y=new BigNumber(y,b)).c;if(!(xc&&yc&&xc[0]&&yc[0]))return!x.s||!y.s||xc&&!xc[0]&&!yc||yc&&!yc[0]&&!xc?y.c=y.e=y.s=null:(y.s*=x.s,xc&&yc?(y.c=[0],y.e=0):y.c=y.e=null),y;for(b=bitFloor(x.e/LOG_BASE)+bitFloor(y.e/LOG_BASE),y.s*=x.s,(xcL=xc.length)<(x=yc.length)&&(zc=xc,xc=yc,yc=zc,i=xcL,xcL=x,x=i),i=xcL+x,zc=[];i--;zc.push(0));for(i=x;0<=--i;){for(ylo=yc[i]%1e7,yhi=yc[i]/1e7|(c=0),j=i+(k=xcL);i<j;)c=((xlo=ylo*(xlo=xc[--k]%1e7)+(m=yhi*xlo+(xhi=xc[k]/1e7|0)*ylo)%1e7*1e7+zc[j]+c)/1e14|0)+(m/1e7|0)+yhi*xhi,zc[j--]=xlo%1e14;zc[j]=c}return c?++b:zc.splice(0,1),normalise(y,zc,b)},P.negated=function(){var x=new BigNumber(this);return x.s=-x.s||null,x},P.plus=function(y,b){var t,x=this,a=x.s;if(b=(y=new BigNumber(y,b)).s,!a||!b)return new BigNumber(NaN);if(a!=b)return y.s=-b,x.minus(y);var xe=x.e/LOG_BASE,ye=y.e/LOG_BASE,xc=x.c,yc=y.c;if(!xe||!ye){if(!xc||!yc)return new BigNumber(a/0);if(!xc[0]||!yc[0])return yc[0]?y:new BigNumber(xc[0]?x:0*a)}if(xe=bitFloor(xe),ye=bitFloor(ye),xc=xc.slice(),a=xe-ye){for((t=0<a?(ye=xe,yc):(a=-a,xc)).reverse();a--;t.push(0));t.reverse()}for((a=xc.length)-(b=yc.length)<0&&(t=yc,yc=xc,xc=t,b=a),a=0;b;)a=(xc[--b]=xc[b]+yc[b]+a)/1e14|0,xc[b]=1e14===xc[b]?0:xc[b]%1e14;return a&&(xc=[a].concat(xc),++ye),normalise(y,xc,ye)},P.precision=P.sd=function(sd,rm){var n,v,x=this;if(null!=sd&&sd!==!!sd)return intCheck(sd,1,1e9),null==rm?rm=ROUNDING_MODE:intCheck(rm,0,8),round(new BigNumber(x),sd,rm);if(!(rm=x.c))return null;if(n=(v=rm.length-1)*LOG_BASE+1,v=rm[v]){for(;v%10==0;v/=10,n--);for(v=rm[0];10<=v;v/=10,n++);}return n=sd&&x.e+1>n?x.e+1:n},P.shiftedBy=function(k){return intCheck(k,-9007199254740991,9007199254740991),this.times("1e"+k)},P.squareRoot=P.sqrt=function(){var m,n,r,rep,t,x=this,c=x.c,s=x.s,e=x.e,dp=DECIMAL_PLACES+4,half=new BigNumber("0.5");if(1!==s||!c||!c[0])return new BigNumber(!s||s<0&&(!c||c[0])?NaN:c?x:1/0);if((r=0==(s=Math.sqrt(+valueOf(x)))||s==1/0?(((n=coeffToString(c)).length+e)%2==0&&(n+="0"),s=Math.sqrt(+n),e=bitFloor((e+1)/2)-(e<0||e%2),new BigNumber(n=s==1/0?"5e"+e:(n=s.toExponential()).slice(0,n.indexOf("e")+1)+e)):new BigNumber(s+"")).c[0])for((s=(e=r.e)+dp)<3&&(s=0);;)if(t=r,r=half.times(t.plus(div(x,t,dp,1))),coeffToString(t.c).slice(0,s)===(n=coeffToString(r.c)).slice(0,s)){if(r.e<e&&--s,"9999"!=(n=n.slice(s-3,s+1))&&(rep||"4999"!=n)){+n&&(+n.slice(1)||"5"!=n.charAt(0))||(round(r,r.e+DECIMAL_PLACES+2,1),m=!r.times(r).eq(x));break}if(!rep&&(round(t,t.e+DECIMAL_PLACES+2,0),t.times(t).eq(x))){r=t;break}dp+=4,s+=4,rep=1}return round(r,r.e+DECIMAL_PLACES+1,ROUNDING_MODE,m)},P.toExponential=function(dp,rm){return null!=dp&&(intCheck(dp,0,1e9),dp++),format(this,dp,rm,1)},P.toFixed=function(dp,rm){return null!=dp&&(intCheck(dp,0,1e9),dp=dp+this.e+1),format(this,dp,rm)},P.toFormat=function(dp,rm,format){var x=this;if(null==format)null!=dp&&rm&&"object"==typeof rm?(format=rm,rm=null):dp&&"object"==typeof dp?(format=dp,dp=rm=null):format=FORMAT;else if("object"!=typeof format)throw Error(bignumberError+"Argument not an object: "+format);if(dp=x.toFixed(dp,rm),x.c){var i,rm=dp.split("."),g1=+format.groupSize,g2=+format.secondaryGroupSize,groupSeparator=format.groupSeparator||"",intPart=rm[0],rm=rm[1],intDigits=(x=x.s<0)?intPart.slice(1):intPart,len=intDigits.length;if(g2&&(i=g1,g1=g2,len-=g2=i),0<g1&&0<len){for(intPart=intDigits.substr(0,i=len%g1||g1);i<len;i+=g1)intPart+=groupSeparator+intDigits.substr(i,g1);0<g2&&(intPart+=groupSeparator+intDigits.slice(i)),x&&(intPart="-"+intPart)}dp=rm?intPart+(format.decimalSeparator||"")+((g2=+format.fractionGroupSize)?rm.replace(new RegExp("\\d{"+g2+"}\\B","g"),"$&"+(format.fractionGroupSeparator||"")):rm):intPart}return(format.prefix||"")+dp+(format.suffix||"")},P.toFraction=function(md){var d,d0,d1,d2,e,exp,n,n0,n1,q,x=this,xc=x.c;if(null!=md&&(!(n=new BigNumber(md)).isInteger()&&(n.c||1!==n.s)||n.lt(ONE)))throw Error(bignumberError+"Argument "+(n.isInteger()?"out of range: ":"not an integer: ")+valueOf(n));if(!xc)return new BigNumber(x);for(d=new BigNumber(ONE),n1=d0=new BigNumber(ONE),d1=n0=new BigNumber(ONE),xc=coeffToString(xc),e=d.e=xc.length-x.e-1,d.c[0]=POWS_TEN[(exp=e%LOG_BASE)<0?LOG_BASE+exp:exp],md=!md||0<n.comparedTo(d)?0<e?d:n1:n,exp=MAX_EXP,MAX_EXP=1/0,n=new BigNumber(xc),n0.c[0]=0;q=div(n,d,0,1),1!=(d2=d0.plus(q.times(d1))).comparedTo(md);)d0=d1,d1=d2,n1=n0.plus(q.times(d2=n1)),n0=d2,d=n.minus(q.times(d2=d)),n=d2;return d2=div(md.minus(d0),d1,0,1),n0=n0.plus(d2.times(n1)),d0=d0.plus(d2.times(d1)),n0.s=n1.s=x.s,xc=div(n1,d1,e*=2,ROUNDING_MODE).minus(x).abs().comparedTo(div(n0,d0,e,ROUNDING_MODE).minus(x).abs())<1?[n1,d1]:[n0,d0],MAX_EXP=exp,xc},P.toNumber=function(){return+valueOf(this)},P.toPrecision=function(sd,rm){return null!=sd&&intCheck(sd,1,1e9),format(this,sd,rm,2)},P.toString=function(b){var str,n=this,s=n.s,e=n.e;return null===e?s?(str="Infinity",s<0&&(str="-"+str)):str="NaN":(str=null==b?e<=TO_EXP_NEG||TO_EXP_POS<=e?toExponential(coeffToString(n.c),e):toFixedPoint(coeffToString(n.c),e,"0"):10===b&&alphabetHasNormalDecimalDigits?toFixedPoint(coeffToString((n=round(new BigNumber(n),DECIMAL_PLACES+e+1,ROUNDING_MODE)).c),n.e,"0"):(intCheck(b,2,ALPHABET.length,"Base"),convertBase(toFixedPoint(coeffToString(n.c),e,"0"),10,b,s,!0)),s<0&&n.c[0]&&(str="-"+str)),str},P.valueOf=P.toJSON=function(){return valueOf(this)},P._isBigNumber=!0,null!=configObject&&BigNumber.set(configObject),BigNumber}()).default=BigNumber.BigNumber=BigNumber,"function"==typeof define&&define.amd?define(function(){return BigNumber}):void 0!==module&&module.exports?module.exports=BigNumber:(globalObject=globalObject||("undefined"!=typeof self&&self?self:window)).BigNumber=BigNumber}(this)},{}],3:[function(require,module,exports){},{}],4:[function(require,module,exports){!function(Buffer){!function(){"use strict";var base64=require("base64-js"),ieee754=require("ieee754"),K_MAX_LENGTH=(exports.Buffer=Buffer,exports.SlowBuffer=function(length){+length!=length&&(length=0);return Buffer.alloc(+length)},exports.INSPECT_MAX_BYTES=50,2147483647);function createBuffer(length){if(K_MAX_LENGTH<length)throw new RangeError('The value "'+length+'" is invalid for option "size"');length=new Uint8Array(length);return length.__proto__=Buffer.prototype,length}function Buffer(arg,encodingOrOffset,length){if("number"!=typeof arg)return from(arg,encodingOrOffset,length);if("string"==typeof encodingOrOffset)throw new TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(arg)}function from(value,encodingOrOffset,length){if("string"==typeof value)return function(string,encoding){"string"==typeof encoding&&""!==encoding||(encoding="utf8");if(!Buffer.isEncoding(encoding))throw new TypeError("Unknown encoding: "+encoding);var length=0|byteLength(string,encoding),buf=createBuffer(length),string=buf.write(string,encoding);string!==length&&(buf=buf.slice(0,string));return buf}(value,encodingOrOffset);if(ArrayBuffer.isView(value))return fromArrayLike(value);if(null==value)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof value);if(isInstance(value,ArrayBuffer)||value&&isInstance(value.buffer,ArrayBuffer))return function(array,byteOffset,length){if(byteOffset<0||array.byteLength<byteOffset)throw new RangeError('"offset" is outside of buffer bounds');if(array.byteLength<byteOffset+(length||0))throw new RangeError('"length" is outside of buffer bounds');array=void 0===byteOffset&&void 0===length?new Uint8Array(array):void 0===length?new Uint8Array(array,byteOffset):new Uint8Array(array,byteOffset,length);return array.__proto__=Buffer.prototype,array}(value,encodingOrOffset,length);if("number"==typeof value)throw new TypeError('The "value" argument must not be of type number. Received type number');var valueOf=value.valueOf&&value.valueOf();if(null!=valueOf&&valueOf!==value)return Buffer.from(valueOf,encodingOrOffset,length);valueOf=function(obj){{var len,buf;if(Buffer.isBuffer(obj))return len=0|checked(obj.length),0!==(buf=createBuffer(len)).length&&obj.copy(buf,0,0,len),buf}if(void 0!==obj.length)return"number"!=typeof obj.length||numberIsNaN(obj.length)?createBuffer(0):fromArrayLike(obj);if("Buffer"===obj.type&&Array.isArray(obj.data))return fromArrayLike(obj.data)}(value);if(valueOf)return valueOf;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof value[Symbol.toPrimitive])return Buffer.from(value[Symbol.toPrimitive]("string"),encodingOrOffset,length);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof value)}function assertSize(size){if("number"!=typeof size)throw new TypeError('"size" argument must be of type number');if(size<0)throw new RangeError('The value "'+size+'" is invalid for option "size"')}function allocUnsafe(size){return assertSize(size),createBuffer(size<0?0:0|checked(size))}function fromArrayLike(array){for(var length=array.length<0?0:0|checked(array.length),buf=createBuffer(length),i=0;i<length;i+=1)buf[i]=255&array[i];return buf}function checked(length){if(K_MAX_LENGTH<=length)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+K_MAX_LENGTH.toString(16)+" bytes");return 0|length}function byteLength(string,encoding){if(Buffer.isBuffer(string))return string.length;if(ArrayBuffer.isView(string)||isInstance(string,ArrayBuffer))return string.byteLength;if("string"!=typeof string)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof string);var len=string.length,mustMatch=2<arguments.length&&!0===arguments[2];if(!mustMatch&&0===len)return 0;for(var loweredCase=!1;;)switch(encoding){case"ascii":case"latin1":case"binary":return len;case"utf8":case"utf-8":return utf8ToBytes(string).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*len;case"hex":return len>>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return mustMatch?-1:utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase(),loweredCase=!0}}function slowToString(encoding,start,end){var loweredCase=!1;if((start=void 0===start||start<0?0:start)>this.length)return"";if((end=void 0===end||end>this.length?this.length:end)<=0)return"";if((end>>>=0)<=(start>>>=0))return"";for(encoding=encoding||"utf8";;)switch(encoding){case"hex":return function(buf,start,end){var len=buf.length;(!start||start<0)&&(start=0);(!end||end<0||len<end)&&(end=len);for(var out="",i=start;i<end;++i)out+=function(n){return n<16?"0"+n.toString(16):n.toString(16)}(buf[i]);return out}(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return function(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;++i)ret+=String.fromCharCode(127&buf[i]);return ret}(this,start,end);case"latin1":case"binary":return function(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;++i)ret+=String.fromCharCode(buf[i]);return ret}(this,start,end);case"base64":return function(buf,start,end){return 0===start&&end===buf.length?base64.fromByteArray(buf):base64.fromByteArray(buf.slice(start,end))}(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(buf,start,end){for(var bytes=buf.slice(start,end),res="",i=0;i<bytes.length;i+=2)res+=String.fromCharCode(bytes[i]+256*bytes[i+1]);return res}(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase(),loweredCase=!0}}function swap(b,n,m){var i=b[n];b[n]=b[m],b[m]=i}function bidirectionalIndexOf(buffer,val,byteOffset,encoding,dir){if(0===buffer.length)return-1;if("string"==typeof byteOffset?(encoding=byteOffset,byteOffset=0):2147483647<byteOffset?byteOffset=2147483647:byteOffset<-2147483648&&(byteOffset=-2147483648),(byteOffset=(byteOffset=numberIsNaN(byteOffset=+byteOffset)?dir?0:buffer.length-1:byteOffset)<0?buffer.length+byteOffset:byteOffset)>=buffer.length){if(dir)return-1;byteOffset=buffer.length-1}else if(byteOffset<0){if(!dir)return-1;byteOffset=0}if("string"==typeof val&&(val=Buffer.from(val,encoding)),Buffer.isBuffer(val))return 0===val.length?-1:arrayIndexOf(buffer,val,byteOffset,encoding,dir);if("number"==typeof val)return val&=255,"function"==typeof Uint8Array.prototype.indexOf?(dir?Uint8Array.prototype.indexOf:Uint8Array.prototype.lastIndexOf).call(buffer,val,byteOffset):arrayIndexOf(buffer,[val],byteOffset,encoding,dir);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1,arrLength=arr.length,valLength=val.length;if(void 0!==encoding&&("ucs2"===(encoding=String(encoding).toLowerCase())||"ucs-2"===encoding||"utf16le"===encoding||"utf-16le"===encoding)){if(arr.length<2||val.length<2)return-1;arrLength/=indexSize=2,valLength/=2,byteOffset/=2}function read(buf,i){return 1===indexSize?buf[i]:buf.readUInt16BE(i*indexSize)}if(dir)for(var foundIndex=-1,i=byteOffset;i<arrLength;i++)if(read(arr,i)===read(val,-1===foundIndex?0:i-foundIndex)){if(i-(foundIndex=-1===foundIndex?i:foundIndex)+1===valLength)return foundIndex*indexSize}else-1!==foundIndex&&(i-=i-foundIndex),foundIndex=-1;else for(i=byteOffset=arrLength<byteOffset+valLength?arrLength-valLength:byteOffset;0<=i;i--){for(var found=!0,j=0;j<valLength;j++)if(read(arr,i+j)!==read(val,j)){found=!1;break}if(found)return i}return-1}function asciiWrite(buf,string,offset,length){return blitBuffer(function(str){for(var byteArray=[],i=0;i<str.length;++i)byteArray.push(255&str.charCodeAt(i));return byteArray}(string),buf,offset,length)}function ucs2Write(buf,string,offset,length){return blitBuffer(function(str,units){for(var c,hi,byteArray=[],i=0;i<str.length&&!((units-=2)<0);++i)c=str.charCodeAt(i),hi=c>>8,byteArray.push(c%256),byteArray.push(hi);return byteArray}(string,buf.length-offset),buf,offset,length)}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);for(var res=[],i=start;i<end;){var secondByte,thirdByte,fourthByte,tempCodePoint,firstByte=buf[i],codePoint=null,bytesPerSequence=239<firstByte?4:223<firstByte?3:191<firstByte?2:1;if(i+bytesPerSequence<=end)switch(bytesPerSequence){case 1:firstByte<128&&(codePoint=firstByte);break;case 2:128==(192&(secondByte=buf[i+1]))&&127<(tempCodePoint=(31&firstByte)<<6|63&secondByte)&&(codePoint=tempCodePoint);break;case 3:secondByte=buf[i+1],thirdByte=buf[i+2],128==(192&secondByte)&&128==(192&thirdByte)&&2047<(tempCodePoint=(15&firstByte)<<12|(63&secondByte)<<6|63&thirdByte)&&(tempCodePoint<55296||57343<tempCodePoint)&&(codePoint=tempCodePoint);break;case 4:secondByte=buf[i+1],thirdByte=buf[i+2],fourthByte=buf[i+3],128==(192&secondByte)&&128==(192&thirdByte)&&128==(192&fourthByte)&&65535<(tempCodePoint=(15&firstByte)<<18|(63&secondByte)<<12|(63&thirdByte)<<6|63&fourthByte)&&tempCodePoint<1114112&&(codePoint=tempCodePoint)}null===codePoint?(codePoint=65533,bytesPerSequence=1):65535<codePoint&&(res.push((codePoint-=65536)>>>10&1023|55296),codePoint=56320|1023&codePoint),res.push(codePoint),i+=bytesPerSequence}return function(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,codePoints);var res="",i=0;for(;i<len;)res+=String.fromCharCode.apply(String,codePoints.slice(i,i+=MAX_ARGUMENTS_LENGTH));return res}(res)}exports.kMaxLength=K_MAX_LENGTH,(Buffer.TYPED_ARRAY_SUPPORT=function(){try{var arr=new Uint8Array(1);return arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===arr.foo()}catch(e){return!1}}())||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(Buffer.prototype,"parent",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.buffer}}),Object.defineProperty(Buffer.prototype,"offset",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&Buffer[Symbol.species]===Buffer&&Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),Buffer.poolSize=8192,Buffer.from=from,Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array,Buffer.alloc=function(size,fill,encoding){return assertSize(size),!(size<=0)&&void 0!==fill?"string"==typeof encoding?createBuffer(size).fill(fill,encoding):createBuffer(size).fill(fill):createBuffer(size)},Buffer.allocUnsafe=allocUnsafe,Buffer.allocUnsafeSlow=allocUnsafe,Buffer.isBuffer=function(b){return null!=b&&!0===b._isBuffer&&b!==Buffer.prototype},Buffer.compare=function(a,b){if(isInstance(a,Uint8Array)&&(a=Buffer.from(a,a.offset,a.byteLength)),isInstance(b,Uint8Array)&&(b=Buffer.from(b,b.offset,b.byteLength)),!Buffer.isBuffer(a)||!Buffer.isBuffer(b))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(a===b)return 0;for(var x=a.length,y=b.length,i=0,len=Math.min(x,y);i<len;++i)if(a[i]!==b[i]){x=a[i],y=b[i];break}return x<y?-1:y<x?1:0},Buffer.isEncoding=function(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.concat=function(list,length){if(!Array.isArray(list))throw new TypeError('"list" argument must be an Array of Buffers');if(0===list.length)return Buffer.alloc(0);if(void 0===length)for(i=length=0;i<list.length;++i)length+=list[i].length;for(var buffer=Buffer.allocUnsafe(length),pos=0,i=0;i<list.length;++i){var buf=list[i];if(isInstance(buf,Uint8Array)&&(buf=Buffer.from(buf)),!Buffer.isBuffer(buf))throw new TypeError('"list" argument must be an Array of Buffers');buf.copy(buffer,pos),pos+=buf.length}return buffer},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function(){var len=this.length;if(len%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var i=0;i<len;i+=2)swap(this,i,i+1);return this},Buffer.prototype.swap32=function(){var len=this.length;if(len%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var i=0;i<len;i+=4)swap(this,i,i+3),swap(this,i+1,i+2);return this},Buffer.prototype.swap64=function(){var len=this.length;if(len%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var i=0;i<len;i+=8)swap(this,i,i+7),swap(this,i+1,i+6),swap(this,i+2,i+5),swap(this,i+3,i+4);return this},Buffer.prototype.toLocaleString=Buffer.prototype.toString=function(){var length=this.length;return 0===length?"":0===arguments.length?utf8Slice(this,0,length):slowToString.apply(this,arguments)},Buffer.prototype.equals=function(b){if(Buffer.isBuffer(b))return this===b||0===Buffer.compare(this,b);throw new TypeError("Argument must be a Buffer")},Buffer.prototype.inspect=function(){var str="",max=exports.INSPECT_MAX_BYTES,str=this.toString("hex",0,max).replace(/(.{2})/g,"$1 ").trim();return this.length>max&&(str+=" ... "),"<Buffer "+str+">"},Buffer.prototype.compare=function(target,start,end,thisStart,thisEnd){if(isInstance(target,Uint8Array)&&(target=Buffer.from(target,target.offset,target.byteLength)),!Buffer.isBuffer(target))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof target);if(void 0===end&&(end=target?target.length:0),void 0===thisStart&&(thisStart=0),void 0===thisEnd&&(thisEnd=this.length),(start=void 0===start?0:start)<0||end>target.length||thisStart<0||thisEnd>this.length)throw new RangeError("out of range index");if(thisEnd<=thisStart&&end<=start)return 0;if(thisEnd<=thisStart)return-1;if(end<=start)return 1;if(this===target)return 0;for(var x=(thisEnd>>>=0)-(thisStart>>>=0),y=(end>>>=0)-(start>>>=0),len=Math.min(x,y),thisCopy=this.slice(thisStart,thisEnd),targetCopy=target.slice(start,end),i=0;i<len;++i)if(thisCopy[i]!==targetCopy[i]){x=thisCopy[i],y=targetCopy[i];break}return x<y?-1:y<x?1:0},Buffer.prototype.includes=function(val,byteOffset,encoding){return-1!==this.indexOf(val,byteOffset,encoding)},Buffer.prototype.indexOf=function(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,!0)},Buffer.prototype.lastIndexOf=function(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,!1)},Buffer.prototype.write=function(string,offset,length,encoding){if(void 0===offset)encoding="utf8",length=this.length,offset=0;else if(void 0===length&&"string"==typeof offset)encoding=offset,length=this.length,offset=0;else{if(!isFinite(offset))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");offset>>>=0,isFinite(length)?(length>>>=0,void 0===encoding&&(encoding="utf8")):(encoding=length,length=void 0)}var remaining=this.length-offset;if((void 0===length||remaining<length)&&(length=remaining),0<string.length&&(length<0||offset<0)||offset>this.length)throw new RangeError("Attempt to write outside buffer bounds");encoding=encoding||"utf8";for(var loweredCase=!1;;)switch(encoding){case"hex":return function(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;(!length||remaining<(length=Number(length)))&&(length=remaining),(remaining=string.length)/2<length&&(length=remaining/2);for(var i=0;i<length;++i){var parsed=parseInt(string.substr(2*i,2),16);if(numberIsNaN(parsed))return i;buf[offset+i]=parsed}return i}(this,string,offset,length);case"utf8":case"utf-8":return function(buf,string,offset,length){return blitBuffer(utf8ToBytes(string,buf.length-offset),buf,offset,length)}(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return asciiWrite(this,string,offset,length);case"base64":return function(buf,string,offset,length){return blitBuffer(base64ToBytes(string),buf,offset,length)}(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase(),loweredCase=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;function checkOffset(offset,ext,length){if(offset%1!=0||offset<0)throw new RangeError("offset is not uint");if(length<offset+ext)throw new RangeError("Trying to access beyond buffer length")}function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(max<value||value<min)throw new RangeError('"value" argument is out of bounds');if(offset+ext>buf.length)throw new RangeError("Index out of range")}function checkIEEE754(buf,value,offset,ext){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){return value=+value,offset>>>=0,noAssert||checkIEEE754(buf,0,offset,4),ieee754.write(buf,value,offset,littleEndian,23,4),offset+4}function writeDouble(buf,value,offset,littleEndian,noAssert){return value=+value,offset>>>=0,noAssert||checkIEEE754(buf,0,offset,8),ieee754.write(buf,value,offset,littleEndian,52,8),offset+8}Buffer.prototype.slice=function(start,end){var len=this.length,len=((start=~~start)<0?(start+=len)<0&&(start=0):len<start&&(start=len),(end=void 0===end?len:~~end)<0?(end+=len)<0&&(end=0):len<end&&(end=len),end<start&&(end=start),this.subarray(start,end));return len.__proto__=Buffer.prototype,len},Buffer.prototype.readUIntLE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset],mul=1,i=0;++i<byteLength&&(mul*=256);)val+=this[offset+i]*mul;return val},Buffer.prototype.readUIntBE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset+--byteLength],mul=1;0<byteLength&&(mul*=256);)val+=this[offset+--byteLength]*mul;return val},Buffer.prototype.readUInt8=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,1,this.length),this[offset]},Buffer.prototype.readUInt16LE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,2,this.length),this[offset]|this[offset+1]<<8},Buffer.prototype.readUInt16BE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,2,this.length),this[offset]<<8|this[offset+1]},Buffer.prototype.readUInt32LE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+16777216*this[offset+3]},Buffer.prototype.readUInt32BE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),16777216*this[offset]+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])},Buffer.prototype.readIntLE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset],mul=1,i=0;++i<byteLength&&(mul*=256);)val+=this[offset+i]*mul;return(mul*=128)<=val&&(val-=Math.pow(2,8*byteLength)),val},Buffer.prototype.readIntBE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var i=byteLength,mul=1,val=this[offset+--i];0<i&&(mul*=256);)val+=this[offset+--i]*mul;return(mul*=128)<=val&&(val-=Math.pow(2,8*byteLength)),val},Buffer.prototype.readInt8=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,1,this.length),128&this[offset]?-1*(255-this[offset]+1):this[offset]},Buffer.prototype.readInt16LE=function(offset,noAssert){offset>>>=0,noAssert||checkOffset(offset,2,this.length);noAssert=this[offset]|this[offset+1]<<8;return 32768&noAssert?4294901760|noAssert:noAssert},Buffer.prototype.readInt16BE=function(offset,noAssert){offset>>>=0,noAssert||checkOffset(offset,2,this.length);noAssert=this[offset+1]|this[offset]<<8;return 32768&noAssert?4294901760|noAssert:noAssert},Buffer.prototype.readInt32LE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24},Buffer.prototype.readInt32BE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]},Buffer.prototype.readFloatLE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),ieee754.read(this,offset,!0,23,4)},Buffer.prototype.readFloatBE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),ieee754.read(this,offset,!1,23,4)},Buffer.prototype.readDoubleLE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,8,this.length),ieee754.read(this,offset,!0,52,8)},Buffer.prototype.readDoubleBE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,8,this.length),ieee754.read(this,offset,!1,52,8)},Buffer.prototype.writeUIntLE=function(value,offset,byteLength,noAssert){value=+value,offset>>>=0,byteLength>>>=0,noAssert||checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength)-1,0);var mul=1,i=0;for(this[offset]=255&value;++i<byteLength&&(mul*=256);)this[offset+i]=value/mul&255;return offset+byteLength},Buffer.prototype.writeUIntBE=function(value,offset,byteLength,noAssert){value=+value,offset>>>=0,byteLength>>>=0,noAssert||checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength)-1,0);var i=byteLength-1,mul=1;for(this[offset+i]=255&value;0<=--i&&(mul*=256);)this[offse