-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathassets_js_libraries.js
35 lines (33 loc) · 44.1 KB
/
assets_js_libraries.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// https://github.com/jeromeetienne/jquery-qrcode
(function(r){r.fn.qrcode=function(h){var s;function u(a){this.mode=s;this.data=a}function o(a,c){this.typeNumber=a;this.errorCorrectLevel=c;this.modules=null;this.moduleCount=0;this.dataCache=null;this.dataList=[]}function q(a,c){if(void 0==a.length)throw Error(a.length+"/"+c);for(var d=0;d<a.length&&0==a[d];)d++;this.num=Array(a.length-d+c);for(var b=0;b<a.length-d;b++)this.num[b]=a[b+d]}function p(a,c){this.totalCount=a;this.dataCount=c}function t(){this.buffer=[];this.length=0}u.prototype={getLength:function(){return this.data.length},
write:function(a){for(var c=0;c<this.data.length;c++)a.put(this.data.charCodeAt(c),8)}};o.prototype={addData:function(a){this.dataList.push(new u(a));this.dataCache=null},isDark:function(a,c){if(0>a||this.moduleCount<=a||0>c||this.moduleCount<=c)throw Error(a+","+c);return this.modules[a][c]},getModuleCount:function(){return this.moduleCount},make:function(){if(1>this.typeNumber){for(var a=1,a=1;40>a;a++){for(var c=p.getRSBlocks(a,this.errorCorrectLevel),d=new t,b=0,e=0;e<c.length;e++)b+=c[e].dataCount;
for(e=0;e<this.dataList.length;e++)c=this.dataList[e],d.put(c.mode,4),d.put(c.getLength(),j.getLengthInBits(c.mode,a)),c.write(d);if(d.getLengthInBits()<=8*b)break}this.typeNumber=a}this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(a,c){this.moduleCount=4*this.typeNumber+17;this.modules=Array(this.moduleCount);for(var d=0;d<this.moduleCount;d++){this.modules[d]=Array(this.moduleCount);for(var b=0;b<this.moduleCount;b++)this.modules[d][b]=null}this.setupPositionProbePattern(0,0);this.setupPositionProbePattern(this.moduleCount-
7,0);this.setupPositionProbePattern(0,this.moduleCount-7);this.setupPositionAdjustPattern();this.setupTimingPattern();this.setupTypeInfo(a,c);7<=this.typeNumber&&this.setupTypeNumber(a);null==this.dataCache&&(this.dataCache=o.createData(this.typeNumber,this.errorCorrectLevel,this.dataList));this.mapData(this.dataCache,c)},setupPositionProbePattern:function(a,c){for(var d=-1;7>=d;d++)if(!(-1>=a+d||this.moduleCount<=a+d))for(var b=-1;7>=b;b++)-1>=c+b||this.moduleCount<=c+b||(this.modules[a+d][c+b]=
0<=d&&6>=d&&(0==b||6==b)||0<=b&&6>=b&&(0==d||6==d)||2<=d&&4>=d&&2<=b&&4>=b?!0:!1)},getBestMaskPattern:function(){for(var a=0,c=0,d=0;8>d;d++){this.makeImpl(!0,d);var b=j.getLostPoint(this);if(0==d||a>b)a=b,c=d}return c},createMovieClip:function(a,c,d){a=a.createEmptyMovieClip(c,d);this.make();for(c=0;c<this.modules.length;c++)for(var d=1*c,b=0;b<this.modules[c].length;b++){var e=1*b;this.modules[c][b]&&(a.beginFill(0,100),a.moveTo(e,d),a.lineTo(e+1,d),a.lineTo(e+1,d+1),a.lineTo(e,d+1),a.endFill())}return a},
setupTimingPattern:function(){for(var a=8;a<this.moduleCount-8;a++)null==this.modules[a][6]&&(this.modules[a][6]=0==a%2);for(a=8;a<this.moduleCount-8;a++)null==this.modules[6][a]&&(this.modules[6][a]=0==a%2)},setupPositionAdjustPattern:function(){for(var a=j.getPatternPosition(this.typeNumber),c=0;c<a.length;c++)for(var d=0;d<a.length;d++){var b=a[c],e=a[d];if(null==this.modules[b][e])for(var f=-2;2>=f;f++)for(var i=-2;2>=i;i++)this.modules[b+f][e+i]=-2==f||2==f||-2==i||2==i||0==f&&0==i?!0:!1}},setupTypeNumber:function(a){for(var c=
j.getBCHTypeNumber(this.typeNumber),d=0;18>d;d++){var b=!a&&1==(c>>d&1);this.modules[Math.floor(d/3)][d%3+this.moduleCount-8-3]=b}for(d=0;18>d;d++)b=!a&&1==(c>>d&1),this.modules[d%3+this.moduleCount-8-3][Math.floor(d/3)]=b},setupTypeInfo:function(a,c){for(var d=j.getBCHTypeInfo(this.errorCorrectLevel<<3|c),b=0;15>b;b++){var e=!a&&1==(d>>b&1);6>b?this.modules[b][8]=e:8>b?this.modules[b+1][8]=e:this.modules[this.moduleCount-15+b][8]=e}for(b=0;15>b;b++)e=!a&&1==(d>>b&1),8>b?this.modules[8][this.moduleCount-
b-1]=e:9>b?this.modules[8][15-b-1+1]=e:this.modules[8][15-b-1]=e;this.modules[this.moduleCount-8][8]=!a},mapData:function(a,c){for(var d=-1,b=this.moduleCount-1,e=7,f=0,i=this.moduleCount-1;0<i;i-=2)for(6==i&&i--;;){for(var g=0;2>g;g++)if(null==this.modules[b][i-g]){var n=!1;f<a.length&&(n=1==(a[f]>>>e&1));j.getMask(c,b,i-g)&&(n=!n);this.modules[b][i-g]=n;e--; -1==e&&(f++,e=7)}b+=d;if(0>b||this.moduleCount<=b){b-=d;d=-d;break}}}};o.PAD0=236;o.PAD1=17;o.createData=function(a,c,d){for(var c=p.getRSBlocks(a,
c),b=new t,e=0;e<d.length;e++){var f=d[e];b.put(f.mode,4);b.put(f.getLength(),j.getLengthInBits(f.mode,a));f.write(b)}for(e=a=0;e<c.length;e++)a+=c[e].dataCount;if(b.getLengthInBits()>8*a)throw Error("code length overflow. ("+b.getLengthInBits()+">"+8*a+")");for(b.getLengthInBits()+4<=8*a&&b.put(0,4);0!=b.getLengthInBits()%8;)b.putBit(!1);for(;!(b.getLengthInBits()>=8*a);){b.put(o.PAD0,8);if(b.getLengthInBits()>=8*a)break;b.put(o.PAD1,8)}return o.createBytes(b,c)};o.createBytes=function(a,c){for(var d=
0,b=0,e=0,f=Array(c.length),i=Array(c.length),g=0;g<c.length;g++){var n=c[g].dataCount,h=c[g].totalCount-n,b=Math.max(b,n),e=Math.max(e,h);f[g]=Array(n);for(var k=0;k<f[g].length;k++)f[g][k]=255&a.buffer[k+d];d+=n;k=j.getErrorCorrectPolynomial(h);n=(new q(f[g],k.getLength()-1)).mod(k);i[g]=Array(k.getLength()-1);for(k=0;k<i[g].length;k++)h=k+n.getLength()-i[g].length,i[g][k]=0<=h?n.get(h):0}for(k=g=0;k<c.length;k++)g+=c[k].totalCount;d=Array(g);for(k=n=0;k<b;k++)for(g=0;g<c.length;g++)k<f[g].length&&
(d[n++]=f[g][k]);for(k=0;k<e;k++)for(g=0;g<c.length;g++)k<i[g].length&&(d[n++]=i[g][k]);return d};s=4;for(var j={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,
78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(a){for(var c=a<<10;0<=j.getBCHDigit(c)-j.getBCHDigit(j.G15);)c^=j.G15<<j.getBCHDigit(c)-j.getBCHDigit(j.G15);return(a<<10|c)^j.G15_MASK},getBCHTypeNumber:function(a){for(var c=a<<12;0<=j.getBCHDigit(c)-
j.getBCHDigit(j.G18);)c^=j.G18<<j.getBCHDigit(c)-j.getBCHDigit(j.G18);return a<<12|c},getBCHDigit:function(a){for(var c=0;0!=a;)c++,a>>>=1;return c},getPatternPosition:function(a){return j.PATTERN_POSITION_TABLE[a-1]},getMask:function(a,c,d){switch(a){case 0:return 0==(c+d)%2;case 1:return 0==c%2;case 2:return 0==d%3;case 3:return 0==(c+d)%3;case 4:return 0==(Math.floor(c/2)+Math.floor(d/3))%2;case 5:return 0==c*d%2+c*d%3;case 6:return 0==(c*d%2+c*d%3)%2;case 7:return 0==(c*d%3+(c+d)%2)%2;default:throw Error("bad maskPattern:"+
a);}},getErrorCorrectPolynomial:function(a){for(var c=new q([1],0),d=0;d<a;d++)c=c.multiply(new q([1,l.gexp(d)],0));return c},getLengthInBits:function(a,c){if(1<=c&&10>c)switch(a){case 1:return 10;case 2:return 9;case s:return 8;case 8:return 8;default:throw Error("mode:"+a);}else if(27>c)switch(a){case 1:return 12;case 2:return 11;case s:return 16;case 8:return 10;default:throw Error("mode:"+a);}else if(41>c)switch(a){case 1:return 14;case 2:return 13;case s:return 16;case 8:return 12;default:throw Error("mode:"+
a);}else throw Error("type:"+c);},getLostPoint:function(a){for(var c=a.getModuleCount(),d=0,b=0;b<c;b++)for(var e=0;e<c;e++){for(var f=0,i=a.isDark(b,e),g=-1;1>=g;g++)if(!(0>b+g||c<=b+g))for(var h=-1;1>=h;h++)0>e+h||c<=e+h||0==g&&0==h||i==a.isDark(b+g,e+h)&&f++;5<f&&(d+=3+f-5)}for(b=0;b<c-1;b++)for(e=0;e<c-1;e++)if(f=0,a.isDark(b,e)&&f++,a.isDark(b+1,e)&&f++,a.isDark(b,e+1)&&f++,a.isDark(b+1,e+1)&&f++,0==f||4==f)d+=3;for(b=0;b<c;b++)for(e=0;e<c-6;e++)a.isDark(b,e)&&!a.isDark(b,e+1)&&a.isDark(b,e+
2)&&a.isDark(b,e+3)&&a.isDark(b,e+4)&&!a.isDark(b,e+5)&&a.isDark(b,e+6)&&(d+=40);for(e=0;e<c;e++)for(b=0;b<c-6;b++)a.isDark(b,e)&&!a.isDark(b+1,e)&&a.isDark(b+2,e)&&a.isDark(b+3,e)&&a.isDark(b+4,e)&&!a.isDark(b+5,e)&&a.isDark(b+6,e)&&(d+=40);for(e=f=0;e<c;e++)for(b=0;b<c;b++)a.isDark(b,e)&&f++;a=Math.abs(100*f/c/c-50)/5;return d+10*a}},l={glog:function(a){if(1>a)throw Error("glog("+a+")");return l.LOG_TABLE[a]},gexp:function(a){for(;0>a;)a+=255;for(;256<=a;)a-=255;return l.EXP_TABLE[a]},EXP_TABLE:Array(256),
LOG_TABLE:Array(256)},m=0;8>m;m++)l.EXP_TABLE[m]=1<<m;for(m=8;256>m;m++)l.EXP_TABLE[m]=l.EXP_TABLE[m-4]^l.EXP_TABLE[m-5]^l.EXP_TABLE[m-6]^l.EXP_TABLE[m-8];for(m=0;255>m;m++)l.LOG_TABLE[l.EXP_TABLE[m]]=m;q.prototype={get:function(a){return this.num[a]},getLength:function(){return this.num.length},multiply:function(a){for(var c=Array(this.getLength()+a.getLength()-1),d=0;d<this.getLength();d++)for(var b=0;b<a.getLength();b++)c[d+b]^=l.gexp(l.glog(this.get(d))+l.glog(a.get(b)));return new q(c,0)},mod:function(a){if(0>
this.getLength()-a.getLength())return this;for(var c=l.glog(this.get(0))-l.glog(a.get(0)),d=Array(this.getLength()),b=0;b<this.getLength();b++)d[b]=this.get(b);for(b=0;b<a.getLength();b++)d[b]^=l.gexp(l.glog(a.get(b))+c);return(new q(d,0)).mod(a)}};p.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],
[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,
116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,
43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,
3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,
55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,
45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];p.getRSBlocks=function(a,c){var d=p.getRsBlockTable(a,c);if(void 0==d)throw Error("bad rs block @ typeNumber:"+a+"/errorCorrectLevel:"+c);for(var b=d.length/3,e=[],f=0;f<b;f++)for(var h=d[3*f+0],g=d[3*f+1],j=d[3*f+2],l=0;l<h;l++)e.push(new p(g,j));return e};p.getRsBlockTable=function(a,c){switch(c){case 1:return p.RS_BLOCK_TABLE[4*(a-1)+0];case 0:return p.RS_BLOCK_TABLE[4*(a-1)+1];case 3:return p.RS_BLOCK_TABLE[4*
(a-1)+2];case 2:return p.RS_BLOCK_TABLE[4*(a-1)+3]}};t.prototype={get:function(a){return 1==(this.buffer[Math.floor(a/8)]>>>7-a%8&1)},put:function(a,c){for(var d=0;d<c;d++)this.putBit(1==(a>>>c-d-1&1))},getLengthInBits:function(){return this.length},putBit:function(a){var c=Math.floor(this.length/8);this.buffer.length<=c&&this.buffer.push(0);a&&(this.buffer[c]|=128>>>this.length%8);this.length++}};"string"===typeof h&&(h={text:h});h=r.extend({},{render:"canvas",width:256,height:256,typeNumber:-1,
correctLevel:2,background:"#ffffff",foreground:"#000000"},h);return this.each(function(){var a;if("canvas"==h.render){a=new o(h.typeNumber,h.correctLevel);a.addData(h.text);a.make();var c=document.createElement("canvas");c.width=h.width;c.height=h.height;for(var d=c.getContext("2d"),b=h.width/a.getModuleCount(),e=h.height/a.getModuleCount(),f=0;f<a.getModuleCount();f++)for(var i=0;i<a.getModuleCount();i++){d.fillStyle=a.isDark(f,i)?h.foreground:h.background;var g=Math.ceil((i+1)*b)-Math.floor(i*b),
j=Math.ceil((f+1)*b)-Math.floor(f*b);d.fillRect(Math.round(i*b),Math.round(f*e),g,j)}}else{a=new o(h.typeNumber,h.correctLevel);a.addData(h.text);a.make();c=r("<table></table>").css("width",h.width+"px").css("height",h.height+"px").css("border","0px").css("border-collapse","collapse").css("background-color",h.background);d=h.width/a.getModuleCount();b=h.height/a.getModuleCount();for(e=0;e<a.getModuleCount();e++){f=r("<tr></tr>").css("height",b+"px").appendTo(c);for(i=0;i<a.getModuleCount();i++)r("<td></td>").css("width",
d+"px").css("background-color",a.isDark(e,i)?h.foreground:h.background).appendTo(f)}}a=c;jQuery(a).appendTo(this)})}})(jQuery);
// QR Scanner Class Definition
class QrScanner{static hasCamera(){return navigator.mediaDevices?navigator.mediaDevices.enumerateDevices().then((e=>e.some((e=>"videoinput"===e.kind)))).catch((()=>!1)):Promise.resolve(!1)}constructor(e,t,i=this._onDecodeError,n=this._calculateScanRegion,a="environment"){this.$video=e,this.$canvas=document.createElement("canvas"),this._onDecode=t,this._legacyCanvasSize=QrScanner.DEFAULT_CANVAS_SIZE,this._preferredFacingMode=a,this._active=!1,this._paused=!1,this._flashOn=!1,"number"==typeof i?(this._legacyCanvasSize=i,console.warn("You're using a deprecated version of the QrScanner constructor which will be removed in the future")):this._onDecodeError=i,"number"==typeof n?(this._legacyCanvasSize=n,console.warn("You're using a deprecated version of the QrScanner constructor which will be removed in the future")):this._calculateScanRegion=n,this._scanRegion=this._calculateScanRegion(e),this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this.$video.playsInline=!0,this.$video.muted=!0,this.$video.disablePictureInPicture=!0,this.$video.addEventListener("play",this._onPlay),this.$video.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),this._qrEnginePromise=QrScanner.createQrEngine()}hasFlash(){if(!("ImageCapture"in window))return Promise.resolve(!1);const e=this.$video.srcObject?this.$video.srcObject.getVideoTracks()[0]:null;if(!e)return Promise.reject("Camera not started or not available");return new ImageCapture(e).getPhotoCapabilities().then((e=>e.fillLightMode.includes("flash"))).catch((e=>(console.warn(e),!1)))}isFlashOn(){return this._flashOn}toggleFlash(){return this._setFlash(!this._flashOn)}turnFlashOff(){return this._setFlash(!1)}turnFlashOn(){return this._setFlash(!0)}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),this.stop(),QrScanner._postWorkerMessage(this._qrEnginePromise,"close")}start(){if(this._active&&!this._paused)return Promise.resolve();if("https:"!==window.location.protocol&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,this._paused=!1,document.hidden)return Promise.resolve();if(clearTimeout(this._offTimeout),this._offTimeout=null,this.$video.srcObject)return this.$video.play(),Promise.resolve();let e=this._preferredFacingMode;return this._getCameraStream(e,!0).catch((()=>(e="environment"===e?"user":"environment",this._getCameraStream()))).then((t=>{e=this._getFacingMode(t)||e,this.$video.srcObject=t,this.$video.play(),this._setVideoMirror(e)})).catch((e=>{throw this._active=!1,e}))}stop(){this.pause(),this._active=!1}pause(){this._paused=!0,this._active&&(this.$video.pause(),this._offTimeout||(this._offTimeout=setTimeout((()=>{const e=this.$video.srcObject?this.$video.srcObject.getTracks():[];for(const t of e)t.stop();this.$video.srcObject=null,this._offTimeout=null}),300)))}static scanImage(e,t=null,i=null,n=null,a=!1,r=!1){const s=i instanceof Worker;let o=Promise.all([i||QrScanner.createQrEngine(),QrScanner._loadImage(e)]).then((([e,r])=>{let o;return i=e,[n,o]=this._drawToCanvas(r,t,n,a),i instanceof Worker?(s||i.postMessage({type:"inversionMode",data:"both"}),new Promise(((e,t)=>{let a,r,s;r=n=>{"qrResult"===n.data.type&&(i.removeEventListener("message",r),i.removeEventListener("error",s),clearTimeout(a),null!==n.data.data?e(n.data.data):t(QrScanner.NO_QR_CODE_FOUND))},s=e=>{i.removeEventListener("message",r),i.removeEventListener("error",s),clearTimeout(a);const n=e?e.message||e:"Unknown Error";t("Scanner error: "+n)},i.addEventListener("message",r),i.addEventListener("error",s),a=setTimeout((()=>s("timeout")),1e4);const c=o.getImageData(0,0,n.width,n.height);i.postMessage({type:"decode",data:c},[c.data.buffer])}))):new Promise(((e,t)=>{const a=setTimeout((()=>t("Scanner error: timeout")),1e4);i.detect(n).then((i=>{i.length?e(i[0].rawValue):t(QrScanner.NO_QR_CODE_FOUND)})).catch((e=>t("Scanner error: "+(e.message||e)))).finally((()=>clearTimeout(a)))}))}));return t&&r&&(o=o.catch((()=>QrScanner.scanImage(e,null,i,n,a)))),o=o.finally((()=>{s||QrScanner._postWorkerMessage(i,"close")})),o}setGrayscaleWeights(e,t,i,n=!0){QrScanner._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:e,green:t,blue:i,useIntegerApproximation:n})}setInversionMode(e){QrScanner._postWorkerMessage(this._qrEnginePromise,"inversionMode",e)}static createQrEngine(e=QrScanner.WORKER_PATH){return("BarcodeDetector"in window?BarcodeDetector.getSupportedFormats():Promise.resolve([])).then((t=>-1!==t.indexOf("qr_code")?new BarcodeDetector({formats:["qr_code"]}):new Worker(e)))}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video)}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(e){const t=Math.min(e.videoWidth,e.videoHeight),i=Math.round(2/3*t);return{x:(e.videoWidth-i)/2,y:(e.videoHeight-i)/2,width:i,height:i,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_scanFrame(){if(!this._active||this.$video.paused||this.$video.ended)return!1;requestAnimationFrame((()=>{this.$video.readyState<=1?this._scanFrame():this._qrEnginePromise.then((e=>QrScanner.scanImage(this.$video,this._scanRegion,e,this.$canvas))).then(this._onDecode,(e=>{if(!this._active)return;-1!==(e.message||e).indexOf("service unavailable")&&(this._qrEnginePromise=QrScanner.createQrEngine()),this._onDecodeError(e)})).then((()=>this._scanFrame()))}))}_onDecodeError(e){e!==QrScanner.NO_QR_CODE_FOUND&&console.log(e)}_getCameraStream(e,t=!1){const i=[{width:{min:1024}},{width:{min:768}},{}];return e&&(t&&(e={exact:e}),i.forEach((t=>t.facingMode=e))),this._getMatchingCameraStream(i)}_getMatchingCameraStream(e){return navigator.mediaDevices&&0!==e.length?navigator.mediaDevices.getUserMedia({video:e.shift()}).catch((()=>this._getMatchingCameraStream(e))):Promise.reject("Camera not found.")}_setFlash(e){return this.hasFlash().then((t=>t?this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:e}]}):Promise.reject("No flash available"))).then((()=>this._flashOn=e))}_setVideoMirror(e){const t="user"===e?-1:1;this.$video.style.transform="scaleX("+t+")"}_getFacingMode(e){const t=e.getVideoTracks()[0];return t?/rear|back|environment/i.test(t.label)?"environment":/front|user|face/i.test(t.label)?"user":null:null}static _drawToCanvas(e,t=null,i=null,n=!1){i=i||document.createElement("canvas");const a=t&&t.x?t.x:0,r=t&&t.y?t.y:0,s=t&&t.width?t.width:e.width||e.videoWidth,o=t&&t.height?t.height:e.height||e.videoHeight;n||(i.width=t&&t.downScaledWidth?t.downScaledWidth:s,i.height=t&&t.downScaledHeight?t.downScaledHeight:o);const c=i.getContext("2d",{alpha:!1});return c.imageSmoothingEnabled=!1,c.drawImage(e,a,r,s,o,0,0,i.width,i.height),[i,c]}static _loadImage(e){if(e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||window.ImageBitmap&&e instanceof window.ImageBitmap||window.OffscreenCanvas&&e instanceof window.OffscreenCanvas)return Promise.resolve(e);if(e instanceof Image)return QrScanner._awaitImageLoad(e).then((()=>e));if(e instanceof File||e instanceof Blob||e instanceof URL||"string"==typeof e){const t=new Image;return e instanceof File||e instanceof Blob?t.src=URL.createObjectURL(e):t.src=e,QrScanner._awaitImageLoad(t).then((()=>((e instanceof File||e instanceof Blob)&&URL.revokeObjectURL(t.src),t)))}return Promise.reject("Unsupported image type.")}static _awaitImageLoad(e){return new Promise(((t,i)=>{if(e.complete&&0!==e.naturalWidth)t();else{let n,a;n=()=>{e.removeEventListener("load",n),e.removeEventListener("error",a),t()},a=()=>{e.removeEventListener("load",n),e.removeEventListener("error",a),i("Image load error")},e.addEventListener("load",n),e.addEventListener("error",a)}}))}static _postWorkerMessage(e,t,i){return Promise.resolve(e).then((e=>{e instanceof Worker&&e.postMessage({type:t,data:i})}))}}QrScanner.DEFAULT_CANVAS_SIZE=400,QrScanner.NO_QR_CODE_FOUND="No QR code found",QrScanner.WORKER_PATH="assets_js_lib_qr-scanner-worker.min.js";
/*! For license information please see cashaddrjs-0.4.4.min.js.LICENSE.txt */
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.cashaddr=r():t.cashaddr=r()}(this,(function(){return(()=>{var t={60:(t,r,e)=>{"use strict";var n=e(744).validate,o={q:0,p:1,z:2,r:3,y:4,9:5,x:6,8:7,g:8,f:9,2:10,t:11,v:12,d:13,w:14,0:15,s:16,3:17,j:18,n:19,5:20,4:21,k:22,h:23,c:24,e:25,6:26,m:27,u:28,a:29,7:30,l:31};t.exports={encode:function(t){n(t instanceof Uint8Array,"Invalid data: "+t+".");for(var r="",e=0;e<t.length;++e){var o=t[e];n(0<=o&&o<32,"Invalid value: "+o+"."),r+="qpzry9x8gf2tvdw0s3jn54khce6mua7l"[o]}return r},decode:function(t){n("string"==typeof t,"Invalid base32-encoded string: "+t+".");for(var r=new Uint8Array(t.length),e=0;e<t.length;++e){var i=t[e];n(i in o,"Invalid value: "+i+"."),r[e]=o[i]}return r}}},146:(t,r,e)=>{"use strict";var n=e(60),o=e(736),i=e(574),a=e(744),u=a.validate,s=a.ValidationError,p=["bitcoincash","bchtest","bchreg"];function l(t){for(var r=new Uint8Array(t.length),e=0;e<t.length;++e)r[e]=31&t[e].charCodeAt(0);return r}function f(t,r){var e=new Uint8Array(t.length+r.length);return e.set(t),e.set(r,t.length),e}function h(t){for(var r=[656907472481,522768456162,0xf33e5fb3c4,748107326120,130178868336],e=o(1),n=0;n<t.length;++n){var i=t[n],a=e.shiftRight(35);e=e.and(34359738367).shiftLeft(5).xor(i);for(var u=0;u<r.length;++u)a.shiftRight(u).and(1).equals(1)&&(e=e.xor(r[u]))}return e.xor(1)}function v(t){return t===t.toLowerCase()||t===t.toUpperCase()}t.exports={encode:function(t,r,e){u("string"==typeof t&&function(t){return v(t)&&-1!==p.indexOf(t.toLowerCase())}(t),"Invalid prefix: "+t+"."),u("string"==typeof r,"Invalid type: "+r+"."),u(e instanceof Uint8Array,"Invalid hash: "+e+".");var o,a=f(l(t),new Uint8Array(1)),c=function(t){switch(t){case"P2PKH":return 0;case"P2SH":return 8;default:throw new s("Invalid type: "+t+".")}}(r)+function(t){switch(8*t.length){case 160:return 0;case 192:return 1;case 224:return 2;case 256:return 3;case 320:return 4;case 384:return 5;case 448:return 6;case 512:return 7;default:throw new s("Invalid hash size: "+t.length+".")}}(e),y=(o=f(new Uint8Array([c]),e),i(o,8,5)),g=f(f(a,y),new Uint8Array(8)),d=f(y,function(t){for(var r=new Uint8Array(8),e=0;e<8;++e)r[7-e]=t.and(31).toJSNumber(),t=t.shiftRight(5);return r}(h(g)));return t+":"+n.encode(d)},decode:function(t){u("string"==typeof t&&v(t),"Invalid address: "+t+".");var r=t.toLowerCase().split(":");u(2===r.length,"Missing prefix: "+t+".");var e=r[0],o=n.decode(r[1]);u(function(t,r){var e=f(l(t),new Uint8Array(1));return h(f(e,r)).equals(0)}(e,o),"Invalid checksum: "+t+".");var a,p=(a=o.subarray(0,-8),i(a,5,8,!0)),c=p[0],y=p.subarray(1);return u(function(t){switch(7&t){case 0:return 160;case 1:return 192;case 2:return 224;case 3:return 256;case 4:return 320;case 5:return 384;case 6:return 448;case 7:return 512}}(c)===8*y.length,"Invalid hash size: "+t+"."),{prefix:e,type:function(t){switch(120&t){case 0:return"P2PKH";case 8:return"P2SH";default:throw new s("Invalid address type in version byte: "+t+".")}}(c),hash:y}},ValidationError:s}},574:(t,r,e)=>{"use strict";var n=e(744).validate;t.exports=function(t,r,e,o){for(var i=o?Math.floor(t.length*r/e):Math.ceil(t.length*r/e),a=(1<<e)-1,u=new Uint8Array(i),s=0,p=0,l=0,f=0;f<t.length;++f){var h=t[f];for(n(0<=h&&h>>r==0,"Invalid value: "+h+"."),p=p<<r|h,l+=r;l>=e;)l-=e,u[s]=p>>l&a,++s}return o?n(l<r&&0==(p<<e-l&a),"Input cannot be converted to "+e+" bits without padding, but strict mode was used."):l>0&&(u[s]=p<<e-l&a,++s),u}},744:t=>{"use strict";function r(t){var r=new Error;this.name=r.name="ValidationError",this.message=r.message=t,this.stack=r.stack}r.prototype=Object.create(Error.prototype),t.exports={ValidationError:r,validate:function(t,e){if(!t)throw new r(e)}}},736:(t,r,e)=>{var n;t=e.nmd(t);var o=function(t){"use strict";var r=1e7,e=9007199254740992,n=l(e),i=Math.log(e);function a(t,r){return void 0===t?a[0]:void 0!==r?10==+r?$(t):T(t,r):$(t)}function u(t,r){this.value=t,this.sign=r,this.isSmall=!1}function s(t){this.value=t,this.sign=t<0,this.isSmall=!0}function p(t){return-e<t&&t<e}function l(t){return t<1e7?[t]:t<1e14?[t%1e7,Math.floor(t/1e7)]:[t%1e7,Math.floor(t/1e7)%1e7,Math.floor(t/1e14)]}function f(t){h(t);var e=t.length;if(e<4&&I(t,n)<0)switch(e){case 0:return 0;case 1:return t[0];case 2:return t[0]+t[1]*r;default:return t[0]+(t[1]+t[2]*r)*r}return t}function h(t){for(var r=t.length;0===t[--r];);t.length=r+1}function v(t){for(var r=new Array(t),e=-1;++e<t;)r[e]=0;return r}function c(t){return t>0?Math.floor(t):Math.ceil(t)}function y(t,e){var n,o,i=t.length,a=e.length,u=new Array(i),s=0,p=r;for(o=0;o<a;o++)s=(n=t[o]+e[o]+s)>=p?1:0,u[o]=n-s*p;for(;o<i;)s=(n=t[o]+s)===p?1:0,u[o++]=n-s*p;return s>0&&u.push(s),u}function g(t,r){return t.length>=r.length?y(t,r):y(r,t)}function d(t,e){var n,o,i=t.length,a=new Array(i),u=r;for(o=0;o<i;o++)n=t[o]-u+e,e=Math.floor(n/u),a[o]=n-e*u,e+=1;for(;e>0;)a[o++]=e%u,e=Math.floor(e/u);return a}function m(t,e){var n,o,i=t.length,a=e.length,u=new Array(i),s=0,p=r;for(n=0;n<a;n++)(o=t[n]-s-e[n])<0?(o+=p,s=1):s=0,u[n]=o;for(n=a;n<i;n++){if(!((o=t[n]-s)<0)){u[n++]=o;break}o+=p,u[n]=o}for(;n<i;n++)u[n]=t[n];return h(u),u}function w(t,e,n){var o,i,a=t.length,p=new Array(a),l=-e,h=r;for(o=0;o<a;o++)i=t[o]+l,l=Math.floor(i/h),i%=h,p[o]=i<0?i+h:i;return"number"==typeof(p=f(p))?(n&&(p=-p),new s(p)):new u(p,n)}function b(t,e){var n,o,i,a,u=t.length,s=e.length,p=v(u+s),l=r;for(i=0;i<u;++i){a=t[i];for(var f=0;f<s;++f)n=a*e[f]+p[i+f],o=Math.floor(n/l),p[i+f]=n-o*l,p[i+f+1]+=o}return h(p),p}function M(t,e){var n,o,i=t.length,a=new Array(i),u=r,s=0;for(o=0;o<i;o++)n=t[o]*e+s,s=Math.floor(n/u),a[o]=n-s*u;for(;s>0;)a[o++]=s%u,s=Math.floor(s/u);return a}function q(t,r){for(var e=[];r-- >0;)e.push(0);return e.concat(t)}function S(t,r){var e=Math.max(t.length,r.length);if(e<=30)return b(t,r);e=Math.ceil(e/2);var n=t.slice(e),o=t.slice(0,e),i=r.slice(e),a=r.slice(0,e),u=S(o,a),s=S(n,i),p=S(g(o,n),g(a,i)),l=g(g(u,q(m(m(p,u),s),e)),q(s,2*e));return h(l),l}function E(t,e,n){return new u(t<r?M(e,t):b(e,l(t)),n)}function x(t){var e,n,o,i,a=t.length,u=v(a+a),s=r;for(o=0;o<a;o++){n=0-(i=t[o])*i;for(var p=o;p<a;p++)e=i*t[p]*2+u[o+p]+n,n=Math.floor(e/s),u[o+p]=e-n*s;u[o+a]=n}return h(u),u}function A(t,r){var e,n,o,i,a=t.length,u=v(a);for(o=0,e=a-1;e>=0;--e)o=(i=1e7*o+t[e])-(n=c(i/r))*r,u[e]=0|n;return[u,0|o]}function N(t,e){var n,o,i=$(e),p=t.value,y=i.value;if(0===y)throw new Error("Cannot divide by zero");if(t.isSmall)return i.isSmall?[new s(c(p/y)),new s(p%y)]:[a[0],t];if(i.isSmall){if(1===y)return[t,a[0]];if(-1==y)return[t.negate(),a[0]];var g=Math.abs(y);if(g<r){o=f((n=A(p,g))[0]);var d=n[1];return t.sign&&(d=-d),"number"==typeof o?(t.sign!==i.sign&&(o=-o),[new s(o),new s(d)]):[new u(o,t.sign!==i.sign),new s(d)]}y=l(g)}var w=I(p,y);if(-1===w)return[a[0],t];if(0===w)return[a[t.sign===i.sign?1:-1],a[0]];o=(n=p.length+y.length<=200?function(t,e){var n,o,i,a,u,s,p,l=t.length,h=e.length,c=r,y=v(e.length),g=e[h-1],d=Math.ceil(c/(2*g)),m=M(t,d),w=M(e,d);for(m.length<=l&&m.push(0),w.push(0),g=w[h-1],o=l-h;o>=0;o--){for(n=c-1,m[o+h]!==g&&(n=Math.floor((m[o+h]*c+m[o+h-1])/g)),i=0,a=0,s=w.length,u=0;u<s;u++)i+=n*w[u],p=Math.floor(i/c),a+=m[o+u]-(i-p*c),i=p,a<0?(m[o+u]=a+c,a=-1):(m[o+u]=a,a=0);for(;0!==a;){for(n-=1,i=0,u=0;u<s;u++)(i+=m[o+u]-c+w[u])<0?(m[o+u]=i+c,i=0):(m[o+u]=i,i=1);a+=i}y[o]=n}return m=A(m,d)[0],[f(y),f(m)]}(p,y):function(t,e){for(var n,o,i,a,u,s=t.length,p=e.length,l=[],v=[],c=r;s;)if(v.unshift(t[--s]),h(v),I(v,e)<0)l.push(0);else{i=v[(o=v.length)-1]*c+v[o-2],a=e[p-1]*c+e[p-2],o>p&&(i=(i+1)*c),n=Math.ceil(i/a);do{if(I(u=M(e,n),v)<=0)break;n--}while(n);l.push(n),v=m(v,u)}return l.reverse(),[f(l),f(v)]}(p,y))[0];var b=t.sign!==i.sign,q=n[1],S=t.sign;return"number"==typeof o?(b&&(o=-o),o=new s(o)):o=new u(o,b),"number"==typeof q?(S&&(q=-q),q=new s(q)):q=new u(q,S),[o,q]}function I(t,r){if(t.length!==r.length)return t.length>r.length?1:-1;for(var e=t.length-1;e>=0;e--)if(t[e]!==r[e])return t[e]>r[e]?1:-1;return 0}function O(t){var r=t.abs();return!r.isUnit()&&(!!(r.equals(2)||r.equals(3)||r.equals(5))||!(r.isEven()||r.isDivisibleBy(3)||r.isDivisibleBy(5))&&(!!r.lesser(49)||void 0))}function P(t,r){for(var e,n,i,u=t.prev(),s=u,p=0;s.isEven();)s=s.divide(2),p++;t:for(n=0;n<r.length;n++)if(!t.lesser(r[n])&&!(i=o(r[n]).modPow(s,t)).equals(a[1])&&!i.equals(u)){for(e=p-1;0!=e;e--){if((i=i.square().mod(t)).isUnit())return!1;if(i.equals(u))continue t}return!1}return!0}u.prototype=Object.create(a.prototype),s.prototype=Object.create(a.prototype),u.prototype.add=function(t){var r=$(t);if(this.sign!==r.sign)return this.subtract(r.negate());var e=this.value,n=r.value;return r.isSmall?new u(d(e,Math.abs(n)),this.sign):new u(g(e,n),this.sign)},u.prototype.plus=u.prototype.add,s.prototype.add=function(t){var r=$(t),e=this.value;if(e<0!==r.sign)return this.subtract(r.negate());var n=r.value;if(r.isSmall){if(p(e+n))return new s(e+n);n=l(Math.abs(n))}return new u(d(n,Math.abs(e)),e<0)},s.prototype.plus=s.prototype.add,u.prototype.subtract=function(t){var r=$(t);if(this.sign!==r.sign)return this.add(r.negate());var e=this.value,n=r.value;return r.isSmall?w(e,Math.abs(n),this.sign):function(t,r,e){var n;return I(t,r)>=0?n=m(t,r):(n=m(r,t),e=!e),"number"==typeof(n=f(n))?(e&&(n=-n),new s(n)):new u(n,e)}(e,n,this.sign)},u.prototype.minus=u.prototype.subtract,s.prototype.subtract=function(t){var r=$(t),e=this.value;if(e<0!==r.sign)return this.add(r.negate());var n=r.value;return r.isSmall?new s(e-n):w(n,Math.abs(e),e>=0)},s.prototype.minus=s.prototype.subtract,u.prototype.negate=function(){return new u(this.value,!this.sign)},s.prototype.negate=function(){var t=this.sign,r=new s(-this.value);return r.sign=!t,r},u.prototype.abs=function(){return new u(this.value,!1)},s.prototype.abs=function(){return new s(Math.abs(this.value))},u.prototype.multiply=function(t){var e,n,o,i=$(t),s=this.value,p=i.value,f=this.sign!==i.sign;if(i.isSmall){if(0===p)return a[0];if(1===p)return this;if(-1===p)return this.negate();if((e=Math.abs(p))<r)return new u(M(s,e),f);p=l(e)}return new u(-.012*(n=s.length)-.012*(o=p.length)+15e-6*n*o>0?S(s,p):b(s,p),f)},u.prototype.times=u.prototype.multiply,s.prototype._multiplyBySmall=function(t){return p(t.value*this.value)?new s(t.value*this.value):E(Math.abs(t.value),l(Math.abs(this.value)),this.sign!==t.sign)},u.prototype._multiplyBySmall=function(t){return 0===t.value?a[0]:1===t.value?this:-1===t.value?this.negate():E(Math.abs(t.value),this.value,this.sign!==t.sign)},s.prototype.multiply=function(t){return $(t)._multiplyBySmall(this)},s.prototype.times=s.prototype.multiply,u.prototype.square=function(){return new u(x(this.value),!1)},s.prototype.square=function(){var t=this.value*this.value;return p(t)?new s(t):new u(x(l(Math.abs(this.value))),!1)},u.prototype.divmod=function(t){var r=N(this,t);return{quotient:r[0],remainder:r[1]}},s.prototype.divmod=u.prototype.divmod,u.prototype.divide=function(t){return N(this,t)[0]},s.prototype.over=s.prototype.divide=u.prototype.over=u.prototype.divide,u.prototype.mod=function(t){return N(this,t)[1]},s.prototype.remainder=s.prototype.mod=u.prototype.remainder=u.prototype.mod,u.prototype.pow=function(t){var r,e,n,o=$(t),i=this.value,u=o.value;if(0===u)return a[1];if(0===i)return a[0];if(1===i)return a[1];if(-1===i)return o.isEven()?a[1]:a[-1];if(o.sign)return a[0];if(!o.isSmall)throw new Error("The exponent "+o.toString()+" is too large.");if(this.isSmall&&p(r=Math.pow(i,u)))return new s(c(r));for(e=this,n=a[1];!0&u&&(n=n.times(e),--u),0!==u;)u/=2,e=e.square();return n},s.prototype.pow=u.prototype.pow,u.prototype.modPow=function(t,r){if(t=$(t),(r=$(r)).isZero())throw new Error("Cannot take modPow with modulus 0");for(var e=a[1],n=this.mod(r);t.isPositive();){if(n.isZero())return a[0];t.isOdd()&&(e=e.multiply(n).mod(r)),t=t.divide(2),n=n.square().mod(r)}return e},s.prototype.modPow=u.prototype.modPow,u.prototype.compareAbs=function(t){var r=$(t),e=this.value,n=r.value;return r.isSmall?1:I(e,n)},s.prototype.compareAbs=function(t){var r=$(t),e=Math.abs(this.value),n=r.value;return r.isSmall?e===(n=Math.abs(n))?0:e>n?1:-1:-1},u.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var r=$(t),e=this.value,n=r.value;return this.sign!==r.sign?r.sign?1:-1:r.isSmall?this.sign?-1:1:I(e,n)*(this.sign?-1:1)},u.prototype.compareTo=u.prototype.compare,s.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var r=$(t),e=this.value,n=r.value;return r.isSmall?e==n?0:e>n?1:-1:e<0!==r.sign?e<0?-1:1:e<0?1:-1},s.prototype.compareTo=s.prototype.compare,u.prototype.equals=function(t){return 0===this.compare(t)},s.prototype.eq=s.prototype.equals=u.prototype.eq=u.prototype.equals,u.prototype.notEquals=function(t){return 0!==this.compare(t)},s.prototype.neq=s.prototype.notEquals=u.prototype.neq=u.prototype.notEquals,u.prototype.greater=function(t){return this.compare(t)>0},s.prototype.gt=s.prototype.greater=u.prototype.gt=u.prototype.greater,u.prototype.lesser=function(t){return this.compare(t)<0},s.prototype.lt=s.prototype.lesser=u.prototype.lt=u.prototype.lesser,u.prototype.greaterOrEquals=function(t){return this.compare(t)>=0},s.prototype.geq=s.prototype.greaterOrEquals=u.prototype.geq=u.prototype.greaterOrEquals,u.prototype.lesserOrEquals=function(t){return this.compare(t)<=0},s.prototype.leq=s.prototype.lesserOrEquals=u.prototype.leq=u.prototype.lesserOrEquals,u.prototype.isEven=function(){return 0==(1&this.value[0])},s.prototype.isEven=function(){return 0==(1&this.value)},u.prototype.isOdd=function(){return 1==(1&this.value[0])},s.prototype.isOdd=function(){return 1==(1&this.value)},u.prototype.isPositive=function(){return!this.sign},s.prototype.isPositive=function(){return this.value>0},u.prototype.isNegative=function(){return this.sign},s.prototype.isNegative=function(){return this.value<0},u.prototype.isUnit=function(){return!1},s.prototype.isUnit=function(){return 1===Math.abs(this.value)},u.prototype.isZero=function(){return!1},s.prototype.isZero=function(){return 0===this.value},u.prototype.isDivisibleBy=function(t){var r=$(t),e=r.value;return 0!==e&&(1===e||(2===e?this.isEven():this.mod(r).equals(a[0])))},s.prototype.isDivisibleBy=u.prototype.isDivisibleBy,u.prototype.isPrime=function(r){var e=O(this);if(e!==t)return e;var n=this.abs(),i=n.bitLength();if(i<=64)return P(n,[2,325,9375,28178,450775,9780504,1795265022]);for(var a=Math.log(2)*i,u=Math.ceil(!0===r?2*Math.pow(a,2):a),s=[],p=0;p<u;p++)s.push(o(p+2));return P(n,s)},s.prototype.isPrime=u.prototype.isPrime,u.prototype.isProbablePrime=function(r){var e=O(this);if(e!==t)return e;for(var n=this.abs(),i=r===t?5:r,a=[],u=0;u<i;u++)a.push(o.randBetween(2,n.minus(2)));return P(n,a)},s.prototype.isProbablePrime=u.prototype.isProbablePrime,u.prototype.modInv=function(t){for(var r,e,n,i=o.zero,a=o.one,u=$(t),s=this.abs();!s.equals(o.zero);)r=u.divide(s),e=i,n=u,i=a,u=s,a=e.subtract(r.multiply(a)),s=n.subtract(r.multiply(s));if(!u.equals(1))throw new Error(this.toString()+" and "+t.toString()+" are not co-prime");return-1===i.compare(0)&&(i=i.add(t)),this.isNegative()?i.negate():i},s.prototype.modInv=u.prototype.modInv,u.prototype.next=function(){var t=this.value;return this.sign?w(t,1,this.sign):new u(d(t,1),this.sign)},s.prototype.next=function(){var t=this.value;return t+1<e?new s(t+1):new u(n,!1)},u.prototype.prev=function(){var t=this.value;return this.sign?new u(d(t,1),!0):w(t,1,this.sign)},s.prototype.prev=function(){var t=this.value;return t-1>-e?new s(t-1):new u(n,!0)};for(var U=[1];2*U[U.length-1]<=r;)U.push(2*U[U.length-1]);var Z=U.length,C=U[Z-1];function L(t){return("number"==typeof t||"string"==typeof t)&&+Math.abs(t)<=r||t instanceof u&&t.value.length<=1}function j(t,r,e){r=$(r);for(var n=t.isNegative(),i=r.isNegative(),a=n?t.not():t,u=i?r.not():r,s=0,p=0,l=null,f=null,h=[];!a.isZero()||!u.isZero();)s=(l=N(a,C))[1].toJSNumber(),n&&(s=C-1-s),p=(f=N(u,C))[1].toJSNumber(),i&&(p=C-1-p),a=l[0],u=f[0],h.push(e(s,p));for(var v=0!==e(n?1:0,i?1:0)?o(-1):o(0),c=h.length-1;c>=0;c-=1)v=v.multiply(C).add(o(h[c]));return v}u.prototype.shiftLeft=function(t){if(!L(t))throw new Error(String(t)+" is too large for shifting.");if((t=+t)<0)return this.shiftRight(-t);var r=this;if(r.isZero())return r;for(;t>=Z;)r=r.multiply(C),t-=Z-1;return r.multiply(U[t])},s.prototype.shiftLeft=u.prototype.shiftLeft,u.prototype.shiftRight=function(t){var r;if(!L(t))throw new Error(String(t)+" is too large for shifting.");if((t=+t)<0)return this.shiftLeft(-t);for(var e=this;t>=Z;){if(e.isZero()||e.isNegative()&&e.isUnit())return e;e=(r=N(e,C))[1].isNegative()?r[0].prev():r[0],t-=Z-1}return(r=N(e,U[t]))[1].isNegative()?r[0].prev():r[0]},s.prototype.shiftRight=u.prototype.shiftRight,u.prototype.not=function(){return this.negate().prev()},s.prototype.not=u.prototype.not,u.prototype.and=function(t){return j(this,t,(function(t,r){return t&r}))},s.prototype.and=u.prototype.and,u.prototype.or=function(t){return j(this,t,(function(t,r){return t|r}))},s.prototype.or=u.prototype.or,u.prototype.xor=function(t){return j(this,t,(function(t,r){return t^r}))},s.prototype.xor=u.prototype.xor;function z(t){var e=t.value,n="number"==typeof e?1073741824|e:e[0]+e[1]*r|1073758208;return n&-n}function B(t,r){if(r.compareTo(t)<=0){var e=B(t,r.square(r)),n=e.p,i=e.e,a=n.multiply(r);return a.compareTo(t)<=0?{p:a,e:2*i+1}:{p:n,e:2*i}}return{p:o(1),e:0}}function k(t,r){return t=$(t),r=$(r),t.greater(r)?t:r}function J(t,r){return t=$(t),r=$(r),t.lesser(r)?t:r}function R(t,r){if(t=$(t).abs(),r=$(r).abs(),t.equals(r))return t;if(t.isZero())return r;if(r.isZero())return t;for(var e,n,o=a[1];t.isEven()&&r.isEven();)e=Math.min(z(t),z(r)),t=t.divide(e),r=r.divide(e),o=o.multiply(e);for(;t.isEven();)t=t.divide(z(t));do{for(;r.isEven();)r=r.divide(z(r));t.greater(r)&&(n=r,r=t,t=n),r=r.subtract(t)}while(!r.isZero());return o.isUnit()?t:t.multiply(o)}u.prototype.bitLength=function(){var t=this;return t.compareTo(o(0))<0&&(t=t.negate().subtract(o(1))),0===t.compareTo(o(0))?o(0):o(B(t,o(2)).e).add(o(1))},s.prototype.bitLength=u.prototype.bitLength;var T=function(t,r){for(var e=t.length,n=Math.abs(r),o=0;o<e;o++)if("-"!==(l=t[o].toLowerCase())&&/[a-z0-9]/.test(l)){if(/[0-9]/.test(l)&&+l>=n){if("1"===l&&1===n)continue;throw new Error(l+" is not a valid digit in base "+r+".")}if(l.charCodeAt(0)-87>=n)throw new Error(l+" is not a valid digit in base "+r+".")}if(2<=r&&r<=36&&e<=i/Math.log(r)){var a=parseInt(t,r);if(isNaN(a))throw new Error(l+" is not a valid digit in base "+r+".");return new s(parseInt(t,r))}r=$(r);var u=[],p="-"===t[0];for(o=p?1:0;o<t.length;o++){var l,f=(l=t[o].toLowerCase()).charCodeAt(0);if(48<=f&&f<=57)u.push($(l));else if(97<=f&&f<=122)u.push($(l.charCodeAt(0)-87));else{if("<"!==l)throw new Error(l+" is not a valid character");var h=o;do{o++}while(">"!==t[o]);u.push($(t.slice(h+1,o)))}}return D(u,r,p)};function D(t,r,e){var n,o=a[0],i=a[1];for(n=t.length-1;n>=0;n--)o=o.add(t[n].times(i)),i=i.times(r);return e?o.negate():o}function H(t){return t<=35?"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t):"<"+t+">"}function V(t,r){if((r=o(r)).isZero()){if(t.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(r.equals(-1)){if(t.isZero())return{value:[0],isNegative:!1};if(t.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-t)).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var e=Array.apply(null,Array(+t-1)).map(Array.prototype.valueOf,[0,1]);return e.unshift([1]),{value:[].concat.apply([],e),isNegative:!1}}var n=!1;if(t.isNegative()&&r.isPositive()&&(n=!0,t=t.abs()),r.equals(1))return t.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(+t)).map(Number.prototype.valueOf,1),isNegative:n};for(var i,a=[],u=t;u.isNegative()||u.compareAbs(r)>=0;){i=u.divmod(r),u=i.quotient;var s=i.remainder;s.isNegative()&&(s=r.minus(s).abs(),u=u.next()),a.push(s.toJSNumber())}return a.push(u.toJSNumber()),{value:a.reverse(),isNegative:n}}function _(t,r){var e=V(t,r);return(e.isNegative?"-":"")+e.value.map(H).join("")}function K(t){if(p(+t)){var r=+t;if(r===c(r))return new s(r);throw new Error("Invalid integer: "+t)}var e="-"===t[0];e&&(t=t.slice(1));var n=t.split(/e/i);if(n.length>2)throw new Error("Invalid integer: "+n.join("e"));if(2===n.length){var o=n[1];if("+"===o[0]&&(o=o.slice(1)),(o=+o)!==c(o)||!p(o))throw new Error("Invalid integer: "+o+" is not a valid exponent.");var i=n[0],a=i.indexOf(".");if(a>=0&&(o-=i.length-a-1,i=i.slice(0,a)+i.slice(a+1)),o<0)throw new Error("Cannot include negative exponent part for integers");t=i+=new Array(o+1).join("0")}if(!/^([0-9][0-9]*)$/.test(t))throw new Error("Invalid integer: "+t);for(var l=[],f=t.length,v=f-7;f>0;)l.push(+t.slice(v,f)),(v-=7)<0&&(v=0),f-=7;return h(l),new u(l,e)}function $(t){return"number"==typeof t?function(t){if(p(t)){if(t!==c(t))throw new Error(t+" is not an integer.");return new s(t)}return K(t.toString())}(t):"string"==typeof t?K(t):t}u.prototype.toArray=function(t){return V(this,t)},s.prototype.toArray=function(t){return V(this,t)},u.prototype.toString=function(r){if(r===t&&(r=10),10!==r)return _(this,r);for(var e,n=this.value,o=n.length,i=String(n[--o]);--o>=0;)e=String(n[o]),i+="0000000".slice(e.length)+e;return(this.sign?"-":"")+i},s.prototype.toString=function(r){return r===t&&(r=10),10!=r?_(this,r):String(this.value)},u.prototype.toJSON=s.prototype.toJSON=function(){return this.toString()},u.prototype.valueOf=function(){return parseInt(this.toString(),10)},u.prototype.toJSNumber=u.prototype.valueOf,s.prototype.valueOf=function(){return this.value},s.prototype.toJSNumber=s.prototype.valueOf;for(var F=0;F<1e3;F++)a[F]=new s(F),F>0&&(a[-F]=new s(-F));return a.one=a[1],a.zero=a[0],a.minusOne=a[-1],a.max=k,a.min=J,a.gcd=R,a.lcm=function(t,r){return t=$(t).abs(),r=$(r).abs(),t.divide(R(t,r)).multiply(r)},a.isInstance=function(t){return t instanceof u||t instanceof s},a.randBetween=function(t,e){var n=J(t=$(t),e=$(e)),o=k(t,e).subtract(n).add(1);if(o.isSmall)return n.add(Math.floor(Math.random()*o));for(var i=[],a=!0,p=o.value.length-1;p>=0;p--){var l=a?o.value[p]:r,h=c(Math.random()*l);i.unshift(h),h<l&&(a=!1)}return i=f(i),n.add("number"==typeof i?new s(i):new u(i,!1))},a.fromArray=function(t,r,e){return D(t.map($),$(r||10),e)},a}();t.hasOwnProperty("exports")&&(t.exports=o),void 0===(n=function(){return o}.apply(r,[]))||(t.exports=n)}},r={};function e(n){if(r[n])return r[n].exports;var o=r[n]={id:n,loaded:!1,exports:{}};return t[n](o,o.exports,e),o.loaded=!0,o.exports}return e.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),e(146)})()}));