{"version":3,"file":"vendors-86233f99.f584a1446b2fc034d810.bundle.js","mappings":"AACA","sources":["webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/ReaderException.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/ReedSolomonException.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/Result.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/ResultMetadataType.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/ResultPoint.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/UnsupportedOperationException.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/WriterException.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/aztec/AztecDetectorResult.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/aztec/AztecReader.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/aztec/AztecWriter.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/aztec/decoder/Decoder.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/aztec/detector/Detector.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/aztec/encoder/AztecCode.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/aztec/encoder/Encoder.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/aztec/encoder/SimpleToken.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/aztec/encoder/Token.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/aztec/encoder/BinaryShiftToken.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/aztec/encoder/TokenHelpers.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/aztec/encoder/EncoderConstants.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/aztec/encoder/LatchTable.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/aztec/encoder/ShiftTable.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/aztec/encoder/State.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/aztec/encoder/CharMap.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/aztec/encoder/HighLevelEncoder.js"],"sourcesContent":["var __extends = (this && this.__extends) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nimport Exception from './Exception';\n/**\n * Custom Error class of type Exception.\n */\nvar ReaderException = /** @class */ (function (_super) {\n    __extends(ReaderException, _super);\n    function ReaderException() {\n        return _super !== null && _super.apply(this, arguments) || this;\n    }\n    ReaderException.kind = 'ReaderException';\n    return ReaderException;\n}(Exception));\nexport default ReaderException;\n","var __extends = (this && this.__extends) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nimport Exception from './Exception';\n/**\n * Custom Error class of type Exception.\n */\nvar ReedSolomonException = /** @class */ (function (_super) {\n    __extends(ReedSolomonException, _super);\n    function ReedSolomonException() {\n        return _super !== null && _super.apply(this, arguments) || this;\n    }\n    ReedSolomonException.kind = 'ReedSolomonException';\n    return ReedSolomonException;\n}(Exception));\nexport default ReedSolomonException;\n","/*\n * Copyright 2007 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport System from './util/System';\n/**\n * <p>Encapsulates the result of decoding a barcode within an image.</p>\n *\n * @author Sean Owen\n */\nvar Result = /** @class */ (function () {\n    // public constructor(private text: string,\n    //               Uint8Array rawBytes,\n    //               ResultPoconst resultPoints: Int32Array,\n    //               BarcodeFormat format) {\n    //   this(text, rawBytes, resultPoints, format, System.currentTimeMillis())\n    // }\n    // public constructor(text: string,\n    //               Uint8Array rawBytes,\n    //               ResultPoconst resultPoints: Int32Array,\n    //               BarcodeFormat format,\n    //               long timestamp) {\n    //   this(text, rawBytes, rawBytes == null ? 0 : 8 * rawBytes.length,\n    //        resultPoints, format, timestamp)\n    // }\n    function Result(text, rawBytes, numBits, resultPoints, format, timestamp) {\n        if (numBits === void 0) { numBits = rawBytes == null ? 0 : 8 * rawBytes.length; }\n        if (timestamp === void 0) { timestamp = System.currentTimeMillis(); }\n        this.text = text;\n        this.rawBytes = rawBytes;\n        this.numBits = numBits;\n        this.resultPoints = resultPoints;\n        this.format = format;\n        this.timestamp = timestamp;\n        this.text = text;\n        this.rawBytes = rawBytes;\n        if (undefined === numBits || null === numBits) {\n            this.numBits = (rawBytes === null || rawBytes === undefined) ? 0 : 8 * rawBytes.length;\n        }\n        else {\n            this.numBits = numBits;\n        }\n        this.resultPoints = resultPoints;\n        this.format = format;\n        this.resultMetadata = null;\n        if (undefined === timestamp || null === timestamp) {\n            this.timestamp = System.currentTimeMillis();\n        }\n        else {\n            this.timestamp = timestamp;\n        }\n    }\n    /**\n     * @return raw text encoded by the barcode\n     */\n    Result.prototype.getText = function () {\n        return this.text;\n    };\n    /**\n     * @return raw bytes encoded by the barcode, if applicable, otherwise {@code null}\n     */\n    Result.prototype.getRawBytes = function () {\n        return this.rawBytes;\n    };\n    /**\n     * @return how many bits of {@link #getRawBytes()} are valid; typically 8 times its length\n     * @since 3.3.0\n     */\n    Result.prototype.getNumBits = function () {\n        return this.numBits;\n    };\n    /**\n     * @return points related to the barcode in the image. These are typically points\n     *         identifying finder patterns or the corners of the barcode. The exact meaning is\n     *         specific to the type of barcode that was decoded.\n     */\n    Result.prototype.getResultPoints = function () {\n        return this.resultPoints;\n    };\n    /**\n     * @return {@link BarcodeFormat} representing the format of the barcode that was decoded\n     */\n    Result.prototype.getBarcodeFormat = function () {\n        return this.format;\n    };\n    /**\n     * @return {@link Map} mapping {@link ResultMetadataType} keys to values. May be\n     *   {@code null}. This contains optional metadata about what was detected about the barcode,\n     *   like orientation.\n     */\n    Result.prototype.getResultMetadata = function () {\n        return this.resultMetadata;\n    };\n    Result.prototype.putMetadata = function (type, value) {\n        if (this.resultMetadata === null) {\n            this.resultMetadata = new Map();\n        }\n        this.resultMetadata.set(type, value);\n    };\n    Result.prototype.putAllMetadata = function (metadata) {\n        if (metadata !== null) {\n            if (this.resultMetadata === null) {\n                this.resultMetadata = metadata;\n            }\n            else {\n                this.resultMetadata = new Map(metadata);\n            }\n        }\n    };\n    Result.prototype.addResultPoints = function (newPoints) {\n        var oldPoints = this.resultPoints;\n        if (oldPoints === null) {\n            this.resultPoints = newPoints;\n        }\n        else if (newPoints !== null && newPoints.length > 0) {\n            var allPoints = new Array(oldPoints.length + newPoints.length);\n            System.arraycopy(oldPoints, 0, allPoints, 0, oldPoints.length);\n            System.arraycopy(newPoints, 0, allPoints, oldPoints.length, newPoints.length);\n            this.resultPoints = allPoints;\n        }\n    };\n    Result.prototype.getTimestamp = function () {\n        return this.timestamp;\n    };\n    /*@Override*/\n    Result.prototype.toString = function () {\n        return this.text;\n    };\n    return Result;\n}());\nexport default Result;\n","/*\n * Copyright 2008 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/*namespace com.google.zxing {*/\n/**\n * Represents some type of metadata about the result of the decoding that the decoder\n * wishes to communicate back to the caller.\n *\n * @author Sean Owen\n */\nvar ResultMetadataType;\n(function (ResultMetadataType) {\n    /**\n     * Unspecified, application-specific metadata. Maps to an unspecified {@link Object}.\n     */\n    ResultMetadataType[ResultMetadataType[\"OTHER\"] = 0] = \"OTHER\";\n    /**\n     * Denotes the likely approximate orientation of the barcode in the image. This value\n     * is given as degrees rotated clockwise from the normal, upright orientation.\n     * For example a 1D barcode which was found by reading top-to-bottom would be\n     * said to have orientation \"90\". This key maps to an {@link Integer} whose\n     * value is in the range [0,360).\n     */\n    ResultMetadataType[ResultMetadataType[\"ORIENTATION\"] = 1] = \"ORIENTATION\";\n    /**\n     * <p>2D barcode formats typically encode text, but allow for a sort of 'byte mode'\n     * which is sometimes used to encode binary data. While {@link Result} makes available\n     * the complete raw bytes in the barcode for these formats, it does not offer the bytes\n     * from the byte segments alone.</p>\n     *\n     * <p>This maps to a {@link java.util.List} of byte arrays corresponding to the\n     * raw bytes in the byte segments in the barcode, in order.</p>\n     */\n    ResultMetadataType[ResultMetadataType[\"BYTE_SEGMENTS\"] = 2] = \"BYTE_SEGMENTS\";\n    /**\n     * Error correction level used, if applicable. The value type depends on the\n     * format, but is typically a String.\n     */\n    ResultMetadataType[ResultMetadataType[\"ERROR_CORRECTION_LEVEL\"] = 3] = \"ERROR_CORRECTION_LEVEL\";\n    /**\n     * For some periodicals, indicates the issue number as an {@link Integer}.\n     */\n    ResultMetadataType[ResultMetadataType[\"ISSUE_NUMBER\"] = 4] = \"ISSUE_NUMBER\";\n    /**\n     * For some products, indicates the suggested retail price in the barcode as a\n     * formatted {@link String}.\n     */\n    ResultMetadataType[ResultMetadataType[\"SUGGESTED_PRICE\"] = 5] = \"SUGGESTED_PRICE\";\n    /**\n     * For some products, the possible country of manufacture as a {@link String} denoting the\n     * ISO country code. Some map to multiple possible countries, like \"US/CA\".\n     */\n    ResultMetadataType[ResultMetadataType[\"POSSIBLE_COUNTRY\"] = 6] = \"POSSIBLE_COUNTRY\";\n    /**\n     * For some products, the extension text\n     */\n    ResultMetadataType[ResultMetadataType[\"UPC_EAN_EXTENSION\"] = 7] = \"UPC_EAN_EXTENSION\";\n    /**\n     * PDF417-specific metadata\n     */\n    ResultMetadataType[ResultMetadataType[\"PDF417_EXTRA_METADATA\"] = 8] = \"PDF417_EXTRA_METADATA\";\n    /**\n     * If the code format supports structured append and the current scanned code is part of one then the\n     * sequence number is given with it.\n     */\n    ResultMetadataType[ResultMetadataType[\"STRUCTURED_APPEND_SEQUENCE\"] = 9] = \"STRUCTURED_APPEND_SEQUENCE\";\n    /**\n     * If the code format supports structured append and the current scanned code is part of one then the\n     * parity is given with it.\n     */\n    ResultMetadataType[ResultMetadataType[\"STRUCTURED_APPEND_PARITY\"] = 10] = \"STRUCTURED_APPEND_PARITY\";\n})(ResultMetadataType || (ResultMetadataType = {}));\nexport default ResultMetadataType;\n","/*\n * Copyright 2007 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/*namespace com.google.zxing {*/\nimport MathUtils from './common/detector/MathUtils';\nimport Float from './util/Float';\n/**\n * <p>Encapsulates a point of interest in an image containing a barcode. Typically, this\n * would be the location of a finder pattern or the corner of the barcode, for example.</p>\n *\n * @author Sean Owen\n */\nvar ResultPoint = /** @class */ (function () {\n    function ResultPoint(x, y) {\n        this.x = x;\n        this.y = y;\n    }\n    ResultPoint.prototype.getX = function () {\n        return this.x;\n    };\n    ResultPoint.prototype.getY = function () {\n        return this.y;\n    };\n    /*@Override*/\n    ResultPoint.prototype.equals = function (other) {\n        if (other instanceof ResultPoint) {\n            var otherPoint = other;\n            return this.x === otherPoint.x && this.y === otherPoint.y;\n        }\n        return false;\n    };\n    /*@Override*/\n    ResultPoint.prototype.hashCode = function () {\n        return 31 * Float.floatToIntBits(this.x) + Float.floatToIntBits(this.y);\n    };\n    /*@Override*/\n    ResultPoint.prototype.toString = function () {\n        return '(' + this.x + ',' + this.y + ')';\n    };\n    /**\n     * Orders an array of three ResultPoints in an order [A,B,C] such that AB is less than AC\n     * and BC is less than AC, and the angle between BC and BA is less than 180 degrees.\n     *\n     * @param patterns array of three {@code ResultPoint} to order\n     */\n    ResultPoint.orderBestPatterns = function (patterns) {\n        // Find distances between pattern centers\n        var zeroOneDistance = this.distance(patterns[0], patterns[1]);\n        var oneTwoDistance = this.distance(patterns[1], patterns[2]);\n        var zeroTwoDistance = this.distance(patterns[0], patterns[2]);\n        var pointA;\n        var pointB;\n        var pointC;\n        // Assume one closest to other two is B; A and C will just be guesses at first\n        if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) {\n            pointB = patterns[0];\n            pointA = patterns[1];\n            pointC = patterns[2];\n        }\n        else if (zeroTwoDistance >= oneTwoDistance && zeroTwoDistance >= zeroOneDistance) {\n            pointB = patterns[1];\n            pointA = patterns[0];\n            pointC = patterns[2];\n        }\n        else {\n            pointB = patterns[2];\n            pointA = patterns[0];\n            pointC = patterns[1];\n        }\n        // Use cross product to figure out whether A and C are correct or flipped.\n        // This asks whether BC x BA has a positive z component, which is the arrangement\n        // we want for A, B, C. If it's negative, then we've got it flipped around and\n        // should swap A and C.\n        if (this.crossProductZ(pointA, pointB, pointC) < 0.0) {\n            var temp = pointA;\n            pointA = pointC;\n            pointC = temp;\n        }\n        patterns[0] = pointA;\n        patterns[1] = pointB;\n        patterns[2] = pointC;\n    };\n    /**\n     * @param pattern1 first pattern\n     * @param pattern2 second pattern\n     * @return distance between two points\n     */\n    ResultPoint.distance = function (pattern1, pattern2) {\n        return MathUtils.distance(pattern1.x, pattern1.y, pattern2.x, pattern2.y);\n    };\n    /**\n     * Returns the z component of the cross product between vectors BC and BA.\n     */\n    ResultPoint.crossProductZ = function (pointA, pointB, pointC) {\n        var bX = pointB.x;\n        var bY = pointB.y;\n        return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX));\n    };\n    return ResultPoint;\n}());\nexport default ResultPoint;\n","var __extends = (this && this.__extends) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nimport Exception from './Exception';\n/**\n * Custom Error class of type Exception.\n */\nvar UnsupportedOperationException = /** @class */ (function (_super) {\n    __extends(UnsupportedOperationException, _super);\n    function UnsupportedOperationException() {\n        return _super !== null && _super.apply(this, arguments) || this;\n    }\n    UnsupportedOperationException.kind = 'UnsupportedOperationException';\n    return UnsupportedOperationException;\n}(Exception));\nexport default UnsupportedOperationException;\n","var __extends = (this && this.__extends) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nimport Exception from './Exception';\n/**\n * Custom Error class of type Exception.\n */\nvar WriterException = /** @class */ (function (_super) {\n    __extends(WriterException, _super);\n    function WriterException() {\n        return _super !== null && _super.apply(this, arguments) || this;\n    }\n    WriterException.kind = 'WriterException';\n    return WriterException;\n}(Exception));\nexport default WriterException;\n","/*\n * Copyright 2010 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nvar __extends = (this && this.__extends) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nimport DetectorResult from '../common/DetectorResult';\n/**\n * <p>Extends {@link DetectorResult} with more information specific to the Aztec format,\n * like the number of layers and whether it's compact.</p>\n *\n * @author Sean Owen\n */\nvar AztecDetectorResult = /** @class */ (function (_super) {\n    __extends(AztecDetectorResult, _super);\n    function AztecDetectorResult(bits, points, compact, nbDatablocks, nbLayers) {\n        var _this = _super.call(this, bits, points) || this;\n        _this.compact = compact;\n        _this.nbDatablocks = nbDatablocks;\n        _this.nbLayers = nbLayers;\n        return _this;\n    }\n    AztecDetectorResult.prototype.getNbLayers = function () {\n        return this.nbLayers;\n    };\n    AztecDetectorResult.prototype.getNbDatablocks = function () {\n        return this.nbDatablocks;\n    };\n    AztecDetectorResult.prototype.isCompact = function () {\n        return this.compact;\n    };\n    return AztecDetectorResult;\n}(DetectorResult));\nexport default AztecDetectorResult;\n","/*\n * Copyright 2010 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport Result from '../Result';\nimport BarcodeFormat from '../BarcodeFormat';\nimport DecodeHintType from '../DecodeHintType';\nimport ResultMetadataType from '../ResultMetadataType';\nimport System from '../util/System';\nimport Decoder from './decoder/Decoder';\nimport Detector from './detector/Detector';\n// import java.util.List;\n// import java.util.Map;\n/**\n * This implementation can detect and decode Aztec codes in an image.\n *\n * @author David Olivier\n */\nvar AztecReader = /** @class */ (function () {\n    function AztecReader() {\n    }\n    /**\n     * Locates and decodes a Data Matrix code in an image.\n     *\n     * @return a String representing the content encoded by the Data Matrix code\n     * @throws NotFoundException if a Data Matrix code cannot be found\n     * @throws FormatException if a Data Matrix code cannot be decoded\n     */\n    AztecReader.prototype.decode = function (image, hints) {\n        if (hints === void 0) { hints = null; }\n        var exception = null;\n        var detector = new Detector(image.getBlackMatrix());\n        var points = null;\n        var decoderResult = null;\n        try {\n            var detectorResult = detector.detectMirror(false);\n            points = detectorResult.getPoints();\n            this.reportFoundResultPoints(hints, points);\n            decoderResult = new Decoder().decode(detectorResult);\n        }\n        catch (e) {\n            exception = e;\n        }\n        if (decoderResult == null) {\n            try {\n                var detectorResult = detector.detectMirror(true);\n                points = detectorResult.getPoints();\n                this.reportFoundResultPoints(hints, points);\n                decoderResult = new Decoder().decode(detectorResult);\n            }\n            catch (e) {\n                if (exception != null) {\n                    throw exception;\n                }\n                throw e;\n            }\n        }\n        var result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), decoderResult.getNumBits(), points, BarcodeFormat.AZTEC, System.currentTimeMillis());\n        var byteSegments = decoderResult.getByteSegments();\n        if (byteSegments != null) {\n            result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments);\n        }\n        var ecLevel = decoderResult.getECLevel();\n        if (ecLevel != null) {\n            result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);\n        }\n        return result;\n    };\n    AztecReader.prototype.reportFoundResultPoints = function (hints, points) {\n        if (hints != null) {\n            var rpcb_1 = hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);\n            if (rpcb_1 != null) {\n                points.forEach(function (point, idx, arr) {\n                    rpcb_1.foundPossibleResultPoint(point);\n                });\n            }\n        }\n    };\n    // @Override\n    AztecReader.prototype.reset = function () {\n        // do nothing\n    };\n    return AztecReader;\n}());\nexport default AztecReader;\n","/*\n* Copyright 2013 ZXing authors\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n*      http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n// package com.google.zxing.aztec;\n// import com.google.zxing.BarcodeFormat;\nimport BarcodeFormat from '../BarcodeFormat';\n// import com.google.zxing.EncodeHintType;\nimport EncodeHintType from '../EncodeHintType';\n// import com.google.zxing.aztec.encoder.Encoder;\nimport Encoder from './encoder/Encoder';\n// import com.google.zxing.common.BitMatrix;\nimport BitMatrix from '../common/BitMatrix';\n// import java.nio.charset.Charset;\nimport Charset from '../util/Charset';\n// import java.nio.charset.StandardCharsets;\nimport StandardCharsets from '../util/StandardCharsets';\n// import java.util.Map;\nimport Integer from '../util/Integer';\nimport IllegalStateException from '../IllegalStateException';\nimport IllegalArgumentException from '../IllegalArgumentException';\nimport StringUtils from '../common/StringUtils';\n/**\n * Renders an Aztec code as a {@link BitMatrix}.\n */\nvar AztecWriter = /** @class */ (function () {\n    function AztecWriter() {\n    }\n    // @Override\n    AztecWriter.prototype.encode = function (contents, format, width, height) {\n        return this.encodeWithHints(contents, format, width, height, null);\n    };\n    // @Override\n    AztecWriter.prototype.encodeWithHints = function (contents, format, width, height, hints) {\n        var charset = StandardCharsets.ISO_8859_1;\n        var eccPercent = Encoder.DEFAULT_EC_PERCENT;\n        var layers = Encoder.DEFAULT_AZTEC_LAYERS;\n        if (hints != null) {\n            if (hints.has(EncodeHintType.CHARACTER_SET)) {\n                charset = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());\n            }\n            if (hints.has(EncodeHintType.ERROR_CORRECTION)) {\n                eccPercent = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString());\n            }\n            if (hints.has(EncodeHintType.AZTEC_LAYERS)) {\n                layers = Integer.parseInt(hints.get(EncodeHintType.AZTEC_LAYERS).toString());\n            }\n        }\n        return AztecWriter.encodeLayers(contents, format, width, height, charset, eccPercent, layers);\n    };\n    AztecWriter.encodeLayers = function (contents, format, width, height, charset, eccPercent, layers) {\n        if (format !== BarcodeFormat.AZTEC) {\n            throw new IllegalArgumentException('Can only encode AZTEC, but got ' + format);\n        }\n        var aztec = Encoder.encode(StringUtils.getBytes(contents, charset), eccPercent, layers);\n        return AztecWriter.renderResult(aztec, width, height);\n    };\n    AztecWriter.renderResult = function (code, width, height) {\n        var input = code.getMatrix();\n        if (input == null) {\n            throw new IllegalStateException();\n        }\n        var inputWidth = input.getWidth();\n        var inputHeight = input.getHeight();\n        var outputWidth = Math.max(width, inputWidth);\n        var outputHeight = Math.max(height, inputHeight);\n        var multiple = Math.min(outputWidth / inputWidth, outputHeight / inputHeight);\n        var leftPadding = (outputWidth - (inputWidth * multiple)) / 2;\n        var topPadding = (outputHeight - (inputHeight * multiple)) / 2;\n        var output = new BitMatrix(outputWidth, outputHeight);\n        for (var inputY /*int*/ = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {\n            // Write the contents of this row of the barcode\n            for (var inputX /*int*/ = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {\n                if (input.get(inputX, inputY)) {\n                    output.setRegion(outputX, outputY, multiple, multiple);\n                }\n            }\n        }\n        return output;\n    };\n    return AztecWriter;\n}());\nexport default AztecWriter;\n","/*\n * Copyright 2010 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport DecoderResult from '../../common/DecoderResult';\nimport GenericGF from '../../common/reedsolomon/GenericGF';\nimport ReedSolomonDecoder from '../../common/reedsolomon/ReedSolomonDecoder';\nimport IllegalStateException from '../../IllegalStateException';\nimport FormatException from '../../FormatException';\nimport StringUtils from '../../common/StringUtils';\nimport Integer from '../../util/Integer';\n// import java.util.Arrays;\nvar Table;\n(function (Table) {\n    Table[Table[\"UPPER\"] = 0] = \"UPPER\";\n    Table[Table[\"LOWER\"] = 1] = \"LOWER\";\n    Table[Table[\"MIXED\"] = 2] = \"MIXED\";\n    Table[Table[\"DIGIT\"] = 3] = \"DIGIT\";\n    Table[Table[\"PUNCT\"] = 4] = \"PUNCT\";\n    Table[Table[\"BINARY\"] = 5] = \"BINARY\";\n})(Table || (Table = {}));\n/**\n * <p>The main class which implements Aztec Code decoding -- as opposed to locating and extracting\n * the Aztec Code from an image.</p>\n *\n * @author David Olivier\n */\nvar Decoder = /** @class */ (function () {\n    function Decoder() {\n    }\n    Decoder.prototype.decode = function (detectorResult) {\n        this.ddata = detectorResult;\n        var matrix = detectorResult.getBits();\n        var rawbits = this.extractBits(matrix);\n        var correctedBits = this.correctBits(rawbits);\n        var rawBytes = Decoder.convertBoolArrayToByteArray(correctedBits);\n        var result = Decoder.getEncodedData(correctedBits);\n        var decoderResult = new DecoderResult(rawBytes, result, null, null);\n        decoderResult.setNumBits(correctedBits.length);\n        return decoderResult;\n    };\n    // This method is used for testing the high-level encoder\n    Decoder.highLevelDecode = function (correctedBits) {\n        return this.getEncodedData(correctedBits);\n    };\n    /**\n     * Gets the string encoded in the aztec code bits\n     *\n     * @return the decoded string\n     */\n    Decoder.getEncodedData = function (correctedBits) {\n        var endIndex = correctedBits.length;\n        var latchTable = Table.UPPER; // table most recently latched to\n        var shiftTable = Table.UPPER; // table to use for the next read\n        var result = '';\n        var index = 0;\n        while (index < endIndex) {\n            if (shiftTable === Table.BINARY) {\n                if (endIndex - index < 5) {\n                    break;\n                }\n                var length_1 = Decoder.readCode(correctedBits, index, 5);\n                index += 5;\n                if (length_1 === 0) {\n                    if (endIndex - index < 11) {\n                        break;\n                    }\n                    length_1 = Decoder.readCode(correctedBits, index, 11) + 31;\n                    index += 11;\n                }\n                for (var charCount = 0; charCount < length_1; charCount++) {\n                    if (endIndex - index < 8) {\n                        index = endIndex; // Force outer loop to exit\n                        break;\n                    }\n                    var code = Decoder.readCode(correctedBits, index, 8);\n                    result += /*(char)*/ StringUtils.castAsNonUtf8Char(code);\n                    index += 8;\n                }\n                // Go back to whatever mode we had been in\n                shiftTable = latchTable;\n            }\n            else {\n                var size = shiftTable === Table.DIGIT ? 4 : 5;\n                if (endIndex - index < size) {\n                    break;\n                }\n                var code = Decoder.readCode(correctedBits, index, size);\n                index += size;\n                var str = Decoder.getCharacter(shiftTable, code);\n                if (str.startsWith('CTRL_')) {\n                    // Table changes\n                    // ISO/IEC 24778:2008 prescribes ending a shift sequence in the mode from which it was invoked.\n                    // That's including when that mode is a shift.\n                    // Our test case dlusbs.png for issue #642 exercises that.\n                    latchTable = shiftTable; // Latch the current mode, so as to return to Upper after U/S B/S\n                    shiftTable = Decoder.getTable(str.charAt(5));\n                    if (str.charAt(6) === 'L') {\n                        latchTable = shiftTable;\n                    }\n                }\n                else {\n                    result += str;\n                    // Go back to whatever mode we had been in\n                    shiftTable = latchTable;\n                }\n            }\n        }\n        return result;\n    };\n    /**\n     * gets the table corresponding to the char passed\n     */\n    Decoder.getTable = function (t) {\n        switch (t) {\n            case 'L':\n                return Table.LOWER;\n            case 'P':\n                return Table.PUNCT;\n            case 'M':\n                return Table.MIXED;\n            case 'D':\n                return Table.DIGIT;\n            case 'B':\n                return Table.BINARY;\n            case 'U':\n            default:\n                return Table.UPPER;\n        }\n    };\n    /**\n     * Gets the character (or string) corresponding to the passed code in the given table\n     *\n     * @param table the table used\n     * @param code the code of the character\n     */\n    Decoder.getCharacter = function (table, code) {\n        switch (table) {\n            case Table.UPPER:\n                return Decoder.UPPER_TABLE[code];\n            case Table.LOWER:\n                return Decoder.LOWER_TABLE[code];\n            case Table.MIXED:\n                return Decoder.MIXED_TABLE[code];\n            case Table.PUNCT:\n                return Decoder.PUNCT_TABLE[code];\n            case Table.DIGIT:\n                return Decoder.DIGIT_TABLE[code];\n            default:\n                // Should not reach here.\n                throw new IllegalStateException('Bad table');\n        }\n    };\n    /**\n     * <p>Performs RS error correction on an array of bits.</p>\n     *\n     * @return the corrected array\n     * @throws FormatException if the input contains too many errors\n     */\n    Decoder.prototype.correctBits = function (rawbits) {\n        var gf;\n        var codewordSize;\n        if (this.ddata.getNbLayers() <= 2) {\n            codewordSize = 6;\n            gf = GenericGF.AZTEC_DATA_6;\n        }\n        else if (this.ddata.getNbLayers() <= 8) {\n            codewordSize = 8;\n            gf = GenericGF.AZTEC_DATA_8;\n        }\n        else if (this.ddata.getNbLayers() <= 22) {\n            codewordSize = 10;\n            gf = GenericGF.AZTEC_DATA_10;\n        }\n        else {\n            codewordSize = 12;\n            gf = GenericGF.AZTEC_DATA_12;\n        }\n        var numDataCodewords = this.ddata.getNbDatablocks();\n        var numCodewords = rawbits.length / codewordSize;\n        if (numCodewords < numDataCodewords) {\n            throw new FormatException();\n        }\n        var offset = rawbits.length % codewordSize;\n        var dataWords = new Int32Array(numCodewords);\n        for (var i = 0; i < numCodewords; i++, offset += codewordSize) {\n            dataWords[i] = Decoder.readCode(rawbits, offset, codewordSize);\n        }\n        try {\n            var rsDecoder = new ReedSolomonDecoder(gf);\n            rsDecoder.decode(dataWords, numCodewords - numDataCodewords);\n        }\n        catch (ex) {\n            throw new FormatException(ex);\n        }\n        // Now perform the unstuffing operation.\n        // First, count how many bits are going to be thrown out as stuffing\n        var mask = (1 << codewordSize) - 1;\n        var stuffedBits = 0;\n        for (var i = 0; i < numDataCodewords; i++) {\n            var dataWord = dataWords[i];\n            if (dataWord === 0 || dataWord === mask) {\n                throw new FormatException();\n            }\n            else if (dataWord === 1 || dataWord === mask - 1) {\n                stuffedBits++;\n            }\n        }\n        // Now, actually unpack the bits and remove the stuffing\n        var correctedBits = new Array(numDataCodewords * codewordSize - stuffedBits);\n        var index = 0;\n        for (var i = 0; i < numDataCodewords; i++) {\n            var dataWord = dataWords[i];\n            if (dataWord === 1 || dataWord === mask - 1) {\n                // next codewordSize-1 bits are all zeros or all ones\n                correctedBits.fill(dataWord > 1, index, index + codewordSize - 1);\n                // Arrays.fill(correctedBits, index, index + codewordSize - 1, dataWord > 1);\n                index += codewordSize - 1;\n            }\n            else {\n                for (var bit = codewordSize - 1; bit >= 0; --bit) {\n                    correctedBits[index++] = (dataWord & (1 << bit)) !== 0;\n                }\n            }\n        }\n        return correctedBits;\n    };\n    /**\n     * Gets the array of bits from an Aztec Code matrix\n     *\n     * @return the array of bits\n     */\n    Decoder.prototype.extractBits = function (matrix) {\n        var compact = this.ddata.isCompact();\n        var layers = this.ddata.getNbLayers();\n        var baseMatrixSize = (compact ? 11 : 14) + layers * 4; // not including alignment lines\n        var alignmentMap = new Int32Array(baseMatrixSize);\n        var rawbits = new Array(this.totalBitsInLayer(layers, compact));\n        if (compact) {\n            for (var i = 0; i < alignmentMap.length; i++) {\n                alignmentMap[i] = i;\n            }\n        }\n        else {\n            var matrixSize = baseMatrixSize + 1 + 2 * Integer.truncDivision((Integer.truncDivision(baseMatrixSize, 2) - 1), 15);\n            var origCenter = baseMatrixSize / 2;\n            var center = Integer.truncDivision(matrixSize, 2);\n            for (var i = 0; i < origCenter; i++) {\n                var newOffset = i + Integer.truncDivision(i, 15);\n                alignmentMap[origCenter - i - 1] = center - newOffset - 1;\n                alignmentMap[origCenter + i] = center + newOffset + 1;\n            }\n        }\n        for (var i = 0, rowOffset = 0; i < layers; i++) {\n            var rowSize = (layers - i) * 4 + (compact ? 9 : 12);\n            // The top-left most point of this layer is <low, low> (not including alignment lines)\n            var low = i * 2;\n            // The bottom-right most point of this layer is <high, high> (not including alignment lines)\n            var high = baseMatrixSize - 1 - low;\n            // We pull bits from the two 2 x rowSize columns and two rowSize x 2 rows\n            for (var j = 0; j < rowSize; j++) {\n                var columnOffset = j * 2;\n                for (var k = 0; k < 2; k++) {\n                    // left column\n                    rawbits[rowOffset + columnOffset + k] =\n                        matrix.get(alignmentMap[low + k], alignmentMap[low + j]);\n                    // bottom row\n                    rawbits[rowOffset + 2 * rowSize + columnOffset + k] =\n                        matrix.get(alignmentMap[low + j], alignmentMap[high - k]);\n                    // right column\n                    rawbits[rowOffset + 4 * rowSize + columnOffset + k] =\n                        matrix.get(alignmentMap[high - k], alignmentMap[high - j]);\n                    // top row\n                    rawbits[rowOffset + 6 * rowSize + columnOffset + k] =\n                        matrix.get(alignmentMap[high - j], alignmentMap[low + k]);\n                }\n            }\n            rowOffset += rowSize * 8;\n        }\n        return rawbits;\n    };\n    /**\n     * Reads a code of given length and at given index in an array of bits\n     */\n    Decoder.readCode = function (rawbits, startIndex, length) {\n        var res = 0;\n        for (var i = startIndex; i < startIndex + length; i++) {\n            res <<= 1;\n            if (rawbits[i]) {\n                res |= 0x01;\n            }\n        }\n        return res;\n    };\n    /**\n     * Reads a code of length 8 in an array of bits, padding with zeros\n     */\n    Decoder.readByte = function (rawbits, startIndex) {\n        var n = rawbits.length - startIndex;\n        if (n >= 8) {\n            return Decoder.readCode(rawbits, startIndex, 8);\n        }\n        return Decoder.readCode(rawbits, startIndex, n) << (8 - n);\n    };\n    /**\n     * Packs a bit array into bytes, most significant bit first\n     */\n    Decoder.convertBoolArrayToByteArray = function (boolArr) {\n        var byteArr = new Uint8Array((boolArr.length + 7) / 8);\n        for (var i = 0; i < byteArr.length; i++) {\n            byteArr[i] = Decoder.readByte(boolArr, 8 * i);\n        }\n        return byteArr;\n    };\n    Decoder.prototype.totalBitsInLayer = function (layers, compact) {\n        return ((compact ? 88 : 112) + 16 * layers) * layers;\n    };\n    Decoder.UPPER_TABLE = [\n        'CTRL_PS', ' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',\n        'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'CTRL_LL', 'CTRL_ML', 'CTRL_DL', 'CTRL_BS'\n    ];\n    Decoder.LOWER_TABLE = [\n        'CTRL_PS', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n        'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'CTRL_US', 'CTRL_ML', 'CTRL_DL', 'CTRL_BS'\n    ];\n    Decoder.MIXED_TABLE = [\n        // Module parse failed: Octal literal in strict mode (50:29)\n        // so number string were scaped\n        'CTRL_PS', ' ', '\\\\1', '\\\\2', '\\\\3', '\\\\4', '\\\\5', '\\\\6', '\\\\7', '\\b', '\\t', '\\n',\n        '\\\\13', '\\f', '\\r', '\\\\33', '\\\\34', '\\\\35', '\\\\36', '\\\\37', '@', '\\\\', '^', '_',\n        '`', '|', '~', '\\\\177', 'CTRL_LL', 'CTRL_UL', 'CTRL_PL', 'CTRL_BS'\n    ];\n    Decoder.PUNCT_TABLE = [\n        '', '\\r', '\\r\\n', '. ', ', ', ': ', '!', '\"', '#', '$', '%', '&', '\\'', '(', ')',\n        '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '{', '}', 'CTRL_UL'\n    ];\n    Decoder.DIGIT_TABLE = [\n        'CTRL_PS', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ',', '.', 'CTRL_UL', 'CTRL_US'\n    ];\n    return Decoder;\n}());\nexport default Decoder;\n","/*\n * Copyright 2010 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport ResultPoint from '../../ResultPoint';\nimport AztecDetectorResult from '../AztecDetectorResult';\nimport MathUtils from '../../common/detector/MathUtils';\nimport WhiteRectangleDetector from '../../common/detector/WhiteRectangleDetector';\nimport GenericGF from '../../common/reedsolomon/GenericGF';\nimport ReedSolomonDecoder from '../../common/reedsolomon/ReedSolomonDecoder';\nimport NotFoundException from '../../NotFoundException';\nimport GridSamplerInstance from '../../common/GridSamplerInstance';\nimport Integer from '../../util/Integer';\nvar Point = /** @class */ (function () {\n    function Point(x, y) {\n        this.x = x;\n        this.y = y;\n    }\n    Point.prototype.toResultPoint = function () {\n        return new ResultPoint(this.getX(), this.getY());\n    };\n    Point.prototype.getX = function () {\n        return this.x;\n    };\n    Point.prototype.getY = function () {\n        return this.y;\n    };\n    return Point;\n}());\nexport { Point };\n/**\n * Encapsulates logic that can detect an Aztec Code in an image, even if the Aztec Code\n * is rotated or skewed, or partially obscured.\n *\n * @author David Olivier\n * @author Frank Yellin\n */\nvar Detector = /** @class */ (function () {\n    function Detector(image) {\n        this.EXPECTED_CORNER_BITS = new Int32Array([\n            0xee0,\n            0x1dc,\n            0x83b,\n            0x707,\n        ]);\n        this.image = image;\n    }\n    Detector.prototype.detect = function () {\n        return this.detectMirror(false);\n    };\n    /**\n     * Detects an Aztec Code in an image.\n     *\n     * @param isMirror if true, image is a mirror-image of original\n     * @return {@link AztecDetectorResult} encapsulating results of detecting an Aztec Code\n     * @throws NotFoundException if no Aztec Code can be found\n     */\n    Detector.prototype.detectMirror = function (isMirror) {\n        // 1. Get the center of the aztec matrix\n        var pCenter = this.getMatrixCenter();\n        // 2. Get the center points of the four diagonal points just outside the bull's eye\n        //  [topRight, bottomRight, bottomLeft, topLeft]\n        var bullsEyeCorners = this.getBullsEyeCorners(pCenter);\n        if (isMirror) {\n            var temp = bullsEyeCorners[0];\n            bullsEyeCorners[0] = bullsEyeCorners[2];\n            bullsEyeCorners[2] = temp;\n        }\n        // 3. Get the size of the matrix and other parameters from the bull's eye\n        this.extractParameters(bullsEyeCorners);\n        // 4. Sample the grid\n        var bits = this.sampleGrid(this.image, bullsEyeCorners[this.shift % 4], bullsEyeCorners[(this.shift + 1) % 4], bullsEyeCorners[(this.shift + 2) % 4], bullsEyeCorners[(this.shift + 3) % 4]);\n        // 5. Get the corners of the matrix.\n        var corners = this.getMatrixCornerPoints(bullsEyeCorners);\n        return new AztecDetectorResult(bits, corners, this.compact, this.nbDataBlocks, this.nbLayers);\n    };\n    /**\n     * Extracts the number of data layers and data blocks from the layer around the bull's eye.\n     *\n     * @param bullsEyeCorners the array of bull's eye corners\n     * @throws NotFoundException in case of too many errors or invalid parameters\n     */\n    Detector.prototype.extractParameters = function (bullsEyeCorners) {\n        if (!this.isValidPoint(bullsEyeCorners[0]) || !this.isValidPoint(bullsEyeCorners[1]) ||\n            !this.isValidPoint(bullsEyeCorners[2]) || !this.isValidPoint(bullsEyeCorners[3])) {\n            throw new NotFoundException();\n        }\n        var length = 2 * this.nbCenterLayers;\n        // Get the bits around the bull's eye\n        var sides = new Int32Array([\n            this.sampleLine(bullsEyeCorners[0], bullsEyeCorners[1], length),\n            this.sampleLine(bullsEyeCorners[1], bullsEyeCorners[2], length),\n            this.sampleLine(bullsEyeCorners[2], bullsEyeCorners[3], length),\n            this.sampleLine(bullsEyeCorners[3], bullsEyeCorners[0], length) // Top\n        ]);\n        // bullsEyeCorners[shift] is the corner of the bulls'eye that has three\n        // orientation marks.\n        // sides[shift] is the row/column that goes from the corner with three\n        // orientation marks to the corner with two.\n        this.shift = this.getRotation(sides, length);\n        // Flatten the parameter bits into a single 28- or 40-bit long\n        var parameterData = 0;\n        for (var i = 0; i < 4; i++) {\n            var side = sides[(this.shift + i) % 4];\n            if (this.compact) {\n                // Each side of the form ..XXXXXXX. where Xs are parameter data\n                parameterData <<= 7;\n                parameterData += (side >> 1) & 0x7F;\n            }\n            else {\n                // Each side of the form ..XXXXX.XXXXX. where Xs are parameter data\n                parameterData <<= 10;\n                parameterData += ((side >> 2) & (0x1f << 5)) + ((side >> 1) & 0x1F);\n            }\n        }\n        // Corrects parameter data using RS.  Returns just the data portion\n        // without the error correction.\n        var correctedData = this.getCorrectedParameterData(parameterData, this.compact);\n        if (this.compact) {\n            // 8 bits:  2 bits layers and 6 bits data blocks\n            this.nbLayers = (correctedData >> 6) + 1;\n            this.nbDataBlocks = (correctedData & 0x3F) + 1;\n        }\n        else {\n            // 16 bits:  5 bits layers and 11 bits data blocks\n            this.nbLayers = (correctedData >> 11) + 1;\n            this.nbDataBlocks = (correctedData & 0x7FF) + 1;\n        }\n    };\n    Detector.prototype.getRotation = function (sides, length) {\n        // In a normal pattern, we expect to See\n        //   **    .*             D       A\n        //   *      *\n        //\n        //   .      *\n        //   ..    ..             C       B\n        //\n        // Grab the 3 bits from each of the sides the form the locator pattern and concatenate\n        // into a 12-bit integer.  Start with the bit at A\n        var cornerBits = 0;\n        sides.forEach(function (side, idx, arr) {\n            // XX......X where X's are orientation marks\n            var t = ((side >> (length - 2)) << 1) + (side & 1);\n            cornerBits = (cornerBits << 3) + t;\n        });\n        // for (var side in sides) {\n        //     // XX......X where X's are orientation marks\n        //     var t = ((side >> (length - 2)) << 1) + (side & 1);\n        //     cornerBits = (cornerBits << 3) + t;\n        // }\n        // Mov the bottom bit to the top, so that the three bits of the locator pattern at A are\n        // together.  cornerBits is now:\n        //  3 orientation bits at A || 3 orientation bits at B || ... || 3 orientation bits at D\n        cornerBits = ((cornerBits & 1) << 11) + (cornerBits >> 1);\n        // The result shift indicates which element of BullsEyeCorners[] goes into the top-left\n        // corner. Since the four rotation values have a Hamming distance of 8, we\n        // can easily tolerate two errors.\n        for (var shift = 0; shift < 4; shift++) {\n            if (Integer.bitCount(cornerBits ^ this.EXPECTED_CORNER_BITS[shift]) <= 2) {\n                return shift;\n            }\n        }\n        throw new NotFoundException();\n    };\n    /**\n     * Corrects the parameter bits using Reed-Solomon algorithm.\n     *\n     * @param parameterData parameter bits\n     * @param compact true if this is a compact Aztec code\n     * @throws NotFoundException if the array contains too many errors\n     */\n    Detector.prototype.getCorrectedParameterData = function (parameterData, compact) {\n        var numCodewords;\n        var numDataCodewords;\n        if (compact) {\n            numCodewords = 7;\n            numDataCodewords = 2;\n        }\n        else {\n            numCodewords = 10;\n            numDataCodewords = 4;\n        }\n        var numECCodewords = numCodewords - numDataCodewords;\n        var parameterWords = new Int32Array(numCodewords);\n        for (var i = numCodewords - 1; i >= 0; --i) {\n            parameterWords[i] = parameterData & 0xF;\n            parameterData >>= 4;\n        }\n        try {\n            var rsDecoder = new ReedSolomonDecoder(GenericGF.AZTEC_PARAM);\n            rsDecoder.decode(parameterWords, numECCodewords);\n        }\n        catch (ignored) {\n            throw new NotFoundException();\n        }\n        // Toss the error correction.  Just return the data as an integer\n        var result = 0;\n        for (var i = 0; i < numDataCodewords; i++) {\n            result = (result << 4) + parameterWords[i];\n        }\n        return result;\n    };\n    /**\n     * Finds the corners of a bull-eye centered on the passed point.\n     * This returns the centers of the diagonal points just outside the bull's eye\n     * Returns [topRight, bottomRight, bottomLeft, topLeft]\n     *\n     * @param pCenter Center point\n     * @return The corners of the bull-eye\n     * @throws NotFoundException If no valid bull-eye can be found\n     */\n    Detector.prototype.getBullsEyeCorners = function (pCenter) {\n        var pina = pCenter;\n        var pinb = pCenter;\n        var pinc = pCenter;\n        var pind = pCenter;\n        var color = true;\n        for (this.nbCenterLayers = 1; this.nbCenterLayers < 9; this.nbCenterLayers++) {\n            var pouta = this.getFirstDifferent(pina, color, 1, -1);\n            var poutb = this.getFirstDifferent(pinb, color, 1, 1);\n            var poutc = this.getFirstDifferent(pinc, color, -1, 1);\n            var poutd = this.getFirstDifferent(pind, color, -1, -1);\n            // d      a\n            //\n            // c      b\n            if (this.nbCenterLayers > 2) {\n                var q = (this.distancePoint(poutd, pouta) * this.nbCenterLayers) / (this.distancePoint(pind, pina) * (this.nbCenterLayers + 2));\n                if (q < 0.75 || q > 1.25 || !this.isWhiteOrBlackRectangle(pouta, poutb, poutc, poutd)) {\n                    break;\n                }\n            }\n            pina = pouta;\n            pinb = poutb;\n            pinc = poutc;\n            pind = poutd;\n            color = !color;\n        }\n        if (this.nbCenterLayers !== 5 && this.nbCenterLayers !== 7) {\n            throw new NotFoundException();\n        }\n        this.compact = this.nbCenterLayers === 5;\n        // Expand the square by .5 pixel in each direction so that we're on the border\n        // between the white square and the black square\n        var pinax = new ResultPoint(pina.getX() + 0.5, pina.getY() - 0.5);\n        var pinbx = new ResultPoint(pinb.getX() + 0.5, pinb.getY() + 0.5);\n        var pincx = new ResultPoint(pinc.getX() - 0.5, pinc.getY() + 0.5);\n        var pindx = new ResultPoint(pind.getX() - 0.5, pind.getY() - 0.5);\n        // Expand the square so that its corners are the centers of the points\n        // just outside the bull's eye.\n        return this.expandSquare([pinax, pinbx, pincx, pindx], 2 * this.nbCenterLayers - 3, 2 * this.nbCenterLayers);\n    };\n    /**\n     * Finds a candidate center point of an Aztec code from an image\n     *\n     * @return the center point\n     */\n    Detector.prototype.getMatrixCenter = function () {\n        var pointA;\n        var pointB;\n        var pointC;\n        var pointD;\n        // Get a white rectangle that can be the border of the matrix in center bull's eye or\n        try {\n            var cornerPoints = new WhiteRectangleDetector(this.image).detect();\n            pointA = cornerPoints[0];\n            pointB = cornerPoints[1];\n            pointC = cornerPoints[2];\n            pointD = cornerPoints[3];\n        }\n        catch (e) {\n            // This exception can be in case the initial rectangle is white\n            // In that case, surely in the bull's eye, we try to expand the rectangle.\n            var cx_1 = this.image.getWidth() / 2;\n            var cy_1 = this.image.getHeight() / 2;\n            pointA = this.getFirstDifferent(new Point(cx_1 + 7, cy_1 - 7), false, 1, -1).toResultPoint();\n            pointB = this.getFirstDifferent(new Point(cx_1 + 7, cy_1 + 7), false, 1, 1).toResultPoint();\n            pointC = this.getFirstDifferent(new Point(cx_1 - 7, cy_1 + 7), false, -1, 1).toResultPoint();\n            pointD = this.getFirstDifferent(new Point(cx_1 - 7, cy_1 - 7), false, -1, -1).toResultPoint();\n        }\n        // Compute the center of the rectangle\n        var cx = MathUtils.round((pointA.getX() + pointD.getX() + pointB.getX() + pointC.getX()) / 4.0);\n        var cy = MathUtils.round((pointA.getY() + pointD.getY() + pointB.getY() + pointC.getY()) / 4.0);\n        // Redetermine the white rectangle starting from previously computed center.\n        // This will ensure that we end up with a white rectangle in center bull's eye\n        // in order to compute a more accurate center.\n        try {\n            var cornerPoints = new WhiteRectangleDetector(this.image, 15, cx, cy).detect();\n            pointA = cornerPoints[0];\n            pointB = cornerPoints[1];\n            pointC = cornerPoints[2];\n            pointD = cornerPoints[3];\n        }\n        catch (e) {\n            // This exception can be in case the initial rectangle is white\n            // In that case we try to expand the rectangle.\n            pointA = this.getFirstDifferent(new Point(cx + 7, cy - 7), false, 1, -1).toResultPoint();\n            pointB = this.getFirstDifferent(new Point(cx + 7, cy + 7), false, 1, 1).toResultPoint();\n            pointC = this.getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toResultPoint();\n            pointD = this.getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toResultPoint();\n        }\n        // Recompute the center of the rectangle\n        cx = MathUtils.round((pointA.getX() + pointD.getX() + pointB.getX() + pointC.getX()) / 4.0);\n        cy = MathUtils.round((pointA.getY() + pointD.getY() + pointB.getY() + pointC.getY()) / 4.0);\n        return new Point(cx, cy);\n    };\n    /**\n     * Gets the Aztec code corners from the bull's eye corners and the parameters.\n     *\n     * @param bullsEyeCorners the array of bull's eye corners\n     * @return the array of aztec code corners\n     */\n    Detector.prototype.getMatrixCornerPoints = function (bullsEyeCorners) {\n        return this.expandSquare(bullsEyeCorners, 2 * this.nbCenterLayers, this.getDimension());\n    };\n    /**\n     * Creates a BitMatrix by sampling the provided image.\n     * topLeft, topRight, bottomRight, and bottomLeft are the centers of the squares on the\n     * diagonal just outside the bull's eye.\n     */\n    Detector.prototype.sampleGrid = function (image, topLeft, topRight, bottomRight, bottomLeft) {\n        var sampler = GridSamplerInstance.getInstance();\n        var dimension = this.getDimension();\n        var low = dimension / 2 - this.nbCenterLayers;\n        var high = dimension / 2 + this.nbCenterLayers;\n        return sampler.sampleGrid(image, dimension, dimension, low, low, // topleft\n        high, low, // topright\n        high, high, // bottomright\n        low, high, // bottomleft\n        topLeft.getX(), topLeft.getY(), topRight.getX(), topRight.getY(), bottomRight.getX(), bottomRight.getY(), bottomLeft.getX(), bottomLeft.getY());\n    };\n    /**\n     * Samples a line.\n     *\n     * @param p1   start point (inclusive)\n     * @param p2   end point (exclusive)\n     * @param size number of bits\n     * @return the array of bits as an int (first bit is high-order bit of result)\n     */\n    Detector.prototype.sampleLine = function (p1, p2, size) {\n        var result = 0;\n        var d = this.distanceResultPoint(p1, p2);\n        var moduleSize = d / size;\n        var px = p1.getX();\n        var py = p1.getY();\n        var dx = moduleSize * (p2.getX() - p1.getX()) / d;\n        var dy = moduleSize * (p2.getY() - p1.getY()) / d;\n        for (var i = 0; i < size; i++) {\n            if (this.image.get(MathUtils.round(px + i * dx), MathUtils.round(py + i * dy))) {\n                result |= 1 << (size - i - 1);\n            }\n        }\n        return result;\n    };\n    /**\n     * @return true if the border of the rectangle passed in parameter is compound of white points only\n     *         or black points only\n     */\n    Detector.prototype.isWhiteOrBlackRectangle = function (p1, p2, p3, p4) {\n        var corr = 3;\n        p1 = new Point(p1.getX() - corr, p1.getY() + corr);\n        p2 = new Point(p2.getX() - corr, p2.getY() - corr);\n        p3 = new Point(p3.getX() + corr, p3.getY() - corr);\n        p4 = new Point(p4.getX() + corr, p4.getY() + corr);\n        var cInit = this.getColor(p4, p1);\n        if (cInit === 0) {\n            return false;\n        }\n        var c = this.getColor(p1, p2);\n        if (c !== cInit) {\n            return false;\n        }\n        c = this.getColor(p2, p3);\n        if (c !== cInit) {\n            return false;\n        }\n        c = this.getColor(p3, p4);\n        return c === cInit;\n    };\n    /**\n     * Gets the color of a segment\n     *\n     * @return 1 if segment more than 90% black, -1 if segment is more than 90% white, 0 else\n     */\n    Detector.prototype.getColor = function (p1, p2) {\n        var d = this.distancePoint(p1, p2);\n        var dx = (p2.getX() - p1.getX()) / d;\n        var dy = (p2.getY() - p1.getY()) / d;\n        var error = 0;\n        var px = p1.getX();\n        var py = p1.getY();\n        var colorModel = this.image.get(p1.getX(), p1.getY());\n        var iMax = Math.ceil(d);\n        for (var i = 0; i < iMax; i++) {\n            px += dx;\n            py += dy;\n            if (this.image.get(MathUtils.round(px), MathUtils.round(py)) !== colorModel) {\n                error++;\n            }\n        }\n        var errRatio = error / d;\n        if (errRatio > 0.1 && errRatio < 0.9) {\n            return 0;\n        }\n        return (errRatio <= 0.1) === colorModel ? 1 : -1;\n    };\n    /**\n     * Gets the coordinate of the first point with a different color in the given direction\n     */\n    Detector.prototype.getFirstDifferent = function (init, color, dx, dy) {\n        var x = init.getX() + dx;\n        var y = init.getY() + dy;\n        while (this.isValid(x, y) && this.image.get(x, y) === color) {\n            x += dx;\n            y += dy;\n        }\n        x -= dx;\n        y -= dy;\n        while (this.isValid(x, y) && this.image.get(x, y) === color) {\n            x += dx;\n        }\n        x -= dx;\n        while (this.isValid(x, y) && this.image.get(x, y) === color) {\n            y += dy;\n        }\n        y -= dy;\n        return new Point(x, y);\n    };\n    /**\n     * Expand the square represented by the corner points by pushing out equally in all directions\n     *\n     * @param cornerPoints the corners of the square, which has the bull's eye at its center\n     * @param oldSide the original length of the side of the square in the target bit matrix\n     * @param newSide the new length of the size of the square in the target bit matrix\n     * @return the corners of the expanded square\n     */\n    Detector.prototype.expandSquare = function (cornerPoints, oldSide, newSide) {\n        var ratio = newSide / (2.0 * oldSide);\n        var dx = cornerPoints[0].getX() - cornerPoints[2].getX();\n        var dy = cornerPoints[0].getY() - cornerPoints[2].getY();\n        var centerx = (cornerPoints[0].getX() + cornerPoints[2].getX()) / 2.0;\n        var centery = (cornerPoints[0].getY() + cornerPoints[2].getY()) / 2.0;\n        var result0 = new ResultPoint(centerx + ratio * dx, centery + ratio * dy);\n        var result2 = new ResultPoint(centerx - ratio * dx, centery - ratio * dy);\n        dx = cornerPoints[1].getX() - cornerPoints[3].getX();\n        dy = cornerPoints[1].getY() - cornerPoints[3].getY();\n        centerx = (cornerPoints[1].getX() + cornerPoints[3].getX()) / 2.0;\n        centery = (cornerPoints[1].getY() + cornerPoints[3].getY()) / 2.0;\n        var result1 = new ResultPoint(centerx + ratio * dx, centery + ratio * dy);\n        var result3 = new ResultPoint(centerx - ratio * dx, centery - ratio * dy);\n        var results = [result0, result1, result2, result3];\n        return results;\n    };\n    Detector.prototype.isValid = function (x, y) {\n        return x >= 0 && x < this.image.getWidth() && y > 0 && y < this.image.getHeight();\n    };\n    Detector.prototype.isValidPoint = function (point) {\n        var x = MathUtils.round(point.getX());\n        var y = MathUtils.round(point.getY());\n        return this.isValid(x, y);\n    };\n    Detector.prototype.distancePoint = function (a, b) {\n        return MathUtils.distance(a.getX(), a.getY(), b.getX(), b.getY());\n    };\n    Detector.prototype.distanceResultPoint = function (a, b) {\n        return MathUtils.distance(a.getX(), a.getY(), b.getX(), b.getY());\n    };\n    Detector.prototype.getDimension = function () {\n        if (this.compact) {\n            return 4 * this.nbLayers + 11;\n        }\n        if (this.nbLayers <= 4) {\n            return 4 * this.nbLayers + 15;\n        }\n        return 4 * this.nbLayers + 2 * (Integer.truncDivision((this.nbLayers - 4), 8) + 1) + 15;\n    };\n    return Detector;\n}());\nexport default Detector;\n","/*\n* Copyright 2013 ZXing authors\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n*      http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n/**\n * Aztec 2D code representation\n *\n * @author Rustam Abdullaev\n */\nvar AztecCode = /** @class */ (function () {\n    function AztecCode() {\n    }\n    /**\n     * @return {@code true} if compact instead of full mode\n     */\n    AztecCode.prototype.isCompact = function () {\n        return this.compact;\n    };\n    AztecCode.prototype.setCompact = function (compact) {\n        this.compact = compact;\n    };\n    /**\n     * @return size in pixels (width and height)\n     */\n    AztecCode.prototype.getSize = function () {\n        return this.size;\n    };\n    AztecCode.prototype.setSize = function (size) {\n        this.size = size;\n    };\n    /**\n     * @return number of levels\n     */\n    AztecCode.prototype.getLayers = function () {\n        return this.layers;\n    };\n    AztecCode.prototype.setLayers = function (layers) {\n        this.layers = layers;\n    };\n    /**\n     * @return number of data codewords\n     */\n    AztecCode.prototype.getCodeWords = function () {\n        return this.codeWords;\n    };\n    AztecCode.prototype.setCodeWords = function (codeWords) {\n        this.codeWords = codeWords;\n    };\n    /**\n     * @return the symbol image\n     */\n    AztecCode.prototype.getMatrix = function () {\n        return this.matrix;\n    };\n    AztecCode.prototype.setMatrix = function (matrix) {\n        this.matrix = matrix;\n    };\n    return AztecCode;\n}());\nexport default AztecCode;\n","var __values = (this && this.__values) || function(o) {\n    var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n    if (m) return m.call(o);\n    if (o && typeof o.length === \"number\") return {\n        next: function () {\n            if (o && i >= o.length) o = void 0;\n            return { value: o && o[i++], done: !o };\n        }\n    };\n    throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n};\nimport BitArray from '../../common/BitArray';\nimport IllegalArgumentException from '../../IllegalArgumentException';\nimport StringUtils from '../../common/StringUtils';\nimport BitMatrix from '../../common/BitMatrix';\nimport AztecCode from './AztecCode';\nimport ReedSolomonEncoder from '../../common/reedsolomon/ReedSolomonEncoder';\nimport GenericGF from '../../common/reedsolomon/GenericGF';\nimport HighLevelEncoder from './HighLevelEncoder';\nimport Integer from '../../util/Integer';\n/*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// package com.google.zxing.aztec.encoder;\n// import com.google.zxing.common.BitArray;\n// import com.google.zxing.common.BitMatrix;\n// import com.google.zxing.common.reedsolomon.GenericGF;\n// import com.google.zxing.common.reedsolomon.ReedSolomonEncoder;\n/**\n * Generates Aztec 2D barcodes.\n *\n * @author Rustam Abdullaev\n */\nvar Encoder = /** @class */ (function () {\n    function Encoder() {\n    }\n    /**\n     * Encodes the given binary content as an Aztec symbol\n     *\n     * @param data input data string\n     * @return Aztec symbol matrix with metadata\n     */\n    Encoder.encodeBytes = function (data) {\n        return Encoder.encode(data, Encoder.DEFAULT_EC_PERCENT, Encoder.DEFAULT_AZTEC_LAYERS);\n    };\n    /**\n     * Encodes the given binary content as an Aztec symbol\n     *\n     * @param data input data string\n     * @param minECCPercent minimal percentage of error check words (According to ISO/IEC 24778:2008,\n     *                      a minimum of 23% + 3 words is recommended)\n     * @param userSpecifiedLayers if non-zero, a user-specified value for the number of layers\n     * @return Aztec symbol matrix with metadata\n     */\n    Encoder.encode = function (data, minECCPercent, userSpecifiedLayers) {\n        // High-level encode\n        var bits = new HighLevelEncoder(data).encode();\n        // stuff bits and choose symbol size\n        var eccBits = Integer.truncDivision((bits.getSize() * minECCPercent), 100) + 11;\n        var totalSizeBits = bits.getSize() + eccBits;\n        var compact;\n        var layers;\n        var totalBitsInLayer;\n        var wordSize;\n        var stuffedBits;\n        if (userSpecifiedLayers !== Encoder.DEFAULT_AZTEC_LAYERS) {\n            compact = userSpecifiedLayers < 0;\n            layers = Math.abs(userSpecifiedLayers);\n            if (layers > (compact ? Encoder.MAX_NB_BITS_COMPACT : Encoder.MAX_NB_BITS)) {\n                throw new IllegalArgumentException(StringUtils.format('Illegal value %s for layers', userSpecifiedLayers));\n            }\n            totalBitsInLayer = Encoder.totalBitsInLayer(layers, compact);\n            wordSize = Encoder.WORD_SIZE[layers];\n            var usableBitsInLayers = totalBitsInLayer - (totalBitsInLayer % wordSize);\n            stuffedBits = Encoder.stuffBits(bits, wordSize);\n            if (stuffedBits.getSize() + eccBits > usableBitsInLayers) {\n                throw new IllegalArgumentException('Data to large for user specified layer');\n            }\n            if (compact && stuffedBits.getSize() > wordSize * 64) {\n                // Compact format only allows 64 data words, though C4 can hold more words than that\n                throw new IllegalArgumentException('Data to large for user specified layer');\n            }\n        }\n        else {\n            wordSize = 0;\n            stuffedBits = null;\n            // We look at the possible table sizes in the order Compact1, Compact2, Compact3,\n            // Compact4, Normal4,...  Normal(i) for i < 4 isn't typically used since Compact(i+1)\n            // is the same size, but has more data.\n            for (var i /*int*/ = 0;; i++) {\n                if (i > Encoder.MAX_NB_BITS) {\n                    throw new IllegalArgumentException('Data too large for an Aztec code');\n                }\n                compact = i <= 3;\n                layers = compact ? i + 1 : i;\n                totalBitsInLayer = Encoder.totalBitsInLayer(layers, compact);\n                if (totalSizeBits > totalBitsInLayer) {\n                    continue;\n                }\n                // [Re]stuff the bits if this is the first opportunity, or if the\n                // wordSize has changed\n                if (stuffedBits == null || wordSize !== Encoder.WORD_SIZE[layers]) {\n                    wordSize = Encoder.WORD_SIZE[layers];\n                    stuffedBits = Encoder.stuffBits(bits, wordSize);\n                }\n                var usableBitsInLayers = totalBitsInLayer - (totalBitsInLayer % wordSize);\n                if (compact && stuffedBits.getSize() > wordSize * 64) {\n                    // Compact format only allows 64 data words, though C4 can hold more words than that\n                    continue;\n                }\n                if (stuffedBits.getSize() + eccBits <= usableBitsInLayers) {\n                    break;\n                }\n            }\n        }\n        var messageBits = Encoder.generateCheckWords(stuffedBits, totalBitsInLayer, wordSize);\n        // generate mode message\n        var messageSizeInWords = stuffedBits.getSize() / wordSize;\n        var modeMessage = Encoder.generateModeMessage(compact, layers, messageSizeInWords);\n        // allocate symbol\n        var baseMatrixSize = (compact ? 11 : 14) + layers * 4; // not including alignment lines\n        var alignmentMap = new Int32Array(baseMatrixSize);\n        var matrixSize;\n        if (compact) {\n            // no alignment marks in compact mode, alignmentMap is a no-op\n            matrixSize = baseMatrixSize;\n            for (var i /*int*/ = 0; i < alignmentMap.length; i++) {\n                alignmentMap[i] = i;\n            }\n        }\n        else {\n            matrixSize = baseMatrixSize + 1 + 2 * Integer.truncDivision((Integer.truncDivision(baseMatrixSize, 2) - 1), 15);\n            var origCenter = Integer.truncDivision(baseMatrixSize, 2);\n            var center = Integer.truncDivision(matrixSize, 2);\n            for (var i /*int*/ = 0; i < origCenter; i++) {\n                var newOffset = i + Integer.truncDivision(i, 15);\n                alignmentMap[origCenter - i - 1] = center - newOffset - 1;\n                alignmentMap[origCenter + i] = center + newOffset + 1;\n            }\n        }\n        var matrix = new BitMatrix(matrixSize);\n        // draw data bits\n        for (var i /*int*/ = 0, rowOffset = 0; i < layers; i++) {\n            var rowSize = (layers - i) * 4 + (compact ? 9 : 12);\n            for (var j /*int*/ = 0; j < rowSize; j++) {\n                var columnOffset = j * 2;\n                for (var k /*int*/ = 0; k < 2; k++) {\n                    if (messageBits.get(rowOffset + columnOffset + k)) {\n                        matrix.set(alignmentMap[i * 2 + k], alignmentMap[i * 2 + j]);\n                    }\n                    if (messageBits.get(rowOffset + rowSize * 2 + columnOffset + k)) {\n                        matrix.set(alignmentMap[i * 2 + j], alignmentMap[baseMatrixSize - 1 - i * 2 - k]);\n                    }\n                    if (messageBits.get(rowOffset + rowSize * 4 + columnOffset + k)) {\n                        matrix.set(alignmentMap[baseMatrixSize - 1 - i * 2 - k], alignmentMap[baseMatrixSize - 1 - i * 2 - j]);\n                    }\n                    if (messageBits.get(rowOffset + rowSize * 6 + columnOffset + k)) {\n                        matrix.set(alignmentMap[baseMatrixSize - 1 - i * 2 - j], alignmentMap[i * 2 + k]);\n                    }\n                }\n            }\n            rowOffset += rowSize * 8;\n        }\n        // draw mode message\n        Encoder.drawModeMessage(matrix, compact, matrixSize, modeMessage);\n        // draw alignment marks\n        if (compact) {\n            Encoder.drawBullsEye(matrix, Integer.truncDivision(matrixSize, 2), 5);\n        }\n        else {\n            Encoder.drawBullsEye(matrix, Integer.truncDivision(matrixSize, 2), 7);\n            for (var i /*int*/ = 0, j = 0; i < Integer.truncDivision(baseMatrixSize, 2) - 1; i += 15, j += 16) {\n                for (var k /*int*/ = Integer.truncDivision(matrixSize, 2) & 1; k < matrixSize; k += 2) {\n                    matrix.set(Integer.truncDivision(matrixSize, 2) - j, k);\n                    matrix.set(Integer.truncDivision(matrixSize, 2) + j, k);\n                    matrix.set(k, Integer.truncDivision(matrixSize, 2) - j);\n                    matrix.set(k, Integer.truncDivision(matrixSize, 2) + j);\n                }\n            }\n        }\n        var aztec = new AztecCode();\n        aztec.setCompact(compact);\n        aztec.setSize(matrixSize);\n        aztec.setLayers(layers);\n        aztec.setCodeWords(messageSizeInWords);\n        aztec.setMatrix(matrix);\n        return aztec;\n    };\n    Encoder.drawBullsEye = function (matrix, center, size) {\n        for (var i /*int*/ = 0; i < size; i += 2) {\n            for (var j /*int*/ = center - i; j <= center + i; j++) {\n                matrix.set(j, center - i);\n                matrix.set(j, center + i);\n                matrix.set(center - i, j);\n                matrix.set(center + i, j);\n            }\n        }\n        matrix.set(center - size, center - size);\n        matrix.set(center - size + 1, center - size);\n        matrix.set(center - size, center - size + 1);\n        matrix.set(center + size, center - size);\n        matrix.set(center + size, center - size + 1);\n        matrix.set(center + size, center + size - 1);\n    };\n    Encoder.generateModeMessage = function (compact, layers, messageSizeInWords) {\n        var modeMessage = new BitArray();\n        if (compact) {\n            modeMessage.appendBits(layers - 1, 2);\n            modeMessage.appendBits(messageSizeInWords - 1, 6);\n            modeMessage = Encoder.generateCheckWords(modeMessage, 28, 4);\n        }\n        else {\n            modeMessage.appendBits(layers - 1, 5);\n            modeMessage.appendBits(messageSizeInWords - 1, 11);\n            modeMessage = Encoder.generateCheckWords(modeMessage, 40, 4);\n        }\n        return modeMessage;\n    };\n    Encoder.drawModeMessage = function (matrix, compact, matrixSize, modeMessage) {\n        var center = Integer.truncDivision(matrixSize, 2);\n        if (compact) {\n            for (var i /*int*/ = 0; i < 7; i++) {\n                var offset = center - 3 + i;\n                if (modeMessage.get(i)) {\n                    matrix.set(offset, center - 5);\n                }\n                if (modeMessage.get(i + 7)) {\n                    matrix.set(center + 5, offset);\n                }\n                if (modeMessage.get(20 - i)) {\n                    matrix.set(offset, center + 5);\n                }\n                if (modeMessage.get(27 - i)) {\n                    matrix.set(center - 5, offset);\n                }\n            }\n        }\n        else {\n            for (var i /*int*/ = 0; i < 10; i++) {\n                var offset = center - 5 + i + Integer.truncDivision(i, 5);\n                if (modeMessage.get(i)) {\n                    matrix.set(offset, center - 7);\n                }\n                if (modeMessage.get(i + 10)) {\n                    matrix.set(center + 7, offset);\n                }\n                if (modeMessage.get(29 - i)) {\n                    matrix.set(offset, center + 7);\n                }\n                if (modeMessage.get(39 - i)) {\n                    matrix.set(center - 7, offset);\n                }\n            }\n        }\n    };\n    Encoder.generateCheckWords = function (bitArray, totalBits, wordSize) {\n        var e_1, _a;\n        // bitArray is guaranteed to be a multiple of the wordSize, so no padding needed\n        var messageSizeInWords = bitArray.getSize() / wordSize;\n        var rs = new ReedSolomonEncoder(Encoder.getGF(wordSize));\n        var totalWords = Integer.truncDivision(totalBits, wordSize);\n        var messageWords = Encoder.bitsToWords(bitArray, wordSize, totalWords);\n        rs.encode(messageWords, totalWords - messageSizeInWords);\n        var startPad = totalBits % wordSize;\n        var messageBits = new BitArray();\n        messageBits.appendBits(0, startPad);\n        try {\n            for (var _b = __values(Array.from(messageWords)), _c = _b.next(); !_c.done; _c = _b.next()) {\n                var messageWord = _c.value /*: int*/;\n                messageBits.appendBits(messageWord, wordSize);\n            }\n        }\n        catch (e_1_1) { e_1 = { error: e_1_1 }; }\n        finally {\n            try {\n                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);\n            }\n            finally { if (e_1) throw e_1.error; }\n        }\n        return messageBits;\n    };\n    Encoder.bitsToWords = function (stuffedBits, wordSize, totalWords) {\n        var message = new Int32Array(totalWords);\n        var i;\n        var n;\n        for (i = 0, n = stuffedBits.getSize() / wordSize; i < n; i++) {\n            var value = 0;\n            for (var j /*int*/ = 0; j < wordSize; j++) {\n                value |= stuffedBits.get(i * wordSize + j) ? (1 << wordSize - j - 1) : 0;\n            }\n            message[i] = value;\n        }\n        return message;\n    };\n    Encoder.getGF = function (wordSize) {\n        switch (wordSize) {\n            case 4:\n                return GenericGF.AZTEC_PARAM;\n            case 6:\n                return GenericGF.AZTEC_DATA_6;\n            case 8:\n                return GenericGF.AZTEC_DATA_8;\n            case 10:\n                return GenericGF.AZTEC_DATA_10;\n            case 12:\n                return GenericGF.AZTEC_DATA_12;\n            default:\n                throw new IllegalArgumentException('Unsupported word size ' + wordSize);\n        }\n    };\n    Encoder.stuffBits = function (bits, wordSize) {\n        var out = new BitArray();\n        var n = bits.getSize();\n        var mask = (1 << wordSize) - 2;\n        for (var i /*int*/ = 0; i < n; i += wordSize) {\n            var word = 0;\n            for (var j /*int*/ = 0; j < wordSize; j++) {\n                if (i + j >= n || bits.get(i + j)) {\n                    word |= 1 << (wordSize - 1 - j);\n                }\n            }\n            if ((word & mask) === mask) {\n                out.appendBits(word & mask, wordSize);\n                i--;\n            }\n            else if ((word & mask) === 0) {\n                out.appendBits(word | 1, wordSize);\n                i--;\n            }\n            else {\n                out.appendBits(word, wordSize);\n            }\n        }\n        return out;\n    };\n    Encoder.totalBitsInLayer = function (layers, compact) {\n        return ((compact ? 88 : 112) + 16 * layers) * layers;\n    };\n    Encoder.DEFAULT_EC_PERCENT = 33; // default minimal percentage of error check words\n    Encoder.DEFAULT_AZTEC_LAYERS = 0;\n    Encoder.MAX_NB_BITS = 32;\n    Encoder.MAX_NB_BITS_COMPACT = 4;\n    Encoder.WORD_SIZE = Int32Array.from([\n        4, 6, 6, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n        12, 12, 12, 12, 12, 12, 12, 12, 12, 12\n    ]);\n    return Encoder;\n}());\nexport default Encoder;\n","/*\n* Copyright 2013 ZXing authors\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n*      http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\nvar __extends = (this && this.__extends) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nimport Token from './Token';\nimport Integer from '../../util/Integer';\nvar SimpleToken = /** @class */ (function (_super) {\n    __extends(SimpleToken, _super);\n    function SimpleToken(previous, value, bitCount) {\n        var _this = _super.call(this, previous) || this;\n        _this.value = value;\n        _this.bitCount = bitCount;\n        return _this;\n    }\n    /**\n     * @Override\n     */\n    SimpleToken.prototype.appendTo = function (bitArray, text) {\n        bitArray.appendBits(this.value, this.bitCount);\n    };\n    SimpleToken.prototype.add = function (value, bitCount) {\n        return new SimpleToken(this, value, bitCount);\n    };\n    SimpleToken.prototype.addBinaryShift = function (start, byteCount) {\n        // no-op can't binary shift a simple token\n        console.warn('addBinaryShift on SimpleToken, this simply returns a copy of this token');\n        return new SimpleToken(this, start, byteCount);\n    };\n    /**\n     * @Override\n     */\n    SimpleToken.prototype.toString = function () {\n        var value = this.value & ((1 << this.bitCount) - 1);\n        value |= 1 << this.bitCount;\n        return '<' + Integer.toBinaryString(value | (1 << this.bitCount)).substring(1) + '>';\n    };\n    return SimpleToken;\n}(Token));\nexport default SimpleToken;\n","/*\n* Copyright 2013 ZXing authors\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n*      http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\nvar Token = /** @class */ (function () {\n    function Token(previous) {\n        this.previous = previous;\n    }\n    Token.prototype.getPrevious = function () {\n        return this.previous;\n    };\n    return Token;\n}());\nexport default Token;\n","/*\n* Copyright 2013 ZXing authors\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n*      http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\nvar __extends = (this && this.__extends) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nimport SimpleToken from './SimpleToken';\nvar BinaryShiftToken = /** @class */ (function (_super) {\n    __extends(BinaryShiftToken, _super);\n    function BinaryShiftToken(previous, binaryShiftStart, binaryShiftByteCount) {\n        var _this = _super.call(this, previous, 0, 0) || this;\n        _this.binaryShiftStart = binaryShiftStart;\n        _this.binaryShiftByteCount = binaryShiftByteCount;\n        return _this;\n    }\n    /**\n     * @Override\n     */\n    BinaryShiftToken.prototype.appendTo = function (bitArray, text) {\n        for (var i = 0; i < this.binaryShiftByteCount; i++) {\n            if (i === 0 || (i === 31 && this.binaryShiftByteCount <= 62)) {\n                // We need a header before the first character, and before\n                // character 31 when the total byte code is <= 62\n                bitArray.appendBits(31, 5); // BINARY_SHIFT\n                if (this.binaryShiftByteCount > 62) {\n                    bitArray.appendBits(this.binaryShiftByteCount - 31, 16);\n                }\n                else if (i === 0) {\n                    // 1 <= binaryShiftByteCode <= 62\n                    bitArray.appendBits(Math.min(this.binaryShiftByteCount, 31), 5);\n                }\n                else {\n                    // 32 <= binaryShiftCount <= 62 and i == 31\n                    bitArray.appendBits(this.binaryShiftByteCount - 31, 5);\n                }\n            }\n            bitArray.appendBits(text[this.binaryShiftStart + i], 8);\n        }\n    };\n    BinaryShiftToken.prototype.addBinaryShift = function (start, byteCount) {\n        // int bitCount = (byteCount * 8) + (byteCount <= 31 ? 10 : byteCount <= 62 ? 20 : 21);\n        return new BinaryShiftToken(this, start, byteCount);\n    };\n    /**\n     * @Override\n     */\n    BinaryShiftToken.prototype.toString = function () {\n        return '<' + this.binaryShiftStart + '::' + (this.binaryShiftStart + this.binaryShiftByteCount - 1) + '>';\n    };\n    return BinaryShiftToken;\n}(SimpleToken));\nexport default BinaryShiftToken;\n","import SimpleToken from './SimpleToken';\nimport BinaryShiftToken from './BinaryShiftToken';\nexport function addBinaryShift(token, start, byteCount) {\n    // int bitCount = (byteCount * 8) + (byteCount <= 31 ? 10 : byteCount <= 62 ? 20 : 21);\n    return new BinaryShiftToken(token, start, byteCount);\n}\nexport function add(token, value, bitCount) {\n    return new SimpleToken(token, value, bitCount);\n}\n","import SimpleToken from './SimpleToken';\nexport var /*final*/ MODE_NAMES = [\n    'UPPER',\n    'LOWER',\n    'DIGIT',\n    'MIXED',\n    'PUNCT'\n];\nexport var /*final*/ MODE_UPPER = 0; // 5 bits\nexport var /*final*/ MODE_LOWER = 1; // 5 bits\nexport var /*final*/ MODE_DIGIT = 2; // 4 bits\nexport var /*final*/ MODE_MIXED = 3; // 5 bits\nexport var /*final*/ MODE_PUNCT = 4; // 5 bits\nexport var EMPTY_TOKEN = new SimpleToken(null, 0, 0);\n","// The Latch Table shows, for each pair of Modes, the optimal method for\n// getting from one mode to another.  In the worst possible case, this can\n// be up to 14 bits.  In the best possible case, we are already there!\n// The high half-word of each entry gives the number of bits.\n// The low half-word of each entry are the actual bits necessary to change\nexport var LATCH_TABLE = [\n    Int32Array.from([\n        0,\n        (5 << 16) + 28,\n        (5 << 16) + 30,\n        (5 << 16) + 29,\n        (10 << 16) + (29 << 5) + 30 // UPPER -> MIXED -> PUNCT\n    ]),\n    Int32Array.from([\n        (9 << 16) + (30 << 4) + 14,\n        0,\n        (5 << 16) + 30,\n        (5 << 16) + 29,\n        (10 << 16) + (29 << 5) + 30 // LOWER -> MIXED -> PUNCT\n    ]),\n    Int32Array.from([\n        (4 << 16) + 14,\n        (9 << 16) + (14 << 5) + 28,\n        0,\n        (9 << 16) + (14 << 5) + 29,\n        (14 << 16) + (14 << 10) + (29 << 5) + 30\n        // DIGIT -> UPPER -> MIXED -> PUNCT\n    ]),\n    Int32Array.from([\n        (5 << 16) + 29,\n        (5 << 16) + 28,\n        (10 << 16) + (29 << 5) + 30,\n        0,\n        (5 << 16) + 30 // MIXED -> PUNCT\n    ]),\n    Int32Array.from([\n        (5 << 16) + 31,\n        (10 << 16) + (31 << 5) + 28,\n        (10 << 16) + (31 << 5) + 30,\n        (10 << 16) + (31 << 5) + 29,\n        0\n    ])\n];\n","var __values = (this && this.__values) || function(o) {\n    var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n    if (m) return m.call(o);\n    if (o && typeof o.length === \"number\") return {\n        next: function () {\n            if (o && i >= o.length) o = void 0;\n            return { value: o && o[i++], done: !o };\n        }\n    };\n    throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n};\nimport Arrays from '../../util/Arrays';\nimport * as C from './EncoderConstants';\nexport function static_SHIFT_TABLE(SHIFT_TABLE) {\n    var e_1, _a;\n    try {\n        for (var SHIFT_TABLE_1 = __values(SHIFT_TABLE), SHIFT_TABLE_1_1 = SHIFT_TABLE_1.next(); !SHIFT_TABLE_1_1.done; SHIFT_TABLE_1_1 = SHIFT_TABLE_1.next()) {\n            var table = SHIFT_TABLE_1_1.value /*Int32Array*/;\n            Arrays.fill(table, -1);\n        }\n    }\n    catch (e_1_1) { e_1 = { error: e_1_1 }; }\n    finally {\n        try {\n            if (SHIFT_TABLE_1_1 && !SHIFT_TABLE_1_1.done && (_a = SHIFT_TABLE_1.return)) _a.call(SHIFT_TABLE_1);\n        }\n        finally { if (e_1) throw e_1.error; }\n    }\n    SHIFT_TABLE[C.MODE_UPPER][C.MODE_PUNCT] = 0;\n    SHIFT_TABLE[C.MODE_LOWER][C.MODE_PUNCT] = 0;\n    SHIFT_TABLE[C.MODE_LOWER][C.MODE_UPPER] = 28;\n    SHIFT_TABLE[C.MODE_MIXED][C.MODE_PUNCT] = 0;\n    SHIFT_TABLE[C.MODE_DIGIT][C.MODE_PUNCT] = 0;\n    SHIFT_TABLE[C.MODE_DIGIT][C.MODE_UPPER] = 15;\n    return SHIFT_TABLE;\n}\nexport var /*final*/ SHIFT_TABLE = static_SHIFT_TABLE(Arrays.createInt32Array(6, 6)); // mode shift codes, per table\n","/*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nvar __values = (this && this.__values) || function(o) {\n    var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n    if (m) return m.call(o);\n    if (o && typeof o.length === \"number\") return {\n        next: function () {\n            if (o && i >= o.length) o = void 0;\n            return { value: o && o[i++], done: !o };\n        }\n    };\n    throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n};\n// package com.google.zxing.aztec.encoder;\n// import java.util.Deque;\n// import java.util.LinkedList;\n// import com.google.zxing.common.BitArray;\nimport BitArray from '../../common/BitArray';\nimport * as TokenHelpers from './TokenHelpers';\nimport * as C from './EncoderConstants';\nimport * as LatchTable from './LatchTable';\nimport * as ShiftTable from './ShiftTable';\nimport StringUtils from '../../common/StringUtils';\n/**\n * State represents all information about a sequence necessary to generate the current output.\n * Note that a state is immutable.\n */\nvar State = /** @class */ (function () {\n    function State(token, mode, binaryBytes, bitCount) {\n        this.token = token;\n        this.mode = mode;\n        this.binaryShiftByteCount = binaryBytes;\n        this.bitCount = bitCount;\n        // Make sure we match the token\n        // int binaryShiftBitCount = (binaryShiftByteCount * 8) +\n        //    (binaryShiftByteCount === 0 ? 0 :\n        //     binaryShiftByteCount <= 31 ? 10 :\n        //     binaryShiftByteCount <= 62 ? 20 : 21);\n        // assert this.bitCount === token.getTotalBitCount() + binaryShiftBitCount;\n    }\n    State.prototype.getMode = function () {\n        return this.mode;\n    };\n    State.prototype.getToken = function () {\n        return this.token;\n    };\n    State.prototype.getBinaryShiftByteCount = function () {\n        return this.binaryShiftByteCount;\n    };\n    State.prototype.getBitCount = function () {\n        return this.bitCount;\n    };\n    // Create a new state representing this state with a latch to a (not\n    // necessary different) mode, and then a code.\n    State.prototype.latchAndAppend = function (mode, value) {\n        // assert binaryShiftByteCount === 0;\n        var bitCount = this.bitCount;\n        var token = this.token;\n        if (mode !== this.mode) {\n            var latch = LatchTable.LATCH_TABLE[this.mode][mode];\n            token = TokenHelpers.add(token, latch & 0xffff, latch >> 16);\n            bitCount += latch >> 16;\n        }\n        var latchModeBitCount = mode === C.MODE_DIGIT ? 4 : 5;\n        token = TokenHelpers.add(token, value, latchModeBitCount);\n        return new State(token, mode, 0, bitCount + latchModeBitCount);\n    };\n    // Create a new state representing this state, with a temporary shift\n    // to a different mode to output a single value.\n    State.prototype.shiftAndAppend = function (mode, value) {\n        // assert binaryShiftByteCount === 0 && this.mode !== mode;\n        var token = this.token;\n        var thisModeBitCount = this.mode === C.MODE_DIGIT ? 4 : 5;\n        // Shifts exist only to UPPER and PUNCT, both with tokens size 5.\n        token = TokenHelpers.add(token, ShiftTable.SHIFT_TABLE[this.mode][mode], thisModeBitCount);\n        token = TokenHelpers.add(token, value, 5);\n        return new State(token, this.mode, 0, this.bitCount + thisModeBitCount + 5);\n    };\n    // Create a new state representing this state, but an additional character\n    // output in Binary Shift mode.\n    State.prototype.addBinaryShiftChar = function (index) {\n        var token = this.token;\n        var mode = this.mode;\n        var bitCount = this.bitCount;\n        if (this.mode === C.MODE_PUNCT || this.mode === C.MODE_DIGIT) {\n            // assert binaryShiftByteCount === 0;\n            var latch = LatchTable.LATCH_TABLE[mode][C.MODE_UPPER];\n            token = TokenHelpers.add(token, latch & 0xffff, latch >> 16);\n            bitCount += latch >> 16;\n            mode = C.MODE_UPPER;\n        }\n        var deltaBitCount = this.binaryShiftByteCount === 0 || this.binaryShiftByteCount === 31\n            ? 18\n            : this.binaryShiftByteCount === 62\n                ? 9\n                : 8;\n        var result = new State(token, mode, this.binaryShiftByteCount + 1, bitCount + deltaBitCount);\n        if (result.binaryShiftByteCount === 2047 + 31) {\n            // The string is as long as it's allowed to be.  We should end it.\n            result = result.endBinaryShift(index + 1);\n        }\n        return result;\n    };\n    // Create the state identical to this one, but we are no longer in\n    // Binary Shift mode.\n    State.prototype.endBinaryShift = function (index) {\n        if (this.binaryShiftByteCount === 0) {\n            return this;\n        }\n        var token = this.token;\n        token = TokenHelpers.addBinaryShift(token, index - this.binaryShiftByteCount, this.binaryShiftByteCount);\n        // assert token.getTotalBitCount() === this.bitCount;\n        return new State(token, this.mode, 0, this.bitCount);\n    };\n    // Returns true if \"this\" state is better (equal: or) to be in than \"that\"\n    // state under all possible circumstances.\n    State.prototype.isBetterThanOrEqualTo = function (other) {\n        var newModeBitCount = this.bitCount + (LatchTable.LATCH_TABLE[this.mode][other.mode] >> 16);\n        if (this.binaryShiftByteCount < other.binaryShiftByteCount) {\n            // add additional B/S encoding cost of other, if any\n            newModeBitCount +=\n                State.calculateBinaryShiftCost(other) -\n                    State.calculateBinaryShiftCost(this);\n        }\n        else if (this.binaryShiftByteCount > other.binaryShiftByteCount &&\n            other.binaryShiftByteCount > 0) {\n            // maximum possible additional cost (it: h)\n            newModeBitCount += 10;\n        }\n        return newModeBitCount <= other.bitCount;\n    };\n    State.prototype.toBitArray = function (text) {\n        var e_1, _a;\n        // Reverse the tokens, so that they are in the order that they should\n        // be output\n        var symbols = [];\n        for (var token = this.endBinaryShift(text.length).token; token !== null; token = token.getPrevious()) {\n            symbols.unshift(token);\n        }\n        var bitArray = new BitArray();\n        try {\n            // Add each token to the result.\n            for (var symbols_1 = __values(symbols), symbols_1_1 = symbols_1.next(); !symbols_1_1.done; symbols_1_1 = symbols_1.next()) {\n                var symbol = symbols_1_1.value;\n                symbol.appendTo(bitArray, text);\n            }\n        }\n        catch (e_1_1) { e_1 = { error: e_1_1 }; }\n        finally {\n            try {\n                if (symbols_1_1 && !symbols_1_1.done && (_a = symbols_1.return)) _a.call(symbols_1);\n            }\n            finally { if (e_1) throw e_1.error; }\n        }\n        // assert bitArray.getSize() === this.bitCount;\n        return bitArray;\n    };\n    /**\n     * @Override\n     */\n    State.prototype.toString = function () {\n        return StringUtils.format('%s bits=%d bytes=%d', C.MODE_NAMES[this.mode], this.bitCount, this.binaryShiftByteCount);\n    };\n    State.calculateBinaryShiftCost = function (state) {\n        if (state.binaryShiftByteCount > 62) {\n            return 21; // B/S with extended length\n        }\n        if (state.binaryShiftByteCount > 31) {\n            return 20; // two B/S\n        }\n        if (state.binaryShiftByteCount > 0) {\n            return 10; // one B/S\n        }\n        return 0;\n    };\n    State.INITIAL_STATE = new State(C.EMPTY_TOKEN, C.MODE_UPPER, 0, 0);\n    return State;\n}());\nexport default State;\n","import * as C from './EncoderConstants';\nimport Arrays from '../../util/Arrays';\nimport StringUtils from '../../common/StringUtils';\nexport function static_CHAR_MAP(CHAR_MAP) {\n    var spaceCharCode = StringUtils.getCharCode(' ');\n    var pointCharCode = StringUtils.getCharCode('.');\n    var commaCharCode = StringUtils.getCharCode(',');\n    CHAR_MAP[C.MODE_UPPER][spaceCharCode] = 1;\n    var zUpperCharCode = StringUtils.getCharCode('Z');\n    var aUpperCharCode = StringUtils.getCharCode('A');\n    for (var c = aUpperCharCode; c <= zUpperCharCode; c++) {\n        CHAR_MAP[C.MODE_UPPER][c] = c - aUpperCharCode + 2;\n    }\n    CHAR_MAP[C.MODE_LOWER][spaceCharCode] = 1;\n    var zLowerCharCode = StringUtils.getCharCode('z');\n    var aLowerCharCode = StringUtils.getCharCode('a');\n    for (var c = aLowerCharCode; c <= zLowerCharCode; c++) {\n        CHAR_MAP[C.MODE_LOWER][c] = c - aLowerCharCode + 2;\n    }\n    CHAR_MAP[C.MODE_DIGIT][spaceCharCode] = 1;\n    var nineCharCode = StringUtils.getCharCode('9');\n    var zeroCharCode = StringUtils.getCharCode('0');\n    for (var c = zeroCharCode; c <= nineCharCode; c++) {\n        CHAR_MAP[C.MODE_DIGIT][c] = c - zeroCharCode + 2;\n    }\n    CHAR_MAP[C.MODE_DIGIT][commaCharCode] = 12;\n    CHAR_MAP[C.MODE_DIGIT][pointCharCode] = 13;\n    var mixedTable = [\n        '\\x00',\n        ' ',\n        '\\x01',\n        '\\x02',\n        '\\x03',\n        '\\x04',\n        '\\x05',\n        '\\x06',\n        '\\x07',\n        '\\b',\n        '\\t',\n        '\\n',\n        '\\x0b',\n        '\\f',\n        '\\r',\n        '\\x1b',\n        '\\x1c',\n        '\\x1d',\n        '\\x1e',\n        '\\x1f',\n        '@',\n        '\\\\',\n        '^',\n        '_',\n        '`',\n        '|',\n        '~',\n        '\\x7f'\n    ];\n    for (var i = 0; i < mixedTable.length; i++) {\n        CHAR_MAP[C.MODE_MIXED][StringUtils.getCharCode(mixedTable[i])] = i;\n    }\n    var punctTable = [\n        '\\x00',\n        '\\r',\n        '\\x00',\n        '\\x00',\n        '\\x00',\n        '\\x00',\n        '!',\n        '\\'',\n        '#',\n        '$',\n        '%',\n        '&',\n        '\\'',\n        '(',\n        ')',\n        '*',\n        '+',\n        ',',\n        '-',\n        '.',\n        '/',\n        ':',\n        ';',\n        '<',\n        '=',\n        '>',\n        '?',\n        '[',\n        ']',\n        '{',\n        '}'\n    ];\n    for (var i = 0; i < punctTable.length; i++) {\n        if (StringUtils.getCharCode(punctTable[i]) > 0) {\n            CHAR_MAP[C.MODE_PUNCT][StringUtils.getCharCode(punctTable[i])] = i;\n        }\n    }\n    return CHAR_MAP;\n}\nexport var CHAR_MAP = static_CHAR_MAP(Arrays.createInt32Array(5, 256));\n","/*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nvar __values = (this && this.__values) || function(o) {\n    var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n    if (m) return m.call(o);\n    if (o && typeof o.length === \"number\") return {\n        next: function () {\n            if (o && i >= o.length) o = void 0;\n            return { value: o && o[i++], done: !o };\n        }\n    };\n    throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n};\n// import java.util.Collection;\n// import java.util.Collections;\nimport Collections from '../../util/Collections';\n// import java.util.Comparator;\n// import java.util.Iterator;\n// import java.util.LinkedList;\nimport State from './State';\nimport * as C from './EncoderConstants';\nimport * as CharMap from './CharMap';\nimport * as ShiftTable from './ShiftTable';\nimport StringUtils from '../../common/StringUtils';\n/**\n * This produces nearly optimal encodings of text into the first-level of\n * encoding used by Aztec code.\n *\n * It uses a dynamic algorithm.  For each prefix of the string, it determines\n * a set of encodings that could lead to this prefix.  We repeatedly add a\n * character and generate a new set of optimal encodings until we have read\n * through the entire input.\n *\n * @author Frank Yellin\n * @author Rustam Abdullaev\n */\nvar HighLevelEncoder = /** @class */ (function () {\n    function HighLevelEncoder(text) {\n        this.text = text;\n    }\n    /**\n     * @return text represented by this encoder encoded as a {@link BitArray}\n     */\n    HighLevelEncoder.prototype.encode = function () {\n        var spaceCharCode = StringUtils.getCharCode(' ');\n        var lineBreakCharCode = StringUtils.getCharCode('\\n');\n        var states = Collections.singletonList(State.INITIAL_STATE);\n        for (var index = 0; index < this.text.length; index++) {\n            var pairCode = void 0;\n            var nextChar = index + 1 < this.text.length ? this.text[index + 1] : 0;\n            switch (this.text[index]) {\n                case StringUtils.getCharCode('\\r'):\n                    pairCode = nextChar === lineBreakCharCode ? 2 : 0;\n                    break;\n                case StringUtils.getCharCode('.'):\n                    pairCode = nextChar === spaceCharCode ? 3 : 0;\n                    break;\n                case StringUtils.getCharCode(','):\n                    pairCode = nextChar === spaceCharCode ? 4 : 0;\n                    break;\n                case StringUtils.getCharCode(':'):\n                    pairCode = nextChar === spaceCharCode ? 5 : 0;\n                    break;\n                default:\n                    pairCode = 0;\n            }\n            if (pairCode > 0) {\n                // We have one of the four special PUNCT pairs.  Treat them specially.\n                // Get a new set of states for the two new characters.\n                states = HighLevelEncoder.updateStateListForPair(states, index, pairCode);\n                index++;\n            }\n            else {\n                // Get a new set of states for the new character.\n                states = this.updateStateListForChar(states, index);\n            }\n        }\n        // We are left with a set of states.  Find the shortest one.\n        var minState = Collections.min(states, function (a, b) {\n            return a.getBitCount() - b.getBitCount();\n        });\n        // Convert it to a bit array, and return.\n        return minState.toBitArray(this.text);\n    };\n    // We update a set of states for a new character by updating each state\n    // for the new character, merging the results, and then removing the\n    // non-optimal states.\n    HighLevelEncoder.prototype.updateStateListForChar = function (states, index) {\n        var e_1, _a;\n        var result = [];\n        try {\n            for (var states_1 = __values(states), states_1_1 = states_1.next(); !states_1_1.done; states_1_1 = states_1.next()) {\n                var state = states_1_1.value /*State*/;\n                this.updateStateForChar(state, index, result);\n            }\n        }\n        catch (e_1_1) { e_1 = { error: e_1_1 }; }\n        finally {\n            try {\n                if (states_1_1 && !states_1_1.done && (_a = states_1.return)) _a.call(states_1);\n            }\n            finally { if (e_1) throw e_1.error; }\n        }\n        return HighLevelEncoder.simplifyStates(result);\n    };\n    // Return a set of states that represent the possible ways of updating this\n    // state for the next character.  The resulting set of states are added to\n    // the \"result\" list.\n    HighLevelEncoder.prototype.updateStateForChar = function (state, index, result) {\n        var ch = (this.text[index] & 0xff);\n        var charInCurrentTable = CharMap.CHAR_MAP[state.getMode()][ch] > 0;\n        var stateNoBinary = null;\n        for (var mode /*int*/ = 0; mode <= C.MODE_PUNCT; mode++) {\n            var charInMode = CharMap.CHAR_MAP[mode][ch];\n            if (charInMode > 0) {\n                if (stateNoBinary == null) {\n                    // Only create stateNoBinary the first time it's required.\n                    stateNoBinary = state.endBinaryShift(index);\n                }\n                // Try generating the character by latching to its mode\n                if (!charInCurrentTable ||\n                    mode === state.getMode() ||\n                    mode === C.MODE_DIGIT) {\n                    // If the character is in the current table, we don't want to latch to\n                    // any other mode except possibly digit (which uses only 4 bits).  Any\n                    // other latch would be equally successful *after* this character, and\n                    // so wouldn't save any bits.\n                    var latchState = stateNoBinary.latchAndAppend(mode, charInMode);\n                    result.push(latchState);\n                }\n                // Try generating the character by switching to its mode.\n                if (!charInCurrentTable &&\n                    ShiftTable.SHIFT_TABLE[state.getMode()][mode] >= 0) {\n                    // It never makes sense to temporarily shift to another mode if the\n                    // character exists in the current mode.  That can never save bits.\n                    var shiftState = stateNoBinary.shiftAndAppend(mode, charInMode);\n                    result.push(shiftState);\n                }\n            }\n        }\n        if (state.getBinaryShiftByteCount() > 0 ||\n            CharMap.CHAR_MAP[state.getMode()][ch] === 0) {\n            // It's never worthwhile to go into binary shift mode if you're not already\n            // in binary shift mode, and the character exists in your current mode.\n            // That can never save bits over just outputting the char in the current mode.\n            var binaryState = state.addBinaryShiftChar(index);\n            result.push(binaryState);\n        }\n    };\n    HighLevelEncoder.updateStateListForPair = function (states, index, pairCode) {\n        var e_2, _a;\n        var result = [];\n        try {\n            for (var states_2 = __values(states), states_2_1 = states_2.next(); !states_2_1.done; states_2_1 = states_2.next()) {\n                var state = states_2_1.value /*State*/;\n                this.updateStateForPair(state, index, pairCode, result);\n            }\n        }\n        catch (e_2_1) { e_2 = { error: e_2_1 }; }\n        finally {\n            try {\n                if (states_2_1 && !states_2_1.done && (_a = states_2.return)) _a.call(states_2);\n            }\n            finally { if (e_2) throw e_2.error; }\n        }\n        return this.simplifyStates(result);\n    };\n    HighLevelEncoder.updateStateForPair = function (state, index, pairCode, result) {\n        var stateNoBinary = state.endBinaryShift(index);\n        // Possibility 1.  Latch to C.MODE_PUNCT, and then append this code\n        result.push(stateNoBinary.latchAndAppend(C.MODE_PUNCT, pairCode));\n        if (state.getMode() !== C.MODE_PUNCT) {\n            // Possibility 2.  Shift to C.MODE_PUNCT, and then append this code.\n            // Every state except C.MODE_PUNCT (handled above) can shift\n            result.push(stateNoBinary.shiftAndAppend(C.MODE_PUNCT, pairCode));\n        }\n        if (pairCode === 3 || pairCode === 4) {\n            // both characters are in DIGITS.  Sometimes better to just add two digits\n            var digitState = stateNoBinary\n                .latchAndAppend(C.MODE_DIGIT, 16 - pairCode) // period or comma in DIGIT\n                .latchAndAppend(C.MODE_DIGIT, 1); // space in DIGIT\n            result.push(digitState);\n        }\n        if (state.getBinaryShiftByteCount() > 0) {\n            // It only makes sense to do the characters as binary if we're already\n            // in binary mode.\n            var binaryState = state\n                .addBinaryShiftChar(index)\n                .addBinaryShiftChar(index + 1);\n            result.push(binaryState);\n        }\n    };\n    HighLevelEncoder.simplifyStates = function (states) {\n        var e_3, _a, e_4, _b;\n        var result = [];\n        try {\n            for (var states_3 = __values(states), states_3_1 = states_3.next(); !states_3_1.done; states_3_1 = states_3.next()) {\n                var newState = states_3_1.value;\n                var add = true;\n                var _loop_1 = function (oldState) {\n                    if (oldState.isBetterThanOrEqualTo(newState)) {\n                        add = false;\n                        return \"break\";\n                    }\n                    if (newState.isBetterThanOrEqualTo(oldState)) {\n                        // iterator.remove();\n                        result = result.filter(function (x) { return x !== oldState; }); // remove old state\n                    }\n                };\n                try {\n                    for (var result_1 = (e_4 = void 0, __values(result)), result_1_1 = result_1.next(); !result_1_1.done; result_1_1 = result_1.next()) {\n                        var oldState = result_1_1.value;\n                        var state_1 = _loop_1(oldState);\n                        if (state_1 === \"break\")\n                            break;\n                    }\n                }\n                catch (e_4_1) { e_4 = { error: e_4_1 }; }\n                finally {\n                    try {\n                        if (result_1_1 && !result_1_1.done && (_b = result_1.return)) _b.call(result_1);\n                    }\n                    finally { if (e_4) throw e_4.error; }\n                }\n                if (add) {\n                    result.push(newState);\n                }\n            }\n        }\n        catch (e_3_1) { e_3 = { error: e_3_1 }; }\n        finally {\n            try {\n                if (states_3_1 && !states_3_1.done && (_a = states_3.return)) _a.call(states_3);\n            }\n            finally { if (e_3) throw e_3.error; }\n        }\n        return result;\n    };\n    return HighLevelEncoder;\n}());\nexport default HighLevelEncoder;\n"],"names":[],"sourceRoot":""}