{"version":3,"file":"vendors-c3b809ff.f584a1446b2fc034d810.bundle.js","mappings":"AAeA","sources":["webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/qrcode/encoder/ByteMatrix.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/qrcode/encoder/BlockPair.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/qrcode/encoder/Encoder.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/qrcode/encoder/MaskUtil.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/qrcode/encoder/MatrixUtil.js","webpack://lernplattform-admin-frontend/../common/node_modules/@zxing/library/esm/core/qrcode/encoder/QRCode.js"],"sourcesContent":["/*\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 */\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/*namespace com.google.zxing.qrcode.encoder {*/\n/*import java.util.Arrays;*/\nimport Arrays from '../../util/Arrays';\nimport StringBuilder from '../../util/StringBuilder';\n/**\n * JAVAPORT: The original code was a 2D array of ints, but since it only ever gets assigned\n * -1, 0, and 1, I'm going to use less memory and go with bytes.\n *\n * @author dswitkin@google.com (Daniel Switkin)\n */\nvar ByteMatrix = /** @class */ (function () {\n    function ByteMatrix(width /*int*/, height /*int*/) {\n        this.width = width;\n        this.height = height;\n        var bytes = new Array(height); // [height][width]\n        for (var i = 0; i !== height; i++) {\n            bytes[i] = new Uint8Array(width);\n        }\n        this.bytes = bytes;\n    }\n    ByteMatrix.prototype.getHeight = function () {\n        return this.height;\n    };\n    ByteMatrix.prototype.getWidth = function () {\n        return this.width;\n    };\n    ByteMatrix.prototype.get = function (x /*int*/, y /*int*/) {\n        return this.bytes[y][x];\n    };\n    /**\n     * @return an internal representation as bytes, in row-major order. array[y][x] represents point (x,y)\n     */\n    ByteMatrix.prototype.getArray = function () {\n        return this.bytes;\n    };\n    // TYPESCRIPTPORT: preffer to let two methods instead of override to avoid type comparison inside\n    ByteMatrix.prototype.setNumber = function (x /*int*/, y /*int*/, value /*byte|int*/) {\n        this.bytes[y][x] = value;\n    };\n    // public set(x: number /*int*/, y: number /*int*/, value: number /*int*/): void {\n    //   bytes[y][x] = (byte) value\n    // }\n    ByteMatrix.prototype.setBoolean = function (x /*int*/, y /*int*/, value) {\n        this.bytes[y][x] = /*(byte) */ (value ? 1 : 0);\n    };\n    ByteMatrix.prototype.clear = function (value /*byte*/) {\n        var e_1, _a;\n        try {\n            for (var _b = __values(this.bytes), _c = _b.next(); !_c.done; _c = _b.next()) {\n                var aByte = _c.value;\n                Arrays.fill(aByte, value);\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    };\n    ByteMatrix.prototype.equals = function (o) {\n        if (!(o instanceof ByteMatrix)) {\n            return false;\n        }\n        var other = o;\n        if (this.width !== other.width) {\n            return false;\n        }\n        if (this.height !== other.height) {\n            return false;\n        }\n        for (var y = 0, height = this.height; y < height; ++y) {\n            var bytesY = this.bytes[y];\n            var otherBytesY = other.bytes[y];\n            for (var x = 0, width = this.width; x < width; ++x) {\n                if (bytesY[x] !== otherBytesY[x]) {\n                    return false;\n                }\n            }\n        }\n        return true;\n    };\n    /*@Override*/\n    ByteMatrix.prototype.toString = function () {\n        var result = new StringBuilder(); // (2 * width * height + 2)\n        for (var y = 0, height = this.height; y < height; ++y) {\n            var bytesY = this.bytes[y];\n            for (var x = 0, width = this.width; x < width; ++x) {\n                switch (bytesY[x]) {\n                    case 0:\n                        result.append(' 0');\n                        break;\n                    case 1:\n                        result.append(' 1');\n                        break;\n                    default:\n                        result.append('  ');\n                        break;\n                }\n            }\n            result.append('\\n');\n        }\n        return result.toString();\n    };\n    return ByteMatrix;\n}());\nexport default ByteMatrix;\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.qrcode.encoder {*/\nvar BlockPair = /** @class */ (function () {\n    function BlockPair(dataBytes, errorCorrectionBytes) {\n        this.dataBytes = dataBytes;\n        this.errorCorrectionBytes = errorCorrectionBytes;\n    }\n    BlockPair.prototype.getDataBytes = function () {\n        return this.dataBytes;\n    };\n    BlockPair.prototype.getErrorCorrectionBytes = function () {\n        return this.errorCorrectionBytes;\n    };\n    return BlockPair;\n}());\nexport default BlockPair;\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 */\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/*namespace com.google.zxing.qrcode.encoder {*/\nimport EncodeHintType from '../../EncodeHintType';\nimport BitArray from '../../common/BitArray';\nimport CharacterSetECI from '../../common/CharacterSetECI';\nimport GenericGF from '../../common/reedsolomon/GenericGF';\nimport ReedSolomonEncoder from '../../common/reedsolomon/ReedSolomonEncoder';\nimport Mode from '../decoder/Mode';\nimport Version from '../decoder/Version';\nimport MaskUtil from './MaskUtil';\nimport ByteMatrix from './ByteMatrix';\nimport QRCode from './QRCode';\nimport MatrixUtil from './MatrixUtil';\nimport StringEncoding from '../../util/StringEncoding';\nimport BlockPair from './BlockPair';\nimport WriterException from '../../WriterException';\n/*import java.io.UnsupportedEncodingException;*/\n/*import java.util.ArrayList;*/\n/*import java.util.Collection;*/\n/*import java.util.Map;*/\n/**\n * @author satorux@google.com (Satoru Takabayashi) - creator\n * @author dswitkin@google.com (Daniel Switkin) - ported from C++\n */\nvar Encoder = /** @class */ (function () {\n    // TYPESCRIPTPORT: changed to UTF8, the default for js\n    function Encoder() {\n    }\n    // The mask penalty calculation is complicated.  See Table 21 of JISX0510:2004 (p.45) for details.\n    // Basically it applies four rules and summate all penalties.\n    Encoder.calculateMaskPenalty = function (matrix) {\n        return MaskUtil.applyMaskPenaltyRule1(matrix)\n            + MaskUtil.applyMaskPenaltyRule2(matrix)\n            + MaskUtil.applyMaskPenaltyRule3(matrix)\n            + MaskUtil.applyMaskPenaltyRule4(matrix);\n    };\n    /**\n     * @param content text to encode\n     * @param ecLevel error correction level to use\n     * @return {@link QRCode} representing the encoded QR code\n     * @throws WriterException if encoding can't succeed, because of for example invalid content\n     *   or configuration\n     */\n    // public static encode(content: string, ecLevel: ErrorCorrectionLevel): QRCode /*throws WriterException*/ {\n    //   return encode(content, ecLevel, null)\n    // }\n    Encoder.encode = function (content, ecLevel, hints) {\n        if (hints === void 0) { hints = null; }\n        // Determine what character encoding has been specified by the caller, if any\n        var encoding = Encoder.DEFAULT_BYTE_MODE_ENCODING;\n        var hasEncodingHint = hints !== null && undefined !== hints.get(EncodeHintType.CHARACTER_SET);\n        if (hasEncodingHint) {\n            encoding = hints.get(EncodeHintType.CHARACTER_SET).toString();\n        }\n        // Pick an encoding mode appropriate for the content. Note that this will not attempt to use\n        // multiple modes / segments even if that were more efficient. Twould be nice.\n        var mode = this.chooseMode(content, encoding);\n        // This will store the header information, like mode and\n        // length, as well as \"header\" segments like an ECI segment.\n        var headerBits = new BitArray();\n        // Append ECI segment if applicable\n        if (mode === Mode.BYTE && (hasEncodingHint || Encoder.DEFAULT_BYTE_MODE_ENCODING !== encoding)) {\n            var eci = CharacterSetECI.getCharacterSetECIByName(encoding);\n            if (eci !== undefined) {\n                this.appendECI(eci, headerBits);\n            }\n        }\n        // (With ECI in place,) Write the mode marker\n        this.appendModeInfo(mode, headerBits);\n        // Collect data within the main segment, separately, to count its size if needed. Don't add it to\n        // main payload yet.\n        var dataBits = new BitArray();\n        this.appendBytes(content, mode, dataBits, encoding);\n        var version;\n        if (hints !== null && undefined !== hints.get(EncodeHintType.QR_VERSION)) {\n            var versionNumber = Number.parseInt(hints.get(EncodeHintType.QR_VERSION).toString(), 10);\n            version = Version.getVersionForNumber(versionNumber);\n            var bitsNeeded = this.calculateBitsNeeded(mode, headerBits, dataBits, version);\n            if (!this.willFit(bitsNeeded, version, ecLevel)) {\n                throw new WriterException('Data too big for requested version');\n            }\n        }\n        else {\n            version = this.recommendVersion(ecLevel, mode, headerBits, dataBits);\n        }\n        var headerAndDataBits = new BitArray();\n        headerAndDataBits.appendBitArray(headerBits);\n        // Find \"length\" of main segment and write it\n        var numLetters = mode === Mode.BYTE ? dataBits.getSizeInBytes() : content.length;\n        this.appendLengthInfo(numLetters, version, mode, headerAndDataBits);\n        // Put data together into the overall payload\n        headerAndDataBits.appendBitArray(dataBits);\n        var ecBlocks = version.getECBlocksForLevel(ecLevel);\n        var numDataBytes = version.getTotalCodewords() - ecBlocks.getTotalECCodewords();\n        // Terminate the bits properly.\n        this.terminateBits(numDataBytes, headerAndDataBits);\n        // Interleave data bits with error correction code.\n        var finalBits = this.interleaveWithECBytes(headerAndDataBits, version.getTotalCodewords(), numDataBytes, ecBlocks.getNumBlocks());\n        var qrCode = new QRCode();\n        qrCode.setECLevel(ecLevel);\n        qrCode.setMode(mode);\n        qrCode.setVersion(version);\n        //  Choose the mask pattern and set to \"qrCode\".\n        var dimension = version.getDimensionForVersion();\n        var matrix = new ByteMatrix(dimension, dimension);\n        var maskPattern = this.chooseMaskPattern(finalBits, ecLevel, version, matrix);\n        qrCode.setMaskPattern(maskPattern);\n        // Build the matrix and set it to \"qrCode\".\n        MatrixUtil.buildMatrix(finalBits, ecLevel, version, maskPattern, matrix);\n        qrCode.setMatrix(matrix);\n        return qrCode;\n    };\n    /**\n     * Decides the smallest version of QR code that will contain all of the provided data.\n     *\n     * @throws WriterException if the data cannot fit in any version\n     */\n    Encoder.recommendVersion = function (ecLevel, mode, headerBits, dataBits) {\n        // Hard part: need to know version to know how many bits length takes. But need to know how many\n        // bits it takes to know version. First we take a guess at version by assuming version will be\n        // the minimum, 1:\n        var provisionalBitsNeeded = this.calculateBitsNeeded(mode, headerBits, dataBits, Version.getVersionForNumber(1));\n        var provisionalVersion = this.chooseVersion(provisionalBitsNeeded, ecLevel);\n        // Use that guess to calculate the right version. I am still not sure this works in 100% of cases.\n        var bitsNeeded = this.calculateBitsNeeded(mode, headerBits, dataBits, provisionalVersion);\n        return this.chooseVersion(bitsNeeded, ecLevel);\n    };\n    Encoder.calculateBitsNeeded = function (mode, headerBits, dataBits, version) {\n        return headerBits.getSize() + mode.getCharacterCountBits(version) + dataBits.getSize();\n    };\n    /**\n     * @return the code point of the table used in alphanumeric mode or\n     *  -1 if there is no corresponding code in the table.\n     */\n    Encoder.getAlphanumericCode = function (code /*int*/) {\n        if (code < Encoder.ALPHANUMERIC_TABLE.length) {\n            return Encoder.ALPHANUMERIC_TABLE[code];\n        }\n        return -1;\n    };\n    // public static chooseMode(content: string): Mode {\n    //   return chooseMode(content, null);\n    // }\n    /**\n     * Choose the best mode by examining the content. Note that 'encoding' is used as a hint;\n     * if it is Shift_JIS, and the input is only double-byte Kanji, then we return {@link Mode#KANJI}.\n     */\n    Encoder.chooseMode = function (content, encoding) {\n        if (encoding === void 0) { encoding = null; }\n        if (CharacterSetECI.SJIS.getName() === encoding && this.isOnlyDoubleByteKanji(content)) {\n            // Choose Kanji mode if all input are double-byte characters\n            return Mode.KANJI;\n        }\n        var hasNumeric = false;\n        var hasAlphanumeric = false;\n        for (var i = 0, length_1 = content.length; i < length_1; ++i) {\n            var c = content.charAt(i);\n            if (Encoder.isDigit(c)) {\n                hasNumeric = true;\n            }\n            else if (this.getAlphanumericCode(c.charCodeAt(0)) !== -1) {\n                hasAlphanumeric = true;\n            }\n            else {\n                return Mode.BYTE;\n            }\n        }\n        if (hasAlphanumeric) {\n            return Mode.ALPHANUMERIC;\n        }\n        if (hasNumeric) {\n            return Mode.NUMERIC;\n        }\n        return Mode.BYTE;\n    };\n    Encoder.isOnlyDoubleByteKanji = function (content) {\n        var bytes;\n        try {\n            bytes = StringEncoding.encode(content, CharacterSetECI.SJIS); // content.getBytes(\"Shift_JIS\"))\n        }\n        catch (ignored /*: UnsupportedEncodingException*/) {\n            return false;\n        }\n        var length = bytes.length;\n        if (length % 2 !== 0) {\n            return false;\n        }\n        for (var i = 0; i < length; i += 2) {\n            var byte1 = bytes[i] & 0xFF;\n            if ((byte1 < 0x81 || byte1 > 0x9F) && (byte1 < 0xE0 || byte1 > 0xEB)) {\n                return false;\n            }\n        }\n        return true;\n    };\n    Encoder.chooseMaskPattern = function (bits, ecLevel, version, matrix) {\n        var minPenalty = Number.MAX_SAFE_INTEGER; // Lower penalty is better.\n        var bestMaskPattern = -1;\n        // We try all mask patterns to choose the best one.\n        for (var maskPattern = 0; maskPattern < QRCode.NUM_MASK_PATTERNS; maskPattern++) {\n            MatrixUtil.buildMatrix(bits, ecLevel, version, maskPattern, matrix);\n            var penalty = this.calculateMaskPenalty(matrix);\n            if (penalty < minPenalty) {\n                minPenalty = penalty;\n                bestMaskPattern = maskPattern;\n            }\n        }\n        return bestMaskPattern;\n    };\n    Encoder.chooseVersion = function (numInputBits /*int*/, ecLevel) {\n        for (var versionNum = 1; versionNum <= 40; versionNum++) {\n            var version = Version.getVersionForNumber(versionNum);\n            if (Encoder.willFit(numInputBits, version, ecLevel)) {\n                return version;\n            }\n        }\n        throw new WriterException('Data too big');\n    };\n    /**\n     * @return true if the number of input bits will fit in a code with the specified version and\n     * error correction level.\n     */\n    Encoder.willFit = function (numInputBits /*int*/, version, ecLevel) {\n        // In the following comments, we use numbers of Version 7-H.\n        // numBytes = 196\n        var numBytes = version.getTotalCodewords();\n        // getNumECBytes = 130\n        var ecBlocks = version.getECBlocksForLevel(ecLevel);\n        var numEcBytes = ecBlocks.getTotalECCodewords();\n        // getNumDataBytes = 196 - 130 = 66\n        var numDataBytes = numBytes - numEcBytes;\n        var totalInputBytes = (numInputBits + 7) / 8;\n        return numDataBytes >= totalInputBytes;\n    };\n    /**\n     * Terminate bits as described in 8.4.8 and 8.4.9 of JISX0510:2004 (p.24).\n     */\n    Encoder.terminateBits = function (numDataBytes /*int*/, bits) {\n        var capacity = numDataBytes * 8;\n        if (bits.getSize() > capacity) {\n            throw new WriterException('data bits cannot fit in the QR Code' + bits.getSize() + ' > ' +\n                capacity);\n        }\n        for (var i = 0; i < 4 && bits.getSize() < capacity; ++i) {\n            bits.appendBit(false);\n        }\n        // Append termination bits. See 8.4.8 of JISX0510:2004 (p.24) for details.\n        // If the last byte isn't 8-bit aligned, we'll add padding bits.\n        var numBitsInLastByte = bits.getSize() & 0x07;\n        if (numBitsInLastByte > 0) {\n            for (var i = numBitsInLastByte; i < 8; i++) {\n                bits.appendBit(false);\n            }\n        }\n        // If we have more space, we'll fill the space with padding patterns defined in 8.4.9 (p.24).\n        var numPaddingBytes = numDataBytes - bits.getSizeInBytes();\n        for (var i = 0; i < numPaddingBytes; ++i) {\n            bits.appendBits((i & 0x01) === 0 ? 0xEC : 0x11, 8);\n        }\n        if (bits.getSize() !== capacity) {\n            throw new WriterException('Bits size does not equal capacity');\n        }\n    };\n    /**\n     * Get number of data bytes and number of error correction bytes for block id \"blockID\". Store\n     * the result in \"numDataBytesInBlock\", and \"numECBytesInBlock\". See table 12 in 8.5.1 of\n     * JISX0510:2004 (p.30)\n     */\n    Encoder.getNumDataBytesAndNumECBytesForBlockID = function (numTotalBytes /*int*/, numDataBytes /*int*/, numRSBlocks /*int*/, blockID /*int*/, numDataBytesInBlock, numECBytesInBlock) {\n        if (blockID >= numRSBlocks) {\n            throw new WriterException('Block ID too large');\n        }\n        // numRsBlocksInGroup2 = 196 % 5 = 1\n        var numRsBlocksInGroup2 = numTotalBytes % numRSBlocks;\n        // numRsBlocksInGroup1 = 5 - 1 = 4\n        var numRsBlocksInGroup1 = numRSBlocks - numRsBlocksInGroup2;\n        // numTotalBytesInGroup1 = 196 / 5 = 39\n        var numTotalBytesInGroup1 = Math.floor(numTotalBytes / numRSBlocks);\n        // numTotalBytesInGroup2 = 39 + 1 = 40\n        var numTotalBytesInGroup2 = numTotalBytesInGroup1 + 1;\n        // numDataBytesInGroup1 = 66 / 5 = 13\n        var numDataBytesInGroup1 = Math.floor(numDataBytes / numRSBlocks);\n        // numDataBytesInGroup2 = 13 + 1 = 14\n        var numDataBytesInGroup2 = numDataBytesInGroup1 + 1;\n        // numEcBytesInGroup1 = 39 - 13 = 26\n        var numEcBytesInGroup1 = numTotalBytesInGroup1 - numDataBytesInGroup1;\n        // numEcBytesInGroup2 = 40 - 14 = 26\n        var numEcBytesInGroup2 = numTotalBytesInGroup2 - numDataBytesInGroup2;\n        // Sanity checks.\n        // 26 = 26\n        if (numEcBytesInGroup1 !== numEcBytesInGroup2) {\n            throw new WriterException('EC bytes mismatch');\n        }\n        // 5 = 4 + 1.\n        if (numRSBlocks !== numRsBlocksInGroup1 + numRsBlocksInGroup2) {\n            throw new WriterException('RS blocks mismatch');\n        }\n        // 196 = (13 + 26) * 4 + (14 + 26) * 1\n        if (numTotalBytes !==\n            ((numDataBytesInGroup1 + numEcBytesInGroup1) *\n                numRsBlocksInGroup1) +\n                ((numDataBytesInGroup2 + numEcBytesInGroup2) *\n                    numRsBlocksInGroup2)) {\n            throw new WriterException('Total bytes mismatch');\n        }\n        if (blockID < numRsBlocksInGroup1) {\n            numDataBytesInBlock[0] = numDataBytesInGroup1;\n            numECBytesInBlock[0] = numEcBytesInGroup1;\n        }\n        else {\n            numDataBytesInBlock[0] = numDataBytesInGroup2;\n            numECBytesInBlock[0] = numEcBytesInGroup2;\n        }\n    };\n    /**\n     * Interleave \"bits\" with corresponding error correction bytes. On success, store the result in\n     * \"result\". The interleave rule is complicated. See 8.6 of JISX0510:2004 (p.37) for details.\n     */\n    Encoder.interleaveWithECBytes = function (bits, numTotalBytes /*int*/, numDataBytes /*int*/, numRSBlocks /*int*/) {\n        var e_1, _a, e_2, _b;\n        // \"bits\" must have \"getNumDataBytes\" bytes of data.\n        if (bits.getSizeInBytes() !== numDataBytes) {\n            throw new WriterException('Number of bits and data bytes does not match');\n        }\n        // Step 1.  Divide data bytes into blocks and generate error correction bytes for them. We'll\n        // store the divided data bytes blocks and error correction bytes blocks into \"blocks\".\n        var dataBytesOffset = 0;\n        var maxNumDataBytes = 0;\n        var maxNumEcBytes = 0;\n        // Since, we know the number of reedsolmon blocks, we can initialize the vector with the number.\n        var blocks = new Array(); // new Array<BlockPair>(numRSBlocks)\n        for (var i = 0; i < numRSBlocks; ++i) {\n            var numDataBytesInBlock = new Int32Array(1);\n            var numEcBytesInBlock = new Int32Array(1);\n            Encoder.getNumDataBytesAndNumECBytesForBlockID(numTotalBytes, numDataBytes, numRSBlocks, i, numDataBytesInBlock, numEcBytesInBlock);\n            var size = numDataBytesInBlock[0];\n            var dataBytes = new Uint8Array(size);\n            bits.toBytes(8 * dataBytesOffset, dataBytes, 0, size);\n            var ecBytes = Encoder.generateECBytes(dataBytes, numEcBytesInBlock[0]);\n            blocks.push(new BlockPair(dataBytes, ecBytes));\n            maxNumDataBytes = Math.max(maxNumDataBytes, size);\n            maxNumEcBytes = Math.max(maxNumEcBytes, ecBytes.length);\n            dataBytesOffset += numDataBytesInBlock[0];\n        }\n        if (numDataBytes !== dataBytesOffset) {\n            throw new WriterException('Data bytes does not match offset');\n        }\n        var result = new BitArray();\n        // First, place data blocks.\n        for (var i = 0; i < maxNumDataBytes; ++i) {\n            try {\n                for (var blocks_1 = (e_1 = void 0, __values(blocks)), blocks_1_1 = blocks_1.next(); !blocks_1_1.done; blocks_1_1 = blocks_1.next()) {\n                    var block = blocks_1_1.value;\n                    var dataBytes = block.getDataBytes();\n                    if (i < dataBytes.length) {\n                        result.appendBits(dataBytes[i], 8);\n                    }\n                }\n            }\n            catch (e_1_1) { e_1 = { error: e_1_1 }; }\n            finally {\n                try {\n                    if (blocks_1_1 && !blocks_1_1.done && (_a = blocks_1.return)) _a.call(blocks_1);\n                }\n                finally { if (e_1) throw e_1.error; }\n            }\n        }\n        // Then, place error correction blocks.\n        for (var i = 0; i < maxNumEcBytes; ++i) {\n            try {\n                for (var blocks_2 = (e_2 = void 0, __values(blocks)), blocks_2_1 = blocks_2.next(); !blocks_2_1.done; blocks_2_1 = blocks_2.next()) {\n                    var block = blocks_2_1.value;\n                    var ecBytes = block.getErrorCorrectionBytes();\n                    if (i < ecBytes.length) {\n                        result.appendBits(ecBytes[i], 8);\n                    }\n                }\n            }\n            catch (e_2_1) { e_2 = { error: e_2_1 }; }\n            finally {\n                try {\n                    if (blocks_2_1 && !blocks_2_1.done && (_b = blocks_2.return)) _b.call(blocks_2);\n                }\n                finally { if (e_2) throw e_2.error; }\n            }\n        }\n        if (numTotalBytes !== result.getSizeInBytes()) { // Should be same.\n            throw new WriterException('Interleaving error: ' + numTotalBytes + ' and ' +\n                result.getSizeInBytes() + ' differ.');\n        }\n        return result;\n    };\n    Encoder.generateECBytes = function (dataBytes, numEcBytesInBlock /*int*/) {\n        var numDataBytes = dataBytes.length;\n        var toEncode = new Int32Array(numDataBytes + numEcBytesInBlock); // int[numDataBytes + numEcBytesInBlock]\n        for (var i = 0; i < numDataBytes; i++) {\n            toEncode[i] = dataBytes[i] & 0xFF;\n        }\n        new ReedSolomonEncoder(GenericGF.QR_CODE_FIELD_256).encode(toEncode, numEcBytesInBlock);\n        var ecBytes = new Uint8Array(numEcBytesInBlock);\n        for (var i = 0; i < numEcBytesInBlock; i++) {\n            ecBytes[i] = /*(byte) */ toEncode[numDataBytes + i];\n        }\n        return ecBytes;\n    };\n    /**\n     * Append mode info. On success, store the result in \"bits\".\n     */\n    Encoder.appendModeInfo = function (mode, bits) {\n        bits.appendBits(mode.getBits(), 4);\n    };\n    /**\n     * Append length info. On success, store the result in \"bits\".\n     */\n    Encoder.appendLengthInfo = function (numLetters /*int*/, version, mode, bits) {\n        var numBits = mode.getCharacterCountBits(version);\n        if (numLetters >= (1 << numBits)) {\n            throw new WriterException(numLetters + ' is bigger than ' + ((1 << numBits) - 1));\n        }\n        bits.appendBits(numLetters, numBits);\n    };\n    /**\n     * Append \"bytes\" in \"mode\" mode (encoding) into \"bits\". On success, store the result in \"bits\".\n     */\n    Encoder.appendBytes = function (content, mode, bits, encoding) {\n        switch (mode) {\n            case Mode.NUMERIC:\n                Encoder.appendNumericBytes(content, bits);\n                break;\n            case Mode.ALPHANUMERIC:\n                Encoder.appendAlphanumericBytes(content, bits);\n                break;\n            case Mode.BYTE:\n                Encoder.append8BitBytes(content, bits, encoding);\n                break;\n            case Mode.KANJI:\n                Encoder.appendKanjiBytes(content, bits);\n                break;\n            default:\n                throw new WriterException('Invalid mode: ' + mode);\n        }\n    };\n    Encoder.getDigit = function (singleCharacter) {\n        return singleCharacter.charCodeAt(0) - 48;\n    };\n    Encoder.isDigit = function (singleCharacter) {\n        var cn = Encoder.getDigit(singleCharacter);\n        return cn >= 0 && cn <= 9;\n    };\n    Encoder.appendNumericBytes = function (content, bits) {\n        var length = content.length;\n        var i = 0;\n        while (i < length) {\n            var num1 = Encoder.getDigit(content.charAt(i));\n            if (i + 2 < length) {\n                // Encode three numeric letters in ten bits.\n                var num2 = Encoder.getDigit(content.charAt(i + 1));\n                var num3 = Encoder.getDigit(content.charAt(i + 2));\n                bits.appendBits(num1 * 100 + num2 * 10 + num3, 10);\n                i += 3;\n            }\n            else if (i + 1 < length) {\n                // Encode two numeric letters in seven bits.\n                var num2 = Encoder.getDigit(content.charAt(i + 1));\n                bits.appendBits(num1 * 10 + num2, 7);\n                i += 2;\n            }\n            else {\n                // Encode one numeric letter in four bits.\n                bits.appendBits(num1, 4);\n                i++;\n            }\n        }\n    };\n    Encoder.appendAlphanumericBytes = function (content, bits) {\n        var length = content.length;\n        var i = 0;\n        while (i < length) {\n            var code1 = Encoder.getAlphanumericCode(content.charCodeAt(i));\n            if (code1 === -1) {\n                throw new WriterException();\n            }\n            if (i + 1 < length) {\n                var code2 = Encoder.getAlphanumericCode(content.charCodeAt(i + 1));\n                if (code2 === -1) {\n                    throw new WriterException();\n                }\n                // Encode two alphanumeric letters in 11 bits.\n                bits.appendBits(code1 * 45 + code2, 11);\n                i += 2;\n            }\n            else {\n                // Encode one alphanumeric letter in six bits.\n                bits.appendBits(code1, 6);\n                i++;\n            }\n        }\n    };\n    Encoder.append8BitBytes = function (content, bits, encoding) {\n        var bytes;\n        try {\n            bytes = StringEncoding.encode(content, encoding);\n        }\n        catch (uee /*: UnsupportedEncodingException*/) {\n            throw new WriterException(uee);\n        }\n        for (var i = 0, length_2 = bytes.length; i !== length_2; i++) {\n            var b = bytes[i];\n            bits.appendBits(b, 8);\n        }\n    };\n    /**\n     * @throws WriterException\n     */\n    Encoder.appendKanjiBytes = function (content, bits) {\n        var bytes;\n        try {\n            bytes = StringEncoding.encode(content, CharacterSetECI.SJIS);\n        }\n        catch (uee /*: UnsupportedEncodingException*/) {\n            throw new WriterException(uee);\n        }\n        var length = bytes.length;\n        for (var i = 0; i < length; i += 2) {\n            var byte1 = bytes[i] & 0xFF;\n            var byte2 = bytes[i + 1] & 0xFF;\n            var code = ((byte1 << 8) & 0xFFFFFFFF) | byte2;\n            var subtracted = -1;\n            if (code >= 0x8140 && code <= 0x9ffc) {\n                subtracted = code - 0x8140;\n            }\n            else if (code >= 0xe040 && code <= 0xebbf) {\n                subtracted = code - 0xc140;\n            }\n            if (subtracted === -1) {\n                throw new WriterException('Invalid byte sequence');\n            }\n            var encoded = ((subtracted >> 8) * 0xc0) + (subtracted & 0xff);\n            bits.appendBits(encoded, 13);\n        }\n    };\n    Encoder.appendECI = function (eci, bits) {\n        bits.appendBits(Mode.ECI.getBits(), 4);\n        // This is correct for values up to 127, which is all we need now.\n        bits.appendBits(eci.getValue(), 8);\n    };\n    // The original table is defined in the table 5 of JISX0510:2004 (p.19).\n    Encoder.ALPHANUMERIC_TABLE = Int32Array.from([\n        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n        36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43,\n        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1,\n        -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,\n        25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,\n    ]);\n    Encoder.DEFAULT_BYTE_MODE_ENCODING = CharacterSetECI.UTF8.getName(); // \"ISO-8859-1\"\n    return Encoder;\n}());\nexport default Encoder;\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 */\nimport IllegalArgumentException from '../../IllegalArgumentException';\n/**\n * @author Satoru Takabayashi\n * @author Daniel Switkin\n * @author Sean Owen\n */\nvar MaskUtil = /** @class */ (function () {\n    function MaskUtil() {\n        // do nothing\n    }\n    /**\n     * Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and\n     * give penalty to them. Example: 00000 or 11111.\n     */\n    MaskUtil.applyMaskPenaltyRule1 = function (matrix) {\n        return MaskUtil.applyMaskPenaltyRule1Internal(matrix, true) + MaskUtil.applyMaskPenaltyRule1Internal(matrix, false);\n    };\n    /**\n     * Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give\n     * penalty to them. This is actually equivalent to the spec's rule, which is to find MxN blocks and give a\n     * penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block.\n     */\n    MaskUtil.applyMaskPenaltyRule2 = function (matrix) {\n        var penalty = 0;\n        var array = matrix.getArray();\n        var width = matrix.getWidth();\n        var height = matrix.getHeight();\n        for (var y = 0; y < height - 1; y++) {\n            var arrayY = array[y];\n            for (var x = 0; x < width - 1; x++) {\n                var value = arrayY[x];\n                if (value === arrayY[x + 1] && value === array[y + 1][x] && value === array[y + 1][x + 1]) {\n                    penalty++;\n                }\n            }\n        }\n        return MaskUtil.N2 * penalty;\n    };\n    /**\n     * Apply mask penalty rule 3 and return the penalty. Find consecutive runs of 1:1:3:1:1:4\n     * starting with black, or 4:1:1:3:1:1 starting with white, and give penalty to them.  If we\n     * find patterns like 000010111010000, we give penalty once.\n     */\n    MaskUtil.applyMaskPenaltyRule3 = function (matrix) {\n        var numPenalties = 0;\n        var array = matrix.getArray();\n        var width = matrix.getWidth();\n        var height = matrix.getHeight();\n        for (var y = 0; y < height; y++) {\n            for (var x = 0; x < width; x++) {\n                var arrayY = array[y]; // We can at least optimize this access\n                if (x + 6 < width &&\n                    arrayY[x] === 1 &&\n                    arrayY[x + 1] === 0 &&\n                    arrayY[x + 2] === 1 &&\n                    arrayY[x + 3] === 1 &&\n                    arrayY[x + 4] === 1 &&\n                    arrayY[x + 5] === 0 &&\n                    arrayY[x + 6] === 1 &&\n                    (MaskUtil.isWhiteHorizontal(arrayY, x - 4, x) || MaskUtil.isWhiteHorizontal(arrayY, x + 7, x + 11))) {\n                    numPenalties++;\n                }\n                if (y + 6 < height &&\n                    array[y][x] === 1 &&\n                    array[y + 1][x] === 0 &&\n                    array[y + 2][x] === 1 &&\n                    array[y + 3][x] === 1 &&\n                    array[y + 4][x] === 1 &&\n                    array[y + 5][x] === 0 &&\n                    array[y + 6][x] === 1 &&\n                    (MaskUtil.isWhiteVertical(array, x, y - 4, y) || MaskUtil.isWhiteVertical(array, x, y + 7, y + 11))) {\n                    numPenalties++;\n                }\n            }\n        }\n        return numPenalties * MaskUtil.N3;\n    };\n    MaskUtil.isWhiteHorizontal = function (rowArray, from /*int*/, to /*int*/) {\n        from = Math.max(from, 0);\n        to = Math.min(to, rowArray.length);\n        for (var i = from; i < to; i++) {\n            if (rowArray[i] === 1) {\n                return false;\n            }\n        }\n        return true;\n    };\n    MaskUtil.isWhiteVertical = function (array, col /*int*/, from /*int*/, to /*int*/) {\n        from = Math.max(from, 0);\n        to = Math.min(to, array.length);\n        for (var i = from; i < to; i++) {\n            if (array[i][col] === 1) {\n                return false;\n            }\n        }\n        return true;\n    };\n    /**\n     * Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give\n     * penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance.\n     */\n    MaskUtil.applyMaskPenaltyRule4 = function (matrix) {\n        var numDarkCells = 0;\n        var array = matrix.getArray();\n        var width = matrix.getWidth();\n        var height = matrix.getHeight();\n        for (var y = 0; y < height; y++) {\n            var arrayY = array[y];\n            for (var x = 0; x < width; x++) {\n                if (arrayY[x] === 1) {\n                    numDarkCells++;\n                }\n            }\n        }\n        var numTotalCells = matrix.getHeight() * matrix.getWidth();\n        var fivePercentVariances = Math.floor(Math.abs(numDarkCells * 2 - numTotalCells) * 10 / numTotalCells);\n        return fivePercentVariances * MaskUtil.N4;\n    };\n    /**\n     * Return the mask bit for \"getMaskPattern\" at \"x\" and \"y\". See 8.8 of JISX0510:2004 for mask\n     * pattern conditions.\n     */\n    MaskUtil.getDataMaskBit = function (maskPattern /*int*/, x /*int*/, y /*int*/) {\n        var intermediate; /*int*/\n        var temp; /*int*/\n        switch (maskPattern) {\n            case 0:\n                intermediate = (y + x) & 0x1;\n                break;\n            case 1:\n                intermediate = y & 0x1;\n                break;\n            case 2:\n                intermediate = x % 3;\n                break;\n            case 3:\n                intermediate = (y + x) % 3;\n                break;\n            case 4:\n                intermediate = (Math.floor(y / 2) + Math.floor(x / 3)) & 0x1;\n                break;\n            case 5:\n                temp = y * x;\n                intermediate = (temp & 0x1) + (temp % 3);\n                break;\n            case 6:\n                temp = y * x;\n                intermediate = ((temp & 0x1) + (temp % 3)) & 0x1;\n                break;\n            case 7:\n                temp = y * x;\n                intermediate = ((temp % 3) + ((y + x) & 0x1)) & 0x1;\n                break;\n            default:\n                throw new IllegalArgumentException('Invalid mask pattern: ' + maskPattern);\n        }\n        return intermediate === 0;\n    };\n    /**\n     * Helper function for applyMaskPenaltyRule1. We need this for doing this calculation in both\n     * vertical and horizontal orders respectively.\n     */\n    MaskUtil.applyMaskPenaltyRule1Internal = function (matrix, isHorizontal) {\n        var penalty = 0;\n        var iLimit = isHorizontal ? matrix.getHeight() : matrix.getWidth();\n        var jLimit = isHorizontal ? matrix.getWidth() : matrix.getHeight();\n        var array = matrix.getArray();\n        for (var i = 0; i < iLimit; i++) {\n            var numSameBitCells = 0;\n            var prevBit = -1;\n            for (var j = 0; j < jLimit; j++) {\n                var bit = isHorizontal ? array[i][j] : array[j][i];\n                if (bit === prevBit) {\n                    numSameBitCells++;\n                }\n                else {\n                    if (numSameBitCells >= 5) {\n                        penalty += MaskUtil.N1 + (numSameBitCells - 5);\n                    }\n                    numSameBitCells = 1; // Include the cell itself.\n                    prevBit = bit;\n                }\n            }\n            if (numSameBitCells >= 5) {\n                penalty += MaskUtil.N1 + (numSameBitCells - 5);\n            }\n        }\n        return penalty;\n    };\n    // Penalty weights from section 6.8.2.1\n    MaskUtil.N1 = 3;\n    MaskUtil.N2 = 3;\n    MaskUtil.N3 = 40;\n    MaskUtil.N4 = 10;\n    return MaskUtil;\n}());\nexport default MaskUtil;\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.qrcode.encoder {*/\nimport BitArray from '../../common/BitArray';\nimport Integer from '../../util/Integer';\nimport QRCode from './QRCode';\nimport MaskUtil from './MaskUtil';\nimport WriterException from '../../WriterException';\nimport IllegalArgumentException from '../../IllegalArgumentException';\n/**\n * @author satorux@google.com (Satoru Takabayashi) - creator\n * @author dswitkin@google.com (Daniel Switkin) - ported from C++\n */\nvar MatrixUtil = /** @class */ (function () {\n    function MatrixUtil() {\n        // do nothing\n    }\n    // Set all cells to -1 (TYPESCRIPTPORT: 255).  -1 (TYPESCRIPTPORT: 255) means that the cell is empty (not set yet).\n    //\n    // JAVAPORT: We shouldn't need to do this at all. The code should be rewritten to begin encoding\n    // with the ByteMatrix initialized all to zero.\n    MatrixUtil.clearMatrix = function (matrix) {\n        // TYPESCRIPTPORT: we use UintArray se changed here from -1 to 255\n        matrix.clear(/*(byte) */ /*-1*/ 255);\n    };\n    // Build 2D matrix of QR Code from \"dataBits\" with \"ecLevel\", \"version\" and \"getMaskPattern\". On\n    // success, store the result in \"matrix\" and return true.\n    MatrixUtil.buildMatrix = function (dataBits, ecLevel, version, maskPattern /*int*/, matrix) {\n        MatrixUtil.clearMatrix(matrix);\n        MatrixUtil.embedBasicPatterns(version, matrix);\n        // Type information appear with any version.\n        MatrixUtil.embedTypeInfo(ecLevel, maskPattern, matrix);\n        // Version info appear if version >= 7.\n        MatrixUtil.maybeEmbedVersionInfo(version, matrix);\n        // Data should be embedded at end.\n        MatrixUtil.embedDataBits(dataBits, maskPattern, matrix);\n    };\n    // Embed basic patterns. On success, modify the matrix and return true.\n    // The basic patterns are:\n    // - Position detection patterns\n    // - Timing patterns\n    // - Dark dot at the left bottom corner\n    // - Position adjustment patterns, if need be\n    MatrixUtil.embedBasicPatterns = function (version, matrix) {\n        // Let's get started with embedding big squares at corners.\n        MatrixUtil.embedPositionDetectionPatternsAndSeparators(matrix);\n        // Then, embed the dark dot at the left bottom corner.\n        MatrixUtil.embedDarkDotAtLeftBottomCorner(matrix);\n        // Position adjustment patterns appear if version >= 2.\n        MatrixUtil.maybeEmbedPositionAdjustmentPatterns(version, matrix);\n        // Timing patterns should be embedded after position adj. patterns.\n        MatrixUtil.embedTimingPatterns(matrix);\n    };\n    // Embed type information. On success, modify the matrix.\n    MatrixUtil.embedTypeInfo = function (ecLevel, maskPattern /*int*/, matrix) {\n        var typeInfoBits = new BitArray();\n        MatrixUtil.makeTypeInfoBits(ecLevel, maskPattern, typeInfoBits);\n        for (var i = 0, size = typeInfoBits.getSize(); i < size; ++i) {\n            // Place bits in LSB to MSB order.  LSB (least significant bit) is the last value in\n            // \"typeInfoBits\".\n            var bit = typeInfoBits.get(typeInfoBits.getSize() - 1 - i);\n            // Type info bits at the left top corner. See 8.9 of JISX0510:2004 (p.46).\n            var coordinates = MatrixUtil.TYPE_INFO_COORDINATES[i];\n            var x1 = coordinates[0];\n            var y1 = coordinates[1];\n            matrix.setBoolean(x1, y1, bit);\n            if (i < 8) {\n                // Right top corner.\n                var x2 = matrix.getWidth() - i - 1;\n                var y2 = 8;\n                matrix.setBoolean(x2, y2, bit);\n            }\n            else {\n                // Left bottom corner.\n                var x2 = 8;\n                var y2 = matrix.getHeight() - 7 + (i - 8);\n                matrix.setBoolean(x2, y2, bit);\n            }\n        }\n    };\n    // Embed version information if need be. On success, modify the matrix and return true.\n    // See 8.10 of JISX0510:2004 (p.47) for how to embed version information.\n    MatrixUtil.maybeEmbedVersionInfo = function (version, matrix) {\n        if (version.getVersionNumber() < 7) { // Version info is necessary if version >= 7.\n            return; // Don't need version info.\n        }\n        var versionInfoBits = new BitArray();\n        MatrixUtil.makeVersionInfoBits(version, versionInfoBits);\n        var bitIndex = 6 * 3 - 1; // It will decrease from 17 to 0.\n        for (var i = 0; i < 6; ++i) {\n            for (var j = 0; j < 3; ++j) {\n                // Place bits in LSB (least significant bit) to MSB order.\n                var bit = versionInfoBits.get(bitIndex);\n                bitIndex--;\n                // Left bottom corner.\n                matrix.setBoolean(i, matrix.getHeight() - 11 + j, bit);\n                // Right bottom corner.\n                matrix.setBoolean(matrix.getHeight() - 11 + j, i, bit);\n            }\n        }\n    };\n    // Embed \"dataBits\" using \"getMaskPattern\". On success, modify the matrix and return true.\n    // For debugging purposes, it skips masking process if \"getMaskPattern\" is -1(TYPESCRIPTPORT: 255).\n    // See 8.7 of JISX0510:2004 (p.38) for how to embed data bits.\n    MatrixUtil.embedDataBits = function (dataBits, maskPattern /*int*/, matrix) {\n        var bitIndex = 0;\n        var direction = -1;\n        // Start from the right bottom cell.\n        var x = matrix.getWidth() - 1;\n        var y = matrix.getHeight() - 1;\n        while (x > 0) {\n            // Skip the vertical timing pattern.\n            if (x === 6) {\n                x -= 1;\n            }\n            while (y >= 0 && y < matrix.getHeight()) {\n                for (var i = 0; i < 2; ++i) {\n                    var xx = x - i;\n                    // Skip the cell if it's not empty.\n                    if (!MatrixUtil.isEmpty(matrix.get(xx, y))) {\n                        continue;\n                    }\n                    var bit = void 0;\n                    if (bitIndex < dataBits.getSize()) {\n                        bit = dataBits.get(bitIndex);\n                        ++bitIndex;\n                    }\n                    else {\n                        // Padding bit. If there is no bit left, we'll fill the left cells with 0, as described\n                        // in 8.4.9 of JISX0510:2004 (p. 24).\n                        bit = false;\n                    }\n                    // Skip masking if mask_pattern is -1 (TYPESCRIPTPORT: 255).\n                    if (maskPattern !== 255 && MaskUtil.getDataMaskBit(maskPattern, xx, y)) {\n                        bit = !bit;\n                    }\n                    matrix.setBoolean(xx, y, bit);\n                }\n                y += direction;\n            }\n            direction = -direction; // Reverse the direction.\n            y += direction;\n            x -= 2; // Move to the left.\n        }\n        // All bits should be consumed.\n        if (bitIndex !== dataBits.getSize()) {\n            throw new WriterException('Not all bits consumed: ' + bitIndex + '/' + dataBits.getSize());\n        }\n    };\n    // Return the position of the most significant bit set (one: to) in the \"value\". The most\n    // significant bit is position 32. If there is no bit set, return 0. Examples:\n    // - findMSBSet(0) => 0\n    // - findMSBSet(1) => 1\n    // - findMSBSet(255) => 8\n    MatrixUtil.findMSBSet = function (value /*int*/) {\n        return 32 - Integer.numberOfLeadingZeros(value);\n    };\n    // Calculate BCH (Bose-Chaudhuri-Hocquenghem) code for \"value\" using polynomial \"poly\". The BCH\n    // code is used for encoding type information and version information.\n    // Example: Calculation of version information of 7.\n    // f(x) is created from 7.\n    //   - 7 = 000111 in 6 bits\n    //   - f(x) = x^2 + x^1 + x^0\n    // g(x) is given by the standard (p. 67)\n    //   - g(x) = x^12 + x^11 + x^10 + x^9 + x^8 + x^5 + x^2 + 1\n    // Multiply f(x) by x^(18 - 6)\n    //   - f'(x) = f(x) * x^(18 - 6)\n    //   - f'(x) = x^14 + x^13 + x^12\n    // Calculate the remainder of f'(x) / g(x)\n    //         x^2\n    //         __________________________________________________\n    //   g(x) )x^14 + x^13 + x^12\n    //         x^14 + x^13 + x^12 + x^11 + x^10 + x^7 + x^4 + x^2\n    //         --------------------------------------------------\n    //                              x^11 + x^10 + x^7 + x^4 + x^2\n    //\n    // The remainder is x^11 + x^10 + x^7 + x^4 + x^2\n    // Encode it in binary: 110010010100\n    // The return value is 0xc94 (1100 1001 0100)\n    //\n    // Since all coefficients in the polynomials are 1 or 0, we can do the calculation by bit\n    // operations. We don't care if coefficients are positive or negative.\n    MatrixUtil.calculateBCHCode = function (value /*int*/, poly /*int*/) {\n        if (poly === 0) {\n            throw new IllegalArgumentException('0 polynomial');\n        }\n        // If poly is \"1 1111 0010 0101\" (version info poly), msbSetInPoly is 13. We'll subtract 1\n        // from 13 to make it 12.\n        var msbSetInPoly = MatrixUtil.findMSBSet(poly);\n        value <<= msbSetInPoly - 1;\n        // Do the division business using exclusive-or operations.\n        while (MatrixUtil.findMSBSet(value) >= msbSetInPoly) {\n            value ^= poly << (MatrixUtil.findMSBSet(value) - msbSetInPoly);\n        }\n        // Now the \"value\" is the remainder (i.e. the BCH code)\n        return value;\n    };\n    // Make bit vector of type information. On success, store the result in \"bits\" and return true.\n    // Encode error correction level and mask pattern. See 8.9 of\n    // JISX0510:2004 (p.45) for details.\n    MatrixUtil.makeTypeInfoBits = function (ecLevel, maskPattern /*int*/, bits) {\n        if (!QRCode.isValidMaskPattern(maskPattern)) {\n            throw new WriterException('Invalid mask pattern');\n        }\n        var typeInfo = (ecLevel.getBits() << 3) | maskPattern;\n        bits.appendBits(typeInfo, 5);\n        var bchCode = MatrixUtil.calculateBCHCode(typeInfo, MatrixUtil.TYPE_INFO_POLY);\n        bits.appendBits(bchCode, 10);\n        var maskBits = new BitArray();\n        maskBits.appendBits(MatrixUtil.TYPE_INFO_MASK_PATTERN, 15);\n        bits.xor(maskBits);\n        if (bits.getSize() !== 15) { // Just in case.\n            throw new WriterException('should not happen but we got: ' + bits.getSize());\n        }\n    };\n    // Make bit vector of version information. On success, store the result in \"bits\" and return true.\n    // See 8.10 of JISX0510:2004 (p.45) for details.\n    MatrixUtil.makeVersionInfoBits = function (version, bits) {\n        bits.appendBits(version.getVersionNumber(), 6);\n        var bchCode = MatrixUtil.calculateBCHCode(version.getVersionNumber(), MatrixUtil.VERSION_INFO_POLY);\n        bits.appendBits(bchCode, 12);\n        if (bits.getSize() !== 18) { // Just in case.\n            throw new WriterException('should not happen but we got: ' + bits.getSize());\n        }\n    };\n    // Check if \"value\" is empty.\n    MatrixUtil.isEmpty = function (value /*int*/) {\n        return value === 255; // -1\n    };\n    MatrixUtil.embedTimingPatterns = function (matrix) {\n        // -8 is for skipping position detection patterns (7: size), and two horizontal/vertical\n        // separation patterns (1: size). Thus, 8 = 7 + 1.\n        for (var i = 8; i < matrix.getWidth() - 8; ++i) {\n            var bit = (i + 1) % 2;\n            // Horizontal line.\n            if (MatrixUtil.isEmpty(matrix.get(i, 6))) {\n                matrix.setNumber(i, 6, bit);\n            }\n            // Vertical line.\n            if (MatrixUtil.isEmpty(matrix.get(6, i))) {\n                matrix.setNumber(6, i, bit);\n            }\n        }\n    };\n    // Embed the lonely dark dot at left bottom corner. JISX0510:2004 (p.46)\n    MatrixUtil.embedDarkDotAtLeftBottomCorner = function (matrix) {\n        if (matrix.get(8, matrix.getHeight() - 8) === 0) {\n            throw new WriterException();\n        }\n        matrix.setNumber(8, matrix.getHeight() - 8, 1);\n    };\n    MatrixUtil.embedHorizontalSeparationPattern = function (xStart /*int*/, yStart /*int*/, matrix) {\n        for (var x = 0; x < 8; ++x) {\n            if (!MatrixUtil.isEmpty(matrix.get(xStart + x, yStart))) {\n                throw new WriterException();\n            }\n            matrix.setNumber(xStart + x, yStart, 0);\n        }\n    };\n    MatrixUtil.embedVerticalSeparationPattern = function (xStart /*int*/, yStart /*int*/, matrix) {\n        for (var y = 0; y < 7; ++y) {\n            if (!MatrixUtil.isEmpty(matrix.get(xStart, yStart + y))) {\n                throw new WriterException();\n            }\n            matrix.setNumber(xStart, yStart + y, 0);\n        }\n    };\n    MatrixUtil.embedPositionAdjustmentPattern = function (xStart /*int*/, yStart /*int*/, matrix) {\n        for (var y = 0; y < 5; ++y) {\n            var patternY = MatrixUtil.POSITION_ADJUSTMENT_PATTERN[y];\n            for (var x = 0; x < 5; ++x) {\n                matrix.setNumber(xStart + x, yStart + y, patternY[x]);\n            }\n        }\n    };\n    MatrixUtil.embedPositionDetectionPattern = function (xStart /*int*/, yStart /*int*/, matrix) {\n        for (var y = 0; y < 7; ++y) {\n            var patternY = MatrixUtil.POSITION_DETECTION_PATTERN[y];\n            for (var x = 0; x < 7; ++x) {\n                matrix.setNumber(xStart + x, yStart + y, patternY[x]);\n            }\n        }\n    };\n    // Embed position detection patterns and surrounding vertical/horizontal separators.\n    MatrixUtil.embedPositionDetectionPatternsAndSeparators = function (matrix) {\n        // Embed three big squares at corners.\n        var pdpWidth = MatrixUtil.POSITION_DETECTION_PATTERN[0].length;\n        // Left top corner.\n        MatrixUtil.embedPositionDetectionPattern(0, 0, matrix);\n        // Right top corner.\n        MatrixUtil.embedPositionDetectionPattern(matrix.getWidth() - pdpWidth, 0, matrix);\n        // Left bottom corner.\n        MatrixUtil.embedPositionDetectionPattern(0, matrix.getWidth() - pdpWidth, matrix);\n        // Embed horizontal separation patterns around the squares.\n        var hspWidth = 8;\n        // Left top corner.\n        MatrixUtil.embedHorizontalSeparationPattern(0, hspWidth - 1, matrix);\n        // Right top corner.\n        MatrixUtil.embedHorizontalSeparationPattern(matrix.getWidth() - hspWidth, hspWidth - 1, matrix);\n        // Left bottom corner.\n        MatrixUtil.embedHorizontalSeparationPattern(0, matrix.getWidth() - hspWidth, matrix);\n        // Embed vertical separation patterns around the squares.\n        var vspSize = 7;\n        // Left top corner.\n        MatrixUtil.embedVerticalSeparationPattern(vspSize, 0, matrix);\n        // Right top corner.\n        MatrixUtil.embedVerticalSeparationPattern(matrix.getHeight() - vspSize - 1, 0, matrix);\n        // Left bottom corner.\n        MatrixUtil.embedVerticalSeparationPattern(vspSize, matrix.getHeight() - vspSize, matrix);\n    };\n    // Embed position adjustment patterns if need be.\n    MatrixUtil.maybeEmbedPositionAdjustmentPatterns = function (version, matrix) {\n        if (version.getVersionNumber() < 2) { // The patterns appear if version >= 2\n            return;\n        }\n        var index = version.getVersionNumber() - 1;\n        var coordinates = MatrixUtil.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];\n        for (var i = 0, length_1 = coordinates.length; i !== length_1; i++) {\n            var y = coordinates[i];\n            if (y >= 0) {\n                for (var j = 0; j !== length_1; j++) {\n                    var x = coordinates[j];\n                    if (x >= 0 && MatrixUtil.isEmpty(matrix.get(x, y))) {\n                        // If the cell is unset, we embed the position adjustment pattern here.\n                        // -2 is necessary since the x/y coordinates point to the center of the pattern, not the\n                        // left top corner.\n                        MatrixUtil.embedPositionAdjustmentPattern(x - 2, y - 2, matrix);\n                    }\n                }\n            }\n        }\n    };\n    MatrixUtil.POSITION_DETECTION_PATTERN = Array.from([\n        Int32Array.from([1, 1, 1, 1, 1, 1, 1]),\n        Int32Array.from([1, 0, 0, 0, 0, 0, 1]),\n        Int32Array.from([1, 0, 1, 1, 1, 0, 1]),\n        Int32Array.from([1, 0, 1, 1, 1, 0, 1]),\n        Int32Array.from([1, 0, 1, 1, 1, 0, 1]),\n        Int32Array.from([1, 0, 0, 0, 0, 0, 1]),\n        Int32Array.from([1, 1, 1, 1, 1, 1, 1]),\n    ]);\n    MatrixUtil.POSITION_ADJUSTMENT_PATTERN = Array.from([\n        Int32Array.from([1, 1, 1, 1, 1]),\n        Int32Array.from([1, 0, 0, 0, 1]),\n        Int32Array.from([1, 0, 1, 0, 1]),\n        Int32Array.from([1, 0, 0, 0, 1]),\n        Int32Array.from([1, 1, 1, 1, 1]),\n    ]);\n    // From Appendix E. Table 1, JIS0510X:2004 (71: p). The table was double-checked by komatsu.\n    MatrixUtil.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE = Array.from([\n        Int32Array.from([-1, -1, -1, -1, -1, -1, -1]),\n        Int32Array.from([6, 18, -1, -1, -1, -1, -1]),\n        Int32Array.from([6, 22, -1, -1, -1, -1, -1]),\n        Int32Array.from([6, 26, -1, -1, -1, -1, -1]),\n        Int32Array.from([6, 30, -1, -1, -1, -1, -1]),\n        Int32Array.from([6, 34, -1, -1, -1, -1, -1]),\n        Int32Array.from([6, 22, 38, -1, -1, -1, -1]),\n        Int32Array.from([6, 24, 42, -1, -1, -1, -1]),\n        Int32Array.from([6, 26, 46, -1, -1, -1, -1]),\n        Int32Array.from([6, 28, 50, -1, -1, -1, -1]),\n        Int32Array.from([6, 30, 54, -1, -1, -1, -1]),\n        Int32Array.from([6, 32, 58, -1, -1, -1, -1]),\n        Int32Array.from([6, 34, 62, -1, -1, -1, -1]),\n        Int32Array.from([6, 26, 46, 66, -1, -1, -1]),\n        Int32Array.from([6, 26, 48, 70, -1, -1, -1]),\n        Int32Array.from([6, 26, 50, 74, -1, -1, -1]),\n        Int32Array.from([6, 30, 54, 78, -1, -1, -1]),\n        Int32Array.from([6, 30, 56, 82, -1, -1, -1]),\n        Int32Array.from([6, 30, 58, 86, -1, -1, -1]),\n        Int32Array.from([6, 34, 62, 90, -1, -1, -1]),\n        Int32Array.from([6, 28, 50, 72, 94, -1, -1]),\n        Int32Array.from([6, 26, 50, 74, 98, -1, -1]),\n        Int32Array.from([6, 30, 54, 78, 102, -1, -1]),\n        Int32Array.from([6, 28, 54, 80, 106, -1, -1]),\n        Int32Array.from([6, 32, 58, 84, 110, -1, -1]),\n        Int32Array.from([6, 30, 58, 86, 114, -1, -1]),\n        Int32Array.from([6, 34, 62, 90, 118, -1, -1]),\n        Int32Array.from([6, 26, 50, 74, 98, 122, -1]),\n        Int32Array.from([6, 30, 54, 78, 102, 126, -1]),\n        Int32Array.from([6, 26, 52, 78, 104, 130, -1]),\n        Int32Array.from([6, 30, 56, 82, 108, 134, -1]),\n        Int32Array.from([6, 34, 60, 86, 112, 138, -1]),\n        Int32Array.from([6, 30, 58, 86, 114, 142, -1]),\n        Int32Array.from([6, 34, 62, 90, 118, 146, -1]),\n        Int32Array.from([6, 30, 54, 78, 102, 126, 150]),\n        Int32Array.from([6, 24, 50, 76, 102, 128, 154]),\n        Int32Array.from([6, 28, 54, 80, 106, 132, 158]),\n        Int32Array.from([6, 32, 58, 84, 110, 136, 162]),\n        Int32Array.from([6, 26, 54, 82, 110, 138, 166]),\n        Int32Array.from([6, 30, 58, 86, 114, 142, 170]),\n    ]);\n    // Type info cells at the left top corner.\n    MatrixUtil.TYPE_INFO_COORDINATES = Array.from([\n        Int32Array.from([8, 0]),\n        Int32Array.from([8, 1]),\n        Int32Array.from([8, 2]),\n        Int32Array.from([8, 3]),\n        Int32Array.from([8, 4]),\n        Int32Array.from([8, 5]),\n        Int32Array.from([8, 7]),\n        Int32Array.from([8, 8]),\n        Int32Array.from([7, 8]),\n        Int32Array.from([5, 8]),\n        Int32Array.from([4, 8]),\n        Int32Array.from([3, 8]),\n        Int32Array.from([2, 8]),\n        Int32Array.from([1, 8]),\n        Int32Array.from([0, 8]),\n    ]);\n    // From Appendix D in JISX0510:2004 (p. 67)\n    MatrixUtil.VERSION_INFO_POLY = 0x1f25; // 1 1111 0010 0101\n    // From Appendix C in JISX0510:2004 (p.65).\n    MatrixUtil.TYPE_INFO_POLY = 0x537;\n    MatrixUtil.TYPE_INFO_MASK_PATTERN = 0x5412;\n    return MatrixUtil;\n}());\nexport default MatrixUtil;\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 */\nimport StringBuilder from '../../util/StringBuilder';\n/**\n * @author satorux@google.com (Satoru Takabayashi) - creator\n * @author dswitkin@google.com (Daniel Switkin) - ported from C++\n */\nvar QRCode = /** @class */ (function () {\n    function QRCode() {\n        this.maskPattern = -1;\n    }\n    QRCode.prototype.getMode = function () {\n        return this.mode;\n    };\n    QRCode.prototype.getECLevel = function () {\n        return this.ecLevel;\n    };\n    QRCode.prototype.getVersion = function () {\n        return this.version;\n    };\n    QRCode.prototype.getMaskPattern = function () {\n        return this.maskPattern;\n    };\n    QRCode.prototype.getMatrix = function () {\n        return this.matrix;\n    };\n    /*@Override*/\n    QRCode.prototype.toString = function () {\n        var result = new StringBuilder(); // (200)\n        result.append('<<\\n');\n        result.append(' mode: ');\n        result.append(this.mode ? this.mode.toString() : 'null');\n        result.append('\\n ecLevel: ');\n        result.append(this.ecLevel ? this.ecLevel.toString() : 'null');\n        result.append('\\n version: ');\n        result.append(this.version ? this.version.toString() : 'null');\n        result.append('\\n maskPattern: ');\n        result.append(this.maskPattern.toString());\n        if (this.matrix) {\n            result.append('\\n matrix:\\n');\n            result.append(this.matrix.toString());\n        }\n        else {\n            result.append('\\n matrix: null\\n');\n        }\n        result.append('>>\\n');\n        return result.toString();\n    };\n    QRCode.prototype.setMode = function (value) {\n        this.mode = value;\n    };\n    QRCode.prototype.setECLevel = function (value) {\n        this.ecLevel = value;\n    };\n    QRCode.prototype.setVersion = function (version) {\n        this.version = version;\n    };\n    QRCode.prototype.setMaskPattern = function (value /*int*/) {\n        this.maskPattern = value;\n    };\n    QRCode.prototype.setMatrix = function (value) {\n        this.matrix = value;\n    };\n    // Check if \"mask_pattern\" is valid.\n    QRCode.isValidMaskPattern = function (maskPattern /*int*/) {\n        return maskPattern >= 0 && maskPattern < QRCode.NUM_MASK_PATTERNS;\n    };\n    QRCode.NUM_MASK_PATTERNS = 8;\n    return QRCode;\n}());\nexport default QRCode;\n"],"names":[],"sourceRoot":""}