Socket
Socket
Sign inDemoInstall

@zxing/library

Package Overview
Dependencies
Maintainers
3
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zxing/library - npm Package Compare versions

Comparing version 0.3.2 to 0.5.0

_config.yml

4

esm5/browser/BrowserCodeReader.d.ts

@@ -5,2 +5,3 @@ import Reader from './../core/Reader';

import VideoInputDevice from './VideoInputDevice';
import DecodeHintType from '../core/DecodeHintType';
/**

@@ -15,2 +16,3 @@ * Base class for browser code reader.

private timeBetweenScansMillis;
private hints;
private videoElement;

@@ -32,3 +34,3 @@ private imageElement;

*/
constructor(reader: Reader, timeBetweenScansMillis?: number);
constructor(reader: Reader, timeBetweenScansMillis?: number, hints?: Map<DecodeHintType, any>);
/**

@@ -35,0 +37,0 @@ * Obtain the list of available devices with type 'videoinput'.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const BinaryBitmap_1 = require("./../core/BinaryBitmap");
const HybridBinarizer_1 = require("./../core/common/HybridBinarizer");
const Exception_1 = require("./../core/Exception");
const HTMLCanvasElementLuminanceSource_1 = require("./HTMLCanvasElementLuminanceSource");
const VideoInputDevice_1 = require("./VideoInputDevice");
var BinaryBitmap_1 = require("./../core/BinaryBitmap");
var HybridBinarizer_1 = require("./../core/common/HybridBinarizer");
var Exception_1 = require("./../core/Exception");
var HTMLCanvasElementLuminanceSource_1 = require("./HTMLCanvasElementLuminanceSource");
var VideoInputDevice_1 = require("./VideoInputDevice");
/**

@@ -14,3 +14,3 @@ * Base class for browser code reader.

*/
class BrowserCodeReader {
var BrowserCodeReader = /** @class */ (function () {
/**

@@ -23,5 +23,7 @@ * Creates an instance of BrowserCodeReader.

*/
constructor(reader, timeBetweenScansMillis = 500) {
function BrowserCodeReader(reader, timeBetweenScansMillis, hints) {
if (timeBetweenScansMillis === void 0) { timeBetweenScansMillis = 500; }
this.reader = reader;
this.timeBetweenScansMillis = timeBetweenScansMillis;
this.hints = hints;
}

@@ -35,12 +37,12 @@ /**

*/
getVideoInputDevices() {
return new Promise((resolve, reject) => {
BrowserCodeReader.prototype.getVideoInputDevices = function () {
return new Promise(function (resolve, reject) {
navigator.mediaDevices.enumerateDevices()
.then((devices) => {
const sources = new Array();
let c = 0;
for (let i = 0, length = devices.length; i !== length; i++) {
const device = devices[i];
.then(function (devices) {
var sources = new Array();
var c = 0;
for (var i = 0, length_1 = devices.length; i !== length_1; i++) {
var device = devices[i];
if (device.kind === 'videoinput') {
sources.push(new VideoInputDevice_1.default(device.deviceId, device.label || `Video source ${c}`));
sources.push(new VideoInputDevice_1.default(device.deviceId, device.label || "Video source " + c));
c++;

@@ -51,7 +53,7 @@ }

})
.catch((err) => {
.catch(function (err) {
reject(err);
});
});
}
};
/**

@@ -66,6 +68,6 @@ * Decodes the barcode from the device specified by deviceId while showing the video in the specified video element.

*/
decodeFromInputVideoDevice(deviceId, videoElement) {
BrowserCodeReader.prototype.decodeFromInputVideoDevice = function (deviceId, videoElement) {
this.reset();
this.prepareVideoElement(videoElement);
let constraints;
var constraints;
if (undefined === deviceId) {

@@ -81,9 +83,9 @@ constraints = {

}
const me = this;
return new Promise((resolve, reject) => {
var me = this;
return new Promise(function (resolve, reject) {
navigator.mediaDevices.getUserMedia(constraints)
.then((stream) => {
.then(function (stream) {
me.stream = stream;
me.videoElement.srcObject = stream;
me.videoPlayingEventListener = () => {
me.videoPlayingEventListener = function () {
me.decodeOnceWithDelay(resolve, reject);

@@ -94,7 +96,7 @@ };

})
.catch((error) => {
.catch(function (error) {
reject(error);
});
});
}
};
/**

@@ -109,8 +111,8 @@ * Decodes a barcode form a video url.

*/
decodeFromVideoSource(videoUrl, videoElement) {
BrowserCodeReader.prototype.decodeFromVideoSource = function (videoUrl, videoElement) {
this.reset();
this.prepareVideoElement(videoElement);
const me = this;
return new Promise((resolve, reject) => {
me.videoPlayEndedEventListener = () => {
var me = this;
return new Promise(function (resolve, reject) {
me.videoPlayEndedEventListener = function () {
me.stop();

@@ -120,3 +122,3 @@ reject(new Exception_1.default(Exception_1.default.NotFoundException));

me.videoElement.addEventListener('ended', me.videoPlayEndedEventListener);
me.videoPlayingEventListener = () => {
me.videoPlayingEventListener = function () {
me.decodeOnceWithDelay(resolve, reject);

@@ -128,8 +130,8 @@ };

});
}
prepareVideoElement(videoElement) {
};
BrowserCodeReader.prototype.prepareVideoElement = function (videoElement) {
if (undefined === videoElement) {
this.videoElement = document.createElement('video');
this.videoElement.width = 200;
this.videoElement.height = 200;
this.videoElement.width = 640;
this.videoElement.height = 480;
}

@@ -147,14 +149,14 @@ else if (typeof videoElement === 'string') {

this.videoElement.setAttribute('autofocus', 'true');
}
getMediaElement(mediaElementId, type) {
const mediaElement = document.getElementById(mediaElementId);
};
BrowserCodeReader.prototype.getMediaElement = function (mediaElementId, type) {
var mediaElement = document.getElementById(mediaElementId);
if (null === mediaElement) {
throw new Exception_1.default(Exception_1.default.ArgumentException, `element with id '${mediaElementId}' not found`);
throw new Exception_1.default(Exception_1.default.ArgumentException, "element with id '" + mediaElementId + "' not found");
}
if (mediaElement.nodeName.toLowerCase() !== type.toLowerCase()) {
console.log(mediaElement.nodeName);
throw new Exception_1.default(Exception_1.default.ArgumentException, `element with id '${mediaElementId}' must be an ${type} element`);
throw new Exception_1.default(Exception_1.default.ArgumentException, "element with id '" + mediaElementId + "' must be an " + type + " element");
}
return mediaElement;
}
};
/**

@@ -169,3 +171,4 @@ * Decodes the barcode from an image.

*/
decodeFromImage(imageElement, imageUrl) {
BrowserCodeReader.prototype.decodeFromImage = function (imageElement, imageUrl) {
var _this = this;
this.reset();

@@ -176,6 +179,6 @@ if (undefined === imageElement && undefined === imageUrl) {

this.prepareImageElement(imageElement);
const me = this;
return new Promise((resolve, reject) => {
var me = this;
return new Promise(function (resolve, reject) {
if (undefined !== imageUrl) {
me.imageLoadedEventListener = () => {
me.imageLoadedEventListener = function () {
me.decodeOnce(resolve, reject, false, true);

@@ -186,11 +189,11 @@ };

}
else if (this.isImageLoaded(this.imageElement)) {
else if (_this.isImageLoaded(_this.imageElement)) {
me.decodeOnce(resolve, reject, false, true);
}
else {
throw new Exception_1.default(Exception_1.default.ArgumentException, `either src or a loaded img should be provided`);
throw new Exception_1.default(Exception_1.default.ArgumentException, "either src or a loaded img should be provided");
}
});
}
isImageLoaded(img) {
};
BrowserCodeReader.prototype.isImageLoaded = function (img) {
// During the onload event, IE correctly identifies any images that

@@ -210,4 +213,4 @@ // weren’t downloaded as not complete. Others should too. Gecko-based

return true;
}
prepareImageElement(imageElement) {
};
BrowserCodeReader.prototype.prepareImageElement = function (imageElement) {
if (undefined === imageElement) {

@@ -224,7 +227,9 @@ this.imageElement = document.createElement('img');

}
}
decodeOnceWithDelay(resolve, reject) {
};
BrowserCodeReader.prototype.decodeOnceWithDelay = function (resolve, reject) {
this.timeoutHandler = window.setTimeout(this.decodeOnce.bind(this, resolve, reject), this.timeBetweenScansMillis);
}
decodeOnce(resolve, reject, retryIfNotFound = true, retryIfChecksumOrFormatError = true) {
};
BrowserCodeReader.prototype.decodeOnce = function (resolve, reject, retryIfNotFound, retryIfChecksumOrFormatError) {
if (retryIfNotFound === void 0) { retryIfNotFound = true; }
if (retryIfChecksumOrFormatError === void 0) { retryIfChecksumOrFormatError = true; }
if (undefined === this.canvasElementContext) {

@@ -234,6 +239,6 @@ this.prepareCaptureCanvas();

this.canvasElementContext.drawImage(this.videoElement || this.imageElement, 0, 0);
const luminanceSource = new HTMLCanvasElementLuminanceSource_1.default(this.canvasElement);
const binaryBitmap = new BinaryBitmap_1.default(new HybridBinarizer_1.default(luminanceSource));
var luminanceSource = new HTMLCanvasElementLuminanceSource_1.default(this.canvasElement);
var binaryBitmap = new BinaryBitmap_1.default(new HybridBinarizer_1.default(luminanceSource));
try {
const result = this.readerDecode(binaryBitmap);
var result = this.readerDecode(binaryBitmap);
resolve(result);

@@ -255,9 +260,9 @@ }

}
}
readerDecode(binaryBitmap) {
return this.reader.decode(binaryBitmap);
}
prepareCaptureCanvas() {
const canvasElement = document.createElement('canvas');
let width, height;
};
BrowserCodeReader.prototype.readerDecode = function (binaryBitmap) {
return this.reader.decode(binaryBitmap, this.hints);
};
BrowserCodeReader.prototype.prepareCaptureCanvas = function () {
var canvasElement = document.createElement('canvas');
var width, height;
if (undefined !== this.videoElement) {

@@ -271,4 +276,4 @@ width = this.videoElement.videoWidth;

}
canvasElement.style.width = `${width}px`;
canvasElement.style.height = `${height}px`;
canvasElement.style.width = width + "px";
canvasElement.style.height = height + "px";
canvasElement.width = width;

@@ -279,4 +284,4 @@ canvasElement.height = height;

// this.videoElement.parentElement.appendChild(this.canvasElement)
}
stop() {
};
BrowserCodeReader.prototype.stop = function () {
if (undefined !== this.timeoutHandler) {

@@ -290,3 +295,3 @@ window.clearTimeout(this.timeoutHandler);

}
}
};
/**

@@ -297,3 +302,3 @@ * Resets the code reader to the initial state. Cancels any ongoing barcode scanning from video or camera.

*/
reset() {
BrowserCodeReader.prototype.reset = function () {
this.stop();

@@ -321,5 +326,6 @@ if (undefined !== this.videoPlayEndedEventListener && undefined !== this.videoElement) {

this.canvasElement = undefined;
}
}
};
return BrowserCodeReader;
}());
exports.default = BrowserCodeReader;
//# sourceMappingURL=BrowserCodeReader.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const QRCodeReader_1 = require("./../core/qrcode/QRCodeReader");
const VideoInputDevice_1 = require("./VideoInputDevice");
var QRCodeReader_1 = require("./../core/qrcode/QRCodeReader");
var VideoInputDevice_1 = require("./VideoInputDevice");
exports.VideoInputDevice = VideoInputDevice_1.default;
const BrowserCodeReader_1 = require("./BrowserCodeReader");
var BrowserCodeReader_1 = require("./BrowserCodeReader");
/**

@@ -13,3 +23,4 @@ * QR Code reader to use from browser.

*/
class BrowserQRCodeReader extends BrowserCodeReader_1.default {
var BrowserQRCodeReader = /** @class */ (function (_super) {
__extends(BrowserQRCodeReader, _super);
/**

@@ -21,7 +32,9 @@ * Creates an instance of BrowserQRCodeReader.

*/
constructor(timeBetweenScansMillis = 500) {
super(new QRCodeReader_1.default(), timeBetweenScansMillis);
function BrowserQRCodeReader(timeBetweenScansMillis) {
if (timeBetweenScansMillis === void 0) { timeBetweenScansMillis = 500; }
return _super.call(this, new QRCodeReader_1.default(), timeBetweenScansMillis) || this;
}
}
return BrowserQRCodeReader;
}(BrowserCodeReader_1.default));
exports.BrowserQRCodeReader = BrowserQRCodeReader;
//# sourceMappingURL=BrowserQRCodeReader.js.map
import EncodeHintType from '../core/EncodeHintType';
declare class BrowserQRCodeSvgWriter {
private static readonly QUIET_ZONE_SIZE;
/**
* SVG markup NameSpace
*/
private static readonly SVG_NS;
/**
* A HTML container element for the image.
*/
private containerElement;
/**
* Constructs. 😉
*/
constructor(containerElement: string | HTMLElement);
write(contents: string, width: number, height: number, hints?: Map<EncodeHintType, any>): SVGSVGElement;
/**
* Note that the input matrix uses 0 == white, 1 == black.
* The output matrix uses 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
*/
private renderResult(code, width, height, quietZone);

@@ -9,0 +22,0 @@ private createSVGElement(w, h);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Exception_1 = require("../core/Exception");
const EncodeHintType_1 = require("../core/EncodeHintType");
const Encoder_1 = require("../core/qrcode/encoder/Encoder");
const ErrorCorrectionLevel_1 = require("../core/qrcode/decoder/ErrorCorrectionLevel");
class BrowserQRCodeSvgWriter {
constructor(containerElement) {
var Exception_1 = require("../core/Exception");
var EncodeHintType_1 = require("../core/EncodeHintType");
var Encoder_1 = require("../core/qrcode/encoder/Encoder");
var ErrorCorrectionLevel_1 = require("../core/qrcode/decoder/ErrorCorrectionLevel");
var BrowserQRCodeSvgWriter = /** @class */ (function () {
/**
* Constructs. 😉
*/
function BrowserQRCodeSvgWriter(containerElement) {
if (typeof containerElement === 'string') {

@@ -16,3 +19,4 @@ this.containerElement = document.getElementById(containerElement);

}
write(contents, width, height, hints = null) {
BrowserQRCodeSvgWriter.prototype.write = function (contents, width, height, hints) {
if (hints === void 0) { hints = null; }
if (contents.length === 0) {

@@ -25,7 +29,6 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Found empty contents');

if (width < 0 || height < 0) {
throw new Exception_1.default('IllegalArgumentException', 'Requested dimensions are too small: ' + width + 'x' +
height);
throw new Exception_1.default('IllegalArgumentException', 'Requested dimensions are too small: ' + width + 'x' + height);
}
let errorCorrectionLevel = ErrorCorrectionLevel_1.default.L;
let quietZone = BrowserQRCodeSvgWriter.QUIET_ZONE_SIZE;
var errorCorrectionLevel = ErrorCorrectionLevel_1.default.L;
var quietZone = BrowserQRCodeSvgWriter.QUIET_ZONE_SIZE;
if (hints !== null) {

@@ -39,19 +42,21 @@ if (undefined !== hints.get(EncodeHintType_1.default.ERROR_CORRECTION)) {

}
const code = Encoder_1.default.encode(contents, errorCorrectionLevel, hints);
var code = Encoder_1.default.encode(contents, errorCorrectionLevel, hints);
return this.renderResult(code, width, height, quietZone);
}
// Note that the input matrix uses 0 == white, 1 == black, while the output matrix uses
// 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
renderResult(code, width /*int*/, height /*int*/, quietZone /*int*/) {
const input = code.getMatrix();
};
/**
* Note that the input matrix uses 0 == white, 1 == black.
* The output matrix uses 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
*/
BrowserQRCodeSvgWriter.prototype.renderResult = function (code, width /*int*/, height /*int*/, quietZone /*int*/) {
var input = code.getMatrix();
if (input === null) {
throw new Exception_1.default(Exception_1.default.IllegalStateException);
}
const inputWidth = input.getWidth();
const inputHeight = input.getHeight();
const qrWidth = inputWidth + (quietZone * 2);
const qrHeight = inputHeight + (quietZone * 2);
const outputWidth = Math.max(width, qrWidth);
const outputHeight = Math.max(height, qrHeight);
const multiple = Math.min(Math.floor(outputWidth / qrWidth), Math.floor(outputHeight / qrHeight));
var inputWidth = input.getWidth();
var inputHeight = input.getHeight();
var qrWidth = inputWidth + (quietZone * 2);
var qrHeight = inputHeight + (quietZone * 2);
var outputWidth = Math.max(width, qrWidth);
var outputHeight = Math.max(height, qrHeight);
var multiple = Math.min(Math.floor(outputWidth / qrWidth), Math.floor(outputHeight / qrHeight));
// Padding includes both the quiet zone and the extra white pixels to accommodate the requested

@@ -61,11 +66,11 @@ // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.

// handle all the padding from 100x100 (the actual QR) up to 200x160.
const leftPadding = Math.floor((outputWidth - (inputWidth * multiple)) / 2);
const topPadding = Math.floor((outputHeight - (inputHeight * multiple)) / 2);
const svgElement = this.createSVGElement(outputWidth, outputHeight);
var leftPadding = Math.floor((outputWidth - (inputWidth * multiple)) / 2);
var topPadding = Math.floor((outputHeight - (inputHeight * multiple)) / 2);
var svgElement = this.createSVGElement(outputWidth, outputHeight);
this.containerElement.appendChild(svgElement);
for (let inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
for (var inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
// Write the contents of this row of the barcode
for (let inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
for (var inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
if (input.get(inputX, inputY) === 1) {
const svgRectElement = this.createSvgRectElement(outputX, outputY, multiple, multiple);
var svgRectElement = this.createSvgRectElement(outputX, outputY, multiple, multiple);
svgElement.appendChild(svgRectElement);

@@ -76,11 +81,11 @@ }

return svgElement;
}
createSVGElement(w, h) {
const svgElement = document.createElementNS(BrowserQRCodeSvgWriter.SVG_NS, 'svg');
};
BrowserQRCodeSvgWriter.prototype.createSVGElement = function (w, h) {
var svgElement = document.createElementNS(BrowserQRCodeSvgWriter.SVG_NS, 'svg');
svgElement.setAttributeNS(null, 'height', w.toString());
svgElement.setAttributeNS(null, 'width', h.toString());
return svgElement;
}
createSvgRectElement(x, y, w, h) {
const rect = document.createElementNS(BrowserQRCodeSvgWriter.SVG_NS, 'rect');
};
BrowserQRCodeSvgWriter.prototype.createSvgRectElement = function (x, y, w, h) {
var rect = document.createElementNS(BrowserQRCodeSvgWriter.SVG_NS, 'rect');
rect.setAttributeNS(null, 'x', x.toString());

@@ -92,7 +97,11 @@ rect.setAttributeNS(null, 'y', y.toString());

return rect;
}
}
BrowserQRCodeSvgWriter.QUIET_ZONE_SIZE = 4;
BrowserQRCodeSvgWriter.SVG_NS = 'http://www.w3.org/2000/svg';
};
BrowserQRCodeSvgWriter.QUIET_ZONE_SIZE = 4;
/**
* SVG markup NameSpace
*/
BrowserQRCodeSvgWriter.SVG_NS = 'http://www.w3.org/2000/svg';
return BrowserQRCodeSvgWriter;
}());
exports.BrowserQRCodeSvgWriter = BrowserQRCodeSvgWriter;
//# sourceMappingURL=BrowserQRCodeSvgWriter.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const InvertedLuminanceSource_1 = require("./../core/InvertedLuminanceSource");
const LuminanceSource_1 = require("./../core/LuminanceSource");
const Exception_1 = require("./../core/Exception");
class HTMLCanvasElementLuminanceSource extends LuminanceSource_1.default {
constructor(canvas) {
super(canvas.width, canvas.height);
this.canvas = canvas;
this.tempCanvasElement = null;
this.buffer = HTMLCanvasElementLuminanceSource.makeBufferFromCanvasImageData(canvas);
var InvertedLuminanceSource_1 = require("./../core/InvertedLuminanceSource");
var LuminanceSource_1 = require("./../core/LuminanceSource");
var Exception_1 = require("./../core/Exception");
var HTMLCanvasElementLuminanceSource = /** @class */ (function (_super) {
__extends(HTMLCanvasElementLuminanceSource, _super);
function HTMLCanvasElementLuminanceSource(canvas) {
var _this = _super.call(this, canvas.width, canvas.height) || this;
_this.canvas = canvas;
_this.tempCanvasElement = null;
_this.buffer = HTMLCanvasElementLuminanceSource.makeBufferFromCanvasImageData(canvas);
return _this;
}
static makeBufferFromCanvasImageData(canvas) {
const imageData = canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height);
HTMLCanvasElementLuminanceSource.makeBufferFromCanvasImageData = function (canvas) {
var imageData = canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height);
return HTMLCanvasElementLuminanceSource.toGrayscaleBuffer(imageData.data, canvas.width, canvas.height);
}
static toGrayscaleBuffer(imageBuffer, width, height) {
const grayscaleBuffer = new Uint8ClampedArray(width * height);
for (let i = 0, j = 0, length = imageBuffer.length; i < length; i += 4, j++) {
let gray;
const alpha = imageBuffer[i + 3];
};
HTMLCanvasElementLuminanceSource.toGrayscaleBuffer = function (imageBuffer, width, height) {
var grayscaleBuffer = new Uint8ClampedArray(width * height);
for (var i = 0, j = 0, length_1 = imageBuffer.length; i < length_1; i += 4, j++) {
var gray = void 0;
var alpha = imageBuffer[i + 3];
// The color of fully-transparent pixels is irrelevant. They are often, technically, fully-transparent

@@ -29,5 +41,5 @@ // black (0 alpha, and then 0 RGB). They are often used, of course as the "white" area in a

else {
const pixelR = imageBuffer[i];
const pixelG = imageBuffer[i + 1];
const pixelB = imageBuffer[i + 2];
var pixelR = imageBuffer[i];
var pixelG = imageBuffer[i + 1];
var pixelB = imageBuffer[i + 2];
// .299R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC),

@@ -44,9 +56,9 @@ // (306*R) >> 10 is approximately equal to R*0.299, and so on.

return grayscaleBuffer;
}
getRow(y /*int*/, row) {
};
HTMLCanvasElementLuminanceSource.prototype.getRow = function (y /*int*/, row) {
if (y < 0 || y >= this.getHeight()) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Requested row is outside the image: ' + y);
}
const width = this.getWidth();
const start = y * width;
var width = this.getWidth();
var start = y * width;
if (row === null) {

@@ -64,13 +76,13 @@ row = this.buffer.slice(start, start + width);

return row;
}
getMatrix() {
};
HTMLCanvasElementLuminanceSource.prototype.getMatrix = function () {
return this.buffer;
}
isCropSupported() {
};
HTMLCanvasElementLuminanceSource.prototype.isCropSupported = function () {
return true;
}
crop(left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
};
HTMLCanvasElementLuminanceSource.prototype.crop = function (left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
this.crop(left, top, width, height);
return this;
}
};
/**

@@ -81,24 +93,25 @@ * This is always true, since the image is a gray-scale image.

*/
isRotateSupported() {
HTMLCanvasElementLuminanceSource.prototype.isRotateSupported = function () {
return true;
}
rotateCounterClockwise() {
};
HTMLCanvasElementLuminanceSource.prototype.rotateCounterClockwise = function () {
this.rotate(-90);
return this;
}
rotateCounterClockwise45() {
};
HTMLCanvasElementLuminanceSource.prototype.rotateCounterClockwise45 = function () {
this.rotate(-45);
return this;
}
getTempCanvasElement() {
};
HTMLCanvasElementLuminanceSource.prototype.getTempCanvasElement = function () {
if (null === this.tempCanvasElement) {
const tempCanvasElement = this.canvas.ownerDocument.createElement('canvas');
tempCanvasElement.style.width = `${this.canvas.width}px`;
tempCanvasElement.style.height = `${this.canvas.height}px`;
var tempCanvasElement = this.canvas.ownerDocument.createElement('canvas');
tempCanvasElement.style.width = this.canvas.width + "px";
tempCanvasElement.style.height = this.canvas.height + "px";
this.tempCanvasElement = tempCanvasElement;
}
return this.tempCanvasElement;
}
rotate(angle) {
const tempCanvasElement = this.getTempCanvasElement();
const tempContext = tempCanvasElement.getContext('2d');
};
HTMLCanvasElementLuminanceSource.prototype.rotate = function (angle) {
var tempCanvasElement = this.getTempCanvasElement();
var tempContext = tempCanvasElement.getContext('2d');
tempContext.rotate(angle * HTMLCanvasElementLuminanceSource.DEGREE_TO_RADIANS);

@@ -108,9 +121,10 @@ tempContext.drawImage(this.canvas, 0, 0);

return this;
}
invert() {
};
HTMLCanvasElementLuminanceSource.prototype.invert = function () {
return new InvertedLuminanceSource_1.default(this);
}
}
HTMLCanvasElementLuminanceSource.DEGREE_TO_RADIANS = Math.PI / 180;
};
HTMLCanvasElementLuminanceSource.DEGREE_TO_RADIANS = Math.PI / 180;
return HTMLCanvasElementLuminanceSource;
}(LuminanceSource_1.default));
exports.default = HTMLCanvasElementLuminanceSource;
//# sourceMappingURL=HTMLCanvasElementLuminanceSource.js.map

@@ -9,3 +9,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
class VideoInputDevice {
var VideoInputDevice = /** @class */ (function () {
/**

@@ -18,8 +18,9 @@ * Creates an instance of VideoInputDevice.

*/
constructor(deviceId, label) {
function VideoInputDevice(deviceId, label) {
this.deviceId = deviceId;
this.label = label;
}
}
return VideoInputDevice;
}());
exports.default = VideoInputDevice;
//# sourceMappingURL=VideoInputDevice.js.map

@@ -26,17 +26,18 @@ "use strict";

*/
class Binarizer {
constructor(source) {
var Binarizer = /** @class */ (function () {
function Binarizer(source) {
this.source = source;
}
getLuminanceSource() {
Binarizer.prototype.getLuminanceSource = function () {
return this.source;
}
getWidth() {
};
Binarizer.prototype.getWidth = function () {
return this.source.getWidth();
}
getHeight() {
};
Binarizer.prototype.getHeight = function () {
return this.source.getHeight();
}
}
};
return Binarizer;
}());
exports.default = Binarizer;
//# sourceMappingURL=Binarizer.js.map

@@ -25,5 +25,5 @@ "use strict";

/*namespace com.google.zxing {*/
const Exception_1 = require("./Exception");
class BinaryBitmap {
constructor(binarizer) {
var Exception_1 = require("./Exception");
var BinaryBitmap = /** @class */ (function () {
function BinaryBitmap(binarizer) {
this.binarizer = binarizer;

@@ -37,11 +37,11 @@ if (binarizer === null) {

*/
getWidth() {
BinaryBitmap.prototype.getWidth = function () {
return this.binarizer.getWidth();
}
};
/**
* @return The height of the bitmap.
*/
getHeight() {
BinaryBitmap.prototype.getHeight = function () {
return this.binarizer.getHeight();
}
};
/**

@@ -58,5 +58,5 @@ * Converts one row of luminance data to 1 bit data. May actually do the conversion, or return

*/
getBlackRow(y /*int*/, row) {
BinaryBitmap.prototype.getBlackRow = function (y /*int*/, row) {
return this.binarizer.getBlackRow(y, row);
}
};
/**

@@ -71,3 +71,3 @@ * Converts a 2D array of luminance data to 1 bit. As above, assume this method is expensive

*/
getBlackMatrix() {
BinaryBitmap.prototype.getBlackMatrix = function () {
// The matrix is created on demand the first time it is requested, then cached. There are two

@@ -82,9 +82,9 @@ // reasons for this:

return this.matrix;
}
};
/**
* @return Whether this bitmap can be cropped.
*/
isCropSupported() {
BinaryBitmap.prototype.isCropSupported = function () {
return this.binarizer.getLuminanceSource().isCropSupported();
}
};
/**

@@ -100,12 +100,12 @@ * Returns a new object with cropped image data. Implementations may keep a reference to the

*/
crop(left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
const newSource = this.binarizer.getLuminanceSource().crop(left, top, width, height);
BinaryBitmap.prototype.crop = function (left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
var newSource = this.binarizer.getLuminanceSource().crop(left, top, width, height);
return new BinaryBitmap(this.binarizer.createBinarizer(newSource));
}
};
/**
* @return Whether this bitmap supports counter-clockwise rotation.
*/
isRotateSupported() {
BinaryBitmap.prototype.isRotateSupported = function () {
return this.binarizer.getLuminanceSource().isRotateSupported();
}
};
/**

@@ -117,6 +117,6 @@ * Returns a new object with rotated image data by 90 degrees counterclockwise.

*/
rotateCounterClockwise() {
const newSource = this.binarizer.getLuminanceSource().rotateCounterClockwise();
BinaryBitmap.prototype.rotateCounterClockwise = function () {
var newSource = this.binarizer.getLuminanceSource().rotateCounterClockwise();
return new BinaryBitmap(this.binarizer.createBinarizer(newSource));
}
};
/**

@@ -128,8 +128,8 @@ * Returns a new object with rotated image data by 45 degrees counterclockwise.

*/
rotateCounterClockwise45() {
const newSource = this.binarizer.getLuminanceSource().rotateCounterClockwise45();
BinaryBitmap.prototype.rotateCounterClockwise45 = function () {
var newSource = this.binarizer.getLuminanceSource().rotateCounterClockwise45();
return new BinaryBitmap(this.binarizer.createBinarizer(newSource));
}
};
/*@Override*/
toString() {
BinaryBitmap.prototype.toString = function () {
try {

@@ -141,5 +141,6 @@ return this.getBlackMatrix().toString();

}
}
}
};
return BinaryBitmap;
}());
exports.default = BinaryBitmap;
//# sourceMappingURL=BinaryBitmap.js.map

@@ -20,6 +20,6 @@ "use strict";

/*import java.util.Arrays;*/
const System_1 = require("./../util/System");
const Integer_1 = require("./../util/Integer");
const Arrays_1 = require("./../util/Arrays");
const Exception_1 = require("./../Exception");
var System_1 = require("./../util/System");
var Integer_1 = require("./../util/Integer");
var Arrays_1 = require("./../util/Arrays");
var Exception_1 = require("./../Exception");
/**

@@ -30,3 +30,3 @@ * <p>A simple, fast array of bits, represented compactly by an array of ints internally.</p>

*/
class BitArray /*implements Cloneable*/ {
var BitArray /*implements Cloneable*/ = /** @class */ (function () {
// public constructor() {

@@ -45,3 +45,3 @@ // this.size = 0

// For testing only
constructor(size /*int*/, bits) {
function BitArray(size /*int*/, bits) {
if (undefined === size) {

@@ -61,15 +61,15 @@ this.size = 0;

}
getSize() {
BitArray.prototype.getSize = function () {
return this.size;
}
getSizeInBytes() {
};
BitArray.prototype.getSizeInBytes = function () {
return Math.floor((this.size + 7) / 8);
}
ensureCapacity(size /*int*/) {
};
BitArray.prototype.ensureCapacity = function (size /*int*/) {
if (size > this.bits.length * 32) {
const newBits = BitArray.makeArray(size);
var newBits = BitArray.makeArray(size);
System_1.default.arraycopy(this.bits, 0, newBits, 0, this.bits.length);
this.bits = newBits;
}
}
};
/**

@@ -79,5 +79,5 @@ * @param i bit to get

*/
get(i /*int*/) {
BitArray.prototype.get = function (i /*int*/) {
return (this.bits[Math.floor(i / 32)] & (1 << (i & 0x1F))) !== 0;
}
};
/**

@@ -88,5 +88,5 @@ * Sets bit i.

*/
set(i /*int*/) {
BitArray.prototype.set = function (i /*int*/) {
this.bits[Math.floor(i / 32)] |= 1 << (i & 0x1F);
}
};
/**

@@ -97,5 +97,5 @@ * Flips bit i.

*/
flip(i /*int*/) {
BitArray.prototype.flip = function (i /*int*/) {
this.bits[Math.floor(i / 32)] ^= 1 << (i & 0x1F);
}
};
/**

@@ -107,13 +107,13 @@ * @param from first bit to check

*/
getNextSet(from /*int*/) {
const size = this.size;
BitArray.prototype.getNextSet = function (from /*int*/) {
var size = this.size;
if (from >= size) {
return size;
}
const bits = this.bits;
let bitsOffset = Math.floor(from / 32);
let currentBits = bits[bitsOffset];
var bits = this.bits;
var bitsOffset = Math.floor(from / 32);
var currentBits = bits[bitsOffset];
// mask off lesser bits first
currentBits &= ~((1 << (from & 0x1F)) - 1);
const length = bits.length;
var length = bits.length;
while (currentBits === 0) {

@@ -125,5 +125,5 @@ if (++bitsOffset === length) {

}
const result = (bitsOffset * 32) + Integer_1.default.numberOfTrailingZeros(currentBits);
var result = (bitsOffset * 32) + Integer_1.default.numberOfTrailingZeros(currentBits);
return result > size ? size : result;
}
};
/**

@@ -134,13 +134,13 @@ * @param from index to start looking for unset bit

*/
getNextUnset(from /*int*/) {
const size = this.size;
BitArray.prototype.getNextUnset = function (from /*int*/) {
var size = this.size;
if (from >= size) {
return size;
}
const bits = this.bits;
let bitsOffset = Math.floor(from / 32);
let currentBits = ~bits[bitsOffset];
var bits = this.bits;
var bitsOffset = Math.floor(from / 32);
var currentBits = ~bits[bitsOffset];
// mask off lesser bits first
currentBits &= ~((1 << (from & 0x1F)) - 1);
const length = bits.length;
var length = bits.length;
while (currentBits === 0) {

@@ -152,5 +152,5 @@ if (++bitsOffset === length) {

}
const result = (bitsOffset * 32) + Integer_1.default.numberOfTrailingZeros(currentBits);
var result = (bitsOffset * 32) + Integer_1.default.numberOfTrailingZeros(currentBits);
return result > size ? size : result;
}
};
/**

@@ -163,5 +163,5 @@ * Sets a block of 32 bits, starting at bit i.

*/
setBulk(i /*int*/, newBits /*int*/) {
BitArray.prototype.setBulk = function (i /*int*/, newBits /*int*/) {
this.bits[Math.floor(i / 32)] = newBits;
}
};
/**

@@ -173,3 +173,3 @@ * Sets a range of bits.

*/
setRange(start /*int*/, end /*int*/) {
BitArray.prototype.setRange = function (start /*int*/, end /*int*/) {
if (end < start || start < 0 || end > this.size) {

@@ -182,23 +182,23 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException);

end--; // will be easier to treat this as the last actually set bit -- inclusive
const firstInt = Math.floor(start / 32);
const lastInt = Math.floor(end / 32);
const bits = this.bits;
for (let i = firstInt; i <= lastInt; i++) {
const firstBit = i > firstInt ? 0 : start & 0x1F;
const lastBit = i < lastInt ? 31 : end & 0x1F;
var firstInt = Math.floor(start / 32);
var lastInt = Math.floor(end / 32);
var bits = this.bits;
for (var i = firstInt; i <= lastInt; i++) {
var firstBit = i > firstInt ? 0 : start & 0x1F;
var lastBit = i < lastInt ? 31 : end & 0x1F;
// Ones from firstBit to lastBit, inclusive
const mask = (2 << lastBit) - (1 << firstBit);
var mask = (2 << lastBit) - (1 << firstBit);
bits[i] |= mask;
}
}
};
/**
* Clears all bits (sets to false).
*/
clear() {
const max = this.bits.length;
const bits = this.bits;
for (let i = 0; i < max; i++) {
BitArray.prototype.clear = function () {
var max = this.bits.length;
var bits = this.bits;
for (var i = 0; i < max; i++) {
bits[i] = 0;
}
}
};
/**

@@ -213,3 +213,3 @@ * Efficient method to check if a range of bits is set, or not set.

*/
isRange(start /*int*/, end /*int*/, value) {
BitArray.prototype.isRange = function (start /*int*/, end /*int*/, value) {
if (end < start || start < 0 || end > this.size) {

@@ -222,10 +222,10 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException);

end--; // will be easier to treat this as the last actually set bit -- inclusive
const firstInt = Math.floor(start / 32);
const lastInt = Math.floor(end / 32);
const bits = this.bits;
for (let i = firstInt; i <= lastInt; i++) {
const firstBit = i > firstInt ? 0 : start & 0x1F;
const lastBit = i < lastInt ? 31 : end & 0x1F;
var firstInt = Math.floor(start / 32);
var lastInt = Math.floor(end / 32);
var bits = this.bits;
for (var i = firstInt; i <= lastInt; i++) {
var firstBit = i > firstInt ? 0 : start & 0x1F;
var lastBit = i < lastInt ? 31 : end & 0x1F;
// Ones from firstBit to lastBit, inclusive
const mask = (2 << lastBit) - (1 << firstBit) & 0xFFFFFFFF;
var mask = (2 << lastBit) - (1 << firstBit) & 0xFFFFFFFF;
// TYPESCRIPTPORT: & 0xFFFFFFFF added to discard anything after 32 bits, as ES has 53 bits

@@ -239,4 +239,4 @@ // Return false if we're looking for 1s and the masked bits[i] isn't all 1s (is: that,

return true;
}
appendBit(bit) {
};
BitArray.prototype.appendBit = function (bit) {
this.ensureCapacity(this.size + 1);

@@ -247,3 +247,3 @@ if (bit) {

this.size++;
}
};
/**

@@ -257,3 +257,3 @@ * Appends the least-significant bits, from value, in order from most-significant to

*/
appendBits(value /*int*/, numBits /*int*/) {
BitArray.prototype.appendBits = function (value /*int*/, numBits /*int*/) {
if (numBits < 0 || numBits > 32) {

@@ -263,21 +263,21 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Num bits must be between 0 and 32');

this.ensureCapacity(this.size + numBits);
const appendBit = this.appendBit;
for (let numBitsLeft = numBits; numBitsLeft > 0; numBitsLeft--) {
var appendBit = this.appendBit;
for (var numBitsLeft = numBits; numBitsLeft > 0; numBitsLeft--) {
this.appendBit(((value >> (numBitsLeft - 1)) & 0x01) === 1);
}
}
appendBitArray(other) {
const otherSize = other.size;
};
BitArray.prototype.appendBitArray = function (other) {
var otherSize = other.size;
this.ensureCapacity(this.size + otherSize);
const appendBit = this.appendBit;
for (let i = 0; i < otherSize; i++) {
var appendBit = this.appendBit;
for (var i = 0; i < otherSize; i++) {
this.appendBit(other.get(i));
}
}
xor(other) {
};
BitArray.prototype.xor = function (other) {
if (this.size !== other.size) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Sizes don\'t match');
}
const bits = this.bits;
for (let i = 0, length = bits.length; i < length; i++) {
var bits = this.bits;
for (var i = 0, length_1 = bits.length; i < length_1; i++) {
// The last int could be incomplete (i.e. not have 32 bits in

@@ -287,3 +287,3 @@ // it) but there is no problem since 0 XOR 0 == 0.

}
}
};
/**

@@ -297,6 +297,6 @@ *

*/
toBytes(bitOffset /*int*/, array, offset /*int*/, numBytes /*int*/) {
for (let i = 0; i < numBytes; i++) {
let theByte = 0;
for (let j = 0; j < 8; j++) {
BitArray.prototype.toBytes = function (bitOffset /*int*/, array, offset /*int*/, numBytes /*int*/) {
for (var i = 0; i < numBytes; i++) {
var theByte = 0;
for (var j = 0; j < 8; j++) {
if (this.get(bitOffset)) {

@@ -309,3 +309,3 @@ theByte |= 1 << (7 - j);

}
}
};
/**

@@ -315,16 +315,16 @@ * @return underlying array of ints. The first element holds the first 32 bits, and the least

*/
getBitArray() {
BitArray.prototype.getBitArray = function () {
return this.bits;
}
};
/**
* Reverses all bits in the array.
*/
reverse() {
const newBits = new Int32Array(this.bits.length);
BitArray.prototype.reverse = function () {
var newBits = new Int32Array(this.bits.length);
// reverse all int's first
const len = Math.floor((this.size - 1) / 32);
const oldBitsLen = len + 1;
const bits = this.bits;
for (let i = 0; i < oldBitsLen; i++) {
let x = bits[i];
var len = Math.floor((this.size - 1) / 32);
var oldBitsLen = len + 1;
var bits = this.bits;
for (var i = 0; i < oldBitsLen; i++) {
var x = bits[i];
x = ((x >> 1) & 0x55555555) | ((x & 0x55555555) << 1);

@@ -339,6 +339,6 @@ x = ((x >> 2) & 0x33333333) | ((x & 0x33333333) << 2);

if (this.size !== oldBitsLen * 32) {
const leftOffset = oldBitsLen * 32 - this.size;
let currentInt = newBits[0] >>> leftOffset;
for (let i = 1; i < oldBitsLen; i++) {
const nextInt = newBits[i];
var leftOffset = oldBitsLen * 32 - this.size;
var currentInt = newBits[0] >>> leftOffset;
for (var i = 1; i < oldBitsLen; i++) {
var nextInt = newBits[i];
currentInt |= nextInt << (32 - leftOffset);

@@ -351,22 +351,22 @@ newBits[i - 1] = currentInt;

this.bits = newBits;
}
static makeArray(size /*int*/) {
};
BitArray.makeArray = function (size /*int*/) {
return new Int32Array(Math.floor((size + 31) / 32));
}
};
/*@Override*/
equals(o) {
BitArray.prototype.equals = function (o) {
if (!(o instanceof BitArray)) {
return false;
}
const other = o;
var other = o;
return this.size === other.size && Arrays_1.default.equals(this.bits, other.bits);
}
};
/*@Override*/
hashCode() {
BitArray.prototype.hashCode = function () {
return 31 * this.size + Arrays_1.default.hashCode(this.bits);
}
};
/*@Override*/
toString() {
let result = '';
for (let i = 0, size = this.size; i < size; i++) {
BitArray.prototype.toString = function () {
var result = '';
for (var i = 0, size = this.size; i < size; i++) {
if ((i & 0x07) === 0) {

@@ -378,9 +378,10 @@ result += ' ';

return result;
}
};
/*@Override*/
clone() {
BitArray.prototype.clone = function () {
return new BitArray(this.size, this.bits.slice());
}
}
};
return BitArray;
}());
exports.default = BitArray;
//# sourceMappingURL=BitArray.js.map

@@ -20,7 +20,7 @@ "use strict";

/*import java.util.Arrays;*/
const Exception_1 = require("./../Exception");
const BitArray_1 = require("./BitArray");
const System_1 = require("./../util/System");
const Arrays_1 = require("./../util/Arrays");
const StringBuilder_1 = require("./../util/StringBuilder");
var Exception_1 = require("./../Exception");
var BitArray_1 = require("./BitArray");
var System_1 = require("./../util/System");
var Arrays_1 = require("./../util/Arrays");
var StringBuilder_1 = require("./../util/StringBuilder");
/**

@@ -41,3 +41,3 @@ * <p>Represents a 2D matrix of bits. In function arguments below, and throughout the common

*/
class BitMatrix /*implements Cloneable*/ {
var BitMatrix /*implements Cloneable*/ = /** @class */ (function () {
/**

@@ -66,3 +66,3 @@ * Creates an empty square {@link BitMatrix}.

// }
constructor(width /*int*/, height /*int*/, rowSize /*int*/, bits) {
function BitMatrix(width /*int*/, height /*int*/, rowSize /*int*/, bits) {
this.width = width; /*int*/

@@ -93,9 +93,9 @@ this.height = height; /*int*/

*/
static parseFromBooleanArray(image) {
const height = image.length;
const width = image[0].length;
const bits = new BitMatrix(width, height);
for (let i = 0; i < height; i++) {
const imageI = image[i];
for (let j = 0; j < width; j++) {
BitMatrix.parseFromBooleanArray = function (image) {
var height = image.length;
var width = image[0].length;
var bits = new BitMatrix(width, height);
for (var i = 0; i < height; i++) {
var imageI = image[i];
for (var j = 0; j < width; j++) {
if (imageI[j]) {

@@ -107,13 +107,13 @@ bits.set(j, i);

return bits;
}
static parseFromString(stringRepresentation, setString, unsetString) {
};
BitMatrix.parseFromString = function (stringRepresentation, setString, unsetString) {
if (stringRepresentation === null) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'stringRepresentation cannot be null');
}
const bits = new Array(stringRepresentation.length);
let bitsPos = 0;
let rowStartPos = 0;
let rowLength = -1;
let nRows = 0;
let pos = 0;
var bits = new Array(stringRepresentation.length);
var bitsPos = 0;
var rowStartPos = 0;
var rowLength = -1;
var nRows = 0;
var pos = 0;
while (pos < stringRepresentation.length) {

@@ -158,4 +158,4 @@ if (stringRepresentation.charAt(pos) === '\n' ||

}
const matrix = new BitMatrix(rowLength, nRows);
for (let i = 0; i < bitsPos; i++) {
var matrix = new BitMatrix(rowLength, nRows);
for (var i = 0; i < bitsPos; i++) {
if (bits[i]) {

@@ -166,3 +166,3 @@ matrix.set(Math.floor(i % rowLength), Math.floor(i / rowLength));

return matrix;
}
};
/**

@@ -175,6 +175,6 @@ * <p>Gets the requested bit, where true means black.</p>

*/
get(x /*int*/, y /*int*/) {
const offset = y * this.rowSize + Math.floor(x / 32);
BitMatrix.prototype.get = function (x /*int*/, y /*int*/) {
var offset = y * this.rowSize + Math.floor(x / 32);
return ((this.bits[offset] >>> (x & 0x1f)) & 1) !== 0;
}
};
/**

@@ -186,10 +186,10 @@ * <p>Sets the given bit to true.</p>

*/
set(x /*int*/, y /*int*/) {
const offset = y * this.rowSize + Math.floor(x / 32);
BitMatrix.prototype.set = function (x /*int*/, y /*int*/) {
var offset = y * this.rowSize + Math.floor(x / 32);
this.bits[offset] |= (1 << (x & 0x1f)) & 0xFFFFFFFF;
}
unset(x /*int*/, y /*int*/) {
const offset = y * this.rowSize + Math.floor(x / 32);
};
BitMatrix.prototype.unset = function (x /*int*/, y /*int*/) {
var offset = y * this.rowSize + Math.floor(x / 32);
this.bits[offset] &= ~((1 << (x & 0x1f)) & 0xFFFFFFFF);
}
};
/**

@@ -201,6 +201,6 @@ * <p>Flips the given bit.</p>

*/
flip(x /*int*/, y /*int*/) {
const offset = y * this.rowSize + Math.floor(x / 32);
BitMatrix.prototype.flip = function (x /*int*/, y /*int*/) {
var offset = y * this.rowSize + Math.floor(x / 32);
this.bits[offset] ^= ((1 << (x & 0x1f)) & 0xFFFFFFFF);
}
};
/**

@@ -212,3 +212,3 @@ * Exclusive-or (XOR): Flip the bit in this {@code BitMatrix} if the corresponding

*/
xor(mask) {
BitMatrix.prototype.xor = function (mask) {
if (this.width !== mask.getWidth() || this.height !== mask.getHeight()

@@ -218,23 +218,23 @@ || this.rowSize !== mask.getRowSize()) {

}
const rowArray = new BitArray_1.default(Math.floor(this.width / 32) + 1);
const rowSize = this.rowSize;
const bits = this.bits;
for (let y = 0, height = this.height; y < height; y++) {
const offset = y * rowSize;
const row = mask.getRow(y, rowArray).getBitArray();
for (let x = 0; x < rowSize; x++) {
var rowArray = new BitArray_1.default(Math.floor(this.width / 32) + 1);
var rowSize = this.rowSize;
var bits = this.bits;
for (var y = 0, height = this.height; y < height; y++) {
var offset = y * rowSize;
var row = mask.getRow(y, rowArray).getBitArray();
for (var x = 0; x < rowSize; x++) {
bits[offset + x] ^= row[x];
}
}
}
};
/**
* Clears all bits (sets to false).
*/
clear() {
const bits = this.bits;
const max = bits.length;
for (let i = 0; i < max; i++) {
BitMatrix.prototype.clear = function () {
var bits = this.bits;
var max = bits.length;
for (var i = 0; i < max; i++) {
bits[i] = 0;
}
}
};
/**

@@ -248,3 +248,3 @@ * <p>Sets a square region of the bit matrix to true.</p>

*/
setRegion(left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
BitMatrix.prototype.setRegion = function (left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
if (top < 0 || left < 0) {

@@ -256,16 +256,16 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Left and top must be nonnegative');

}
const right = left + width;
const bottom = top + height;
var right = left + width;
var bottom = top + height;
if (bottom > this.height || right > this.width) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'The region must fit inside the matrix');
}
const rowSize = this.rowSize;
const bits = this.bits;
for (let y = top; y < bottom; y++) {
const offset = y * rowSize;
for (let x = left; x < right; x++) {
var rowSize = this.rowSize;
var bits = this.bits;
for (var y = top; y < bottom; y++) {
var offset = y * rowSize;
for (var x = left; x < right; x++) {
bits[offset + Math.floor(x / 32)] |= ((1 << (x & 0x1f)) & 0xFFFFFFFF);
}
}
}
};
/**

@@ -279,3 +279,3 @@ * A fast method to retrieve one row of data from the matrix as a BitArray.

*/
getRow(y /*int*/, row) {
BitMatrix.prototype.getRow = function (y /*int*/, row) {
if (row === null || row === undefined || row.getSize() < this.width) {

@@ -287,10 +287,10 @@ row = new BitArray_1.default(this.width);

}
const rowSize = this.rowSize;
const bits = this.bits;
const offset = y * rowSize;
for (let x = 0; x < rowSize; x++) {
var rowSize = this.rowSize;
var bits = this.bits;
var offset = y * rowSize;
for (var x = 0; x < rowSize; x++) {
row.setBulk(x * 32, bits[offset + x]);
}
return row;
}
};
/**

@@ -300,14 +300,14 @@ * @param y row to set

*/
setRow(y /*int*/, row) {
BitMatrix.prototype.setRow = function (y /*int*/, row) {
System_1.default.arraycopy(row.getBitArray(), 0, this.bits, y * this.rowSize, this.rowSize);
}
};
/**
* Modifies this {@code BitMatrix} to represent the same but rotated 180 degrees
*/
rotate180() {
const width = this.getWidth();
const height = this.getHeight();
let topRow = new BitArray_1.default(width);
let bottomRow = new BitArray_1.default(width);
for (let i = 0, length = Math.floor((height + 1) / 2); i < length; i++) {
BitMatrix.prototype.rotate180 = function () {
var width = this.getWidth();
var height = this.getHeight();
var topRow = new BitArray_1.default(width);
var bottomRow = new BitArray_1.default(width);
for (var i = 0, length_1 = Math.floor((height + 1) / 2); i < length_1; i++) {
topRow = this.getRow(i, topRow);

@@ -320,3 +320,3 @@ bottomRow = this.getRow(height - 1 - i, bottomRow);

}
}
};
/**

@@ -327,14 +327,14 @@ * This is useful in detecting the enclosing rectangle of a 'pure' barcode.

*/
getEnclosingRectangle() {
const width = this.width;
const height = this.height;
const rowSize = this.rowSize;
const bits = this.bits;
let left = width;
let top = height;
let right = -1;
let bottom = -1;
for (let y = 0; y < height; y++) {
for (let x32 = 0; x32 < rowSize; x32++) {
const theBits = bits[y * rowSize + x32];
BitMatrix.prototype.getEnclosingRectangle = function () {
var width = this.width;
var height = this.height;
var rowSize = this.rowSize;
var bits = this.bits;
var left = width;
var top = height;
var right = -1;
var bottom = -1;
for (var y = 0; y < height; y++) {
for (var x32 = 0; x32 < rowSize; x32++) {
var theBits = bits[y * rowSize + x32];
if (theBits !== 0) {

@@ -348,3 +348,3 @@ if (y < top) {

if (x32 * 32 < left) {
let bit = 0;
var bit = 0;
while (((theBits << (31 - bit)) & 0xFFFFFFFF) === 0) {

@@ -358,3 +358,3 @@ bit++;

if (x32 * 32 + 31 > right) {
let bit = 31;
var bit = 31;
while ((theBits >>> bit) === 0) {

@@ -374,3 +374,3 @@ bit--;

return Int32Array.from([left, top, right - left + 1, bottom - top + 1]);
}
};
/**

@@ -381,6 +381,6 @@ * This is useful in detecting a corner of a 'pure' barcode.

*/
getTopLeftOnBit() {
const rowSize = this.rowSize;
const bits = this.bits;
let bitsOffset = 0;
BitMatrix.prototype.getTopLeftOnBit = function () {
var rowSize = this.rowSize;
var bits = this.bits;
var bitsOffset = 0;
while (bitsOffset < bits.length && bits[bitsOffset] === 0) {

@@ -392,6 +392,6 @@ bitsOffset++;

}
const y = bitsOffset / rowSize;
let x = (bitsOffset % rowSize) * 32;
const theBits = bits[bitsOffset];
let bit = 0;
var y = bitsOffset / rowSize;
var x = (bitsOffset % rowSize) * 32;
var theBits = bits[bitsOffset];
var bit = 0;
while (((theBits << (31 - bit)) & 0xFFFFFFFF) === 0) {

@@ -402,7 +402,7 @@ bit++;

return Int32Array.from([x, y]);
}
getBottomRightOnBit() {
const rowSize = this.rowSize;
const bits = this.bits;
let bitsOffset = bits.length - 1;
};
BitMatrix.prototype.getBottomRightOnBit = function () {
var rowSize = this.rowSize;
var bits = this.bits;
var bitsOffset = bits.length - 1;
while (bitsOffset >= 0 && bits[bitsOffset] === 0) {

@@ -414,6 +414,6 @@ bitsOffset--;

}
const y = Math.floor(bitsOffset / rowSize);
let x = Math.floor(bitsOffset % rowSize) * 32;
const theBits = bits[bitsOffset];
let bit = 31;
var y = Math.floor(bitsOffset / rowSize);
var x = Math.floor(bitsOffset % rowSize) * 32;
var theBits = bits[bitsOffset];
var bit = 31;
while ((theBits >>> bit) === 0) {

@@ -424,33 +424,33 @@ bit--;

return Int32Array.from([x, y]);
}
};
/**
* @return The width of the matrix
*/
getWidth() {
BitMatrix.prototype.getWidth = function () {
return this.width;
}
};
/**
* @return The height of the matrix
*/
getHeight() {
BitMatrix.prototype.getHeight = function () {
return this.height;
}
};
/**
* @return The row size of the matrix
*/
getRowSize() {
BitMatrix.prototype.getRowSize = function () {
return this.rowSize;
}
};
/*@Override*/
equals(o) {
BitMatrix.prototype.equals = function (o) {
if (!(o instanceof BitMatrix)) {
return false;
}
const other = o;
var other = o;
return this.width === other.width && this.height === other.height && this.rowSize === other.rowSize &&
Arrays_1.default.equals(this.bits, other.bits);
}
};
/*@Override*/
hashCode() {
let hash = this.width;
BitMatrix.prototype.hashCode = function () {
var hash = this.width;
hash = 31 * hash + this.width;

@@ -461,3 +461,3 @@ hash = 31 * hash + this.height;

return hash;
}
};
/**

@@ -486,10 +486,13 @@ * @return string representation using "X" for set and " " for unset bits

// @Deprecated
toString(setString = 'x', unsetString = ' ', lineSeparator = '\n') {
BitMatrix.prototype.toString = function (setString, unsetString, lineSeparator) {
if (setString === void 0) { setString = 'x'; }
if (unsetString === void 0) { unsetString = ' '; }
if (lineSeparator === void 0) { lineSeparator = '\n'; }
return this.buildToString(setString, unsetString, lineSeparator);
}
buildToString(setString, unsetString, lineSeparator) {
let result = new StringBuilder_1.default();
};
BitMatrix.prototype.buildToString = function (setString, unsetString, lineSeparator) {
var result = new StringBuilder_1.default();
result.append(lineSeparator);
for (let y = 0, height = this.height; y < height; y++) {
for (let x = 0, width = this.width; x < width; x++) {
for (var y = 0, height = this.height; y < height; y++) {
for (var x = 0, width = this.width; x < width; x++) {
result.append(this.get(x, y) ? setString : unsetString);

@@ -500,9 +503,10 @@ }

return result.toString();
}
};
/*@Override*/
clone() {
BitMatrix.prototype.clone = function () {
return new BitMatrix(this.width, this.height, this.rowSize, this.bits.slice());
}
}
};
return BitMatrix;
}());
exports.default = BitMatrix;
//# sourceMappingURL=BitMatrix.js.map

@@ -19,3 +19,3 @@ "use strict";

/*namespace com.google.zxing.common {*/
const Exception_1 = require("./../Exception");
var Exception_1 = require("./../Exception");
/**

@@ -30,3 +30,3 @@ * <p>This provides an easy abstraction to read bits at a time from a sequence of bytes, where the

*/
class BitSource {
var BitSource = /** @class */ (function () {
/**

@@ -36,3 +36,3 @@ * @param bytes bytes from which this will read bits. Bits will be read from the first byte first.

*/
constructor(bytes) {
function BitSource(bytes) {
this.bytes = bytes;

@@ -45,11 +45,11 @@ this.byteOffset = 0;

*/
getBitOffset() {
BitSource.prototype.getBitOffset = function () {
return this.bitOffset;
}
};
/**
* @return index of next byte in input byte array which would be read by the next call to {@link #readBits(int)}.
*/
getByteOffset() {
BitSource.prototype.getByteOffset = function () {
return this.byteOffset;
}
};
/**

@@ -61,16 +61,16 @@ * @param numBits number of bits to read

*/
readBits(numBits /*int*/) {
BitSource.prototype.readBits = function (numBits /*int*/) {
if (numBits < 1 || numBits > 32 || numBits > this.available()) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, '' + numBits);
}
let result = 0;
let bitOffset = this.bitOffset;
let byteOffset = this.byteOffset;
const bytes = this.bytes;
var result = 0;
var bitOffset = this.bitOffset;
var byteOffset = this.byteOffset;
var bytes = this.bytes;
// First, read remainder from current byte
if (bitOffset > 0) {
const bitsLeft = 8 - bitOffset;
const toRead = numBits < bitsLeft ? numBits : bitsLeft;
const bitsToNotRead = bitsLeft - toRead;
const mask = (0xFF >> (8 - toRead)) << bitsToNotRead;
var bitsLeft = 8 - bitOffset;
var toRead = numBits < bitsLeft ? numBits : bitsLeft;
var bitsToNotRead = bitsLeft - toRead;
var mask = (0xFF >> (8 - toRead)) << bitsToNotRead;
result = (bytes[byteOffset] & mask) >> bitsToNotRead;

@@ -93,4 +93,4 @@ numBits -= toRead;

if (numBits > 0) {
const bitsToNotRead = 8 - numBits;
const mask = (0xFF >> bitsToNotRead) << bitsToNotRead;
var bitsToNotRead = 8 - numBits;
var mask = (0xFF >> bitsToNotRead) << bitsToNotRead;
result = (result << numBits) | ((bytes[byteOffset] & mask) >> bitsToNotRead);

@@ -103,11 +103,12 @@ bitOffset += numBits;

return result;
}
};
/**
* @return number of bits that can be read successfully
*/
available() {
BitSource.prototype.available = function () {
return 8 * (this.bytes.length - this.byteOffset) - this.bitOffset;
}
}
};
return BitSource;
}());
exports.default = BitSource;
//# sourceMappingURL=BitSource.js.map

@@ -19,3 +19,3 @@ "use strict";

/*namespace com.google.zxing.common {*/
const Exception_1 = require("./../Exception");
var Exception_1 = require("./../Exception");
/**

@@ -27,4 +27,8 @@ * Encapsulates a Character Set ECI, according to "Extended Channel Interpretations" 5.3.1.1

*/
class CharacterSetECI {
constructor(valueIdentifier, valuesParam, name, ...otherEncodingNames) {
var CharacterSetECI = /** @class */ (function () {
function CharacterSetECI(valueIdentifier, valuesParam, name) {
var otherEncodingNames = [];
for (var _i = 3; _i < arguments.length; _i++) {
otherEncodingNames[_i - 3] = arguments[_i];
}
this.valueIdentifier = valueIdentifier;

@@ -41,8 +45,9 @@ this.name = name;

CharacterSetECI.NAME_TO_ECI.set(name, this);
const values = this.values;
for (let i = 0, length = values.length; i !== length; i++) {
const v = values[i];
var values = this.values;
for (var i = 0, length_1 = values.length; i !== length_1; i++) {
var v = values[i];
CharacterSetECI.VALUES_TO_ECI.set(v, this);
}
for (const otherName of otherEncodingNames) {
for (var _a = 0, otherEncodingNames_1 = otherEncodingNames; _a < otherEncodingNames_1.length; _a++) {
var otherName = otherEncodingNames_1[_a];
CharacterSetECI.NAME_TO_ECI.set(otherName, this);

@@ -62,11 +67,11 @@ }

// }
getValueIdentifier() {
CharacterSetECI.prototype.getValueIdentifier = function () {
return this.valueIdentifier;
}
getName() {
};
CharacterSetECI.prototype.getName = function () {
return this.name;
}
getValue() {
};
CharacterSetECI.prototype.getValue = function () {
return this.values[0];
}
};
/**

@@ -78,7 +83,7 @@ * @param value character set ECI value

*/
static getCharacterSetECIByValue(value /*int*/) {
CharacterSetECI.getCharacterSetECIByValue = function (value /*int*/) {
if (value < 0 || value >= 900) {
throw new Exception_1.default(Exception_1.default.FormatException, 'incorect value');
}
const characterSet = CharacterSetECI.VALUES_TO_ECI.get(value);
var characterSet = CharacterSetECI.VALUES_TO_ECI.get(value);
if (undefined === characterSet) {

@@ -88,3 +93,3 @@ throw new Exception_1.default(Exception_1.default.FormatException, 'incorect value');

return characterSet;
}
};
/**

@@ -95,4 +100,4 @@ * @param name character set ECI encoding name

*/
static getCharacterSetECIByName(name) {
const characterSet = CharacterSetECI.NAME_TO_ECI.get(name);
CharacterSetECI.getCharacterSetECIByName = function (name) {
var characterSet = CharacterSetECI.NAME_TO_ECI.get(name);
if (undefined === characterSet) {

@@ -102,46 +107,47 @@ throw new Exception_1.default(Exception_1.default.FormatException, 'incorect value');

return characterSet;
}
equals(o) {
};
CharacterSetECI.prototype.equals = function (o) {
if (!(o instanceof CharacterSetECI)) {
return false;
}
const other = o;
var other = o;
return this.getName() === other.getName();
}
}
CharacterSetECI.VALUE_IDENTIFIER_TO_ECI = new Map();
CharacterSetECI.VALUES_TO_ECI = new Map();
CharacterSetECI.NAME_TO_ECI = new Map();
// Enum name is a Java encoding valid for java.lang and java.io
// TYPESCRIPTPORT: changed the main label for ISO as the TextEncoder did not recognized them in the form from java
// (eg ISO8859_1 must be ISO88591 or ISO8859-1 or ISO-8859-1)
// later on: well, except 16 wich does not work with ISO885916 so used ISO-8859-1 form for default
CharacterSetECI.Cp437 = new CharacterSetECI(0 /* Cp437 */, Int32Array.from([0, 2]), 'Cp437');
CharacterSetECI.ISO8859_1 = new CharacterSetECI(1 /* ISO8859_1 */, Int32Array.from([1, 3]), 'ISO-8859-1', 'ISO88591', 'ISO8859_1');
CharacterSetECI.ISO8859_2 = new CharacterSetECI(2 /* ISO8859_2 */, 4, 'ISO-8859-2', 'ISO88592', 'ISO8859_2');
CharacterSetECI.ISO8859_3 = new CharacterSetECI(3 /* ISO8859_3 */, 5, 'ISO-8859-3', 'ISO88593', 'ISO8859_3');
CharacterSetECI.ISO8859_4 = new CharacterSetECI(4 /* ISO8859_4 */, 6, 'ISO-8859-4', 'ISO88594', 'ISO8859_4');
CharacterSetECI.ISO8859_5 = new CharacterSetECI(5 /* ISO8859_5 */, 7, 'ISO-8859-5', 'ISO88595', 'ISO8859_5');
CharacterSetECI.ISO8859_6 = new CharacterSetECI(6 /* ISO8859_6 */, 8, 'ISO-8859-6', 'ISO88596', 'ISO8859_6');
CharacterSetECI.ISO8859_7 = new CharacterSetECI(7 /* ISO8859_7 */, 9, 'ISO-8859-7', 'ISO88597', 'ISO8859_7');
CharacterSetECI.ISO8859_8 = new CharacterSetECI(8 /* ISO8859_8 */, 10, 'ISO-8859-8', 'ISO88598', 'ISO8859_8');
CharacterSetECI.ISO8859_9 = new CharacterSetECI(9 /* ISO8859_9 */, 11, 'ISO-8859-9', 'ISO88599', 'ISO8859_9');
CharacterSetECI.ISO8859_10 = new CharacterSetECI(10 /* ISO8859_10 */, 12, 'ISO-8859-10', 'ISO885910', 'ISO8859_10');
CharacterSetECI.ISO8859_11 = new CharacterSetECI(11 /* ISO8859_11 */, 13, 'ISO-8859-11', 'ISO885911', 'ISO8859_11');
CharacterSetECI.ISO8859_13 = new CharacterSetECI(12 /* ISO8859_13 */, 15, 'ISO-8859-13', 'ISO885913', 'ISO8859_13');
CharacterSetECI.ISO8859_14 = new CharacterSetECI(13 /* ISO8859_14 */, 16, 'ISO-8859-14', 'ISO885914', 'ISO8859_14');
CharacterSetECI.ISO8859_15 = new CharacterSetECI(14 /* ISO8859_15 */, 17, 'ISO-8859-15', 'ISO885915', 'ISO8859_15');
CharacterSetECI.ISO8859_16 = new CharacterSetECI(15 /* ISO8859_16 */, 18, 'ISO-8859-16', 'ISO885916', 'ISO8859_16');
CharacterSetECI.SJIS = new CharacterSetECI(16 /* SJIS */, 20, 'SJIS', 'Shift_JIS');
CharacterSetECI.Cp1250 = new CharacterSetECI(17 /* Cp1250 */, 21, 'Cp1250', 'windows-1250');
CharacterSetECI.Cp1251 = new CharacterSetECI(18 /* Cp1251 */, 22, 'Cp1251', 'windows-1251');
CharacterSetECI.Cp1252 = new CharacterSetECI(19 /* Cp1252 */, 23, 'Cp1252', 'windows-1252');
CharacterSetECI.Cp1256 = new CharacterSetECI(20 /* Cp1256 */, 24, 'Cp1256', 'windows-1256');
CharacterSetECI.UnicodeBigUnmarked = new CharacterSetECI(21 /* UnicodeBigUnmarked */, 25, 'UnicodeBigUnmarked', 'UTF-16BE', 'UnicodeBig');
CharacterSetECI.UTF8 = new CharacterSetECI(22 /* UTF8 */, 26, 'UTF8', 'UTF-8');
CharacterSetECI.ASCII = new CharacterSetECI(23 /* ASCII */, Int32Array.from([27, 170]), 'ASCII', 'US-ASCII');
CharacterSetECI.Big5 = new CharacterSetECI(24 /* Big5 */, 28, 'Big5');
CharacterSetECI.GB18030 = new CharacterSetECI(25 /* GB18030 */, 29, 'GB18030', 'GB2312', 'EUC_CN', 'GBK');
CharacterSetECI.EUC_KR = new CharacterSetECI(26 /* EUC_KR */, 30, 'EUC_KR', 'EUC-KR');
};
CharacterSetECI.VALUE_IDENTIFIER_TO_ECI = new Map();
CharacterSetECI.VALUES_TO_ECI = new Map();
CharacterSetECI.NAME_TO_ECI = new Map();
// Enum name is a Java encoding valid for java.lang and java.io
// TYPESCRIPTPORT: changed the main label for ISO as the TextEncoder did not recognized them in the form from java
// (eg ISO8859_1 must be ISO88591 or ISO8859-1 or ISO-8859-1)
// later on: well, except 16 wich does not work with ISO885916 so used ISO-8859-1 form for default
CharacterSetECI.Cp437 = new CharacterSetECI(0 /* Cp437 */, Int32Array.from([0, 2]), 'Cp437');
CharacterSetECI.ISO8859_1 = new CharacterSetECI(1 /* ISO8859_1 */, Int32Array.from([1, 3]), 'ISO-8859-1', 'ISO88591', 'ISO8859_1');
CharacterSetECI.ISO8859_2 = new CharacterSetECI(2 /* ISO8859_2 */, 4, 'ISO-8859-2', 'ISO88592', 'ISO8859_2');
CharacterSetECI.ISO8859_3 = new CharacterSetECI(3 /* ISO8859_3 */, 5, 'ISO-8859-3', 'ISO88593', 'ISO8859_3');
CharacterSetECI.ISO8859_4 = new CharacterSetECI(4 /* ISO8859_4 */, 6, 'ISO-8859-4', 'ISO88594', 'ISO8859_4');
CharacterSetECI.ISO8859_5 = new CharacterSetECI(5 /* ISO8859_5 */, 7, 'ISO-8859-5', 'ISO88595', 'ISO8859_5');
CharacterSetECI.ISO8859_6 = new CharacterSetECI(6 /* ISO8859_6 */, 8, 'ISO-8859-6', 'ISO88596', 'ISO8859_6');
CharacterSetECI.ISO8859_7 = new CharacterSetECI(7 /* ISO8859_7 */, 9, 'ISO-8859-7', 'ISO88597', 'ISO8859_7');
CharacterSetECI.ISO8859_8 = new CharacterSetECI(8 /* ISO8859_8 */, 10, 'ISO-8859-8', 'ISO88598', 'ISO8859_8');
CharacterSetECI.ISO8859_9 = new CharacterSetECI(9 /* ISO8859_9 */, 11, 'ISO-8859-9', 'ISO88599', 'ISO8859_9');
CharacterSetECI.ISO8859_10 = new CharacterSetECI(10 /* ISO8859_10 */, 12, 'ISO-8859-10', 'ISO885910', 'ISO8859_10');
CharacterSetECI.ISO8859_11 = new CharacterSetECI(11 /* ISO8859_11 */, 13, 'ISO-8859-11', 'ISO885911', 'ISO8859_11');
CharacterSetECI.ISO8859_13 = new CharacterSetECI(12 /* ISO8859_13 */, 15, 'ISO-8859-13', 'ISO885913', 'ISO8859_13');
CharacterSetECI.ISO8859_14 = new CharacterSetECI(13 /* ISO8859_14 */, 16, 'ISO-8859-14', 'ISO885914', 'ISO8859_14');
CharacterSetECI.ISO8859_15 = new CharacterSetECI(14 /* ISO8859_15 */, 17, 'ISO-8859-15', 'ISO885915', 'ISO8859_15');
CharacterSetECI.ISO8859_16 = new CharacterSetECI(15 /* ISO8859_16 */, 18, 'ISO-8859-16', 'ISO885916', 'ISO8859_16');
CharacterSetECI.SJIS = new CharacterSetECI(16 /* SJIS */, 20, 'SJIS', 'Shift_JIS');
CharacterSetECI.Cp1250 = new CharacterSetECI(17 /* Cp1250 */, 21, 'Cp1250', 'windows-1250');
CharacterSetECI.Cp1251 = new CharacterSetECI(18 /* Cp1251 */, 22, 'Cp1251', 'windows-1251');
CharacterSetECI.Cp1252 = new CharacterSetECI(19 /* Cp1252 */, 23, 'Cp1252', 'windows-1252');
CharacterSetECI.Cp1256 = new CharacterSetECI(20 /* Cp1256 */, 24, 'Cp1256', 'windows-1256');
CharacterSetECI.UnicodeBigUnmarked = new CharacterSetECI(21 /* UnicodeBigUnmarked */, 25, 'UnicodeBigUnmarked', 'UTF-16BE', 'UnicodeBig');
CharacterSetECI.UTF8 = new CharacterSetECI(22 /* UTF8 */, 26, 'UTF8', 'UTF-8');
CharacterSetECI.ASCII = new CharacterSetECI(23 /* ASCII */, Int32Array.from([27, 170]), 'ASCII', 'US-ASCII');
CharacterSetECI.Big5 = new CharacterSetECI(24 /* Big5 */, 28, 'Big5');
CharacterSetECI.GB18030 = new CharacterSetECI(25 /* GB18030 */, 29, 'GB18030', 'GB2312', 'EUC_CN', 'GBK');
CharacterSetECI.EUC_KR = new CharacterSetECI(26 /* EUC_KR */, 30, 'EUC_KR', 'EUC-KR');
return CharacterSetECI;
}());
exports.default = CharacterSetECI;
//# sourceMappingURL=CharacterSetECI.js.map

@@ -27,3 +27,3 @@ "use strict";

*/
class DecoderResult {
var DecoderResult = /** @class */ (function () {
// public constructor(rawBytes: Uint8Array,

@@ -35,3 +35,5 @@ // text: string,

// }
constructor(rawBytes, text, byteSegments, ecLevel, structuredAppendSequenceNumber = -1, structuredAppendParity = -1) {
function DecoderResult(rawBytes, text, byteSegments, ecLevel, structuredAppendSequenceNumber, structuredAppendParity) {
if (structuredAppendSequenceNumber === void 0) { structuredAppendSequenceNumber = -1; }
if (structuredAppendParity === void 0) { structuredAppendParity = -1; }
this.rawBytes = rawBytes;

@@ -48,5 +50,5 @@ this.text = text;

*/
getRawBytes() {
DecoderResult.prototype.getRawBytes = function () {
return this.rawBytes;
}
};
/**

@@ -56,5 +58,5 @@ * @return how many bits of {@link #getRawBytes()} are valid; typically 8 times its length

*/
getNumBits() {
DecoderResult.prototype.getNumBits = function () {
return this.numBits;
}
};
/**

@@ -64,61 +66,62 @@ * @param numBits overrides the number of bits that are valid in {@link #getRawBytes()}

*/
setNumBits(numBits /*int*/) {
DecoderResult.prototype.setNumBits = function (numBits /*int*/) {
this.numBits = numBits;
}
};
/**
* @return text representation of the result
*/
getText() {
DecoderResult.prototype.getText = function () {
return this.text;
}
};
/**
* @return list of byte segments in the result, or {@code null} if not applicable
*/
getByteSegments() {
DecoderResult.prototype.getByteSegments = function () {
return this.byteSegments;
}
};
/**
* @return name of error correction level used, or {@code null} if not applicable
*/
getECLevel() {
DecoderResult.prototype.getECLevel = function () {
return this.ecLevel;
}
};
/**
* @return number of errors corrected, or {@code null} if not applicable
*/
getErrorsCorrected() {
DecoderResult.prototype.getErrorsCorrected = function () {
return this.errorsCorrected;
}
setErrorsCorrected(errorsCorrected /*Integer*/) {
};
DecoderResult.prototype.setErrorsCorrected = function (errorsCorrected /*Integer*/) {
this.errorsCorrected = errorsCorrected;
}
};
/**
* @return number of erasures corrected, or {@code null} if not applicable
*/
getErasures() {
DecoderResult.prototype.getErasures = function () {
return this.erasures;
}
setErasures(erasures /*Integer*/) {
};
DecoderResult.prototype.setErasures = function (erasures /*Integer*/) {
this.erasures = erasures;
}
};
/**
* @return arbitrary additional metadata
*/
getOther() {
DecoderResult.prototype.getOther = function () {
return this.other;
}
setOther(other) {
};
DecoderResult.prototype.setOther = function (other) {
this.other = other;
}
hasStructuredAppend() {
};
DecoderResult.prototype.hasStructuredAppend = function () {
return this.structuredAppendParity >= 0 && this.structuredAppendSequenceNumber >= 0;
}
getStructuredAppendParity() {
};
DecoderResult.prototype.getStructuredAppendParity = function () {
return this.structuredAppendParity;
}
getStructuredAppendSequenceNumber() {
};
DecoderResult.prototype.getStructuredAppendSequenceNumber = function () {
return this.structuredAppendSequenceNumber;
}
}
};
return DecoderResult;
}());
exports.default = DecoderResult;
//# sourceMappingURL=DecoderResult.js.map

@@ -17,28 +17,42 @@ "use strict";

*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
/*namespace com.google.zxing.common {*/
const GridSampler_1 = require("./GridSampler");
const BitMatrix_1 = require("./BitMatrix");
const PerspectiveTransform_1 = require("./PerspectiveTransform");
const Exception_1 = require("./../Exception");
var GridSampler_1 = require("./GridSampler");
var BitMatrix_1 = require("./BitMatrix");
var PerspectiveTransform_1 = require("./PerspectiveTransform");
var Exception_1 = require("./../Exception");
/**
* @author Sean Owen
*/
class DefaultGridSampler extends GridSampler_1.default {
var DefaultGridSampler = /** @class */ (function (_super) {
__extends(DefaultGridSampler, _super);
function DefaultGridSampler() {
return _super !== null && _super.apply(this, arguments) || this;
}
/*@Override*/
sampleGrid(image, dimensionX /*int*/, dimensionY /*int*/, p1ToX /*float*/, p1ToY /*float*/, p2ToX /*float*/, p2ToY /*float*/, p3ToX /*float*/, p3ToY /*float*/, p4ToX /*float*/, p4ToY /*float*/, p1FromX /*float*/, p1FromY /*float*/, p2FromX /*float*/, p2FromY /*float*/, p3FromX /*float*/, p3FromY /*float*/, p4FromX /*float*/, p4FromY /*float*/) {
const transform = PerspectiveTransform_1.default.quadrilateralToQuadrilateral(p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY);
DefaultGridSampler.prototype.sampleGrid = function (image, dimensionX /*int*/, dimensionY /*int*/, p1ToX /*float*/, p1ToY /*float*/, p2ToX /*float*/, p2ToY /*float*/, p3ToX /*float*/, p3ToY /*float*/, p4ToX /*float*/, p4ToY /*float*/, p1FromX /*float*/, p1FromY /*float*/, p2FromX /*float*/, p2FromY /*float*/, p3FromX /*float*/, p3FromY /*float*/, p4FromX /*float*/, p4FromY /*float*/) {
var transform = PerspectiveTransform_1.default.quadrilateralToQuadrilateral(p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY);
return this.sampleGridWithTransform(image, dimensionX, dimensionY, transform);
}
};
/*@Override*/
sampleGridWithTransform(image, dimensionX /*int*/, dimensionY /*int*/, transform) {
DefaultGridSampler.prototype.sampleGridWithTransform = function (image, dimensionX /*int*/, dimensionY /*int*/, transform) {
if (dimensionX <= 0 || dimensionY <= 0) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
}
const bits = new BitMatrix_1.default(dimensionX, dimensionY);
const points = new Float32Array(2 * dimensionX);
for (let y = 0; y < dimensionY; y++) {
const max = points.length;
const iValue = y + 0.5;
for (let x = 0; x < max; x += 2) {
var bits = new BitMatrix_1.default(dimensionX, dimensionY);
var points = new Float32Array(2 * dimensionX);
for (var y = 0; y < dimensionY; y++) {
var max = points.length;
var iValue = y + 0.5;
for (var x = 0; x < max; x += 2) {
points[x] = /*(float)*/ (x / 2) + 0.5;

@@ -52,3 +66,3 @@ points[x + 1] = iValue;

try {
for (let x = 0; x < max; x += 2) {
for (var x = 0; x < max; x += 2) {
if (image.get(Math.floor(points[x]), Math.floor(points[x + 1]))) {

@@ -72,5 +86,6 @@ // Black(-ish) pixel

return bits;
}
}
};
return DefaultGridSampler;
}(GridSampler_1.default));
exports.default = DefaultGridSampler;
//# sourceMappingURL=DefaultGridSampler.js.map

@@ -22,5 +22,7 @@ "use strict";

*/
class MathUtils {
MathUtils() {
var MathUtils = /** @class */ (function () {
function MathUtils() {
}
MathUtils.prototype.MathUtils = function () {
};
/**

@@ -35,3 +37,3 @@ * Ends up being a bit faster than {@link Math#round(float)}. This merely rounds its

*/
static round(d /*float*/) {
MathUtils.round = function (d /*float*/) {
if (NaN === d)

@@ -44,3 +46,3 @@ return 0;

return /*(int) */ (d + (d < 0.0 ? -0.5 : 0.5)) | 0;
}
};
// TYPESCRIPTPORT: maybe remove round method and call directly Math.round, it looks like it doesn't make sense for js

@@ -54,7 +56,7 @@ /**

*/
static distance(aX /*float|int*/, aY /*float|int*/, bX /*float|int*/, bY /*float|int*/) {
const xDiff = aX - bX;
const yDiff = aY - bY;
MathUtils.distance = function (aX /*float|int*/, aY /*float|int*/, bX /*float|int*/, bY /*float|int*/) {
var xDiff = aX - bX;
var yDiff = aY - bY;
return /*(float) */ Math.sqrt(xDiff * xDiff + yDiff * yDiff);
}
};
/**

@@ -76,12 +78,13 @@ * @param aX point A x coordinate

*/
static sum(array) {
let count = 0;
for (let i = 0, length = array.length; i !== length; i++) {
const a = array[i];
MathUtils.sum = function (array) {
var count = 0;
for (var i = 0, length_1 = array.length; i !== length_1; i++) {
var a = array[i];
count += a;
}
return count;
}
}
};
return MathUtils;
}());
exports.default = MathUtils;
//# sourceMappingURL=MathUtils.js.map

@@ -19,5 +19,5 @@ "use strict";

/*namespace com.google.zxing.common.detector {*/
const ResultPoint_1 = require("./../../ResultPoint");
const Exception_1 = require("./../../Exception");
const MathUtils_1 = require("./MathUtils");
var ResultPoint_1 = require("./../../ResultPoint");
var Exception_1 = require("./../../Exception");
var MathUtils_1 = require("./MathUtils");
/**

@@ -33,3 +33,3 @@ * <p>

*/
class WhiteRectangleDetector {
var WhiteRectangleDetector = /** @class */ (function () {
// public constructor(private image: BitMatrix) /*throws NotFoundException*/ {

@@ -45,3 +45,3 @@ // this(image, INIT_SIZE, image.getWidth() / 2, image.getHeight() / 2)

*/
constructor(image, initSize /*int*/, x /*int*/, y /*int*/) {
function WhiteRectangleDetector(image, initSize /*int*/, x /*int*/, y /*int*/) {
this.image = image;

@@ -59,3 +59,3 @@ this.height = image.getHeight();

}
const halfsize = initSize / 2;
var halfsize = initSize / 2;
this.leftInit = x - halfsize;

@@ -83,16 +83,16 @@ this.rightInit = x + halfsize;

*/
detect() {
let left = this.leftInit;
let right = this.rightInit;
let up = this.upInit;
let down = this.downInit;
let sizeExceeded = false;
let aBlackPointFoundOnBorder = true;
let atLeastOneBlackPointFoundOnBorder = false;
let atLeastOneBlackPointFoundOnRight = false;
let atLeastOneBlackPointFoundOnBottom = false;
let atLeastOneBlackPointFoundOnLeft = false;
let atLeastOneBlackPointFoundOnTop = false;
const width = this.width;
const height = this.height;
WhiteRectangleDetector.prototype.detect = function () {
var left = this.leftInit;
var right = this.rightInit;
var up = this.upInit;
var down = this.downInit;
var sizeExceeded = false;
var aBlackPointFoundOnBorder = true;
var atLeastOneBlackPointFoundOnBorder = false;
var atLeastOneBlackPointFoundOnRight = false;
var atLeastOneBlackPointFoundOnBottom = false;
var atLeastOneBlackPointFoundOnLeft = false;
var atLeastOneBlackPointFoundOnTop = false;
var width = this.width;
var height = this.height;
while (aBlackPointFoundOnBorder) {

@@ -103,3 +103,3 @@ aBlackPointFoundOnBorder = false;

// .....
let rightBorderNotWhite = true;
var rightBorderNotWhite = true;
while ((rightBorderNotWhite || !atLeastOneBlackPointFoundOnRight) && right < width) {

@@ -123,3 +123,3 @@ rightBorderNotWhite = this.containsBlackPoint(up, down, right, false);

// .___.
let bottomBorderNotWhite = true;
var bottomBorderNotWhite = true;
while ((bottomBorderNotWhite || !atLeastOneBlackPointFoundOnBottom) && down < height) {

@@ -143,3 +143,3 @@ bottomBorderNotWhite = this.containsBlackPoint(left, right, down, true);

// .....
let leftBorderNotWhite = true;
var leftBorderNotWhite = true;
while ((leftBorderNotWhite || !atLeastOneBlackPointFoundOnLeft) && left >= 0) {

@@ -163,3 +163,3 @@ leftBorderNotWhite = this.containsBlackPoint(up, down, left, false);

// .....
let topBorderNotWhite = true;
var topBorderNotWhite = true;
while ((topBorderNotWhite || !atLeastOneBlackPointFoundOnTop) && up >= 0) {

@@ -185,5 +185,5 @@ topBorderNotWhite = this.containsBlackPoint(left, right, up, true);

if (!sizeExceeded && atLeastOneBlackPointFoundOnBorder) {
const maxSize = right - left;
let z = null;
for (let i = 1; z === null && i < maxSize; i++) {
var maxSize = right - left;
var z = null;
for (var i = 1; z === null && i < maxSize; i++) {
z = this.getBlackPointOnSegment(left, down - i, left + i, down);

@@ -194,5 +194,5 @@ }

}
let t = null;
var t = null;
// go down right
for (let i = 1; t === null && i < maxSize; i++) {
for (var i = 1; t === null && i < maxSize; i++) {
t = this.getBlackPointOnSegment(left, up + i, left + i, up);

@@ -203,5 +203,5 @@ }

}
let x = null;
var x = null;
// go down left
for (let i = 1; x === null && i < maxSize; i++) {
for (var i = 1; x === null && i < maxSize; i++) {
x = this.getBlackPointOnSegment(right, up + i, right - i, up);

@@ -212,5 +212,5 @@ }

}
let y = null;
var y = null;
// go up left
for (let i = 1; y === null && i < maxSize; i++) {
for (var i = 1; y === null && i < maxSize; i++) {
y = this.getBlackPointOnSegment(right, down - i, right - i, down);

@@ -226,11 +226,11 @@ }

}
}
getBlackPointOnSegment(aX /*float*/, aY /*float*/, bX /*float*/, bY /*float*/) {
const dist = MathUtils_1.default.round(MathUtils_1.default.distance(aX, aY, bX, bY));
const xStep = (bX - aX) / dist;
const yStep = (bY - aY) / dist;
const image = this.image;
for (let i = 0; i < dist; i++) {
const x = MathUtils_1.default.round(aX + i * xStep);
const y = MathUtils_1.default.round(aY + i * yStep);
};
WhiteRectangleDetector.prototype.getBlackPointOnSegment = function (aX /*float*/, aY /*float*/, bX /*float*/, bY /*float*/) {
var dist = MathUtils_1.default.round(MathUtils_1.default.distance(aX, aY, bX, bY));
var xStep = (bX - aX) / dist;
var yStep = (bY - aY) / dist;
var image = this.image;
for (var i = 0; i < dist; i++) {
var x = MathUtils_1.default.round(aX + i * xStep);
var y = MathUtils_1.default.round(aY + i * yStep);
if (image.get(x, y)) {

@@ -241,3 +241,3 @@ return new ResultPoint_1.default(x, y);

return null;
}
};
/**

@@ -256,3 +256,3 @@ * recenters the points of a constant distance towards the center

*/
centerEdges(y, z, x, t) {
WhiteRectangleDetector.prototype.centerEdges = function (y, z, x, t) {
//

@@ -264,11 +264,11 @@ // t t

//
const yi = y.getX();
const yj = y.getY();
const zi = z.getX();
const zj = z.getY();
const xi = x.getX();
const xj = x.getY();
const ti = t.getX();
const tj = t.getY();
const CORR = WhiteRectangleDetector.CORR;
var yi = y.getX();
var yj = y.getY();
var zi = z.getX();
var zj = z.getY();
var xi = x.getX();
var xj = x.getY();
var ti = t.getX();
var tj = t.getY();
var CORR = WhiteRectangleDetector.CORR;
if (yi < this.width / 2.0) {

@@ -290,3 +290,3 @@ return [

}
}
};
/**

@@ -301,6 +301,6 @@ * Determines whether a segment contains a black point

*/
containsBlackPoint(a /*int*/, b /*int*/, fixed /*int*/, horizontal) {
const image = this.image;
WhiteRectangleDetector.prototype.containsBlackPoint = function (a /*int*/, b /*int*/, fixed /*int*/, horizontal) {
var image = this.image;
if (horizontal) {
for (let x = a; x <= b; x++) {
for (var x = a; x <= b; x++) {
if (image.get(x, fixed)) {

@@ -312,3 +312,3 @@ return true;

else {
for (let y = a; y <= b; y++) {
for (var y = a; y <= b; y++) {
if (image.get(fixed, y)) {

@@ -320,7 +320,8 @@ return true;

return false;
}
}
WhiteRectangleDetector.INIT_SIZE = 10;
WhiteRectangleDetector.CORR = 1;
};
WhiteRectangleDetector.INIT_SIZE = 10;
WhiteRectangleDetector.CORR = 1;
return WhiteRectangleDetector;
}());
exports.default = WhiteRectangleDetector;
//# sourceMappingURL=WhiteRectangleDetector.js.map

@@ -25,15 +25,16 @@ "use strict";

*/
class DetectorResult {
constructor(bits, points) {
var DetectorResult = /** @class */ (function () {
function DetectorResult(bits, points) {
this.bits = bits;
this.points = points;
}
getBits() {
DetectorResult.prototype.getBits = function () {
return this.bits;
}
getPoints() {
};
DetectorResult.prototype.getPoints = function () {
return this.points;
}
}
};
return DetectorResult;
}());
exports.default = DetectorResult;
//# sourceMappingURL=DetectorResult.js.map

@@ -17,8 +17,18 @@ "use strict";

*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
/*namespace com.google.zxing.common {*/
const Binarizer_1 = require("./../Binarizer");
const BitArray_1 = require("./BitArray");
const BitMatrix_1 = require("./BitMatrix");
const Exception_1 = require("./../Exception");
var Binarizer_1 = require("./../Binarizer");
var BitArray_1 = require("./BitArray");
var BitMatrix_1 = require("./BitMatrix");
var Exception_1 = require("./../Exception");
/**

@@ -35,13 +45,15 @@ * This Binarizer implementation uses the old ZXing global histogram approach. It is suitable

*/
class GlobalHistogramBinarizer extends Binarizer_1.default {
constructor(source) {
super(source);
this.luminances = GlobalHistogramBinarizer.EMPTY;
this.buckets = new Int32Array(GlobalHistogramBinarizer.LUMINANCE_BUCKETS);
var GlobalHistogramBinarizer = /** @class */ (function (_super) {
__extends(GlobalHistogramBinarizer, _super);
function GlobalHistogramBinarizer(source) {
var _this = _super.call(this, source) || this;
_this.luminances = GlobalHistogramBinarizer.EMPTY;
_this.buckets = new Int32Array(GlobalHistogramBinarizer.LUMINANCE_BUCKETS);
return _this;
}
// Applies simple sharpening to the row data to improve performance of the 1D Readers.
/*@Override*/
getBlackRow(y /*int*/, row) {
const source = this.getLuminanceSource();
const width = source.getWidth();
GlobalHistogramBinarizer.prototype.getBlackRow = function (y /*int*/, row) {
var source = this.getLuminanceSource();
var width = source.getWidth();
if (row === undefined || row === null || row.getSize() < width) {

@@ -54,11 +66,11 @@ row = new BitArray_1.default(width);

this.initArrays(width);
const localLuminances = source.getRow(y, this.luminances);
const localBuckets = this.buckets;
for (let x = 0; x < width; x++) {
var localLuminances = source.getRow(y, this.luminances);
var localBuckets = this.buckets;
for (var x = 0; x < width; x++) {
localBuckets[(localLuminances[x] & 0xff) >> GlobalHistogramBinarizer.LUMINANCE_SHIFT]++;
}
const blackPoint = GlobalHistogramBinarizer.estimateBlackPoint(localBuckets);
var blackPoint = GlobalHistogramBinarizer.estimateBlackPoint(localBuckets);
if (width < 3) {
// Special case for very small images
for (let x = 0; x < width; x++) {
for (var x = 0; x < width; x++) {
if ((localLuminances[x] & 0xff) < blackPoint) {

@@ -70,6 +82,6 @@ row.set(x);

else {
let left = localLuminances[0] & 0xff;
let center = localLuminances[1] & 0xff;
for (let x = 1; x < width - 1; x++) {
const right = localLuminances[x + 1] & 0xff;
var left = localLuminances[0] & 0xff;
var center = localLuminances[1] & 0xff;
for (var x = 1; x < width - 1; x++) {
var right = localLuminances[x + 1] & 0xff;
// A simple -1 4 -1 box filter with a weight of 2.

@@ -84,32 +96,32 @@ if (((center * 4) - left - right) / 2 < blackPoint) {

return row;
}
};
// Does not sharpen the data, as this call is intended to only be used by 2D Readers.
/*@Override*/
getBlackMatrix() {
const source = this.getLuminanceSource();
const width = source.getWidth();
const height = source.getHeight();
const matrix = new BitMatrix_1.default(width, height);
GlobalHistogramBinarizer.prototype.getBlackMatrix = function () {
var source = this.getLuminanceSource();
var width = source.getWidth();
var height = source.getHeight();
var matrix = new BitMatrix_1.default(width, height);
// Quickly calculates the histogram by sampling four rows from the image. This proved to be
// more robust on the blackbox tests than sampling a diagonal as we used to do.
this.initArrays(width);
const localBuckets = this.buckets;
for (let y = 1; y < 5; y++) {
const row = height * y / 5;
const localLuminances = source.getRow(row, this.luminances);
const right = Math.floor((width * 4) / 5);
for (let x = Math.floor(width / 5); x < right; x++) {
const pixel = localLuminances[x] & 0xff;
var localBuckets = this.buckets;
for (var y = 1; y < 5; y++) {
var row = height * y / 5;
var localLuminances_1 = source.getRow(row, this.luminances);
var right = Math.floor((width * 4) / 5);
for (var x = Math.floor(width / 5); x < right; x++) {
var pixel = localLuminances_1[x] & 0xff;
localBuckets[pixel >> GlobalHistogramBinarizer.LUMINANCE_SHIFT]++;
}
}
const blackPoint = GlobalHistogramBinarizer.estimateBlackPoint(localBuckets);
var blackPoint = GlobalHistogramBinarizer.estimateBlackPoint(localBuckets);
// We delay reading the entire image luminance until the black point estimation succeeds.
// Although we end up reading four rows twice, it is consistent with our motto of
// "fail quickly" which is necessary for continuous scanning.
const localLuminances = source.getMatrix();
for (let y = 0; y < height; y++) {
const offset = y * width;
for (let x = 0; x < width; x++) {
const pixel = localLuminances[offset + x] & 0xff;
var localLuminances = source.getMatrix();
for (var y = 0; y < height; y++) {
var offset = y * width;
for (var x = 0; x < width; x++) {
var pixel = localLuminances[offset + x] & 0xff;
if (pixel < blackPoint) {

@@ -121,23 +133,23 @@ matrix.set(x, y);

return matrix;
}
};
/*@Override*/
createBinarizer(source) {
GlobalHistogramBinarizer.prototype.createBinarizer = function (source) {
return new GlobalHistogramBinarizer(source);
}
initArrays(luminanceSize /*int*/) {
};
GlobalHistogramBinarizer.prototype.initArrays = function (luminanceSize /*int*/) {
if (this.luminances.length < luminanceSize) {
this.luminances = new Uint8ClampedArray(luminanceSize);
}
const buckets = this.buckets;
for (let x = 0; x < GlobalHistogramBinarizer.LUMINANCE_BUCKETS; x++) {
var buckets = this.buckets;
for (var x = 0; x < GlobalHistogramBinarizer.LUMINANCE_BUCKETS; x++) {
buckets[x] = 0;
}
}
static estimateBlackPoint(buckets) {
};
GlobalHistogramBinarizer.estimateBlackPoint = function (buckets) {
// Find the tallest peak in the histogram.
const numBuckets = buckets.length;
let maxBucketCount = 0;
let firstPeak = 0;
let firstPeakSize = 0;
for (let x = 0; x < numBuckets; x++) {
var numBuckets = buckets.length;
var maxBucketCount = 0;
var firstPeak = 0;
var firstPeakSize = 0;
for (var x = 0; x < numBuckets; x++) {
if (buckets[x] > firstPeakSize) {

@@ -152,8 +164,8 @@ firstPeak = x;

// Find the second-tallest peak which is somewhat far from the tallest peak.
let secondPeak = 0;
let secondPeakScore = 0;
for (let x = 0; x < numBuckets; x++) {
const distanceToBiggest = x - firstPeak;
var secondPeak = 0;
var secondPeakScore = 0;
for (var x = 0; x < numBuckets; x++) {
var distanceToBiggest = x - firstPeak;
// Encourage more distant second peaks by multiplying by square of distance.
const score = buckets[x] * distanceToBiggest * distanceToBiggest;
var score = buckets[x] * distanceToBiggest * distanceToBiggest;
if (score > secondPeakScore) {

@@ -166,3 +178,3 @@ secondPeak = x;

if (firstPeak > secondPeak) {
const temp = firstPeak;
var temp = firstPeak;
firstPeak = secondPeak;

@@ -177,7 +189,7 @@ secondPeak = temp;

// Find a valley between them that is low and closer to the white peak.
let bestValley = secondPeak - 1;
let bestValleyScore = -1;
for (let x = secondPeak - 1; x > firstPeak; x--) {
const fromFirst = x - firstPeak;
const score = fromFirst * fromFirst * (secondPeak - x) * (maxBucketCount - buckets[x]);
var bestValley = secondPeak - 1;
var bestValleyScore = -1;
for (var x = secondPeak - 1; x > firstPeak; x--) {
var fromFirst = x - firstPeak;
var score = fromFirst * fromFirst * (secondPeak - x) * (maxBucketCount - buckets[x]);
if (score > bestValleyScore) {

@@ -189,9 +201,10 @@ bestValley = x;

return bestValley << GlobalHistogramBinarizer.LUMINANCE_SHIFT;
}
}
GlobalHistogramBinarizer.LUMINANCE_BITS = 5;
GlobalHistogramBinarizer.LUMINANCE_SHIFT = 8 - GlobalHistogramBinarizer.LUMINANCE_BITS;
GlobalHistogramBinarizer.LUMINANCE_BUCKETS = 1 << GlobalHistogramBinarizer.LUMINANCE_BITS;
GlobalHistogramBinarizer.EMPTY = Uint8ClampedArray.from([0]);
};
GlobalHistogramBinarizer.LUMINANCE_BITS = 5;
GlobalHistogramBinarizer.LUMINANCE_SHIFT = 8 - GlobalHistogramBinarizer.LUMINANCE_BITS;
GlobalHistogramBinarizer.LUMINANCE_BUCKETS = 1 << GlobalHistogramBinarizer.LUMINANCE_BITS;
GlobalHistogramBinarizer.EMPTY = Uint8ClampedArray.from([0]);
return GlobalHistogramBinarizer;
}(Binarizer_1.default));
exports.default = GlobalHistogramBinarizer;
//# sourceMappingURL=GlobalHistogramBinarizer.js.map

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const Exception_1 = require("./../Exception");
var Exception_1 = require("./../Exception");
/**

@@ -33,3 +33,5 @@ * Implementations of this class can, given locations of finder patterns for a QR code in an

*/
class GridSampler {
var GridSampler = /** @class */ (function () {
function GridSampler() {
}
/**

@@ -50,10 +52,10 @@ * <p>Checks a set of points that have been transformed to sample points on an image against

*/
static checkAndNudgePoints(image, points) {
const width = image.getWidth();
const height = image.getHeight();
GridSampler.checkAndNudgePoints = function (image, points) {
var width = image.getWidth();
var height = image.getHeight();
// Check and nudge points from start until we see some that are OK:
let nudged = true;
for (let offset = 0; offset < points.length && nudged; offset += 2) {
const x = Math.floor(points[offset]);
const y = Math.floor(points[offset + 1]);
var nudged = true;
for (var offset = 0; offset < points.length && nudged; offset += 2) {
var x = Math.floor(points[offset]);
var y = Math.floor(points[offset + 1]);
if (x < -1 || x > width || y < -1 || y > height) {

@@ -82,5 +84,5 @@ throw new Exception_1.default(Exception_1.default.NotFoundException);

nudged = true;
for (let offset = points.length - 2; offset >= 0 && nudged; offset -= 2) {
const x = Math.floor(points[offset]);
const y = Math.floor(points[offset + 1]);
for (var offset = points.length - 2; offset >= 0 && nudged; offset -= 2) {
var x = Math.floor(points[offset]);
var y = Math.floor(points[offset + 1]);
if (x < -1 || x > width || y < -1 || y > height) {

@@ -107,5 +109,6 @@ throw new Exception_1.default(Exception_1.default.NotFoundException);

}
}
}
};
return GridSampler;
}());
exports.default = GridSampler;
//# sourceMappingURL=GridSampler.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const DefaultGridSampler_1 = require("./DefaultGridSampler");
class GridSamplerInstance {
var DefaultGridSampler_1 = require("./DefaultGridSampler");
var GridSamplerInstance = /** @class */ (function () {
function GridSamplerInstance() {
}
/**

@@ -14,14 +16,15 @@ * Sets the implementation of GridSampler used by the library. One global

*/
static setGridSampler(newGridSampler) {
GridSamplerInstance.setGridSampler = function (newGridSampler) {
GridSamplerInstance.gridSampler = newGridSampler;
}
};
/**
* @return the current implementation of GridSampler
*/
static getInstance() {
GridSamplerInstance.getInstance = function () {
return GridSamplerInstance.gridSampler;
}
}
GridSamplerInstance.gridSampler = new DefaultGridSampler_1.default();
};
GridSamplerInstance.gridSampler = new DefaultGridSampler_1.default();
return GridSamplerInstance;
}());
exports.default = GridSamplerInstance;
//# sourceMappingURL=GridSamplerInstance.js.map

@@ -17,5 +17,15 @@ "use strict";

*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const GlobalHistogramBinarizer_1 = require("./GlobalHistogramBinarizer");
const BitMatrix_1 = require("./BitMatrix");
var GlobalHistogramBinarizer_1 = require("./GlobalHistogramBinarizer");
var BitMatrix_1 = require("./BitMatrix");
/**

@@ -38,6 +48,8 @@ * This class implements a local thresholding algorithm, which while slower than the

*/
class HybridBinarizer extends GlobalHistogramBinarizer_1.default {
constructor(source) {
super(source);
this.matrix = null;
var HybridBinarizer = /** @class */ (function (_super) {
__extends(HybridBinarizer, _super);
function HybridBinarizer(source) {
var _this = _super.call(this, source) || this;
_this.matrix = null;
return _this;
}

@@ -50,21 +62,21 @@ /**

/*@Override*/
getBlackMatrix() {
HybridBinarizer.prototype.getBlackMatrix = function () {
if (this.matrix !== null) {
return this.matrix;
}
const source = this.getLuminanceSource();
const width = source.getWidth();
const height = source.getHeight();
var source = this.getLuminanceSource();
var width = source.getWidth();
var height = source.getHeight();
if (width >= HybridBinarizer.MINIMUM_DIMENSION && height >= HybridBinarizer.MINIMUM_DIMENSION) {
const luminances = source.getMatrix();
let subWidth = width >> HybridBinarizer.BLOCK_SIZE_POWER;
var luminances = source.getMatrix();
var subWidth = width >> HybridBinarizer.BLOCK_SIZE_POWER;
if ((width & HybridBinarizer.BLOCK_SIZE_MASK) !== 0) {
subWidth++;
}
let subHeight = height >> HybridBinarizer.BLOCK_SIZE_POWER;
var subHeight = height >> HybridBinarizer.BLOCK_SIZE_POWER;
if ((height & HybridBinarizer.BLOCK_SIZE_MASK) !== 0) {
subHeight++;
}
const blackPoints = HybridBinarizer.calculateBlackPoints(luminances, subWidth, subHeight, width, height);
const newMatrix = new BitMatrix_1.default(width, height);
var blackPoints = HybridBinarizer.calculateBlackPoints(luminances, subWidth, subHeight, width, height);
var newMatrix = new BitMatrix_1.default(width, height);
HybridBinarizer.calculateThresholdForBlock(luminances, subWidth, subHeight, width, height, blackPoints, newMatrix);

@@ -75,10 +87,10 @@ this.matrix = newMatrix;

// If the image is too small, fall back to the global histogram approach.
this.matrix = super.getBlackMatrix();
this.matrix = _super.prototype.getBlackMatrix.call(this);
}
return this.matrix;
}
};
/*@Override*/
createBinarizer(source) {
HybridBinarizer.prototype.createBinarizer = function (source) {
return new HybridBinarizer(source);
}
};
/**

@@ -89,36 +101,36 @@ * For each block in the image, calculate the average black point using a 5x5 grid

*/
static calculateThresholdForBlock(luminances, subWidth /*int*/, subHeight /*int*/, width /*int*/, height /*int*/, blackPoints, matrix) {
const maxYOffset = height - HybridBinarizer.BLOCK_SIZE;
const maxXOffset = width - HybridBinarizer.BLOCK_SIZE;
for (let y = 0; y < subHeight; y++) {
let yoffset = y << HybridBinarizer.BLOCK_SIZE_POWER;
HybridBinarizer.calculateThresholdForBlock = function (luminances, subWidth /*int*/, subHeight /*int*/, width /*int*/, height /*int*/, blackPoints, matrix) {
var maxYOffset = height - HybridBinarizer.BLOCK_SIZE;
var maxXOffset = width - HybridBinarizer.BLOCK_SIZE;
for (var y = 0; y < subHeight; y++) {
var yoffset = y << HybridBinarizer.BLOCK_SIZE_POWER;
if (yoffset > maxYOffset) {
yoffset = maxYOffset;
}
const top = HybridBinarizer.cap(y, 2, subHeight - 3);
for (let x = 0; x < subWidth; x++) {
let xoffset = x << HybridBinarizer.BLOCK_SIZE_POWER;
var top_1 = HybridBinarizer.cap(y, 2, subHeight - 3);
for (var x = 0; x < subWidth; x++) {
var xoffset = x << HybridBinarizer.BLOCK_SIZE_POWER;
if (xoffset > maxXOffset) {
xoffset = maxXOffset;
}
const left = HybridBinarizer.cap(x, 2, subWidth - 3);
let sum = 0;
for (let z = -2; z <= 2; z++) {
const blackRow = blackPoints[top + z];
var left = HybridBinarizer.cap(x, 2, subWidth - 3);
var sum = 0;
for (var z = -2; z <= 2; z++) {
var blackRow = blackPoints[top_1 + z];
sum += blackRow[left - 2] + blackRow[left - 1] + blackRow[left] + blackRow[left + 1] + blackRow[left + 2];
}
const average = sum / 25;
var average = sum / 25;
HybridBinarizer.thresholdBlock(luminances, xoffset, yoffset, average, width, matrix);
}
}
}
static cap(value /*int*/, min /*int*/, max /*int*/) {
};
HybridBinarizer.cap = function (value /*int*/, min /*int*/, max /*int*/) {
return value < min ? min : value > max ? max : value;
}
};
/**
* Applies a single threshold to a block of pixels.
*/
static thresholdBlock(luminances, xoffset /*int*/, yoffset /*int*/, threshold /*int*/, stride /*int*/, matrix) {
for (let y = 0, offset = yoffset * stride + xoffset; y < HybridBinarizer.BLOCK_SIZE; y++, offset += stride) {
for (let x = 0; x < HybridBinarizer.BLOCK_SIZE; x++) {
HybridBinarizer.thresholdBlock = function (luminances, xoffset /*int*/, yoffset /*int*/, threshold /*int*/, stride /*int*/, matrix) {
for (var y = 0, offset = yoffset * stride + xoffset; y < HybridBinarizer.BLOCK_SIZE; y++, offset += stride) {
for (var x = 0; x < HybridBinarizer.BLOCK_SIZE; x++) {
// Comparison needs to be <= so that black == 0 pixels are black even if the threshold is 0.

@@ -130,3 +142,3 @@ if ((luminances[offset + x] & 0xFF) <= threshold) {

}
}
};
/**

@@ -137,24 +149,24 @@ * Calculates a single black point for each block of pixels and saves it away.

*/
static calculateBlackPoints(luminances, subWidth /*int*/, subHeight /*int*/, width /*int*/, height /*int*/) {
const maxYOffset = height - HybridBinarizer.BLOCK_SIZE;
const maxXOffset = width - HybridBinarizer.BLOCK_SIZE;
HybridBinarizer.calculateBlackPoints = function (luminances, subWidth /*int*/, subHeight /*int*/, width /*int*/, height /*int*/) {
var maxYOffset = height - HybridBinarizer.BLOCK_SIZE;
var maxXOffset = width - HybridBinarizer.BLOCK_SIZE;
// tslint:disable-next-line:whitespace
const blackPoints = new Array(subHeight); // subWidth
for (let y = 0; y < subHeight; y++) {
var blackPoints = new Array(subHeight); // subWidth
for (var y = 0; y < subHeight; y++) {
blackPoints[y] = new Int32Array(subWidth);
let yoffset = y << HybridBinarizer.BLOCK_SIZE_POWER;
var yoffset = y << HybridBinarizer.BLOCK_SIZE_POWER;
if (yoffset > maxYOffset) {
yoffset = maxYOffset;
}
for (let x = 0; x < subWidth; x++) {
let xoffset = x << HybridBinarizer.BLOCK_SIZE_POWER;
for (var x = 0; x < subWidth; x++) {
var xoffset = x << HybridBinarizer.BLOCK_SIZE_POWER;
if (xoffset > maxXOffset) {
xoffset = maxXOffset;
}
let sum = 0;
let min = 0xFF;
let max = 0;
for (let yy = 0, offset = yoffset * width + xoffset; yy < HybridBinarizer.BLOCK_SIZE; yy++, offset += width) {
for (let xx = 0; xx < HybridBinarizer.BLOCK_SIZE; xx++) {
const pixel = luminances[offset + xx] & 0xFF;
var sum = 0;
var min = 0xFF;
var max = 0;
for (var yy = 0, offset = yoffset * width + xoffset; yy < HybridBinarizer.BLOCK_SIZE; yy++, offset += width) {
for (var xx = 0; xx < HybridBinarizer.BLOCK_SIZE; xx++) {
var pixel = luminances[offset + xx] & 0xFF;
sum += pixel;

@@ -173,3 +185,3 @@ // still looking for good contrast

for (yy++, offset += width; yy < HybridBinarizer.BLOCK_SIZE; yy++, offset += width) {
for (let xx = 0; xx < HybridBinarizer.BLOCK_SIZE; xx++) {
for (var xx = 0; xx < HybridBinarizer.BLOCK_SIZE; xx++) {
sum += luminances[offset + xx] & 0xFF;

@@ -181,3 +193,3 @@ }

// The default estimate is the average of the values in the block.
let average = sum >> (HybridBinarizer.BLOCK_SIZE_POWER * 2);
var average = sum >> (HybridBinarizer.BLOCK_SIZE_POWER * 2);
if (max - min <= HybridBinarizer.MIN_DYNAMIC_RANGE) {

@@ -198,3 +210,3 @@ // If variation within the block is low, assume this is a block with only light or only

// The (min < bp) is arbitrary but works better than other heuristics that were tried.
const averageNeighborBlackPoint = (blackPoints[y - 1][x] + (2 * blackPoints[y][x - 1]) + blackPoints[y - 1][x - 1]) / 4;
var averageNeighborBlackPoint = (blackPoints[y - 1][x] + (2 * blackPoints[y][x - 1]) + blackPoints[y - 1][x - 1]) / 4;
if (min < averageNeighborBlackPoint) {

@@ -209,12 +221,13 @@ average = averageNeighborBlackPoint;

return blackPoints;
}
}
// This class uses 5x5 blocks to compute local luminance, where each block is 8x8 pixels.
// So this is the smallest dimension in each axis we can accept.
HybridBinarizer.BLOCK_SIZE_POWER = 3;
HybridBinarizer.BLOCK_SIZE = 1 << HybridBinarizer.BLOCK_SIZE_POWER; // ...0100...00
HybridBinarizer.BLOCK_SIZE_MASK = HybridBinarizer.BLOCK_SIZE - 1; // ...0011...11
HybridBinarizer.MINIMUM_DIMENSION = HybridBinarizer.BLOCK_SIZE * 5;
HybridBinarizer.MIN_DYNAMIC_RANGE = 24;
};
// This class uses 5x5 blocks to compute local luminance, where each block is 8x8 pixels.
// So this is the smallest dimension in each axis we can accept.
HybridBinarizer.BLOCK_SIZE_POWER = 3;
HybridBinarizer.BLOCK_SIZE = 1 << HybridBinarizer.BLOCK_SIZE_POWER; // ...0100...00
HybridBinarizer.BLOCK_SIZE_MASK = HybridBinarizer.BLOCK_SIZE - 1; // ...0011...11
HybridBinarizer.MINIMUM_DIMENSION = HybridBinarizer.BLOCK_SIZE * 5;
HybridBinarizer.MIN_DYNAMIC_RANGE = 24;
return HybridBinarizer;
}(GlobalHistogramBinarizer_1.default));
exports.default = HybridBinarizer;
//# sourceMappingURL=HybridBinarizer.js.map

@@ -26,4 +26,4 @@ "use strict";

*/
class PerspectiveTransform {
constructor(a11 /*float*/, a21 /*float*/, a31 /*float*/, a12 /*float*/, a22 /*float*/, a32 /*float*/, a13 /*float*/, a23 /*float*/, a33 /*float*/) {
var PerspectiveTransform = /** @class */ (function () {
function PerspectiveTransform(a11 /*float*/, a21 /*float*/, a31 /*float*/, a12 /*float*/, a22 /*float*/, a32 /*float*/, a13 /*float*/, a23 /*float*/, a33 /*float*/) {
this.a11 = a11; /*float*/

@@ -39,48 +39,48 @@ this.a21 = a21; /*float*/

}
static quadrilateralToQuadrilateral(x0 /*float*/, y0 /*float*/, x1 /*float*/, y1 /*float*/, x2 /*float*/, y2 /*float*/, x3 /*float*/, y3 /*float*/, x0p /*float*/, y0p /*float*/, x1p /*float*/, y1p /*float*/, x2p /*float*/, y2p /*float*/, x3p /*float*/, y3p /*float*/) {
const qToS = PerspectiveTransform.quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3);
const sToQ = PerspectiveTransform.squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p);
PerspectiveTransform.quadrilateralToQuadrilateral = function (x0 /*float*/, y0 /*float*/, x1 /*float*/, y1 /*float*/, x2 /*float*/, y2 /*float*/, x3 /*float*/, y3 /*float*/, x0p /*float*/, y0p /*float*/, x1p /*float*/, y1p /*float*/, x2p /*float*/, y2p /*float*/, x3p /*float*/, y3p /*float*/) {
var qToS = PerspectiveTransform.quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3);
var sToQ = PerspectiveTransform.squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p);
return sToQ.times(qToS);
}
transformPoints(points) {
const max = points.length;
const a11 = this.a11;
const a12 = this.a12;
const a13 = this.a13;
const a21 = this.a21;
const a22 = this.a22;
const a23 = this.a23;
const a31 = this.a31;
const a32 = this.a32;
const a33 = this.a33;
for (let i = 0; i < max; i += 2) {
const x = points[i];
const y = points[i + 1];
const denominator = a13 * x + a23 * y + a33;
};
PerspectiveTransform.prototype.transformPoints = function (points) {
var max = points.length;
var a11 = this.a11;
var a12 = this.a12;
var a13 = this.a13;
var a21 = this.a21;
var a22 = this.a22;
var a23 = this.a23;
var a31 = this.a31;
var a32 = this.a32;
var a33 = this.a33;
for (var i = 0; i < max; i += 2) {
var x = points[i];
var y = points[i + 1];
var denominator = a13 * x + a23 * y + a33;
points[i] = (a11 * x + a21 * y + a31) / denominator;
points[i + 1] = (a12 * x + a22 * y + a32) / denominator;
}
}
transformPointsWithValues(xValues, yValues) {
const a11 = this.a11;
const a12 = this.a12;
const a13 = this.a13;
const a21 = this.a21;
const a22 = this.a22;
const a23 = this.a23;
const a31 = this.a31;
const a32 = this.a32;
const a33 = this.a33;
const n = xValues.length;
for (let i = 0; i < n; i++) {
const x = xValues[i];
const y = yValues[i];
const denominator = a13 * x + a23 * y + a33;
};
PerspectiveTransform.prototype.transformPointsWithValues = function (xValues, yValues) {
var a11 = this.a11;
var a12 = this.a12;
var a13 = this.a13;
var a21 = this.a21;
var a22 = this.a22;
var a23 = this.a23;
var a31 = this.a31;
var a32 = this.a32;
var a33 = this.a33;
var n = xValues.length;
for (var i = 0; i < n; i++) {
var x = xValues[i];
var y = yValues[i];
var denominator = a13 * x + a23 * y + a33;
xValues[i] = (a11 * x + a21 * y + a31) / denominator;
yValues[i] = (a12 * x + a22 * y + a32) / denominator;
}
}
static squareToQuadrilateral(x0 /*float*/, y0 /*float*/, x1 /*float*/, y1 /*float*/, x2 /*float*/, y2 /*float*/, x3 /*float*/, y3 /*float*/) {
const dx3 = x0 - x1 + x2 - x3;
const dy3 = y0 - y1 + y2 - y3;
};
PerspectiveTransform.squareToQuadrilateral = function (x0 /*float*/, y0 /*float*/, x1 /*float*/, y1 /*float*/, x2 /*float*/, y2 /*float*/, x3 /*float*/, y3 /*float*/) {
var dx3 = x0 - x1 + x2 - x3;
var dy3 = y0 - y1 + y2 - y3;
if (dx3 === 0.0 && dy3 === 0.0) {

@@ -91,25 +91,26 @@ // Affine

else {
const dx1 = x1 - x2;
const dx2 = x3 - x2;
const dy1 = y1 - y2;
const dy2 = y3 - y2;
const denominator = dx1 * dy2 - dx2 * dy1;
const a13 = (dx3 * dy2 - dx2 * dy3) / denominator;
const a23 = (dx1 * dy3 - dx3 * dy1) / denominator;
var dx1 = x1 - x2;
var dx2 = x3 - x2;
var dy1 = y1 - y2;
var dy2 = y3 - y2;
var denominator = dx1 * dy2 - dx2 * dy1;
var a13 = (dx3 * dy2 - dx2 * dy3) / denominator;
var a23 = (dx1 * dy3 - dx3 * dy1) / denominator;
return new PerspectiveTransform(x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, y1 - y0 + a13 * y1, y3 - y0 + a23 * y3, y0, a13, a23, 1.0);
}
}
static quadrilateralToSquare(x0 /*float*/, y0 /*float*/, x1 /*float*/, y1 /*float*/, x2 /*float*/, y2 /*float*/, x3 /*float*/, y3 /*float*/) {
};
PerspectiveTransform.quadrilateralToSquare = function (x0 /*float*/, y0 /*float*/, x1 /*float*/, y1 /*float*/, x2 /*float*/, y2 /*float*/, x3 /*float*/, y3 /*float*/) {
// Here, the adjoint serves as the inverse:
return PerspectiveTransform.squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3).buildAdjoint();
}
buildAdjoint() {
};
PerspectiveTransform.prototype.buildAdjoint = function () {
// Adjoint is the transpose of the cofactor matrix:
return new PerspectiveTransform(this.a22 * this.a33 - this.a23 * this.a32, this.a23 * this.a31 - this.a21 * this.a33, this.a21 * this.a32 - this.a22 * this.a31, this.a13 * this.a32 - this.a12 * this.a33, this.a11 * this.a33 - this.a13 * this.a31, this.a12 * this.a31 - this.a11 * this.a32, this.a12 * this.a23 - this.a13 * this.a22, this.a13 * this.a21 - this.a11 * this.a23, this.a11 * this.a22 - this.a12 * this.a21);
}
times(other) {
};
PerspectiveTransform.prototype.times = function (other) {
return new PerspectiveTransform(this.a11 * other.a11 + this.a21 * other.a12 + this.a31 * other.a13, this.a11 * other.a21 + this.a21 * other.a22 + this.a31 * other.a23, this.a11 * other.a31 + this.a21 * other.a32 + this.a31 * other.a33, this.a12 * other.a11 + this.a22 * other.a12 + this.a32 * other.a13, this.a12 * other.a21 + this.a22 * other.a22 + this.a32 * other.a23, this.a12 * other.a31 + this.a22 * other.a32 + this.a32 * other.a33, this.a13 * other.a11 + this.a23 * other.a12 + this.a33 * other.a13, this.a13 * other.a21 + this.a23 * other.a22 + this.a33 * other.a23, this.a13 * other.a31 + this.a23 * other.a32 + this.a33 * other.a33);
}
}
};
return PerspectiveTransform;
}());
exports.default = PerspectiveTransform;
//# sourceMappingURL=PerspectiveTransform.js.map

@@ -19,5 +19,5 @@ "use strict";

/*namespace com.google.zxing.common.reedsolomon {*/
const GenericGFPoly_1 = require("./GenericGFPoly");
const Exception_1 = require("./../../Exception");
const Integer_1 = require("./../../util/Integer");
var GenericGFPoly_1 = require("./GenericGFPoly");
var Exception_1 = require("./../../Exception");
var Integer_1 = require("./../../util/Integer");
/**

@@ -34,3 +34,3 @@ * <p>This class contains utility methods for performing mathematical operations over

*/
class GenericGF {
var GenericGF = /** @class */ (function () {
/**

@@ -47,9 +47,9 @@ * Create a representation of GF(size) using the given primitive polynomial.

*/
constructor(primitive /*int*/, size /*int*/, generatorBase /*int*/) {
function GenericGF(primitive /*int*/, size /*int*/, generatorBase /*int*/) {
this.primitive = primitive; /*int*/
this.size = size; /*int*/
this.generatorBase = generatorBase; /*int*/
const expTable = new Int32Array(size);
let x = 1;
for (let i = 0; i < size; i++) {
var expTable = new Int32Array(size);
var x = 1;
for (var i = 0; i < size; i++) {
expTable[i] = x;

@@ -63,4 +63,4 @@ x *= 2; // we're assuming the generator alpha is 2

this.expTable = expTable;
const logTable = new Int32Array(size);
for (let i = 0; i < size - 1; i++) {
var logTable = new Int32Array(size);
for (var i = 0; i < size - 1; i++) {
logTable[expTable[i]] = i;

@@ -73,12 +73,12 @@ }

}
getZero() {
GenericGF.prototype.getZero = function () {
return this.zero;
}
getOne() {
};
GenericGF.prototype.getOne = function () {
return this.one;
}
};
/**
* @return the monomial representing coefficient * x^degree
*/
buildMonomial(degree /*int*/, coefficient /*int*/) {
GenericGF.prototype.buildMonomial = function (degree /*int*/, coefficient /*int*/) {
if (degree < 0) {

@@ -90,6 +90,6 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException);

}
const coefficients = new Int32Array(degree + 1);
var coefficients = new Int32Array(degree + 1);
coefficients[0] = coefficient;
return new GenericGFPoly_1.default(this, coefficients);
}
};
/**

@@ -100,15 +100,15 @@ * Implements both addition and subtraction -- they are the same in GF(size).

*/
static addOrSubtract(a /*int*/, b /*int*/) {
GenericGF.addOrSubtract = function (a /*int*/, b /*int*/) {
return a ^ b;
}
};
/**
* @return 2 to the power of a in GF(size)
*/
exp(a /*int*/) {
GenericGF.prototype.exp = function (a /*int*/) {
return this.expTable[a];
}
};
/**
* @return base 2 log of a in GF(size)
*/
log(a /*int*/) {
GenericGF.prototype.log = function (a /*int*/) {
if (a === 0) {

@@ -118,7 +118,7 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException);

return this.logTable[a];
}
};
/**
* @return multiplicative inverse of a
*/
inverse(a /*int*/) {
GenericGF.prototype.inverse = function (a /*int*/) {
if (a === 0) {

@@ -128,7 +128,7 @@ throw new Exception_1.default(Exception_1.default.ArithmeticException);

return this.expTable[this.size - this.logTable[a] - 1];
}
};
/**
* @return product of a and b in GF(size)
*/
multiply(a /*int*/, b /*int*/) {
GenericGF.prototype.multiply = function (a /*int*/, b /*int*/) {
if (a === 0 || b === 0) {

@@ -138,26 +138,27 @@ return 0;

return this.expTable[(this.logTable[a] + this.logTable[b]) % (this.size - 1)];
}
getSize() {
};
GenericGF.prototype.getSize = function () {
return this.size;
}
getGeneratorBase() {
};
GenericGF.prototype.getGeneratorBase = function () {
return this.generatorBase;
}
};
/*@Override*/
toString() {
GenericGF.prototype.toString = function () {
return 'GF(0x' + Integer_1.default.toHexString(this.primitive) + ',' + this.size + ')';
}
equals(o) {
};
GenericGF.prototype.equals = function (o) {
return o === this;
}
}
GenericGF.AZTEC_DATA_12 = new GenericGF(0x1069, 4096, 1); // x^12 + x^6 + x^5 + x^3 + 1
GenericGF.AZTEC_DATA_10 = new GenericGF(0x409, 1024, 1); // x^10 + x^3 + 1
GenericGF.AZTEC_DATA_6 = new GenericGF(0x43, 64, 1); // x^6 + x + 1
GenericGF.AZTEC_PARAM = new GenericGF(0x13, 16, 1); // x^4 + x + 1
GenericGF.QR_CODE_FIELD_256 = new GenericGF(0x011D, 256, 0); // x^8 + x^4 + x^3 + x^2 + 1
GenericGF.DATA_MATRIX_FIELD_256 = new GenericGF(0x012D, 256, 1); // x^8 + x^5 + x^3 + x^2 + 1
GenericGF.AZTEC_DATA_8 = GenericGF.DATA_MATRIX_FIELD_256;
GenericGF.MAXICODE_FIELD_64 = GenericGF.AZTEC_DATA_6;
};
GenericGF.AZTEC_DATA_12 = new GenericGF(0x1069, 4096, 1); // x^12 + x^6 + x^5 + x^3 + 1
GenericGF.AZTEC_DATA_10 = new GenericGF(0x409, 1024, 1); // x^10 + x^3 + 1
GenericGF.AZTEC_DATA_6 = new GenericGF(0x43, 64, 1); // x^6 + x + 1
GenericGF.AZTEC_PARAM = new GenericGF(0x13, 16, 1); // x^4 + x + 1
GenericGF.QR_CODE_FIELD_256 = new GenericGF(0x011D, 256, 0); // x^8 + x^4 + x^3 + x^2 + 1
GenericGF.DATA_MATRIX_FIELD_256 = new GenericGF(0x012D, 256, 1); // x^8 + x^5 + x^3 + x^2 + 1
GenericGF.AZTEC_DATA_8 = GenericGF.DATA_MATRIX_FIELD_256;
GenericGF.MAXICODE_FIELD_64 = GenericGF.AZTEC_DATA_6;
return GenericGF;
}());
exports.default = GenericGF;
//# sourceMappingURL=GenericGF.js.map

@@ -19,5 +19,5 @@ "use strict";

/*namespace com.google.zxing.common.reedsolomon {*/
const GenericGF_1 = require("./GenericGF");
const Exception_1 = require("./../../Exception");
const System_1 = require("./../../util/System");
var GenericGF_1 = require("./GenericGF");
var Exception_1 = require("./../../Exception");
var System_1 = require("./../../util/System");
/**

@@ -32,3 +32,3 @@ * <p>Represents a polynomial whose coefficients are elements of a GF.

*/
class GenericGFPoly {
var GenericGFPoly = /** @class */ (function () {
/**

@@ -43,3 +43,3 @@ * @param field the {@link GenericGF} instance representing the field to use

*/
constructor(field, coefficients) {
function GenericGFPoly(field, coefficients) {
if (coefficients.length === 0) {

@@ -49,6 +49,6 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException);

this.field = field;
const coefficientsLength = coefficients.length;
var coefficientsLength = coefficients.length;
if (coefficientsLength > 1 && coefficients[0] === 0) {
// Leading term must be non-zero for anything except the constant polynomial "0"
let firstNonZero = 1;
var firstNonZero = 1;
while (firstNonZero < coefficientsLength && coefficients[firstNonZero] === 0) {

@@ -69,27 +69,27 @@ firstNonZero++;

}
getCoefficients() {
GenericGFPoly.prototype.getCoefficients = function () {
return this.coefficients;
}
};
/**
* @return degree of this polynomial
*/
getDegree() {
GenericGFPoly.prototype.getDegree = function () {
return this.coefficients.length - 1;
}
};
/**
* @return true iff this polynomial is the monomial "0"
*/
isZero() {
GenericGFPoly.prototype.isZero = function () {
return this.coefficients[0] === 0;
}
};
/**
* @return coefficient of x^degree term in this polynomial
*/
getCoefficient(degree /*int*/) {
GenericGFPoly.prototype.getCoefficient = function (degree /*int*/) {
return this.coefficients[this.coefficients.length - 1 - degree];
}
};
/**
* @return evaluation of this polynomial at a given point
*/
evaluateAt(a /*int*/) {
GenericGFPoly.prototype.evaluateAt = function (a /*int*/) {
if (a === 0) {

@@ -99,9 +99,9 @@ // Just return the x^0 coefficient

}
const coefficients = this.coefficients;
let result;
var coefficients = this.coefficients;
var result;
if (a === 1) {
// Just the sum of the coefficients
result = 0;
for (let i = 0, length = coefficients.length; i !== length; i++) {
const coefficient = coefficients[i];
for (var i = 0, length_1 = coefficients.length; i !== length_1; i++) {
var coefficient = coefficients[i];
result = GenericGF_1.default.addOrSubtract(result, coefficient);

@@ -112,10 +112,10 @@ }

result = coefficients[0];
const size = coefficients.length;
const field = this.field;
for (let i = 1; i < size; i++) {
var size = coefficients.length;
var field = this.field;
for (var i = 1; i < size; i++) {
result = GenericGF_1.default.addOrSubtract(field.multiply(a, result), coefficients[i]);
}
return result;
}
addOrSubtract(other) {
};
GenericGFPoly.prototype.addOrSubtract = function (other) {
if (!this.field.equals(other.field)) {

@@ -130,19 +130,19 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'GenericGFPolys do not have same GenericGF field');

}
let smallerCoefficients = this.coefficients;
let largerCoefficients = other.coefficients;
var smallerCoefficients = this.coefficients;
var largerCoefficients = other.coefficients;
if (smallerCoefficients.length > largerCoefficients.length) {
const temp = smallerCoefficients;
var temp = smallerCoefficients;
smallerCoefficients = largerCoefficients;
largerCoefficients = temp;
}
let sumDiff = new Int32Array(largerCoefficients.length);
const lengthDiff = largerCoefficients.length - smallerCoefficients.length;
var sumDiff = new Int32Array(largerCoefficients.length);
var lengthDiff = largerCoefficients.length - smallerCoefficients.length;
// Copy high-order terms only found in higher-degree polynomial's coefficients
System_1.default.arraycopy(largerCoefficients, 0, sumDiff, 0, lengthDiff);
for (let i = lengthDiff; i < largerCoefficients.length; i++) {
for (var i = lengthDiff; i < largerCoefficients.length; i++) {
sumDiff[i] = GenericGF_1.default.addOrSubtract(smallerCoefficients[i - lengthDiff], largerCoefficients[i]);
}
return new GenericGFPoly(this.field, sumDiff);
}
multiply(other) {
};
GenericGFPoly.prototype.multiply = function (other) {
if (!this.field.equals(other.field)) {

@@ -154,11 +154,11 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'GenericGFPolys do not have same GenericGF field');

}
const aCoefficients = this.coefficients;
const aLength = aCoefficients.length;
const bCoefficients = other.coefficients;
const bLength = bCoefficients.length;
const product = new Int32Array(aLength + bLength - 1);
const field = this.field;
for (let i = 0; i < aLength; i++) {
const aCoeff = aCoefficients[i];
for (let j = 0; j < bLength; j++) {
var aCoefficients = this.coefficients;
var aLength = aCoefficients.length;
var bCoefficients = other.coefficients;
var bLength = bCoefficients.length;
var product = new Int32Array(aLength + bLength - 1);
var field = this.field;
for (var i = 0; i < aLength; i++) {
var aCoeff = aCoefficients[i];
for (var j = 0; j < bLength; j++) {
product[i + j] = GenericGF_1.default.addOrSubtract(product[i + j], field.multiply(aCoeff, bCoefficients[j]));

@@ -168,4 +168,4 @@ }

return new GenericGFPoly(field, product);
}
multiplyScalar(scalar /*int*/) {
};
GenericGFPoly.prototype.multiplyScalar = function (scalar /*int*/) {
if (scalar === 0) {

@@ -177,12 +177,12 @@ return this.field.getZero();

}
const size = this.coefficients.length;
const field = this.field;
const product = new Int32Array(size);
const coefficients = this.coefficients;
for (let i = 0; i < size; i++) {
var size = this.coefficients.length;
var field = this.field;
var product = new Int32Array(size);
var coefficients = this.coefficients;
for (var i = 0; i < size; i++) {
product[i] = field.multiply(coefficients[i], scalar);
}
return new GenericGFPoly(field, product);
}
multiplyByMonomial(degree /*int*/, coefficient /*int*/) {
};
GenericGFPoly.prototype.multiplyByMonomial = function (degree /*int*/, coefficient /*int*/) {
if (degree < 0) {

@@ -194,12 +194,12 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException);

}
const coefficients = this.coefficients;
const size = coefficients.length;
const product = new Int32Array(size + degree);
const field = this.field;
for (let i = 0; i < size; i++) {
var coefficients = this.coefficients;
var size = coefficients.length;
var product = new Int32Array(size + degree);
var field = this.field;
for (var i = 0; i < size; i++) {
product[i] = field.multiply(coefficients[i], coefficient);
}
return new GenericGFPoly(field, product);
}
divide(other) {
};
GenericGFPoly.prototype.divide = function (other) {
if (!this.field.equals(other.field)) {

@@ -211,12 +211,12 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'GenericGFPolys do not have same GenericGF field');

}
const field = this.field;
let quotient = field.getZero();
let remainder = this;
const denominatorLeadingTerm = other.getCoefficient(other.getDegree());
const inverseDenominatorLeadingTerm = field.inverse(denominatorLeadingTerm);
var field = this.field;
var quotient = field.getZero();
var remainder = this;
var denominatorLeadingTerm = other.getCoefficient(other.getDegree());
var inverseDenominatorLeadingTerm = field.inverse(denominatorLeadingTerm);
while (remainder.getDegree() >= other.getDegree() && !remainder.isZero()) {
const degreeDifference = remainder.getDegree() - other.getDegree();
const scale = field.multiply(remainder.getCoefficient(remainder.getDegree()), inverseDenominatorLeadingTerm);
const term = other.multiplyByMonomial(degreeDifference, scale);
const iterationQuotient = field.buildMonomial(degreeDifference, scale);
var degreeDifference = remainder.getDegree() - other.getDegree();
var scale = field.multiply(remainder.getCoefficient(remainder.getDegree()), inverseDenominatorLeadingTerm);
var term = other.multiplyByMonomial(degreeDifference, scale);
var iterationQuotient = field.buildMonomial(degreeDifference, scale);
quotient = quotient.addOrSubtract(iterationQuotient);

@@ -226,8 +226,8 @@ remainder = remainder.addOrSubtract(term);

return [quotient, remainder];
}
};
/*@Override*/
toString() {
let result = '';
for (let degree = this.getDegree(); degree >= 0; degree--) {
let coefficient = this.getCoefficient(degree);
GenericGFPoly.prototype.toString = function () {
var result = '';
for (var degree = this.getDegree(); degree >= 0; degree--) {
var coefficient = this.getCoefficient(degree);
if (coefficient !== 0) {

@@ -244,3 +244,3 @@ if (coefficient < 0) {

if (degree === 0 || coefficient !== 1) {
const alphaPower = this.field.log(coefficient);
var alphaPower = this.field.log(coefficient);
if (alphaPower === 0) {

@@ -269,5 +269,6 @@ result += '1';

return result;
}
}
};
return GenericGFPoly;
}());
exports.default = GenericGFPoly;
//# sourceMappingURL=GenericGFPoly.js.map

@@ -19,5 +19,5 @@ "use strict";

/*namespace com.google.zxing.common.reedsolomon {*/
const GenericGF_1 = require("./GenericGF");
const GenericGFPoly_1 = require("./GenericGFPoly");
const Exception_1 = require("./../../Exception");
var GenericGF_1 = require("./GenericGF");
var GenericGFPoly_1 = require("./GenericGFPoly");
var Exception_1 = require("./../../Exception");
/**

@@ -45,4 +45,4 @@ * <p>Implements Reed-Solomon decoding, as the name implies.</p>

*/
class ReedSolomonDecoder {
constructor(field) {
var ReedSolomonDecoder = /** @class */ (function () {
function ReedSolomonDecoder(field) {
this.field = field;

@@ -59,9 +59,9 @@ }

*/
decode(received, twoS /*int*/) {
const field = this.field;
const poly = new GenericGFPoly_1.default(field, received);
const syndromeCoefficients = new Int32Array(twoS);
let noError = true;
for (let i = 0; i < twoS; i++) {
const evalResult = poly.evaluateAt(field.exp(i + field.getGeneratorBase()));
ReedSolomonDecoder.prototype.decode = function (received, twoS /*int*/) {
var field = this.field;
var poly = new GenericGFPoly_1.default(field, received);
var syndromeCoefficients = new Int32Array(twoS);
var noError = true;
for (var i = 0; i < twoS; i++) {
var evalResult = poly.evaluateAt(field.exp(i + field.getGeneratorBase()));
syndromeCoefficients[syndromeCoefficients.length - 1 - i] = evalResult;

@@ -75,10 +75,10 @@ if (evalResult !== 0) {

}
const syndrome = new GenericGFPoly_1.default(field, syndromeCoefficients);
const sigmaOmega = this.runEuclideanAlgorithm(field.buildMonomial(twoS, 1), syndrome, twoS);
const sigma = sigmaOmega[0];
const omega = sigmaOmega[1];
const errorLocations = this.findErrorLocations(sigma);
const errorMagnitudes = this.findErrorMagnitudes(omega, errorLocations);
for (let i = 0; i < errorLocations.length; i++) {
const position = received.length - 1 - field.log(errorLocations[i]);
var syndrome = new GenericGFPoly_1.default(field, syndromeCoefficients);
var sigmaOmega = this.runEuclideanAlgorithm(field.buildMonomial(twoS, 1), syndrome, twoS);
var sigma = sigmaOmega[0];
var omega = sigmaOmega[1];
var errorLocations = this.findErrorLocations(sigma);
var errorMagnitudes = this.findErrorMagnitudes(omega, errorLocations);
for (var i = 0; i < errorLocations.length; i++) {
var position = received.length - 1 - field.log(errorLocations[i]);
if (position < 0) {

@@ -89,19 +89,19 @@ throw new Exception_1.default(Exception_1.default.ReedSolomonException, 'Bad error location');

}
}
runEuclideanAlgorithm(a, b, R /*int*/) {
};
ReedSolomonDecoder.prototype.runEuclideanAlgorithm = function (a, b, R /*int*/) {
// Assume a's degree is >= b's
if (a.getDegree() < b.getDegree()) {
const temp = a;
var temp = a;
a = b;
b = temp;
}
const field = this.field;
let rLast = a;
let r = b;
let tLast = field.getZero();
let t = field.getOne();
var field = this.field;
var rLast = a;
var r = b;
var tLast = field.getZero();
var t = field.getOne();
// Run Euclidean algorithm until r's degree is less than R/2
while (r.getDegree() >= R / 2) {
let rLastLast = rLast;
let tLastLast = tLast;
var rLastLast = rLast;
var tLastLast = tLast;
rLast = r;

@@ -115,8 +115,8 @@ tLast = t;

r = rLastLast;
let q = field.getZero();
const denominatorLeadingTerm = rLast.getCoefficient(rLast.getDegree());
const dltInverse = field.inverse(denominatorLeadingTerm);
var q = field.getZero();
var denominatorLeadingTerm = rLast.getCoefficient(rLast.getDegree());
var dltInverse = field.inverse(denominatorLeadingTerm);
while (r.getDegree() >= rLast.getDegree() && !r.isZero()) {
const degreeDiff = r.getDegree() - rLast.getDegree();
const scale = field.multiply(r.getCoefficient(r.getDegree()), dltInverse);
var degreeDiff = r.getDegree() - rLast.getDegree();
var scale = field.multiply(r.getCoefficient(r.getDegree()), dltInverse);
q = q.addOrSubtract(field.buildMonomial(degreeDiff, scale));

@@ -130,21 +130,21 @@ r = r.addOrSubtract(rLast.multiplyByMonomial(degreeDiff, scale));

}
const sigmaTildeAtZero = t.getCoefficient(0);
var sigmaTildeAtZero = t.getCoefficient(0);
if (sigmaTildeAtZero === 0) {
throw new Exception_1.default(Exception_1.default.ReedSolomonException, 'sigmaTilde(0) was zero');
}
const inverse = field.inverse(sigmaTildeAtZero);
const sigma = t.multiplyScalar(inverse);
const omega = r.multiplyScalar(inverse);
var inverse = field.inverse(sigmaTildeAtZero);
var sigma = t.multiplyScalar(inverse);
var omega = r.multiplyScalar(inverse);
return [sigma, omega];
}
findErrorLocations(errorLocator) {
};
ReedSolomonDecoder.prototype.findErrorLocations = function (errorLocator) {
// This is a direct application of Chien's search
const numErrors = errorLocator.getDegree();
var numErrors = errorLocator.getDegree();
if (numErrors === 1) {
return Int32Array.from([errorLocator.getCoefficient(1)]);
}
const result = new Int32Array(numErrors);
let e = 0;
const field = this.field;
for (let i = 1; i < field.getSize() && e < numErrors; i++) {
var result = new Int32Array(numErrors);
var e = 0;
var field = this.field;
for (var i = 1; i < field.getSize() && e < numErrors; i++) {
if (errorLocator.evaluateAt(i) === 0) {

@@ -159,12 +159,12 @@ result[e] = field.inverse(i);

return result;
}
findErrorMagnitudes(errorEvaluator, errorLocations) {
};
ReedSolomonDecoder.prototype.findErrorMagnitudes = function (errorEvaluator, errorLocations) {
// This is directly applying Forney's Formula
const s = errorLocations.length;
const result = new Int32Array(s);
const field = this.field;
for (let i = 0; i < s; i++) {
const xiInverse = field.inverse(errorLocations[i]);
let denominator = 1;
for (let j = 0; j < s; j++) {
var s = errorLocations.length;
var result = new Int32Array(s);
var field = this.field;
for (var i = 0; i < s; i++) {
var xiInverse = field.inverse(errorLocations[i]);
var denominator = 1;
for (var j = 0; j < s; j++) {
if (i !== j) {

@@ -175,4 +175,4 @@ // denominator = field.multiply(denominator,

// Below is a funny-looking workaround from Steven Parkes
const term = field.multiply(errorLocations[j], xiInverse);
const termPlus1 = (term & 0x1) === 0 ? term | 1 : term & ~1;
var term = field.multiply(errorLocations[j], xiInverse);
var termPlus1 = (term & 0x1) === 0 ? term | 1 : term & ~1;
denominator = field.multiply(denominator, termPlus1);

@@ -187,5 +187,6 @@ }

return result;
}
}
};
return ReedSolomonDecoder;
}());
exports.default = ReedSolomonDecoder;
//# sourceMappingURL=ReedSolomonDecoder.js.map

@@ -18,5 +18,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const GenericGFPoly_1 = require("./GenericGFPoly");
const Exception_1 = require("./../../Exception");
const System_1 = require("./../../util/System");
var GenericGFPoly_1 = require("./GenericGFPoly");
var Exception_1 = require("./../../Exception");
var System_1 = require("./../../util/System");
/**

@@ -28,4 +28,4 @@ * <p>Implements Reed-Solomon encoding, as the name implies.</p>

*/
class ReedSolomonEncoder {
constructor(field) {
var ReedSolomonEncoder = /** @class */ (function () {
function ReedSolomonEncoder(field) {
this.field = field;

@@ -35,9 +35,9 @@ this.cachedGenerators = [];

}
buildGenerator(degree /*int*/) {
const cachedGenerators = this.cachedGenerators;
ReedSolomonEncoder.prototype.buildGenerator = function (degree /*int*/) {
var cachedGenerators = this.cachedGenerators;
if (degree >= cachedGenerators.length) {
let lastGenerator = cachedGenerators[cachedGenerators.length - 1];
const field = this.field;
for (let d = cachedGenerators.length; d <= degree; d++) {
const nextGenerator = lastGenerator.multiply(new GenericGFPoly_1.default(field, Int32Array.from([1, field.exp(d - 1 + field.getGeneratorBase())])));
var lastGenerator = cachedGenerators[cachedGenerators.length - 1];
var field = this.field;
for (var d = cachedGenerators.length; d <= degree; d++) {
var nextGenerator = lastGenerator.multiply(new GenericGFPoly_1.default(field, Int32Array.from([1, field.exp(d - 1 + field.getGeneratorBase())])));
cachedGenerators.push(nextGenerator);

@@ -48,26 +48,27 @@ lastGenerator = nextGenerator;

return cachedGenerators[degree];
}
encode(toEncode, ecBytes /*int*/) {
};
ReedSolomonEncoder.prototype.encode = function (toEncode, ecBytes /*int*/) {
if (ecBytes === 0) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'No error correction bytes');
}
const dataBytes = toEncode.length - ecBytes;
var dataBytes = toEncode.length - ecBytes;
if (dataBytes <= 0) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'No data bytes provided');
}
const generator = this.buildGenerator(ecBytes);
const infoCoefficients = new Int32Array(dataBytes);
var generator = this.buildGenerator(ecBytes);
var infoCoefficients = new Int32Array(dataBytes);
System_1.default.arraycopy(toEncode, 0, infoCoefficients, 0, dataBytes);
let info = new GenericGFPoly_1.default(this.field, infoCoefficients);
var info = new GenericGFPoly_1.default(this.field, infoCoefficients);
info = info.multiplyByMonomial(ecBytes, 1);
const remainder = info.divide(generator)[1];
const coefficients = remainder.getCoefficients();
const numZeroCoefficients = ecBytes - coefficients.length;
for (let i = 0; i < numZeroCoefficients; i++) {
var remainder = info.divide(generator)[1];
var coefficients = remainder.getCoefficients();
var numZeroCoefficients = ecBytes - coefficients.length;
for (var i = 0; i < numZeroCoefficients; i++) {
toEncode[dataBytes + i] = 0;
}
System_1.default.arraycopy(coefficients, 0, toEncode, dataBytes + numZeroCoefficients, coefficients.length);
}
}
};
return ReedSolomonEncoder;
}());
exports.default = ReedSolomonEncoder;
//# sourceMappingURL=ReedSolomonEncoder.js.map

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const CharacterSetECI_1 = require("./CharacterSetECI");
var CharacterSetECI_1 = require("./CharacterSetECI");
/**

@@ -26,6 +26,8 @@ * Common string-related functions.

*/
class StringUtils {
var StringUtils = /** @class */ (function () {
function StringUtils() {
}
// SHIFT_JIS.equalsIgnoreCase(PLATFORM_DEFAULT_ENCODING) ||
// EUC_JP.equalsIgnoreCase(PLATFORM_DEFAULT_ENCODING);
StringUtils() { }
StringUtils.prototype.StringUtils = function () { };
/**

@@ -38,3 +40,3 @@ * @param bytes bytes encoding a string, whose encoding should be guessed

*/
static guessEncoding(bytes, hints) {
StringUtils.guessEncoding = function (bytes, hints) {
if (hints !== null && hints !== undefined && undefined !== hints.get(4 /* CHARACTER_SET */)) {

@@ -45,28 +47,28 @@ return hints.get(4 /* CHARACTER_SET */).toString();

// which should be by far the most common encodings.
const length = bytes.length;
let canBeISO88591 = true;
let canBeShiftJIS = true;
let canBeUTF8 = true;
let utf8BytesLeft = 0;
var length = bytes.length;
var canBeISO88591 = true;
var canBeShiftJIS = true;
var canBeUTF8 = true;
var utf8BytesLeft = 0;
// int utf8LowChars = 0
let utf2BytesChars = 0;
let utf3BytesChars = 0;
let utf4BytesChars = 0;
let sjisBytesLeft = 0;
var utf2BytesChars = 0;
var utf3BytesChars = 0;
var utf4BytesChars = 0;
var sjisBytesLeft = 0;
// int sjisLowChars = 0
let sjisKatakanaChars = 0;
var sjisKatakanaChars = 0;
// int sjisDoubleBytesChars = 0
let sjisCurKatakanaWordLength = 0;
let sjisCurDoubleBytesWordLength = 0;
let sjisMaxKatakanaWordLength = 0;
let sjisMaxDoubleBytesWordLength = 0;
var sjisCurKatakanaWordLength = 0;
var sjisCurDoubleBytesWordLength = 0;
var sjisMaxKatakanaWordLength = 0;
var sjisMaxDoubleBytesWordLength = 0;
// int isoLowChars = 0
// int isoHighChars = 0
let isoHighOther = 0;
const utf8bom = bytes.length > 3 &&
var isoHighOther = 0;
var utf8bom = bytes.length > 3 &&
bytes[0] === /*(byte) */ 0xEF &&
bytes[1] === /*(byte) */ 0xBB &&
bytes[2] === /*(byte) */ 0xBF;
for (let i = 0; i < length && (canBeISO88591 || canBeShiftJIS || canBeUTF8); i++) {
const value = bytes[i] & 0xFF;
for (var i = 0; i < length && (canBeISO88591 || canBeShiftJIS || canBeUTF8); i++) {
var value = bytes[i] & 0xFF;
// UTF-8 stuff

@@ -198,12 +200,13 @@ if (canBeUTF8) {

return StringUtils.PLATFORM_DEFAULT_ENCODING;
}
}
StringUtils.SHIFT_JIS = CharacterSetECI_1.default.SJIS.getName(); // "SJIS"
StringUtils.GB2312 = 'GB2312';
StringUtils.EUC_JP = 'EUC_JP';
StringUtils.UTF8 = CharacterSetECI_1.default.UTF8.getName(); // "UTF8"
StringUtils.PLATFORM_DEFAULT_ENCODING = StringUtils.UTF8; // "UTF8"//Charset.defaultCharset().name()
StringUtils.ISO88591 = CharacterSetECI_1.default.ISO8859_1.getName(); // "ISO8859_1"
StringUtils.ASSUME_SHIFT_JIS = false;
};
StringUtils.SHIFT_JIS = CharacterSetECI_1.default.SJIS.getName(); // "SJIS"
StringUtils.GB2312 = 'GB2312';
StringUtils.EUC_JP = 'EUC_JP';
StringUtils.UTF8 = CharacterSetECI_1.default.UTF8.getName(); // "UTF8"
StringUtils.PLATFORM_DEFAULT_ENCODING = StringUtils.UTF8; // "UTF8"//Charset.defaultCharset().name()
StringUtils.ISO88591 = CharacterSetECI_1.default.ISO8859_1.getName(); // "ISO8859_1"
StringUtils.ASSUME_SHIFT_JIS = false;
return StringUtils;
}());
exports.default = StringUtils;
//# sourceMappingURL=StringUtils.js.map

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const Exception_1 = require("./Exception");
var Exception_1 = require("./Exception");
/*namespace com.google.zxing {*/

@@ -24,4 +24,4 @@ /**

*/
class Dimension {
constructor(width /*int*/, height /*int*/) {
var Dimension = /** @class */ (function () {
function Dimension(width /*int*/, height /*int*/) {
this.width = width; /*int*/

@@ -33,26 +33,27 @@ this.height = height; /*int*/

}
getWidth() {
Dimension.prototype.getWidth = function () {
return this.width;
}
getHeight() {
};
Dimension.prototype.getHeight = function () {
return this.height;
}
};
/*@Override*/
equals(other) {
Dimension.prototype.equals = function (other) {
if (other instanceof Dimension) {
const d = other;
var d = other;
return this.width === d.width && this.height === d.height;
}
return false;
}
};
/*@Override*/
hashCode() {
Dimension.prototype.hashCode = function () {
return this.width * 32713 + this.height;
}
};
/*@Override*/
toString() {
Dimension.prototype.toString = function () {
return this.width + 'x' + this.height;
}
}
};
return Dimension;
}());
exports.default = Dimension;
//# sourceMappingURL=Dimension.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Exception {
constructor(type, message) {
var Exception = /** @class */ (function () {
function Exception(type, message) {
this.type = type;
this.message = message;
}
getType() {
Exception.prototype.getType = function () {
return this.type;
}
getMessage() {
};
Exception.prototype.getMessage = function () {
return this.message;
}
static isOfType(ex, type) {
};
Exception.isOfType = function (ex, type) {
return ex.type === type;
}
}
Exception.IllegalArgumentException = 'IllegalArgumentException';
Exception.NotFoundException = 'NotFoundException';
Exception.ArithmeticException = 'ArithmeticException';
Exception.FormatException = 'FormatException';
Exception.ChecksumException = 'ChecksumException';
Exception.WriterException = 'WriterException';
Exception.IllegalStateException = 'IllegalStateException';
Exception.UnsupportedOperationException = 'UnsupportedOperationException';
Exception.ReedSolomonException = 'ReedSolomonException';
Exception.ArgumentException = 'ArgumentException';
Exception.ReaderException = 'ReaderException';
};
Exception.IllegalArgumentException = 'IllegalArgumentException';
Exception.NotFoundException = 'NotFoundException';
Exception.ArithmeticException = 'ArithmeticException';
Exception.FormatException = 'FormatException';
Exception.ChecksumException = 'ChecksumException';
Exception.WriterException = 'WriterException';
Exception.IllegalStateException = 'IllegalStateException';
Exception.UnsupportedOperationException = 'UnsupportedOperationException';
Exception.ReedSolomonException = 'ReedSolomonException';
Exception.ArgumentException = 'ArgumentException';
Exception.ReaderException = 'ReaderException';
return Exception;
}());
exports.default = Exception;
//# sourceMappingURL=Exception.js.map

@@ -17,4 +17,14 @@ "use strict";

*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const LuminanceSource_1 = require("./LuminanceSource");
var LuminanceSource_1 = require("./LuminanceSource");
/*namespace com.google.zxing {*/

@@ -27,38 +37,40 @@ /**

*/
class InvertedLuminanceSource extends LuminanceSource_1.default {
constructor(delegate) {
super(delegate.getWidth(), delegate.getHeight());
this.delegate = delegate;
var InvertedLuminanceSource = /** @class */ (function (_super) {
__extends(InvertedLuminanceSource, _super);
function InvertedLuminanceSource(delegate) {
var _this = _super.call(this, delegate.getWidth(), delegate.getHeight()) || this;
_this.delegate = delegate;
return _this;
}
/*@Override*/
getRow(y /*int*/, row) {
const sourceRow = this.delegate.getRow(y, row);
const width = this.getWidth();
for (let i = 0; i < width; i++) {
InvertedLuminanceSource.prototype.getRow = function (y /*int*/, row) {
var sourceRow = this.delegate.getRow(y, row);
var width = this.getWidth();
for (var i = 0; i < width; i++) {
sourceRow[i] = /*(byte)*/ (255 - (sourceRow[i] & 0xFF));
}
return sourceRow;
}
};
/*@Override*/
getMatrix() {
const matrix = this.delegate.getMatrix();
const length = this.getWidth() * this.getHeight();
const invertedMatrix = new Uint8ClampedArray(length);
for (let i = 0; i < length; i++) {
InvertedLuminanceSource.prototype.getMatrix = function () {
var matrix = this.delegate.getMatrix();
var length = this.getWidth() * this.getHeight();
var invertedMatrix = new Uint8ClampedArray(length);
for (var i = 0; i < length; i++) {
invertedMatrix[i] = /*(byte)*/ (255 - (matrix[i] & 0xFF));
}
return invertedMatrix;
}
};
/*@Override*/
isCropSupported() {
InvertedLuminanceSource.prototype.isCropSupported = function () {
return this.delegate.isCropSupported();
}
};
/*@Override*/
crop(left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
InvertedLuminanceSource.prototype.crop = function (left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
return new InvertedLuminanceSource(this.delegate.crop(left, top, width, height));
}
};
/*@Override*/
isRotateSupported() {
InvertedLuminanceSource.prototype.isRotateSupported = function () {
return this.delegate.isRotateSupported();
}
};
/**

@@ -68,15 +80,16 @@ * @return original delegate {@link LuminanceSource} since invert undoes itself

/*@Override*/
invert() {
InvertedLuminanceSource.prototype.invert = function () {
return this.delegate;
}
};
/*@Override*/
rotateCounterClockwise() {
InvertedLuminanceSource.prototype.rotateCounterClockwise = function () {
return new InvertedLuminanceSource(this.delegate.rotateCounterClockwise());
}
};
/*@Override*/
rotateCounterClockwise45() {
InvertedLuminanceSource.prototype.rotateCounterClockwise45 = function () {
return new InvertedLuminanceSource(this.delegate.rotateCounterClockwise45());
}
}
};
return InvertedLuminanceSource;
}(LuminanceSource_1.default));
exports.default = InvertedLuminanceSource;
//# sourceMappingURL=InvertedLuminanceSource.js.map

@@ -18,4 +18,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const Exception_1 = require("./Exception");
const StringBuilder_1 = require("./util/StringBuilder");
var Exception_1 = require("./Exception");
var StringBuilder_1 = require("./util/StringBuilder");
/*namespace com.google.zxing {*/

@@ -31,4 +31,4 @@ /**

*/
class LuminanceSource {
constructor(width /*int*/, height /*int*/) {
var LuminanceSource = /** @class */ (function () {
function LuminanceSource(width /*int*/, height /*int*/) {
this.width = width; /*int*/

@@ -40,17 +40,17 @@ this.height = height; /*int*/

*/
getWidth() {
LuminanceSource.prototype.getWidth = function () {
return this.width;
}
};
/**
* @return The height of the bitmap.
*/
getHeight() {
LuminanceSource.prototype.getHeight = function () {
return this.height;
}
};
/**
* @return Whether this subclass supports cropping.
*/
isCropSupported() {
LuminanceSource.prototype.isCropSupported = function () {
return false;
}
};
/**

@@ -66,11 +66,11 @@ * Returns a new object with cropped image data. Implementations may keep a reference to the

*/
crop(left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
LuminanceSource.prototype.crop = function (left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
throw new Exception_1.default(Exception_1.default.UnsupportedOperationException, 'This luminance source does not support cropping.');
}
};
/**
* @return Whether this subclass supports counter-clockwise rotation.
*/
isRotateSupported() {
LuminanceSource.prototype.isRotateSupported = function () {
return false;
}
};
/**

@@ -82,5 +82,5 @@ * Returns a new object with rotated image data by 90 degrees counterclockwise.

*/
rotateCounterClockwise() {
LuminanceSource.prototype.rotateCounterClockwise = function () {
throw new Exception_1.default(Exception_1.default.UnsupportedOperationException, 'This luminance source does not support rotation by 90 degrees.');
}
};
/**

@@ -92,14 +92,14 @@ * Returns a new object with rotated image data by 45 degrees counterclockwise.

*/
rotateCounterClockwise45() {
LuminanceSource.prototype.rotateCounterClockwise45 = function () {
throw new Exception_1.default(Exception_1.default.UnsupportedOperationException, 'This luminance source does not support rotation by 45 degrees.');
}
};
/*@Override*/
toString() {
const row = new Uint8ClampedArray(this.width);
let result = new StringBuilder_1.default();
for (let y = 0; y < this.height; y++) {
const sourceRow = this.getRow(y, row);
for (let x = 0; x < this.width; x++) {
const luminance = sourceRow[x] & 0xFF;
let c;
LuminanceSource.prototype.toString = function () {
var row = new Uint8ClampedArray(this.width);
var result = new StringBuilder_1.default();
for (var y = 0; y < this.height; y++) {
var sourceRow = this.getRow(y, row);
for (var x = 0; x < this.width; x++) {
var luminance = sourceRow[x] & 0xFF;
var c = void 0;
if (luminance < 0x40) {

@@ -122,5 +122,6 @@ c = '#';

return result.toString();
}
}
};
return LuminanceSource;
}());
exports.default = LuminanceSource;
//# sourceMappingURL=LuminanceSource.js.map

@@ -18,4 +18,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const QRCodeReader_1 = require("./qrcode/QRCodeReader");
const Exception_1 = require("./Exception");
var QRCodeReader_1 = require("./qrcode/QRCodeReader");
var Exception_1 = require("./Exception");
var MultiFormatOneDReader_1 = require("./oned/MultiFormatOneDReader");
/*namespace com.google.zxing {*/

@@ -30,3 +31,5 @@ /**

*/
class MultiFormatReader {
var MultiFormatReader = /** @class */ (function () {
function MultiFormatReader() {
}
/**

@@ -55,6 +58,6 @@ * This version of decode honors the intent of Reader.decode(BinaryBitmap) in that it

/*@Override*/
decode(image, hints) {
MultiFormatReader.prototype.decode = function (image, hints) {
this.setHints(hints);
return this.decodeInternal(image);
}
};
/**

@@ -68,3 +71,3 @@ * Decode an image using the state set up by calling setHints() previously. Continuous scan

*/
decodeWithState(image) {
MultiFormatReader.prototype.decodeWithState = function (image) {
// Make sure to set up the default state so we don't crash

@@ -75,3 +78,3 @@ if (this.readers === null || this.readers === undefined) {

return this.decodeInternal(image);
}
};
/**

@@ -84,10 +87,10 @@ * This method adds state to the MultiFormatReader. By setting the hints once, subsequent calls

*/
setHints(hints) {
MultiFormatReader.prototype.setHints = function (hints) {
this.hints = hints;
const tryHarder = hints !== null && hints !== undefined && undefined !== hints.get(3 /* TRY_HARDER */);
var tryHarder = hints !== null && hints !== undefined && undefined !== hints.get(3 /* TRY_HARDER */);
/*@SuppressWarnings("unchecked")*/
const formats = hints === null || hints === undefined ? null : hints.get(2 /* POSSIBLE_FORMATS */);
const readers = new Array();
var formats = hints === null || hints === undefined ? null : hints.get(2 /* POSSIBLE_FORMATS */);
var readers = new Array();
if (formats !== null && formats !== undefined) {
const addOneDReader = formats.contains(14 /* UPC_A */) ||
var addOneDReader = formats.contains(14 /* UPC_A */) ||
formats.contains(15 /* UPC_E */) ||

@@ -105,5 +108,5 @@ formats.contains(7 /* EAN_13 */) ||

// TYPESCRIPTPORT: TODO: uncomment below as they are ported
// if (addOneDReader && !tryHarder) {
// readers.push(new MultiFormatOneDReader(hints))
// }
if (addOneDReader && !tryHarder) {
readers.push(new MultiFormatOneDReader_1.default(hints));
}
if (formats.contains(11 /* QR_CODE */)) {

@@ -124,11 +127,11 @@ readers.push(new QRCodeReader_1.default());

// }
// // At end in "try harder" mode
// if (addOneDReader && tryHarder) {
// readers.push(new MultiFormatOneDReader(hints))
// }
// At end in "try harder" mode
if (addOneDReader && tryHarder) {
readers.push(new MultiFormatOneDReader_1.default(hints));
}
}
if (readers.length === 0) {
// if (!tryHarder) {
// readers.push(new MultiFormatOneDReader(hints))
// }
if (!tryHarder) {
readers.push(new MultiFormatOneDReader_1.default(hints));
}
readers.push(new QRCodeReader_1.default());

@@ -139,21 +142,21 @@ // readers.push(new DataMatrixReader())

// readers.push(new MaxiCodeReader())
// if (tryHarder) {
// readers.push(new MultiFormatOneDReader(hints))
// }
if (tryHarder) {
readers.push(new MultiFormatOneDReader_1.default(hints));
}
}
this.readers = readers; // .toArray(new Reader[readers.size()])
}
};
/*@Override*/
reset() {
MultiFormatReader.prototype.reset = function () {
if (this.readers !== null) {
for (let i = 0, length = this.readers.length; i !== length; i++) {
const reader = this.readers[i];
for (var i = 0, length_1 = this.readers.length; i !== length_1; i++) {
var reader = this.readers[i];
reader.reset();
}
}
}
decodeInternal(image) {
};
MultiFormatReader.prototype.decodeInternal = function (image) {
if (this.readers !== null) {
for (let i = 0, length = this.readers.length; i !== length; i++) {
const reader = this.readers[i];
for (var i = 0, length_2 = this.readers.length; i !== length_2; i++) {
var reader = this.readers[i];
try {

@@ -171,5 +174,6 @@ return reader.decode(image, this.hints);

throw new Exception_1.default(Exception_1.default.NotFoundException);
}
}
};
return MultiFormatReader;
}());
exports.default = MultiFormatReader;
//# sourceMappingURL=MultiFormatReader.js.map

@@ -29,4 +29,4 @@ "use strict";

// import PDF417Writer from './pdf417/PDF417Writer'
const QRCodeWriter_1 = require("./qrcode/QRCodeWriter");
const Exception_1 = require("./Exception");
var QRCodeWriter_1 = require("./qrcode/QRCodeWriter");
var Exception_1 = require("./Exception");
/*import java.util.Map;*/

@@ -39,3 +39,5 @@ /**

*/
class MultiFormatWriter {
var MultiFormatWriter = /** @class */ (function () {
function MultiFormatWriter() {
}
/*@Override*/

@@ -49,4 +51,4 @@ // public encode(contents: string,

/*@Override*/
encode(contents, format, width /*int*/, height /*int*/, hints) {
let writer;
MultiFormatWriter.prototype.encode = function (contents, format, width /*int*/, height /*int*/, hints) {
var writer;
switch (format) {

@@ -96,5 +98,6 @@ // case BarcodeFormat.EAN_8:

return writer.encode(contents, format, width, height, hints);
}
}
};
return MultiFormatWriter;
}());
exports.default = MultiFormatWriter;
//# sourceMappingURL=MultiFormatWriter.js.map

@@ -17,8 +17,18 @@ "use strict";

*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
/*namespace com.google.zxing {*/
const System_1 = require("./util/System");
const Exception_1 = require("./Exception");
const LuminanceSource_1 = require("./LuminanceSource");
const InvertedLuminanceSource_1 = require("./InvertedLuminanceSource");
var System_1 = require("./util/System");
var Exception_1 = require("./Exception");
var LuminanceSource_1 = require("./LuminanceSource");
var InvertedLuminanceSource_1 = require("./InvertedLuminanceSource");
/**

@@ -34,10 +44,11 @@ * This object extends LuminanceSource around an array of YUV data returned from the camera driver,

*/
class PlanarYUVLuminanceSource extends LuminanceSource_1.default {
constructor(yuvData, dataWidth /*int*/, dataHeight /*int*/, left /*int*/, top /*int*/, width /*int*/, height /*int*/, reverseHorizontal) {
super(width, height);
this.yuvData = yuvData;
this.dataWidth = dataWidth; /*int*/
this.dataHeight = dataHeight; /*int*/
this.left = left; /*int*/
this.top = top; /*int*/
var PlanarYUVLuminanceSource = /** @class */ (function (_super) {
__extends(PlanarYUVLuminanceSource, _super);
function PlanarYUVLuminanceSource(yuvData, dataWidth /*int*/, dataHeight /*int*/, left /*int*/, top /*int*/, width /*int*/, height /*int*/, reverseHorizontal) {
var _this = _super.call(this, width, height) || this;
_this.yuvData = yuvData;
_this.dataWidth = dataWidth; /*int*/
_this.dataHeight = dataHeight; /*int*/
_this.left = left; /*int*/
_this.top = top; /*int*/
if (left + width > dataWidth || top + height > dataHeight) {

@@ -47,22 +58,23 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Crop rectangle does not fit within image data.');

if (reverseHorizontal) {
this.reverseHorizontal(width, height);
_this.reverseHorizontal(width, height);
}
return _this;
}
/*@Override*/
getRow(y /*int*/, row) {
PlanarYUVLuminanceSource.prototype.getRow = function (y /*int*/, row) {
if (y < 0 || y >= this.getHeight()) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Requested row is outside the image: ' + y);
}
const width = this.getWidth();
var width = this.getWidth();
if (row === null || row === undefined || row.length < width) {
row = new Uint8ClampedArray(width);
}
const offset = (y + this.top) * this.dataWidth + this.left;
var offset = (y + this.top) * this.dataWidth + this.left;
System_1.default.arraycopy(this.yuvData, offset, row, 0, width);
return row;
}
};
/*@Override*/
getMatrix() {
const width = this.getWidth();
const height = this.getHeight();
PlanarYUVLuminanceSource.prototype.getMatrix = function () {
var width = this.getWidth();
var height = this.getHeight();
// If the caller asks for the entire underlying image, save the copy and give them the

@@ -73,5 +85,5 @@ // original data. The docs specifically warn that result.length must be ignored.

}
const area = width * height;
const matrix = new Uint8ClampedArray(area);
let inputOffset = this.top * this.dataWidth + this.left;
var area = width * height;
var matrix = new Uint8ClampedArray(area);
var inputOffset = this.top * this.dataWidth + this.left;
// If the width matches the full width of the underlying data, perform a single copy.

@@ -83,4 +95,4 @@ if (width === this.dataWidth) {

// Otherwise copy one cropped row at a time.
for (let y = 0; y < height; y++) {
const outputOffset = y * width;
for (var y = 0; y < height; y++) {
var outputOffset = y * width;
System_1.default.arraycopy(this.yuvData, inputOffset, matrix, outputOffset, width);

@@ -90,21 +102,21 @@ inputOffset += this.dataWidth;

return matrix;
}
};
/*@Override*/
isCropSupported() {
PlanarYUVLuminanceSource.prototype.isCropSupported = function () {
return true;
}
};
/*@Override*/
crop(left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
PlanarYUVLuminanceSource.prototype.crop = function (left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
return new PlanarYUVLuminanceSource(this.yuvData, this.dataWidth, this.dataHeight, this.left + left, this.top + top, width, height, false);
}
renderThumbnail() {
const width = this.getWidth() / PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR;
const height = this.getHeight() / PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR;
const pixels = new Int32Array(width * height);
const yuv = this.yuvData;
let inputOffset = this.top * this.dataWidth + this.left;
for (let y = 0; y < height; y++) {
const outputOffset = y * width;
for (let x = 0; x < width; x++) {
const grey = yuv[inputOffset + x * PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR] & 0xff;
};
PlanarYUVLuminanceSource.prototype.renderThumbnail = function () {
var width = this.getWidth() / PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR;
var height = this.getHeight() / PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR;
var pixels = new Int32Array(width * height);
var yuv = this.yuvData;
var inputOffset = this.top * this.dataWidth + this.left;
for (var y = 0; y < height; y++) {
var outputOffset = y * width;
for (var x = 0; x < width; x++) {
var grey = yuv[inputOffset + x * PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR] & 0xff;
pixels[outputOffset + x] = 0xFF000000 | (grey * 0x00010101);

@@ -115,21 +127,21 @@ }

return pixels;
}
};
/**
* @return width of image from {@link #renderThumbnail()}
*/
getThumbnailWidth() {
PlanarYUVLuminanceSource.prototype.getThumbnailWidth = function () {
return this.getWidth() / PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR;
}
};
/**
* @return height of image from {@link #renderThumbnail()}
*/
getThumbnailHeight() {
PlanarYUVLuminanceSource.prototype.getThumbnailHeight = function () {
return this.getHeight() / PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR;
}
reverseHorizontal(width /*int*/, height /*int*/) {
const yuvData = this.yuvData;
for (let y = 0, rowStart = this.top * this.dataWidth + this.left; y < height; y++, rowStart += this.dataWidth) {
const middle = rowStart + width / 2;
for (let x1 = rowStart, x2 = rowStart + width - 1; x1 < middle; x1++, x2--) {
const temp = yuvData[x1];
};
PlanarYUVLuminanceSource.prototype.reverseHorizontal = function (width /*int*/, height /*int*/) {
var yuvData = this.yuvData;
for (var y = 0, rowStart = this.top * this.dataWidth + this.left; y < height; y++, rowStart += this.dataWidth) {
var middle = rowStart + width / 2;
for (var x1 = rowStart, x2 = rowStart + width - 1; x1 < middle; x1++, x2--) {
var temp = yuvData[x1];
yuvData[x1] = yuvData[x2];

@@ -139,9 +151,10 @@ yuvData[x2] = temp;

}
}
invert() {
};
PlanarYUVLuminanceSource.prototype.invert = function () {
return new InvertedLuminanceSource_1.default(this);
}
}
PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR = 2;
};
PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR = 2;
return PlanarYUVLuminanceSource;
}(LuminanceSource_1.default));
exports.default = PlanarYUVLuminanceSource;
//# sourceMappingURL=PlanarYUVLuminanceSource.js.map

@@ -18,10 +18,10 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const Version_1 = require("./Version");
const FormatInformation_1 = require("./FormatInformation");
const Exception_1 = require("./../../Exception");
const DataMask_1 = require("./DataMask");
var Version_1 = require("./Version");
var FormatInformation_1 = require("./FormatInformation");
var Exception_1 = require("./../../Exception");
var DataMask_1 = require("./DataMask");
/**
* @author Sean Owen
*/
class BitMatrixParser {
var BitMatrixParser = /** @class */ (function () {
/**

@@ -31,4 +31,4 @@ * @param bitMatrix {@link BitMatrix} to parse

*/
constructor(bitMatrix) {
const dimension = bitMatrix.getHeight();
function BitMatrixParser(bitMatrix) {
var dimension = bitMatrix.getHeight();
if (dimension < 21 || (dimension & 0x03) !== 1) {

@@ -46,3 +46,3 @@ throw new Exception_1.default(Exception_1.default.FormatException);

*/
readFormatInformation() {
BitMatrixParser.prototype.readFormatInformation = function () {
if (this.parsedFormatInfo !== null && this.parsedFormatInfo !== undefined) {

@@ -52,4 +52,4 @@ return this.parsedFormatInfo;

// Read top-left format info bits
let formatInfoBits1 = 0;
for (let i = 0; i < 6; i++) {
var formatInfoBits1 = 0;
for (var i = 0; i < 6; i++) {
formatInfoBits1 = this.copyBit(i, 8, formatInfoBits1);

@@ -62,13 +62,13 @@ }

// .. and skip a bit in the timing pattern ...
for (let j = 5; j >= 0; j--) {
for (var j = 5; j >= 0; j--) {
formatInfoBits1 = this.copyBit(8, j, formatInfoBits1);
}
// Read the top-right/bottom-left pattern too
const dimension = this.bitMatrix.getHeight();
let formatInfoBits2 = 0;
const jMin = dimension - 7;
for (let j = dimension - 1; j >= jMin; j--) {
var dimension = this.bitMatrix.getHeight();
var formatInfoBits2 = 0;
var jMin = dimension - 7;
for (var j = dimension - 1; j >= jMin; j--) {
formatInfoBits2 = this.copyBit(8, j, formatInfoBits2);
}
for (let i = dimension - 8; i < dimension; i++) {
for (var i = dimension - 8; i < dimension; i++) {
formatInfoBits2 = this.copyBit(i, 8, formatInfoBits2);

@@ -81,3 +81,3 @@ }

throw new Exception_1.default(Exception_1.default.FormatException);
}
};
/**

@@ -90,8 +90,8 @@ * <p>Reads version information from one of its two locations within the QR Code.</p>

*/
readVersion() {
BitMatrixParser.prototype.readVersion = function () {
if (this.parsedVersion !== null && this.parsedVersion !== undefined) {
return this.parsedVersion;
}
const dimension = this.bitMatrix.getHeight();
const provisionalVersion = Math.floor((dimension - 17) / 4);
var dimension = this.bitMatrix.getHeight();
var provisionalVersion = Math.floor((dimension - 17) / 4);
if (provisionalVersion <= 6) {

@@ -101,10 +101,10 @@ return Version_1.default.getVersionForNumber(provisionalVersion);

// Read top-right version info: 3 wide by 6 tall
let versionBits = 0;
const ijMin = dimension - 11;
for (let j = 5; j >= 0; j--) {
for (let i = dimension - 9; i >= ijMin; i--) {
var versionBits = 0;
var ijMin = dimension - 11;
for (var j = 5; j >= 0; j--) {
for (var i = dimension - 9; i >= ijMin; i--) {
versionBits = this.copyBit(i, j, versionBits);
}
}
let theParsedVersion = Version_1.default.decodeVersionInformation(versionBits);
var theParsedVersion = Version_1.default.decodeVersionInformation(versionBits);
if (theParsedVersion !== null && theParsedVersion.getDimensionForVersion() === dimension) {

@@ -116,4 +116,4 @@ this.parsedVersion = theParsedVersion;

versionBits = 0;
for (let i = 5; i >= 0; i--) {
for (let j = dimension - 9; j >= ijMin; j--) {
for (var i = 5; i >= 0; i--) {
for (var j = dimension - 9; j >= ijMin; j--) {
versionBits = this.copyBit(i, j, versionBits);

@@ -128,7 +128,7 @@ }

throw new Exception_1.default(Exception_1.default.FormatException);
}
copyBit(i /*int*/, j /*int*/, versionBits /*int*/) {
const bit = this.isMirror ? this.bitMatrix.get(j, i) : this.bitMatrix.get(i, j);
};
BitMatrixParser.prototype.copyBit = function (i /*int*/, j /*int*/, versionBits /*int*/) {
var bit = this.isMirror ? this.bitMatrix.get(j, i) : this.bitMatrix.get(i, j);
return bit ? (versionBits << 1) | 0x1 : versionBits << 1;
}
};
/**

@@ -142,18 +142,18 @@ * <p>Reads the bits in the {@link BitMatrix} representing the finder pattern in the

*/
readCodewords() {
const formatInfo = this.readFormatInformation();
const version = this.readVersion();
BitMatrixParser.prototype.readCodewords = function () {
var formatInfo = this.readFormatInformation();
var version = this.readVersion();
// Get the data mask for the format used in this QR Code. This will exclude
// some bits from reading as we wind through the bit matrix.
const dataMask = DataMask_1.default.values.get(formatInfo.getDataMask());
const dimension = this.bitMatrix.getHeight();
var dataMask = DataMask_1.default.values.get(formatInfo.getDataMask());
var dimension = this.bitMatrix.getHeight();
dataMask.unmaskBitMatrix(this.bitMatrix, dimension);
const functionPattern = version.buildFunctionPattern();
let readingUp = true;
const result = new Uint8Array(version.getTotalCodewords());
let resultOffset = 0;
let currentByte = 0;
let bitsRead = 0;
var functionPattern = version.buildFunctionPattern();
var readingUp = true;
var result = new Uint8Array(version.getTotalCodewords());
var resultOffset = 0;
var currentByte = 0;
var bitsRead = 0;
// Read columns in pairs, from right to left
for (let j = dimension - 1; j > 0; j -= 2) {
for (var j = dimension - 1; j > 0; j -= 2) {
if (j === 6) {

@@ -165,5 +165,5 @@ // Skip whole column with vertical alignment pattern

// Read alternatingly from bottom to top then top to bottom
for (let count = 0; count < dimension; count++) {
const i = readingUp ? dimension - 1 - count : count;
for (let col = 0; col < 2; col++) {
for (var count = 0; count < dimension; count++) {
var i = readingUp ? dimension - 1 - count : count;
for (var col = 0; col < 2; col++) {
// Ignore bits covered by the function pattern

@@ -192,14 +192,14 @@ if (!functionPattern.get(j - col, i)) {

return result;
}
};
/**
* Revert the mask removal done while reading the code words. The bit matrix should revert to its original state.
*/
remask() {
BitMatrixParser.prototype.remask = function () {
if (this.parsedFormatInfo === null) {
return; // We have no format information, and have no data mask
}
const dataMask = DataMask_1.default.values[this.parsedFormatInfo.getDataMask()];
const dimension = this.bitMatrix.getHeight();
var dataMask = DataMask_1.default.values[this.parsedFormatInfo.getDataMask()];
var dimension = this.bitMatrix.getHeight();
dataMask.unmaskBitMatrix(this.bitMatrix, dimension);
}
};
/**

@@ -213,12 +213,12 @@ * Prepare the parser for a mirrored operation.

*/
setMirror(isMirror) {
BitMatrixParser.prototype.setMirror = function (isMirror) {
this.parsedVersion = null;
this.parsedFormatInfo = null;
this.isMirror = isMirror;
}
};
/** Mirror the bit matrix in order to attempt a second reading. */
mirror() {
const bitMatrix = this.bitMatrix;
for (let x = 0, width = bitMatrix.getWidth(); x < width; x++) {
for (let y = x + 1, height = bitMatrix.getHeight(); y < height; y++) {
BitMatrixParser.prototype.mirror = function () {
var bitMatrix = this.bitMatrix;
for (var x = 0, width = bitMatrix.getWidth(); x < width; x++) {
for (var y = x + 1, height = bitMatrix.getHeight(); y < height; y++) {
if (bitMatrix.get(x, y) !== bitMatrix.get(y, x)) {

@@ -230,5 +230,6 @@ bitMatrix.flip(y, x);

}
}
}
};
return BitMatrixParser;
}());
exports.default = BitMatrixParser;
//# sourceMappingURL=BitMatrixParser.js.map

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const Exception_1 = require("./../../Exception");
var Exception_1 = require("./../../Exception");
/**

@@ -27,4 +27,4 @@ * <p>Encapsulates a block of data within a QR Code. QR Codes may split their data into

*/
class DataBlock {
constructor(numDataCodewords /*int*/, codewords) {
var DataBlock = /** @class */ (function () {
function DataBlock(numDataCodewords /*int*/, codewords) {
this.numDataCodewords = numDataCodewords; /*int*/

@@ -44,3 +44,3 @@ this.codewords = codewords;

*/
static getDataBlocks(rawCodewords, version, ecLevel) {
DataBlock.getDataBlocks = function (rawCodewords, version, ecLevel) {
if (rawCodewords.length !== version.getTotalCodewords()) {

@@ -51,16 +51,18 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException);

// error correction level
const ecBlocks = version.getECBlocksForLevel(ecLevel);
var ecBlocks = version.getECBlocksForLevel(ecLevel);
// First count the total number of data blocks
let totalBlocks = 0;
const ecBlockArray = ecBlocks.getECBlocks();
for (const ecBlock of ecBlockArray) {
var totalBlocks = 0;
var ecBlockArray = ecBlocks.getECBlocks();
for (var _i = 0, ecBlockArray_1 = ecBlockArray; _i < ecBlockArray_1.length; _i++) {
var ecBlock = ecBlockArray_1[_i];
totalBlocks += ecBlock.getCount();
}
// Now establish DataBlocks of the appropriate size and number of data codewords
const result = new Array(totalBlocks);
let numResultBlocks = 0;
for (const ecBlock of ecBlockArray) {
for (let i = 0; i < ecBlock.getCount(); i++) {
const numDataCodewords = ecBlock.getDataCodewords();
const numBlockCodewords = ecBlocks.getECCodewordsPerBlock() + numDataCodewords;
var result = new Array(totalBlocks);
var numResultBlocks = 0;
for (var _a = 0, ecBlockArray_2 = ecBlockArray; _a < ecBlockArray_2.length; _a++) {
var ecBlock = ecBlockArray_2[_a];
for (var i = 0; i < ecBlock.getCount(); i++) {
var numDataCodewords = ecBlock.getDataCodewords();
var numBlockCodewords = ecBlocks.getECCodewordsPerBlock() + numDataCodewords;
result[numResultBlocks++] = new DataBlock(numDataCodewords, new Uint8Array(numBlockCodewords));

@@ -71,7 +73,7 @@ }

// (where n may be 0) have 1 more byte. Figure out where these start.
const shorterBlocksTotalCodewords = result[0].codewords.length;
let longerBlocksStartAt = result.length - 1;
var shorterBlocksTotalCodewords = result[0].codewords.length;
var longerBlocksStartAt = result.length - 1;
// TYPESCRIPTPORT: check length is correct here
while (longerBlocksStartAt >= 0) {
const numCodewords = result[longerBlocksStartAt].codewords.length;
var numCodewords = result[longerBlocksStartAt].codewords.length;
if (numCodewords === shorterBlocksTotalCodewords) {

@@ -83,8 +85,8 @@ break;

longerBlocksStartAt++;
const shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.getECCodewordsPerBlock();
var shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.getECCodewordsPerBlock();
// The last elements of result may be 1 element longer
// first fill out as many elements as all of them have
let rawCodewordsOffset = 0;
for (let i = 0; i < shorterBlocksNumDataCodewords; i++) {
for (let j = 0; j < numResultBlocks; j++) {
var rawCodewordsOffset = 0;
for (var i = 0; i < shorterBlocksNumDataCodewords; i++) {
for (var j = 0; j < numResultBlocks; j++) {
result[j].codewords[i] = rawCodewords[rawCodewordsOffset++];

@@ -94,10 +96,10 @@ }

// Fill out the last data block in the longer ones
for (let j = longerBlocksStartAt; j < numResultBlocks; j++) {
for (var j = longerBlocksStartAt; j < numResultBlocks; j++) {
result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++];
}
// Now add in error correction blocks
const max = result[0].codewords.length;
for (let i = shorterBlocksNumDataCodewords; i < max; i++) {
for (let j = 0; j < numResultBlocks; j++) {
const iOffset = j < longerBlocksStartAt ? i : i + 1;
var max = result[0].codewords.length;
for (var i = shorterBlocksNumDataCodewords; i < max; i++) {
for (var j = 0; j < numResultBlocks; j++) {
var iOffset = j < longerBlocksStartAt ? i : i + 1;
result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++];

@@ -107,11 +109,12 @@ }

return result;
}
getNumDataCodewords() {
};
DataBlock.prototype.getNumDataCodewords = function () {
return this.numDataCodewords;
}
getCodewords() {
};
DataBlock.prototype.getCodewords = function () {
return this.codewords;
}
}
};
return DataBlock;
}());
exports.default = DataBlock;
//# sourceMappingURL=DataBlock.js.map

@@ -29,5 +29,5 @@ "use strict";

*/
class DataMask {
var DataMask = /** @class */ (function () {
// See ISO 18004:2006 6.8.1
constructor(value, isMasked) {
function DataMask(value, isMasked) {
this.value = value;

@@ -44,5 +44,5 @@ this.isMasked = isMasked;

*/
unmaskBitMatrix(bits, dimension /*int*/) {
for (let i = 0; i < dimension; i++) {
for (let j = 0; j < dimension; j++) {
DataMask.prototype.unmaskBitMatrix = function (bits, dimension /*int*/) {
for (var i = 0; i < dimension; i++) {
for (var j = 0; j < dimension; j++) {
if (this.isMasked(i, j)) {

@@ -53,42 +53,43 @@ bits.flip(j, i);

}
}
}
DataMask.values = new Map([
/**
* 000: mask bits for which (x + y) mod 2 == 0
*/
[0 /* DATA_MASK_000 */, new DataMask(0 /* DATA_MASK_000 */, (i /*int*/, j /*int*/) => { return ((i + j) & 0x01) === 0; })],
/**
* 001: mask bits for which x mod 2 == 0
*/
[1 /* DATA_MASK_001 */, new DataMask(1 /* DATA_MASK_001 */, (i /*int*/, j /*int*/) => { return (i & 0x01) === 0; })],
/**
* 010: mask bits for which y mod 3 == 0
*/
[2 /* DATA_MASK_010 */, new DataMask(2 /* DATA_MASK_010 */, (i /*int*/, j /*int*/) => { return j % 3 === 0; })],
/**
* 011: mask bits for which (x + y) mod 3 == 0
*/
[3 /* DATA_MASK_011 */, new DataMask(3 /* DATA_MASK_011 */, (i /*int*/, j /*int*/) => { return (i + j) % 3 === 0; })],
/**
* 100: mask bits for which (x/2 + y/3) mod 2 == 0
*/
[4 /* DATA_MASK_100 */, new DataMask(4 /* DATA_MASK_100 */, (i /*int*/, j /*int*/) => { return ((Math.floor(i / 2) + Math.floor(j / 3)) & 0x01) === 0; })],
/**
* 101: mask bits for which xy mod 2 + xy mod 3 == 0
* equivalently, such that xy mod 6 == 0
*/
[5 /* DATA_MASK_101 */, new DataMask(5 /* DATA_MASK_101 */, (i /*int*/, j /*int*/) => { return (i * j) % 6 === 0; })],
/**
* 110: mask bits for which (xy mod 2 + xy mod 3) mod 2 == 0
* equivalently, such that xy mod 6 < 3
*/
[6 /* DATA_MASK_110 */, new DataMask(6 /* DATA_MASK_110 */, (i /*int*/, j /*int*/) => { return ((i * j) % 6) < 3; })],
/**
* 111: mask bits for which ((x+y)mod 2 + xy mod 3) mod 2 == 0
* equivalently, such that (x + y + xy mod 3) mod 2 == 0
*/
[7 /* DATA_MASK_111 */, new DataMask(7 /* DATA_MASK_111 */, (i /*int*/, j /*int*/) => { return ((i + j + ((i * j) % 3)) & 0x01) === 0; })],
]);
};
DataMask.values = new Map([
/**
* 000: mask bits for which (x + y) mod 2 == 0
*/
[0 /* DATA_MASK_000 */, new DataMask(0 /* DATA_MASK_000 */, function (i /*int*/, j /*int*/) { return ((i + j) & 0x01) === 0; })],
/**
* 001: mask bits for which x mod 2 == 0
*/
[1 /* DATA_MASK_001 */, new DataMask(1 /* DATA_MASK_001 */, function (i /*int*/, j /*int*/) { return (i & 0x01) === 0; })],
/**
* 010: mask bits for which y mod 3 == 0
*/
[2 /* DATA_MASK_010 */, new DataMask(2 /* DATA_MASK_010 */, function (i /*int*/, j /*int*/) { return j % 3 === 0; })],
/**
* 011: mask bits for which (x + y) mod 3 == 0
*/
[3 /* DATA_MASK_011 */, new DataMask(3 /* DATA_MASK_011 */, function (i /*int*/, j /*int*/) { return (i + j) % 3 === 0; })],
/**
* 100: mask bits for which (x/2 + y/3) mod 2 == 0
*/
[4 /* DATA_MASK_100 */, new DataMask(4 /* DATA_MASK_100 */, function (i /*int*/, j /*int*/) { return ((Math.floor(i / 2) + Math.floor(j / 3)) & 0x01) === 0; })],
/**
* 101: mask bits for which xy mod 2 + xy mod 3 == 0
* equivalently, such that xy mod 6 == 0
*/
[5 /* DATA_MASK_101 */, new DataMask(5 /* DATA_MASK_101 */, function (i /*int*/, j /*int*/) { return (i * j) % 6 === 0; })],
/**
* 110: mask bits for which (xy mod 2 + xy mod 3) mod 2 == 0
* equivalently, such that xy mod 6 < 3
*/
[6 /* DATA_MASK_110 */, new DataMask(6 /* DATA_MASK_110 */, function (i /*int*/, j /*int*/) { return ((i * j) % 6) < 3; })],
/**
* 111: mask bits for which ((x+y)mod 2 + xy mod 3) mod 2 == 0
* equivalently, such that (x + y + xy mod 3) mod 2 == 0
*/
[7 /* DATA_MASK_111 */, new DataMask(7 /* DATA_MASK_111 */, function (i /*int*/, j /*int*/) { return ((i + j + ((i * j) % 3)) & 0x01) === 0; })],
]);
return DataMask;
}());
exports.default = DataMask;
//# sourceMappingURL=DataMask.js.map

@@ -18,10 +18,10 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const BitSource_1 = require("./../../common/BitSource");
const CharacterSetECI_1 = require("./../../common/CharacterSetECI");
const DecoderResult_1 = require("./../../common/DecoderResult");
const StringUtils_1 = require("./../../common/StringUtils");
const Mode_1 = require("./Mode");
const Exception_1 = require("./../../Exception");
const StringBuilder_1 = require("./../../util/StringBuilder");
const StringEncoding_1 = require("./../../util/StringEncoding");
var BitSource_1 = require("./../../common/BitSource");
var CharacterSetECI_1 = require("./../../common/CharacterSetECI");
var DecoderResult_1 = require("./../../common/DecoderResult");
var StringUtils_1 = require("./../../common/StringUtils");
var Mode_1 = require("./Mode");
var Exception_1 = require("./../../Exception");
var StringBuilder_1 = require("./../../util/StringBuilder");
var StringEncoding_1 = require("./../../util/StringEncoding");
/*import java.io.UnsupportedEncodingException;*/

@@ -40,14 +40,16 @@ /*import java.util.ArrayList;*/

*/
class DecodedBitStreamParser {
static decode(bytes, version, ecLevel, hints) {
const bits = new BitSource_1.default(bytes);
let result = new StringBuilder_1.default();
const byteSegments = new Array(); // 1
var DecodedBitStreamParser = /** @class */ (function () {
function DecodedBitStreamParser() {
}
DecodedBitStreamParser.decode = function (bytes, version, ecLevel, hints) {
var bits = new BitSource_1.default(bytes);
var result = new StringBuilder_1.default();
var byteSegments = new Array(); // 1
// TYPESCRIPTPORT: I do not use constructor with size 1 as in original Java means capacity and the array length is checked below
let symbolSequence = -1;
let parityData = -1;
var symbolSequence = -1;
var parityData = -1;
try {
let currentCharacterSetECI = null;
let fc1InEffect = false;
let mode;
var currentCharacterSetECI = null;
var fc1InEffect = false;
var mode = void 0;
do {

@@ -60,3 +62,3 @@ // While still another segment to read...

else {
const modeBits = bits.readBits(4);
var modeBits = bits.readBits(4);
mode = Mode_1.default.forBits(modeBits); // mode is encoded by 4 bits

@@ -83,3 +85,3 @@ }

// Count doesn't apply to ECI
const value = DecodedBitStreamParser.parseECIValue(bits);
var value = DecodedBitStreamParser.parseECIValue(bits);
currentCharacterSetECI = CharacterSetECI_1.default.getCharacterSetECIByValue(value);

@@ -93,4 +95,4 @@ if (currentCharacterSetECI === null) {

// Chinese mode contains a sub set indicator right after mode indicator
const subset = bits.readBits(4);
const countHanzi = bits.readBits(mode.getCharacterCountBits(version));
var subset = bits.readBits(4);
var countHanzi = bits.readBits(mode.getCharacterCountBits(version));
if (subset === DecodedBitStreamParser.GB2312_SUBSET) {

@@ -103,3 +105,3 @@ DecodedBitStreamParser.decodeHanziSegment(bits, result, countHanzi);

// How many characters will follow, encoded in this mode?
const count = bits.readBits(mode.getCharacterCountBits(version));
var count = bits.readBits(mode.getCharacterCountBits(version));
switch (mode) {

@@ -130,7 +132,7 @@ case Mode_1.default.NUMERIC:

return new DecoderResult_1.default(bytes, result.toString(), byteSegments.length === 0 ? null : byteSegments, ecLevel === null ? null : ecLevel.toString(), symbolSequence, parityData);
}
};
/**
* See specification GBT 18284-2000
*/
static decodeHanziSegment(bits, result, count /*int*/) {
DecodedBitStreamParser.decodeHanziSegment = function (bits, result, count /*int*/) {
// Don't crash trying to read more bits than we have available.

@@ -142,8 +144,8 @@ if (count * 13 > bits.available()) {

// and decode as GB2312 afterwards
const buffer = new Uint8Array(2 * count);
let offset = 0;
var buffer = new Uint8Array(2 * count);
var offset = 0;
while (count > 0) {
// Each 13 bits encodes a 2-byte character
const twoBytes = bits.readBits(13);
let assembledTwoBytes = (((twoBytes / 0x060) << 8) & 0xFFFFFFFF) | (twoBytes % 0x060);
var twoBytes = bits.readBits(13);
var assembledTwoBytes = (((twoBytes / 0x060) << 8) & 0xFFFFFFFF) | (twoBytes % 0x060);
if (assembledTwoBytes < 0x003BF) {

@@ -169,4 +171,4 @@ // In the 0xA1A1 to 0xAAFE range

}
}
static decodeKanjiSegment(bits, result, count /*int*/) {
};
DecodedBitStreamParser.decodeKanjiSegment = function (bits, result, count /*int*/) {
// Don't crash trying to read more bits than we have available.

@@ -178,8 +180,8 @@ if (count * 13 > bits.available()) {

// and decode as Shift_JIS afterwards
const buffer = new Uint8Array(2 * count);
let offset = 0;
var buffer = new Uint8Array(2 * count);
var offset = 0;
while (count > 0) {
// Each 13 bits encodes a 2-byte character
const twoBytes = bits.readBits(13);
let assembledTwoBytes = (((twoBytes / 0x0C0) << 8) & 0xFFFFFFFF) | (twoBytes % 0x0C0);
var twoBytes = bits.readBits(13);
var assembledTwoBytes = (((twoBytes / 0x0C0) << 8) & 0xFFFFFFFF) | (twoBytes % 0x0C0);
if (assembledTwoBytes < 0x01F00) {

@@ -206,4 +208,4 @@ // In the 0x8140 to 0x9FFC range

}
}
static decodeByteSegment(bits, result, count /*int*/, currentCharacterSetECI, byteSegments, hints) {
};
DecodedBitStreamParser.decodeByteSegment = function (bits, result, count /*int*/, currentCharacterSetECI, byteSegments, hints) {
// Don't crash trying to read more bits than we have available.

@@ -213,7 +215,7 @@ if (8 * count > bits.available()) {

}
const readBytes = new Uint8Array(count);
for (let i = 0; i < count; i++) {
var readBytes = new Uint8Array(count);
for (var i = 0; i < count; i++) {
readBytes[i] = /*(byte) */ bits.readBits(8);
}
let encoding;
var encoding;
if (currentCharacterSetECI === null) {

@@ -237,4 +239,4 @@ // The spec isn't clear on this mode; see

byteSegments.push(readBytes);
}
static toAlphaNumericChar(value /*int*/) {
};
DecodedBitStreamParser.toAlphaNumericChar = function (value /*int*/) {
if (value >= DecodedBitStreamParser.ALPHANUMERIC_CHARS.length) {

@@ -244,6 +246,6 @@ throw new Exception_1.default(Exception_1.default.FormatException);

return DecodedBitStreamParser.ALPHANUMERIC_CHARS[value];
}
static decodeAlphanumericSegment(bits, result, count /*int*/, fc1InEffect) {
};
DecodedBitStreamParser.decodeAlphanumericSegment = function (bits, result, count /*int*/, fc1InEffect) {
// Read two characters at a time
const start = result.length();
var start = result.length();
while (count > 1) {

@@ -253,3 +255,3 @@ if (bits.available() < 11) {

}
const nextTwoCharsBits = bits.readBits(11);
var nextTwoCharsBits = bits.readBits(11);
result.append(DecodedBitStreamParser.toAlphaNumericChar(Math.floor(nextTwoCharsBits / 45)));

@@ -269,3 +271,3 @@ result.append(DecodedBitStreamParser.toAlphaNumericChar(nextTwoCharsBits % 45));

// We need to massage the result a bit if in an FNC1 mode:
for (let i = start; i < result.length(); i++) {
for (var i = start; i < result.length(); i++) {
if (result.charAt(i) === '%') {

@@ -283,4 +285,4 @@ if (i < result.length() - 1 && result.charAt(i + 1) === '%') {

}
}
static decodeNumericSegment(bits, result, count /*int*/) {
};
DecodedBitStreamParser.decodeNumericSegment = function (bits, result, count /*int*/) {
// Read three digits at a time

@@ -292,3 +294,3 @@ while (count >= 3) {

}
const threeDigitsBits = bits.readBits(10);
var threeDigitsBits = bits.readBits(10);
if (threeDigitsBits >= 1000) {

@@ -307,3 +309,3 @@ throw new Exception_1.default(Exception_1.default.FormatException);

}
const twoDigitsBits = bits.readBits(7);
var twoDigitsBits = bits.readBits(7);
if (twoDigitsBits >= 100) {

@@ -320,3 +322,3 @@ throw new Exception_1.default(Exception_1.default.FormatException);

}
const digitBits = bits.readBits(4);
var digitBits = bits.readBits(4);
if (digitBits >= 10) {

@@ -327,5 +329,5 @@ throw new Exception_1.default(Exception_1.default.FormatException);

}
}
static parseECIValue(bits) {
const firstByte = bits.readBits(8);
};
DecodedBitStreamParser.parseECIValue = function (bits) {
var firstByte = bits.readBits(8);
if ((firstByte & 0x80) === 0) {

@@ -337,3 +339,3 @@ // just one byte

// two bytes
const secondByte = bits.readBits(8);
var secondByte = bits.readBits(8);
return (((firstByte & 0x3F) << 8) & 0xFFFFFFFF) | secondByte;

@@ -343,18 +345,19 @@ }

// three bytes
const secondThirdBytes = bits.readBits(16);
var secondThirdBytes = bits.readBits(16);
return (((firstByte & 0x1F) << 16) & 0xFFFFFFFF) | secondThirdBytes;
}
throw new Exception_1.default(Exception_1.default.FormatException);
}
}
/**
* See ISO 18004:2006, 6.4.4 Table 5
*/
DecodedBitStreamParser.ALPHANUMERIC_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:';
DecodedBitStreamParser.GB2312_SUBSET = 1;
};
/**
* See ISO 18004:2006, 6.4.4 Table 5
*/
DecodedBitStreamParser.ALPHANUMERIC_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:';
DecodedBitStreamParser.GB2312_SUBSET = 1;
return DecodedBitStreamParser;
}());
exports.default = DecodedBitStreamParser;
function Uint8ArrayToString(a) {
const CHUNK_SZ = 0x8000;
const c = new StringBuilder_1.default();
for (let i = 0, length = a.length; i < length; i += CHUNK_SZ) {
var CHUNK_SZ = 0x8000;
var c = new StringBuilder_1.default();
for (var i = 0, length_1 = a.length; i < length_1; i += CHUNK_SZ) {
c.append(String.fromCharCode.apply(null, a.subarray(i, i + CHUNK_SZ)));

@@ -361,0 +364,0 @@ }

@@ -18,10 +18,10 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const BitMatrix_1 = require("./../../common/BitMatrix");
const GenericGF_1 = require("./../../common/reedsolomon/GenericGF");
const ReedSolomonDecoder_1 = require("./../../common/reedsolomon/ReedSolomonDecoder");
const BitMatrixParser_1 = require("./BitMatrixParser");
const QRCodeDecoderMetaData_1 = require("./QRCodeDecoderMetaData");
const DataBlock_1 = require("./DataBlock");
const DecodedBitStreamParser_1 = require("./DecodedBitStreamParser");
const Exception_1 = require("./../../Exception");
var BitMatrix_1 = require("./../../common/BitMatrix");
var GenericGF_1 = require("./../../common/reedsolomon/GenericGF");
var ReedSolomonDecoder_1 = require("./../../common/reedsolomon/ReedSolomonDecoder");
var BitMatrixParser_1 = require("./BitMatrixParser");
var QRCodeDecoderMetaData_1 = require("./QRCodeDecoderMetaData");
var DataBlock_1 = require("./DataBlock");
var DecodedBitStreamParser_1 = require("./DecodedBitStreamParser");
var Exception_1 = require("./../../Exception");
/*import java.util.Map;*/

@@ -34,4 +34,4 @@ /**

*/
class Decoder {
constructor() {
var Decoder = /** @class */ (function () {
function Decoder() {
this.rsDecoder = new ReedSolomonDecoder_1.default(GenericGF_1.default.QR_CODE_FIELD_256);

@@ -52,5 +52,5 @@ }

*/
decodeBooleanArray(image, hints) {
Decoder.prototype.decodeBooleanArray = function (image, hints) {
return this.decodeBitMatrix(BitMatrix_1.default.parseFromBooleanArray(image), hints);
}
};
// public decodeBitMatrix(bits: BitMatrix): DecoderResult /*throws ChecksumException, FormatException*/ {

@@ -68,6 +68,6 @@ // return decode(bits, null)

*/
decodeBitMatrix(bits, hints) {
Decoder.prototype.decodeBitMatrix = function (bits, hints) {
// Construct a parser and read version, error-correction level
const parser = new BitMatrixParser_1.default(bits);
let ex = null;
var parser = new BitMatrixParser_1.default(bits);
var ex = null;
try {

@@ -96,3 +96,3 @@ return this.decodeBitMatrixParser(parser, hints);

parser.mirror();
const result = this.decodeBitMatrixParser(parser, hints);
var result = this.decodeBitMatrixParser(parser, hints);
// Success! Notify the caller that the code was mirrored.

@@ -109,23 +109,25 @@ result.setOther(new QRCodeDecoderMetaData_1.default(true));

}
}
decodeBitMatrixParser(parser, hints) {
const version = parser.readVersion();
const ecLevel = parser.readFormatInformation().getErrorCorrectionLevel();
};
Decoder.prototype.decodeBitMatrixParser = function (parser, hints) {
var version = parser.readVersion();
var ecLevel = parser.readFormatInformation().getErrorCorrectionLevel();
// Read codewords
const codewords = parser.readCodewords();
var codewords = parser.readCodewords();
// Separate into data blocks
const dataBlocks = DataBlock_1.default.getDataBlocks(codewords, version, ecLevel);
var dataBlocks = DataBlock_1.default.getDataBlocks(codewords, version, ecLevel);
// Count total number of data bytes
let totalBytes = 0;
for (const dataBlock of dataBlocks) {
var totalBytes = 0;
for (var _i = 0, dataBlocks_1 = dataBlocks; _i < dataBlocks_1.length; _i++) {
var dataBlock = dataBlocks_1[_i];
totalBytes += dataBlock.getNumDataCodewords();
}
const resultBytes = new Uint8Array(totalBytes);
let resultOffset = 0;
var resultBytes = new Uint8Array(totalBytes);
var resultOffset = 0;
// Error-correct and copy data blocks together into a stream of bytes
for (const dataBlock of dataBlocks) {
const codewordBytes = dataBlock.getCodewords();
const numDataCodewords = dataBlock.getNumDataCodewords();
for (var _a = 0, dataBlocks_2 = dataBlocks; _a < dataBlocks_2.length; _a++) {
var dataBlock = dataBlocks_2[_a];
var codewordBytes = dataBlock.getCodewords();
var numDataCodewords = dataBlock.getNumDataCodewords();
this.correctErrors(codewordBytes, numDataCodewords);
for (let i = 0; i < numDataCodewords; i++) {
for (var i = 0; i < numDataCodewords; i++) {
resultBytes[resultOffset++] = codewordBytes[i];

@@ -136,3 +138,3 @@ }

return DecodedBitStreamParser_1.default.decode(resultBytes, version, ecLevel, hints);
}
};
/**

@@ -146,6 +148,6 @@ * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to

*/
correctErrors(codewordBytes, numDataCodewords /*int*/) {
const numCodewords = codewordBytes.length;
Decoder.prototype.correctErrors = function (codewordBytes, numDataCodewords /*int*/) {
var numCodewords = codewordBytes.length;
// First read into an array of ints
const codewordsInts = new Int32Array(codewordBytes);
var codewordsInts = new Int32Array(codewordBytes);
// TYPESCRIPTPORT: not realy necessary to transform to ints? could redesign everything to work with unsigned bytes?

@@ -164,8 +166,9 @@ // const codewordsInts = new Int32Array(numCodewords)

// We don't care about errors in the error-correction codewords
for (let i = 0; i < numDataCodewords; i++) {
for (var i = 0; i < numDataCodewords; i++) {
codewordBytes[i] = /*(byte) */ codewordsInts[i];
}
}
}
};
return Decoder;
}());
exports.default = Decoder;
//# sourceMappingURL=Decoder.js.map

@@ -8,15 +8,16 @@ "use strict";

*/
class ECB {
constructor(count /*int*/, dataCodewords /*int*/) {
var ECB = /** @class */ (function () {
function ECB(count /*int*/, dataCodewords /*int*/) {
this.count = count;
this.dataCodewords = dataCodewords;
}
getCount() {
ECB.prototype.getCount = function () {
return this.count;
}
getDataCodewords() {
};
ECB.prototype.getDataCodewords = function () {
return this.dataCodewords;
}
}
};
return ECB;
}());
exports.default = ECB;
//# sourceMappingURL=ECB.js.map

@@ -9,26 +9,32 @@ "use strict";

*/
class ECBlocks {
constructor(ecCodewordsPerBlock /*int*/, ...ecBlocks) {
var ECBlocks = /** @class */ (function () {
function ECBlocks(ecCodewordsPerBlock /*int*/) {
var ecBlocks = [];
for (var _i = 1; _i < arguments.length; _i++) {
ecBlocks[_i - 1] = arguments[_i];
}
this.ecCodewordsPerBlock = ecCodewordsPerBlock; /*int*/
this.ecBlocks = ecBlocks;
}
getECCodewordsPerBlock() {
ECBlocks.prototype.getECCodewordsPerBlock = function () {
return this.ecCodewordsPerBlock;
}
getNumBlocks() {
let total = 0;
const ecBlocks = this.ecBlocks;
for (const ecBlock of ecBlocks) {
};
ECBlocks.prototype.getNumBlocks = function () {
var total = 0;
var ecBlocks = this.ecBlocks;
for (var _i = 0, ecBlocks_1 = ecBlocks; _i < ecBlocks_1.length; _i++) {
var ecBlock = ecBlocks_1[_i];
total += ecBlock.getCount();
}
return total;
}
getTotalECCodewords() {
};
ECBlocks.prototype.getTotalECCodewords = function () {
return this.ecCodewordsPerBlock * this.getNumBlocks();
}
getECBlocks() {
};
ECBlocks.prototype.getECBlocks = function () {
return this.ecBlocks;
}
}
};
return ECBlocks;
}());
exports.default = ECBlocks;
//# sourceMappingURL=ECBlocks.js.map

@@ -19,3 +19,3 @@ "use strict";

/*namespace com.google.zxing.qrcode.decoder {*/
const Exception_1 = require("./../../Exception");
var Exception_1 = require("./../../Exception");
/**

@@ -27,4 +27,4 @@ * <p>See ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels

*/
class ErrorCorrectionLevel {
constructor(value, stringValue, bits /*int*/) {
var ErrorCorrectionLevel = /** @class */ (function () {
function ErrorCorrectionLevel(value, stringValue, bits /*int*/) {
this.value = value;

@@ -36,9 +36,9 @@ this.stringValue = stringValue;

}
getValue() {
ErrorCorrectionLevel.prototype.getValue = function () {
return this.value;
}
getBits() {
};
ErrorCorrectionLevel.prototype.getBits = function () {
return this.bits;
}
static fromString(s) {
};
ErrorCorrectionLevel.fromString = function (s) {
switch (s) {

@@ -51,13 +51,13 @@ case 'L': return ErrorCorrectionLevel.L;

}
}
toString() {
};
ErrorCorrectionLevel.prototype.toString = function () {
return this.stringValue;
}
equals(o) {
};
ErrorCorrectionLevel.prototype.equals = function (o) {
if (!(o instanceof ErrorCorrectionLevel)) {
return false;
}
const other = o;
var other = o;
return this.value === other.value;
}
};
/**

@@ -67,3 +67,3 @@ * @param bits int containing the two bits encoding a QR Code's error correction level

*/
static forBits(bits /*int*/) {
ErrorCorrectionLevel.forBits = function (bits /*int*/) {
if (bits < 0 || bits >= ErrorCorrectionLevel.FOR_BITS.size) {

@@ -73,15 +73,16 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException);

return ErrorCorrectionLevel.FOR_BITS.get(bits);
}
}
ErrorCorrectionLevel.FOR_BITS = new Map();
ErrorCorrectionLevel.FOR_VALUE = new Map();
/** L = ~7% correction */
ErrorCorrectionLevel.L = new ErrorCorrectionLevel(0 /* L */, 'L', 0x01);
/** M = ~15% correction */
ErrorCorrectionLevel.M = new ErrorCorrectionLevel(1 /* M */, 'M', 0x00);
/** Q = ~25% correction */
ErrorCorrectionLevel.Q = new ErrorCorrectionLevel(2 /* Q */, 'Q', 0x03);
/** H = ~30% correction */
ErrorCorrectionLevel.H = new ErrorCorrectionLevel(3 /* H */, 'H', 0x02);
};
ErrorCorrectionLevel.FOR_BITS = new Map();
ErrorCorrectionLevel.FOR_VALUE = new Map();
/** L = ~7% correction */
ErrorCorrectionLevel.L = new ErrorCorrectionLevel(0 /* L */, 'L', 0x01);
/** M = ~15% correction */
ErrorCorrectionLevel.M = new ErrorCorrectionLevel(1 /* M */, 'M', 0x00);
/** Q = ~25% correction */
ErrorCorrectionLevel.Q = new ErrorCorrectionLevel(2 /* Q */, 'Q', 0x03);
/** H = ~30% correction */
ErrorCorrectionLevel.H = new ErrorCorrectionLevel(3 /* H */, 'H', 0x02);
return ErrorCorrectionLevel;
}());
exports.default = ErrorCorrectionLevel;
//# sourceMappingURL=ErrorCorrectionLevel.js.map

@@ -19,4 +19,4 @@ "use strict";

/*namespace com.google.zxing.qrcode.decoder {*/
const ErrorCorrectionLevel_1 = require("./ErrorCorrectionLevel");
const Integer_1 = require("./../../util/Integer");
var ErrorCorrectionLevel_1 = require("./ErrorCorrectionLevel");
var Integer_1 = require("./../../util/Integer");
/**

@@ -30,4 +30,4 @@ * <p>Encapsulates a QR Code's format information, including the data mask used and

*/
class FormatInformation {
constructor(formatInfo /*int*/) {
var FormatInformation = /** @class */ (function () {
function FormatInformation(formatInfo /*int*/) {
// Bits 3,4

@@ -38,5 +38,5 @@ this.errorCorrectionLevel = ErrorCorrectionLevel_1.default.forBits((formatInfo >> 3) & 0x03);

}
static numBitsDiffering(a /*int*/, b /*int*/) {
FormatInformation.numBitsDiffering = function (a /*int*/, b /*int*/) {
return Integer_1.default.bitCount(a ^ b);
}
};
/**

@@ -49,4 +49,4 @@ * @param maskedFormatInfo1 format info indicator, with mask still applied

*/
static decodeFormatInformation(maskedFormatInfo1 /*int*/, maskedFormatInfo2 /*int*/) {
const formatInfo = FormatInformation.doDecodeFormatInformation(maskedFormatInfo1, maskedFormatInfo2);
FormatInformation.decodeFormatInformation = function (maskedFormatInfo1 /*int*/, maskedFormatInfo2 /*int*/) {
var formatInfo = FormatInformation.doDecodeFormatInformation(maskedFormatInfo1, maskedFormatInfo2);
if (formatInfo !== null) {

@@ -59,9 +59,10 @@ return formatInfo;

return FormatInformation.doDecodeFormatInformation(maskedFormatInfo1 ^ FormatInformation.FORMAT_INFO_MASK_QR, maskedFormatInfo2 ^ FormatInformation.FORMAT_INFO_MASK_QR);
}
static doDecodeFormatInformation(maskedFormatInfo1 /*int*/, maskedFormatInfo2 /*int*/) {
};
FormatInformation.doDecodeFormatInformation = function (maskedFormatInfo1 /*int*/, maskedFormatInfo2 /*int*/) {
// Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing
let bestDifference = Number.MAX_SAFE_INTEGER;
let bestFormatInfo = 0;
for (const decodeInfo of FormatInformation.FORMAT_INFO_DECODE_LOOKUP) {
const targetInfo = decodeInfo[0];
var bestDifference = Number.MAX_SAFE_INTEGER;
var bestFormatInfo = 0;
for (var _i = 0, _a = FormatInformation.FORMAT_INFO_DECODE_LOOKUP; _i < _a.length; _i++) {
var decodeInfo = _a[_i];
var targetInfo = decodeInfo[0];
if (targetInfo === maskedFormatInfo1 || targetInfo === maskedFormatInfo2) {

@@ -71,3 +72,3 @@ // Found an exact match

}
let bitsDifference = FormatInformation.numBitsDiffering(maskedFormatInfo1, targetInfo);
var bitsDifference = FormatInformation.numBitsDiffering(maskedFormatInfo1, targetInfo);
if (bitsDifference < bestDifference) {

@@ -92,62 +93,63 @@ bestFormatInfo = decodeInfo[1];

return null;
}
getErrorCorrectionLevel() {
};
FormatInformation.prototype.getErrorCorrectionLevel = function () {
return this.errorCorrectionLevel;
}
getDataMask() {
};
FormatInformation.prototype.getDataMask = function () {
return this.dataMask;
}
};
/*@Override*/
hashCode() {
FormatInformation.prototype.hashCode = function () {
return (this.errorCorrectionLevel.getBits() << 3) | this.dataMask;
}
};
/*@Override*/
equals(o) {
FormatInformation.prototype.equals = function (o) {
if (!(o instanceof FormatInformation)) {
return false;
}
const other = o;
var other = o;
return this.errorCorrectionLevel === other.errorCorrectionLevel &&
this.dataMask === other.dataMask;
}
}
FormatInformation.FORMAT_INFO_MASK_QR = 0x5412;
/**
* See ISO 18004:2006, Annex C, Table C.1
*/
FormatInformation.FORMAT_INFO_DECODE_LOOKUP = [
Int32Array.from([0x5412, 0x00]),
Int32Array.from([0x5125, 0x01]),
Int32Array.from([0x5E7C, 0x02]),
Int32Array.from([0x5B4B, 0x03]),
Int32Array.from([0x45F9, 0x04]),
Int32Array.from([0x40CE, 0x05]),
Int32Array.from([0x4F97, 0x06]),
Int32Array.from([0x4AA0, 0x07]),
Int32Array.from([0x77C4, 0x08]),
Int32Array.from([0x72F3, 0x09]),
Int32Array.from([0x7DAA, 0x0A]),
Int32Array.from([0x789D, 0x0B]),
Int32Array.from([0x662F, 0x0C]),
Int32Array.from([0x6318, 0x0D]),
Int32Array.from([0x6C41, 0x0E]),
Int32Array.from([0x6976, 0x0F]),
Int32Array.from([0x1689, 0x10]),
Int32Array.from([0x13BE, 0x11]),
Int32Array.from([0x1CE7, 0x12]),
Int32Array.from([0x19D0, 0x13]),
Int32Array.from([0x0762, 0x14]),
Int32Array.from([0x0255, 0x15]),
Int32Array.from([0x0D0C, 0x16]),
Int32Array.from([0x083B, 0x17]),
Int32Array.from([0x355F, 0x18]),
Int32Array.from([0x3068, 0x19]),
Int32Array.from([0x3F31, 0x1A]),
Int32Array.from([0x3A06, 0x1B]),
Int32Array.from([0x24B4, 0x1C]),
Int32Array.from([0x2183, 0x1D]),
Int32Array.from([0x2EDA, 0x1E]),
Int32Array.from([0x2BED, 0x1F]),
];
};
FormatInformation.FORMAT_INFO_MASK_QR = 0x5412;
/**
* See ISO 18004:2006, Annex C, Table C.1
*/
FormatInformation.FORMAT_INFO_DECODE_LOOKUP = [
Int32Array.from([0x5412, 0x00]),
Int32Array.from([0x5125, 0x01]),
Int32Array.from([0x5E7C, 0x02]),
Int32Array.from([0x5B4B, 0x03]),
Int32Array.from([0x45F9, 0x04]),
Int32Array.from([0x40CE, 0x05]),
Int32Array.from([0x4F97, 0x06]),
Int32Array.from([0x4AA0, 0x07]),
Int32Array.from([0x77C4, 0x08]),
Int32Array.from([0x72F3, 0x09]),
Int32Array.from([0x7DAA, 0x0A]),
Int32Array.from([0x789D, 0x0B]),
Int32Array.from([0x662F, 0x0C]),
Int32Array.from([0x6318, 0x0D]),
Int32Array.from([0x6C41, 0x0E]),
Int32Array.from([0x6976, 0x0F]),
Int32Array.from([0x1689, 0x10]),
Int32Array.from([0x13BE, 0x11]),
Int32Array.from([0x1CE7, 0x12]),
Int32Array.from([0x19D0, 0x13]),
Int32Array.from([0x0762, 0x14]),
Int32Array.from([0x0255, 0x15]),
Int32Array.from([0x0D0C, 0x16]),
Int32Array.from([0x083B, 0x17]),
Int32Array.from([0x355F, 0x18]),
Int32Array.from([0x3068, 0x19]),
Int32Array.from([0x3F31, 0x1A]),
Int32Array.from([0x3A06, 0x1B]),
Int32Array.from([0x24B4, 0x1C]),
Int32Array.from([0x2183, 0x1D]),
Int32Array.from([0x2EDA, 0x1E]),
Int32Array.from([0x2BED, 0x1F]),
];
return FormatInformation;
}());
exports.default = FormatInformation;
//# sourceMappingURL=FormatInformation.js.map

@@ -19,3 +19,3 @@ "use strict";

/*namespace com.google.zxing.qrcode.decoder {*/
const Exception_1 = require("./../../Exception");
var Exception_1 = require("./../../Exception");
/**

@@ -27,4 +27,4 @@ * <p>See ISO 18004:2006, 6.4.1, Tables 2 and 3. This enum encapsulates the various modes in which

*/
class Mode {
constructor(value, stringValue, characterCountBitsForVersions, bits /*int*/) {
var Mode = /** @class */ (function () {
function Mode(value, stringValue, characterCountBitsForVersions, bits /*int*/) {
this.value = value;

@@ -42,4 +42,4 @@ this.stringValue = stringValue;

*/
static forBits(bits /*int*/) {
const mode = Mode.FOR_BITS.get(bits);
Mode.forBits = function (bits /*int*/) {
var mode = Mode.FOR_BITS.get(bits);
if (undefined === mode) {

@@ -49,3 +49,3 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException);

return mode;
}
};
/**

@@ -56,5 +56,5 @@ * @param version version in question

*/
getCharacterCountBits(version) {
const versionNumber = version.getVersionNumber();
let offset;
Mode.prototype.getCharacterCountBits = function (version) {
var versionNumber = version.getVersionNumber();
var offset;
if (versionNumber <= 9) {

@@ -70,34 +70,35 @@ offset = 0;

return this.characterCountBitsForVersions[offset];
}
getValue() {
};
Mode.prototype.getValue = function () {
return this.value;
}
getBits() {
};
Mode.prototype.getBits = function () {
return this.bits;
}
equals(o) {
};
Mode.prototype.equals = function (o) {
if (!(o instanceof Mode)) {
return false;
}
const other = o;
var other = o;
return this.value === other.value;
}
toString() {
};
Mode.prototype.toString = function () {
return this.stringValue;
}
}
Mode.FOR_BITS = new Map();
Mode.FOR_VALUE = new Map();
Mode.TERMINATOR = new Mode(0 /* TERMINATOR */, 'TERMINATOR', Int32Array.from([0, 0, 0]), 0x00); // Not really a mode...
Mode.NUMERIC = new Mode(1 /* NUMERIC */, 'NUMERIC', Int32Array.from([10, 12, 14]), 0x01);
Mode.ALPHANUMERIC = new Mode(2 /* ALPHANUMERIC */, 'ALPHANUMERIC', Int32Array.from([9, 11, 13]), 0x02);
Mode.STRUCTURED_APPEND = new Mode(3 /* STRUCTURED_APPEND */, 'STRUCTURED_APPEND', Int32Array.from([0, 0, 0]), 0x03); // Not supported
Mode.BYTE = new Mode(4 /* BYTE */, 'BYTE', Int32Array.from([8, 16, 16]), 0x04);
Mode.ECI = new Mode(5 /* ECI */, 'ECI', Int32Array.from([0, 0, 0]), 0x07); // character counts don't apply
Mode.KANJI = new Mode(6 /* KANJI */, 'KANJI', Int32Array.from([8, 10, 12]), 0x08);
Mode.FNC1_FIRST_POSITION = new Mode(7 /* FNC1_FIRST_POSITION */, 'FNC1_FIRST_POSITION', Int32Array.from([0, 0, 0]), 0x05);
Mode.FNC1_SECOND_POSITION = new Mode(8 /* FNC1_SECOND_POSITION */, 'FNC1_SECOND_POSITION', Int32Array.from([0, 0, 0]), 0x09);
/** See GBT 18284-2000; "Hanzi" is a transliteration of this mode name. */
Mode.HANZI = new Mode(9 /* HANZI */, 'HANZI', Int32Array.from([8, 10, 12]), 0x0D);
};
Mode.FOR_BITS = new Map();
Mode.FOR_VALUE = new Map();
Mode.TERMINATOR = new Mode(0 /* TERMINATOR */, 'TERMINATOR', Int32Array.from([0, 0, 0]), 0x00); // Not really a mode...
Mode.NUMERIC = new Mode(1 /* NUMERIC */, 'NUMERIC', Int32Array.from([10, 12, 14]), 0x01);
Mode.ALPHANUMERIC = new Mode(2 /* ALPHANUMERIC */, 'ALPHANUMERIC', Int32Array.from([9, 11, 13]), 0x02);
Mode.STRUCTURED_APPEND = new Mode(3 /* STRUCTURED_APPEND */, 'STRUCTURED_APPEND', Int32Array.from([0, 0, 0]), 0x03); // Not supported
Mode.BYTE = new Mode(4 /* BYTE */, 'BYTE', Int32Array.from([8, 16, 16]), 0x04);
Mode.ECI = new Mode(5 /* ECI */, 'ECI', Int32Array.from([0, 0, 0]), 0x07); // character counts don't apply
Mode.KANJI = new Mode(6 /* KANJI */, 'KANJI', Int32Array.from([8, 10, 12]), 0x08);
Mode.FNC1_FIRST_POSITION = new Mode(7 /* FNC1_FIRST_POSITION */, 'FNC1_FIRST_POSITION', Int32Array.from([0, 0, 0]), 0x05);
Mode.FNC1_SECOND_POSITION = new Mode(8 /* FNC1_SECOND_POSITION */, 'FNC1_SECOND_POSITION', Int32Array.from([0, 0, 0]), 0x09);
/** See GBT 18284-2000; "Hanzi" is a transliteration of this mode name. */
Mode.HANZI = new Mode(9 /* HANZI */, 'HANZI', Int32Array.from([8, 10, 12]), 0x0D);
return Mode;
}());
exports.default = Mode;
//# sourceMappingURL=Mode.js.map

@@ -24,4 +24,4 @@ "use strict";

*/
class QRCodeDecoderMetaData {
constructor(mirrored) {
var QRCodeDecoderMetaData = /** @class */ (function () {
function QRCodeDecoderMetaData(mirrored) {
this.mirrored = mirrored;

@@ -32,5 +32,5 @@ }

*/
isMirrored() {
QRCodeDecoderMetaData.prototype.isMirrored = function () {
return this.mirrored;
}
};
/**

@@ -41,13 +41,14 @@ * Apply the result points' order correction due to mirroring.

*/
applyMirroredCorrection(points) {
QRCodeDecoderMetaData.prototype.applyMirroredCorrection = function (points) {
if (!this.mirrored || points === null || points.length < 3) {
return;
}
const bottomLeft = points[0];
var bottomLeft = points[0];
points[0] = points[2];
points[2] = bottomLeft;
// No need to 'fix' top-left and alignment pattern.
}
}
};
return QRCodeDecoderMetaData;
}());
exports.default = QRCodeDecoderMetaData;
//# sourceMappingURL=QRCodeDecoderMetaData.js.map

@@ -19,7 +19,7 @@ "use strict";

/*namespace com.google.zxing.qrcode.decoder {*/
const BitMatrix_1 = require("./../../common/BitMatrix");
const Exception_1 = require("./../../Exception");
const FormatInformation_1 = require("./FormatInformation");
const ECBlocks_1 = require("./ECBlocks");
const ECB_1 = require("./ECB");
var BitMatrix_1 = require("./../../common/BitMatrix");
var Exception_1 = require("./../../Exception");
var FormatInformation_1 = require("./FormatInformation");
var ECBlocks_1 = require("./ECBlocks");
var ECB_1 = require("./ECB");
/**

@@ -30,11 +30,16 @@ * See ISO 18004:2006 Annex D

*/
class Version {
constructor(versionNumber /*int*/, alignmentPatternCenters, ...ecBlocks) {
var Version = /** @class */ (function () {
function Version(versionNumber /*int*/, alignmentPatternCenters) {
var ecBlocks = [];
for (var _i = 2; _i < arguments.length; _i++) {
ecBlocks[_i - 2] = arguments[_i];
}
this.versionNumber = versionNumber; /*int*/
this.alignmentPatternCenters = alignmentPatternCenters;
this.ecBlocks = ecBlocks;
let total = 0;
const ecCodewords = ecBlocks[0].getECCodewordsPerBlock();
const ecbArray = ecBlocks[0].getECBlocks();
for (const ecBlock of ecbArray) {
var total = 0;
var ecCodewords = ecBlocks[0].getECCodewordsPerBlock();
var ecbArray = ecBlocks[0].getECBlocks();
for (var _a = 0, ecbArray_1 = ecbArray; _a < ecbArray_1.length; _a++) {
var ecBlock = ecbArray_1[_a];
total += ecBlock.getCount() * (ecBlock.getDataCodewords() + ecCodewords);

@@ -44,19 +49,19 @@ }

}
getVersionNumber() {
Version.prototype.getVersionNumber = function () {
return this.versionNumber;
}
getAlignmentPatternCenters() {
};
Version.prototype.getAlignmentPatternCenters = function () {
return this.alignmentPatternCenters;
}
getTotalCodewords() {
};
Version.prototype.getTotalCodewords = function () {
return this.totalCodewords;
}
getDimensionForVersion() {
};
Version.prototype.getDimensionForVersion = function () {
return 17 + 4 * this.versionNumber;
}
getECBlocksForLevel(ecLevel) {
};
Version.prototype.getECBlocksForLevel = function (ecLevel) {
return this.ecBlocks[ecLevel.getValue()];
// TYPESCRIPTPORT: original was using ordinal, and using the order of levels as defined in ErrorCorrectionLevel enum (LMQH)
// I will use the direct value from ErrorCorrectionLevelValues enum which in typescript goes to a number
}
};
/**

@@ -69,3 +74,3 @@ * <p>Deduces version information purely from QR Code dimensions.</p>

*/
static getProvisionalVersionForDimension(dimension /*int*/) {
Version.getProvisionalVersionForDimension = function (dimension /*int*/) {
if (dimension % 4 !== 1) {

@@ -80,4 +85,4 @@ throw new Exception_1.default(Exception_1.default.FormatException);

}
}
static getVersionForNumber(versionNumber /*int*/) {
};
Version.getVersionForNumber = function (versionNumber /*int*/) {
if (versionNumber < 1 || versionNumber > 40) {

@@ -87,8 +92,8 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException);

return Version.VERSIONS[versionNumber - 1];
}
static decodeVersionInformation(versionBits /*int*/) {
let bestDifference = Number.MAX_SAFE_INTEGER;
let bestVersion = 0;
for (let i = 0; i < Version.VERSION_DECODE_INFO.length; i++) {
const targetVersion = Version.VERSION_DECODE_INFO[i];
};
Version.decodeVersionInformation = function (versionBits /*int*/) {
var bestDifference = Number.MAX_SAFE_INTEGER;
var bestVersion = 0;
for (var i = 0; i < Version.VERSION_DECODE_INFO.length; i++) {
var targetVersion = Version.VERSION_DECODE_INFO[i];
// Do the version info bits match exactly? done.

@@ -100,3 +105,3 @@ if (targetVersion === versionBits) {

// we have seen so far
const bitsDifference = FormatInformation_1.default.numBitsDiffering(versionBits, targetVersion);
var bitsDifference = FormatInformation_1.default.numBitsDiffering(versionBits, targetVersion);
if (bitsDifference < bestDifference) {

@@ -114,9 +119,9 @@ bestVersion = i + 7;

return null;
}
};
/**
* See ISO 18004:2006 Annex E
*/
buildFunctionPattern() {
const dimension = this.getDimensionForVersion();
const bitMatrix = new BitMatrix_1.default(dimension);
Version.prototype.buildFunctionPattern = function () {
var dimension = this.getDimensionForVersion();
var bitMatrix = new BitMatrix_1.default(dimension);
// Top left finder pattern + separator + format

@@ -129,6 +134,6 @@ bitMatrix.setRegion(0, 0, 9, 9);

// Alignment patterns
const max = this.alignmentPatternCenters.length;
for (let x = 0; x < max; x++) {
const i = this.alignmentPatternCenters[x] - 2;
for (let y = 0; y < max; y++) {
var max = this.alignmentPatternCenters.length;
for (var x = 0; x < max; x++) {
var i = this.alignmentPatternCenters[x] - 2;
for (var y = 0; y < max; y++) {
if ((x === 0 && (y === 0 || y === max - 1)) || (x === max - 1 && y === 0)) {

@@ -152,67 +157,68 @@ // No alignment patterns near the three finder patterns

return bitMatrix;
}
};
/*@Override*/
toString() {
Version.prototype.toString = function () {
return '' + this.versionNumber;
}
}
/**
* See ISO 18004:2006 Annex D.
* Element i represents the raw version bits that specify version i + 7
*/
Version.VERSION_DECODE_INFO = Int32Array.from([
0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6,
0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78,
0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683,
0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB,
0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250,
0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B,
0x2542E, 0x26A64, 0x27541, 0x28C69
]);
/**
* See ISO 18004:2006 6.5.1 Table 9
*/
Version.VERSIONS = [
new Version(1, new Int32Array(0), new ECBlocks_1.default(7, new ECB_1.default(1, 19)), new ECBlocks_1.default(10, new ECB_1.default(1, 16)), new ECBlocks_1.default(13, new ECB_1.default(1, 13)), new ECBlocks_1.default(17, new ECB_1.default(1, 9))),
new Version(2, Int32Array.from([6, 18]), new ECBlocks_1.default(10, new ECB_1.default(1, 34)), new ECBlocks_1.default(16, new ECB_1.default(1, 28)), new ECBlocks_1.default(22, new ECB_1.default(1, 22)), new ECBlocks_1.default(28, new ECB_1.default(1, 16))),
new Version(3, Int32Array.from([6, 22]), new ECBlocks_1.default(15, new ECB_1.default(1, 55)), new ECBlocks_1.default(26, new ECB_1.default(1, 44)), new ECBlocks_1.default(18, new ECB_1.default(2, 17)), new ECBlocks_1.default(22, new ECB_1.default(2, 13))),
new Version(4, Int32Array.from([6, 26]), new ECBlocks_1.default(20, new ECB_1.default(1, 80)), new ECBlocks_1.default(18, new ECB_1.default(2, 32)), new ECBlocks_1.default(26, new ECB_1.default(2, 24)), new ECBlocks_1.default(16, new ECB_1.default(4, 9))),
new Version(5, Int32Array.from([6, 30]), new ECBlocks_1.default(26, new ECB_1.default(1, 108)), new ECBlocks_1.default(24, new ECB_1.default(2, 43)), new ECBlocks_1.default(18, new ECB_1.default(2, 15), new ECB_1.default(2, 16)), new ECBlocks_1.default(22, new ECB_1.default(2, 11), new ECB_1.default(2, 12))),
new Version(6, Int32Array.from([6, 34]), new ECBlocks_1.default(18, new ECB_1.default(2, 68)), new ECBlocks_1.default(16, new ECB_1.default(4, 27)), new ECBlocks_1.default(24, new ECB_1.default(4, 19)), new ECBlocks_1.default(28, new ECB_1.default(4, 15))),
new Version(7, Int32Array.from([6, 22, 38]), new ECBlocks_1.default(20, new ECB_1.default(2, 78)), new ECBlocks_1.default(18, new ECB_1.default(4, 31)), new ECBlocks_1.default(18, new ECB_1.default(2, 14), new ECB_1.default(4, 15)), new ECBlocks_1.default(26, new ECB_1.default(4, 13), new ECB_1.default(1, 14))),
new Version(8, Int32Array.from([6, 24, 42]), new ECBlocks_1.default(24, new ECB_1.default(2, 97)), new ECBlocks_1.default(22, new ECB_1.default(2, 38), new ECB_1.default(2, 39)), new ECBlocks_1.default(22, new ECB_1.default(4, 18), new ECB_1.default(2, 19)), new ECBlocks_1.default(26, new ECB_1.default(4, 14), new ECB_1.default(2, 15))),
new Version(9, Int32Array.from([6, 26, 46]), new ECBlocks_1.default(30, new ECB_1.default(2, 116)), new ECBlocks_1.default(22, new ECB_1.default(3, 36), new ECB_1.default(2, 37)), new ECBlocks_1.default(20, new ECB_1.default(4, 16), new ECB_1.default(4, 17)), new ECBlocks_1.default(24, new ECB_1.default(4, 12), new ECB_1.default(4, 13))),
new Version(10, Int32Array.from([6, 28, 50]), new ECBlocks_1.default(18, new ECB_1.default(2, 68), new ECB_1.default(2, 69)), new ECBlocks_1.default(26, new ECB_1.default(4, 43), new ECB_1.default(1, 44)), new ECBlocks_1.default(24, new ECB_1.default(6, 19), new ECB_1.default(2, 20)), new ECBlocks_1.default(28, new ECB_1.default(6, 15), new ECB_1.default(2, 16))),
new Version(11, Int32Array.from([6, 30, 54]), new ECBlocks_1.default(20, new ECB_1.default(4, 81)), new ECBlocks_1.default(30, new ECB_1.default(1, 50), new ECB_1.default(4, 51)), new ECBlocks_1.default(28, new ECB_1.default(4, 22), new ECB_1.default(4, 23)), new ECBlocks_1.default(24, new ECB_1.default(3, 12), new ECB_1.default(8, 13))),
new Version(12, Int32Array.from([6, 32, 58]), new ECBlocks_1.default(24, new ECB_1.default(2, 92), new ECB_1.default(2, 93)), new ECBlocks_1.default(22, new ECB_1.default(6, 36), new ECB_1.default(2, 37)), new ECBlocks_1.default(26, new ECB_1.default(4, 20), new ECB_1.default(6, 21)), new ECBlocks_1.default(28, new ECB_1.default(7, 14), new ECB_1.default(4, 15))),
new Version(13, Int32Array.from([6, 34, 62]), new ECBlocks_1.default(26, new ECB_1.default(4, 107)), new ECBlocks_1.default(22, new ECB_1.default(8, 37), new ECB_1.default(1, 38)), new ECBlocks_1.default(24, new ECB_1.default(8, 20), new ECB_1.default(4, 21)), new ECBlocks_1.default(22, new ECB_1.default(12, 11), new ECB_1.default(4, 12))),
new Version(14, Int32Array.from([6, 26, 46, 66]), new ECBlocks_1.default(30, new ECB_1.default(3, 115), new ECB_1.default(1, 116)), new ECBlocks_1.default(24, new ECB_1.default(4, 40), new ECB_1.default(5, 41)), new ECBlocks_1.default(20, new ECB_1.default(11, 16), new ECB_1.default(5, 17)), new ECBlocks_1.default(24, new ECB_1.default(11, 12), new ECB_1.default(5, 13))),
new Version(15, Int32Array.from([6, 26, 48, 70]), new ECBlocks_1.default(22, new ECB_1.default(5, 87), new ECB_1.default(1, 88)), new ECBlocks_1.default(24, new ECB_1.default(5, 41), new ECB_1.default(5, 42)), new ECBlocks_1.default(30, new ECB_1.default(5, 24), new ECB_1.default(7, 25)), new ECBlocks_1.default(24, new ECB_1.default(11, 12), new ECB_1.default(7, 13))),
new Version(16, Int32Array.from([6, 26, 50, 74]), new ECBlocks_1.default(24, new ECB_1.default(5, 98), new ECB_1.default(1, 99)), new ECBlocks_1.default(28, new ECB_1.default(7, 45), new ECB_1.default(3, 46)), new ECBlocks_1.default(24, new ECB_1.default(15, 19), new ECB_1.default(2, 20)), new ECBlocks_1.default(30, new ECB_1.default(3, 15), new ECB_1.default(13, 16))),
new Version(17, Int32Array.from([6, 30, 54, 78]), new ECBlocks_1.default(28, new ECB_1.default(1, 107), new ECB_1.default(5, 108)), new ECBlocks_1.default(28, new ECB_1.default(10, 46), new ECB_1.default(1, 47)), new ECBlocks_1.default(28, new ECB_1.default(1, 22), new ECB_1.default(15, 23)), new ECBlocks_1.default(28, new ECB_1.default(2, 14), new ECB_1.default(17, 15))),
new Version(18, Int32Array.from([6, 30, 56, 82]), new ECBlocks_1.default(30, new ECB_1.default(5, 120), new ECB_1.default(1, 121)), new ECBlocks_1.default(26, new ECB_1.default(9, 43), new ECB_1.default(4, 44)), new ECBlocks_1.default(28, new ECB_1.default(17, 22), new ECB_1.default(1, 23)), new ECBlocks_1.default(28, new ECB_1.default(2, 14), new ECB_1.default(19, 15))),
new Version(19, Int32Array.from([6, 30, 58, 86]), new ECBlocks_1.default(28, new ECB_1.default(3, 113), new ECB_1.default(4, 114)), new ECBlocks_1.default(26, new ECB_1.default(3, 44), new ECB_1.default(11, 45)), new ECBlocks_1.default(26, new ECB_1.default(17, 21), new ECB_1.default(4, 22)), new ECBlocks_1.default(26, new ECB_1.default(9, 13), new ECB_1.default(16, 14))),
new Version(20, Int32Array.from([6, 34, 62, 90]), new ECBlocks_1.default(28, new ECB_1.default(3, 107), new ECB_1.default(5, 108)), new ECBlocks_1.default(26, new ECB_1.default(3, 41), new ECB_1.default(13, 42)), new ECBlocks_1.default(30, new ECB_1.default(15, 24), new ECB_1.default(5, 25)), new ECBlocks_1.default(28, new ECB_1.default(15, 15), new ECB_1.default(10, 16))),
new Version(21, Int32Array.from([6, 28, 50, 72, 94]), new ECBlocks_1.default(28, new ECB_1.default(4, 116), new ECB_1.default(4, 117)), new ECBlocks_1.default(26, new ECB_1.default(17, 42)), new ECBlocks_1.default(28, new ECB_1.default(17, 22), new ECB_1.default(6, 23)), new ECBlocks_1.default(30, new ECB_1.default(19, 16), new ECB_1.default(6, 17))),
new Version(22, Int32Array.from([6, 26, 50, 74, 98]), new ECBlocks_1.default(28, new ECB_1.default(2, 111), new ECB_1.default(7, 112)), new ECBlocks_1.default(28, new ECB_1.default(17, 46)), new ECBlocks_1.default(30, new ECB_1.default(7, 24), new ECB_1.default(16, 25)), new ECBlocks_1.default(24, new ECB_1.default(34, 13))),
new Version(23, Int32Array.from([6, 30, 54, 78, 102]), new ECBlocks_1.default(30, new ECB_1.default(4, 121), new ECB_1.default(5, 122)), new ECBlocks_1.default(28, new ECB_1.default(4, 47), new ECB_1.default(14, 48)), new ECBlocks_1.default(30, new ECB_1.default(11, 24), new ECB_1.default(14, 25)), new ECBlocks_1.default(30, new ECB_1.default(16, 15), new ECB_1.default(14, 16))),
new Version(24, Int32Array.from([6, 28, 54, 80, 106]), new ECBlocks_1.default(30, new ECB_1.default(6, 117), new ECB_1.default(4, 118)), new ECBlocks_1.default(28, new ECB_1.default(6, 45), new ECB_1.default(14, 46)), new ECBlocks_1.default(30, new ECB_1.default(11, 24), new ECB_1.default(16, 25)), new ECBlocks_1.default(30, new ECB_1.default(30, 16), new ECB_1.default(2, 17))),
new Version(25, Int32Array.from([6, 32, 58, 84, 110]), new ECBlocks_1.default(26, new ECB_1.default(8, 106), new ECB_1.default(4, 107)), new ECBlocks_1.default(28, new ECB_1.default(8, 47), new ECB_1.default(13, 48)), new ECBlocks_1.default(30, new ECB_1.default(7, 24), new ECB_1.default(22, 25)), new ECBlocks_1.default(30, new ECB_1.default(22, 15), new ECB_1.default(13, 16))),
new Version(26, Int32Array.from([6, 30, 58, 86, 114]), new ECBlocks_1.default(28, new ECB_1.default(10, 114), new ECB_1.default(2, 115)), new ECBlocks_1.default(28, new ECB_1.default(19, 46), new ECB_1.default(4, 47)), new ECBlocks_1.default(28, new ECB_1.default(28, 22), new ECB_1.default(6, 23)), new ECBlocks_1.default(30, new ECB_1.default(33, 16), new ECB_1.default(4, 17))),
new Version(27, Int32Array.from([6, 34, 62, 90, 118]), new ECBlocks_1.default(30, new ECB_1.default(8, 122), new ECB_1.default(4, 123)), new ECBlocks_1.default(28, new ECB_1.default(22, 45), new ECB_1.default(3, 46)), new ECBlocks_1.default(30, new ECB_1.default(8, 23), new ECB_1.default(26, 24)), new ECBlocks_1.default(30, new ECB_1.default(12, 15), new ECB_1.default(28, 16))),
new Version(28, Int32Array.from([6, 26, 50, 74, 98, 122]), new ECBlocks_1.default(30, new ECB_1.default(3, 117), new ECB_1.default(10, 118)), new ECBlocks_1.default(28, new ECB_1.default(3, 45), new ECB_1.default(23, 46)), new ECBlocks_1.default(30, new ECB_1.default(4, 24), new ECB_1.default(31, 25)), new ECBlocks_1.default(30, new ECB_1.default(11, 15), new ECB_1.default(31, 16))),
new Version(29, Int32Array.from([6, 30, 54, 78, 102, 126]), new ECBlocks_1.default(30, new ECB_1.default(7, 116), new ECB_1.default(7, 117)), new ECBlocks_1.default(28, new ECB_1.default(21, 45), new ECB_1.default(7, 46)), new ECBlocks_1.default(30, new ECB_1.default(1, 23), new ECB_1.default(37, 24)), new ECBlocks_1.default(30, new ECB_1.default(19, 15), new ECB_1.default(26, 16))),
new Version(30, Int32Array.from([6, 26, 52, 78, 104, 130]), new ECBlocks_1.default(30, new ECB_1.default(5, 115), new ECB_1.default(10, 116)), new ECBlocks_1.default(28, new ECB_1.default(19, 47), new ECB_1.default(10, 48)), new ECBlocks_1.default(30, new ECB_1.default(15, 24), new ECB_1.default(25, 25)), new ECBlocks_1.default(30, new ECB_1.default(23, 15), new ECB_1.default(25, 16))),
new Version(31, Int32Array.from([6, 30, 56, 82, 108, 134]), new ECBlocks_1.default(30, new ECB_1.default(13, 115), new ECB_1.default(3, 116)), new ECBlocks_1.default(28, new ECB_1.default(2, 46), new ECB_1.default(29, 47)), new ECBlocks_1.default(30, new ECB_1.default(42, 24), new ECB_1.default(1, 25)), new ECBlocks_1.default(30, new ECB_1.default(23, 15), new ECB_1.default(28, 16))),
new Version(32, Int32Array.from([6, 34, 60, 86, 112, 138]), new ECBlocks_1.default(30, new ECB_1.default(17, 115)), new ECBlocks_1.default(28, new ECB_1.default(10, 46), new ECB_1.default(23, 47)), new ECBlocks_1.default(30, new ECB_1.default(10, 24), new ECB_1.default(35, 25)), new ECBlocks_1.default(30, new ECB_1.default(19, 15), new ECB_1.default(35, 16))),
new Version(33, Int32Array.from([6, 30, 58, 86, 114, 142]), new ECBlocks_1.default(30, new ECB_1.default(17, 115), new ECB_1.default(1, 116)), new ECBlocks_1.default(28, new ECB_1.default(14, 46), new ECB_1.default(21, 47)), new ECBlocks_1.default(30, new ECB_1.default(29, 24), new ECB_1.default(19, 25)), new ECBlocks_1.default(30, new ECB_1.default(11, 15), new ECB_1.default(46, 16))),
new Version(34, Int32Array.from([6, 34, 62, 90, 118, 146]), new ECBlocks_1.default(30, new ECB_1.default(13, 115), new ECB_1.default(6, 116)), new ECBlocks_1.default(28, new ECB_1.default(14, 46), new ECB_1.default(23, 47)), new ECBlocks_1.default(30, new ECB_1.default(44, 24), new ECB_1.default(7, 25)), new ECBlocks_1.default(30, new ECB_1.default(59, 16), new ECB_1.default(1, 17))),
new Version(35, Int32Array.from([6, 30, 54, 78, 102, 126, 150]), new ECBlocks_1.default(30, new ECB_1.default(12, 121), new ECB_1.default(7, 122)), new ECBlocks_1.default(28, new ECB_1.default(12, 47), new ECB_1.default(26, 48)), new ECBlocks_1.default(30, new ECB_1.default(39, 24), new ECB_1.default(14, 25)), new ECBlocks_1.default(30, new ECB_1.default(22, 15), new ECB_1.default(41, 16))),
new Version(36, Int32Array.from([6, 24, 50, 76, 102, 128, 154]), new ECBlocks_1.default(30, new ECB_1.default(6, 121), new ECB_1.default(14, 122)), new ECBlocks_1.default(28, new ECB_1.default(6, 47), new ECB_1.default(34, 48)), new ECBlocks_1.default(30, new ECB_1.default(46, 24), new ECB_1.default(10, 25)), new ECBlocks_1.default(30, new ECB_1.default(2, 15), new ECB_1.default(64, 16))),
new Version(37, Int32Array.from([6, 28, 54, 80, 106, 132, 158]), new ECBlocks_1.default(30, new ECB_1.default(17, 122), new ECB_1.default(4, 123)), new ECBlocks_1.default(28, new ECB_1.default(29, 46), new ECB_1.default(14, 47)), new ECBlocks_1.default(30, new ECB_1.default(49, 24), new ECB_1.default(10, 25)), new ECBlocks_1.default(30, new ECB_1.default(24, 15), new ECB_1.default(46, 16))),
new Version(38, Int32Array.from([6, 32, 58, 84, 110, 136, 162]), new ECBlocks_1.default(30, new ECB_1.default(4, 122), new ECB_1.default(18, 123)), new ECBlocks_1.default(28, new ECB_1.default(13, 46), new ECB_1.default(32, 47)), new ECBlocks_1.default(30, new ECB_1.default(48, 24), new ECB_1.default(14, 25)), new ECBlocks_1.default(30, new ECB_1.default(42, 15), new ECB_1.default(32, 16))),
new Version(39, Int32Array.from([6, 26, 54, 82, 110, 138, 166]), new ECBlocks_1.default(30, new ECB_1.default(20, 117), new ECB_1.default(4, 118)), new ECBlocks_1.default(28, new ECB_1.default(40, 47), new ECB_1.default(7, 48)), new ECBlocks_1.default(30, new ECB_1.default(43, 24), new ECB_1.default(22, 25)), new ECBlocks_1.default(30, new ECB_1.default(10, 15), new ECB_1.default(67, 16))),
new Version(40, Int32Array.from([6, 30, 58, 86, 114, 142, 170]), new ECBlocks_1.default(30, new ECB_1.default(19, 118), new ECB_1.default(6, 119)), new ECBlocks_1.default(28, new ECB_1.default(18, 47), new ECB_1.default(31, 48)), new ECBlocks_1.default(30, new ECB_1.default(34, 24), new ECB_1.default(34, 25)), new ECBlocks_1.default(30, new ECB_1.default(20, 15), new ECB_1.default(61, 16)))
];
};
/**
* See ISO 18004:2006 Annex D.
* Element i represents the raw version bits that specify version i + 7
*/
Version.VERSION_DECODE_INFO = Int32Array.from([
0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6,
0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78,
0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683,
0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB,
0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250,
0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B,
0x2542E, 0x26A64, 0x27541, 0x28C69
]);
/**
* See ISO 18004:2006 6.5.1 Table 9
*/
Version.VERSIONS = [
new Version(1, new Int32Array(0), new ECBlocks_1.default(7, new ECB_1.default(1, 19)), new ECBlocks_1.default(10, new ECB_1.default(1, 16)), new ECBlocks_1.default(13, new ECB_1.default(1, 13)), new ECBlocks_1.default(17, new ECB_1.default(1, 9))),
new Version(2, Int32Array.from([6, 18]), new ECBlocks_1.default(10, new ECB_1.default(1, 34)), new ECBlocks_1.default(16, new ECB_1.default(1, 28)), new ECBlocks_1.default(22, new ECB_1.default(1, 22)), new ECBlocks_1.default(28, new ECB_1.default(1, 16))),
new Version(3, Int32Array.from([6, 22]), new ECBlocks_1.default(15, new ECB_1.default(1, 55)), new ECBlocks_1.default(26, new ECB_1.default(1, 44)), new ECBlocks_1.default(18, new ECB_1.default(2, 17)), new ECBlocks_1.default(22, new ECB_1.default(2, 13))),
new Version(4, Int32Array.from([6, 26]), new ECBlocks_1.default(20, new ECB_1.default(1, 80)), new ECBlocks_1.default(18, new ECB_1.default(2, 32)), new ECBlocks_1.default(26, new ECB_1.default(2, 24)), new ECBlocks_1.default(16, new ECB_1.default(4, 9))),
new Version(5, Int32Array.from([6, 30]), new ECBlocks_1.default(26, new ECB_1.default(1, 108)), new ECBlocks_1.default(24, new ECB_1.default(2, 43)), new ECBlocks_1.default(18, new ECB_1.default(2, 15), new ECB_1.default(2, 16)), new ECBlocks_1.default(22, new ECB_1.default(2, 11), new ECB_1.default(2, 12))),
new Version(6, Int32Array.from([6, 34]), new ECBlocks_1.default(18, new ECB_1.default(2, 68)), new ECBlocks_1.default(16, new ECB_1.default(4, 27)), new ECBlocks_1.default(24, new ECB_1.default(4, 19)), new ECBlocks_1.default(28, new ECB_1.default(4, 15))),
new Version(7, Int32Array.from([6, 22, 38]), new ECBlocks_1.default(20, new ECB_1.default(2, 78)), new ECBlocks_1.default(18, new ECB_1.default(4, 31)), new ECBlocks_1.default(18, new ECB_1.default(2, 14), new ECB_1.default(4, 15)), new ECBlocks_1.default(26, new ECB_1.default(4, 13), new ECB_1.default(1, 14))),
new Version(8, Int32Array.from([6, 24, 42]), new ECBlocks_1.default(24, new ECB_1.default(2, 97)), new ECBlocks_1.default(22, new ECB_1.default(2, 38), new ECB_1.default(2, 39)), new ECBlocks_1.default(22, new ECB_1.default(4, 18), new ECB_1.default(2, 19)), new ECBlocks_1.default(26, new ECB_1.default(4, 14), new ECB_1.default(2, 15))),
new Version(9, Int32Array.from([6, 26, 46]), new ECBlocks_1.default(30, new ECB_1.default(2, 116)), new ECBlocks_1.default(22, new ECB_1.default(3, 36), new ECB_1.default(2, 37)), new ECBlocks_1.default(20, new ECB_1.default(4, 16), new ECB_1.default(4, 17)), new ECBlocks_1.default(24, new ECB_1.default(4, 12), new ECB_1.default(4, 13))),
new Version(10, Int32Array.from([6, 28, 50]), new ECBlocks_1.default(18, new ECB_1.default(2, 68), new ECB_1.default(2, 69)), new ECBlocks_1.default(26, new ECB_1.default(4, 43), new ECB_1.default(1, 44)), new ECBlocks_1.default(24, new ECB_1.default(6, 19), new ECB_1.default(2, 20)), new ECBlocks_1.default(28, new ECB_1.default(6, 15), new ECB_1.default(2, 16))),
new Version(11, Int32Array.from([6, 30, 54]), new ECBlocks_1.default(20, new ECB_1.default(4, 81)), new ECBlocks_1.default(30, new ECB_1.default(1, 50), new ECB_1.default(4, 51)), new ECBlocks_1.default(28, new ECB_1.default(4, 22), new ECB_1.default(4, 23)), new ECBlocks_1.default(24, new ECB_1.default(3, 12), new ECB_1.default(8, 13))),
new Version(12, Int32Array.from([6, 32, 58]), new ECBlocks_1.default(24, new ECB_1.default(2, 92), new ECB_1.default(2, 93)), new ECBlocks_1.default(22, new ECB_1.default(6, 36), new ECB_1.default(2, 37)), new ECBlocks_1.default(26, new ECB_1.default(4, 20), new ECB_1.default(6, 21)), new ECBlocks_1.default(28, new ECB_1.default(7, 14), new ECB_1.default(4, 15))),
new Version(13, Int32Array.from([6, 34, 62]), new ECBlocks_1.default(26, new ECB_1.default(4, 107)), new ECBlocks_1.default(22, new ECB_1.default(8, 37), new ECB_1.default(1, 38)), new ECBlocks_1.default(24, new ECB_1.default(8, 20), new ECB_1.default(4, 21)), new ECBlocks_1.default(22, new ECB_1.default(12, 11), new ECB_1.default(4, 12))),
new Version(14, Int32Array.from([6, 26, 46, 66]), new ECBlocks_1.default(30, new ECB_1.default(3, 115), new ECB_1.default(1, 116)), new ECBlocks_1.default(24, new ECB_1.default(4, 40), new ECB_1.default(5, 41)), new ECBlocks_1.default(20, new ECB_1.default(11, 16), new ECB_1.default(5, 17)), new ECBlocks_1.default(24, new ECB_1.default(11, 12), new ECB_1.default(5, 13))),
new Version(15, Int32Array.from([6, 26, 48, 70]), new ECBlocks_1.default(22, new ECB_1.default(5, 87), new ECB_1.default(1, 88)), new ECBlocks_1.default(24, new ECB_1.default(5, 41), new ECB_1.default(5, 42)), new ECBlocks_1.default(30, new ECB_1.default(5, 24), new ECB_1.default(7, 25)), new ECBlocks_1.default(24, new ECB_1.default(11, 12), new ECB_1.default(7, 13))),
new Version(16, Int32Array.from([6, 26, 50, 74]), new ECBlocks_1.default(24, new ECB_1.default(5, 98), new ECB_1.default(1, 99)), new ECBlocks_1.default(28, new ECB_1.default(7, 45), new ECB_1.default(3, 46)), new ECBlocks_1.default(24, new ECB_1.default(15, 19), new ECB_1.default(2, 20)), new ECBlocks_1.default(30, new ECB_1.default(3, 15), new ECB_1.default(13, 16))),
new Version(17, Int32Array.from([6, 30, 54, 78]), new ECBlocks_1.default(28, new ECB_1.default(1, 107), new ECB_1.default(5, 108)), new ECBlocks_1.default(28, new ECB_1.default(10, 46), new ECB_1.default(1, 47)), new ECBlocks_1.default(28, new ECB_1.default(1, 22), new ECB_1.default(15, 23)), new ECBlocks_1.default(28, new ECB_1.default(2, 14), new ECB_1.default(17, 15))),
new Version(18, Int32Array.from([6, 30, 56, 82]), new ECBlocks_1.default(30, new ECB_1.default(5, 120), new ECB_1.default(1, 121)), new ECBlocks_1.default(26, new ECB_1.default(9, 43), new ECB_1.default(4, 44)), new ECBlocks_1.default(28, new ECB_1.default(17, 22), new ECB_1.default(1, 23)), new ECBlocks_1.default(28, new ECB_1.default(2, 14), new ECB_1.default(19, 15))),
new Version(19, Int32Array.from([6, 30, 58, 86]), new ECBlocks_1.default(28, new ECB_1.default(3, 113), new ECB_1.default(4, 114)), new ECBlocks_1.default(26, new ECB_1.default(3, 44), new ECB_1.default(11, 45)), new ECBlocks_1.default(26, new ECB_1.default(17, 21), new ECB_1.default(4, 22)), new ECBlocks_1.default(26, new ECB_1.default(9, 13), new ECB_1.default(16, 14))),
new Version(20, Int32Array.from([6, 34, 62, 90]), new ECBlocks_1.default(28, new ECB_1.default(3, 107), new ECB_1.default(5, 108)), new ECBlocks_1.default(26, new ECB_1.default(3, 41), new ECB_1.default(13, 42)), new ECBlocks_1.default(30, new ECB_1.default(15, 24), new ECB_1.default(5, 25)), new ECBlocks_1.default(28, new ECB_1.default(15, 15), new ECB_1.default(10, 16))),
new Version(21, Int32Array.from([6, 28, 50, 72, 94]), new ECBlocks_1.default(28, new ECB_1.default(4, 116), new ECB_1.default(4, 117)), new ECBlocks_1.default(26, new ECB_1.default(17, 42)), new ECBlocks_1.default(28, new ECB_1.default(17, 22), new ECB_1.default(6, 23)), new ECBlocks_1.default(30, new ECB_1.default(19, 16), new ECB_1.default(6, 17))),
new Version(22, Int32Array.from([6, 26, 50, 74, 98]), new ECBlocks_1.default(28, new ECB_1.default(2, 111), new ECB_1.default(7, 112)), new ECBlocks_1.default(28, new ECB_1.default(17, 46)), new ECBlocks_1.default(30, new ECB_1.default(7, 24), new ECB_1.default(16, 25)), new ECBlocks_1.default(24, new ECB_1.default(34, 13))),
new Version(23, Int32Array.from([6, 30, 54, 78, 102]), new ECBlocks_1.default(30, new ECB_1.default(4, 121), new ECB_1.default(5, 122)), new ECBlocks_1.default(28, new ECB_1.default(4, 47), new ECB_1.default(14, 48)), new ECBlocks_1.default(30, new ECB_1.default(11, 24), new ECB_1.default(14, 25)), new ECBlocks_1.default(30, new ECB_1.default(16, 15), new ECB_1.default(14, 16))),
new Version(24, Int32Array.from([6, 28, 54, 80, 106]), new ECBlocks_1.default(30, new ECB_1.default(6, 117), new ECB_1.default(4, 118)), new ECBlocks_1.default(28, new ECB_1.default(6, 45), new ECB_1.default(14, 46)), new ECBlocks_1.default(30, new ECB_1.default(11, 24), new ECB_1.default(16, 25)), new ECBlocks_1.default(30, new ECB_1.default(30, 16), new ECB_1.default(2, 17))),
new Version(25, Int32Array.from([6, 32, 58, 84, 110]), new ECBlocks_1.default(26, new ECB_1.default(8, 106), new ECB_1.default(4, 107)), new ECBlocks_1.default(28, new ECB_1.default(8, 47), new ECB_1.default(13, 48)), new ECBlocks_1.default(30, new ECB_1.default(7, 24), new ECB_1.default(22, 25)), new ECBlocks_1.default(30, new ECB_1.default(22, 15), new ECB_1.default(13, 16))),
new Version(26, Int32Array.from([6, 30, 58, 86, 114]), new ECBlocks_1.default(28, new ECB_1.default(10, 114), new ECB_1.default(2, 115)), new ECBlocks_1.default(28, new ECB_1.default(19, 46), new ECB_1.default(4, 47)), new ECBlocks_1.default(28, new ECB_1.default(28, 22), new ECB_1.default(6, 23)), new ECBlocks_1.default(30, new ECB_1.default(33, 16), new ECB_1.default(4, 17))),
new Version(27, Int32Array.from([6, 34, 62, 90, 118]), new ECBlocks_1.default(30, new ECB_1.default(8, 122), new ECB_1.default(4, 123)), new ECBlocks_1.default(28, new ECB_1.default(22, 45), new ECB_1.default(3, 46)), new ECBlocks_1.default(30, new ECB_1.default(8, 23), new ECB_1.default(26, 24)), new ECBlocks_1.default(30, new ECB_1.default(12, 15), new ECB_1.default(28, 16))),
new Version(28, Int32Array.from([6, 26, 50, 74, 98, 122]), new ECBlocks_1.default(30, new ECB_1.default(3, 117), new ECB_1.default(10, 118)), new ECBlocks_1.default(28, new ECB_1.default(3, 45), new ECB_1.default(23, 46)), new ECBlocks_1.default(30, new ECB_1.default(4, 24), new ECB_1.default(31, 25)), new ECBlocks_1.default(30, new ECB_1.default(11, 15), new ECB_1.default(31, 16))),
new Version(29, Int32Array.from([6, 30, 54, 78, 102, 126]), new ECBlocks_1.default(30, new ECB_1.default(7, 116), new ECB_1.default(7, 117)), new ECBlocks_1.default(28, new ECB_1.default(21, 45), new ECB_1.default(7, 46)), new ECBlocks_1.default(30, new ECB_1.default(1, 23), new ECB_1.default(37, 24)), new ECBlocks_1.default(30, new ECB_1.default(19, 15), new ECB_1.default(26, 16))),
new Version(30, Int32Array.from([6, 26, 52, 78, 104, 130]), new ECBlocks_1.default(30, new ECB_1.default(5, 115), new ECB_1.default(10, 116)), new ECBlocks_1.default(28, new ECB_1.default(19, 47), new ECB_1.default(10, 48)), new ECBlocks_1.default(30, new ECB_1.default(15, 24), new ECB_1.default(25, 25)), new ECBlocks_1.default(30, new ECB_1.default(23, 15), new ECB_1.default(25, 16))),
new Version(31, Int32Array.from([6, 30, 56, 82, 108, 134]), new ECBlocks_1.default(30, new ECB_1.default(13, 115), new ECB_1.default(3, 116)), new ECBlocks_1.default(28, new ECB_1.default(2, 46), new ECB_1.default(29, 47)), new ECBlocks_1.default(30, new ECB_1.default(42, 24), new ECB_1.default(1, 25)), new ECBlocks_1.default(30, new ECB_1.default(23, 15), new ECB_1.default(28, 16))),
new Version(32, Int32Array.from([6, 34, 60, 86, 112, 138]), new ECBlocks_1.default(30, new ECB_1.default(17, 115)), new ECBlocks_1.default(28, new ECB_1.default(10, 46), new ECB_1.default(23, 47)), new ECBlocks_1.default(30, new ECB_1.default(10, 24), new ECB_1.default(35, 25)), new ECBlocks_1.default(30, new ECB_1.default(19, 15), new ECB_1.default(35, 16))),
new Version(33, Int32Array.from([6, 30, 58, 86, 114, 142]), new ECBlocks_1.default(30, new ECB_1.default(17, 115), new ECB_1.default(1, 116)), new ECBlocks_1.default(28, new ECB_1.default(14, 46), new ECB_1.default(21, 47)), new ECBlocks_1.default(30, new ECB_1.default(29, 24), new ECB_1.default(19, 25)), new ECBlocks_1.default(30, new ECB_1.default(11, 15), new ECB_1.default(46, 16))),
new Version(34, Int32Array.from([6, 34, 62, 90, 118, 146]), new ECBlocks_1.default(30, new ECB_1.default(13, 115), new ECB_1.default(6, 116)), new ECBlocks_1.default(28, new ECB_1.default(14, 46), new ECB_1.default(23, 47)), new ECBlocks_1.default(30, new ECB_1.default(44, 24), new ECB_1.default(7, 25)), new ECBlocks_1.default(30, new ECB_1.default(59, 16), new ECB_1.default(1, 17))),
new Version(35, Int32Array.from([6, 30, 54, 78, 102, 126, 150]), new ECBlocks_1.default(30, new ECB_1.default(12, 121), new ECB_1.default(7, 122)), new ECBlocks_1.default(28, new ECB_1.default(12, 47), new ECB_1.default(26, 48)), new ECBlocks_1.default(30, new ECB_1.default(39, 24), new ECB_1.default(14, 25)), new ECBlocks_1.default(30, new ECB_1.default(22, 15), new ECB_1.default(41, 16))),
new Version(36, Int32Array.from([6, 24, 50, 76, 102, 128, 154]), new ECBlocks_1.default(30, new ECB_1.default(6, 121), new ECB_1.default(14, 122)), new ECBlocks_1.default(28, new ECB_1.default(6, 47), new ECB_1.default(34, 48)), new ECBlocks_1.default(30, new ECB_1.default(46, 24), new ECB_1.default(10, 25)), new ECBlocks_1.default(30, new ECB_1.default(2, 15), new ECB_1.default(64, 16))),
new Version(37, Int32Array.from([6, 28, 54, 80, 106, 132, 158]), new ECBlocks_1.default(30, new ECB_1.default(17, 122), new ECB_1.default(4, 123)), new ECBlocks_1.default(28, new ECB_1.default(29, 46), new ECB_1.default(14, 47)), new ECBlocks_1.default(30, new ECB_1.default(49, 24), new ECB_1.default(10, 25)), new ECBlocks_1.default(30, new ECB_1.default(24, 15), new ECB_1.default(46, 16))),
new Version(38, Int32Array.from([6, 32, 58, 84, 110, 136, 162]), new ECBlocks_1.default(30, new ECB_1.default(4, 122), new ECB_1.default(18, 123)), new ECBlocks_1.default(28, new ECB_1.default(13, 46), new ECB_1.default(32, 47)), new ECBlocks_1.default(30, new ECB_1.default(48, 24), new ECB_1.default(14, 25)), new ECBlocks_1.default(30, new ECB_1.default(42, 15), new ECB_1.default(32, 16))),
new Version(39, Int32Array.from([6, 26, 54, 82, 110, 138, 166]), new ECBlocks_1.default(30, new ECB_1.default(20, 117), new ECB_1.default(4, 118)), new ECBlocks_1.default(28, new ECB_1.default(40, 47), new ECB_1.default(7, 48)), new ECBlocks_1.default(30, new ECB_1.default(43, 24), new ECB_1.default(22, 25)), new ECBlocks_1.default(30, new ECB_1.default(10, 15), new ECB_1.default(67, 16))),
new Version(40, Int32Array.from([6, 30, 58, 86, 114, 142, 170]), new ECBlocks_1.default(30, new ECB_1.default(19, 118), new ECB_1.default(6, 119)), new ECBlocks_1.default(28, new ECB_1.default(18, 47), new ECB_1.default(31, 48)), new ECBlocks_1.default(30, new ECB_1.default(34, 24), new ECB_1.default(34, 25)), new ECBlocks_1.default(30, new ECB_1.default(20, 15), new ECB_1.default(61, 16)))
];
return Version;
}());
exports.default = Version;
//# sourceMappingURL=Version.js.map

@@ -17,5 +17,15 @@ "use strict";

*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
/*namespace com.google.zxing.qrcode.detector {*/
const ResultPoint_1 = require("./../../ResultPoint");
var ResultPoint_1 = require("./../../ResultPoint");
/**

@@ -27,6 +37,8 @@ * <p>Encapsulates an alignment pattern, which are the smaller square patterns found in

*/
class AlignmentPattern extends ResultPoint_1.default {
constructor(posX /*float*/, posY /*float*/, estimatedModuleSize /*float*/) {
super(posX, posY);
this.estimatedModuleSize = estimatedModuleSize; /*float*/
var AlignmentPattern = /** @class */ (function (_super) {
__extends(AlignmentPattern, _super);
function AlignmentPattern(posX /*float*/, posY /*float*/, estimatedModuleSize /*float*/) {
var _this = _super.call(this, posX, posY) || this;
_this.estimatedModuleSize = estimatedModuleSize; /*float*/
return _this;
}

@@ -37,9 +49,9 @@ /**

*/
aboutEquals(moduleSize /*float*/, i /*float*/, j /*float*/) {
AlignmentPattern.prototype.aboutEquals = function (moduleSize /*float*/, i /*float*/, j /*float*/) {
if (Math.abs(i - this.getY()) <= moduleSize && Math.abs(j - this.getX()) <= moduleSize) {
const moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize);
var moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize);
return moduleSizeDiff <= 1.0 || moduleSizeDiff <= this.estimatedModuleSize;
}
return false;
}
};
/**

@@ -49,10 +61,11 @@ * Combines this object's current estimate of a finder pattern position and module size

*/
combineEstimate(i /*float*/, j /*float*/, newModuleSize /*float*/) {
const combinedX = (this.getX() + j) / 2.0;
const combinedY = (this.getY() + i) / 2.0;
const combinedModuleSize = (this.estimatedModuleSize + newModuleSize) / 2.0;
AlignmentPattern.prototype.combineEstimate = function (i /*float*/, j /*float*/, newModuleSize /*float*/) {
var combinedX = (this.getX() + j) / 2.0;
var combinedY = (this.getY() + i) / 2.0;
var combinedModuleSize = (this.estimatedModuleSize + newModuleSize) / 2.0;
return new AlignmentPattern(combinedX, combinedY, combinedModuleSize);
}
}
};
return AlignmentPattern;
}(ResultPoint_1.default));
exports.default = AlignmentPattern;
//# sourceMappingURL=AlignmentPattern.js.map

@@ -18,4 +18,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const AlignmentPattern_1 = require("./AlignmentPattern");
const Exception_1 = require("./../../Exception");
var AlignmentPattern_1 = require("./AlignmentPattern");
var Exception_1 = require("./../../Exception");
/*import java.util.ArrayList;*/

@@ -37,3 +37,3 @@ /*import java.util.List;*/

*/
class AlignmentPatternFinder {
var AlignmentPatternFinder = /** @class */ (function () {
/**

@@ -49,3 +49,3 @@ * <p>Creates a finder that will look in a portion of the whole image.</p>

*/
constructor(image, startX /*int*/, startY /*int*/, width /*int*/, height /*int*/, moduleSize /*float*/, resultPointCallback) {
function AlignmentPatternFinder(image, startX /*int*/, startY /*int*/, width /*int*/, height /*int*/, moduleSize /*float*/, resultPointCallback) {
this.image = image;

@@ -69,19 +69,19 @@ this.startX = startX; /*int*/

*/
find() {
const startX = this.startX;
const height = this.height;
const width = this.width;
const maxJ = startX + width;
const middleI = this.startY + (height / 2);
AlignmentPatternFinder.prototype.find = function () {
var startX = this.startX;
var height = this.height;
var width = this.width;
var maxJ = startX + width;
var middleI = this.startY + (height / 2);
// We are looking for black/white/black modules in 1:1:1 ratio
// this tracks the number of black/white/black modules seen so far
const stateCount = new Int32Array(3);
const image = this.image;
for (let iGen = 0; iGen < height; iGen++) {
var stateCount = new Int32Array(3);
var image = this.image;
for (var iGen = 0; iGen < height; iGen++) {
// Search from middle outwards
const i = middleI + ((iGen & 0x01) === 0 ? Math.floor((iGen + 1) / 2) : -Math.floor((iGen + 1) / 2));
var i = middleI + ((iGen & 0x01) === 0 ? Math.floor((iGen + 1) / 2) : -Math.floor((iGen + 1) / 2));
stateCount[0] = 0;
stateCount[1] = 0;
stateCount[2] = 0;
let j = startX;
var j = startX;
// Burn off leading white pixels before anything else; if we start in the middle of

@@ -93,3 +93,3 @@ // a white run, it doesn't make sense to count its length, since we don't know if the

}
let currentState = 0;
var currentState = 0;
while (j < maxJ) {

@@ -104,3 +104,3 @@ if (image.get(j, i)) {

if (this.foundPatternCross(stateCount)) {
const confirmed = this.handlePossibleCenter(stateCount, i, j);
var confirmed = this.handlePossibleCenter(stateCount, i, j);
if (confirmed !== null) {

@@ -129,3 +129,3 @@ return confirmed;

if (this.foundPatternCross(stateCount)) {
const confirmed = this.handlePossibleCenter(stateCount, i, maxJ);
var confirmed = this.handlePossibleCenter(stateCount, i, maxJ);
if (confirmed !== null) {

@@ -142,3 +142,3 @@ return confirmed;

throw new Exception_1.default(Exception_1.default.NotFoundException);
}
};
/**

@@ -148,5 +148,5 @@ * Given a count of black/white/black pixels just seen and an end position,

*/
static centerFromEnd(stateCount, end /*int*/) {
AlignmentPatternFinder.centerFromEnd = function (stateCount, end /*int*/) {
return (end - stateCount[2]) - stateCount[1] / 2.0;
}
};
/**

@@ -157,6 +157,6 @@ * @param stateCount count of black/white/black pixels just read

*/
foundPatternCross(stateCount) {
const moduleSize = this.moduleSize;
const maxVariance = moduleSize / 2.0;
for (let i = 0; i < 3; i++) {
AlignmentPatternFinder.prototype.foundPatternCross = function (stateCount) {
var moduleSize = this.moduleSize;
var maxVariance = moduleSize / 2.0;
for (var i = 0; i < 3; i++) {
if (Math.abs(moduleSize - stateCount[i]) >= maxVariance) {

@@ -167,3 +167,3 @@ return false;

return true;
}
};
/**

@@ -180,6 +180,6 @@ * <p>After a horizontal scan finds a potential alignment pattern, this method

*/
crossCheckVertical(startI /*int*/, centerJ /*int*/, maxCount /*int*/, originalStateCountTotal /*int*/) {
const image = this.image;
const maxI = image.getHeight();
const stateCount = this.crossCheckStateCount;
AlignmentPatternFinder.prototype.crossCheckVertical = function (startI /*int*/, centerJ /*int*/, maxCount /*int*/, originalStateCountTotal /*int*/) {
var image = this.image;
var maxI = image.getHeight();
var stateCount = this.crossCheckStateCount;
stateCount[0] = 0;

@@ -189,3 +189,3 @@ stateCount[1] = 0;

// Start counting up from center
let i = startI;
var i = startI;
while (i >= 0 && image.get(centerJ, i) && stateCount[1] <= maxCount) {

@@ -222,3 +222,3 @@ stateCount[1]++;

}
const stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) {

@@ -228,3 +228,3 @@ return NaN;

return this.foundPatternCross(stateCount) ? AlignmentPatternFinder.centerFromEnd(stateCount, i) : NaN;
}
};
/**

@@ -241,9 +241,10 @@ * <p>This is called when a horizontal scan finds a possible alignment pattern. It will

*/
handlePossibleCenter(stateCount, i /*int*/, j /*int*/) {
const stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
const centerJ = AlignmentPatternFinder.centerFromEnd(stateCount, j);
const centerI = this.crossCheckVertical(i, /*(int) */ centerJ, 2 * stateCount[1], stateCountTotal);
AlignmentPatternFinder.prototype.handlePossibleCenter = function (stateCount, i /*int*/, j /*int*/) {
var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
var centerJ = AlignmentPatternFinder.centerFromEnd(stateCount, j);
var centerI = this.crossCheckVertical(i, /*(int) */ centerJ, 2 * stateCount[1], stateCountTotal);
if (!isNaN(centerI)) {
const estimatedModuleSize = (stateCount[0] + stateCount[1] + stateCount[2]) / 3.0;
for (const center of this.possibleCenters) {
var estimatedModuleSize = (stateCount[0] + stateCount[1] + stateCount[2]) / 3.0;
for (var _i = 0, _a = this.possibleCenters; _i < _a.length; _i++) {
var center = _a[_i];
// Look for about the same center and module size:

@@ -255,3 +256,3 @@ if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) {

// Hadn't found this before; save it
const point = new AlignmentPattern_1.default(centerJ, centerI, estimatedModuleSize);
var point = new AlignmentPattern_1.default(centerJ, centerI, estimatedModuleSize);
this.possibleCenters.push(point);

@@ -263,5 +264,6 @@ if (this.resultPointCallback !== null && this.resultPointCallback !== undefined) {

return null;
}
}
};
return AlignmentPatternFinder;
}());
exports.default = AlignmentPatternFinder;
//# sourceMappingURL=AlignmentPatternFinder.js.map

@@ -18,11 +18,11 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const ResultPoint_1 = require("./../../ResultPoint");
const DetectorResult_1 = require("./../../common/DetectorResult");
const GridSamplerInstance_1 = require("./../../common/GridSamplerInstance");
const PerspectiveTransform_1 = require("./../../common/PerspectiveTransform");
const MathUtils_1 = require("./../../common/detector/MathUtils");
const Version_1 = require("./../decoder/Version");
const FinderPatternFinder_1 = require("./FinderPatternFinder");
const Exception_1 = require("./../../Exception");
const AlignmentPatternFinder_1 = require("./AlignmentPatternFinder");
var ResultPoint_1 = require("./../../ResultPoint");
var DetectorResult_1 = require("./../../common/DetectorResult");
var GridSamplerInstance_1 = require("./../../common/GridSamplerInstance");
var PerspectiveTransform_1 = require("./../../common/PerspectiveTransform");
var MathUtils_1 = require("./../../common/detector/MathUtils");
var Version_1 = require("./../decoder/Version");
var FinderPatternFinder_1 = require("./FinderPatternFinder");
var Exception_1 = require("./../../Exception");
var AlignmentPatternFinder_1 = require("./AlignmentPatternFinder");
/*import java.util.Map;*/

@@ -35,12 +35,12 @@ /**

*/
class Detector {
constructor(image) {
var Detector = /** @class */ (function () {
function Detector(image) {
this.image = image;
}
getImage() {
Detector.prototype.getImage = function () {
return this.image;
}
getResultPointCallback() {
};
Detector.prototype.getResultPointCallback = function () {
return this.resultPointCallback;
}
};
/**

@@ -64,33 +64,33 @@ * <p>Detects a QR Code in an image.</p>

*/
detect(hints) {
Detector.prototype.detect = function (hints) {
this.resultPointCallback = (hints === null || hints === undefined) ? null :
/*(ResultPointCallback) */ hints.get(9 /* NEED_RESULT_POINT_CALLBACK */);
const finder = new FinderPatternFinder_1.default(this.image, this.resultPointCallback);
const info = finder.find(hints);
var finder = new FinderPatternFinder_1.default(this.image, this.resultPointCallback);
var info = finder.find(hints);
return this.processFinderPatternInfo(info);
}
processFinderPatternInfo(info) {
const topLeft = info.getTopLeft();
const topRight = info.getTopRight();
const bottomLeft = info.getBottomLeft();
const moduleSize = this.calculateModuleSize(topLeft, topRight, bottomLeft);
};
Detector.prototype.processFinderPatternInfo = function (info) {
var topLeft = info.getTopLeft();
var topRight = info.getTopRight();
var bottomLeft = info.getBottomLeft();
var moduleSize = this.calculateModuleSize(topLeft, topRight, bottomLeft);
if (moduleSize < 1.0) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
}
const dimension = Detector.computeDimension(topLeft, topRight, bottomLeft, moduleSize);
const provisionalVersion = Version_1.default.getProvisionalVersionForDimension(dimension);
const modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;
let alignmentPattern = null;
var dimension = Detector.computeDimension(topLeft, topRight, bottomLeft, moduleSize);
var provisionalVersion = Version_1.default.getProvisionalVersionForDimension(dimension);
var modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;
var alignmentPattern = null;
// Anything above version 1 has an alignment pattern
if (provisionalVersion.getAlignmentPatternCenters().length > 0) {
// Guess where a "bottom right" finder pattern would have been
const bottomRightX = topRight.getX() - topLeft.getX() + bottomLeft.getX();
const bottomRightY = topRight.getY() - topLeft.getY() + bottomLeft.getY();
var bottomRightX = topRight.getX() - topLeft.getX() + bottomLeft.getX();
var bottomRightY = topRight.getY() - topLeft.getY() + bottomLeft.getY();
// Estimate that alignment pattern is closer by 3 modules
// from "bottom right" to known top left location
const correctionToTopLeft = 1.0 - 3.0 / modulesBetweenFPCenters;
const estAlignmentX = Math.floor(topLeft.getX() + correctionToTopLeft * (bottomRightX - topLeft.getX()));
const estAlignmentY = Math.floor(topLeft.getY() + correctionToTopLeft * (bottomRightY - topLeft.getY()));
var correctionToTopLeft = 1.0 - 3.0 / modulesBetweenFPCenters;
var estAlignmentX = Math.floor(topLeft.getX() + correctionToTopLeft * (bottomRightX - topLeft.getX()));
var estAlignmentY = Math.floor(topLeft.getY() + correctionToTopLeft * (bottomRightY - topLeft.getY()));
// Kind of arbitrary -- expand search radius before giving up
for (let i = 4; i <= 16; i <<= 1) {
for (var i = 4; i <= 16; i <<= 1) {
try {

@@ -109,5 +109,5 @@ alignmentPattern = this.findAlignmentInRegion(moduleSize, estAlignmentX, estAlignmentY, i);

}
const transform = Detector.createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);
const bits = Detector.sampleGrid(this.image, transform, dimension);
let points;
var transform = Detector.createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);
var bits = Detector.sampleGrid(this.image, transform, dimension);
var points;
if (alignmentPattern === null) {

@@ -120,9 +120,9 @@ points = [bottomLeft, topLeft, topRight];

return new DetectorResult_1.default(bits, points);
}
static createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension /*int*/) {
const dimMinusThree = dimension - 3.5;
let bottomRightX; /*float*/
let bottomRightY; /*float*/
let sourceBottomRightX; /*float*/
let sourceBottomRightY; /*float*/
};
Detector.createTransform = function (topLeft, topRight, bottomLeft, alignmentPattern, dimension /*int*/) {
var dimMinusThree = dimension - 3.5;
var bottomRightX; /*float*/
var bottomRightY; /*float*/
var sourceBottomRightX; /*float*/
var sourceBottomRightY; /*float*/
if (alignmentPattern !== null) {

@@ -142,7 +142,7 @@ bottomRightX = alignmentPattern.getX();

return PerspectiveTransform_1.default.quadrilateralToQuadrilateral(3.5, 3.5, dimMinusThree, 3.5, sourceBottomRightX, sourceBottomRightY, 3.5, dimMinusThree, topLeft.getX(), topLeft.getY(), topRight.getX(), topRight.getY(), bottomRightX, bottomRightY, bottomLeft.getX(), bottomLeft.getY());
}
static sampleGrid(image, transform, dimension /*int*/) {
const sampler = GridSamplerInstance_1.default.getInstance();
};
Detector.sampleGrid = function (image, transform, dimension /*int*/) {
var sampler = GridSamplerInstance_1.default.getInstance();
return sampler.sampleGridWithTransform(image, dimension, dimension, transform);
}
};
/**

@@ -152,6 +152,6 @@ * <p>Computes the dimension (number of modules on a size) of the QR Code based on the position

*/
static computeDimension(topLeft, topRight, bottomLeft, moduleSize /*float*/) {
const tltrCentersDimension = MathUtils_1.default.round(ResultPoint_1.default.distance(topLeft, topRight) / moduleSize);
const tlblCentersDimension = MathUtils_1.default.round(ResultPoint_1.default.distance(topLeft, bottomLeft) / moduleSize);
let dimension = Math.floor((tltrCentersDimension + tlblCentersDimension) / 2) + 7;
Detector.computeDimension = function (topLeft, topRight, bottomLeft, moduleSize /*float*/) {
var tltrCentersDimension = MathUtils_1.default.round(ResultPoint_1.default.distance(topLeft, topRight) / moduleSize);
var tlblCentersDimension = MathUtils_1.default.round(ResultPoint_1.default.distance(topLeft, bottomLeft) / moduleSize);
var dimension = Math.floor((tltrCentersDimension + tlblCentersDimension) / 2) + 7;
switch (dimension & 0x03) {

@@ -169,3 +169,3 @@ case 0:

return dimension;
}
};
/**

@@ -180,7 +180,7 @@ * <p>Computes an average estimated module size based on estimated derived from the positions

*/
calculateModuleSize(topLeft, topRight, bottomLeft) {
Detector.prototype.calculateModuleSize = function (topLeft, topRight, bottomLeft) {
// Take the average
return (this.calculateModuleSizeOneWay(topLeft, topRight) +
this.calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0;
}
};
/**

@@ -191,8 +191,8 @@ * <p>Estimates module size based on two finder patterns -- it uses

*/
calculateModuleSizeOneWay(pattern, otherPattern) {
const moduleSizeEst1 = this.sizeOfBlackWhiteBlackRunBothWays(/*(int) */ Math.floor(pattern.getX()),
Detector.prototype.calculateModuleSizeOneWay = function (pattern, otherPattern) {
var moduleSizeEst1 = this.sizeOfBlackWhiteBlackRunBothWays(/*(int) */ Math.floor(pattern.getX()),
/*(int) */ Math.floor(pattern.getY()),
/*(int) */ Math.floor(otherPattern.getX()),
/*(int) */ Math.floor(otherPattern.getY()));
const moduleSizeEst2 = this.sizeOfBlackWhiteBlackRunBothWays(/*(int) */ Math.floor(otherPattern.getX()),
var moduleSizeEst2 = this.sizeOfBlackWhiteBlackRunBothWays(/*(int) */ Math.floor(otherPattern.getX()),
/*(int) */ Math.floor(otherPattern.getY()),

@@ -210,3 +210,3 @@ /*(int) */ Math.floor(pattern.getX()),

return (moduleSizeEst1 + moduleSizeEst2) / 14.0;
}
};
/**

@@ -217,7 +217,7 @@ * See {@link #sizeOfBlackWhiteBlackRun(int, int, int, int)}; computes the total width of

*/
sizeOfBlackWhiteBlackRunBothWays(fromX /*int*/, fromY /*int*/, toX /*int*/, toY /*int*/) {
let result = this.sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY);
Detector.prototype.sizeOfBlackWhiteBlackRunBothWays = function (fromX /*int*/, fromY /*int*/, toX /*int*/, toY /*int*/) {
var result = this.sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY);
// Now count other way -- don't run off image though of course
let scale = 1.0;
let otherToX = fromX - (toX - fromX);
var scale = 1.0;
var otherToX = fromX - (toX - fromX);
if (otherToX < 0) {

@@ -231,3 +231,3 @@ scale = fromX / /*(float) */ (fromX - otherToX);

}
let otherToY = Math.floor(fromY - (toY - fromY) * scale);
var otherToY = Math.floor(fromY - (toY - fromY) * scale);
scale = 1.0;

@@ -246,3 +246,3 @@ if (otherToY < 0) {

return result - 1.0;
}
};
/**

@@ -256,8 +256,8 @@ * <p>This method traces a line from a point in the image, in the direction towards another point.

*/
sizeOfBlackWhiteBlackRun(fromX /*int*/, fromY /*int*/, toX /*int*/, toY /*int*/) {
Detector.prototype.sizeOfBlackWhiteBlackRun = function (fromX /*int*/, fromY /*int*/, toX /*int*/, toY /*int*/) {
// Mild variant of Bresenham's algorithm
// see http://en.wikipedia.org/wiki/Bresenham's_line_algorithm
const steep = Math.abs(toY - fromY) > Math.abs(toX - fromX);
var steep = Math.abs(toY - fromY) > Math.abs(toX - fromX);
if (steep) {
let temp = fromX;
var temp = fromX;
fromX = fromY;

@@ -269,14 +269,14 @@ fromY = temp;

}
const dx = Math.abs(toX - fromX);
const dy = Math.abs(toY - fromY);
let error = -dx / 2;
const xstep = fromX < toX ? 1 : -1;
const ystep = fromY < toY ? 1 : -1;
var dx = Math.abs(toX - fromX);
var dy = Math.abs(toY - fromY);
var error = -dx / 2;
var xstep = fromX < toX ? 1 : -1;
var ystep = fromY < toY ? 1 : -1;
// In black pixels, looking for white, first or second time.
let state = 0;
var state = 0;
// Loop up until x == toX, but not beyond
const xLimit = toX + xstep;
for (let x = fromX, y = fromY; x !== xLimit; x += xstep) {
const realX = steep ? y : x;
const realY = steep ? x : y;
var xLimit = toX + xstep;
for (var x = fromX, y = fromY; x !== xLimit; x += xstep) {
var realX = steep ? y : x;
var realY = steep ? x : y;
// Does current pixel mean we have moved white to black or vice versa?

@@ -308,3 +308,3 @@ // Scanning black in state 0,2 and white in state 1, so if we find the wrong

return NaN;
}
};
/**

@@ -321,21 +321,22 @@ * <p>Attempts to locate an alignment pattern in a limited region of the image, which is

*/
findAlignmentInRegion(overallEstModuleSize /*float*/, estAlignmentX /*int*/, estAlignmentY /*int*/, allowanceFactor /*float*/) {
Detector.prototype.findAlignmentInRegion = function (overallEstModuleSize /*float*/, estAlignmentX /*int*/, estAlignmentY /*int*/, allowanceFactor /*float*/) {
// Look for an alignment pattern (3 modules in size) around where it
// should be
const allowance = Math.floor(allowanceFactor * overallEstModuleSize);
const alignmentAreaLeftX = Math.max(0, estAlignmentX - allowance);
const alignmentAreaRightX = Math.min(this.image.getWidth() - 1, estAlignmentX + allowance);
var allowance = Math.floor(allowanceFactor * overallEstModuleSize);
var alignmentAreaLeftX = Math.max(0, estAlignmentX - allowance);
var alignmentAreaRightX = Math.min(this.image.getWidth() - 1, estAlignmentX + allowance);
if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
}
const alignmentAreaTopY = Math.max(0, estAlignmentY - allowance);
const alignmentAreaBottomY = Math.min(this.image.getHeight() - 1, estAlignmentY + allowance);
var alignmentAreaTopY = Math.max(0, estAlignmentY - allowance);
var alignmentAreaBottomY = Math.min(this.image.getHeight() - 1, estAlignmentY + allowance);
if (alignmentAreaBottomY - alignmentAreaTopY < overallEstModuleSize * 3) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
}
const alignmentFinder = new AlignmentPatternFinder_1.default(this.image, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, this.resultPointCallback);
var alignmentFinder = new AlignmentPatternFinder_1.default(this.image, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, this.resultPointCallback);
return alignmentFinder.find();
}
}
};
return Detector;
}());
exports.default = Detector;
//# sourceMappingURL=Detector.js.map

@@ -17,5 +17,15 @@ "use strict";

*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
/*namespace com.google.zxing.qrcode.detector {*/
const ResultPoint_1 = require("./../../ResultPoint");
var ResultPoint_1 = require("./../../ResultPoint");
/**

@@ -28,20 +38,22 @@ * <p>Encapsulates a finder pattern, which are the three square patterns found in

*/
class FinderPattern extends ResultPoint_1.default {
var FinderPattern = /** @class */ (function (_super) {
__extends(FinderPattern, _super);
// FinderPattern(posX: number/*float*/, posY: number/*float*/, estimatedModuleSize: number/*float*/) {
// this(posX, posY, estimatedModuleSize, 1)
// }
constructor(posX /*float*/, posY /*float*/, estimatedModuleSize /*float*/, count /*int*/) {
super(posX, posY);
this.estimatedModuleSize = estimatedModuleSize; /*float*/
this.count = count; /*int*/
function FinderPattern(posX /*float*/, posY /*float*/, estimatedModuleSize /*float*/, count /*int*/) {
var _this = _super.call(this, posX, posY) || this;
_this.estimatedModuleSize = estimatedModuleSize; /*float*/
_this.count = count; /*int*/
if (undefined === count) {
this.count = 1;
_this.count = 1;
}
return _this;
}
getEstimatedModuleSize() {
FinderPattern.prototype.getEstimatedModuleSize = function () {
return this.estimatedModuleSize;
}
getCount() {
};
FinderPattern.prototype.getCount = function () {
return this.count;
}
};
/*

@@ -56,9 +68,9 @@ void incrementCount() {

*/
aboutEquals(moduleSize /*float*/, i /*float*/, j /*float*/) {
FinderPattern.prototype.aboutEquals = function (moduleSize /*float*/, i /*float*/, j /*float*/) {
if (Math.abs(i - this.getY()) <= moduleSize && Math.abs(j - this.getX()) <= moduleSize) {
const moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize);
var moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize);
return moduleSizeDiff <= 1.0 || moduleSizeDiff <= this.estimatedModuleSize;
}
return false;
}
};
/**

@@ -69,11 +81,12 @@ * Combines this object's current estimate of a finder pattern position and module size

*/
combineEstimate(i /*float*/, j /*float*/, newModuleSize /*float*/) {
const combinedCount = this.count + 1;
const combinedX = (this.count * this.getX() + j) / combinedCount;
const combinedY = (this.count * this.getY() + i) / combinedCount;
const combinedModuleSize = (this.count * this.estimatedModuleSize + newModuleSize) / combinedCount;
FinderPattern.prototype.combineEstimate = function (i /*float*/, j /*float*/, newModuleSize /*float*/) {
var combinedCount = this.count + 1;
var combinedX = (this.count * this.getX() + j) / combinedCount;
var combinedY = (this.count * this.getY() + i) / combinedCount;
var combinedModuleSize = (this.count * this.estimatedModuleSize + newModuleSize) / combinedCount;
return new FinderPattern(combinedX, combinedY, combinedModuleSize, combinedCount);
}
}
};
return FinderPattern;
}(ResultPoint_1.default));
exports.default = FinderPattern;
//# sourceMappingURL=FinderPattern.js.map

@@ -18,6 +18,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const ResultPoint_1 = require("./../../ResultPoint");
const FinderPattern_1 = require("./FinderPattern");
const FinderPatternInfo_1 = require("./FinderPatternInfo");
const Exception_1 = require("./../../Exception");
var ResultPoint_1 = require("./../../ResultPoint");
var FinderPattern_1 = require("./FinderPattern");
var FinderPatternInfo_1 = require("./FinderPatternInfo");
var Exception_1 = require("./../../Exception");
/*import java.io.Serializable;*/

@@ -37,3 +37,3 @@ /*import java.util.ArrayList;*/

*/
class FinderPatternFinder {
var FinderPatternFinder = /** @class */ (function () {
/**

@@ -47,3 +47,3 @@ * <p>Creates a finder that will search the image for three finder patterns.</p>

// }
constructor(image, resultPointCallback) {
function FinderPatternFinder(image, resultPointCallback) {
this.image = image;

@@ -55,14 +55,14 @@ this.resultPointCallback = resultPointCallback;

}
getImage() {
FinderPatternFinder.prototype.getImage = function () {
return this.image;
}
getPossibleCenters() {
};
FinderPatternFinder.prototype.getPossibleCenters = function () {
return this.possibleCenters;
}
find(hints) {
const tryHarder = (hints !== null && hints !== undefined) && undefined !== hints.get(3 /* TRY_HARDER */);
const pureBarcode = (hints !== null && hints !== undefined) && undefined !== hints.get(1 /* PURE_BARCODE */);
const image = this.image;
const maxI = image.getHeight();
const maxJ = image.getWidth();
};
FinderPatternFinder.prototype.find = function (hints) {
var tryHarder = (hints !== null && hints !== undefined) && undefined !== hints.get(3 /* TRY_HARDER */);
var pureBarcode = (hints !== null && hints !== undefined) && undefined !== hints.get(1 /* PURE_BARCODE */);
var image = this.image;
var maxI = image.getHeight();
var maxJ = image.getWidth();
// We are looking for black/white/black/white/black modules in

@@ -74,9 +74,9 @@ // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far

// QR versions regardless of how dense they are.
let iSkip = Math.floor((3 * maxI) / (4 * FinderPatternFinder.MAX_MODULES));
var iSkip = Math.floor((3 * maxI) / (4 * FinderPatternFinder.MAX_MODULES));
if (iSkip < FinderPatternFinder.MIN_SKIP || tryHarder) {
iSkip = FinderPatternFinder.MIN_SKIP;
}
let done = false;
const stateCount = new Int32Array(5);
for (let i = iSkip - 1; i < maxI && !done; i += iSkip) {
var done = false;
var stateCount = new Int32Array(5);
for (var i = iSkip - 1; i < maxI && !done; i += iSkip) {
// Get a row of black/white values

@@ -88,4 +88,4 @@ stateCount[0] = 0;

stateCount[4] = 0;
let currentState = 0;
for (let j = 0; j < maxJ; j++) {
var currentState = 0;
for (var j = 0; j < maxJ; j++) {
if (image.get(j, i)) {

@@ -102,3 +102,3 @@ // Black pixel

if (FinderPatternFinder.foundPatternCross(stateCount)) {
const confirmed = this.handlePossibleCenter(stateCount, i, j, pureBarcode);
var confirmed = this.handlePossibleCenter(stateCount, i, j, pureBarcode);
if (confirmed === true) {

@@ -112,3 +112,3 @@ // Start examining every other line. Checking each line turned out to be too

else {
const rowSkip = this.findRowSkip();
var rowSkip = this.findRowSkip();
if (rowSkip > stateCount[2]) {

@@ -163,3 +163,3 @@ // Skip rows between row of lower confirmed center

if (FinderPatternFinder.foundPatternCross(stateCount)) {
const confirmed = this.handlePossibleCenter(stateCount, i, maxJ, pureBarcode);
var confirmed = this.handlePossibleCenter(stateCount, i, maxJ, pureBarcode);
if (confirmed === true) {

@@ -174,6 +174,6 @@ iSkip = stateCount[0];

}
const patternInfo = this.selectBestPatterns();
var patternInfo = this.selectBestPatterns();
ResultPoint_1.default.orderBestPatterns(patternInfo);
return new FinderPatternInfo_1.default(patternInfo);
}
};
/**

@@ -183,5 +183,5 @@ * Given a count of black/white/black/white/black pixels just seen and an end position,

*/
static centerFromEnd(stateCount, end /*int*/) {
FinderPatternFinder.centerFromEnd = function (stateCount, end /*int*/) {
return (end - stateCount[4] - stateCount[3]) - stateCount[2] / 2.0;
}
};
/**

@@ -192,6 +192,6 @@ * @param stateCount count of black/white/black/white/black pixels just read

*/
static foundPatternCross(stateCount) {
let totalModuleSize = 0;
for (let i = 0; i < 5; i++) {
const count = stateCount[i];
FinderPatternFinder.foundPatternCross = function (stateCount) {
var totalModuleSize = 0;
for (var i = 0; i < 5; i++) {
var count = stateCount[i];
if (count === 0) {

@@ -205,4 +205,4 @@ return false;

}
const moduleSize = totalModuleSize / 7.0;
const maxVariance = moduleSize / 2.0;
var moduleSize = totalModuleSize / 7.0;
var maxVariance = moduleSize / 2.0;
// Allow less than 50% variance from 1-1-3-1-1 proportions

@@ -214,5 +214,5 @@ return Math.abs(moduleSize - stateCount[0]) < maxVariance &&

Math.abs(moduleSize - stateCount[4]) < maxVariance;
}
getCrossCheckStateCount() {
const crossCheckStateCount = this.crossCheckStateCount;
};
FinderPatternFinder.prototype.getCrossCheckStateCount = function () {
var crossCheckStateCount = this.crossCheckStateCount;
crossCheckStateCount[0] = 0;

@@ -224,3 +224,3 @@ crossCheckStateCount[1] = 0;

return crossCheckStateCount;
}
};
/**

@@ -238,7 +238,7 @@ * After a vertical and horizontal scan finds a potential finder pattern, this method

*/
crossCheckDiagonal(startI /*int*/, centerJ /*int*/, maxCount /*int*/, originalStateCountTotal /*int*/) {
const stateCount = this.getCrossCheckStateCount();
FinderPatternFinder.prototype.crossCheckDiagonal = function (startI /*int*/, centerJ /*int*/, maxCount /*int*/, originalStateCountTotal /*int*/) {
var stateCount = this.getCrossCheckStateCount();
// Start counting up, left from center finding black center mass
let i = 0;
const image = this.image;
var i = 0;
var image = this.image;
while (startI >= i && centerJ >= i && image.get(centerJ - i, startI - i)) {

@@ -270,4 +270,4 @@ stateCount[2]++;

}
const maxI = image.getHeight();
const maxJ = image.getWidth();
var maxI = image.getHeight();
var maxJ = image.getWidth();
// Now also count down, right from center

@@ -301,6 +301,6 @@ i = 1;

// the original, assume it's a false positive
const stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
return Math.abs(stateCountTotal - originalStateCountTotal) < 2 * originalStateCountTotal &&
FinderPatternFinder.foundPatternCross(stateCount);
}
};
/**

@@ -317,8 +317,8 @@ * <p>After a horizontal scan finds a potential finder pattern, this method

*/
crossCheckVertical(startI /*int*/, centerJ /*int*/, maxCount /*int*/, originalStateCountTotal /*int*/) {
const image = this.image;
const maxI = image.getHeight();
const stateCount = this.getCrossCheckStateCount();
FinderPatternFinder.prototype.crossCheckVertical = function (startI /*int*/, centerJ /*int*/, maxCount /*int*/, originalStateCountTotal /*int*/) {
var image = this.image;
var maxI = image.getHeight();
var stateCount = this.getCrossCheckStateCount();
// Start counting up from center
let i = startI;
var i = startI;
while (i >= 0 && image.get(centerJ, i)) {

@@ -371,3 +371,3 @@ stateCount[2]++;

// the original, assume it's a false positive
const stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] +
var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] +
stateCount[4];

@@ -378,3 +378,3 @@ if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) {

return FinderPatternFinder.foundPatternCross(stateCount) ? FinderPatternFinder.centerFromEnd(stateCount, i) : NaN;
}
};
/**

@@ -385,7 +385,7 @@ * <p>Like {@link #crossCheckVertical(int, int, int, int)}, and in fact is basically identical,

*/
crossCheckHorizontal(startJ /*int*/, centerI /*int*/, maxCount /*int*/, originalStateCountTotal /*int*/) {
const image = this.image;
const maxJ = image.getWidth();
const stateCount = this.getCrossCheckStateCount();
let j = startJ;
FinderPatternFinder.prototype.crossCheckHorizontal = function (startJ /*int*/, centerI /*int*/, maxCount /*int*/, originalStateCountTotal /*int*/) {
var image = this.image;
var maxJ = image.getWidth();
var stateCount = this.getCrossCheckStateCount();
var j = startJ;
while (j >= 0 && image.get(j, centerI)) {

@@ -436,3 +436,3 @@ stateCount[2]++;

// the original, assume it's a false positive
const stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] +
var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] +
stateCount[4];

@@ -443,3 +443,3 @@ if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= originalStateCountTotal) {

return FinderPatternFinder.foundPatternCross(stateCount) ? FinderPatternFinder.centerFromEnd(stateCount, j) : NaN;
}
};
/**

@@ -463,7 +463,7 @@ * <p>This is called when a horizontal scan finds a possible alignment pattern. It will

*/
handlePossibleCenter(stateCount, i /*int*/, j /*int*/, pureBarcode) {
const stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] +
FinderPatternFinder.prototype.handlePossibleCenter = function (stateCount, i /*int*/, j /*int*/, pureBarcode) {
var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] +
stateCount[4];
let centerJ = FinderPatternFinder.centerFromEnd(stateCount, j);
let centerI = this.crossCheckVertical(i, /*(int) */ Math.floor(centerJ), stateCount[2], stateCountTotal);
var centerJ = FinderPatternFinder.centerFromEnd(stateCount, j);
var centerI = this.crossCheckVertical(i, /*(int) */ Math.floor(centerJ), stateCount[2], stateCountTotal);
if (!isNaN(centerI)) {

@@ -474,7 +474,7 @@ // Re-cross check

(!pureBarcode || this.crossCheckDiagonal(/*(int) */ Math.floor(centerI), /*(int) */ Math.floor(centerJ), stateCount[2], stateCountTotal))) {
const estimatedModuleSize = stateCountTotal / 7.0;
let found = false;
const possibleCenters = this.possibleCenters;
for (let index = 0, length = possibleCenters.length; index < length; index++) {
const center = possibleCenters[index];
var estimatedModuleSize = stateCountTotal / 7.0;
var found = false;
var possibleCenters = this.possibleCenters;
for (var index = 0, length_1 = possibleCenters.length; index < length_1; index++) {
var center = possibleCenters[index];
// Look for about the same center and module size:

@@ -488,3 +488,3 @@ if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) {

if (!found) {
const point = new FinderPattern_1.default(centerJ, centerI, estimatedModuleSize);
var point = new FinderPattern_1.default(centerJ, centerI, estimatedModuleSize);
possibleCenters.push(point);

@@ -499,3 +499,3 @@ if (this.resultPointCallback !== null && this.resultPointCallback !== undefined) {

return false;
}
};
/**

@@ -507,9 +507,10 @@ * @return number of rows we could safely skip during scanning, based on the first

*/
findRowSkip() {
const max = this.possibleCenters.length;
FinderPatternFinder.prototype.findRowSkip = function () {
var max = this.possibleCenters.length;
if (max <= 1) {
return 0;
}
let firstConfirmedCenter = null;
for (const center of this.possibleCenters) {
var firstConfirmedCenter = null;
for (var _i = 0, _a = this.possibleCenters; _i < _a.length; _i++) {
var center = _a[_i];
if (center.getCount() >= FinderPatternFinder.CENTER_QUORUM) {

@@ -532,3 +533,3 @@ if (firstConfirmedCenter == null) {

return 0;
}
};
/**

@@ -539,7 +540,8 @@ * @return true iff we have found at least 3 finder patterns that have been detected

*/
haveMultiplyConfirmedCenters() {
let confirmedCount = 0;
let totalModuleSize = 0.0;
const max = this.possibleCenters.length;
for (const pattern of this.possibleCenters) {
FinderPatternFinder.prototype.haveMultiplyConfirmedCenters = function () {
var confirmedCount = 0;
var totalModuleSize = 0.0;
var max = this.possibleCenters.length;
for (var _i = 0, _a = this.possibleCenters; _i < _a.length; _i++) {
var pattern = _a[_i];
if (pattern.getCount() >= FinderPatternFinder.CENTER_QUORUM) {

@@ -557,9 +559,10 @@ confirmedCount++;

// 5% of the total module size estimates, it's too much.
const average = totalModuleSize / max;
let totalDeviation = 0.0;
for (const pattern of this.possibleCenters) {
var average = totalModuleSize / max;
var totalDeviation = 0.0;
for (var _b = 0, _c = this.possibleCenters; _b < _c.length; _b++) {
var pattern = _c[_b];
totalDeviation += Math.abs(pattern.getEstimatedModuleSize() - average);
}
return totalDeviation <= 0.05 * totalModuleSize;
}
};
/**

@@ -571,4 +574,4 @@ * @return the 3 best {@link FinderPattern}s from our list of candidates. The "best" are

*/
selectBestPatterns() {
const startSize = this.possibleCenters.length;
FinderPatternFinder.prototype.selectBestPatterns = function () {
var startSize = this.possibleCenters.length;
if (startSize < 3) {

@@ -578,11 +581,12 @@ // Couldn't find enough finder patterns

}
const possibleCenters = this.possibleCenters;
let average; /*float*/
var possibleCenters = this.possibleCenters;
var average; /*float*/
// Filter outlier possibilities whose module size is too different
if (startSize > 3) {
// But we can only afford to do so if we have at least 4 possibilities to choose from
let totalModuleSize = 0.0;
let square = 0.0;
for (const center of this.possibleCenters) {
const size = center.getEstimatedModuleSize();
var totalModuleSize = 0.0;
var square = 0.0;
for (var _i = 0, _a = this.possibleCenters; _i < _a.length; _i++) {
var center = _a[_i];
var size = center.getEstimatedModuleSize();
totalModuleSize += size;

@@ -592,3 +596,3 @@ square += size * size;

average = totalModuleSize / startSize;
let stdDev = Math.sqrt(square / startSize - average * average);
var stdDev = Math.sqrt(square / startSize - average * average);
possibleCenters.sort(

@@ -599,10 +603,10 @@ /**

// FurthestFromAverageComparator implements Comparator<FinderPattern>
(center1, center2) => {
const dA = Math.abs(center2.getEstimatedModuleSize() - average);
const dB = Math.abs(center1.getEstimatedModuleSize() - average);
function (center1, center2) {
var dA = Math.abs(center2.getEstimatedModuleSize() - average);
var dB = Math.abs(center1.getEstimatedModuleSize() - average);
return dA < dB ? -1 : dA > dB ? 1 : 0;
});
const limit = Math.max(0.2 * average, stdDev);
for (let i = 0; i < possibleCenters.length && possibleCenters.length > 3; i++) {
const pattern = possibleCenters[i];
var limit = Math.max(0.2 * average, stdDev);
for (var i = 0; i < possibleCenters.length && possibleCenters.length > 3; i++) {
var pattern = possibleCenters[i];
if (Math.abs(pattern.getEstimatedModuleSize() - average) > limit) {

@@ -616,4 +620,5 @@ possibleCenters.splice(i, 1);

// Throw away all but those first size candidate points we found.
let totalModuleSize = 0.0;
for (const possibleCenter of possibleCenters) {
var totalModuleSize = 0.0;
for (var _b = 0, possibleCenters_1 = possibleCenters; _b < possibleCenters_1.length; _b++) {
var possibleCenter = possibleCenters_1[_b];
totalModuleSize += possibleCenter.getEstimatedModuleSize();

@@ -627,6 +632,6 @@ }

// CenterComparator implements Comparator<FinderPattern>
(center1, center2) => {
function (center1, center2) {
if (center2.getCount() === center1.getCount()) {
const dA = Math.abs(center2.getEstimatedModuleSize() - average);
const dB = Math.abs(center1.getEstimatedModuleSize() - average);
var dA = Math.abs(center2.getEstimatedModuleSize() - average);
var dB = Math.abs(center1.getEstimatedModuleSize() - average);
return dA < dB ? 1 : dA > dB ? -1 : 0;

@@ -645,8 +650,9 @@ }

];
}
}
FinderPatternFinder.CENTER_QUORUM = 2;
FinderPatternFinder.MIN_SKIP = 3; // 1 pixel/module times 3 modules/center
FinderPatternFinder.MAX_MODULES = 57; // support up to version 10 for mobile clients
};
FinderPatternFinder.CENTER_QUORUM = 2;
FinderPatternFinder.MIN_SKIP = 3; // 1 pixel/module times 3 modules/center
FinderPatternFinder.MAX_MODULES = 57; // support up to version 10 for mobile clients
return FinderPatternFinder;
}());
exports.default = FinderPatternFinder;
//# sourceMappingURL=FinderPatternFinder.js.map

@@ -24,4 +24,4 @@ "use strict";

*/
class FinderPatternInfo {
constructor(patternCenters) {
var FinderPatternInfo = /** @class */ (function () {
function FinderPatternInfo(patternCenters) {
this.bottomLeft = patternCenters[0];

@@ -31,13 +31,14 @@ this.topLeft = patternCenters[1];

}
getBottomLeft() {
FinderPatternInfo.prototype.getBottomLeft = function () {
return this.bottomLeft;
}
getTopLeft() {
};
FinderPatternInfo.prototype.getTopLeft = function () {
return this.topLeft;
}
getTopRight() {
};
FinderPatternInfo.prototype.getTopRight = function () {
return this.topRight;
}
}
};
return FinderPatternInfo;
}());
exports.default = FinderPatternInfo;
//# sourceMappingURL=FinderPatternInfo.js.map

@@ -19,15 +19,16 @@ "use strict";

/*namespace com.google.zxing.qrcode.encoder {*/
class BlockPair {
constructor(dataBytes, errorCorrectionBytes) {
var BlockPair = /** @class */ (function () {
function BlockPair(dataBytes, errorCorrectionBytes) {
this.dataBytes = dataBytes;
this.errorCorrectionBytes = errorCorrectionBytes;
}
getDataBytes() {
BlockPair.prototype.getDataBytes = function () {
return this.dataBytes;
}
getErrorCorrectionBytes() {
};
BlockPair.prototype.getErrorCorrectionBytes = function () {
return this.errorCorrectionBytes;
}
}
};
return BlockPair;
}());
exports.default = BlockPair;
//# sourceMappingURL=BlockPair.js.map

@@ -20,4 +20,4 @@ "use strict";

/*import java.util.Arrays;*/
const Arrays_1 = require("./../../util/Arrays");
const StringBuilder_1 = require("./../../util/StringBuilder");
var Arrays_1 = require("./../../util/Arrays");
var StringBuilder_1 = require("./../../util/StringBuilder");
/**

@@ -29,8 +29,8 @@ * JAVAPORT: The original code was a 2D array of ints, but since it only ever gets assigned

*/
class ByteMatrix {
constructor(width /*int*/, height /*int*/) {
var ByteMatrix = /** @class */ (function () {
function ByteMatrix(width /*int*/, height /*int*/) {
this.width = width; /*int*/
this.height = height; /*int*/
const bytes = new Array(height); // [height][width]
for (let i = 0; i !== height; i++) {
var bytes = new Array(height); // [height][width]
for (var i = 0; i !== height; i++) {
bytes[i] = new Uint8Array(width);

@@ -40,37 +40,38 @@ }

}
getHeight() {
ByteMatrix.prototype.getHeight = function () {
return this.height;
}
getWidth() {
};
ByteMatrix.prototype.getWidth = function () {
return this.width;
}
get(x /*int*/, y /*int*/) {
};
ByteMatrix.prototype.get = function (x /*int*/, y /*int*/) {
return this.bytes[y][x];
}
};
/**
* @return an internal representation as bytes, in row-major order. array[y][x] represents point (x,y)
*/
getArray() {
ByteMatrix.prototype.getArray = function () {
return this.bytes;
}
};
// TYPESCRIPTPORT: preffer to let two methods instead of override to avoid type comparison inside
setNumber(x /*int*/, y /*int*/, value /*byte|int*/) {
ByteMatrix.prototype.setNumber = function (x /*int*/, y /*int*/, value /*byte|int*/) {
this.bytes[y][x] = value;
}
};
// public set(x: number /*int*/, y: number /*int*/, value: number /*int*/): void {
// bytes[y][x] = (byte) value
// }
setBoolean(x /*int*/, y /*int*/, value) {
ByteMatrix.prototype.setBoolean = function (x /*int*/, y /*int*/, value) {
this.bytes[y][x] = /*(byte) */ (value ? 1 : 0);
}
clear(value /*byte*/) {
for (const aByte of this.bytes) {
};
ByteMatrix.prototype.clear = function (value /*byte*/) {
for (var _i = 0, _a = this.bytes; _i < _a.length; _i++) {
var aByte = _a[_i];
Arrays_1.default.fillUint8Array(aByte, value);
}
}
equals(o) {
};
ByteMatrix.prototype.equals = function (o) {
if (!(o instanceof ByteMatrix)) {
return false;
}
const other = o;
var other = o;
if (this.width !== other.width) {

@@ -82,6 +83,6 @@ return false;

}
for (let y = 0, height = this.height; y < height; ++y) {
const bytesY = this.bytes[y];
const otherBytesY = other.bytes[y];
for (let x = 0, width = this.width; x < width; ++x) {
for (var y = 0, height = this.height; y < height; ++y) {
var bytesY = this.bytes[y];
var otherBytesY = other.bytes[y];
for (var x = 0, width = this.width; x < width; ++x) {
if (bytesY[x] !== otherBytesY[x]) {

@@ -93,9 +94,9 @@ return false;

return true;
}
};
/*@Override*/
toString() {
const result = new StringBuilder_1.default(); // (2 * width * height + 2)
for (let y = 0, height = this.height; y < height; ++y) {
const bytesY = this.bytes[y];
for (let x = 0, width = this.width; x < width; ++x) {
ByteMatrix.prototype.toString = function () {
var result = new StringBuilder_1.default(); // (2 * width * height + 2)
for (var y = 0, height = this.height; y < height; ++y) {
var bytesY = this.bytes[y];
for (var x = 0, width = this.width; x < width; ++x) {
switch (bytesY[x]) {

@@ -116,5 +117,6 @@ case 0:

return result.toString();
}
}
};
return ByteMatrix;
}());
exports.default = ByteMatrix;
//# sourceMappingURL=ByteMatrix.js.map

@@ -19,16 +19,16 @@ "use strict";

/*namespace com.google.zxing.qrcode.encoder {*/
const EncodeHintType_1 = require("./../../EncodeHintType");
const BitArray_1 = require("./../../common/BitArray");
const CharacterSetECI_1 = require("./../../common/CharacterSetECI");
const GenericGF_1 = require("./../../common/reedsolomon/GenericGF");
const ReedSolomonEncoder_1 = require("./../../common/reedsolomon/ReedSolomonEncoder");
const Mode_1 = require("./../decoder/Mode");
const Version_1 = require("./../decoder/Version");
const MaskUtil_1 = require("./MaskUtil");
const ByteMatrix_1 = require("./ByteMatrix");
const QRCode_1 = require("./QRCode");
const Exception_1 = require("./../../Exception");
const MatrixUtil_1 = require("./MatrixUtil");
const StringEncoding_1 = require("./../../util/StringEncoding");
const BlockPair_1 = require("./BlockPair");
var EncodeHintType_1 = require("./../../EncodeHintType");
var BitArray_1 = require("./../../common/BitArray");
var CharacterSetECI_1 = require("./../../common/CharacterSetECI");
var GenericGF_1 = require("./../../common/reedsolomon/GenericGF");
var ReedSolomonEncoder_1 = require("./../../common/reedsolomon/ReedSolomonEncoder");
var Mode_1 = require("./../decoder/Mode");
var Version_1 = require("./../decoder/Version");
var MaskUtil_1 = require("./MaskUtil");
var ByteMatrix_1 = require("./ByteMatrix");
var QRCode_1 = require("./QRCode");
var Exception_1 = require("./../../Exception");
var MatrixUtil_1 = require("./MatrixUtil");
var StringEncoding_1 = require("./../../util/StringEncoding");
var BlockPair_1 = require("./BlockPair");
/*import java.io.UnsupportedEncodingException;*/

@@ -42,8 +42,9 @@ /*import java.util.ArrayList;*/

*/
class Encoder {
var Encoder = /** @class */ (function () {
// TYPESCRIPTPORT: changed to UTF8, the default for js
constructor() { }
function Encoder() {
}
// The mask penalty calculation is complicated. See Table 21 of JISX0510:2004 (p.45) for details.
// Basically it applies four rules and summate all penalties.
static calculateMaskPenalty(matrix) {
Encoder.calculateMaskPenalty = function (matrix) {
return MaskUtil_1.default.applyMaskPenaltyRule1(matrix)

@@ -53,3 +54,3 @@ + MaskUtil_1.default.applyMaskPenaltyRule2(matrix)

+ MaskUtil_1.default.applyMaskPenaltyRule4(matrix);
}
};
/**

@@ -65,6 +66,7 @@ * @param content text to encode

// }
static encode(content, ecLevel, hints = null) {
Encoder.encode = function (content, ecLevel, hints) {
if (hints === void 0) { hints = null; }
// Determine what character encoding has been specified by the caller, if any
let encoding = Encoder.DEFAULT_BYTE_MODE_ENCODING;
const hasEncodingHint = hints !== null && undefined !== hints.get(EncodeHintType_1.default.CHARACTER_SET);
var encoding = Encoder.DEFAULT_BYTE_MODE_ENCODING;
var hasEncodingHint = hints !== null && undefined !== hints.get(EncodeHintType_1.default.CHARACTER_SET);
if (hasEncodingHint) {

@@ -75,9 +77,9 @@ encoding = hints.get(EncodeHintType_1.default.CHARACTER_SET).toString();

// multiple modes / segments even if that were more efficient. Twould be nice.
const mode = this.chooseMode(content, encoding);
var mode = this.chooseMode(content, encoding);
// This will store the header information, like mode and
// length, as well as "header" segments like an ECI segment.
const headerBits = new BitArray_1.default();
var headerBits = new BitArray_1.default();
// Append ECI segment if applicable
if (mode === Mode_1.default.BYTE && (hasEncodingHint || Encoder.DEFAULT_BYTE_MODE_ENCODING !== encoding)) {
const eci = CharacterSetECI_1.default.getCharacterSetECIByName(encoding);
var eci = CharacterSetECI_1.default.getCharacterSetECIByName(encoding);
if (eci !== undefined) {

@@ -91,9 +93,9 @@ this.appendECI(eci, headerBits);

// main payload yet.
const dataBits = new BitArray_1.default();
var dataBits = new BitArray_1.default();
this.appendBytes(content, mode, dataBits, encoding);
let version;
var version;
if (hints !== null && undefined !== hints.get(EncodeHintType_1.default.QR_VERSION)) {
const versionNumber = Number.parseInt(hints.get(EncodeHintType_1.default.QR_VERSION).toString(), 10);
var versionNumber = Number.parseInt(hints.get(EncodeHintType_1.default.QR_VERSION).toString(), 10);
version = Version_1.default.getVersionForNumber(versionNumber);
const bitsNeeded = this.calculateBitsNeeded(mode, headerBits, dataBits, version);
var bitsNeeded = this.calculateBitsNeeded(mode, headerBits, dataBits, version);
if (!this.willFit(bitsNeeded, version, ecLevel)) {

@@ -106,16 +108,16 @@ throw new Exception_1.default(Exception_1.default.WriterException, 'Data too big for requested version');

}
const headerAndDataBits = new BitArray_1.default();
var headerAndDataBits = new BitArray_1.default();
headerAndDataBits.appendBitArray(headerBits);
// Find "length" of main segment and write it
const numLetters = mode === Mode_1.default.BYTE ? dataBits.getSizeInBytes() : content.length;
var numLetters = mode === Mode_1.default.BYTE ? dataBits.getSizeInBytes() : content.length;
this.appendLengthInfo(numLetters, version, mode, headerAndDataBits);
// Put data together into the overall payload
headerAndDataBits.appendBitArray(dataBits);
const ecBlocks = version.getECBlocksForLevel(ecLevel);
const numDataBytes = version.getTotalCodewords() - ecBlocks.getTotalECCodewords();
var ecBlocks = version.getECBlocksForLevel(ecLevel);
var numDataBytes = version.getTotalCodewords() - ecBlocks.getTotalECCodewords();
// Terminate the bits properly.
this.terminateBits(numDataBytes, headerAndDataBits);
// Interleave data bits with error correction code.
const finalBits = this.interleaveWithECBytes(headerAndDataBits, version.getTotalCodewords(), numDataBytes, ecBlocks.getNumBlocks());
const qrCode = new QRCode_1.default();
var finalBits = this.interleaveWithECBytes(headerAndDataBits, version.getTotalCodewords(), numDataBytes, ecBlocks.getNumBlocks());
var qrCode = new QRCode_1.default();
qrCode.setECLevel(ecLevel);

@@ -125,5 +127,5 @@ qrCode.setMode(mode);

// Choose the mask pattern and set to "qrCode".
const dimension = version.getDimensionForVersion();
const matrix = new ByteMatrix_1.default(dimension, dimension);
const maskPattern = this.chooseMaskPattern(finalBits, ecLevel, version, matrix);
var dimension = version.getDimensionForVersion();
var matrix = new ByteMatrix_1.default(dimension, dimension);
var maskPattern = this.chooseMaskPattern(finalBits, ecLevel, version, matrix);
qrCode.setMaskPattern(maskPattern);

@@ -134,3 +136,3 @@ // Build the matrix and set it to "qrCode".

return qrCode;
}
};
/**

@@ -141,15 +143,15 @@ * Decides the smallest version of QR code that will contain all of the provided data.

*/
static recommendVersion(ecLevel, mode, headerBits, dataBits) {
Encoder.recommendVersion = function (ecLevel, mode, headerBits, dataBits) {
// Hard part: need to know version to know how many bits length takes. But need to know how many
// bits it takes to know version. First we take a guess at version by assuming version will be
// the minimum, 1:
const provisionalBitsNeeded = this.calculateBitsNeeded(mode, headerBits, dataBits, Version_1.default.getVersionForNumber(1));
const provisionalVersion = this.chooseVersion(provisionalBitsNeeded, ecLevel);
var provisionalBitsNeeded = this.calculateBitsNeeded(mode, headerBits, dataBits, Version_1.default.getVersionForNumber(1));
var provisionalVersion = this.chooseVersion(provisionalBitsNeeded, ecLevel);
// Use that guess to calculate the right version. I am still not sure this works in 100% of cases.
const bitsNeeded = this.calculateBitsNeeded(mode, headerBits, dataBits, provisionalVersion);
var bitsNeeded = this.calculateBitsNeeded(mode, headerBits, dataBits, provisionalVersion);
return this.chooseVersion(bitsNeeded, ecLevel);
}
static calculateBitsNeeded(mode, headerBits, dataBits, version) {
};
Encoder.calculateBitsNeeded = function (mode, headerBits, dataBits, version) {
return headerBits.getSize() + mode.getCharacterCountBits(version) + dataBits.getSize();
}
};
/**

@@ -159,3 +161,3 @@ * @return the code point of the table used in alphanumeric mode or

*/
static getAlphanumericCode(code /*int*/) {
Encoder.getAlphanumericCode = function (code /*int*/) {
if (code < Encoder.ALPHANUMERIC_TABLE.length) {

@@ -165,3 +167,3 @@ return Encoder.ALPHANUMERIC_TABLE[code];

return -1;
}
};
// public static chooseMode(content: string): Mode {

@@ -174,3 +176,4 @@ // return chooseMode(content, null);

*/
static chooseMode(content, encoding = null) {
Encoder.chooseMode = function (content, encoding) {
if (encoding === void 0) { encoding = null; }
if (CharacterSetECI_1.default.SJIS.getName() === encoding && this.isOnlyDoubleByteKanji(content)) {

@@ -180,6 +183,6 @@ // Choose Kanji mode if all input are double-byte characters

}
let hasNumeric = false;
let hasAlphanumeric = false;
for (let i = 0, length = content.length; i < length; ++i) {
const c = content.charAt(i);
var hasNumeric = false;
var hasAlphanumeric = false;
for (var i = 0, length_1 = content.length; i < length_1; ++i) {
var c = content.charAt(i);
if (Encoder.isDigit(c)) {

@@ -202,5 +205,5 @@ hasNumeric = true;

return Mode_1.default.BYTE;
}
static isOnlyDoubleByteKanji(content) {
let bytes;
};
Encoder.isOnlyDoubleByteKanji = function (content) {
var bytes;
try {

@@ -212,8 +215,8 @@ bytes = StringEncoding_1.default.encode(content, CharacterSetECI_1.default.SJIS.getName()); // content.getBytes("Shift_JIS"))

}
const length = bytes.length;
var length = bytes.length;
if (length % 2 !== 0) {
return false;
}
for (let i = 0; i < length; i += 2) {
const byte1 = bytes[i] & 0xFF;
for (var i = 0; i < length; i += 2) {
var byte1 = bytes[i] & 0xFF;
if ((byte1 < 0x81 || byte1 > 0x9F) && (byte1 < 0xE0 || byte1 > 0xEB)) {

@@ -224,10 +227,10 @@ return false;

return true;
}
static chooseMaskPattern(bits, ecLevel, version, matrix) {
let minPenalty = Number.MAX_SAFE_INTEGER; // Lower penalty is better.
let bestMaskPattern = -1;
};
Encoder.chooseMaskPattern = function (bits, ecLevel, version, matrix) {
var minPenalty = Number.MAX_SAFE_INTEGER; // Lower penalty is better.
var bestMaskPattern = -1;
// We try all mask patterns to choose the best one.
for (let maskPattern = 0; maskPattern < QRCode_1.default.NUM_MASK_PATTERNS; maskPattern++) {
for (var maskPattern = 0; maskPattern < QRCode_1.default.NUM_MASK_PATTERNS; maskPattern++) {
MatrixUtil_1.default.buildMatrix(bits, ecLevel, version, maskPattern, matrix);
let penalty = this.calculateMaskPenalty(matrix);
var penalty = this.calculateMaskPenalty(matrix);
if (penalty < minPenalty) {

@@ -239,6 +242,6 @@ minPenalty = penalty;

return bestMaskPattern;
}
static chooseVersion(numInputBits /*int*/, ecLevel) {
for (let versionNum = 1; versionNum <= 40; versionNum++) {
const version = Version_1.default.getVersionForNumber(versionNum);
};
Encoder.chooseVersion = function (numInputBits /*int*/, ecLevel) {
for (var versionNum = 1; versionNum <= 40; versionNum++) {
var version = Version_1.default.getVersionForNumber(versionNum);
if (Encoder.willFit(numInputBits, version, ecLevel)) {

@@ -249,3 +252,3 @@ return version;

throw new Exception_1.default(Exception_1.default.WriterException, 'Data too big');
}
};
/**

@@ -255,19 +258,19 @@ * @return true if the number of input bits will fit in a code with the specified version and

*/
static willFit(numInputBits /*int*/, version, ecLevel) {
Encoder.willFit = function (numInputBits /*int*/, version, ecLevel) {
// In the following comments, we use numbers of Version 7-H.
// numBytes = 196
const numBytes = version.getTotalCodewords();
var numBytes = version.getTotalCodewords();
// getNumECBytes = 130
const ecBlocks = version.getECBlocksForLevel(ecLevel);
const numEcBytes = ecBlocks.getTotalECCodewords();
var ecBlocks = version.getECBlocksForLevel(ecLevel);
var numEcBytes = ecBlocks.getTotalECCodewords();
// getNumDataBytes = 196 - 130 = 66
const numDataBytes = numBytes - numEcBytes;
const totalInputBytes = (numInputBits + 7) / 8;
var numDataBytes = numBytes - numEcBytes;
var totalInputBytes = (numInputBits + 7) / 8;
return numDataBytes >= totalInputBytes;
}
};
/**
* Terminate bits as described in 8.4.8 and 8.4.9 of JISX0510:2004 (p.24).
*/
static terminateBits(numDataBytes /*int*/, bits) {
const capacity = numDataBytes * 8;
Encoder.terminateBits = function (numDataBytes /*int*/, bits) {
var capacity = numDataBytes * 8;
if (bits.getSize() > capacity) {

@@ -277,3 +280,3 @@ throw new Exception_1.default(Exception_1.default.WriterException, 'data bits cannot fit in the QR Code' + bits.getSize() + ' > ' +

}
for (let i = 0; i < 4 && bits.getSize() < capacity; ++i) {
for (var i = 0; i < 4 && bits.getSize() < capacity; ++i) {
bits.appendBit(false);

@@ -283,5 +286,5 @@ }

// If the last byte isn't 8-bit aligned, we'll add padding bits.
const numBitsInLastByte = bits.getSize() & 0x07;
var numBitsInLastByte = bits.getSize() & 0x07;
if (numBitsInLastByte > 0) {
for (let i = numBitsInLastByte; i < 8; i++) {
for (var i = numBitsInLastByte; i < 8; i++) {
bits.appendBit(false);

@@ -291,4 +294,4 @@ }

// If we have more space, we'll fill the space with padding patterns defined in 8.4.9 (p.24).
const numPaddingBytes = numDataBytes - bits.getSizeInBytes();
for (let i = 0; i < numPaddingBytes; ++i) {
var numPaddingBytes = numDataBytes - bits.getSizeInBytes();
for (var i = 0; i < numPaddingBytes; ++i) {
bits.appendBits((i & 0x01) === 0 ? 0xEC : 0x11, 8);

@@ -299,3 +302,3 @@ }

}
}
};
/**

@@ -306,3 +309,3 @@ * Get number of data bytes and number of error correction bytes for block id "blockID". Store

*/
static getNumDataBytesAndNumECBytesForBlockID(numTotalBytes /*int*/, numDataBytes /*int*/, numRSBlocks /*int*/, blockID /*int*/, numDataBytesInBlock, numECBytesInBlock) {
Encoder.getNumDataBytesAndNumECBytesForBlockID = function (numTotalBytes /*int*/, numDataBytes /*int*/, numRSBlocks /*int*/, blockID /*int*/, numDataBytesInBlock, numECBytesInBlock) {
if (blockID >= numRSBlocks) {

@@ -312,17 +315,17 @@ throw new Exception_1.default(Exception_1.default.WriterException, 'Block ID too large');

// numRsBlocksInGroup2 = 196 % 5 = 1
const numRsBlocksInGroup2 = numTotalBytes % numRSBlocks;
var numRsBlocksInGroup2 = numTotalBytes % numRSBlocks;
// numRsBlocksInGroup1 = 5 - 1 = 4
const numRsBlocksInGroup1 = numRSBlocks - numRsBlocksInGroup2;
var numRsBlocksInGroup1 = numRSBlocks - numRsBlocksInGroup2;
// numTotalBytesInGroup1 = 196 / 5 = 39
const numTotalBytesInGroup1 = Math.floor(numTotalBytes / numRSBlocks);
var numTotalBytesInGroup1 = Math.floor(numTotalBytes / numRSBlocks);
// numTotalBytesInGroup2 = 39 + 1 = 40
const numTotalBytesInGroup2 = numTotalBytesInGroup1 + 1;
var numTotalBytesInGroup2 = numTotalBytesInGroup1 + 1;
// numDataBytesInGroup1 = 66 / 5 = 13
const numDataBytesInGroup1 = Math.floor(numDataBytes / numRSBlocks);
var numDataBytesInGroup1 = Math.floor(numDataBytes / numRSBlocks);
// numDataBytesInGroup2 = 13 + 1 = 14
const numDataBytesInGroup2 = numDataBytesInGroup1 + 1;
var numDataBytesInGroup2 = numDataBytesInGroup1 + 1;
// numEcBytesInGroup1 = 39 - 13 = 26
const numEcBytesInGroup1 = numTotalBytesInGroup1 - numDataBytesInGroup1;
var numEcBytesInGroup1 = numTotalBytesInGroup1 - numDataBytesInGroup1;
// numEcBytesInGroup2 = 40 - 14 = 26
const numEcBytesInGroup2 = numTotalBytesInGroup2 - numDataBytesInGroup2;
var numEcBytesInGroup2 = numTotalBytesInGroup2 - numDataBytesInGroup2;
// Sanity checks.

@@ -353,3 +356,3 @@ // 26 = 26

}
}
};
/**

@@ -359,3 +362,3 @@ * Interleave "bits" with corresponding error correction bytes. On success, store the result in

*/
static interleaveWithECBytes(bits, numTotalBytes /*int*/, numDataBytes /*int*/, numRSBlocks /*int*/) {
Encoder.interleaveWithECBytes = function (bits, numTotalBytes /*int*/, numDataBytes /*int*/, numRSBlocks /*int*/) {
// "bits" must have "getNumDataBytes" bytes of data.

@@ -367,15 +370,15 @@ if (bits.getSizeInBytes() !== numDataBytes) {

// store the divided data bytes blocks and error correction bytes blocks into "blocks".
let dataBytesOffset = 0;
let maxNumDataBytes = 0;
let maxNumEcBytes = 0;
var dataBytesOffset = 0;
var maxNumDataBytes = 0;
var maxNumEcBytes = 0;
// Since, we know the number of reedsolmon blocks, we can initialize the vector with the number.
const blocks = new Array(); // new Array<BlockPair>(numRSBlocks)
for (let i = 0; i < numRSBlocks; ++i) {
const numDataBytesInBlock = new Int32Array(1);
const numEcBytesInBlock = new Int32Array(1);
var blocks = new Array(); // new Array<BlockPair>(numRSBlocks)
for (var i = 0; i < numRSBlocks; ++i) {
var numDataBytesInBlock = new Int32Array(1);
var numEcBytesInBlock = new Int32Array(1);
Encoder.getNumDataBytesAndNumECBytesForBlockID(numTotalBytes, numDataBytes, numRSBlocks, i, numDataBytesInBlock, numEcBytesInBlock);
const size = numDataBytesInBlock[0];
const dataBytes = new Uint8Array(size);
var size = numDataBytesInBlock[0];
var dataBytes = new Uint8Array(size);
bits.toBytes(8 * dataBytesOffset, dataBytes, 0, size);
const ecBytes = Encoder.generateECBytes(dataBytes, numEcBytesInBlock[0]);
var ecBytes = Encoder.generateECBytes(dataBytes, numEcBytesInBlock[0]);
blocks.push(new BlockPair_1.default(dataBytes, ecBytes));

@@ -389,7 +392,8 @@ maxNumDataBytes = Math.max(maxNumDataBytes, size);

}
const result = new BitArray_1.default();
var result = new BitArray_1.default();
// First, place data blocks.
for (let i = 0; i < maxNumDataBytes; ++i) {
for (const block of blocks) {
const dataBytes = block.getDataBytes();
for (var i = 0; i < maxNumDataBytes; ++i) {
for (var _i = 0, blocks_1 = blocks; _i < blocks_1.length; _i++) {
var block = blocks_1[_i];
var dataBytes = block.getDataBytes();
if (i < dataBytes.length) {

@@ -401,5 +405,6 @@ result.appendBits(dataBytes[i], 8);

// Then, place error correction blocks.
for (let i = 0; i < maxNumEcBytes; ++i) {
for (const block of blocks) {
const ecBytes = block.getErrorCorrectionBytes();
for (var i = 0; i < maxNumEcBytes; ++i) {
for (var _a = 0, blocks_2 = blocks; _a < blocks_2.length; _a++) {
var block = blocks_2[_a];
var ecBytes = block.getErrorCorrectionBytes();
if (i < ecBytes.length) {

@@ -415,27 +420,27 @@ result.appendBits(ecBytes[i], 8);

return result;
}
static generateECBytes(dataBytes, numEcBytesInBlock /*int*/) {
const numDataBytes = dataBytes.length;
const toEncode = new Int32Array(numDataBytes + numEcBytesInBlock); // int[numDataBytes + numEcBytesInBlock]
for (let i = 0; i < numDataBytes; i++) {
};
Encoder.generateECBytes = function (dataBytes, numEcBytesInBlock /*int*/) {
var numDataBytes = dataBytes.length;
var toEncode = new Int32Array(numDataBytes + numEcBytesInBlock); // int[numDataBytes + numEcBytesInBlock]
for (var i = 0; i < numDataBytes; i++) {
toEncode[i] = dataBytes[i] & 0xFF;
}
new ReedSolomonEncoder_1.default(GenericGF_1.default.QR_CODE_FIELD_256).encode(toEncode, numEcBytesInBlock);
const ecBytes = new Uint8Array(numEcBytesInBlock);
for (let i = 0; i < numEcBytesInBlock; i++) {
var ecBytes = new Uint8Array(numEcBytesInBlock);
for (var i = 0; i < numEcBytesInBlock; i++) {
ecBytes[i] = /*(byte) */ toEncode[numDataBytes + i];
}
return ecBytes;
}
};
/**
* Append mode info. On success, store the result in "bits".
*/
static appendModeInfo(mode, bits) {
Encoder.appendModeInfo = function (mode, bits) {
bits.appendBits(mode.getBits(), 4);
}
};
/**
* Append length info. On success, store the result in "bits".
*/
static appendLengthInfo(numLetters /*int*/, version, mode, bits) {
const numBits = mode.getCharacterCountBits(version);
Encoder.appendLengthInfo = function (numLetters /*int*/, version, mode, bits) {
var numBits = mode.getCharacterCountBits(version);
if (numLetters >= (1 << numBits)) {

@@ -445,7 +450,7 @@ throw new Exception_1.default(Exception_1.default.WriterException, numLetters + ' is bigger than ' + ((1 << numBits) - 1));

bits.appendBits(numLetters, numBits);
}
};
/**
* Append "bytes" in "mode" mode (encoding) into "bits". On success, store the result in "bits".
*/
static appendBytes(content, mode, bits, encoding) {
Encoder.appendBytes = function (content, mode, bits, encoding) {
switch (mode) {

@@ -467,19 +472,19 @@ case Mode_1.default.NUMERIC:

}
}
static getDigit(singleCharacter) {
};
Encoder.getDigit = function (singleCharacter) {
return singleCharacter.charCodeAt(0) - 48;
}
static isDigit(singleCharacter) {
const cn = Encoder.getDigit(singleCharacter);
};
Encoder.isDigit = function (singleCharacter) {
var cn = Encoder.getDigit(singleCharacter);
return cn >= 0 && cn <= 9;
}
static appendNumericBytes(content, bits) {
const length = content.length;
let i = 0;
};
Encoder.appendNumericBytes = function (content, bits) {
var length = content.length;
var i = 0;
while (i < length) {
const num1 = Encoder.getDigit(content.charAt(i));
var num1 = Encoder.getDigit(content.charAt(i));
if (i + 2 < length) {
// Encode three numeric letters in ten bits.
const num2 = Encoder.getDigit(content.charAt(i + 1));
const num3 = Encoder.getDigit(content.charAt(i + 2));
var num2 = Encoder.getDigit(content.charAt(i + 1));
var num3 = Encoder.getDigit(content.charAt(i + 2));
bits.appendBits(num1 * 100 + num2 * 10 + num3, 10);

@@ -490,3 +495,3 @@ i += 3;

// Encode two numeric letters in seven bits.
const num2 = Encoder.getDigit(content.charAt(i + 1));
var num2 = Encoder.getDigit(content.charAt(i + 1));
bits.appendBits(num1 * 10 + num2, 7);

@@ -501,8 +506,8 @@ i += 2;

}
}
static appendAlphanumericBytes(content, bits) {
const length = content.length;
let i = 0;
};
Encoder.appendAlphanumericBytes = function (content, bits) {
var length = content.length;
var i = 0;
while (i < length) {
const code1 = Encoder.getAlphanumericCode(content.charCodeAt(i));
var code1 = Encoder.getAlphanumericCode(content.charCodeAt(i));
if (code1 === -1) {

@@ -512,3 +517,3 @@ throw new Exception_1.default(Exception_1.default.WriterException);

if (i + 1 < length) {
const code2 = Encoder.getAlphanumericCode(content.charCodeAt(i + 1));
var code2 = Encoder.getAlphanumericCode(content.charCodeAt(i + 1));
if (code2 === -1) {

@@ -527,5 +532,5 @@ throw new Exception_1.default(Exception_1.default.WriterException);

}
}
static append8BitBytes(content, bits, encoding) {
let bytes;
};
Encoder.append8BitBytes = function (content, bits, encoding) {
var bytes;
try {

@@ -537,9 +542,9 @@ bytes = StringEncoding_1.default.encode(content, encoding);

}
for (let i = 0, length = bytes.length; i !== length; i++) {
const b = bytes[i];
for (var i = 0, length_2 = bytes.length; i !== length_2; i++) {
var b = bytes[i];
bits.appendBits(b, 8);
}
}
static appendKanjiBytes(content, bits) {
let bytes;
};
Encoder.appendKanjiBytes = function (content, bits) {
var bytes;
try {

@@ -551,8 +556,8 @@ bytes = StringEncoding_1.default.encode(content, CharacterSetECI_1.default.SJIS.getName());

}
const length = bytes.length;
for (let i = 0; i < length; i += 2) {
const byte1 = bytes[i] & 0xFF;
const byte2 = bytes[i + 1] & 0xFF;
const code = ((byte1 << 8) & 0xFFFFFFFF) | byte2;
let subtracted = -1;
var length = bytes.length;
for (var i = 0; i < length; i += 2) {
var byte1 = bytes[i] & 0xFF;
var byte2 = bytes[i + 1] & 0xFF;
var code = ((byte1 << 8) & 0xFFFFFFFF) | byte2;
var subtracted = -1;
if (code >= 0x8140 && code <= 0x9ffc) {

@@ -567,23 +572,24 @@ subtracted = code - 0x8140;

}
const encoded = ((subtracted >> 8) * 0xc0) + (subtracted & 0xff);
var encoded = ((subtracted >> 8) * 0xc0) + (subtracted & 0xff);
bits.appendBits(encoded, 13);
}
}
static appendECI(eci, bits) {
};
Encoder.appendECI = function (eci, bits) {
bits.appendBits(Mode_1.default.ECI.getBits(), 4);
// This is correct for values up to 127, which is all we need now.
bits.appendBits(eci.getValue(), 8);
}
}
// The original table is defined in the table 5 of JISX0510:2004 (p.19).
Encoder.ALPHANUMERIC_TABLE = Int32Array.from([
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,
]);
Encoder.DEFAULT_BYTE_MODE_ENCODING = CharacterSetECI_1.default.UTF8.getName(); // "ISO-8859-1"
};
// The original table is defined in the table 5 of JISX0510:2004 (p.19).
Encoder.ALPHANUMERIC_TABLE = Int32Array.from([
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,
]);
Encoder.DEFAULT_BYTE_MODE_ENCODING = CharacterSetECI_1.default.UTF8.getName(); // "ISO-8859-1"
return Encoder;
}());
exports.default = Encoder;
//# sourceMappingURL=Encoder.js.map

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const Exception_1 = require("./../../Exception");
var Exception_1 = require("./../../Exception");
/**

@@ -25,4 +25,4 @@ * @author Satoru Takabayashi

*/
class MaskUtil {
constructor() {
var MaskUtil = /** @class */ (function () {
function MaskUtil() {
// do nothing

@@ -34,5 +34,5 @@ }

*/
static applyMaskPenaltyRule1(matrix) {
MaskUtil.applyMaskPenaltyRule1 = function (matrix) {
return MaskUtil.applyMaskPenaltyRule1Internal(matrix, true) + MaskUtil.applyMaskPenaltyRule1Internal(matrix, false);
}
};
/**

@@ -43,11 +43,11 @@ * Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give

*/
static applyMaskPenaltyRule2(matrix) {
let penalty = 0;
const array = matrix.getArray();
const width = matrix.getWidth();
const height = matrix.getHeight();
for (let y = 0; y < height - 1; y++) {
const arrayY = array[y];
for (let x = 0; x < width - 1; x++) {
const value = arrayY[x];
MaskUtil.applyMaskPenaltyRule2 = function (matrix) {
var penalty = 0;
var array = matrix.getArray();
var width = matrix.getWidth();
var height = matrix.getHeight();
for (var y = 0; y < height - 1; y++) {
var arrayY = array[y];
for (var x = 0; x < width - 1; x++) {
var value = arrayY[x];
if (value === arrayY[x + 1] && value === array[y + 1][x] && value === array[y + 1][x + 1]) {

@@ -59,3 +59,3 @@ penalty++;

return MaskUtil.N2 * penalty;
}
};
/**

@@ -66,10 +66,10 @@ * Apply mask penalty rule 3 and return the penalty. Find consecutive runs of 1:1:3:1:1:4

*/
static applyMaskPenaltyRule3(matrix) {
let numPenalties = 0;
const array = matrix.getArray();
const width = matrix.getWidth();
const height = matrix.getHeight();
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
const arrayY = array[y]; // We can at least optimize this access
MaskUtil.applyMaskPenaltyRule3 = function (matrix) {
var numPenalties = 0;
var array = matrix.getArray();
var width = matrix.getWidth();
var height = matrix.getHeight();
for (var y = 0; y < height; y++) {
for (var x = 0; x < width; x++) {
var arrayY = array[y]; // We can at least optimize this access
if (x + 6 < width &&

@@ -100,7 +100,7 @@ arrayY[x] === 1 &&

return numPenalties * MaskUtil.N3;
}
static isWhiteHorizontal(rowArray, from /*int*/, to /*int*/) {
};
MaskUtil.isWhiteHorizontal = function (rowArray, from /*int*/, to /*int*/) {
from = Math.max(from, 0);
to = Math.min(to, rowArray.length);
for (let i = from; i < to; i++) {
for (var i = from; i < to; i++) {
if (rowArray[i] === 1) {

@@ -111,7 +111,7 @@ return false;

return true;
}
static isWhiteVertical(array, col /*int*/, from /*int*/, to /*int*/) {
};
MaskUtil.isWhiteVertical = function (array, col /*int*/, from /*int*/, to /*int*/) {
from = Math.max(from, 0);
to = Math.min(to, array.length);
for (let i = from; i < to; i++) {
for (var i = from; i < to; i++) {
if (array[i][col] === 1) {

@@ -122,3 +122,3 @@ return false;

return true;
}
};
/**

@@ -128,10 +128,10 @@ * Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give

*/
static applyMaskPenaltyRule4(matrix) {
let numDarkCells = 0;
const array = matrix.getArray();
const width = matrix.getWidth();
const height = matrix.getHeight();
for (let y = 0; y < height; y++) {
const arrayY = array[y];
for (let x = 0; x < width; x++) {
MaskUtil.applyMaskPenaltyRule4 = function (matrix) {
var numDarkCells = 0;
var array = matrix.getArray();
var width = matrix.getWidth();
var height = matrix.getHeight();
for (var y = 0; y < height; y++) {
var arrayY = array[y];
for (var x = 0; x < width; x++) {
if (arrayY[x] === 1) {

@@ -142,6 +142,6 @@ numDarkCells++;

}
const numTotalCells = matrix.getHeight() * matrix.getWidth();
const fivePercentVariances = Math.floor(Math.abs(numDarkCells * 2 - numTotalCells) * 10 / numTotalCells);
var numTotalCells = matrix.getHeight() * matrix.getWidth();
var fivePercentVariances = Math.floor(Math.abs(numDarkCells * 2 - numTotalCells) * 10 / numTotalCells);
return fivePercentVariances * MaskUtil.N4;
}
};
/**

@@ -151,5 +151,5 @@ * Return the mask bit for "getMaskPattern" at "x" and "y". See 8.8 of JISX0510:2004 for mask

*/
static getDataMaskBit(maskPattern /*int*/, x /*int*/, y /*int*/) {
let intermediate; /*int*/
let temp; /*int*/
MaskUtil.getDataMaskBit = function (maskPattern /*int*/, x /*int*/, y /*int*/) {
var intermediate; /*int*/
var temp; /*int*/
switch (maskPattern) {

@@ -187,3 +187,3 @@ case 0:

return intermediate === 0;
}
};
/**

@@ -193,12 +193,12 @@ * Helper function for applyMaskPenaltyRule1. We need this for doing this calculation in both

*/
static applyMaskPenaltyRule1Internal(matrix, isHorizontal) {
let penalty = 0;
const iLimit = isHorizontal ? matrix.getHeight() : matrix.getWidth();
const jLimit = isHorizontal ? matrix.getWidth() : matrix.getHeight();
const array = matrix.getArray();
for (let i = 0; i < iLimit; i++) {
let numSameBitCells = 0;
let prevBit = -1;
for (let j = 0; j < jLimit; j++) {
const bit = isHorizontal ? array[i][j] : array[j][i];
MaskUtil.applyMaskPenaltyRule1Internal = function (matrix, isHorizontal) {
var penalty = 0;
var iLimit = isHorizontal ? matrix.getHeight() : matrix.getWidth();
var jLimit = isHorizontal ? matrix.getWidth() : matrix.getHeight();
var array = matrix.getArray();
for (var i = 0; i < iLimit; i++) {
var numSameBitCells = 0;
var prevBit = -1;
for (var j = 0; j < jLimit; j++) {
var bit = isHorizontal ? array[i][j] : array[j][i];
if (bit === prevBit) {

@@ -220,10 +220,11 @@ numSameBitCells++;

return penalty;
}
}
// Penalty weights from section 6.8.2.1
MaskUtil.N1 = 3;
MaskUtil.N2 = 3;
MaskUtil.N3 = 40;
MaskUtil.N4 = 10;
};
// Penalty weights from section 6.8.2.1
MaskUtil.N1 = 3;
MaskUtil.N2 = 3;
MaskUtil.N3 = 40;
MaskUtil.N4 = 10;
return MaskUtil;
}());
exports.default = MaskUtil;
//# sourceMappingURL=MaskUtil.js.map

@@ -19,7 +19,7 @@ "use strict";

/*namespace com.google.zxing.qrcode.encoder {*/
const BitArray_1 = require("./../../common/BitArray");
const Exception_1 = require("./../../Exception");
const Integer_1 = require("./../../util/Integer");
const QRCode_1 = require("./QRCode");
const MaskUtil_1 = require("./MaskUtil");
var BitArray_1 = require("./../../common/BitArray");
var Exception_1 = require("./../../Exception");
var Integer_1 = require("./../../util/Integer");
var QRCode_1 = require("./QRCode");
var MaskUtil_1 = require("./MaskUtil");
/**

@@ -29,4 +29,4 @@ * @author satorux@google.com (Satoru Takabayashi) - creator

*/
class MatrixUtil {
constructor() {
var MatrixUtil = /** @class */ (function () {
function MatrixUtil() {
// do nothing

@@ -38,9 +38,9 @@ }

// with the ByteMatrix initialized all to zero.
static clearMatrix(matrix) {
MatrixUtil.clearMatrix = function (matrix) {
// TYPESCRIPTPORT: we use UintArray se changed here from -1 to 255
matrix.clear(/*(byte) */ /*-1*/ 255);
}
};
// Build 2D matrix of QR Code from "dataBits" with "ecLevel", "version" and "getMaskPattern". On
// success, store the result in "matrix" and return true.
static buildMatrix(dataBits, ecLevel, version, maskPattern /*int*/, matrix) {
MatrixUtil.buildMatrix = function (dataBits, ecLevel, version, maskPattern /*int*/, matrix) {
MatrixUtil.clearMatrix(matrix);

@@ -54,3 +54,3 @@ MatrixUtil.embedBasicPatterns(version, matrix);

MatrixUtil.embedDataBits(dataBits, maskPattern, matrix);
}
};
// Embed basic patterns. On success, modify the matrix and return true.

@@ -62,3 +62,3 @@ // The basic patterns are:

// - Position adjustment patterns, if need be
static embedBasicPatterns(version, matrix) {
MatrixUtil.embedBasicPatterns = function (version, matrix) {
// Let's get started with embedding big squares at corners.

@@ -72,20 +72,20 @@ MatrixUtil.embedPositionDetectionPatternsAndSeparators(matrix);

MatrixUtil.embedTimingPatterns(matrix);
}
};
// Embed type information. On success, modify the matrix.
static embedTypeInfo(ecLevel, maskPattern /*int*/, matrix) {
const typeInfoBits = new BitArray_1.default();
MatrixUtil.embedTypeInfo = function (ecLevel, maskPattern /*int*/, matrix) {
var typeInfoBits = new BitArray_1.default();
MatrixUtil.makeTypeInfoBits(ecLevel, maskPattern, typeInfoBits);
for (let i = 0, size = typeInfoBits.getSize(); i < size; ++i) {
for (var i = 0, size = typeInfoBits.getSize(); i < size; ++i) {
// Place bits in LSB to MSB order. LSB (least significant bit) is the last value in
// "typeInfoBits".
const bit = typeInfoBits.get(typeInfoBits.getSize() - 1 - i);
var bit = typeInfoBits.get(typeInfoBits.getSize() - 1 - i);
// Type info bits at the left top corner. See 8.9 of JISX0510:2004 (p.46).
const coordinates = MatrixUtil.TYPE_INFO_COORDINATES[i];
const x1 = coordinates[0];
const y1 = coordinates[1];
var coordinates = MatrixUtil.TYPE_INFO_COORDINATES[i];
var x1 = coordinates[0];
var y1 = coordinates[1];
matrix.setBoolean(x1, y1, bit);
if (i < 8) {
// Right top corner.
const x2 = matrix.getWidth() - i - 1;
const y2 = 8;
var x2 = matrix.getWidth() - i - 1;
var y2 = 8;
matrix.setBoolean(x2, y2, bit);

@@ -95,21 +95,21 @@ }

// Left bottom corner.
const x2 = 8;
const y2 = matrix.getHeight() - 7 + (i - 8);
var x2 = 8;
var y2 = matrix.getHeight() - 7 + (i - 8);
matrix.setBoolean(x2, y2, bit);
}
}
}
};
// Embed version information if need be. On success, modify the matrix and return true.
// See 8.10 of JISX0510:2004 (p.47) for how to embed version information.
static maybeEmbedVersionInfo(version, matrix) {
MatrixUtil.maybeEmbedVersionInfo = function (version, matrix) {
if (version.getVersionNumber() < 7) {
return; // Don't need version info.
}
const versionInfoBits = new BitArray_1.default();
var versionInfoBits = new BitArray_1.default();
MatrixUtil.makeVersionInfoBits(version, versionInfoBits);
let bitIndex = 6 * 3 - 1; // It will decrease from 17 to 0.
for (let i = 0; i < 6; ++i) {
for (let j = 0; j < 3; ++j) {
var bitIndex = 6 * 3 - 1; // It will decrease from 17 to 0.
for (var i = 0; i < 6; ++i) {
for (var j = 0; j < 3; ++j) {
// Place bits in LSB (least significant bit) to MSB order.
const bit = versionInfoBits.get(bitIndex);
var bit = versionInfoBits.get(bitIndex);
bitIndex--;

@@ -122,12 +122,12 @@ // Left bottom corner.

}
}
};
// Embed "dataBits" using "getMaskPattern". On success, modify the matrix and return true.
// For debugging purposes, it skips masking process if "getMaskPattern" is -1(TYPESCRIPTPORT: 255).
// See 8.7 of JISX0510:2004 (p.38) for how to embed data bits.
static embedDataBits(dataBits, maskPattern /*int*/, matrix) {
let bitIndex = 0;
let direction = -1;
MatrixUtil.embedDataBits = function (dataBits, maskPattern /*int*/, matrix) {
var bitIndex = 0;
var direction = -1;
// Start from the right bottom cell.
let x = matrix.getWidth() - 1;
let y = matrix.getHeight() - 1;
var x = matrix.getWidth() - 1;
var y = matrix.getHeight() - 1;
while (x > 0) {

@@ -139,4 +139,4 @@ // Skip the vertical timing pattern.

while (y >= 0 && y < matrix.getHeight()) {
for (let i = 0; i < 2; ++i) {
const xx = x - i;
for (var i = 0; i < 2; ++i) {
var xx = x - i;
// Skip the cell if it's not empty.

@@ -146,3 +146,3 @@ if (!MatrixUtil.isEmpty(matrix.get(xx, y))) {

}
let bit;
var bit = void 0;
if (bitIndex < dataBits.getSize()) {

@@ -173,3 +173,3 @@ bit = dataBits.get(bitIndex);

}
}
};
// Return the position of the most significant bit set (one: to) in the "value". The most

@@ -180,5 +180,5 @@ // significant bit is position 32. If there is no bit set, return 0. Examples:

// - findMSBSet(255) => 8
static findMSBSet(value /*int*/) {
MatrixUtil.findMSBSet = function (value /*int*/) {
return 32 - Integer_1.default.numberOfLeadingZeros(value);
}
};
// Calculate BCH (Bose-Chaudhuri-Hocquenghem) code for "value" using polynomial "poly". The BCH

@@ -209,3 +209,3 @@ // code is used for encoding type information and version information.

// operations. We don't care if coefficients are positive or negative.
static calculateBCHCode(value /*int*/, poly /*int*/) {
MatrixUtil.calculateBCHCode = function (value /*int*/, poly /*int*/) {
if (poly === 0) {

@@ -216,3 +216,3 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException, '0 polynomial');

// from 13 to make it 12.
const msbSetInPoly = MatrixUtil.findMSBSet(poly);
var msbSetInPoly = MatrixUtil.findMSBSet(poly);
value <<= msbSetInPoly - 1;

@@ -225,15 +225,15 @@ // Do the division business using exclusive-or operations.

return value;
}
};
// Make bit vector of type information. On success, store the result in "bits" and return true.
// Encode error correction level and mask pattern. See 8.9 of
// JISX0510:2004 (p.45) for details.
static makeTypeInfoBits(ecLevel, maskPattern /*int*/, bits) {
MatrixUtil.makeTypeInfoBits = function (ecLevel, maskPattern /*int*/, bits) {
if (!QRCode_1.default.isValidMaskPattern(maskPattern)) {
throw new Exception_1.default(Exception_1.default.WriterException, 'Invalid mask pattern');
}
const typeInfo = (ecLevel.getBits() << 3) | maskPattern;
var typeInfo = (ecLevel.getBits() << 3) | maskPattern;
bits.appendBits(typeInfo, 5);
const bchCode = MatrixUtil.calculateBCHCode(typeInfo, MatrixUtil.TYPE_INFO_POLY);
var bchCode = MatrixUtil.calculateBCHCode(typeInfo, MatrixUtil.TYPE_INFO_POLY);
bits.appendBits(bchCode, 10);
const maskBits = new BitArray_1.default();
var maskBits = new BitArray_1.default();
maskBits.appendBits(MatrixUtil.TYPE_INFO_MASK_PATTERN, 15);

@@ -244,8 +244,8 @@ bits.xor(maskBits);

}
}
};
// Make bit vector of version information. On success, store the result in "bits" and return true.
// See 8.10 of JISX0510:2004 (p.45) for details.
static makeVersionInfoBits(version, bits) {
MatrixUtil.makeVersionInfoBits = function (version, bits) {
bits.appendBits(version.getVersionNumber(), 6);
const bchCode = MatrixUtil.calculateBCHCode(version.getVersionNumber(), MatrixUtil.VERSION_INFO_POLY);
var bchCode = MatrixUtil.calculateBCHCode(version.getVersionNumber(), MatrixUtil.VERSION_INFO_POLY);
bits.appendBits(bchCode, 12);

@@ -255,12 +255,12 @@ if (bits.getSize() !== 18) {

}
}
};
// Check if "value" is empty.
static isEmpty(value /*int*/) {
MatrixUtil.isEmpty = function (value /*int*/) {
return value === 255; // -1
}
static embedTimingPatterns(matrix) {
};
MatrixUtil.embedTimingPatterns = function (matrix) {
// -8 is for skipping position detection patterns (7: size), and two horizontal/vertical
// separation patterns (1: size). Thus, 8 = 7 + 1.
for (let i = 8; i < matrix.getWidth() - 8; ++i) {
const bit = (i + 1) % 2;
for (var i = 8; i < matrix.getWidth() - 8; ++i) {
var bit = (i + 1) % 2;
// Horizontal line.

@@ -275,5 +275,5 @@ if (MatrixUtil.isEmpty(matrix.get(i, 6))) {

}
}
};
// Embed the lonely dark dot at left bottom corner. JISX0510:2004 (p.46)
static embedDarkDotAtLeftBottomCorner(matrix) {
MatrixUtil.embedDarkDotAtLeftBottomCorner = function (matrix) {
if (matrix.get(8, matrix.getHeight() - 8) === 0) {

@@ -283,5 +283,5 @@ throw new Exception_1.default(Exception_1.default.WriterException);

matrix.setNumber(8, matrix.getHeight() - 8, 1);
}
static embedHorizontalSeparationPattern(xStart /*int*/, yStart /*int*/, matrix) {
for (let x = 0; x < 8; ++x) {
};
MatrixUtil.embedHorizontalSeparationPattern = function (xStart /*int*/, yStart /*int*/, matrix) {
for (var x = 0; x < 8; ++x) {
if (!MatrixUtil.isEmpty(matrix.get(xStart + x, yStart))) {

@@ -292,5 +292,5 @@ throw new Exception_1.default(Exception_1.default.WriterException);

}
}
static embedVerticalSeparationPattern(xStart /*int*/, yStart /*int*/, matrix) {
for (let y = 0; y < 7; ++y) {
};
MatrixUtil.embedVerticalSeparationPattern = function (xStart /*int*/, yStart /*int*/, matrix) {
for (var y = 0; y < 7; ++y) {
if (!MatrixUtil.isEmpty(matrix.get(xStart, yStart + y))) {

@@ -301,23 +301,23 @@ throw new Exception_1.default(Exception_1.default.WriterException);

}
}
static embedPositionAdjustmentPattern(xStart /*int*/, yStart /*int*/, matrix) {
for (let y = 0; y < 5; ++y) {
const patternY = MatrixUtil.POSITION_ADJUSTMENT_PATTERN[y];
for (let x = 0; x < 5; ++x) {
};
MatrixUtil.embedPositionAdjustmentPattern = function (xStart /*int*/, yStart /*int*/, matrix) {
for (var y = 0; y < 5; ++y) {
var patternY = MatrixUtil.POSITION_ADJUSTMENT_PATTERN[y];
for (var x = 0; x < 5; ++x) {
matrix.setNumber(xStart + x, yStart + y, patternY[x]);
}
}
}
static embedPositionDetectionPattern(xStart /*int*/, yStart /*int*/, matrix) {
for (let y = 0; y < 7; ++y) {
const patternY = MatrixUtil.POSITION_DETECTION_PATTERN[y];
for (let x = 0; x < 7; ++x) {
};
MatrixUtil.embedPositionDetectionPattern = function (xStart /*int*/, yStart /*int*/, matrix) {
for (var y = 0; y < 7; ++y) {
var patternY = MatrixUtil.POSITION_DETECTION_PATTERN[y];
for (var x = 0; x < 7; ++x) {
matrix.setNumber(xStart + x, yStart + y, patternY[x]);
}
}
}
};
// Embed position detection patterns and surrounding vertical/horizontal separators.
static embedPositionDetectionPatternsAndSeparators(matrix) {
MatrixUtil.embedPositionDetectionPatternsAndSeparators = function (matrix) {
// Embed three big squares at corners.
const pdpWidth = MatrixUtil.POSITION_DETECTION_PATTERN[0].length;
var pdpWidth = MatrixUtil.POSITION_DETECTION_PATTERN[0].length;
// Left top corner.

@@ -330,3 +330,3 @@ MatrixUtil.embedPositionDetectionPattern(0, 0, matrix);

// Embed horizontal separation patterns around the squares.
const hspWidth = 8;
var hspWidth = 8;
// Left top corner.

@@ -339,3 +339,3 @@ MatrixUtil.embedHorizontalSeparationPattern(0, hspWidth - 1, matrix);

// Embed vertical separation patterns around the squares.
const vspSize = 7;
var vspSize = 7;
// Left top corner.

@@ -347,15 +347,15 @@ MatrixUtil.embedVerticalSeparationPattern(vspSize, 0, matrix);

MatrixUtil.embedVerticalSeparationPattern(vspSize, matrix.getHeight() - vspSize, matrix);
}
};
// Embed position adjustment patterns if need be.
static maybeEmbedPositionAdjustmentPatterns(version, matrix) {
MatrixUtil.maybeEmbedPositionAdjustmentPatterns = function (version, matrix) {
if (version.getVersionNumber() < 2) {
return;
}
const index = version.getVersionNumber() - 1;
const coordinates = MatrixUtil.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];
for (let i = 0, length = coordinates.length; i !== length; i++) {
const y = coordinates[i];
var index = version.getVersionNumber() - 1;
var coordinates = MatrixUtil.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];
for (var i = 0, length_1 = coordinates.length; i !== length_1; i++) {
var y = coordinates[i];
if (y >= 0) {
for (let j = 0; j !== length; j++) {
const x = coordinates[j];
for (var j = 0; j !== length_1; j++) {
var x = coordinates[j];
if (x >= 0 && MatrixUtil.isEmpty(matrix.get(x, y))) {

@@ -370,87 +370,88 @@ // If the cell is unset, we embed the position adjustment pattern here.

}
}
}
MatrixUtil.POSITION_DETECTION_PATTERN = Array.from([
Int32Array.from([1, 1, 1, 1, 1, 1, 1]),
Int32Array.from([1, 0, 0, 0, 0, 0, 1]),
Int32Array.from([1, 0, 1, 1, 1, 0, 1]),
Int32Array.from([1, 0, 1, 1, 1, 0, 1]),
Int32Array.from([1, 0, 1, 1, 1, 0, 1]),
Int32Array.from([1, 0, 0, 0, 0, 0, 1]),
Int32Array.from([1, 1, 1, 1, 1, 1, 1]),
]);
MatrixUtil.POSITION_ADJUSTMENT_PATTERN = Array.from([
Int32Array.from([1, 1, 1, 1, 1]),
Int32Array.from([1, 0, 0, 0, 1]),
Int32Array.from([1, 0, 1, 0, 1]),
Int32Array.from([1, 0, 0, 0, 1]),
Int32Array.from([1, 1, 1, 1, 1]),
]);
// From Appendix E. Table 1, JIS0510X:2004 (71: p). The table was double-checked by komatsu.
MatrixUtil.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE = Array.from([
Int32Array.from([-1, -1, -1, -1, -1, -1, -1]),
Int32Array.from([6, 18, -1, -1, -1, -1, -1]),
Int32Array.from([6, 22, -1, -1, -1, -1, -1]),
Int32Array.from([6, 26, -1, -1, -1, -1, -1]),
Int32Array.from([6, 30, -1, -1, -1, -1, -1]),
Int32Array.from([6, 34, -1, -1, -1, -1, -1]),
Int32Array.from([6, 22, 38, -1, -1, -1, -1]),
Int32Array.from([6, 24, 42, -1, -1, -1, -1]),
Int32Array.from([6, 26, 46, -1, -1, -1, -1]),
Int32Array.from([6, 28, 50, -1, -1, -1, -1]),
Int32Array.from([6, 30, 54, -1, -1, -1, -1]),
Int32Array.from([6, 32, 58, -1, -1, -1, -1]),
Int32Array.from([6, 34, 62, -1, -1, -1, -1]),
Int32Array.from([6, 26, 46, 66, -1, -1, -1]),
Int32Array.from([6, 26, 48, 70, -1, -1, -1]),
Int32Array.from([6, 26, 50, 74, -1, -1, -1]),
Int32Array.from([6, 30, 54, 78, -1, -1, -1]),
Int32Array.from([6, 30, 56, 82, -1, -1, -1]),
Int32Array.from([6, 30, 58, 86, -1, -1, -1]),
Int32Array.from([6, 34, 62, 90, -1, -1, -1]),
Int32Array.from([6, 28, 50, 72, 94, -1, -1]),
Int32Array.from([6, 26, 50, 74, 98, -1, -1]),
Int32Array.from([6, 30, 54, 78, 102, -1, -1]),
Int32Array.from([6, 28, 54, 80, 106, -1, -1]),
Int32Array.from([6, 32, 58, 84, 110, -1, -1]),
Int32Array.from([6, 30, 58, 86, 114, -1, -1]),
Int32Array.from([6, 34, 62, 90, 118, -1, -1]),
Int32Array.from([6, 26, 50, 74, 98, 122, -1]),
Int32Array.from([6, 30, 54, 78, 102, 126, -1]),
Int32Array.from([6, 26, 52, 78, 104, 130, -1]),
Int32Array.from([6, 30, 56, 82, 108, 134, -1]),
Int32Array.from([6, 34, 60, 86, 112, 138, -1]),
Int32Array.from([6, 30, 58, 86, 114, 142, -1]),
Int32Array.from([6, 34, 62, 90, 118, 146, -1]),
Int32Array.from([6, 30, 54, 78, 102, 126, 150]),
Int32Array.from([6, 24, 50, 76, 102, 128, 154]),
Int32Array.from([6, 28, 54, 80, 106, 132, 158]),
Int32Array.from([6, 32, 58, 84, 110, 136, 162]),
Int32Array.from([6, 26, 54, 82, 110, 138, 166]),
Int32Array.from([6, 30, 58, 86, 114, 142, 170]),
]);
// Type info cells at the left top corner.
MatrixUtil.TYPE_INFO_COORDINATES = Array.from([
Int32Array.from([8, 0]),
Int32Array.from([8, 1]),
Int32Array.from([8, 2]),
Int32Array.from([8, 3]),
Int32Array.from([8, 4]),
Int32Array.from([8, 5]),
Int32Array.from([8, 7]),
Int32Array.from([8, 8]),
Int32Array.from([7, 8]),
Int32Array.from([5, 8]),
Int32Array.from([4, 8]),
Int32Array.from([3, 8]),
Int32Array.from([2, 8]),
Int32Array.from([1, 8]),
Int32Array.from([0, 8]),
]);
// From Appendix D in JISX0510:2004 (p. 67)
MatrixUtil.VERSION_INFO_POLY = 0x1f25; // 1 1111 0010 0101
// From Appendix C in JISX0510:2004 (p.65).
MatrixUtil.TYPE_INFO_POLY = 0x537;
MatrixUtil.TYPE_INFO_MASK_PATTERN = 0x5412;
};
MatrixUtil.POSITION_DETECTION_PATTERN = Array.from([
Int32Array.from([1, 1, 1, 1, 1, 1, 1]),
Int32Array.from([1, 0, 0, 0, 0, 0, 1]),
Int32Array.from([1, 0, 1, 1, 1, 0, 1]),
Int32Array.from([1, 0, 1, 1, 1, 0, 1]),
Int32Array.from([1, 0, 1, 1, 1, 0, 1]),
Int32Array.from([1, 0, 0, 0, 0, 0, 1]),
Int32Array.from([1, 1, 1, 1, 1, 1, 1]),
]);
MatrixUtil.POSITION_ADJUSTMENT_PATTERN = Array.from([
Int32Array.from([1, 1, 1, 1, 1]),
Int32Array.from([1, 0, 0, 0, 1]),
Int32Array.from([1, 0, 1, 0, 1]),
Int32Array.from([1, 0, 0, 0, 1]),
Int32Array.from([1, 1, 1, 1, 1]),
]);
// From Appendix E. Table 1, JIS0510X:2004 (71: p). The table was double-checked by komatsu.
MatrixUtil.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE = Array.from([
Int32Array.from([-1, -1, -1, -1, -1, -1, -1]),
Int32Array.from([6, 18, -1, -1, -1, -1, -1]),
Int32Array.from([6, 22, -1, -1, -1, -1, -1]),
Int32Array.from([6, 26, -1, -1, -1, -1, -1]),
Int32Array.from([6, 30, -1, -1, -1, -1, -1]),
Int32Array.from([6, 34, -1, -1, -1, -1, -1]),
Int32Array.from([6, 22, 38, -1, -1, -1, -1]),
Int32Array.from([6, 24, 42, -1, -1, -1, -1]),
Int32Array.from([6, 26, 46, -1, -1, -1, -1]),
Int32Array.from([6, 28, 50, -1, -1, -1, -1]),
Int32Array.from([6, 30, 54, -1, -1, -1, -1]),
Int32Array.from([6, 32, 58, -1, -1, -1, -1]),
Int32Array.from([6, 34, 62, -1, -1, -1, -1]),
Int32Array.from([6, 26, 46, 66, -1, -1, -1]),
Int32Array.from([6, 26, 48, 70, -1, -1, -1]),
Int32Array.from([6, 26, 50, 74, -1, -1, -1]),
Int32Array.from([6, 30, 54, 78, -1, -1, -1]),
Int32Array.from([6, 30, 56, 82, -1, -1, -1]),
Int32Array.from([6, 30, 58, 86, -1, -1, -1]),
Int32Array.from([6, 34, 62, 90, -1, -1, -1]),
Int32Array.from([6, 28, 50, 72, 94, -1, -1]),
Int32Array.from([6, 26, 50, 74, 98, -1, -1]),
Int32Array.from([6, 30, 54, 78, 102, -1, -1]),
Int32Array.from([6, 28, 54, 80, 106, -1, -1]),
Int32Array.from([6, 32, 58, 84, 110, -1, -1]),
Int32Array.from([6, 30, 58, 86, 114, -1, -1]),
Int32Array.from([6, 34, 62, 90, 118, -1, -1]),
Int32Array.from([6, 26, 50, 74, 98, 122, -1]),
Int32Array.from([6, 30, 54, 78, 102, 126, -1]),
Int32Array.from([6, 26, 52, 78, 104, 130, -1]),
Int32Array.from([6, 30, 56, 82, 108, 134, -1]),
Int32Array.from([6, 34, 60, 86, 112, 138, -1]),
Int32Array.from([6, 30, 58, 86, 114, 142, -1]),
Int32Array.from([6, 34, 62, 90, 118, 146, -1]),
Int32Array.from([6, 30, 54, 78, 102, 126, 150]),
Int32Array.from([6, 24, 50, 76, 102, 128, 154]),
Int32Array.from([6, 28, 54, 80, 106, 132, 158]),
Int32Array.from([6, 32, 58, 84, 110, 136, 162]),
Int32Array.from([6, 26, 54, 82, 110, 138, 166]),
Int32Array.from([6, 30, 58, 86, 114, 142, 170]),
]);
// Type info cells at the left top corner.
MatrixUtil.TYPE_INFO_COORDINATES = Array.from([
Int32Array.from([8, 0]),
Int32Array.from([8, 1]),
Int32Array.from([8, 2]),
Int32Array.from([8, 3]),
Int32Array.from([8, 4]),
Int32Array.from([8, 5]),
Int32Array.from([8, 7]),
Int32Array.from([8, 8]),
Int32Array.from([7, 8]),
Int32Array.from([5, 8]),
Int32Array.from([4, 8]),
Int32Array.from([3, 8]),
Int32Array.from([2, 8]),
Int32Array.from([1, 8]),
Int32Array.from([0, 8]),
]);
// From Appendix D in JISX0510:2004 (p. 67)
MatrixUtil.VERSION_INFO_POLY = 0x1f25; // 1 1111 0010 0101
// From Appendix C in JISX0510:2004 (p.65).
MatrixUtil.TYPE_INFO_POLY = 0x537;
MatrixUtil.TYPE_INFO_MASK_PATTERN = 0x5412;
return MatrixUtil;
}());
exports.default = MatrixUtil;
//# sourceMappingURL=MatrixUtil.js.map

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const StringBuilder_1 = require("./../../util/StringBuilder");
var StringBuilder_1 = require("./../../util/StringBuilder");
/**

@@ -24,24 +24,24 @@ * @author satorux@google.com (Satoru Takabayashi) - creator

*/
class QRCode {
constructor() {
var QRCode = /** @class */ (function () {
function QRCode() {
this.maskPattern = -1;
}
getMode() {
QRCode.prototype.getMode = function () {
return this.mode;
}
getECLevel() {
};
QRCode.prototype.getECLevel = function () {
return this.ecLevel;
}
getVersion() {
};
QRCode.prototype.getVersion = function () {
return this.version;
}
getMaskPattern() {
};
QRCode.prototype.getMaskPattern = function () {
return this.maskPattern;
}
getMatrix() {
};
QRCode.prototype.getMatrix = function () {
return this.matrix;
}
};
/*@Override*/
toString() {
const result = new StringBuilder_1.default(); // (200)
QRCode.prototype.toString = function () {
var result = new StringBuilder_1.default(); // (200)
result.append('<<\n');

@@ -65,25 +65,26 @@ result.append(' mode: ');

return result.toString();
}
setMode(value) {
};
QRCode.prototype.setMode = function (value) {
this.mode = value;
}
setECLevel(value) {
};
QRCode.prototype.setECLevel = function (value) {
this.ecLevel = value;
}
setVersion(version) {
};
QRCode.prototype.setVersion = function (version) {
this.version = version;
}
setMaskPattern(value /*int*/) {
};
QRCode.prototype.setMaskPattern = function (value /*int*/) {
this.maskPattern = value;
}
setMatrix(value) {
};
QRCode.prototype.setMatrix = function (value) {
this.matrix = value;
}
};
// Check if "mask_pattern" is valid.
static isValidMaskPattern(maskPattern /*int*/) {
QRCode.isValidMaskPattern = function (maskPattern /*int*/) {
return maskPattern >= 0 && maskPattern < QRCode.NUM_MASK_PATTERNS;
}
}
QRCode.NUM_MASK_PATTERNS = 8;
};
QRCode.NUM_MASK_PATTERNS = 8;
return QRCode;
}());
exports.default = QRCode;
//# sourceMappingURL=QRCode.js.map

@@ -18,9 +18,9 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const Result_1 = require("./../Result");
const ResultMetadataType_1 = require("./../ResultMetadataType");
const BitMatrix_1 = require("./../common/BitMatrix");
const Decoder_1 = require("./decoder/Decoder");
const QRCodeDecoderMetaData_1 = require("./decoder/QRCodeDecoderMetaData");
const Detector_1 = require("./detector/Detector");
const Exception_1 = require("./../Exception");
var Result_1 = require("./../Result");
var ResultMetadataType_1 = require("./../ResultMetadataType");
var BitMatrix_1 = require("./../common/BitMatrix");
var Decoder_1 = require("./decoder/Decoder");
var QRCodeDecoderMetaData_1 = require("./decoder/QRCodeDecoderMetaData");
var Detector_1 = require("./detector/Detector");
var Exception_1 = require("./../Exception");
/*import java.util.List;*/

@@ -33,9 +33,9 @@ /*import java.util.Map;*/

*/
class QRCodeReader {
constructor() {
var QRCodeReader = /** @class */ (function () {
function QRCodeReader() {
this.decoder = new Decoder_1.default();
}
getDecoder() {
QRCodeReader.prototype.getDecoder = function () {
return this.decoder;
}
};
/**

@@ -54,7 +54,7 @@ * Locates and decodes a QR code in an image.

/*@Override*/
decode(image, hints) {
let decoderResult;
let points;
QRCodeReader.prototype.decode = function (image, hints) {
var decoderResult;
var points;
if (hints !== undefined && hints !== null && undefined !== hints.get(1 /* PURE_BARCODE */)) {
const bits = QRCodeReader.extractPureBits(image.getBlackMatrix());
var bits = QRCodeReader.extractPureBits(image.getBlackMatrix());
decoderResult = this.decoder.decodeBitMatrix(bits, hints);

@@ -64,3 +64,3 @@ points = QRCodeReader.NO_POINTS;

else {
const detectorResult = new Detector_1.default(image.getBlackMatrix()).detect(hints);
var detectorResult = new Detector_1.default(image.getBlackMatrix()).detect(hints);
decoderResult = this.decoder.decodeBitMatrix(detectorResult.getBits(), hints);

@@ -73,8 +73,8 @@ points = detectorResult.getPoints();

}
const result = new Result_1.default(decoderResult.getText(), decoderResult.getRawBytes(), undefined, points, 11 /* QR_CODE */, undefined);
const byteSegments = decoderResult.getByteSegments();
var result = new Result_1.default(decoderResult.getText(), decoderResult.getRawBytes(), undefined, points, 11 /* QR_CODE */, undefined);
var byteSegments = decoderResult.getByteSegments();
if (byteSegments !== null) {
result.putMetadata(ResultMetadataType_1.default.BYTE_SEGMENTS, byteSegments);
}
const ecLevel = decoderResult.getECLevel();
var ecLevel = decoderResult.getECLevel();
if (ecLevel !== null) {

@@ -88,7 +88,7 @@ result.putMetadata(ResultMetadataType_1.default.ERROR_CORRECTION_LEVEL, ecLevel);

return result;
}
};
/*@Override*/
reset() {
QRCodeReader.prototype.reset = function () {
// do nothing
}
};
/**

@@ -102,13 +102,13 @@ * This method detects a code in a "pure" image -- that is, pure monochrome image

*/
static extractPureBits(image) {
const leftTopBlack = image.getTopLeftOnBit();
const rightBottomBlack = image.getBottomRightOnBit();
QRCodeReader.extractPureBits = function (image) {
var leftTopBlack = image.getTopLeftOnBit();
var rightBottomBlack = image.getBottomRightOnBit();
if (leftTopBlack === null || rightBottomBlack === null) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
}
const moduleSize = this.moduleSize(leftTopBlack, image);
let top = leftTopBlack[1];
let bottom = rightBottomBlack[1];
let left = leftTopBlack[0];
let right = rightBottomBlack[0];
var moduleSize = this.moduleSize(leftTopBlack, image);
var top = leftTopBlack[1];
var bottom = rightBottomBlack[1];
var left = leftTopBlack[0];
var right = rightBottomBlack[0];
// Sanity check!

@@ -127,4 +127,4 @@ if (left >= right || top >= bottom) {

}
const matrixWidth = Math.round((right - left + 1) / moduleSize);
const matrixHeight = Math.round((bottom - top + 1) / moduleSize);
var matrixWidth = Math.round((right - left + 1) / moduleSize);
var matrixHeight = Math.round((bottom - top + 1) / moduleSize);
if (matrixWidth <= 0 || matrixHeight <= 0) {

@@ -140,3 +140,3 @@ throw new Exception_1.default(Exception_1.default.NotFoundException);

// little off, this will help recover.
const nudge = Math.floor(moduleSize / 2.0);
var nudge = Math.floor(moduleSize / 2.0);
top += nudge;

@@ -147,3 +147,3 @@ left += nudge;

// This is positive by how much the inner x loop below would be too large
const nudgedTooFarRight = left + /*(int) */ Math.floor((matrixWidth - 1) * moduleSize) - right;
var nudgedTooFarRight = left + /*(int) */ Math.floor((matrixWidth - 1) * moduleSize) - right;
if (nudgedTooFarRight > 0) {

@@ -157,3 +157,3 @@ if (nudgedTooFarRight > nudge) {

// See logic above
const nudgedTooFarDown = top + /*(int) */ Math.floor((matrixHeight - 1) * moduleSize) - bottom;
var nudgedTooFarDown = top + /*(int) */ Math.floor((matrixHeight - 1) * moduleSize) - bottom;
if (nudgedTooFarDown > 0) {

@@ -167,6 +167,6 @@ if (nudgedTooFarDown > nudge) {

// Now just read off the bits
const bits = new BitMatrix_1.default(matrixWidth, matrixHeight);
for (let y = 0; y < matrixHeight; y++) {
const iOffset = top + /*(int) */ Math.floor(y * moduleSize);
for (let x = 0; x < matrixWidth; x++) {
var bits = new BitMatrix_1.default(matrixWidth, matrixHeight);
for (var y = 0; y < matrixHeight; y++) {
var iOffset = top + /*(int) */ Math.floor(y * moduleSize);
for (var x = 0; x < matrixWidth; x++) {
if (image.get(left + /*(int) */ Math.floor(x * moduleSize), iOffset)) {

@@ -178,10 +178,10 @@ bits.set(x, y);

return bits;
}
static moduleSize(leftTopBlack, image) {
const height = image.getHeight();
const width = image.getWidth();
let x = leftTopBlack[0];
let y = leftTopBlack[1];
let inBlack = true;
let transitions = 0;
};
QRCodeReader.moduleSize = function (leftTopBlack, image) {
var height = image.getHeight();
var width = image.getWidth();
var x = leftTopBlack[0];
var y = leftTopBlack[1];
var inBlack = true;
var transitions = 0;
while (x < width && y < height) {

@@ -201,6 +201,7 @@ if (inBlack !== image.get(x, y)) {

return (x - leftTopBlack[0]) / 7.0;
}
}
QRCodeReader.NO_POINTS = new Array();
};
QRCodeReader.NO_POINTS = new Array();
return QRCodeReader;
}());
exports.default = QRCodeReader;
//# sourceMappingURL=QRCodeReader.js.map

@@ -18,7 +18,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const EncodeHintType_1 = require("./../EncodeHintType");
const BitMatrix_1 = require("./../common/BitMatrix");
const ErrorCorrectionLevel_1 = require("./decoder/ErrorCorrectionLevel");
const Encoder_1 = require("./encoder/Encoder");
const Exception_1 = require("./../Exception");
var EncodeHintType_1 = require("./../EncodeHintType");
var BitMatrix_1 = require("./../common/BitMatrix");
var ErrorCorrectionLevel_1 = require("./decoder/ErrorCorrectionLevel");
var Encoder_1 = require("./encoder/Encoder");
var Exception_1 = require("./../Exception");
/*import java.util.Map;*/

@@ -30,3 +30,5 @@ /**

*/
class QRCodeWriter {
var QRCodeWriter = /** @class */ (function () {
function QRCodeWriter() {
}
/*@Override*/

@@ -38,3 +40,3 @@ // public encode(contents: string, format: BarcodeFormat, width: number /*int*/, height: number /*int*/): BitMatrix

/*@Override*/
encode(contents, format, width /*int*/, height /*int*/, hints) {
QRCodeWriter.prototype.encode = function (contents, format, width /*int*/, height /*int*/, hints) {
if (contents.length === 0) {

@@ -50,4 +52,4 @@ throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Found empty contents');

}
let errorCorrectionLevel = ErrorCorrectionLevel_1.default.L;
let quietZone = QRCodeWriter.QUIET_ZONE_SIZE;
var errorCorrectionLevel = ErrorCorrectionLevel_1.default.L;
var quietZone = QRCodeWriter.QUIET_ZONE_SIZE;
if (hints !== null) {

@@ -61,19 +63,19 @@ if (undefined !== hints.get(EncodeHintType_1.default.ERROR_CORRECTION)) {

}
const code = Encoder_1.default.encode(contents, errorCorrectionLevel, hints);
var code = Encoder_1.default.encode(contents, errorCorrectionLevel, hints);
return QRCodeWriter.renderResult(code, width, height, quietZone);
}
};
// Note that the input matrix uses 0 == white, 1 == black, while the output matrix uses
// 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
static renderResult(code, width /*int*/, height /*int*/, quietZone /*int*/) {
const input = code.getMatrix();
QRCodeWriter.renderResult = function (code, width /*int*/, height /*int*/, quietZone /*int*/) {
var input = code.getMatrix();
if (input === null) {
throw new Exception_1.default(Exception_1.default.IllegalStateException);
}
const inputWidth = input.getWidth();
const inputHeight = input.getHeight();
const qrWidth = inputWidth + (quietZone * 2);
const qrHeight = inputHeight + (quietZone * 2);
const outputWidth = Math.max(width, qrWidth);
const outputHeight = Math.max(height, qrHeight);
const multiple = Math.min(Math.floor(outputWidth / qrWidth), Math.floor(outputHeight / qrHeight));
var inputWidth = input.getWidth();
var inputHeight = input.getHeight();
var qrWidth = inputWidth + (quietZone * 2);
var qrHeight = inputHeight + (quietZone * 2);
var outputWidth = Math.max(width, qrWidth);
var outputHeight = Math.max(height, qrHeight);
var multiple = Math.min(Math.floor(outputWidth / qrWidth), Math.floor(outputHeight / qrHeight));
// Padding includes both the quiet zone and the extra white pixels to accommodate the requested

@@ -83,8 +85,8 @@ // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.

// handle all the padding from 100x100 (the actual QR) up to 200x160.
const leftPadding = Math.floor((outputWidth - (inputWidth * multiple)) / 2);
const topPadding = Math.floor((outputHeight - (inputHeight * multiple)) / 2);
const output = new BitMatrix_1.default(outputWidth, outputHeight);
for (let inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
var leftPadding = Math.floor((outputWidth - (inputWidth * multiple)) / 2);
var topPadding = Math.floor((outputHeight - (inputHeight * multiple)) / 2);
var output = new BitMatrix_1.default(outputWidth, outputHeight);
for (var inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
// Write the contents of this row of the barcode
for (let inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
for (var inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
if (input.get(inputX, inputY) === 1) {

@@ -96,6 +98,7 @@ output.setRegion(outputX, outputY, multiple, multiple);

return output;
}
}
QRCodeWriter.QUIET_ZONE_SIZE = 4;
};
QRCodeWriter.QUIET_ZONE_SIZE = 4;
return QRCodeWriter;
}());
exports.default = QRCodeWriter;
//# sourceMappingURL=QRCodeWriter.js.map

@@ -21,4 +21,4 @@ "use strict";

/*import java.util.Map;*/
const ResultPoint_1 = require("./ResultPoint");
const System_1 = require("./util/System");
var ResultPoint_1 = require("./ResultPoint");
var System_1 = require("./util/System");
/**

@@ -29,3 +29,3 @@ * <p>Encapsulates the result of decoding a barcode within an image.</p>

*/
class Result {
var Result = /** @class */ (function () {
// public constructor(private text: string,

@@ -45,3 +45,3 @@ // Uint8Array rawBytes,

// }
constructor(text, rawBytes, numBits /*int*/, resultPoints, format, timestamp /*long*/) {
function Result(text, rawBytes, numBits /*int*/, resultPoints, format, timestamp /*long*/) {
this.text = text;

@@ -74,11 +74,11 @@ this.rawBytes = rawBytes;

*/
getText() {
Result.prototype.getText = function () {
return this.text;
}
};
/**
* @return raw bytes encoded by the barcode, if applicable, otherwise {@code null}
*/
getRawBytes() {
Result.prototype.getRawBytes = function () {
return this.rawBytes;
}
};
/**

@@ -88,5 +88,5 @@ * @return how many bits of {@link #getRawBytes()} are valid; typically 8 times its length

*/
getNumBits() {
Result.prototype.getNumBits = function () {
return this.numBits;
}
};
/**

@@ -97,11 +97,11 @@ * @return points related to the barcode in the image. These are typically points

*/
getResultPoints() {
Result.prototype.getResultPoints = function () {
return this.resultPoints;
}
};
/**
* @return {@link BarcodeFormat} representing the format of the barcode that was decoded
*/
getBarcodeFormat() {
Result.prototype.getBarcodeFormat = function () {
return this.format;
}
};
/**

@@ -112,6 +112,6 @@ * @return {@link Map} mapping {@link ResultMetadataType} keys to values. May be

*/
getResultMetadata() {
Result.prototype.getResultMetadata = function () {
return this.resultMetadata;
}
putMetadata(type, value) {
};
Result.prototype.putMetadata = function (type, value) {
if (this.resultMetadata === null) {

@@ -121,4 +121,4 @@ this.resultMetadata = new Map();

this.resultMetadata.set(type, value);
}
putAllMetadata(metadata) {
};
Result.prototype.putAllMetadata = function (metadata) {
if (metadata !== null) {

@@ -132,5 +132,5 @@ if (this.resultMetadata === null) {

}
}
addResultPoints(newPoints) {
const oldPoints = this.resultPoints;
};
Result.prototype.addResultPoints = function (newPoints) {
var oldPoints = this.resultPoints;
if (oldPoints === null) {

@@ -140,3 +140,3 @@ this.resultPoints = newPoints;

else if (newPoints !== null && newPoints.length > 0) {
const allPoints = new ResultPoint_1.default[oldPoints.length + newPoints.length];
var allPoints = new ResultPoint_1.default[oldPoints.length + newPoints.length];
System_1.default.arraycopy(oldPoints, 0, allPoints, 0, oldPoints.length);

@@ -146,12 +146,13 @@ System_1.default.arraycopy(newPoints, 0, allPoints, oldPoints.length, newPoints.length);

}
}
getTimestamp() {
};
Result.prototype.getTimestamp = function () {
return this.timestamp;
}
};
/*@Override*/
toString() {
Result.prototype.toString = function () {
return this.text;
}
}
};
return Result;
}());
exports.default = Result;
//# sourceMappingURL=Result.js.map

@@ -19,4 +19,4 @@ "use strict";

/*namespace com.google.zxing {*/
const MathUtils_1 = require("./common/detector/MathUtils");
const Float_1 = require("./util/Float");
var MathUtils_1 = require("./common/detector/MathUtils");
var Float_1 = require("./util/Float");
/**

@@ -28,29 +28,29 @@ * <p>Encapsulates a point of interest in an image containing a barcode. Typically, this

*/
class ResultPoint {
constructor(x /*float*/, y /*float*/) {
var ResultPoint = /** @class */ (function () {
function ResultPoint(x /*float*/, y /*float*/) {
this.x = x; /*float*/
this.y = y; /*float*/
}
getX() {
ResultPoint.prototype.getX = function () {
return this.x;
}
getY() {
};
ResultPoint.prototype.getY = function () {
return this.y;
}
};
/*@Override*/
equals(other) {
ResultPoint.prototype.equals = function (other) {
if (other instanceof ResultPoint) {
const otherPoint = other;
var otherPoint = other;
return this.x === otherPoint.x && this.y === otherPoint.y;
}
return false;
}
};
/*@Override*/
hashCode() {
ResultPoint.prototype.hashCode = function () {
return 31 * Float_1.default.floatToIntBits(this.x) + Float_1.default.floatToIntBits(this.y);
}
};
/*@Override*/
toString() {
ResultPoint.prototype.toString = function () {
return '(' + this.x + ',' + this.y + ')';
}
};
/**

@@ -62,10 +62,10 @@ * Orders an array of three ResultPoints in an order [A,B,C] such that AB is less than AC

*/
static orderBestPatterns(patterns) {
ResultPoint.orderBestPatterns = function (patterns) {
// Find distances between pattern centers
const zeroOneDistance = this.distance(patterns[0], patterns[1]);
const oneTwoDistance = this.distance(patterns[1], patterns[2]);
const zeroTwoDistance = this.distance(patterns[0], patterns[2]);
let pointA;
let pointB;
let pointC;
var zeroOneDistance = this.distance(patterns[0], patterns[1]);
var oneTwoDistance = this.distance(patterns[1], patterns[2]);
var zeroTwoDistance = this.distance(patterns[0], patterns[2]);
var pointA;
var pointB;
var pointC;
// Assume one closest to other two is B; A and C will just be guesses at first

@@ -92,3 +92,3 @@ if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) {

if (this.crossProductZ(pointA, pointB, pointC) < 0.0) {
const temp = pointA;
var temp = pointA;
pointA = pointC;

@@ -100,3 +100,3 @@ pointC = temp;

patterns[2] = pointC;
}
};
/**

@@ -107,15 +107,16 @@ * @param pattern1 first pattern

*/
static distance(pattern1, pattern2) {
ResultPoint.distance = function (pattern1, pattern2) {
return MathUtils_1.default.distance(pattern1.x, pattern1.y, pattern2.x, pattern2.y);
}
};
/**
* Returns the z component of the cross product between vectors BC and BA.
*/
static crossProductZ(pointA, pointB, pointC) {
const bX = pointB.x;
const bY = pointB.y;
ResultPoint.crossProductZ = function (pointA, pointB, pointC) {
var bX = pointB.x;
var bY = pointB.y;
return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX));
}
}
};
return ResultPoint;
}());
exports.default = ResultPoint;
//# sourceMappingURL=ResultPoint.js.map

@@ -17,9 +17,19 @@ "use strict";

*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
/*namespace com.google.zxing {*/
require("./InvertedLuminanceSource"); // required because of circular dependencies between LuminanceSource and InvertedLuminanceSource
const InvertedLuminanceSource_1 = require("./InvertedLuminanceSource");
const LuminanceSource_1 = require("./LuminanceSource");
const Exception_1 = require("./Exception");
const System_1 = require("./util/System");
var InvertedLuminanceSource_1 = require("./InvertedLuminanceSource");
var LuminanceSource_1 = require("./LuminanceSource");
var Exception_1 = require("./Exception");
var System_1 = require("./util/System");
/**

@@ -32,58 +42,60 @@ * This class is used to help decode images from files which arrive as RGB data from

*/
class RGBLuminanceSource extends LuminanceSource_1.default {
constructor(luminances, width /*int*/, height /*int*/, dataWidth /*int*/, dataHeight /*int*/, left /*int*/, top /*int*/) {
super(width, height);
this.dataWidth = dataWidth; /*int*/
this.dataHeight = dataHeight; /*int*/
this.left = left; /*int*/
this.top = top; /*int*/
var RGBLuminanceSource = /** @class */ (function (_super) {
__extends(RGBLuminanceSource, _super);
function RGBLuminanceSource(luminances, width /*int*/, height /*int*/, dataWidth /*int*/, dataHeight /*int*/, left /*int*/, top /*int*/) {
var _this = _super.call(this, width, height) || this;
_this.dataWidth = dataWidth; /*int*/
_this.dataHeight = dataHeight; /*int*/
_this.left = left; /*int*/
_this.top = top; /*int*/
if (luminances.BYTES_PER_ELEMENT === 4) {
const size = width * height;
const luminancesUint8Array = new Uint8ClampedArray(size);
for (let offset = 0; offset < size; offset++) {
const pixel = luminances[offset];
const r = (pixel >> 16) & 0xff; // red
const g2 = (pixel >> 7) & 0x1fe; // 2 * green
const b = pixel & 0xff; // blue
var size = width * height;
var luminancesUint8Array = new Uint8ClampedArray(size);
for (var offset = 0; offset < size; offset++) {
var pixel = luminances[offset];
var r = (pixel >> 16) & 0xff; // red
var g2 = (pixel >> 7) & 0x1fe; // 2 * green
var b = pixel & 0xff; // blue
// Calculate green-favouring average cheaply
luminancesUint8Array[offset] = /*(byte) */ ((r + g2 + b) / 4) & 0xFF;
}
this.luminances = luminancesUint8Array;
_this.luminances = luminancesUint8Array;
}
else {
this.luminances = luminances;
_this.luminances = luminances;
}
if (undefined === dataWidth) {
this.dataWidth = width;
_this.dataWidth = width;
}
if (undefined === dataHeight) {
this.dataHeight = height;
_this.dataHeight = height;
}
if (undefined === left) {
this.left = 0;
_this.left = 0;
}
if (undefined === top) {
this.top = 0;
_this.top = 0;
}
if (this.left + width > this.dataWidth || this.top + height > this.dataHeight) {
if (_this.left + width > _this.dataWidth || _this.top + height > _this.dataHeight) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Crop rectangle does not fit within image data.');
}
return _this;
}
/*@Override*/
getRow(y /*int*/, row) {
RGBLuminanceSource.prototype.getRow = function (y /*int*/, row) {
if (y < 0 || y >= this.getHeight()) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Requested row is outside the image: ' + y);
}
const width = this.getWidth();
var width = this.getWidth();
if (row === null || row === undefined || row.length < width) {
row = new Uint8ClampedArray(width);
}
const offset = (y + this.top) * this.dataWidth + this.left;
var offset = (y + this.top) * this.dataWidth + this.left;
System_1.default.arraycopy(this.luminances, offset, row, 0, width);
return row;
}
};
/*@Override*/
getMatrix() {
const width = this.getWidth();
const height = this.getHeight();
RGBLuminanceSource.prototype.getMatrix = function () {
var width = this.getWidth();
var height = this.getHeight();
// If the caller asks for the entire underlying image, save the copy and give them the

@@ -94,5 +106,5 @@ // original data. The docs specifically warn that result.length must be ignored.

}
const area = width * height;
const matrix = new Uint8ClampedArray(area);
let inputOffset = this.top * this.dataWidth + this.left;
var area = width * height;
var matrix = new Uint8ClampedArray(area);
var inputOffset = this.top * this.dataWidth + this.left;
// If the width matches the full width of the underlying data, perform a single copy.

@@ -104,4 +116,4 @@ if (width === this.dataWidth) {

// Otherwise copy one cropped row at a time.
for (let y = 0; y < height; y++) {
const outputOffset = y * width;
for (var y = 0; y < height; y++) {
var outputOffset = y * width;
System_1.default.arraycopy(this.luminances, inputOffset, matrix, outputOffset, width);

@@ -111,16 +123,17 @@ inputOffset += this.dataWidth;

return matrix;
}
};
/*@Override*/
isCropSupported() {
RGBLuminanceSource.prototype.isCropSupported = function () {
return true;
}
};
/*@Override*/
crop(left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
RGBLuminanceSource.prototype.crop = function (left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
return new RGBLuminanceSource(this.luminances, width, height, this.dataWidth, this.dataHeight, this.left + left, this.top + top);
}
invert() {
};
RGBLuminanceSource.prototype.invert = function () {
return new InvertedLuminanceSource_1.default(this);
}
}
};
return RGBLuminanceSource;
}(LuminanceSource_1.default));
exports.default = RGBLuminanceSource;
//# sourceMappingURL=RGBLuminanceSource.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const System_1 = require("./System");
class Arrays {
static equals(first, second) {
var System_1 = require("./System");
var Arrays = /** @class */ (function () {
function Arrays() {
}
Arrays.equals = function (first, second) {
if (!first) {

@@ -21,3 +23,3 @@ return false;

}
for (let i = 0, length = first.length; i < length; i++) {
for (var i = 0, length_1 = first.length; i < length_1; i++) {
if (first[i] !== second[i]) {

@@ -28,23 +30,24 @@ return false;

return true;
}
static hashCode(a) {
};
Arrays.hashCode = function (a) {
if (a === null) {
return 0;
}
let result = 1;
for (const element of a) {
var result = 1;
for (var _i = 0, a_1 = a; _i < a_1.length; _i++) {
var element = a_1[_i];
result = 31 * result + element;
}
return result;
}
static fillUint8Array(a, value) {
for (let i = 0; i !== a.length; i++) {
};
Arrays.fillUint8Array = function (a, value) {
for (var i = 0; i !== a.length; i++) {
a[i] = value;
}
}
static copyOf(original, newLength) {
const copy = new Int32Array(newLength);
};
Arrays.copyOf = function (original, newLength) {
var copy = new Int32Array(newLength);
System_1.default.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
return copy;
}
};
/*

@@ -65,11 +68,11 @@ * Returns the index of of the element in a sorted array or (-n-1) where n is the insertion point

*/
static binarySearch(ar, el, comparator) {
Arrays.binarySearch = function (ar, el, comparator) {
if (undefined === comparator) {
comparator = Arrays.numberComparator;
}
let m = 0;
let n = ar.length - 1;
var m = 0;
var n = ar.length - 1;
while (m <= n) {
const k = (n + m) >> 1;
const cmp = comparator(el, ar[k]);
var k = (n + m) >> 1;
var cmp = comparator(el, ar[k]);
if (cmp > 0) {

@@ -86,8 +89,9 @@ m = k + 1;

return -m - 1;
}
static numberComparator(a, b) {
};
Arrays.numberComparator = function (a, b) {
return a - b;
}
}
};
return Arrays;
}());
exports.default = Arrays;
//# sourceMappingURL=Arrays.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Float {
static floatToIntBits(f) {
var Float = /** @class */ (function () {
function Float() {
}
Float.floatToIntBits = function (f) {
return f;
}
}
};
return Float;
}());
exports.default = Float;
//# sourceMappingURL=Float.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Integer {
static numberOfTrailingZeros(i) {
let y;
var Integer = /** @class */ (function () {
function Integer() {
}
Integer.numberOfTrailingZeros = function (i) {
var y;
if (i === 0)
return 32;
let n = 31;
var n = 31;
y = i << 16;

@@ -30,4 +32,4 @@ if (y !== 0) {

return n - ((i << 1) >>> 31);
}
static numberOfLeadingZeros(i) {
};
Integer.numberOfLeadingZeros = function (i) {
// HD, Figure 5-6

@@ -37,3 +39,3 @@ if (i === 0) {

}
let n = 1;
var n = 1;
if (i >>> 16 === 0) {

@@ -57,10 +59,10 @@ n += 16;

return n;
}
static toHexString(i) {
};
Integer.toHexString = function (i) {
return i.toString(16);
}
};
// Returns the number of one-bits in the two's complement binary representation of the specified int value. This function is sometimes referred to as the population count.
// Returns:
// the number of one-bits in the two's complement binary representation of the specified int value.
static bitCount(i) {
Integer.bitCount = function (i) {
// HD, Figure 5-2

@@ -73,6 +75,7 @@ i = i - ((i >>> 1) & 0x55555555);

return i & 0x3f;
}
}
Integer.MIN_VALUE_32_BITS = -2147483648;
};
Integer.MIN_VALUE_32_BITS = -2147483648;
return Integer;
}());
exports.default = Integer;
//# sourceMappingURL=Integer.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class StringBuilder {
constructor(value = '') {
var StringBuilder = /** @class */ (function () {
function StringBuilder(value) {
if (value === void 0) { value = ''; }
this.value = value;
}
append(s) {
StringBuilder.prototype.append = function (s) {
if (typeof s === 'string') {

@@ -15,20 +16,21 @@ this.value += s.toString();

return this;
}
length() {
};
StringBuilder.prototype.length = function () {
return this.value.length;
}
charAt(n) {
};
StringBuilder.prototype.charAt = function (n) {
return this.value.charAt(n);
}
deleteCharAt(n) {
};
StringBuilder.prototype.deleteCharAt = function (n) {
this.value = this.value.substr(0, n) + this.value.substring(n + 1);
}
setCharAt(n, c) {
};
StringBuilder.prototype.setCharAt = function (n, c) {
this.value = this.value.substr(0, n) + c + this.value.substr(n + 1);
}
toString() {
};
StringBuilder.prototype.toString = function () {
return this.value;
}
}
};
return StringBuilder;
}());
exports.default = StringBuilder;
//# sourceMappingURL=StringBuilder.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const CharacterSetECI_1 = require("./../common/CharacterSetECI");
const Exception_1 = require("./../Exception");
class StringEncoding {
static decode(bytes, encoding) {
let encodingString;
var CharacterSetECI_1 = require("./../common/CharacterSetECI");
var Exception_1 = require("./../Exception");
var StringEncoding = /** @class */ (function () {
function StringEncoding() {
}
StringEncoding.decode = function (bytes, encoding) {
var encodingString;
if (typeof encoding === 'string') {

@@ -16,3 +18,3 @@ encodingString = encoding;

// tslint:disable-next-line:no-string-literal
const TextDecoderBrowser = window['TextDecoder'];
var TextDecoderBrowser = window['TextDecoder'];
// use TextEncoder if is available (should be in newer browsers)

@@ -29,8 +31,8 @@ if (undefined !== TextDecoderBrowser) {

else {
const TextDecoderFromTEClass = require('text-encoding').TextDecoder;
var TextDecoderFromTEClass = require('text-encoding').TextDecoder;
return new TextDecoderFromTEClass(encodingString).decode(bytes);
}
}
static encode(s, encoding) {
let encodingString;
};
StringEncoding.encode = function (s, encoding) {
var encodingString;
if (typeof encoding === 'string') {

@@ -44,5 +46,5 @@ encodingString = encoding;

// tslint:disable-next-line:no-string-literal
const TextEncoderBrowser = window['TextEncoder'];
var TextEncoderBrowser = window['TextEncoder'];
// use TextEncoder if is available (should be in newer browsers)
const ec = CharacterSetECI_1.default.getCharacterSetECIByName(encodingString);
var ec = CharacterSetECI_1.default.getCharacterSetECIByName(encodingString);
if (undefined !== TextEncoderBrowser) {

@@ -60,17 +62,17 @@ // TODO: TextEncoder only supports utf-8 encoding as per specs

// TextEncoder only encodes to UTF8 by default as specified by encoding.spec.whatwg.org
const TextEncoderFromTEClass = require('text-encoding').TextEncoder;
var TextEncoderFromTEClass = require('text-encoding').TextEncoder;
return new TextEncoderFromTEClass(encodingString, { NONSTANDARD_allowLegacyEncoding: true }).encode(s);
}
}
static isBrowser() {
};
StringEncoding.isBrowser = function () {
return typeof window !== 'undefined' && ({}).toString.call(window) === '[object Window]';
}
static decodeFallBack(bytes, encoding) {
const ec = CharacterSetECI_1.default.getCharacterSetECIByName(encoding);
};
StringEncoding.decodeFallBack = function (bytes, encoding) {
var ec = CharacterSetECI_1.default.getCharacterSetECIByName(encoding);
if (ec.equals(CharacterSetECI_1.default.UTF8) ||
ec.equals(CharacterSetECI_1.default.ISO8859_1) ||
ec.equals(CharacterSetECI_1.default.ASCII)) {
let s = '';
for (let i = 0, length = bytes.length; i < length; i++) {
let h = bytes[i].toString(16);
var s = '';
for (var i = 0, length_1 = bytes.length; i < length_1; i++) {
var h = bytes[i].toString(16);
if (h.length < 2) {

@@ -87,11 +89,12 @@ h = '0' + h;

else {
throw new Exception_1.default(Exception_1.default.UnsupportedOperationException, `encoding ${encoding} not supported`);
throw new Exception_1.default(Exception_1.default.UnsupportedOperationException, "encoding " + encoding + " not supported");
}
}
static encodeFallBack(s, encoding) {
};
StringEncoding.encodeFallBack = function (s, encoding) {
// TODO: encode
return null;
}
}
};
return StringEncoding;
}());
exports.default = StringEncoding;
//# sourceMappingURL=StringEncoding.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class System {
var System = /** @class */ (function () {
function System() {
}
// public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
static arraycopy(src, srcPos, dest, destPos, length) {
System.arraycopy = function (src, srcPos, dest, destPos, length) {
// TODO: better use split or set?
let i = srcPos;
let j = destPos;
let c = length;
var i = srcPos;
var j = destPos;
var c = length;
while (c--) {
dest[j++] = src[i++];
}
}
static currentTimeMillis() {
};
System.currentTimeMillis = function () {
return Date.now();
}
}
};
return System;
}());
exports.default = System;
//# sourceMappingURL=System.js.map

@@ -6,2 +6,3 @@ export { default as BrowserCodeReader } from './browser/BrowserCodeReader';

export { default as VideoInputDevice } from './browser/VideoInputDevice';
export * from './browser/BrowserBarcodeReader';
export { default as BarcodeFormat } from './core/BarcodeFormat';

@@ -44,1 +45,4 @@ export { default as Binarizer } from './core/Binarizer';

export { default as QRCodeWriter } from './core/qrcode/QRCodeWriter';
export { default as OneDReader } from './core/oned/OneDReader';
export { default as Code128Reader } from './core/oned/Code128Reader';
export { default as ITFReader } from './core/oned/ITFReader';

@@ -15,2 +15,3 @@ "use strict";

exports.VideoInputDevice = VideoInputDevice_1.default;
__export(require("./browser/BrowserBarcodeReader"));
var Binarizer_1 = require("./core/Binarizer");

@@ -85,2 +86,9 @@ exports.Binarizer = Binarizer_1.default;

exports.QRCodeWriter = QRCodeWriter_1.default;
// core/oned
var OneDReader_1 = require("./core/oned/OneDReader");
exports.OneDReader = OneDReader_1.default;
var Code128Reader_1 = require("./core/oned/Code128Reader");
exports.Code128Reader = Code128Reader_1.default;
var ITFReader_1 = require("./core/oned/ITFReader");
exports.ITFReader = ITFReader_1.default;
//# sourceMappingURL=index.js.map

@@ -6,3 +6,4 @@ /**

*/
const path = require('path');
import * as path from 'path';
const ROOT = path.resolve(__dirname, '.');

@@ -16,3 +17,3 @@

module.exports = function (config) {
export default function (config) {
config.set({

@@ -19,0 +20,0 @@

{
"name": "@zxing/library",
"version": "0.3.2",
"description": "TypeScript port of ZXing multi-format 1D/2D barcode image processing library.",
"version": "0.5.0",
"description": "TypeScript port of ZXing multi-format 1D/2D barcode image processing library, with Code128 and ITF support.",
"keywords": [
"reader",
"writer",
"decode",
"encode",
"scanner",
"reader",
"generator",
"barcode",
"qr-code",
"code-128",
"ITF",
"i2of5",
"typescript",

@@ -26,2 +32,9 @@ "zxing-typescript",

"email": "machado@odahcam.com"
},
{
"name": "Ricardo Sousa",
"email": "sousa.ricardo10@gmail.com"
},
{
"name": "Tjieco"
}

@@ -42,5 +55,4 @@ ],

"clean": "shx rm -rf bundles esm5",
"build:before": "yarn run clean",
"build": "yarn build:before && tsc && tsc --target es2017 --outDir esm5 && webpack && webpack --env.prod",
"test": "mocha-webpack --webpack-config webpack.config.test.js src/test.js",
"build": "yarn clean && tsc && tsc --target es5 --outDir esm5 && webpack && webpack --env.prod",
"test": "mocha-webpack --webpack-config webpack.config.test.js src/test.js --timeout 20000",
"lint": "tslint src/**/*.ts"

@@ -56,3 +68,3 @@ },

"@types/mocha": "^2.2.48",
"@types/node": "^8.9.1",
"@types/node": "^8.10.15",
"@types/seedrandom": "^2.4.27",

@@ -64,2 +76,3 @@ "@types/sharp": "^0.17.7",

"chai": "^4.1.2",
"eslint": "^4.19.1",
"jasmine": "^3.0.0",

@@ -69,4 +82,4 @@ "karma": "^2.0.0",

"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.1.1",
"karma-coverage": "^1.1.2",
"karma-jasmine": "^1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",

@@ -89,7 +102,7 @@ "karma-mocha": "^1.3.0",

"ts-loader": "^3.5.0",
"tslint": "^5.9.1",
"typescript": "^2.7.1",
"uglify-js": "^3.3.10",
"tslint": "^5.10.0",
"typescript": "~2.7.1",
"uglify-js": "^3.3.25",
"uglifyjs-webpack-plugin": "^1.1.8",
"webpack": "^3.10.0",
"webpack": "^3.12.0",
"webpack-config-utils": "2.3.0",

@@ -96,0 +109,0 @@ "webpack-node-externals": "^1.6.0"

@@ -1,38 +0,52 @@

[![Build Status](https://travis-ci.org/odahcam/zxing-ts.svg?branch=master)](https://travis-ci.org/odahcam/zxing-ts)
[![NPM downloads](https://img.shields.io/npm/dt/@barn/zxing.svg?&label=npm%20downloads)][0]
[![NPM version](https://img.shields.io/npm/v/@barn/zxing.svg?&label=npm)][0]
![Dependencies](https://david-dm.org/odahcam/zxing-ts.svg)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/odahcam/zxing-ts.svg)](http://isitmaintained.com/project/odahcam/zxing-ts "Average time to resolve an issue")
[<img align="right" src="https://raw.github.com/wiki/zxing/zxing/zxing-logo.png"/>][1]
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f7a8692eca4147e983abfc0d8291cf84)](https://www.codacy.com/app/odahcam/zxing-ts?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=odahcam/zxing-ts&amp;utm_campaign=Badge_Grade)
[![Maintainability](https://api.codeclimate.com/v1/badges/181de5153c3535321974/maintainability)](https://codeclimate.com/github/odahcam/zxing-ts/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/181de5153c3535321974/test_coverage)](https://codeclimate.com/github/odahcam/zxing-ts/test_coverage)
[![Bless](https://cdn.rawgit.com/LunaGao/BlessYourCodeTag/master/tags/alpaca.svg)](http://lunagao.github.io/BlessYourCodeTag/)
# ZXing
[<img align="right" src="https://raw.github.com/wiki/zxing/zxing/zxing-logo.png"/>](https://github.com/zxing/zxing)
## Written in TypeScript, Deployed in JavaScript
# ZXing <small>_in TypeScript_</small>
Multi-format 1D/2D barcode image processing library.
> Multi-format 1D/2D barcode image processing library.
>
> *Ported from [ZXing](https://github.com/zxing/zxing) project (written in Java).*
> [ZXing][1] ("zebra crossing") is an open-source, multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages.
## Supported Formats
## _WIP_
**_WIP_**: see [Status and Roadmap](#roadmap) for what is currently done and what's planned next. 👀
There's still some things we gotta do here, see [Status and Roadmap](#status-and-roadmap) for what is currently done and what's planned next.
| 1D product | 1D industrial | 2D
| ---------- | ------------------------ | --------------
| ~UPC-A~ | ~Code 39~ | QR Code
| ~UPC-E~ | ~Code 93~ | ~Data Matrix~
| ~EAN-8~ | Code 128 (_no docs_) | ~Aztec (beta)~
| ~EAN-13~ | ~Codabar~ | PDF 417 (_in-progress_)
| | ITF (_in-progress_) | ~MaxiCode~
| | ~RSS-14~ |
| | ~RSS-Expanded~ |
# Demo
## Status
See [some demo examples](https://aleris.github.io/zxing-typescript/) in browser.
[![Build Status](https://travis-ci.org/zxing-js/library.svg?branch=master)](https://travis-ci.org/zxing-js/library)
# Usage
[![NPM version](https://img.shields.io/npm/v/@zxing/library.svg?&label=npm)][0]
[![NPM downloads](https://img.shields.io/npm/dt/@zxing/library.svg?&label=npm%20downloads)][0]
![Dependencies](https://david-dm.org/zxing-js/library.svg)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/39d86bc5d5f04bc8953cc68d729807b0)](https://www.codacy.com/app/zxing-js/library?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=zxing-js/library&amp;utm_campaign=Badge_Grade)
[![Maintainability](https://api.codeclimate.com/v1/badges/2b9c6ae92412ee8e15a9/maintainability)](https://codeclimate.com/github/zxing-js/library/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/2b9c6ae92412ee8e15a9/test_coverage)](https://codeclimate.com/github/zxing-js/library/test_coverage)
## Demo
See [some demo examples](https://zxing-js.github.io/library/) in browser.
## Usage
The library can be used from browser with TypeScript (include anything from src/browser however you must do the packaging yourself) or with plain javascript (see below). It can also be used from node (see also below). The library is using separate builds for node and browser to allow different ES targeting.
## Browser Usage
### Environments
#### Browser
Examples below are for QR barcode, all other supported barcodes work similary.
`npm i @barn/zxing --save`
`npm i @zxing/library --save`

@@ -49,2 +63,24 @@ To use from JS you need to include what you need from `build/umd` folder (for example `zxing.min.js`).

#### TypeScript
Install the package:
`npm i @zxing/library --save`
And then include directly the classes files you need, for example:
```javascript
import { BrowserQRCodeReader, VideoInputDevice } from '@zxing/library';
```
The usage is identical with the above.
#### Node
`npm i @zxing/library --save`
To use in node you will need to provide an implementation of [`LuminanceSource`](https://github.com/odahcam/zxing-ts/blob/master/src/core/LuminanceSource.ts) for an image. A starting point is [`SharpImageLuminanceSource`](https://github.com/odahcam/zxing-ts/blob/master/src/test/core/SharpImageLuminanceSource.ts) from tests that is using [sharp image processing](https://github.com/lovell/sharp) node library.
No examples are availabe for now, however you can have a look at the extensive [tests cases](https://github.com/odahcam/zxing-ts/tree/master/src/test/core/qrcode).
### Scanning from Video Camera

@@ -206,26 +242,4 @@

## Using from TypeScript
### Text Encoding and Decoding
Install the package:
`npm i @barn/zxing --save`
And then include directly the classes files you need, for example:
```javascript
import { BrowserQRCodeReader, VideoInputDevice } from '@barn/zxing';
```
The usage is identical with the above.
## Node Usage
`npm i @barn/zxing --save`
To use in node you will need to provide an implementation of [`LuminanceSource`](https://github.com/odahcam/zxing-ts/blob/master/src/core/LuminanceSource.ts) for an image. A starting point is [`SharpImageLuminanceSource`](https://github.com/odahcam/zxing-ts/blob/master/src/test/core/SharpImageLuminanceSource.ts) from tests that is using [sharp image processing](https://github.com/lovell/sharp) node library.
No examples are availabe for now, however you can have a look at the extensive [tests cases](https://github.com/odahcam/zxing-ts/tree/master/src/test/core/qrcode).
# Text Encoding and Decoding
To decode a barcode, the library needs at some point to decode from bits to text. Also, to generate a barcode it needs to encode text to bits. Unfortunately, the state of encoding and decoding text in javascript/browser is somehow messy at the moment.

@@ -237,33 +251,17 @@

# Porting Information
## Roadmap
See [TypeScript Port Info](typescriptport.md) for information regarding porting approach and reasoning behind some of the approaches taken.
- [Projects](/zxing-js/library/projects).
- [Milestones](/zxing-js/library/milestones).
# Status and Roadmap
### Porting Information
**Done:**
- [x] Port root, common and qrcode format and make it compile
- [x] Add unit test infrastructure, a first unit test and make it pass (common/BitArray.spec)
- [x] Add all unit tests for everything in root, common and qrcode
- [x] Add one "back box" test for qrcode
- [x] Add all "back box" tests for qrcode
- [x] Create browser integration module and demo UI for qrcode
- [x] Document browser usage
- [x] Implement QR barcode generation to SVG in browser
See [TypeScript Port Info](typescriptport.md) for information regarding porting approach and reasoning behind some of the approaches taken.
**Todo:**
- [ ] Move all these tasks to a "Project".
- [ ] Port pdf417 format with unit and browser tests and documentation
- [ ] Adapt documentation for JSDoc, generate documentation, cleanup source files
- [ ] Create automatic tests for all major current browsers
- [ ] Port aztec format with unit and browser tests
- [ ] Port multi parsing with unit and browser tests and documentation
- [ ] Port datamatrix format with unit and browser tests and documentation
- [ ] Port maxicode format with unit and browser tests and documentation
- [ ] Port oned format with unit and browser tests and documentation
- [ ] Port client/result parsing with unit and browser tests and documentation
- [ ] Documentation for using directly from TypeScript
---
[![Bless](https://cdn.rawgit.com/LunaGao/BlessYourCodeTag/master/tags/alpaca.svg)](http://lunagao.github.io/BlessYourCodeTag/)
[0]: https://www.npmjs.com/package/@barn/zxing
[0]: https://www.npmjs.com/package/@zxing/library
[1]: https://github.com/zxing/zxing

@@ -8,2 +8,3 @@ import Reader from './../core/Reader';

import VideoInputDevice from './VideoInputDevice';
import DecodeHintType from '../core/DecodeHintType';

@@ -34,3 +35,3 @@ /**

*/
public constructor(private reader: Reader, private timeBetweenScansMillis: number = 500) { }
public constructor(private reader: Reader, private timeBetweenScansMillis: number = 500, private hints?: Map<DecodeHintType, any>) { }

@@ -145,4 +146,4 @@ /**

this.videoElement = document.createElement('video');
this.videoElement.width = 200;
this.videoElement.height = 200;
this.videoElement.width = 640;
this.videoElement.height = 480;
} else if (typeof videoElement === 'string') {

@@ -270,3 +271,3 @@ this.videoElement = <HTMLVideoElement>this.getMediaElement(videoElement, 'video');

protected readerDecode(binaryBitmap: BinaryBitmap): Result {
return this.reader.decode(binaryBitmap);
return this.reader.decode(binaryBitmap, this.hints);
}

@@ -273,0 +274,0 @@

@@ -8,7 +8,17 @@ import Exception from '../core/Exception';

class BrowserQRCodeSvgWriter {
private static readonly QUIET_ZONE_SIZE = 4;
/**
* SVG markup NameSpace
*/
private static readonly SVG_NS = 'http://www.w3.org/2000/svg';
/**
* A HTML container element for the image.
*/
private containerElement: HTMLElement;
/**
* Constructs. 😉
*/
public constructor(containerElement: string | HTMLElement) {

@@ -22,6 +32,8 @@ if (typeof containerElement === 'string') {

public write(contents: string,
public write(
contents: string,
width: number,
height: number,
hints: Map<EncodeHintType, any> = null): SVGSVGElement {
hints: Map<EncodeHintType, any> = null
): SVGSVGElement {

@@ -37,4 +49,6 @@ if (contents.length === 0) {

if (width < 0 || height < 0) {
throw new Exception('IllegalArgumentException', 'Requested dimensions are too small: ' + width + 'x' +
height);
throw new Exception(
'IllegalArgumentException',
'Requested dimensions are too small: ' + width + 'x' + height
);
}

@@ -44,6 +58,9 @@

let quietZone = BrowserQRCodeSvgWriter.QUIET_ZONE_SIZE;
if (hints !== null) {
if (undefined !== hints.get(EncodeHintType.ERROR_CORRECTION)) {
errorCorrectionLevel = ErrorCorrectionLevel.fromString(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
}
if (undefined !== hints.get(EncodeHintType.MARGIN)) {

@@ -55,12 +72,18 @@ quietZone = Number.parseInt(hints.get(EncodeHintType.MARGIN).toString(), 10);

const code = Encoder.encode(contents, errorCorrectionLevel, hints);
return this.renderResult(code, width, height, quietZone);
}
// Note that the input matrix uses 0 == white, 1 == black, while the output matrix uses
// 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
/**
* Note that the input matrix uses 0 == white, 1 == black.
* The output matrix uses 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
*/
private renderResult(code: QRCode, width: number /*int*/, height: number /*int*/, quietZone: number /*int*/): SVGSVGElement {
const input = code.getMatrix();
if (input === null) {
throw new Exception(Exception.IllegalStateException);
}
const inputWidth = input.getWidth();

@@ -74,2 +97,3 @@ const inputHeight = input.getHeight();

const multiple = Math.min(Math.floor(outputWidth / qrWidth), Math.floor(outputHeight / qrHeight));
// Padding includes both the quiet zone and the extra white pixels to accommodate the requested

@@ -83,3 +107,5 @@ // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.

const svgElement = this.createSVGElement(outputWidth, outputHeight);
this.containerElement.appendChild(svgElement);
for (let inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++ , outputY += multiple) {

@@ -99,5 +125,8 @@ // Write the contents of this row of the barcode

private createSVGElement(w: number, h: number): SVGSVGElement {
const svgElement = document.createElementNS(BrowserQRCodeSvgWriter.SVG_NS, 'svg');
svgElement.setAttributeNS(null, 'height', w.toString());
svgElement.setAttributeNS(null, 'width', h.toString());
return svgElement;

@@ -107,3 +136,5 @@ }

private createSvgRectElement(x: number, y: number, w: number, h: number): SVGRectElement {
const rect = document.createElementNS(BrowserQRCodeSvgWriter.SVG_NS, 'rect');
rect.setAttributeNS(null, 'x', x.toString());

@@ -114,2 +145,3 @@ rect.setAttributeNS(null, 'y', y.toString());

rect.setAttributeNS(null, 'fill', '#000000');
return rect;

@@ -116,0 +148,0 @@ }

@@ -107,2 +107,3 @@ import InvertedLuminanceSource from './../core/InvertedLuminanceSource';

tempCanvasElement.style.height = `${this.canvas.height}px`;
this.tempCanvasElement = tempCanvasElement;
}

@@ -109,0 +110,0 @@

@@ -24,2 +24,3 @@ /*

import Exception from './Exception';
import MultiFormatOneDReader from './oned/MultiFormatOneDReader';

@@ -117,5 +118,5 @@ /*namespace com.google.zxing {*/

// if (addOneDReader && !tryHarder) {
// readers.push(new MultiFormatOneDReader(hints))
// }
if (addOneDReader && !tryHarder) {
readers.push(new MultiFormatOneDReader(hints));
}
if (formats.contains(BarcodeFormat.QR_CODE)) {

@@ -136,11 +137,11 @@ readers.push(new QRCodeReader());

// }
// // At end in "try harder" mode
// if (addOneDReader && tryHarder) {
// readers.push(new MultiFormatOneDReader(hints))
// }
// At end in "try harder" mode
if (addOneDReader && tryHarder) {
readers.push(new MultiFormatOneDReader(hints));
}
}
if (readers.length === 0) {
// if (!tryHarder) {
// readers.push(new MultiFormatOneDReader(hints))
// }
if (!tryHarder) {
readers.push(new MultiFormatOneDReader(hints));
}

@@ -153,5 +154,5 @@ readers.push(new QRCodeReader());

// if (tryHarder) {
// readers.push(new MultiFormatOneDReader(hints))
// }
if (tryHarder) {
readers.push(new MultiFormatOneDReader(hints));
}
}

@@ -158,0 +159,0 @@ this.readers = readers; // .toArray(new Reader[readers.size()])

@@ -118,2 +118,3 @@ /*

public getMatrix(): Uint8ClampedArray {
const width = this.getWidth();

@@ -120,0 +121,0 @@ const height = this.getHeight();

@@ -56,9 +56,11 @@ /*

*/
encode(contents: string,
encode(
contents: string,
format: BarcodeFormat,
width: number /*int*/,
height: number /*int*/,
hints: Map<EncodeHintType, any>): BitMatrix;
hints: Map<EncodeHintType, any>
): BitMatrix;
/*throws WriterException*/
}

@@ -7,2 +7,3 @@ // browser

export { default as VideoInputDevice } from './browser/VideoInputDevice';
export * from './browser/BrowserBarcodeReader';

@@ -56,1 +57,6 @@ // core

export { default as QRCodeWriter } from './core/qrcode/QRCodeWriter';
// core/oned
export { default as OneDReader } from './core/oned/OneDReader';
export { default as Code128Reader } from './core/oned/Code128Reader';
export { default as ITFReader } from './core/oned/ITFReader';

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc