var _aa={};_aa._ab=function(h,t){for(var n=qrcode.width,r=qrcode.height,i=!0,s=0;sn||a<-1||a>r)throw"Error._ab ";i=!1,e==-1?(t[s]=0,i=!0):e==n&&(t[s]=n-1,i=!0),a==-1?(t[s+1]=0,i=!0):a==r&&(t[s+1]=r-1,i=!0)}i=!0;for(var s=t.length-2;s>=0&&i;s-=2){var e=Math.floor(t[s]),a=Math.floor(t[s+1]);if(e<-1||e>n||a<-1||a>r)throw"Error._ab ";i=!1,e==-1?(t[s]=0,i=!0):e==n&&(t[s]=n-1,i=!0),a==-1?(t[s+1]=0,i=!0):a==r&&(t[s+1]=r-1,i=!0)}},_aa._af=function(h,t,n){for(var r=new _ac(t),i=new Array(t<<1),s=0;s>1)+.5,i[o+1]=a;n._ad(i),_aa._ab(h,i);try{for(var o=0;o>1,s)}}catch(_){throw"Error._ab"}}return r},_aa._ah=function(h,t,n,r,i,s,e,a,o,w,_,f,v,u,c,d,l,g){var y=_ae._ag(n,r,i,s,e,a,o,w,_,f,v,u,c,d,l,g);return _aa._af(h,t,y)};function _a1(h,t){this.count=h,this._fc=t,this.__defineGetter__("Count",function(){return this.count}),this.__defineGetter__("_dm",function(){return this._fc})}function _a2(h,t,n){this._bm=h,n?this._do=new Array(t,n):this._do=new Array(t),this.__defineGetter__("_bo",function(){return this._bm}),this.__defineGetter__("_dn",function(){return this._bm*this._fo}),this.__defineGetter__("_fo",function(){for(var r=0,i=0;i6&&(v._bq(f-11,0,3,6),v._bq(0,f-11,6,3)),v},this._bu=function(f){return this._do[f.ordinal()]}}_a3._bv=new Array(31892,34236,39577,42195,48118,51042,55367,58893,63784,68472,70749,76311,79154,84390,87683,92361,96236,102084,102881,110507,110734,117786,119615,126325,127568,133589,136944,141498,145311,150283,152622,158308,161089,167017),_a3.VERSIONS=_ay(),_a3._av=function(h){if(h<1||h>40)throw"bad arguments";return _a3.VERSIONS[h-1]},_a3._at=function(h){if(h%4!=1)throw"Error _at";try{return _a3._av(h-17>>2)}catch(t){throw"Error _av"}},_a3._aw=function(h){for(var t=4294967295,n=0,r=0;r<_a3._bv.length;r++){var i=_a3._bv[r];if(i==h)return this._av(r+7);var s=_ax._gj(h,i);sMath.abs(r-t);if(s){var e=t;t=n,n=e,e=r,r=i,i=e}for(var a=Math.abs(r-t),o=Math.abs(i-n),w=-a>>1,_=n0){if(c==i)break;c+=_,w-=a}}var A=r-t,b=i-n;return Math.sqrt(A*A+b*b)},this._bh=function(t,n,r,i){var s=this._bi(t,n,r,i),e=1,a=t-(r-t);a<0?(e=t/(t-a),a=0):a>=qrcode.width&&(e=(qrcode.width-1-t)/(a-t),a=qrcode.width-1);var o=Math.floor(n-(i-n)*e);return e=1,o<0?(e=n/(n-o),o=0):o>=qrcode.height&&(e=(qrcode.height-1-n)/(o-n),o=qrcode.height-1),a=Math.floor(t+(a-t)*e),s+=this._bi(t,n,a,o),s-1},this._bj=function(t,n){var r=this._bh(Math.floor(t.X),Math.floor(t.Y),Math.floor(n.X),Math.floor(n.Y)),i=this._bh(Math.floor(n.X),Math.floor(n.Y),Math.floor(t.X),Math.floor(t.Y));return isNaN(r)?i/7:isNaN(i)?r/7:(r+i)/14},this._bk=function(t,n,r){return(this._bj(t,n)+this._bj(t,r))/2},this.distance=function(t,n){var r=t.X-n.X,i=t.Y-n.Y;return Math.sqrt(r*r+i*i)},this._bx=function(t,n,r,i){var s=Math.round(this.distance(t,n)/i),e=Math.round(this.distance(t,r)/i),a=(s+e>>1)+7;switch(a&3){case 0:a++;break;case 2:a--;break;case 3:throw"Error"}return a},this._bl=function(t,n,r,i){var s=Math.floor(i*t),e=Math.max(0,n-s),a=Math.min(qrcode.width-1,n+s);if(a-e0)for(var _=r.X-n.X+i.X,f=r.Y-n.Y+i.Y,v=1-3/o,u=Math.floor(n.X+v*(_-n.X)),c=Math.floor(n.Y+v*(f-n.Y)),d=4;d<=16;d<<=1){w=this._bl(s,u,c,d);break}var l=this.createTransform(n,r,i,w,e),g=this._bz(this.image,l,e),y;return w==null?y=new Array(i,n,r):y=new Array(i,n,r,w),new _bg(g,y)},this.detect=function(){var t=new _cc()._ce(this.image);return this._cd(t)}}var _ca=21522,_cb=new Array(new Array(21522,0),new Array(20773,1),new Array(24188,2),new Array(23371,3),new Array(17913,4),new Array(16590,5),new Array(20375,6),new Array(19104,7),new Array(30660,8),new Array(29427,9),new Array(32170,10),new Array(30877,11),new Array(26159,12),new Array(25368,13),new Array(27713,14),new Array(26998,15),new Array(5769,16),new Array(5054,17),new Array(7399,18),new Array(6608,19),new Array(1890,20),new Array(597,21),new Array(3340,22),new Array(2107,23),new Array(13663,24),new Array(12392,25),new Array(16177,26),new Array(14854,27),new Array(9396,28),new Array(8579,29),new Array(11994,30),new Array(11245,31)),_ch=new Array(0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4);function _ax(h){this._cf=_cg.forBits(h>>3&3),this._fe=h&7,this.__defineGetter__("_cg",function(){return this._cf}),this.__defineGetter__("_dx",function(){return this._fe}),this.GetHashCode=function(){return this._cf.ordinal()<<3|_fe},this.Equals=function(t){var n=t;return this._cf==n._cf&&this._fe==n._fe}}_ax._gj=function(h,t){return h^=t,_ch[h&15]+_ch[_ew(h,4)&15]+_ch[_ew(h,8)&15]+_ch[_ew(h,12)&15]+_ch[_ew(h,16)&15]+_ch[_ew(h,20)&15]+_ch[_ew(h,24)&15]+_ch[_ew(h,28)&15]},_ax._ci=function(h){var t=_ax._cj(h);return t!=null?t:_ax._cj(h^_ca)},_ax._cj=function(h){for(var t=4294967295,n=0,r=0;r<_cb.length;r++){var i=_cb[r],s=i[0];if(s==h)return new _ax(i[1]);var e=this._gj(h,s);e=FOR_BITS.length)throw"bad arguments";return FOR_BITS[h]};var L=new _cg(0,1,"L"),M=new _cg(1,0,"M"),Q=new _cg(2,3,"Q"),H=new _cg(3,2,"H"),FOR_BITS=new Array(M,L,H,Q);function _ac(h,t){if(t||(t=h),h<1||t<1)throw"Both dimensions must be greater than 0";this.width=h,this.height=t;var n=h>>5;(h&31)!=0&&n++,this.rowSize=n,this.bits=new Array(n*t);for(var r=0;r>5);return(_ew(this.bits[e],i&31)&1)!=0},this._dq=function(i,s){var e=s*this.rowSize+(i>>5);this.bits[e]|=1<<(i&31)},this.flip=function(i,s){var e=s*this.rowSize+(i>>5);this.bits[e]^=1<<(i&31)},this.clear=function(){for(var i=this.bits.length,s=0;sthis.height||o>this.width)throw"The region must fit inside the matrix";for(var _=s;_>5)]|=1<<(v&31)}}function _dl(h,t){this._dv=h,this._dw=t,this.__defineGetter__("_du",function(){return this._dv}),this.__defineGetter__("Codewords",function(){return this._dw})}_dl._gn=function(h,t,n){if(h.length!=t._dp)throw"bad arguments";for(var r=t._bu(n),i=0,s=r._fb(),e=0;e=0;){var d=a[c]._dw.length;if(d==u)break;c--}c++;for(var l=u-r._bo,g=0,e=0;e=0;i--)n=this._dk(8,i,n);if(this._co=_ax._ci(n),this._co!=null)return this._co;var s=this._au.Dimension;n=0;for(var e=s-8,r=s-1;r>=e;r--)n=this._dk(r,8,n);for(var i=s-7;i>2;if(r<=6)return _a3._av(r);for(var i=0,s=n-11,e=5;e>=0;e--)for(var a=n-9;a>=s;a--)i=this._dk(a,e,i);if(this._cp=_a3._aw(i),this._cp!=null&&this._cp._cr==n)return this._cp;i=0;for(var a=5;a>=0;a--)for(var e=n-9;e>=s;e--)i=this._dk(a,e,i);if(this._cp=_a3._aw(i),this._cp!=null&&this._cp._cr==n)return this._cp;throw"Error _cq"},this._gk=function(){var n=this._cm(),r=this._cq(),i=_dx._gl(n._dx),s=this._au.Dimension;i._dj(this._au,s);for(var e=r._aq(),a=!0,o=new Array(r._dp),w=0,_=0,f=0,v=s-1;v>0;v-=2){v==6&&v--;for(var u=0;u7)throw"bad arguments";return _dx._dy[h]};function _fg(){this._dj=function(h,t){for(var n=0;n=Math.floor(r/2);){var f=s,v=a,u=w;if(s=e,a=o,w=_,s.Zero)throw"r_{i-1} was zero";e=f;for(var c=this._fa.Zero,d=s._ex(s._ec),l=this._fa.inverse(d);e._ec>=s._ec&&!e.Zero;){var g=e._ec-s._ec,y=this._fa.multiply(e._ex(e._ec),l);c=c._bd(this._fa._ba(g,y)),e=e._bd(s._dc(g,y))}o=c.multiply1(a)._bd(v),_=c.multiply1(w)._bd(u)}var A=_._ex(0);if(A==0)throw"ReedSolomonException sigmaTilde(0) was zero";var b=this._fa.inverse(A),m=_.multiply2(b),p=e.multiply2(b);return new Array(m,p)},this._ey=function(t){var n=t._ec;if(n==1)return new Array(t._ex(1));for(var r=new Array(n),i=0,s=1;s<256&&i1&&t[0]==0){for(var r=1;ro.length){var w=a;a=o,o=w}for(var _=new Array(o.length),f=o.length-a.length,v=0;v=e._ec&&!o.Zero;){var f=o._ec-e._ec,v=this._fa.multiply(o._ex(o._ec),_),u=e._dc(f,v),c=this._fa._ba(f,v);a=a._bd(c),o=o._bd(u)}return new Array(a,o)}}function _az(h){this._gh=new Array(256),this._gi=new Array(256);for(var t=1,n=0;n<256;n++)this._gh[n]=t,t<<=1,t>=256&&(t^=h);for(var n=0;n<255;n++)this._gi[this._gh[n]]=n;var r=new Array(1);r[0]=0,this.zero=new _bp(this,new Array(r));var i=new Array(1);i[0]=1,this.one=new _bp(this,new Array(i)),this.__defineGetter__("Zero",function(){return this.zero}),this.__defineGetter__("One",function(){return this.one}),this._ba=function(s,e){if(s<0)throw"bad arguments";if(e==0)return zero;for(var a=new Array(s+1),o=0;o-1&&(n=[{sourceId:i.deviceId}]),console.log(i.kind+": "+i.label+" id = "+i.deviceId)})})}catch(r){console.log(r)}else console.log("no navigator.mediaDevices.enumerateDevices");t.getUserMedia?t.getUserMedia({video:n,audio:!1},qrcode.vidSuccess,qrcode.vidError):t.webkitGetUserMedia?(qrcode.webkit=!0,t.webkitGetUserMedia({video:n,audio:!1},qrcode.vidSuccess,qrcode.vidError)):t.mozGetUserMedia&&(qrcode.moz=!0,t.mozGetUserMedia({video:n,audio:!1},qrcode.vidSuccess,qrcode.vidError))},qrcode.decode=function(h){if(arguments.length==0){if(qrcode.canvas_qr2)var t=qrcode.canvas_qr2,n=qrcode.qrcontext2;else var t=document.getElementById("qr-canvas"),n=t.getContext("2d");return qrcode.width=t.width,qrcode.height=t.height,qrcode.imagedata=n.getImageData(0,0,qrcode.width,qrcode.height),qrcode.result=qrcode.process(n),qrcode.callback!=null&&qrcode.callback(qrcode.result),qrcode.result}else{var r=new Image;r.crossOrigin="Anonymous",r.onload=function(){var i=document.getElementById("out-canvas");if(i!=null){var s=i.getContext("2d");s.clearRect(0,0,320,240),s.drawImage(r,0,0,320,240)}var e=document.createElement("canvas"),a=e.getContext("2d"),o=r.height,w=r.width;if(r.width*r.height>qrcode.maxImgSize){var _=r.width/r.height;o=Math.sqrt(qrcode.maxImgSize/_),w=_*o}e.width=w,e.height=o,a.drawImage(r,0,0,e.width,e.height),qrcode.width=e.width,qrcode.height=e.height;try{qrcode.imagedata=a.getImageData(0,0,e.width,e.height)}catch(f){qrcode.result="Cross domain image reading not supported in your browser! Save it to your computer then drag and drop the file!",qrcode.callback!=null&&qrcode.callback(qrcode.result);return}try{qrcode.result=qrcode.process(a)}catch(f){console.log(f),qrcode.result="error decoding QR Code"}qrcode.callback!=null&&qrcode.callback(qrcode.result)},r.onerror=function(){qrcode.callback!=null&&qrcode.callback("Failed to load the image")},r.src=h}},qrcode.isUrl=function(h){var t=/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;return t.test(h)},qrcode.decode_url=function(h){var t="";try{t=escape(h)}catch(r){console.log(r),t=h}var n="";try{n=decodeURIComponent(t)}catch(r){console.log(r),n=t}return n},qrcode.decode_utf8=function(h){return qrcode.isUrl(h)?qrcode.decode_url(h):h},qrcode.process=function(h){var t=new Date().getTime(),n=qrcode.grayScaleToBitmap(qrcode.grayscale());if(qrcode.debug){for(var r=0;ri[o][a][1]&&(i[o][a][1]=f)}}for(var v=new Array(t),u=0;u=0?h>>t:(h>>t)+(2<<~t)}var _gf=3,_eh=57,_el=8,_eg=2;qrcode._er=function(h){function t(_,f){var v=_.X-f.X,u=_.Y-f.Y;return Math.sqrt(v*v+u*u)}function n(_,f,v){var u=f.x,c=f.y;return(v.x-u)*(_.y-c)-(v.y-c)*(_.x-u)}var r=t(h[0],h[1]),i=t(h[1],h[2]),s=t(h[0],h[2]),e,a,o;if(i>=r&&i>=s?(a=h[0],e=h[1],o=h[2]):s>=i&&s>=r?(a=h[1],e=h[0],o=h[2]):(a=h[2],e=h[0],o=h[1]),n(e,a,o)<0){var w=e;e=o,o=w}h[0]=e,h[1]=a,h[2]=o};function _cz(h,t,n){this.x=h,this.y=t,this.count=1,this._aj=n,this.__defineGetter__("_ei",function(){return this._aj}),this.__defineGetter__("Count",function(){return this.count}),this.__defineGetter__("X",function(){return this.x}),this.__defineGetter__("Y",function(){return this.y}),this._ek=function(){this.count++},this._ev=function(r,i,s){if(Math.abs(i-this.y)<=r&&Math.abs(s-this.x)<=r){var e=Math.abs(r-this._aj);return e<=1||e/this._aj<=1}return!1}}function _es(h){this._go=h[0],this._gu=h[1],this._gr=h[2],this.__defineGetter__("_gp",function(){return this._go}),this.__defineGetter__("_gq",function(){return this._gu}),this.__defineGetter__("_gs",function(){return this._gr})}function _cc(){this.image=null,this._cv=[],this._ge=!1,this._al=new Array(0,0,0,0,0),this._am=null,this.__defineGetter__("_da",function(){return this._al[0]=0,this._al[1]=0,this._al[2]=0,this._al[3]=0,this._al[4]=0,this._al}),this._ao=function(h){for(var t=0,n=0;n<5;n++){var r=h[n];if(r==0)return!1;t+=r}if(t<7)return!1;var i=Math.floor((t<<_el)/7),s=Math.floor(i/2);return Math.abs(i-(h[0]<<_el))=0&&i[t+a*qrcode.width];)e[2]++,a--;if(a<0)return NaN;for(;a>=0&&!i[t+a*qrcode.width]&&e[1]<=n;)e[1]++,a--;if(a<0||e[1]>n)return NaN;for(;a>=0&&i[t+a*qrcode.width]&&e[0]<=n;)e[0]++,a--;if(e[0]>n)return NaN;for(a=h+1;a=n)return NaN;for(;a=n)return NaN;var o=e[0]+e[1]+e[2]+e[3]+e[4];return 5*Math.abs(o-r)>=2*r?NaN:this._ao(e)?this._an(e,a):NaN},this._ej=function(h,t,n,r){for(var i=this.image,s=qrcode.width,e=this._da,a=h;a>=0&&i[a+t*qrcode.width];)e[2]++,a--;if(a<0)return NaN;for(;a>=0&&!i[a+t*qrcode.width]&&e[1]<=n;)e[1]++,a--;if(a<0||e[1]>n)return NaN;for(;a>=0&&i[a+t*qrcode.width]&&e[0]<=n;)e[0]++,a--;if(e[0]>n)return NaN;for(a=h+1;a=n)return NaN;for(;a=n)return NaN;var o=e[0]+e[1]+e[2]+e[3]+e[4];return 5*Math.abs(o-r)>=r?NaN:this._ao(e)?this._an(e,a):NaN},this._cu=function(h,t,n){var r=h[0]+h[1]+h[2]+h[3]+h[4],i=this._an(h,n),s=this._ap(t,Math.floor(i),h[2],r);if(!isNaN(s)&&(i=this._ej(Math.floor(i),Math.floor(s),h[2],r),!isNaN(i))){for(var e=r/7,a=!1,o=this._cv.length,w=0;w3){for(var t=0,n=0,r=0;r=0;r--){var o=this._cv[r];Math.abs(o._ei-s)>a&&this._cv.splice(r,1)}}return this._cv.length>3&&this._cv.sort(function(w,_){return w.count>_.count?-1:w.count<_.count?1:0}),new Array(this._cv[0],this._cv[1],this._cv[2])},this._eq=function(){var h=this._cv.length;if(h<=1)return 0;for(var t=null,n=0;n=_eg)if(t==null)t=r;else return this._ge=!0,Math.floor((Math.abs(t.X-r.X)-Math.abs(t.Y-r.Y))/2)}return 0},this._cx=function(){for(var h=0,t=0,n=this._cv.length,r=0;r=_eg&&(h++,t+=i._ei)}if(h<3)return!1;for(var s=t/n,e=0,r=0;re[2]&&(a+=f-e[2]-i,w=r-1)}else{do w++;while(w=w)return!1;return!0},this._ap=function(a,o,w,_){var f=this.image,v=qrcode.height,u=this._al;u[0]=0,u[1]=0,u[2]=0;for(var c=a;c>=0&&f[o+c*qrcode.width]&&u[1]<=w;)u[1]++,c--;if(c<0||u[1]>w)return NaN;for(;c>=0&&!f[o+c*qrcode.width]&&u[0]<=w;)u[0]++,c--;if(u[0]>w)return NaN;for(c=a+1;cw)return NaN;for(;cw)return NaN;var d=u[0]+u[1]+u[2];return 5*Math.abs(d-_)>=2*_?NaN:this._ao(u)?this._an(u,c):NaN},this._cu=function(a,o,w){var _=a[0]+a[1]+a[2],f=this._an(a,w),v=this._ap(o,Math.floor(f),2*a[1],_);if(!isNaN(v)){for(var u=(a[0]+a[1]+a[2])/3,c=this._cv.length,d=0;d>1),f=new Array(0,0,0),v=0;v>1:-(v+1>>1));f[0]=0,f[1]=0,f[2]=0;for(var c=a;c=10&&t<=26?this.dataLengthMode=1:t>=27&&t<=40&&(this.dataLengthMode=2),this._gd=function(r){var i=0;if(r>this._cw-r+1,this._cw-=r,i}else if(r>8-(r-(this._cw+1)),this._cw=this._cw-r%8,this._cw<0&&(this._cw=8+this._cw),i}else if(r>8-(r-(this._cw+1+8));return i=w+_+f,this._cw=this._cw-(r-8)%8,this._cw<0&&(this._cw=8+this._cw),i}else return 0},this.NextMode=function(){return this._ed>this.blocks.length-this._en-2?0:this._gd(4)},this.getDataLength=function(r){for(var i=0;r>>i!=1;)i++;return this._gd(qrcode._eo[this.dataLengthMode][i])},this.getRomanAndFigureString=function(r){var i=r,s=0,e="",a=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":");do if(i>1){s=this._gd(11);var o=Math.floor(s/45),w=s%45;e+=a[o],e+=a[w],i-=2}else i==1&&(s=this._gd(6),e+=a[s],i-=1);while(i>0);return e},this.getFigureString=function(r){var i=r,s=0,e="";do i>=3?(s=this._gd(10),s<100&&(e+="0"),s<10&&(e+="0"),i-=3):i==2?(s=this._gd(7),s<10&&(e+="0"),i-=2):i==1&&(s=this._gd(4),i-=1),e+=s;while(i>0);return e},this.get8bitByteArray=function(r){var i=r,s=0,e=new Array;do s=this._gd(8),e.push(s),i--;while(i>0);return e},this.getKanjiString=function(r){var i=r,s=0,e="";do{s=_gd(13);var a=s%192,o=s/192,w=(o<<8)+a,_=0;w+33088<=40956?_=w+33088:_=w+49472,e+=String.fromCharCode(_),i--}while(i>0);return e},this.__defineGetter__("DataByte",function(){var r=new Array,i=1,s=2,e=4,a=8;do{var o=this.NextMode();if(o==0){if(r.length>0)break;throw"Empty data block"}if(o!=i&&o!=s&&o!=e&&o!=a)throw"Invalid mode: "+o+" in (block:"+this._ed+" bit:"+this._cw+")";var w=this.getDataLength(o);if(w<1)throw"Invalid data length: "+w;switch(o){case i:for(var _=this.getFigureString(w),f=new Array(_.length),v=0;v<_.length;v++)f[v]=_.charCodeAt(v);r.push(f);break;case s:for(var _=this.getRomanAndFigureString(w),f=new Array(_.length),v=0;v<_.length;v++)f[v]=_.charCodeAt(v);r.push(f);break;case e:var u=this.get8bitByteArray(w);r.push(u);break;case a:var _=this.getKanjiString(w);r.push(_);break}}while(!0);return r})}