@slidoapp/qrcode
Advanced tools
Comparing version 2.0.2 to 2.1.0
@@ -1,1 +0,1 @@ | ||
var QRCode=function(t){"use strict";function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e,n,o={};function i(){return n?e:(n=1,e=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then})}var a,u={},s={};function f(){if(a)return s;var t;a=1;var r=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return s.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return 4*t+17},s.getSymbolTotalCodewords=function(t){return r[t]},s.getBCHDigit=function(t){for(var r=0;0!==t;)r++,t>>>=1;return r},s.setToSJISFunction=function(r){if("function"!=typeof r)throw new Error('"toSJISFunc" is not a valid function.');t=r},s.isKanjiModeEnabled=function(){return void 0!==t},s.toSJIS=function(r){return t(r)},s}var c,h,d,g,l,v={};function p(){return c||(c=1,function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2},t.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},t.from=function(r,e){if(t.isValid(r))return r;try{return function(r){if("string"!=typeof r)throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+r)}}(r)}catch(t){return e}}}(v)),v}var w,m={};var E,y={};var A,C={};var B,M={};function I(){if(B)return M;B=1;var t=p(),r=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],e=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return M.getBlocksCount=function(e,n){switch(n){case t.L:return r[4*(e-1)+0];case t.M:return r[4*(e-1)+1];case t.Q:return r[4*(e-1)+2];case t.H:return r[4*(e-1)+3];default:return}},M.getTotalCodewordsCount=function(r,n){switch(n){case t.L:return e[4*(r-1)+0];case t.M:return e[4*(r-1)+1];case t.Q:return e[4*(r-1)+2];case t.H:return e[4*(r-1)+3];default:return}},M}var T,P,N,b,R={},L={};function U(){return P||(P=1,function(t){var r=function(){if(T)return L;T=1;var t=new Uint8Array(512),r=new Uint8Array(256);return function(){for(var e=1,n=0;n<255;n++)t[n]=e,r[e]=n,256&(e<<=1)&&(e^=285);for(var o=255;o<512;o++)t[o]=t[o-255]}(),L.log=function(t){if(t<1)throw new Error("log("+t+")");return r[t]},L.exp=function(r){return t[r]},L.mul=function(e,n){return 0===e||0===n?0:t[r[e]+r[n]]},L}();t.mul=function(t,e){for(var n=new Uint8Array(t.length+e.length-1),o=0;o<t.length;o++)for(var i=0;i<e.length;i++)n[o+i]^=r.mul(t[o],e[i]);return n},t.mod=function(t,e){for(var n=new Uint8Array(t);n.length-e.length>=0;){for(var o=n[0],i=0;i<e.length;i++)n[i]^=r.mul(e[i],o);for(var a=0;a<n.length&&0===n[a];)a++;n=n.slice(a)}return n},t.generateECPolynomial=function(e){for(var n=new Uint8Array([1]),o=0;o<e;o++)n=t.mul(n,new Uint8Array([1,r.exp(o)]));return n}}(R)),R}var x,S={},k={},F={};function z(){return x||(x=1,F.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),F}var D,_,H,J={};function K(){if(D)return J;D=1;var t="[0-9]+",r="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+",e="(?:(?![A-Z0-9 $%*+\\-./:]|"+(r=r.replace(/u/g,"\\u"))+")(?:.|[\r\n]))+";J.KANJI=new RegExp(r,"g"),J.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),J.BYTE=new RegExp(e,"g"),J.NUMERIC=new RegExp(t,"g"),J.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");var n=new RegExp("^"+r+"$"),o=new RegExp("^"+t+"$"),i=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return J.testKanji=function(t){return n.test(t)},J.testNumeric=function(t){return o.test(t)},J.testAlphanumeric=function(t){return i.test(t)},J}function Y(){return _||(_=1,function(t){var r=z(),e=K();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(t,e){if(!t.ccBits)throw new Error("Invalid mode: "+t);if(!r.isValid(e))throw new Error("Invalid version: "+e);return e>=1&&e<10?t.ccBits[0]:e<27?t.ccBits[1]:t.ccBits[2]},t.getBestModeForData=function(r){return e.testNumeric(r)?t.NUMERIC:e.testAlphanumeric(r)?t.ALPHANUMERIC:e.testKanji(r)?t.KANJI:t.BYTE},t.toString=function(t){if(t&&t.id)return t.id;throw new Error("Invalid mode")},t.isValid=function(t){return t&&t.bit&&t.ccBits},t.from=function(r,e){if(t.isValid(r))return r;try{return function(r){if("string"!=typeof r)throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+r)}}(r)}catch(t){return e}}}(k)),k}function O(){return H||(H=1,function(t){var r=f(),e=I(),n=p(),o=Y(),i=z(),a=r.getBCHDigit(7973);function u(t,r){return o.getCharCountIndicator(t,r)+4}function s(t,r){var e=0;return t.forEach((function(t){var n=u(t.mode,r);e+=n+t.getBitsLength()})),e}t.from=function(t,r){return i.isValid(t)?parseInt(t,10):r},t.getCapacity=function(t,n,a){if(!i.isValid(t))throw new Error("Invalid QR Code version");void 0===a&&(a=o.BYTE);var s=8*(r.getSymbolTotalCodewords(t)-e.getTotalCodewordsCount(t,n));if(a===o.MIXED)return s;var f=s-u(a,t);switch(a){case o.NUMERIC:return Math.floor(f/10*3);case o.ALPHANUMERIC:return Math.floor(f/11*2);case o.KANJI:return Math.floor(f/13);case o.BYTE:default:return Math.floor(f/8)}},t.getBestVersionForData=function(r,e){var i,a=n.from(e,n.M);if(Array.isArray(r)){if(r.length>1)return function(r,e){for(var n=1;n<=40;n++)if(s(r,n)<=t.getCapacity(n,e,o.MIXED))return n}(r,a);if(0===r.length)return 1;i=r[0]}else i=r;return function(r,e,n){for(var o=1;o<=40;o++)if(e<=t.getCapacity(o,n,r))return o}(i.mode,i.getLength(),a)},t.getEncodedBits=function(t){if(!i.isValid(t)||t<7)throw new Error("Invalid QR Code version");for(var e=t<<12;r.getBCHDigit(e)-a>=0;)e^=7973<<r.getBCHDigit(e)-a;return t<<12|e}}(S)),S}var j,V={};var Q,q,$,Z,X,W,G,tt,rt={};var et,nt,ot,it={exports:{}};function at(){return et||(et=1,function(t){var r={single_source_shortest_paths:function(t,e,n){var o={},i={};i[e]=0;var a,u,s,f,c,h,d,g=r.PriorityQueue.make();for(g.push(e,0);!g.empty();)for(s in u=(a=g.pop()).value,f=a.cost,c=t[u]||{})c.hasOwnProperty(s)&&(h=f+c[s],d=i[s],(void 0===i[s]||d>h)&&(i[s]=h,g.push(s,h),o[s]=u));if(void 0!==n&&void 0===i[n]){var l=["Could not find a path from ",e," to ",n,"."].join("");throw new Error(l)}return o},extract_shortest_path_from_predecessor_list:function(t,r){for(var e=[],n=r;n;)e.push(n),t[n],n=t[n];return e.reverse(),e},find_path:function(t,e,n){var o=r.single_source_shortest_paths(t,e,n);return r.extract_shortest_path_from_predecessor_list(o,n)},PriorityQueue:{make:function(t){var e,n=r.PriorityQueue,o={};for(e in t=t||{},n)n.hasOwnProperty(e)&&(o[e]=n[e]);return o.queue=[],o.sorter=t.sorter||n.default_sorter,o},default_sorter:function(t,r){return t.cost-r.cost},push:function(t,r){var e={value:t,cost:r};this.queue.push(e),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};t.exports=r}(it)),it.exports}function ut(){return nt||(nt=1,function(t){var r=Y(),e=function(){if(q)return Q;q=1;var t=Y();function r(r){this.mode=t.NUMERIC,this.data=r.toString()}return r.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(t){var r,e,n;for(r=0;r+3<=this.data.length;r+=3)e=this.data.substr(r,3),n=parseInt(e,10),t.put(n,10);var o=this.data.length-r;o>0&&(e=this.data.substr(r),n=parseInt(e,10),t.put(n,3*o+1))},Q=r}(),n=function(){if(Z)return $;Z=1;var t=Y(),r=["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"," ","$","%","*","+","-",".","/",":"];function e(r){this.mode=t.ALPHANUMERIC,this.data=r}return e.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(t){var e;for(e=0;e+2<=this.data.length;e+=2){var n=45*r.indexOf(this.data[e]);n+=r.indexOf(this.data[e+1]),t.put(n,11)}this.data.length%2&&t.put(r.indexOf(this.data[e]),6)},$=e}(),o=function(){if(W)return X;W=1;var t=Y();function r(r){this.mode=t.BYTE,this.data="string"==typeof r?(new TextEncoder).encode(r):new Uint8Array(r)}return r.getBitsLength=function(t){return 8*t},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(t){for(var r=0,e=this.data.length;r<e;r++)t.put(this.data[r],8)},X=r}(),i=function(){if(tt)return G;tt=1;var t=Y(),r=f();function e(r){this.mode=t.KANJI,this.data=r}return e.getBitsLength=function(t){return 13*t},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(t){var e;for(e=0;e<this.data.length;e++){var n=r.toSJIS(this.data[e]);if(n>=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[e]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),t.put(n,13)}},G=e}(),a=K(),u=f(),s=at();function c(t){return unescape(encodeURIComponent(t)).length}function h(t,r,e){for(var n,o=[];null!==(n=t.exec(e));)o.push({data:n[0],index:n.index,mode:r,length:n[0].length});return o}function d(t){var e,n,o=h(a.NUMERIC,r.NUMERIC,t),i=h(a.ALPHANUMERIC,r.ALPHANUMERIC,t);return u.isKanjiModeEnabled()?(e=h(a.BYTE,r.BYTE,t),n=h(a.KANJI,r.KANJI,t)):(e=h(a.BYTE_KANJI,r.BYTE,t),n=[]),o.concat(i,e,n).sort((function(t,r){return t.index-r.index})).map((function(t){return{data:t.data,mode:t.mode,length:t.length}}))}function g(t,a){switch(a){case r.NUMERIC:return e.getBitsLength(t);case r.ALPHANUMERIC:return n.getBitsLength(t);case r.KANJI:return i.getBitsLength(t);case r.BYTE:return o.getBitsLength(t)}}function l(t,a){var s,f=r.getBestModeForData(t);if((s=r.from(a,f))!==r.BYTE&&s.bit<f.bit)throw new Error('"'+t+'" cannot be encoded with mode '+r.toString(s)+".\n Suggested mode is: "+r.toString(f));switch(s!==r.KANJI||u.isKanjiModeEnabled()||(s=r.BYTE),s){case r.NUMERIC:return new e(t);case r.ALPHANUMERIC:return new n(t);case r.KANJI:return new i(t);case r.BYTE:return new o(t)}}t.fromArray=function(t){return t.reduce((function(t,r){return"string"==typeof r?t.push(l(r,null)):r.data&&t.push(l(r.data,r.mode)),t}),[])},t.fromString=function(e,n){for(var o=function(t){for(var e=[],n=0;n<t.length;n++){var o=t[n];switch(o.mode){case r.NUMERIC:e.push([o,{data:o.data,mode:r.ALPHANUMERIC,length:o.length},{data:o.data,mode:r.BYTE,length:o.length}]);break;case r.ALPHANUMERIC:e.push([o,{data:o.data,mode:r.BYTE,length:o.length}]);break;case r.KANJI:e.push([o,{data:o.data,mode:r.BYTE,length:c(o.data)}]);break;case r.BYTE:e.push([{data:o.data,mode:r.BYTE,length:c(o.data)}])}}return e}(d(e,u.isKanjiModeEnabled())),i=function(t,e){for(var n={},o={start:{}},i=["start"],a=0;a<t.length;a++){for(var u=t[a],s=[],f=0;f<u.length;f++){var c=u[f],h=""+a+f;s.push(h),n[h]={node:c,lastCount:0},o[h]={};for(var d=0;d<i.length;d++){var l=i[d];n[l]&&n[l].node.mode===c.mode?(o[l][h]=g(n[l].lastCount+c.length,c.mode)-g(n[l].lastCount,c.mode),n[l].lastCount+=c.length):(n[l]&&(n[l].lastCount=c.length),o[l][h]=g(c.length,c.mode)+4+r.getCharCountIndicator(c.mode,e))}}i=s}for(var v=0;v<i.length;v++)o[i[v]].end=0;return{map:o,table:n}}(o,n),a=s.find_path(i.map,"start","end"),f=[],h=1;h<a.length-1;h++)f.push(i.table[a[h]].node);return t.fromArray(function(t){return t.reduce((function(t,r){var e=t.length-1>=0?t[t.length-1]:null;return e&&e.mode===r.mode?(t[t.length-1].data+=r.data,t):(t.push(r),t)}),[])}(f))},t.rawSplit=function(r){return t.fromArray(d(r,u.isKanjiModeEnabled()))}}(rt)),rt}function st(){if(ot)return u;ot=1;var t=f(),r=p(),e=function(){if(d)return h;function t(){this.buffer=[],this.length=0}return d=1,t.prototype={get:function(t){var r=Math.floor(t/8);return 1==(this.buffer[r]>>>7-t%8&1)},put:function(t,r){for(var e=0;e<r;e++)this.putBit(1==(t>>>r-e-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),t&&(this.buffer[r]|=128>>>this.length%8),this.length++}},h=t}(),n=function(){if(l)return g;function t(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return l=1,t.prototype.set=function(t,r,e,n){var o=t*this.size+r;this.data[o]=e,n&&(this.reservedBit[o]=!0)},t.prototype.get=function(t,r){return this.data[t*this.size+r]},t.prototype.xor=function(t,r,e){this.data[t*this.size+r]^=e},t.prototype.isReserved=function(t,r){return this.reservedBit[t*this.size+r]},g=t}(),o=(w||(w=1,function(t){var r=f().getSymbolSize;t.getRowColCoords=function(t){if(1===t)return[];for(var e=Math.floor(t/7)+2,n=r(t),o=145===n?26:2*Math.ceil((n-13)/(2*e-2)),i=[n-7],a=1;a<e-1;a++)i[a]=i[a-1]-o;return i.push(6),i.reverse()},t.getPositions=function(r){for(var e=[],n=t.getRowColCoords(r),o=n.length,i=0;i<o;i++)for(var a=0;a<o;a++)0===i&&0===a||0===i&&a===o-1||i===o-1&&0===a||e.push([n[i],n[a]]);return e}}(m)),m),i=function(){if(E)return y;E=1;var t=f().getSymbolSize;return y.getPositions=function(r){var e=t(r);return[[0,0],[e-7,0],[0,e-7]]},y}(),a=(A||(A=1,function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var r=3,e=3,n=40,o=10;function i(r,e,n){switch(r){case t.Patterns.PATTERN000:return(e+n)%2==0;case t.Patterns.PATTERN001:return e%2==0;case t.Patterns.PATTERN010:return n%3==0;case t.Patterns.PATTERN011:return(e+n)%3==0;case t.Patterns.PATTERN100:return(Math.floor(e/2)+Math.floor(n/3))%2==0;case t.Patterns.PATTERN101:return e*n%2+e*n%3==0;case t.Patterns.PATTERN110:return(e*n%2+e*n%3)%2==0;case t.Patterns.PATTERN111:return(e*n%3+(e+n)%2)%2==0;default:throw new Error("bad maskPattern:"+r)}}t.isValid=function(t){return null!=t&&""!==t&&!isNaN(t)&&t>=0&&t<=7},t.from=function(r){return t.isValid(r)?parseInt(r,10):void 0},t.getPenaltyN1=function(t){for(var e=t.size,n=0,o=0,i=0,a=null,u=null,s=0;s<e;s++){o=i=0,a=u=null;for(var f=0;f<e;f++){var c=t.get(s,f);c===a?o++:(o>=5&&(n+=r+(o-5)),a=c,o=1),(c=t.get(f,s))===u?i++:(i>=5&&(n+=r+(i-5)),u=c,i=1)}o>=5&&(n+=r+(o-5)),i>=5&&(n+=r+(i-5))}return n},t.getPenaltyN2=function(t){for(var r=t.size,n=0,o=0;o<r-1;o++)for(var i=0;i<r-1;i++){var a=t.get(o,i)+t.get(o,i+1)+t.get(o+1,i)+t.get(o+1,i+1);4!==a&&0!==a||n++}return n*e},t.getPenaltyN3=function(t){for(var r=t.size,e=0,o=0,i=0,a=0;a<r;a++){o=i=0;for(var u=0;u<r;u++)o=o<<1&2047|t.get(a,u),u>=10&&(1488===o||93===o)&&e++,i=i<<1&2047|t.get(u,a),u>=10&&(1488===i||93===i)&&e++}return e*n},t.getPenaltyN4=function(t){for(var r=0,e=t.data.length,n=0;n<e;n++)r+=t.data[n];return Math.abs(Math.ceil(100*r/e/5)-10)*o},t.applyMask=function(t,r){for(var e=r.size,n=0;n<e;n++)for(var o=0;o<e;o++)r.isReserved(o,n)||r.xor(o,n,i(t,o,n))},t.getBestMask=function(r,e){for(var n=Object.keys(t.Patterns).length,o=0,i=1/0,a=0;a<n;a++){e(a),t.applyMask(a,r);var u=t.getPenaltyN1(r)+t.getPenaltyN2(r)+t.getPenaltyN3(r)+t.getPenaltyN4(r);t.applyMask(a,r),u<i&&(i=u,o=a)}return o}}(C)),C),s=I(),c=function(){if(b)return N;b=1;var t=U();function r(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}return r.prototype.initialize=function(r){this.degree=r,this.genPoly=t.generateECPolynomial(this.degree)},r.prototype.encode=function(r){if(!this.genPoly)throw new Error("Encoder not initialized");var e=new Uint8Array(r.length+this.degree);e.set(r);var n=t.mod(e,this.genPoly),o=this.degree-n.length;if(o>0){var i=new Uint8Array(this.degree);return i.set(n,o),i}return n},N=r}(),v=O(),B=function(){if(j)return V;j=1;var t=f(),r=t.getBCHDigit(1335);return V.getEncodedBits=function(e,n){for(var o=e.bit<<3|n,i=o<<10;t.getBCHDigit(i)-r>=0;)i^=1335<<t.getBCHDigit(i)-r;return 21522^(o<<10|i)},V}(),M=Y(),T=ut();function P(t,r,e){var n,o,i=t.size,a=B.getEncodedBits(r,e);for(n=0;n<15;n++)o=1==(a>>n&1),n<6?t.set(n,8,o,!0):n<8?t.set(n+1,8,o,!0):t.set(i-15+n,8,o,!0),n<8?t.set(8,i-n-1,o,!0):n<9?t.set(8,15-n-1+1,o,!0):t.set(8,15-n-1,o,!0);t.set(i-8,8,1,!0)}function R(r,n,o){var i=new e;o.forEach((function(t){i.put(t.mode.bit,4),i.put(t.getLength(),M.getCharCountIndicator(t.mode,r)),t.write(i)}));var a=8*(t.getSymbolTotalCodewords(r)-s.getTotalCodewordsCount(r,n));for(i.getLengthInBits()+4<=a&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);for(var u=(a-i.getLengthInBits())/8,f=0;f<u;f++)i.put(f%2?17:236,8);return function(r,e,n){for(var o=t.getSymbolTotalCodewords(e),i=s.getTotalCodewordsCount(e,n),a=o-i,u=s.getBlocksCount(e,n),f=u-o%u,h=Math.floor(o/u),d=Math.floor(a/u),g=d+1,l=h-d,v=new c(l),p=0,w=new Array(u),m=new Array(u),E=0,y=new Uint8Array(r.buffer),A=0;A<u;A++){var C=A<f?d:g;w[A]=y.slice(p,p+C),m[A]=v.encode(w[A]),p+=C,E=Math.max(E,C)}var B,M,I=new Uint8Array(o),T=0;for(B=0;B<E;B++)for(M=0;M<u;M++)B<w[M].length&&(I[T++]=w[M][B]);for(B=0;B<l;B++)for(M=0;M<u;M++)I[T++]=m[M][B];return I}(i,r,n)}function L(r,e,u,s){var f;if(Array.isArray(r))f=T.fromArray(r);else{if("string"!=typeof r)throw new Error("Invalid data");var c=e;if(!c){var h=T.rawSplit(r);c=v.getBestVersionForData(h,u)}f=T.fromString(r,c||40)}var d=v.getBestVersionForData(f,u);if(!d)throw new Error("The amount of data is too big to be stored in a QR Code");if(e){if(e<d)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+d+".\n")}else e=d;var g=R(e,u,f),l=t.getSymbolSize(e),p=new n(l);return function(t,r){for(var e=t.size,n=i.getPositions(r),o=0;o<n.length;o++)for(var a=n[o][0],u=n[o][1],s=-1;s<=7;s++)if(!(a+s<=-1||e<=a+s))for(var f=-1;f<=7;f++)u+f<=-1||e<=u+f||(s>=0&&s<=6&&(0===f||6===f)||f>=0&&f<=6&&(0===s||6===s)||s>=2&&s<=4&&f>=2&&f<=4?t.set(a+s,u+f,!0,!0):t.set(a+s,u+f,!1,!0))}(p,e),function(t){for(var r=t.size,e=8;e<r-8;e++){var n=e%2==0;t.set(e,6,n,!0),t.set(6,e,n,!0)}}(p),function(t,r){for(var e=o.getPositions(r),n=0;n<e.length;n++)for(var i=e[n][0],a=e[n][1],u=-2;u<=2;u++)for(var s=-2;s<=2;s++)-2===u||2===u||-2===s||2===s||0===u&&0===s?t.set(i+u,a+s,!0,!0):t.set(i+u,a+s,!1,!0)}(p,e),P(p,u,0),e>=7&&function(t,r){for(var e,n,o,i=t.size,a=v.getEncodedBits(r),u=0;u<18;u++)e=Math.floor(u/3),n=u%3+i-8-3,o=1==(a>>u&1),t.set(e,n,o,!0),t.set(n,e,o,!0)}(p,e),function(t,r){for(var e=t.size,n=-1,o=e-1,i=7,a=0,u=e-1;u>0;u-=2)for(6===u&&u--;;){for(var s=0;s<2;s++)if(!t.isReserved(o,u-s)){var f=!1;a<r.length&&(f=1==(r[a]>>>i&1)),t.set(o,u-s,f),-1==--i&&(a++,i=7)}if((o+=n)<0||e<=o){o-=n,n=-n;break}}}(p,g),isNaN(s)&&(s=a.getBestMask(p,P.bind(null,p,u))),a.applyMask(s,p),P(p,u,s),{modules:p,version:e,errorCorrectionLevel:u,maskPattern:s,segments:f}}return u.create=function(e,n){if(void 0===e||""===e)throw new Error("No input text");var o,i,u=r.M;return void 0!==n&&(u=r.from(n.errorCorrectionLevel,r.M),o=v.from(n.version),i=a.from(n.maskPattern),n.toSJISFunc&&t.setToSJISFunction(n.toSJISFunc)),L(e,o,u,i)},u}var ft,ct,ht={},dt={};function gt(){return ft||(ft=1,function(t){function r(t){if("number"==typeof t&&(t=t.toString()),"string"!=typeof t)throw new Error("Color should be defined as hex string");var r=t.slice().replace("#","").split("");if(r.length<3||5===r.length||r.length>8)throw new Error("Invalid hex color: "+t);3!==r.length&&4!==r.length||(r=Array.prototype.concat.apply([],r.map((function(t){return[t,t]})))),6===r.length&&r.push("F","F");var e=parseInt(r.join(""),16);return{r:e>>24&255,g:e>>16&255,b:e>>8&255,a:255&e,hex:"#"+r.slice(0,6).join("")}}t.getOptions=function(t){t||(t={}),t.color||(t.color={});var e=void 0===t.margin||null===t.margin||t.margin<0?4:t.margin,n=t.width&&t.width>=21?t.width:void 0,o=t.scale||4;return{width:n,scale:n?4:o,margin:e,color:{dark:r(t.color.dark||"#000000ff"),light:r(t.color.light||"#ffffffff")},type:t.type,rendererOpts:t.rendererOpts||{}}},t.getScale=function(t,r){return r.width&&r.width>=t+2*r.margin?r.width/(t+2*r.margin):r.scale},t.getImageWidth=function(r,e){var n=t.getScale(r,e);return Math.floor((r+2*e.margin)*n)},t.qrToImageData=function(r,e,n){for(var o=e.modules.size,i=e.modules.data,a=t.getScale(o,n),u=Math.floor((o+2*n.margin)*a),s=n.margin*a,f=[n.color.light,n.color.dark],c=0;c<u;c++)for(var h=0;h<u;h++){var d=4*(c*u+h),g=n.color.light;if(c>=s&&h>=s&&c<u-s&&h<u-s)g=f[i[Math.floor((c-s)/a)*o+Math.floor((h-s)/a)]?1:0];r[d++]=g.r,r[d++]=g.g,r[d++]=g.b,r[d]=g.a}}}(dt)),dt}function lt(){return ct||(ct=1,function(t){var r=gt();t.render=function(t,e,n){var o=n,i=e;void 0!==o||e&&e.getContext||(o=e,e=void 0),e||(i=function(){try{return document.createElement("canvas")}catch(t){throw new Error("You need to specify a canvas element")}}()),o=r.getOptions(o);var a=r.getImageWidth(t.modules.size,o),u=i.getContext("2d"),s=u.createImageData(a,a);return r.qrToImageData(s.data,t,o),function(t,r,e){t.clearRect(0,0,r.width,r.height),r.style||(r.style={}),r.height=e,r.width=e,r.style.height=e+"px",r.style.width=e+"px"}(u,i,a),u.putImageData(s,0,0),i},t.renderToDataURL=function(r,e,n){var o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});var i=t.render(r,e,o),a=o.type||"image/png",u=o.rendererOpts||{};return i.toDataURL(a,u.quality)}}(ht)),ht}var vt,pt,wt={};function mt(){if(vt)return wt;vt=1;var t=gt();function r(t,r){var e=t.a/255,n=r+'="'+t.hex+'"';return e<1?n+" "+r+'-opacity="'+e.toFixed(2).slice(1)+'"':n}function e(t,r,e){var n=t+r;return void 0!==e&&(n+=" "+e),n}return wt.render=function(n,o,i){var a=t.getOptions(o),u=n.modules.size,s=n.modules.data,f=u+2*a.margin,c=a.color.light.a?"<path "+r(a.color.light,"fill")+' d="M0 0h'+f+"v"+f+'H0z"/>':"",h="<path "+r(a.color.dark,"stroke")+' d="'+function(t,r,n){for(var o="",i=0,a=!1,u=0,s=0;s<t.length;s++){var f=Math.floor(s%r),c=Math.floor(s/r);f||a||(a=!0),t[s]?(u++,s>0&&f>0&&t[s-1]||(o+=a?e("M",f+n,.5+c+n):e("m",i,0),i=0,a=!1),f+1<r&&t[s+1]||(o+=e("h",u),u=0)):i++}return o}(s,u,a.margin)+'"/>',d='viewBox="0 0 '+f+" "+f+'"',g='<svg xmlns="http://www.w3.org/2000/svg" '+(a.width?'width="'+a.width+'" height="'+a.width+'" ':"")+d+' shape-rendering="crispEdges">'+c+h+"</svg>\n";return"function"==typeof i&&i(null,g),g},wt}var Et=function(){if(pt)return o;pt=1;var t=i(),r=st(),e=lt(),n=mt();function a(e,n,o,i,a){var u=[].slice.call(arguments,1),s=u.length,f="function"==typeof u[s-1];if(!f&&!t())throw new Error("Callback required as last argument");if(!f){if(s<1)throw new Error("Too few arguments provided");return 1===s?(o=n,n=i=void 0):2!==s||n.getContext||(i=o,o=n,n=void 0),new Promise((function(t,a){try{var u=r.create(o,i);t(e(u,n,i))}catch(t){a(t)}}))}if(s<2)throw new Error("Too few arguments provided");2===s?(a=o,o=n,n=i=void 0):3===s&&(n.getContext&&void 0===a?(a=i,i=void 0):(a=i,i=o,o=n,n=void 0));try{var c=r.create(o,i);a(null,e(c,n,i))}catch(t){a(t)}}return o.create=r.create,o.toCanvas=a.bind(null,e.render),o.toDataURL=a.bind(null,e.renderToDataURL),o.toString=a.bind(null,(function(t,r,e){return n.render(t,e)})),o}(),yt=r(Et);return t.default=yt,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); | ||
var QRCode=function(t){"use strict";function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e,n,o={};function i(){return n?e:(n=1,e=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then})}var a,u={},s={};function f(){if(a)return s;var t;a=1;var r=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return s.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return 4*t+17},s.getSymbolTotalCodewords=function(t){return r[t]},s.getBCHDigit=function(t){for(var r=0;0!==t;)r++,t>>>=1;return r},s.setToSJISFunction=function(r){if("function"!=typeof r)throw new Error('"toSJISFunc" is not a valid function.');t=r},s.isKanjiModeEnabled=function(){return void 0!==t},s.toSJIS=function(r){return t(r)},s}var c,h,d,g,l,v={};function p(){return c||(c=1,function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2},t.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},t.from=function(r,e){if(t.isValid(r))return r;try{return function(r){if("string"!=typeof r)throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+r)}}(r)}catch(t){return e}}}(v)),v}var w,m={};var E,y={};var A,C={};var B,M={};function I(){if(B)return M;B=1;var t=p(),r=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],e=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return M.getBlocksCount=function(e,n){switch(n){case t.L:return r[4*(e-1)+0];case t.M:return r[4*(e-1)+1];case t.Q:return r[4*(e-1)+2];case t.H:return r[4*(e-1)+3];default:return}},M.getTotalCodewordsCount=function(r,n){switch(n){case t.L:return e[4*(r-1)+0];case t.M:return e[4*(r-1)+1];case t.Q:return e[4*(r-1)+2];case t.H:return e[4*(r-1)+3];default:return}},M}var T,P,N,b,R={},L={};function U(){return P||(P=1,function(t){var r=function(){if(T)return L;T=1;var t=new Uint8Array(512),r=new Uint8Array(256);return function(){for(var e=1,n=0;n<255;n++)t[n]=e,r[e]=n,256&(e<<=1)&&(e^=285);for(var o=255;o<512;o++)t[o]=t[o-255]}(),L.log=function(t){if(t<1)throw new Error("log("+t+")");return r[t]},L.exp=function(r){return t[r]},L.mul=function(e,n){return 0===e||0===n?0:t[r[e]+r[n]]},L}();t.mul=function(t,e){for(var n=new Uint8Array(t.length+e.length-1),o=0;o<t.length;o++)for(var i=0;i<e.length;i++)n[o+i]^=r.mul(t[o],e[i]);return n},t.mod=function(t,e){for(var n=new Uint8Array(t);n.length-e.length>=0;){for(var o=n[0],i=0;i<e.length;i++)n[i]^=r.mul(e[i],o);for(var a=0;a<n.length&&0===n[a];)a++;n=n.slice(a)}return n},t.generateECPolynomial=function(e){for(var n=new Uint8Array([1]),o=0;o<e;o++)n=t.mul(n,new Uint8Array([1,r.exp(o)]));return n}}(R)),R}var x,S={},k={},F={};function z(){return x||(x=1,F.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),F}var D,_,H,J={};function K(){if(D)return J;D=1;var t="[0-9]+",r="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+",e="(?:(?![A-Z0-9 $%*+\\-./:]|"+(r=r.replace(/u/g,"\\u"))+")(?:.|[\r\n]))+";J.KANJI=new RegExp(r,"g"),J.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),J.BYTE=new RegExp(e,"g"),J.NUMERIC=new RegExp(t,"g"),J.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");var n=new RegExp("^"+r+"$"),o=new RegExp("^"+t+"$"),i=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return J.testKanji=function(t){return n.test(t)},J.testNumeric=function(t){return o.test(t)},J.testAlphanumeric=function(t){return i.test(t)},J}function Y(){return _||(_=1,function(t){var r=z(),e=K();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(t,e){if(!t.ccBits)throw new Error("Invalid mode: "+t);if(!r.isValid(e))throw new Error("Invalid version: "+e);return e>=1&&e<10?t.ccBits[0]:e<27?t.ccBits[1]:t.ccBits[2]},t.getBestModeForData=function(r){return e.testNumeric(r)?t.NUMERIC:e.testAlphanumeric(r)?t.ALPHANUMERIC:e.testKanji(r)?t.KANJI:t.BYTE},t.toString=function(t){if(t&&t.id)return t.id;throw new Error("Invalid mode")},t.isValid=function(t){return t&&t.bit&&t.ccBits},t.from=function(r,e){if(t.isValid(r))return r;try{return function(r){if("string"!=typeof r)throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+r)}}(r)}catch(t){return e}}}(k)),k}function O(){return H||(H=1,function(t){var r=f(),e=I(),n=p(),o=Y(),i=z(),a=r.getBCHDigit(7973);function u(t,r){return o.getCharCountIndicator(t,r)+4}function s(t,r){var e=0;return t.forEach((function(t){var n=u(t.mode,r);e+=n+t.getBitsLength()})),e}t.from=function(t,r){return i.isValid(t)?parseInt(t,10):r},t.getCapacity=function(t,n,a){if(!i.isValid(t))throw new Error("Invalid QR Code version");void 0===a&&(a=o.BYTE);var s=8*(r.getSymbolTotalCodewords(t)-e.getTotalCodewordsCount(t,n));if(a===o.MIXED)return s;var f=s-u(a,t);switch(a){case o.NUMERIC:return Math.floor(f/10*3);case o.ALPHANUMERIC:return Math.floor(f/11*2);case o.KANJI:return Math.floor(f/13);case o.BYTE:default:return Math.floor(f/8)}},t.getBestVersionForData=function(r,e){var i,a=n.from(e,n.M);if(Array.isArray(r)){if(r.length>1)return function(r,e){for(var n=1;n<=40;n++)if(s(r,n)<=t.getCapacity(n,e,o.MIXED))return n}(r,a);if(0===r.length)return 1;i=r[0]}else i=r;return function(r,e,n){for(var o=1;o<=40;o++)if(e<=t.getCapacity(o,n,r))return o}(i.mode,i.getLength(),a)},t.getEncodedBits=function(t){if(!i.isValid(t)||t<7)throw new Error("Invalid QR Code version");for(var e=t<<12;r.getBCHDigit(e)-a>=0;)e^=7973<<r.getBCHDigit(e)-a;return t<<12|e}}(S)),S}var j,V={};var q,Q,$,Z,X,W,G,tt,rt={};var et,nt,ot,it={exports:{}};function at(){return et||(et=1,function(t){var r={single_source_shortest_paths:function(t,e,n){var o={},i={};i[e]=0;var a,u,s,f,c,h,d,g=r.PriorityQueue.make();for(g.push(e,0);!g.empty();)for(s in u=(a=g.pop()).value,f=a.cost,c=t[u]||{})c.hasOwnProperty(s)&&(h=f+c[s],d=i[s],(void 0===i[s]||d>h)&&(i[s]=h,g.push(s,h),o[s]=u));if(void 0!==n&&void 0===i[n]){var l=["Could not find a path from ",e," to ",n,"."].join("");throw new Error(l)}return o},extract_shortest_path_from_predecessor_list:function(t,r){for(var e=[],n=r;n;)e.push(n),t[n],n=t[n];return e.reverse(),e},find_path:function(t,e,n){var o=r.single_source_shortest_paths(t,e,n);return r.extract_shortest_path_from_predecessor_list(o,n)},PriorityQueue:{make:function(t){var e,n=r.PriorityQueue,o={};for(e in t=t||{},n)n.hasOwnProperty(e)&&(o[e]=n[e]);return o.queue=[],o.sorter=t.sorter||n.default_sorter,o},default_sorter:function(t,r){return t.cost-r.cost},push:function(t,r){var e={value:t,cost:r};this.queue.push(e),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};t.exports=r}(it)),it.exports}function ut(){return nt||(nt=1,function(t){var r=Y(),e=function(){if(Q)return q;Q=1;var t=Y();function r(r){this.mode=t.NUMERIC,this.data=r.toString()}return r.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(t){var r,e,n;for(r=0;r+3<=this.data.length;r+=3)e=this.data.substr(r,3),n=parseInt(e,10),t.put(n,10);var o=this.data.length-r;o>0&&(e=this.data.substr(r),n=parseInt(e,10),t.put(n,3*o+1))},q=r}(),n=function(){if(Z)return $;Z=1;var t=Y(),r=["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"," ","$","%","*","+","-",".","/",":"];function e(r){this.mode=t.ALPHANUMERIC,this.data=r}return e.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(t){var e;for(e=0;e+2<=this.data.length;e+=2){var n=45*r.indexOf(this.data[e]);n+=r.indexOf(this.data[e+1]),t.put(n,11)}this.data.length%2&&t.put(r.indexOf(this.data[e]),6)},$=e}(),o=function(){if(W)return X;W=1;var t=Y();function r(r){this.mode=t.BYTE,this.data="string"==typeof r?(new TextEncoder).encode(r):new Uint8Array(r)}return r.getBitsLength=function(t){return 8*t},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(t){for(var r=0,e=this.data.length;r<e;r++)t.put(this.data[r],8)},X=r}(),i=function(){if(tt)return G;tt=1;var t=Y(),r=f();function e(r){this.mode=t.KANJI,this.data=r}return e.getBitsLength=function(t){return 13*t},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(t){var e;for(e=0;e<this.data.length;e++){var n=r.toSJIS(this.data[e]);if(n>=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[e]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),t.put(n,13)}},G=e}(),a=K(),u=f(),s=at();function c(t){return unescape(encodeURIComponent(t)).length}function h(t,r,e){for(var n,o=[];null!==(n=t.exec(e));)o.push({data:n[0],index:n.index,mode:r,length:n[0].length});return o}function d(t){var e,n,o=h(a.NUMERIC,r.NUMERIC,t),i=h(a.ALPHANUMERIC,r.ALPHANUMERIC,t);return u.isKanjiModeEnabled()?(e=h(a.BYTE,r.BYTE,t),n=h(a.KANJI,r.KANJI,t)):(e=h(a.BYTE_KANJI,r.BYTE,t),n=[]),o.concat(i,e,n).sort((function(t,r){return t.index-r.index})).map((function(t){return{data:t.data,mode:t.mode,length:t.length}}))}function g(t,a){switch(a){case r.NUMERIC:return e.getBitsLength(t);case r.ALPHANUMERIC:return n.getBitsLength(t);case r.KANJI:return i.getBitsLength(t);case r.BYTE:return o.getBitsLength(t)}}function l(t,a){var s,f=r.getBestModeForData(t);if((s=r.from(a,f))!==r.BYTE&&s.bit<f.bit)throw new Error('"'+t+'" cannot be encoded with mode '+r.toString(s)+".\n Suggested mode is: "+r.toString(f));switch(s!==r.KANJI||u.isKanjiModeEnabled()||(s=r.BYTE),s){case r.NUMERIC:return new e(t);case r.ALPHANUMERIC:return new n(t);case r.KANJI:return new i(t);case r.BYTE:return new o(t)}}t.fromArray=function(t){return t.reduce((function(t,r){return"string"==typeof r?t.push(l(r,null)):r.data&&t.push(l(r.data,r.mode)),t}),[])},t.fromString=function(e,n){for(var o=function(t){for(var e=[],n=0;n<t.length;n++){var o=t[n];switch(o.mode){case r.NUMERIC:e.push([o,{data:o.data,mode:r.ALPHANUMERIC,length:o.length},{data:o.data,mode:r.BYTE,length:o.length}]);break;case r.ALPHANUMERIC:e.push([o,{data:o.data,mode:r.BYTE,length:o.length}]);break;case r.KANJI:e.push([o,{data:o.data,mode:r.BYTE,length:c(o.data)}]);break;case r.BYTE:e.push([{data:o.data,mode:r.BYTE,length:c(o.data)}])}}return e}(d(e,u.isKanjiModeEnabled())),i=function(t,e){for(var n={},o={start:{}},i=["start"],a=0;a<t.length;a++){for(var u=t[a],s=[],f=0;f<u.length;f++){var c=u[f],h=""+a+f;s.push(h),n[h]={node:c,lastCount:0},o[h]={};for(var d=0;d<i.length;d++){var l=i[d];n[l]&&n[l].node.mode===c.mode?(o[l][h]=g(n[l].lastCount+c.length,c.mode)-g(n[l].lastCount,c.mode),n[l].lastCount+=c.length):(n[l]&&(n[l].lastCount=c.length),o[l][h]=g(c.length,c.mode)+4+r.getCharCountIndicator(c.mode,e))}}i=s}for(var v=0;v<i.length;v++)o[i[v]].end=0;return{map:o,table:n}}(o,n),a=s.find_path(i.map,"start","end"),f=[],h=1;h<a.length-1;h++)f.push(i.table[a[h]].node);return t.fromArray(function(t){return t.reduce((function(t,r){var e=t.length-1>=0?t[t.length-1]:null;return e&&e.mode===r.mode?(t[t.length-1].data+=r.data,t):(t.push(r),t)}),[])}(f))},t.rawSplit=function(r){return t.fromArray(d(r,u.isKanjiModeEnabled()))}}(rt)),rt}function st(){if(ot)return u;ot=1;var t=f(),r=p(),e=function(){if(d)return h;function t(){this.buffer=[],this.length=0}return d=1,t.prototype={get:function(t){var r=Math.floor(t/8);return 1==(this.buffer[r]>>>7-t%8&1)},put:function(t,r){for(var e=0;e<r;e++)this.putBit(1==(t>>>r-e-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),t&&(this.buffer[r]|=128>>>this.length%8),this.length++}},h=t}(),n=function(){if(l)return g;function t(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return l=1,t.prototype.set=function(t,r,e,n){var o=t*this.size+r;this.data[o]=e,n&&(this.reservedBit[o]=!0)},t.prototype.get=function(t,r){return this.data[t*this.size+r]},t.prototype.xor=function(t,r,e){this.data[t*this.size+r]^=e},t.prototype.isReserved=function(t,r){return this.reservedBit[t*this.size+r]},g=t}(),o=(w||(w=1,function(t){var r=f().getSymbolSize;t.getRowColCoords=function(t){if(1===t)return[];for(var e=Math.floor(t/7)+2,n=r(t),o=145===n?26:2*Math.ceil((n-13)/(2*e-2)),i=[n-7],a=1;a<e-1;a++)i[a]=i[a-1]-o;return i.push(6),i.reverse()},t.getPositions=function(r){for(var e=[],n=t.getRowColCoords(r),o=n.length,i=0;i<o;i++)for(var a=0;a<o;a++)0===i&&0===a||0===i&&a===o-1||i===o-1&&0===a||e.push([n[i],n[a]]);return e}}(m)),m),i=function(){if(E)return y;E=1;var t=f().getSymbolSize;return y.getPositions=function(r){var e=t(r);return[[0,0],[e-7,0],[0,e-7]]},y}(),a=(A||(A=1,function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var r=3,e=3,n=40,o=10;function i(r,e,n){switch(r){case t.Patterns.PATTERN000:return(e+n)%2==0;case t.Patterns.PATTERN001:return e%2==0;case t.Patterns.PATTERN010:return n%3==0;case t.Patterns.PATTERN011:return(e+n)%3==0;case t.Patterns.PATTERN100:return(Math.floor(e/2)+Math.floor(n/3))%2==0;case t.Patterns.PATTERN101:return e*n%2+e*n%3==0;case t.Patterns.PATTERN110:return(e*n%2+e*n%3)%2==0;case t.Patterns.PATTERN111:return(e*n%3+(e+n)%2)%2==0;default:throw new Error("bad maskPattern:"+r)}}t.isValid=function(t){return null!=t&&""!==t&&!isNaN(t)&&t>=0&&t<=7},t.from=function(r){return t.isValid(r)?parseInt(r,10):void 0},t.getPenaltyN1=function(t){for(var e=t.size,n=0,o=0,i=0,a=null,u=null,s=0;s<e;s++){o=i=0,a=u=null;for(var f=0;f<e;f++){var c=t.get(s,f);c===a?o++:(o>=5&&(n+=r+(o-5)),a=c,o=1),(c=t.get(f,s))===u?i++:(i>=5&&(n+=r+(i-5)),u=c,i=1)}o>=5&&(n+=r+(o-5)),i>=5&&(n+=r+(i-5))}return n},t.getPenaltyN2=function(t){for(var r=t.size,n=0,o=0;o<r-1;o++)for(var i=0;i<r-1;i++){var a=t.get(o,i)+t.get(o,i+1)+t.get(o+1,i)+t.get(o+1,i+1);4!==a&&0!==a||n++}return n*e},t.getPenaltyN3=function(t){for(var r=t.size,e=0,o=0,i=0,a=0;a<r;a++){o=i=0;for(var u=0;u<r;u++)o=o<<1&2047|t.get(a,u),u>=10&&(1488===o||93===o)&&e++,i=i<<1&2047|t.get(u,a),u>=10&&(1488===i||93===i)&&e++}return e*n},t.getPenaltyN4=function(t){for(var r=0,e=t.data.length,n=0;n<e;n++)r+=t.data[n];return Math.abs(Math.ceil(100*r/e/5)-10)*o},t.applyMask=function(t,r){for(var e=r.size,n=0;n<e;n++)for(var o=0;o<e;o++)r.isReserved(o,n)||r.xor(o,n,i(t,o,n))},t.getBestMask=function(r,e){for(var n=Object.keys(t.Patterns).length,o=0,i=1/0,a=0;a<n;a++){e(a),t.applyMask(a,r);var u=t.getPenaltyN1(r)+t.getPenaltyN2(r)+t.getPenaltyN3(r)+t.getPenaltyN4(r);t.applyMask(a,r),u<i&&(i=u,o=a)}return o}}(C)),C),s=I(),c=function(){if(b)return N;b=1;var t=U();function r(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}return r.prototype.initialize=function(r){this.degree=r,this.genPoly=t.generateECPolynomial(this.degree)},r.prototype.encode=function(r){if(!this.genPoly)throw new Error("Encoder not initialized");var e=new Uint8Array(r.length+this.degree);e.set(r);var n=t.mod(e,this.genPoly),o=this.degree-n.length;if(o>0){var i=new Uint8Array(this.degree);return i.set(n,o),i}return n},N=r}(),v=O(),B=function(){if(j)return V;j=1;var t=f(),r=t.getBCHDigit(1335);return V.getEncodedBits=function(e,n){for(var o=e.bit<<3|n,i=o<<10;t.getBCHDigit(i)-r>=0;)i^=1335<<t.getBCHDigit(i)-r;return 21522^(o<<10|i)},V}(),M=Y(),T=ut();function P(t,r,e){var n,o,i=t.size,a=B.getEncodedBits(r,e);for(n=0;n<15;n++)o=1==(a>>n&1),n<6?t.set(n,8,o,!0):n<8?t.set(n+1,8,o,!0):t.set(i-15+n,8,o,!0),n<8?t.set(8,i-n-1,o,!0):n<9?t.set(8,15-n-1+1,o,!0):t.set(8,15-n-1,o,!0);t.set(i-8,8,1,!0)}function R(r,n,o){var i=new e;o.forEach((function(t){i.put(t.mode.bit,4),i.put(t.getLength(),M.getCharCountIndicator(t.mode,r)),t.write(i)}));var a=8*(t.getSymbolTotalCodewords(r)-s.getTotalCodewordsCount(r,n));for(i.getLengthInBits()+4<=a&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);for(var u=(a-i.getLengthInBits())/8,f=0;f<u;f++)i.put(f%2?17:236,8);return function(r,e,n){for(var o=t.getSymbolTotalCodewords(e),i=s.getTotalCodewordsCount(e,n),a=o-i,u=s.getBlocksCount(e,n),f=u-o%u,h=Math.floor(o/u),d=Math.floor(a/u),g=d+1,l=h-d,v=new c(l),p=0,w=new Array(u),m=new Array(u),E=0,y=new Uint8Array(r.buffer),A=0;A<u;A++){var C=A<f?d:g;w[A]=y.slice(p,p+C),m[A]=v.encode(w[A]),p+=C,E=Math.max(E,C)}var B,M,I=new Uint8Array(o),T=0;for(B=0;B<E;B++)for(M=0;M<u;M++)B<w[M].length&&(I[T++]=w[M][B]);for(B=0;B<l;B++)for(M=0;M<u;M++)I[T++]=m[M][B];return I}(i,r,n)}function L(r,e,u,s){var f;if(Array.isArray(r))f=T.fromArray(r);else{if("string"!=typeof r)throw new Error("Invalid data");var c=e;if(!c){var h=T.rawSplit(r);c=v.getBestVersionForData(h,u)}f=T.fromString(r,c||40)}var d=v.getBestVersionForData(f,u);if(!d)throw new Error("The amount of data is too big to be stored in a QR Code");if(e){if(e<d)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+d+".\n")}else e=d;var g=R(e,u,f),l=t.getSymbolSize(e),p=new n(l);return function(t,r){for(var e=t.size,n=i.getPositions(r),o=0;o<n.length;o++)for(var a=n[o][0],u=n[o][1],s=-1;s<=7;s++)if(!(a+s<=-1||e<=a+s))for(var f=-1;f<=7;f++)u+f<=-1||e<=u+f||(s>=0&&s<=6&&(0===f||6===f)||f>=0&&f<=6&&(0===s||6===s)||s>=2&&s<=4&&f>=2&&f<=4?t.set(a+s,u+f,!0,!0):t.set(a+s,u+f,!1,!0))}(p,e),function(t){for(var r=t.size,e=8;e<r-8;e++){var n=e%2==0;t.set(e,6,n,!0),t.set(6,e,n,!0)}}(p),function(t,r){for(var e=o.getPositions(r),n=0;n<e.length;n++)for(var i=e[n][0],a=e[n][1],u=-2;u<=2;u++)for(var s=-2;s<=2;s++)-2===u||2===u||-2===s||2===s||0===u&&0===s?t.set(i+u,a+s,!0,!0):t.set(i+u,a+s,!1,!0)}(p,e),P(p,u,0),e>=7&&function(t,r){for(var e,n,o,i=t.size,a=v.getEncodedBits(r),u=0;u<18;u++)e=Math.floor(u/3),n=u%3+i-8-3,o=1==(a>>u&1),t.set(e,n,o,!0),t.set(n,e,o,!0)}(p,e),function(t,r){for(var e=t.size,n=-1,o=e-1,i=7,a=0,u=e-1;u>0;u-=2)for(6===u&&u--;;){for(var s=0;s<2;s++)if(!t.isReserved(o,u-s)){var f=!1;a<r.length&&(f=1==(r[a]>>>i&1)),t.set(o,u-s,f),-1==--i&&(a++,i=7)}if((o+=n)<0||e<=o){o-=n,n=-n;break}}}(p,g),isNaN(s)&&(s=a.getBestMask(p,P.bind(null,p,u))),a.applyMask(s,p),P(p,u,s),{modules:p,version:e,errorCorrectionLevel:u,maskPattern:s,segments:f}}return u.create=function(e,n){if(void 0===e||""===e)throw new Error("No input text");var o,i,u=r.M;return void 0!==n&&(u=r.from(n.errorCorrectionLevel,r.M),o=v.from(n.version),i=a.from(n.maskPattern),n.toSJISFunc&&t.setToSJISFunction(n.toSJISFunc)),L(e,o,u,i)},u}var ft,ct,ht={},dt={};function gt(){return ft||(ft=1,function(t){function r(t){if("number"==typeof t&&(t=t.toString()),"string"!=typeof t)throw new Error("Color should be defined as hex string");var r=t.slice().replace("#","").split("");if(r.length<3||5===r.length||r.length>8)throw new Error("Invalid hex color: "+t);3!==r.length&&4!==r.length||(r=Array.prototype.concat.apply([],r.map((function(t){return[t,t]})))),6===r.length&&r.push("F","F");var e=parseInt(r.join(""),16);return{r:e>>24&255,g:e>>16&255,b:e>>8&255,a:255&e,hex:"#"+r.slice(0,6).join("")}}t.getOptions=function(t){t||(t={}),t.color||(t.color={});var e=void 0===t.margin||null===t.margin||t.margin<0?4:t.margin,n=t.width&&t.width>=21?t.width:void 0,o=t.scale||4;return{width:n,scale:n?4:o,margin:e,color:{dark:r(t.color.dark||"#000000ff"),light:r(t.color.light||"#ffffffff")},type:t.type,rendererOpts:t.rendererOpts||{}}},t.getScale=function(t,r){return r.width&&r.width>=t+2*r.margin?r.width/(t+2*r.margin):r.scale},t.getImageWidth=function(r,e){var n=t.getScale(r,e);return Math.floor((r+2*e.margin)*n)},t.qrToImageData=function(r,e,n){for(var o=e.modules.size,i=e.modules.data,a=t.getScale(o,n),u=Math.floor((o+2*n.margin)*a),s=n.margin*a,f=[n.color.light,n.color.dark],c=0;c<u;c++)for(var h=0;h<u;h++){var d=4*(c*u+h),g=n.color.light;if(c>=s&&h>=s&&c<u-s&&h<u-s)g=f[i[Math.floor((c-s)/a)*o+Math.floor((h-s)/a)]?1:0];r[d++]=g.r,r[d++]=g.g,r[d++]=g.b,r[d]=g.a}}}(dt)),dt}function lt(){return ct||(ct=1,function(t){var r=gt();t.render=function(t,e,n){var o=n,i=e;void 0!==o||e&&e.getContext||(o=e,e=void 0),e||(i=function(){try{return document.createElement("canvas")}catch(t){throw new Error("You need to specify a canvas element")}}()),o=r.getOptions(o);var a=r.getImageWidth(t.modules.size,o),u=i.getContext("2d"),s=u.createImageData(a,a);return r.qrToImageData(s.data,t,o),function(t,r,e){t.clearRect(0,0,r.width,r.height),r.style||(r.style={}),r.height=e,r.width=e,r.style.height=e+"px",r.style.width=e+"px"}(u,i,a),u.putImageData(s,0,0),i},t.renderToDataURL=function(r,e,n){var o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});var i=t.render(r,e,o),a=o.type||"image/png",u=o.rendererOpts||{};return i.toDataURL(a,u.quality)},t.renderToBlob=function(r,e,n,o){var i=o;void 0!==i||n&&n.getContext||(i=n,n=void 0),i||(i={});var a=t.render(e,n,i),u=i.type||"image/png",s=i.rendererOpts||{};a.toBlob(r,u,s.quality)}}(ht)),ht}var vt,pt,wt={};function mt(){if(vt)return wt;vt=1;var t=gt();function r(t,r){var e=t.a/255,n=r+'="'+t.hex+'"';return e<1?n+" "+r+'-opacity="'+e.toFixed(2).slice(1)+'"':n}function e(t,r,e){var n=t+r;return void 0!==e&&(n+=" "+e),n}return wt.render=function(n,o,i){var a=t.getOptions(o),u=n.modules.size,s=n.modules.data,f=u+2*a.margin,c=a.color.light.a?"<path "+r(a.color.light,"fill")+' d="M0 0h'+f+"v"+f+'H0z"/>':"",h="<path "+r(a.color.dark,"stroke")+' d="'+function(t,r,n){for(var o="",i=0,a=!1,u=0,s=0;s<t.length;s++){var f=Math.floor(s%r),c=Math.floor(s/r);f||a||(a=!0),t[s]?(u++,s>0&&f>0&&t[s-1]||(o+=a?e("M",f+n,.5+c+n):e("m",i,0),i=0,a=!1),f+1<r&&t[s+1]||(o+=e("h",u),u=0)):i++}return o}(s,u,a.margin)+'"/>',d='viewBox="0 0 '+f+" "+f+'"',g='<svg xmlns="http://www.w3.org/2000/svg" '+(a.width?'width="'+a.width+'" height="'+a.width+'" ':"")+d+' shape-rendering="crispEdges">'+c+h+"</svg>\n";return"function"==typeof i&&i(null,g),g},wt}var Et=function(){if(pt)return o;pt=1;var t=i(),r=st(),e=lt(),n=mt();function a(e,n,o,i,a){var u=[].slice.call(arguments,1),s=u.length,f="function"==typeof u[s-1];if(!f&&!t())throw new Error("Callback required as last argument");if(!f){if(s<1)throw new Error("Too few arguments provided");return 1===s?(o=n,n=i=void 0):2!==s||n.getContext||(i=o,o=n,n=void 0),new Promise((function(t,a){try{var u=r.create(o,i);t(e(u,n,i))}catch(t){a(t)}}))}if(s<2)throw new Error("Too few arguments provided");2===s?(a=o,o=n,n=i=void 0):3===s&&(n.getContext&&void 0===a?(a=i,i=void 0):(a=i,i=o,o=n,n=void 0));try{var c=r.create(o,i);a(null,e(c,n,i))}catch(t){a(t)}}return o.create=r.create,o.toCanvas=a.bind(null,e.render),o.toDataURL=a.bind(null,e.renderToDataURL),o.toString=a.bind(null,(function(t,r,e){return n.render(t,e)})),o}(),yt=r(Et);return t.default=yt,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); |
@@ -64,1 +64,19 @@ const Utils = require('./utils') | ||
} | ||
exports.renderToBlob = function renderToBlob (cb, qrData, canvas, options) { | ||
let opts = options | ||
if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) { | ||
opts = canvas | ||
canvas = undefined | ||
} | ||
if (!opts) opts = {} | ||
const canvasEl = exports.render(qrData, canvas, opts) | ||
const type = opts.type || 'image/png' | ||
const rendererOpts = opts.rendererOpts || {} | ||
canvasEl.toBlob(cb, type, rendererOpts.quality) | ||
} |
{ | ||
"name": "@slidoapp/qrcode", | ||
"description": "Generate Quick Response (QR) codes using JavaScript in a browser, server side code, or using a command line tool.", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"author": "Ryan Day <soldair@gmail.com>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
199827
3435