diff --git a/.babelrc b/.babelrc
new file mode 100644
index 00000000..7b1c321b
--- /dev/null
+++ b/.babelrc
@@ -0,0 +1,4 @@
+{
+ "presets": ["es2015"],
+ "plugins": ["babel-plugin-add-module-exports"]
+}
\ No newline at end of file
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..48fe40a1
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,12 @@
+root = true
+
+[*]
+indent_style = space
+indent_size = 2
+end_of_line = LF
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 00000000..7797b10b
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,184 @@
+{
+ "ecmaFeatures": {
+ "globalReturn": true,
+ "jsx": true,
+ "modules": true
+ },
+
+ "env": {
+ "browser": true,
+ "es6": true,
+ "node": true
+ },
+
+ "globals": {
+ "document": false,
+ "escape": false,
+ "navigator": false,
+ "unescape": false,
+ "window": false,
+ "describe": true,
+ "before": true,
+ "it": true,
+ "expect": true,
+ "sinon": true
+ },
+
+ "parser": "babel-eslint",
+
+ "plugins": [
+
+ ],
+
+ "rules": {
+ // "block-scoped-var": 2,
+ // "brace-style": [2, "1tbs", { "allowSingleLine": true }],
+ // "camelcase": [2, { "properties": "always" }],
+ // "comma-dangle": [2, "never"],
+ // "comma-spacing": [2, { "before": false, "after": true }],
+ // "comma-style": [2, "last"],
+ // "complexity": 0,
+ // "consistent-return": 2,
+ // "consistent-this": 0,
+ // "curly": [2, "multi-line"],
+ // "default-case": 0,
+ // "dot-location": [2, "property"],
+ // "dot-notation": 0,
+ // "eol-last": 2,
+ // "eqeqeq": [2, "allow-null"],
+ // "func-names": 0,
+ // "func-style": 0,
+ // "generator-star-spacing": [2, "both"],
+ // "guard-for-in": 0,
+ // "handle-callback-err": [2, "^(err|error|anySpecificError)$" ],
+ // "indent": [2, 2, { "SwitchCase": 1 }],
+ // "key-spacing": [2, { "beforeColon": false, "afterColon": true }],
+ // "keyword-spacing": [2, {"before": true, "after": true}],
+ // "linebreak-style": 0,
+ // "max-depth": 0,
+ // "max-len": [2, 120, 4],
+ // "max-nested-callbacks": 0,
+ // "max-params": 0,
+ // "max-statements": 0,
+ // "new-cap": [2, { "newIsCap": true, "capIsNew": false }],
+ // "newline-after-var": [2, "always"],
+ // "new-parens": 2,
+ // "no-alert": 0,
+ // "no-array-constructor": 2,
+ // "no-bitwise": 0,
+ // "no-caller": 2,
+ // "no-catch-shadow": 0,
+ // "no-cond-assign": 2,
+ // "no-console": 0,
+ // "no-constant-condition": 0,
+ // "no-continue": 0,
+ // "no-control-regex": 2,
+ // "no-debugger": 2,
+ // "no-delete-var": 2,
+ // "no-div-regex": 0,
+ // "no-dupe-args": 2,
+ // "no-dupe-keys": 2,
+ // "no-duplicate-case": 2,
+ // "no-else-return": 2,
+ // "no-empty": 0,
+ // "no-empty-character-class": 2,
+ // "no-eq-null": 0,
+ // "no-eval": 2,
+ // "no-ex-assign": 2,
+ // "no-extend-native": 2,
+ // "no-extra-bind": 2,
+ // "no-extra-boolean-cast": 2,
+ // "no-extra-parens": 0,
+ // "no-extra-semi": 0,
+ // "no-extra-strict": 0,
+ // "no-fallthrough": 2,
+ // "no-floating-decimal": 2,
+ // "no-func-assign": 2,
+ // "no-implied-eval": 2,
+ // "no-inline-comments": 0,
+ // "no-inner-declarations": [2, "functions"],
+ // "no-invalid-regexp": 2,
+ // "no-irregular-whitespace": 2,
+ // "no-iterator": 2,
+ // "no-label-var": 2,
+ // "no-labels": 2,
+ // "no-lone-blocks": 0,
+ // "no-lonely-if": 0,
+ // "no-loop-func": 0,
+ // "no-mixed-requires": 0,
+ // "no-mixed-spaces-and-tabs": [2, false],
+ // "no-multi-spaces": 2,
+ // "no-multi-str": 2,
+ // "no-multiple-empty-lines": [2, { "max": 1 }],
+ // "no-native-reassign": 2,
+ // "no-negated-in-lhs": 2,
+ // "no-nested-ternary": 0,
+ // "no-new": 2,
+ // "no-new-func": 2,
+ // "no-new-object": 2,
+ // "no-new-require": 2,
+ // "no-new-wrappers": 2,
+ // "no-obj-calls": 2,
+ // "no-octal": 2,
+ // "no-octal-escape": 2,
+ // "no-path-concat": 0,
+ // "no-plusplus": 0,
+ // "no-process-env": 0,
+ // "no-process-exit": 0,
+ // "no-proto": 2,
+ // "no-redeclare": 2,
+ // "no-regex-spaces": 2,
+ // "no-reserved-keys": 0,
+ // "no-restricted-modules": 0,
+ // "no-return-assign": 2,
+ // "no-script-url": 0,
+ // "no-self-compare": 2,
+ // "no-sequences": 2,
+ // "no-shadow": 0,
+ // "no-shadow-restricted-names": 2,
+ // "no-spaced-func": 2,
+ // "no-sparse-arrays": 2,
+ // "no-sync": 0,
+ // "no-ternary": 0,
+ // "no-throw-literal": 2,
+ // "no-trailing-spaces": 2,
+ // "no-undef": 2,
+ // "no-undef-init": 2,
+ // "no-undefined": 0,
+ // "no-underscore-dangle": 0,
+ // "no-unneeded-ternary": 2,
+ // "no-unreachable": 2,
+ // "no-unused-expressions": 0,
+ // "no-unused-vars": [2, { "vars": "all", "args": "none" }],
+ // "no-use-before-define": 2,
+ // "no-var": 0,
+ // "no-void": 0,
+ // "no-warning-comments": 0,
+ // "no-with": 2,
+ // "one-var": 0,
+ // "operator-assignment": 0,
+ // "operator-linebreak": [2, "after"],
+ // "padded-blocks": 0,
+ // "quote-props": 0,
+ // "quotes": [2, "single", "avoid-escape"],
+ // "radix": 2,
+ // "semi": [2, "always"],
+ // "semi-spacing": 0,
+ // "sort-vars": 0,
+ // "space-before-blocks": [2, "always"],
+ // "space-before-function-paren": [2, {"anonymous": "always", "named": "never"}],
+ // "space-in-brackets": 0,
+ // "space-in-parens": [2, "never"],
+ // "space-infix-ops": 2,
+ // "space-unary-ops": [2, { "words": true, "nonwords": false }],
+ // "spaced-comment": [2, "always"],
+ // "strict": 0,
+ // "use-isnan": 2,
+ // "valid-jsdoc": 0,
+ // "valid-typeof": 2,
+ // "vars-on-top": 2,
+ // "wrap-iife": [2, "any"],
+ // "wrap-regex": 0,
+ // "yoda": [2, "never"]
+ }
+}
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..bc2b59db
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,31 @@
+# Logs
+logs
+*.log
+
+# Runtime data
+pids
+*.pid
+*.seed
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+
+# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (http://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directory
+# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
+node_modules
+
+# Remove some common IDE working directories
+.idea
+.vscode
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 00000000..55bea42d
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Krasimir Tsonev
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
diff --git a/README b/README
deleted file mode 100644
index bf5dd799..00000000
--- a/README
+++ /dev/null
@@ -1,36 +0,0 @@
-JavaScript QRCode reader for HTML5 enabled browser.
-2011 Lazar Laszlo http://lazarsoft.info
-
-Try it online: http://webqr.com
-
-This is a port of ZXing qrcode scanner, http://code.google.com/p/zxing.
-
-Usage:
-
-Include the scripts in the following order:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Set qrcode.callback to function "func(data)", where data will get the decoded information.
-
-Decode image with: qrcode.decode(url or DataURL).
-Decode from canvas with "qr-canvas" ID: qrcode.decode()
-
-[new from 2014.01.09]
-For webcam qrcode decoding (included in the test.html) you will need a browser with getUserMedia (WebRTC) capability.
diff --git a/README.md b/README.md
new file mode 100644
index 00000000..f9d190a9
--- /dev/null
+++ b/README.md
@@ -0,0 +1,34 @@
+JavaScript QRCode reader for HTML5 enabled browser.
+===================================================
+
+This was started as a port of Lazarsoft’s qrcode reader.
+
+It is a maintained fork, so feel free to open issues or PR !
+
+Installation
+============
+
+```
+npm install jsqrcode-modules
+```
+
+Usage
+=====
+
+```
+var qrcode = require('jsqrcode-modules');
+```
+
+Set Webcam
+
+```
+qrcode.setWebcame(element_id)
+```
+
+Set its callback to a custom function:
+
+```
+qrcode.callback = function(result) {
+ console.log(result)
+}
+```
diff --git a/lib/qrcode.js b/lib/qrcode.js
new file mode 100644
index 00000000..e72cbf5c
--- /dev/null
+++ b/lib/qrcode.js
@@ -0,0 +1,3725 @@
+(function webpackUniversalModuleDefinition(root, factory) {
+ if(typeof exports === 'object' && typeof module === 'object')
+ module.exports = factory();
+ else if(typeof define === 'function' && define.amd)
+ define("qrcode", [], factory);
+ else if(typeof exports === 'object')
+ exports["qrcode"] = factory();
+ else
+ root["qrcode"] = factory();
+})(this, function() {
+return /******/ (function(modules) { // webpackBootstrap
+/******/ // The module cache
+/******/ var installedModules = {};
+/******/
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+/******/
+/******/ // Check if module is in cache
+/******/ if(installedModules[moduleId]) {
+/******/ return installedModules[moduleId].exports;
+/******/ }
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = installedModules[moduleId] = {
+/******/ i: moduleId,
+/******/ l: false,
+/******/ exports: {}
+/******/ };
+/******/
+/******/ // Execute the module function
+/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+/******/
+/******/ // Flag the module as loaded
+/******/ module.l = true;
+/******/
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
+/******/
+/******/
+/******/ // expose the modules object (__webpack_modules__)
+/******/ __webpack_require__.m = modules;
+/******/
+/******/ // expose the module cache
+/******/ __webpack_require__.c = installedModules;
+/******/
+/******/ // define getter function for harmony exports
+/******/ __webpack_require__.d = function(exports, name, getter) {
+/******/ if(!__webpack_require__.o(exports, name)) {
+/******/ Object.defineProperty(exports, name, {
+/******/ configurable: false,
+/******/ enumerable: true,
+/******/ get: getter
+/******/ });
+/******/ }
+/******/ };
+/******/
+/******/ // getDefaultExport function for compatibility with non-harmony modules
+/******/ __webpack_require__.n = function(module) {
+/******/ var getter = module && module.__esModule ?
+/******/ function getDefault() { return module['default']; } :
+/******/ function getModuleExports() { return module; };
+/******/ __webpack_require__.d(getter, 'a', getter);
+/******/ return getter;
+/******/ };
+/******/
+/******/ // Object.prototype.hasOwnProperty.call
+/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
+/******/
+/******/ // __webpack_public_path__
+/******/ __webpack_require__.p = "";
+/******/
+/******/ // Load entry module and return exports
+/******/ return __webpack_require__(__webpack_require__.s = 6);
+/******/ })
+/************************************************************************/
+/******/ ([
+/* 0 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.URShift = URShift;
+
+var _detector = __webpack_require__(7);
+
+var _detector2 = _interopRequireDefault(_detector);
+
+var _decoder = __webpack_require__(12);
+
+var _decoder2 = _interopRequireDefault(_decoder);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/*
+ Copyright 2011 Lazar Laszlo (lazarsoft@gmail.com, www.lazarsoft.info)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+var qrcode = {};
+qrcode.imagedata = null;
+qrcode.width = 0;
+qrcode.height = 0;
+qrcode.qrCodeSymbol = null;
+qrcode.debug = false;
+qrcode.maxImgSize = 1024 * 1024;
+
+qrcode.sizeOfDataLengthInfo = [[10, 9, 8, 8], [12, 11, 16, 10], [14, 13, 16, 12]];
+
+qrcode.callback = null;
+qrcode.src = null;
+qrcode.result = null;
+
+qrcode.vidSuccess = function (stream) {
+ qrcode.localstream = stream;
+ // if(qrcode.webkit)
+ // qrcode.video.src = window.webkitURL.createObjectURL(stream);
+ // else
+ // if(qrcode.moz)
+ // {
+ // qrcode.video.mozSrcObject = stream;
+ // qrcode.video.play();
+ // }
+ // else
+ // qrcode.video.src = stream;
+ qrcode.video.src = window.URL.createObjectURL(stream);
+ // if (qrcode.src != null) {
+ // qrcode.src(qrcode.video.src);
+ // }
+ qrcode.gUM = true;
+
+ qrcode.canvas_qr2 = document.createElement('canvas');
+ qrcode.canvas_qr2.id = "qr-canvas";
+ qrcode.qrcontext2 = qrcode.canvas_qr2.getContext('2d');
+ qrcode.canvas_qr2.width = qrcode.video.videoWidth;
+ qrcode.canvas_qr2.height = qrcode.video.videoHeight;
+ setTimeout(qrcode.captureToCanvas, 500);
+};
+
+qrcode.vidError = function (error) {
+ qrcode.gUM = false;
+ return;
+};
+
+qrcode.captureToCanvas = function () {
+ if (qrcode.gUM) {
+ try {
+ if (qrcode.video.videoWidth == 0) {
+ setTimeout(qrcode.captureToCanvas, 500);
+ return;
+ } else {
+ qrcode.canvas_qr2.width = qrcode.video.videoWidth;
+ qrcode.canvas_qr2.height = qrcode.video.videoHeight;
+ }
+ qrcode.qrcontext2.drawImage(qrcode.video, 0, 0);
+ try {
+ qrcode.decode();
+ } catch (e) {
+ console.log(e);
+ setTimeout(qrcode.captureToCanvas, 500);
+ };
+ } catch (e) {
+ console.log(e);
+ setTimeout(qrcode.captureToCanvas, 500);
+ };
+ }
+};
+
+qrcode.destroyWebcam = function () {
+ // qrcode.video.pause()
+ qrcode.localstream.getTracks()[0].stop();
+};
+
+qrcode.setWebcam = function (videoId) {
+ var n = navigator;
+ qrcode.video = document.getElementById(videoId);
+
+ var options = true;
+ if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) {
+ try {
+ navigator.mediaDevices.enumerateDevices().then(function (devices) {
+ devices.forEach(function (device) {
+ console.log("deb1");
+ if (device.kind === 'videoinput') {
+ if (device.label.toLowerCase().search("back") > -1) options = [{
+ 'sourceId': device.deviceId
+ }];
+ }
+ console.log(device.kind + ": " + device.label + " id = " + device.deviceId);
+ });
+ });
+ } catch (e) {
+ console.log(e);
+ }
+ } else {
+ console.log("no navigator.mediaDevices.enumerateDevices");
+ }
+
+ n.mediaDevices.getUserMedia({
+ video: options,
+ audio: false
+ }).then(qrcode.vidSuccess).catch(qrcode.vidError);
+
+ // if(n.getUserMedia)
+ // n.getUserMedia({video: options, audio: false}, qrcode.vidSuccess, qrcode.vidError);
+ // else
+ // if(n.webkitGetUserMedia)
+ // {
+ // qrcode.webkit=true;
+ // n.webkitGetUserMedia({video:options, audio: false}, qrcode.vidSuccess, qrcode.vidError);
+ // }
+ // else
+ // if(n.mozGetUserMedia)
+ // {
+ // qrcode.moz=true;
+ // n.mozGetUserMedia({video: options, audio: false}, qrcode.vidSuccess, qrcode.vidError);
+ // }
+};
+
+qrcode.decode = function (src) {
+
+ if (arguments.length == 0) {
+ if (qrcode.canvas_qr2) {
+ var canvas_qr = qrcode.canvas_qr2;
+ var context = qrcode.qrcontext2;
+ } else {
+ var canvas_qr = document.getElementById("qr-canvas");
+ var context = canvas_qr.getContext('2d');
+ }
+ qrcode.width = canvas_qr.width;
+ qrcode.height = canvas_qr.height;
+ qrcode.imagedata = context.getImageData(0, 0, qrcode.width, qrcode.height);
+ qrcode.result = qrcode.process(context);
+ if (qrcode.callback != null) qrcode.callback(qrcode.result);
+ return qrcode.result;
+ } else {
+ var image = new Image();
+ image.crossOrigin = "Anonymous";
+ image.onload = function () {
+ //var canvas_qr = document.getElementById("qr-canvas");
+ var canvas_out = document.getElementById("out-canvas");
+ if (canvas_out != null) {
+ var outctx = canvas_out.getContext('2d');
+ outctx.clearRect(0, 0, 320, 240);
+ outctx.drawImage(image, 0, 0, 320, 240);
+ }
+
+ var canvas_qr = document.createElement('canvas');
+ var context = canvas_qr.getContext('2d');
+ var nheight = image.height;
+ var nwidth = image.width;
+ if (image.width * image.height > qrcode.maxImgSize) {
+ var ir = image.width / image.height;
+ nheight = Math.sqrt(qrcode.maxImgSize / ir);
+ nwidth = ir * nheight;
+ }
+
+ canvas_qr.width = nwidth;
+ canvas_qr.height = nheight;
+
+ context.drawImage(image, 0, 0, canvas_qr.width, canvas_qr.height);
+ qrcode.width = canvas_qr.width;
+ qrcode.height = canvas_qr.height;
+ try {
+ qrcode.imagedata = context.getImageData(0, 0, canvas_qr.width, canvas_qr.height);
+ } catch (e) {
+ qrcode.result = "Cross domain image reading not supported in your browser! Save it to your computer then drag and drop the file!";
+ if (qrcode.callback != null) qrcode.callback(qrcode.result);
+ return;
+ }
+
+ try {
+ qrcode.result = qrcode.process(context);
+ } catch (e) {
+ console.log(e);
+ qrcode.result = "error decoding QR Code";
+ }
+ if (qrcode.callback != null) qrcode.callback(qrcode.result);
+ };
+ image.onerror = function () {
+ if (qrcode.callback != null) qrcode.callback("Failed to load the image");
+ };
+ image.src = src;
+ }
+};
+
+qrcode.isUrl = function (s) {
+ var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
+ return regexp.test(s);
+};
+
+qrcode.decode_url = function (s) {
+ var escaped = "";
+ try {
+ escaped = escape(s);
+ } catch (e) {
+ console.log(e);
+ escaped = s;
+ }
+ var ret = "";
+ try {
+ ret = decodeURIComponent(escaped);
+ } catch (e) {
+ console.log(e);
+ ret = escaped;
+ }
+ return ret;
+};
+
+qrcode.decode_utf8 = function (s) {
+ if (qrcode.isUrl(s)) return qrcode.decode_url(s);else return s;
+};
+
+qrcode.process = function (ctx) {
+
+ var start = new Date().getTime();
+
+ var image = qrcode.grayScaleToBitmap(qrcode.grayscale());
+ //var image = qrcode.binarize(128);
+
+ if (qrcode.debug) {
+ for (var y = 0; y < qrcode.height; y++) {
+ for (var x = 0; x < qrcode.width; x++) {
+ var point = x * 4 + y * qrcode.width * 4;
+ qrcode.imagedata.data[point] = image[x + y * qrcode.width] ? 0 : 0;
+ qrcode.imagedata.data[point + 1] = image[x + y * qrcode.width] ? 0 : 0;
+ qrcode.imagedata.data[point + 2] = image[x + y * qrcode.width] ? 255 : 0;
+ }
+ }
+ ctx.putImageData(qrcode.imagedata, 0, 0);
+ }
+
+ //var finderPatternInfo = new FinderPatternFinder().findFinderPattern(image);
+
+ var detector = new _detector2.default(image);
+
+ var qRCodeMatrix = detector.detect();
+
+ if (qrcode.debug) {
+ for (var y = 0; y < qRCodeMatrix.bits.Height; y++) {
+ for (var x = 0; x < qRCodeMatrix.bits.Width; x++) {
+ var point = x * 4 * 2 + y * 2 * qrcode.width * 4;
+ qrcode.imagedata.data[point] = qRCodeMatrix.bits.get_Renamed(x, y) ? 0 : 0;
+ qrcode.imagedata.data[point + 1] = qRCodeMatrix.bits.get_Renamed(x, y) ? 0 : 0;
+ qrcode.imagedata.data[point + 2] = qRCodeMatrix.bits.get_Renamed(x, y) ? 255 : 0;
+ }
+ }
+ ctx.putImageData(qrcode.imagedata, 0, 0);
+ }
+
+ var reader = _decoder2.default.decode(qRCodeMatrix.bits);
+ var data = reader.DataByte;
+ var str = "";
+ for (var i = 0; i < data.length; i++) {
+ for (var j = 0; j < data[i].length; j++) {
+ str += String.fromCharCode(data[i][j]);
+ }
+ }
+
+ var end = new Date().getTime();
+ var time = end - start;
+ console.log(time);
+
+ return qrcode.decode_utf8(str);
+ //alert("Time:" + time + " Code: "+str);
+};
+
+qrcode.getPixel = function (x, y) {
+ if (qrcode.width < x) {
+ throw "point error";
+ }
+ if (qrcode.height < y) {
+ throw "point error";
+ }
+ var point = x * 4 + y * qrcode.width * 4;
+ var p = (qrcode.imagedata.data[point] * 33 + qrcode.imagedata.data[point + 1] * 34 + qrcode.imagedata.data[point + 2] * 33) / 100;
+ return p;
+};
+
+qrcode.binarize = function (th) {
+ var ret = new Array(qrcode.width * qrcode.height);
+ for (var y = 0; y < qrcode.height; y++) {
+ for (var x = 0; x < qrcode.width; x++) {
+ var gray = qrcode.getPixel(x, y);
+
+ ret[x + y * qrcode.width] = gray <= th ? true : false;
+ }
+ }
+ return ret;
+};
+
+qrcode.getMiddleBrightnessPerArea = function (image) {
+ var numSqrtArea = 4;
+ //obtain middle brightness((min + max) / 2) per area
+ var areaWidth = Math.floor(qrcode.width / numSqrtArea);
+ var areaHeight = Math.floor(qrcode.height / numSqrtArea);
+ var minmax = new Array(numSqrtArea);
+ for (var i = 0; i < numSqrtArea; i++) {
+ minmax[i] = new Array(numSqrtArea);
+ for (var i2 = 0; i2 < numSqrtArea; i2++) {
+ minmax[i][i2] = new Array(0, 0);
+ }
+ }
+ for (var ay = 0; ay < numSqrtArea; ay++) {
+ for (var ax = 0; ax < numSqrtArea; ax++) {
+ minmax[ax][ay][0] = 0xFF;
+ for (var dy = 0; dy < areaHeight; dy++) {
+ for (var dx = 0; dx < areaWidth; dx++) {
+ var target = image[areaWidth * ax + dx + (areaHeight * ay + dy) * qrcode.width];
+ if (target < minmax[ax][ay][0]) minmax[ax][ay][0] = target;
+ if (target > minmax[ax][ay][1]) minmax[ax][ay][1] = target;
+ }
+ }
+ //minmax[ax][ay][0] = (minmax[ax][ay][0] + minmax[ax][ay][1]) / 2;
+ }
+ }
+ var middle = new Array(numSqrtArea);
+ for (var i3 = 0; i3 < numSqrtArea; i3++) {
+ middle[i3] = new Array(numSqrtArea);
+ }
+ for (var ay = 0; ay < numSqrtArea; ay++) {
+ for (var ax = 0; ax < numSqrtArea; ax++) {
+ middle[ax][ay] = Math.floor((minmax[ax][ay][0] + minmax[ax][ay][1]) / 2);
+ //Console.out.print(middle[ax][ay] + ",");
+ }
+ //Console.out.println("");
+ }
+ //Console.out.println("");
+
+ return middle;
+};
+
+qrcode.grayScaleToBitmap = function (grayScale) {
+ var middle = qrcode.getMiddleBrightnessPerArea(grayScale);
+ var sqrtNumArea = middle.length;
+ var areaWidth = Math.floor(qrcode.width / sqrtNumArea);
+ var areaHeight = Math.floor(qrcode.height / sqrtNumArea);
+
+ var buff = new ArrayBuffer(qrcode.width * qrcode.height);
+ var bitmap = new Uint8Array(buff);
+
+ //var bitmap = new Array(qrcode.height*qrcode.width);
+
+ for (var ay = 0; ay < sqrtNumArea; ay++) {
+ for (var ax = 0; ax < sqrtNumArea; ax++) {
+ for (var dy = 0; dy < areaHeight; dy++) {
+ for (var dx = 0; dx < areaWidth; dx++) {
+ bitmap[areaWidth * ax + dx + (areaHeight * ay + dy) * qrcode.width] = grayScale[areaWidth * ax + dx + (areaHeight * ay + dy) * qrcode.width] < middle[ax][ay] ? true : false;
+ }
+ }
+ }
+ }
+ return bitmap;
+};
+
+qrcode.grayscale = function () {
+ var buff = new ArrayBuffer(qrcode.width * qrcode.height);
+ var ret = new Uint8Array(buff);
+ //var ret = new Array(qrcode.width*qrcode.height);
+
+ for (var y = 0; y < qrcode.height; y++) {
+ for (var x = 0; x < qrcode.width; x++) {
+ var gray = qrcode.getPixel(x, y);
+
+ ret[x + y * qrcode.width] = gray;
+ }
+ }
+ return ret;
+};
+
+exports.default = qrcode;
+function URShift(number, bits) {
+ if (number >= 0) return number >> bits;else return (number >> bits) + (2 << ~bits);
+}
+
+/***/ }),
+/* 1 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = GF256;
+
+var _gf256poly = __webpack_require__(5);
+
+var _gf256poly2 = _interopRequireDefault(_gf256poly);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function GF256(primitive) {
+ this.expTable = new Array(256);
+ this.logTable = new Array(256);
+ var x = 1;
+ for (var i = 0; i < 256; i++) {
+ this.expTable[i] = x;
+ x <<= 1; // x = x * 2; we're assuming the generator alpha is 2
+ if (x >= 0x100) {
+ x ^= primitive;
+ }
+ }
+ for (var i = 0; i < 255; i++) {
+ this.logTable[this.expTable[i]] = i;
+ }
+ // logTable[0] == 0 but this should never be used
+ var at0 = new Array(1);
+ at0[0] = 0;
+ this.zero = new _gf256poly2.default(this, new Array(at0));
+ var at1 = new Array(1);
+ at1[0] = 1;
+ this.one = new _gf256poly2.default(this, new Array(at1));
+
+ this.__defineGetter__("Zero", function () {
+ return this.zero;
+ });
+ this.__defineGetter__("One", function () {
+ return this.one;
+ });
+ this.buildMonomial = function (degree, coefficient) {
+ if (degree < 0) {
+ throw "System.ArgumentException";
+ }
+ if (coefficient == 0) {
+ return this.zero;
+ }
+ var coefficients = new Array(degree + 1);
+ for (var i = 0; i < coefficients.length; i++) {
+ coefficients[i] = 0;
+ }coefficients[0] = coefficient;
+ return new _gf256poly2.default(this, coefficients);
+ };
+ this.exp = function (a) {
+ return this.expTable[a];
+ };
+ this.log = function (a) {
+ if (a == 0) {
+ throw "System.ArgumentException";
+ }
+ return this.logTable[a];
+ };
+ this.inverse = function (a) {
+ if (a == 0) {
+ throw "System.ArithmeticException";
+ }
+ return this.expTable[255 - this.logTable[a]];
+ };
+
+ this.multiply = function (a, b) {
+ if (a == 0 || b == 0) {
+ return 0;
+ }
+ if (a == 1) {
+ return b;
+ }
+ if (b == 1) {
+ return a;
+ }
+ return this.expTable[(this.logTable[a] + this.logTable[b]) % 255];
+ };
+} /*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+ */
+
+/*
+ *
+ * Copyright 2007 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+GF256.QR_CODE_FIELD = new GF256(0x011D);
+GF256.DATA_MATRIX_FIELD = new GF256(0x012D);
+
+GF256.addOrSubtract = function (a, b) {
+ return a ^ b;
+};
+module.exports = exports["default"];
+
+/***/ }),
+/* 2 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = Version;
+
+var _formatinf = __webpack_require__(3);
+
+var _formatinf2 = _interopRequireDefault(_formatinf);
+
+var _bitmat = __webpack_require__(4);
+
+var _bitmat2 = _interopRequireDefault(_bitmat);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+*/
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+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;
+ if (ecBlocks2) this.ecBlocks = new Array(ecBlocks1, ecBlocks2);else this.ecBlocks = new Array(ecBlocks1);
+
+ this.__defineGetter__("ECCodewordsPerBlock", function () {
+ return this.ecCodewordsPerBlock;
+ });
+
+ this.__defineGetter__("TotalECCodewords", function () {
+ return this.ecCodewordsPerBlock * this.NumBlocks;
+ });
+
+ this.__defineGetter__("NumBlocks", function () {
+ var total = 0;
+ for (var 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);
+
+ var total = 0;
+ var ecCodewords = ecBlocks1.ECCodewordsPerBlock;
+ var ecbArray = ecBlocks1.getECBlocks();
+ for (var 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;
+ var bitMatrix = new _bitmat2.default(dimension);
+
+ // Top left finder pattern + separator + format
+ bitMatrix.setRegion(0, 0, 9, 9);
+ // Top right finder pattern + separator + format
+ bitMatrix.setRegion(dimension - 8, 0, 8, 9);
+ // Bottom left finder pattern + separator + format
+ bitMatrix.setRegion(0, dimension - 8, 9, 8);
+
+ // Alignment patterns
+ var max = this.alignmentPatternCenters.length;
+ for (var x = 0; x < max; x++) {
+ var i = this.alignmentPatternCenters[x] - 2;
+ for (var y = 0; y < max; y++) {
+ if (x == 0 && (y == 0 || y == max - 1) || x == max - 1 && y == 0) {
+ // No alignment patterns near the three finder paterns
+ continue;
+ }
+ bitMatrix.setRegion(this.alignmentPatternCenters[y] - 2, i, 5, 5);
+ }
+ }
+
+ // Vertical timing pattern
+ bitMatrix.setRegion(6, 9, 1, dimension - 17);
+ // Horizontal timing pattern
+ bitMatrix.setRegion(9, 6, dimension - 17, 1);
+
+ if (this.versionNumber > 6) {
+ // Version info, top right
+ bitMatrix.setRegion(dimension - 11, 0, 3, 6);
+ // Version info, bottom left
+ bitMatrix.setRegion(0, dimension - 11, 6, 3);
+ }
+
+ return bitMatrix;
+ };
+ this.getECBlocksForLevel = function (ecLevel) {
+ return this.ecBlocks[ecLevel.ordinal()];
+ };
+}
+
+Version.VERSION_DECODE_INFO = new Array(0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, 0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78, 0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683, 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB, 0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, 0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B, 0x2542E, 0x26A64, 0x27541, 0x28C69);
+
+Version.VERSIONS = buildVersions();
+
+Version.getVersionForNumber = function (versionNumber) {
+ if (versionNumber < 1 || versionNumber > 40) {
+ 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) {
+ var bestDifference = 0xffffffff;
+ var bestVersion = 0;
+ for (var i = 0; i < Version.VERSION_DECODE_INFO.length; i++) {
+ var targetVersion = Version.VERSION_DECODE_INFO[i];
+ // Do the version info bits match exactly? done.
+ if (targetVersion == versionBits) {
+ return this.getVersionForNumber(i + 7);
+ }
+ // Otherwise see if this is the closest to a real version info bit string
+ // we have seen so far
+ var bitsDifference = _formatinf2.default.numBitsDiffering(versionBits, targetVersion);
+ if (bitsDifference < bestDifference) {
+ bestVersion = i + 7;
+ bestDifference = bitsDifference;
+ }
+ }
+ // We can tolerate up to 3 bits of error since no two version info codewords will
+ // differ in less than 4 bits.
+ if (bestDifference <= 3) {
+ return this.getVersionForNumber(bestVersion);
+ }
+ // If we didn't find a close enough match, fail
+ return null;
+};
+
+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))));
+}
+module.exports = exports['default'];
+
+/***/ }),
+/* 3 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = FormatInformation;
+
+var _qrcode = __webpack_require__(0);
+
+var _errorlevel = __webpack_require__(8);
+
+var _errorlevel2 = _interopRequireDefault(_errorlevel);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+*/
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+var FORMAT_INFO_MASK_QR = 0x5412;
+var FORMAT_INFO_DECODE_LOOKUP = new Array(new Array(0x5412, 0x00), new Array(0x5125, 0x01), new Array(0x5E7C, 0x02), new Array(0x5B4B, 0x03), new Array(0x45F9, 0x04), new Array(0x40CE, 0x05), new Array(0x4F97, 0x06), new Array(0x4AA0, 0x07), new Array(0x77C4, 0x08), new Array(0x72F3, 0x09), new Array(0x7DAA, 0x0A), new Array(0x789D, 0x0B), new Array(0x662F, 0x0C), new Array(0x6318, 0x0D), new Array(0x6C41, 0x0E), new Array(0x6976, 0x0F), new Array(0x1689, 0x10), new Array(0x13BE, 0x11), new Array(0x1CE7, 0x12), new Array(0x19D0, 0x13), new Array(0x0762, 0x14), new Array(0x0255, 0x15), new Array(0x0D0C, 0x16), new Array(0x083B, 0x17), new Array(0x355F, 0x18), new Array(0x3068, 0x19), new Array(0x3F31, 0x1A), new Array(0x3A06, 0x1B), new Array(0x24B4, 0x1C), new Array(0x2183, 0x1D), new Array(0x2EDA, 0x1E), new Array(0x2BED, 0x1F));
+var 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 = _errorlevel2.default.forBits(formatInfo >> 3 & 0x03);
+ this.dataMask = formatInfo & 0x07;
+
+ this.__defineGetter__("ErrorCorrectionLevel", function () {
+ return this.errorCorrectionLevel;
+ });
+ this.__defineGetter__("DataMask", function () {
+ return this.dataMask;
+ });
+ this.GetHashCode = function () {
+ return this.errorCorrectionLevel.ordinal() << 3 | this.dataMask;
+ };
+ this.Equals = function (o) {
+ var other = o;
+ return this.errorCorrectionLevel == other.errorCorrectionLevel && this.dataMask == other.dataMask;
+ };
+}
+
+FormatInformation.numBitsDiffering = function (a, b) {
+ a ^= b; // a now has a 1 bit exactly where its bit differs with b's
+ // Count bits set quickly with a series of lookups:
+ return BITS_SET_IN_HALF_BYTE[a & 0x0F] + BITS_SET_IN_HALF_BYTE[(0, _qrcode.URShift)(a, 4) & 0x0F] + BITS_SET_IN_HALF_BYTE[(0, _qrcode.URShift)(a, 8) & 0x0F] + BITS_SET_IN_HALF_BYTE[(0, _qrcode.URShift)(a, 12) & 0x0F] + BITS_SET_IN_HALF_BYTE[(0, _qrcode.URShift)(a, 16) & 0x0F] + BITS_SET_IN_HALF_BYTE[(0, _qrcode.URShift)(a, 20) & 0x0F] + BITS_SET_IN_HALF_BYTE[(0, _qrcode.URShift)(a, 24) & 0x0F] + BITS_SET_IN_HALF_BYTE[(0, _qrcode.URShift)(a, 28) & 0x0F];
+};
+
+FormatInformation.decodeFormatInformation = function (maskedFormatInfo) {
+ var formatInfo = FormatInformation.doDecodeFormatInformation(maskedFormatInfo);
+ if (formatInfo != null) {
+ return formatInfo;
+ }
+ // Should return null, but, some QR codes apparently
+ // do not mask this info. Try again by actually masking the pattern
+ // first
+ return FormatInformation.doDecodeFormatInformation(maskedFormatInfo ^ FORMAT_INFO_MASK_QR);
+};
+FormatInformation.doDecodeFormatInformation = function (maskedFormatInfo) {
+ // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing
+ var bestDifference = 0xffffffff;
+ var bestFormatInfo = 0;
+ for (var i = 0; i < FORMAT_INFO_DECODE_LOOKUP.length; i++) {
+ var decodeInfo = FORMAT_INFO_DECODE_LOOKUP[i];
+ var targetInfo = decodeInfo[0];
+ if (targetInfo == maskedFormatInfo) {
+ // Found an exact match
+ return new FormatInformation(decodeInfo[1]);
+ }
+ var bitsDifference = this.numBitsDiffering(maskedFormatInfo, targetInfo);
+ if (bitsDifference < bestDifference) {
+ bestFormatInfo = decodeInfo[1];
+ bestDifference = bitsDifference;
+ }
+ }
+ // Hamming distance of the 32 masked codes is 7, by construction, so <= 3 bits
+ // differing means we found a match
+ if (bestDifference <= 3) {
+ return new FormatInformation(bestFormatInfo);
+ }
+ return null;
+};
+module.exports = exports['default'];
+
+/***/ }),
+/* 4 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = BitMatrix;
+
+var _qrcode = __webpack_require__(0);
+
+function BitMatrix(width, height) {
+ if (!height) height = width;
+ if (width < 1 || height < 1) {
+ throw "Both dimensions must be greater than 0";
+ }
+ this.width = width;
+ this.height = height;
+ var rowSize = width >> 5;
+ if ((width & 0x1f) != 0) {
+ 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, _qrcode.URShift)(this.bits[offset], x & 0x1f) & 1) != 0;
+ };
+ this.set_Renamed = function (x, y) {
+ var offset = y * this.rowSize + (x >> 5);
+ this.bits[offset] |= 1 << (x & 0x1f);
+ };
+ this.flip = function (x, y) {
+ var offset = y * this.rowSize + (x >> 5);
+ this.bits[offset] ^= 1 << (x & 0x1f);
+ };
+ this.clear = function () {
+ var max = this.bits.length;
+ for (var i = 0; i < max; i++) {
+ this.bits[i] = 0;
+ }
+ };
+ this.setRegion = function (left, top, width, height) {
+ if (top < 0 || left < 0) {
+ throw "Left and top must be nonnegative";
+ }
+ if (height < 1 || width < 1) {
+ throw "Height and width must be at least 1";
+ }
+ var right = left + width;
+ var bottom = top + height;
+ if (bottom > this.height || right > this.width) {
+ throw "The region must fit inside the matrix";
+ }
+ for (var y = top; y < bottom; y++) {
+ var offset = y * this.rowSize;
+ for (var x = left; x < right; x++) {
+ this.bits[offset + (x >> 5)] |= 1 << (x & 0x1f);
+ }
+ }
+ };
+} /*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+ */
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+module.exports = exports["default"];
+
+/***/ }),
+/* 5 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = GF256Poly;
+
+var _gf = __webpack_require__(1);
+
+var _gf2 = _interopRequireDefault(_gf);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function GF256Poly(field, coefficients) {
+ if (coefficients == null || coefficients.length == 0) {
+ throw "System.ArgumentException";
+ }
+ this.field = field;
+ var coefficientsLength = coefficients.length;
+ if (coefficientsLength > 1 && coefficients[0] == 0) {
+ // Leading term must be non-zero for anything except the constant polynomial "0"
+ var firstNonZero = 1;
+ while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0) {
+ firstNonZero++;
+ }
+ if (firstNonZero == coefficientsLength) {
+ this.coefficients = field.Zero.coefficients;
+ } else {
+ this.coefficients = new Array(coefficientsLength - firstNonZero);
+ for (var i = 0; i < this.coefficients.length; i++) {
+ this.coefficients[i] = 0;
+ } //Array.Copy(coefficients, firstNonZero, this.coefficients, 0, this.coefficients.length);
+ for (var ci = 0; ci < this.coefficients.length; ci++) {
+ this.coefficients[ci] = coefficients[firstNonZero + ci];
+ }
+ }
+ } else {
+ this.coefficients = coefficients;
+ }
+
+ this.__defineGetter__("Zero", function () {
+ return this.coefficients[0] == 0;
+ });
+ this.__defineGetter__("Degree", function () {
+ return this.coefficients.length - 1;
+ });
+ this.__defineGetter__("Coefficients", function () {
+ return this.coefficients;
+ });
+
+ this.getCoefficient = function (degree) {
+ return this.coefficients[this.coefficients.length - 1 - degree];
+ };
+
+ this.evaluateAt = function (a) {
+ if (a == 0) {
+ // Just return the x^0 coefficient
+ return this.getCoefficient(0);
+ }
+ var size = this.coefficients.length;
+ if (a == 1) {
+ // Just the sum of the coefficients
+ var result = 0;
+ for (var i = 0; i < size; i++) {
+ result = _gf2.default.addOrSubtract(result, this.coefficients[i]);
+ }
+ return result;
+ }
+ var result2 = this.coefficients[0];
+ for (var i = 1; i < size; i++) {
+ result2 = _gf2.default.addOrSubtract(this.field.multiply(a, result2), this.coefficients[i]);
+ }
+ return result2;
+ };
+
+ this.addOrSubtract = function (other) {
+ if (this.field != other.field) {
+ throw "GF256Polys do not have same GF256 field";
+ }
+ if (this.Zero) {
+ return other;
+ }
+ if (other.Zero) {
+ return this;
+ }
+
+ var smallerCoefficients = this.coefficients;
+ var largerCoefficients = other.coefficients;
+ if (smallerCoefficients.length > largerCoefficients.length) {
+ var temp = smallerCoefficients;
+ smallerCoefficients = largerCoefficients;
+ largerCoefficients = temp;
+ }
+ var sumDiff = new Array(largerCoefficients.length);
+ var lengthDiff = largerCoefficients.length - smallerCoefficients.length;
+ // Copy high-order terms only found in higher-degree polynomial's coefficients
+ //Array.Copy(largerCoefficients, 0, sumDiff, 0, lengthDiff);
+ for (var ci = 0; ci < lengthDiff; ci++) {
+ sumDiff[ci] = largerCoefficients[ci];
+ }for (var i = lengthDiff; i < largerCoefficients.length; i++) {
+ sumDiff[i] = _gf2.default.addOrSubtract(smallerCoefficients[i - lengthDiff], largerCoefficients[i]);
+ }
+
+ return new GF256Poly(field, sumDiff);
+ };
+ this.multiply1 = function (other) {
+ if (this.field != other.field) {
+ throw "GF256Polys do not have same GF256 field";
+ }
+ if (this.Zero || other.Zero) {
+ return this.field.Zero;
+ }
+ var aCoefficients = this.coefficients;
+ var aLength = aCoefficients.length;
+ var bCoefficients = other.coefficients;
+ var bLength = bCoefficients.length;
+ var product = new Array(aLength + bLength - 1);
+ for (var i = 0; i < aLength; i++) {
+ var aCoeff = aCoefficients[i];
+ for (var j = 0; j < bLength; j++) {
+ product[i + j] = _gf2.default.addOrSubtract(product[i + j], this.field.multiply(aCoeff, bCoefficients[j]));
+ }
+ }
+ return new GF256Poly(this.field, product);
+ };
+ this.multiply2 = function (scalar) {
+ if (scalar == 0) {
+ return this.field.Zero;
+ }
+ if (scalar == 1) {
+ return this;
+ }
+ var size = this.coefficients.length;
+ var product = new Array(size);
+ for (var i = 0; i < size; i++) {
+ product[i] = this.field.multiply(this.coefficients[i], scalar);
+ }
+ return new GF256Poly(this.field, product);
+ };
+ this.multiplyByMonomial = function (degree, coefficient) {
+ if (degree < 0) {
+ throw "System.ArgumentException";
+ }
+ if (coefficient == 0) {
+ return this.field.Zero;
+ }
+ var size = this.coefficients.length;
+ var product = new Array(size + degree);
+ for (var i = 0; i < product.length; i++) {
+ product[i] = 0;
+ }for (var i = 0; i < size; i++) {
+ product[i] = this.field.multiply(this.coefficients[i], coefficient);
+ }
+ return new GF256Poly(this.field, product);
+ };
+ this.divide = function (other) {
+ if (this.field != other.field) {
+ throw "GF256Polys do not have same GF256 field";
+ }
+ if (other.Zero) {
+ throw "Divide by 0";
+ }
+
+ var quotient = this.field.Zero;
+ var remainder = this;
+
+ var denominatorLeadingTerm = other.getCoefficient(other.Degree);
+ var inverseDenominatorLeadingTerm = this.field.inverse(denominatorLeadingTerm);
+
+ while (remainder.Degree >= other.Degree && !remainder.Zero) {
+ var degreeDifference = remainder.Degree - other.Degree;
+ var scale = this.field.multiply(remainder.getCoefficient(remainder.Degree), inverseDenominatorLeadingTerm);
+ var term = other.multiplyByMonomial(degreeDifference, scale);
+ var iterationQuotient = this.field.buildMonomial(degreeDifference, scale);
+ quotient = quotient.addOrSubtract(iterationQuotient);
+ remainder = remainder.addOrSubtract(term);
+ }
+
+ return new Array(quotient, remainder);
+ };
+} /*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+ */
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+module.exports = exports["default"];
+
+/***/ }),
+/* 6 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _qrcode = __webpack_require__(0);
+
+var _qrcode2 = _interopRequireDefault(_qrcode);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+exports.default = _qrcode2.default;
+module.exports = exports['default'];
+
+/***/ }),
+/* 7 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = Detector;
+
+var _qrcode = __webpack_require__(0);
+
+var _qrcode2 = _interopRequireDefault(_qrcode);
+
+var _version = __webpack_require__(2);
+
+var _version2 = _interopRequireDefault(_version);
+
+var _alignpat = __webpack_require__(9);
+
+var _grid = __webpack_require__(10);
+
+var _grid2 = _interopRequireDefault(_grid);
+
+var _findpat = __webpack_require__(11);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+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) {
+ var max = points.length;
+ var a11 = this.a11;
+ var a12 = this.a12;
+ var a13 = this.a13;
+ var a21 = this.a21;
+ var a22 = this.a22;
+ var a23 = this.a23;
+ var a31 = this.a31;
+ var a32 = this.a32;
+ var a33 = this.a33;
+ for (var i = 0; i < max; i += 2) {
+ var x = points[i];
+ var y = points[i + 1];
+ var 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) {
+ var n = xValues.length;
+ for (var i = 0; i < n; i++) {
+ var x = xValues[i];
+ var y = yValues[i];
+ var 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 () {
+ // Adjoint is the transpose of the cofactor matrix:
+ 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);
+ };
+} /*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+ */
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+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);
+ var sToQ = this.squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p);
+ return sToQ.times(qToS);
+};
+
+PerspectiveTransform.squareToQuadrilateral = function (x0, y0, x1, y1, x2, y2, x3, y3) {
+ var dy2 = y3 - y2;
+ var dy3 = y0 - y1 + y2 - y3;
+ if (dy2 == 0.0 && dy3 == 0.0) {
+ return new PerspectiveTransform(x1 - x0, x2 - x1, x0, y1 - y0, y2 - y1, y0, 0.0, 0.0, 1.0);
+ } else {
+ var dx1 = x1 - x2;
+ var dx2 = x3 - x2;
+ var dx3 = x0 - x1 + x2 - x3;
+ var dy1 = y1 - y2;
+ var denominator = dx1 * dy2 - dx2 * dy1;
+ var a13 = (dx3 * dy2 - dx2 * dy3) / denominator;
+ var a23 = (dx1 * dy3 - dx3 * dy1) / denominator;
+ return new PerspectiveTransform(x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, y1 - y0 + a13 * y1, y3 - y0 + a23 * y3, y0, a13, a23, 1.0);
+ }
+};
+
+PerspectiveTransform.quadrilateralToSquare = function (x0, y0, x1, y1, x2, y2, x3, y3) {
+ // Here, the adjoint serves as the inverse:
+ return this.squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3).buildAdjoint();
+};
+
+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) {
+ // Mild variant of Bresenham's algorithm;
+ // see http://en.wikipedia.org/wiki/Bresenham's_line_algorithm
+ 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;
+ }
+
+ var dx = Math.abs(toX - fromX);
+ var dy = Math.abs(toY - fromY);
+ var error = -dx >> 1;
+ var ystep = fromY < toY ? 1 : -1;
+ var xstep = fromX < toX ? 1 : -1;
+ var state = 0; // In black pixels, looking for white, first or second time
+ for (var x = fromX, y = fromY; x != toX; x += xstep) {
+
+ var realX = steep ? y : x;
+ var realY = steep ? x : y;
+ if (state == 1) {
+ // In white pixels, looking for black
+ if (this.image[realX + realY * _qrcode2.default.width]) {
+ state++;
+ }
+ } else {
+ if (!this.image[realX + realY * _qrcode2.default.width]) {
+ state++;
+ }
+ }
+
+ if (state == 3) {
+ // Found black, white, black, and stumbled back onto white; done
+ var diffX = x - fromX;
+ var diffY = y - fromY;
+ return Math.sqrt(diffX * diffX + diffY * diffY);
+ }
+ error += dy;
+ if (error > 0) {
+ if (y == toY) {
+ break;
+ }
+ y += ystep;
+ error -= dx;
+ }
+ }
+ var diffX2 = toX - fromX;
+ var 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);
+
+ // Now count other way -- don't run off image though of course
+ var scale = 1.0;
+ var otherToX = fromX - (toX - fromX);
+ if (otherToX < 0) {
+ scale = fromX / (fromX - otherToX);
+ otherToX = 0;
+ } else if (otherToX >= _qrcode2.default.width) {
+ scale = (_qrcode2.default.width - 1 - fromX) / (otherToX - fromX);
+ otherToX = _qrcode2.default.width - 1;
+ }
+ var otherToY = Math.floor(fromY - (toY - fromY) * scale);
+
+ scale = 1.0;
+ if (otherToY < 0) {
+ scale = fromY / (fromY - otherToY);
+ otherToY = 0;
+ } else if (otherToY >= _qrcode2.default.height) {
+ scale = (_qrcode2.default.height - 1 - fromY) / (otherToY - fromY);
+ otherToY = _qrcode2.default.height - 1;
+ }
+ otherToX = Math.floor(fromX + (otherToX - fromX) * scale);
+
+ result += this.sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY);
+ return result - 1.0; // -1 because we counted the middle pixel twice
+ };
+
+ 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));
+ var moduleSizeEst2 = this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(otherPattern.X), Math.floor(otherPattern.Y), Math.floor(pattern.X), Math.floor(pattern.Y));
+ if (isNaN(moduleSizeEst1)) {
+ return moduleSizeEst2 / 7.0;
+ }
+ if (isNaN(moduleSizeEst2)) {
+ return moduleSizeEst1 / 7.0;
+ }
+ // Average them, and divide by 7 since we've counted the width of 3 black modules,
+ // and 1 white and 1 black module on either side. Ergo, divide sum by 14.
+ return (moduleSizeEst1 + moduleSizeEst2) / 14.0;
+ };
+
+ this.calculateModuleSize = function (topLeft, topRight, bottomLeft) {
+ // Take the average
+ return (this.calculateModuleSizeOneWay(topLeft, topRight) + this.calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0;
+ };
+
+ this.distance = function (pattern1, pattern2) {
+ var xDiff = pattern1.X - pattern2.X;
+ var yDiff = pattern1.Y - pattern2.Y;
+ return Math.sqrt(xDiff * xDiff + yDiff * yDiff);
+ };
+ this.computeDimension = function (topLeft, topRight, bottomLeft, moduleSize) {
+
+ var tltrCentersDimension = Math.round(this.distance(topLeft, topRight) / moduleSize);
+ var tlblCentersDimension = Math.round(this.distance(topLeft, bottomLeft) / moduleSize);
+ var dimension = (tltrCentersDimension + tlblCentersDimension >> 1) + 7;
+ switch (dimension & 0x03) {
+
+ // mod 4
+ case 0:
+ dimension++;
+ break;
+ // 1? do nothing
+
+ case 2:
+ dimension--;
+ break;
+
+ case 3:
+ throw "Error";
+ }
+ return dimension;
+ };
+
+ this.findAlignmentInRegion = function (overallEstModuleSize, estAlignmentX, estAlignmentY, allowanceFactor) {
+ // Look for an alignment pattern (3 modules in size) around where it
+ // should be
+ var allowance = Math.floor(allowanceFactor * overallEstModuleSize);
+ var alignmentAreaLeftX = Math.max(0, estAlignmentX - allowance);
+ var alignmentAreaRightX = Math.min(_qrcode2.default.width - 1, estAlignmentX + allowance);
+ if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) {
+ throw "Error";
+ }
+
+ var alignmentAreaTopY = Math.max(0, estAlignmentY - allowance);
+ var alignmentAreaBottomY = Math.min(_qrcode2.default.height - 1, estAlignmentY + allowance);
+
+ var alignmentFinder = new _alignpat.AlignmentPatternFinder(this.image, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, this.resultPointCallback);
+ return alignmentFinder.find();
+ };
+
+ this.createTransform = function (topLeft, topRight, bottomLeft, alignmentPattern, dimension) {
+ var dimMinusThree = dimension - 3.5;
+ var bottomRightX;
+ var bottomRightY;
+ var sourceBottomRightX;
+ var sourceBottomRightY;
+ if (alignmentPattern != null) {
+ bottomRightX = alignmentPattern.X;
+ bottomRightY = alignmentPattern.Y;
+ sourceBottomRightX = sourceBottomRightY = dimMinusThree - 3.0;
+ } else {
+ // Don't have an alignment pattern, just make up the bottom-right point
+ bottomRightX = topRight.X - topLeft.X + bottomLeft.X;
+ bottomRightY = topRight.Y - topLeft.Y + bottomLeft.Y;
+ sourceBottomRightX = sourceBottomRightY = dimMinusThree;
+ }
+
+ var transform = 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);
+
+ return transform;
+ };
+
+ this.sampleGrid = function (image, transform, dimension) {
+
+ var sampler = _grid2.default;
+ return sampler.sampleGrid3(image, dimension, transform);
+ };
+
+ this.processFinderPatternInfo = function (info) {
+
+ var topLeft = info.TopLeft;
+ var topRight = info.TopRight;
+ var bottomLeft = info.BottomLeft;
+
+ var moduleSize = this.calculateModuleSize(topLeft, topRight, bottomLeft);
+ if (moduleSize < 1.0) {
+ throw "Error";
+ }
+ var dimension = this.computeDimension(topLeft, topRight, bottomLeft, moduleSize);
+ var provisionalVersion = _version2.default.getProvisionalVersionForDimension(dimension);
+ var modulesBetweenFPCenters = provisionalVersion.DimensionForVersion - 7;
+
+ var alignmentPattern = null;
+ // Anything above version 1 has an alignment pattern
+ if (provisionalVersion.AlignmentPatternCenters.length > 0) {
+
+ // Guess where a "bottom right" finder pattern would have been
+ var bottomRightX = topRight.X - topLeft.X + bottomLeft.X;
+ var bottomRightY = topRight.Y - topLeft.Y + bottomLeft.Y;
+
+ // Estimate that alignment pattern is closer by 3 modules
+ // from "bottom right" to known top left location
+ var correctionToTopLeft = 1.0 - 3.0 / modulesBetweenFPCenters;
+ var estAlignmentX = Math.floor(topLeft.X + correctionToTopLeft * (bottomRightX - topLeft.X));
+ var estAlignmentY = Math.floor(topLeft.Y + correctionToTopLeft * (bottomRightY - topLeft.Y));
+
+ // Kind of arbitrary -- expand search radius before giving up
+ for (var i = 4; i <= 16; i <<= 1) {
+ //try
+ //{
+ alignmentPattern = this.findAlignmentInRegion(moduleSize, estAlignmentX, estAlignmentY, i);
+ break;
+ //}
+ //catch (re)
+ //{
+ // try next round
+ //}
+ }
+ // If we didn't find alignment pattern... well try anyway without it
+ }
+
+ var transform = this.createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);
+
+ var bits = this.sampleGrid(this.image, transform, dimension);
+
+ var points;
+ if (alignmentPattern == null) {
+ points = new Array(bottomLeft, topLeft, topRight);
+ } else {
+ points = new Array(bottomLeft, topLeft, topRight, alignmentPattern);
+ }
+ return new DetectorResult(bits, points);
+ };
+
+ this.detect = function () {
+ var info = new _findpat.FinderPatternFinder().findFinderPattern(this.image);
+
+ return this.processFinderPatternInfo(info);
+ };
+}
+module.exports = exports['default'];
+
+/***/ }),
+/* 8 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = ErrorCorrectionLevel;
+/*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+*/
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+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;
+ };
+}
+
+ErrorCorrectionLevel.forBits = function (bits) {
+ if (bits < 0 || bits >= FOR_BITS.length) {
+ throw "ArgumentException";
+ }
+ return FOR_BITS[bits];
+};
+
+var L = new ErrorCorrectionLevel(0, 0x01, "L");
+var M = new ErrorCorrectionLevel(1, 0x00, "M");
+var Q = new ErrorCorrectionLevel(2, 0x03, "Q");
+var H = new ErrorCorrectionLevel(3, 0x02, "H");
+var FOR_BITS = new Array(M, L, H, Q);
+module.exports = exports["default"];
+
+/***/ }),
+/* 9 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = AlignmentPattern;
+exports.AlignmentPatternFinder = AlignmentPatternFinder;
+
+var _qrcode = __webpack_require__(0);
+
+var _qrcode2 = _interopRequireDefault(_qrcode);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function AlignmentPattern(posX, posY, estimatedModuleSize) {
+ this.x = posX;
+ this.y = posY;
+ this.count = 1;
+ this.estimatedModuleSize = estimatedModuleSize;
+
+ this.__defineGetter__("EstimatedModuleSize", function () {
+ return this.estimatedModuleSize;
+ });
+ this.__defineGetter__("Count", function () {
+ return this.count;
+ });
+ this.__defineGetter__("X", function () {
+ return Math.floor(this.x);
+ });
+ this.__defineGetter__("Y", function () {
+ return Math.floor(this.y);
+ });
+ this.incrementCount = function () {
+ this.count++;
+ };
+ this.aboutEquals = function (moduleSize, i, j) {
+ if (Math.abs(i - this.y) <= moduleSize && Math.abs(j - this.x) <= moduleSize) {
+ var moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize);
+ return moduleSizeDiff <= 1.0 || moduleSizeDiff / this.estimatedModuleSize <= 1.0;
+ }
+ return false;
+ };
+} /*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+ */
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+function AlignmentPatternFinder(image, startX, startY, width, height, moduleSize, resultPointCallback) {
+ this.image = image;
+ this.possibleCenters = new Array();
+ this.startX = startX;
+ this.startY = startY;
+ this.width = width;
+ this.height = height;
+ this.moduleSize = moduleSize;
+ this.crossCheckStateCount = new Array(0, 0, 0);
+ this.resultPointCallback = resultPointCallback;
+
+ this.centerFromEnd = function (stateCount, end) {
+ return end - stateCount[2] - stateCount[1] / 2.0;
+ };
+ this.foundPatternCross = function (stateCount) {
+ var moduleSize = this.moduleSize;
+ var maxVariance = moduleSize / 2.0;
+ for (var i = 0; i < 3; i++) {
+ if (Math.abs(moduleSize - stateCount[i]) >= maxVariance) {
+ return false;
+ }
+ }
+ return true;
+ };
+
+ this.crossCheckVertical = function (startI, centerJ, maxCount, originalStateCountTotal) {
+ var image = this.image;
+
+ var maxI = _qrcode2.default.height;
+ var stateCount = this.crossCheckStateCount;
+ stateCount[0] = 0;
+ stateCount[1] = 0;
+ stateCount[2] = 0;
+
+ // Start counting up from center
+ var i = startI;
+ while (i >= 0 && image[centerJ + i * _qrcode2.default.width] && stateCount[1] <= maxCount) {
+ stateCount[1]++;
+ i--;
+ }
+ // If already too many modules in this state or ran off the edge:
+ if (i < 0 || stateCount[1] > maxCount) {
+ return NaN;
+ }
+ while (i >= 0 && !image[centerJ + i * _qrcode2.default.width] && stateCount[0] <= maxCount) {
+ stateCount[0]++;
+ i--;
+ }
+ if (stateCount[0] > maxCount) {
+ return NaN;
+ }
+
+ // Now also count down from center
+ i = startI + 1;
+ while (i < maxI && image[centerJ + i * _qrcode2.default.width] && stateCount[1] <= maxCount) {
+ stateCount[1]++;
+ i++;
+ }
+ if (i == maxI || stateCount[1] > maxCount) {
+ return NaN;
+ }
+ while (i < maxI && !image[centerJ + i * _qrcode2.default.width] && stateCount[2] <= maxCount) {
+ stateCount[2]++;
+ i++;
+ }
+ if (stateCount[2] > maxCount) {
+ return NaN;
+ }
+
+ var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
+ if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) {
+ return NaN;
+ }
+
+ return this.foundPatternCross(stateCount) ? this.centerFromEnd(stateCount, i) : NaN;
+ };
+
+ this.handlePossibleCenter = function (stateCount, i, j) {
+ var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
+ var centerJ = this.centerFromEnd(stateCount, j);
+ var centerI = this.crossCheckVertical(i, Math.floor(centerJ), 2 * stateCount[1], stateCountTotal);
+ if (!isNaN(centerI)) {
+ var estimatedModuleSize = (stateCount[0] + stateCount[1] + stateCount[2]) / 3.0;
+ var max = this.possibleCenters.length;
+ for (var index = 0; index < max; index++) {
+ var center = this.possibleCenters[index];
+ // Look for about the same center and module size:
+ if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) {
+ return new AlignmentPattern(centerJ, centerI, estimatedModuleSize);
+ }
+ }
+ // Hadn't found this before; save it
+ var point = new AlignmentPattern(centerJ, centerI, estimatedModuleSize);
+ this.possibleCenters.push(point);
+ if (this.resultPointCallback != null) {
+ this.resultPointCallback.foundPossibleResultPoint(point);
+ }
+ }
+ return null;
+ };
+
+ this.find = function () {
+ var startX = this.startX;
+ var height = this.height;
+ var maxJ = startX + width;
+ var middleI = startY + (height >> 1);
+ // We are looking for black/white/black modules in 1:1:1 ratio;
+ // this tracks the number of black/white/black modules seen so far
+ var stateCount = new Array(0, 0, 0);
+ for (var iGen = 0; iGen < height; iGen++) {
+ // Search from middle outwards
+ var i = middleI + ((iGen & 0x01) == 0 ? iGen + 1 >> 1 : -(iGen + 1 >> 1));
+ stateCount[0] = 0;
+ stateCount[1] = 0;
+ stateCount[2] = 0;
+ var j = startX;
+ // Burn off leading white pixels before anything else; if we start in the middle of
+ // a white run, it doesn't make sense to count its length, since we don't know if the
+ // white run continued to the left of the start point
+ while (j < maxJ && !image[j + _qrcode2.default.width * i]) {
+ j++;
+ }
+ var currentState = 0;
+ while (j < maxJ) {
+ if (image[j + i * _qrcode2.default.width]) {
+ // Black pixel
+ if (currentState == 1) {
+ // Counting black pixels
+ stateCount[currentState]++;
+ } else {
+ // Counting white pixels
+ if (currentState == 2) {
+ // A winner?
+ if (this.foundPatternCross(stateCount)) {
+ // Yes
+ var confirmed = this.handlePossibleCenter(stateCount, i, j);
+ if (confirmed != null) {
+ return confirmed;
+ }
+ }
+ stateCount[0] = stateCount[2];
+ stateCount[1] = 1;
+ stateCount[2] = 0;
+ currentState = 1;
+ } else {
+ stateCount[++currentState]++;
+ }
+ }
+ } else {
+ // White pixel
+ if (currentState == 1) {
+ // Counting black pixels
+ currentState++;
+ }
+ stateCount[currentState]++;
+ }
+ j++;
+ }
+ if (this.foundPatternCross(stateCount)) {
+ var confirmed = this.handlePossibleCenter(stateCount, i, maxJ);
+ if (confirmed != null) {
+ return confirmed;
+ }
+ }
+ }
+
+ // Hmm, nothing we saw was observed and confirmed twice. If we had
+ // any guess at all, return it.
+ if (!(this.possibleCenters.length == 0)) {
+ return this.possibleCenters[0];
+ }
+
+ throw "Couldn't find enough alignment patterns";
+ };
+}
+
+/***/ }),
+/* 10 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _bitmat = __webpack_require__(4);
+
+var _bitmat2 = _interopRequireDefault(_bitmat);
+
+var _qrcode = __webpack_require__(0);
+
+var _qrcode2 = _interopRequireDefault(_qrcode);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+*/
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+var GridSampler = {};
+
+GridSampler.checkAndNudgePoints = function (image, points) {
+ var width = _qrcode2.default.width;
+ var height = _qrcode2.default.height;
+ // Check and nudge points from start until we see some that are OK:
+ var nudged = true;
+ for (var offset = 0; offset < points.length && nudged; offset += 2) {
+ var x = Math.floor(points[offset]);
+ var y = Math.floor(points[offset + 1]);
+ if (x < -1 || x > width || y < -1 || y > height) {
+ throw "Error.checkAndNudgePoints ";
+ }
+ nudged = false;
+ if (x == -1) {
+ points[offset] = 0.0;
+ nudged = true;
+ } else if (x == width) {
+ points[offset] = width - 1;
+ nudged = true;
+ }
+ if (y == -1) {
+ points[offset + 1] = 0.0;
+ nudged = true;
+ } else if (y == height) {
+ points[offset + 1] = height - 1;
+ nudged = true;
+ }
+ }
+ // Check and nudge points from end:
+ nudged = true;
+ for (var offset = points.length - 2; offset >= 0 && nudged; offset -= 2) {
+ var x = Math.floor(points[offset]);
+ var y = Math.floor(points[offset + 1]);
+ if (x < -1 || x > width || y < -1 || y > height) {
+ throw "Error.checkAndNudgePoints ";
+ }
+ nudged = false;
+ if (x == -1) {
+ points[offset] = 0.0;
+ nudged = true;
+ } else if (x == width) {
+ points[offset] = width - 1;
+ nudged = true;
+ }
+ if (y == -1) {
+ points[offset + 1] = 0.0;
+ nudged = true;
+ } else if (y == height) {
+ points[offset + 1] = height - 1;
+ nudged = true;
+ }
+ }
+};
+
+GridSampler.sampleGrid3 = function (image, dimension, transform) {
+ var bits = new _bitmat2.default(dimension);
+ var points = new Array(dimension << 1);
+ for (var y = 0; y < dimension; y++) {
+ var max = points.length;
+ var iValue = y + 0.5;
+ for (var x = 0; x < max; x += 2) {
+ points[x] = (x >> 1) + 0.5;
+ points[x + 1] = iValue;
+ }
+ transform.transformPoints1(points);
+ // Quick check to see if points transformed to something inside the image;
+ // sufficient to check the endpoints
+ GridSampler.checkAndNudgePoints(image, points);
+ try {
+ for (var x = 0; x < max; x += 2) {
+ //var xpoint = (Math.floor( points[x]) * 4) + (Math.floor( points[x + 1]) * qrcode.width * 4);
+ var bit = image[Math.floor(points[x]) + _qrcode2.default.width * Math.floor(points[x + 1])];
+ //qrcode.imagedata.data[xpoint] = bit?255:0;
+ //qrcode.imagedata.data[xpoint+1] = bit?255:0;
+ //qrcode.imagedata.data[xpoint+2] = 0;
+ //qrcode.imagedata.data[xpoint+3] = 255;
+ //bits[x >> 1][ y]=bit;
+ if (bit) bits.set_Renamed(x >> 1, y);
+ }
+ } catch (aioobe) {
+ // This feels wrong, but, sometimes if the finder patterns are misidentified, the resulting
+ // transform gets "twisted" such that it maps a straight line of points to a set of points
+ // whose endpoints are in bounds, but others are not. There is probably some mathematical
+ // way to detect this about the transformation that I don't know yet.
+ // This results in an ugly runtime exception despite our clever checks above -- can't have
+ // that. We could check each point's coordinates but that feels duplicative. We settle for
+ // catching and wrapping ArrayIndexOutOfBoundsException.
+ throw "Error.checkAndNudgePoints";
+ }
+ }
+ return bits;
+};
+
+GridSampler.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);
+};
+
+exports.default = GridSampler;
+module.exports = exports['default'];
+
+/***/ }),
+/* 11 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.FinderPatternFinder = FinderPatternFinder;
+
+var _qrcode = __webpack_require__(0);
+
+var _qrcode2 = _interopRequireDefault(_qrcode);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+var MIN_SKIP = 3; /*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+ */
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+var MAX_MODULES = 57;
+var INTEGER_MATH_SHIFT = 8;
+var CENTER_QUORUM = 2;
+
+function orderBestPatterns(patterns) {
+
+ function distance(pattern1, pattern2) {
+ var xDiff = pattern1.X - pattern2.X;
+ var yDiff = pattern1.Y - pattern2.Y;
+ return Math.sqrt(xDiff * xDiff + yDiff * yDiff);
+ }
+
+ /// Returns the z component of the cross product between vectors BC and BA.
+ function crossProductZ(pointA, pointB, pointC) {
+ var bX = pointB.x;
+ var bY = pointB.y;
+ return (pointC.x - bX) * (pointA.y - bY) - (pointC.y - bY) * (pointA.x - bX);
+ }
+
+ // Find distances between pattern centers
+ var zeroOneDistance = distance(patterns[0], patterns[1]);
+ var oneTwoDistance = distance(patterns[1], patterns[2]);
+ var zeroTwoDistance = distance(patterns[0], patterns[2]);
+
+ var pointA, pointB, pointC;
+ // Assume one closest to other two is B; A and C will just be guesses at first
+ if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) {
+ pointB = patterns[0];
+ pointA = patterns[1];
+ pointC = patterns[2];
+ } else if (zeroTwoDistance >= oneTwoDistance && zeroTwoDistance >= zeroOneDistance) {
+ pointB = patterns[1];
+ pointA = patterns[0];
+ pointC = patterns[2];
+ } else {
+ pointB = patterns[2];
+ pointA = patterns[0];
+ pointC = patterns[1];
+ }
+
+ // Use cross product to figure out whether A and C are correct or flipped.
+ // This asks whether BC x BA has a positive z component, which is the arrangement
+ // we want for A, B, C. If it's negative, then we've got it flipped around and
+ // should swap A and C.
+ if (crossProductZ(pointA, pointB, pointC) < 0.0) {
+ var temp = pointA;
+ pointA = pointC;
+ pointC = temp;
+ }
+
+ patterns[0] = pointA;
+ patterns[1] = pointB;
+ patterns[2] = pointC;
+}
+
+function FinderPattern(posX, posY, estimatedModuleSize) {
+ this.x = posX;
+ this.y = posY;
+ this.count = 1;
+ this.estimatedModuleSize = estimatedModuleSize;
+
+ this.__defineGetter__("EstimatedModuleSize", function () {
+ return this.estimatedModuleSize;
+ });
+ this.__defineGetter__("Count", function () {
+ return this.count;
+ });
+ this.__defineGetter__("X", function () {
+ return this.x;
+ });
+ this.__defineGetter__("Y", function () {
+ return this.y;
+ });
+ this.incrementCount = function () {
+ this.count++;
+ };
+ this.aboutEquals = function (moduleSize, i, j) {
+ if (Math.abs(i - this.y) <= moduleSize && Math.abs(j - this.x) <= moduleSize) {
+ var moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize);
+ return moduleSizeDiff <= 1.0 || moduleSizeDiff / this.estimatedModuleSize <= 1.0;
+ }
+ return false;
+ };
+}
+
+function FinderPatternInfo(patternCenters) {
+ this.bottomLeft = patternCenters[0];
+ this.topLeft = patternCenters[1];
+ this.topRight = patternCenters[2];
+ this.__defineGetter__("BottomLeft", function () {
+ return this.bottomLeft;
+ });
+ this.__defineGetter__("TopLeft", function () {
+ return this.topLeft;
+ });
+ this.__defineGetter__("TopRight", function () {
+ return this.topRight;
+ });
+}
+
+function FinderPatternFinder() {
+ this.image = null;
+ this.possibleCenters = [];
+ this.hasSkipped = false;
+ this.crossCheckStateCount = new Array(0, 0, 0, 0, 0);
+ this.resultPointCallback = null;
+
+ this.__defineGetter__("CrossCheckStateCount", function () {
+ this.crossCheckStateCount[0] = 0;
+ this.crossCheckStateCount[1] = 0;
+ this.crossCheckStateCount[2] = 0;
+ this.crossCheckStateCount[3] = 0;
+ this.crossCheckStateCount[4] = 0;
+ return this.crossCheckStateCount;
+ });
+
+ this.foundPatternCross = function (stateCount) {
+ var totalModuleSize = 0;
+ for (var i = 0; i < 5; i++) {
+ var count = stateCount[i];
+ if (count == 0) {
+ return false;
+ }
+ totalModuleSize += count;
+ }
+ if (totalModuleSize < 7) {
+ return false;
+ }
+ var moduleSize = Math.floor((totalModuleSize << INTEGER_MATH_SHIFT) / 7);
+ var maxVariance = Math.floor(moduleSize / 2);
+ // Allow less than 50% variance from 1-1-3-1-1 proportions
+ return Math.abs(moduleSize - (stateCount[0] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(moduleSize - (stateCount[1] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(3 * moduleSize - (stateCount[2] << INTEGER_MATH_SHIFT)) < 3 * maxVariance && Math.abs(moduleSize - (stateCount[3] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(moduleSize - (stateCount[4] << INTEGER_MATH_SHIFT)) < maxVariance;
+ };
+ this.centerFromEnd = function (stateCount, end) {
+ return end - stateCount[4] - stateCount[3] - stateCount[2] / 2.0;
+ };
+ this.crossCheckVertical = function (startI, centerJ, maxCount, originalStateCountTotal) {
+ var image = this.image;
+
+ var maxI = _qrcode2.default.height;
+ var stateCount = this.CrossCheckStateCount;
+
+ // Start counting up from center
+ var i = startI;
+ while (i >= 0 && image[centerJ + i * _qrcode2.default.width]) {
+ stateCount[2]++;
+ i--;
+ }
+ if (i < 0) {
+ return NaN;
+ }
+ while (i >= 0 && !image[centerJ + i * _qrcode2.default.width] && stateCount[1] <= maxCount) {
+ stateCount[1]++;
+ i--;
+ }
+ // If already too many modules in this state or ran off the edge:
+ if (i < 0 || stateCount[1] > maxCount) {
+ return NaN;
+ }
+ while (i >= 0 && image[centerJ + i * _qrcode2.default.width] && stateCount[0] <= maxCount) {
+ stateCount[0]++;
+ i--;
+ }
+ if (stateCount[0] > maxCount) {
+ return NaN;
+ }
+
+ // Now also count down from center
+ i = startI + 1;
+ while (i < maxI && image[centerJ + i * _qrcode2.default.width]) {
+ stateCount[2]++;
+ i++;
+ }
+ if (i == maxI) {
+ return NaN;
+ }
+ while (i < maxI && !image[centerJ + i * _qrcode2.default.width] && stateCount[3] < maxCount) {
+ stateCount[3]++;
+ i++;
+ }
+ if (i == maxI || stateCount[3] >= maxCount) {
+ return NaN;
+ }
+ while (i < maxI && image[centerJ + i * _qrcode2.default.width] && stateCount[4] < maxCount) {
+ stateCount[4]++;
+ i++;
+ }
+ if (stateCount[4] >= maxCount) {
+ return NaN;
+ }
+
+ // If we found a finder-pattern-like section, but its size is more than 40% different than
+ // the original, assume it's a false positive
+ var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
+ if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) {
+ return NaN;
+ }
+
+ return this.foundPatternCross(stateCount) ? this.centerFromEnd(stateCount, i) : NaN;
+ };
+ this.crossCheckHorizontal = function (startJ, centerI, maxCount, originalStateCountTotal) {
+ var image = this.image;
+
+ var maxJ = _qrcode2.default.width;
+ var stateCount = this.CrossCheckStateCount;
+
+ var j = startJ;
+ while (j >= 0 && image[j + centerI * _qrcode2.default.width]) {
+ stateCount[2]++;
+ j--;
+ }
+ if (j < 0) {
+ return NaN;
+ }
+ while (j >= 0 && !image[j + centerI * _qrcode2.default.width] && stateCount[1] <= maxCount) {
+ stateCount[1]++;
+ j--;
+ }
+ if (j < 0 || stateCount[1] > maxCount) {
+ return NaN;
+ }
+ while (j >= 0 && image[j + centerI * _qrcode2.default.width] && stateCount[0] <= maxCount) {
+ stateCount[0]++;
+ j--;
+ }
+ if (stateCount[0] > maxCount) {
+ return NaN;
+ }
+
+ j = startJ + 1;
+ while (j < maxJ && image[j + centerI * _qrcode2.default.width]) {
+ stateCount[2]++;
+ j++;
+ }
+ if (j == maxJ) {
+ return NaN;
+ }
+ while (j < maxJ && !image[j + centerI * _qrcode2.default.width] && stateCount[3] < maxCount) {
+ stateCount[3]++;
+ j++;
+ }
+ if (j == maxJ || stateCount[3] >= maxCount) {
+ return NaN;
+ }
+ while (j < maxJ && image[j + centerI * _qrcode2.default.width] && stateCount[4] < maxCount) {
+ stateCount[4]++;
+ j++;
+ }
+ if (stateCount[4] >= maxCount) {
+ return NaN;
+ }
+
+ // If we found a finder-pattern-like section, but its size is significantly different than
+ // the original, assume it's a false positive
+ var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
+ if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= originalStateCountTotal) {
+ return NaN;
+ }
+
+ return this.foundPatternCross(stateCount) ? this.centerFromEnd(stateCount, j) : NaN;
+ };
+ this.handlePossibleCenter = function (stateCount, i, j) {
+ var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
+ var centerJ = this.centerFromEnd(stateCount, j); //float
+ var centerI = this.crossCheckVertical(i, Math.floor(centerJ), stateCount[2], stateCountTotal); //float
+ if (!isNaN(centerI)) {
+ // Re-cross check
+ centerJ = this.crossCheckHorizontal(Math.floor(centerJ), Math.floor(centerI), stateCount[2], stateCountTotal);
+ if (!isNaN(centerJ)) {
+ var estimatedModuleSize = stateCountTotal / 7.0;
+ var found = false;
+ var max = this.possibleCenters.length;
+ for (var index = 0; index < max; index++) {
+ var center = this.possibleCenters[index];
+ // Look for about the same center and module size:
+ if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) {
+ center.incrementCount();
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ var point = new FinderPattern(centerJ, centerI, estimatedModuleSize);
+ this.possibleCenters.push(point);
+ if (this.resultPointCallback != null) {
+ this.resultPointCallback.foundPossibleResultPoint(point);
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ };
+
+ this.selectBestPatterns = function () {
+
+ var startSize = this.possibleCenters.length;
+ if (startSize < 3) {
+ // Couldn't find enough finder patterns
+ throw "Couldn't find enough finder patterns (found " + startSize + ")";
+ }
+
+ // Filter outlier possibilities whose module size is too different
+ if (startSize > 3) {
+ // But we can only afford to do so if we have at least 4 possibilities to choose from
+ var totalModuleSize = 0.0;
+ var square = 0.0;
+ for (var i = 0; i < startSize; i++) {
+ //totalModuleSize += this.possibleCenters[i].EstimatedModuleSize;
+ var centerValue = this.possibleCenters[i].EstimatedModuleSize;
+ totalModuleSize += centerValue;
+ square += centerValue * centerValue;
+ }
+ var average = totalModuleSize / startSize;
+ this.possibleCenters.sort(function (center1, center2) {
+ var dA = Math.abs(center2.EstimatedModuleSize - average);
+ var dB = Math.abs(center1.EstimatedModuleSize - average);
+ if (dA < dB) {
+ return -1;
+ } else if (dA == dB) {
+ return 0;
+ } else {
+ return 1;
+ }
+ });
+
+ var stdDev = Math.sqrt(square / startSize - average * average);
+ var limit = Math.max(0.2 * average, stdDev);
+ //for (var i = 0; i < this.possibleCenters.length && this.possibleCenters.length > 3; i++)
+ for (var i = this.possibleCenters.length - 1; i >= 0; i--) {
+ var pattern = this.possibleCenters[i];
+ //if (Math.abs(pattern.EstimatedModuleSize - average) > 0.2 * average)
+ if (Math.abs(pattern.EstimatedModuleSize - average) > limit) {
+ //this.possibleCenters.remove(i);
+ this.possibleCenters.splice(i, 1);
+ //i--;
+ }
+ }
+ }
+
+ if (this.possibleCenters.length > 3) {
+ // Throw away all but those first size candidate points we found.
+ this.possibleCenters.sort(function (a, b) {
+ if (a.count > b.count) {
+ return -1;
+ }
+ if (a.count < b.count) {
+ return 1;
+ }
+ return 0;
+ });
+ }
+
+ return new Array(this.possibleCenters[0], this.possibleCenters[1], this.possibleCenters[2]);
+ };
+
+ this.findRowSkip = function () {
+ var max = this.possibleCenters.length;
+ if (max <= 1) {
+ return 0;
+ }
+ var firstConfirmedCenter = null;
+ for (var i = 0; i < max; i++) {
+ var center = this.possibleCenters[i];
+ if (center.Count >= CENTER_QUORUM) {
+ if (firstConfirmedCenter == null) {
+ firstConfirmedCenter = center;
+ } else {
+ // We have two confirmed centers
+ // How far down can we skip before resuming looking for the next
+ // pattern? In the worst case, only the difference between the
+ // difference in the x / y coordinates of the two centers.
+ // This is the case where you find top left last.
+ this.hasSkipped = true;
+ return Math.floor((Math.abs(firstConfirmedCenter.X - center.X) - Math.abs(firstConfirmedCenter.Y - center.Y)) / 2);
+ }
+ }
+ }
+ return 0;
+ };
+
+ this.haveMultiplyConfirmedCenters = function () {
+ var confirmedCount = 0;
+ var totalModuleSize = 0.0;
+ var max = this.possibleCenters.length;
+ for (var i = 0; i < max; i++) {
+ var pattern = this.possibleCenters[i];
+ if (pattern.Count >= CENTER_QUORUM) {
+ confirmedCount++;
+ totalModuleSize += pattern.EstimatedModuleSize;
+ }
+ }
+ if (confirmedCount < 3) {
+ return false;
+ }
+ // OK, we have at least 3 confirmed centers, but, it's possible that one is a "false positive"
+ // and that we need to keep looking. We detect this by asking if the estimated module sizes
+ // vary too much. We arbitrarily say that when the total deviation from average exceeds
+ // 5% of the total module size estimates, it's too much.
+ var average = totalModuleSize / max;
+ var totalDeviation = 0.0;
+ for (var i = 0; i < max; i++) {
+ pattern = this.possibleCenters[i];
+ totalDeviation += Math.abs(pattern.EstimatedModuleSize - average);
+ }
+ return totalDeviation <= 0.05 * totalModuleSize;
+ };
+
+ this.findFinderPattern = function (image) {
+ var tryHarder = false;
+ this.image = image;
+ var maxI = _qrcode2.default.height;
+ var maxJ = _qrcode2.default.width;
+ var iSkip = Math.floor(3 * maxI / (4 * MAX_MODULES));
+ if (iSkip < MIN_SKIP || tryHarder) {
+ iSkip = MIN_SKIP;
+ }
+
+ var done = false;
+ var stateCount = new Array(5);
+ for (var i = iSkip - 1; i < maxI && !done; i += iSkip) {
+ // Get a row of black/white values
+ stateCount[0] = 0;
+ stateCount[1] = 0;
+ stateCount[2] = 0;
+ stateCount[3] = 0;
+ stateCount[4] = 0;
+ var currentState = 0;
+ for (var j = 0; j < maxJ; j++) {
+ if (image[j + i * _qrcode2.default.width]) {
+ // Black pixel
+ if ((currentState & 1) == 1) {
+ // Counting white pixels
+ currentState++;
+ }
+ stateCount[currentState]++;
+ } else {
+ // White pixel
+ if ((currentState & 1) == 0) {
+ // Counting black pixels
+ if (currentState == 4) {
+ // A winner?
+ if (this.foundPatternCross(stateCount)) {
+ // Yes
+ var confirmed = this.handlePossibleCenter(stateCount, i, j);
+ if (confirmed) {
+ // Start examining every other line. Checking each line turned out to be too
+ // expensive and didn't improve performance.
+ iSkip = 2;
+ if (this.hasSkipped) {
+ done = this.haveMultiplyConfirmedCenters();
+ } else {
+ var rowSkip = this.findRowSkip();
+ if (rowSkip > stateCount[2]) {
+ // Skip rows between row of lower confirmed center
+ // and top of presumed third confirmed center
+ // but back up a bit to get a full chance of detecting
+ // it, entire width of center of finder pattern
+
+ // Skip by rowSkip, but back off by stateCount[2] (size of last center
+ // of pattern we saw) to be conservative, and also back off by iSkip which
+ // is about to be re-added
+ i += rowSkip - stateCount[2] - iSkip;
+ j = maxJ - 1;
+ }
+ }
+ } else {
+ // Advance to next black pixel
+ do {
+ j++;
+ } while (j < maxJ && !image[j + i * _qrcode2.default.width]);
+ j--; // back up to that last white pixel
+ }
+ // Clear state to start looking again
+ currentState = 0;
+ stateCount[0] = 0;
+ stateCount[1] = 0;
+ stateCount[2] = 0;
+ stateCount[3] = 0;
+ stateCount[4] = 0;
+ } else {
+ // No, shift counts back by two
+ stateCount[0] = stateCount[2];
+ stateCount[1] = stateCount[3];
+ stateCount[2] = stateCount[4];
+ stateCount[3] = 1;
+ stateCount[4] = 0;
+ currentState = 3;
+ }
+ } else {
+ stateCount[++currentState]++;
+ }
+ } else {
+ // Counting white pixels
+ stateCount[currentState]++;
+ }
+ }
+ }
+ if (this.foundPatternCross(stateCount)) {
+ var confirmed = this.handlePossibleCenter(stateCount, i, maxJ);
+ if (confirmed) {
+ iSkip = stateCount[0];
+ if (this.hasSkipped) {
+ // Found a third one
+ done = this.haveMultiplyConfirmedCenters();
+ }
+ }
+ }
+ }
+
+ var patternInfo = this.selectBestPatterns();
+ orderBestPatterns(patternInfo);
+
+ return new FinderPatternInfo(patternInfo);
+ };
+}
+
+/***/ }),
+/* 12 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _rsdecoder = __webpack_require__(13);
+
+var _rsdecoder2 = _interopRequireDefault(_rsdecoder);
+
+var _gf = __webpack_require__(1);
+
+var _gf2 = _interopRequireDefault(_gf);
+
+var _bmparser = __webpack_require__(14);
+
+var _bmparser2 = _interopRequireDefault(_bmparser);
+
+var _datablock = __webpack_require__(16);
+
+var _datablock2 = _interopRequireDefault(_datablock);
+
+var _databr = __webpack_require__(17);
+
+var _databr2 = _interopRequireDefault(_databr);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+var Decoder = {}; /*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+ */
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+Decoder.rsDecoder = new _rsdecoder2.default(_gf2.default.QR_CODE_FIELD);
+
+Decoder.correctErrors = function (codewordBytes, numDataCodewords) {
+ var numCodewords = codewordBytes.length;
+ // First read into an array of ints
+ var codewordsInts = new Array(numCodewords);
+ for (var i = 0; i < numCodewords; i++) {
+ codewordsInts[i] = codewordBytes[i] & 0xFF;
+ }
+ var numECCodewords = codewordBytes.length - numDataCodewords;
+ try {
+ Decoder.rsDecoder.decode(codewordsInts, numECCodewords);
+ //var corrector = new ReedSolomon(codewordsInts, numECCodewords);
+ //corrector.correct();
+ } catch (rse) {
+ throw rse;
+ }
+ // Copy back into array of bytes -- only need to worry about the bytes that were data
+ // We don't care about errors in the error-correction codewords
+ for (var i = 0; i < numDataCodewords; i++) {
+ codewordBytes[i] = codewordsInts[i];
+ }
+};
+
+Decoder.decode = function (bits) {
+ var parser = new _bmparser2.default(bits);
+ var version = parser.readVersion();
+ var ecLevel = parser.readFormatInformation().ErrorCorrectionLevel;
+
+ // Read codewords
+ var codewords = parser.readCodewords();
+
+ // Separate into data blocks
+ var dataBlocks = _datablock2.default.getDataBlocks(codewords, version, ecLevel);
+
+ // Count total number of data bytes
+ var totalBytes = 0;
+ for (var i = 0; i < dataBlocks.length; i++) {
+ totalBytes += dataBlocks[i].NumDataCodewords;
+ }
+ var resultBytes = new Array(totalBytes);
+ var resultOffset = 0;
+
+ // Error-correct and copy data blocks together into a stream of bytes
+ for (var j = 0; j < dataBlocks.length; j++) {
+ var dataBlock = dataBlocks[j];
+ var codewordBytes = dataBlock.Codewords;
+ var numDataCodewords = dataBlock.NumDataCodewords;
+ Decoder.correctErrors(codewordBytes, numDataCodewords);
+ for (var i = 0; i < numDataCodewords; i++) {
+ resultBytes[resultOffset++] = codewordBytes[i];
+ }
+ }
+
+ // Decode the contents of that stream of bytes
+ var reader = new _databr2.default(resultBytes, version.VersionNumber, ecLevel.Bits);
+ return reader;
+ //return DecodedBitStreamParser.decode(resultBytes, version, ecLevel);
+};
+
+exports.default = Decoder;
+module.exports = exports['default'];
+
+/***/ }),
+/* 13 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = ReedSolomonDecoder;
+
+var _gf = __webpack_require__(1);
+
+var _gf2 = _interopRequireDefault(_gf);
+
+var _gf256poly = __webpack_require__(5);
+
+var _gf256poly2 = _interopRequireDefault(_gf256poly);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+*/
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+function ReedSolomonDecoder(field) {
+ this.field = field;
+ this.decode = function (received, twoS) {
+ var poly = new _gf256poly2.default(this.field, received);
+ var syndromeCoefficients = new Array(twoS);
+ for (var i = 0; i < syndromeCoefficients.length; i++) {
+ syndromeCoefficients[i] = 0;
+ }var dataMatrix = false; //this.field.Equals(GF256.DATA_MATRIX_FIELD);
+ var noError = true;
+ for (var i = 0; i < twoS; i++) {
+ // Thanks to sanfordsquires for this fix:
+ var evalu = poly.evaluateAt(this.field.exp(dataMatrix ? i + 1 : i));
+ syndromeCoefficients[syndromeCoefficients.length - 1 - i] = evalu;
+ if (evalu != 0) {
+ noError = false;
+ }
+ }
+ if (noError) {
+ return;
+ }
+ var syndrome = new _gf256poly2.default(this.field, syndromeCoefficients);
+ var sigmaOmega = this.runEuclideanAlgorithm(this.field.buildMonomial(twoS, 1), syndrome, twoS);
+ var sigma = sigmaOmega[0];
+ var omega = sigmaOmega[1];
+ var errorLocations = this.findErrorLocations(sigma);
+ var errorMagnitudes = this.findErrorMagnitudes(omega, errorLocations, dataMatrix);
+ for (var i = 0; i < errorLocations.length; i++) {
+ var position = received.length - 1 - this.field.log(errorLocations[i]);
+ if (position < 0) {
+ throw "ReedSolomonException Bad error location";
+ }
+ received[position] = _gf2.default.addOrSubtract(received[position], errorMagnitudes[i]);
+ }
+ };
+
+ this.runEuclideanAlgorithm = function (a, b, R) {
+ // Assume a's degree is >= b's
+ if (a.Degree < b.Degree) {
+ var temp = a;
+ a = b;
+ b = temp;
+ }
+
+ var rLast = a;
+ var r = b;
+ var sLast = this.field.One;
+ var s = this.field.Zero;
+ var tLast = this.field.Zero;
+ var t = this.field.One;
+
+ // Run Euclidean algorithm until r's degree is less than R/2
+ while (r.Degree >= Math.floor(R / 2)) {
+ var rLastLast = rLast;
+ var sLastLast = sLast;
+ var tLastLast = tLast;
+ rLast = r;
+ sLast = s;
+ tLast = t;
+
+ // Divide rLastLast by rLast, with quotient in q and remainder in r
+ if (rLast.Zero) {
+ // Oops, Euclidean algorithm already terminated?
+ throw "r_{i-1} was zero";
+ }
+ r = rLastLast;
+ var q = this.field.Zero;
+ var denominatorLeadingTerm = rLast.getCoefficient(rLast.Degree);
+ var dltInverse = this.field.inverse(denominatorLeadingTerm);
+ while (r.Degree >= rLast.Degree && !r.Zero) {
+ var degreeDiff = r.Degree - rLast.Degree;
+ var scale = this.field.multiply(r.getCoefficient(r.Degree), dltInverse);
+ q = q.addOrSubtract(this.field.buildMonomial(degreeDiff, scale));
+ r = r.addOrSubtract(rLast.multiplyByMonomial(degreeDiff, scale));
+ //r.EXE();
+ }
+
+ s = q.multiply1(sLast).addOrSubtract(sLastLast);
+ t = q.multiply1(tLast).addOrSubtract(tLastLast);
+ }
+
+ var sigmaTildeAtZero = t.getCoefficient(0);
+ if (sigmaTildeAtZero == 0) {
+ throw "ReedSolomonException sigmaTilde(0) was zero";
+ }
+
+ var inverse = this.field.inverse(sigmaTildeAtZero);
+ var sigma = t.multiply2(inverse);
+ var omega = r.multiply2(inverse);
+ return new Array(sigma, omega);
+ };
+ this.findErrorLocations = function (errorLocator) {
+ // This is a direct application of Chien's search
+ var numErrors = errorLocator.Degree;
+ if (numErrors == 1) {
+ // shortcut
+ return new Array(errorLocator.getCoefficient(1));
+ }
+ var result = new Array(numErrors);
+ var e = 0;
+ for (var i = 1; i < 256 && e < numErrors; i++) {
+ if (errorLocator.evaluateAt(i) == 0) {
+ result[e] = this.field.inverse(i);
+ e++;
+ }
+ }
+ if (e != numErrors) {
+ throw "Error locator degree does not match number of roots";
+ }
+ return result;
+ };
+ this.findErrorMagnitudes = function (errorEvaluator, errorLocations, dataMatrix) {
+ // This is directly applying Forney's Formula
+ var s = errorLocations.length;
+ var result = new Array(s);
+ for (var i = 0; i < s; i++) {
+ var xiInverse = this.field.inverse(errorLocations[i]);
+ var denominator = 1;
+ for (var j = 0; j < s; j++) {
+ if (i != j) {
+ denominator = this.field.multiply(denominator, _gf2.default.addOrSubtract(1, this.field.multiply(errorLocations[j], xiInverse)));
+ }
+ }
+ result[i] = this.field.multiply(errorEvaluator.evaluateAt(xiInverse), this.field.inverse(denominator));
+ // Thanks to sanfordsquires for this fix:
+ if (dataMatrix) {
+ result[i] = this.field.multiply(result[i], xiInverse);
+ }
+ }
+ return result;
+ };
+}
+module.exports = exports['default'];
+
+/***/ }),
+/* 14 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = BitMatrixParser;
+
+var _formatinf = __webpack_require__(3);
+
+var _formatinf2 = _interopRequireDefault(_formatinf);
+
+var _version = __webpack_require__(2);
+
+var _version2 = _interopRequireDefault(_version);
+
+var _datamask = __webpack_require__(15);
+
+var _datamask2 = _interopRequireDefault(_datamask);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function BitMatrixParser(bitMatrix) {
+ var dimension = bitMatrix.Dimension;
+ if (dimension < 21 || (dimension & 0x03) != 1) {
+ throw "Error BitMatrixParser";
+ }
+ this.bitMatrix = bitMatrix;
+ this.parsedVersion = null;
+ this.parsedFormatInfo = null;
+
+ this.copyBit = function (i, j, versionBits) {
+ return this.bitMatrix.get_Renamed(i, j) ? versionBits << 1 | 0x1 : versionBits << 1;
+ };
+
+ this.readFormatInformation = function () {
+ if (this.parsedFormatInfo != null) {
+ return this.parsedFormatInfo;
+ }
+
+ // Read top-left format info bits
+ var formatInfoBits = 0;
+ for (var i = 0; i < 6; i++) {
+ formatInfoBits = this.copyBit(i, 8, formatInfoBits);
+ }
+ // .. and skip a bit in the timing pattern ...
+ formatInfoBits = this.copyBit(7, 8, formatInfoBits);
+ formatInfoBits = this.copyBit(8, 8, formatInfoBits);
+ formatInfoBits = this.copyBit(8, 7, formatInfoBits);
+ // .. and skip a bit in the timing pattern ...
+ for (var j = 5; j >= 0; j--) {
+ formatInfoBits = this.copyBit(8, j, formatInfoBits);
+ }
+
+ this.parsedFormatInfo = _formatinf2.default.decodeFormatInformation(formatInfoBits);
+ if (this.parsedFormatInfo != null) {
+ return this.parsedFormatInfo;
+ }
+
+ // Hmm, failed. Try the top-right/bottom-left pattern
+ var dimension = this.bitMatrix.Dimension;
+ formatInfoBits = 0;
+ var iMin = dimension - 8;
+ for (var i = dimension - 1; i >= iMin; i--) {
+ formatInfoBits = this.copyBit(i, 8, formatInfoBits);
+ }
+ for (var j = dimension - 7; j < dimension; j++) {
+ formatInfoBits = this.copyBit(8, j, formatInfoBits);
+ }
+
+ this.parsedFormatInfo = _formatinf2.default.decodeFormatInformation(formatInfoBits);
+ if (this.parsedFormatInfo != null) {
+ return this.parsedFormatInfo;
+ }
+ throw "Error readFormatInformation";
+ };
+ this.readVersion = function () {
+
+ if (this.parsedVersion != null) {
+ return this.parsedVersion;
+ }
+
+ var dimension = this.bitMatrix.Dimension;
+
+ var provisionalVersion = dimension - 17 >> 2;
+ if (provisionalVersion <= 6) {
+ return _version2.default.getVersionForNumber(provisionalVersion);
+ }
+
+ // Read top-right version info: 3 wide by 6 tall
+ var versionBits = 0;
+ var ijMin = dimension - 11;
+ for (var j = 5; j >= 0; j--) {
+ for (var i = dimension - 9; i >= ijMin; i--) {
+ versionBits = this.copyBit(i, j, versionBits);
+ }
+ }
+
+ this.parsedVersion = _version2.default.decodeVersionInformation(versionBits);
+ if (this.parsedVersion != null && this.parsedVersion.DimensionForVersion == dimension) {
+ return this.parsedVersion;
+ }
+
+ // Hmm, failed. Try bottom left: 6 wide by 3 tall
+ versionBits = 0;
+ for (var i = 5; i >= 0; i--) {
+ for (var j = dimension - 9; j >= ijMin; j--) {
+ versionBits = this.copyBit(i, j, versionBits);
+ }
+ }
+
+ this.parsedVersion = _version2.default.decodeVersionInformation(versionBits);
+ if (this.parsedVersion != null && this.parsedVersion.DimensionForVersion == dimension) {
+ return this.parsedVersion;
+ }
+ throw "Error readVersion";
+ };
+ this.readCodewords = function () {
+
+ var formatInfo = this.readFormatInformation();
+ var version = this.readVersion();
+
+ // Get the data mask for the format used in this QR Code. This will exclude
+ // some bits from reading as we wind through the bit matrix.
+ var dataMask = _datamask2.default.forReference(formatInfo.DataMask);
+ var dimension = this.bitMatrix.Dimension;
+ dataMask.unmaskBitMatrix(this.bitMatrix, dimension);
+
+ var functionPattern = version.buildFunctionPattern();
+
+ var readingUp = true;
+ var result = new Array(version.TotalCodewords);
+ var resultOffset = 0;
+ var currentByte = 0;
+ var bitsRead = 0;
+ // Read columns in pairs, from right to left
+ for (var j = dimension - 1; j > 0; j -= 2) {
+ if (j == 6) {
+ // Skip whole column with vertical alignment pattern;
+ // saves time and makes the other code proceed more cleanly
+ j--;
+ }
+ // Read alternatingly from bottom to top then top to bottom
+ for (var count = 0; count < dimension; count++) {
+ var i = readingUp ? dimension - 1 - count : count;
+ for (var col = 0; col < 2; col++) {
+ // Ignore bits covered by the function pattern
+ if (!functionPattern.get_Renamed(j - col, i)) {
+ // Read a bit
+ bitsRead++;
+ currentByte <<= 1;
+ if (this.bitMatrix.get_Renamed(j - col, i)) {
+ currentByte |= 1;
+ }
+ // If we've made a whole byte, save it off
+ if (bitsRead == 8) {
+ result[resultOffset++] = currentByte;
+ bitsRead = 0;
+ currentByte = 0;
+ }
+ }
+ }
+ }
+ readingUp ^= true; // readingUp = !readingUp; // switch directions
+ }
+ if (resultOffset != version.TotalCodewords) {
+ throw "Error readCodewords";
+ }
+ return result;
+ };
+} /*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+ */
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+module.exports = exports['default'];
+
+/***/ }),
+/* 15 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _qrcode = __webpack_require__(0);
+
+var DataMask = {}; /*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+ */
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+DataMask.forReference = function (reference) {
+ if (reference < 0 || reference > 7) {
+ throw "System.ArgumentException";
+ }
+ return DataMask.DATA_MASKS[reference];
+};
+
+function DataMask000() {
+ this.unmaskBitMatrix = function (bits, dimension) {
+ for (var i = 0; i < dimension; i++) {
+ for (var j = 0; j < dimension; j++) {
+ if (this.isMasked(i, j)) {
+ bits.flip(j, i);
+ }
+ }
+ }
+ };
+ this.isMasked = function (i, j) {
+ return (i + j & 0x01) == 0;
+ };
+}
+
+function DataMask001() {
+ this.unmaskBitMatrix = function (bits, dimension) {
+ for (var i = 0; i < dimension; i++) {
+ for (var j = 0; j < dimension; j++) {
+ if (this.isMasked(i, j)) {
+ bits.flip(j, i);
+ }
+ }
+ }
+ };
+ this.isMasked = function (i, j) {
+ return (i & 0x01) == 0;
+ };
+}
+
+function DataMask010() {
+ this.unmaskBitMatrix = function (bits, dimension) {
+ for (var i = 0; i < dimension; i++) {
+ for (var j = 0; j < dimension; j++) {
+ if (this.isMasked(i, j)) {
+ bits.flip(j, i);
+ }
+ }
+ }
+ };
+ this.isMasked = function (i, j) {
+ return j % 3 == 0;
+ };
+}
+
+function DataMask011() {
+ this.unmaskBitMatrix = function (bits, dimension) {
+ for (var i = 0; i < dimension; i++) {
+ for (var j = 0; j < dimension; j++) {
+ if (this.isMasked(i, j)) {
+ bits.flip(j, i);
+ }
+ }
+ }
+ };
+ this.isMasked = function (i, j) {
+ return (i + j) % 3 == 0;
+ };
+}
+
+function DataMask100() {
+ this.unmaskBitMatrix = function (bits, dimension) {
+ for (var i = 0; i < dimension; i++) {
+ for (var j = 0; j < dimension; j++) {
+ if (this.isMasked(i, j)) {
+ bits.flip(j, i);
+ }
+ }
+ }
+ };
+ this.isMasked = function (i, j) {
+ return ((0, _qrcode.URShift)(i, 1) + j / 3 & 0x01) == 0;
+ };
+}
+
+function DataMask101() {
+ this.unmaskBitMatrix = function (bits, dimension) {
+ for (var i = 0; i < dimension; i++) {
+ for (var j = 0; j < dimension; j++) {
+ if (this.isMasked(i, j)) {
+ bits.flip(j, i);
+ }
+ }
+ }
+ };
+ this.isMasked = function (i, j) {
+ var temp = i * j;
+ return (temp & 0x01) + temp % 3 == 0;
+ };
+}
+
+function DataMask110() {
+ this.unmaskBitMatrix = function (bits, dimension) {
+ for (var i = 0; i < dimension; i++) {
+ for (var j = 0; j < dimension; j++) {
+ if (this.isMasked(i, j)) {
+ bits.flip(j, i);
+ }
+ }
+ }
+ };
+ this.isMasked = function (i, j) {
+ var temp = i * j;
+ return ((temp & 0x01) + temp % 3 & 0x01) == 0;
+ };
+}
+function DataMask111() {
+ this.unmaskBitMatrix = function (bits, dimension) {
+ for (var i = 0; i < dimension; i++) {
+ for (var j = 0; j < dimension; j++) {
+ if (this.isMasked(i, j)) {
+ bits.flip(j, i);
+ }
+ }
+ }
+ };
+ this.isMasked = function (i, j) {
+ return ((i + j & 0x01) + i * j % 3 & 0x01) == 0;
+ };
+}
+
+DataMask.DATA_MASKS = new Array(new DataMask000(), new DataMask001(), new DataMask010(), new DataMask011(), new DataMask100(), new DataMask101(), new DataMask110(), new DataMask111());
+
+exports.default = DataMask;
+module.exports = exports["default"];
+
+/***/ }),
+/* 16 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = DataBlock;
+/*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+*/
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+function DataBlock(numDataCodewords, codewords) {
+ this.numDataCodewords = numDataCodewords;
+ this.codewords = codewords;
+
+ this.__defineGetter__("NumDataCodewords", function () {
+ return this.numDataCodewords;
+ });
+ this.__defineGetter__("Codewords", function () {
+ return this.codewords;
+ });
+}
+
+DataBlock.getDataBlocks = function (rawCodewords, version, ecLevel) {
+
+ if (rawCodewords.length != version.TotalCodewords) {
+ throw "ArgumentException";
+ }
+
+ // Figure out the number and size of data blocks used by this version and
+ // error correction level
+ var ecBlocks = version.getECBlocksForLevel(ecLevel);
+
+ // First count the total number of data blocks
+ var totalBlocks = 0;
+ var ecBlockArray = ecBlocks.getECBlocks();
+ for (var i = 0; i < ecBlockArray.length; i++) {
+ totalBlocks += ecBlockArray[i].Count;
+ }
+
+ // Now establish DataBlocks of the appropriate size and number of data codewords
+ var result = new Array(totalBlocks);
+ var numResultBlocks = 0;
+ for (var j = 0; j < ecBlockArray.length; j++) {
+ var ecBlock = ecBlockArray[j];
+ for (var i = 0; i < ecBlock.Count; i++) {
+ var numDataCodewords = ecBlock.DataCodewords;
+ var numBlockCodewords = ecBlocks.ECCodewordsPerBlock + numDataCodewords;
+ result[numResultBlocks++] = new DataBlock(numDataCodewords, new Array(numBlockCodewords));
+ }
+ }
+
+ // All blocks have the same amount of data, except that the last n
+ // (where n may be 0) have 1 more byte. Figure out where these start.
+ var shorterBlocksTotalCodewords = result[0].codewords.length;
+ var longerBlocksStartAt = result.length - 1;
+ while (longerBlocksStartAt >= 0) {
+ var numCodewords = result[longerBlocksStartAt].codewords.length;
+ if (numCodewords == shorterBlocksTotalCodewords) {
+ break;
+ }
+ longerBlocksStartAt--;
+ }
+ longerBlocksStartAt++;
+
+ var shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.ECCodewordsPerBlock;
+ // The last elements of result may be 1 element longer;
+ // first fill out as many elements as all of them have
+ var rawCodewordsOffset = 0;
+ for (var i = 0; i < shorterBlocksNumDataCodewords; i++) {
+ for (var j = 0; j < numResultBlocks; j++) {
+ result[j].codewords[i] = rawCodewords[rawCodewordsOffset++];
+ }
+ }
+ // Fill out the last data block in the longer ones
+ for (var j = longerBlocksStartAt; j < numResultBlocks; j++) {
+ result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++];
+ }
+ // Now add in error correction blocks
+ var max = result[0].codewords.length;
+ for (var i = shorterBlocksNumDataCodewords; i < max; i++) {
+ for (var j = 0; j < numResultBlocks; j++) {
+ var iOffset = j < longerBlocksStartAt ? i : i + 1;
+ result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++];
+ }
+ }
+ return result;
+};
+module.exports = exports["default"];
+
+/***/ }),
+/* 17 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = QRCodeDataBlockReader;
+
+var _qrcode = __webpack_require__(0);
+
+var _qrcode2 = _interopRequireDefault(_qrcode);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function QRCodeDataBlockReader(blocks, version, numErrorCorrectionCode) {
+ this.blockPointer = 0;
+ this.bitPointer = 7;
+ this.dataLength = 0;
+ this.blocks = blocks;
+ this.numErrorCorrectionCode = numErrorCorrectionCode;
+ if (version <= 9) this.dataLengthMode = 0;else if (version >= 10 && version <= 26) this.dataLengthMode = 1;else if (version >= 27 && version <= 40) this.dataLengthMode = 2;
+
+ this.getNextBits = function (numBits) {
+ var bits = 0;
+ if (numBits < this.bitPointer + 1) {
+ // next word fits into current data block
+ var mask = 0;
+ for (var i = 0; i < numBits; i++) {
+ mask += 1 << i;
+ }
+ mask <<= this.bitPointer - numBits + 1;
+
+ bits = (this.blocks[this.blockPointer] & mask) >> this.bitPointer - numBits + 1;
+ this.bitPointer -= numBits;
+ return bits;
+ } else if (numBits < this.bitPointer + 1 + 8) {
+ // next word crosses 2 data blocks
+ var mask1 = 0;
+ for (var i = 0; i < this.bitPointer + 1; i++) {
+ mask1 += 1 << i;
+ }
+ bits = (this.blocks[this.blockPointer] & mask1) << numBits - (this.bitPointer + 1);
+ this.blockPointer++;
+ bits += this.blocks[this.blockPointer] >> 8 - (numBits - (this.bitPointer + 1));
+
+ this.bitPointer = this.bitPointer - numBits % 8;
+ if (this.bitPointer < 0) {
+ this.bitPointer = 8 + this.bitPointer;
+ }
+ return bits;
+ } else if (numBits < this.bitPointer + 1 + 16) {
+ // next word crosses 3 data blocks
+ var mask1 = 0; // mask of first block
+ var mask3 = 0; // mask of 3rd block
+ //bitPointer + 1 : number of bits of the 1st block
+ //8 : number of the 2nd block (note that use already 8bits because next word uses 3 data blocks)
+ //numBits - (bitPointer + 1 + 8) : number of bits of the 3rd block
+ for (var i = 0; i < this.bitPointer + 1; i++) {
+ mask1 += 1 << i;
+ }
+ var bitsFirstBlock = (this.blocks[this.blockPointer] & mask1) << numBits - (this.bitPointer + 1);
+ this.blockPointer++;
+
+ var bitsSecondBlock = this.blocks[this.blockPointer] << numBits - (this.bitPointer + 1 + 8);
+ this.blockPointer++;
+
+ for (var i = 0; i < numBits - (this.bitPointer + 1 + 8); i++) {
+ mask3 += 1 << i;
+ }
+ mask3 <<= 8 - (numBits - (this.bitPointer + 1 + 8));
+ var bitsThirdBlock = (this.blocks[this.blockPointer] & mask3) >> 8 - (numBits - (this.bitPointer + 1 + 8));
+
+ bits = bitsFirstBlock + bitsSecondBlock + bitsThirdBlock;
+ this.bitPointer = this.bitPointer - (numBits - 8) % 8;
+ if (this.bitPointer < 0) {
+ this.bitPointer = 8 + this.bitPointer;
+ }
+ return bits;
+ } else {
+ return 0;
+ }
+ };
+ this.NextMode = function () {
+ if (this.blockPointer > this.blocks.length - this.numErrorCorrectionCode - 2) return 0;else return this.getNextBits(4);
+ };
+ this.getDataLength = function (modeIndicator) {
+ var index = 0;
+ while (true) {
+ if (modeIndicator >> index == 1) break;
+ index++;
+ }
+
+ return this.getNextBits(_qrcode2.default.sizeOfDataLengthInfo[this.dataLengthMode][index]);
+ };
+ this.getRomanAndFigureString = function (dataLength) {
+ var length = dataLength;
+ var intData = 0;
+ var strData = "";
+ var tableRomanAndFigure = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*', '+', '-', '.', '/', ':');
+ do {
+ if (length > 1) {
+ intData = this.getNextBits(11);
+ var firstLetter = Math.floor(intData / 45);
+ var secondLetter = intData % 45;
+ strData += tableRomanAndFigure[firstLetter];
+ strData += tableRomanAndFigure[secondLetter];
+ length -= 2;
+ } else if (length == 1) {
+ intData = this.getNextBits(6);
+ strData += tableRomanAndFigure[intData];
+ length -= 1;
+ }
+ } while (length > 0);
+
+ return strData;
+ };
+ this.getFigureString = function (dataLength) {
+ var length = dataLength;
+ var intData = 0;
+ var strData = "";
+ do {
+ if (length >= 3) {
+ intData = this.getNextBits(10);
+ if (intData < 100) strData += "0";
+ if (intData < 10) strData += "0";
+ length -= 3;
+ } else if (length == 2) {
+ intData = this.getNextBits(7);
+ if (intData < 10) strData += "0";
+ length -= 2;
+ } else if (length == 1) {
+ intData = this.getNextBits(4);
+ length -= 1;
+ }
+ strData += intData;
+ } while (length > 0);
+
+ return strData;
+ };
+ this.get8bitByteArray = function (dataLength) {
+ var length = dataLength;
+ var intData = 0;
+ var output = new Array();
+
+ do {
+ intData = this.getNextBits(8);
+ output.push(intData);
+ length--;
+ } while (length > 0);
+ return output;
+ };
+ this.getKanjiString = function (dataLength) {
+ var length = dataLength;
+ var intData = 0;
+ var unicodeString = "";
+ do {
+ intData = this.getNextBits(13);
+ var lowerByte = intData % 0xC0;
+ var higherByte = intData / 0xC0;
+
+ var tempWord = (higherByte << 8) + lowerByte;
+ var shiftjisWord = 0;
+ if (tempWord + 0x8140 <= 0x9FFC) {
+ // between 8140 - 9FFC on Shift_JIS character set
+ shiftjisWord = tempWord + 0x8140;
+ } else {
+ // between E040 - EBBF on Shift_JIS character set
+ shiftjisWord = tempWord + 0xC140;
+ }
+
+ //var tempByte = new Array(0,0);
+ //tempByte[0] = (sbyte) (shiftjisWord >> 8);
+ //tempByte[1] = (sbyte) (shiftjisWord & 0xFF);
+ //unicodeString += new String(SystemUtils.ToCharArray(SystemUtils.ToByteArray(tempByte)));
+ unicodeString += String.fromCharCode(shiftjisWord);
+ length--;
+ } while (length > 0);
+
+ return unicodeString;
+ };
+
+ this.parseECIValue = function () {
+ var intData = 0;
+ var firstByte = this.getNextBits(8);
+ if ((firstByte & 0x80) == 0) {
+ intData = firstByte & 0x7F;
+ }
+ if ((firstByte & 0xC0) == 0x80) {
+ // two bytes
+ var secondByte = this.getNextBits(8);
+ intData = (firstByte & 0x3F) << 8 | secondByte;
+ }
+ if ((firstByte & 0xE0) == 0xC0) {
+ // three bytes
+ var secondThirdBytes = this.getNextBits(8);;
+ intData = (firstByte & 0x1F) << 16 | secondThirdBytes;
+ }
+ return intData;
+ };
+
+ this.__defineGetter__("DataByte", function () {
+ var output = new Array();
+ var MODE_NUMBER = 1;
+ var MODE_ROMAN_AND_NUMBER = 2;
+ var MODE_8BIT_BYTE = 4;
+ var MODE_ECI = 7;
+ var MODE_KANJI = 8;
+ do {
+ var mode = this.NextMode();
+ //canvas.println("mode: " + mode);
+ if (mode == 0) {
+ if (output.length > 0) break;else throw "Empty data block";
+ }
+ if (mode != MODE_NUMBER && mode != MODE_ROMAN_AND_NUMBER && mode != MODE_8BIT_BYTE && mode != MODE_KANJI && mode != MODE_ECI) {
+ throw "Invalid mode: " + mode + " in (block:" + this.blockPointer + " bit:" + this.bitPointer + ")";
+ }
+
+ if (mode == MODE_ECI) {
+ var temp_sbyteArray3 = this.parseECIValue();
+ //output.push(temp_sbyteArray3);
+ } else {
+
+ var dataLength = this.getDataLength(mode);
+ if (dataLength < 1) throw "Invalid data length: " + dataLength;
+ switch (mode) {
+
+ case MODE_NUMBER:
+ var temp_str = this.getFigureString(dataLength);
+ var ta = new Array(temp_str.length);
+ for (var j = 0; j < temp_str.length; j++) {
+ ta[j] = temp_str.charCodeAt(j);
+ }output.push(ta);
+ break;
+
+ case MODE_ROMAN_AND_NUMBER:
+ var temp_str = this.getRomanAndFigureString(dataLength);
+ var ta = new Array(temp_str.length);
+ for (var j = 0; j < temp_str.length; j++) {
+ ta[j] = temp_str.charCodeAt(j);
+ }output.push(ta);
+ break;
+
+ case MODE_8BIT_BYTE:
+ var temp_sbyteArray3 = this.get8bitByteArray(dataLength);
+ output.push(temp_sbyteArray3);
+ break;
+
+ case MODE_KANJI:
+ var temp_str = this.getKanjiString(dataLength);
+ output.push(temp_str);
+ break;
+ }
+ }
+ } while (true);
+ return output;
+ });
+} /*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+ */
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+module.exports = exports['default'];
+
+/***/ })
+/******/ ]);
+});
+//# sourceMappingURL=qrcode.js.map
\ No newline at end of file
diff --git a/lib/qrcode.js.map b/lib/qrcode.js.map
new file mode 100644
index 00000000..06d5518f
--- /dev/null
+++ b/lib/qrcode.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 1562e5ec7f339bb9e92d","webpack:///./src/qrcode.js","webpack:///./src/gf256.js","webpack:///./src/version.js","webpack:///./src/formatinf.js","webpack:///./src/bitmat.js","webpack:///./src/gf256poly.js","webpack:///./src/index.js","webpack:///./src/detector.js","webpack:///./src/errorlevel.js","webpack:///./src/alignpat.js","webpack:///./src/grid.js","webpack:///./src/findpat.js","webpack:///./src/decoder.js","webpack:///./src/rsdecoder.js","webpack:///./src/bmparser.js","webpack:///./src/datamask.js","webpack:///./src/datablock.js","webpack:///./src/databr.js"],"names":["URShift","qrcode","imagedata","width","height","qrCodeSymbol","debug","maxImgSize","sizeOfDataLengthInfo","callback","src","result","vidSuccess","stream","localstream","video","window","URL","createObjectURL","gUM","canvas_qr2","document","createElement","id","qrcontext2","getContext","videoWidth","videoHeight","setTimeout","captureToCanvas","vidError","error","drawImage","decode","e","console","log","destroyWebcam","getTracks","stop","setWebcam","videoId","n","navigator","getElementById","options","mediaDevices","enumerateDevices","then","devices","forEach","device","kind","label","toLowerCase","search","deviceId","getUserMedia","audio","catch","arguments","length","canvas_qr","context","getImageData","process","image","Image","crossOrigin","onload","canvas_out","outctx","clearRect","nheight","nwidth","ir","Math","sqrt","onerror","isUrl","s","regexp","test","decode_url","escaped","escape","ret","decodeURIComponent","decode_utf8","ctx","start","Date","getTime","grayScaleToBitmap","grayscale","y","x","point","data","putImageData","detector","qRCodeMatrix","detect","bits","Height","Width","get_Renamed","reader","DataByte","str","i","j","String","fromCharCode","end","time","getPixel","p","binarize","th","Array","gray","getMiddleBrightnessPerArea","numSqrtArea","areaWidth","floor","areaHeight","minmax","i2","ay","ax","dy","dx","target","middle","i3","grayScale","sqrtNumArea","buff","ArrayBuffer","bitmap","Uint8Array","number","GF256","primitive","expTable","logTable","at0","zero","at1","one","__defineGetter__","buildMonomial","degree","coefficient","coefficients","exp","a","inverse","multiply","b","QR_CODE_FIELD","DATA_MATRIX_FIELD","addOrSubtract","Version","ECB","count","dataCodewords","ECBlocks","ecCodewordsPerBlock","ecBlocks1","ecBlocks2","ecBlocks","NumBlocks","total","getECBlocks","versionNumber","alignmentPatternCenters","ecBlocks3","ecBlocks4","ecCodewords","ECCodewordsPerBlock","ecbArray","ecBlock","Count","DataCodewords","totalCodewords","buildFunctionPattern","dimension","DimensionForVersion","bitMatrix","setRegion","max","getECBlocksForLevel","ecLevel","ordinal","VERSION_DECODE_INFO","VERSIONS","buildVersions","getVersionForNumber","getProvisionalVersionForDimension","iae","decodeVersionInformation","versionBits","bestDifference","bestVersion","targetVersion","bitsDifference","numBitsDiffering","FormatInformation","FORMAT_INFO_MASK_QR","FORMAT_INFO_DECODE_LOOKUP","BITS_SET_IN_HALF_BYTE","formatInfo","errorCorrectionLevel","forBits","dataMask","GetHashCode","Equals","o","other","decodeFormatInformation","maskedFormatInfo","doDecodeFormatInformation","bestFormatInfo","decodeInfo","targetInfo","BitMatrix","rowSize","offset","set_Renamed","flip","clear","left","top","right","bottom","GF256Poly","field","coefficientsLength","firstNonZero","Zero","ci","getCoefficient","evaluateAt","size","result2","smallerCoefficients","largerCoefficients","temp","sumDiff","lengthDiff","multiply1","aCoefficients","aLength","bCoefficients","bLength","product","aCoeff","multiply2","scalar","multiplyByMonomial","divide","quotient","remainder","denominatorLeadingTerm","Degree","inverseDenominatorLeadingTerm","degreeDifference","scale","term","iterationQuotient","Detector","PerspectiveTransform","a11","a21","a31","a12","a22","a32","a13","a23","a33","transformPoints1","points","denominator","transformPoints2","xValues","yValues","buildAdjoint","times","quadrilateralToQuadrilateral","x0","y0","x1","y1","x2","y2","x3","y3","x0p","y0p","x1p","y1p","x2p","y2p","x3p","y3p","qToS","quadrilateralToSquare","sToQ","squareToQuadrilateral","dy2","dy3","dx1","dx2","dx3","dy1","DetectorResult","resultPointCallback","sizeOfBlackWhiteBlackRun","fromX","fromY","toX","toY","steep","abs","ystep","xstep","state","realX","realY","diffX","diffY","diffX2","diffY2","sizeOfBlackWhiteBlackRunBothWays","otherToX","otherToY","calculateModuleSizeOneWay","pattern","otherPattern","moduleSizeEst1","X","Y","moduleSizeEst2","isNaN","calculateModuleSize","topLeft","topRight","bottomLeft","distance","pattern1","pattern2","xDiff","yDiff","computeDimension","moduleSize","tltrCentersDimension","round","tlblCentersDimension","findAlignmentInRegion","overallEstModuleSize","estAlignmentX","estAlignmentY","allowanceFactor","allowance","alignmentAreaLeftX","alignmentAreaRightX","min","alignmentAreaTopY","alignmentAreaBottomY","alignmentFinder","find","createTransform","alignmentPattern","dimMinusThree","bottomRightX","bottomRightY","sourceBottomRightX","sourceBottomRightY","transform","sampleGrid","sampler","sampleGrid3","processFinderPatternInfo","info","TopLeft","TopRight","BottomLeft","provisionalVersion","modulesBetweenFPCenters","AlignmentPatternCenters","correctionToTopLeft","findFinderPattern","ErrorCorrectionLevel","name","ordinal_Renamed_Field","FOR_BITS","L","M","Q","H","AlignmentPattern","AlignmentPatternFinder","posX","posY","estimatedModuleSize","incrementCount","aboutEquals","moduleSizeDiff","startX","startY","possibleCenters","crossCheckStateCount","centerFromEnd","stateCount","foundPatternCross","maxVariance","crossCheckVertical","startI","centerJ","maxCount","originalStateCountTotal","maxI","NaN","stateCountTotal","handlePossibleCenter","centerI","index","center","push","foundPossibleResultPoint","maxJ","middleI","iGen","currentState","confirmed","GridSampler","checkAndNudgePoints","nudged","iValue","bit","aioobe","sampleGridx","p1ToX","p1ToY","p2ToX","p2ToY","p3ToX","p3ToY","p4ToX","p4ToY","p1FromX","p1FromY","p2FromX","p2FromY","p3FromX","p3FromY","p4FromX","p4FromY","FinderPatternFinder","MIN_SKIP","MAX_MODULES","INTEGER_MATH_SHIFT","CENTER_QUORUM","orderBestPatterns","patterns","crossProductZ","pointA","pointB","pointC","bX","bY","zeroOneDistance","oneTwoDistance","zeroTwoDistance","FinderPattern","FinderPatternInfo","patternCenters","hasSkipped","totalModuleSize","CrossCheckStateCount","crossCheckHorizontal","startJ","found","selectBestPatterns","startSize","square","centerValue","EstimatedModuleSize","average","sort","center1","center2","dA","dB","stdDev","limit","splice","findRowSkip","firstConfirmedCenter","haveMultiplyConfirmedCenters","confirmedCount","totalDeviation","tryHarder","iSkip","done","rowSkip","patternInfo","Decoder","rsDecoder","correctErrors","codewordBytes","numDataCodewords","numCodewords","codewordsInts","numECCodewords","rse","parser","version","readVersion","readFormatInformation","codewords","readCodewords","dataBlocks","getDataBlocks","totalBytes","NumDataCodewords","resultBytes","resultOffset","dataBlock","Codewords","VersionNumber","Bits","ReedSolomonDecoder","received","twoS","poly","syndromeCoefficients","dataMatrix","noError","evalu","syndrome","sigmaOmega","runEuclideanAlgorithm","sigma","omega","errorLocations","findErrorLocations","errorMagnitudes","findErrorMagnitudes","position","R","rLast","r","sLast","One","tLast","t","rLastLast","sLastLast","tLastLast","q","dltInverse","degreeDiff","sigmaTildeAtZero","errorLocator","numErrors","errorEvaluator","xiInverse","BitMatrixParser","Dimension","parsedVersion","parsedFormatInfo","copyBit","formatInfoBits","iMin","ijMin","forReference","DataMask","unmaskBitMatrix","functionPattern","readingUp","TotalCodewords","currentByte","bitsRead","col","reference","DATA_MASKS","DataMask000","isMasked","DataMask001","DataMask010","DataMask011","DataMask100","DataMask101","DataMask110","DataMask111","DataBlock","rawCodewords","totalBlocks","ecBlockArray","numResultBlocks","numBlockCodewords","shorterBlocksTotalCodewords","longerBlocksStartAt","shorterBlocksNumDataCodewords","rawCodewordsOffset","iOffset","QRCodeDataBlockReader","blocks","numErrorCorrectionCode","blockPointer","bitPointer","dataLength","dataLengthMode","getNextBits","numBits","mask","mask1","mask3","bitsFirstBlock","bitsSecondBlock","bitsThirdBlock","NextMode","getDataLength","modeIndicator","getRomanAndFigureString","intData","strData","tableRomanAndFigure","firstLetter","secondLetter","getFigureString","get8bitByteArray","output","getKanjiString","unicodeString","lowerByte","higherByte","tempWord","shiftjisWord","parseECIValue","firstByte","secondByte","secondThirdBytes","MODE_NUMBER","MODE_ROMAN_AND_NUMBER","MODE_8BIT_BYTE","MODE_ECI","MODE_KANJI","mode","temp_sbyteArray3","temp_str","ta","charCodeAt"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;;;QC6VgBA,O,GAAAA,O;;AA3YhB;;;;AACA;;;;;;AAhBA;;;;;;;;;;;;;;;AAkBA,IAAIC,SAAS,EAAb;AACAA,OAAOC,SAAP,GAAmB,IAAnB;AACAD,OAAOE,KAAP,GAAe,CAAf;AACAF,OAAOG,MAAP,GAAgB,CAAhB;AACAH,OAAOI,YAAP,GAAsB,IAAtB;AACAJ,OAAOK,KAAP,GAAe,KAAf;AACAL,OAAOM,UAAP,GAAoB,OAAO,IAA3B;;AAEAN,OAAOO,oBAAP,GAA8B,CAC1B,CAAC,EAAD,EAAK,CAAL,EAAQ,CAAR,EAAW,CAAX,CAD0B,EAE1B,CAAC,EAAD,EAAK,EAAL,EAAS,EAAT,EAAa,EAAb,CAF0B,EAG1B,CAAC,EAAD,EAAK,EAAL,EAAS,EAAT,EAAa,EAAb,CAH0B,CAA9B;;AAMAP,OAAOQ,QAAP,GAAkB,IAAlB;AACAR,OAAOS,GAAP,GAAa,IAAb;AACAT,OAAOU,MAAP,GAAgB,I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AGC,UAAKL,WAAL;AACC,UAAIO,WAAW,KAAKpB,eAAL,CAAqBnB,UAArB,CAAf;AACA,UAAIwC,KAAK,IAAIvhB,KAAJ,CAAUshB,SAASjlB,MAAnB,CAAT;AACA,WAAI,IAAIkD,IAAE,CAAV,EAAYA,IAAE+hB,SAASjlB,MAAvB,EAA8BkD,GAA9B;AACCgiB,UAAGhiB,CAAH,IAAM+hB,SAASE,UAAT,CAAoBjiB,CAApB,CAAN;AADD,OAEA6gB,OAAO7M,IAAP,CAAYgO,EAAZ;AACA;;AAED,UAAKP,qBAAL;AACC,UAAIM,WAAW,KAAK1B,uBAAL,CAA6Bb,UAA7B,CAAf;AACA,UAAIwC,KAAK,IAAIvhB,KAAJ,CAAUshB,SAASjlB,MAAnB,CAAT;AACA,WAAI,IAAIkD,IAAE,CAAV,EAAYA,IAAE+hB,SAASjlB,MAAvB,EAA8BkD,GAA9B;AACCgiB,UAAGhiB,CAAH,IAAM+hB,SAASE,UAAT,CAAoBjiB,CAApB,CAAN;AADD,OAEA6gB,OAAO7M,IAAP,CAAYgO,EAAZ;AACA;;AAED,UAAKN,cAAL;AACC,UAAII,mBAAmB,KAAKlB,gBAAL,CAAsBpB,UAAtB,CAAvB;AACAqB,aAAO7M,IAAP,CAAY8N,gBAAZ;AACA;;AAED,UAAKF,UAAL;AACC,UAAIG,WAAW,KAAKjB,cAAL,CAAoBtB,UAApB,CAAf;AACAqB,aAAO7M,IAAP,CAAY+N,QAAZ;AACA;AA3BF;AA6BA;AACD,GAzDJ,QA0DU,IA1DV;AA2DA,SAAOlB,MAAP;AACA,EApED;AAqEA,C,CA/UD;;;;;;;AAOA","file":"qrcode.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"qrcode\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"qrcode\"] = factory();\n\telse\n\t\troot[\"qrcode\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 6);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 1562e5ec7f339bb9e92d","/*\r\n Copyright 2011 Lazar Laszlo (lazarsoft@gmail.com, www.lazarsoft.info)\r\n \r\n Licensed under the Apache License, Version 2.0 (the \"License\");\r\n you may not use this file except in compliance with the License.\r\n You may obtain a copy of the License at\r\n\r\n http://www.apache.org/licenses/LICENSE-2.0\r\n\r\n Unless required by applicable law or agreed to in writing, software\r\n distributed under the License is distributed on an \"AS IS\" BASIS,\r\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n See the License for the specific language governing permissions and\r\n limitations under the License.\r\n*/\r\nimport Detector from './detector';\r\nimport Decoder from './decoder';\r\n\r\nvar qrcode = {};\r\nqrcode.imagedata = null;\r\nqrcode.width = 0;\r\nqrcode.height = 0;\r\nqrcode.qrCodeSymbol = null;\r\nqrcode.debug = false;\r\nqrcode.maxImgSize = 1024 * 1024;\r\n\r\nqrcode.sizeOfDataLengthInfo = [\r\n [10, 9, 8, 8],\r\n [12, 11, 16, 10],\r\n [14, 13, 16, 12]\r\n];\r\n\r\nqrcode.callback = null;\r\nqrcode.src = null;\r\nqrcode.result = null;\r\n\r\nqrcode.vidSuccess = function (stream) {\r\n qrcode.localstream = stream;\r\n // if(qrcode.webkit)\r\n // qrcode.video.src = window.webkitURL.createObjectURL(stream);\r\n // else\r\n // if(qrcode.moz)\r\n // {\r\n // qrcode.video.mozSrcObject = stream;\r\n // qrcode.video.play();\r\n // }\r\n // else\r\n // qrcode.video.src = stream;\r\n qrcode.video.src = window.URL.createObjectURL(stream);\r\n // if (qrcode.src != null) {\r\n // qrcode.src(qrcode.video.src);\r\n // }\r\n qrcode.gUM = true;\r\n\r\n qrcode.canvas_qr2 = document.createElement('canvas');\r\n qrcode.canvas_qr2.id = \"qr-canvas\";\r\n qrcode.qrcontext2 = qrcode.canvas_qr2.getContext('2d');\r\n qrcode.canvas_qr2.width = qrcode.video.videoWidth;\r\n qrcode.canvas_qr2.height = qrcode.video.videoHeight;\r\n setTimeout(qrcode.captureToCanvas, 500);\r\n}\r\n\r\nqrcode.vidError = function (error) {\r\n qrcode.gUM = false;\r\n return;\r\n}\r\n\r\nqrcode.captureToCanvas = function () {\r\n if (qrcode.gUM) {\r\n try {\r\n if (qrcode.video.videoWidth == 0) {\r\n setTimeout(qrcode.captureToCanvas, 500);\r\n return;\r\n } else {\r\n qrcode.canvas_qr2.width = qrcode.video.videoWidth;\r\n qrcode.canvas_qr2.height = qrcode.video.videoHeight;\r\n }\r\n qrcode.qrcontext2.drawImage(qrcode.video, 0, 0);\r\n try {\r\n qrcode.decode();\r\n } catch (e) {\r\n console.log(e);\r\n setTimeout(qrcode.captureToCanvas, 500);\r\n };\r\n } catch (e) {\r\n console.log(e);\r\n setTimeout(qrcode.captureToCanvas, 500);\r\n };\r\n }\r\n}\r\n\r\nqrcode.destroyWebcam = function() {\r\n // qrcode.video.pause()\r\n qrcode.localstream.getTracks()[0].stop();\r\n}\r\n\r\nqrcode.setWebcam = function (videoId) {\r\n var n = navigator;\r\n qrcode.video = document.getElementById(videoId);\r\n\r\n var options = true; \r\n if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) {\r\n try {\r\n navigator.mediaDevices.enumerateDevices()\r\n .then(function (devices) {\r\n devices.forEach(function (device) {\r\n console.log(\"deb1\");\r\n if (device.kind === 'videoinput') {\r\n if (device.label.toLowerCase().search(\"back\") > -1)\r\n options = [{\r\n 'sourceId': device.deviceId\r\n }];\r\n }\r\n console.log(device.kind + \": \" + device.label +\r\n \" id = \" + device.deviceId);\r\n });\r\n })\r\n\r\n } catch (e) {\r\n console.log(e);\r\n }\r\n } else {\r\n console.log(\"no navigator.mediaDevices.enumerateDevices\");\r\n }\r\n\r\n n.mediaDevices.getUserMedia({\r\n video: options,\r\n audio: false\r\n })\r\n .then(qrcode.vidSuccess)\r\n .catch(qrcode.vidError);\r\n\r\n // if(n.getUserMedia)\r\n // n.getUserMedia({video: options, audio: false}, qrcode.vidSuccess, qrcode.vidError);\r\n // else\r\n // if(n.webkitGetUserMedia)\r\n // {\r\n // qrcode.webkit=true;\r\n // n.webkitGetUserMedia({video:options, audio: false}, qrcode.vidSuccess, qrcode.vidError);\r\n // }\r\n // else\r\n // if(n.mozGetUserMedia)\r\n // {\r\n // qrcode.moz=true;\r\n // n.mozGetUserMedia({video: options, audio: false}, qrcode.vidSuccess, qrcode.vidError);\r\n // }\r\n}\r\n\r\nqrcode.decode = function (src) {\r\n\r\n if (arguments.length == 0) {\r\n if (qrcode.canvas_qr2) {\r\n var canvas_qr = qrcode.canvas_qr2;\r\n var context = qrcode.qrcontext2;\r\n } else {\r\n var canvas_qr = document.getElementById(\"qr-canvas\");\r\n var context = canvas_qr.getContext('2d');\r\n }\r\n qrcode.width = canvas_qr.width;\r\n qrcode.height = canvas_qr.height;\r\n qrcode.imagedata = context.getImageData(0, 0, qrcode.width, qrcode.height);\r\n qrcode.result = qrcode.process(context);\r\n if (qrcode.callback != null)\r\n qrcode.callback(qrcode.result);\r\n return qrcode.result;\r\n } else {\r\n var image = new Image();\r\n image.crossOrigin = \"Anonymous\";\r\n image.onload = function () {\r\n //var canvas_qr = document.getElementById(\"qr-canvas\");\r\n var canvas_out = document.getElementById(\"out-canvas\");\r\n if (canvas_out != null) {\r\n var outctx = canvas_out.getContext('2d');\r\n outctx.clearRect(0, 0, 320, 240);\r\n outctx.drawImage(image, 0, 0, 320, 240);\r\n }\r\n\r\n var canvas_qr = document.createElement('canvas');\r\n var context = canvas_qr.getContext('2d');\r\n var nheight = image.height;\r\n var nwidth = image.width;\r\n if (image.width * image.height > qrcode.maxImgSize) {\r\n var ir = image.width / image.height;\r\n nheight = Math.sqrt(qrcode.maxImgSize / ir);\r\n nwidth = ir * nheight;\r\n }\r\n\r\n canvas_qr.width = nwidth;\r\n canvas_qr.height = nheight;\r\n\r\n context.drawImage(image, 0, 0, canvas_qr.width, canvas_qr.height);\r\n qrcode.width = canvas_qr.width;\r\n qrcode.height = canvas_qr.height;\r\n try {\r\n qrcode.imagedata = context.getImageData(0, 0, canvas_qr.width, canvas_qr.height);\r\n } catch (e) {\r\n qrcode.result = \"Cross domain image reading not supported in your browser! Save it to your computer then drag and drop the file!\";\r\n if (qrcode.callback != null)\r\n qrcode.callback(qrcode.result);\r\n return;\r\n }\r\n\r\n try {\r\n qrcode.result = qrcode.process(context);\r\n } catch (e) {\r\n console.log(e);\r\n qrcode.result = \"error decoding QR Code\";\r\n }\r\n if (qrcode.callback != null)\r\n qrcode.callback(qrcode.result);\r\n }\r\n image.onerror = function () {\r\n if (qrcode.callback != null)\r\n qrcode.callback(\"Failed to load the image\");\r\n }\r\n image.src = src;\r\n }\r\n}\r\n\r\nqrcode.isUrl = function (s) {\r\n var regexp = /(ftp|http|https):\\/\\/(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(\\/|\\/([\\w#!:.?+=&%@!\\-\\/]))?/;\r\n return regexp.test(s);\r\n}\r\n\r\nqrcode.decode_url = function (s) {\r\n var escaped = \"\";\r\n try {\r\n escaped = escape(s);\r\n } catch (e) {\r\n console.log(e);\r\n escaped = s;\r\n }\r\n var ret = \"\";\r\n try {\r\n ret = decodeURIComponent(escaped);\r\n } catch (e) {\r\n console.log(e);\r\n ret = escaped;\r\n }\r\n return ret;\r\n}\r\n\r\nqrcode.decode_utf8 = function (s) {\r\n if (qrcode.isUrl(s))\r\n return qrcode.decode_url(s);\r\n else\r\n return s;\r\n}\r\n\r\nqrcode.process = function (ctx) {\r\n\r\n var start = new Date().getTime();\r\n\r\n var image = qrcode.grayScaleToBitmap(qrcode.grayscale());\r\n //var image = qrcode.binarize(128);\r\n\r\n if (qrcode.debug) {\r\n for (var y = 0; y < qrcode.height; y++) {\r\n for (var x = 0; x < qrcode.width; x++) {\r\n var point = (x * 4) + (y * qrcode.width * 4);\r\n qrcode.imagedata.data[point] = image[x + y * qrcode.width] ? 0 : 0;\r\n qrcode.imagedata.data[point + 1] = image[x + y * qrcode.width] ? 0 : 0;\r\n qrcode.imagedata.data[point + 2] = image[x + y * qrcode.width] ? 255 : 0;\r\n }\r\n }\r\n ctx.putImageData(qrcode.imagedata, 0, 0);\r\n }\r\n\r\n //var finderPatternInfo = new FinderPatternFinder().findFinderPattern(image);\r\n\r\n var detector = new Detector(image);\r\n\r\n var qRCodeMatrix = detector.detect();\r\n\r\n if (qrcode.debug) {\r\n for (var y = 0; y < qRCodeMatrix.bits.Height; y++) {\r\n for (var x = 0; x < qRCodeMatrix.bits.Width; x++) {\r\n var point = (x * 4 * 2) + (y * 2 * qrcode.width * 4);\r\n qrcode.imagedata.data[point] = qRCodeMatrix.bits.get_Renamed(x, y) ? 0 : 0;\r\n qrcode.imagedata.data[point + 1] = qRCodeMatrix.bits.get_Renamed(x, y) ? 0 : 0;\r\n qrcode.imagedata.data[point + 2] = qRCodeMatrix.bits.get_Renamed(x, y) ? 255 : 0;\r\n }\r\n }\r\n ctx.putImageData(qrcode.imagedata, 0, 0);\r\n }\r\n\r\n\r\n var reader = Decoder.decode(qRCodeMatrix.bits);\r\n var data = reader.DataByte;\r\n var str = \"\";\r\n for (var i = 0; i < data.length; i++) {\r\n for (var j = 0; j < data[i].length; j++)\r\n str += String.fromCharCode(data[i][j]);\r\n }\r\n\r\n var end = new Date().getTime();\r\n var time = end - start;\r\n console.log(time);\r\n\r\n return qrcode.decode_utf8(str);\r\n //alert(\"Time:\" + time + \" Code: \"+str);\r\n}\r\n\r\nqrcode.getPixel = function (x, y) {\r\n if (qrcode.width < x) {\r\n throw \"point error\";\r\n }\r\n if (qrcode.height < y) {\r\n throw \"point error\";\r\n }\r\n var point = (x * 4) + (y * qrcode.width * 4);\r\n var p = (qrcode.imagedata.data[point] * 33 + qrcode.imagedata.data[point + 1] * 34 + qrcode.imagedata.data[point + 2] * 33) / 100;\r\n return p;\r\n}\r\n\r\nqrcode.binarize = function (th) {\r\n var ret = new Array(qrcode.width * qrcode.height);\r\n for (var y = 0; y < qrcode.height; y++) {\r\n for (var x = 0; x < qrcode.width; x++) {\r\n var gray = qrcode.getPixel(x, y);\r\n\r\n ret[x + y * qrcode.width] = gray <= th ? true : false;\r\n }\r\n }\r\n return ret;\r\n}\r\n\r\nqrcode.getMiddleBrightnessPerArea = function (image) {\r\n var numSqrtArea = 4;\r\n //obtain middle brightness((min + max) / 2) per area\r\n var areaWidth = Math.floor(qrcode.width / numSqrtArea);\r\n var areaHeight = Math.floor(qrcode.height / numSqrtArea);\r\n var minmax = new Array(numSqrtArea);\r\n for (var i = 0; i < numSqrtArea; i++) {\r\n minmax[i] = new Array(numSqrtArea);\r\n for (var i2 = 0; i2 < numSqrtArea; i2++) {\r\n minmax[i][i2] = new Array(0, 0);\r\n }\r\n }\r\n for (var ay = 0; ay < numSqrtArea; ay++) {\r\n for (var ax = 0; ax < numSqrtArea; ax++) {\r\n minmax[ax][ay][0] = 0xFF;\r\n for (var dy = 0; dy < areaHeight; dy++) {\r\n for (var dx = 0; dx < areaWidth; dx++) {\r\n var target = image[areaWidth * ax + dx + (areaHeight * ay + dy) * qrcode.width];\r\n if (target < minmax[ax][ay][0])\r\n minmax[ax][ay][0] = target;\r\n if (target > minmax[ax][ay][1])\r\n minmax[ax][ay][1] = target;\r\n }\r\n }\r\n //minmax[ax][ay][0] = (minmax[ax][ay][0] + minmax[ax][ay][1]) / 2;\r\n }\r\n }\r\n var middle = new Array(numSqrtArea);\r\n for (var i3 = 0; i3 < numSqrtArea; i3++) {\r\n middle[i3] = new Array(numSqrtArea);\r\n }\r\n for (var ay = 0; ay < numSqrtArea; ay++) {\r\n for (var ax = 0; ax < numSqrtArea; ax++) {\r\n middle[ax][ay] = Math.floor((minmax[ax][ay][0] + minmax[ax][ay][1]) / 2);\r\n //Console.out.print(middle[ax][ay] + \",\");\r\n }\r\n //Console.out.println(\"\");\r\n }\r\n //Console.out.println(\"\");\r\n\r\n return middle;\r\n}\r\n\r\nqrcode.grayScaleToBitmap = function (grayScale) {\r\n var middle = qrcode.getMiddleBrightnessPerArea(grayScale);\r\n var sqrtNumArea = middle.length;\r\n var areaWidth = Math.floor(qrcode.width / sqrtNumArea);\r\n var areaHeight = Math.floor(qrcode.height / sqrtNumArea);\r\n\r\n var buff = new ArrayBuffer(qrcode.width * qrcode.height);\r\n var bitmap = new Uint8Array(buff);\r\n\r\n //var bitmap = new Array(qrcode.height*qrcode.width);\r\n\r\n for (var ay = 0; ay < sqrtNumArea; ay++) {\r\n for (var ax = 0; ax < sqrtNumArea; ax++) {\r\n for (var dy = 0; dy < areaHeight; dy++) {\r\n for (var dx = 0; dx < areaWidth; dx++) {\r\n bitmap[areaWidth * ax + dx + (areaHeight * ay + dy) * qrcode.width] = (grayScale[areaWidth * ax + dx + (areaHeight * ay + dy) * qrcode.width] < middle[ax][ay]) ? true : false;\r\n }\r\n }\r\n }\r\n }\r\n return bitmap;\r\n}\r\n\r\nqrcode.grayscale = function () {\r\n var buff = new ArrayBuffer(qrcode.width * qrcode.height);\r\n var ret = new Uint8Array(buff);\r\n //var ret = new Array(qrcode.width*qrcode.height);\r\n\r\n for (var y = 0; y < qrcode.height; y++) {\r\n for (var x = 0; x < qrcode.width; x++) {\r\n var gray = qrcode.getPixel(x, y);\r\n\r\n ret[x + y * qrcode.width] = gray;\r\n }\r\n }\r\n return ret;\r\n}\r\n\r\nexport default qrcode;\r\n\r\nexport function URShift(number, bits) {\r\n if (number >= 0)\r\n return number >> bits;\r\n else\r\n return (number >> bits) + (2 << ~bits);\r\n}\n\n\n// WEBPACK FOOTER //\n// ./src/qrcode.js","/*\r\n Ported to JavaScript by Lazar Laszlo 2011 \r\n \r\n lazarsoft@gmail.com, www.lazarsoft.info\r\n \r\n*/\r\n\r\n/*\r\n *\r\n * Copyright 2007 ZXing authors\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nimport GF256Poly from './gf256poly';\r\n\r\nexport default function GF256(primitive) {\r\n\tthis.expTable = new Array(256);\r\n\tthis.logTable = new Array(256);\r\n\tvar x = 1;\r\n\tfor (var i = 0; i < 256; i++) {\r\n\t\tthis.expTable[i] = x;\r\n\t\tx <<= 1; // x = x * 2; we're assuming the generator alpha is 2\r\n\t\tif (x >= 0x100) {\r\n\t\t\tx ^= primitive;\r\n\t\t}\r\n\t}\r\n\tfor (var i = 0; i < 255; i++) {\r\n\t\tthis.logTable[this.expTable[i]] = i;\r\n\t}\r\n\t// logTable[0] == 0 but this should never be used\r\n\tvar at0 = new Array(1);\r\n\tat0[0] = 0;\r\n\tthis.zero = new GF256Poly(this, new Array(at0));\r\n\tvar at1 = new Array(1);\r\n\tat1[0] = 1;\r\n\tthis.one = new GF256Poly(this, new Array(at1));\r\n\r\n\tthis.__defineGetter__(\"Zero\", function () {\r\n\t\treturn this.zero;\r\n\t});\r\n\tthis.__defineGetter__(\"One\", function () {\r\n\t\treturn this.one;\r\n\t});\r\n\tthis.buildMonomial = function (degree, coefficient) {\r\n\t\tif (degree < 0) {\r\n\t\t\tthrow \"System.ArgumentException\";\r\n\t\t}\r\n\t\tif (coefficient == 0) {\r\n\t\t\treturn this.zero;\r\n\t\t}\r\n\t\tvar coefficients = new Array(degree + 1);\r\n\t\tfor (var i = 0; i < coefficients.length; i++) coefficients[i] = 0;\r\n\t\tcoefficients[0] = coefficient;\r\n\t\treturn new GF256Poly(this, coefficients);\r\n\t}\r\n\tthis.exp = function (a) {\r\n\t\treturn this.expTable[a];\r\n\t}\r\n\tthis.log = function (a) {\r\n\t\tif (a == 0) {\r\n\t\t\tthrow \"System.ArgumentException\";\r\n\t\t}\r\n\t\treturn this.logTable[a];\r\n\t}\r\n\tthis.inverse = function (a) {\r\n\t\tif (a == 0) {\r\n\t\t\tthrow \"System.ArithmeticException\";\r\n\t\t}\r\n\t\treturn this.expTable[255 - this.logTable[a]];\r\n\t}\r\n\r\n\tthis.multiply = function (a, b) {\r\n\t\tif (a == 0 || b == 0) {\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\tif (a == 1) {\r\n\t\t\treturn b;\r\n\t\t}\r\n\t\tif (b == 1) {\r\n\t\t\treturn a;\r\n\t\t}\r\n\t\treturn this.expTable[(this.logTable[a] + this.logTable[b]) % 255];\r\n\t}\r\n}\r\n\r\nGF256.QR_CODE_FIELD = new GF256(0x011D);\r\nGF256.DATA_MATRIX_FIELD = new GF256(0x012D);\r\n\r\nGF256.addOrSubtract = function (a, b) {\r\n\treturn a ^ b;\r\n}\n\n\n// WEBPACK FOOTER //\n// ./src/gf256.js","/*\r\n Ported to JavaScript by Lazar Laszlo 2011 \r\n \r\n lazarsoft@gmail.com, www.lazarsoft.info\r\n \r\n*/\r\n\r\n/*\r\n*\r\n* Copyright 2007 ZXing authors\r\n*\r\n* Licensed under the Apache License, Version 2.0 (the \"License\");\r\n* you may not use this file except in compliance with the License.\r\n* You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing, software\r\n* distributed under the License is distributed on an \"AS IS\" BASIS,\r\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n* See the License for the specific language governing permissions and\r\n* limitations under the License.\r\n*/\r\n\r\nimport FormatInformation from './formatinf';\r\nimport BitMatrix from './bitmat';\r\n\r\nfunction ECB(count, dataCodewords)\r\n{\r\n\tthis.count = count;\r\n\tthis.dataCodewords = dataCodewords;\r\n\t\r\n\tthis.__defineGetter__(\"Count\", function()\r\n\t{\r\n\t\treturn this.count;\r\n\t});\r\n\tthis.__defineGetter__(\"DataCodewords\", function()\r\n\t{\r\n\t\treturn this.dataCodewords;\r\n\t});\r\n}\r\n\r\nfunction ECBlocks( ecCodewordsPerBlock, ecBlocks1, ecBlocks2)\r\n{\r\n\tthis.ecCodewordsPerBlock = ecCodewordsPerBlock;\r\n\tif(ecBlocks2)\r\n\t\tthis.ecBlocks = new Array(ecBlocks1, ecBlocks2);\r\n\telse\r\n\t\tthis.ecBlocks = new Array(ecBlocks1);\r\n\t\r\n\tthis.__defineGetter__(\"ECCodewordsPerBlock\", function()\r\n\t{\r\n\t\treturn this.ecCodewordsPerBlock;\r\n\t});\r\n\t\r\n\tthis.__defineGetter__(\"TotalECCodewords\", function()\r\n\t{\r\n\t\treturn this.ecCodewordsPerBlock * this.NumBlocks;\r\n\t});\r\n\t\r\n\tthis.__defineGetter__(\"NumBlocks\", function()\r\n\t{\r\n\t\tvar total = 0;\r\n\t\tfor (var i = 0; i < this.ecBlocks.length; i++)\r\n\t\t{\r\n\t\t\ttotal += this.ecBlocks[i].length;\r\n\t\t}\r\n\t\treturn total;\r\n\t});\r\n\t\r\n\tthis.getECBlocks=function()\r\n\t\t\t{\r\n\t\t\t\treturn this.ecBlocks;\r\n\t\t\t}\r\n}\r\n\r\nexport default function Version( versionNumber, alignmentPatternCenters, ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4)\r\n{\r\n\tthis.versionNumber = versionNumber;\r\n\tthis.alignmentPatternCenters = alignmentPatternCenters;\r\n\tthis.ecBlocks = new Array(ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4);\r\n\t\r\n\tvar total = 0;\r\n\tvar ecCodewords = ecBlocks1.ECCodewordsPerBlock;\r\n\tvar ecbArray = ecBlocks1.getECBlocks();\r\n\tfor (var i = 0; i < ecbArray.length; i++)\r\n\t{\r\n\t\tvar ecBlock = ecbArray[i];\r\n\t\ttotal += ecBlock.Count * (ecBlock.DataCodewords + ecCodewords);\r\n\t}\r\n\tthis.totalCodewords = total;\r\n\t\r\n\tthis.__defineGetter__(\"VersionNumber\", function()\r\n\t{\r\n\t\treturn this.versionNumber;\r\n\t});\r\n\t\r\n\tthis.__defineGetter__(\"AlignmentPatternCenters\", function()\r\n\t{\r\n\t\treturn this.alignmentPatternCenters;\r\n\t});\r\n\tthis.__defineGetter__(\"TotalCodewords\", function()\r\n\t{\r\n\t\treturn this.totalCodewords;\r\n\t});\r\n\tthis.__defineGetter__(\"DimensionForVersion\", function()\r\n\t{\r\n\t\treturn 17 + 4 * this.versionNumber;\r\n\t});\r\n\t\r\n\tthis.buildFunctionPattern=function()\r\n\t\t{\r\n\t\t\tvar dimension = this.DimensionForVersion;\r\n\t\t\tvar bitMatrix = new BitMatrix(dimension);\r\n\t\t\t\r\n\t\t\t// Top left finder pattern + separator + format\r\n\t\t\tbitMatrix.setRegion(0, 0, 9, 9);\r\n\t\t\t// Top right finder pattern + separator + format\r\n\t\t\tbitMatrix.setRegion(dimension - 8, 0, 8, 9);\r\n\t\t\t// Bottom left finder pattern + separator + format\r\n\t\t\tbitMatrix.setRegion(0, dimension - 8, 9, 8);\r\n\t\t\t\r\n\t\t\t// Alignment patterns\r\n\t\t\tvar max = this.alignmentPatternCenters.length;\r\n\t\t\tfor (var x = 0; x < max; x++)\r\n\t\t\t{\r\n\t\t\t\tvar i = this.alignmentPatternCenters[x] - 2;\r\n\t\t\t\tfor (var y = 0; y < max; y++)\r\n\t\t\t\t{\r\n\t\t\t\t\tif ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// No alignment patterns near the three finder paterns\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbitMatrix.setRegion(this.alignmentPatternCenters[y] - 2, i, 5, 5);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t// Vertical timing pattern\r\n\t\t\tbitMatrix.setRegion(6, 9, 1, dimension - 17);\r\n\t\t\t// Horizontal timing pattern\r\n\t\t\tbitMatrix.setRegion(9, 6, dimension - 17, 1);\r\n\t\t\t\r\n\t\t\tif (this.versionNumber > 6)\r\n\t\t\t{\r\n\t\t\t\t// Version info, top right\r\n\t\t\t\tbitMatrix.setRegion(dimension - 11, 0, 3, 6);\r\n\t\t\t\t// Version info, bottom left\r\n\t\t\t\tbitMatrix.setRegion(0, dimension - 11, 6, 3);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\treturn bitMatrix;\r\n\t\t}\r\n\tthis.getECBlocksForLevel=function( ecLevel)\r\n\t{\r\n\t\treturn this.ecBlocks[ecLevel.ordinal()];\r\n\t}\r\n}\r\n\r\nVersion.VERSION_DECODE_INFO = new Array(0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, 0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78, 0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683, 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB, 0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, 0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B, 0x2542E, 0x26A64, 0x27541, 0x28C69);\r\n\r\nVersion.VERSIONS = buildVersions();\r\n\r\nVersion.getVersionForNumber=function( versionNumber)\r\n{\r\n\tif (versionNumber < 1 || versionNumber > 40)\r\n\t{\r\n\t\tthrow \"ArgumentException\";\r\n\t}\r\n\treturn Version.VERSIONS[versionNumber - 1];\r\n}\r\n\r\nVersion.getProvisionalVersionForDimension=function(dimension)\r\n{\r\n\tif (dimension % 4 != 1)\r\n\t{\r\n\t\tthrow \"Error getProvisionalVersionForDimension\";\r\n\t}\r\n\ttry\r\n\t{\r\n\t\treturn Version.getVersionForNumber((dimension - 17) >> 2);\r\n\t}\r\n\tcatch ( iae)\r\n\t{\r\n\t\tthrow \"Error getVersionForNumber\";\r\n\t}\r\n}\r\n\r\nVersion.decodeVersionInformation=function( versionBits)\r\n{\r\n\tvar bestDifference = 0xffffffff;\r\n\tvar bestVersion = 0;\r\n\tfor (var i = 0; i < Version.VERSION_DECODE_INFO.length; i++)\r\n\t{\r\n\t\tvar targetVersion = Version.VERSION_DECODE_INFO[i];\r\n\t\t// Do the version info bits match exactly? done.\r\n\t\tif (targetVersion == versionBits)\r\n\t\t{\r\n\t\t\treturn this.getVersionForNumber(i + 7);\r\n\t\t}\r\n\t\t// Otherwise see if this is the closest to a real version info bit string\r\n\t\t// we have seen so far\r\n\t\tvar bitsDifference = FormatInformation.numBitsDiffering(versionBits, targetVersion);\r\n\t\tif (bitsDifference < bestDifference)\r\n\t\t{\r\n\t\t\tbestVersion = i + 7;\r\n\t\t\tbestDifference = bitsDifference;\r\n\t\t}\r\n\t}\r\n\t// We can tolerate up to 3 bits of error since no two version info codewords will\r\n\t// differ in less than 4 bits.\r\n\tif (bestDifference <= 3)\r\n\t{\r\n\t\treturn this.getVersionForNumber(bestVersion);\r\n\t}\r\n\t// If we didn't find a close enough match, fail\r\n\treturn null;\r\n}\r\n\r\nfunction buildVersions()\r\n{\r\n\treturn 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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), \t\tnew ECB(28, 16))),\r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))), \r\n\tnew 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))));\r\n}\n\n\n// WEBPACK FOOTER //\n// ./src/version.js","/*\r\n Ported to JavaScript by Lazar Laszlo 2011 \r\n \r\n lazarsoft@gmail.com, www.lazarsoft.info\r\n \r\n*/\r\n\r\n/*\r\n*\r\n* Copyright 2007 ZXing authors\r\n*\r\n* Licensed under the Apache License, Version 2.0 (the \"License\");\r\n* you may not use this file except in compliance with the License.\r\n* You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing, software\r\n* distributed under the License is distributed on an \"AS IS\" BASIS,\r\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n* See the License for the specific language governing permissions and\r\n* limitations under the License.\r\n*/\r\nimport {URShift} from './qrcode';\r\nimport ErrorCorrectionLevel from './errorlevel';\r\n\r\nvar FORMAT_INFO_MASK_QR = 0x5412;\r\nvar FORMAT_INFO_DECODE_LOOKUP = new Array(new Array(0x5412, 0x00), new Array(0x5125, 0x01), new Array(0x5E7C, 0x02), new Array(0x5B4B, 0x03), new Array(0x45F9, 0x04), new Array(0x40CE, 0x05), new Array(0x4F97, 0x06), new Array(0x4AA0, 0x07), new Array(0x77C4, 0x08), new Array(0x72F3, 0x09), new Array(0x7DAA, 0x0A), new Array(0x789D, 0x0B), new Array(0x662F, 0x0C), new Array(0x6318, 0x0D), new Array(0x6C41, 0x0E), new Array(0x6976, 0x0F), new Array(0x1689, 0x10), new Array(0x13BE, 0x11), new Array(0x1CE7, 0x12), new Array(0x19D0, 0x13), new Array(0x0762, 0x14), new Array(0x0255, 0x15), new Array(0x0D0C, 0x16), new Array(0x083B, 0x17), new Array(0x355F, 0x18), new Array(0x3068, 0x19), new Array(0x3F31, 0x1A), new Array(0x3A06, 0x1B), new Array(0x24B4, 0x1C), new Array(0x2183, 0x1D), new Array(0x2EDA, 0x1E), new Array(0x2BED, 0x1F));\r\nvar BITS_SET_IN_HALF_BYTE = new Array(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4);\r\n\r\n\r\nexport default function FormatInformation(formatInfo)\r\n{\r\n\tthis.errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03);\r\n\tthis.dataMask = (formatInfo & 0x07);\r\n\r\n\tthis.__defineGetter__(\"ErrorCorrectionLevel\", function()\r\n\t{\r\n\t\treturn this.errorCorrectionLevel;\r\n\t});\r\n\tthis.__defineGetter__(\"DataMask\", function()\r\n\t{\r\n\t\treturn this.dataMask;\r\n\t});\r\n\tthis.GetHashCode=function()\r\n\t{\r\n\t\treturn (this.errorCorrectionLevel.ordinal() << 3) | this.dataMask;\r\n\t}\r\n\tthis.Equals=function( o)\r\n\t{\r\n\t\tvar other = o;\r\n\t\treturn this.errorCorrectionLevel == other.errorCorrectionLevel && this.dataMask == other.dataMask;\r\n\t}\r\n}\r\n\r\nFormatInformation.numBitsDiffering=function( a, b)\r\n{\r\n\ta ^= b; // a now has a 1 bit exactly where its bit differs with b's\r\n\t// Count bits set quickly with a series of lookups:\r\n\treturn BITS_SET_IN_HALF_BYTE[a & 0x0F] + BITS_SET_IN_HALF_BYTE[(URShift(a, 4) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 8) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 12) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 16) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 20) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 24) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 28) & 0x0F)];\r\n}\r\n\r\nFormatInformation.decodeFormatInformation=function( maskedFormatInfo)\r\n{\r\n\tvar formatInfo = FormatInformation.doDecodeFormatInformation(maskedFormatInfo);\r\n\tif (formatInfo != null)\r\n\t{\r\n\t\treturn formatInfo;\r\n\t}\r\n\t// Should return null, but, some QR codes apparently\r\n\t// do not mask this info. Try again by actually masking the pattern\r\n\t// first\r\n\treturn FormatInformation.doDecodeFormatInformation(maskedFormatInfo ^ FORMAT_INFO_MASK_QR);\r\n}\r\nFormatInformation.doDecodeFormatInformation=function( maskedFormatInfo)\r\n{\r\n\t// Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing\r\n\tvar bestDifference = 0xffffffff;\r\n\tvar bestFormatInfo = 0;\r\n\tfor (var i = 0; i < FORMAT_INFO_DECODE_LOOKUP.length; i++)\r\n\t{\r\n\t\tvar decodeInfo = FORMAT_INFO_DECODE_LOOKUP[i];\r\n\t\tvar targetInfo = decodeInfo[0];\r\n\t\tif (targetInfo == maskedFormatInfo)\r\n\t\t{\r\n\t\t\t// Found an exact match\r\n\t\t\treturn new FormatInformation(decodeInfo[1]);\r\n\t\t}\r\n\t\tvar bitsDifference = this.numBitsDiffering(maskedFormatInfo, targetInfo);\r\n\t\tif (bitsDifference < bestDifference)\r\n\t\t{\r\n\t\t\tbestFormatInfo = decodeInfo[1];\r\n\t\t\tbestDifference = bitsDifference;\r\n\t\t}\r\n\t}\r\n\t// Hamming distance of the 32 masked codes is 7, by construction, so <= 3 bits\r\n\t// differing means we found a match\r\n\tif (bestDifference <= 3)\r\n\t{\r\n\t\treturn new FormatInformation(bestFormatInfo);\r\n\t}\r\n\treturn null;\r\n}\r\n\r\n\t\t\n\n\n// WEBPACK FOOTER //\n// ./src/formatinf.js","/*\r\n Ported to JavaScript by Lazar Laszlo 2011 \r\n \r\n lazarsoft@gmail.com, www.lazarsoft.info\r\n \r\n*/\r\n\r\n/*\r\n*\r\n* Copyright 2007 ZXing authors\r\n*\r\n* Licensed under the Apache License, Version 2.0 (the \"License\");\r\n* you may not use this file except in compliance with the License.\r\n* You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing, software\r\n* distributed under the License is distributed on an \"AS IS\" BASIS,\r\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n* See the License for the specific language governing permissions and\r\n* limitations under the License.\r\n*/\r\n\r\nimport {URShift} from './qrcode'\r\n\r\nexport default function BitMatrix( width, height)\r\n{\r\n\tif(!height)\r\n\t\theight=width;\r\n\tif (width < 1 || height < 1)\r\n\t{\r\n\t\tthrow \"Both dimensions must be greater than 0\";\r\n\t}\r\n\tthis.width = width;\r\n\tthis.height = height;\r\n\tvar rowSize = width >> 5;\r\n\tif ((width & 0x1f) != 0)\r\n\t{\r\n\t\trowSize++;\r\n\t}\r\n\tthis.rowSize = rowSize;\r\n\tthis.bits = new Array(rowSize * height);\r\n\tfor(var i=0;i> 5);\r\n\t\t\treturn ((URShift(this.bits[offset], (x & 0x1f))) & 1) != 0;\r\n\t\t}\r\n\tthis.set_Renamed=function( x, y)\r\n\t\t{\r\n\t\t\tvar offset = y * this.rowSize + (x >> 5);\r\n\t\t\tthis.bits[offset] |= 1 << (x & 0x1f);\r\n\t\t}\r\n\tthis.flip=function( x, y)\r\n\t\t{\r\n\t\t\tvar offset = y * this.rowSize + (x >> 5);\r\n\t\t\tthis.bits[offset] ^= 1 << (x & 0x1f);\r\n\t\t}\r\n\tthis.clear=function()\r\n\t\t{\r\n\t\t\tvar max = this.bits.length;\r\n\t\t\tfor (var i = 0; i < max; i++)\r\n\t\t\t{\r\n\t\t\t\tthis.bits[i] = 0;\r\n\t\t\t}\r\n\t\t}\r\n\tthis.setRegion=function( left, top, width, height)\r\n\t\t{\r\n\t\t\tif (top < 0 || left < 0)\r\n\t\t\t{\r\n\t\t\t\tthrow \"Left and top must be nonnegative\";\r\n\t\t\t}\r\n\t\t\tif (height < 1 || width < 1)\r\n\t\t\t{\r\n\t\t\t\tthrow \"Height and width must be at least 1\";\r\n\t\t\t}\r\n\t\t\tvar right = left + width;\r\n\t\t\tvar bottom = top + height;\r\n\t\t\tif (bottom > this.height || right > this.width)\r\n\t\t\t{\r\n\t\t\t\tthrow \"The region must fit inside the matrix\";\r\n\t\t\t}\r\n\t\t\tfor (var y = top; y < bottom; y++)\r\n\t\t\t{\r\n\t\t\t\tvar offset = y * this.rowSize;\r\n\t\t\t\tfor (var x = left; x < right; x++)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.bits[offset + (x >> 5)] |= 1 << (x & 0x1f);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n}\n\n\n// WEBPACK FOOTER //\n// ./src/bitmat.js","/*\r\n Ported to JavaScript by Lazar Laszlo 2011 \r\n \r\n lazarsoft@gmail.com, www.lazarsoft.info\r\n \r\n*/\r\n\r\n/*\r\n*\r\n* Copyright 2007 ZXing authors\r\n*\r\n* Licensed under the Apache License, Version 2.0 (the \"License\");\r\n* you may not use this file except in compliance with the License.\r\n* You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing, software\r\n* distributed under the License is distributed on an \"AS IS\" BASIS,\r\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n* See the License for the specific language governing permissions and\r\n* limitations under the License.\r\n*/\r\nimport GF256 from './gf256'\r\n\r\nexport default function GF256Poly(field, coefficients)\r\n{\r\n\tif (coefficients == null || coefficients.length == 0)\r\n\t{\r\n\t\tthrow \"System.ArgumentException\";\r\n\t}\r\n\tthis.field = field;\r\n\tvar coefficientsLength = coefficients.length;\r\n\tif (coefficientsLength > 1 && coefficients[0] == 0)\r\n\t{\r\n\t\t// Leading term must be non-zero for anything except the constant polynomial \"0\"\r\n\t\tvar firstNonZero = 1;\r\n\t\twhile (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0)\r\n\t\t{\r\n\t\t\tfirstNonZero++;\r\n\t\t}\r\n\t\tif (firstNonZero == coefficientsLength)\r\n\t\t{\r\n\t\t\tthis.coefficients = field.Zero.coefficients;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.coefficients = new Array(coefficientsLength - firstNonZero);\r\n\t\t\tfor(var i=0;i largerCoefficients.length)\r\n\t\t\t{\r\n\t\t\t\tvar temp = smallerCoefficients;\r\n\t\t\t\tsmallerCoefficients = largerCoefficients;\r\n\t\t\t\tlargerCoefficients = temp;\r\n\t\t\t}\r\n\t\t\tvar sumDiff = new Array(largerCoefficients.length);\r\n\t\t\tvar lengthDiff = largerCoefficients.length - smallerCoefficients.length;\r\n\t\t\t// Copy high-order terms only found in higher-degree polynomial's coefficients\r\n\t\t\t//Array.Copy(largerCoefficients, 0, sumDiff, 0, lengthDiff);\r\n\t\t\tfor(var ci=0;ci= other.Degree && !remainder.Zero)\r\n\t\t\t{\r\n\t\t\t\tvar degreeDifference = remainder.Degree - other.Degree;\r\n\t\t\t\tvar scale = this.field.multiply(remainder.getCoefficient(remainder.Degree), inverseDenominatorLeadingTerm);\r\n\t\t\t\tvar term = other.multiplyByMonomial(degreeDifference, scale);\r\n\t\t\t\tvar iterationQuotient = this.field.buildMonomial(degreeDifference, scale);\r\n\t\t\t\tquotient = quotient.addOrSubtract(iterationQuotient);\r\n\t\t\t\tremainder = remainder.addOrSubtract(term);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\treturn new Array(quotient, remainder);\r\n\t\t}\r\n}\n\n\n// WEBPACK FOOTER //\n// ./src/gf256poly.js","import qrcode from './qrcode'\r\n\r\nexport default qrcode;\n\n\n// WEBPACK FOOTER //\n// ./src/index.js","/*\r\n Ported to JavaScript by Lazar Laszlo 2011 \r\n \r\n lazarsoft@gmail.com, www.lazarsoft.info\r\n \r\n*/\r\n\r\n/*\r\n*\r\n* Copyright 2007 ZXing authors\r\n*\r\n* Licensed under the Apache License, Version 2.0 (the \"License\");\r\n* you may not use this file except in compliance with the License.\r\n* You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing, software\r\n* distributed under the License is distributed on an \"AS IS\" BASIS,\r\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n* See the License for the specific language governing permissions and\r\n* limitations under the License.\r\n*/\r\nimport qrcode from './qrcode'\r\nimport Version from './version';\r\nimport {AlignmentPatternFinder} from './alignpat';\r\nimport GridSampler from './grid';\r\nimport {FinderPatternFinder} from './findpat';\r\n\r\nfunction PerspectiveTransform( a11, a21, a31, a12, a22, a32, a13, a23, a33)\r\n{\r\n\tthis.a11 = a11;\r\n\tthis.a12 = a12;\r\n\tthis.a13 = a13;\r\n\tthis.a21 = a21;\r\n\tthis.a22 = a22;\r\n\tthis.a23 = a23;\r\n\tthis.a31 = a31;\r\n\tthis.a32 = a32;\r\n\tthis.a33 = a33;\r\n\tthis.transformPoints1=function( points)\r\n\t\t{\r\n\t\t\tvar max = points.length;\r\n\t\t\tvar a11 = this.a11;\r\n\t\t\tvar a12 = this.a12;\r\n\t\t\tvar a13 = this.a13;\r\n\t\t\tvar a21 = this.a21;\r\n\t\t\tvar a22 = this.a22;\r\n\t\t\tvar a23 = this.a23;\r\n\t\t\tvar a31 = this.a31;\r\n\t\t\tvar a32 = this.a32;\r\n\t\t\tvar a33 = this.a33;\r\n\t\t\tfor (var i = 0; i < max; i += 2)\r\n\t\t\t{\r\n\t\t\t\tvar x = points[i];\r\n\t\t\t\tvar y = points[i + 1];\r\n\t\t\t\tvar denominator = a13 * x + a23 * y + a33;\r\n\t\t\t\tpoints[i] = (a11 * x + a21 * y + a31) / denominator;\r\n\t\t\t\tpoints[i + 1] = (a12 * x + a22 * y + a32) / denominator;\r\n\t\t\t}\r\n\t\t}\r\n\tthis. transformPoints2=function(xValues, yValues)\r\n\t\t{\r\n\t\t\tvar n = xValues.length;\r\n\t\t\tfor (var i = 0; i < n; i++)\r\n\t\t\t{\r\n\t\t\t\tvar x = xValues[i];\r\n\t\t\t\tvar y = yValues[i];\r\n\t\t\t\tvar denominator = this.a13 * x + this.a23 * y + this.a33;\r\n\t\t\t\txValues[i] = (this.a11 * x + this.a21 * y + this.a31) / denominator;\r\n\t\t\t\tyValues[i] = (this.a12 * x + this.a22 * y + this.a32) / denominator;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\tthis.buildAdjoint=function()\r\n\t\t{\r\n\t\t\t// Adjoint is the transpose of the cofactor matrix:\r\n\t\t\treturn 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);\r\n\t\t}\r\n\tthis.times=function( other)\r\n\t\t{\r\n\t\t\treturn 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);\r\n\t\t}\r\n\r\n}\r\n\r\nPerspectiveTransform.quadrilateralToQuadrilateral=function( x0, y0, x1, y1, x2, y2, x3, y3, x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p)\r\n{\r\n\t\r\n\tvar qToS = this.quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3);\r\n\tvar sToQ = this.squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p);\r\n\treturn sToQ.times(qToS);\r\n}\r\n\r\nPerspectiveTransform.squareToQuadrilateral=function( x0, y0, x1, y1, x2, y2, x3, y3)\r\n{\r\n\tvar dy2 = y3 - y2;\r\n\tvar dy3 = y0 - y1 + y2 - y3;\r\n\tif (dy2 == 0.0 && dy3 == 0.0)\r\n\t{\r\n\t\treturn new PerspectiveTransform(x1 - x0, x2 - x1, x0, y1 - y0, y2 - y1, y0, 0.0, 0.0, 1.0);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tvar dx1 = x1 - x2;\r\n\t\tvar dx2 = x3 - x2;\r\n\t\tvar dx3 = x0 - x1 + x2 - x3;\r\n\t\tvar dy1 = y1 - y2;\r\n\t\tvar denominator = dx1 * dy2 - dx2 * dy1;\r\n\t\tvar a13 = (dx3 * dy2 - dx2 * dy3) / denominator;\r\n\t\tvar a23 = (dx1 * dy3 - dx3 * dy1) / denominator;\r\n\t\treturn new PerspectiveTransform(x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, y1 - y0 + a13 * y1, y3 - y0 + a23 * y3, y0, a13, a23, 1.0);\r\n\t}\r\n}\r\n\r\nPerspectiveTransform.quadrilateralToSquare=function( x0, y0, x1, y1, x2, y2, x3, y3)\r\n{\r\n\t// Here, the adjoint serves as the inverse:\r\n\treturn this.squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3).buildAdjoint();\r\n}\r\n\r\nfunction DetectorResult(bits, points)\r\n{\r\n\tthis.bits = bits;\r\n\tthis.points = points;\r\n}\r\n\r\n\r\nexport default function Detector(image)\r\n{\r\n\tthis.image=image;\r\n\tthis.resultPointCallback = null;\r\n\t\r\n\tthis.sizeOfBlackWhiteBlackRun=function( fromX, fromY, toX, toY)\r\n\t\t{\r\n\t\t\t// Mild variant of Bresenham's algorithm;\r\n\t\t\t// see http://en.wikipedia.org/wiki/Bresenham's_line_algorithm\r\n\t\t\tvar steep = Math.abs(toY - fromY) > Math.abs(toX - fromX);\r\n\t\t\tif (steep)\r\n\t\t\t{\r\n\t\t\t\tvar temp = fromX;\r\n\t\t\t\tfromX = fromY;\r\n\t\t\t\tfromY = temp;\r\n\t\t\t\ttemp = toX;\r\n\t\t\t\ttoX = toY;\r\n\t\t\t\ttoY = temp;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tvar dx = Math.abs(toX - fromX);\r\n\t\t\tvar dy = Math.abs(toY - fromY);\r\n\t\t\tvar error = - dx >> 1;\r\n\t\t\tvar ystep = fromY < toY?1:- 1;\r\n\t\t\tvar xstep = fromX < toX?1:- 1;\r\n\t\t\tvar state = 0; // In black pixels, looking for white, first or second time\r\n\t\t\tfor (var x = fromX, y = fromY; x != toX; x += xstep)\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\tvar realX = steep?y:x;\r\n\t\t\t\tvar realY = steep?x:y;\r\n\t\t\t\tif (state == 1)\r\n\t\t\t\t{\r\n\t\t\t\t\t// In white pixels, looking for black\r\n\t\t\t\t\tif (this.image[realX + realY*qrcode.width])\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tstate++;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tif (!this.image[realX + realY*qrcode.width])\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tstate++;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tif (state == 3)\r\n\t\t\t\t{\r\n\t\t\t\t\t// Found black, white, black, and stumbled back onto white; done\r\n\t\t\t\t\tvar diffX = x - fromX;\r\n\t\t\t\t\tvar diffY = y - fromY;\r\n\t\t\t\t\treturn Math.sqrt( (diffX * diffX + diffY * diffY));\r\n\t\t\t\t}\r\n\t\t\t\terror += dy;\r\n\t\t\t\tif (error > 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (y == toY)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\ty += ystep;\r\n\t\t\t\t\terror -= dx;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tvar diffX2 = toX - fromX;\r\n\t\t\tvar diffY2 = toY - fromY;\r\n\t\t\treturn Math.sqrt( (diffX2 * diffX2 + diffY2 * diffY2));\r\n\t\t}\r\n\r\n\t\r\n\tthis.sizeOfBlackWhiteBlackRunBothWays=function( fromX, fromY, toX, toY)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tvar result = this.sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY);\r\n\t\t\t\r\n\t\t\t// Now count other way -- don't run off image though of course\r\n\t\t\tvar scale = 1.0;\r\n\t\t\tvar otherToX = fromX - (toX - fromX);\r\n\t\t\tif (otherToX < 0)\r\n\t\t\t{\r\n\t\t\t\tscale = fromX / (fromX - otherToX);\r\n\t\t\t\totherToX = 0;\r\n\t\t\t}\r\n\t\t\telse if (otherToX >= qrcode.width)\r\n\t\t\t{\r\n\t\t\t\tscale = (qrcode.width - 1 - fromX) / (otherToX - fromX);\r\n\t\t\t\totherToX = qrcode.width - 1;\r\n\t\t\t}\r\n\t\t\tvar otherToY = Math.floor (fromY - (toY - fromY) * scale);\r\n\t\t\t\r\n\t\t\tscale = 1.0;\r\n\t\t\tif (otherToY < 0)\r\n\t\t\t{\r\n\t\t\t\tscale = fromY / (fromY - otherToY);\r\n\t\t\t\totherToY = 0;\r\n\t\t\t}\r\n\t\t\telse if (otherToY >= qrcode.height)\r\n\t\t\t{\r\n\t\t\t\tscale = (qrcode.height - 1 - fromY) / (otherToY - fromY);\r\n\t\t\t\totherToY = qrcode.height - 1;\r\n\t\t\t}\r\n\t\t\totherToX = Math.floor (fromX + (otherToX - fromX) * scale);\r\n\t\t\t\r\n\t\t\tresult += this.sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY);\r\n\t\t\treturn result - 1.0; // -1 because we counted the middle pixel twice\r\n\t\t}\r\n\t\t\r\n\r\n\t\r\n\tthis.calculateModuleSizeOneWay=function( pattern, otherPattern)\r\n\t\t{\r\n\t\t\tvar moduleSizeEst1 = this.sizeOfBlackWhiteBlackRunBothWays(Math.floor( pattern.X), Math.floor( pattern.Y), Math.floor( otherPattern.X), Math.floor(otherPattern.Y));\r\n\t\t\tvar moduleSizeEst2 = this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(otherPattern.X), Math.floor(otherPattern.Y), Math.floor( pattern.X), Math.floor(pattern.Y));\r\n\t\t\tif (isNaN(moduleSizeEst1))\r\n\t\t\t{\r\n\t\t\t\treturn moduleSizeEst2 / 7.0;\r\n\t\t\t}\r\n\t\t\tif (isNaN(moduleSizeEst2))\r\n\t\t\t{\r\n\t\t\t\treturn moduleSizeEst1 / 7.0;\r\n\t\t\t}\r\n\t\t\t// Average them, and divide by 7 since we've counted the width of 3 black modules,\r\n\t\t\t// and 1 white and 1 black module on either side. Ergo, divide sum by 14.\r\n\t\t\treturn (moduleSizeEst1 + moduleSizeEst2) / 14.0;\r\n\t\t}\r\n\r\n\t\r\n\tthis.calculateModuleSize=function( topLeft, topRight, bottomLeft)\r\n\t\t{\r\n\t\t\t// Take the average\r\n\t\t\treturn (this.calculateModuleSizeOneWay(topLeft, topRight) + this.calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0;\r\n\t\t}\r\n\r\n\tthis.distance=function( pattern1, pattern2)\r\n\t{\r\n\t\tvar xDiff = pattern1.X - pattern2.X;\r\n\t\tvar yDiff = pattern1.Y - pattern2.Y;\r\n\t\treturn Math.sqrt( (xDiff * xDiff + yDiff * yDiff));\r\n\t}\r\n\tthis.computeDimension=function( topLeft, topRight, bottomLeft, moduleSize)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tvar tltrCentersDimension = Math.round(this.distance(topLeft, topRight) / moduleSize);\r\n\t\t\tvar tlblCentersDimension = Math.round(this.distance(topLeft, bottomLeft) / moduleSize);\r\n\t\t\tvar dimension = ((tltrCentersDimension + tlblCentersDimension) >> 1) + 7;\r\n\t\t\tswitch (dimension & 0x03)\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\t// mod 4\r\n\t\t\t\tcase 0: \r\n\t\t\t\t\tdimension++;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t// 1? do nothing\r\n\t\t\t\t\r\n\t\t\t\tcase 2: \r\n\t\t\t\t\tdimension--;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\r\n\t\t\t\tcase 3: \r\n\t\t\t\t\tthrow \"Error\";\r\n\t\t\t\t}\r\n\t\t\treturn dimension;\r\n\t\t}\r\n\r\n\tthis.findAlignmentInRegion=function( overallEstModuleSize, estAlignmentX, estAlignmentY, allowanceFactor)\r\n\t\t{\r\n\t\t\t// Look for an alignment pattern (3 modules in size) around where it\r\n\t\t\t// should be\r\n\t\t\tvar allowance = Math.floor (allowanceFactor * overallEstModuleSize);\r\n\t\t\tvar alignmentAreaLeftX = Math.max(0, estAlignmentX - allowance);\r\n\t\t\tvar alignmentAreaRightX = Math.min(qrcode.width - 1, estAlignmentX + allowance);\r\n\t\t\tif (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3)\r\n\t\t\t{\r\n\t\t\t\tthrow \"Error\";\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tvar alignmentAreaTopY = Math.max(0, estAlignmentY - allowance);\r\n\t\t\tvar alignmentAreaBottomY = Math.min(qrcode.height - 1, estAlignmentY + allowance);\r\n\t\t\t\r\n\t\t\tvar alignmentFinder = new AlignmentPatternFinder(this.image, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, this.resultPointCallback);\r\n\t\t\treturn alignmentFinder.find();\r\n\t\t}\r\n\t\t\r\n\tthis.createTransform=function( topLeft, topRight, bottomLeft, alignmentPattern, dimension)\r\n\t\t{\r\n\t\t\tvar dimMinusThree = dimension - 3.5;\r\n\t\t\tvar bottomRightX;\r\n\t\t\tvar bottomRightY;\r\n\t\t\tvar sourceBottomRightX;\r\n\t\t\tvar sourceBottomRightY;\r\n\t\t\tif (alignmentPattern != null)\r\n\t\t\t{\r\n\t\t\t\tbottomRightX = alignmentPattern.X;\r\n\t\t\t\tbottomRightY = alignmentPattern.Y;\r\n\t\t\t\tsourceBottomRightX = sourceBottomRightY = dimMinusThree - 3.0;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t// Don't have an alignment pattern, just make up the bottom-right point\r\n\t\t\t\tbottomRightX = (topRight.X - topLeft.X) + bottomLeft.X;\r\n\t\t\t\tbottomRightY = (topRight.Y - topLeft.Y) + bottomLeft.Y;\r\n\t\t\t\tsourceBottomRightX = sourceBottomRightY = dimMinusThree;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tvar transform = 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);\r\n\t\t\t\r\n\t\t\treturn transform;\r\n\t\t}\t\t\r\n\t\r\n\tthis.sampleGrid=function( image, transform, dimension)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tvar sampler = GridSampler;\r\n\t\t\treturn sampler.sampleGrid3(image, dimension, transform);\r\n\t\t}\r\n\t\r\n\tthis.processFinderPatternInfo = function( info)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tvar topLeft = info.TopLeft;\r\n\t\t\tvar topRight = info.TopRight;\r\n\t\t\tvar bottomLeft = info.BottomLeft;\r\n\t\t\t\r\n\t\t\tvar moduleSize = this.calculateModuleSize(topLeft, topRight, bottomLeft);\r\n\t\t\tif (moduleSize < 1.0)\r\n\t\t\t{\r\n\t\t\t\tthrow \"Error\";\r\n\t\t\t}\r\n\t\t\tvar dimension = this.computeDimension(topLeft, topRight, bottomLeft, moduleSize);\r\n\t\t\tvar provisionalVersion = Version.getProvisionalVersionForDimension(dimension);\r\n\t\t\tvar modulesBetweenFPCenters = provisionalVersion.DimensionForVersion - 7;\r\n\t\t\t\r\n\t\t\tvar alignmentPattern = null;\r\n\t\t\t// Anything above version 1 has an alignment pattern\r\n\t\t\tif (provisionalVersion.AlignmentPatternCenters.length > 0)\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\t// Guess where a \"bottom right\" finder pattern would have been\r\n\t\t\t\tvar bottomRightX = topRight.X - topLeft.X + bottomLeft.X;\r\n\t\t\t\tvar bottomRightY = topRight.Y - topLeft.Y + bottomLeft.Y;\r\n\t\t\t\t\r\n\t\t\t\t// Estimate that alignment pattern is closer by 3 modules\r\n\t\t\t\t// from \"bottom right\" to known top left location\r\n\t\t\t\tvar correctionToTopLeft = 1.0 - 3.0 / modulesBetweenFPCenters;\r\n\t\t\t\tvar estAlignmentX = Math.floor (topLeft.X + correctionToTopLeft * (bottomRightX - topLeft.X));\r\n\t\t\t\tvar estAlignmentY = Math.floor (topLeft.Y + correctionToTopLeft * (bottomRightY - topLeft.Y));\r\n\t\t\t\t\r\n\t\t\t\t// Kind of arbitrary -- expand search radius before giving up\r\n\t\t\t\tfor (var i = 4; i <= 16; i <<= 1)\r\n\t\t\t\t{\r\n\t\t\t\t\t//try\r\n\t\t\t\t\t//{\r\n\t\t\t\t\t\talignmentPattern = this.findAlignmentInRegion(moduleSize, estAlignmentX, estAlignmentY, i);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t//}\r\n\t\t\t\t\t//catch (re)\r\n\t\t\t\t\t//{\r\n\t\t\t\t\t\t// try next round\r\n\t\t\t\t\t//}\r\n\t\t\t\t}\r\n\t\t\t\t// If we didn't find alignment pattern... well try anyway without it\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tvar transform = this.createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);\r\n\t\t\t\r\n\t\t\tvar bits = this.sampleGrid(this.image, transform, dimension);\r\n\t\t\t\r\n\t\t\tvar points;\r\n\t\t\tif (alignmentPattern == null)\r\n\t\t\t{\r\n\t\t\t\tpoints = new Array(bottomLeft, topLeft, topRight);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tpoints = new Array(bottomLeft, topLeft, topRight, alignmentPattern);\r\n\t\t\t}\r\n\t\t\treturn new DetectorResult(bits, points);\r\n\t\t}\r\n\t\t\r\n\r\n\t\r\n\tthis.detect=function()\r\n\t{\r\n\t\tvar info = new FinderPatternFinder().findFinderPattern(this.image);\r\n\t\t\t\r\n\t\treturn this.processFinderPatternInfo(info); \r\n\t}\r\n}\n\n\n// WEBPACK FOOTER //\n// ./src/detector.js","/*\r\n Ported to JavaScript by Lazar Laszlo 2011 \r\n \r\n lazarsoft@gmail.com, www.lazarsoft.info\r\n \r\n*/\r\n\r\n/*\r\n*\r\n* Copyright 2007 ZXing authors\r\n*\r\n* Licensed under the Apache License, Version 2.0 (the \"License\");\r\n* you may not use this file except in compliance with the License.\r\n* You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing, software\r\n* distributed under the License is distributed on an \"AS IS\" BASIS,\r\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n* See the License for the specific language governing permissions and\r\n* limitations under the License.\r\n*/\r\n\r\n\r\nexport default function ErrorCorrectionLevel(ordinal, bits, name)\r\n{\r\n\tthis.ordinal_Renamed_Field = ordinal;\r\n\tthis.bits = bits;\r\n\tthis.name = name;\r\n\tthis.__defineGetter__(\"Bits\", function()\r\n\t{\r\n\t\treturn this.bits;\r\n\t});\r\n\tthis.__defineGetter__(\"Name\", function()\r\n\t{\r\n\t\treturn this.name;\r\n\t});\r\n\tthis.ordinal=function()\r\n\t{\r\n\t\treturn this.ordinal_Renamed_Field;\r\n\t}\r\n}\r\n\r\nErrorCorrectionLevel.forBits=function( bits)\r\n{\r\n\tif (bits < 0 || bits >= FOR_BITS.length)\r\n\t{\r\n\t\tthrow \"ArgumentException\";\r\n\t}\r\n\treturn FOR_BITS[bits];\r\n}\r\n\r\nvar L = new ErrorCorrectionLevel(0, 0x01, \"L\");\r\nvar M = new ErrorCorrectionLevel(1, 0x00, \"M\");\r\nvar Q = new ErrorCorrectionLevel(2, 0x03, \"Q\");\r\nvar H = new ErrorCorrectionLevel(3, 0x02, \"H\");\r\nvar FOR_BITS = new Array( M, L, H, Q);\n\n\n// WEBPACK FOOTER //\n// ./src/errorlevel.js","/*\r\n Ported to JavaScript by Lazar Laszlo 2011 \r\n \r\n lazarsoft@gmail.com, www.lazarsoft.info\r\n \r\n*/\r\n\r\n/*\r\n*\r\n* Copyright 2007 ZXing authors\r\n*\r\n* Licensed under the Apache License, Version 2.0 (the \"License\");\r\n* you may not use this file except in compliance with the License.\r\n* You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing, software\r\n* distributed under the License is distributed on an \"AS IS\" BASIS,\r\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n* See the License for the specific language governing permissions and\r\n* limitations under the License.\r\n*/\r\nimport qrcode from './qrcode';\r\n\r\nexport default function AlignmentPattern(posX, posY, estimatedModuleSize)\r\n{\r\n\tthis.x=posX;\r\n\tthis.y=posY;\r\n\tthis.count = 1;\r\n\tthis.estimatedModuleSize = estimatedModuleSize;\r\n\t\r\n\tthis.__defineGetter__(\"EstimatedModuleSize\", function()\r\n\t{\r\n\t\treturn this.estimatedModuleSize;\r\n\t}); \r\n\tthis.__defineGetter__(\"Count\", function()\r\n\t{\r\n\t\treturn this.count;\r\n\t});\r\n\tthis.__defineGetter__(\"X\", function()\r\n\t{\r\n\t\treturn Math.floor(this.x);\r\n\t});\r\n\tthis.__defineGetter__(\"Y\", function()\r\n\t{\r\n\t\treturn Math.floor(this.y);\r\n\t});\r\n\tthis.incrementCount = function()\r\n\t{\r\n\t\tthis.count++;\r\n\t}\r\n\tthis.aboutEquals=function( moduleSize, i, j)\r\n\t\t{\r\n\t\t\tif (Math.abs(i - this.y) <= moduleSize && Math.abs(j - this.x) <= moduleSize)\r\n\t\t\t{\r\n\t\t\t\tvar moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize);\r\n\t\t\t\treturn moduleSizeDiff <= 1.0 || moduleSizeDiff / this.estimatedModuleSize <= 1.0;\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\r\n}\r\n\r\nexport function AlignmentPatternFinder( image, startX, startY, width, height, moduleSize, resultPointCallback)\r\n{\r\n\tthis.image = image;\r\n\tthis.possibleCenters = new Array();\r\n\tthis.startX = startX;\r\n\tthis.startY = startY;\r\n\tthis.width = width;\r\n\tthis.height = height;\r\n\tthis.moduleSize = moduleSize;\r\n\tthis.crossCheckStateCount = new Array(0,0,0);\r\n\tthis.resultPointCallback = resultPointCallback;\r\n\t\r\n\tthis.centerFromEnd=function(stateCount, end)\r\n\t\t{\r\n\t\t\treturn (end - stateCount[2]) - stateCount[1] / 2.0;\r\n\t\t}\r\n\tthis.foundPatternCross = function(stateCount)\r\n\t\t{\r\n\t\t\tvar moduleSize = this.moduleSize;\r\n\t\t\tvar maxVariance = moduleSize / 2.0;\r\n\t\t\tfor (var i = 0; i < 3; i++)\r\n\t\t\t{\r\n\t\t\t\tif (Math.abs(moduleSize - stateCount[i]) >= maxVariance)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\tthis.crossCheckVertical=function( startI, centerJ, maxCount, originalStateCountTotal)\r\n\t\t{\r\n\t\t\tvar image = this.image;\r\n\t\t\t\r\n\t\t\tvar maxI = qrcode.height;\r\n\t\t\tvar stateCount = this.crossCheckStateCount;\r\n\t\t\tstateCount[0] = 0;\r\n\t\t\tstateCount[1] = 0;\r\n\t\t\tstateCount[2] = 0;\r\n\t\t\t\r\n\t\t\t// Start counting up from center\r\n\t\t\tvar i = startI;\r\n\t\t\twhile (i >= 0 && image[centerJ + i*qrcode.width] && stateCount[1] <= maxCount)\r\n\t\t\t{\r\n\t\t\t\tstateCount[1]++;\r\n\t\t\t\ti--;\r\n\t\t\t}\r\n\t\t\t// If already too many modules in this state or ran off the edge:\r\n\t\t\tif (i < 0 || stateCount[1] > maxCount)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\twhile (i >= 0 && !image[centerJ + i*qrcode.width] && stateCount[0] <= maxCount)\r\n\t\t\t{\r\n\t\t\t\tstateCount[0]++;\r\n\t\t\t\ti--;\r\n\t\t\t}\r\n\t\t\tif (stateCount[0] > maxCount)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t// Now also count down from center\r\n\t\t\ti = startI + 1;\r\n\t\t\twhile (i < maxI && image[centerJ + i*qrcode.width] && stateCount[1] <= maxCount)\r\n\t\t\t{\r\n\t\t\t\tstateCount[1]++;\r\n\t\t\t\ti++;\r\n\t\t\t}\r\n\t\t\tif (i == maxI || stateCount[1] > maxCount)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\twhile (i < maxI && !image[centerJ + i*qrcode.width] && stateCount[2] <= maxCount)\r\n\t\t\t{\r\n\t\t\t\tstateCount[2]++;\r\n\t\t\t\ti++;\r\n\t\t\t}\r\n\t\t\tif (stateCount[2] > maxCount)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tvar stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];\r\n\t\t\tif (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\treturn this.foundPatternCross(stateCount)?this.centerFromEnd(stateCount, i):NaN;\r\n\t\t}\r\n\t\t\r\n\tthis.handlePossibleCenter=function( stateCount, i, j)\r\n\t\t{\r\n\t\t\tvar stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];\r\n\t\t\tvar centerJ = this.centerFromEnd(stateCount, j);\r\n\t\t\tvar centerI = this.crossCheckVertical(i, Math.floor (centerJ), 2 * stateCount[1], stateCountTotal);\r\n\t\t\tif (!isNaN(centerI))\r\n\t\t\t{\r\n\t\t\t\tvar estimatedModuleSize = (stateCount[0] + stateCount[1] + stateCount[2]) / 3.0;\r\n\t\t\t\tvar max = this.possibleCenters.length;\r\n\t\t\t\tfor (var index = 0; index < max; index++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar center = this.possibleCenters[index];\r\n\t\t\t\t\t// Look for about the same center and module size:\r\n\t\t\t\t\tif (center.aboutEquals(estimatedModuleSize, centerI, centerJ))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn new AlignmentPattern(centerJ, centerI, estimatedModuleSize);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t// Hadn't found this before; save it\r\n\t\t\t\tvar point = new AlignmentPattern(centerJ, centerI, estimatedModuleSize);\r\n\t\t\t\tthis.possibleCenters.push(point);\r\n\t\t\t\tif (this.resultPointCallback != null)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.resultPointCallback.foundPossibleResultPoint(point);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn null;\r\n\t\t}\r\n\t\t\r\n\tthis.find = function()\r\n\t{\r\n\t\t\tvar startX = this.startX;\r\n\t\t\tvar height = this.height;\r\n\t\t\tvar maxJ = startX + width;\r\n\t\t\tvar middleI = startY + (height >> 1);\r\n\t\t\t// We are looking for black/white/black modules in 1:1:1 ratio;\r\n\t\t\t// this tracks the number of black/white/black modules seen so far\r\n\t\t\tvar stateCount = new Array(0,0,0);\r\n\t\t\tfor (var iGen = 0; iGen < height; iGen++)\r\n\t\t\t{\r\n\t\t\t\t// Search from middle outwards\r\n\t\t\t\tvar i = middleI + ((iGen & 0x01) == 0?((iGen + 1) >> 1):- ((iGen + 1) >> 1));\r\n\t\t\t\tstateCount[0] = 0;\r\n\t\t\t\tstateCount[1] = 0;\r\n\t\t\t\tstateCount[2] = 0;\r\n\t\t\t\tvar j = startX;\r\n\t\t\t\t// Burn off leading white pixels before anything else; if we start in the middle of\r\n\t\t\t\t// a white run, it doesn't make sense to count its length, since we don't know if the\r\n\t\t\t\t// white run continued to the left of the start point\r\n\t\t\t\twhile (j < maxJ && !image[j + qrcode.width* i])\r\n\t\t\t\t{\r\n\t\t\t\t\tj++;\r\n\t\t\t\t}\r\n\t\t\t\tvar currentState = 0;\r\n\t\t\t\twhile (j < maxJ)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (image[j + i*qrcode.width])\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// Black pixel\r\n\t\t\t\t\t\tif (currentState == 1)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t// Counting black pixels\r\n\t\t\t\t\t\t\tstateCount[currentState]++;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t// Counting white pixels\r\n\t\t\t\t\t\t\tif (currentState == 2)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t// A winner?\r\n\t\t\t\t\t\t\t\tif (this.foundPatternCross(stateCount))\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t// Yes\r\n\t\t\t\t\t\t\t\t\tvar confirmed = this.handlePossibleCenter(stateCount, i, j);\r\n\t\t\t\t\t\t\t\t\tif (confirmed != null)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\treturn confirmed;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tstateCount[0] = stateCount[2];\r\n\t\t\t\t\t\t\t\tstateCount[1] = 1;\r\n\t\t\t\t\t\t\t\tstateCount[2] = 0;\r\n\t\t\t\t\t\t\t\tcurrentState = 1;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tstateCount[++currentState]++;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// White pixel\r\n\t\t\t\t\t\tif (currentState == 1)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t// Counting black pixels\r\n\t\t\t\t\t\t\tcurrentState++;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tstateCount[currentState]++;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tj++;\r\n\t\t\t\t}\r\n\t\t\t\tif (this.foundPatternCross(stateCount))\r\n\t\t\t\t{\r\n\t\t\t\t\tvar confirmed = this.handlePossibleCenter(stateCount, i, maxJ);\r\n\t\t\t\t\tif (confirmed != null)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn confirmed;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t// Hmm, nothing we saw was observed and confirmed twice. If we had\r\n\t\t\t// any guess at all, return it.\r\n\t\t\tif (!(this.possibleCenters.length == 0))\r\n\t\t\t{\r\n\t\t\t\treturn this.possibleCenters[0];\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tthrow \"Couldn't find enough alignment patterns\";\r\n\t\t}\r\n\t\r\n}\n\n\n// WEBPACK FOOTER //\n// ./src/alignpat.js","/*\r\n Ported to JavaScript by Lazar Laszlo 2011 \r\n \r\n lazarsoft@gmail.com, www.lazarsoft.info\r\n \r\n*/\r\n\r\n/*\r\n*\r\n* Copyright 2007 ZXing authors\r\n*\r\n* Licensed under the Apache License, Version 2.0 (the \"License\");\r\n* you may not use this file except in compliance with the License.\r\n* You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing, software\r\n* distributed under the License is distributed on an \"AS IS\" BASIS,\r\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n* See the License for the specific language governing permissions and\r\n* limitations under the License.\r\n*/\r\nimport BitMatrix from './bitmat';\r\nimport qrcode from './qrcode'\r\nvar GridSampler = {};\r\n\r\nGridSampler.checkAndNudgePoints=function( image, points)\r\n\t\t{\r\n\t\t\tvar width = qrcode.width;\r\n\t\t\tvar height = qrcode.height;\r\n\t\t\t// Check and nudge points from start until we see some that are OK:\r\n\t\t\tvar nudged = true;\r\n\t\t\tfor (var offset = 0; offset < points.length && nudged; offset += 2)\r\n\t\t\t{\r\n\t\t\t\tvar x = Math.floor (points[offset]);\r\n\t\t\t\tvar y = Math.floor( points[offset + 1]);\r\n\t\t\t\tif (x < - 1 || x > width || y < - 1 || y > height)\r\n\t\t\t\t{\r\n\t\t\t\t\tthrow \"Error.checkAndNudgePoints \";\r\n\t\t\t\t}\r\n\t\t\t\tnudged = false;\r\n\t\t\t\tif (x == - 1)\r\n\t\t\t\t{\r\n\t\t\t\t\tpoints[offset] = 0.0;\r\n\t\t\t\t\tnudged = true;\r\n\t\t\t\t}\r\n\t\t\t\telse if (x == width)\r\n\t\t\t\t{\r\n\t\t\t\t\tpoints[offset] = width - 1;\r\n\t\t\t\t\tnudged = true;\r\n\t\t\t\t}\r\n\t\t\t\tif (y == - 1)\r\n\t\t\t\t{\r\n\t\t\t\t\tpoints[offset + 1] = 0.0;\r\n\t\t\t\t\tnudged = true;\r\n\t\t\t\t}\r\n\t\t\t\telse if (y == height)\r\n\t\t\t\t{\r\n\t\t\t\t\tpoints[offset + 1] = height - 1;\r\n\t\t\t\t\tnudged = true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// Check and nudge points from end:\r\n\t\t\tnudged = true;\r\n\t\t\tfor (var offset = points.length - 2; offset >= 0 && nudged; offset -= 2)\r\n\t\t\t{\r\n\t\t\t\tvar x = Math.floor( points[offset]);\r\n\t\t\t\tvar y = Math.floor( points[offset + 1]);\r\n\t\t\t\tif (x < - 1 || x > width || y < - 1 || y > height)\r\n\t\t\t\t{\r\n\t\t\t\t\tthrow \"Error.checkAndNudgePoints \";\r\n\t\t\t\t}\r\n\t\t\t\tnudged = false;\r\n\t\t\t\tif (x == - 1)\r\n\t\t\t\t{\r\n\t\t\t\t\tpoints[offset] = 0.0;\r\n\t\t\t\t\tnudged = true;\r\n\t\t\t\t}\r\n\t\t\t\telse if (x == width)\r\n\t\t\t\t{\r\n\t\t\t\t\tpoints[offset] = width - 1;\r\n\t\t\t\t\tnudged = true;\r\n\t\t\t\t}\r\n\t\t\t\tif (y == - 1)\r\n\t\t\t\t{\r\n\t\t\t\t\tpoints[offset + 1] = 0.0;\r\n\t\t\t\t\tnudged = true;\r\n\t\t\t\t}\r\n\t\t\t\telse if (y == height)\r\n\t\t\t\t{\r\n\t\t\t\t\tpoints[offset + 1] = height - 1;\r\n\t\t\t\t\tnudged = true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\r\n\r\n\r\nGridSampler.sampleGrid3=function( image, dimension, transform)\r\n\t\t{\r\n\t\t\tvar bits = new BitMatrix(dimension);\r\n\t\t\tvar points = new Array(dimension << 1);\r\n\t\t\tfor (var y = 0; y < dimension; y++)\r\n\t\t\t{\r\n\t\t\t\tvar max = points.length;\r\n\t\t\t\tvar iValue = y + 0.5;\r\n\t\t\t\tfor (var x = 0; x < max; x += 2)\r\n\t\t\t\t{\r\n\t\t\t\t\tpoints[x] = (x >> 1) + 0.5;\r\n\t\t\t\t\tpoints[x + 1] = iValue;\r\n\t\t\t\t}\r\n\t\t\t\ttransform.transformPoints1(points);\r\n\t\t\t\t// Quick check to see if points transformed to something inside the image;\r\n\t\t\t\t// sufficient to check the endpoints\r\n\t\t\t\tGridSampler.checkAndNudgePoints(image, points);\r\n\t\t\t\ttry\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (var x = 0; x < max; x += 2)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t//var xpoint = (Math.floor( points[x]) * 4) + (Math.floor( points[x + 1]) * qrcode.width * 4);\r\n var bit = image[Math.floor( points[x])+ qrcode.width* Math.floor( points[x + 1])];\r\n\t\t\t\t\t\t//qrcode.imagedata.data[xpoint] = bit?255:0;\r\n\t\t\t\t\t\t//qrcode.imagedata.data[xpoint+1] = bit?255:0;\r\n\t\t\t\t\t\t//qrcode.imagedata.data[xpoint+2] = 0;\r\n\t\t\t\t\t\t//qrcode.imagedata.data[xpoint+3] = 255;\r\n\t\t\t\t\t\t//bits[x >> 1][ y]=bit;\r\n\t\t\t\t\t\tif(bit)\r\n\t\t\t\t\t\t\tbits.set_Renamed(x >> 1, y);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tcatch ( aioobe)\r\n\t\t\t\t{\r\n\t\t\t\t\t// This feels wrong, but, sometimes if the finder patterns are misidentified, the resulting\r\n\t\t\t\t\t// transform gets \"twisted\" such that it maps a straight line of points to a set of points\r\n\t\t\t\t\t// whose endpoints are in bounds, but others are not. There is probably some mathematical\r\n\t\t\t\t\t// way to detect this about the transformation that I don't know yet.\r\n\t\t\t\t\t// This results in an ugly runtime exception despite our clever checks above -- can't have\r\n\t\t\t\t\t// that. We could check each point's coordinates but that feels duplicative. We settle for\r\n\t\t\t\t\t// catching and wrapping ArrayIndexOutOfBoundsException.\r\n\t\t\t\t\tthrow \"Error.checkAndNudgePoints\";\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn bits;\r\n\t\t}\r\n\r\nGridSampler.sampleGridx=function( image, dimension, p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY)\r\n{\r\n\tvar transform = PerspectiveTransform.quadrilateralToQuadrilateral(p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY);\r\n\t\t\t\r\n\treturn GridSampler.sampleGrid3(image, dimension, transform);\r\n}\r\n\r\nexport default GridSampler;\n\n\n// WEBPACK FOOTER //\n// ./src/grid.js","/*\r\n Ported to JavaScript by Lazar Laszlo 2011 \r\n \r\n lazarsoft@gmail.com, www.lazarsoft.info\r\n \r\n*/\r\n\r\n/*\r\n*\r\n* Copyright 2007 ZXing authors\r\n*\r\n* Licensed under the Apache License, Version 2.0 (the \"License\");\r\n* you may not use this file except in compliance with the License.\r\n* You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing, software\r\n* distributed under the License is distributed on an \"AS IS\" BASIS,\r\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n* See the License for the specific language governing permissions and\r\n* limitations under the License.\r\n*/\r\nimport qrcode from './qrcode'\r\n\r\nvar MIN_SKIP = 3;\r\nvar MAX_MODULES = 57;\r\nvar INTEGER_MATH_SHIFT = 8;\r\nvar CENTER_QUORUM = 2;\r\n\r\nfunction orderBestPatterns(patterns)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tfunction distance( pattern1, pattern2)\r\n\t\t\t{\r\n\t\t\t\tvar xDiff = pattern1.X - pattern2.X;\r\n\t\t\t\tvar yDiff = pattern1.Y - pattern2.Y;\r\n\t\t\t\treturn Math.sqrt( (xDiff * xDiff + yDiff * yDiff));\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t/// Returns the z component of the cross product between vectors BC and BA.\r\n\t\t\tfunction crossProductZ( pointA, pointB, pointC)\r\n\t\t\t{\r\n\t\t\t\tvar bX = pointB.x;\r\n\t\t\t\tvar bY = pointB.y;\r\n\t\t\t\treturn ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX));\r\n\t\t\t}\r\n\r\n\t\t\t\r\n\t\t\t// Find distances between pattern centers\r\n\t\t\tvar zeroOneDistance = distance(patterns[0], patterns[1]);\r\n\t\t\tvar oneTwoDistance = distance(patterns[1], patterns[2]);\r\n\t\t\tvar zeroTwoDistance = distance(patterns[0], patterns[2]);\r\n\t\t\t\r\n\t\t\tvar pointA, pointB, pointC;\r\n\t\t\t// Assume one closest to other two is B; A and C will just be guesses at first\r\n\t\t\tif (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance)\r\n\t\t\t{\r\n\t\t\t\tpointB = patterns[0];\r\n\t\t\t\tpointA = patterns[1];\r\n\t\t\t\tpointC = patterns[2];\r\n\t\t\t}\r\n\t\t\telse if (zeroTwoDistance >= oneTwoDistance && zeroTwoDistance >= zeroOneDistance)\r\n\t\t\t{\r\n\t\t\t\tpointB = patterns[1];\r\n\t\t\t\tpointA = patterns[0];\r\n\t\t\t\tpointC = patterns[2];\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tpointB = patterns[2];\r\n\t\t\t\tpointA = patterns[0];\r\n\t\t\t\tpointC = patterns[1];\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t// Use cross product to figure out whether A and C are correct or flipped.\r\n\t\t\t// This asks whether BC x BA has a positive z component, which is the arrangement\r\n\t\t\t// we want for A, B, C. If it's negative, then we've got it flipped around and\r\n\t\t\t// should swap A and C.\r\n\t\t\tif (crossProductZ(pointA, pointB, pointC) < 0.0)\r\n\t\t\t{\r\n\t\t\t\tvar temp = pointA;\r\n\t\t\t\tpointA = pointC;\r\n\t\t\t\tpointC = temp;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tpatterns[0] = pointA;\r\n\t\t\tpatterns[1] = pointB;\r\n\t\t\tpatterns[2] = pointC;\r\n\t\t}\r\n\r\n\r\nfunction FinderPattern(posX, posY, estimatedModuleSize)\r\n{\r\n\tthis.x=posX;\r\n\tthis.y=posY;\r\n\tthis.count = 1;\r\n\tthis.estimatedModuleSize = estimatedModuleSize;\r\n\t\r\n\tthis.__defineGetter__(\"EstimatedModuleSize\", function()\r\n\t{\r\n\t\treturn this.estimatedModuleSize;\r\n\t}); \r\n\tthis.__defineGetter__(\"Count\", function()\r\n\t{\r\n\t\treturn this.count;\r\n\t});\r\n\tthis.__defineGetter__(\"X\", function()\r\n\t{\r\n\t\treturn this.x;\r\n\t});\r\n\tthis.__defineGetter__(\"Y\", function()\r\n\t{\r\n\t\treturn this.y;\r\n\t});\r\n\tthis.incrementCount = function()\r\n\t{\r\n\t\tthis.count++;\r\n\t}\r\n\tthis.aboutEquals=function( moduleSize, i, j)\r\n\t\t{\r\n\t\t\tif (Math.abs(i - this.y) <= moduleSize && Math.abs(j - this.x) <= moduleSize)\r\n\t\t\t{\r\n\t\t\t\tvar moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize);\r\n\t\t\t\treturn moduleSizeDiff <= 1.0 || moduleSizeDiff / this.estimatedModuleSize <= 1.0;\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\r\n}\r\n\r\nfunction FinderPatternInfo(patternCenters)\r\n{\r\n\tthis.bottomLeft = patternCenters[0];\r\n\tthis.topLeft = patternCenters[1];\r\n\tthis.topRight = patternCenters[2];\r\n\tthis.__defineGetter__(\"BottomLeft\", function()\r\n\t{\r\n\t\treturn this.bottomLeft;\r\n\t}); \r\n\tthis.__defineGetter__(\"TopLeft\", function()\r\n\t{\r\n\t\treturn this.topLeft;\r\n\t}); \r\n\tthis.__defineGetter__(\"TopRight\", function()\r\n\t{\r\n\t\treturn this.topRight;\r\n\t}); \r\n}\r\n\r\nexport function FinderPatternFinder()\r\n{\r\n\tthis.image=null;\r\n\tthis.possibleCenters = [];\r\n\tthis.hasSkipped = false;\r\n\tthis.crossCheckStateCount = new Array(0,0,0,0,0);\r\n\tthis.resultPointCallback = null;\r\n\t\r\n\tthis.__defineGetter__(\"CrossCheckStateCount\", function()\r\n\t{\r\n\t\tthis.crossCheckStateCount[0] = 0;\r\n\t\tthis.crossCheckStateCount[1] = 0;\r\n\t\tthis.crossCheckStateCount[2] = 0;\r\n\t\tthis.crossCheckStateCount[3] = 0;\r\n\t\tthis.crossCheckStateCount[4] = 0;\r\n\t\treturn this.crossCheckStateCount;\r\n\t}); \r\n\t\r\n\tthis.foundPatternCross=function( stateCount)\r\n\t\t{\r\n\t\t\tvar totalModuleSize = 0;\r\n\t\t\tfor (var i = 0; i < 5; i++)\r\n\t\t\t{\r\n\t\t\t\tvar count = stateCount[i];\r\n\t\t\t\tif (count == 0)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t\ttotalModuleSize += count;\r\n\t\t\t}\r\n\t\t\tif (totalModuleSize < 7)\r\n\t\t\t{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\tvar moduleSize = Math.floor((totalModuleSize << INTEGER_MATH_SHIFT) / 7);\r\n\t\t\tvar maxVariance = Math.floor(moduleSize / 2);\r\n\t\t\t// Allow less than 50% variance from 1-1-3-1-1 proportions\r\n\t\t\treturn Math.abs(moduleSize - (stateCount[0] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(moduleSize - (stateCount[1] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(3 * moduleSize - (stateCount[2] << INTEGER_MATH_SHIFT)) < 3 * maxVariance && Math.abs(moduleSize - (stateCount[3] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(moduleSize - (stateCount[4] << INTEGER_MATH_SHIFT)) < maxVariance;\r\n\t\t}\r\n\tthis.centerFromEnd=function( stateCount, end)\r\n\t\t{\r\n\t\t\treturn (end - stateCount[4] - stateCount[3]) - stateCount[2] / 2.0;\r\n\t\t}\r\n\tthis.crossCheckVertical=function( startI, centerJ, maxCount, originalStateCountTotal)\r\n\t\t{\r\n\t\t\tvar image = this.image;\r\n\t\t\t\r\n\t\t\tvar maxI = qrcode.height;\r\n\t\t\tvar stateCount = this.CrossCheckStateCount;\r\n\t\t\t\r\n\t\t\t// Start counting up from center\r\n\t\t\tvar i = startI;\r\n\t\t\twhile (i >= 0 && image[centerJ + i*qrcode.width])\r\n\t\t\t{\r\n\t\t\t\tstateCount[2]++;\r\n\t\t\t\ti--;\r\n\t\t\t}\r\n\t\t\tif (i < 0)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\twhile (i >= 0 && !image[centerJ +i*qrcode.width] && stateCount[1] <= maxCount)\r\n\t\t\t{\r\n\t\t\t\tstateCount[1]++;\r\n\t\t\t\ti--;\r\n\t\t\t}\r\n\t\t\t// If already too many modules in this state or ran off the edge:\r\n\t\t\tif (i < 0 || stateCount[1] > maxCount)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\twhile (i >= 0 && image[centerJ + i*qrcode.width] && stateCount[0] <= maxCount)\r\n\t\t\t{\r\n\t\t\t\tstateCount[0]++;\r\n\t\t\t\ti--;\r\n\t\t\t}\r\n\t\t\tif (stateCount[0] > maxCount)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t// Now also count down from center\r\n\t\t\ti = startI + 1;\r\n\t\t\twhile (i < maxI && image[centerJ +i*qrcode.width])\r\n\t\t\t{\r\n\t\t\t\tstateCount[2]++;\r\n\t\t\t\ti++;\r\n\t\t\t}\r\n\t\t\tif (i == maxI)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\twhile (i < maxI && !image[centerJ + i*qrcode.width] && stateCount[3] < maxCount)\r\n\t\t\t{\r\n\t\t\t\tstateCount[3]++;\r\n\t\t\t\ti++;\r\n\t\t\t}\r\n\t\t\tif (i == maxI || stateCount[3] >= maxCount)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\twhile (i < maxI && image[centerJ + i*qrcode.width] && stateCount[4] < maxCount)\r\n\t\t\t{\r\n\t\t\t\tstateCount[4]++;\r\n\t\t\t\ti++;\r\n\t\t\t}\r\n\t\t\tif (stateCount[4] >= maxCount)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t// If we found a finder-pattern-like section, but its size is more than 40% different than\r\n\t\t\t// the original, assume it's a false positive\r\n\t\t\tvar stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];\r\n\t\t\tif (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\treturn this.foundPatternCross(stateCount)?this.centerFromEnd(stateCount, i):NaN;\r\n\t\t}\r\n\tthis.crossCheckHorizontal=function( startJ, centerI, maxCount, originalStateCountTotal)\r\n\t\t{\r\n\t\t\tvar image = this.image;\r\n\t\t\t\r\n\t\t\tvar maxJ = qrcode.width;\r\n\t\t\tvar stateCount = this.CrossCheckStateCount;\r\n\t\t\t\r\n\t\t\tvar j = startJ;\r\n\t\t\twhile (j >= 0 && image[j+ centerI*qrcode.width])\r\n\t\t\t{\r\n\t\t\t\tstateCount[2]++;\r\n\t\t\t\tj--;\r\n\t\t\t}\r\n\t\t\tif (j < 0)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\twhile (j >= 0 && !image[j+ centerI*qrcode.width] && stateCount[1] <= maxCount)\r\n\t\t\t{\r\n\t\t\t\tstateCount[1]++;\r\n\t\t\t\tj--;\r\n\t\t\t}\r\n\t\t\tif (j < 0 || stateCount[1] > maxCount)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\twhile (j >= 0 && image[j+ centerI*qrcode.width] && stateCount[0] <= maxCount)\r\n\t\t\t{\r\n\t\t\t\tstateCount[0]++;\r\n\t\t\t\tj--;\r\n\t\t\t}\r\n\t\t\tif (stateCount[0] > maxCount)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tj = startJ + 1;\r\n\t\t\twhile (j < maxJ && image[j+ centerI*qrcode.width])\r\n\t\t\t{\r\n\t\t\t\tstateCount[2]++;\r\n\t\t\t\tj++;\r\n\t\t\t}\r\n\t\t\tif (j == maxJ)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\twhile (j < maxJ && !image[j+ centerI*qrcode.width] && stateCount[3] < maxCount)\r\n\t\t\t{\r\n\t\t\t\tstateCount[3]++;\r\n\t\t\t\tj++;\r\n\t\t\t}\r\n\t\t\tif (j == maxJ || stateCount[3] >= maxCount)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\twhile (j < maxJ && image[j+ centerI*qrcode.width] && stateCount[4] < maxCount)\r\n\t\t\t{\r\n\t\t\t\tstateCount[4]++;\r\n\t\t\t\tj++;\r\n\t\t\t}\r\n\t\t\tif (stateCount[4] >= maxCount)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t// If we found a finder-pattern-like section, but its size is significantly different than\r\n\t\t\t// the original, assume it's a false positive\r\n\t\t\tvar stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];\r\n\t\t\tif (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= originalStateCountTotal)\r\n\t\t\t{\r\n\t\t\t\treturn NaN;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\treturn this.foundPatternCross(stateCount)?this.centerFromEnd(stateCount, j):NaN;\r\n\t\t}\r\n\tthis.handlePossibleCenter=function( stateCount, i, j)\r\n\t\t{\r\n\t\t\tvar stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];\r\n\t\t\tvar centerJ = this.centerFromEnd(stateCount, j); //float\r\n\t\t\tvar centerI = this.crossCheckVertical(i, Math.floor( centerJ), stateCount[2], stateCountTotal); //float\r\n\t\t\tif (!isNaN(centerI))\r\n\t\t\t{\r\n\t\t\t\t// Re-cross check\r\n\t\t\t\tcenterJ = this.crossCheckHorizontal(Math.floor( centerJ), Math.floor( centerI), stateCount[2], stateCountTotal);\r\n\t\t\t\tif (!isNaN(centerJ))\r\n\t\t\t\t{\r\n\t\t\t\t\tvar estimatedModuleSize = stateCountTotal / 7.0;\r\n\t\t\t\t\tvar found = false;\r\n\t\t\t\t\tvar max = this.possibleCenters.length;\r\n\t\t\t\t\tfor (var index = 0; index < max; index++)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar center = this.possibleCenters[index];\r\n\t\t\t\t\t\t// Look for about the same center and module size:\r\n\t\t\t\t\t\tif (center.aboutEquals(estimatedModuleSize, centerI, centerJ))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tcenter.incrementCount();\r\n\t\t\t\t\t\t\tfound = true;\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (!found)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar point = new FinderPattern(centerJ, centerI, estimatedModuleSize);\r\n\t\t\t\t\t\tthis.possibleCenters.push(point);\r\n\t\t\t\t\t\tif (this.resultPointCallback != null)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.resultPointCallback.foundPossibleResultPoint(point);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\t\r\n\tthis.selectBestPatterns=function()\r\n\t\t{\r\n\t\t\t\r\n\t\t\tvar startSize = this.possibleCenters.length;\r\n\t\t\tif (startSize < 3)\r\n\t\t\t{\r\n\t\t\t\t// Couldn't find enough finder patterns\r\n\t\t\t\tthrow \"Couldn't find enough finder patterns (found \" + startSize + \")\"\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t// Filter outlier possibilities whose module size is too different\r\n\t\t\tif (startSize > 3)\r\n\t\t\t{\r\n\t\t\t\t// But we can only afford to do so if we have at least 4 possibilities to choose from\r\n\t\t\t\tvar totalModuleSize = 0.0;\r\n var square = 0.0;\r\n\t\t\t\tfor (var i = 0; i < startSize; i++)\r\n\t\t\t\t{\r\n\t\t\t\t\t//totalModuleSize += this.possibleCenters[i].EstimatedModuleSize;\r\n var\tcenterValue=this.possibleCenters[i].EstimatedModuleSize;\r\n\t\t\t\t\ttotalModuleSize += centerValue;\r\n\t\t\t\t\tsquare += (centerValue * centerValue);\r\n\t\t\t\t}\r\n\t\t\t\tvar average = totalModuleSize / startSize;\r\n this.possibleCenters.sort(function(center1,center2) {\r\n\t\t\t\t var dA=Math.abs(center2.EstimatedModuleSize - average);\r\n\t\t\t\t var dB=Math.abs(center1.EstimatedModuleSize - average);\r\n\t\t\t\t if (dA < dB) {\r\n\t\t\t\t \t return (-1);\r\n\t\t\t\t } else if (dA == dB) {\r\n\t\t\t\t \t return 0;\r\n\t\t\t\t } else {\r\n\t\t\t\t \t return 1;\r\n\t\t\t\t }\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\tvar stdDev = Math.sqrt(square / startSize - average * average);\r\n\t\t\t\tvar limit = Math.max(0.2 * average, stdDev);\r\n\t\t\t\t//for (var i = 0; i < this.possibleCenters.length && this.possibleCenters.length > 3; i++)\r\n\t\t\t\tfor (var i = this.possibleCenters.length - 1; i >= 0 ; i--)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar pattern = this.possibleCenters[i];\r\n\t\t\t\t\t//if (Math.abs(pattern.EstimatedModuleSize - average) > 0.2 * average)\r\n if (Math.abs(pattern.EstimatedModuleSize - average) > limit)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t//this.possibleCenters.remove(i);\r\n\t\t\t\t\t\tthis.possibleCenters.splice(i,1);\r\n\t\t\t\t\t\t//i--;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif (this.possibleCenters.length > 3)\r\n\t\t\t{\r\n\t\t\t\t// Throw away all but those first size candidate points we found.\r\n\t\t\t\tthis.possibleCenters.sort(function(a, b){\r\n\t\t\t\t\tif (a.count > b.count){return -1;}\r\n\t\t\t\t\tif (a.count < b.count){return 1;}\r\n\t\t\t\t\treturn 0;\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\treturn new Array( this.possibleCenters[0], this.possibleCenters[1], this.possibleCenters[2]);\r\n\t\t}\r\n\t\t\r\n\tthis.findRowSkip=function()\r\n\t\t{\r\n\t\t\tvar max = this.possibleCenters.length;\r\n\t\t\tif (max <= 1)\r\n\t\t\t{\r\n\t\t\t\treturn 0;\r\n\t\t\t}\r\n\t\t\tvar firstConfirmedCenter = null;\r\n\t\t\tfor (var i = 0; i < max; i++)\r\n\t\t\t{\r\n\t\t\t\tvar center = this.possibleCenters[i];\r\n\t\t\t\tif (center.Count >= CENTER_QUORUM)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (firstConfirmedCenter == null)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfirstConfirmedCenter = center;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// We have two confirmed centers\r\n\t\t\t\t\t\t// How far down can we skip before resuming looking for the next\r\n\t\t\t\t\t\t// pattern? In the worst case, only the difference between the\r\n\t\t\t\t\t\t// difference in the x / y coordinates of the two centers.\r\n\t\t\t\t\t\t// This is the case where you find top left last.\r\n\t\t\t\t\t\tthis.hasSkipped = true;\r\n\t\t\t\t\t\treturn Math.floor ((Math.abs(firstConfirmedCenter.X - center.X) - Math.abs(firstConfirmedCenter.Y - center.Y)) / 2);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\r\n\tthis.haveMultiplyConfirmedCenters=function()\r\n\t\t{\r\n\t\t\tvar confirmedCount = 0;\r\n\t\t\tvar totalModuleSize = 0.0;\r\n\t\t\tvar max = this.possibleCenters.length;\r\n\t\t\tfor (var i = 0; i < max; i++)\r\n\t\t\t{\r\n\t\t\t\tvar pattern = this.possibleCenters[i];\r\n\t\t\t\tif (pattern.Count >= CENTER_QUORUM)\r\n\t\t\t\t{\r\n\t\t\t\t\tconfirmedCount++;\r\n\t\t\t\t\ttotalModuleSize += pattern.EstimatedModuleSize;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (confirmedCount < 3)\r\n\t\t\t{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\t// OK, we have at least 3 confirmed centers, but, it's possible that one is a \"false positive\"\r\n\t\t\t// and that we need to keep looking. We detect this by asking if the estimated module sizes\r\n\t\t\t// vary too much. We arbitrarily say that when the total deviation from average exceeds\r\n\t\t\t// 5% of the total module size estimates, it's too much.\r\n\t\t\tvar average = totalModuleSize / max;\r\n\t\t\tvar totalDeviation = 0.0;\r\n\t\t\tfor (var i = 0; i < max; i++)\r\n\t\t\t{\r\n\t\t\t\tpattern = this.possibleCenters[i];\r\n\t\t\t\ttotalDeviation += Math.abs(pattern.EstimatedModuleSize - average);\r\n\t\t\t}\r\n\t\t\treturn totalDeviation <= 0.05 * totalModuleSize;\r\n\t\t}\r\n\t\t\r\n\tthis.findFinderPattern = function(image){\r\n\t\tvar tryHarder = false;\r\n\t\tthis.image=image;\r\n\t\tvar maxI = qrcode.height;\r\n\t\tvar maxJ = qrcode.width;\r\n\t\tvar iSkip = Math.floor((3 * maxI) / (4 * MAX_MODULES));\r\n\t\tif (iSkip < MIN_SKIP || tryHarder)\r\n\t\t{\r\n\t\t\t\tiSkip = MIN_SKIP;\r\n\t\t}\r\n\t\t\r\n\t\tvar done = false;\r\n\t\tvar stateCount = new Array(5);\r\n\t\tfor (var i = iSkip - 1; i < maxI && !done; i += iSkip)\r\n\t\t{\r\n\t\t\t// Get a row of black/white values\r\n\t\t\tstateCount[0] = 0;\r\n\t\t\tstateCount[1] = 0;\r\n\t\t\tstateCount[2] = 0;\r\n\t\t\tstateCount[3] = 0;\r\n\t\t\tstateCount[4] = 0;\r\n\t\t\tvar currentState = 0;\r\n\t\t\tfor (var j = 0; j < maxJ; j++)\r\n\t\t\t{\r\n\t\t\t\tif (image[j+i*qrcode.width] )\r\n\t\t\t\t{\r\n\t\t\t\t\t// Black pixel\r\n\t\t\t\t\tif ((currentState & 1) == 1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// Counting white pixels\r\n\t\t\t\t\t\tcurrentState++;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tstateCount[currentState]++;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t// White pixel\r\n\t\t\t\t\tif ((currentState & 1) == 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// Counting black pixels\r\n\t\t\t\t\t\tif (currentState == 4)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t// A winner?\r\n\t\t\t\t\t\t\tif (this.foundPatternCross(stateCount))\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t// Yes\r\n\t\t\t\t\t\t\t\tvar confirmed = this.handlePossibleCenter(stateCount, i, j);\r\n\t\t\t\t\t\t\t\tif (confirmed)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t// Start examining every other line. Checking each line turned out to be too\r\n\t\t\t\t\t\t\t\t\t// expensive and didn't improve performance.\r\n\t\t\t\t\t\t\t\t\tiSkip = 2;\r\n\t\t\t\t\t\t\t\t\tif (this.hasSkipped)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdone = this.haveMultiplyConfirmedCenters();\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tvar rowSkip = this.findRowSkip();\r\n\t\t\t\t\t\t\t\t\t\tif (rowSkip > stateCount[2])\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t// Skip rows between row of lower confirmed center\r\n\t\t\t\t\t\t\t\t\t\t\t// and top of presumed third confirmed center\r\n\t\t\t\t\t\t\t\t\t\t\t// but back up a bit to get a full chance of detecting\r\n\t\t\t\t\t\t\t\t\t\t\t// it, entire width of center of finder pattern\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t// Skip by rowSkip, but back off by stateCount[2] (size of last center\r\n\t\t\t\t\t\t\t\t\t\t\t// of pattern we saw) to be conservative, and also back off by iSkip which\r\n\t\t\t\t\t\t\t\t\t\t\t// is about to be re-added\r\n\t\t\t\t\t\t\t\t\t\t\ti += rowSkip - stateCount[2] - iSkip;\r\n\t\t\t\t\t\t\t\t\t\t\tj = maxJ - 1;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t// Advance to next black pixel\r\n\t\t\t\t\t\t\t\t\tdo \r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tj++;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\twhile (j < maxJ && !image[j + i*qrcode.width]);\r\n\t\t\t\t\t\t\t\t\tj--; // back up to that last white pixel\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t// Clear state to start looking again\r\n\t\t\t\t\t\t\t\tcurrentState = 0;\r\n\t\t\t\t\t\t\t\tstateCount[0] = 0;\r\n\t\t\t\t\t\t\t\tstateCount[1] = 0;\r\n\t\t\t\t\t\t\t\tstateCount[2] = 0;\r\n\t\t\t\t\t\t\t\tstateCount[3] = 0;\r\n\t\t\t\t\t\t\t\tstateCount[4] = 0;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t// No, shift counts back by two\r\n\t\t\t\t\t\t\t\tstateCount[0] = stateCount[2];\r\n\t\t\t\t\t\t\t\tstateCount[1] = stateCount[3];\r\n\t\t\t\t\t\t\t\tstateCount[2] = stateCount[4];\r\n\t\t\t\t\t\t\t\tstateCount[3] = 1;\r\n\t\t\t\t\t\t\t\tstateCount[4] = 0;\r\n\t\t\t\t\t\t\t\tcurrentState = 3;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tstateCount[++currentState]++;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// Counting white pixels\r\n\t\t\t\t\t\tstateCount[currentState]++;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (this.foundPatternCross(stateCount))\r\n\t\t\t{\r\n\t\t\t\tvar confirmed = this.handlePossibleCenter(stateCount, i, maxJ);\r\n\t\t\t\tif (confirmed)\r\n\t\t\t\t{\r\n\t\t\t\t\tiSkip = stateCount[0];\r\n\t\t\t\t\tif (this.hasSkipped)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// Found a third one\r\n\t\t\t\t\t\tdone = this.haveMultiplyConfirmedCenters();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tvar patternInfo = this.selectBestPatterns();\r\n\t\torderBestPatterns(patternInfo);\r\n\t\t\r\n\t\treturn new FinderPatternInfo(patternInfo);\r\n\t};\r\n}\n\n\n// WEBPACK FOOTER //\n// ./src/findpat.js","/*\r\n Ported to JavaScript by Lazar Laszlo 2011 \r\n \r\n lazarsoft@gmail.com, www.lazarsoft.info\r\n \r\n*/\r\n\r\n/*\r\n*\r\n* Copyright 2007 ZXing authors\r\n*\r\n* Licensed under the Apache License, Version 2.0 (the \"License\");\r\n* you may not use this file except in compliance with the License.\r\n* You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing, software\r\n* distributed under the License is distributed on an \"AS IS\" BASIS,\r\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n* See the License for the specific language governing permissions and\r\n* limitations under the License.\r\n*/\r\nimport ReedSolomonDecoder from './rsdecoder';\r\nimport GF256 from './gf256';\r\nimport BitMatrixParser from './bmparser';\r\nimport DataBlock from './datablock';\r\nimport QRCodeDataBlockReader from './databr';\r\n\r\nvar Decoder={};\r\nDecoder.rsDecoder = new ReedSolomonDecoder(GF256.QR_CODE_FIELD);\r\n\r\nDecoder.correctErrors=function( codewordBytes, numDataCodewords)\r\n{\r\n\tvar numCodewords = codewordBytes.length;\r\n\t// First read into an array of ints\r\n\tvar codewordsInts = new Array(numCodewords);\r\n\tfor (var i = 0; i < numCodewords; i++)\r\n\t{\r\n\t\tcodewordsInts[i] = codewordBytes[i] & 0xFF;\r\n\t}\r\n\tvar numECCodewords = codewordBytes.length - numDataCodewords;\r\n\ttry\r\n\t{\r\n\t\tDecoder.rsDecoder.decode(codewordsInts, numECCodewords);\r\n\t\t//var corrector = new ReedSolomon(codewordsInts, numECCodewords);\r\n\t\t//corrector.correct();\r\n\t}\r\n\tcatch ( rse)\r\n\t{\r\n\t\tthrow rse;\r\n\t}\r\n\t// Copy back into array of bytes -- only need to worry about the bytes that were data\r\n\t// We don't care about errors in the error-correction codewords\r\n\tfor (var i = 0; i < numDataCodewords; i++)\r\n\t{\r\n\t\tcodewordBytes[i] = codewordsInts[i];\r\n\t}\r\n}\r\n\r\nDecoder.decode=function(bits)\r\n{\r\n\tvar parser = new BitMatrixParser(bits);\r\n\tvar version = parser.readVersion();\r\n\tvar ecLevel = parser.readFormatInformation().ErrorCorrectionLevel;\r\n\t\r\n\t// Read codewords\r\n\tvar codewords = parser.readCodewords();\r\n\r\n\t// Separate into data blocks\r\n\tvar dataBlocks = DataBlock.getDataBlocks(codewords, version, ecLevel);\r\n\t\r\n\t// Count total number of data bytes\r\n\tvar totalBytes = 0;\r\n\tfor (var i = 0; i < dataBlocks.length; i++)\r\n\t{\r\n\t\ttotalBytes += dataBlocks[i].NumDataCodewords;\r\n\t}\r\n\tvar resultBytes = new Array(totalBytes);\r\n\tvar resultOffset = 0;\r\n\t\r\n\t// Error-correct and copy data blocks together into a stream of bytes\r\n\tfor (var j = 0; j < dataBlocks.length; j++)\r\n\t{\r\n\t\tvar dataBlock = dataBlocks[j];\r\n\t\tvar codewordBytes = dataBlock.Codewords;\r\n\t\tvar numDataCodewords = dataBlock.NumDataCodewords;\r\n\t\tDecoder.correctErrors(codewordBytes, numDataCodewords);\r\n\t\tfor (var i = 0; i < numDataCodewords; i++)\r\n\t\t{\r\n\t\t\tresultBytes[resultOffset++] = codewordBytes[i];\r\n\t\t}\r\n\t}\r\n\t\r\n\t// Decode the contents of that stream of bytes\r\n\tvar reader = new QRCodeDataBlockReader(resultBytes, version.VersionNumber, ecLevel.Bits);\r\n\treturn reader;\r\n\t//return DecodedBitStreamParser.decode(resultBytes, version, ecLevel);\r\n}\r\n\r\nexport default Decoder;\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/decoder.js","/*\r\n Ported to JavaScript by Lazar Laszlo 2011 \r\n \r\n lazarsoft@gmail.com, www.lazarsoft.info\r\n \r\n*/\r\n\r\n/*\r\n*\r\n* Copyright 2007 ZXing authors\r\n*\r\n* Licensed under the Apache License, Version 2.0 (the \"License\");\r\n* you may not use this file except in compliance with the License.\r\n* You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing, software\r\n* distributed under the License is distributed on an \"AS IS\" BASIS,\r\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n* See the License for the specific language governing permissions and\r\n* limitations under the License.\r\n*/\r\nimport GF256 from './gf256';\r\nimport GF256Poly from './gf256poly';\r\n\r\nexport default function ReedSolomonDecoder(field)\r\n{\r\n\tthis.field = field;\r\n\tthis.decode=function(received, twoS)\r\n\t{\r\n\t\t\tvar poly = new GF256Poly(this.field, received);\r\n\t\t\tvar syndromeCoefficients = new Array(twoS);\r\n\t\t\tfor(var i=0;i= b's\r\n\t\t\tif (a.Degree < b.Degree)\r\n\t\t\t{\r\n\t\t\t\tvar temp = a;\r\n\t\t\t\ta = b;\r\n\t\t\t\tb = temp;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tvar rLast = a;\r\n\t\t\tvar r = b;\r\n\t\t\tvar sLast = this.field.One;\r\n\t\t\tvar s = this.field.Zero;\r\n\t\t\tvar tLast = this.field.Zero;\r\n\t\t\tvar t = this.field.One;\r\n\t\t\t\r\n\t\t\t// Run Euclidean algorithm until r's degree is less than R/2\r\n\t\t\twhile (r.Degree >= Math.floor(R / 2))\r\n\t\t\t{\r\n\t\t\t\tvar rLastLast = rLast;\r\n\t\t\t\tvar sLastLast = sLast;\r\n\t\t\t\tvar tLastLast = tLast;\r\n\t\t\t\trLast = r;\r\n\t\t\t\tsLast = s;\r\n\t\t\t\ttLast = t;\r\n\t\t\t\t\r\n\t\t\t\t// Divide rLastLast by rLast, with quotient in q and remainder in r\r\n\t\t\t\tif (rLast.Zero)\r\n\t\t\t\t{\r\n\t\t\t\t\t// Oops, Euclidean algorithm already terminated?\r\n\t\t\t\t\tthrow \"r_{i-1} was zero\";\r\n\t\t\t\t}\r\n\t\t\t\tr = rLastLast;\r\n\t\t\t\tvar q = this.field.Zero;\r\n\t\t\t\tvar denominatorLeadingTerm = rLast.getCoefficient(rLast.Degree);\r\n\t\t\t\tvar dltInverse = this.field.inverse(denominatorLeadingTerm);\r\n\t\t\t\twhile (r.Degree >= rLast.Degree && !r.Zero)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar degreeDiff = r.Degree - rLast.Degree;\r\n\t\t\t\t\tvar scale = this.field.multiply(r.getCoefficient(r.Degree), dltInverse);\r\n\t\t\t\t\tq = q.addOrSubtract(this.field.buildMonomial(degreeDiff, scale));\r\n\t\t\t\t\tr = r.addOrSubtract(rLast.multiplyByMonomial(degreeDiff, scale));\r\n\t\t\t\t\t//r.EXE();\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\ts = q.multiply1(sLast).addOrSubtract(sLastLast);\r\n\t\t\t\tt = q.multiply1(tLast).addOrSubtract(tLastLast);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tvar sigmaTildeAtZero = t.getCoefficient(0);\r\n\t\t\tif (sigmaTildeAtZero == 0)\r\n\t\t\t{\r\n\t\t\t\tthrow \"ReedSolomonException sigmaTilde(0) was zero\";\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tvar inverse = this.field.inverse(sigmaTildeAtZero);\r\n\t\t\tvar sigma = t.multiply2(inverse);\r\n\t\t\tvar omega = r.multiply2(inverse);\r\n\t\t\treturn new Array(sigma, omega);\r\n\t\t}\r\n\tthis.findErrorLocations=function( errorLocator)\r\n\t\t{\r\n\t\t\t// This is a direct application of Chien's search\r\n\t\t\tvar numErrors = errorLocator.Degree;\r\n\t\t\tif (numErrors == 1)\r\n\t\t\t{\r\n\t\t\t\t// shortcut\r\n\t\t\t\treturn new Array(errorLocator.getCoefficient(1));\r\n\t\t\t}\r\n\t\t\tvar result = new Array(numErrors);\r\n\t\t\tvar e = 0;\r\n\t\t\tfor (var i = 1; i < 256 && e < numErrors; i++)\r\n\t\t\t{\r\n\t\t\t\tif (errorLocator.evaluateAt(i) == 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tresult[e] = this.field.inverse(i);\r\n\t\t\t\t\te++;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (e != numErrors)\r\n\t\t\t{\r\n\t\t\t\tthrow \"Error locator degree does not match number of roots\";\r\n\t\t\t}\r\n\t\t\treturn result;\r\n\t\t}\r\n\tthis.findErrorMagnitudes=function( errorEvaluator, errorLocations, dataMatrix)\r\n\t\t{\r\n\t\t\t// This is directly applying Forney's Formula\r\n\t\t\tvar s = errorLocations.length;\r\n\t\t\tvar result = new Array(s);\r\n\t\t\tfor (var i = 0; i < s; i++)\r\n\t\t\t{\r\n\t\t\t\tvar xiInverse = this.field.inverse(errorLocations[i]);\r\n\t\t\t\tvar denominator = 1;\r\n\t\t\t\tfor (var j = 0; j < s; j++)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (i != j)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tdenominator = this.field.multiply(denominator, GF256.addOrSubtract(1, this.field.multiply(errorLocations[j], xiInverse)));\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tresult[i] = this.field.multiply(errorEvaluator.evaluateAt(xiInverse), this.field.inverse(denominator));\r\n\t\t\t\t// Thanks to sanfordsquires for this fix:\r\n\t\t\t\tif (dataMatrix)\r\n\t\t\t\t{\r\n\t\t\t\t\tresult[i] = this.field.multiply(result[i], xiInverse);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn result;\r\n\t\t}\r\n}\n\n\n// WEBPACK FOOTER //\n// ./src/rsdecoder.js","/*\r\n Ported to JavaScript by Lazar Laszlo 2011 \r\n \r\n lazarsoft@gmail.com, www.lazarsoft.info\r\n \r\n*/\r\n\r\n/*\r\n*\r\n* Copyright 2007 ZXing authors\r\n*\r\n* Licensed under the Apache License, Version 2.0 (the \"License\");\r\n* you may not use this file except in compliance with the License.\r\n* You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing, software\r\n* distributed under the License is distributed on an \"AS IS\" BASIS,\r\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n* See the License for the specific language governing permissions and\r\n* limitations under the License.\r\n*/\r\nimport FormatInformation from './formatinf'\r\nimport Version from './version'\r\nimport DataMask from './datamask'\r\n\r\nexport default function BitMatrixParser(bitMatrix)\r\n{\r\n\tvar dimension = bitMatrix.Dimension;\r\n\tif (dimension < 21 || (dimension & 0x03) != 1)\r\n\t{\r\n\t\tthrow \"Error BitMatrixParser\";\r\n\t}\r\n\tthis.bitMatrix = bitMatrix;\r\n\tthis.parsedVersion = null;\r\n\tthis.parsedFormatInfo = null;\r\n\t\r\n\tthis.copyBit=function( i, j, versionBits)\r\n\t{\r\n\t\treturn this.bitMatrix.get_Renamed(i, j)?(versionBits << 1) | 0x1:versionBits << 1;\r\n\t}\r\n\t\r\n\tthis.readFormatInformation=function()\r\n\t{\r\n\t\t\tif (this.parsedFormatInfo != null)\r\n\t\t\t{\r\n\t\t\t\treturn this.parsedFormatInfo;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t// Read top-left format info bits\r\n\t\t\tvar formatInfoBits = 0;\r\n\t\t\tfor (var i = 0; i < 6; i++)\r\n\t\t\t{\r\n\t\t\t\tformatInfoBits = this.copyBit(i, 8, formatInfoBits);\r\n\t\t\t}\r\n\t\t\t// .. and skip a bit in the timing pattern ...\r\n\t\t\tformatInfoBits = this.copyBit(7, 8, formatInfoBits);\r\n\t\t\tformatInfoBits = this.copyBit(8, 8, formatInfoBits);\r\n\t\t\tformatInfoBits = this.copyBit(8, 7, formatInfoBits);\r\n\t\t\t// .. and skip a bit in the timing pattern ...\r\n\t\t\tfor (var j = 5; j >= 0; j--)\r\n\t\t\t{\r\n\t\t\t\tformatInfoBits = this.copyBit(8, j, formatInfoBits);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tthis.parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits);\r\n\t\t\tif (this.parsedFormatInfo != null)\r\n\t\t\t{\r\n\t\t\t\treturn this.parsedFormatInfo;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t// Hmm, failed. Try the top-right/bottom-left pattern\r\n\t\t\tvar dimension = this.bitMatrix.Dimension;\r\n\t\t\tformatInfoBits = 0;\r\n\t\t\tvar iMin = dimension - 8;\r\n\t\t\tfor (var i = dimension - 1; i >= iMin; i--)\r\n\t\t\t{\r\n\t\t\t\tformatInfoBits = this.copyBit(i, 8, formatInfoBits);\r\n\t\t\t}\r\n\t\t\tfor (var j = dimension - 7; j < dimension; j++)\r\n\t\t\t{\r\n\t\t\t\tformatInfoBits = this.copyBit(8, j, formatInfoBits);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tthis.parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits);\r\n\t\t\tif (this.parsedFormatInfo != null)\r\n\t\t\t{\r\n\t\t\t\treturn this.parsedFormatInfo;\r\n\t\t\t}\r\n\t\t\tthrow \"Error readFormatInformation\";\t\r\n\t}\r\n\tthis.readVersion=function()\r\n\t\t{\r\n\t\t\t\r\n\t\t\tif (this.parsedVersion != null)\r\n\t\t\t{\r\n\t\t\t\treturn this.parsedVersion;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tvar dimension = this.bitMatrix.Dimension;\r\n\t\t\t\r\n\t\t\tvar provisionalVersion = (dimension - 17) >> 2;\r\n\t\t\tif (provisionalVersion <= 6)\r\n\t\t\t{\r\n\t\t\t\treturn Version.getVersionForNumber(provisionalVersion);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t// Read top-right version info: 3 wide by 6 tall\r\n\t\t\tvar versionBits = 0;\r\n\t\t\tvar ijMin = dimension - 11;\r\n\t\t\tfor (var j = 5; j >= 0; j--)\r\n\t\t\t{\r\n\t\t\t\tfor (var i = dimension - 9; i >= ijMin; i--)\r\n\t\t\t\t{\r\n\t\t\t\t\tversionBits = this.copyBit(i, j, versionBits);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tthis.parsedVersion = Version.decodeVersionInformation(versionBits);\r\n\t\t\tif (this.parsedVersion != null && this.parsedVersion.DimensionForVersion == dimension)\r\n\t\t\t{\r\n\t\t\t\treturn this.parsedVersion;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t// Hmm, failed. Try bottom left: 6 wide by 3 tall\r\n\t\t\tversionBits = 0;\r\n\t\t\tfor (var i = 5; i >= 0; i--)\r\n\t\t\t{\r\n\t\t\t\tfor (var j = dimension - 9; j >= ijMin; j--)\r\n\t\t\t\t{\r\n\t\t\t\t\tversionBits = this.copyBit(i, j, versionBits);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tthis.parsedVersion = Version.decodeVersionInformation(versionBits);\r\n\t\t\tif (this.parsedVersion != null && this.parsedVersion.DimensionForVersion == dimension)\r\n\t\t\t{\r\n\t\t\t\treturn this.parsedVersion;\r\n\t\t\t}\r\n\t\t\tthrow \"Error readVersion\";\r\n\t\t}\r\n\tthis.readCodewords=function()\r\n\t\t{\r\n\t\t\t\r\n\t\t\tvar formatInfo = this.readFormatInformation();\r\n\t\t\tvar version = this.readVersion();\r\n\t\t\t\r\n\t\t\t// Get the data mask for the format used in this QR Code. This will exclude\r\n\t\t\t// some bits from reading as we wind through the bit matrix.\r\n\t\t\tvar dataMask = DataMask.forReference( formatInfo.DataMask);\r\n\t\t\tvar dimension = this.bitMatrix.Dimension;\r\n\t\t\tdataMask.unmaskBitMatrix(this.bitMatrix, dimension);\r\n\t\t\t\r\n\t\t\tvar functionPattern = version.buildFunctionPattern();\r\n\t\t\t\r\n\t\t\tvar readingUp = true;\r\n\t\t\tvar result = new Array(version.TotalCodewords);\r\n\t\t\tvar resultOffset = 0;\r\n\t\t\tvar currentByte = 0;\r\n\t\t\tvar bitsRead = 0;\r\n\t\t\t// Read columns in pairs, from right to left\r\n\t\t\tfor (var j = dimension - 1; j > 0; j -= 2)\r\n\t\t\t{\r\n\t\t\t\tif (j == 6)\r\n\t\t\t\t{\r\n\t\t\t\t\t// Skip whole column with vertical alignment pattern;\r\n\t\t\t\t\t// saves time and makes the other code proceed more cleanly\r\n\t\t\t\t\tj--;\r\n\t\t\t\t}\r\n\t\t\t\t// Read alternatingly from bottom to top then top to bottom\r\n\t\t\t\tfor (var count = 0; count < dimension; count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar i = readingUp?dimension - 1 - count:count;\r\n\t\t\t\t\tfor (var col = 0; col < 2; col++)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// Ignore bits covered by the function pattern\r\n\t\t\t\t\t\tif (!functionPattern.get_Renamed(j - col, i))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t// Read a bit\r\n\t\t\t\t\t\t\tbitsRead++;\r\n\t\t\t\t\t\t\tcurrentByte <<= 1;\r\n\t\t\t\t\t\t\tif (this.bitMatrix.get_Renamed(j - col, i))\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tcurrentByte |= 1;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t// If we've made a whole byte, save it off\r\n\t\t\t\t\t\t\tif (bitsRead == 8)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tresult[resultOffset++] = currentByte;\r\n\t\t\t\t\t\t\t\tbitsRead = 0;\r\n\t\t\t\t\t\t\t\tcurrentByte = 0;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treadingUp ^= true; // readingUp = !readingUp; // switch directions\r\n\t\t\t}\r\n\t\t\tif (resultOffset != version.TotalCodewords)\r\n\t\t\t{\r\n\t\t\t\tthrow \"Error readCodewords\";\r\n\t\t\t}\r\n\t\t\treturn result;\r\n\t\t}\r\n}\n\n\n// WEBPACK FOOTER //\n// ./src/bmparser.js","/*\r\n Ported to JavaScript by Lazar Laszlo 2011 \r\n \r\n lazarsoft@gmail.com, www.lazarsoft.info\r\n \r\n*/\r\n\r\n/*\r\n*\r\n* Copyright 2007 ZXing authors\r\n*\r\n* Licensed under the Apache License, Version 2.0 (the \"License\");\r\n* you may not use this file except in compliance with the License.\r\n* You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing, software\r\n* distributed under the License is distributed on an \"AS IS\" BASIS,\r\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n* See the License for the specific language governing permissions and\r\n* limitations under the License.\r\n*/\r\nimport {URShift} from './qrcode'\r\n\r\nvar DataMask = {};\r\n\r\nDataMask.forReference = function(reference)\r\n{\r\n\tif (reference < 0 || reference > 7)\r\n\t{\r\n\t\tthrow \"System.ArgumentException\";\r\n\t}\r\n\treturn DataMask.DATA_MASKS[reference];\r\n}\r\n\r\nfunction DataMask000()\r\n{\r\n\tthis.unmaskBitMatrix=function(bits, dimension)\r\n\t{\r\n\t\tfor (var i = 0; i < dimension; i++)\r\n\t\t{\r\n\t\t\tfor (var j = 0; j < dimension; j++)\r\n\t\t\t{\r\n\t\t\t\tif (this.isMasked(i, j))\r\n\t\t\t\t{\r\n\t\t\t\t\tbits.flip(j, i);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tthis.isMasked=function( i, j)\r\n\t{\r\n\t\treturn ((i + j) & 0x01) == 0;\r\n\t}\r\n}\r\n\r\nfunction DataMask001()\r\n{\r\n\tthis.unmaskBitMatrix=function(bits, dimension)\r\n\t{\r\n\t\tfor (var i = 0; i < dimension; i++)\r\n\t\t{\r\n\t\t\tfor (var j = 0; j < dimension; j++)\r\n\t\t\t{\r\n\t\t\t\tif (this.isMasked(i, j))\r\n\t\t\t\t{\r\n\t\t\t\t\tbits.flip(j, i);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tthis.isMasked=function( i, j)\r\n\t{\r\n\t\treturn (i & 0x01) == 0;\r\n\t}\r\n}\r\n\r\nfunction DataMask010()\r\n{\r\n\tthis.unmaskBitMatrix=function(bits, dimension)\r\n\t{\r\n\t\tfor (var i = 0; i < dimension; i++)\r\n\t\t{\r\n\t\t\tfor (var j = 0; j < dimension; j++)\r\n\t\t\t{\r\n\t\t\t\tif (this.isMasked(i, j))\r\n\t\t\t\t{\r\n\t\t\t\t\tbits.flip(j, i);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tthis.isMasked=function( i, j)\r\n\t{\r\n\t\treturn j % 3 == 0;\r\n\t}\r\n}\r\n\r\nfunction DataMask011()\r\n{\r\n\tthis.unmaskBitMatrix=function(bits, dimension)\r\n\t{\r\n\t\tfor (var i = 0; i < dimension; i++)\r\n\t\t{\r\n\t\t\tfor (var j = 0; j < dimension; j++)\r\n\t\t\t{\r\n\t\t\t\tif (this.isMasked(i, j))\r\n\t\t\t\t{\r\n\t\t\t\t\tbits.flip(j, i);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tthis.isMasked=function( i, j)\r\n\t{\r\n\t\treturn (i + j) % 3 == 0;\r\n\t}\r\n}\r\n\r\nfunction DataMask100()\r\n{\r\n\tthis.unmaskBitMatrix=function(bits, dimension)\r\n\t{\r\n\t\tfor (var i = 0; i < dimension; i++)\r\n\t\t{\r\n\t\t\tfor (var j = 0; j < dimension; j++)\r\n\t\t\t{\r\n\t\t\t\tif (this.isMasked(i, j))\r\n\t\t\t\t{\r\n\t\t\t\t\tbits.flip(j, i);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tthis.isMasked=function( i, j)\r\n\t{\r\n\t\treturn (((URShift(i, 1)) + (j / 3)) & 0x01) == 0;\r\n\t}\r\n}\r\n\r\nfunction DataMask101()\r\n{\r\n\tthis.unmaskBitMatrix=function(bits, dimension)\r\n\t{\r\n\t\tfor (var i = 0; i < dimension; i++)\r\n\t\t{\r\n\t\t\tfor (var j = 0; j < dimension; j++)\r\n\t\t\t{\r\n\t\t\t\tif (this.isMasked(i, j))\r\n\t\t\t\t{\r\n\t\t\t\t\tbits.flip(j, i);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tthis.isMasked=function( i, j)\r\n\t{\r\n\t\tvar temp = i * j;\r\n\t\treturn (temp & 0x01) + (temp % 3) == 0;\r\n\t}\r\n}\r\n\r\nfunction DataMask110()\r\n{\r\n\tthis.unmaskBitMatrix=function(bits, dimension)\r\n\t{\r\n\t\tfor (var i = 0; i < dimension; i++)\r\n\t\t{\r\n\t\t\tfor (var j = 0; j < dimension; j++)\r\n\t\t\t{\r\n\t\t\t\tif (this.isMasked(i, j))\r\n\t\t\t\t{\r\n\t\t\t\t\tbits.flip(j, i);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tthis.isMasked=function( i, j)\r\n\t{\r\n\t\tvar temp = i * j;\r\n\t\treturn (((temp & 0x01) + (temp % 3)) & 0x01) == 0;\r\n\t}\r\n}\r\nfunction DataMask111()\r\n{\r\n\tthis.unmaskBitMatrix=function(bits, dimension)\r\n\t{\r\n\t\tfor (var i = 0; i < dimension; i++)\r\n\t\t{\r\n\t\t\tfor (var j = 0; j < dimension; j++)\r\n\t\t\t{\r\n\t\t\t\tif (this.isMasked(i, j))\r\n\t\t\t\t{\r\n\t\t\t\t\tbits.flip(j, i);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tthis.isMasked=function( i, j)\r\n\t{\r\n\t\treturn ((((i + j) & 0x01) + ((i * j) % 3)) & 0x01) == 0;\r\n\t}\r\n}\r\n\r\nDataMask.DATA_MASKS = new Array(new DataMask000(), new DataMask001(), new DataMask010(), new DataMask011(), new DataMask100(), new DataMask101(), new DataMask110(), new DataMask111());\r\n\r\nexport default DataMask;\n\n\n// WEBPACK FOOTER //\n// ./src/datamask.js","/*\r\n Ported to JavaScript by Lazar Laszlo 2011 \r\n \r\n lazarsoft@gmail.com, www.lazarsoft.info\r\n \r\n*/\r\n\r\n/*\r\n*\r\n* Copyright 2007 ZXing authors\r\n*\r\n* Licensed under the Apache License, Version 2.0 (the \"License\");\r\n* you may not use this file except in compliance with the License.\r\n* You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing, software\r\n* distributed under the License is distributed on an \"AS IS\" BASIS,\r\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n* See the License for the specific language governing permissions and\r\n* limitations under the License.\r\n*/\r\n\r\n\r\nexport default function DataBlock(numDataCodewords, codewords)\r\n{\r\n\tthis.numDataCodewords = numDataCodewords;\r\n\tthis.codewords = codewords;\r\n\t\r\n\tthis.__defineGetter__(\"NumDataCodewords\", function()\r\n\t{\r\n\t\treturn this.numDataCodewords;\r\n\t});\r\n\tthis.__defineGetter__(\"Codewords\", function()\r\n\t{\r\n\t\treturn this.codewords;\r\n\t});\r\n}\t\r\n\t\r\nDataBlock.getDataBlocks=function(rawCodewords, version, ecLevel)\r\n{\r\n\t\r\n\tif (rawCodewords.length != version.TotalCodewords)\r\n\t{\r\n\t\tthrow \"ArgumentException\";\r\n\t}\r\n\t\r\n\t// Figure out the number and size of data blocks used by this version and\r\n\t// error correction level\r\n\tvar ecBlocks = version.getECBlocksForLevel(ecLevel);\r\n\t\r\n\t// First count the total number of data blocks\r\n\tvar totalBlocks = 0;\r\n\tvar ecBlockArray = ecBlocks.getECBlocks();\r\n\tfor (var i = 0; i < ecBlockArray.length; i++)\r\n\t{\r\n\t\ttotalBlocks += ecBlockArray[i].Count;\r\n\t}\r\n\t\r\n\t// Now establish DataBlocks of the appropriate size and number of data codewords\r\n\tvar result = new Array(totalBlocks);\r\n\tvar numResultBlocks = 0;\r\n\tfor (var j = 0; j < ecBlockArray.length; j++)\r\n\t{\r\n\t\tvar ecBlock = ecBlockArray[j];\r\n\t\tfor (var i = 0; i < ecBlock.Count; i++)\r\n\t\t{\r\n\t\t\tvar numDataCodewords = ecBlock.DataCodewords;\r\n\t\t\tvar numBlockCodewords = ecBlocks.ECCodewordsPerBlock + numDataCodewords;\r\n\t\t\tresult[numResultBlocks++] = new DataBlock(numDataCodewords, new Array(numBlockCodewords));\r\n\t\t}\r\n\t}\r\n\t\r\n\t// All blocks have the same amount of data, except that the last n\r\n\t// (where n may be 0) have 1 more byte. Figure out where these start.\r\n\tvar shorterBlocksTotalCodewords = result[0].codewords.length;\r\n\tvar longerBlocksStartAt = result.length - 1;\r\n\twhile (longerBlocksStartAt >= 0)\r\n\t{\r\n\t\tvar numCodewords = result[longerBlocksStartAt].codewords.length;\r\n\t\tif (numCodewords == shorterBlocksTotalCodewords)\r\n\t\t{\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tlongerBlocksStartAt--;\r\n\t}\r\n\tlongerBlocksStartAt++;\r\n\t\r\n\tvar shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.ECCodewordsPerBlock;\r\n\t// The last elements of result may be 1 element longer;\r\n\t// first fill out as many elements as all of them have\r\n\tvar rawCodewordsOffset = 0;\r\n\tfor (var i = 0; i < shorterBlocksNumDataCodewords; i++)\r\n\t{\r\n\t\tfor (var j = 0; j < numResultBlocks; j++)\r\n\t\t{\r\n\t\t\tresult[j].codewords[i] = rawCodewords[rawCodewordsOffset++];\r\n\t\t}\r\n\t}\r\n\t// Fill out the last data block in the longer ones\r\n\tfor (var j = longerBlocksStartAt; j < numResultBlocks; j++)\r\n\t{\r\n\t\tresult[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++];\r\n\t}\r\n\t// Now add in error correction blocks\r\n\tvar max = result[0].codewords.length;\r\n\tfor (var i = shorterBlocksNumDataCodewords; i < max; i++)\r\n\t{\r\n\t\tfor (var j = 0; j < numResultBlocks; j++)\r\n\t\t{\r\n\t\t\tvar iOffset = j < longerBlocksStartAt?i:i + 1;\r\n\t\t\tresult[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++];\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/datablock.js","/*\r\n Ported to JavaScript by Lazar Laszlo 2011 \r\n \r\n lazarsoft@gmail.com, www.lazarsoft.info\r\n \r\n*/\r\n\r\n/*\r\n*\r\n* Copyright 2007 ZXing authors\r\n*\r\n* Licensed under the Apache License, Version 2.0 (the \"License\");\r\n* you may not use this file except in compliance with the License.\r\n* You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing, software\r\n* distributed under the License is distributed on an \"AS IS\" BASIS,\r\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n* See the License for the specific language governing permissions and\r\n* limitations under the License.\r\n*/\r\nimport qrcode from './qrcode'\r\n\r\nexport default function QRCodeDataBlockReader(blocks, version, numErrorCorrectionCode)\r\n{\r\n\tthis.blockPointer = 0;\r\n\tthis.bitPointer = 7;\r\n\tthis.dataLength = 0;\r\n\tthis.blocks = blocks;\r\n\tthis.numErrorCorrectionCode = numErrorCorrectionCode;\r\n\tif (version <= 9)\r\n\t\tthis.dataLengthMode = 0;\r\n\telse if (version >= 10 && version <= 26)\r\n\t\tthis.dataLengthMode = 1;\r\n\telse if (version >= 27 && version <= 40)\r\n\t\tthis.dataLengthMode = 2;\r\n\t\t\r\n\tthis.getNextBits = function( numBits)\r\n\t\t{\t\t\t\r\n\t\t\tvar bits = 0;\r\n\t\t\tif (numBits < this.bitPointer + 1)\r\n\t\t\t{\r\n\t\t\t\t// next word fits into current data block\r\n\t\t\t\tvar mask = 0;\r\n\t\t\t\tfor (var i = 0; i < numBits; i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tmask += (1 << i);\r\n\t\t\t\t}\r\n\t\t\t\tmask <<= (this.bitPointer - numBits + 1);\r\n\t\t\t\t\r\n\t\t\t\tbits = (this.blocks[this.blockPointer] & mask) >> (this.bitPointer - numBits + 1);\r\n\t\t\t\tthis.bitPointer -= numBits;\r\n\t\t\t\treturn bits;\r\n\t\t\t}\r\n\t\t\telse if (numBits < this.bitPointer + 1 + 8)\r\n\t\t\t{\r\n\t\t\t\t// next word crosses 2 data blocks\r\n\t\t\t\tvar mask1 = 0;\r\n\t\t\t\tfor (var i = 0; i < this.bitPointer + 1; i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tmask1 += (1 << i);\r\n\t\t\t\t}\r\n\t\t\t\tbits = (this.blocks[this.blockPointer] & mask1) << (numBits - (this.bitPointer + 1));\r\n this.blockPointer++;\r\n\t\t\t\tbits += ((this.blocks[this.blockPointer]) >> (8 - (numBits - (this.bitPointer + 1))));\r\n\t\t\t\t\r\n\t\t\t\tthis.bitPointer = this.bitPointer - numBits % 8;\r\n\t\t\t\tif (this.bitPointer < 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.bitPointer = 8 + this.bitPointer;\r\n\t\t\t\t}\r\n\t\t\t\treturn bits;\r\n\t\t\t}\r\n\t\t\telse if (numBits < this.bitPointer + 1 + 16)\r\n\t\t\t{\r\n\t\t\t\t// next word crosses 3 data blocks\r\n\t\t\t\tvar mask1 = 0; // mask of first block\r\n\t\t\t\tvar mask3 = 0; // mask of 3rd block\r\n\t\t\t\t//bitPointer + 1 : number of bits of the 1st block\r\n\t\t\t\t//8 : number of the 2nd block (note that use already 8bits because next word uses 3 data blocks)\r\n\t\t\t\t//numBits - (bitPointer + 1 + 8) : number of bits of the 3rd block \r\n\t\t\t\tfor (var i = 0; i < this.bitPointer + 1; i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tmask1 += (1 << i);\r\n\t\t\t\t}\r\n\t\t\t\tvar bitsFirstBlock = (this.blocks[this.blockPointer] & mask1) << (numBits - (this.bitPointer + 1));\r\n\t\t\t\tthis.blockPointer++;\r\n\t\t\t\t\r\n\t\t\t\tvar bitsSecondBlock = this.blocks[this.blockPointer] << (numBits - (this.bitPointer + 1 + 8));\r\n\t\t\t\tthis.blockPointer++;\r\n\t\t\t\t\r\n\t\t\t\tfor (var i = 0; i < numBits - (this.bitPointer + 1 + 8); i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tmask3 += (1 << i);\r\n\t\t\t\t}\r\n\t\t\t\tmask3 <<= 8 - (numBits - (this.bitPointer + 1 + 8));\r\n\t\t\t\tvar bitsThirdBlock = (this.blocks[this.blockPointer] & mask3) >> (8 - (numBits - (this.bitPointer + 1 + 8)));\r\n\t\t\t\t\r\n\t\t\t\tbits = bitsFirstBlock + bitsSecondBlock + bitsThirdBlock;\r\n\t\t\t\tthis.bitPointer = this.bitPointer - (numBits - 8) % 8;\r\n\t\t\t\tif (this.bitPointer < 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.bitPointer = 8 + this.bitPointer;\r\n\t\t\t\t}\r\n\t\t\t\treturn bits;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treturn 0;\r\n\t\t\t}\r\n\t\t}\r\n\tthis.NextMode=function()\r\n\t{\r\n\t\tif ((this.blockPointer > this.blocks.length - this.numErrorCorrectionCode - 2))\r\n\t\t\treturn 0;\r\n\t\telse\r\n\t\t\treturn this.getNextBits(4);\r\n\t}\r\n\tthis.getDataLength=function( modeIndicator)\r\n\t\t{\r\n\t\t\tvar index = 0;\r\n\t\t\twhile (true)\r\n\t\t\t{\r\n\t\t\t\tif ((modeIndicator >> index) == 1)\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tindex++;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\treturn this.getNextBits(qrcode.sizeOfDataLengthInfo[this.dataLengthMode][index]);\r\n\t\t}\r\n\tthis.getRomanAndFigureString=function( dataLength)\r\n\t\t{\r\n\t\t\tvar length = dataLength;\r\n\t\t\tvar intData = 0;\r\n\t\t\tvar strData = \"\";\r\n\t\t\tvar tableRomanAndFigure = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*', '+', '-', '.', '/', ':');\r\n\t\t\tdo \r\n\t\t\t{\r\n\t\t\t\tif (length > 1)\r\n\t\t\t\t{\r\n\t\t\t\t\tintData = this.getNextBits(11);\r\n\t\t\t\t\tvar firstLetter = Math.floor(intData / 45);\r\n\t\t\t\t\tvar secondLetter = intData % 45;\r\n\t\t\t\t\tstrData += tableRomanAndFigure[firstLetter];\r\n\t\t\t\t\tstrData += tableRomanAndFigure[secondLetter];\r\n\t\t\t\t\tlength -= 2;\r\n\t\t\t\t}\r\n\t\t\t\telse if (length == 1)\r\n\t\t\t\t{\r\n\t\t\t\t\tintData = this.getNextBits(6);\r\n\t\t\t\t\tstrData += tableRomanAndFigure[intData];\r\n\t\t\t\t\tlength -= 1;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\twhile (length > 0);\r\n\t\t\t\r\n\t\t\treturn strData;\r\n\t\t}\r\n\tthis.getFigureString=function( dataLength)\r\n\t\t{\r\n\t\t\tvar length = dataLength;\r\n\t\t\tvar intData = 0;\r\n\t\t\tvar strData = \"\";\r\n\t\t\tdo \r\n\t\t\t{\r\n\t\t\t\tif (length >= 3)\r\n\t\t\t\t{\r\n\t\t\t\t\tintData = this.getNextBits(10);\r\n\t\t\t\t\tif (intData < 100)\r\n\t\t\t\t\t\tstrData += \"0\";\r\n\t\t\t\t\tif (intData < 10)\r\n\t\t\t\t\t\tstrData += \"0\";\r\n\t\t\t\t\tlength -= 3;\r\n\t\t\t\t}\r\n\t\t\t\telse if (length == 2)\r\n\t\t\t\t{\r\n\t\t\t\t\tintData = this.getNextBits(7);\r\n\t\t\t\t\tif (intData < 10)\r\n\t\t\t\t\t\tstrData += \"0\";\r\n\t\t\t\t\tlength -= 2;\r\n\t\t\t\t}\r\n\t\t\t\telse if (length == 1)\r\n\t\t\t\t{\r\n\t\t\t\t\tintData = this.getNextBits(4);\r\n\t\t\t\t\tlength -= 1;\r\n\t\t\t\t}\r\n\t\t\t\tstrData += intData;\r\n\t\t\t}\r\n\t\t\twhile (length > 0);\r\n\t\t\t\r\n\t\t\treturn strData;\r\n\t\t}\r\n\tthis.get8bitByteArray=function( dataLength)\r\n\t\t{\r\n\t\t\tvar length = dataLength;\r\n\t\t\tvar intData = 0;\r\n\t\t\tvar output = new Array();\r\n\t\t\t\r\n\t\t\tdo \r\n\t\t\t{\r\n\t\t\t\tintData = this.getNextBits(8);\r\n\t\t\t\toutput.push( intData);\r\n\t\t\t\tlength--;\r\n\t\t\t}\r\n\t\t\twhile (length > 0);\r\n\t\t\treturn output;\r\n\t\t}\r\n this.getKanjiString=function( dataLength)\r\n\t\t{\r\n\t\t\tvar length = dataLength;\r\n\t\t\tvar intData = 0;\r\n\t\t\tvar unicodeString = \"\";\r\n\t\t\tdo \r\n\t\t\t{\r\n\t\t\t\tintData = this.getNextBits(13);\r\n\t\t\t\tvar lowerByte = intData % 0xC0;\r\n\t\t\t\tvar higherByte = intData / 0xC0;\r\n\t\t\t\t\r\n\t\t\t\tvar tempWord = (higherByte << 8) + lowerByte;\r\n\t\t\t\tvar shiftjisWord = 0;\r\n\t\t\t\tif (tempWord + 0x8140 <= 0x9FFC)\r\n\t\t\t\t{\r\n\t\t\t\t\t// between 8140 - 9FFC on Shift_JIS character set\r\n\t\t\t\t\tshiftjisWord = tempWord + 0x8140;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t// between E040 - EBBF on Shift_JIS character set\r\n\t\t\t\t\tshiftjisWord = tempWord + 0xC140;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\t//var tempByte = new Array(0,0);\r\n\t\t\t\t//tempByte[0] = (sbyte) (shiftjisWord >> 8);\r\n\t\t\t\t//tempByte[1] = (sbyte) (shiftjisWord & 0xFF);\r\n\t\t\t\t//unicodeString += new String(SystemUtils.ToCharArray(SystemUtils.ToByteArray(tempByte)));\r\n unicodeString += String.fromCharCode(shiftjisWord);\r\n\t\t\t\tlength--;\r\n\t\t\t}\r\n\t\t\twhile (length > 0);\r\n\t\t\t\r\n\t\t\t\r\n\t\t\treturn unicodeString;\r\n\t\t}\r\n\r\n\tthis.parseECIValue = function ()\r\n\t{\r\n\t\tvar intData = 0;\r\n\t\tvar firstByte = this.getNextBits(8);\r\n\t\tif ((firstByte & 0x80) == 0) {\r\n\t\t\tintData = firstByte & 0x7F;\r\n\t\t}\r\n\t\tif ((firstByte & 0xC0) == 0x80) {\r\n\t\t\t// two bytes\r\n\t\t\tvar secondByte = this.getNextBits(8);\r\n\t\t\tintData = ((firstByte & 0x3F) << 8) | secondByte;\r\n\t\t}\r\n\t\tif ((firstByte & 0xE0) == 0xC0) {\r\n\t\t\t// three bytes\r\n\t\t\tvar secondThirdBytes = this.getNextBits(8);;\r\n\t\t\tintData = ((firstByte & 0x1F) << 16) | secondThirdBytes;\r\n\t\t}\r\n\t\treturn intData;\r\n\t}\r\n\r\n\tthis.__defineGetter__(\"DataByte\", function()\r\n\t{\r\n\t\tvar output = new Array();\r\n\t\tvar MODE_NUMBER = 1;\r\n\t var MODE_ROMAN_AND_NUMBER = 2;\r\n\t var MODE_8BIT_BYTE = 4;\r\n\t\tvar MODE_ECI = 7;\r\n\t var MODE_KANJI = 8;\r\n\t\tdo \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar mode = this.NextMode();\r\n\t\t\t\t\t\t//canvas.println(\"mode: \" + mode);\r\n\t\t\t\t\t\tif (mode == 0)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (output.length > 0)\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\tthrow \"Empty data block\";\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (mode != MODE_NUMBER && mode != MODE_ROMAN_AND_NUMBER && mode != MODE_8BIT_BYTE && mode != MODE_KANJI && mode != MODE_ECI)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthrow \"Invalid mode: \" + mode + \" in (block:\" + this.blockPointer + \" bit:\" + this.bitPointer + \")\";\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tif(mode == MODE_ECI)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tvar temp_sbyteArray3 = this.parseECIValue();\r\n\t\t\t\t\t\t\t//output.push(temp_sbyteArray3);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\tvar dataLength = this.getDataLength(mode);\r\n\t\t\t\t\t\t\tif (dataLength < 1)\r\n\t\t\t\t\t\t\t\tthrow \"Invalid data length: \" + dataLength;\r\n\t\t\t\t\t\t\tswitch (mode)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tcase MODE_NUMBER: \r\n\t\t\t\t\t\t\t\t\tvar temp_str = this.getFigureString(dataLength);\r\n\t\t\t\t\t\t\t\t\tvar ta = new Array(temp_str.length);\r\n\t\t\t\t\t\t\t\t\tfor(var j=0;j=0?e>>t:(e>>t)+(2<<~t)}Object.defineProperty(t,"__esModule",{value:!0}),t.URShift=i;var a=n(7),o=r(a),s=n(12),h=r(s),u={};u.imagedata=null,u.width=0,u.height=0,u.qrCodeSymbol=null,u.debug=!1,u.maxImgSize=1048576,u.sizeOfDataLengthInfo=[[10,9,8,8],[12,11,16,10],[14,13,16,12]],u.callback=null,u.src=null,u.result=null,u.vidSuccess=function(e){u.localstream=e,u.video.src=window.URL.createObjectURL(e),u.gUM=!0,u.canvas_qr2=document.createElement("canvas"),u.canvas_qr2.id="qr-canvas",u.qrcontext2=u.canvas_qr2.getContext("2d"),u.canvas_qr2.width=u.video.videoWidth,u.canvas_qr2.height=u.video.videoHeight,setTimeout(u.captureToCanvas,500)},u.vidError=function(e){u.gUM=!1},u.captureToCanvas=function(){if(u.gUM)try{if(0==u.video.videoWidth)return void setTimeout(u.captureToCanvas,500);u.canvas_qr2.width=u.video.videoWidth,u.canvas_qr2.height=u.video.videoHeight,u.qrcontext2.drawImage(u.video,0,0);try{u.decode()}catch(e){console.log(e),setTimeout(u.captureToCanvas,500)}}catch(e){console.log(e),setTimeout(u.captureToCanvas,500)}},u.destroyWebcam=function(){u.localstream.getTracks()[0].stop()},u.setWebcam=function(e){var t=navigator;u.video=document.getElementById(e);var n=!0;if(navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices)try{navigator.mediaDevices.enumerateDevices().then(function(e){e.forEach(function(e){console.log("deb1"),"videoinput"===e.kind&&e.label.toLowerCase().search("back")>-1&&(n=[{sourceId:e.deviceId}]),console.log(e.kind+": "+e.label+" id = "+e.deviceId)})})}catch(e){console.log(e)}else console.log("no navigator.mediaDevices.enumerateDevices");t.mediaDevices.getUserMedia({video:n,audio:!1}).then(u.vidSuccess).catch(u.vidError)},u.decode=function(e){if(0==arguments.length){if(u.canvas_qr2)var t=u.canvas_qr2,n=u.qrcontext2;else var t=document.getElementById("qr-canvas"),n=t.getContext("2d");return u.width=t.width,u.height=t.height,u.imagedata=n.getImageData(0,0,u.width,u.height),u.result=u.process(n),null!=u.callback&&u.callback(u.result),u.result}var r=new Image;r.crossOrigin="Anonymous",r.onload=function(){var e=document.getElementById("out-canvas");if(null!=e){var t=e.getContext("2d");t.clearRect(0,0,320,240),t.drawImage(r,0,0,320,240)}var n=document.createElement("canvas"),i=n.getContext("2d"),a=r.height,o=r.width;if(r.width*r.height>u.maxImgSize){var s=r.width/r.height;a=Math.sqrt(u.maxImgSize/s),o=s*a}n.width=o,n.height=a,i.drawImage(r,0,0,n.width,n.height),u.width=n.width,u.height=n.height;try{u.imagedata=i.getImageData(0,0,n.width,n.height)}catch(e){return u.result="Cross domain image reading not supported in your browser! Save it to your computer then drag and drop the file!",void(null!=u.callback&&u.callback(u.result))}try{u.result=u.process(i)}catch(e){console.log(e),u.result="error decoding QR Code"}null!=u.callback&&u.callback(u.result)},r.onerror=function(){null!=u.callback&&u.callback("Failed to load the image")},r.src=e},u.isUrl=function(e){return/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/.test(e)},u.decode_url=function(e){var t="";try{t=escape(e)}catch(n){console.log(n),t=e}var n="";try{n=decodeURIComponent(t)}catch(e){console.log(e),n=t}return n},u.decode_utf8=function(e){return u.isUrl(e)?u.decode_url(e):e},u.process=function(e){var t=(new Date).getTime(),n=u.grayScaleToBitmap(u.grayscale());if(u.debug){for(var r=0;rr[s][o][1]&&(r[s][o][1]=l)}}for(var d=new Array(4),w=0;w<4;w++)d[w]=new Array(4);for(var o=0;o<4;o++)for(var s=0;s<4;s++)d[s][o]=Math.floor((r[s][o][0]+r[s][o][1])/2);return d},u.grayScaleToBitmap=function(e){for(var t=u.getMiddleBrightnessPerArea(e),n=t.length,r=Math.floor(u.width/n),i=Math.floor(u.height/n),a=new ArrayBuffer(u.width*u.height),o=new Uint8Array(a),s=0;s=256&&(t^=e);for(var n=0;n<255;n++)this.logTable[this.expTable[n]]=n;var r=new Array(1);r[0]=0,this.zero=new a.default(this,new Array(r));var i=new Array(1);i[0]=1,this.one=new a.default(this,new Array(i)),this.__defineGetter__("Zero",function(){return this.zero}),this.__defineGetter__("One",function(){return this.one}),this.buildMonomial=function(e,t){if(e<0)throw"System.ArgumentException";if(0==t)return this.zero;for(var n=new Array(e+1),r=0;r6&&(t.setRegion(e-11,0,3,6),t.setRegion(0,e-11,6,3)),t},this.getECBlocksForLevel=function(e){return this.ecBlocks[e.ordinal()]}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var s=n(3),h=r(s),u=n(4),f=r(u);o.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),o.VERSIONS=function(){return new Array(new o(1,new Array,new a(7,new i(1,19)),new a(10,new i(1,16)),new a(13,new i(1,13)),new a(17,new i(1,9))),new o(2,new Array(6,18),new a(10,new i(1,34)),new a(16,new i(1,28)),new a(22,new i(1,22)),new a(28,new i(1,16))),new o(3,new Array(6,22),new a(15,new i(1,55)),new a(26,new i(1,44)),new a(18,new i(2,17)),new a(22,new i(2,13))),new o(4,new Array(6,26),new a(20,new i(1,80)),new a(18,new i(2,32)),new a(26,new i(2,24)),new a(16,new i(4,9))),new o(5,new Array(6,30),new a(26,new i(1,108)),new a(24,new i(2,43)),new a(18,new i(2,15),new i(2,16)),new a(22,new i(2,11),new i(2,12))),new o(6,new Array(6,34),new a(18,new i(2,68)),new a(16,new i(4,27)),new a(24,new i(4,19)),new a(28,new i(4,15))),new o(7,new Array(6,22,38),new a(20,new i(2,78)),new a(18,new i(4,31)),new a(18,new i(2,14),new i(4,15)),new a(26,new i(4,13),new i(1,14))),new o(8,new Array(6,24,42),new a(24,new i(2,97)),new a(22,new i(2,38),new i(2,39)),new a(22,new i(4,18),new i(2,19)),new a(26,new i(4,14),new i(2,15))),new o(9,new Array(6,26,46),new a(30,new i(2,116)),new a(22,new i(3,36),new i(2,37)),new a(20,new i(4,16),new i(4,17)),new a(24,new i(4,12),new i(4,13))),new o(10,new Array(6,28,50),new a(18,new i(2,68),new i(2,69)),new a(26,new i(4,43),new i(1,44)),new a(24,new i(6,19),new i(2,20)),new a(28,new i(6,15),new i(2,16))),new o(11,new Array(6,30,54),new a(20,new i(4,81)),new a(30,new i(1,50),new i(4,51)),new a(28,new i(4,22),new i(4,23)),new a(24,new i(3,12),new i(8,13))),new o(12,new Array(6,32,58),new a(24,new i(2,92),new i(2,93)),new a(22,new i(6,36),new i(2,37)),new a(26,new i(4,20),new i(6,21)),new a(28,new i(7,14),new i(4,15))),new o(13,new Array(6,34,62),new a(26,new i(4,107)),new a(22,new i(8,37),new i(1,38)),new a(24,new i(8,20),new i(4,21)),new a(22,new i(12,11),new i(4,12))),new o(14,new Array(6,26,46,66),new a(30,new i(3,115),new i(1,116)),new a(24,new i(4,40),new i(5,41)),new a(20,new i(11,16),new i(5,17)),new a(24,new i(11,12),new i(5,13))),new o(15,new Array(6,26,48,70),new a(22,new i(5,87),new i(1,88)),new a(24,new i(5,41),new i(5,42)),new a(30,new i(5,24),new i(7,25)),new a(24,new i(11,12),new i(7,13))),new o(16,new Array(6,26,50,74),new a(24,new i(5,98),new i(1,99)),new a(28,new i(7,45),new i(3,46)),new a(24,new i(15,19),new i(2,20)),new a(30,new i(3,15),new i(13,16))),new o(17,new Array(6,30,54,78),new a(28,new i(1,107),new i(5,108)),new a(28,new i(10,46),new i(1,47)),new a(28,new i(1,22),new i(15,23)),new a(28,new i(2,14),new i(17,15))),new o(18,new Array(6,30,56,82),new a(30,new i(5,120),new i(1,121)),new a(26,new i(9,43),new i(4,44)),new a(28,new i(17,22),new i(1,23)),new a(28,new i(2,14),new i(19,15))),new o(19,new Array(6,30,58,86),new a(28,new i(3,113),new i(4,114)),new a(26,new i(3,44),new i(11,45)),new a(26,new i(17,21),new i(4,22)),new a(26,new i(9,13),new i(16,14))),new o(20,new Array(6,34,62,90),new a(28,new i(3,107),new i(5,108)),new a(26,new i(3,41),new i(13,42)),new a(30,new i(15,24),new i(5,25)),new a(28,new i(15,15),new i(10,16))),new o(21,new Array(6,28,50,72,94),new a(28,new i(4,116),new i(4,117)),new a(26,new i(17,42)),new a(28,new i(17,22),new i(6,23)),new a(30,new i(19,16),new i(6,17))),new o(22,new Array(6,26,50,74,98),new a(28,new i(2,111),new i(7,112)),new a(28,new i(17,46)),new a(30,new i(7,24),new i(16,25)),new a(24,new i(34,13))),new o(23,new Array(6,30,54,74,102),new a(30,new i(4,121),new i(5,122)),new a(28,new i(4,47),new i(14,48)),new a(30,new i(11,24),new i(14,25)),new a(30,new i(16,15),new i(14,16))),new o(24,new Array(6,28,54,80,106),new a(30,new i(6,117),new i(4,118)),new a(28,new i(6,45),new i(14,46)),new a(30,new i(11,24),new i(16,25)),new a(30,new i(30,16),new i(2,17))),new o(25,new Array(6,32,58,84,110),new a(26,new i(8,106),new i(4,107)),new a(28,new i(8,47),new i(13,48)),new a(30,new i(7,24),new i(22,25)),new a(30,new i(22,15),new i(13,16))),new o(26,new Array(6,30,58,86,114),new a(28,new i(10,114),new i(2,115)),new a(28,new i(19,46),new i(4,47)),new a(28,new i(28,22),new i(6,23)),new a(30,new i(33,16),new i(4,17))),new o(27,new Array(6,34,62,90,118),new a(30,new i(8,122),new i(4,123)),new a(28,new i(22,45),new i(3,46)),new a(30,new i(8,23),new i(26,24)),new a(30,new i(12,15),new i(28,16))),new o(28,new Array(6,26,50,74,98,122),new a(30,new i(3,117),new i(10,118)),new a(28,new i(3,45),new i(23,46)),new a(30,new i(4,24),new i(31,25)),new a(30,new i(11,15),new i(31,16))),new o(29,new Array(6,30,54,78,102,126),new a(30,new i(7,116),new i(7,117)),new a(28,new i(21,45),new i(7,46)),new a(30,new i(1,23),new i(37,24)),new a(30,new i(19,15),new i(26,16))),new o(30,new Array(6,26,52,78,104,130),new a(30,new i(5,115),new i(10,116)),new a(28,new i(19,47),new i(10,48)),new a(30,new i(15,24),new i(25,25)),new a(30,new i(23,15),new i(25,16))),new o(31,new Array(6,30,56,82,108,134),new a(30,new i(13,115),new i(3,116)),new a(28,new i(2,46),new i(29,47)),new a(30,new i(42,24),new i(1,25)),new a(30,new i(23,15),new i(28,16))),new o(32,new Array(6,34,60,86,112,138),new a(30,new i(17,115)),new a(28,new i(10,46),new i(23,47)),new a(30,new i(10,24),new i(35,25)),new a(30,new i(19,15),new i(35,16))),new o(33,new Array(6,30,58,86,114,142),new a(30,new i(17,115),new i(1,116)),new a(28,new i(14,46),new i(21,47)),new a(30,new i(29,24),new i(19,25)),new a(30,new i(11,15),new i(46,16))),new o(34,new Array(6,34,62,90,118,146),new a(30,new i(13,115),new i(6,116)),new a(28,new i(14,46),new i(23,47)),new a(30,new i(44,24),new i(7,25)),new a(30,new i(59,16),new i(1,17))),new o(35,new Array(6,30,54,78,102,126,150),new a(30,new i(12,121),new i(7,122)),new a(28,new i(12,47),new i(26,48)),new a(30,new i(39,24),new i(14,25)),new a(30,new i(22,15),new i(41,16))),new o(36,new Array(6,24,50,76,102,128,154),new a(30,new i(6,121),new i(14,122)),new a(28,new i(6,47),new i(34,48)),new a(30,new i(46,24),new i(10,25)),new a(30,new i(2,15),new i(64,16))),new o(37,new Array(6,28,54,80,106,132,158),new a(30,new i(17,122),new i(4,123)),new a(28,new i(29,46),new i(14,47)),new a(30,new i(49,24),new i(10,25)),new a(30,new i(24,15),new i(46,16))),new o(38,new Array(6,32,58,84,110,136,162),new a(30,new i(4,122),new i(18,123)),new a(28,new i(13,46),new i(32,47)),new a(30,new i(48,24),new i(14,25)),new a(30,new i(42,15),new i(32,16))),new o(39,new Array(6,26,54,82,110,138,166),new a(30,new i(20,117),new i(4,118)),new a(28,new i(40,47),new i(7,48)),new a(30,new i(43,24),new i(22,25)),new a(30,new i(10,15),new i(67,16))),new o(40,new Array(6,30,58,86,114,142,170),new a(30,new i(19,118),new i(6,119)),new a(28,new i(18,47),new i(31,48)),new a(30,new i(34,24),new i(34,25)),new a(30,new i(20,15),new i(61,16))))}(),o.getVersionForNumber=function(e){if(e<1||e>40)throw"ArgumentException";return o.VERSIONS[e-1]},o.getProvisionalVersionForDimension=function(e){if(e%4!=1)throw"Error getProvisionalVersionForDimension";try{return o.getVersionForNumber(e-17>>2)}catch(e){throw"Error getVersionForNumber"}},o.decodeVersionInformation=function(e){for(var t=4294967295,n=0,r=0;r>3&3),this.dataMask=7&e,this.__defineGetter__("ErrorCorrectionLevel",function(){return this.errorCorrectionLevel}),this.__defineGetter__("DataMask",function(){return this.dataMask}),this.GetHashCode=function(){return this.errorCorrectionLevel.ordinal()<<3|this.dataMask},this.Equals=function(e){var t=e;return this.errorCorrectionLevel==t.errorCorrectionLevel&&this.dataMask==t.dataMask}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var i=n(0),a=n(8),o=function(e){return e&&e.__esModule?e:{default:e}}(a),s=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)),h=new Array(0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4);r.numBitsDiffering=function(e,t){return e^=t,h[15&e]+h[15&(0,i.URShift)(e,4)]+h[15&(0,i.URShift)(e,8)]+h[15&(0,i.URShift)(e,12)]+h[15&(0,i.URShift)(e,16)]+h[15&(0,i.URShift)(e,20)]+h[15&(0,i.URShift)(e,24)]+h[15&(0,i.URShift)(e,28)]},r.decodeFormatInformation=function(e){var t=r.doDecodeFormatInformation(e);return null!=t?t:r.doDecodeFormatInformation(21522^e)},r.doDecodeFormatInformation=function(e){for(var t=4294967295,n=0,i=0;i>5;0!=(31&e)&&n++,this.rowSize=n,this.bits=new Array(n*t);for(var r=0;r>5);return 0!=(1&(0,i.URShift)(this.bits[n],31&e))},this.set_Renamed=function(e,t){var n=t*this.rowSize+(e>>5);this.bits[n]|=1<<(31&e)},this.flip=function(e,t){var n=t*this.rowSize+(e>>5);this.bits[n]^=1<<(31&e)},this.clear=function(){for(var e=this.bits.length,t=0;tthis.height||i>this.width)throw"The region must fit inside the matrix";for(var o=t;o>5)]|=1<<(31&h)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var i=n(0);e.exports=t.default},function(e,t,n){"use strict";function r(e,t){if(null==t||0==t.length)throw"System.ArgumentException";this.field=e;var n=t.length;if(n>1&&0==t[0]){for(var i=1;ii.length){var o=n;n=i,i=o}for(var s=new Array(i.length),h=i.length-n.length,u=0;u=e.Degree&&!n.Zero;){var a=n.Degree-e.Degree,o=this.field.multiply(n.getCoefficient(n.Degree),i),s=e.multiplyByMonomial(a,o),h=this.field.buildMonomial(a,o);t=t.addOrSubtract(h),n=n.addOrSubtract(s)}return new Array(t,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var i=n(1),a=function(e){return e&&e.__esModule?e:{default:e}}(i);e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=function(e){return e&&e.__esModule?e:{default:e}}(r);t.default=i.default,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t,n,r,a,o,s,h,u){this.a11=e,this.a12=r,this.a13=s,this.a21=t,this.a22=a,this.a23=h,this.a31=n,this.a32=o,this.a33=u,this.transformPoints1=function(e){for(var t=e.length,n=this.a11,r=this.a12,i=this.a13,a=this.a21,o=this.a22,s=this.a23,h=this.a31,u=this.a32,f=this.a33,l=0;lMath.abs(n-e);if(i){var a=e;e=t,t=a,a=n,n=r,r=a}for(var o=Math.abs(n-e),s=Math.abs(r-t),u=-o>>1,f=t0){if(c==r)break;c+=f,u-=o}}var _=n-e,y=r-t;return Math.sqrt(_*_+y*y)},this.sizeOfBlackWhiteBlackRunBothWays=function(e,t,n,r){var i=this.sizeOfBlackWhiteBlackRun(e,t,n,r),a=1,o=e-(n-e);o<0?(a=e/(e-o),o=0):o>=h.default.width&&(a=(h.default.width-1-e)/(o-e),o=h.default.width-1);var s=Math.floor(t-(r-t)*a);return a=1,s<0?(a=t/(t-s),s=0):s>=h.default.height&&(a=(h.default.height-1-t)/(s-t),s=h.default.height-1),o=Math.floor(e+(o-e)*a),(i+=this.sizeOfBlackWhiteBlackRun(e,t,o,s))-1},this.calculateModuleSizeOneWay=function(e,t){var n=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(e.X),Math.floor(e.Y),Math.floor(t.X),Math.floor(t.Y)),r=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(t.X),Math.floor(t.Y),Math.floor(e.X),Math.floor(e.Y));return isNaN(n)?r/7:isNaN(r)?n/7:(n+r)/14},this.calculateModuleSize=function(e,t,n){return(this.calculateModuleSizeOneWay(e,t)+this.calculateModuleSizeOneWay(e,n))/2},this.distance=function(e,t){var n=e.X-t.X,r=e.Y-t.Y;return Math.sqrt(n*n+r*r)},this.computeDimension=function(e,t,n,r){var i=Math.round(this.distance(e,t)/r),a=Math.round(this.distance(e,n)/r),o=7+(i+a>>1);switch(3&o){case 0:o++;break;case 2:o--;break;case 3:throw"Error"}return o},this.findAlignmentInRegion=function(e,t,n,r){var i=Math.floor(r*e),a=Math.max(0,t-i),o=Math.min(h.default.width-1,t+i);if(o-a<3*e)throw"Error";var s=Math.max(0,n-i),u=Math.min(h.default.height-1,n+i);return new l.AlignmentPatternFinder(this.image,a,s,o-a,u-s,e,this.resultPointCallback).find()},this.createTransform=function(e,t,n,r,a){var o,s,h,u,f=a-3.5;return null!=r?(o=r.X,s=r.Y,h=u=f-3):(o=t.X-e.X+n.X,s=t.Y-e.Y+n.Y,h=u=f),i.quadrilateralToQuadrilateral(3.5,3.5,f,3.5,h,u,3.5,f,e.X,e.Y,t.X,t.Y,o,s,n.X,n.Y)},this.sampleGrid=function(e,t,n){return w.default.sampleGrid3(e,n,t)},this.processFinderPatternInfo=function(e){var t=e.TopLeft,n=e.TopRight,r=e.BottomLeft,i=this.calculateModuleSize(t,n,r);if(i<1)throw"Error";var o=this.computeDimension(t,n,r,i),s=f.default.getProvisionalVersionForDimension(o),h=s.DimensionForVersion-7,u=null;if(s.AlignmentPatternCenters.length>0)for(var l=n.X-t.X+r.X,d=n.Y-t.Y+r.Y,w=1-3/h,c=Math.floor(t.X+w*(l-t.X)),v=Math.floor(t.Y+w*(d-t.Y)),g=4;g<=16;g<<=1){u=this.findAlignmentInRegion(i,c,v,g);break}var m,b=this.createTransform(t,n,r,u,o),_=this.sampleGrid(this.image,b,o);return m=null==u?new Array(r,t,n):new Array(r,t,n,u),new a(_,m)},this.detect=function(){var e=(new c.FinderPatternFinder).findFinderPattern(this.image);return this.processFinderPatternInfo(e)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var s=n(0),h=r(s),u=n(2),f=r(u),l=n(9),d=n(10),w=r(d),c=n(11);i.quadrilateralToQuadrilateral=function(e,t,n,r,i,a,o,s,h,u,f,l,d,w,c,v){var g=this.quadrilateralToSquare(e,t,n,r,i,a,o,s);return this.squareToQuadrilateral(h,u,f,l,d,w,c,v).times(g)},i.squareToQuadrilateral=function(e,t,n,r,a,o,s,h){var u=h-o,f=t-r+o-h;if(0==u&&0==f)return new i(n-e,a-n,e,r-t,o-r,t,0,0,1);var l=n-a,d=s-a,w=e-n+a-s,c=r-o,v=l*u-d*c,g=(w*u-d*f)/v,m=(l*f-w*c)/v;return new i(n-e+g*n,s-e+m*s,e,r-t+g*r,h-t+m*h,t,g,m,1)},i.quadrilateralToSquare=function(e,t,n,r,i,a,o,s){return this.squareToQuadrilateral(e,t,n,r,i,a,o,s).buildAdjoint()},e.exports=t.default},function(e,t,n){"use strict";function r(e,t,n){this.ordinal_Renamed_Field=e,this.bits=t,this.name=n,this.__defineGetter__("Bits",function(){return this.bits}),this.__defineGetter__("Name",function(){return this.name}),this.ordinal=function(){return this.ordinal_Renamed_Field}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r,r.forBits=function(e){if(e<0||e>=h.length)throw"ArgumentException";return h[e]};var i=new r(0,1,"L"),a=new r(1,0,"M"),o=new r(2,3,"Q"),s=new r(3,2,"H"),h=new Array(a,i,s,o);e.exports=t.default},function(e,t,n){"use strict";function r(e,t,n){this.x=e,this.y=t,this.count=1,this.estimatedModuleSize=n,this.__defineGetter__("EstimatedModuleSize",function(){return this.estimatedModuleSize}),this.__defineGetter__("Count",function(){return this.count}),this.__defineGetter__("X",function(){return Math.floor(this.x)}),this.__defineGetter__("Y",function(){return Math.floor(this.y)}),this.incrementCount=function(){this.count++},this.aboutEquals=function(e,t,n){if(Math.abs(t-this.y)<=e&&Math.abs(n-this.x)<=e){var r=Math.abs(e-this.estimatedModuleSize);return r<=1||r/this.estimatedModuleSize<=1}return!1}}function i(e,t,n,i,a,s,h){this.image=e,this.possibleCenters=new Array,this.startX=t,this.startY=n,this.width=i,this.height=a,this.moduleSize=s,this.crossCheckStateCount=new Array(0,0,0),this.resultPointCallback=h,this.centerFromEnd=function(e,t){return t-e[2]-e[1]/2},this.foundPatternCross=function(e){for(var t=this.moduleSize,n=t/2,r=0;r<3;r++)if(Math.abs(t-e[r])>=n)return!1;return!0},this.crossCheckVertical=function(e,t,n,r){var i=this.image,a=o.default.height,s=this.crossCheckStateCount;s[0]=0,s[1]=0,s[2]=0;for(var h=e;h>=0&&i[t+h*o.default.width]&&s[1]<=n;)s[1]++,h--;if(h<0||s[1]>n)return NaN;for(;h>=0&&!i[t+h*o.default.width]&&s[0]<=n;)s[0]++,h--;if(s[0]>n)return NaN;for(h=e+1;hn)return NaN;for(;hn)return NaN;var u=s[0]+s[1]+s[2];return 5*Math.abs(u-r)>=2*r?NaN:this.foundPatternCross(s)?this.centerFromEnd(s,h):NaN},this.handlePossibleCenter=function(e,t,n){var i=e[0]+e[1]+e[2],a=this.centerFromEnd(e,n),o=this.crossCheckVertical(t,Math.floor(a),2*e[1],i);if(!isNaN(o)){for(var s=(e[0]+e[1]+e[2])/3,h=this.possibleCenters.length,u=0;u>1),h=new Array(0,0,0),u=0;u>1:-(u+1>>1));h[0]=0,h[1]=0,h[2]=0;for(var l=t;ln||h<-1||h>r)throw"Error.checkAndNudgePoints ";i=!1,-1==o?(t[a]=0,i=!0):o==n&&(t[a]=n-1,i=!0),-1==h?(t[a+1]=0,i=!0):h==r&&(t[a+1]=r-1,i=!0)}i=!0;for(var a=t.length-2;a>=0&&i;a-=2){var o=Math.floor(t[a]),h=Math.floor(t[a+1]);if(o<-1||o>n||h<-1||h>r)throw"Error.checkAndNudgePoints ";i=!1,-1==o?(t[a]=0,i=!0):o==n&&(t[a]=n-1,i=!0),-1==h?(t[a+1]=0,i=!0):h==r&&(t[a+1]=r-1,i=!0)}},h.sampleGrid3=function(e,t,n){for(var r=new a.default(t),i=new Array(t<<1),o=0;o>1),i[l+1]=f;n.transformPoints1(i),h.checkAndNudgePoints(e,i);try{for(var l=0;l>1,o)}}catch(e){throw"Error.checkAndNudgePoints"}}return r},h.sampleGridx=function(e,t,n,r,i,a,o,s,u,f,l,d,w,c,v,g,m,b){var _=PerspectiveTransform.quadrilateralToQuadrilateral(n,r,i,a,o,s,u,f,l,d,w,c,v,g,m,b);return h.sampleGrid3(e,t,_)},t.default=h,e.exports=t.default},function(e,t,n){"use strict";function r(e){function t(e,t){var n=e.X-t.X,r=e.Y-t.Y;return Math.sqrt(n*n+r*r)}var n,r,i,a=t(e[0],e[1]),o=t(e[1],e[2]),s=t(e[0],e[2]);if(o>=a&&o>=s?(r=e[0],n=e[1],i=e[2]):s>=o&&s>=a?(r=e[1],n=e[0],i=e[2]):(r=e[2],n=e[0],i=e[1]),function(e,t,n){var r=t.x,i=t.y;return(n.x-r)*(e.y-i)-(n.y-i)*(e.x-r)}(n,r,i)<0){var h=n;n=i,i=h}e[0]=n,e[1]=r,e[2]=i}function i(e,t,n){this.x=e,this.y=t,this.count=1,this.estimatedModuleSize=n,this.__defineGetter__("EstimatedModuleSize",function(){return this.estimatedModuleSize}),this.__defineGetter__("Count",function(){return this.count}),this.__defineGetter__("X",function(){return this.x}),this.__defineGetter__("Y",function(){return this.y}),this.incrementCount=function(){this.count++},this.aboutEquals=function(e,t,n){if(Math.abs(t-this.y)<=e&&Math.abs(n-this.x)<=e){var r=Math.abs(e-this.estimatedModuleSize);return r<=1||r/this.estimatedModuleSize<=1}return!1}}function a(e){this.bottomLeft=e[0],this.topLeft=e[1],this.topRight=e[2],this.__defineGetter__("BottomLeft",function(){return this.bottomLeft}),this.__defineGetter__("TopLeft",function(){return this.topLeft}),this.__defineGetter__("TopRight",function(){return this.topRight})}function o(){this.image=null,this.possibleCenters=[],this.hasSkipped=!1,this.crossCheckStateCount=new Array(0,0,0,0,0),this.resultPointCallback=null,this.__defineGetter__("CrossCheckStateCount",function(){return this.crossCheckStateCount[0]=0,this.crossCheckStateCount[1]=0,this.crossCheckStateCount[2]=0,this.crossCheckStateCount[3]=0,this.crossCheckStateCount[4]=0,this.crossCheckStateCount}),this.foundPatternCross=function(e){for(var t=0,n=0;n<5;n++){var r=e[n];if(0==r)return!1;t+=r}if(t<7)return!1;var i=Math.floor((t<=0&&i[t+s*h.default.width];)o[2]++,s--;if(s<0)return NaN;for(;s>=0&&!i[t+s*h.default.width]&&o[1]<=n;)o[1]++,s--;if(s<0||o[1]>n)return NaN;for(;s>=0&&i[t+s*h.default.width]&&o[0]<=n;)o[0]++,s--;if(o[0]>n)return NaN;for(s=e+1;s=n)return NaN;for(;s=n)return NaN;var u=o[0]+o[1]+o[2]+o[3]+o[4];return 5*Math.abs(u-r)>=2*r?NaN:this.foundPatternCross(o)?this.centerFromEnd(o,s):NaN},this.crossCheckHorizontal=function(e,t,n,r){for(var i=this.image,a=h.default.width,o=this.CrossCheckStateCount,s=e;s>=0&&i[s+t*h.default.width];)o[2]++,s--;if(s<0)return NaN;for(;s>=0&&!i[s+t*h.default.width]&&o[1]<=n;)o[1]++,s--;if(s<0||o[1]>n)return NaN;for(;s>=0&&i[s+t*h.default.width]&&o[0]<=n;)o[0]++,s--;if(o[0]>n)return NaN;for(s=e+1;s=n)return NaN;for(;s=n)return NaN;var u=o[0]+o[1]+o[2]+o[3]+o[4];return 5*Math.abs(u-r)>=r?NaN:this.foundPatternCross(o)?this.centerFromEnd(o,s):NaN},this.handlePossibleCenter=function(e,t,n){var r=e[0]+e[1]+e[2]+e[3]+e[4],a=this.centerFromEnd(e,n),o=this.crossCheckVertical(t,Math.floor(a),e[2],r);if(!isNaN(o)&&(a=this.crossCheckHorizontal(Math.floor(a),Math.floor(o),e[2],r),!isNaN(a))){for(var s=r/7,h=!1,u=this.possibleCenters.length,f=0;f3){for(var t=0,n=0,r=0;r=0;r--){var h=this.possibleCenters[r];Math.abs(h.EstimatedModuleSize-a)>s&&this.possibleCenters.splice(r,1)}}return this.possibleCenters.length>3&&this.possibleCenters.sort(function(e,t){return e.count>t.count?-1:e.count=d){if(null!=t)return this.hasSkipped=!0,Math.floor((Math.abs(t.X-r.X)-Math.abs(t.Y-r.Y))/2);t=r}}return 0},this.haveMultiplyConfirmedCenters=function(){for(var e=0,t=0,n=this.possibleCenters.length,r=0;r=d&&(e++,t+=i.EstimatedModuleSize)}if(e<3)return!1;for(var a=t/n,o=0,r=0;rs[2]&&(l+=v-s[2]-i,w=n-1)}else{do{w++}while(w=Math.floor(n/2);){var f=i,l=o,d=h;if(i=a,o=s,h=u,i.Zero)throw"r_{i-1} was zero";a=f;for(var w=this.field.Zero,c=i.getCoefficient(i.Degree),v=this.field.inverse(c);a.Degree>=i.Degree&&!a.Zero;){var g=a.Degree-i.Degree,m=this.field.multiply(a.getCoefficient(a.Degree),v);w=w.addOrSubtract(this.field.buildMonomial(g,m)),a=a.addOrSubtract(i.multiplyByMonomial(g,m))}s=w.multiply1(o).addOrSubtract(l),u=w.multiply1(h).addOrSubtract(d)}var b=u.getCoefficient(0);if(0==b)throw"ReedSolomonException sigmaTilde(0) was zero";var _=this.field.inverse(b),y=u.multiply2(_),p=a.multiply2(_);return new Array(y,p)},this.findErrorLocations=function(e){var t=e.Degree;if(1==t)return new Array(e.getCoefficient(1));for(var n=new Array(t),r=0,i=1;i<256&&r=0;n--)e=this.copyBit(8,n,e);if(this.parsedFormatInfo=o.default.decodeFormatInformation(e),null!=this.parsedFormatInfo)return this.parsedFormatInfo;var r=this.bitMatrix.Dimension;e=0;for(var i=r-8,t=r-1;t>=i;t--)e=this.copyBit(t,8,e);for(var n=r-7;n>2;if(t<=6)return h.default.getVersionForNumber(t);for(var n=0,r=e-11,i=5;i>=0;i--)for(var a=e-9;a>=r;a--)n=this.copyBit(a,i,n);if(this.parsedVersion=h.default.decodeVersionInformation(n),null!=this.parsedVersion&&this.parsedVersion.DimensionForVersion==e)return this.parsedVersion;n=0;for(var a=5;a>=0;a--)for(var i=e-9;i>=r;i--)n=this.copyBit(a,i,n);if(this.parsedVersion=h.default.decodeVersionInformation(n),null!=this.parsedVersion&&this.parsedVersion.DimensionForVersion==e)return this.parsedVersion;throw"Error readVersion"},this.readCodewords=function(){var e=this.readFormatInformation(),t=this.readVersion(),n=f.default.forReference(e.DataMask),r=this.bitMatrix.Dimension;n.unmaskBitMatrix(this.bitMatrix,r);for(var i=t.buildFunctionPattern(),a=!0,o=new Array(t.TotalCodewords),s=0,h=0,u=0,l=r-1;l>0;l-=2){6==l&&l--;for(var d=0;d7)throw"System.ArgumentException";return d.DATA_MASKS[e]},d.DATA_MASKS=new Array(new r,new i,new a,new o,new s,new h,new u,new f),t.default=d,e.exports=t.default},function(e,t,n){"use strict";function r(e,t){this.numDataCodewords=e,this.codewords=t,this.__defineGetter__("NumDataCodewords",function(){return this.numDataCodewords}),this.__defineGetter__("Codewords",function(){return this.codewords})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r,r.getDataBlocks=function(e,t,n){if(e.length!=t.TotalCodewords)throw"ArgumentException";for(var i=t.getECBlocksForLevel(n),a=0,o=i.getECBlocks(),s=0;s=0;){if(h[v].codewords.length==c)break;v--}v++;for(var g=c-i.ECCodewordsPerBlock,m=0,s=0;s=10&&t<=26?this.dataLengthMode=1:t>=27&&t<=40&&(this.dataLengthMode=2),this.getNextBits=function(e){var t=0;if(e>this.bitPointer-e+1,this.bitPointer-=e,t}if(e>8-(e-(this.bitPointer+1)),this.bitPointer=this.bitPointer-e%8,this.bitPointer<0&&(this.bitPointer=8+this.bitPointer),t}if(e>8-(e-(this.bitPointer+1+8))),this.bitPointer=this.bitPointer-(e-8)%8,this.bitPointer<0&&(this.bitPointer=8+this.bitPointer),t}return 0},this.NextMode=function(){return this.blockPointer>this.blocks.length-this.numErrorCorrectionCode-2?0:this.getNextBits(4)},this.getDataLength=function(e){for(var t=0;;){if(e>>t==1)break;t++}return this.getNextBits(a.default.sizeOfDataLengthInfo[this.dataLengthMode][t])},this.getRomanAndFigureString=function(e){var t=e,n=0,r="",i=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":");do{if(t>1){n=this.getNextBits(11);var a=Math.floor(n/45),o=n%45;r+=i[a],r+=i[o],t-=2}else 1==t&&(n=this.getNextBits(6),r+=i[n],t-=1)}while(t>0);return r},this.getFigureString=function(e){var t=e,n=0,r="";do{t>=3?(n=this.getNextBits(10),n<100&&(r+="0"),n<10&&(r+="0"),t-=3):2==t?(n=this.getNextBits(7),n<10&&(r+="0"),t-=2):1==t&&(n=this.getNextBits(4),t-=1),r+=n}while(t>0);return r},this.get8bitByteArray=function(e){var t=e,n=0,r=new Array;do{n=this.getNextBits(8),r.push(n),t--}while(t>0);return r},this.getKanjiString=function(e){var t=e,n=0,r="";do{n=this.getNextBits(13);var i=n%192,a=n/192,o=(a<<8)+i,s=0;s=o+33088<=40956?o+33088:o+49472,r+=String.fromCharCode(s),t--}while(t>0);return r},this.parseECIValue=function(){var e=0,t=this.getNextBits(8);if(0==(128&t)&&(e=127&t),128==(192&t)){e=(63&t)<<8|this.getNextBits(8)}if(192==(224&t)){e=(31&t)<<16|this.getNextBits(8)}return e},this.__defineGetter__("DataByte",function(){for(var e=new Array;;){var t=this.NextMode();if(0==t){if(e.length>0)break;throw"Empty data block"}if(1!=t&&2!=t&&4!=t&&8!=t&&7!=t)throw"Invalid mode: "+t+" in (block:"+this.blockPointer+" bit:"+this.bitPointer+")";if(7==t)var n=this.parseECIValue();else{var r=this.getDataLength(t);if(r<1)throw"Invalid data length: "+r;switch(t){case 1:for(var i=this.getFigureString(r),a=new Array(i.length),o=0;o",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/Alucrad/jsqrcode/issues"
+ },
+ "homepage": "https://github.com/Alucrad/jsqrcode/"
+}
diff --git a/src/alignpat.js b/src/alignpat.js
index 967473f3..6790575a 100644
--- a/src/alignpat.js
+++ b/src/alignpat.js
@@ -21,9 +21,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import qrcode from './qrcode';
-
-function AlignmentPattern(posX, posY, estimatedModuleSize)
+export default function AlignmentPattern(posX, posY, estimatedModuleSize)
{
this.x=posX;
this.y=posY;
@@ -62,7 +62,7 @@ function AlignmentPattern(posX, posY, estimatedModuleSize)
}
-function AlignmentPatternFinder( image, startX, startY, width, height, moduleSize, resultPointCallback)
+export function AlignmentPatternFinder( image, startX, startY, width, height, moduleSize, resultPointCallback)
{
this.image = image;
this.possibleCenters = new Array();
diff --git a/src/bitmat.js b/src/bitmat.js
index 5b007842..273484ec 100644
--- a/src/bitmat.js
+++ b/src/bitmat.js
@@ -22,8 +22,9 @@
* limitations under the License.
*/
+import {URShift} from './qrcode'
-function BitMatrix( width, height)
+export default function BitMatrix( width, height)
{
if(!height)
height=width;
diff --git a/src/bmparser.js b/src/bmparser.js
index 51c6e85d..e9191efa 100644
--- a/src/bmparser.js
+++ b/src/bmparser.js
@@ -21,9 +21,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import FormatInformation from './formatinf'
+import Version from './version'
+import DataMask from './datamask'
-
-function BitMatrixParser(bitMatrix)
+export default function BitMatrixParser(bitMatrix)
{
var dimension = bitMatrix.Dimension;
if (dimension < 21 || (dimension & 0x03) != 1)
diff --git a/src/datablock.js b/src/datablock.js
index 3cb277a8..7080994f 100644
--- a/src/datablock.js
+++ b/src/datablock.js
@@ -23,7 +23,7 @@
*/
-function DataBlock(numDataCodewords, codewords)
+export default function DataBlock(numDataCodewords, codewords)
{
this.numDataCodewords = numDataCodewords;
this.codewords = codewords;
diff --git a/src/databr.js b/src/databr.js
index f40257f2..9a01621e 100644
--- a/src/databr.js
+++ b/src/databr.js
@@ -21,9 +21,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import qrcode from './qrcode'
-
-function QRCodeDataBlockReader(blocks, version, numErrorCorrectionCode)
+export default function QRCodeDataBlockReader(blocks, version, numErrorCorrectionCode)
{
this.blockPointer = 0;
this.bitPointer = 7;
diff --git a/src/datamask.js b/src/datamask.js
index 2f99523a..76f75eba 100644
--- a/src/datamask.js
+++ b/src/datamask.js
@@ -21,7 +21,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+import {URShift} from './qrcode'
var DataMask = {};
@@ -205,3 +205,4 @@ function DataMask111()
DataMask.DATA_MASKS = new Array(new DataMask000(), new DataMask001(), new DataMask010(), new DataMask011(), new DataMask100(), new DataMask101(), new DataMask110(), new DataMask111());
+export default DataMask;
\ No newline at end of file
diff --git a/src/decoder.js b/src/decoder.js
index d0c1ed57..8dec8350 100644
--- a/src/decoder.js
+++ b/src/decoder.js
@@ -21,7 +21,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+import ReedSolomonDecoder from './rsdecoder';
+import GF256 from './gf256';
+import BitMatrixParser from './bmparser';
+import DataBlock from './datablock';
+import QRCodeDataBlockReader from './databr';
var Decoder={};
Decoder.rsDecoder = new ReedSolomonDecoder(GF256.QR_CODE_FIELD);
@@ -93,3 +97,5 @@ Decoder.decode=function(bits)
return reader;
//return DecodedBitStreamParser.decode(resultBytes, version, ecLevel);
}
+
+export default Decoder;
diff --git a/src/detector.js b/src/detector.js
index 06c214a3..603c90d5 100644
--- a/src/detector.js
+++ b/src/detector.js
@@ -21,7 +21,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+import qrcode from './qrcode'
+import Version from './version';
+import {AlignmentPatternFinder} from './alignpat';
+import GridSampler from './grid';
+import {FinderPatternFinder} from './findpat';
function PerspectiveTransform( a11, a21, a31, a12, a22, a32, a13, a23, a33)
{
@@ -122,7 +126,7 @@ function DetectorResult(bits, points)
}
-function Detector(image)
+export default function Detector(image)
{
this.image=image;
this.resultPointCallback = null;
diff --git a/src/errorlevel.js b/src/errorlevel.js
index 5ce2a276..9940c44d 100644
--- a/src/errorlevel.js
+++ b/src/errorlevel.js
@@ -23,7 +23,7 @@
*/
-function ErrorCorrectionLevel(ordinal, bits, name)
+export default function ErrorCorrectionLevel(ordinal, bits, name)
{
this.ordinal_Renamed_Field = ordinal;
this.bits = bits;
diff --git a/src/findpat.js b/src/findpat.js
index 7f6ba898..7071d44c 100644
--- a/src/findpat.js
+++ b/src/findpat.js
@@ -21,14 +21,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+import qrcode from './qrcode'
var MIN_SKIP = 3;
var MAX_MODULES = 57;
var INTEGER_MATH_SHIFT = 8;
var CENTER_QUORUM = 2;
-qrcode.orderBestPatterns=function(patterns)
+function orderBestPatterns(patterns)
{
function distance( pattern1, pattern2)
@@ -148,7 +148,7 @@ function FinderPatternInfo(patternCenters)
});
}
-function FinderPatternFinder()
+export function FinderPatternFinder()
{
this.image=null;
this.possibleCenters = [];
@@ -644,7 +644,7 @@ function FinderPatternFinder()
}
var patternInfo = this.selectBestPatterns();
- qrcode.orderBestPatterns(patternInfo);
+ orderBestPatterns(patternInfo);
return new FinderPatternInfo(patternInfo);
};
diff --git a/src/formatinf.js b/src/formatinf.js
index 62266a4c..c027de2c 100644
--- a/src/formatinf.js
+++ b/src/formatinf.js
@@ -21,14 +21,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+import {URShift} from './qrcode';
+import ErrorCorrectionLevel from './errorlevel';
var FORMAT_INFO_MASK_QR = 0x5412;
var FORMAT_INFO_DECODE_LOOKUP = new Array(new Array(0x5412, 0x00), new Array(0x5125, 0x01), new Array(0x5E7C, 0x02), new Array(0x5B4B, 0x03), new Array(0x45F9, 0x04), new Array(0x40CE, 0x05), new Array(0x4F97, 0x06), new Array(0x4AA0, 0x07), new Array(0x77C4, 0x08), new Array(0x72F3, 0x09), new Array(0x7DAA, 0x0A), new Array(0x789D, 0x0B), new Array(0x662F, 0x0C), new Array(0x6318, 0x0D), new Array(0x6C41, 0x0E), new Array(0x6976, 0x0F), new Array(0x1689, 0x10), new Array(0x13BE, 0x11), new Array(0x1CE7, 0x12), new Array(0x19D0, 0x13), new Array(0x0762, 0x14), new Array(0x0255, 0x15), new Array(0x0D0C, 0x16), new Array(0x083B, 0x17), new Array(0x355F, 0x18), new Array(0x3068, 0x19), new Array(0x3F31, 0x1A), new Array(0x3A06, 0x1B), new Array(0x24B4, 0x1C), new Array(0x2183, 0x1D), new Array(0x2EDA, 0x1E), new Array(0x2BED, 0x1F));
var 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)
+export default function FormatInformation(formatInfo)
{
this.errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03);
this.dataMask = (formatInfo & 0x07);
diff --git a/src/gf256.js b/src/gf256.js
index 8eb6b617..91db48b9 100644
--- a/src/gf256.js
+++ b/src/gf256.js
@@ -6,112 +6,96 @@
*/
/*
-*
-* Copyright 2007 ZXing authors
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
+ *
+ * Copyright 2007 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import GF256Poly from './gf256poly';
-function GF256( primitive)
-{
+export default function GF256(primitive) {
this.expTable = new Array(256);
this.logTable = new Array(256);
var x = 1;
- for (var i = 0; i < 256; i++)
- {
+ for (var i = 0; i < 256; i++) {
this.expTable[i] = x;
x <<= 1; // x = x * 2; we're assuming the generator alpha is 2
- if (x >= 0x100)
- {
+ if (x >= 0x100) {
x ^= primitive;
}
}
- for (var i = 0; i < 255; i++)
- {
+ for (var i = 0; i < 255; i++) {
this.logTable[this.expTable[i]] = i;
}
// logTable[0] == 0 but this should never be used
- var at0=new Array(1);at0[0]=0;
+ var at0 = new Array(1);
+ at0[0] = 0;
this.zero = new GF256Poly(this, new Array(at0));
- var at1=new Array(1);at1[0]=1;
+ var at1 = new Array(1);
+ at1[0] = 1;
this.one = new GF256Poly(this, new Array(at1));
-
- this.__defineGetter__("Zero", function()
- {
+
+ this.__defineGetter__("Zero", function () {
return this.zero;
});
- this.__defineGetter__("One", function()
- {
+ this.__defineGetter__("One", function () {
return this.one;
});
- this.buildMonomial=function( degree, coefficient)
- {
- if (degree < 0)
- {
- throw "System.ArgumentException";
- }
- if (coefficient == 0)
- {
- return this.zero;
- }
- var coefficients = new Array(degree + 1);
- for(var i=0;i-1)
- options=[{'sourceId': device.deviceId}] ;
- }
- console.log(device.kind + ": " + device.label +
+ .then(function (devices) {
+ devices.forEach(function (device) {
+ console.log("deb1");
+ if (device.kind === 'videoinput') {
+ if (device.label.toLowerCase().search("back") > -1)
+ options = [{
+ 'sourceId': device.deviceId
+ }];
+ }
+ console.log(device.kind + ": " + device.label +
" id = " + device.deviceId);
- });
- })
-
- }
- catch(e)
- {
+ });
+ })
+
+ } catch (e) {
console.log(e);
}
+ } else {
+ console.log("no navigator.mediaDevices.enumerateDevices");
}
- else{
- console.log("no navigator.mediaDevices.enumerateDevices" );
- }
-
- if(n.getUserMedia)
- n.getUserMedia({video: options, audio: false}, qrcode.vidSuccess, qrcode.vidError);
- else
- if(n.webkitGetUserMedia)
- {
- qrcode.webkit=true;
- n.webkitGetUserMedia({video:options, audio: false}, qrcode.vidSuccess, qrcode.vidError);
- }
- else
- if(n.mozGetUserMedia)
- {
- qrcode.moz=true;
- n.mozGetUserMedia({video: options, audio: false}, qrcode.vidSuccess, qrcode.vidError);
- }
+
+ n.mediaDevices.getUserMedia({
+ video: options,
+ audio: false
+ })
+ .then(qrcode.vidSuccess)
+ .catch(qrcode.vidError);
+
+ // if(n.getUserMedia)
+ // n.getUserMedia({video: options, audio: false}, qrcode.vidSuccess, qrcode.vidError);
+ // else
+ // if(n.webkitGetUserMedia)
+ // {
+ // qrcode.webkit=true;
+ // n.webkitGetUserMedia({video:options, audio: false}, qrcode.vidSuccess, qrcode.vidError);
+ // }
+ // else
+ // if(n.mozGetUserMedia)
+ // {
+ // qrcode.moz=true;
+ // n.mozGetUserMedia({video: options, audio: false}, qrcode.vidSuccess, qrcode.vidError);
+ // }
}
-qrcode.decode = function(src){
-
- if(arguments.length==0)
- {
- if(qrcode.canvas_qr2)
- {
+qrcode.decode = function (src) {
+
+ if (arguments.length == 0) {
+ if (qrcode.canvas_qr2) {
var canvas_qr = qrcode.canvas_qr2;
var context = qrcode.qrcontext2;
- }
- else
- {
+ } else {
var canvas_qr = document.getElementById("qr-canvas");
var context = canvas_qr.getContext('2d');
}
@@ -154,19 +160,16 @@ qrcode.decode = function(src){
qrcode.height = canvas_qr.height;
qrcode.imagedata = context.getImageData(0, 0, qrcode.width, qrcode.height);
qrcode.result = qrcode.process(context);
- if(qrcode.callback!=null)
+ if (qrcode.callback != null)
qrcode.callback(qrcode.result);
return qrcode.result;
- }
- else
- {
+ } else {
var image = new Image();
image.crossOrigin = "Anonymous";
- image.onload=function(){
+ image.onload = function () {
//var canvas_qr = document.getElementById("qr-canvas");
var canvas_out = document.getElementById("out-canvas");
- if(canvas_out!=null)
- {
+ if (canvas_out != null) {
var outctx = canvas_out.getContext('2d');
outctx.clearRect(0, 0, 320, 240);
outctx.drawImage(image, 0, 0, 320, 240);
@@ -176,148 +179,129 @@ qrcode.decode = function(src){
var context = canvas_qr.getContext('2d');
var nheight = image.height;
var nwidth = image.width;
- if(image.width*image.height>qrcode.maxImgSize)
- {
+ if (image.width * image.height > qrcode.maxImgSize) {
var ir = image.width / image.height;
- nheight = Math.sqrt(qrcode.maxImgSize/ir);
- nwidth=ir*nheight;
+ nheight = Math.sqrt(qrcode.maxImgSize / ir);
+ nwidth = ir * nheight;
}
canvas_qr.width = nwidth;
canvas_qr.height = nheight;
-
- context.drawImage(image, 0, 0, canvas_qr.width, canvas_qr.height );
+
+ context.drawImage(image, 0, 0, canvas_qr.width, canvas_qr.height);
qrcode.width = canvas_qr.width;
qrcode.height = canvas_qr.height;
- try{
+ try {
qrcode.imagedata = context.getImageData(0, 0, canvas_qr.width, canvas_qr.height);
- }catch(e){
+ } catch (e) {
qrcode.result = "Cross domain image reading not supported in your browser! Save it to your computer then drag and drop the file!";
- if(qrcode.callback!=null)
+ if (qrcode.callback != null)
qrcode.callback(qrcode.result);
return;
}
-
- try
- {
+
+ try {
qrcode.result = qrcode.process(context);
- }
- catch(e)
- {
+ } catch (e) {
console.log(e);
qrcode.result = "error decoding QR Code";
}
- if(qrcode.callback!=null)
+ if (qrcode.callback != null)
qrcode.callback(qrcode.result);
}
- image.onerror = function ()
- {
- if(qrcode.callback!=null)
+ image.onerror = function () {
+ if (qrcode.callback != null)
qrcode.callback("Failed to load the image");
}
image.src = src;
}
}
-qrcode.isUrl = function(s)
-{
+qrcode.isUrl = function (s) {
var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
return regexp.test(s);
}
-qrcode.decode_url = function (s)
-{
- var escaped = "";
- try{
- escaped = escape( s );
- }
- catch(e)
- {
- console.log(e);
- escaped = s;
- }
- var ret = "";
- try{
- ret = decodeURIComponent( escaped );
- }
- catch(e)
- {
- console.log(e);
- ret = escaped;
- }
- return ret;
+qrcode.decode_url = function (s) {
+ var escaped = "";
+ try {
+ escaped = escape(s);
+ } catch (e) {
+ console.log(e);
+ escaped = s;
+ }
+ var ret = "";
+ try {
+ ret = decodeURIComponent(escaped);
+ } catch (e) {
+ console.log(e);
+ ret = escaped;
+ }
+ return ret;
}
-qrcode.decode_utf8 = function ( s )
-{
- if(qrcode.isUrl(s))
+qrcode.decode_utf8 = function (s) {
+ if (qrcode.isUrl(s))
return qrcode.decode_url(s);
else
return s;
}
-qrcode.process = function(ctx){
-
+qrcode.process = function (ctx) {
+
var start = new Date().getTime();
var image = qrcode.grayScaleToBitmap(qrcode.grayscale());
//var image = qrcode.binarize(128);
-
- if(qrcode.debug)
- {
- for (var y = 0; y < qrcode.height; y++)
- {
- for (var x = 0; x < qrcode.width; x++)
- {
+
+ if (qrcode.debug) {
+ for (var y = 0; y < qrcode.height; y++) {
+ for (var x = 0; x < qrcode.width; x++) {
var point = (x * 4) + (y * qrcode.width * 4);
- qrcode.imagedata.data[point] = image[x+y*qrcode.width]?0:0;
- qrcode.imagedata.data[point+1] = image[x+y*qrcode.width]?0:0;
- qrcode.imagedata.data[point+2] = image[x+y*qrcode.width]?255:0;
+ qrcode.imagedata.data[point] = image[x + y * qrcode.width] ? 0 : 0;
+ qrcode.imagedata.data[point + 1] = image[x + y * qrcode.width] ? 0 : 0;
+ qrcode.imagedata.data[point + 2] = image[x + y * qrcode.width] ? 255 : 0;
}
}
ctx.putImageData(qrcode.imagedata, 0, 0);
}
-
+
//var finderPatternInfo = new FinderPatternFinder().findFinderPattern(image);
-
+
var detector = new Detector(image);
var qRCodeMatrix = detector.detect();
-
- if(qrcode.debug)
- {
- for (var y = 0; y < qRCodeMatrix.bits.Height; y++)
- {
- for (var x = 0; x < qRCodeMatrix.bits.Width; x++)
- {
- var point = (x * 4*2) + (y*2 * qrcode.width * 4);
- qrcode.imagedata.data[point] = qRCodeMatrix.bits.get_Renamed(x,y)?0:0;
- qrcode.imagedata.data[point+1] = qRCodeMatrix.bits.get_Renamed(x,y)?0:0;
- qrcode.imagedata.data[point+2] = qRCodeMatrix.bits.get_Renamed(x,y)?255:0;
+
+ if (qrcode.debug) {
+ for (var y = 0; y < qRCodeMatrix.bits.Height; y++) {
+ for (var x = 0; x < qRCodeMatrix.bits.Width; x++) {
+ var point = (x * 4 * 2) + (y * 2 * qrcode.width * 4);
+ qrcode.imagedata.data[point] = qRCodeMatrix.bits.get_Renamed(x, y) ? 0 : 0;
+ qrcode.imagedata.data[point + 1] = qRCodeMatrix.bits.get_Renamed(x, y) ? 0 : 0;
+ qrcode.imagedata.data[point + 2] = qRCodeMatrix.bits.get_Renamed(x, y) ? 255 : 0;
}
}
ctx.putImageData(qrcode.imagedata, 0, 0);
}
-
-
+
+
var reader = Decoder.decode(qRCodeMatrix.bits);
var data = reader.DataByte;
- var str="";
- for(var i=0;i minmax[ax][ay][1])
@@ -378,45 +353,37 @@ qrcode.getMiddleBrightnessPerArea=function(image)
}
}
var middle = new Array(numSqrtArea);
- for (var i3 = 0; i3 < numSqrtArea; i3++)
- {
+ for (var i3 = 0; i3 < numSqrtArea; i3++) {
middle[i3] = new Array(numSqrtArea);
}
- for (var ay = 0; ay < numSqrtArea; ay++)
- {
- for (var ax = 0; ax < numSqrtArea; ax++)
- {
+ for (var ay = 0; ay < numSqrtArea; ay++) {
+ for (var ax = 0; ax < numSqrtArea; ax++) {
middle[ax][ay] = Math.floor((minmax[ax][ay][0] + minmax[ax][ay][1]) / 2);
//Console.out.print(middle[ax][ay] + ",");
}
//Console.out.println("");
}
//Console.out.println("");
-
+
return middle;
}
-qrcode.grayScaleToBitmap=function(grayScale)
-{
+qrcode.grayScaleToBitmap = function (grayScale) {
var middle = qrcode.getMiddleBrightnessPerArea(grayScale);
var sqrtNumArea = middle.length;
var areaWidth = Math.floor(qrcode.width / sqrtNumArea);
var areaHeight = Math.floor(qrcode.height / sqrtNumArea);
- var buff = new ArrayBuffer(qrcode.width*qrcode.height);
+ var buff = new ArrayBuffer(qrcode.width * qrcode.height);
var bitmap = new Uint8Array(buff);
//var bitmap = new Array(qrcode.height*qrcode.width);
-
- for (var ay = 0; ay < sqrtNumArea; ay++)
- {
- for (var ax = 0; ax < sqrtNumArea; ax++)
- {
- for (var dy = 0; dy < areaHeight; dy++)
- {
- for (var dx = 0; dx < areaWidth; dx++)
- {
- bitmap[areaWidth * ax + dx+ (areaHeight * ay + dy)*qrcode.width] = (grayScale[areaWidth * ax + dx+ (areaHeight * ay + dy)*qrcode.width] < middle[ax][ay])?true:false;
+
+ for (var ay = 0; ay < sqrtNumArea; ay++) {
+ for (var ax = 0; ax < sqrtNumArea; ax++) {
+ for (var dy = 0; dy < areaHeight; dy++) {
+ for (var dx = 0; dx < areaWidth; dx++) {
+ bitmap[areaWidth * ax + dx + (areaHeight * ay + dy) * qrcode.width] = (grayScale[areaWidth * ax + dx + (areaHeight * ay + dy) * qrcode.width] < middle[ax][ay]) ? true : false;
}
}
}
@@ -424,32 +391,26 @@ qrcode.grayScaleToBitmap=function(grayScale)
return bitmap;
}
-qrcode.grayscale = function()
-{
- var buff = new ArrayBuffer(qrcode.width*qrcode.height);
+qrcode.grayscale = function () {
+ var buff = new ArrayBuffer(qrcode.width * qrcode.height);
var ret = new Uint8Array(buff);
//var ret = new Array(qrcode.width*qrcode.height);
-
- for (var y = 0; y < qrcode.height; y++)
- {
- for (var x = 0; x < qrcode.width; x++)
- {
+
+ for (var y = 0; y < qrcode.height; y++) {
+ for (var x = 0; x < qrcode.width; x++) {
var gray = qrcode.getPixel(x, y);
-
- ret[x+y*qrcode.width] = gray;
+
+ ret[x + y * qrcode.width] = gray;
}
}
return ret;
}
+export default qrcode;
-
-
-function URShift( number, bits)
-{
+export function URShift(number, bits) {
if (number >= 0)
return number >> bits;
else
return (number >> bits) + (2 << ~bits);
-}
-
+}
\ No newline at end of file
diff --git a/src/rsdecoder.js b/src/rsdecoder.js
index c110c43c..84c25c85 100644
--- a/src/rsdecoder.js
+++ b/src/rsdecoder.js
@@ -21,9 +21,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import GF256 from './gf256';
+import GF256Poly from './gf256poly';
-
-function ReedSolomonDecoder(field)
+export default function ReedSolomonDecoder(field)
{
this.field = field;
this.decode=function(received, twoS)
diff --git a/src/test.html b/src/test.html
deleted file mode 100644
index 9f400d03..00000000
--- a/src/test.html
+++ /dev/null
@@ -1,149 +0,0 @@
-
-
-QRCODE
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/version.js b/src/version.js
index 4e19c7f1..fecf1af9 100644
--- a/src/version.js
+++ b/src/version.js
@@ -22,7 +22,8 @@
* limitations under the License.
*/
-
+import FormatInformation from './formatinf';
+import BitMatrix from './bitmat';
function ECB(count, dataCodewords)
{
@@ -73,7 +74,7 @@ function ECBlocks( ecCodewordsPerBlock, ecBlocks1, ecBlocks2)
}
}
-function Version( versionNumber, alignmentPatternCenters, ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4)
+export default function Version( versionNumber, alignmentPatternCenters, ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4)
{
this.versionNumber = versionNumber;
this.alignmentPatternCenters = alignmentPatternCenters;
diff --git a/webpack.config.js b/webpack.config.js
new file mode 100644
index 00000000..e7321dfa
--- /dev/null
+++ b/webpack.config.js
@@ -0,0 +1,50 @@
+/* global __dirname, require, module*/
+
+const webpack = require('webpack');
+const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
+const path = require('path');
+const env = require('yargs').argv.env; // use --env with webpack 2
+
+let libraryName = 'qrcode';
+
+let plugins = [], outputFile;
+
+if (env === 'build') {
+ plugins.push(new UglifyJsPlugin({ minimize: true }));
+ outputFile = libraryName + '.min.js';
+} else {
+ outputFile = libraryName + '.js';
+}
+
+const config = {
+ entry: __dirname + '/src/index.js',
+ devtool: 'source-map',
+ output: {
+ path: __dirname + '/lib',
+ filename: outputFile,
+ library: libraryName,
+ libraryTarget: 'umd',
+ umdNamedDefine: true
+ },
+ module: {
+ rules: [
+ {
+ test: /(\.jsx|\.js)$/,
+ loader: 'babel-loader',
+ exclude: /(node_modules|bower_components)/
+ },
+ {
+ test: /(\.jsx|\.js)$/,
+ loader: 'eslint-loader',
+ exclude: /node_modules/
+ }
+ ]
+ },
+ resolve: {
+ modules: [path.resolve('./node_modules'), path.resolve('./src')],
+ extensions: ['.json', '.js']
+ },
+ plugins: plugins
+};
+
+module.exports = config;