@gohelpfund/insight-ui
Version:
An open-source frontend for the Insight API. The Insight API provides you with a convenient, powerful and simple way to query and broadcast data on the Help network and build your own services with it.
3 lines (2 loc) • 141 kB
JavaScript
/*! @gohelpfund/insight-ui 2.4.13 */
!function(){function renderImageToCanvas(img,canvas,options,doSquash){var iw=img.naturalWidth,ih=img.naturalHeight,width=options.width,height=options.height,ctx=canvas.getContext("2d");ctx.save(),function(canvas,width,height,orientation){switch(orientation){case 5:case 6:case 7:case 8:canvas.width=height,canvas.height=width;break;default:canvas.width=width,canvas.height=height}var ctx=canvas.getContext("2d");switch(orientation){case 2:ctx.translate(width,0),ctx.scale(-1,1);break;case 3:ctx.translate(width,height),ctx.rotate(Math.PI);break;case 4:ctx.translate(0,height),ctx.scale(1,-1);break;case 5:ctx.rotate(.5*Math.PI),ctx.scale(1,-1);break;case 6:ctx.rotate(.5*Math.PI),ctx.translate(0,-height);break;case 7:ctx.rotate(.5*Math.PI),ctx.translate(width,-height),ctx.scale(-1,1);break;case 8:ctx.rotate(-.5*Math.PI),ctx.translate(-width,0)}}(canvas,width,height,options.orientation),function(img){var iw=img.naturalWidth;if(1048576<iw*img.naturalHeight){var canvas=document.createElement("canvas");canvas.width=canvas.height=1;var ctx=canvas.getContext("2d");return ctx.drawImage(img,1-iw,0),0===ctx.getImageData(0,0,1,1).data[3]}return!1}(img)&&(iw/=2,ih/=2);var d=1024,tmpCanvas=document.createElement("canvas");tmpCanvas.width=tmpCanvas.height=d;for(var tmpCtx=tmpCanvas.getContext("2d"),vertSquashRatio=doSquash?function(img,iw,ih){var canvas=document.createElement("canvas");canvas.width=1,canvas.height=ih;var ctx=canvas.getContext("2d");ctx.drawImage(img,0,0);for(var data=ctx.getImageData(0,0,1,ih).data,sy=0,ey=ih,py=ih;sy<py;){0===data[4*(py-1)+3]?ey=py:sy=py,py=ey+sy>>1}var ratio=py/ih;return 0==ratio?1:ratio}(img,0,ih):1,dw=Math.ceil(d*width/iw),dh=Math.ceil(d*height/ih/vertSquashRatio),sy=0,dy=0;sy<ih;){for(var sx=0,dx=0;sx<iw;)tmpCtx.clearRect(0,0,d,d),tmpCtx.drawImage(img,-sx,-sy),ctx.drawImage(tmpCanvas,0,0,d,d,dx,dy,dw,dh),sx+=d,dx+=dw;sy+=d,dy+=dh}ctx.restore(),tmpCanvas=tmpCtx=null}function MegaPixImage(srcImage){if(window.Blob&&srcImage instanceof Blob){var img=new Image,URL=window.URL&&window.URL.createObjectURL?window.URL:window.webkitURL&&window.webkitURL.createObjectURL?window.webkitURL:null;if(!URL)throw Error("No createObjectURL function found to create blob url");img.src=URL.createObjectURL(srcImage),this.blob=srcImage,srcImage=img}if(!srcImage.naturalWidth&&!srcImage.naturalHeight){var _this=this;srcImage.onload=function(){var listeners=_this.imageLoadListeners;if(listeners){_this.imageLoadListeners=null;for(var i=0,len=listeners.length;i<len;i++)listeners[i]()}},this.imageLoadListeners=[]}this.srcImage=srcImage}MegaPixImage.prototype.render=function(target,options){if(this.imageLoadListeners){var _this=this;this.imageLoadListeners.push(function(){_this.render(target,options)})}else{options=options||{};var imgWidth=this.srcImage.naturalWidth,imgHeight=this.srcImage.naturalHeight,width=options.width,height=options.height,maxWidth=options.maxWidth,maxHeight=options.maxHeight,doSquash=!this.blob||"image/jpeg"===this.blob.type;width&&!height?height=imgHeight*width/imgWidth<<0:height&&!width?width=imgWidth*height/imgHeight<<0:(width=imgWidth,height=imgHeight),maxWidth&&maxWidth<width&&(height=imgHeight*(width=maxWidth)/imgWidth<<0),maxHeight&&maxHeight<height&&(width=imgWidth*(height=maxHeight)/imgHeight<<0);var opt={width:width,height:height};for(var k in options)opt[k]=options[k];var tagName=target.tagName.toLowerCase();"img"===tagName?target.src=function(img,options,doSquash){var canvas=document.createElement("canvas");return renderImageToCanvas(img,canvas,options,doSquash),canvas.toDataURL("image/jpeg",options.quality||.8)}(this.srcImage,opt,doSquash):"canvas"===tagName&&renderImageToCanvas(this.srcImage,target,opt,doSquash),"function"==typeof this.onrender&&this.onrender(target)}},"function"==typeof define&&define.amd?define([],function(){return MegaPixImage}):this.MegaPixImage=MegaPixImage}();var qrcode=function(){function qrcode(typeNumber,errorCorrectLevel){function makeImpl(test,maskPattern){_modules=function(moduleCount){for(var modules=new Array(moduleCount),row=0;row<moduleCount;row+=1){modules[row]=new Array(moduleCount);for(var col=0;col<moduleCount;col+=1)modules[row][col]=null}return modules}(_moduleCount=4*_typeNumber+17),setupPositionProbePattern(0,0),setupPositionProbePattern(_moduleCount-7,0),setupPositionProbePattern(0,_moduleCount-7),setupPositionAdjustPattern(),setupTimingPattern(),setupTypeInfo(test,maskPattern),7<=_typeNumber&&setupTypeNumber(test),null==_dataCache&&(_dataCache=createData(_typeNumber,_errorCorrectLevel,_dataList)),mapData(_dataCache,maskPattern)}var _typeNumber=typeNumber,_errorCorrectLevel=QRErrorCorrectLevel[errorCorrectLevel],_modules=null,_moduleCount=0,_dataCache=null,_dataList=new Array,_this={},setupPositionProbePattern=function(row,col){for(var r=-1;r<=7;r+=1)if(!(row+r<=-1||_moduleCount<=row+r))for(var c=-1;c<=7;c+=1)col+c<=-1||_moduleCount<=col+c||(_modules[row+r][col+c]=0<=r&&r<=6&&(0==c||6==c)||0<=c&&c<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=c&&c<=4)},setupTimingPattern=function(){for(var r=8;r<_moduleCount-8;r+=1)null==_modules[r][6]&&(_modules[r][6]=r%2==0);for(var c=8;c<_moduleCount-8;c+=1)null==_modules[6][c]&&(_modules[6][c]=c%2==0)},setupPositionAdjustPattern=function(){for(var pos=QRUtil.getPatternPosition(_typeNumber),i=0;i<pos.length;i+=1)for(var j=0;j<pos.length;j+=1){var row=pos[i],col=pos[j];if(null==_modules[row][col])for(var r=-2;r<=2;r+=1)for(var c=-2;c<=2;c+=1)_modules[row+r][col+c]=-2==r||2==r||-2==c||2==c||0==r&&0==c}},setupTypeNumber=function(test){for(var bits=QRUtil.getBCHTypeNumber(_typeNumber),i=0;i<18;i+=1){var mod=!test&&1==(bits>>i&1);_modules[Math.floor(i/3)][i%3+_moduleCount-8-3]=mod}for(i=0;i<18;i+=1){mod=!test&&1==(bits>>i&1);_modules[i%3+_moduleCount-8-3][Math.floor(i/3)]=mod}},setupTypeInfo=function(test,maskPattern){for(var data=_errorCorrectLevel<<3|maskPattern,bits=QRUtil.getBCHTypeInfo(data),i=0;i<15;i+=1){var mod=!test&&1==(bits>>i&1);i<6?_modules[i][8]=mod:i<8?_modules[i+1][8]=mod:_modules[_moduleCount-15+i][8]=mod}for(i=0;i<15;i+=1){mod=!test&&1==(bits>>i&1);i<8?_modules[8][_moduleCount-i-1]=mod:i<9?_modules[8][15-i-1+1]=mod:_modules[8][15-i-1]=mod}_modules[_moduleCount-8][8]=!test},mapData=function(data,maskPattern){for(var inc=-1,row=_moduleCount-1,bitIndex=7,byteIndex=0,maskFunc=QRUtil.getMaskFunction(maskPattern),col=_moduleCount-1;0<col;col-=2)for(6==col&&(col-=1);;){for(var c=0;c<2;c+=1)if(null==_modules[row][col-c]){var dark=!1;byteIndex<data.length&&(dark=1==(data[byteIndex]>>>bitIndex&1)),maskFunc(row,col-c)&&(dark=!dark),_modules[row][col-c]=dark,-1==(bitIndex-=1)&&(byteIndex+=1,bitIndex=7)}if((row+=inc)<0||_moduleCount<=row){row-=inc,inc=-inc;break}}},createData=function(typeNumber,errorCorrectLevel,dataList){for(var rsBlocks=QRRSBlock.getRSBlocks(typeNumber,errorCorrectLevel),buffer=qrBitBuffer(),i=0;i<dataList.length;i+=1){var data=dataList[i];buffer.put(data.getMode(),4),buffer.put(data.getLength(),QRUtil.getLengthInBits(data.getMode(),typeNumber)),data.write(buffer)}var totalDataCount=0;for(i=0;i<rsBlocks.length;i+=1)totalDataCount+=rsBlocks[i].dataCount;if(buffer.getLengthInBits()>8*totalDataCount)throw new Error("code length overflow. ("+buffer.getLengthInBits()+">"+8*totalDataCount+")");for(buffer.getLengthInBits()+4<=8*totalDataCount&&buffer.put(0,4);buffer.getLengthInBits()%8!=0;)buffer.putBit(!1);for(;!(buffer.getLengthInBits()>=8*totalDataCount||(buffer.put(236,8),buffer.getLengthInBits()>=8*totalDataCount));)buffer.put(17,8);return function(buffer,rsBlocks){for(var offset=0,maxDcCount=0,maxEcCount=0,dcdata=new Array(rsBlocks.length),ecdata=new Array(rsBlocks.length),r=0;r<rsBlocks.length;r+=1){var dcCount=rsBlocks[r].dataCount,ecCount=rsBlocks[r].totalCount-dcCount;maxDcCount=Math.max(maxDcCount,dcCount),maxEcCount=Math.max(maxEcCount,ecCount),dcdata[r]=new Array(dcCount);for(var i=0;i<dcdata[r].length;i+=1)dcdata[r][i]=255&buffer.getBuffer()[i+offset];offset+=dcCount;var rsPoly=QRUtil.getErrorCorrectPolynomial(ecCount),modPoly=qrPolynomial(dcdata[r],rsPoly.getLength()-1).mod(rsPoly);ecdata[r]=new Array(rsPoly.getLength()-1);for(i=0;i<ecdata[r].length;i+=1){var modIndex=i+modPoly.getLength()-ecdata[r].length;ecdata[r][i]=0<=modIndex?modPoly.getAt(modIndex):0}}var totalCodeCount=0;for(i=0;i<rsBlocks.length;i+=1)totalCodeCount+=rsBlocks[i].totalCount;var data=new Array(totalCodeCount),index=0;for(i=0;i<maxDcCount;i+=1)for(r=0;r<rsBlocks.length;r+=1)i<dcdata[r].length&&(data[index]=dcdata[r][i],index+=1);for(i=0;i<maxEcCount;i+=1)for(r=0;r<rsBlocks.length;r+=1)i<ecdata[r].length&&(data[index]=ecdata[r][i],index+=1);return data}(buffer,rsBlocks)};return _this.addData=function(data){var newData=qr8BitByte(data);_dataList.push(newData),_dataCache=null},_this.isDark=function(row,col){if(row<0||_moduleCount<=row||col<0||_moduleCount<=col)throw new Error(row+","+col);return _modules[row][col]},_this.getModuleCount=function(){return _moduleCount},_this.make=function(){makeImpl(!1,function(){for(var minLostPoint=0,pattern=0,i=0;i<8;i+=1){makeImpl(!0,i);var lostPoint=QRUtil.getLostPoint(_this);(0==i||lostPoint<minLostPoint)&&(minLostPoint=lostPoint,pattern=i)}return pattern}())},_this.createTableTag=function(cellSize,margin){cellSize=cellSize||2;var qrHtml="";qrHtml+='<table style="',qrHtml+=" border-width: 0px; border-style: none;",qrHtml+=" border-collapse: collapse;",qrHtml+=" padding: 0px; margin: "+(margin=void 0===margin?4*cellSize:margin)+"px;",qrHtml+='">',qrHtml+="<tbody>";for(var r=0;r<_this.getModuleCount();r+=1){qrHtml+="<tr>";for(var c=0;c<_this.getModuleCount();c+=1)qrHtml+='<td style="',qrHtml+=" border-width: 0px; border-style: none;",qrHtml+=" border-collapse: collapse;",qrHtml+=" padding: 0px; margin: 0px;",qrHtml+=" width: "+cellSize+"px;",qrHtml+=" height: "+cellSize+"px;",qrHtml+=" background-color: ",qrHtml+=_this.isDark(r,c)?"#000000":"#ffffff",qrHtml+=";",qrHtml+='"/>';qrHtml+="</tr>"}return qrHtml+="</tbody>",qrHtml+="</table>"},_this.createImgTag=function(cellSize,margin){cellSize=cellSize||2,margin=void 0===margin?4*cellSize:margin;var size=_this.getModuleCount()*cellSize+2*margin,min=margin,max=size-margin;return createImgTag(size,size,function(x,y){if(min<=x&&x<max&&min<=y&&y<max){var c=Math.floor((x-min)/cellSize),r=Math.floor((y-min)/cellSize);return _this.isDark(r,c)?0:1}return 1})},_this}qrcode.stringToBytes=function(s){for(var bytes=new Array,i=0;i<s.length;i+=1){var c=s.charCodeAt(i);bytes.push(255&c)}return bytes},qrcode.createStringToBytes=function(unicodeData,numChars){var unicodeMap=function(){function read(){var b=bin.read();if(-1==b)throw new Error;return b}for(var bin=base64DecodeInputStream(unicodeData),count=0,unicodeMap={};;){var b0=bin.read();if(-1==b0)break;var b1=read(),v=read()<<8|read();unicodeMap[String.fromCharCode(b0<<8|b1)]=v,count+=1}if(count!=numChars)throw new Error(count+" != "+numChars);return unicodeMap}(),unknownChar="?".charCodeAt(0);return function(s){for(var bytes=new Array,i=0;i<s.length;i+=1){var c=s.charCodeAt(i);if(c<128)bytes.push(c);else{var b=unicodeMap[s.charAt(i)];"number"==typeof b?(255&b)==b?bytes.push(b):(bytes.push(b>>>8),bytes.push(255&b)):bytes.push(unknownChar)}}return bytes}};var PATTERN_POSITION_TABLE,_this,QRMode_MODE_NUMBER=1,QRMode_MODE_ALPHA_NUM=2,QRMode_MODE_8BIT_BYTE=4,QRMode_MODE_KANJI=8,QRErrorCorrectLevel={L:1,M:0,Q:3,H:2},QRMaskPattern_PATTERN000=0,QRMaskPattern_PATTERN001=1,QRMaskPattern_PATTERN010=2,QRMaskPattern_PATTERN011=3,QRMaskPattern_PATTERN100=4,QRMaskPattern_PATTERN101=5,QRMaskPattern_PATTERN110=6,QRMaskPattern_PATTERN111=7,QRUtil=(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]],(_this={}).getBCHTypeInfo=function(data){for(var d=data<<10;0<=getBCHDigit(d)-getBCHDigit(1335);)d^=1335<<getBCHDigit(d)-getBCHDigit(1335);return 21522^(data<<10|d)},_this.getBCHTypeNumber=function(data){for(var d=data<<12;0<=getBCHDigit(d)-getBCHDigit(7973);)d^=7973<<getBCHDigit(d)-getBCHDigit(7973);return data<<12|d},_this.getPatternPosition=function(typeNumber){return PATTERN_POSITION_TABLE[typeNumber-1]},_this.getMaskFunction=function(maskPattern){switch(maskPattern){case QRMaskPattern_PATTERN000:return function(i,j){return(i+j)%2==0};case QRMaskPattern_PATTERN001:return function(i,j){return i%2==0};case QRMaskPattern_PATTERN010:return function(i,j){return j%3==0};case QRMaskPattern_PATTERN011:return function(i,j){return(i+j)%3==0};case QRMaskPattern_PATTERN100:return function(i,j){return(Math.floor(i/2)+Math.floor(j/3))%2==0};case QRMaskPattern_PATTERN101:return function(i,j){return i*j%2+i*j%3==0};case QRMaskPattern_PATTERN110:return function(i,j){return(i*j%2+i*j%3)%2==0};case QRMaskPattern_PATTERN111:return function(i,j){return(i*j%3+(i+j)%2)%2==0};default:throw new Error("bad maskPattern:"+maskPattern)}},_this.getErrorCorrectPolynomial=function(errorCorrectLength){for(var a=qrPolynomial([1],0),i=0;i<errorCorrectLength;i+=1)a=a.multiply(qrPolynomial([1,QRMath.gexp(i)],0));return a},_this.getLengthInBits=function(mode,type){if(1<=type&&type<10)switch(mode){case QRMode_MODE_NUMBER:return 10;case QRMode_MODE_ALPHA_NUM:return 9;case QRMode_MODE_8BIT_BYTE:case QRMode_MODE_KANJI:return 8;default:throw new Error("mode:"+mode)}else if(type<27)switch(mode){case QRMode_MODE_NUMBER:return 12;case QRMode_MODE_ALPHA_NUM:return 11;case QRMode_MODE_8BIT_BYTE:return 16;case QRMode_MODE_KANJI:return 10;default:throw new Error("mode:"+mode)}else{if(!(type<41))throw new Error("type:"+type);switch(mode){case QRMode_MODE_NUMBER:return 14;case QRMode_MODE_ALPHA_NUM:return 13;case QRMode_MODE_8BIT_BYTE:return 16;case QRMode_MODE_KANJI:return 12;default:throw new Error("mode:"+mode)}}},_this.getLostPoint=function(qrcode){for(var moduleCount=qrcode.getModuleCount(),lostPoint=0,row=0;row<moduleCount;row+=1)for(var col=0;col<moduleCount;col+=1){for(var sameCount=0,dark=qrcode.isDark(row,col),r=-1;r<=1;r+=1)if(!(row+r<0||moduleCount<=row+r))for(var c=-1;c<=1;c+=1)col+c<0||moduleCount<=col+c||0==r&&0==c||dark==qrcode.isDark(row+r,col+c)&&(sameCount+=1);5<sameCount&&(lostPoint+=3+sameCount-5)}for(row=0;row<moduleCount-1;row+=1)for(col=0;col<moduleCount-1;col+=1){var count=0;qrcode.isDark(row,col)&&(count+=1),qrcode.isDark(row+1,col)&&(count+=1),qrcode.isDark(row,col+1)&&(count+=1),qrcode.isDark(row+1,col+1)&&(count+=1),0!=count&&4!=count||(lostPoint+=3)}for(row=0;row<moduleCount;row+=1)for(col=0;col<moduleCount-6;col+=1)qrcode.isDark(row,col)&&!qrcode.isDark(row,col+1)&&qrcode.isDark(row,col+2)&&qrcode.isDark(row,col+3)&&qrcode.isDark(row,col+4)&&!qrcode.isDark(row,col+5)&&qrcode.isDark(row,col+6)&&(lostPoint+=40);for(col=0;col<moduleCount;col+=1)for(row=0;row<moduleCount-6;row+=1)qrcode.isDark(row,col)&&!qrcode.isDark(row+1,col)&&qrcode.isDark(row+2,col)&&qrcode.isDark(row+3,col)&&qrcode.isDark(row+4,col)&&!qrcode.isDark(row+5,col)&&qrcode.isDark(row+6,col)&&(lostPoint+=40);var darkCount=0;for(col=0;col<moduleCount;col+=1)for(row=0;row<moduleCount;row+=1)qrcode.isDark(row,col)&&(darkCount+=1);return lostPoint+=Math.abs(100*darkCount/moduleCount/moduleCount-50)/5*10},_this);function getBCHDigit(data){for(var digit=0;0!=data;)digit+=1,data>>>=1;return digit}var QRMath=function(){for(var EXP_TABLE=new Array(256),LOG_TABLE=new Array(256),i=0;i<8;i+=1)EXP_TABLE[i]=1<<i;for(i=8;i<256;i+=1)EXP_TABLE[i]=EXP_TABLE[i-4]^EXP_TABLE[i-5]^EXP_TABLE[i-6]^EXP_TABLE[i-8];for(i=0;i<255;i+=1)LOG_TABLE[EXP_TABLE[i]]=i;var _this={glog:function(n){if(n<1)throw new Error("glog("+n+")");return LOG_TABLE[n]},gexp:function(n){for(;n<0;)n+=255;for(;256<=n;)n-=255;return EXP_TABLE[n]}};return _this}();function qrPolynomial(num,shift){if(void 0===num.length)throw new Error(num.length+"/"+shift);var _num=function(){for(var offset=0;offset<num.length&&0==num[offset];)offset+=1;for(var _num=new Array(num.length-offset+shift),i=0;i<num.length-offset;i+=1)_num[i]=num[i+offset];return _num}(),_this={getAt:function(index){return _num[index]},getLength:function(){return _num.length},multiply:function(e){for(var num=new Array(_this.getLength()+e.getLength()-1),i=0;i<_this.getLength();i+=1)for(var j=0;j<e.getLength();j+=1)num[i+j]^=QRMath.gexp(QRMath.glog(_this.getAt(i))+QRMath.glog(e.getAt(j)));return qrPolynomial(num,0)},mod:function(e){if(_this.getLength()-e.getLength()<0)return _this;for(var ratio=QRMath.glog(_this.getAt(0))-QRMath.glog(e.getAt(0)),num=new Array(_this.getLength()),i=0;i<_this.getLength();i+=1)num[i]=_this.getAt(i);for(i=0;i<e.getLength();i+=1)num[i]^=QRMath.gexp(QRMath.glog(e.getAt(i))+ratio);return qrPolynomial(num,0).mod(e)}};return _this}function byteArrayOutputStream(){var _bytes=new Array,_this={writeByte:function(b){_bytes.push(255&b)},writeShort:function(i){_this.writeByte(i),_this.writeByte(i>>>8)},writeBytes:function(b,off,len){off=off||0,len=len||b.length;for(var i=0;i<len;i+=1)_this.writeByte(b[i+off])},writeString:function(s){for(var i=0;i<s.length;i+=1)_this.writeByte(s.charCodeAt(i))},toByteArray:function(){return _bytes},toString:function(){var s="";s+="[";for(var i=0;i<_bytes.length;i+=1)0<i&&(s+=","),s+=_bytes[i];return s+="]"}};return _this}function gifImage(width,height){var _width=width,_height=height,_data=new Array(width*height),_this={setPixel:function(x,y,pixel){_data[y*_width+x]=pixel},write:function(out){out.writeString("GIF87a"),out.writeShort(_width),out.writeShort(_height),out.writeByte(128),out.writeByte(0),out.writeByte(0),out.writeByte(0),out.writeByte(0),out.writeByte(0),out.writeByte(255),out.writeByte(255),out.writeByte(255),out.writeString(","),out.writeShort(0),out.writeShort(0),out.writeShort(_width),out.writeShort(_height),out.writeByte(0);var raster=getLZWRaster(2);out.writeByte(2);for(var offset=0;255<raster.length-offset;)out.writeByte(255),out.writeBytes(raster,offset,255),offset+=255;out.writeByte(raster.length-offset),out.writeBytes(raster,offset,raster.length-offset),out.writeByte(0),out.writeString(";")}},getLZWRaster=function(lzwMinCodeSize){for(var clearCode=1<<lzwMinCodeSize,endCode=1+(1<<lzwMinCodeSize),bitLength=lzwMinCodeSize+1,table=lzwTable(),i=0;i<clearCode;i+=1)table.add(String.fromCharCode(i));table.add(String.fromCharCode(clearCode)),table.add(String.fromCharCode(endCode));var byteOut=byteArrayOutputStream(),bitOut=function(out){var _out=out,_bitLength=0,_bitBuffer=0,_this={write:function(data,length){if(data>>>length!=0)throw new Error("length over");for(;8<=_bitLength+length;)_out.writeByte(255&(data<<_bitLength|_bitBuffer)),length-=8-_bitLength,data>>>=8-_bitLength,_bitLength=_bitBuffer=0;_bitBuffer|=data<<_bitLength,_bitLength+=length},flush:function(){0<_bitLength&&_out.writeByte(_bitBuffer)}};return _this}(byteOut);bitOut.write(clearCode,bitLength);var dataIndex=0,s=String.fromCharCode(_data[dataIndex]);for(dataIndex+=1;dataIndex<_data.length;){var c=String.fromCharCode(_data[dataIndex]);dataIndex+=1,table.contains(s+c)?s+=c:(bitOut.write(table.indexOf(s),bitLength),table.size()<4095&&(table.size()==1<<bitLength&&(bitLength+=1),table.add(s+c)),s=c)}return bitOut.write(table.indexOf(s),bitLength),bitOut.write(endCode,bitLength),bitOut.flush(),byteOut.toByteArray()},lzwTable=function(){var _map={},_size=0,_this={add:function(key){if(_this.contains(key))throw new Error("dup key:"+key);_map[key]=_size,_size+=1},size:function(){return _size},indexOf:function(key){return _map[key]},contains:function(key){return void 0!==_map[key]}};return _this};return _this}var QRRSBlock=function(){function qrRSBlock(totalCount,dataCount){var _this={};return _this.totalCount=totalCount,_this.dataCount=dataCount,_this}var 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]],_this={};return _this.getRSBlocks=function(typeNumber,errorCorrectLevel){var rsBlock=function(typeNumber,errorCorrectLevel){switch(errorCorrectLevel){case QRErrorCorrectLevel.L:return RS_BLOCK_TABLE[4*(typeNumber-1)+0];case QRErrorCorrectLevel.M:return RS_BLOCK_TABLE[4*(typeNumber-1)+1];case QRErrorCorrectLevel.Q:return RS_BLOCK_TABLE[4*(typeNumber-1)+2];case QRErrorCorrectLevel.H:return RS_BLOCK_TABLE[4*(typeNumber-1)+3];default:return}}(typeNumber,errorCorrectLevel);if(void 0===rsBlock)throw new Error("bad rs block @ typeNumber:"+typeNumber+"/errorCorrectLevel:"+errorCorrectLevel);for(var length=rsBlock.length/3,list=new Array,i=0;i<length;i+=1)for(var count=rsBlock[3*i+0],totalCount=rsBlock[3*i+1],dataCount=rsBlock[3*i+2],j=0;j<count;j+=1)list.push(qrRSBlock(totalCount,dataCount));return list},_this}(),qrBitBuffer=function(){var _buffer=new Array,_length=0,_this={getBuffer:function(){return _buffer},getAt:function(index){var bufIndex=Math.floor(index/8);return 1==(_buffer[bufIndex]>>>7-index%8&1)},put:function(num,length){for(var i=0;i<length;i+=1)_this.putBit(1==(num>>>length-i-1&1))},getLengthInBits:function(){return _length},putBit:function(bit){var bufIndex=Math.floor(_length/8);_buffer.length<=bufIndex&&_buffer.push(0),bit&&(_buffer[bufIndex]|=128>>>_length%8),_length+=1}};return _this},qr8BitByte=function(data){var _mode=QRMode_MODE_8BIT_BYTE,_bytes=qrcode.stringToBytes(data),_this={getMode:function(){return _mode},getLength:function(buffer){return _bytes.length},write:function(buffer){for(var i=0;i<_bytes.length;i+=1)buffer.put(_bytes[i],8)}};return _this},base64DecodeInputStream=function(str){var _str=str,_pos=0,_buffer=0,_buflen=0,_this={read:function(){for(;_buflen<8;){if(_pos>=_str.length){if(0==_buflen)return-1;throw new Error("unexpected end of file./"+_buflen)}var c=_str.charAt(_pos);if(_pos+=1,"="==c)return _buflen=0,-1;c.match(/^\s$/)||(_buffer=_buffer<<6|decode(c.charCodeAt(0)),_buflen+=6)}var n=_buffer>>>_buflen-8&255;return _buflen-=8,n}},decode=function(c){if(65<=c&&c<=90)return c-65;if(97<=c&&c<=122)return c-97+26;if(48<=c&&c<=57)return c-48+52;if(43==c)return 62;if(47==c)return 63;throw new Error("c:"+c)};return _this},createImgTag=function(width,height,getPixel,alt){for(var gif=gifImage(width,height),y=0;y<height;y+=1)for(var x=0;x<width;x+=1)gif.setPixel(x,y,getPixel(x,y));var b=byteArrayOutputStream();gif.write(b);for(var base64=function(){function writeEncoded(b){_base64+=String.fromCharCode(encode(63&b))}var _buffer=0,_buflen=0,_length=0,_base64="",_this={},encode=function(n){if(n<0);else{if(n<26)return 65+n;if(n<52)return n-26+97;if(n<62)return n-52+48;if(62==n)return 43;if(63==n)return 47}throw new Error("n:"+n)};return _this.writeByte=function(n){for(_buffer=_buffer<<8|255&n,_buflen+=8,_length+=1;6<=_buflen;)writeEncoded(_buffer>>>_buflen-6),_buflen-=6},_this.flush=function(){if(0<_buflen&&(writeEncoded(_buffer<<6-_buflen),_buflen=_buffer=0),_length%3!=0)for(var padlen=3-_length%3,i=0;i<padlen;i+=1)_base64+="="},_this.toString=function(){return _base64},_this}(),bytes=b.toByteArray(),i=0;i<bytes.length;i+=1)base64.writeByte(bytes[i]);base64.flush();var img="";return img+="<img",img+=' src="',img+="data:image/gif;base64,",img+=base64,img+='"',img+=' width="',img+=width,img+='"',img+=' height="',img+=height,img+='"',alt&&(img+=' alt="',img+=alt,img+='"'),img+="/>"};return qrcode}();function ECB(count,dataCodewords){this.count=count,this.dataCodewords=dataCodewords,this.__defineGetter__("Count",function(){return this.count}),this.__defineGetter__("DataCodewords",function(){return this.dataCodewords})}function ECBlocks(ecCodewordsPerBlock,ecBlocks1,ecBlocks2){this.ecCodewordsPerBlock=ecCodewordsPerBlock,this.ecBlocks=ecBlocks2?new Array(ecBlocks1,ecBlocks2):new Array(ecBlocks1),this.__defineGetter__("ECCodewordsPerBlock",function(){return this.ecCodewordsPerBlock}),this.__defineGetter__("TotalECCodewords",function(){return this.ecCodewordsPerBlock*this.NumBlocks}),this.__defineGetter__("NumBlocks",function(){for(var total=0,i=0;i<this.ecBlocks.length;i++)total+=this.ecBlocks[i].length;return total}),this.getECBlocks=function(){return this.ecBlocks}}function Version(versionNumber,alignmentPatternCenters,ecBlocks1,ecBlocks2,ecBlocks3,ecBlocks4){this.versionNumber=versionNumber,this.alignmentPatternCenters=alignmentPatternCenters,this.ecBlocks=new Array(ecBlocks1,ecBlocks2,ecBlocks3,ecBlocks4);for(var total=0,ecCodewords=ecBlocks1.ECCodewordsPerBlock,ecbArray=ecBlocks1.getECBlocks(),i=0;i<ecbArray.length;i++){var ecBlock=ecbArray[i];total+=ecBlock.Count*(ecBlock.DataCodewords+ecCodewords)}this.totalCodewords=total,this.__defineGetter__("VersionNumber",function(){return this.versionNumber}),this.__defineGetter__("AlignmentPatternCenters",function(){return this.alignmentPatternCenters}),this.__defineGetter__("TotalCodewords",function(){return this.totalCodewords}),this.__defineGetter__("DimensionForVersion",function(){return 17+4*this.versionNumber}),this.buildFunctionPattern=function(){var dimension=this.DimensionForVersion,bitMatrix=new BitMatrix(dimension);bitMatrix.setRegion(0,0,9,9),bitMatrix.setRegion(dimension-8,0,8,9),bitMatrix.setRegion(0,dimension-8,9,8);for(var max=this.alignmentPatternCenters.length,x=0;x<max;x++)for(var i=this.alignmentPatternCenters[x]-2,y=0;y<max;y++)0==x&&(0==y||y==max-1)||x==max-1&&0==y||bitMatrix.setRegion(this.alignmentPatternCenters[y]-2,i,5,5);return bitMatrix.setRegion(6,9,1,dimension-17),bitMatrix.setRegion(9,6,dimension-17,1),6<this.versionNumber&&(bitMatrix.setRegion(dimension-11,0,3,6),bitMatrix.setRegion(0,dimension-11,6,3)),bitMatrix},this.getECBlocksForLevel=function(ecLevel){return this.ecBlocks[ecLevel.ordinal()]}}function buildVersions(){return new Array(new Version(1,new Array,new ECBlocks(7,new ECB(1,19)),new ECBlocks(10,new ECB(1,16)),new ECBlocks(13,new ECB(1,13)),new ECBlocks(17,new ECB(1,9))),new Version(2,new Array(6,18),new ECBlocks(10,new ECB(1,34)),new ECBlocks(16,new ECB(1,28)),new ECBlocks(22,new ECB(1,22)),new ECBlocks(28,new ECB(1,16))),new Version(3,new Array(6,22),new ECBlocks(15,new ECB(1,55)),new ECBlocks(26,new ECB(1,44)),new ECBlocks(18,new ECB(2,17)),new ECBlocks(22,new ECB(2,13))),new Version(4,new Array(6,26),new ECBlocks(20,new ECB(1,80)),new ECBlocks(18,new ECB(2,32)),new ECBlocks(26,new ECB(2,24)),new ECBlocks(16,new ECB(4,9))),new Version(5,new Array(6,30),new ECBlocks(26,new ECB(1,108)),new ECBlocks(24,new ECB(2,43)),new ECBlocks(18,new ECB(2,15),new ECB(2,16)),new ECBlocks(22,new ECB(2,11),new ECB(2,12))),new Version(6,new Array(6,34),new ECBlocks(18,new ECB(2,68)),new ECBlocks(16,new ECB(4,27)),new ECBlocks(24,new ECB(4,19)),new ECBlocks(28,new ECB(4,15))),new Version(7,new Array(6,22,38),new ECBlocks(20,new ECB(2,78)),new ECBlocks(18,new ECB(4,31)),new ECBlocks(18,new ECB(2,14),new ECB(4,15)),new ECBlocks(26,new ECB(4,13),new ECB(1,14))),new Version(8,new Array(6,24,42),new ECBlocks(24,new ECB(2,97)),new ECBlocks(22,new ECB(2,38),new ECB(2,39)),new ECBlocks(22,new ECB(4,18),new ECB(2,19)),new ECBlocks(26,new ECB(4,14),new ECB(2,15))),new Version(9,new Array(6,26,46),new ECBlocks(30,new ECB(2,116)),new ECBlocks(22,new ECB(3,36),new ECB(2,37)),new ECBlocks(20,new ECB(4,16),new ECB(4,17)),new ECBlocks(24,new ECB(4,12),new ECB(4,13))),new Version(10,new Array(6,28,50),new ECBlocks(18,new ECB(2,68),new ECB(2,69)),new ECBlocks(26,new ECB(4,43),new ECB(1,44)),new ECBlocks(24,new ECB(6,19),new ECB(2,20)),new ECBlocks(28,new ECB(6,15),new ECB(2,16))),new Version(11,new Array(6,30,54),new ECBlocks(20,new ECB(4,81)),new ECBlocks(30,new ECB(1,50),new ECB(4,51)),new ECBlocks(28,new ECB(4,22),new ECB(4,23)),new ECBlocks(24,new ECB(3,12),new ECB(8,13))),new Version(12,new Array(6,32,58),new ECBlocks(24,new ECB(2,92),new ECB(2,93)),new ECBlocks(22,new ECB(6,36),new ECB(2,37)),new ECBlocks(26,new ECB(4,20),new ECB(6,21)),new ECBlocks(28,new ECB(7,14),new ECB(4,15))),new Version(13,new Array(6,34,62),new ECBlocks(26,new ECB(4,107)),new ECBlocks(22,new ECB(8,37),new ECB(1,38)),new ECBlocks(24,new ECB(8,20),new ECB(4,21)),new ECBlocks(22,new ECB(12,11),new ECB(4,12))),new Version(14,new Array(6,26,46,66),new ECBlocks(30,new ECB(3,115),new ECB(1,116)),new ECBlocks(24,new ECB(4,40),new ECB(5,41)),new ECBlocks(20,new ECB(11,16),new ECB(5,17)),new ECBlocks(24,new ECB(11,12),new ECB(5,13))),new Version(15,new Array(6,26,48,70),new ECBlocks(22,new ECB(5,87),new ECB(1,88)),new ECBlocks(24,new ECB(5,41),new ECB(5,42)),new ECBlocks(30,new ECB(5,24),new ECB(7,25)),new ECBlocks(24,new ECB(11,12),new ECB(7,13))),new Version(16,new Array(6,26,50,74),new ECBlocks(24,new ECB(5,98),new ECB(1,99)),new ECBlocks(28,new ECB(7,45),new ECB(3,46)),new ECBlocks(24,new ECB(15,19),new ECB(2,20)),new ECBlocks(30,new ECB(3,15),new ECB(13,16))),new Version(17,new Array(6,30,54,78),new ECBlocks(28,new ECB(1,107),new ECB(5,108)),new ECBlocks(28,new ECB(10,46),new ECB(1,47)),new ECBlocks(28,new ECB(1,22),new ECB(15,23)),new ECBlocks(28,new ECB(2,14),new ECB(17,15))),new Version(18,new Array(6,30,56,82),new ECBlocks(30,new ECB(5,120),new ECB(1,121)),new ECBlocks(26,new ECB(9,43),new ECB(4,44)),new ECBlocks(28,new ECB(17,22),new ECB(1,23)),new ECBlocks(28,new ECB(2,14),new ECB(19,15))),new Version(19,new Array(6,30,58,86),new ECBlocks(28,new ECB(3,113),new ECB(4,114)),new ECBlocks(26,new ECB(3,44),new ECB(11,45)),new ECBlocks(26,new ECB(17,21),new ECB(4,22)),new ECBlocks(26,new ECB(9,13),new ECB(16,14))),new Version(20,new Array(6,34,62,90),new ECBlocks(28,new ECB(3,107),new ECB(5,108)),new ECBlocks(26,new ECB(3,41),new ECB(13,42)),new ECBlocks(30,new ECB(15,24),new ECB(5,25)),new ECBlocks(28,new ECB(15,15),new ECB(10,16))),new Version(21,new Array(6,28,50,72,94),new ECBlocks(28,new ECB(4,116),new ECB(4,117)),new ECBlocks(26,new ECB(17,42)),new ECBlocks(28,new ECB(17,22),new ECB(6,23)),new ECBlocks(30,new ECB(19,16),new ECB(6,17))),new Version(22,new Array(6,26,50,74,98),new ECBlocks(28,new ECB(2,111),new ECB(7,112)),new ECBlocks(28,new ECB(17,46)),new ECBlocks(30,new ECB(7,24),new ECB(16,25)),new ECBlocks(24,new ECB(34,13))),new Version(23,new Array(6,30,54,74,102),new ECBlocks(30,new ECB(4,121),new ECB(5,122)),new ECBlocks(28,new ECB(4,47),new ECB(14,48)),new ECBlocks(30,new ECB(11,24),new ECB(14,25)),new ECBlocks(30,new ECB(16,15),new ECB(14,16))),new Version(24,new Array(6,28,54,80,106),new ECBlocks(30,new ECB(6,117),new ECB(4,118)),new ECBlocks(28,new ECB(6,45),new ECB(14,46)),new ECBlocks(30,new ECB(11,24),new ECB(16,25)),new ECBlocks(30,new ECB(30,16),new ECB(2,17))),new Version(25,new Array(6,32,58,84,110),new ECBlocks(26,new ECB(8,106),new ECB(4,107)),new ECBlocks(28,new ECB(8,47),new ECB(13,48)),new ECBlocks(30,new ECB(7,24),new ECB(22,25)),new ECBlocks(30,new ECB(22,15),new ECB(13,16))),new Version(26,new Array(6,30,58,86,114),new ECBlocks(28,new ECB(10,114),new ECB(2,115)),new ECBlocks(28,new ECB(19,46),new ECB(4,47)),new ECBlocks(28,new ECB(28,22),new ECB(6,23)),new ECBlocks(30,new ECB(33,16),new ECB(4,17))),new Version(27,new Array(6,34,62,90,118),new ECBlocks(30,new ECB(8,122),new ECB(4,123)),new ECBlocks(28,new ECB(22,45),new ECB(3,46)),new ECBlocks(30,new ECB(8,23),new ECB(26,24)),new ECBlocks(30,new ECB(12,15),new ECB(28,16))),new Version(28,new Array(6,26,50,74,98,122),new ECBlocks(30,new ECB(3,117),new ECB(10,118)),new ECBlocks(28,new ECB(3,45),new ECB(23,46)),new ECBlocks(30,new ECB(4,24),new ECB(31,25)),new ECBlocks(30,new ECB(11,15),new ECB(31,16))),new Version(29,new Array(6,30,54,78,102,126),new ECBlocks(30,new ECB(7,116),new ECB(7,117)),new ECBlocks(28,new ECB(21,45),new ECB(7,46)),new ECBlocks(30,new ECB(1,23),new ECB(37,24)),new ECBlocks(30,new ECB(19,15),new ECB(26,16))),new Version(30,new Array(6,26,52,78,104,130),new ECBlocks(30,new ECB(5,115),new ECB(10,116)),new ECBlocks(28,new ECB(19,47),new ECB(10,48)),new ECBlocks(30,new ECB(15,24),new ECB(25,25)),new ECBlocks(30,new ECB(23,15),new ECB(25,16))),new Version(31,new Array(6,30,56,82,108,134),new ECBlocks(30,new ECB(13,115),new ECB(3,116)),new ECBlocks(28,new ECB(2,46),new ECB(29,47)),new ECBlocks(30,new ECB(42,24),new ECB(1,25)),new ECBlocks(30,new ECB(23,15),new ECB(28,16))),new Version(32,new Array(6,34,60,86,112,138),new ECBlocks(30,new ECB(17,115)),new ECBlocks(28,new ECB(10,46),new ECB(23,47)),new ECBlocks(30,new ECB(10,24),new ECB(35,25)),new ECBlocks(30,new ECB(19,15),new ECB(35,16))),new Version(33,new Array(6,30,58,86,114,142),new ECBlocks(30,new ECB(17,115),new ECB(1,116)),new ECBlocks(28,new ECB(14,46),new ECB(21,47)),new ECBlocks(30,new ECB(29,24),new ECB(19,25)),new ECBlocks(30,new ECB(11,15),new ECB(46,16))),new Version(34,new Array(6,34,62,90,118,146),new ECBlocks(30,new ECB(13,115),new ECB(6,116)),new ECBlocks(28,new ECB(14,46),new ECB(23,47)),new ECBlocks(30,new ECB(44,24),new ECB(7,25)),new ECBlocks(30,new ECB(59,16),new ECB(1,17))),new Version(35,new Array(6,30,54,78,102,126,150),new ECBlocks(30,new ECB(12,121),new ECB(7,122)),new ECBlocks(28,new ECB(12,47),new ECB(26,48)),new ECBlocks(30,new ECB(39,24),new ECB(14,25)),new ECBlocks(30,new ECB(22,15),new ECB(41,16))),new Version(36,new Array(6,24,50,76,102,128,154),new ECBlocks(30,new ECB(6,121),new ECB(14,122)),new ECBlocks(28,new ECB(6,47),new ECB(34,48)),new ECBlocks(30,new ECB(46,24),new ECB(10,25)),new ECBlocks(30,new ECB(2,15),new ECB(64,16))),new Version(37,new Array(6,28,54,80,106,132,158),new ECBlocks(30,new ECB(17,122),new ECB(4,123)),new ECBlocks(28,new ECB(29,46),new ECB(14,47)),new ECBlocks(30,new ECB(49,24),new ECB(10,25)),new ECBlocks(30,new ECB(24,15),new ECB(46,16))),new Version(38,new Array(6,32,58,84,110,136,162),new ECBlocks(30,new ECB(4,122),new ECB(18,123)),new ECBlocks(28,new ECB(13,46),new ECB(32,47)),new ECBlocks(30,new ECB(48,24),new ECB(14,25)),new ECBlocks(30,new ECB(42,15),new ECB(32,16))),new Version(39,new Array(6,26,54,82,110,138,166),new ECBlocks(30,new ECB(20,117),new ECB(4,118)),new ECBlocks(28,new ECB(40,47),new ECB(7,48)),new ECBlocks(30,new ECB(43,24),new ECB(22,25)),new ECBlocks(30,new ECB(10,15),new ECB(67,16))),new Version(40,new Array(6,30,58,86,114,142,170),new ECBlocks(30,new ECB(19,118),new ECB(6,119)),new ECBlocks(28,new ECB(18,47),new ECB(31,48)),new ECBlocks(30,new ECB(34,24),new ECB(34,25)),new ECBlocks(30,new ECB(20,15),new ECB(61,16))))}function PerspectiveTransform(a11,a21,a31,a12,a22,a32,a13,a23,a33){this.a11=a11,this.a12=a12,this.a13=a13,this.a21=a21,this.a22=a22,this.a23=a23,this.a31=a31,this.a32=a32,this.a33=a33,this.transformPoints1=function(points){for(var max=points.length,a11=this.a11,a12=this.a12,a13=this.a13,a21=this.a21,a22=this.a22,a23=this.a23,a31=this.a31,a32=this.a32,a33=this.a33,i=0;i<max;i+=2){var x=points[i],y=points[i+1],denominator=a13*x+a23*y+a33;points[i]=(a11*x+a21*y+a31)/denominator,points[i+1]=(a12*x+a22*y+a32)/denominator}},this.transformPoints2=function(xValues,yValues){for(var n=xValues.length,i=0;i<n;i++){var x=xValues[i],y=yValues[i],denominator=this.a13*x+this.a23*y+this.a33;xValues[i]=(this.a11*x+this.a21*y+this.a31)/denominator,yValues[i]=(this.a12*x+this.a22*y+this.a32)/denominator}},this.buildAdjoint=function(){return new PerspectiveTransform(this.a22*this.a33-this.a23*this.a32,this.a23*this.a31-this.a21*this.a33,this.a21*this.a32-this.a22*this.a31,this.a13*this.a32-this.a12*this.a33,this.a11*this.a33-this.a13*this.a31,this.a12*this.a31-this.a11*this.a32,this.a12*this.a23-this.a13*this.a22,this.a13*this.a21-this.a11*this.a23,this.a11*this.a22-this.a12*this.a21)},this.times=function(other){return new PerspectiveTransform(this.a11*other.a11+this.a21*other.a12+this.a31*other.a13,this.a11*other.a21+this.a21*other.a22+this.a31*other.a23,this.a11*other.a31+this.a21*other.a32+this.a31*other.a33,this.a12*other.a11+this.a22*other.a12+this.a32*other.a13,this.a12*other.a21+this.a22*other.a22+this.a32*other.a23,this.a12*other.a31+this.a22*other.a32+this.a32*other.a33,this.a13*other.a11+this.a23*other.a12+this.a33*other.a13,this.a13*other.a21+this.a23*other.a22+this.a33*other.a23,this.a13*other.a31+this.a23*other.a32+this.a33*other.a33)}}function DetectorResult(bits,points){this.bits=bits,this.points=points}function Detector(image){this.image=image,this.resultPointCallback=null,this.sizeOfBlackWhiteBlackRun=function(fromX,fromY,toX,toY){var steep=Math.abs(toY-fromY)>Math.abs(toX-fromX);if(steep){var temp=fromX;fromX=fromY,fromY=temp,temp=toX,toX=toY,toY=temp}for(var dx=Math.abs(toX-fromX),dy=Math.abs(toY-fromY),error=-dx>>1,ystep=fromY<toY?1:-1,xstep=fromX<toX?1:-1,state=0,x=fromX,y=fromY;x!=toX;x+=xstep){var realX=steep?y:x,realY=steep?x:y;if(1==state?this.image[realX+realY*qrcode.width]&&state++:this.image[realX+realY*qrcode.width]||state++,3==state){var diffX=x-fromX,diffY=y-fromY;return Math.sqrt(diffX*diffX+diffY*diffY)}if(0<(error+=dy)){if(y==toY)break;y+=ystep,error-=dx}}var diffX2=toX-fromX,diffY2=toY-fromY;return Math.sqrt(diffX2*diffX2+diffY2*diffY2)},this.sizeOfBlackWhiteBlackRunBothWays=function(fromX,fromY,toX,toY){var result=this.sizeOfBlackWhiteBlackRun(fromX,fromY,toX,toY),scale=1,otherToX=fromX-(toX-fromX);otherToX<0?(scale=fromX/(fromX-otherToX),otherToX=0):otherToX>=qrcode.width&&(scale=(qrcode.width-1-fromX)/(otherToX-fromX),otherToX=qrcode.width-1);var otherToY=Math.floor(fromY-(toY-fromY)*scale);return scale=1,otherToY<0?(scale=fromY/(fromY-otherToY),otherToY=0):otherToY>=qrcode.height&&(scale=(qrcode.height-1-fromY)/(otherToY-fromY),otherToY=qrcode.height-1),otherToX=Math.floor(fromX+(otherToX-fromX)*scale),(result+=this.sizeOfBlackWhiteBlackRun(fromX,fromY,otherToX,otherToY))-1},this.calculateModuleSizeOneWay=function(pattern,otherPattern){var moduleSizeEst1=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(pattern.X),Math.floor(pattern.Y),Math.floor(otherPattern.X),Math.floor(otherPattern.Y)),moduleSizeEst2=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(otherPattern.X),Math.floor(otherPattern.Y),Math.floor(pattern.X),Math.floor(pattern.Y));return isNaN(moduleSizeEst1)?moduleSizeEst2/7:isNaN(moduleSizeEst2)?moduleSizeEst1/7:(moduleSizeEst1+moduleSizeEst2)/14},this.calculateModuleSize=function(topLeft,topRight,bottomLeft){return(this.calculateModuleSizeOneWay(topLeft,topRight)+this.calculateModuleSizeOneWay(topLeft,bottomLeft))/2},this.distance=function(pattern1,pattern2){return xDiff=pattern1.X-pattern2.X,yDiff=pattern1.Y-pattern2.Y,Math.sqrt(xDiff*xDiff+yDiff*yDiff)},this.computeDimension=function(topLeft,topRight,bottomLeft,moduleSize){var dimension=7+(Math.round(this.distance(topLeft,topRight)/moduleSize)+Math.round(this.distance(topLeft,bottomLeft)/moduleSize)>>1);switch(3&dimension){case 0:dimension++;break;case 2:dimension--;break;case 3:throw"Error"}return dimension},this.findAlignmentInRegion=function(overallEstModuleSize,estAlignmentX,estAlignmentY,allowanceFactor){var allowance=Math.floor(allowanceFactor*overallEstModuleSize),alignmentAreaLeftX=Math.max(0,estAlignmentX-allowance),alignmentAreaRightX=Math.min(qrcode.width-1,estAlignmentX+allowance);if(alignmentAreaRightX-alignmentAreaLeftX<3*overallEstModuleSize)throw"Error";var alignmentAreaTopY=Math.max(0,estAlignmentY-allowance),alignmentAreaBottomY=Math.min(qrcode.height-1,estAlignmentY+allowance);return new AlignmentPatternFinder(this.image,alignmentAreaLeftX,alignmentAreaTopY,alignmentAreaRightX-alignmentAreaLeftX,alignmentAreaBottomY-alignmentAreaTopY,overallEstModuleSize,this.resultPointCallback).find()},this.createTransform=function(topLeft,topRight,bottomLeft,alignmentPattern,dimension){var bottomRightX,bottomRightY,sourceBottomRightX,sourceBottomRightY,dimMinusThree=dimension-3.5;return sourceBottomRightX=sourceBottomRightY=null!=alignmentPattern?(bottomRightX=alignmentPattern.X,bottomRightY=alignmentPattern.Y,dimMinusThree-3):(bottomRightX=topRight.X-topLeft.X+bottomLeft.X,bottomRightY=topRight.Y-topLeft.Y+bottomLeft.Y,dimMinusThree),PerspectiveTransform.quadrilateralToQuadrilateral(3.5,3.5,dimMinusThree,3.5,sourceBottomRightX,sourceBottomRightY,3.5,dimMinusThree,topLeft.X,topLeft.Y,topRight.X,topRight.Y,bottomRightX,bottomRightY,bottomLeft.X,bottomLeft.Y)},this.sampleGrid=function(image,transform,dimension){return GridSampler.sampleGrid3(image,dimension,transform)},this.processFinderPatternInfo=function(info){var topLeft=info.TopLeft,topRight=info.TopRight,bottomLeft=info.BottomLeft,moduleSize=this.calculateModuleSize(topLeft,topRight,bottomLeft);if(moduleSize<1)throw"Error";var dimension=this.computeDimension(topLeft,topRight,bottomLeft,moduleSize),provisionalVersion=Version.getProvisionalVersionForDimension(dimension),modulesBetweenFPCenters=provisionalVersion.DimensionForVersion-7,alignmentPattern=null;if(0<provisionalVersion.AlignmentPatternCenters.length)for(var bottomRightX=topRight.X-topLeft.X+bottomLeft.X,bottomRightY=topRight.Y-topLeft.Y+bottomLeft.Y,correctionToTopLeft=1-3/modulesBetweenFPCenters,estAlignmentX=Math.floor(topLeft.X+correctionToTopLeft*(bottomRightX-topLeft.X)),estAlignmentY=Math.floor(topLeft.Y+correctionToTopLeft*(bottomRightY-topLeft.Y)),i=4;i<=16;i<<=1){alignmentPattern=this.findAlignmentInRegion(moduleSize,estAlignmentX,estAlignmentY,i);break}var transform=this.createTransform(topLeft,topRight,bottomLeft,alignmentPattern,dimension);return new DetectorResult(this.sampleGrid(this.image,transform,dimension),null==alignmentPattern?new Array(bottomLeft,topLeft,topRight):new Array(bottomLeft,topLeft,topRight,alignmentPattern))},this.detect=function(){var info=(new FinderPatternFinder).findFinderPattern(this.image);return this.processFinderPatternInfo(info)}}GridSampler={checkAndNudgePoints:function(image,points){for(var width=qrcode.width,height=qrcode.height,nudged=!0,offset=0;offset<points.length&&nudged;offset+=2){var x=Math.floor(points[offset]),y=Math.floor(points[offset+1]);if(x<-1||width<x||y<-1||height<y)throw"Error.checkAndNudgePoints ";nudged=!1,-1==x?nudged=!(points[offset]=0):x==width&&(points[offset]=width-1,nudged=!0),-1==y?nudged=!(points[offset+1]=0):y==height&&(points[offset+1]=height-1,nudged=!0)}nudged=!0;for(offset=points.length-2;0<=offset&&nudged;offset-=2){x=Math.floor(points[offset]),y=Math.floor(points[offset+1]);if(x<-1||width<x||y<-1||height<y)throw"Error.checkAndNudgePoints ";nudged=!1,-1==x?nudged=!(points[offset]=0):x==width&&(points[offset]=width-1,nudged=!0),-1==y?nudged=!(points[offset+1]=0):y==height&&(points[offset+1]=height-1,nudged=!0)}},sampleGrid3:function(image,dimension,transform){for(var bits=new BitMatrix(dimension),points=new Array(dimension<<1),y=0;y<dimension;y++){for(var max=points.length,iValue=y+.5,x=0;x<max;x+=2)points[x]=.5+(x>>1),points[x+1]=iValue;transform.transformPoints1(points),GridSampler.checkAndNudgePoints(image,points);try{for(x=0;x<max;x+=2){var xpoint=4*Math.floor(points[x])+Math.floor(points[x+1])*qrcode.width*4,bit=image[Math.floor(points[x])+qrcode.width*Math.floor(points[x+1])];qrcode.imagedata.data[xpoint]=bit?255:0,qrcode.imagedata.data[1+xpoint]=bit?255:0,qrcode.imagedata.data[2+xpoint]=0,qrcode.imagedata.data[3+xpoint]=255,bit&&bits.set_Renamed(x>>1,y)}}catch(aioobe){throw"Error.checkAndNudgePoints"}}return bits},sampleGridx:function(image,dimension,p1ToX,p1ToY,p2ToX,p2ToY,p3ToX,p3ToY,p4ToX,p4ToY,p1FromX,p1FromY,p2FromX,p2FromY,p3FromX,p3FromY,p4FromX,p4FromY){var transform=PerspectiveTransform.quadrilateralToQuadrilateral(p1ToX,p1ToY,p2ToX,p2ToY,p3ToX,p3ToY,p4ToX,p4ToY,p1FromX,p1FromY,p2FromX,p2FromY,p3FromX,p3FromY,p4FromX,p4FromY);return GridSampler.sampleGrid3(image,dimension,transform)}},Version.VERSION_DECODE_INFO=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),Version.VERSIONS=buildVersions(),Version.getVersionForNumber=function(versionNumber){if(versionNumber<1||40<versionNumber)throw"ArgumentException";return Version.VERSIONS[versionNumber-1]},Version.getProvisionalVersionForDimension=function(dimension){if(dimension%4!=1)throw"Error getProvisionalVersionForDimension";try{return Version.getVersionForNumber(dimension-17>>2)}catch(iae){throw"Error getVersionForNumber"}},Version.decodeVersionInformation=function(versionBits){for(var bestDifference=4294967295,bestVersion=0,i=0;i<Version.VERSION_DECODE_INFO.length;i++){var targetVersion=Version.VERSION_DECODE_INFO[i];if(targetVersion==versionBits)return this.getVersionForNumber(i+7);var bitsDifference=FormatInformation.numBitsDiffering(versionBits,targetVersion);bitsDifference<bestDifference&&(bestVersion=i+7,bestDifference=bitsDifference)}return bestDifference<=3?this.getVersionForNumber(bestVersion):null},PerspectiveTransform.quadrilateralToQuadrilateral=function(x0,y0,x1,y1,x2,y2,x3,y3,x0p,y0p,x1p,y1p,x2p,y2p,x3p,y3p){var qToS=this.quadrilateralToSquare(x0,y0,x1,y1,x2,y2,x3,y3);return this.squareToQuadrilateral(x0p,y0p,x1p,y1p,x2p,y2p,x3p,y3p).times(qToS)},PerspectiveTransform.squareToQuadrilateral=function(x0,y0,x1,y1,x2,y2,x3,y3){return dy2=y3-y2,dy3=y0-y1+y2-y3,0==dy2&&0==dy3?new PerspectiveTransform(x1-x0,x2-x1,x0,y1-y0,y2-y1,y0,0,0,1):(dx1=x1-x2,dx2=x3-x2,dx3=x0-x1+x2-x3,dy1=y1-y2,denominator=dx1*dy2-dx2*dy1,a13=(dx3*dy2-dx2*dy3)/denominator,a23=(dx1*dy3-dx3*dy1)/denominator,new PerspectiveTransform(x1-x0+a13*x1,x3-x0+a23*x3,x0,y1-y0+a13*y1,y3-y0+a23*y3,y0,a13,a23,1))},PerspectiveTransform.quadrilateralToSquare=function(x0,y0,x1,y1,x2,y2,x3,y3){return this.squareToQuadrilateral(x0,y0,x1,y1,x2,y2,x3,y3).buildAdjoint()};var FORMAT_INFO_MASK_QR=21522,FORMAT_INFO_DECODE_LOOKUP=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)),BITS_SET_IN_HALF_BYTE=new Array(0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4);function FormatInformation(formatInfo){this.errorCorrectionLevel=ErrorCorrectionLevel.forBits(formatInfo>>3&3),this.dataMask=7&formatInfo,this.__defineGetter__("ErrorCorrectionLevel",function(){return this.errorCorrectionLevel}),this.__defineGetter__("DataMask",function(){return this.dataMask}),this.GetHashCode=function(){return this.errorCorrectionLevel.ordinal()<<3|dataMask},this.Equals=function(o){var other=o;return this.errorCorrectionLevel==other.errorCorrectionLevel&&this.dataMask==other.dataMask}}function ErrorCorrectionLevel(ordinal,bits,name){this.ordinal_Renamed_Field=ordinal,this.bits=bits,this.name=name,this.__defineGetter__("Bits",function(){return this.bits}),this.__defineGetter__("Name",function(){return this.name}),this.ordinal=function(){return this.ordinal_Renamed_Field}}FormatInformation.numBitsDiffering=function(a,b){return BITS_SET_IN_HALF_BYTE[15&(a^=b)]+BITS_SET_IN_HALF_BYTE[15&URShift(a,4)]+BITS_SET_IN_HALF_BYTE[15&URShift(a,8)]+BITS_SET_IN_HALF_BYTE[15&URShift(a,12)]+BITS_SET_IN_HALF_BYTE[15&URShift(a,16)]+BITS_SET_IN_HALF_BYTE[15&URShift(a,20)]+BITS_SET_IN_HALF_BYTE[15&URShift(a,24)]+BITS_SET_IN_HALF_BYTE[15&URShift(a,28)]},FormatInformation.decodeFormatInformation=function(maskedFormatInfo){var formatInfo=FormatInformation.doDecodeFormatInformation(maskedFormatInfo);return null!=formatInfo?formatInfo:FormatInformation.doDecodeFormatInformation(maskedFormatInfo^FORMAT_INFO_MASK_QR)},FormatInformation.doDecodeFormatInformation=function(maskedFormatInfo){for(var bestDifference=4294967295,bestFormatInfo=0,i=0;i<FORMAT_INFO_DECODE_LOOKUP.length;i++){var decodeInfo=FORMAT_INFO_DECODE_LOOKUP[i],targetInfo=decodeInfo[0];if(targetInfo==maskedFormatInfo)return new FormatInformation(decodeInfo[1]);var bitsDifference=this.numBitsDiffering(maskedFormatInfo,targetInfo);bitsDifference<bestDifference&&(bestFormatInfo=decodeInfo[1],bestDifference=bitsDifference)}return bestDifference<=3?new FormatInformation(bestFormatInfo):null},ErrorCorrectionLevel.forBits=function(bits){if(bits<0||bits>=FOR_BITS.length)throw"ArgumentException";return FOR_BITS[bits]};var L=new ErrorCorrectionLevel(0,1,"L"),M=new ErrorCorrectionLevel(1,0,"M"),Q=new ErrorCorrectionLevel(2,3,"Q"),H=new ErrorCorrectionLevel(3,2,"H"),FOR_BITS=new Array(M,L,H,Q);function BitMatrix(width,height){if(height=height||width,width<1||height<1)throw"Both dimensions must be greater than 0";this.width=width,this.height=height;var rowSize=width>>5;0!=(31&width)&&rowSize++,this.rowSize=rowSize,this.bits=new Array(rowSize*height);for(var i=0;i<this.bits.length;i++)this.bits[i]=0;this.__defineGetter__("Width",function(){return this.width}),this.__defineGetter__("Height",function(){return this.height}),this.__defineGetter__("Dimension",function(){if(this.width!=this.height)throw"Can't call getDimension() on a non-square matrix";return this.width}),this.get_Renamed=function(x,y){var offset=y*this.rowSize+(x>>5);return 0!=(1&URShift(this.bits[offset],31&x))},this.set_Renamed=function(x,y){var offset=y*this.rowSize+(x>>5);this.bits[offset]|=1<<(31&x)},this.flip=function(x,y){var offset=y*this.rowSize+(x>>5);this.bits[offset]^=1<<(31&x)},this.clear=function(){for(var max=this.bits.lengt