Orders by {@link FinderPattern#getCount()}, descending.
*/
// CenterComparator implements Comparator
(center1, center2) => {
if (center2.getCount() === center1.getCount()) {
const dA = Math.abs(center2.getEstimatedModuleSize() - average);
const dB = Math.abs(center1.getEstimatedModuleSize() - average);
return dA < dB ? 1 : dA > dB ? -1 : 0;
}
else {
return center2.getCount() - center1.getCount();
}
});
possibleCenters.splice(3); // this is not realy necessary as we only return first 3 anyway
}
return [
possibleCenters[0],
possibleCenters[1],
possibleCenters[2]
];
}
}
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
/*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*import java.util.Map;*/
/**
* Encapsulates logic that can detect a QR Code in an image, even if the QR Code
* is rotated or skewed, or partially obscured.
*
* @author Sean Owen
*/
class Detector$2 {
constructor(image) {
this.image = image;
}
getImage() {
return this.image;
}
getResultPointCallback() {
return this.resultPointCallback;
}
/**
* Detects a QR Code in an image.
*
* @return {@link DetectorResult} encapsulating results of detecting a QR Code
* @throws NotFoundException if QR Code cannot be found
* @throws FormatException if a QR Code cannot be decoded
*/
// public detect(): DetectorResult /*throws NotFoundException, FormatException*/ {
// return detect(null)
// }
/**
* Detects a QR Code in an image.
*
* @param hints optional hints to detector
* @return {@link DetectorResult} encapsulating results of detecting a QR Code
* @throws NotFoundException if QR Code cannot be found
* @throws FormatException if a QR Code cannot be decoded
*/
detect(hints) {
this.resultPointCallback = (hints === null || hints === undefined) ? null :
/*(ResultPointCallback) */ hints.get(DecodeHintType$1.NEED_RESULT_POINT_CALLBACK);
const finder = new FinderPatternFinder(this.image, this.resultPointCallback);
const 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);
if (moduleSize < 1.0) {
throw new NotFoundException('No pattern found in proccess finder.');
}
const dimension = Detector$2.computeDimension(topLeft, topRight, bottomLeft, moduleSize);
const provisionalVersion = Version$1.getProvisionalVersionForDimension(dimension);
const modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;
let 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();
// 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 = /*(int) */ Math.floor(topLeft.getX() + correctionToTopLeft * (bottomRightX - topLeft.getX()));
const estAlignmentY = /*(int) */ 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) {
try {
alignmentPattern = this.findAlignmentInRegion(moduleSize, estAlignmentX, estAlignmentY, i);
break;
}
catch (re /*NotFoundException*/) {
if (!(re instanceof NotFoundException)) {
throw re;
}
// try next round
}
}
// If we didn't find alignment pattern... well try anyway without it
}
const transform = Detector$2.createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);
const bits = Detector$2.sampleGrid(this.image, transform, dimension);
let points;
if (alignmentPattern === null) {
points = [bottomLeft, topLeft, topRight];
}
else {
points = [bottomLeft, topLeft, topRight, alignmentPattern];
}
return new DetectorResult(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*/
if (alignmentPattern !== null) {
bottomRightX = alignmentPattern.getX();
bottomRightY = alignmentPattern.getY();
sourceBottomRightX = dimMinusThree - 3.0;
sourceBottomRightY = sourceBottomRightX;
}
else {
// Don't have an alignment pattern, just make up the bottom-right point
bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();
bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();
sourceBottomRightX = dimMinusThree;
sourceBottomRightY = dimMinusThree;
}
return PerspectiveTransform.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.getInstance();
return sampler.sampleGridWithTransform(image, dimension, dimension, transform);
}
/**
* Computes the dimension (number of modules on a size) of the QR Code based on the position
* of the finder patterns and estimated module size.
*/
static computeDimension(topLeft, topRight, bottomLeft, moduleSize /*float*/) {
const tltrCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, topRight) / moduleSize);
const tlblCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, bottomLeft) / moduleSize);
let dimension = Math.floor((tltrCentersDimension + tlblCentersDimension) / 2) + 7;
switch (dimension & 0x03) { // mod 4
case 0:
dimension++;
break;
// 1? do nothing
case 2:
dimension--;
break;
case 3:
throw new NotFoundException('Dimensions could be not found.');
}
return dimension;
}
/**
* Computes an average estimated module size based on estimated derived from the positions
* of the three finder patterns.
*
* @param topLeft detected top-left finder pattern center
* @param topRight detected top-right finder pattern center
* @param bottomLeft detected bottom-left finder pattern center
* @return estimated module size
*/
calculateModuleSize(topLeft, topRight, bottomLeft) {
// Take the average
return (this.calculateModuleSizeOneWay(topLeft, topRight) +
this.calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0;
}
/**
* Estimates module size based on two finder patterns -- it uses
* {@link #sizeOfBlackWhiteBlackRunBothWays(int, int, int, int)} to figure the
* width of each, measuring along the axis between their centers.
*/
calculateModuleSizeOneWay(pattern, otherPattern) {
const 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()),
/*(int) */ Math.floor(otherPattern.getY()),
/*(int) */ Math.floor(pattern.getX()),
/*(int) */ Math.floor(pattern.getY()));
if (isNaN(moduleSizeEst1)) {
return moduleSizeEst2 / 7.0;
}
if (isNaN(moduleSizeEst2)) {
return moduleSizeEst1 / 7.0;
}
// Average them, and divide by 7 since we've counted the width of 3 black modules,
// and 1 white and 1 black module on either side. Ergo, divide sum by 14.
return (moduleSizeEst1 + moduleSizeEst2) / 14.0;
}
/**
* See {@link #sizeOfBlackWhiteBlackRun(int, int, int, int)}; computes the total width of
* a finder pattern by looking for a black-white-black run from the center in the direction
* of another point (another finder pattern center), and in the opposite direction too.
*/
sizeOfBlackWhiteBlackRunBothWays(fromX /*int*/, fromY /*int*/, toX /*int*/, toY /*int*/) {
let 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);
if (otherToX < 0) {
scale = fromX / /*(float) */ (fromX - otherToX);
otherToX = 0;
}
else if (otherToX >= this.image.getWidth()) {
scale = (this.image.getWidth() - 1 - fromX) / /*(float) */ (otherToX - fromX);
otherToX = this.image.getWidth() - 1;
}
let otherToY = /*(int) */ Math.floor(fromY - (toY - fromY) * scale);
scale = 1.0;
if (otherToY < 0) {
scale = fromY / /*(float) */ (fromY - otherToY);
otherToY = 0;
}
else if (otherToY >= this.image.getHeight()) {
scale = (this.image.getHeight() - 1 - fromY) / /*(float) */ (otherToY - fromY);
otherToY = this.image.getHeight() - 1;
}
otherToX = /*(int) */ Math.floor(fromX + (otherToX - fromX) * scale);
result += this.sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY);
// Middle pixel is double-counted this way; subtract 1
return result - 1.0;
}
/**
* This method traces a line from a point in the image, in the direction towards another point.
* It begins in a black region, and keeps going until it finds white, then black, then white again.
* It reports the distance from the start to this point.
*
* This is used when figuring out how wide a finder pattern is, when the finder pattern
* may be skewed or rotated.
*/
sizeOfBlackWhiteBlackRun(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);
if (steep) {
let temp = fromX;
fromX = fromY;
fromY = temp;
temp = toX;
toX = toY;
toY = 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;
// In black pixels, looking for white, first or second time.
let 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;
// Does current pixel mean we have moved white to black or vice versa?
// Scanning black in state 0,2 and white in state 1, so if we find the wrong
// color, advance to next state or end if we are in state 2 already
if ((state === 1) === this.image.get(realX, realY)) {
if (state === 2) {
return MathUtils.distance(x, y, fromX, fromY);
}
state++;
}
error += dy;
if (error > 0) {
if (y === toY) {
break;
}
y += ystep;
error -= dx;
}
}
// Found black-white-black; give the benefit of the doubt that the next pixel outside the image
// is "white" so this last point at (toX+xStep,toY) is the right ending. This is really a
// small approximation; (toX+xStep,toY+yStep) might be really correct. Ignore this.
if (state === 2) {
return MathUtils.distance(toX + xstep, toY, fromX, fromY);
}
// else we didn't find even black-white-black; no estimate is really possible
return NaN;
}
/**
* Attempts to locate an alignment pattern in a limited region of the image, which is
* guessed to contain it. This method uses {@link AlignmentPattern}.
*
* @param overallEstModuleSize estimated module size so far
* @param estAlignmentX x coordinate of center of area probably containing alignment pattern
* @param estAlignmentY y coordinate of above
* @param allowanceFactor number of pixels in all directions to search from the center
* @return {@link AlignmentPattern} if found, or null otherwise
* @throws NotFoundException if an unexpected error occurs during detection
*/
findAlignmentInRegion(overallEstModuleSize /*float*/, estAlignmentX /*int*/, estAlignmentY /*int*/, allowanceFactor /*float*/) {
// Look for an alignment pattern (3 modules in size) around where it
// should be
const allowance = /*(int) */ Math.floor(allowanceFactor * overallEstModuleSize);
const alignmentAreaLeftX = Math.max(0, estAlignmentX - allowance);
const alignmentAreaRightX = Math.min(this.image.getWidth() - 1, estAlignmentX + allowance);
if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) {
throw new NotFoundException('Alignment top exceeds estimated module size.');
}
const alignmentAreaTopY = Math.max(0, estAlignmentY - allowance);
const alignmentAreaBottomY = Math.min(this.image.getHeight() - 1, estAlignmentY + allowance);
if (alignmentAreaBottomY - alignmentAreaTopY < overallEstModuleSize * 3) {
throw new NotFoundException('Alignment bottom exceeds estimated module size.');
}
const alignmentFinder = new AlignmentPatternFinder(this.image, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, this.resultPointCallback);
return alignmentFinder.find();
}
}
/*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*import java.util.List;*/
/*import java.util.Map;*/
/**
* This implementation can detect and decode QR Codes in an image.
*
* @author Sean Owen
*/
class QRCodeReader {
constructor() {
this.decoder = new Decoder$2();
}
getDecoder() {
return this.decoder;
}
/**
* Locates and decodes a QR code in an image.
*
* @return a representing: string the content encoded by the QR code
* @throws NotFoundException if a QR code cannot be found
* @throws FormatException if a QR code cannot be decoded
* @throws ChecksumException if error correction fails
*/
/*@Override*/
// public decode(image: BinaryBitmap): Result /*throws NotFoundException, ChecksumException, FormatException */ {
// return this.decode(image, null)
// }
/*@Override*/
decode(image, hints) {
let decoderResult;
let points;
if (hints !== undefined && hints !== null && undefined !== hints.get(DecodeHintType$1.PURE_BARCODE)) {
const bits = QRCodeReader.extractPureBits(image.getBlackMatrix());
decoderResult = this.decoder.decodeBitMatrix(bits, hints);
points = QRCodeReader.NO_POINTS;
}
else {
const detectorResult = new Detector$2(image.getBlackMatrix()).detect(hints);
decoderResult = this.decoder.decodeBitMatrix(detectorResult.getBits(), hints);
points = detectorResult.getPoints();
}
// If the code was mirrored: swap the bottom-left and the top-right points.
if (decoderResult.getOther() instanceof QRCodeDecoderMetaData) {
decoderResult.getOther().applyMirroredCorrection(points);
}
const result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), undefined, points, BarcodeFormat$1.QR_CODE, undefined);
const byteSegments = decoderResult.getByteSegments();
if (byteSegments !== null) {
result.putMetadata(ResultMetadataType$1.BYTE_SEGMENTS, byteSegments);
}
const ecLevel = decoderResult.getECLevel();
if (ecLevel !== null) {
result.putMetadata(ResultMetadataType$1.ERROR_CORRECTION_LEVEL, ecLevel);
}
if (decoderResult.hasStructuredAppend()) {
result.putMetadata(ResultMetadataType$1.STRUCTURED_APPEND_SEQUENCE, decoderResult.getStructuredAppendSequenceNumber());
result.putMetadata(ResultMetadataType$1.STRUCTURED_APPEND_PARITY, decoderResult.getStructuredAppendParity());
}
return result;
}
/*@Override*/
reset() {
// do nothing
}
/**
* This method detects a code in a "pure" image -- that is, pure monochrome image
* which contains only an unrotated, unskewed, image of a code, with some white border
* around it. This is a specialized method that works exceptionally fast in this special
* case.
*
* @see com.google.zxing.datamatrix.DataMatrixReader#extractPureBits(BitMatrix)
*/
static extractPureBits(image) {
const leftTopBlack = image.getTopLeftOnBit();
const rightBottomBlack = image.getBottomRightOnBit();
if (leftTopBlack === null || rightBottomBlack === null) {
throw new NotFoundException();
}
const moduleSize = this.moduleSize(leftTopBlack, image);
let top = leftTopBlack[1];
let bottom = rightBottomBlack[1];
let left = leftTopBlack[0];
let right = rightBottomBlack[0];
// Sanity check!
if (left >= right || top >= bottom) {
throw new NotFoundException();
}
if (bottom - top !== right - left) {
// Special case, where bottom-right module wasn't black so we found something else in the last row
// Assume it's a square, so use height as the width
right = left + (bottom - top);
if (right >= image.getWidth()) {
// Abort if that would not make sense -- off image
throw new NotFoundException();
}
}
const matrixWidth = Math.round((right - left + 1) / moduleSize);
const matrixHeight = Math.round((bottom - top + 1) / moduleSize);
if (matrixWidth <= 0 || matrixHeight <= 0) {
throw new NotFoundException();
}
if (matrixHeight !== matrixWidth) {
// Only possibly decode square regions
throw new NotFoundException();
}
// Push in the "border" by half the module width so that we start
// sampling in the middle of the module. Just in case the image is a
// little off, this will help recover.
const nudge = /*(int) */ Math.floor(moduleSize / 2.0);
top += nudge;
left += nudge;
// But careful that this does not sample off the edge
// "right" is the farthest-right valid pixel location -- right+1 is not necessarily
// 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;
if (nudgedTooFarRight > 0) {
if (nudgedTooFarRight > nudge) {
// Neither way fits; abort
throw new NotFoundException();
}
left -= nudgedTooFarRight;
}
// See logic above
const nudgedTooFarDown = top + /*(int) */ Math.floor((matrixHeight - 1) * moduleSize) - bottom;
if (nudgedTooFarDown > 0) {
if (nudgedTooFarDown > nudge) {
// Neither way fits; abort
throw new NotFoundException();
}
top -= nudgedTooFarDown;
}
// Now just read off the bits
const bits = new BitMatrix(matrixWidth, matrixHeight);
for (let y = 0; y < matrixHeight; y++) {
const iOffset = top + /*(int) */ Math.floor(y * moduleSize);
for (let x = 0; x < matrixWidth; x++) {
if (image.get(left + /*(int) */ Math.floor(x * moduleSize), iOffset)) {
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;
while (x < width && y < height) {
if (inBlack !== image.get(x, y)) {
if (++transitions === 5) {
break;
}
inBlack = !inBlack;
}
x++;
y++;
}
if (x === width || y === height) {
throw new NotFoundException();
}
return (x - leftTopBlack[0]) / 7.0;
}
}
QRCodeReader.NO_POINTS = new Array();
/*
* Copyright 2009 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author SITA Lab (kevin.osullivan@sita.aero)
* @author Guenther Grau
*/
/*public final*/ class PDF417Common {
PDF417Common() {
}
/**
* @param moduleBitCount values to sum
* @return sum of values
* @deprecated call {@link MathUtils#sum(int[])}
*/
// @Deprecated
static getBitCountSum(moduleBitCount) {
return MathUtils.sum(moduleBitCount);
}
static toIntArray(list) {
if (list == null || !list.length) {
return PDF417Common.EMPTY_INT_ARRAY;
}
const result = new Int32Array(list.length);
let i = 0;
for (const integer of list) {
result[i++] = integer;
}
return result;
}
/**
* @param symbol encoded symbol to translate to a codeword
* @return the codeword corresponding to the symbol.
*/
static getCodeword(symbol /*int*/) {
const i = Arrays.binarySearch(PDF417Common.SYMBOL_TABLE, symbol & 0x3FFFF);
if (i < 0) {
return -1;
}
return (PDF417Common.CODEWORD_TABLE[i] - 1) % PDF417Common.NUMBER_OF_CODEWORDS;
}
}
PDF417Common.NUMBER_OF_CODEWORDS = 929;
// Maximum Codewords (Data + Error).
PDF417Common.MAX_CODEWORDS_IN_BARCODE = PDF417Common.NUMBER_OF_CODEWORDS - 1;
PDF417Common.MIN_ROWS_IN_BARCODE = 3;
PDF417Common.MAX_ROWS_IN_BARCODE = 90;
// One left row indication column + max 30 data columns + one right row indicator column
// public static /*final*/ MAX_CODEWORDS_IN_ROW: /*int*/ number = 32;
PDF417Common.MODULES_IN_CODEWORD = 17;
PDF417Common.MODULES_IN_STOP_PATTERN = 18;
PDF417Common.BARS_IN_MODULE = 8;
PDF417Common.EMPTY_INT_ARRAY = new Int32Array([]);
/**
* The sorted table of all possible symbols. Extracted from the PDF417
* specification. The index of a symbol in this table corresponds to the
* index into the codeword table.
*/
PDF417Common.SYMBOL_TABLE = Int32Array.from([
0x1025e, 0x1027a, 0x1029e, 0x102bc, 0x102f2, 0x102f4, 0x1032e, 0x1034e, 0x1035c, 0x10396, 0x103a6, 0x103ac,
0x10422, 0x10428, 0x10436, 0x10442, 0x10444, 0x10448, 0x10450, 0x1045e, 0x10466, 0x1046c, 0x1047a, 0x10482,
0x1049e, 0x104a0, 0x104bc, 0x104c6, 0x104d8, 0x104ee, 0x104f2, 0x104f4, 0x10504, 0x10508, 0x10510, 0x1051e,
0x10520, 0x1053c, 0x10540, 0x10578, 0x10586, 0x1058c, 0x10598, 0x105b0, 0x105be, 0x105ce, 0x105dc, 0x105e2,
0x105e4, 0x105e8, 0x105f6, 0x1062e, 0x1064e, 0x1065c, 0x1068e, 0x1069c, 0x106b8, 0x106de, 0x106fa, 0x10716,
0x10726, 0x1072c, 0x10746, 0x1074c, 0x10758, 0x1076e, 0x10792, 0x10794, 0x107a2, 0x107a4, 0x107a8, 0x107b6,
0x10822, 0x10828, 0x10842, 0x10848, 0x10850, 0x1085e, 0x10866, 0x1086c, 0x1087a, 0x10882, 0x10884, 0x10890,
0x1089e, 0x108a0, 0x108bc, 0x108c6, 0x108cc, 0x108d8, 0x108ee, 0x108f2, 0x108f4, 0x10902, 0x10908, 0x1091e,
0x10920, 0x1093c, 0x10940, 0x10978, 0x10986, 0x10998, 0x109b0, 0x109be, 0x109ce, 0x109dc, 0x109e2, 0x109e4,
0x109e8, 0x109f6, 0x10a08, 0x10a10, 0x10a1e, 0x10a20, 0x10a3c, 0x10a40, 0x10a78, 0x10af0, 0x10b06, 0x10b0c,
0x10b18, 0x10b30, 0x10b3e, 0x10b60, 0x10b7c, 0x10b8e, 0x10b9c, 0x10bb8, 0x10bc2, 0x10bc4, 0x10bc8, 0x10bd0,
0x10bde, 0x10be6, 0x10bec, 0x10c2e, 0x10c4e, 0x10c5c, 0x10c62, 0x10c64, 0x10c68, 0x10c76, 0x10c8e, 0x10c9c,
0x10cb8, 0x10cc2, 0x10cc4, 0x10cc8, 0x10cd0, 0x10cde, 0x10ce6, 0x10cec, 0x10cfa, 0x10d0e, 0x10d1c, 0x10d38,
0x10d70, 0x10d7e, 0x10d82, 0x10d84, 0x10d88, 0x10d90, 0x10d9e, 0x10da0, 0x10dbc, 0x10dc6, 0x10dcc, 0x10dd8,
0x10dee, 0x10df2, 0x10df4, 0x10e16, 0x10e26, 0x10e2c, 0x10e46, 0x10e58, 0x10e6e, 0x10e86, 0x10e8c, 0x10e98,
0x10eb0, 0x10ebe, 0x10ece, 0x10edc, 0x10f0a, 0x10f12, 0x10f14, 0x10f22, 0x10f28, 0x10f36, 0x10f42, 0x10f44,
0x10f48, 0x10f50, 0x10f5e, 0x10f66, 0x10f6c, 0x10fb2, 0x10fb4, 0x11022, 0x11028, 0x11042, 0x11048, 0x11050,
0x1105e, 0x1107a, 0x11082, 0x11084, 0x11090, 0x1109e, 0x110a0, 0x110bc, 0x110c6, 0x110cc, 0x110d8, 0x110ee,
0x110f2, 0x110f4, 0x11102, 0x1111e, 0x11120, 0x1113c, 0x11140, 0x11178, 0x11186, 0x11198, 0x111b0, 0x111be,
0x111ce, 0x111dc, 0x111e2, 0x111e4, 0x111e8, 0x111f6, 0x11208, 0x1121e, 0x11220, 0x11278, 0x112f0, 0x1130c,
0x11330, 0x1133e, 0x11360, 0x1137c, 0x1138e, 0x1139c, 0x113b8, 0x113c2, 0x113c8, 0x113d0, 0x113de, 0x113e6,
0x113ec, 0x11408, 0x11410, 0x1141e, 0x11420, 0x1143c, 0x11440, 0x11478, 0x114f0, 0x115e0, 0x1160c, 0x11618,
0x11630, 0x1163e, 0x11660, 0x1167c, 0x116c0, 0x116f8, 0x1171c, 0x11738, 0x11770, 0x1177e, 0x11782, 0x11784,
0x11788, 0x11790, 0x1179e, 0x117a0, 0x117bc, 0x117c6, 0x117cc, 0x117d8, 0x117ee, 0x1182e, 0x11834, 0x1184e,
0x1185c, 0x11862, 0x11864, 0x11868, 0x11876, 0x1188e, 0x1189c, 0x118b8, 0x118c2, 0x118c8, 0x118d0, 0x118de,
0x118e6, 0x118ec, 0x118fa, 0x1190e, 0x1191c, 0x11938, 0x11970, 0x1197e, 0x11982, 0x11984, 0x11990, 0x1199e,
0x119a0, 0x119bc, 0x119c6, 0x119cc, 0x119d8, 0x119ee, 0x119f2, 0x119f4, 0x11a0e, 0x11a1c, 0x11a38, 0x11a70,
0x11a7e, 0x11ae0, 0x11afc, 0x11b08, 0x11b10, 0x11b1e, 0x11b20, 0x11b3c, 0x11b40, 0x11b78, 0x11b8c, 0x11b98,
0x11bb0, 0x11bbe, 0x11bce, 0x11bdc, 0x11be2, 0x11be4, 0x11be8, 0x11bf6, 0x11c16, 0x11c26, 0x11c2c, 0x11c46,
0x11c4c, 0x11c58, 0x11c6e, 0x11c86, 0x11c98, 0x11cb0, 0x11cbe, 0x11cce, 0x11cdc, 0x11ce2, 0x11ce4, 0x11ce8,
0x11cf6, 0x11d06, 0x11d0c, 0x11d18, 0x11d30, 0x11d3e, 0x11d60, 0x11d7c, 0x11d8e, 0x11d9c, 0x11db8, 0x11dc4,
0x11dc8, 0x11dd0, 0x11dde, 0x11de6, 0x11dec, 0x11dfa, 0x11e0a, 0x11e12, 0x11e14, 0x11e22, 0x11e24, 0x11e28,
0x11e36, 0x11e42, 0x11e44, 0x11e50, 0x11e5e, 0x11e66, 0x11e6c, 0x11e82, 0x11e84, 0x11e88, 0x11e90, 0x11e9e,
0x11ea0, 0x11ebc, 0x11ec6, 0x11ecc, 0x11ed8, 0x11eee, 0x11f1a, 0x11f2e, 0x11f32, 0x11f34, 0x11f4e, 0x11f5c,
0x11f62, 0x11f64, 0x11f68, 0x11f76, 0x12048, 0x1205e, 0x12082, 0x12084, 0x12090, 0x1209e, 0x120a0, 0x120bc,
0x120d8, 0x120f2, 0x120f4, 0x12108, 0x1211e, 0x12120, 0x1213c, 0x12140, 0x12178, 0x12186, 0x12198, 0x121b0,
0x121be, 0x121e2, 0x121e4, 0x121e8, 0x121f6, 0x12204, 0x12210, 0x1221e, 0x12220, 0x12278, 0x122f0, 0x12306,
0x1230c, 0x12330, 0x1233e, 0x12360, 0x1237c, 0x1238e, 0x1239c, 0x123b8, 0x123c2, 0x123c8, 0x123d0, 0x123e6,
0x123ec, 0x1241e, 0x12420, 0x1243c, 0x124f0, 0x125e0, 0x12618, 0x1263e, 0x12660, 0x1267c, 0x126c0, 0x126f8,
0x12738, 0x12770, 0x1277e, 0x12782, 0x12784, 0x12790, 0x1279e, 0x127a0, 0x127bc, 0x127c6, 0x127cc, 0x127d8,
0x127ee, 0x12820, 0x1283c, 0x12840, 0x12878, 0x128f0, 0x129e0, 0x12bc0, 0x12c18, 0x12c30, 0x12c3e, 0x12c60,
0x12c7c, 0x12cc0, 0x12cf8, 0x12df0, 0x12e1c, 0x12e38, 0x12e70, 0x12e7e, 0x12ee0, 0x12efc, 0x12f04, 0x12f08,
0x12f10, 0x12f20, 0x12f3c, 0x12f40, 0x12f78, 0x12f86, 0x12f8c, 0x12f98, 0x12fb0, 0x12fbe, 0x12fce, 0x12fdc,
0x1302e, 0x1304e, 0x1305c, 0x13062, 0x13068, 0x1308e, 0x1309c, 0x130b8, 0x130c2, 0x130c8, 0x130d0, 0x130de,
0x130ec, 0x130fa, 0x1310e, 0x13138, 0x13170, 0x1317e, 0x13182, 0x13184, 0x13190, 0x1319e, 0x131a0, 0x131bc,
0x131c6, 0x131cc, 0x131d8, 0x131f2, 0x131f4, 0x1320e, 0x1321c, 0x13270, 0x1327e, 0x132e0, 0x132fc, 0x13308,
0x1331e, 0x13320, 0x1333c, 0x13340, 0x13378, 0x13386, 0x13398, 0x133b0, 0x133be, 0x133ce, 0x133dc, 0x133e2,
0x133e4, 0x133e8, 0x133f6, 0x1340e, 0x1341c, 0x13438, 0x13470, 0x1347e, 0x134e0, 0x134fc, 0x135c0, 0x135f8,
0x13608, 0x13610, 0x1361e, 0x13620, 0x1363c, 0x13640, 0x13678, 0x136f0, 0x1370c, 0x13718, 0x13730, 0x1373e,
0x13760, 0x1377c, 0x1379c, 0x137b8, 0x137c2, 0x137c4, 0x137c8, 0x137d0, 0x137de, 0x137e6, 0x137ec, 0x13816,
0x13826, 0x1382c, 0x13846, 0x1384c, 0x13858, 0x1386e, 0x13874, 0x13886, 0x13898, 0x138b0, 0x138be, 0x138ce,
0x138dc, 0x138e2, 0x138e4, 0x138e8, 0x13906, 0x1390c, 0x13930, 0x1393e, 0x13960, 0x1397c, 0x1398e, 0x1399c,
0x139b8, 0x139c8, 0x139d0, 0x139de, 0x139e6, 0x139ec, 0x139fa, 0x13a06, 0x13a0c, 0x13a18, 0x13a30, 0x13a3e,
0x13a60, 0x13a7c, 0x13ac0, 0x13af8, 0x13b0e, 0x13b1c, 0x13b38, 0x13b70, 0x13b7e, 0x13b88, 0x13b90, 0x13b9e,
0x13ba0, 0x13bbc, 0x13bcc, 0x13bd8, 0x13bee, 0x13bf2, 0x13bf4, 0x13c12, 0x13c14, 0x13c22, 0x13c24, 0x13c28,
0x13c36, 0x13c42, 0x13c48, 0x13c50, 0x13c5e, 0x13c66, 0x13c6c, 0x13c82, 0x13c84, 0x13c90, 0x13c9e, 0x13ca0,
0x13cbc, 0x13cc6, 0x13ccc, 0x13cd8, 0x13cee, 0x13d02, 0x13d04, 0x13d08, 0x13d10, 0x13d1e, 0x13d20, 0x13d3c,
0x13d40, 0x13d78, 0x13d86, 0x13d8c, 0x13d98, 0x13db0, 0x13dbe, 0x13dce, 0x13ddc, 0x13de4, 0x13de8, 0x13df6,
0x13e1a, 0x13e2e, 0x13e32, 0x13e34, 0x13e4e, 0x13e5c, 0x13e62, 0x13e64, 0x13e68, 0x13e76, 0x13e8e, 0x13e9c,
0x13eb8, 0x13ec2, 0x13ec4, 0x13ec8, 0x13ed0, 0x13ede, 0x13ee6, 0x13eec, 0x13f26, 0x13f2c, 0x13f3a, 0x13f46,
0x13f4c, 0x13f58, 0x13f6e, 0x13f72, 0x13f74, 0x14082, 0x1409e, 0x140a0, 0x140bc, 0x14104, 0x14108, 0x14110,
0x1411e, 0x14120, 0x1413c, 0x14140, 0x14178, 0x1418c, 0x14198, 0x141b0, 0x141be, 0x141e2, 0x141e4, 0x141e8,
0x14208, 0x14210, 0x1421e, 0x14220, 0x1423c, 0x14240, 0x14278, 0x142f0, 0x14306, 0x1430c, 0x14318, 0x14330,
0x1433e, 0x14360, 0x1437c, 0x1438e, 0x143c2, 0x143c4, 0x143c8, 0x143d0, 0x143e6, 0x143ec, 0x14408, 0x14410,
0x1441e, 0x14420, 0x1443c, 0x14440, 0x14478, 0x144f0, 0x145e0, 0x1460c, 0x14618, 0x14630, 0x1463e, 0x14660,
0x1467c, 0x146c0, 0x146f8, 0x1471c, 0x14738, 0x14770, 0x1477e, 0x14782, 0x14784, 0x14788, 0x14790, 0x147a0,
0x147bc, 0x147c6, 0x147cc, 0x147d8, 0x147ee, 0x14810, 0x14820, 0x1483c, 0x14840, 0x14878, 0x148f0, 0x149e0,
0x14bc0, 0x14c30, 0x14c3e, 0x14c60, 0x14c7c, 0x14cc0, 0x14cf8, 0x14df0, 0x14e38, 0x14e70, 0x14e7e, 0x14ee0,
0x14efc, 0x14f04, 0x14f08, 0x14f10, 0x14f1e, 0x14f20, 0x14f3c, 0x14f40, 0x14f78, 0x14f86, 0x14f8c, 0x14f98,
0x14fb0, 0x14fce, 0x14fdc, 0x15020, 0x15040, 0x15078, 0x150f0, 0x151e0, 0x153c0, 0x15860, 0x1587c, 0x158c0,
0x158f8, 0x159f0, 0x15be0, 0x15c70, 0x15c7e, 0x15ce0, 0x15cfc, 0x15dc0, 0x15df8, 0x15e08, 0x15e10, 0x15e20,
0x15e40, 0x15e78, 0x15ef0, 0x15f0c, 0x15f18, 0x15f30, 0x15f60, 0x15f7c, 0x15f8e, 0x15f9c, 0x15fb8, 0x1604e,
0x1605c, 0x1608e, 0x1609c, 0x160b8, 0x160c2, 0x160c4, 0x160c8, 0x160de, 0x1610e, 0x1611c, 0x16138, 0x16170,
0x1617e, 0x16184, 0x16188, 0x16190, 0x1619e, 0x161a0, 0x161bc, 0x161c6, 0x161cc, 0x161d8, 0x161f2, 0x161f4,
0x1620e, 0x1621c, 0x16238, 0x16270, 0x1627e, 0x162e0, 0x162fc, 0x16304, 0x16308, 0x16310, 0x1631e, 0x16320,
0x1633c, 0x16340, 0x16378, 0x16386, 0x1638c, 0x16398, 0x163b0, 0x163be, 0x163ce, 0x163dc, 0x163e2, 0x163e4,
0x163e8, 0x163f6, 0x1640e, 0x1641c, 0x16438, 0x16470, 0x1647e, 0x164e0, 0x164fc, 0x165c0, 0x165f8, 0x16610,
0x1661e, 0x16620, 0x1663c, 0x16640, 0x16678, 0x166f0, 0x16718, 0x16730, 0x1673e, 0x16760, 0x1677c, 0x1678e,
0x1679c, 0x167b8, 0x167c2, 0x167c4, 0x167c8, 0x167d0, 0x167de, 0x167e6, 0x167ec, 0x1681c, 0x16838, 0x16870,
0x168e0, 0x168fc, 0x169c0, 0x169f8, 0x16bf0, 0x16c10, 0x16c1e, 0x16c20, 0x16c3c, 0x16c40, 0x16c78, 0x16cf0,
0x16de0, 0x16e18, 0x16e30, 0x16e3e, 0x16e60, 0x16e7c, 0x16ec0, 0x16ef8, 0x16f1c, 0x16f38, 0x16f70, 0x16f7e,
0x16f84, 0x16f88, 0x16f90, 0x16f9e, 0x16fa0, 0x16fbc, 0x16fc6, 0x16fcc, 0x16fd8, 0x17026, 0x1702c, 0x17046,
0x1704c, 0x17058, 0x1706e, 0x17086, 0x1708c, 0x17098, 0x170b0, 0x170be, 0x170ce, 0x170dc, 0x170e8, 0x17106,
0x1710c, 0x17118, 0x17130, 0x1713e, 0x17160, 0x1717c, 0x1718e, 0x1719c, 0x171b8, 0x171c2, 0x171c4, 0x171c8,
0x171d0, 0x171de, 0x171e6, 0x171ec, 0x171fa, 0x17206, 0x1720c, 0x17218, 0x17230, 0x1723e, 0x17260, 0x1727c,
0x172c0, 0x172f8, 0x1730e, 0x1731c, 0x17338, 0x17370, 0x1737e, 0x17388, 0x17390, 0x1739e, 0x173a0, 0x173bc,
0x173cc, 0x173d8, 0x173ee, 0x173f2, 0x173f4, 0x1740c, 0x17418, 0x17430, 0x1743e, 0x17460, 0x1747c, 0x174c0,
0x174f8, 0x175f0, 0x1760e, 0x1761c, 0x17638, 0x17670, 0x1767e, 0x176e0, 0x176fc, 0x17708, 0x17710, 0x1771e,
0x17720, 0x1773c, 0x17740, 0x17778, 0x17798, 0x177b0, 0x177be, 0x177dc, 0x177e2, 0x177e4, 0x177e8, 0x17822,
0x17824, 0x17828, 0x17836, 0x17842, 0x17844, 0x17848, 0x17850, 0x1785e, 0x17866, 0x1786c, 0x17882, 0x17884,
0x17888, 0x17890, 0x1789e, 0x178a0, 0x178bc, 0x178c6, 0x178cc, 0x178d8, 0x178ee, 0x178f2, 0x178f4, 0x17902,
0x17904, 0x17908, 0x17910, 0x1791e, 0x17920, 0x1793c, 0x17940, 0x17978, 0x17986, 0x1798c, 0x17998, 0x179b0,
0x179be, 0x179ce, 0x179dc, 0x179e2, 0x179e4, 0x179e8, 0x179f6, 0x17a04, 0x17a08, 0x17a10, 0x17a1e, 0x17a20,
0x17a3c, 0x17a40, 0x17a78, 0x17af0, 0x17b06, 0x17b0c, 0x17b18, 0x17b30, 0x17b3e, 0x17b60, 0x17b7c, 0x17b8e,
0x17b9c, 0x17bb8, 0x17bc4, 0x17bc8, 0x17bd0, 0x17bde, 0x17be6, 0x17bec, 0x17c2e, 0x17c32, 0x17c34, 0x17c4e,
0x17c5c, 0x17c62, 0x17c64, 0x17c68, 0x17c76, 0x17c8e, 0x17c9c, 0x17cb8, 0x17cc2, 0x17cc4, 0x17cc8, 0x17cd0,
0x17cde, 0x17ce6, 0x17cec, 0x17d0e, 0x17d1c, 0x17d38, 0x17d70, 0x17d82, 0x17d84, 0x17d88, 0x17d90, 0x17d9e,
0x17da0, 0x17dbc, 0x17dc6, 0x17dcc, 0x17dd8, 0x17dee, 0x17e26, 0x17e2c, 0x17e3a, 0x17e46, 0x17e4c, 0x17e58,
0x17e6e, 0x17e72, 0x17e74, 0x17e86, 0x17e8c, 0x17e98, 0x17eb0, 0x17ece, 0x17edc, 0x17ee2, 0x17ee4, 0x17ee8,
0x17ef6, 0x1813a, 0x18172, 0x18174, 0x18216, 0x18226, 0x1823a, 0x1824c, 0x18258, 0x1826e, 0x18272, 0x18274,
0x18298, 0x182be, 0x182e2, 0x182e4, 0x182e8, 0x182f6, 0x1835e, 0x1837a, 0x183ae, 0x183d6, 0x18416, 0x18426,
0x1842c, 0x1843a, 0x18446, 0x18458, 0x1846e, 0x18472, 0x18474, 0x18486, 0x184b0, 0x184be, 0x184ce, 0x184dc,
0x184e2, 0x184e4, 0x184e8, 0x184f6, 0x18506, 0x1850c, 0x18518, 0x18530, 0x1853e, 0x18560, 0x1857c, 0x1858e,
0x1859c, 0x185b8, 0x185c2, 0x185c4, 0x185c8, 0x185d0, 0x185de, 0x185e6, 0x185ec, 0x185fa, 0x18612, 0x18614,
0x18622, 0x18628, 0x18636, 0x18642, 0x18650, 0x1865e, 0x1867a, 0x18682, 0x18684, 0x18688, 0x18690, 0x1869e,
0x186a0, 0x186bc, 0x186c6, 0x186cc, 0x186d8, 0x186ee, 0x186f2, 0x186f4, 0x1872e, 0x1874e, 0x1875c, 0x18796,
0x187a6, 0x187ac, 0x187d2, 0x187d4, 0x18826, 0x1882c, 0x1883a, 0x18846, 0x1884c, 0x18858, 0x1886e, 0x18872,
0x18874, 0x18886, 0x18898, 0x188b0, 0x188be, 0x188ce, 0x188dc, 0x188e2, 0x188e4, 0x188e8, 0x188f6, 0x1890c,
0x18930, 0x1893e, 0x18960, 0x1897c, 0x1898e, 0x189b8, 0x189c2, 0x189c8, 0x189d0, 0x189de, 0x189e6, 0x189ec,
0x189fa, 0x18a18, 0x18a30, 0x18a3e, 0x18a60, 0x18a7c, 0x18ac0, 0x18af8, 0x18b1c, 0x18b38, 0x18b70, 0x18b7e,
0x18b82, 0x18b84, 0x18b88, 0x18b90, 0x18b9e, 0x18ba0, 0x18bbc, 0x18bc6, 0x18bcc, 0x18bd8, 0x18bee, 0x18bf2,
0x18bf4, 0x18c22, 0x18c24, 0x18c28, 0x18c36, 0x18c42, 0x18c48, 0x18c50, 0x18c5e, 0x18c66, 0x18c7a, 0x18c82,
0x18c84, 0x18c90, 0x18c9e, 0x18ca0, 0x18cbc, 0x18ccc, 0x18cf2, 0x18cf4, 0x18d04, 0x18d08, 0x18d10, 0x18d1e,
0x18d20, 0x18d3c, 0x18d40, 0x18d78, 0x18d86, 0x18d98, 0x18dce, 0x18de2, 0x18de4, 0x18de8, 0x18e2e, 0x18e32,
0x18e34, 0x18e4e, 0x18e5c, 0x18e62, 0x18e64, 0x18e68, 0x18e8e, 0x18e9c, 0x18eb8, 0x18ec2, 0x18ec4, 0x18ec8,
0x18ed0, 0x18efa, 0x18f16, 0x18f26, 0x18f2c, 0x18f46, 0x18f4c, 0x18f58, 0x18f6e, 0x18f8a, 0x18f92, 0x18f94,
0x18fa2, 0x18fa4, 0x18fa8, 0x18fb6, 0x1902c, 0x1903a, 0x19046, 0x1904c, 0x19058, 0x19072, 0x19074, 0x19086,
0x19098, 0x190b0, 0x190be, 0x190ce, 0x190dc, 0x190e2, 0x190e8, 0x190f6, 0x19106, 0x1910c, 0x19130, 0x1913e,
0x19160, 0x1917c, 0x1918e, 0x1919c, 0x191b8, 0x191c2, 0x191c8, 0x191d0, 0x191de, 0x191e6, 0x191ec, 0x191fa,
0x19218, 0x1923e, 0x19260, 0x1927c, 0x192c0, 0x192f8, 0x19338, 0x19370, 0x1937e, 0x19382, 0x19384, 0x19390,
0x1939e, 0x193a0, 0x193bc, 0x193c6, 0x193cc, 0x193d8, 0x193ee, 0x193f2, 0x193f4, 0x19430, 0x1943e, 0x19460,
0x1947c, 0x194c0, 0x194f8, 0x195f0, 0x19638, 0x19670, 0x1967e, 0x196e0, 0x196fc, 0x19702, 0x19704, 0x19708,
0x19710, 0x19720, 0x1973c, 0x19740, 0x19778, 0x19786, 0x1978c, 0x19798, 0x197b0, 0x197be, 0x197ce, 0x197dc,
0x197e2, 0x197e4, 0x197e8, 0x19822, 0x19824, 0x19842, 0x19848, 0x19850, 0x1985e, 0x19866, 0x1987a, 0x19882,
0x19884, 0x19890, 0x1989e, 0x198a0, 0x198bc, 0x198cc, 0x198f2, 0x198f4, 0x19902, 0x19908, 0x1991e, 0x19920,
0x1993c, 0x19940, 0x19978, 0x19986, 0x19998, 0x199ce, 0x199e2, 0x199e4, 0x199e8, 0x19a08, 0x19a10, 0x19a1e,
0x19a20, 0x19a3c, 0x19a40, 0x19a78, 0x19af0, 0x19b18, 0x19b3e, 0x19b60, 0x19b9c, 0x19bc2, 0x19bc4, 0x19bc8,
0x19bd0, 0x19be6, 0x19c2e, 0x19c34, 0x19c4e, 0x19c5c, 0x19c62, 0x19c64, 0x19c68, 0x19c8e, 0x19c9c, 0x19cb8,
0x19cc2, 0x19cc8, 0x19cd0, 0x19ce6, 0x19cfa, 0x19d0e, 0x19d1c, 0x19d38, 0x19d70, 0x19d7e, 0x19d82, 0x19d84,
0x19d88, 0x19d90, 0x19da0, 0x19dcc, 0x19df2, 0x19df4, 0x19e16, 0x19e26, 0x19e2c, 0x19e46, 0x19e4c, 0x19e58,
0x19e74, 0x19e86, 0x19e8c, 0x19e98, 0x19eb0, 0x19ebe, 0x19ece, 0x19ee2, 0x19ee4, 0x19ee8, 0x19f0a, 0x19f12,
0x19f14, 0x19f22, 0x19f24, 0x19f28, 0x19f42, 0x19f44, 0x19f48, 0x19f50, 0x19f5e, 0x19f6c, 0x19f9a, 0x19fae,
0x19fb2, 0x19fb4, 0x1a046, 0x1a04c, 0x1a072, 0x1a074, 0x1a086, 0x1a08c, 0x1a098, 0x1a0b0, 0x1a0be, 0x1a0e2,
0x1a0e4, 0x1a0e8, 0x1a0f6, 0x1a106, 0x1a10c, 0x1a118, 0x1a130, 0x1a13e, 0x1a160, 0x1a17c, 0x1a18e, 0x1a19c,
0x1a1b8, 0x1a1c2, 0x1a1c4, 0x1a1c8, 0x1a1d0, 0x1a1de, 0x1a1e6, 0x1a1ec, 0x1a218, 0x1a230, 0x1a23e, 0x1a260,
0x1a27c, 0x1a2c0, 0x1a2f8, 0x1a31c, 0x1a338, 0x1a370, 0x1a37e, 0x1a382, 0x1a384, 0x1a388, 0x1a390, 0x1a39e,
0x1a3a0, 0x1a3bc, 0x1a3c6, 0x1a3cc, 0x1a3d8, 0x1a3ee, 0x1a3f2, 0x1a3f4, 0x1a418, 0x1a430, 0x1a43e, 0x1a460,
0x1a47c, 0x1a4c0, 0x1a4f8, 0x1a5f0, 0x1a61c, 0x1a638, 0x1a670, 0x1a67e, 0x1a6e0, 0x1a6fc, 0x1a702, 0x1a704,
0x1a708, 0x1a710, 0x1a71e, 0x1a720, 0x1a73c, 0x1a740, 0x1a778, 0x1a786, 0x1a78c, 0x1a798, 0x1a7b0, 0x1a7be,
0x1a7ce, 0x1a7dc, 0x1a7e2, 0x1a7e4, 0x1a7e8, 0x1a830, 0x1a860, 0x1a87c, 0x1a8c0, 0x1a8f8, 0x1a9f0, 0x1abe0,
0x1ac70, 0x1ac7e, 0x1ace0, 0x1acfc, 0x1adc0, 0x1adf8, 0x1ae04, 0x1ae08, 0x1ae10, 0x1ae20, 0x1ae3c, 0x1ae40,
0x1ae78, 0x1aef0, 0x1af06, 0x1af0c, 0x1af18, 0x1af30, 0x1af3e, 0x1af60, 0x1af7c, 0x1af8e, 0x1af9c, 0x1afb8,
0x1afc4, 0x1afc8, 0x1afd0, 0x1afde, 0x1b042, 0x1b05e, 0x1b07a, 0x1b082, 0x1b084, 0x1b088, 0x1b090, 0x1b09e,
0x1b0a0, 0x1b0bc, 0x1b0cc, 0x1b0f2, 0x1b0f4, 0x1b102, 0x1b104, 0x1b108, 0x1b110, 0x1b11e, 0x1b120, 0x1b13c,
0x1b140, 0x1b178, 0x1b186, 0x1b198, 0x1b1ce, 0x1b1e2, 0x1b1e4, 0x1b1e8, 0x1b204, 0x1b208, 0x1b210, 0x1b21e,
0x1b220, 0x1b23c, 0x1b240, 0x1b278, 0x1b2f0, 0x1b30c, 0x1b33e, 0x1b360, 0x1b39c, 0x1b3c2, 0x1b3c4, 0x1b3c8,
0x1b3d0, 0x1b3e6, 0x1b410, 0x1b41e, 0x1b420, 0x1b43c, 0x1b440, 0x1b478, 0x1b4f0, 0x1b5e0, 0x1b618, 0x1b660,
0x1b67c, 0x1b6c0, 0x1b738, 0x1b782, 0x1b784, 0x1b788, 0x1b790, 0x1b79e, 0x1b7a0, 0x1b7cc, 0x1b82e, 0x1b84e,
0x1b85c, 0x1b88e, 0x1b89c, 0x1b8b8, 0x1b8c2, 0x1b8c4, 0x1b8c8, 0x1b8d0, 0x1b8e6, 0x1b8fa, 0x1b90e, 0x1b91c,
0x1b938, 0x1b970, 0x1b97e, 0x1b982, 0x1b984, 0x1b988, 0x1b990, 0x1b99e, 0x1b9a0, 0x1b9cc, 0x1b9f2, 0x1b9f4,
0x1ba0e, 0x1ba1c, 0x1ba38, 0x1ba70, 0x1ba7e, 0x1bae0, 0x1bafc, 0x1bb08, 0x1bb10, 0x1bb20, 0x1bb3c, 0x1bb40,
0x1bb98, 0x1bbce, 0x1bbe2, 0x1bbe4, 0x1bbe8, 0x1bc16, 0x1bc26, 0x1bc2c, 0x1bc46, 0x1bc4c, 0x1bc58, 0x1bc72,
0x1bc74, 0x1bc86, 0x1bc8c, 0x1bc98, 0x1bcb0, 0x1bcbe, 0x1bcce, 0x1bce2, 0x1bce4, 0x1bce8, 0x1bd06, 0x1bd0c,
0x1bd18, 0x1bd30, 0x1bd3e, 0x1bd60, 0x1bd7c, 0x1bd9c, 0x1bdc2, 0x1bdc4, 0x1bdc8, 0x1bdd0, 0x1bde6, 0x1bdfa,
0x1be12, 0x1be14, 0x1be22, 0x1be24, 0x1be28, 0x1be42, 0x1be44, 0x1be48, 0x1be50, 0x1be5e, 0x1be66, 0x1be82,
0x1be84, 0x1be88, 0x1be90, 0x1be9e, 0x1bea0, 0x1bebc, 0x1becc, 0x1bef4, 0x1bf1a, 0x1bf2e, 0x1bf32, 0x1bf34,
0x1bf4e, 0x1bf5c, 0x1bf62, 0x1bf64, 0x1bf68, 0x1c09a, 0x1c0b2, 0x1c0b4, 0x1c11a, 0x1c132, 0x1c134, 0x1c162,
0x1c164, 0x1c168, 0x1c176, 0x1c1ba, 0x1c21a, 0x1c232, 0x1c234, 0x1c24e, 0x1c25c, 0x1c262, 0x1c264, 0x1c268,
0x1c276, 0x1c28e, 0x1c2c2, 0x1c2c4, 0x1c2c8, 0x1c2d0, 0x1c2de, 0x1c2e6, 0x1c2ec, 0x1c2fa, 0x1c316, 0x1c326,
0x1c33a, 0x1c346, 0x1c34c, 0x1c372, 0x1c374, 0x1c41a, 0x1c42e, 0x1c432, 0x1c434, 0x1c44e, 0x1c45c, 0x1c462,
0x1c464, 0x1c468, 0x1c476, 0x1c48e, 0x1c49c, 0x1c4b8, 0x1c4c2, 0x1c4c8, 0x1c4d0, 0x1c4de, 0x1c4e6, 0x1c4ec,
0x1c4fa, 0x1c51c, 0x1c538, 0x1c570, 0x1c57e, 0x1c582, 0x1c584, 0x1c588, 0x1c590, 0x1c59e, 0x1c5a0, 0x1c5bc,
0x1c5c6, 0x1c5cc, 0x1c5d8, 0x1c5ee, 0x1c5f2, 0x1c5f4, 0x1c616, 0x1c626, 0x1c62c, 0x1c63a, 0x1c646, 0x1c64c,
0x1c658, 0x1c66e, 0x1c672, 0x1c674, 0x1c686, 0x1c68c, 0x1c698, 0x1c6b0, 0x1c6be, 0x1c6ce, 0x1c6dc, 0x1c6e2,
0x1c6e4, 0x1c6e8, 0x1c712, 0x1c714, 0x1c722, 0x1c728, 0x1c736, 0x1c742, 0x1c744, 0x1c748, 0x1c750, 0x1c75e,
0x1c766, 0x1c76c, 0x1c77a, 0x1c7ae, 0x1c7d6, 0x1c7ea, 0x1c81a, 0x1c82e, 0x1c832, 0x1c834, 0x1c84e, 0x1c85c,
0x1c862, 0x1c864, 0x1c868, 0x1c876, 0x1c88e, 0x1c89c, 0x1c8b8, 0x1c8c2, 0x1c8c8, 0x1c8d0, 0x1c8de, 0x1c8e6,
0x1c8ec, 0x1c8fa, 0x1c90e, 0x1c938, 0x1c970, 0x1c97e, 0x1c982, 0x1c984, 0x1c990, 0x1c99e, 0x1c9a0, 0x1c9bc,
0x1c9c6, 0x1c9cc, 0x1c9d8, 0x1c9ee, 0x1c9f2, 0x1c9f4, 0x1ca38, 0x1ca70, 0x1ca7e, 0x1cae0, 0x1cafc, 0x1cb02,
0x1cb04, 0x1cb08, 0x1cb10, 0x1cb20, 0x1cb3c, 0x1cb40, 0x1cb78, 0x1cb86, 0x1cb8c, 0x1cb98, 0x1cbb0, 0x1cbbe,
0x1cbce, 0x1cbdc, 0x1cbe2, 0x1cbe4, 0x1cbe8, 0x1cbf6, 0x1cc16, 0x1cc26, 0x1cc2c, 0x1cc3a, 0x1cc46, 0x1cc58,
0x1cc72, 0x1cc74, 0x1cc86, 0x1ccb0, 0x1ccbe, 0x1ccce, 0x1cce2, 0x1cce4, 0x1cce8, 0x1cd06, 0x1cd0c, 0x1cd18,
0x1cd30, 0x1cd3e, 0x1cd60, 0x1cd7c, 0x1cd9c, 0x1cdc2, 0x1cdc4, 0x1cdc8, 0x1cdd0, 0x1cdde, 0x1cde6, 0x1cdfa,
0x1ce22, 0x1ce28, 0x1ce42, 0x1ce50, 0x1ce5e, 0x1ce66, 0x1ce7a, 0x1ce82, 0x1ce84, 0x1ce88, 0x1ce90, 0x1ce9e,
0x1cea0, 0x1cebc, 0x1cecc, 0x1cef2, 0x1cef4, 0x1cf2e, 0x1cf32, 0x1cf34, 0x1cf4e, 0x1cf5c, 0x1cf62, 0x1cf64,
0x1cf68, 0x1cf96, 0x1cfa6, 0x1cfac, 0x1cfca, 0x1cfd2, 0x1cfd4, 0x1d02e, 0x1d032, 0x1d034, 0x1d04e, 0x1d05c,
0x1d062, 0x1d064, 0x1d068, 0x1d076, 0x1d08e, 0x1d09c, 0x1d0b8, 0x1d0c2, 0x1d0c4, 0x1d0c8, 0x1d0d0, 0x1d0de,
0x1d0e6, 0x1d0ec, 0x1d0fa, 0x1d11c, 0x1d138, 0x1d170, 0x1d17e, 0x1d182, 0x1d184, 0x1d188, 0x1d190, 0x1d19e,
0x1d1a0, 0x1d1bc, 0x1d1c6, 0x1d1cc, 0x1d1d8, 0x1d1ee, 0x1d1f2, 0x1d1f4, 0x1d21c, 0x1d238, 0x1d270, 0x1d27e,
0x1d2e0, 0x1d2fc, 0x1d302, 0x1d304, 0x1d308, 0x1d310, 0x1d31e, 0x1d320, 0x1d33c, 0x1d340, 0x1d378, 0x1d386,
0x1d38c, 0x1d398, 0x1d3b0, 0x1d3be, 0x1d3ce, 0x1d3dc, 0x1d3e2, 0x1d3e4, 0x1d3e8, 0x1d3f6, 0x1d470, 0x1d47e,
0x1d4e0, 0x1d4fc, 0x1d5c0, 0x1d5f8, 0x1d604, 0x1d608, 0x1d610, 0x1d620, 0x1d640, 0x1d678, 0x1d6f0, 0x1d706,
0x1d70c, 0x1d718, 0x1d730, 0x1d73e, 0x1d760, 0x1d77c, 0x1d78e, 0x1d79c, 0x1d7b8, 0x1d7c2, 0x1d7c4, 0x1d7c8,
0x1d7d0, 0x1d7de, 0x1d7e6, 0x1d7ec, 0x1d826, 0x1d82c, 0x1d83a, 0x1d846, 0x1d84c, 0x1d858, 0x1d872, 0x1d874,
0x1d886, 0x1d88c, 0x1d898, 0x1d8b0, 0x1d8be, 0x1d8ce, 0x1d8e2, 0x1d8e4, 0x1d8e8, 0x1d8f6, 0x1d90c, 0x1d918,
0x1d930, 0x1d93e, 0x1d960, 0x1d97c, 0x1d99c, 0x1d9c2, 0x1d9c4, 0x1d9c8, 0x1d9d0, 0x1d9e6, 0x1d9fa, 0x1da0c,
0x1da18, 0x1da30, 0x1da3e, 0x1da60, 0x1da7c, 0x1dac0, 0x1daf8, 0x1db38, 0x1db82, 0x1db84, 0x1db88, 0x1db90,
0x1db9e, 0x1dba0, 0x1dbcc, 0x1dbf2, 0x1dbf4, 0x1dc22, 0x1dc42, 0x1dc44, 0x1dc48, 0x1dc50, 0x1dc5e, 0x1dc66,
0x1dc7a, 0x1dc82, 0x1dc84, 0x1dc88, 0x1dc90, 0x1dc9e, 0x1dca0, 0x1dcbc, 0x1dccc, 0x1dcf2, 0x1dcf4, 0x1dd04,
0x1dd08, 0x1dd10, 0x1dd1e, 0x1dd20, 0x1dd3c, 0x1dd40, 0x1dd78, 0x1dd86, 0x1dd98, 0x1ddce, 0x1dde2, 0x1dde4,
0x1dde8, 0x1de2e, 0x1de32, 0x1de34, 0x1de4e, 0x1de5c, 0x1de62, 0x1de64, 0x1de68, 0x1de8e, 0x1de9c, 0x1deb8,
0x1dec2, 0x1dec4, 0x1dec8, 0x1ded0, 0x1dee6, 0x1defa, 0x1df16, 0x1df26, 0x1df2c, 0x1df46, 0x1df4c, 0x1df58,
0x1df72, 0x1df74, 0x1df8a, 0x1df92, 0x1df94, 0x1dfa2, 0x1dfa4, 0x1dfa8, 0x1e08a, 0x1e092, 0x1e094, 0x1e0a2,
0x1e0a4, 0x1e0a8, 0x1e0b6, 0x1e0da, 0x1e10a, 0x1e112, 0x1e114, 0x1e122, 0x1e124, 0x1e128, 0x1e136, 0x1e142,
0x1e144, 0x1e148, 0x1e150, 0x1e166, 0x1e16c, 0x1e17a, 0x1e19a, 0x1e1b2, 0x1e1b4, 0x1e20a, 0x1e212, 0x1e214,
0x1e222, 0x1e224, 0x1e228, 0x1e236, 0x1e242, 0x1e248, 0x1e250, 0x1e25e, 0x1e266, 0x1e26c, 0x1e27a, 0x1e282,
0x1e284, 0x1e288, 0x1e290, 0x1e2a0, 0x1e2bc, 0x1e2c6, 0x1e2cc, 0x1e2d8, 0x1e2ee, 0x1e2f2, 0x1e2f4, 0x1e31a,
0x1e332, 0x1e334, 0x1e35c, 0x1e362, 0x1e364, 0x1e368, 0x1e3ba, 0x1e40a, 0x1e412, 0x1e414, 0x1e422, 0x1e428,
0x1e436, 0x1e442, 0x1e448, 0x1e450, 0x1e45e, 0x1e466, 0x1e46c, 0x1e47a, 0x1e482, 0x1e484, 0x1e490, 0x1e49e,
0x1e4a0, 0x1e4bc, 0x1e4c6, 0x1e4cc, 0x1e4d8, 0x1e4ee, 0x1e4f2, 0x1e4f4, 0x1e502, 0x1e504, 0x1e508, 0x1e510,
0x1e51e, 0x1e520, 0x1e53c, 0x1e540, 0x1e578, 0x1e586, 0x1e58c, 0x1e598, 0x1e5b0, 0x1e5be, 0x1e5ce, 0x1e5dc,
0x1e5e2, 0x1e5e4, 0x1e5e8, 0x1e5f6, 0x1e61a, 0x1e62e, 0x1e632, 0x1e634, 0x1e64e, 0x1e65c, 0x1e662, 0x1e668,
0x1e68e, 0x1e69c, 0x1e6b8, 0x1e6c2, 0x1e6c4, 0x1e6c8, 0x1e6d0, 0x1e6e6, 0x1e6fa, 0x1e716, 0x1e726, 0x1e72c,
0x1e73a, 0x1e746, 0x1e74c, 0x1e758, 0x1e772, 0x1e774, 0x1e792, 0x1e794, 0x1e7a2, 0x1e7a4, 0x1e7a8, 0x1e7b6,
0x1e812, 0x1e814, 0x1e822, 0x1e824, 0x1e828, 0x1e836, 0x1e842, 0x1e844, 0x1e848, 0x1e850, 0x1e85e, 0x1e866,
0x1e86c, 0x1e87a, 0x1e882, 0x1e884, 0x1e888, 0x1e890, 0x1e89e, 0x1e8a0, 0x1e8bc, 0x1e8c6, 0x1e8cc, 0x1e8d8,
0x1e8ee, 0x1e8f2, 0x1e8f4, 0x1e902, 0x1e904, 0x1e908, 0x1e910, 0x1e920, 0x1e93c, 0x1e940, 0x1e978, 0x1e986,
0x1e98c, 0x1e998, 0x1e9b0, 0x1e9be, 0x1e9ce, 0x1e9dc, 0x1e9e2, 0x1e9e4, 0x1e9e8, 0x1e9f6, 0x1ea04, 0x1ea08,
0x1ea10, 0x1ea20, 0x1ea40, 0x1ea78, 0x1eaf0, 0x1eb06, 0x1eb0c, 0x1eb18, 0x1eb30, 0x1eb3e, 0x1eb60, 0x1eb7c,
0x1eb8e, 0x1eb9c, 0x1ebb8, 0x1ebc2, 0x1ebc4, 0x1ebc8, 0x1ebd0, 0x1ebde, 0x1ebe6, 0x1ebec, 0x1ec1a, 0x1ec2e,
0x1ec32, 0x1ec34, 0x1ec4e, 0x1ec5c, 0x1ec62, 0x1ec64, 0x1ec68, 0x1ec8e, 0x1ec9c, 0x1ecb8, 0x1ecc2, 0x1ecc4,
0x1ecc8, 0x1ecd0, 0x1ece6, 0x1ecfa, 0x1ed0e, 0x1ed1c, 0x1ed38, 0x1ed70, 0x1ed7e, 0x1ed82, 0x1ed84, 0x1ed88,
0x1ed90, 0x1ed9e, 0x1eda0, 0x1edcc, 0x1edf2, 0x1edf4, 0x1ee16, 0x1ee26, 0x1ee2c, 0x1ee3a, 0x1ee46, 0x1ee4c,
0x1ee58, 0x1ee6e, 0x1ee72, 0x1ee74, 0x1ee86, 0x1ee8c, 0x1ee98, 0x1eeb0, 0x1eebe, 0x1eece, 0x1eedc, 0x1eee2,
0x1eee4, 0x1eee8, 0x1ef12, 0x1ef22, 0x1ef24, 0x1ef28, 0x1ef36, 0x1ef42, 0x1ef44, 0x1ef48, 0x1ef50, 0x1ef5e,
0x1ef66, 0x1ef6c, 0x1ef7a, 0x1efae, 0x1efb2, 0x1efb4, 0x1efd6, 0x1f096, 0x1f0a6, 0x1f0ac, 0x1f0ba, 0x1f0ca,
0x1f0d2, 0x1f0d4, 0x1f116, 0x1f126, 0x1f12c, 0x1f13a, 0x1f146, 0x1f14c, 0x1f158, 0x1f16e, 0x1f172, 0x1f174,
0x1f18a, 0x1f192, 0x1f194, 0x1f1a2, 0x1f1a4, 0x1f1a8, 0x1f1da, 0x1f216, 0x1f226, 0x1f22c, 0x1f23a, 0x1f246,
0x1f258, 0x1f26e, 0x1f272, 0x1f274, 0x1f286, 0x1f28c, 0x1f298, 0x1f2b0, 0x1f2be, 0x1f2ce, 0x1f2dc, 0x1f2e2,
0x1f2e4, 0x1f2e8, 0x1f2f6, 0x1f30a, 0x1f312, 0x1f314, 0x1f322, 0x1f328, 0x1f342, 0x1f344, 0x1f348, 0x1f350,
0x1f35e, 0x1f366, 0x1f37a, 0x1f39a, 0x1f3ae, 0x1f3b2, 0x1f3b4, 0x1f416, 0x1f426, 0x1f42c, 0x1f43a, 0x1f446,
0x1f44c, 0x1f458, 0x1f46e, 0x1f472, 0x1f474, 0x1f486, 0x1f48c, 0x1f498, 0x1f4b0, 0x1f4be, 0x1f4ce, 0x1f4dc,
0x1f4e2, 0x1f4e4, 0x1f4e8, 0x1f4f6, 0x1f506, 0x1f50c, 0x1f518, 0x1f530, 0x1f53e, 0x1f560, 0x1f57c, 0x1f58e,
0x1f59c, 0x1f5b8, 0x1f5c2, 0x1f5c4, 0x1f5c8, 0x1f5d0, 0x1f5de, 0x1f5e6, 0x1f5ec, 0x1f5fa, 0x1f60a, 0x1f612,
0x1f614, 0x1f622, 0x1f624, 0x1f628, 0x1f636, 0x1f642, 0x1f644, 0x1f648, 0x1f650, 0x1f65e, 0x1f666, 0x1f67a,
0x1f682, 0x1f684, 0x1f688, 0x1f690, 0x1f69e, 0x1f6a0, 0x1f6bc, 0x1f6cc, 0x1f6f2, 0x1f6f4, 0x1f71a, 0x1f72e,
0x1f732, 0x1f734, 0x1f74e, 0x1f75c, 0x1f762, 0x1f764, 0x1f768, 0x1f776, 0x1f796, 0x1f7a6, 0x1f7ac, 0x1f7ba,
0x1f7d2, 0x1f7d4, 0x1f89a, 0x1f8ae, 0x1f8b2, 0x1f8b4, 0x1f8d6, 0x1f8ea, 0x1f91a, 0x1f92e, 0x1f932, 0x1f934,
0x1f94e, 0x1f95c, 0x1f962, 0x1f964, 0x1f968, 0x1f976, 0x1f996, 0x1f9a6, 0x1f9ac, 0x1f9ba, 0x1f9ca, 0x1f9d2,
0x1f9d4, 0x1fa1a, 0x1fa2e, 0x1fa32, 0x1fa34, 0x1fa4e, 0x1fa5c, 0x1fa62, 0x1fa64, 0x1fa68, 0x1fa76, 0x1fa8e,
0x1fa9c, 0x1fab8, 0x1fac2, 0x1fac4, 0x1fac8, 0x1fad0, 0x1fade, 0x1fae6, 0x1faec, 0x1fb16, 0x1fb26, 0x1fb2c,
0x1fb3a, 0x1fb46, 0x1fb4c, 0x1fb58, 0x1fb6e, 0x1fb72, 0x1fb74, 0x1fb8a, 0x1fb92, 0x1fb94, 0x1fba2, 0x1fba4,
0x1fba8, 0x1fbb6, 0x1fbda
]);
/**
* This table contains to codewords for all symbols.
*/
PDF417Common.CODEWORD_TABLE = Int32Array.from([
2627, 1819, 2622, 2621, 1813, 1812, 2729, 2724, 2723, 2779, 2774, 2773, 902, 896, 908, 868, 865, 861, 859, 2511,
873, 871, 1780, 835, 2493, 825, 2491, 842, 837, 844, 1764, 1762, 811, 810, 809, 2483, 807, 2482, 806, 2480, 815,
814, 813, 812, 2484, 817, 816, 1745, 1744, 1742, 1746, 2655, 2637, 2635, 2626, 2625, 2623, 2628, 1820, 2752,
2739, 2737, 2728, 2727, 2725, 2730, 2785, 2783, 2778, 2777, 2775, 2780, 787, 781, 747, 739, 736, 2413, 754, 752,
1719, 692, 689, 681, 2371, 678, 2369, 700, 697, 694, 703, 1688, 1686, 642, 638, 2343, 631, 2341, 627, 2338, 651,
646, 643, 2345, 654, 652, 1652, 1650, 1647, 1654, 601, 599, 2322, 596, 2321, 594, 2319, 2317, 611, 610, 608, 606,
2324, 603, 2323, 615, 614, 612, 1617, 1616, 1614, 1612, 616, 1619, 1618, 2575, 2538, 2536, 905, 901, 898, 909,
2509, 2507, 2504, 870, 867, 864, 860, 2512, 875, 872, 1781, 2490, 2489, 2487, 2485, 1748, 836, 834, 832, 830,
2494, 827, 2492, 843, 841, 839, 845, 1765, 1763, 2701, 2676, 2674, 2653, 2648, 2656, 2634, 2633, 2631, 2629,
1821, 2638, 2636, 2770, 2763, 2761, 2750, 2745, 2753, 2736, 2735, 2733, 2731, 1848, 2740, 2738, 2786, 2784, 591,
588, 576, 569, 566, 2296, 1590, 537, 534, 526, 2276, 522, 2274, 545, 542, 539, 548, 1572, 1570, 481, 2245, 466,
2242, 462, 2239, 492, 485, 482, 2249, 496, 494, 1534, 1531, 1528, 1538, 413, 2196, 406, 2191, 2188, 425, 419,
2202, 415, 2199, 432, 430, 427, 1472, 1467, 1464, 433, 1476, 1474, 368, 367, 2160, 365, 2159, 362, 2157, 2155,
2152, 378, 377, 375, 2166, 372, 2165, 369, 2162, 383, 381, 379, 2168, 1419, 1418, 1416, 1414, 385, 1411, 384,
1423, 1422, 1420, 1424, 2461, 802, 2441, 2439, 790, 786, 783, 794, 2409, 2406, 2403, 750, 742, 738, 2414, 756,
753, 1720, 2367, 2365, 2362, 2359, 1663, 693, 691, 684, 2373, 680, 2370, 702, 699, 696, 704, 1690, 1687, 2337,
2336, 2334, 2332, 1624, 2329, 1622, 640, 637, 2344, 634, 2342, 630, 2340, 650, 648, 645, 2346, 655, 653, 1653,
1651, 1649, 1655, 2612, 2597, 2595, 2571, 2568, 2565, 2576, 2534, 2529, 2526, 1787, 2540, 2537, 907, 904, 900,
910, 2503, 2502, 2500, 2498, 1768, 2495, 1767, 2510, 2508, 2506, 869, 866, 863, 2513, 876, 874, 1782, 2720, 2713,
2711, 2697, 2694, 2691, 2702, 2672, 2670, 2664, 1828, 2678, 2675, 2647, 2646, 2644, 2642, 1823, 2639, 1822, 2654,
2652, 2650, 2657, 2771, 1855, 2765, 2762, 1850, 1849, 2751, 2749, 2747, 2754, 353, 2148, 344, 342, 336, 2142,
332, 2140, 345, 1375, 1373, 306, 2130, 299, 2128, 295, 2125, 319, 314, 311, 2132, 1354, 1352, 1349, 1356, 262,
257, 2101, 253, 2096, 2093, 274, 273, 267, 2107, 263, 2104, 280, 278, 275, 1316, 1311, 1308, 1320, 1318, 2052,
202, 2050, 2044, 2040, 219, 2063, 212, 2060, 208, 2055, 224, 221, 2066, 1260, 1258, 1252, 231, 1248, 229, 1266,
1264, 1261, 1268, 155, 1998, 153, 1996, 1994, 1991, 1988, 165, 164, 2007, 162, 2006, 159, 2003, 2000, 172, 171,
169, 2012, 166, 2010, 1186, 1184, 1182, 1179, 175, 1176, 173, 1192, 1191, 1189, 1187, 176, 1194, 1193, 2313,
2307, 2305, 592, 589, 2294, 2292, 2289, 578, 572, 568, 2297, 580, 1591, 2272, 2267, 2264, 1547, 538, 536, 529,
2278, 525, 2275, 547, 544, 541, 1574, 1571, 2237, 2235, 2229, 1493, 2225, 1489, 478, 2247, 470, 2244, 465, 2241,
493, 488, 484, 2250, 498, 495, 1536, 1533, 1530, 1539, 2187, 2186, 2184, 2182, 1432, 2179, 1430, 2176, 1427, 414,
412, 2197, 409, 2195, 405, 2193, 2190, 426, 424, 421, 2203, 418, 2201, 431, 429, 1473, 1471, 1469, 1466, 434,
1477, 1475, 2478, 2472, 2470, 2459, 2457, 2454, 2462, 803, 2437, 2432, 2429, 1726, 2443, 2440, 792, 789, 785,
2401, 2399, 2393, 1702, 2389, 1699, 2411, 2408, 2405, 745, 741, 2415, 758, 755, 1721, 2358, 2357, 2355, 2353,
1661, 2350, 1660, 2347, 1657, 2368, 2366, 2364, 2361, 1666, 690, 687, 2374, 683, 2372, 701, 698, 705, 1691, 1689,
2619, 2617, 2610, 2608, 2605, 2613, 2593, 2588, 2585, 1803, 2599, 2596, 2563, 2561, 2555, 1797, 2551, 1795, 2573,
2570, 2567, 2577, 2525, 2524, 2522, 2520, 1786, 2517, 1785, 2514, 1783, 2535, 2533, 2531, 2528, 1788, 2541, 2539,
906, 903, 911, 2721, 1844, 2715, 2712, 1838, 1836, 2699, 2696, 2693, 2703, 1827, 1826, 1824, 2673, 2671, 2669,
2666, 1829, 2679, 2677, 1858, 1857, 2772, 1854, 1853, 1851, 1856, 2766, 2764, 143, 1987, 139, 1986, 135, 133,
131, 1984, 128, 1983, 125, 1981, 138, 137, 136, 1985, 1133, 1132, 1130, 112, 110, 1974, 107, 1973, 104, 1971,
1969, 122, 121, 119, 117, 1977, 114, 1976, 124, 1115, 1114, 1112, 1110, 1117, 1116, 84, 83, 1953, 81, 1952, 78,
1950, 1948, 1945, 94, 93, 91, 1959, 88, 1958, 85, 1955, 99, 97, 95, 1961, 1086, 1085, 1083, 1081, 1078, 100,
1090, 1089, 1087, 1091, 49, 47, 1917, 44, 1915, 1913, 1910, 1907, 59, 1926, 56, 1925, 53, 1922, 1919, 66, 64,
1931, 61, 1929, 1042, 1040, 1038, 71, 1035, 70, 1032, 68, 1048, 1047, 1045, 1043, 1050, 1049, 12, 10, 1869, 1867,
1864, 1861, 21, 1880, 19, 1877, 1874, 1871, 28, 1888, 25, 1886, 22, 1883, 982, 980, 977, 974, 32, 30, 991, 989,
987, 984, 34, 995, 994, 992, 2151, 2150, 2147, 2146, 2144, 356, 355, 354, 2149, 2139, 2138, 2136, 2134, 1359,
343, 341, 338, 2143, 335, 2141, 348, 347, 346, 1376, 1374, 2124, 2123, 2121, 2119, 1326, 2116, 1324, 310, 308,
305, 2131, 302, 2129, 298, 2127, 320, 318, 316, 313, 2133, 322, 321, 1355, 1353, 1351, 1357, 2092, 2091, 2089,
2087, 1276, 2084, 1274, 2081, 1271, 259, 2102, 256, 2100, 252, 2098, 2095, 272, 269, 2108, 266, 2106, 281, 279,
277, 1317, 1315, 1313, 1310, 282, 1321, 1319, 2039, 2037, 2035, 2032, 1203, 2029, 1200, 1197, 207, 2053, 205,
2051, 201, 2049, 2046, 2043, 220, 218, 2064, 215, 2062, 211, 2059, 228, 226, 223, 2069, 1259, 1257, 1254, 232,
1251, 230, 1267, 1265, 1263, 2316, 2315, 2312, 2311, 2309, 2314, 2304, 2303, 2301, 2299, 1593, 2308, 2306, 590,
2288, 2287, 2285, 2283, 1578, 2280, 1577, 2295, 2293, 2291, 579, 577, 574, 571, 2298, 582, 581, 1592, 2263, 2262,
2260, 2258, 1545, 2255, 1544, 2252, 1541, 2273, 2271, 2269, 2266, 1550, 535, 532, 2279, 528, 2277, 546, 543, 549,
1575, 1573, 2224, 2222, 2220, 1486, 2217, 1485, 2214, 1482, 1479, 2238, 2236, 2234, 2231, 1496, 2228, 1492, 480,
477, 2248, 473, 2246, 469, 2243, 490, 487, 2251, 497, 1537, 1535, 1532, 2477, 2476, 2474, 2479, 2469, 2468, 2466,
2464, 1730, 2473, 2471, 2453, 2452, 2450, 2448, 1729, 2445, 1728, 2460, 2458, 2456, 2463, 805, 804, 2428, 2427,
2425, 2423, 1725, 2420, 1724, 2417, 1722, 2438, 2436, 2434, 2431, 1727, 2444, 2442, 793, 791, 788, 795, 2388,
2386, 2384, 1697, 2381, 1696, 2378, 1694, 1692, 2402, 2400, 2398, 2395, 1703, 2392, 1701, 2412, 2410, 2407, 751,
748, 744, 2416, 759, 757, 1807, 2620, 2618, 1806, 1805, 2611, 2609, 2607, 2614, 1802, 1801, 1799, 2594, 2592,
2590, 2587, 1804, 2600, 2598, 1794, 1793, 1791, 1789, 2564, 2562, 2560, 2557, 1798, 2554, 1796, 2574, 2572, 2569,
2578, 1847, 1846, 2722, 1843, 1842, 1840, 1845, 2716, 2714, 1835, 1834, 1832, 1830, 1839, 1837, 2700, 2698, 2695,
2704, 1817, 1811, 1810, 897, 862, 1777, 829, 826, 838, 1760, 1758, 808, 2481, 1741, 1740, 1738, 1743, 2624, 1818,
2726, 2776, 782, 740, 737, 1715, 686, 679, 695, 1682, 1680, 639, 628, 2339, 647, 644, 1645, 1643, 1640, 1648,
602, 600, 597, 595, 2320, 593, 2318, 609, 607, 604, 1611, 1610, 1608, 1606, 613, 1615, 1613, 2328, 926, 924, 892,
886, 899, 857, 850, 2505, 1778, 824, 823, 821, 819, 2488, 818, 2486, 833, 831, 828, 840, 1761, 1759, 2649, 2632,
2630, 2746, 2734, 2732, 2782, 2781, 570, 567, 1587, 531, 527, 523, 540, 1566, 1564, 476, 467, 463, 2240, 486,
483, 1524, 1521, 1518, 1529, 411, 403, 2192, 399, 2189, 423, 416, 1462, 1457, 1454, 428, 1468, 1465, 2210, 366,
363, 2158, 360, 2156, 357, 2153, 376, 373, 370, 2163, 1410, 1409, 1407, 1405, 382, 1402, 380, 1417, 1415, 1412,
1421, 2175, 2174, 777, 774, 771, 784, 732, 725, 722, 2404, 743, 1716, 676, 674, 668, 2363, 665, 2360, 685, 1684,
1681, 626, 624, 622, 2335, 620, 2333, 617, 2330, 641, 635, 649, 1646, 1644, 1642, 2566, 928, 925, 2530, 2527,
894, 891, 888, 2501, 2499, 2496, 858, 856, 854, 851, 1779, 2692, 2668, 2665, 2645, 2643, 2640, 2651, 2768, 2759,
2757, 2744, 2743, 2741, 2748, 352, 1382, 340, 337, 333, 1371, 1369, 307, 300, 296, 2126, 315, 312, 1347, 1342,
1350, 261, 258, 250, 2097, 246, 2094, 271, 268, 264, 1306, 1301, 1298, 276, 1312, 1309, 2115, 203, 2048, 195,
2045, 191, 2041, 213, 209, 2056, 1246, 1244, 1238, 225, 1234, 222, 1256, 1253, 1249, 1262, 2080, 2079, 154, 1997,
150, 1995, 147, 1992, 1989, 163, 160, 2004, 156, 2001, 1175, 1174, 1172, 1170, 1167, 170, 1164, 167, 1185, 1183,
1180, 1177, 174, 1190, 1188, 2025, 2024, 2022, 587, 586, 564, 559, 556, 2290, 573, 1588, 520, 518, 512, 2268,
508, 2265, 530, 1568, 1565, 461, 457, 2233, 450, 2230, 446, 2226, 479, 471, 489, 1526, 1523, 1520, 397, 395,
2185, 392, 2183, 389, 2180, 2177, 410, 2194, 402, 422, 1463, 1461, 1459, 1456, 1470, 2455, 799, 2433, 2430, 779,
776, 773, 2397, 2394, 2390, 734, 728, 724, 746, 1717, 2356, 2354, 2351, 2348, 1658, 677, 675, 673, 670, 667, 688,
1685, 1683, 2606, 2589, 2586, 2559, 2556, 2552, 927, 2523, 2521, 2518, 2515, 1784, 2532, 895, 893, 890, 2718,
2709, 2707, 2689, 2687, 2684, 2663, 2662, 2660, 2658, 1825, 2667, 2769, 1852, 2760, 2758, 142, 141, 1139, 1138,
134, 132, 129, 126, 1982, 1129, 1128, 1126, 1131, 113, 111, 108, 105, 1972, 101, 1970, 120, 118, 115, 1109, 1108,
1106, 1104, 123, 1113, 1111, 82, 79, 1951, 75, 1949, 72, 1946, 92, 89, 86, 1956, 1077, 1076, 1074, 1072, 98,
1069, 96, 1084, 1082, 1079, 1088, 1968, 1967, 48, 45, 1916, 42, 1914, 39, 1911, 1908, 60, 57, 54, 1923, 50, 1920,
1031, 1030, 1028, 1026, 67, 1023, 65, 1020, 62, 1041, 1039, 1036, 1033, 69, 1046, 1044, 1944, 1943, 1941, 11, 9,
1868, 7, 1865, 1862, 1859, 20, 1878, 16, 1875, 13, 1872, 970, 968, 966, 963, 29, 960, 26, 23, 983, 981, 978, 975,
33, 971, 31, 990, 988, 985, 1906, 1904, 1902, 993, 351, 2145, 1383, 331, 330, 328, 326, 2137, 323, 2135, 339,
1372, 1370, 294, 293, 291, 289, 2122, 286, 2120, 283, 2117, 309, 303, 317, 1348, 1346, 1344, 245, 244, 242, 2090,
239, 2088, 236, 2085, 2082, 260, 2099, 249, 270, 1307, 1305, 1303, 1300, 1314, 189, 2038, 186, 2036, 183, 2033,
2030, 2026, 206, 198, 2047, 194, 216, 1247, 1245, 1243, 1240, 227, 1237, 1255, 2310, 2302, 2300, 2286, 2284,
2281, 565, 563, 561, 558, 575, 1589, 2261, 2259, 2256, 2253, 1542, 521, 519, 517, 514, 2270, 511, 533, 1569,
1567, 2223, 2221, 2218, 2215, 1483, 2211, 1480, 459, 456, 453, 2232, 449, 474, 491, 1527, 1525, 1522, 2475, 2467,
2465, 2451, 2449, 2446, 801, 800, 2426, 2424, 2421, 2418, 1723, 2435, 780, 778, 775, 2387, 2385, 2382, 2379,
1695, 2375, 1693, 2396, 735, 733, 730, 727, 749, 1718, 2616, 2615, 2604, 2603, 2601, 2584, 2583, 2581, 2579,
1800, 2591, 2550, 2549, 2547, 2545, 1792, 2542, 1790, 2558, 929, 2719, 1841, 2710, 2708, 1833, 1831, 2690, 2688,
2686, 1815, 1809, 1808, 1774, 1756, 1754, 1737, 1736, 1734, 1739, 1816, 1711, 1676, 1674, 633, 629, 1638, 1636,
1633, 1641, 598, 1605, 1604, 1602, 1600, 605, 1609, 1607, 2327, 887, 853, 1775, 822, 820, 1757, 1755, 1584, 524,
1560, 1558, 468, 464, 1514, 1511, 1508, 1519, 408, 404, 400, 1452, 1447, 1444, 417, 1458, 1455, 2208, 364, 361,
358, 2154, 1401, 1400, 1398, 1396, 374, 1393, 371, 1408, 1406, 1403, 1413, 2173, 2172, 772, 726, 723, 1712, 672,
669, 666, 682, 1678, 1675, 625, 623, 621, 618, 2331, 636, 632, 1639, 1637, 1635, 920, 918, 884, 880, 889, 849,
848, 847, 846, 2497, 855, 852, 1776, 2641, 2742, 2787, 1380, 334, 1367, 1365, 301, 297, 1340, 1338, 1335, 1343,
255, 251, 247, 1296, 1291, 1288, 265, 1302, 1299, 2113, 204, 196, 192, 2042, 1232, 1230, 1224, 214, 1220, 210,
1242, 1239, 1235, 1250, 2077, 2075, 151, 148, 1993, 144, 1990, 1163, 1162, 1160, 1158, 1155, 161, 1152, 157,
1173, 1171, 1168, 1165, 168, 1181, 1178, 2021, 2020, 2018, 2023, 585, 560, 557, 1585, 516, 509, 1562, 1559, 458,
447, 2227, 472, 1516, 1513, 1510, 398, 396, 393, 390, 2181, 386, 2178, 407, 1453, 1451, 1449, 1446, 420, 1460,
2209, 769, 764, 720, 712, 2391, 729, 1713, 664, 663, 661, 659, 2352, 656, 2349, 671, 1679, 1677, 2553, 922, 919,
2519, 2516, 885, 883, 881, 2685, 2661, 2659, 2767, 2756, 2755, 140, 1137, 1136, 130, 127, 1125, 1124, 1122, 1127,
109, 106, 102, 1103, 1102, 1100, 1098, 116, 1107, 1105, 1980, 80, 76, 73, 1947, 1068, 1067, 1065, 1063, 90, 1060,
87, 1075, 1073, 1070, 1080, 1966, 1965, 46, 43, 40, 1912, 36, 1909, 1019, 1018, 1016, 1014, 58, 1011, 55, 1008,
51, 1029, 1027, 1024, 1021, 63, 1037, 1034, 1940, 1939, 1937, 1942, 8, 1866, 4, 1863, 1, 1860, 956, 954, 952,
949, 946, 17, 14, 969, 967, 964, 961, 27, 957, 24, 979, 976, 972, 1901, 1900, 1898, 1896, 986, 1905, 1903, 350,
349, 1381, 329, 327, 324, 1368, 1366, 292, 290, 287, 284, 2118, 304, 1341, 1339, 1337, 1345, 243, 240, 237, 2086,
233, 2083, 254, 1297, 1295, 1293, 1290, 1304, 2114, 190, 187, 184, 2034, 180, 2031, 177, 2027, 199, 1233, 1231,
1229, 1226, 217, 1223, 1241, 2078, 2076, 584, 555, 554, 552, 550, 2282, 562, 1586, 507, 506, 504, 502, 2257, 499,
2254, 515, 1563, 1561, 445, 443, 441, 2219, 438, 2216, 435, 2212, 460, 454, 475, 1517, 1515, 1512, 2447, 798,
797, 2422, 2419, 770, 768, 766, 2383, 2380, 2376, 721, 719, 717, 714, 731, 1714, 2602, 2582, 2580, 2548, 2546,
2543, 923, 921, 2717, 2706, 2705, 2683, 2682, 2680, 1771, 1752, 1750, 1733, 1732, 1731, 1735, 1814, 1707, 1670,
1668, 1631, 1629, 1626, 1634, 1599, 1598, 1596, 1594, 1603, 1601, 2326, 1772, 1753, 1751, 1581, 1554, 1552, 1504,
1501, 1498, 1509, 1442, 1437, 1434, 401, 1448, 1445, 2206, 1392, 1391, 1389, 1387, 1384, 359, 1399, 1397, 1394,
1404, 2171, 2170, 1708, 1672, 1669, 619, 1632, 1630, 1628, 1773, 1378, 1363, 1361, 1333, 1328, 1336, 1286, 1281,
1278, 248, 1292, 1289, 2111, 1218, 1216, 1210, 197, 1206, 193, 1228, 1225, 1221, 1236, 2073, 2071, 1151, 1150,
1148, 1146, 152, 1143, 149, 1140, 145, 1161, 1159, 1156, 1153, 158, 1169, 1166, 2017, 2016, 2014, 2019, 1582,
510, 1556, 1553, 452, 448, 1506, 1500, 394, 391, 387, 1443, 1441, 1439, 1436, 1450, 2207, 765, 716, 713, 1709,
662, 660, 657, 1673, 1671, 916, 914, 879, 878, 877, 882, 1135, 1134, 1121, 1120, 1118, 1123, 1097, 1096, 1094,
1092, 103, 1101, 1099, 1979, 1059, 1058, 1056, 1054, 77, 1051, 74, 1066, 1064, 1061, 1071, 1964, 1963, 1007,
1006, 1004, 1002, 999, 41, 996, 37, 1017, 1015, 1012, 1009, 52, 1025, 1022, 1936, 1935, 1933, 1938, 942, 940,
938, 935, 932, 5, 2, 955, 953, 950, 947, 18, 943, 15, 965, 962, 958, 1895, 1894, 1892, 1890, 973, 1899, 1897,
1379, 325, 1364, 1362, 288, 285, 1334, 1332, 1330, 241, 238, 234, 1287, 1285, 1283, 1280, 1294, 2112, 188, 185,
181, 178, 2028, 1219, 1217, 1215, 1212, 200, 1209, 1227, 2074, 2072, 583, 553, 551, 1583, 505, 503, 500, 513,
1557, 1555, 444, 442, 439, 436, 2213, 455, 451, 1507, 1505, 1502, 796, 763, 762, 760, 767, 711, 710, 708, 706,
2377, 718, 715, 1710, 2544, 917, 915, 2681, 1627, 1597, 1595, 2325, 1769, 1749, 1747, 1499, 1438, 1435, 2204,
1390, 1388, 1385, 1395, 2169, 2167, 1704, 1665, 1662, 1625, 1623, 1620, 1770, 1329, 1282, 1279, 2109, 1214, 1207,
1222, 2068, 2065, 1149, 1147, 1144, 1141, 146, 1157, 1154, 2013, 2011, 2008, 2015, 1579, 1549, 1546, 1495, 1487,
1433, 1431, 1428, 1425, 388, 1440, 2205, 1705, 658, 1667, 1664, 1119, 1095, 1093, 1978, 1057, 1055, 1052, 1062,
1962, 1960, 1005, 1003, 1000, 997, 38, 1013, 1010, 1932, 1930, 1927, 1934, 941, 939, 936, 933, 6, 930, 3, 951,
948, 944, 1889, 1887, 1884, 1881, 959, 1893, 1891, 35, 1377, 1360, 1358, 1327, 1325, 1322, 1331, 1277, 1275,
1272, 1269, 235, 1284, 2110, 1205, 1204, 1201, 1198, 182, 1195, 179, 1213, 2070, 2067, 1580, 501, 1551, 1548,
440, 437, 1497, 1494, 1490, 1503, 761, 709, 707, 1706, 913, 912, 2198, 1386, 2164, 2161, 1621, 1766, 2103, 1208,
2058, 2054, 1145, 1142, 2005, 2002, 1999, 2009, 1488, 1429, 1426, 2200, 1698, 1659, 1656, 1975, 1053, 1957, 1954,
1001, 998, 1924, 1921, 1918, 1928, 937, 934, 931, 1879, 1876, 1873, 1870, 945, 1885, 1882, 1323, 1273, 1270,
2105, 1202, 1199, 1196, 1211, 2061, 2057, 1576, 1543, 1540, 1484, 1481, 1478, 1491, 1700
]);
/*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// import java.util.List;
/**
* @author Guenther Grau
*/
/*public final*/ class PDF417DetectorResult {
constructor(bits, points) {
this.bits = bits;
this.points = points;
}
getBits() {
return this.bits;
}
getPoints() {
return this.points;
}
}
/*
* Copyright 2009 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// import java.util.ArrayList;
// import java.util.Arrays;
// import java.util.List;
// import java.util.Map;
/**
* Encapsulates logic that can detect a PDF417 Code in an image, even if the
* PDF417 Code is rotated or skewed, or partially obscured.
*
* @author SITA Lab (kevin.osullivan@sita.aero)
* @author dswitkin@google.com (Daniel Switkin)
* @author Guenther Grau
*/
/*public*/ /*final*/ class Detector$3 {
/**
* Detects a PDF417 Code in an image. Only checks 0 and 180 degree rotations.
*
* @param image barcode image to decode
* @param hints optional hints to detector
* @param multiple if true, then the image is searched for multiple codes. If false, then at most one code will
* be found and returned
* @return {@link PDF417DetectorResult} encapsulating results of detecting a PDF417 code
* @throws NotFoundException if no PDF417 Code can be found
*/
static detectMultiple(image, hints, multiple) {
// TODO detection improvement, tryHarder could try several different luminance thresholds/blackpoints or even
// different binarizers
// boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
let bitMatrix = image.getBlackMatrix();
let barcodeCoordinates = Detector$3.detect(multiple, bitMatrix);
if (!barcodeCoordinates.length) {
bitMatrix = bitMatrix.clone();
bitMatrix.rotate180();
barcodeCoordinates = Detector$3.detect(multiple, bitMatrix);
}
return new PDF417DetectorResult(bitMatrix, barcodeCoordinates);
}
/**
* Detects PDF417 codes in an image. Only checks 0 degree rotation
* @param multiple if true, then the image is searched for multiple codes. If false, then at most one code will
* be found and returned
* @param bitMatrix bit matrix to detect barcodes in
* @return List of ResultPoint arrays containing the coordinates of found barcodes
*/
static detect(multiple, bitMatrix) {
const barcodeCoordinates = new Array();
let row = 0;
let column = 0;
let foundBarcodeInRow = false;
while (row < bitMatrix.getHeight()) {
const vertices = Detector$3.findVertices(bitMatrix, row, column);
if (vertices[0] == null && vertices[3] == null) {
if (!foundBarcodeInRow) {
// we didn't find any barcode so that's the end of searching
break;
}
// we didn't find a barcode starting at the given column and row. Try again from the first column and slightly
// below the lowest barcode we found so far.
foundBarcodeInRow = false;
column = 0;
for (const barcodeCoordinate of barcodeCoordinates) {
if (barcodeCoordinate[1] != null) {
row = Math.trunc(Math.max(row, barcodeCoordinate[1].getY()));
}
if (barcodeCoordinate[3] != null) {
row = Math.max(row, Math.trunc(barcodeCoordinate[3].getY()));
}
}
row += Detector$3.ROW_STEP;
continue;
}
foundBarcodeInRow = true;
barcodeCoordinates.push(vertices);
if (!multiple) {
break;
}
// if we didn't find a right row indicator column, then continue the search for the next barcode after the
// start pattern of the barcode just found.
if (vertices[2] != null) {
column = Math.trunc(vertices[2].getX());
row = Math.trunc(vertices[2].getY());
}
else {
column = Math.trunc(vertices[4].getX());
row = Math.trunc(vertices[4].getY());
}
}
return barcodeCoordinates;
}
/**
* Locate the vertices and the codewords area of a black blob using the Start
* and Stop patterns as locators.
*
* @param matrix the scanned barcode image.
* @return an array containing the vertices:
* vertices[0] x, y top left barcode
* vertices[1] x, y bottom left barcode
* vertices[2] x, y top right barcode
* vertices[3] x, y bottom right barcode
* vertices[4] x, y top left codeword area
* vertices[5] x, y bottom left codeword area
* vertices[6] x, y top right codeword area
* vertices[7] x, y bottom right codeword area
*/
static findVertices(matrix, startRow, startColumn) {
const height = matrix.getHeight();
const width = matrix.getWidth();
// const result = new ResultPoint[8];
const result = new Array(8);
Detector$3.copyToResult(result, Detector$3.findRowsWithPattern(matrix, height, width, startRow, startColumn, Detector$3.START_PATTERN), Detector$3.INDEXES_START_PATTERN);
if (result[4] != null) {
startColumn = Math.trunc(result[4].getX());
startRow = Math.trunc(result[4].getY());
}
Detector$3.copyToResult(result, Detector$3.findRowsWithPattern(matrix, height, width, startRow, startColumn, Detector$3.STOP_PATTERN), Detector$3.INDEXES_STOP_PATTERN);
return result;
}
static copyToResult(result, tmpResult, destinationIndexes) {
for (let i = 0; i < destinationIndexes.length; i++) {
result[destinationIndexes[i]] = tmpResult[i];
}
}
static findRowsWithPattern(matrix, height, width, startRow, startColumn, pattern) {
// const result = new ResultPoint[4];
const result = new Array(4);
let found = false;
const counters = new Int32Array(pattern.length);
for (; startRow < height; startRow += Detector$3.ROW_STEP) {
let loc = Detector$3.findGuardPattern(matrix, startColumn, startRow, width, false, pattern, counters);
if (loc != null) {
while (startRow > 0) {
const previousRowLoc = Detector$3.findGuardPattern(matrix, startColumn, --startRow, width, false, pattern, counters);
if (previousRowLoc != null) {
loc = previousRowLoc;
}
else {
startRow++;
break;
}
}
result[0] = new ResultPoint(loc[0], startRow);
result[1] = new ResultPoint(loc[1], startRow);
found = true;
break;
}
}
let stopRow = startRow + 1;
// Last row of the current symbol that contains pattern
if (found) {
let skippedRowCount = 0;
let previousRowLoc = Int32Array.from([Math.trunc(result[0].getX()), Math.trunc(result[1].getX())]);
for (; stopRow < height; stopRow++) {
const loc = Detector$3.findGuardPattern(matrix, previousRowLoc[0], stopRow, width, false, pattern, counters);
// a found pattern is only considered to belong to the same barcode if the start and end positions
// don't differ too much. Pattern drift should be not bigger than two for consecutive rows. With
// a higher number of skipped rows drift could be larger. To keep it simple for now, we allow a slightly
// larger drift and don't check for skipped rows.
if (loc != null &&
Math.abs(previousRowLoc[0] - loc[0]) < Detector$3.MAX_PATTERN_DRIFT &&
Math.abs(previousRowLoc[1] - loc[1]) < Detector$3.MAX_PATTERN_DRIFT) {
previousRowLoc = loc;
skippedRowCount = 0;
}
else {
if (skippedRowCount > Detector$3.SKIPPED_ROW_COUNT_MAX) {
break;
}
else {
skippedRowCount++;
}
}
}
stopRow -= skippedRowCount + 1;
result[2] = new ResultPoint(previousRowLoc[0], stopRow);
result[3] = new ResultPoint(previousRowLoc[1], stopRow);
}
if (stopRow - startRow < Detector$3.BARCODE_MIN_HEIGHT) {
Arrays.fill(result, null);
}
return result;
}
/**
* @param matrix row of black/white values to search
* @param column x position to start search
* @param row y position to start search
* @param width the number of pixels to search on this row
* @param pattern pattern of counts of number of black and white pixels that are
* being searched for as a pattern
* @param counters array of counters, as long as pattern, to re-use
* @return start/end horizontal offset of guard pattern, as an array of two ints.
*/
static findGuardPattern(matrix, column, row, width, whiteFirst, pattern, counters) {
Arrays.fillWithin(counters, 0, counters.length, 0);
let patternStart = column;
let pixelDrift = 0;
// if there are black pixels left of the current pixel shift to the left, but only for MAX_PIXEL_DRIFT pixels
while (matrix.get(patternStart, row) && patternStart > 0 && pixelDrift++ < Detector$3.MAX_PIXEL_DRIFT) {
patternStart--;
}
let x = patternStart;
let counterPosition = 0;
let patternLength = pattern.length;
for (let isWhite = whiteFirst; x < width; x++) {
let pixel = matrix.get(x, row);
if (pixel !== isWhite) {
counters[counterPosition]++;
}
else {
if (counterPosition === patternLength - 1) {
if (Detector$3.patternMatchVariance(counters, pattern, Detector$3.MAX_INDIVIDUAL_VARIANCE) < Detector$3.MAX_AVG_VARIANCE) {
return new Int32Array([patternStart, x]);
}
patternStart += counters[0] + counters[1];
System.arraycopy(counters, 2, counters, 0, counterPosition - 1);
counters[counterPosition - 1] = 0;
counters[counterPosition] = 0;
counterPosition--;
}
else {
counterPosition++;
}
counters[counterPosition] = 1;
isWhite = !isWhite;
}
}
if (counterPosition === patternLength - 1 &&
Detector$3.patternMatchVariance(counters, pattern, Detector$3.MAX_INDIVIDUAL_VARIANCE) < Detector$3.MAX_AVG_VARIANCE) {
return new Int32Array([patternStart, x - 1]);
}
return null;
}
/**
* Determines how closely a set of observed counts of runs of black/white
* values matches a given target pattern. This is reported as the ratio of
* the total variance from the expected pattern proportions across all
* pattern elements, to the length of the pattern.
*
* @param counters observed counters
* @param pattern expected pattern
* @param maxIndividualVariance The most any counter can differ before we give up
* @return ratio of total variance between counters and pattern compared to total pattern size
*/
static patternMatchVariance(counters, pattern, maxIndividualVariance) {
let numCounters = counters.length;
let total = 0;
let patternLength = 0;
for (let i = 0; i < numCounters; i++) {
total += counters[i];
patternLength += pattern[i];
}
if (total < patternLength) {
// If we don't even have one pixel per unit of bar width, assume this
// is too small to reliably match, so fail:
return /*Float.POSITIVE_INFINITY*/ Infinity;
}
// We're going to fake floating-point math in integers. We just need to use more bits.
// Scale up patternLength so that intermediate values below like scaledCounter will have
// more "significant digits".
let unitBarWidth = total / patternLength;
maxIndividualVariance *= unitBarWidth;
let totalVariance = 0.0;
for (let x = 0; x < numCounters; x++) {
let counter = counters[x];
let scaledPattern = pattern[x] * unitBarWidth;
let variance = counter > scaledPattern ? counter - scaledPattern : scaledPattern - counter;
if (variance > maxIndividualVariance) {
return /*Float.POSITIVE_INFINITY*/ Infinity;
}
totalVariance += variance;
}
return totalVariance / total;
}
}
Detector$3.INDEXES_START_PATTERN = Int32Array.from([0, 4, 1, 5]);
Detector$3.INDEXES_STOP_PATTERN = Int32Array.from([6, 2, 7, 3]);
Detector$3.MAX_AVG_VARIANCE = 0.42;
Detector$3.MAX_INDIVIDUAL_VARIANCE = 0.8;
// B S B S B S B S Bar/Space pattern
// 11111111 0 1 0 1 0 1 000
Detector$3.START_PATTERN = Int32Array.from([8, 1, 1, 1, 1, 1, 1, 3]);
// 1111111 0 1 000 1 0 1 00 1
Detector$3.STOP_PATTERN = Int32Array.from([7, 1, 1, 3, 1, 1, 1, 2, 1]);
Detector$3.MAX_PIXEL_DRIFT = 3;
Detector$3.MAX_PATTERN_DRIFT = 5;
// if we set the value too low, then we don't detect the correct height of the bar if the start patterns are damaged.
// if we set the value too high, then we might detect the start pattern from a neighbor barcode.
Detector$3.SKIPPED_ROW_COUNT_MAX = 25;
// A PDF471 barcode should have at least 3 rows, with each row being >= 3 times the module width. Therefore it should be at least
// 9 pixels tall. To be conservative, we use about half the size to ensure we don't miss it.
Detector$3.ROW_STEP = 5;
Detector$3.BARCODE_MIN_HEIGHT = 10;
/*
* Copyright 2012 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author Sean Owen
* @see com.google.zxing.common.reedsolomon.GenericGFPoly
*/
/*final*/ class ModulusPoly {
constructor(field, coefficients) {
if (coefficients.length === 0) {
throw new IllegalArgumentException();
}
this.field = field;
let coefficientsLength = /*int*/ coefficients.length;
if (coefficientsLength > 1 && coefficients[0] === 0) {
// Leading term must be non-zero for anything except the constant polynomial "0"
let firstNonZero = /*int*/ 1;
while (firstNonZero < coefficientsLength && coefficients[firstNonZero] === 0) {
firstNonZero++;
}
if (firstNonZero === coefficientsLength) {
this.coefficients = new Int32Array([0]);
}
else {
this.coefficients = new Int32Array(coefficientsLength - firstNonZero);
System.arraycopy(coefficients, firstNonZero, this.coefficients, 0, this.coefficients.length);
}
}
else {
this.coefficients = coefficients;
}
}
getCoefficients() {
return this.coefficients;
}
/**
* @return degree of this polynomial
*/
getDegree() {
return this.coefficients.length - 1;
}
/**
* @return true iff this polynomial is the monomial "0"
*/
isZero() {
return this.coefficients[0] === 0;
}
/**
* @return coefficient of x^degree term in this polynomial
*/
getCoefficient(degree) {
return this.coefficients[this.coefficients.length - 1 - degree];
}
/**
* @return evaluation of this polynomial at a given point
*/
evaluateAt(a) {
if (a === 0) {
// Just return the x^0 coefficient
return this.getCoefficient(0);
}
if (a === 1) {
// Just the sum of the coefficients
let sum = /*int*/ 0;
for (let coefficient /*int*/ of this.coefficients) {
sum = this.field.add(sum, coefficient);
}
return sum;
}
let result = /*int*/ this.coefficients[0];
let size = /*int*/ this.coefficients.length;
for (let i /*int*/ = 1; i < size; i++) {
result = this.field.add(this.field.multiply(a, result), this.coefficients[i]);
}
return result;
}
add(other) {
if (!this.field.equals(other.field)) {
throw new IllegalArgumentException('ModulusPolys do not have same ModulusGF field');
}
if (this.isZero()) {
return other;
}
if (other.isZero()) {
return this;
}
let smallerCoefficients = this.coefficients;
let largerCoefficients = other.coefficients;
if (smallerCoefficients.length > largerCoefficients.length) {
let temp = smallerCoefficients;
smallerCoefficients = largerCoefficients;
largerCoefficients = temp;
}
let sumDiff = new Int32Array(largerCoefficients.length);
let lengthDiff = /*int*/ largerCoefficients.length - smallerCoefficients.length;
// Copy high-order terms only found in higher-degree polynomial's coefficients
System.arraycopy(largerCoefficients, 0, sumDiff, 0, lengthDiff);
for (let i /*int*/ = lengthDiff; i < largerCoefficients.length; i++) {
sumDiff[i] = this.field.add(smallerCoefficients[i - lengthDiff], largerCoefficients[i]);
}
return new ModulusPoly(this.field, sumDiff);
}
subtract(other) {
if (!this.field.equals(other.field)) {
throw new IllegalArgumentException('ModulusPolys do not have same ModulusGF field');
}
if (other.isZero()) {
return this;
}
return this.add(other.negative());
}
multiply(other) {
if (other instanceof ModulusPoly) {
return this.multiplyOther(other);
}
return this.multiplyScalar(other);
}
multiplyOther(other) {
if (!this.field.equals(other.field)) {
throw new IllegalArgumentException('ModulusPolys do not have same ModulusGF field');
}
if (this.isZero() || other.isZero()) {
// return this.field.getZero();
return new ModulusPoly(this.field, new Int32Array([0]));
}
let aCoefficients = this.coefficients;
let aLength = /*int*/ aCoefficients.length;
let bCoefficients = other.coefficients;
let bLength = /*int*/ bCoefficients.length;
let product = new Int32Array(aLength + bLength - 1);
for (let i /*int*/ = 0; i < aLength; i++) {
let aCoeff = /*int*/ aCoefficients[i];
for (let j /*int*/ = 0; j < bLength; j++) {
product[i + j] = this.field.add(product[i + j], this.field.multiply(aCoeff, bCoefficients[j]));
}
}
return new ModulusPoly(this.field, product);
}
negative() {
let size = /*int*/ this.coefficients.length;
let negativeCoefficients = new Int32Array(size);
for (let i /*int*/ = 0; i < size; i++) {
negativeCoefficients[i] = this.field.subtract(0, this.coefficients[i]);
}
return new ModulusPoly(this.field, negativeCoefficients);
}
multiplyScalar(scalar) {
if (scalar === 0) {
return new ModulusPoly(this.field, new Int32Array([0]));
}
if (scalar === 1) {
return this;
}
let size = /*int*/ this.coefficients.length;
let product = new Int32Array(size);
for (let i /*int*/ = 0; i < size; i++) {
product[i] = this.field.multiply(this.coefficients[i], scalar);
}
return new ModulusPoly(this.field, product);
}
multiplyByMonomial(degree, coefficient) {
if (degree < 0) {
throw new IllegalArgumentException();
}
if (coefficient === 0) {
return new ModulusPoly(this.field, new Int32Array([0]));
}
let size = /*int*/ this.coefficients.length;
let product = new Int32Array(size + degree);
for (let i /*int*/ = 0; i < size; i++) {
product[i] = this.field.multiply(this.coefficients[i], coefficient);
}
return new ModulusPoly(this.field, product);
}
/*
ModulusPoly[] divide(other: ModulusPoly) {
if (!field.equals(other.field)) {
throw new IllegalArgumentException("ModulusPolys do not have same ModulusGF field");
}
if (other.isZero()) {
throw new IllegalArgumentException("Divide by 0");
}
let quotient: ModulusPoly = field.getZero();
let remainder: ModulusPoly = this;
let denominatorLeadingTerm: /*int/ number = other.getCoefficient(other.getDegree());
let inverseDenominatorLeadingTerm: /*int/ number = field.inverse(denominatorLeadingTerm);
while (remainder.getDegree() >= other.getDegree() && !remainder.isZero()) {
let degreeDifference: /*int/ number = remainder.getDegree() - other.getDegree();
let scale: /*int/ number = field.multiply(remainder.getCoefficient(remainder.getDegree()), inverseDenominatorLeadingTerm);
let term: ModulusPoly = other.multiplyByMonomial(degreeDifference, scale);
let iterationQuotient: ModulusPoly = field.buildMonomial(degreeDifference, scale);
quotient = quotient.add(iterationQuotient);
remainder = remainder.subtract(term);
}
return new ModulusPoly[] { quotient, remainder };
}
*/
// @Override
toString() {
let result = new StringBuilder( /*8 * this.getDegree()*/); // dynamic string size in JS
for (let degree /*int*/ = this.getDegree(); degree >= 0; degree--) {
let coefficient = /*int*/ this.getCoefficient(degree);
if (coefficient !== 0) {
if (coefficient < 0) {
result.append(' - ');
coefficient = -coefficient;
}
else {
if (result.length() > 0) {
result.append(' + ');
}
}
if (degree === 0 || coefficient !== 1) {
result.append(coefficient);
}
if (degree !== 0) {
if (degree === 1) {
result.append('x');
}
else {
result.append('x^');
result.append(degree);
}
}
}
}
return result.toString();
}
}
class ModulusBase {
add(a, b) {
return (a + b) % this.modulus;
}
subtract(a, b) {
return (this.modulus + a - b) % this.modulus;
}
exp(a) {
return this.expTable[a];
}
log(a) {
if (a === 0) {
throw new IllegalArgumentException();
}
return this.logTable[a];
}
inverse(a) {
if (a === 0) {
throw new ArithmeticException();
}
return this.expTable[this.modulus - this.logTable[a] - 1];
}
multiply(a, b) {
if (a === 0 || b === 0) {
return 0;
}
return this.expTable[(this.logTable[a] + this.logTable[b]) % (this.modulus - 1)];
}
getSize() {
return this.modulus;
}
equals(o) {
return o === this;
}
}
/*
* Copyright 2012 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* A field based on powers of a generator integer, modulo some modulus.
*
* @author Sean Owen
* @see com.google.zxing.common.reedsolomon.GenericGF
*/
/*public final*/ class ModulusGF extends ModulusBase {
// private /*final*/ modulus: /*int*/ number;
constructor(modulus, generator) {
super();
this.modulus = modulus;
this.expTable = new Int32Array(modulus);
this.logTable = new Int32Array(modulus);
let x = /*int*/ 1;
for (let i /*int*/ = 0; i < modulus; i++) {
this.expTable[i] = x;
x = (x * generator) % modulus;
}
for (let i /*int*/ = 0; i < modulus - 1; i++) {
this.logTable[this.expTable[i]] = i;
}
// logTable[0] == 0 but this should never be used
this.zero = new ModulusPoly(this, new Int32Array([0]));
this.one = new ModulusPoly(this, new Int32Array([1]));
}
getZero() {
return this.zero;
}
getOne() {
return this.one;
}
buildMonomial(degree, coefficient) {
if (degree < 0) {
throw new IllegalArgumentException();
}
if (coefficient === 0) {
return this.zero;
}
let coefficients = new Int32Array(degree + 1);
coefficients[0] = coefficient;
return new ModulusPoly(this, coefficients);
}
}
ModulusGF.PDF417_GF = new ModulusGF(PDF417Common.NUMBER_OF_CODEWORDS, 3);
/*
* Copyright 2012 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* PDF417 error correction implementation.
*
* This example
* is quite useful in understanding the algorithm.
*
* @author Sean Owen
* @see com.google.zxing.common.reedsolomon.ReedSolomonDecoder
*/
/*public final*/ class ErrorCorrection {
constructor() {
this.field = ModulusGF.PDF417_GF;
}
/**
* @param received received codewords
* @param numECCodewords number of those codewords used for EC
* @param erasures location of erasures
* @return number of errors
* @throws ChecksumException if errors cannot be corrected, maybe because of too many errors
*/
decode(received, numECCodewords, erasures) {
let poly = new ModulusPoly(this.field, received);
let S = new Int32Array(numECCodewords);
let error = false;
for (let i /*int*/ = numECCodewords; i > 0; i--) {
let evaluation = poly.evaluateAt(this.field.exp(i));
S[numECCodewords - i] = evaluation;
if (evaluation !== 0) {
error = true;
}
}
if (!error) {
return 0;
}
let knownErrors = this.field.getOne();
if (erasures != null) {
for (const erasure of erasures) {
let b = this.field.exp(received.length - 1 - erasure);
// Add (1 - bx) term:
let term = new ModulusPoly(this.field, new Int32Array([this.field.subtract(0, b), 1]));
knownErrors = knownErrors.multiply(term);
}
}
let syndrome = new ModulusPoly(this.field, S);
// syndrome = syndrome.multiply(knownErrors);
let sigmaOmega = this.runEuclideanAlgorithm(this.field.buildMonomial(numECCodewords, 1), syndrome, numECCodewords);
let sigma = sigmaOmega[0];
let omega = sigmaOmega[1];
// sigma = sigma.multiply(knownErrors);
let errorLocations = this.findErrorLocations(sigma);
let errorMagnitudes = this.findErrorMagnitudes(omega, sigma, errorLocations);
for (let i /*int*/ = 0; i < errorLocations.length; i++) {
let position = received.length - 1 - this.field.log(errorLocations[i]);
if (position < 0) {
throw ChecksumException.getChecksumInstance();
}
received[position] = this.field.subtract(received[position], errorMagnitudes[i]);
}
return errorLocations.length;
}
/**
*
* @param ModulusPoly
* @param a
* @param ModulusPoly
* @param b
* @param int
* @param R
* @throws ChecksumException
*/
runEuclideanAlgorithm(a, b, R) {
// Assume a's degree is >= b's
if (a.getDegree() < b.getDegree()) {
let temp = a;
a = b;
b = temp;
}
let rLast = a;
let r = b;
let tLast = this.field.getZero();
let t = this.field.getOne();
// Run Euclidean algorithm until r's degree is less than R/2
while (r.getDegree() >= Math.round(R / 2)) {
let rLastLast = rLast;
let tLastLast = tLast;
rLast = r;
tLast = t;
// Divide rLastLast by rLast, with quotient in q and remainder in r
if (rLast.isZero()) {
// Oops, Euclidean algorithm already terminated?
throw ChecksumException.getChecksumInstance();
}
r = rLastLast;
let q = this.field.getZero();
let denominatorLeadingTerm = rLast.getCoefficient(rLast.getDegree());
let dltInverse = this.field.inverse(denominatorLeadingTerm);
while (r.getDegree() >= rLast.getDegree() && !r.isZero()) {
let degreeDiff = r.getDegree() - rLast.getDegree();
let scale = this.field.multiply(r.getCoefficient(r.getDegree()), dltInverse);
q = q.add(this.field.buildMonomial(degreeDiff, scale));
r = r.subtract(rLast.multiplyByMonomial(degreeDiff, scale));
}
t = q.multiply(tLast).subtract(tLastLast).negative();
}
let sigmaTildeAtZero = t.getCoefficient(0);
if (sigmaTildeAtZero === 0) {
throw ChecksumException.getChecksumInstance();
}
let inverse = this.field.inverse(sigmaTildeAtZero);
let sigma = t.multiply(inverse);
let omega = r.multiply(inverse);
return [sigma, omega];
}
/**
*
* @param errorLocator
* @throws ChecksumException
*/
findErrorLocations(errorLocator) {
// This is a direct application of Chien's search
let numErrors = errorLocator.getDegree();
let result = new Int32Array(numErrors);
let e = 0;
for (let i /*int*/ = 1; i < this.field.getSize() && e < numErrors; i++) {
if (errorLocator.evaluateAt(i) === 0) {
result[e] = this.field.inverse(i);
e++;
}
}
if (e !== numErrors) {
throw ChecksumException.getChecksumInstance();
}
return result;
}
findErrorMagnitudes(errorEvaluator, errorLocator, errorLocations) {
let errorLocatorDegree = errorLocator.getDegree();
let formalDerivativeCoefficients = new Int32Array(errorLocatorDegree);
for (let i /*int*/ = 1; i <= errorLocatorDegree; i++) {
formalDerivativeCoefficients[errorLocatorDegree - i] =
this.field.multiply(i, errorLocator.getCoefficient(i));
}
let formalDerivative = new ModulusPoly(this.field, formalDerivativeCoefficients);
// This is directly applying Forney's Formula
let s = errorLocations.length;
let result = new Int32Array(s);
for (let i /*int*/ = 0; i < s; i++) {
let xiInverse = this.field.inverse(errorLocations[i]);
let numerator = this.field.subtract(0, errorEvaluator.evaluateAt(xiInverse));
let denominator = this.field.inverse(formalDerivative.evaluateAt(xiInverse));
result[i] = this.field.multiply(numerator, denominator);
}
return result;
}
}
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author Guenther Grau
*/
/*final*/ class BoundingBox {
constructor(image, topLeft, bottomLeft, topRight, bottomRight) {
if (image instanceof BoundingBox) {
this.constructor_2(image);
}
else {
this.constructor_1(image, topLeft, bottomLeft, topRight, bottomRight);
}
}
/**
*
* @param image
* @param topLeft
* @param bottomLeft
* @param topRight
* @param bottomRight
*
* @throws NotFoundException
*/
constructor_1(image, topLeft, bottomLeft, topRight, bottomRight) {
const leftUnspecified = topLeft == null || bottomLeft == null;
const rightUnspecified = topRight == null || bottomRight == null;
if (leftUnspecified && rightUnspecified) {
throw new NotFoundException();
}
if (leftUnspecified) {
topLeft = new ResultPoint(0, topRight.getY());
bottomLeft = new ResultPoint(0, bottomRight.getY());
}
else if (rightUnspecified) {
topRight = new ResultPoint(image.getWidth() - 1, topLeft.getY());
bottomRight = new ResultPoint(image.getWidth() - 1, bottomLeft.getY());
}
this.image = image;
this.topLeft = topLeft;
this.bottomLeft = bottomLeft;
this.topRight = topRight;
this.bottomRight = bottomRight;
this.minX = Math.trunc(Math.min(topLeft.getX(), bottomLeft.getX()));
this.maxX = Math.trunc(Math.max(topRight.getX(), bottomRight.getX()));
this.minY = Math.trunc(Math.min(topLeft.getY(), topRight.getY()));
this.maxY = Math.trunc(Math.max(bottomLeft.getY(), bottomRight.getY()));
}
constructor_2(boundingBox) {
this.image = boundingBox.image;
this.topLeft = boundingBox.getTopLeft();
this.bottomLeft = boundingBox.getBottomLeft();
this.topRight = boundingBox.getTopRight();
this.bottomRight = boundingBox.getBottomRight();
this.minX = boundingBox.getMinX();
this.maxX = boundingBox.getMaxX();
this.minY = boundingBox.getMinY();
this.maxY = boundingBox.getMaxY();
}
/**
* @throws NotFoundException
*/
static merge(leftBox, rightBox) {
if (leftBox == null) {
return rightBox;
}
if (rightBox == null) {
return leftBox;
}
return new BoundingBox(leftBox.image, leftBox.topLeft, leftBox.bottomLeft, rightBox.topRight, rightBox.bottomRight);
}
/**
* @throws NotFoundException
*/
addMissingRows(missingStartRows, missingEndRows, isLeft) {
let newTopLeft = this.topLeft;
let newBottomLeft = this.bottomLeft;
let newTopRight = this.topRight;
let newBottomRight = this.bottomRight;
if (missingStartRows > 0) {
let top = isLeft ? this.topLeft : this.topRight;
let newMinY = Math.trunc(top.getY() - missingStartRows);
if (newMinY < 0) {
newMinY = 0;
}
let newTop = new ResultPoint(top.getX(), newMinY);
if (isLeft) {
newTopLeft = newTop;
}
else {
newTopRight = newTop;
}
}
if (missingEndRows > 0) {
let bottom = isLeft ? this.bottomLeft : this.bottomRight;
let newMaxY = Math.trunc(bottom.getY() + missingEndRows);
if (newMaxY >= this.image.getHeight()) {
newMaxY = this.image.getHeight() - 1;
}
let newBottom = new ResultPoint(bottom.getX(), newMaxY);
if (isLeft) {
newBottomLeft = newBottom;
}
else {
newBottomRight = newBottom;
}
}
return new BoundingBox(this.image, newTopLeft, newBottomLeft, newTopRight, newBottomRight);
}
getMinX() {
return this.minX;
}
getMaxX() {
return this.maxX;
}
getMinY() {
return this.minY;
}
getMaxY() {
return this.maxY;
}
getTopLeft() {
return this.topLeft;
}
getTopRight() {
return this.topRight;
}
getBottomLeft() {
return this.bottomLeft;
}
getBottomRight() {
return this.bottomRight;
}
}
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// package com.google.zxing.pdf417.decoder;
/**
* @author Guenther Grau
*/
/*final*/ class BarcodeMetadata {
constructor(columnCount, rowCountUpperPart, rowCountLowerPart, errorCorrectionLevel) {
this.columnCount = columnCount;
this.errorCorrectionLevel = errorCorrectionLevel;
this.rowCountUpperPart = rowCountUpperPart;
this.rowCountLowerPart = rowCountLowerPart;
this.rowCount = rowCountUpperPart + rowCountLowerPart;
}
getColumnCount() {
return this.columnCount;
}
getErrorCorrectionLevel() {
return this.errorCorrectionLevel;
}
getRowCount() {
return this.rowCount;
}
getRowCountUpperPart() {
return this.rowCountUpperPart;
}
getRowCountLowerPart() {
return this.rowCountLowerPart;
}
}
/**
* Java Formatter class polyfill that works in the JS way.
*/
class Formatter {
constructor() {
this.buffer = '';
}
/**
*
* @see https://stackoverflow.com/a/13439711/4367683
*
* @param str
* @param arr
*/
static form(str, arr) {
let i = -1;
function callback(exp, p0, p1, p2, p3, p4) {
if (exp === '%%')
return '%';
if (arr[++i] === undefined)
return undefined;
exp = p2 ? parseInt(p2.substr(1)) : undefined;
let base = p3 ? parseInt(p3.substr(1)) : undefined;
let val;
switch (p4) {
case 's':
val = arr[i];
break;
case 'c':
val = arr[i][0];
break;
case 'f':
val = parseFloat(arr[i]).toFixed(exp);
break;
case 'p':
val = parseFloat(arr[i]).toPrecision(exp);
break;
case 'e':
val = parseFloat(arr[i]).toExponential(exp);
break;
case 'x':
val = parseInt(arr[i]).toString(base ? base : 16);
break;
case 'd':
val = parseFloat(parseInt(arr[i], base ? base : 10).toPrecision(exp)).toFixed(0);
break;
}
val = typeof val === 'object' ? JSON.stringify(val) : (+val).toString(base);
let size = parseInt(p1); /* padding size */
let ch = p1 && (p1[0] + '') === '0' ? '0' : ' '; /* isnull? */
while (val.length < size)
val = p0 !== undefined ? val + ch : ch + val; /* isminus? */
return val;
}
let regex = /%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;
return str.replace(regex, callback);
}
/**
*
* @param append The new string to append.
* @param args Argumets values to be formated.
*/
format(append, ...args) {
this.buffer += Formatter.form(append, args);
}
/**
* Returns the Formatter string value.
*/
toString() {
return this.buffer;
}
}
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author Guenther Grau
*/
class DetectionResultColumn {
constructor(boundingBox) {
this.boundingBox = new BoundingBox(boundingBox);
// this.codewords = new Codeword[boundingBox.getMaxY() - boundingBox.getMinY() + 1];
this.codewords = new Array(boundingBox.getMaxY() - boundingBox.getMinY() + 1);
}
/*final*/ getCodewordNearby(imageRow) {
let codeword = this.getCodeword(imageRow);
if (codeword != null) {
return codeword;
}
for (let i = 1; i < DetectionResultColumn.MAX_NEARBY_DISTANCE; i++) {
let nearImageRow = this.imageRowToCodewordIndex(imageRow) - i;
if (nearImageRow >= 0) {
codeword = this.codewords[nearImageRow];
if (codeword != null) {
return codeword;
}
}
nearImageRow = this.imageRowToCodewordIndex(imageRow) + i;
if (nearImageRow < this.codewords.length) {
codeword = this.codewords[nearImageRow];
if (codeword != null) {
return codeword;
}
}
}
return null;
}
/*final int*/ imageRowToCodewordIndex(imageRow) {
return imageRow - this.boundingBox.getMinY();
}
/*final void*/ setCodeword(imageRow, codeword) {
this.codewords[this.imageRowToCodewordIndex(imageRow)] = codeword;
}
/*final*/ getCodeword(imageRow) {
return this.codewords[this.imageRowToCodewordIndex(imageRow)];
}
/*final*/ getBoundingBox() {
return this.boundingBox;
}
/*final*/ getCodewords() {
return this.codewords;
}
// @Override
toString() {
const formatter = new Formatter();
let row = 0;
for (const codeword of this.codewords) {
if (codeword == null) {
formatter.format('%3d: | %n', row++);
continue;
}
formatter.format('%3d: %3d|%3d%n', row++, codeword.getRowNumber(), codeword.getValue());
}
return formatter.toString();
}
}
DetectionResultColumn.MAX_NEARBY_DISTANCE = 5;
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// import java.util.ArrayList;
// import java.util.Collection;
// import java.util.HashMap;
// import java.util.Map;
// import java.util.Map.Entry;
/**
* @author Guenther Grau
*/
/*final*/ class BarcodeValue {
constructor() {
this.values = new Map();
}
/**
* Add an occurrence of a value
*/
setValue(value) {
value = Math.trunc(value);
let confidence = this.values.get(value);
if (confidence == null) {
confidence = 0;
}
confidence++;
this.values.set(value, confidence);
}
/**
* Determines the maximum occurrence of a set value and returns all values which were set with this occurrence.
* @return an array of int, containing the values with the highest occurrence, or null, if no value was set
*/
getValue() {
let maxConfidence = -1;
let result = new Array();
for (const [key, value] of this.values.entries()) {
const entry = {
getKey: () => key,
getValue: () => value,
};
if (entry.getValue() > maxConfidence) {
maxConfidence = entry.getValue();
result = [];
result.push(entry.getKey());
}
else if (entry.getValue() === maxConfidence) {
result.push(entry.getKey());
}
}
return PDF417Common.toIntArray(result);
}
getConfidence(value) {
return this.values.get(value);
}
}
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author Guenther Grau
*/
/*final*/ class DetectionResultRowIndicatorColumn extends DetectionResultColumn {
constructor(boundingBox, isLeft) {
super(boundingBox);
this._isLeft = isLeft;
}
setRowNumbers() {
for (let codeword /*Codeword*/ of this.getCodewords()) {
if (codeword != null) {
codeword.setRowNumberAsRowIndicatorColumn();
}
}
}
// TODO implement properly
// TODO maybe we should add missing codewords to store the correct row number to make
// finding row numbers for other columns easier
// use row height count to make detection of invalid row numbers more reliable
adjustCompleteIndicatorColumnRowNumbers(barcodeMetadata) {
let codewords = this.getCodewords();
this.setRowNumbers();
this.removeIncorrectCodewords(codewords, barcodeMetadata);
let boundingBox = this.getBoundingBox();
let top = this._isLeft ? boundingBox.getTopLeft() : boundingBox.getTopRight();
let bottom = this._isLeft ? boundingBox.getBottomLeft() : boundingBox.getBottomRight();
let firstRow = this.imageRowToCodewordIndex(Math.trunc(top.getY()));
let lastRow = this.imageRowToCodewordIndex(Math.trunc(bottom.getY()));
// We need to be careful using the average row height. Barcode could be skewed so that we have smaller and
// taller rows
// float averageRowHeight = (lastRow - firstRow) / /*(float)*/ barcodeMetadata.getRowCount();
let barcodeRow = -1;
let maxRowHeight = 1;
let currentRowHeight = 0;
for (let codewordsRow /*int*/ = firstRow; codewordsRow < lastRow; codewordsRow++) {
if (codewords[codewordsRow] == null) {
continue;
}
let codeword = codewords[codewordsRow];
// float expectedRowNumber = (codewordsRow - firstRow) / averageRowHeight;
// if (Math.abs(codeword.getRowNumber() - expectedRowNumber) > 2) {
// SimpleLog.log(LEVEL.WARNING,
// "Removing codeword, rowNumberSkew too high, codeword[" + codewordsRow + "]: Expected Row: " +
// expectedRowNumber + ", RealRow: " + codeword.getRowNumber() + ", value: " + codeword.getValue());
// codewords[codewordsRow] = null;
// }
let rowDifference = codeword.getRowNumber() - barcodeRow;
// TODO improve handling with case where first row indicator doesn't start with 0
if (rowDifference === 0) {
currentRowHeight++;
}
else if (rowDifference === 1) {
maxRowHeight = Math.max(maxRowHeight, currentRowHeight);
currentRowHeight = 1;
barcodeRow = codeword.getRowNumber();
}
else if (rowDifference < 0 ||
codeword.getRowNumber() >= barcodeMetadata.getRowCount() ||
rowDifference > codewordsRow) {
codewords[codewordsRow] = null;
}
else {
let checkedRows;
if (maxRowHeight > 2) {
checkedRows = (maxRowHeight - 2) * rowDifference;
}
else {
checkedRows = rowDifference;
}
let closePreviousCodewordFound = checkedRows >= codewordsRow;
for (let i /*int*/ = 1; i <= checkedRows && !closePreviousCodewordFound; i++) {
// there must be (height * rowDifference) number of codewords missing. For now we assume height = 1.
// This should hopefully get rid of most problems already.
closePreviousCodewordFound = codewords[codewordsRow - i] != null;
}
if (closePreviousCodewordFound) {
codewords[codewordsRow] = null;
}
else {
barcodeRow = codeword.getRowNumber();
currentRowHeight = 1;
}
}
}
// return (int) (averageRowHeight + 0.5);
}
getRowHeights() {
let barcodeMetadata = this.getBarcodeMetadata();
if (barcodeMetadata == null) {
return null;
}
this.adjustIncompleteIndicatorColumnRowNumbers(barcodeMetadata);
let result = new Int32Array(barcodeMetadata.getRowCount());
for (let codeword /*Codeword*/ of this.getCodewords()) {
if (codeword != null) {
let rowNumber = codeword.getRowNumber();
if (rowNumber >= result.length) {
// We have more rows than the barcode metadata allows for, ignore them.
continue;
}
result[rowNumber]++;
} // else throw exception?
}
return result;
}
// TODO maybe we should add missing codewords to store the correct row number to make
// finding row numbers for other columns easier
// use row height count to make detection of invalid row numbers more reliable
adjustIncompleteIndicatorColumnRowNumbers(barcodeMetadata) {
let boundingBox = this.getBoundingBox();
let top = this._isLeft ? boundingBox.getTopLeft() : boundingBox.getTopRight();
let bottom = this._isLeft ? boundingBox.getBottomLeft() : boundingBox.getBottomRight();
let firstRow = this.imageRowToCodewordIndex(Math.trunc(top.getY()));
let lastRow = this.imageRowToCodewordIndex(Math.trunc(bottom.getY()));
// float averageRowHeight = (lastRow - firstRow) / /*(float)*/ barcodeMetadata.getRowCount();
let codewords = this.getCodewords();
let barcodeRow = -1;
for (let codewordsRow /*int*/ = firstRow; codewordsRow < lastRow; codewordsRow++) {
if (codewords[codewordsRow] == null) {
continue;
}
let codeword = codewords[codewordsRow];
codeword.setRowNumberAsRowIndicatorColumn();
let rowDifference = codeword.getRowNumber() - barcodeRow;
// TODO improve handling with case where first row indicator doesn't start with 0
if (rowDifference === 0) ;
else if (rowDifference === 1) {
barcodeRow = codeword.getRowNumber();
}
else if (codeword.getRowNumber() >= barcodeMetadata.getRowCount()) {
codewords[codewordsRow] = null;
}
else {
barcodeRow = codeword.getRowNumber();
}
}
// return (int) (averageRowHeight + 0.5);
}
getBarcodeMetadata() {
let codewords = this.getCodewords();
let barcodeColumnCount = new BarcodeValue();
let barcodeRowCountUpperPart = new BarcodeValue();
let barcodeRowCountLowerPart = new BarcodeValue();
let barcodeECLevel = new BarcodeValue();
for (let codeword /*Codeword*/ of codewords) {
if (codeword == null) {
continue;
}
codeword.setRowNumberAsRowIndicatorColumn();
let rowIndicatorValue = codeword.getValue() % 30;
let codewordRowNumber = codeword.getRowNumber();
if (!this._isLeft) {
codewordRowNumber += 2;
}
switch (codewordRowNumber % 3) {
case 0:
barcodeRowCountUpperPart.setValue(rowIndicatorValue * 3 + 1);
break;
case 1:
barcodeECLevel.setValue(rowIndicatorValue / 3);
barcodeRowCountLowerPart.setValue(rowIndicatorValue % 3);
break;
case 2:
barcodeColumnCount.setValue(rowIndicatorValue + 1);
break;
}
}
// Maybe we should check if we have ambiguous values?
if ((barcodeColumnCount.getValue().length === 0) ||
(barcodeRowCountUpperPart.getValue().length === 0) ||
(barcodeRowCountLowerPart.getValue().length === 0) ||
(barcodeECLevel.getValue().length === 0) ||
barcodeColumnCount.getValue()[0] < 1 ||
barcodeRowCountUpperPart.getValue()[0] + barcodeRowCountLowerPart.getValue()[0] < PDF417Common.MIN_ROWS_IN_BARCODE ||
barcodeRowCountUpperPart.getValue()[0] + barcodeRowCountLowerPart.getValue()[0] > PDF417Common.MAX_ROWS_IN_BARCODE) {
return null;
}
let barcodeMetadata = new BarcodeMetadata(barcodeColumnCount.getValue()[0], barcodeRowCountUpperPart.getValue()[0], barcodeRowCountLowerPart.getValue()[0], barcodeECLevel.getValue()[0]);
this.removeIncorrectCodewords(codewords, barcodeMetadata);
return barcodeMetadata;
}
removeIncorrectCodewords(codewords, barcodeMetadata) {
// Remove codewords which do not match the metadata
// TODO Maybe we should keep the incorrect codewords for the start and end positions?
for (let codewordRow /*int*/ = 0; codewordRow < codewords.length; codewordRow++) {
let codeword = codewords[codewordRow];
if (codewords[codewordRow] == null) {
continue;
}
let rowIndicatorValue = codeword.getValue() % 30;
let codewordRowNumber = codeword.getRowNumber();
if (codewordRowNumber > barcodeMetadata.getRowCount()) {
codewords[codewordRow] = null;
continue;
}
if (!this._isLeft) {
codewordRowNumber += 2;
}
switch (codewordRowNumber % 3) {
case 0:
if (rowIndicatorValue * 3 + 1 !== barcodeMetadata.getRowCountUpperPart()) {
codewords[codewordRow] = null;
}
break;
case 1:
if (Math.trunc(rowIndicatorValue / 3) !== barcodeMetadata.getErrorCorrectionLevel() ||
rowIndicatorValue % 3 !== barcodeMetadata.getRowCountLowerPart()) {
codewords[codewordRow] = null;
}
break;
case 2:
if (rowIndicatorValue + 1 !== barcodeMetadata.getColumnCount()) {
codewords[codewordRow] = null;
}
break;
}
}
}
isLeft() {
return this._isLeft;
}
// @Override
toString() {
return 'IsLeft: ' + this._isLeft + '\n' + super.toString();
}
}
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author Guenther Grau
*/
/*final*/ class DetectionResult {
constructor(barcodeMetadata, boundingBox) {
/*final*/ this.ADJUST_ROW_NUMBER_SKIP = 2;
this.barcodeMetadata = barcodeMetadata;
this.barcodeColumnCount = barcodeMetadata.getColumnCount();
this.boundingBox = boundingBox;
// this.detectionResultColumns = new DetectionResultColumn[this.barcodeColumnCount + 2];
this.detectionResultColumns = new Array(this.barcodeColumnCount + 2);
}
getDetectionResultColumns() {
this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]);
this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount + 1]);
let unadjustedCodewordCount = PDF417Common.MAX_CODEWORDS_IN_BARCODE;
let previousUnadjustedCount;
do {
previousUnadjustedCount = unadjustedCodewordCount;
unadjustedCodewordCount = this.adjustRowNumbersAndGetCount();
} while (unadjustedCodewordCount > 0 && unadjustedCodewordCount < previousUnadjustedCount);
return this.detectionResultColumns;
}
adjustIndicatorColumnRowNumbers(detectionResultColumn) {
if (detectionResultColumn != null) {
detectionResultColumn
.adjustCompleteIndicatorColumnRowNumbers(this.barcodeMetadata);
}
}
// TODO ensure that no detected codewords with unknown row number are left
// we should be able to estimate the row height and use it as a hint for the row number
// we should also fill the rows top to bottom and bottom to top
/**
* @return number of codewords which don't have a valid row number. Note that the count is not accurate as codewords
* will be counted several times. It just serves as an indicator to see when we can stop adjusting row numbers
*/
adjustRowNumbersAndGetCount() {
let unadjustedCount = this.adjustRowNumbersByRow();
if (unadjustedCount === 0) {
return 0;
}
for (let barcodeColumn /*int*/ = 1; barcodeColumn < this.barcodeColumnCount + 1; barcodeColumn++) {
let codewords = this.detectionResultColumns[barcodeColumn].getCodewords();
for (let codewordsRow /*int*/ = 0; codewordsRow < codewords.length; codewordsRow++) {
if (codewords[codewordsRow] == null) {
continue;
}
if (!codewords[codewordsRow].hasValidRowNumber()) {
this.adjustRowNumbers(barcodeColumn, codewordsRow, codewords);
}
}
}
return unadjustedCount;
}
adjustRowNumbersByRow() {
this.adjustRowNumbersFromBothRI();
// TODO we should only do full row adjustments if row numbers of left and right row indicator column match.
// Maybe it's even better to calculated the height (rows: d) and divide it by the number of barcode
// rows. This, together with the LRI and RRI row numbers should allow us to get a good estimate where a row
// number starts and ends.
let unadjustedCount = this.adjustRowNumbersFromLRI();
return unadjustedCount + this.adjustRowNumbersFromRRI();
}
adjustRowNumbersFromBothRI() {
if (this.detectionResultColumns[0] == null || this.detectionResultColumns[this.barcodeColumnCount + 1] == null) {
return;
}
let LRIcodewords = this.detectionResultColumns[0].getCodewords();
let RRIcodewords = this.detectionResultColumns[this.barcodeColumnCount + 1].getCodewords();
for (let codewordsRow /*int*/ = 0; codewordsRow < LRIcodewords.length; codewordsRow++) {
if (LRIcodewords[codewordsRow] != null &&
RRIcodewords[codewordsRow] != null &&
LRIcodewords[codewordsRow].getRowNumber() === RRIcodewords[codewordsRow].getRowNumber()) {
for (let barcodeColumn /*int*/ = 1; barcodeColumn <= this.barcodeColumnCount; barcodeColumn++) {
let codeword = this.detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow];
if (codeword == null) {
continue;
}
codeword.setRowNumber(LRIcodewords[codewordsRow].getRowNumber());
if (!codeword.hasValidRowNumber()) {
this.detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow] = null;
}
}
}
}
}
adjustRowNumbersFromRRI() {
if (this.detectionResultColumns[this.barcodeColumnCount + 1] == null) {
return 0;
}
let unadjustedCount = 0;
let codewords = this.detectionResultColumns[this.barcodeColumnCount + 1].getCodewords();
for (let codewordsRow /*int*/ = 0; codewordsRow < codewords.length; codewordsRow++) {
if (codewords[codewordsRow] == null) {
continue;
}
let rowIndicatorRowNumber = codewords[codewordsRow].getRowNumber();
let invalidRowCounts = 0;
for (let barcodeColumn /*int*/ = this.barcodeColumnCount + 1; barcodeColumn > 0 && invalidRowCounts < this.ADJUST_ROW_NUMBER_SKIP; barcodeColumn--) {
let codeword = this.detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow];
if (codeword != null) {
invalidRowCounts = DetectionResult.adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword);
if (!codeword.hasValidRowNumber()) {
unadjustedCount++;
}
}
}
}
return unadjustedCount;
}
adjustRowNumbersFromLRI() {
if (this.detectionResultColumns[0] == null) {
return 0;
}
let unadjustedCount = 0;
let codewords = this.detectionResultColumns[0].getCodewords();
for (let codewordsRow /*int*/ = 0; codewordsRow < codewords.length; codewordsRow++) {
if (codewords[codewordsRow] == null) {
continue;
}
let rowIndicatorRowNumber = codewords[codewordsRow].getRowNumber();
let invalidRowCounts = 0;
for (let barcodeColumn /*int*/ = 1; barcodeColumn < this.barcodeColumnCount + 1 && invalidRowCounts < this.ADJUST_ROW_NUMBER_SKIP; barcodeColumn++) {
let codeword = this.detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow];
if (codeword != null) {
invalidRowCounts = DetectionResult.adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword);
if (!codeword.hasValidRowNumber()) {
unadjustedCount++;
}
}
}
}
return unadjustedCount;
}
static adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword) {
if (codeword == null) {
return invalidRowCounts;
}
if (!codeword.hasValidRowNumber()) {
if (codeword.isValidRowNumber(rowIndicatorRowNumber)) {
codeword.setRowNumber(rowIndicatorRowNumber);
invalidRowCounts = 0;
}
else {
++invalidRowCounts;
}
}
return invalidRowCounts;
}
adjustRowNumbers(barcodeColumn, codewordsRow, codewords) {
if (!this.detectionResultColumns[barcodeColumn - 1]) {
return;
}
let codeword = codewords[codewordsRow];
let previousColumnCodewords = this.detectionResultColumns[barcodeColumn - 1].getCodewords();
let nextColumnCodewords = previousColumnCodewords;
if (this.detectionResultColumns[barcodeColumn + 1] != null) {
nextColumnCodewords = this.detectionResultColumns[barcodeColumn + 1].getCodewords();
}
// let otherCodewords: Codeword[] = new Codeword[14];
let otherCodewords = new Array(14);
otherCodewords[2] = previousColumnCodewords[codewordsRow];
otherCodewords[3] = nextColumnCodewords[codewordsRow];
if (codewordsRow > 0) {
otherCodewords[0] = codewords[codewordsRow - 1];
otherCodewords[4] = previousColumnCodewords[codewordsRow - 1];
otherCodewords[5] = nextColumnCodewords[codewordsRow - 1];
}
if (codewordsRow > 1) {
otherCodewords[8] = codewords[codewordsRow - 2];
otherCodewords[10] = previousColumnCodewords[codewordsRow - 2];
otherCodewords[11] = nextColumnCodewords[codewordsRow - 2];
}
if (codewordsRow < codewords.length - 1) {
otherCodewords[1] = codewords[codewordsRow + 1];
otherCodewords[6] = previousColumnCodewords[codewordsRow + 1];
otherCodewords[7] = nextColumnCodewords[codewordsRow + 1];
}
if (codewordsRow < codewords.length - 2) {
otherCodewords[9] = codewords[codewordsRow + 2];
otherCodewords[12] = previousColumnCodewords[codewordsRow + 2];
otherCodewords[13] = nextColumnCodewords[codewordsRow + 2];
}
for (let otherCodeword of otherCodewords) {
if (DetectionResult.adjustRowNumber(codeword, otherCodeword)) {
return;
}
}
}
/**
* @return true, if row number was adjusted, false otherwise
*/
static adjustRowNumber(codeword, otherCodeword) {
if (otherCodeword == null) {
return false;
}
if (otherCodeword.hasValidRowNumber() && otherCodeword.getBucket() === codeword.getBucket()) {
codeword.setRowNumber(otherCodeword.getRowNumber());
return true;
}
return false;
}
getBarcodeColumnCount() {
return this.barcodeColumnCount;
}
getBarcodeRowCount() {
return this.barcodeMetadata.getRowCount();
}
getBarcodeECLevel() {
return this.barcodeMetadata.getErrorCorrectionLevel();
}
setBoundingBox(boundingBox) {
this.boundingBox = boundingBox;
}
getBoundingBox() {
return this.boundingBox;
}
setDetectionResultColumn(barcodeColumn, detectionResultColumn) {
this.detectionResultColumns[barcodeColumn] = detectionResultColumn;
}
getDetectionResultColumn(barcodeColumn) {
return this.detectionResultColumns[barcodeColumn];
}
// @Override
toString() {
let rowIndicatorColumn = this.detectionResultColumns[0];
if (rowIndicatorColumn == null) {
rowIndicatorColumn = this.detectionResultColumns[this.barcodeColumnCount + 1];
}
// try (
let formatter = new Formatter();
// ) {
for (let codewordsRow /*int*/ = 0; codewordsRow < rowIndicatorColumn.getCodewords().length; codewordsRow++) {
formatter.format('CW %3d:', codewordsRow);
for (let barcodeColumn /*int*/ = 0; barcodeColumn < this.barcodeColumnCount + 2; barcodeColumn++) {
if (this.detectionResultColumns[barcodeColumn] == null) {
formatter.format(' | ');
continue;
}
let codeword = this.detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow];
if (codeword == null) {
formatter.format(' | ');
continue;
}
formatter.format(' %3d|%3d', codeword.getRowNumber(), codeword.getValue());
}
formatter.format('%n');
}
return formatter.toString();
// }
}
}
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// package com.google.zxing.pdf417.decoder;
/**
* @author Guenther Grau
*/
/*final*/ class Codeword {
constructor(startX, endX, bucket, value) {
this.rowNumber = Codeword.BARCODE_ROW_UNKNOWN;
this.startX = Math.trunc(startX);
this.endX = Math.trunc(endX);
this.bucket = Math.trunc(bucket);
this.value = Math.trunc(value);
}
hasValidRowNumber() {
return this.isValidRowNumber(this.rowNumber);
}
isValidRowNumber(rowNumber) {
return rowNumber !== Codeword.BARCODE_ROW_UNKNOWN && this.bucket === (rowNumber % 3) * 3;
}
setRowNumberAsRowIndicatorColumn() {
this.rowNumber = Math.trunc((Math.trunc(this.value / 30)) * 3 + Math.trunc(this.bucket / 3));
}
getWidth() {
return this.endX - this.startX;
}
getStartX() {
return this.startX;
}
getEndX() {
return this.endX;
}
getBucket() {
return this.bucket;
}
getValue() {
return this.value;
}
getRowNumber() {
return this.rowNumber;
}
setRowNumber(rowNumber) {
this.rowNumber = rowNumber;
}
// @Override
toString() {
return this.rowNumber + '|' + this.value;
}
}
Codeword.BARCODE_ROW_UNKNOWN = -1;
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author Guenther Grau
* @author creatale GmbH (christoph.schulz@creatale.de)
*/
/*final*/ class PDF417CodewordDecoder {
/* @note
* this action have to be performed before first use of class
* - static constructor
* working with 32bit float (based from Java logic)
*/
static initialize() {
// Pre-computes the symbol ratio table.
for ( /*int*/let i = 0; i < PDF417Common.SYMBOL_TABLE.length; i++) {
let currentSymbol = PDF417Common.SYMBOL_TABLE[i];
let currentBit = currentSymbol & 0x1;
for ( /*int*/let j = 0; j < PDF417Common.BARS_IN_MODULE; j++) {
let size = 0.0;
while ((currentSymbol & 0x1) === currentBit) {
size += 1.0;
currentSymbol >>= 1;
}
currentBit = currentSymbol & 0x1;
if (!PDF417CodewordDecoder.RATIOS_TABLE[i]) {
PDF417CodewordDecoder.RATIOS_TABLE[i] = new Array(PDF417Common.BARS_IN_MODULE);
}
PDF417CodewordDecoder.RATIOS_TABLE[i][PDF417Common.BARS_IN_MODULE - j - 1] = Math.fround(size / PDF417Common.MODULES_IN_CODEWORD);
}
}
this.bSymbolTableReady = true;
}
static getDecodedValue(moduleBitCount) {
let decodedValue = PDF417CodewordDecoder.getDecodedCodewordValue(PDF417CodewordDecoder.sampleBitCounts(moduleBitCount));
if (decodedValue !== -1) {
return decodedValue;
}
return PDF417CodewordDecoder.getClosestDecodedValue(moduleBitCount);
}
static sampleBitCounts(moduleBitCount) {
let bitCountSum = MathUtils.sum(moduleBitCount);
let result = new Int32Array(PDF417Common.BARS_IN_MODULE);
let bitCountIndex = 0;
let sumPreviousBits = 0;
for ( /*int*/let i = 0; i < PDF417Common.MODULES_IN_CODEWORD; i++) {
let sampleIndex = bitCountSum / (2 * PDF417Common.MODULES_IN_CODEWORD) +
(i * bitCountSum) / PDF417Common.MODULES_IN_CODEWORD;
if (sumPreviousBits + moduleBitCount[bitCountIndex] <= sampleIndex) {
sumPreviousBits += moduleBitCount[bitCountIndex];
bitCountIndex++;
}
result[bitCountIndex]++;
}
return result;
}
static getDecodedCodewordValue(moduleBitCount) {
let decodedValue = PDF417CodewordDecoder.getBitValue(moduleBitCount);
return PDF417Common.getCodeword(decodedValue) === -1 ? -1 : decodedValue;
}
static getBitValue(moduleBitCount) {
let result = /*long*/ 0;
for (let /*int*/ i = 0; i < moduleBitCount.length; i++) {
for ( /*int*/let bit = 0; bit < moduleBitCount[i]; bit++) {
result = (result << 1) | (i % 2 === 0 ? 1 : 0);
}
}
return Math.trunc(result);
}
// working with 32bit float (as in Java)
static getClosestDecodedValue(moduleBitCount) {
let bitCountSum = MathUtils.sum(moduleBitCount);
let bitCountRatios = new Array(PDF417Common.BARS_IN_MODULE);
if (bitCountSum > 1) {
for (let /*int*/ i = 0; i < bitCountRatios.length; i++) {
bitCountRatios[i] = Math.fround(moduleBitCount[i] / bitCountSum);
}
}
let bestMatchError = Float.MAX_VALUE;
let bestMatch = -1;
if (!this.bSymbolTableReady) {
PDF417CodewordDecoder.initialize();
}
for ( /*int*/let j = 0; j < PDF417CodewordDecoder.RATIOS_TABLE.length; j++) {
let error = 0.0;
let ratioTableRow = PDF417CodewordDecoder.RATIOS_TABLE[j];
for ( /*int*/let k = 0; k < PDF417Common.BARS_IN_MODULE; k++) {
let diff = Math.fround(ratioTableRow[k] - bitCountRatios[k]);
error += Math.fround(diff * diff);
if (error >= bestMatchError) {
break;
}
}
if (error < bestMatchError) {
bestMatchError = error;
bestMatch = PDF417Common.SYMBOL_TABLE[j];
}
}
return bestMatch;
}
}
// flag that the table is ready for use
PDF417CodewordDecoder.bSymbolTableReady = false;
PDF417CodewordDecoder.RATIOS_TABLE = new Array(PDF417Common.SYMBOL_TABLE.length).map(x => x = new Array(PDF417Common.BARS_IN_MODULE));
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// package com.google.zxing.pdf417;
/**
* @author Guenther Grau
*/
/*public final*/ class PDF417ResultMetadata {
constructor() {
this.segmentCount = -1;
this.fileSize = -1;
this.timestamp = -1;
this.checksum = -1;
}
/**
* The Segment ID represents the segment of the whole file distributed over different symbols.
*
* @return File segment index
*/
getSegmentIndex() {
return this.segmentIndex;
}
setSegmentIndex(segmentIndex) {
this.segmentIndex = segmentIndex;
}
/**
* Is the same for each related PDF417 symbol
*
* @return File ID
*/
getFileId() {
return this.fileId;
}
setFileId(fileId) {
this.fileId = fileId;
}
/**
* @return always null
* @deprecated use dedicated already parsed fields
*/
// @Deprecated
getOptionalData() {
return this.optionalData;
}
/**
* @param optionalData old optional data format as int array
* @deprecated parse and use new fields
*/
// @Deprecated
setOptionalData(optionalData) {
this.optionalData = optionalData;
}
/**
* @return true if it is the last segment
*/
isLastSegment() {
return this.lastSegment;
}
setLastSegment(lastSegment) {
this.lastSegment = lastSegment;
}
/**
* @return count of segments, -1 if not set
*/
getSegmentCount() {
return this.segmentCount;
}
setSegmentCount(segmentCount /*int*/) {
this.segmentCount = segmentCount;
}
getSender() {
return this.sender || null;
}
setSender(sender) {
this.sender = sender;
}
getAddressee() {
return this.addressee || null;
}
setAddressee(addressee) {
this.addressee = addressee;
}
/**
* Filename of the encoded file
*
* @return filename
*/
getFileName() {
return this.fileName;
}
setFileName(fileName) {
this.fileName = fileName;
}
/**
* filesize in bytes of the encoded file
*
* @return filesize in bytes, -1 if not set
*/
getFileSize() {
return this.fileSize;
}
setFileSize(fileSize /*long*/) {
this.fileSize = fileSize;
}
/**
* 16-bit CRC checksum using CCITT-16
*
* @return crc checksum, -1 if not set
*/
getChecksum() {
return this.checksum;
}
setChecksum(checksum /*int*/) {
this.checksum = checksum;
}
/**
* unix epock timestamp, elapsed seconds since 1970-01-01
*
* @return elapsed seconds, -1 if not set
*/
getTimestamp() {
return this.timestamp;
}
setTimestamp(timestamp /*long*/) {
this.timestamp = timestamp;
}
}
/**
* Ponyfill for Java's Long class.
*/
class Long {
/**
* Parses a string to a number, since JS has no really Int64.
*
* @param num Numeric string.
* @param radix Destination radix.
*/
static parseLong(num, radix = undefined) {
return parseInt(num, radix);
}
}
/**
* Custom Error class of type Exception.
*/
class NullPointerException extends Exception {
}
NullPointerException.kind = 'NullPointerException';
/*
* Copyright (c) 1994, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// package java.io;
/**
* This abstract class is the superclass of all classes representing
* an output stream of bytes. An output stream accepts output bytes
* and sends them to some sink.
*
* Applications that need to define a subclass of
* OutputStream
must always provide at least a method
* that writes one byte of output.
*
* @author Arthur van Hoff
* @see java.io.BufferedOutputStream
* @see java.io.ByteArrayOutputStream
* @see java.io.DataOutputStream
* @see java.io.FilterOutputStream
* @see java.io.InputStream
* @see java.io.OutputStream#write(int)
* @since JDK1.0
*/
/*public*/ class OutputStream /*implements Closeable, Flushable*/ {
/**
* Writes b.length
bytes from the specified byte array
* to this output stream. The general contract for write(b)
* is that it should have exactly the same effect as the call
* write(b, 0, b.length)
.
*
* @param b the data.
* @exception IOException if an I/O error occurs.
* @see java.io.OutputStream#write(byte[], int, int)
*/
writeBytes(b) {
this.writeBytesOffset(b, 0, b.length);
}
/**
* Writes len
bytes from the specified byte array
* starting at offset off
to this output stream.
* The general contract for write(b, off, len)
is that
* some of the bytes in the array b
are written to the
* output stream in order; element b[off]
is the first
* byte written and b[off+len-1]
is the last byte written
* by this operation.
*
* The write
method of OutputStream
calls
* the write method of one argument on each of the bytes to be
* written out. Subclasses are encouraged to override this method and
* provide a more efficient implementation.
*
* If b
is null
, a
* NullPointerException
is thrown.
*
* If off
is negative, or len
is negative, or
* off+len
is greater than the length of the array
* b
, then an IndexOutOfBoundsException is thrown.
*
* @param b the data.
* @param off the start offset in the data.
* @param len the number of bytes to write.
* @exception IOException if an I/O error occurs. In particular,
* an IOException
is thrown if the output
* stream is closed.
*/
writeBytesOffset(b, off, len) {
if (b == null) {
throw new NullPointerException();
}
else if ((off < 0) || (off > b.length) || (len < 0) ||
((off + len) > b.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
}
else if (len === 0) {
return;
}
for (let i = 0; i < len; i++) {
this.write(b[off + i]);
}
}
/**
* Flushes this output stream and forces any buffered output bytes
* to be written out. The general contract of flush
is
* that calling it is an indication that, if any bytes previously
* written have been buffered by the implementation of the output
* stream, such bytes should immediately be written to their
* intended destination.
*
* If the intended destination of this stream is an abstraction provided by
* the underlying operating system, for example a file, then flushing the
* stream guarantees only that bytes previously written to the stream are
* passed to the operating system for writing; it does not guarantee that
* they are actually written to a physical device such as a disk drive.
*
* The flush
method of OutputStream
does nothing.
*
* @exception IOException if an I/O error occurs.
*/
flush() {
}
/**
* Closes this output stream and releases any system resources
* associated with this stream. The general contract of close
* is that it closes the output stream. A closed stream cannot perform
* output operations and cannot be reopened.
*
* The close
method of OutputStream
does nothing.
*
* @exception IOException if an I/O error occurs.
*/
close() {
}
}
/**
* Custom Error class of type Exception.
*/
class OutOfMemoryError extends Exception {
}
/*
* Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class implements an output stream in which the data is
* written into a byte array. The buffer automatically grows as data
* is written to it.
* The data can be retrieved using toByteArray()
and
* toString()
.
*
* Closing a ByteArrayOutputStream has no effect. The methods in
* this class can be called after the stream has been closed without
* generating an IOException.
*
* @author Arthur van Hoff
* @since JDK1.0
*/
/*public*/ class ByteArrayOutputStream extends OutputStream {
/**
* Creates a new byte array output stream. The buffer capacity is
* initially 32 bytes, though its size increases if necessary.
*/
// public constructor() {
// this(32);
// }
/**
* Creates a new byte array output stream, with a buffer capacity of
* the specified size, in bytes.
*
* @param size the initial size.
* @exception IllegalArgumentException if size is negative.
*/
constructor(size = 32) {
super();
/**
* The number of valid bytes in the buffer.
*/
this.count = 0;
if (size < 0) {
throw new IllegalArgumentException('Negative initial size: '
+ size);
}
this.buf = new Uint8Array(size);
}
/**
* Increases the capacity if necessary to ensure that it can hold
* at least the number of elements specified by the minimum
* capacity argument.
*
* @param minCapacity the desired minimum capacity
* @throws OutOfMemoryError if {@code minCapacity < 0}. This is
* interpreted as a request for the unsatisfiably large capacity
* {@code (long) Integer.MAX_VALUE + (minCapacity - Integer.MAX_VALUE)}.
*/
ensureCapacity(minCapacity) {
// overflow-conscious code
if (minCapacity - this.buf.length > 0)
this.grow(minCapacity);
}
/**
* Increases the capacity to ensure that it can hold at least the
* number of elements specified by the minimum capacity argument.
*
* @param minCapacity the desired minimum capacity
*/
grow(minCapacity) {
// overflow-conscious code
let oldCapacity = this.buf.length;
let newCapacity = oldCapacity << 1;
if (newCapacity - minCapacity < 0)
newCapacity = minCapacity;
if (newCapacity < 0) {
if (minCapacity < 0) // overflow
throw new OutOfMemoryError();
newCapacity = Integer.MAX_VALUE;
}
this.buf = Arrays.copyOfUint8Array(this.buf, newCapacity);
}
/**
* Writes the specified byte to this byte array output stream.
*
* @param b the byte to be written.
*/
write(b) {
this.ensureCapacity(this.count + 1);
this.buf[this.count] = /*(byte)*/ b;
this.count += 1;
}
/**
* Writes len
bytes from the specified byte array
* starting at offset off
to this byte array output stream.
*
* @param b the data.
* @param off the start offset in the data.
* @param len the number of bytes to write.
*/
writeBytesOffset(b, off, len) {
if ((off < 0) || (off > b.length) || (len < 0) ||
((off + len) - b.length > 0)) {
throw new IndexOutOfBoundsException();
}
this.ensureCapacity(this.count + len);
System.arraycopy(b, off, this.buf, this.count, len);
this.count += len;
}
/**
* Writes the complete contents of this byte array output stream to
* the specified output stream argument, as if by calling the output
* stream's write method using out.write(buf, 0, count)
.
*
* @param out the output stream to which to write the data.
* @exception IOException if an I/O error occurs.
*/
writeTo(out) {
out.writeBytesOffset(this.buf, 0, this.count);
}
/**
* Resets the count
field of this byte array output
* stream to zero, so that all currently accumulated output in the
* output stream is discarded. The output stream can be used again,
* reusing the already allocated buffer space.
*
* @see java.io.ByteArrayInputStream#count
*/
reset() {
this.count = 0;
}
/**
* Creates a newly allocated byte array. Its size is the current
* size of this output stream and the valid contents of the buffer
* have been copied into it.
*
* @return the current contents of this output stream, as a byte array.
* @see java.io.ByteArrayOutputStream#size()
*/
toByteArray() {
return Arrays.copyOfUint8Array(this.buf, this.count);
}
/**
* Returns the current size of the buffer.
*
* @return the value of the count
field, which is the number
* of valid bytes in this output stream.
* @see java.io.ByteArrayOutputStream#count
*/
size() {
return this.count;
}
toString(param) {
if (!param) {
return this.toString_void();
}
if (typeof param === 'string') {
return this.toString_string(param);
}
return this.toString_number(param);
}
/**
* Converts the buffer's contents into a string decoding bytes using the
* platform's default character set. The length of the new String
* is a function of the character set, and hence may not be equal to the
* size of the buffer.
*
*
This method always replaces malformed-input and unmappable-character
* sequences with the default replacement string for the platform's
* default character set. The {@linkplain java.nio.charset.CharsetDecoder}
* class should be used when more control over the decoding process is
* required.
*
* @return String decoded from the buffer's contents.
* @since JDK1.1
*/
toString_void() {
return new String(this.buf /*, 0, this.count*/).toString();
}
/**
* Converts the buffer's contents into a string by decoding the bytes using
* the specified {@link java.nio.charset.Charset charsetName}. The length of
* the new String is a function of the charset, and hence may not be
* equal to the length of the byte array.
*
*
This method always replaces malformed-input and unmappable-character
* sequences with this charset's default replacement string. The {@link
* java.nio.charset.CharsetDecoder} class should be used when more control
* over the decoding process is required.
*
* @param charsetName the name of a supported
* {@linkplain java.nio.charset.Charset charset}
* @return String decoded from the buffer's contents.
* @exception UnsupportedEncodingException
* If the named charset is not supported
* @since JDK1.1
*/
toString_string(charsetName) {
return new String(this.buf /*, 0, this.count, charsetName*/).toString();
}
/**
* Creates a newly allocated string. Its size is the current size of
* the output stream and the valid contents of the buffer have been
* copied into it. Each character c in the resulting string is
* constructed from the corresponding element b in the byte
* array such that:
*
* c == (char)(((hibyte & 0xff) << 8) | (b & 0xff))
*
*
* @deprecated This method does not properly convert bytes into characters.
* As of JDK 1.1, the preferred way to do this is via the
* toString(String enc)
method, which takes an encoding-name
* argument, or the toString()
method, which uses the
* platform's default character encoding.
*
* @param hibyte the high byte of each resulting Unicode character.
* @return the current contents of the output stream, as a string.
* @see java.io.ByteArrayOutputStream#size()
* @see java.io.ByteArrayOutputStream#toString(String)
* @see java.io.ByteArrayOutputStream#toString()
*/
// @Deprecated
toString_number(hibyte) {
return new String(this.buf /*, hibyte, 0, this.count*/).toString();
}
/**
* Closing a ByteArrayOutputStream has no effect. The methods in
* this class can be called after the stream has been closed without
* generating an IOException.
*
*
* @throws IOException
*/
close() {
}
}
/*
* Copyright 2009 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*private*/ var Mode$2;
(function (Mode) {
Mode[Mode["ALPHA"] = 0] = "ALPHA";
Mode[Mode["LOWER"] = 1] = "LOWER";
Mode[Mode["MIXED"] = 2] = "MIXED";
Mode[Mode["PUNCT"] = 3] = "PUNCT";
Mode[Mode["ALPHA_SHIFT"] = 4] = "ALPHA_SHIFT";
Mode[Mode["PUNCT_SHIFT"] = 5] = "PUNCT_SHIFT";
})(Mode$2 || (Mode$2 = {}));
/**
* Indirectly access the global BigInt constructor, it
* allows browsers that doesn't support BigInt to run
* the library without breaking due to "undefined BigInt"
* errors.
*/
function getBigIntConstructor() {
if (typeof window !== 'undefined') {
return window['BigInt'] || null;
}
if (typeof __webpack_require__.g !== 'undefined') {
return __webpack_require__.g['BigInt'] || null;
}
if (typeof self !== 'undefined') {
return self['BigInt'] || null;
}
throw new Error('Can\'t search globals for BigInt!');
}
/**
* Used to store the BigInt constructor.
*/
let BigInteger;
/**
* This function creates a bigint value. It allows browsers
* that doesn't support BigInt to run the rest of the library
* by not directly accessing the BigInt constructor.
*/
function createBigInt(num) {
if (typeof BigInteger === 'undefined') {
BigInteger = getBigIntConstructor();
}
if (BigInteger === null) {
throw new Error('BigInt is not supported!');
}
return BigInteger(num);
}
function getEXP900() {
// in Java - array with length = 16
let EXP900 = [];
EXP900[0] = createBigInt(1);
let nineHundred = createBigInt(900);
EXP900[1] = nineHundred;
// in Java - array with length = 16
for (let i /*int*/ = 2; i < 16; i++) {
EXP900[i] = EXP900[i - 1] * nineHundred;
}
return EXP900;
}
/**
*
This class contains the methods for decoding the PDF417 codewords.
*
* @author SITA Lab (kevin.osullivan@sita.aero)
* @author Guenther Grau
*/
/*final*/ class DecodedBitStreamParser$2 {
// private DecodedBitStreamParser() {
// }
/**
*
* @param codewords
* @param ecLevel
*
* @throws FormatException
*/
static decode(codewords, ecLevel) {
// pass encoding to result (will be used for decode symbols in byte mode)
let result = new StringBuilder('');
// let encoding: Charset = StandardCharsets.ISO_8859_1;
let encoding = CharacterSetECI.ISO8859_1;
/**
* @note the next command is specific from this TypeScript library
* because TS can't properly cast some values to char and
* convert it to string later correctly due to encoding
* differences from Java version. As reported here:
* https://github.com/zxing-js/library/pull/264/files#r382831593
*/
result.enableDecoding(encoding);
// Get compaction mode
let codeIndex = 1;
let code = codewords[codeIndex++];
let resultMetadata = new PDF417ResultMetadata();
while (codeIndex < codewords[0]) {
switch (code) {
case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:
codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex, result);
break;
case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH:
case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6:
codeIndex = DecodedBitStreamParser$2.byteCompaction(code, codewords, encoding, codeIndex, result);
break;
case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:
result.append(/*(char)*/ codewords[codeIndex++]);
break;
case DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH:
codeIndex = DecodedBitStreamParser$2.numericCompaction(codewords, codeIndex, result);
break;
case DecodedBitStreamParser$2.ECI_CHARSET:
let charsetECI = CharacterSetECI.getCharacterSetECIByValue(codewords[codeIndex++]);
// encoding = Charset.forName(charsetECI.getName());
break;
case DecodedBitStreamParser$2.ECI_GENERAL_PURPOSE:
// Can't do anything with generic ECI; skip its 2 characters
codeIndex += 2;
break;
case DecodedBitStreamParser$2.ECI_USER_DEFINED:
// Can't do anything with user ECI; skip its 1 character
codeIndex++;
break;
case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK:
codeIndex = DecodedBitStreamParser$2.decodeMacroBlock(codewords, codeIndex, resultMetadata);
break;
case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:
case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR:
// Should not see these outside a macro block
throw new FormatException();
default:
// Default to text compaction. During testing numerous barcodes
// appeared to be missing the starting mode. In these cases defaulting
// to text compaction seems to work.
codeIndex--;
codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex, result);
break;
}
if (codeIndex < codewords.length) {
code = codewords[codeIndex++];
}
else {
throw FormatException.getFormatInstance();
}
}
if (result.length() === 0) {
throw FormatException.getFormatInstance();
}
let decoderResult = new DecoderResult(null, result.toString(), null, ecLevel);
decoderResult.setOther(resultMetadata);
return decoderResult;
}
/**
*
* @param int
* @param param1
* @param codewords
* @param int
* @param codeIndex
* @param PDF417ResultMetadata
* @param resultMetadata
*
* @throws FormatException
*/
// @SuppressWarnings("deprecation")
static decodeMacroBlock(codewords, codeIndex, resultMetadata) {
if (codeIndex + DecodedBitStreamParser$2.NUMBER_OF_SEQUENCE_CODEWORDS > codewords[0]) {
// we must have at least two bytes left for the segment index
throw FormatException.getFormatInstance();
}
let segmentIndexArray = new Int32Array(DecodedBitStreamParser$2.NUMBER_OF_SEQUENCE_CODEWORDS);
for (let i /*int*/ = 0; i < DecodedBitStreamParser$2.NUMBER_OF_SEQUENCE_CODEWORDS; i++, codeIndex++) {
segmentIndexArray[i] = codewords[codeIndex];
}
resultMetadata.setSegmentIndex(Integer.parseInt(DecodedBitStreamParser$2.decodeBase900toBase10(segmentIndexArray, DecodedBitStreamParser$2.NUMBER_OF_SEQUENCE_CODEWORDS)));
let fileId = new StringBuilder();
codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex, fileId);
resultMetadata.setFileId(fileId.toString());
let optionalFieldsStart = -1;
if (codewords[codeIndex] === DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD) {
optionalFieldsStart = codeIndex + 1;
}
while (codeIndex < codewords[0]) {
switch (codewords[codeIndex]) {
case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:
codeIndex++;
switch (codewords[codeIndex]) {
case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME:
let fileName = new StringBuilder();
codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex + 1, fileName);
resultMetadata.setFileName(fileName.toString());
break;
case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_SENDER:
let sender = new StringBuilder();
codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex + 1, sender);
resultMetadata.setSender(sender.toString());
break;
case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE:
let addressee = new StringBuilder();
codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex + 1, addressee);
resultMetadata.setAddressee(addressee.toString());
break;
case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT:
let segmentCount = new StringBuilder();
codeIndex = DecodedBitStreamParser$2.numericCompaction(codewords, codeIndex + 1, segmentCount);
resultMetadata.setSegmentCount(Integer.parseInt(segmentCount.toString()));
break;
case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP:
let timestamp = new StringBuilder();
codeIndex = DecodedBitStreamParser$2.numericCompaction(codewords, codeIndex + 1, timestamp);
resultMetadata.setTimestamp(Long.parseLong(timestamp.toString()));
break;
case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM:
let checksum = new StringBuilder();
codeIndex = DecodedBitStreamParser$2.numericCompaction(codewords, codeIndex + 1, checksum);
resultMetadata.setChecksum(Integer.parseInt(checksum.toString()));
break;
case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE:
let fileSize = new StringBuilder();
codeIndex = DecodedBitStreamParser$2.numericCompaction(codewords, codeIndex + 1, fileSize);
resultMetadata.setFileSize(Long.parseLong(fileSize.toString()));
break;
default:
throw FormatException.getFormatInstance();
}
break;
case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR:
codeIndex++;
resultMetadata.setLastSegment(true);
break;
default:
throw FormatException.getFormatInstance();
}
}
// copy optional fields to additional options
if (optionalFieldsStart !== -1) {
let optionalFieldsLength = codeIndex - optionalFieldsStart;
if (resultMetadata.isLastSegment()) {
// do not include terminator
optionalFieldsLength--;
}
resultMetadata.setOptionalData(Arrays.copyOfRange(codewords, optionalFieldsStart, optionalFieldsStart + optionalFieldsLength));
}
return codeIndex;
}
/**
* Text Compaction mode (see 5.4.1.5) permits all printable ASCII characters to be
* encoded, i.e. values 32 - 126 inclusive in accordance with ISO/IEC 646 (IRV), as
* well as selected control characters.
*
* @param codewords The array of codewords (data + error)
* @param codeIndex The current index into the codeword array.
* @param result The decoded data is appended to the result.
* @return The next index into the codeword array.
*/
static textCompaction(codewords, codeIndex, result) {
// 2 character per codeword
let textCompactionData = new Int32Array((codewords[0] - codeIndex) * 2);
// Used to hold the byte compaction value if there is a mode shift
let byteCompactionData = new Int32Array((codewords[0] - codeIndex) * 2);
let index = 0;
let end = false;
while ((codeIndex < codewords[0]) && !end) {
let code = codewords[codeIndex++];
if (code < DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH) {
textCompactionData[index] = code / 30;
textCompactionData[index + 1] = code % 30;
index += 2;
}
else {
switch (code) {
case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:
// reinitialize text compaction mode to alpha sub mode
textCompactionData[index++] = DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH;
break;
case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH:
case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6:
case DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH:
case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK:
case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:
case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR:
codeIndex--;
end = true;
break;
case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:
// The Mode Shift codeword 913 shall cause a temporary
// switch from Text Compaction mode to Byte Compaction mode.
// This switch shall be in effect for only the next codeword,
// after which the mode shall revert to the prevailing sub-mode
// of the Text Compaction mode. Codeword 913 is only available
// in Text Compaction mode; its use is described in 5.4.2.4.
textCompactionData[index] = DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE;
code = codewords[codeIndex++];
byteCompactionData[index] = code;
index++;
break;
}
}
}
DecodedBitStreamParser$2.decodeTextCompaction(textCompactionData, byteCompactionData, index, result);
return codeIndex;
}
/**
* The Text Compaction mode includes all the printable ASCII characters
* (i.e. values from 32 to 126) and three ASCII control characters: HT or tab
* (9: e), LF or line feed (10: e), and CR or carriage
* return (13: e). The Text Compaction mode also includes various latch
* and shift characters which are used exclusively within the mode. The Text
* Compaction mode encodes up to 2 characters per codeword. The compaction rules
* for converting data into PDF417 codewords are defined in 5.4.2.2. The sub-mode
* switches are defined in 5.4.2.3.
*
* @param textCompactionData The text compaction data.
* @param byteCompactionData The byte compaction data if there
* was a mode shift.
* @param length The size of the text compaction and byte compaction data.
* @param result The decoded data is appended to the result.
*/
static decodeTextCompaction(textCompactionData, byteCompactionData, length, result) {
// Beginning from an initial state of the Alpha sub-mode
// The default compaction mode for PDF417 in effect at the start of each symbol shall always be Text
// Compaction mode Alpha sub-mode (alphabetic: uppercase). A latch codeword from another mode to the Text
// Compaction mode shall always switch to the Text Compaction Alpha sub-mode.
let subMode = Mode$2.ALPHA;
let priorToShiftMode = Mode$2.ALPHA;
let i = 0;
while (i < length) {
let subModeCh = textCompactionData[i];
let ch = /*char*/ '';
switch (subMode) {
case Mode$2.ALPHA:
// Alpha (alphabetic: uppercase)
if (subModeCh < 26) {
// Upper case Alpha Character
// Note: 65 = 'A' ASCII -> there is byte code of symbol
ch = /*(char)('A' + subModeCh) */ String.fromCharCode(65 + subModeCh);
}
else {
switch (subModeCh) {
case 26:
ch = ' ';
break;
case DecodedBitStreamParser$2.LL:
subMode = Mode$2.LOWER;
break;
case DecodedBitStreamParser$2.ML:
subMode = Mode$2.MIXED;
break;
case DecodedBitStreamParser$2.PS:
// Shift to punctuation
priorToShiftMode = subMode;
subMode = Mode$2.PUNCT_SHIFT;
break;
case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:
result.append(/*(char)*/ byteCompactionData[i]);
break;
case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:
subMode = Mode$2.ALPHA;
break;
}
}
break;
case Mode$2.LOWER:
// Lower (alphabetic: lowercase)
if (subModeCh < 26) {
ch = /*(char)('a' + subModeCh)*/ String.fromCharCode(97 + subModeCh);
}
else {
switch (subModeCh) {
case 26:
ch = ' ';
break;
case DecodedBitStreamParser$2.AS:
// Shift to alpha
priorToShiftMode = subMode;
subMode = Mode$2.ALPHA_SHIFT;
break;
case DecodedBitStreamParser$2.ML:
subMode = Mode$2.MIXED;
break;
case DecodedBitStreamParser$2.PS:
// Shift to punctuation
priorToShiftMode = subMode;
subMode = Mode$2.PUNCT_SHIFT;
break;
case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:
// TODO Does this need to use the current character encoding? See other occurrences below
result.append(/*(char)*/ byteCompactionData[i]);
break;
case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:
subMode = Mode$2.ALPHA;
break;
}
}
break;
case Mode$2.MIXED:
// Mixed (punctuation: e)
if (subModeCh < DecodedBitStreamParser$2.PL) {
ch = DecodedBitStreamParser$2.MIXED_CHARS[subModeCh];
}
else {
switch (subModeCh) {
case DecodedBitStreamParser$2.PL:
subMode = Mode$2.PUNCT;
break;
case 26:
ch = ' ';
break;
case DecodedBitStreamParser$2.LL:
subMode = Mode$2.LOWER;
break;
case DecodedBitStreamParser$2.AL:
subMode = Mode$2.ALPHA;
break;
case DecodedBitStreamParser$2.PS:
// Shift to punctuation
priorToShiftMode = subMode;
subMode = Mode$2.PUNCT_SHIFT;
break;
case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:
result.append(/*(char)*/ byteCompactionData[i]);
break;
case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:
subMode = Mode$2.ALPHA;
break;
}
}
break;
case Mode$2.PUNCT:
// Punctuation
if (subModeCh < DecodedBitStreamParser$2.PAL) {
ch = DecodedBitStreamParser$2.PUNCT_CHARS[subModeCh];
}
else {
switch (subModeCh) {
case DecodedBitStreamParser$2.PAL:
subMode = Mode$2.ALPHA;
break;
case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:
result.append(/*(char)*/ byteCompactionData[i]);
break;
case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:
subMode = Mode$2.ALPHA;
break;
}
}
break;
case Mode$2.ALPHA_SHIFT:
// Restore sub-mode
subMode = priorToShiftMode;
if (subModeCh < 26) {
ch = /*(char)('A' + subModeCh)*/ String.fromCharCode(65 + subModeCh);
}
else {
switch (subModeCh) {
case 26:
ch = ' ';
break;
case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:
subMode = Mode$2.ALPHA;
break;
}
}
break;
case Mode$2.PUNCT_SHIFT:
// Restore sub-mode
subMode = priorToShiftMode;
if (subModeCh < DecodedBitStreamParser$2.PAL) {
ch = DecodedBitStreamParser$2.PUNCT_CHARS[subModeCh];
}
else {
switch (subModeCh) {
case DecodedBitStreamParser$2.PAL:
subMode = Mode$2.ALPHA;
break;
case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:
// PS before Shift-to-Byte is used as a padding character,
// see 5.4.2.4 of the specification
result.append(/*(char)*/ byteCompactionData[i]);
break;
case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:
subMode = Mode$2.ALPHA;
break;
}
}
break;
}
// if (ch !== 0) {
if (ch !== '') {
// Append decoded character to result
result.append(ch);
}
i++;
}
}
/**
* Byte Compaction mode (see 5.4.3) permits all 256 possible 8-bit byte values to be encoded.
* This includes all ASCII characters value 0 to 127 inclusive and provides for international
* character set support.
*
* @param mode The byte compaction mode i.e. 901 or 924
* @param codewords The array of codewords (data + error)
* @param encoding Currently active character encoding
* @param codeIndex The current index into the codeword array.
* @param result The decoded data is appended to the result.
* @return The next index into the codeword array.
*/
static /*int*/ byteCompaction(mode, codewords, encoding, codeIndex, result) {
let decodedBytes = new ByteArrayOutputStream();
let count = 0;
let value = /*long*/ 0;
let end = false;
switch (mode) {
case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH:
// Total number of Byte Compaction characters to be encoded
// is not a multiple of 6
let byteCompactedCodewords = new Int32Array(6);
let nextCode = codewords[codeIndex++];
while ((codeIndex < codewords[0]) && !end) {
byteCompactedCodewords[count++] = nextCode;
// Base 900
value = 900 * value + nextCode;
nextCode = codewords[codeIndex++];
// perhaps it should be ok to check only nextCode >= TEXT_COMPACTION_MODE_LATCH
switch (nextCode) {
case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:
case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH:
case DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH:
case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6:
case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK:
case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:
case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR:
codeIndex--;
end = true;
break;
default:
if ((count % 5 === 0) && (count > 0)) {
// Decode every 5 codewords
// Convert to Base 256
for (let j /*int*/ = 0; j < 6; ++j) {
/* @note
* JavaScript stores numbers as 64 bits floating point numbers, but all bitwise operations are performed on 32 bits binary numbers.
* So the next bitwise operation could not be done with simple numbers
*/
decodedBytes.write(/*(byte)*/ Number(createBigInt(value) >> createBigInt(8 * (5 - j))));
}
value = 0;
count = 0;
}
break;
}
}
// if the end of all codewords is reached the last codeword needs to be added
if (codeIndex === codewords[0] && nextCode < DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH) {
byteCompactedCodewords[count++] = nextCode;
}
// If Byte Compaction mode is invoked with codeword 901,
// the last group of codewords is interpreted directly
// as one byte per codeword, without compaction.
for (let i /*int*/ = 0; i < count; i++) {
decodedBytes.write(/*(byte)*/ byteCompactedCodewords[i]);
}
break;
case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6:
// Total number of Byte Compaction characters to be encoded
// is an integer multiple of 6
while (codeIndex < codewords[0] && !end) {
let code = codewords[codeIndex++];
if (code < DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH) {
count++;
// Base 900
value = 900 * value + code;
}
else {
switch (code) {
case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:
case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH:
case DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH:
case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6:
case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK:
case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:
case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR:
codeIndex--;
end = true;
break;
}
}
if ((count % 5 === 0) && (count > 0)) {
// Decode every 5 codewords
// Convert to Base 256
/* @note
* JavaScript stores numbers as 64 bits floating point numbers, but all bitwise operations are performed on 32 bits binary numbers.
* So the next bitwise operation could not be done with simple numbers
*/
for (let j /*int*/ = 0; j < 6; ++j) {
decodedBytes.write(/*(byte)*/ Number(createBigInt(value) >> createBigInt(8 * (5 - j))));
}
value = 0;
count = 0;
}
}
break;
}
result.append(StringEncoding.decode(decodedBytes.toByteArray(), encoding));
return codeIndex;
}
/**
* Numeric Compaction mode (see 5.4.4) permits efficient encoding of numeric data strings.
*
* @param codewords The array of codewords (data + error)
* @param codeIndex The current index into the codeword array.
* @param result The decoded data is appended to the result.
* @return The next index into the codeword array.
*
* @throws FormatException
*/
static numericCompaction(codewords, codeIndex /*int*/, result) {
let count = 0;
let end = false;
let numericCodewords = new Int32Array(DecodedBitStreamParser$2.MAX_NUMERIC_CODEWORDS);
while (codeIndex < codewords[0] && !end) {
let code = codewords[codeIndex++];
if (codeIndex === codewords[0]) {
end = true;
}
if (code < DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH) {
numericCodewords[count] = code;
count++;
}
else {
switch (code) {
case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:
case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH:
case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6:
case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK:
case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:
case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR:
codeIndex--;
end = true;
break;
}
}
if ((count % DecodedBitStreamParser$2.MAX_NUMERIC_CODEWORDS === 0 || code === DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH || end) && count > 0) {
// Re-invoking Numeric Compaction mode (by using codeword 902
// while in Numeric Compaction mode) serves to terminate the
// current Numeric Compaction mode grouping as described in 5.4.4.2,
// and then to start a new one grouping.
result.append(DecodedBitStreamParser$2.decodeBase900toBase10(numericCodewords, count));
count = 0;
}
}
return codeIndex;
}
/**
* Convert a list of Numeric Compacted codewords from Base 900 to Base 10.
*
* @param codewords The array of codewords
* @param count The number of codewords
* @return The decoded string representing the Numeric data.
*
* EXAMPLE
* Encode the fifteen digit numeric string 000213298174000
* Prefix the numeric string with a 1 and set the initial value of
* t = 1 000 213 298 174 000
* Calculate codeword 0
* d0 = 1 000 213 298 174 000 mod 900 = 200
*
* t = 1 000 213 298 174 000 div 900 = 1 111 348 109 082
* Calculate codeword 1
* d1 = 1 111 348 109 082 mod 900 = 282
*
* t = 1 111 348 109 082 div 900 = 1 234 831 232
* Calculate codeword 2
* d2 = 1 234 831 232 mod 900 = 632
*
* t = 1 234 831 232 div 900 = 1 372 034
* Calculate codeword 3
* d3 = 1 372 034 mod 900 = 434
*
* t = 1 372 034 div 900 = 1 524
* Calculate codeword 4
* d4 = 1 524 mod 900 = 624
*
* t = 1 524 div 900 = 1
* Calculate codeword 5
* d5 = 1 mod 900 = 1
* t = 1 div 900 = 0
* Codeword sequence is: 1, 624, 434, 632, 282, 200
*
* Decode the above codewords involves
* 1 x 900 power of 5 + 624 x 900 power of 4 + 434 x 900 power of 3 +
* 632 x 900 power of 2 + 282 x 900 power of 1 + 200 x 900 power of 0 = 1000213298174000
*
* Remove leading 1 => Result is 000213298174000
*
* @throws FormatException
*/
static decodeBase900toBase10(codewords, count) {
let result = createBigInt(0);
for (let i /*int*/ = 0; i < count; i++) {
result += DecodedBitStreamParser$2.EXP900[count - i - 1] * createBigInt(codewords[i]);
}
let resultString = result.toString();
if (resultString.charAt(0) !== '1') {
throw new FormatException();
}
return resultString.substring(1);
}
}
DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH = 900;
DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH = 901;
DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH = 902;
DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6 = 924;
DecodedBitStreamParser$2.ECI_USER_DEFINED = 925;
DecodedBitStreamParser$2.ECI_GENERAL_PURPOSE = 926;
DecodedBitStreamParser$2.ECI_CHARSET = 927;
DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK = 928;
DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD = 923;
DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR = 922;
DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE = 913;
DecodedBitStreamParser$2.MAX_NUMERIC_CODEWORDS = 15;
DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME = 0;
DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT = 1;
DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP = 2;
DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_SENDER = 3;
DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE = 4;
DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE = 5;
DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM = 6;
DecodedBitStreamParser$2.PL = 25;
DecodedBitStreamParser$2.LL = 27;
DecodedBitStreamParser$2.AS = 27;
DecodedBitStreamParser$2.ML = 28;
DecodedBitStreamParser$2.AL = 28;
DecodedBitStreamParser$2.PS = 29;
DecodedBitStreamParser$2.PAL = 29;
DecodedBitStreamParser$2.PUNCT_CHARS = ';<>@[\\]_`~!\r\t,:\n-.$/"|*()?{}\'';
DecodedBitStreamParser$2.MIXED_CHARS = '0123456789&\r\t,:#-.$/+%*=^';
/**
* Table containing values for the exponent of 900.
* This is used in the numeric compaction decode algorithm.
*/
DecodedBitStreamParser$2.EXP900 = getBigIntConstructor() ? getEXP900() : [];
DecodedBitStreamParser$2.NUMBER_OF_SEQUENCE_CODEWORDS = 2;
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// import java.util.ArrayList;
// import java.util.Collection;
// import java.util.Formatter;
// import java.util.List;
/**
* @author Guenther Grau
*/
/*public final*/ class PDF417ScanningDecoder {
constructor() { }
/**
* @TODO don't pass in minCodewordWidth and maxCodewordWidth, pass in barcode columns for start and stop pattern
*
* columns. That way width can be deducted from the pattern column.
* This approach also allows to detect more details about the barcode, e.g. if a bar type (white or black) is wider
* than it should be. This can happen if the scanner used a bad blackpoint.
*
* @param BitMatrix
* @param image
* @param ResultPoint
* @param imageTopLeft
* @param ResultPoint
* @param imageBottomLeft
* @param ResultPoint
* @param imageTopRight
* @param ResultPoint
* @param imageBottomRight
* @param int
* @param minCodewordWidth
* @param int
* @param maxCodewordWidth
*
* @throws NotFoundException
* @throws FormatException
* @throws ChecksumException
*/
static decode(image, imageTopLeft, imageBottomLeft, imageTopRight, imageBottomRight, minCodewordWidth, maxCodewordWidth) {
let boundingBox = new BoundingBox(image, imageTopLeft, imageBottomLeft, imageTopRight, imageBottomRight);
let leftRowIndicatorColumn = null;
let rightRowIndicatorColumn = null;
let detectionResult;
for (let firstPass /*boolean*/ = true;; firstPass = false) {
if (imageTopLeft != null) {
leftRowIndicatorColumn = PDF417ScanningDecoder.getRowIndicatorColumn(image, boundingBox, imageTopLeft, true, minCodewordWidth, maxCodewordWidth);
}
if (imageTopRight != null) {
rightRowIndicatorColumn = PDF417ScanningDecoder.getRowIndicatorColumn(image, boundingBox, imageTopRight, false, minCodewordWidth, maxCodewordWidth);
}
detectionResult = PDF417ScanningDecoder.merge(leftRowIndicatorColumn, rightRowIndicatorColumn);
if (detectionResult == null) {
throw NotFoundException.getNotFoundInstance();
}
let resultBox = detectionResult.getBoundingBox();
if (firstPass && resultBox != null &&
(resultBox.getMinY() < boundingBox.getMinY() || resultBox.getMaxY() > boundingBox.getMaxY())) {
boundingBox = resultBox;
}
else {
break;
}
}
detectionResult.setBoundingBox(boundingBox);
let maxBarcodeColumn = detectionResult.getBarcodeColumnCount() + 1;
detectionResult.setDetectionResultColumn(0, leftRowIndicatorColumn);
detectionResult.setDetectionResultColumn(maxBarcodeColumn, rightRowIndicatorColumn);
let leftToRight = leftRowIndicatorColumn != null;
for (let barcodeColumnCount /*int*/ = 1; barcodeColumnCount <= maxBarcodeColumn; barcodeColumnCount++) {
let barcodeColumn = leftToRight ? barcodeColumnCount : maxBarcodeColumn - barcodeColumnCount;
if (detectionResult.getDetectionResultColumn(barcodeColumn) !== /* null */ undefined) {
// This will be the case for the opposite row indicator column, which doesn't need to be decoded again.
continue;
}
let detectionResultColumn;
if (barcodeColumn === 0 || barcodeColumn === maxBarcodeColumn) {
detectionResultColumn = new DetectionResultRowIndicatorColumn(boundingBox, barcodeColumn === 0);
}
else {
detectionResultColumn = new DetectionResultColumn(boundingBox);
}
detectionResult.setDetectionResultColumn(barcodeColumn, detectionResultColumn);
let startColumn = -1;
let previousStartColumn = startColumn;
// TODO start at a row for which we know the start position, then detect upwards and downwards from there.
for (let imageRow /*int*/ = boundingBox.getMinY(); imageRow <= boundingBox.getMaxY(); imageRow++) {
startColumn = PDF417ScanningDecoder.getStartColumn(detectionResult, barcodeColumn, imageRow, leftToRight);
if (startColumn < 0 || startColumn > boundingBox.getMaxX()) {
if (previousStartColumn === -1) {
continue;
}
startColumn = previousStartColumn;
}
let codeword = PDF417ScanningDecoder.detectCodeword(image, boundingBox.getMinX(), boundingBox.getMaxX(), leftToRight, startColumn, imageRow, minCodewordWidth, maxCodewordWidth);
if (codeword != null) {
detectionResultColumn.setCodeword(imageRow, codeword);
previousStartColumn = startColumn;
minCodewordWidth = Math.min(minCodewordWidth, codeword.getWidth());
maxCodewordWidth = Math.max(maxCodewordWidth, codeword.getWidth());
}
}
}
return PDF417ScanningDecoder.createDecoderResult(detectionResult);
}
/**
*
* @param leftRowIndicatorColumn
* @param rightRowIndicatorColumn
*
* @throws NotFoundException
*/
static merge(leftRowIndicatorColumn, rightRowIndicatorColumn) {
if (leftRowIndicatorColumn == null && rightRowIndicatorColumn == null) {
return null;
}
let barcodeMetadata = PDF417ScanningDecoder.getBarcodeMetadata(leftRowIndicatorColumn, rightRowIndicatorColumn);
if (barcodeMetadata == null) {
return null;
}
let boundingBox = BoundingBox.merge(PDF417ScanningDecoder.adjustBoundingBox(leftRowIndicatorColumn), PDF417ScanningDecoder.adjustBoundingBox(rightRowIndicatorColumn));
return new DetectionResult(barcodeMetadata, boundingBox);
}
/**
*
* @param rowIndicatorColumn
*
* @throws NotFoundException
*/
static adjustBoundingBox(rowIndicatorColumn) {
if (rowIndicatorColumn == null) {
return null;
}
let rowHeights = rowIndicatorColumn.getRowHeights();
if (rowHeights == null) {
return null;
}
let maxRowHeight = PDF417ScanningDecoder.getMax(rowHeights);
let missingStartRows = 0;
for (let rowHeight /*int*/ of rowHeights) {
missingStartRows += maxRowHeight - rowHeight;
if (rowHeight > 0) {
break;
}
}
let codewords = rowIndicatorColumn.getCodewords();
for (let row /*int*/ = 0; missingStartRows > 0 && codewords[row] == null; row++) {
missingStartRows--;
}
let missingEndRows = 0;
for (let row /*int*/ = rowHeights.length - 1; row >= 0; row--) {
missingEndRows += maxRowHeight - rowHeights[row];
if (rowHeights[row] > 0) {
break;
}
}
for (let row /*int*/ = codewords.length - 1; missingEndRows > 0 && codewords[row] == null; row--) {
missingEndRows--;
}
return rowIndicatorColumn.getBoundingBox().addMissingRows(missingStartRows, missingEndRows, rowIndicatorColumn.isLeft());
}
static getMax(values) {
let maxValue = -1;
for (let value /*int*/ of values) {
maxValue = Math.max(maxValue, value);
}
return maxValue;
}
static getBarcodeMetadata(leftRowIndicatorColumn, rightRowIndicatorColumn) {
let leftBarcodeMetadata;
if (leftRowIndicatorColumn == null ||
(leftBarcodeMetadata = leftRowIndicatorColumn.getBarcodeMetadata()) == null) {
return rightRowIndicatorColumn == null ? null : rightRowIndicatorColumn.getBarcodeMetadata();
}
let rightBarcodeMetadata;
if (rightRowIndicatorColumn == null ||
(rightBarcodeMetadata = rightRowIndicatorColumn.getBarcodeMetadata()) == null) {
return leftBarcodeMetadata;
}
if (leftBarcodeMetadata.getColumnCount() !== rightBarcodeMetadata.getColumnCount() &&
leftBarcodeMetadata.getErrorCorrectionLevel() !== rightBarcodeMetadata.getErrorCorrectionLevel() &&
leftBarcodeMetadata.getRowCount() !== rightBarcodeMetadata.getRowCount()) {
return null;
}
return leftBarcodeMetadata;
}
static getRowIndicatorColumn(image, boundingBox, startPoint, leftToRight, minCodewordWidth, maxCodewordWidth) {
let rowIndicatorColumn = new DetectionResultRowIndicatorColumn(boundingBox, leftToRight);
for (let i /*int*/ = 0; i < 2; i++) {
let increment = i === 0 ? 1 : -1;
let startColumn = Math.trunc(Math.trunc(startPoint.getX()));
for (let imageRow /*int*/ = Math.trunc(Math.trunc(startPoint.getY())); imageRow <= boundingBox.getMaxY() &&
imageRow >= boundingBox.getMinY(); imageRow += increment) {
let codeword = PDF417ScanningDecoder.detectCodeword(image, 0, image.getWidth(), leftToRight, startColumn, imageRow, minCodewordWidth, maxCodewordWidth);
if (codeword != null) {
rowIndicatorColumn.setCodeword(imageRow, codeword);
if (leftToRight) {
startColumn = codeword.getStartX();
}
else {
startColumn = codeword.getEndX();
}
}
}
}
return rowIndicatorColumn;
}
/**
*
* @param detectionResult
* @param BarcodeValue
* @param param2
* @param param3
* @param barcodeMatrix
*
* @throws NotFoundException
*/
static adjustCodewordCount(detectionResult, barcodeMatrix) {
let barcodeMatrix01 = barcodeMatrix[0][1];
let numberOfCodewords = barcodeMatrix01.getValue();
let calculatedNumberOfCodewords = detectionResult.getBarcodeColumnCount() *
detectionResult.getBarcodeRowCount() -
PDF417ScanningDecoder.getNumberOfECCodeWords(detectionResult.getBarcodeECLevel());
if (numberOfCodewords.length === 0) {
if (calculatedNumberOfCodewords < 1 || calculatedNumberOfCodewords > PDF417Common.MAX_CODEWORDS_IN_BARCODE) {
throw NotFoundException.getNotFoundInstance();
}
barcodeMatrix01.setValue(calculatedNumberOfCodewords);
}
else if (numberOfCodewords[0] !== calculatedNumberOfCodewords) {
// The calculated one is more reliable as it is derived from the row indicator columns
barcodeMatrix01.setValue(calculatedNumberOfCodewords);
}
}
/**
*
* @param detectionResult
*
* @throws FormatException
* @throws ChecksumException
* @throws NotFoundException
*/
static createDecoderResult(detectionResult) {
let barcodeMatrix = PDF417ScanningDecoder.createBarcodeMatrix(detectionResult);
PDF417ScanningDecoder.adjustCodewordCount(detectionResult, barcodeMatrix);
let erasures /*Collection*/ = new Array();
let codewords = new Int32Array(detectionResult.getBarcodeRowCount() * detectionResult.getBarcodeColumnCount());
let ambiguousIndexValuesList = /*List*/ [];
let ambiguousIndexesList = /*Collection*/ new Array();
for (let row /*int*/ = 0; row < detectionResult.getBarcodeRowCount(); row++) {
for (let column /*int*/ = 0; column < detectionResult.getBarcodeColumnCount(); column++) {
let values = barcodeMatrix[row][column + 1].getValue();
let codewordIndex = row * detectionResult.getBarcodeColumnCount() + column;
if (values.length === 0) {
erasures.push(codewordIndex);
}
else if (values.length === 1) {
codewords[codewordIndex] = values[0];
}
else {
ambiguousIndexesList.push(codewordIndex);
ambiguousIndexValuesList.push(values);
}
}
}
let ambiguousIndexValues = new Array(ambiguousIndexValuesList.length);
for (let i /*int*/ = 0; i < ambiguousIndexValues.length; i++) {
ambiguousIndexValues[i] = ambiguousIndexValuesList[i];
}
return PDF417ScanningDecoder.createDecoderResultFromAmbiguousValues(detectionResult.getBarcodeECLevel(), codewords, PDF417Common.toIntArray(erasures), PDF417Common.toIntArray(ambiguousIndexesList), ambiguousIndexValues);
}
/**
* This method deals with the fact, that the decoding process doesn't always yield a single most likely value. The
* current error correction implementation doesn't deal with erasures very well, so it's better to provide a value
* for these ambiguous codewords instead of treating it as an erasure. The problem is that we don't know which of
* the ambiguous values to choose. We try decode using the first value, and if that fails, we use another of the
* ambiguous values and try to decode again. This usually only happens on very hard to read and decode barcodes,
* so decoding the normal barcodes is not affected by this.
*
* @param erasureArray contains the indexes of erasures
* @param ambiguousIndexes array with the indexes that have more than one most likely value
* @param ambiguousIndexValues two dimensional array that contains the ambiguous values. The first dimension must
* be the same length as the ambiguousIndexes array
*
* @throws FormatException
* @throws ChecksumException
*/
static createDecoderResultFromAmbiguousValues(ecLevel, codewords, erasureArray, ambiguousIndexes, ambiguousIndexValues) {
let ambiguousIndexCount = new Int32Array(ambiguousIndexes.length);
let tries = 100;
while (tries-- > 0) {
for (let i /*int*/ = 0; i < ambiguousIndexCount.length; i++) {
codewords[ambiguousIndexes[i]] = ambiguousIndexValues[i][ambiguousIndexCount[i]];
}
try {
return PDF417ScanningDecoder.decodeCodewords(codewords, ecLevel, erasureArray);
}
catch (err) {
let ignored = err instanceof ChecksumException;
if (!ignored) {
throw err;
}
}
if (ambiguousIndexCount.length === 0) {
throw ChecksumException.getChecksumInstance();
}
for (let i /*int*/ = 0; i < ambiguousIndexCount.length; i++) {
if (ambiguousIndexCount[i] < ambiguousIndexValues[i].length - 1) {
ambiguousIndexCount[i]++;
break;
}
else {
ambiguousIndexCount[i] = 0;
if (i === ambiguousIndexCount.length - 1) {
throw ChecksumException.getChecksumInstance();
}
}
}
}
throw ChecksumException.getChecksumInstance();
}
static createBarcodeMatrix(detectionResult) {
// let barcodeMatrix: BarcodeValue[][] =
// new BarcodeValue[detectionResult.getBarcodeRowCount()][detectionResult.getBarcodeColumnCount() + 2];
let barcodeMatrix = Array.from({ length: detectionResult.getBarcodeRowCount() }, () => new Array(detectionResult.getBarcodeColumnCount() + 2));
for (let row /*int*/ = 0; row < barcodeMatrix.length; row++) {
for (let column /*int*/ = 0; column < barcodeMatrix[row].length; column++) {
barcodeMatrix[row][column] = new BarcodeValue();
}
}
let column = 0;
for (let detectionResultColumn /*DetectionResultColumn*/ of detectionResult.getDetectionResultColumns()) {
if (detectionResultColumn != null) {
for (let codeword /*Codeword*/ of detectionResultColumn.getCodewords()) {
if (codeword != null) {
let rowNumber = codeword.getRowNumber();
if (rowNumber >= 0) {
if (rowNumber >= barcodeMatrix.length) {
// We have more rows than the barcode metadata allows for, ignore them.
continue;
}
barcodeMatrix[rowNumber][column].setValue(codeword.getValue());
}
}
}
}
column++;
}
return barcodeMatrix;
}
static isValidBarcodeColumn(detectionResult, barcodeColumn) {
return barcodeColumn >= 0 && barcodeColumn <= detectionResult.getBarcodeColumnCount() + 1;
}
static getStartColumn(detectionResult, barcodeColumn, imageRow, leftToRight) {
let offset = leftToRight ? 1 : -1;
let codeword = null;
if (PDF417ScanningDecoder.isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) {
codeword = detectionResult.getDetectionResultColumn(barcodeColumn - offset).getCodeword(imageRow);
}
if (codeword != null) {
return leftToRight ? codeword.getEndX() : codeword.getStartX();
}
codeword = detectionResult.getDetectionResultColumn(barcodeColumn).getCodewordNearby(imageRow);
if (codeword != null) {
return leftToRight ? codeword.getStartX() : codeword.getEndX();
}
if (PDF417ScanningDecoder.isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) {
codeword = detectionResult.getDetectionResultColumn(barcodeColumn - offset).getCodewordNearby(imageRow);
}
if (codeword != null) {
return leftToRight ? codeword.getEndX() : codeword.getStartX();
}
let skippedColumns = 0;
while (PDF417ScanningDecoder.isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) {
barcodeColumn -= offset;
for (let previousRowCodeword /*Codeword*/ of detectionResult.getDetectionResultColumn(barcodeColumn).getCodewords()) {
if (previousRowCodeword != null) {
return (leftToRight ? previousRowCodeword.getEndX() : previousRowCodeword.getStartX()) +
offset *
skippedColumns *
(previousRowCodeword.getEndX() - previousRowCodeword.getStartX());
}
}
skippedColumns++;
}
return leftToRight ? detectionResult.getBoundingBox().getMinX() : detectionResult.getBoundingBox().getMaxX();
}
static detectCodeword(image, minColumn, maxColumn, leftToRight, startColumn, imageRow, minCodewordWidth, maxCodewordWidth) {
startColumn = PDF417ScanningDecoder.adjustCodewordStartColumn(image, minColumn, maxColumn, leftToRight, startColumn, imageRow);
// we usually know fairly exact now how long a codeword is. We should provide minimum and maximum expected length
// and try to adjust the read pixels, e.g. remove single pixel errors or try to cut off exceeding pixels.
// min and maxCodewordWidth should not be used as they are calculated for the whole barcode an can be inaccurate
// for the current position
let moduleBitCount = PDF417ScanningDecoder.getModuleBitCount(image, minColumn, maxColumn, leftToRight, startColumn, imageRow);
if (moduleBitCount == null) {
return null;
}
let endColumn;
let codewordBitCount = MathUtils.sum(moduleBitCount);
if (leftToRight) {
endColumn = startColumn + codewordBitCount;
}
else {
for (let i /*int*/ = 0; i < moduleBitCount.length / 2; i++) {
let tmpCount = moduleBitCount[i];
moduleBitCount[i] = moduleBitCount[moduleBitCount.length - 1 - i];
moduleBitCount[moduleBitCount.length - 1 - i] = tmpCount;
}
endColumn = startColumn;
startColumn = endColumn - codewordBitCount;
}
// TODO implement check for width and correction of black and white bars
// use start (and maybe stop pattern) to determine if black bars are wider than white bars. If so, adjust.
// should probably done only for codewords with a lot more than 17 bits.
// The following fixes 10-1.png, which has wide black bars and small white bars
// for (let i /*int*/ = 0; i < moduleBitCount.length; i++) {
// if (i % 2 === 0) {
// moduleBitCount[i]--;
// } else {
// moduleBitCount[i]++;
// }
// }
// We could also use the width of surrounding codewords for more accurate results, but this seems
// sufficient for now
if (!PDF417ScanningDecoder.checkCodewordSkew(codewordBitCount, minCodewordWidth, maxCodewordWidth)) {
// We could try to use the startX and endX position of the codeword in the same column in the previous row,
// create the bit count from it and normalize it to 8. This would help with single pixel errors.
return null;
}
let decodedValue = PDF417CodewordDecoder.getDecodedValue(moduleBitCount);
let codeword = PDF417Common.getCodeword(decodedValue);
if (codeword === -1) {
return null;
}
return new Codeword(startColumn, endColumn, PDF417ScanningDecoder.getCodewordBucketNumber(decodedValue), codeword);
}
static getModuleBitCount(image, minColumn, maxColumn, leftToRight, startColumn, imageRow) {
let imageColumn = startColumn;
let moduleBitCount = new Int32Array(8);
let moduleNumber = 0;
let increment = leftToRight ? 1 : -1;
let previousPixelValue = leftToRight;
while ((leftToRight ? imageColumn < maxColumn : imageColumn >= minColumn) &&
moduleNumber < moduleBitCount.length) {
if (image.get(imageColumn, imageRow) === previousPixelValue) {
moduleBitCount[moduleNumber]++;
imageColumn += increment;
}
else {
moduleNumber++;
previousPixelValue = !previousPixelValue;
}
}
if (moduleNumber === moduleBitCount.length ||
((imageColumn === (leftToRight ? maxColumn : minColumn)) &&
moduleNumber === moduleBitCount.length - 1)) {
return moduleBitCount;
}
return null;
}
static getNumberOfECCodeWords(barcodeECLevel) {
return 2 << barcodeECLevel;
}
static adjustCodewordStartColumn(image, minColumn, maxColumn, leftToRight, codewordStartColumn, imageRow) {
let correctedStartColumn = codewordStartColumn;
let increment = leftToRight ? -1 : 1;
// there should be no black pixels before the start column. If there are, then we need to start earlier.
for (let i /*int*/ = 0; i < 2; i++) {
while ((leftToRight ? correctedStartColumn >= minColumn : correctedStartColumn < maxColumn) &&
leftToRight === image.get(correctedStartColumn, imageRow)) {
if (Math.abs(codewordStartColumn - correctedStartColumn) > PDF417ScanningDecoder.CODEWORD_SKEW_SIZE) {
return codewordStartColumn;
}
correctedStartColumn += increment;
}
increment = -increment;
leftToRight = !leftToRight;
}
return correctedStartColumn;
}
static checkCodewordSkew(codewordSize, minCodewordWidth, maxCodewordWidth) {
return minCodewordWidth - PDF417ScanningDecoder.CODEWORD_SKEW_SIZE <= codewordSize &&
codewordSize <= maxCodewordWidth + PDF417ScanningDecoder.CODEWORD_SKEW_SIZE;
}
/**
* @throws FormatException,
* @throws ChecksumException
*/
static decodeCodewords(codewords, ecLevel, erasures) {
if (codewords.length === 0) {
throw FormatException.getFormatInstance();
}
let numECCodewords = 1 << (ecLevel + 1);
let correctedErrorsCount = PDF417ScanningDecoder.correctErrors(codewords, erasures, numECCodewords);
PDF417ScanningDecoder.verifyCodewordCount(codewords, numECCodewords);
// Decode the codewords
let decoderResult = DecodedBitStreamParser$2.decode(codewords, '' + ecLevel);
decoderResult.setErrorsCorrected(correctedErrorsCount);
decoderResult.setErasures(erasures.length);
return decoderResult;
}
/**
* Given data and error-correction codewords received, possibly corrupted by errors, attempts to
* correct the errors in-place.
*
* @param codewords data and error correction codewords
* @param erasures positions of any known erasures
* @param numECCodewords number of error correction codewords that are available in codewords
* @throws ChecksumException if error correction fails
*/
static correctErrors(codewords, erasures, numECCodewords) {
if (erasures != null &&
erasures.length > numECCodewords / 2 + PDF417ScanningDecoder.MAX_ERRORS ||
numECCodewords < 0 ||
numECCodewords > PDF417ScanningDecoder.MAX_EC_CODEWORDS) {
// Too many errors or EC Codewords is corrupted
throw ChecksumException.getChecksumInstance();
}
return PDF417ScanningDecoder.errorCorrection.decode(codewords, numECCodewords, erasures);
}
/**
* Verify that all is OK with the codeword array.
* @throws FormatException
*/
static verifyCodewordCount(codewords, numECCodewords) {
if (codewords.length < 4) {
// Codeword array size should be at least 4 allowing for
// Count CW, At least one Data CW, Error Correction CW, Error Correction CW
throw FormatException.getFormatInstance();
}
// The first codeword, the Symbol Length Descriptor, shall always encode the total number of data
// codewords in the symbol, including the Symbol Length Descriptor itself, data codewords and pad
// codewords, but excluding the number of error correction codewords.
let numberOfCodewords = codewords[0];
if (numberOfCodewords > codewords.length) {
throw FormatException.getFormatInstance();
}
if (numberOfCodewords === 0) {
// Reset to the length of the array - 8 (Allow for at least level 3 Error Correction (8 Error Codewords)
if (numECCodewords < codewords.length) {
codewords[0] = codewords.length - numECCodewords;
}
else {
throw FormatException.getFormatInstance();
}
}
}
static getBitCountForCodeword(codeword) {
let result = new Int32Array(8);
let previousValue = 0;
let i = result.length - 1;
while (true) {
if ((codeword & 0x1) !== previousValue) {
previousValue = codeword & 0x1;
i--;
if (i < 0) {
break;
}
}
result[i]++;
codeword >>= 1;
}
return result;
}
static getCodewordBucketNumber(codeword) {
if (codeword instanceof Int32Array) {
return this.getCodewordBucketNumber_Int32Array(codeword);
}
return this.getCodewordBucketNumber_number(codeword);
}
static getCodewordBucketNumber_number(codeword) {
return PDF417ScanningDecoder.getCodewordBucketNumber(PDF417ScanningDecoder.getBitCountForCodeword(codeword));
}
static getCodewordBucketNumber_Int32Array(moduleBitCount) {
return (moduleBitCount[0] - moduleBitCount[2] + moduleBitCount[4] - moduleBitCount[6] + 9) % 9;
}
static toString(barcodeMatrix) {
let formatter = new Formatter();
// try (let formatter = new Formatter()) {
for (let row /*int*/ = 0; row < barcodeMatrix.length; row++) {
formatter.format('Row %2d: ', row);
for (let column /*int*/ = 0; column < barcodeMatrix[row].length; column++) {
let barcodeValue = barcodeMatrix[row][column];
if (barcodeValue.getValue().length === 0) {
formatter.format(' ', null);
}
else {
formatter.format('%4d(%2d)', barcodeValue.getValue()[0], barcodeValue.getConfidence(barcodeValue.getValue()[0]));
}
}
formatter.format('%n');
}
return formatter.toString();
// }
}
}
/*final*/ PDF417ScanningDecoder.CODEWORD_SKEW_SIZE = 2;
/*final*/ PDF417ScanningDecoder.MAX_ERRORS = 3;
/*final*/ PDF417ScanningDecoder.MAX_EC_CODEWORDS = 512;
/*final*/ PDF417ScanningDecoder.errorCorrection = new ErrorCorrection();
/*
* Copyright 2009 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// import java.util.ArrayList;
// import java.util.List;
// import java.util.Map;
/**
* This implementation can detect and decode PDF417 codes in an image.
*
* @author Guenther Grau
*/
/*public final*/ class PDF417Reader {
// private static /*final Result[]*/ EMPTY_RESULT_ARRAY: Result[] = new Result([0]);
/**
* Locates and decodes a PDF417 code in an image.
*
* @return a String representing the content encoded by the PDF417 code
* @throws NotFoundException if a PDF417 code cannot be found,
* @throws FormatException if a PDF417 cannot be decoded
* @throws ChecksumException
*/
// @Override
decode(image, hints = null) {
let result = PDF417Reader.decode(image, hints, false);
if (result == null || result.length === 0 || result[0] == null) {
throw NotFoundException.getNotFoundInstance();
}
return result[0];
}
/**
*
* @param BinaryBitmap
* @param image
* @throws NotFoundException
*/
// @Override
decodeMultiple(image, hints = null) {
try {
return PDF417Reader.decode(image, hints, true);
}
catch (ignored) {
if (ignored instanceof FormatException || ignored instanceof ChecksumException) {
throw NotFoundException.getNotFoundInstance();
}
throw ignored;
}
}
/**
*
* @param image
* @param hints
* @param multiple
*
* @throws NotFoundException
* @throws FormatExceptionß
* @throws ChecksumException
*/
static decode(image, hints, multiple) {
const results = new Array();
const detectorResult = Detector$3.detectMultiple(image, hints, multiple);
for (const points of detectorResult.getPoints()) {
const decoderResult = PDF417ScanningDecoder.decode(detectorResult.getBits(), points[4], points[5], points[6], points[7], PDF417Reader.getMinCodewordWidth(points), PDF417Reader.getMaxCodewordWidth(points));
const result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), undefined, points, BarcodeFormat$1.PDF_417);
result.putMetadata(ResultMetadataType$1.ERROR_CORRECTION_LEVEL, decoderResult.getECLevel());
const pdf417ResultMetadata = decoderResult.getOther();
if (pdf417ResultMetadata != null) {
result.putMetadata(ResultMetadataType$1.PDF417_EXTRA_METADATA, pdf417ResultMetadata);
}
results.push(result);
}
return results.map(x => x);
}
static getMaxWidth(p1, p2) {
if (p1 == null || p2 == null) {
return 0;
}
return Math.trunc(Math.abs(p1.getX() - p2.getX()));
}
static getMinWidth(p1, p2) {
if (p1 == null || p2 == null) {
return Integer.MAX_VALUE;
}
return Math.trunc(Math.abs(p1.getX() - p2.getX()));
}
static getMaxCodewordWidth(p) {
return Math.floor(Math.max(Math.max(PDF417Reader.getMaxWidth(p[0], p[4]), PDF417Reader.getMaxWidth(p[6], p[2]) * PDF417Common.MODULES_IN_CODEWORD /
PDF417Common.MODULES_IN_STOP_PATTERN), Math.max(PDF417Reader.getMaxWidth(p[1], p[5]), PDF417Reader.getMaxWidth(p[7], p[3]) * PDF417Common.MODULES_IN_CODEWORD /
PDF417Common.MODULES_IN_STOP_PATTERN)));
}
static getMinCodewordWidth(p) {
return Math.floor(Math.min(Math.min(PDF417Reader.getMinWidth(p[0], p[4]), PDF417Reader.getMinWidth(p[6], p[2]) * PDF417Common.MODULES_IN_CODEWORD /
PDF417Common.MODULES_IN_STOP_PATTERN), Math.min(PDF417Reader.getMinWidth(p[1], p[5]), PDF417Reader.getMinWidth(p[7], p[3]) * PDF417Common.MODULES_IN_CODEWORD /
PDF417Common.MODULES_IN_STOP_PATTERN)));
}
// @Override
reset() {
// nothing needs to be reset
}
}
/**
* Custom Error class of type Exception.
*/
class ReaderException extends Exception {
}
ReaderException.kind = 'ReaderException';
/*
* Copyright 2009 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*namespace com.google.zxing {*/
/**
* MultiFormatReader is a convenience class and the main entry point into the library for most uses.
* By default it attempts to decode all barcode formats that the library supports. Optionally, you
* can provide a hints object to request different behavior, for example only decoding QR codes.
*
* @author Sean Owen
* @author dswitkin@google.com (Daniel Switkin)
*/
class MultiFormatReader {
/**
* Creates an instance of this class
*
* @param {Boolean} verbose if 'true' logs will be dumped to console, otherwise hidden.
* @param hints The hints to use, clearing the previous state.
*/
constructor(verbose, hints) {
this.verbose = (verbose === true);
if (hints) {
this.setHints(hints);
}
}
/**
* This version of decode honors the intent of Reader.decode(BinaryBitmap) in that it
* passes null as a hint to the decoders. However, that makes it inefficient to call repeatedly.
* Use setHints() followed by decodeWithState() for continuous scan applications.
*
* @param image The pixel data to decode
* @return The contents of the image
*
* @throws NotFoundException Any errors which occurred
*/
/*@Override*/
// public decode(image: BinaryBitmap): Result {
// setHints(null)
// return decodeInternal(image)
// }
/**
* Decode an image using the hints provided. Does not honor existing state.
*
* @param image The pixel data to decode
* @param hints The hints to use, clearing the previous state.
* @return The contents of the image
*
* @throws NotFoundException Any errors which occurred
*/
/*@Override*/
decode(image, hints) {
if (hints) {
this.setHints(hints);
}
return this.decodeInternal(image);
}
/**
* Decode an image using the state set up by calling setHints() previously. Continuous scan
* clients will get a large speed increase by using this instead of decode().
*
* @param image The pixel data to decode
* @return The contents of the image
*
* @throws NotFoundException Any errors which occurred
*/
decodeWithState(image) {
// Make sure to set up the default state so we don't crash
if (this.readers === null || this.readers === undefined) {
this.setHints(null);
}
return this.decodeInternal(image);
}
/**
* This method adds state to the MultiFormatReader. By setting the hints once, subsequent calls
* to decodeWithState(image) can reuse the same set of readers without reallocating memory. This
* is important for performance in continuous scan clients.
*
* @param hints The set of hints to use for subsequent calls to decode(image)
*/
setHints(hints) {
this.hints = hints;
const tryHarder = !isNullOrUndefined(hints)
&& hints.get(DecodeHintType$1.TRY_HARDER) === true;
const formats = isNullOrUndefined(hints) ? null : hints.get(DecodeHintType$1.POSSIBLE_FORMATS);
const readers = new Array();
if (!isNullOrUndefined(formats)) {
const addOneDReader = formats.some(f => {
return (
f === BarcodeFormat$1.UPC_A ||
f === BarcodeFormat$1.UPC_E ||
f === BarcodeFormat$1.EAN_13 ||
f === BarcodeFormat$1.EAN_8 ||
f === BarcodeFormat$1.CODABAR ||
f === BarcodeFormat$1.CODE_39 ||
f === BarcodeFormat$1.CODE_93 ||
f === BarcodeFormat$1.CODE_128 ||
f === BarcodeFormat$1.ITF ||
f === BarcodeFormat$1.RSS_14 ||
f === BarcodeFormat$1.RSS_EXPANDED);
});
// Put 1D readers upfront in "normal" mode
if (addOneDReader && !tryHarder) {
readers.push(new MultiFormatOneDReader(hints, this.verbose));
}
if (formats.includes(BarcodeFormat$1.QR_CODE)) {
readers.push(new QRCodeReader());
}
if (formats.includes(BarcodeFormat$1.DATA_MATRIX)) {
readers.push(new DataMatrixReader());
}
if (formats.includes(BarcodeFormat$1.AZTEC)) {
readers.push(new AztecReader());
}
if (formats.includes(BarcodeFormat$1.PDF_417)) {
readers.push(new PDF417Reader());
}
// if (formats.includes(BarcodeFormat.MAXICODE)) {
// readers.push(new MaxiCodeReader())
// }
// At end in "try harder" mode
if (addOneDReader && tryHarder) {
readers.push(new MultiFormatOneDReader(hints, this.verbose));
}
}
if (readers.length === 0) {
if (!tryHarder) {
readers.push(new MultiFormatOneDReader(hints, this.verbose));
}
readers.push(new QRCodeReader());
readers.push(new DataMatrixReader());
readers.push(new AztecReader());
readers.push(new PDF417Reader());
// readers.push(new MaxiCodeReader())
if (tryHarder) {
readers.push(new MultiFormatOneDReader(hints, this.verbose));
}
}
this.readers = readers; // .toArray(new Reader[readers.size()])
}
/*@Override*/
reset() {
if (this.readers !== null) {
for (const reader of this.readers) {
reader.reset();
}
}
}
/**
* @throws NotFoundException
*/
decodeInternal(image) {
if (this.readers === null) {
throw new ReaderException('No readers where selected, nothing can be read.');
}
for (const reader of this.readers) {
// Trying to decode with ${reader} reader.
try {
return reader.decode(image, this.hints);
}
catch (ex) {
if (ex instanceof ReaderException) {
continue;
}
// Bad Exception.
}
}
throw new NotFoundException('No MultiFormat Readers were able to detect the code.');
}
}
class BrowserMultiFormatReader extends BrowserCodeReader {
constructor(hints = null, timeBetweenScansMillis = 500) {
const reader = new MultiFormatReader();
reader.setHints(hints);
super(reader, timeBetweenScansMillis);
}
/**
* Overwrite decodeBitmap to call decodeWithState, which will pay
* attention to the hints set in the constructor function
*/
decodeBitmap(binaryBitmap) {
return this.reader.decodeWithState(binaryBitmap);
}
}
/**
* @deprecated Moving to @zxing/browser
*
* QR Code reader to use from browser.
*/
class BrowserPDF417Reader extends BrowserCodeReader {
/**
* Creates an instance of BrowserPDF417Reader.
* @param {number} [timeBetweenScansMillis=500] the time delay between subsequent decode tries
*/
constructor(timeBetweenScansMillis = 500) {
super(new PDF417Reader(), timeBetweenScansMillis);
}
}
/**
* @deprecated Moving to @zxing/browser
*
* QR Code reader to use from browser.
*/
class BrowserQRCodeReader extends BrowserCodeReader {
/**
* Creates an instance of BrowserQRCodeReader.
* @param {number} [timeBetweenScansMillis=500] the time delay between subsequent decode tries
*/
constructor(timeBetweenScansMillis = 500) {
super(new QRCodeReader(), timeBetweenScansMillis);
}
}
/*
* Copyright 2009 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*namespace com.google.zxing {*/
/**
* These are a set of hints that you may pass to Writers to specify their behavior.
*
* @author dswitkin@google.com (Daniel Switkin)
*/
var EncodeHintType;
(function (EncodeHintType) {
/**
* Specifies what degree of error correction to use, for example in QR Codes.
* Type depends on the encoder. For example for QR codes it's type
* {@link com.google.zxing.qrcode.decoder.ErrorCorrectionLevel ErrorCorrectionLevel}.
* For Aztec it is of type {@link Integer}, representing the minimal percentage of error correction words.
* For PDF417 it is of type {@link Integer}, valid values being 0 to 8.
* In all cases, it can also be a {@link String} representation of the desired value as well.
* Note: an Aztec symbol should have a minimum of 25% EC words.
*/
EncodeHintType[EncodeHintType["ERROR_CORRECTION"] = 0] = "ERROR_CORRECTION";
/**
* Specifies what character encoding to use where applicable (type {@link String})
*/
EncodeHintType[EncodeHintType["CHARACTER_SET"] = 1] = "CHARACTER_SET";
/**
* Specifies the matrix shape for Data Matrix (type {@link com.google.zxing.datamatrix.encoder.SymbolShapeHint})
*/
EncodeHintType[EncodeHintType["DATA_MATRIX_SHAPE"] = 2] = "DATA_MATRIX_SHAPE";
/**
* Specifies a minimum barcode size (type {@link Dimension}). Only applicable to Data Matrix now.
*
* @deprecated use width/height params in
* {@link com.google.zxing.datamatrix.DataMatrixWriter#encode(String, BarcodeFormat, int, int)}
*/
/*@Deprecated*/
EncodeHintType[EncodeHintType["MIN_SIZE"] = 3] = "MIN_SIZE";
/**
* Specifies a maximum barcode size (type {@link Dimension}). Only applicable to Data Matrix now.
*
* @deprecated without replacement
*/
/*@Deprecated*/
EncodeHintType[EncodeHintType["MAX_SIZE"] = 4] = "MAX_SIZE";
/**
* Specifies margin, in pixels, to use when generating the barcode. The meaning can vary
* by format; for example it controls margin before and after the barcode horizontally for
* most 1D formats. (Type {@link Integer}, or {@link String} representation of the integer value).
*/
EncodeHintType[EncodeHintType["MARGIN"] = 5] = "MARGIN";
/**
* Specifies whether to use compact mode for PDF417 (type {@link Boolean}, or "true" or "false"
* {@link String} value).
*/
EncodeHintType[EncodeHintType["PDF417_COMPACT"] = 6] = "PDF417_COMPACT";
/**
* Specifies what compaction mode to use for PDF417 (type
* {@link com.google.zxing.pdf417.encoder.Compaction Compaction} or {@link String} value of one of its
* enum values).
*/
EncodeHintType[EncodeHintType["PDF417_COMPACTION"] = 7] = "PDF417_COMPACTION";
/**
* Specifies the minimum and maximum number of rows and columns for PDF417 (type
* {@link com.google.zxing.pdf417.encoder.Dimensions Dimensions}).
*/
EncodeHintType[EncodeHintType["PDF417_DIMENSIONS"] = 8] = "PDF417_DIMENSIONS";
/**
* Specifies the required number of layers for an Aztec code.
* A negative number (-1, -2, -3, -4) specifies a compact Aztec code.
* 0 indicates to use the minimum number of layers (the default).
* A positive number (1, 2, .. 32) specifies a normal (non-compact) Aztec code.
* (Type {@link Integer}, or {@link String} representation of the integer value).
*/
EncodeHintType[EncodeHintType["AZTEC_LAYERS"] = 9] = "AZTEC_LAYERS";
/**
* Specifies the exact version of QR code to be encoded.
* (Type {@link Integer}, or {@link String} representation of the integer value).
*/
EncodeHintType[EncodeHintType["QR_VERSION"] = 10] = "QR_VERSION";
})(EncodeHintType || (EncodeHintType = {}));
var EncodeHintType$1 = EncodeHintType;
/**
* Implements Reed-Solomon encoding, as the name implies.
*
* @author Sean Owen
* @author William Rucklidge
*/
class ReedSolomonEncoder {
/**
* A reed solomon error-correcting encoding constructor is created by
* passing as Galois Field with of size equal to the number of code
* words (symbols) in the alphabet (the number of values in each
* element of arrays that are encoded/decoded).
* @param field A galois field with a number of elements equal to the size
* of the alphabet of symbols to encode.
*/
constructor(field) {
this.field = field;
this.cachedGenerators = [];
this.cachedGenerators.push(new GenericGFPoly(field, Int32Array.from([1])));
}
buildGenerator(degree /*int*/) {
const 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(field, Int32Array.from([1, field.exp(d - 1 + field.getGeneratorBase())])));
cachedGenerators.push(nextGenerator);
lastGenerator = nextGenerator;
}
}
return cachedGenerators[degree];
}
/**
* Encode a sequence of code words (symbols) using Reed-Solomon to allow decoders
* to detect and correct errors that may have been introduced when the resulting
* data is stored or transmitted.
*
* @param toEncode array used for both and output. Caller initializes the array with
* the code words (symbols) to be encoded followed by empty elements allocated to make
* space for error-correction code words in the encoded output. The array contains
* the encdoded output when encode returns. Code words are encoded as numbers from
* 0 to n-1, where n is the number of possible code words (symbols), as determined
* by the size of the Galois Field passed in the constructor of this object.
* @param ecBytes the number of elements reserved in the array (first parameter)
* to store error-correction code words. Thus, the number of code words (symbols)
* to encode in the first parameter is thus toEncode.length - ecBytes.
* Note, the use of "bytes" in the name of this parameter is misleading, as there may
* be more or fewer than 256 symbols being encoded, as determined by the number of
* elements in the Galois Field passed as a constructor to this object.
* @throws IllegalArgumentException thrown in response to validation errros.
*/
encode(toEncode, ecBytes /*int*/) {
if (ecBytes === 0) {
throw new IllegalArgumentException('No error correction bytes');
}
const dataBytes = toEncode.length - ecBytes;
if (dataBytes <= 0) {
throw new IllegalArgumentException('No data bytes provided');
}
const generator = this.buildGenerator(ecBytes);
const infoCoefficients = new Int32Array(dataBytes);
System.arraycopy(toEncode, 0, infoCoefficients, 0, dataBytes);
let info = new GenericGFPoly(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++) {
toEncode[dataBytes + i] = 0;
}
System.arraycopy(coefficients, 0, toEncode, dataBytes + numZeroCoefficients, coefficients.length);
}
}
/**
* @author Satoru Takabayashi
* @author Daniel Switkin
* @author Sean Owen
*/
class MaskUtil {
constructor() {
// do nothing
}
/**
* Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and
* give penalty to them. Example: 00000 or 11111.
*/
static applyMaskPenaltyRule1(matrix) {
return MaskUtil.applyMaskPenaltyRule1Internal(matrix, true) + MaskUtil.applyMaskPenaltyRule1Internal(matrix, false);
}
/**
* Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give
* penalty to them. This is actually equivalent to the spec's rule, which is to find MxN blocks and give a
* penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block.
*/
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];
if (value === arrayY[x + 1] && value === array[y + 1][x] && value === array[y + 1][x + 1]) {
penalty++;
}
}
}
return MaskUtil.N2 * penalty;
}
/**
* Apply mask penalty rule 3 and return the penalty. Find consecutive runs of 1:1:3:1:1:4
* starting with black, or 4:1:1:3:1:1 starting with white, and give penalty to them. If we
* find patterns like 000010111010000, we give penalty once.
*/
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
if (x + 6 < width &&
arrayY[x] === 1 &&
arrayY[x + 1] === 0 &&
arrayY[x + 2] === 1 &&
arrayY[x + 3] === 1 &&
arrayY[x + 4] === 1 &&
arrayY[x + 5] === 0 &&
arrayY[x + 6] === 1 &&
(MaskUtil.isWhiteHorizontal(arrayY, x - 4, x) || MaskUtil.isWhiteHorizontal(arrayY, x + 7, x + 11))) {
numPenalties++;
}
if (y + 6 < height &&
array[y][x] === 1 &&
array[y + 1][x] === 0 &&
array[y + 2][x] === 1 &&
array[y + 3][x] === 1 &&
array[y + 4][x] === 1 &&
array[y + 5][x] === 0 &&
array[y + 6][x] === 1 &&
(MaskUtil.isWhiteVertical(array, x, y - 4, y) || MaskUtil.isWhiteVertical(array, x, y + 7, y + 11))) {
numPenalties++;
}
}
}
return numPenalties * MaskUtil.N3;
}
static isWhiteHorizontal(rowArray, from /*int*/, to /*int*/) {
from = Math.max(from, 0);
to = Math.min(to, rowArray.length);
for (let i = from; i < to; i++) {
if (rowArray[i] === 1) {
return false;
}
}
return true;
}
static isWhiteVertical(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++) {
if (array[i][col] === 1) {
return false;
}
}
return true;
}
/**
* Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give
* penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance.
*/
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++) {
if (arrayY[x] === 1) {
numDarkCells++;
}
}
}
const numTotalCells = matrix.getHeight() * matrix.getWidth();
const fivePercentVariances = Math.floor(Math.abs(numDarkCells * 2 - numTotalCells) * 10 / numTotalCells);
return fivePercentVariances * MaskUtil.N4;
}
/**
* Return the mask bit for "getMaskPattern" at "x" and "y". See 8.8 of JISX0510:2004 for mask
* pattern conditions.
*/
static getDataMaskBit(maskPattern /*int*/, x /*int*/, y /*int*/) {
let intermediate; /*int*/
let temp; /*int*/
switch (maskPattern) {
case 0:
intermediate = (y + x) & 0x1;
break;
case 1:
intermediate = y & 0x1;
break;
case 2:
intermediate = x % 3;
break;
case 3:
intermediate = (y + x) % 3;
break;
case 4:
intermediate = (Math.floor(y / 2) + Math.floor(x / 3)) & 0x1;
break;
case 5:
temp = y * x;
intermediate = (temp & 0x1) + (temp % 3);
break;
case 6:
temp = y * x;
intermediate = ((temp & 0x1) + (temp % 3)) & 0x1;
break;
case 7:
temp = y * x;
intermediate = ((temp % 3) + ((y + x) & 0x1)) & 0x1;
break;
default:
throw new IllegalArgumentException('Invalid mask pattern: ' + maskPattern);
}
return intermediate === 0;
}
/**
* Helper function for applyMaskPenaltyRule1. We need this for doing this calculation in both
* vertical and horizontal orders respectively.
*/
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];
if (bit === prevBit) {
numSameBitCells++;
}
else {
if (numSameBitCells >= 5) {
penalty += MaskUtil.N1 + (numSameBitCells - 5);
}
numSameBitCells = 1; // Include the cell itself.
prevBit = bit;
}
}
if (numSameBitCells >= 5) {
penalty += MaskUtil.N1 + (numSameBitCells - 5);
}
}
return penalty;
}
}
// Penalty weights from section 6.8.2.1
MaskUtil.N1 = 3;
MaskUtil.N2 = 3;
MaskUtil.N3 = 40;
MaskUtil.N4 = 10;
/**
* JAVAPORT: The original code was a 2D array of ints, but since it only ever gets assigned
* -1, 0, and 1, I'm going to use less memory and go with bytes.
*
* @author dswitkin@google.com (Daniel Switkin)
*/
class ByteMatrix {
constructor(width /*int*/, height /*int*/) {
this.width = width;
this.height = height;
const bytes = new Array(height); // [height][width]
for (let i = 0; i !== height; i++) {
bytes[i] = new Uint8Array(width);
}
this.bytes = bytes;
}
getHeight() {
return this.height;
}
getWidth() {
return this.width;
}
get(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() {
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*/) {
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) {
this.bytes[y][x] = /*(byte) */ (value ? 1 : 0);
}
clear(value /*byte*/) {
for (const aByte of this.bytes) {
Arrays.fill(aByte, value);
}
}
equals(o) {
if (!(o instanceof ByteMatrix)) {
return false;
}
const other = o;
if (this.width !== other.width) {
return false;
}
if (this.height !== other.height) {
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) {
if (bytesY[x] !== otherBytesY[x]) {
return false;
}
}
}
return true;
}
/*@Override*/
toString() {
const result = new StringBuilder(); // (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) {
switch (bytesY[x]) {
case 0:
result.append(' 0');
break;
case 1:
result.append(' 1');
break;
default:
result.append(' ');
break;
}
}
result.append('\n');
}
return result.toString();
}
}
/**
* @author satorux@google.com (Satoru Takabayashi) - creator
* @author dswitkin@google.com (Daniel Switkin) - ported from C++
*/
class QRCode {
constructor() {
this.maskPattern = -1;
}
getMode() {
return this.mode;
}
getECLevel() {
return this.ecLevel;
}
getVersion() {
return this.version;
}
getMaskPattern() {
return this.maskPattern;
}
getMatrix() {
return this.matrix;
}
/*@Override*/
toString() {
const result = new StringBuilder(); // (200)
result.append('<<\n');
result.append(' mode: ');
result.append(this.mode ? this.mode.toString() : 'null');
result.append('\n ecLevel: ');
result.append(this.ecLevel ? this.ecLevel.toString() : 'null');
result.append('\n version: ');
result.append(this.version ? this.version.toString() : 'null');
result.append('\n maskPattern: ');
result.append(this.maskPattern.toString());
if (this.matrix) {
result.append('\n matrix:\n');
result.append(this.matrix.toString());
}
else {
result.append('\n matrix: null\n');
}
result.append('>>\n');
return result.toString();
}
setMode(value) {
this.mode = value;
}
setECLevel(value) {
this.ecLevel = value;
}
setVersion(version) {
this.version = version;
}
setMaskPattern(value /*int*/) {
this.maskPattern = value;
}
setMatrix(value) {
this.matrix = value;
}
// Check if "mask_pattern" is valid.
static isValidMaskPattern(maskPattern /*int*/) {
return maskPattern >= 0 && maskPattern < QRCode.NUM_MASK_PATTERNS;
}
}
QRCode.NUM_MASK_PATTERNS = 8;
/**
* Custom Error class of type Exception.
*/
class WriterException extends Exception {
}
WriterException.kind = 'WriterException';
/**
* @author satorux@google.com (Satoru Takabayashi) - creator
* @author dswitkin@google.com (Daniel Switkin) - ported from C++
*/
class MatrixUtil {
constructor() {
// do nothing
}
// Set all cells to -1 (TYPESCRIPTPORT: 255). -1 (TYPESCRIPTPORT: 255) means that the cell is empty (not set yet).
//
// JAVAPORT: We shouldn't need to do this at all. The code should be rewritten to begin encoding
// with the ByteMatrix initialized all to zero.
static clearMatrix(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.clearMatrix(matrix);
MatrixUtil.embedBasicPatterns(version, matrix);
// Type information appear with any version.
MatrixUtil.embedTypeInfo(ecLevel, maskPattern, matrix);
// Version info appear if version >= 7.
MatrixUtil.maybeEmbedVersionInfo(version, matrix);
// Data should be embedded at end.
MatrixUtil.embedDataBits(dataBits, maskPattern, matrix);
}
// Embed basic patterns. On success, modify the matrix and return true.
// The basic patterns are:
// - Position detection patterns
// - Timing patterns
// - Dark dot at the left bottom corner
// - Position adjustment patterns, if need be
static embedBasicPatterns(version, matrix) {
// Let's get started with embedding big squares at corners.
MatrixUtil.embedPositionDetectionPatternsAndSeparators(matrix);
// Then, embed the dark dot at the left bottom corner.
MatrixUtil.embedDarkDotAtLeftBottomCorner(matrix);
// Position adjustment patterns appear if version >= 2.
MatrixUtil.maybeEmbedPositionAdjustmentPatterns(version, matrix);
// Timing patterns should be embedded after position adj. patterns.
MatrixUtil.embedTimingPatterns(matrix);
}
// Embed type information. On success, modify the matrix.
static embedTypeInfo(ecLevel, maskPattern /*int*/, matrix) {
const typeInfoBits = new BitArray();
MatrixUtil.makeTypeInfoBits(ecLevel, maskPattern, typeInfoBits);
for (let 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);
// 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];
matrix.setBoolean(x1, y1, bit);
if (i < 8) {
// Right top corner.
const x2 = matrix.getWidth() - i - 1;
const y2 = 8;
matrix.setBoolean(x2, y2, bit);
}
else {
// Left bottom corner.
const x2 = 8;
const 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) {
if (version.getVersionNumber() < 7) { // Version info is necessary if version >= 7.
return; // Don't need version info.
}
const versionInfoBits = new BitArray();
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) {
// Place bits in LSB (least significant bit) to MSB order.
const bit = versionInfoBits.get(bitIndex);
bitIndex--;
// Left bottom corner.
matrix.setBoolean(i, matrix.getHeight() - 11 + j, bit);
// Right bottom corner.
matrix.setBoolean(matrix.getHeight() - 11 + j, i, bit);
}
}
}
// 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;
// Start from the right bottom cell.
let x = matrix.getWidth() - 1;
let y = matrix.getHeight() - 1;
while (x > 0) {
// Skip the vertical timing pattern.
if (x === 6) {
x -= 1;
}
while (y >= 0 && y < matrix.getHeight()) {
for (let i = 0; i < 2; ++i) {
const xx = x - i;
// Skip the cell if it's not empty.
if (!MatrixUtil.isEmpty(matrix.get(xx, y))) {
continue;
}
let bit;
if (bitIndex < dataBits.getSize()) {
bit = dataBits.get(bitIndex);
++bitIndex;
}
else {
// Padding bit. If there is no bit left, we'll fill the left cells with 0, as described
// in 8.4.9 of JISX0510:2004 (p. 24).
bit = false;
}
// Skip masking if mask_pattern is -1 (TYPESCRIPTPORT: 255).
if (maskPattern !== 255 && MaskUtil.getDataMaskBit(maskPattern, xx, y)) {
bit = !bit;
}
matrix.setBoolean(xx, y, bit);
}
y += direction;
}
direction = -direction; // Reverse the direction.
y += direction;
x -= 2; // Move to the left.
}
// All bits should be consumed.
if (bitIndex !== dataBits.getSize()) {
throw new WriterException('Not all bits consumed: ' + bitIndex + '/' + dataBits.getSize());
}
}
// Return the position of the most significant bit set (one: to) in the "value". The most
// significant bit is position 32. If there is no bit set, return 0. Examples:
// - findMSBSet(0) => 0
// - findMSBSet(1) => 1
// - findMSBSet(255) => 8
static findMSBSet(value /*int*/) {
return 32 - Integer.numberOfLeadingZeros(value);
}
// Calculate BCH (Bose-Chaudhuri-Hocquenghem) code for "value" using polynomial "poly". The BCH
// code is used for encoding type information and version information.
// Example: Calculation of version information of 7.
// f(x) is created from 7.
// - 7 = 000111 in 6 bits
// - f(x) = x^2 + x^1 + x^0
// g(x) is given by the standard (p. 67)
// - g(x) = x^12 + x^11 + x^10 + x^9 + x^8 + x^5 + x^2 + 1
// Multiply f(x) by x^(18 - 6)
// - f'(x) = f(x) * x^(18 - 6)
// - f'(x) = x^14 + x^13 + x^12
// Calculate the remainder of f'(x) / g(x)
// x^2
// __________________________________________________
// g(x) )x^14 + x^13 + x^12
// x^14 + x^13 + x^12 + x^11 + x^10 + x^7 + x^4 + x^2
// --------------------------------------------------
// x^11 + x^10 + x^7 + x^4 + x^2
//
// The remainder is x^11 + x^10 + x^7 + x^4 + x^2
// Encode it in binary: 110010010100
// The return value is 0xc94 (1100 1001 0100)
//
// Since all coefficients in the polynomials are 1 or 0, we can do the calculation by bit
// operations. We don't care if coefficients are positive or negative.
static calculateBCHCode(value /*int*/, poly /*int*/) {
if (poly === 0) {
throw new IllegalArgumentException('0 polynomial');
}
// If poly is "1 1111 0010 0101" (version info poly), msbSetInPoly is 13. We'll subtract 1
// from 13 to make it 12.
const msbSetInPoly = MatrixUtil.findMSBSet(poly);
value <<= msbSetInPoly - 1;
// Do the division business using exclusive-or operations.
while (MatrixUtil.findMSBSet(value) >= msbSetInPoly) {
value ^= poly << (MatrixUtil.findMSBSet(value) - msbSetInPoly);
}
// Now the "value" is the remainder (i.e. the BCH code)
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) {
if (!QRCode.isValidMaskPattern(maskPattern)) {
throw new WriterException('Invalid mask pattern');
}
const typeInfo = (ecLevel.getBits() << 3) | maskPattern;
bits.appendBits(typeInfo, 5);
const bchCode = MatrixUtil.calculateBCHCode(typeInfo, MatrixUtil.TYPE_INFO_POLY);
bits.appendBits(bchCode, 10);
const maskBits = new BitArray();
maskBits.appendBits(MatrixUtil.TYPE_INFO_MASK_PATTERN, 15);
bits.xor(maskBits);
if (bits.getSize() !== 15) { // Just in case.
throw new WriterException('should not happen but we got: ' + bits.getSize());
}
}
// 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) {
bits.appendBits(version.getVersionNumber(), 6);
const bchCode = MatrixUtil.calculateBCHCode(version.getVersionNumber(), MatrixUtil.VERSION_INFO_POLY);
bits.appendBits(bchCode, 12);
if (bits.getSize() !== 18) { // Just in case.
throw new WriterException('should not happen but we got: ' + bits.getSize());
}
}
// Check if "value" is empty.
static isEmpty(value /*int*/) {
return value === 255; // -1
}
static embedTimingPatterns(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;
// Horizontal line.
if (MatrixUtil.isEmpty(matrix.get(i, 6))) {
matrix.setNumber(i, 6, bit);
}
// Vertical line.
if (MatrixUtil.isEmpty(matrix.get(6, i))) {
matrix.setNumber(6, i, bit);
}
}
}
// Embed the lonely dark dot at left bottom corner. JISX0510:2004 (p.46)
static embedDarkDotAtLeftBottomCorner(matrix) {
if (matrix.get(8, matrix.getHeight() - 8) === 0) {
throw new WriterException();
}
matrix.setNumber(8, matrix.getHeight() - 8, 1);
}
static embedHorizontalSeparationPattern(xStart /*int*/, yStart /*int*/, matrix) {
for (let x = 0; x < 8; ++x) {
if (!MatrixUtil.isEmpty(matrix.get(xStart + x, yStart))) {
throw new WriterException();
}
matrix.setNumber(xStart + x, yStart, 0);
}
}
static embedVerticalSeparationPattern(xStart /*int*/, yStart /*int*/, matrix) {
for (let y = 0; y < 7; ++y) {
if (!MatrixUtil.isEmpty(matrix.get(xStart, yStart + y))) {
throw new WriterException();
}
matrix.setNumber(xStart, yStart + y, 0);
}
}
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) {
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) {
matrix.setNumber(xStart + x, yStart + y, patternY[x]);
}
}
}
// Embed position detection patterns and surrounding vertical/horizontal separators.
static embedPositionDetectionPatternsAndSeparators(matrix) {
// Embed three big squares at corners.
const pdpWidth = MatrixUtil.POSITION_DETECTION_PATTERN[0].length;
// Left top corner.
MatrixUtil.embedPositionDetectionPattern(0, 0, matrix);
// Right top corner.
MatrixUtil.embedPositionDetectionPattern(matrix.getWidth() - pdpWidth, 0, matrix);
// Left bottom corner.
MatrixUtil.embedPositionDetectionPattern(0, matrix.getWidth() - pdpWidth, matrix);
// Embed horizontal separation patterns around the squares.
const hspWidth = 8;
// Left top corner.
MatrixUtil.embedHorizontalSeparationPattern(0, hspWidth - 1, matrix);
// Right top corner.
MatrixUtil.embedHorizontalSeparationPattern(matrix.getWidth() - hspWidth, hspWidth - 1, matrix);
// Left bottom corner.
MatrixUtil.embedHorizontalSeparationPattern(0, matrix.getWidth() - hspWidth, matrix);
// Embed vertical separation patterns around the squares.
const vspSize = 7;
// Left top corner.
MatrixUtil.embedVerticalSeparationPattern(vspSize, 0, matrix);
// Right top corner.
MatrixUtil.embedVerticalSeparationPattern(matrix.getHeight() - vspSize - 1, 0, matrix);
// Left bottom corner.
MatrixUtil.embedVerticalSeparationPattern(vspSize, matrix.getHeight() - vspSize, matrix);
}
// Embed position adjustment patterns if need be.
static maybeEmbedPositionAdjustmentPatterns(version, matrix) {
if (version.getVersionNumber() < 2) { // The patterns appear if version >= 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];
if (y >= 0) {
for (let j = 0; j !== length; j++) {
const x = coordinates[j];
if (x >= 0 && MatrixUtil.isEmpty(matrix.get(x, y))) {
// If the cell is unset, we embed the position adjustment pattern here.
// -2 is necessary since the x/y coordinates point to the center of the pattern, not the
// left top corner.
MatrixUtil.embedPositionAdjustmentPattern(x - 2, y - 2, matrix);
}
}
}
}
}
}
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;
/*namespace com.google.zxing.qrcode.encoder {*/
class BlockPair {
constructor(dataBytes, errorCorrectionBytes) {
this.dataBytes = dataBytes;
this.errorCorrectionBytes = errorCorrectionBytes;
}
getDataBytes() {
return this.dataBytes;
}
getErrorCorrectionBytes() {
return this.errorCorrectionBytes;
}
}
/*import java.io.UnsupportedEncodingException;*/
/*import java.util.ArrayList;*/
/*import java.util.Collection;*/
/*import java.util.Map;*/
/**
* @author satorux@google.com (Satoru Takabayashi) - creator
* @author dswitkin@google.com (Daniel Switkin) - ported from C++
*/
class Encoder {
// TYPESCRIPTPORT: changed to UTF8, the default for js
constructor() { }
// 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) {
return MaskUtil.applyMaskPenaltyRule1(matrix)
+ MaskUtil.applyMaskPenaltyRule2(matrix)
+ MaskUtil.applyMaskPenaltyRule3(matrix)
+ MaskUtil.applyMaskPenaltyRule4(matrix);
}
/**
* @param content text to encode
* @param ecLevel error correction level to use
* @return {@link QRCode} representing the encoded QR code
* @throws WriterException if encoding can't succeed, because of for example invalid content
* or configuration
*/
// public static encode(content: string, ecLevel: ErrorCorrectionLevel): QRCode /*throws WriterException*/ {
// return encode(content, ecLevel, null)
// }
static encode(content, ecLevel, 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.CHARACTER_SET);
if (hasEncodingHint) {
encoding = hints.get(EncodeHintType$1.CHARACTER_SET).toString();
}
// Pick an encoding mode appropriate for the content. Note that this will not attempt to use
// multiple modes / segments even if that were more efficient. Twould be nice.
const 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();
// Append ECI segment if applicable
if (mode === Mode$1.BYTE && (hasEncodingHint || Encoder.DEFAULT_BYTE_MODE_ENCODING !== encoding)) {
const eci = CharacterSetECI.getCharacterSetECIByName(encoding);
if (eci !== undefined) {
this.appendECI(eci, headerBits);
}
}
// (With ECI in place,) Write the mode marker
this.appendModeInfo(mode, headerBits);
// Collect data within the main segment, separately, to count its size if needed. Don't add it to
// main payload yet.
const dataBits = new BitArray();
this.appendBytes(content, mode, dataBits, encoding);
let version;
if (hints !== null && undefined !== hints.get(EncodeHintType$1.QR_VERSION)) {
const versionNumber = Number.parseInt(hints.get(EncodeHintType$1.QR_VERSION).toString(), 10);
version = Version$1.getVersionForNumber(versionNumber);
const bitsNeeded = this.calculateBitsNeeded(mode, headerBits, dataBits, version);
if (!this.willFit(bitsNeeded, version, ecLevel)) {
throw new WriterException('Data too big for requested version');
}
}
else {
version = this.recommendVersion(ecLevel, mode, headerBits, dataBits);
}
const headerAndDataBits = new BitArray();
headerAndDataBits.appendBitArray(headerBits);
// Find "length" of main segment and write it
const numLetters = mode === Mode$1.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();
// 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();
qrCode.setECLevel(ecLevel);
qrCode.setMode(mode);
qrCode.setVersion(version);
// Choose the mask pattern and set to "qrCode".
const dimension = version.getDimensionForVersion();
const matrix = new ByteMatrix(dimension, dimension);
const maskPattern = this.chooseMaskPattern(finalBits, ecLevel, version, matrix);
qrCode.setMaskPattern(maskPattern);
// Build the matrix and set it to "qrCode".
MatrixUtil.buildMatrix(finalBits, ecLevel, version, maskPattern, matrix);
qrCode.setMatrix(matrix);
return qrCode;
}
/**
* Decides the smallest version of QR code that will contain all of the provided data.
*
* @throws WriterException if the data cannot fit in any version
*/
static recommendVersion(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.getVersionForNumber(1));
const 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);
return this.chooseVersion(bitsNeeded, ecLevel);
}
static calculateBitsNeeded(mode, headerBits, dataBits, version) {
return headerBits.getSize() + mode.getCharacterCountBits(version) + dataBits.getSize();
}
/**
* @return the code point of the table used in alphanumeric mode or
* -1 if there is no corresponding code in the table.
*/
static getAlphanumericCode(code /*int*/) {
if (code < Encoder.ALPHANUMERIC_TABLE.length) {
return Encoder.ALPHANUMERIC_TABLE[code];
}
return -1;
}
// public static chooseMode(content: string): Mode {
// return chooseMode(content, null);
// }
/**
* Choose the best mode by examining the content. Note that 'encoding' is used as a hint;
* if it is Shift_JIS, and the input is only double-byte Kanji, then we return {@link Mode#KANJI}.
*/
static chooseMode(content, encoding = null) {
if (CharacterSetECI.SJIS.getName() === encoding && this.isOnlyDoubleByteKanji(content)) {
// Choose Kanji mode if all input are double-byte characters
return Mode$1.KANJI;
}
let hasNumeric = false;
let hasAlphanumeric = false;
for (let i = 0, length = content.length; i < length; ++i) {
const c = content.charAt(i);
if (Encoder.isDigit(c)) {
hasNumeric = true;
}
else if (this.getAlphanumericCode(c.charCodeAt(0)) !== -1) {
hasAlphanumeric = true;
}
else {
return Mode$1.BYTE;
}
}
if (hasAlphanumeric) {
return Mode$1.ALPHANUMERIC;
}
if (hasNumeric) {
return Mode$1.NUMERIC;
}
return Mode$1.BYTE;
}
static isOnlyDoubleByteKanji(content) {
let bytes;
try {
bytes = StringEncoding.encode(content, CharacterSetECI.SJIS); // content.getBytes("Shift_JIS"))
}
catch (ignored /*: UnsupportedEncodingException*/) {
return false;
}
const length = bytes.length;
if (length % 2 !== 0) {
return false;
}
for (let i = 0; i < length; i += 2) {
const byte1 = bytes[i] & 0xFF;
if ((byte1 < 0x81 || byte1 > 0x9F) && (byte1 < 0xE0 || byte1 > 0xEB)) {
return false;
}
}
return true;
}
static chooseMaskPattern(bits, ecLevel, version, matrix) {
let minPenalty = Number.MAX_SAFE_INTEGER; // Lower penalty is better.
let bestMaskPattern = -1;
// We try all mask patterns to choose the best one.
for (let maskPattern = 0; maskPattern < QRCode.NUM_MASK_PATTERNS; maskPattern++) {
MatrixUtil.buildMatrix(bits, ecLevel, version, maskPattern, matrix);
let penalty = this.calculateMaskPenalty(matrix);
if (penalty < minPenalty) {
minPenalty = penalty;
bestMaskPattern = maskPattern;
}
}
return bestMaskPattern;
}
static chooseVersion(numInputBits /*int*/, ecLevel) {
for (let versionNum = 1; versionNum <= 40; versionNum++) {
const version = Version$1.getVersionForNumber(versionNum);
if (Encoder.willFit(numInputBits, version, ecLevel)) {
return version;
}
}
throw new WriterException('Data too big');
}
/**
* @return true if the number of input bits will fit in a code with the specified version and
* error correction level.
*/
static willFit(numInputBits /*int*/, version, ecLevel) {
// In the following comments, we use numbers of Version 7-H.
// numBytes = 196
const numBytes = version.getTotalCodewords();
// getNumECBytes = 130
const ecBlocks = version.getECBlocksForLevel(ecLevel);
const numEcBytes = ecBlocks.getTotalECCodewords();
// getNumDataBytes = 196 - 130 = 66
const numDataBytes = numBytes - numEcBytes;
const 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;
if (bits.getSize() > capacity) {
throw new WriterException('data bits cannot fit in the QR Code' + bits.getSize() + ' > ' +
capacity);
}
for (let i = 0; i < 4 && bits.getSize() < capacity; ++i) {
bits.appendBit(false);
}
// Append termination bits. See 8.4.8 of JISX0510:2004 (p.24) for details.
// If the last byte isn't 8-bit aligned, we'll add padding bits.
const numBitsInLastByte = bits.getSize() & 0x07;
if (numBitsInLastByte > 0) {
for (let i = numBitsInLastByte; i < 8; i++) {
bits.appendBit(false);
}
}
// 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) {
bits.appendBits((i & 0x01) === 0 ? 0xEC : 0x11, 8);
}
if (bits.getSize() !== capacity) {
throw new WriterException('Bits size does not equal capacity');
}
}
/**
* Get number of data bytes and number of error correction bytes for block id "blockID". Store
* the result in "numDataBytesInBlock", and "numECBytesInBlock". See table 12 in 8.5.1 of
* JISX0510:2004 (p.30)
*/
static getNumDataBytesAndNumECBytesForBlockID(numTotalBytes /*int*/, numDataBytes /*int*/, numRSBlocks /*int*/, blockID /*int*/, numDataBytesInBlock, numECBytesInBlock) {
if (blockID >= numRSBlocks) {
throw new WriterException('Block ID too large');
}
// numRsBlocksInGroup2 = 196 % 5 = 1
const numRsBlocksInGroup2 = numTotalBytes % numRSBlocks;
// numRsBlocksInGroup1 = 5 - 1 = 4
const numRsBlocksInGroup1 = numRSBlocks - numRsBlocksInGroup2;
// numTotalBytesInGroup1 = 196 / 5 = 39
const numTotalBytesInGroup1 = Math.floor(numTotalBytes / numRSBlocks);
// numTotalBytesInGroup2 = 39 + 1 = 40
const numTotalBytesInGroup2 = numTotalBytesInGroup1 + 1;
// numDataBytesInGroup1 = 66 / 5 = 13
const numDataBytesInGroup1 = Math.floor(numDataBytes / numRSBlocks);
// numDataBytesInGroup2 = 13 + 1 = 14
const numDataBytesInGroup2 = numDataBytesInGroup1 + 1;
// numEcBytesInGroup1 = 39 - 13 = 26
const numEcBytesInGroup1 = numTotalBytesInGroup1 - numDataBytesInGroup1;
// numEcBytesInGroup2 = 40 - 14 = 26
const numEcBytesInGroup2 = numTotalBytesInGroup2 - numDataBytesInGroup2;
// Sanity checks.
// 26 = 26
if (numEcBytesInGroup1 !== numEcBytesInGroup2) {
throw new WriterException('EC bytes mismatch');
}
// 5 = 4 + 1.
if (numRSBlocks !== numRsBlocksInGroup1 + numRsBlocksInGroup2) {
throw new WriterException('RS blocks mismatch');
}
// 196 = (13 + 26) * 4 + (14 + 26) * 1
if (numTotalBytes !==
((numDataBytesInGroup1 + numEcBytesInGroup1) *
numRsBlocksInGroup1) +
((numDataBytesInGroup2 + numEcBytesInGroup2) *
numRsBlocksInGroup2)) {
throw new WriterException('Total bytes mismatch');
}
if (blockID < numRsBlocksInGroup1) {
numDataBytesInBlock[0] = numDataBytesInGroup1;
numECBytesInBlock[0] = numEcBytesInGroup1;
}
else {
numDataBytesInBlock[0] = numDataBytesInGroup2;
numECBytesInBlock[0] = numEcBytesInGroup2;
}
}
/**
* Interleave "bits" with corresponding error correction bytes. On success, store the result in
* "result". The interleave rule is complicated. See 8.6 of JISX0510:2004 (p.37) for details.
*/
static interleaveWithECBytes(bits, numTotalBytes /*int*/, numDataBytes /*int*/, numRSBlocks /*int*/) {
// "bits" must have "getNumDataBytes" bytes of data.
if (bits.getSizeInBytes() !== numDataBytes) {
throw new WriterException('Number of bits and data bytes does not match');
}
// Step 1. Divide data bytes into blocks and generate error correction bytes for them. We'll
// store the divided data bytes blocks and error correction bytes blocks into "blocks".
let dataBytesOffset = 0;
let maxNumDataBytes = 0;
let maxNumEcBytes = 0;
// Since, we know the number of reedsolmon blocks, we can initialize the vector with the number.
const blocks = new Array(); // new Array(numRSBlocks)
for (let i = 0; i < numRSBlocks; ++i) {
const numDataBytesInBlock = new Int32Array(1);
const numEcBytesInBlock = new Int32Array(1);
Encoder.getNumDataBytesAndNumECBytesForBlockID(numTotalBytes, numDataBytes, numRSBlocks, i, numDataBytesInBlock, numEcBytesInBlock);
const size = numDataBytesInBlock[0];
const dataBytes = new Uint8Array(size);
bits.toBytes(8 * dataBytesOffset, dataBytes, 0, size);
const ecBytes = Encoder.generateECBytes(dataBytes, numEcBytesInBlock[0]);
blocks.push(new BlockPair(dataBytes, ecBytes));
maxNumDataBytes = Math.max(maxNumDataBytes, size);
maxNumEcBytes = Math.max(maxNumEcBytes, ecBytes.length);
dataBytesOffset += numDataBytesInBlock[0];
}
if (numDataBytes !== dataBytesOffset) {
throw new WriterException('Data bytes does not match offset');
}
const result = new BitArray();
// First, place data blocks.
for (let i = 0; i < maxNumDataBytes; ++i) {
for (const block of blocks) {
const dataBytes = block.getDataBytes();
if (i < dataBytes.length) {
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();
if (i < ecBytes.length) {
result.appendBits(ecBytes[i], 8);
}
}
}
if (numTotalBytes !== result.getSizeInBytes()) { // Should be same.
throw new WriterException('Interleaving error: ' + numTotalBytes + ' and ' +
result.getSizeInBytes() + ' differ.');
}
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++) {
toEncode[i] = dataBytes[i] & 0xFF;
}
new ReedSolomonEncoder(GenericGF.QR_CODE_FIELD_256).encode(toEncode, numEcBytesInBlock);
const ecBytes = new Uint8Array(numEcBytesInBlock);
for (let 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) {
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);
if (numLetters >= (1 << numBits)) {
throw new 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) {
switch (mode) {
case Mode$1.NUMERIC:
Encoder.appendNumericBytes(content, bits);
break;
case Mode$1.ALPHANUMERIC:
Encoder.appendAlphanumericBytes(content, bits);
break;
case Mode$1.BYTE:
Encoder.append8BitBytes(content, bits, encoding);
break;
case Mode$1.KANJI:
Encoder.appendKanjiBytes(content, bits);
break;
default:
throw new WriterException('Invalid mode: ' + mode);
}
}
static getDigit(singleCharacter) {
return singleCharacter.charCodeAt(0) - 48;
}
static isDigit(singleCharacter) {
const cn = Encoder.getDigit(singleCharacter);
return cn >= 0 && cn <= 9;
}
static appendNumericBytes(content, bits) {
const length = content.length;
let i = 0;
while (i < length) {
const 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));
bits.appendBits(num1 * 100 + num2 * 10 + num3, 10);
i += 3;
}
else if (i + 1 < length) {
// Encode two numeric letters in seven bits.
const num2 = Encoder.getDigit(content.charAt(i + 1));
bits.appendBits(num1 * 10 + num2, 7);
i += 2;
}
else {
// Encode one numeric letter in four bits.
bits.appendBits(num1, 4);
i++;
}
}
}
static appendAlphanumericBytes(content, bits) {
const length = content.length;
let i = 0;
while (i < length) {
const code1 = Encoder.getAlphanumericCode(content.charCodeAt(i));
if (code1 === -1) {
throw new WriterException();
}
if (i + 1 < length) {
const code2 = Encoder.getAlphanumericCode(content.charCodeAt(i + 1));
if (code2 === -1) {
throw new WriterException();
}
// Encode two alphanumeric letters in 11 bits.
bits.appendBits(code1 * 45 + code2, 11);
i += 2;
}
else {
// Encode one alphanumeric letter in six bits.
bits.appendBits(code1, 6);
i++;
}
}
}
static append8BitBytes(content, bits, encoding) {
let bytes;
try {
bytes = StringEncoding.encode(content, encoding);
}
catch (uee /*: UnsupportedEncodingException*/) {
throw new WriterException(uee);
}
for (let i = 0, length = bytes.length; i !== length; i++) {
const b = bytes[i];
bits.appendBits(b, 8);
}
}
/**
* @throws WriterException
*/
static appendKanjiBytes(content, bits) {
let bytes;
try {
bytes = StringEncoding.encode(content, CharacterSetECI.SJIS);
}
catch (uee /*: UnsupportedEncodingException*/) {
throw new WriterException(uee);
}
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;
if (code >= 0x8140 && code <= 0x9ffc) {
subtracted = code - 0x8140;
}
else if (code >= 0xe040 && code <= 0xebbf) {
subtracted = code - 0xc140;
}
if (subtracted === -1) {
throw new WriterException('Invalid byte sequence');
}
const encoded = ((subtracted >> 8) * 0xc0) + (subtracted & 0xff);
bits.appendBits(encoded, 13);
}
}
static appendECI(eci, bits) {
bits.appendBits(Mode$1.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.UTF8.getName(); // "ISO-8859-1"
/**
* @deprecated Moving to @zxing/browser
*/
class BrowserQRCodeSvgWriter {
/**
* Writes and renders a QRCode SVG element.
*
* @param contents
* @param width
* @param height
* @param hints
*/
write(contents, width, height, hints = null) {
if (contents.length === 0) {
throw new IllegalArgumentException('Found empty contents');
}
// if (format != BarcodeFormat.QR_CODE) {
// throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format)
// }
if (width < 0 || height < 0) {
throw new IllegalArgumentException('Requested dimensions are too small: ' + width + 'x' + height);
}
let errorCorrectionLevel = ErrorCorrectionLevel.L;
let quietZone = BrowserQRCodeSvgWriter.QUIET_ZONE_SIZE;
if (hints !== null) {
if (undefined !== hints.get(EncodeHintType$1.ERROR_CORRECTION)) {
errorCorrectionLevel = ErrorCorrectionLevel.fromString(hints.get(EncodeHintType$1.ERROR_CORRECTION).toString());
}
if (undefined !== hints.get(EncodeHintType$1.MARGIN)) {
quietZone = Number.parseInt(hints.get(EncodeHintType$1.MARGIN).toString(), 10);
}
}
const code = Encoder.encode(contents, errorCorrectionLevel, hints);
return this.renderResult(code, width, height, quietZone);
}
/**
* Renders the result and then appends it to the DOM.
*/
writeToDom(containerElement, contents, width, height, hints = null) {
if (typeof containerElement === 'string') {
containerElement = document.querySelector(containerElement);
}
const svgElement = this.write(contents, width, height, hints);
if (containerElement)
containerElement.appendChild(svgElement);
}
/**
* 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).
*/
renderResult(code, width /*int*/, height /*int*/, quietZone /*int*/) {
const input = code.getMatrix();
if (input === null) {
throw new 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));
// Padding includes both the quiet zone and the extra white pixels to accommodate the requested
// dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.
// If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will
// 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);
for (let 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) {
if (input.get(inputX, inputY) === 1) {
const svgRectElement = this.createSvgRectElement(outputX, outputY, multiple, multiple);
svgElement.appendChild(svgRectElement);
}
}
}
return svgElement;
}
/**
* Creates a SVG element.
*
* @param w SVG's width attribute
* @param h SVG's height attribute
*/
createSVGElement(w, h) {
const svgElement = document.createElementNS(BrowserQRCodeSvgWriter.SVG_NS, 'svg');
svgElement.setAttributeNS(null, 'height', w.toString());
svgElement.setAttributeNS(null, 'width', h.toString());
return svgElement;
}
/**
* Creates a SVG rect element.
*
* @param x Element's x coordinate
* @param y Element's y coordinate
* @param w Element's width attribute
* @param h Element's height attribute
*/
createSvgRectElement(x, y, w, h) {
const rect = document.createElementNS(BrowserQRCodeSvgWriter.SVG_NS, 'rect');
rect.setAttributeNS(null, 'x', x.toString());
rect.setAttributeNS(null, 'y', y.toString());
rect.setAttributeNS(null, 'height', w.toString());
rect.setAttributeNS(null, 'width', h.toString());
rect.setAttributeNS(null, 'fill', '#000000');
return rect;
}
}
BrowserQRCodeSvgWriter.QUIET_ZONE_SIZE = 4;
/**
* SVG markup NameSpace
*/
BrowserQRCodeSvgWriter.SVG_NS = 'http://www.w3.org/2000/svg';
/*import java.util.Map;*/
/**
* This object renders a QR Code as a BitMatrix 2D array of greyscale values.
*
* @author dswitkin@google.com (Daniel Switkin)
*/
class QRCodeWriter {
/*@Override*/
// public encode(contents: string, format: BarcodeFormat, width: number /*int*/, height: number /*int*/): BitMatrix
// /*throws WriterException */ {
// return encode(contents, format, width, height, null)
// }
/*@Override*/
encode(contents, format, width /*int*/, height /*int*/, hints) {
if (contents.length === 0) {
throw new IllegalArgumentException('Found empty contents');
}
if (format !== BarcodeFormat$1.QR_CODE) {
throw new IllegalArgumentException('Can only encode QR_CODE, but got ' + format);
}
if (width < 0 || height < 0) {
throw new IllegalArgumentException(`Requested dimensions are too small: ${width}x${height}`);
}
let errorCorrectionLevel = ErrorCorrectionLevel.L;
let quietZone = QRCodeWriter.QUIET_ZONE_SIZE;
if (hints !== null) {
if (undefined !== hints.get(EncodeHintType$1.ERROR_CORRECTION)) {
errorCorrectionLevel = ErrorCorrectionLevel.fromString(hints.get(EncodeHintType$1.ERROR_CORRECTION).toString());
}
if (undefined !== hints.get(EncodeHintType$1.MARGIN)) {
quietZone = Number.parseInt(hints.get(EncodeHintType$1.MARGIN).toString(), 10);
}
}
const code = Encoder.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();
if (input === null) {
throw new 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));
// Padding includes both the quiet zone and the extra white pixels to accommodate the requested
// dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.
// If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will
// 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(outputWidth, outputHeight);
for (let 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) {
if (input.get(inputX, inputY) === 1) {
output.setRegion(outputX, outputY, multiple, multiple);
}
}
}
return output;
}
}
QRCodeWriter.QUIET_ZONE_SIZE = 4;
/*import java.util.Map;*/
/**
* This is a factory class which finds the appropriate Writer subclass for the BarcodeFormat
* requested and encodes the barcode with the supplied contents.
*
* @author dswitkin@google.com (Daniel Switkin)
*/
class MultiFormatWriter {
/*@Override*/
// public encode(contents: string,
// format: BarcodeFormat,
// width: number /*int*/,
// height: number /*int*/): BitMatrix /*throws WriterException */ {
// return encode(contents, format, width, height, null)
// }
/*@Override*/
encode(contents, format, width /*int*/, height /*int*/, hints) {
let writer;
switch (format) {
// case BarcodeFormat.EAN_8:
// writer = new EAN8Writer()
// break
// case BarcodeFormat.UPC_E:
// writer = new UPCEWriter()
// break
// case BarcodeFormat.EAN_13:
// writer = new EAN13Writer()
// break
// case BarcodeFormat.UPC_A:
// writer = new UPCAWriter()
// break
case BarcodeFormat$1.QR_CODE:
writer = new QRCodeWriter();
break;
// case BarcodeFormat.CODE_39:
// writer = new Code39Writer()
// break
// case BarcodeFormat.CODE_93:
// writer = new Code93Writer()
// break
// case BarcodeFormat.CODE_128:
// writer = new Code128Writer()
// break
// case BarcodeFormat.ITF:
// writer = new ITFWriter()
// break
// case BarcodeFormat.PDF_417:
// writer = new PDF417Writer()
// break
// case BarcodeFormat.CODABAR:
// writer = new CodaBarWriter()
// break
// case BarcodeFormat.DATA_MATRIX:
// writer = new DataMatrixWriter()
// break
// case BarcodeFormat.AZTEC:
// writer = new AztecWriter()
// break
default:
throw new IllegalArgumentException('No encoder available for format ' + format);
}
return writer.encode(contents, format, width, height, hints);
}
}
/*
* Copyright 2009 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This object extends LuminanceSource around an array of YUV data returned from the camera driver,
* with the option to crop to a rectangle within the full data. This can be used to exclude
* superfluous pixels around the perimeter and speed up decoding.
*
* It works for any pixel format where the Y channel is planar and appears first, including
* YCbCr_420_SP and YCbCr_422_SP.
*
* @author dswitkin@google.com (Daniel Switkin)
*/
class PlanarYUVLuminanceSource extends LuminanceSource {
constructor(yuvData, dataWidth /*int*/, dataHeight /*int*/, left /*int*/, top /*int*/, width /*int*/, height /*int*/, reverseHorizontal) {
super(width, height);
this.yuvData = yuvData;
this.dataWidth = dataWidth;
this.dataHeight = dataHeight;
this.left = left;
this.top = top;
if (left + width > dataWidth || top + height > dataHeight) {
throw new IllegalArgumentException('Crop rectangle does not fit within image data.');
}
if (reverseHorizontal) {
this.reverseHorizontal(width, height);
}
}
/*@Override*/
getRow(y /*int*/, row) {
if (y < 0 || y >= this.getHeight()) {
throw new IllegalArgumentException('Requested row is outside the image: ' + y);
}
const width = this.getWidth();
if (row === null || row === undefined || row.length < width) {
row = new Uint8ClampedArray(width);
}
const offset = (y + this.top) * this.dataWidth + this.left;
System.arraycopy(this.yuvData, offset, row, 0, width);
return row;
}
/*@Override*/
getMatrix() {
const width = this.getWidth();
const height = this.getHeight();
// If the caller asks for the entire underlying image, save the copy and give them the
// original data. The docs specifically warn that result.length must be ignored.
if (width === this.dataWidth && height === this.dataHeight) {
return this.yuvData;
}
const area = width * height;
const matrix = new Uint8ClampedArray(area);
let inputOffset = this.top * this.dataWidth + this.left;
// If the width matches the full width of the underlying data, perform a single copy.
if (width === this.dataWidth) {
System.arraycopy(this.yuvData, inputOffset, matrix, 0, area);
return matrix;
}
// Otherwise copy one cropped row at a time.
for (let y = 0; y < height; y++) {
const outputOffset = y * width;
System.arraycopy(this.yuvData, inputOffset, matrix, outputOffset, width);
inputOffset += this.dataWidth;
}
return matrix;
}
/*@Override*/
isCropSupported() {
return true;
}
/*@Override*/
crop(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;
pixels[outputOffset + x] = 0xFF000000 | (grey * 0x00010101);
}
inputOffset += this.dataWidth * PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR;
}
return pixels;
}
/**
* @return width of image from {@link #renderThumbnail()}
*/
getThumbnailWidth() {
return this.getWidth() / PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR;
}
/**
* @return height of image from {@link #renderThumbnail()}
*/
getThumbnailHeight() {
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];
yuvData[x1] = yuvData[x2];
yuvData[x2] = temp;
}
}
}
invert() {
return new InvertedLuminanceSource(this);
}
}
PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR = 2;
/*
* Copyright 2009 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This class is used to help decode images from files which arrive as RGB data from
* an ARGB pixel array. It does not support rotation.
*
* @author dswitkin@google.com (Daniel Switkin)
* @author Betaminos
*/
class RGBLuminanceSource extends LuminanceSource {
constructor(luminances, width /*int*/, height /*int*/, dataWidth /*int*/, dataHeight /*int*/, left /*int*/, top /*int*/) {
super(width, height);
this.dataWidth = dataWidth;
this.dataHeight = dataHeight;
this.left = left;
this.top = top;
if (luminances.BYTES_PER_ELEMENT === 4) { // Int32Array
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
// Calculate green-favouring average cheaply
luminancesUint8Array[offset] = /*(byte) */ ((r + g2 + b) / 4) & 0xFF;
}
this.luminances = luminancesUint8Array;
}
else {
this.luminances = luminances;
}
if (undefined === dataWidth) {
this.dataWidth = width;
}
if (undefined === dataHeight) {
this.dataHeight = height;
}
if (undefined === left) {
this.left = 0;
}
if (undefined === top) {
this.top = 0;
}
if (this.left + width > this.dataWidth || this.top + height > this.dataHeight) {
throw new IllegalArgumentException('Crop rectangle does not fit within image data.');
}
}
/*@Override*/
getRow(y /*int*/, row) {
if (y < 0 || y >= this.getHeight()) {
throw new IllegalArgumentException('Requested row is outside the image: ' + y);
}
const width = this.getWidth();
if (row === null || row === undefined || row.length < width) {
row = new Uint8ClampedArray(width);
}
const offset = (y + this.top) * this.dataWidth + this.left;
System.arraycopy(this.luminances, offset, row, 0, width);
return row;
}
/*@Override*/
getMatrix() {
const width = this.getWidth();
const height = this.getHeight();
// If the caller asks for the entire underlying image, save the copy and give them the
// original data. The docs specifically warn that result.length must be ignored.
if (width === this.dataWidth && height === this.dataHeight) {
return this.luminances;
}
const area = width * height;
const matrix = new Uint8ClampedArray(area);
let inputOffset = this.top * this.dataWidth + this.left;
// If the width matches the full width of the underlying data, perform a single copy.
if (width === this.dataWidth) {
System.arraycopy(this.luminances, inputOffset, matrix, 0, area);
return matrix;
}
// Otherwise copy one cropped row at a time.
for (let y = 0; y < height; y++) {
const outputOffset = y * width;
System.arraycopy(this.luminances, inputOffset, matrix, outputOffset, width);
inputOffset += this.dataWidth;
}
return matrix;
}
/*@Override*/
isCropSupported() {
return true;
}
/*@Override*/
crop(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() {
return new InvertedLuminanceSource(this);
}
}
/**
* Just to make a shortcut between Java code and TS code.
*/
class Charset extends CharacterSetECI {
static forName(name) {
return this.getCharacterSetECIByName(name);
}
}
/**
* Just to make a shortcut between Java code and TS code.
*/
class StandardCharsets {
}
StandardCharsets.ISO_8859_1 = CharacterSetECI.ISO8859_1;
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Aztec 2D code representation
*
* @author Rustam Abdullaev
*/
/*public final*/ class AztecCode {
/**
* @return {@code true} if compact instead of full mode
*/
isCompact() {
return this.compact;
}
setCompact(compact) {
this.compact = compact;
}
/**
* @return size in pixels (width and height)
*/
getSize() {
return this.size;
}
setSize(size) {
this.size = size;
}
/**
* @return number of levels
*/
getLayers() {
return this.layers;
}
setLayers(layers) {
this.layers = layers;
}
/**
* @return number of data codewords
*/
getCodeWords() {
return this.codeWords;
}
setCodeWords(codeWords) {
this.codeWords = codeWords;
}
/**
* @return the symbol image
*/
getMatrix() {
return this.matrix;
}
setMatrix(matrix) {
this.matrix = matrix;
}
}
class Collections {
/**
* The singletonList(T) method is used to return an immutable list containing only the specified object.
*/
static singletonList(item) {
return [item];
}
/**
* The min(Collection extends T>, Comparator super T>) method is used to return the minimum element of the given collection, according to the order induced by the specified comparator.
*/
static min(collection, comparator) {
return collection.sort(comparator)[0];
}
}
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Token {
constructor(previous) {
this.previous = previous;
}
getPrevious() {
return this.previous;
}
}
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*final*/ class SimpleToken extends Token {
constructor(previous, value, bitCount) {
super(previous);
this.value = value;
this.bitCount = bitCount;
}
/**
* @Override
*/
appendTo(bitArray, text) {
bitArray.appendBits(this.value, this.bitCount);
}
add(value, bitCount) {
return new SimpleToken(this, value, bitCount);
}
addBinaryShift(start, byteCount) {
// no-op can't binary shift a simple token
console.warn('addBinaryShift on SimpleToken, this simply returns a copy of this token');
return new SimpleToken(this, start, byteCount);
}
/**
* @Override
*/
toString() {
let value = this.value & ((1 << this.bitCount) - 1);
value |= 1 << this.bitCount;
return '<' + Integer.toBinaryString(value | (1 << this.bitCount)).substring(1) + '>';
}
}
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*final*/ class BinaryShiftToken extends SimpleToken {
constructor(previous, binaryShiftStart, binaryShiftByteCount) {
super(previous, 0, 0);
this.binaryShiftStart = binaryShiftStart;
this.binaryShiftByteCount = binaryShiftByteCount;
}
/**
* @Override
*/
appendTo(bitArray, text) {
for (let i = 0; i < this.binaryShiftByteCount; i++) {
if (i === 0 || (i === 31 && this.binaryShiftByteCount <= 62)) {
// We need a header before the first character, and before
// character 31 when the total byte code is <= 62
bitArray.appendBits(31, 5); // BINARY_SHIFT
if (this.binaryShiftByteCount > 62) {
bitArray.appendBits(this.binaryShiftByteCount - 31, 16);
}
else if (i === 0) {
// 1 <= binaryShiftByteCode <= 62
bitArray.appendBits(Math.min(this.binaryShiftByteCount, 31), 5);
}
else {
// 32 <= binaryShiftCount <= 62 and i == 31
bitArray.appendBits(this.binaryShiftByteCount - 31, 5);
}
}
bitArray.appendBits(text[this.binaryShiftStart + i], 8);
}
}
addBinaryShift(start, byteCount) {
// int bitCount = (byteCount * 8) + (byteCount <= 31 ? 10 : byteCount <= 62 ? 20 : 21);
return new BinaryShiftToken(this, start, byteCount);
}
/**
* @Override
*/
toString() {
return '<' + this.binaryShiftStart + '::' + (this.binaryShiftStart + this.binaryShiftByteCount - 1) + '>';
}
}
function addBinaryShift(token, start, byteCount) {
// int bitCount = (byteCount * 8) + (byteCount <= 31 ? 10 : byteCount <= 62 ? 20 : 21);
return new BinaryShiftToken(token, start, byteCount);
}
function add(token, value, bitCount) {
return new SimpleToken(token, value, bitCount);
}
const /*final*/ MODE_NAMES = [
'UPPER',
'LOWER',
'DIGIT',
'MIXED',
'PUNCT'
];
const /*final*/ MODE_UPPER = 0; // 5 bits
const /*final*/ MODE_LOWER = 1; // 5 bits
const /*final*/ MODE_DIGIT = 2; // 4 bits
const /*final*/ MODE_MIXED = 3; // 5 bits
const /*final*/ MODE_PUNCT = 4; // 5 bits
const EMPTY_TOKEN = new SimpleToken(null, 0, 0);
// The Latch Table shows, for each pair of Modes, the optimal method for
// getting from one mode to another. In the worst possible case, this can
// be up to 14 bits. In the best possible case, we are already there!
// The high half-word of each entry gives the number of bits.
// The low half-word of each entry are the actual bits necessary to change
const LATCH_TABLE = [
Int32Array.from([
0,
(5 << 16) + 28,
(5 << 16) + 30,
(5 << 16) + 29,
(10 << 16) + (29 << 5) + 30 // UPPER -> MIXED -> PUNCT
]),
Int32Array.from([
(9 << 16) + (30 << 4) + 14,
0,
(5 << 16) + 30,
(5 << 16) + 29,
(10 << 16) + (29 << 5) + 30 // LOWER -> MIXED -> PUNCT
]),
Int32Array.from([
(4 << 16) + 14,
(9 << 16) + (14 << 5) + 28,
0,
(9 << 16) + (14 << 5) + 29,
(14 << 16) + (14 << 10) + (29 << 5) + 30
// DIGIT -> UPPER -> MIXED -> PUNCT
]),
Int32Array.from([
(5 << 16) + 29,
(5 << 16) + 28,
(10 << 16) + (29 << 5) + 30,
0,
(5 << 16) + 30 // MIXED -> PUNCT
]),
Int32Array.from([
(5 << 16) + 31,
(10 << 16) + (31 << 5) + 28,
(10 << 16) + (31 << 5) + 30,
(10 << 16) + (31 << 5) + 29,
0
])
];
function static_SHIFT_TABLE(SHIFT_TABLE) {
for (let table /*Int32Array*/ of SHIFT_TABLE) {
Arrays.fill(table, -1);
}
SHIFT_TABLE[MODE_UPPER][MODE_PUNCT] = 0;
SHIFT_TABLE[MODE_LOWER][MODE_PUNCT] = 0;
SHIFT_TABLE[MODE_LOWER][MODE_UPPER] = 28;
SHIFT_TABLE[MODE_MIXED][MODE_PUNCT] = 0;
SHIFT_TABLE[MODE_DIGIT][MODE_PUNCT] = 0;
SHIFT_TABLE[MODE_DIGIT][MODE_UPPER] = 15;
return SHIFT_TABLE;
}
const /*final*/ SHIFT_TABLE = static_SHIFT_TABLE(Arrays.createInt32Array(6, 6)); // mode shift codes, per table
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* State represents all information about a sequence necessary to generate the current output.
* Note that a state is immutable.
*/
/*final*/ class State {
constructor(token, mode, binaryBytes, bitCount) {
this.token = token;
this.mode = mode;
this.binaryShiftByteCount = binaryBytes;
this.bitCount = bitCount;
// Make sure we match the token
// int binaryShiftBitCount = (binaryShiftByteCount * 8) +
// (binaryShiftByteCount === 0 ? 0 :
// binaryShiftByteCount <= 31 ? 10 :
// binaryShiftByteCount <= 62 ? 20 : 21);
// assert this.bitCount === token.getTotalBitCount() + binaryShiftBitCount;
}
getMode() {
return this.mode;
}
getToken() {
return this.token;
}
getBinaryShiftByteCount() {
return this.binaryShiftByteCount;
}
getBitCount() {
return this.bitCount;
}
// Create a new state representing this state with a latch to a (not
// necessary different) mode, and then a code.
latchAndAppend(mode, value) {
// assert binaryShiftByteCount === 0;
let bitCount = this.bitCount;
let token = this.token;
if (mode !== this.mode) {
let latch = LATCH_TABLE[this.mode][mode];
token = add(token, latch & 0xffff, latch >> 16);
bitCount += latch >> 16;
}
let latchModeBitCount = mode === MODE_DIGIT ? 4 : 5;
token = add(token, value, latchModeBitCount);
return new State(token, mode, 0, bitCount + latchModeBitCount);
}
// Create a new state representing this state, with a temporary shift
// to a different mode to output a single value.
shiftAndAppend(mode, value) {
// assert binaryShiftByteCount === 0 && this.mode !== mode;
let token = this.token;
let thisModeBitCount = this.mode === MODE_DIGIT ? 4 : 5;
// Shifts exist only to UPPER and PUNCT, both with tokens size 5.
token = add(token, SHIFT_TABLE[this.mode][mode], thisModeBitCount);
token = add(token, value, 5);
return new State(token, this.mode, 0, this.bitCount + thisModeBitCount + 5);
}
// Create a new state representing this state, but an additional character
// output in Binary Shift mode.
addBinaryShiftChar(index) {
let token = this.token;
let mode = this.mode;
let bitCount = this.bitCount;
if (this.mode === MODE_PUNCT || this.mode === MODE_DIGIT) {
// assert binaryShiftByteCount === 0;
let latch = LATCH_TABLE[mode][MODE_UPPER];
token = add(token, latch & 0xffff, latch >> 16);
bitCount += latch >> 16;
mode = MODE_UPPER;
}
let deltaBitCount = this.binaryShiftByteCount === 0 || this.binaryShiftByteCount === 31
? 18
: this.binaryShiftByteCount === 62
? 9
: 8;
let result = new State(token, mode, this.binaryShiftByteCount + 1, bitCount + deltaBitCount);
if (result.binaryShiftByteCount === 2047 + 31) {
// The string is as long as it's allowed to be. We should end it.
result = result.endBinaryShift(index + 1);
}
return result;
}
// Create the state identical to this one, but we are no longer in
// Binary Shift mode.
endBinaryShift(index) {
if (this.binaryShiftByteCount === 0) {
return this;
}
let token = this.token;
token = addBinaryShift(token, index - this.binaryShiftByteCount, this.binaryShiftByteCount);
// assert token.getTotalBitCount() === this.bitCount;
return new State(token, this.mode, 0, this.bitCount);
}
// Returns true if "this" state is better (equal: or) to be in than "that"
// state under all possible circumstances.
isBetterThanOrEqualTo(other) {
let newModeBitCount = this.bitCount + (LATCH_TABLE[this.mode][other.mode] >> 16);
if (this.binaryShiftByteCount < other.binaryShiftByteCount) {
// add additional B/S encoding cost of other, if any
newModeBitCount +=
State.calculateBinaryShiftCost(other) -
State.calculateBinaryShiftCost(this);
}
else if (this.binaryShiftByteCount > other.binaryShiftByteCount &&
other.binaryShiftByteCount > 0) {
// maximum possible additional cost (it: h)
newModeBitCount += 10;
}
return newModeBitCount <= other.bitCount;
}
toBitArray(text) {
// Reverse the tokens, so that they are in the order that they should
// be output
let symbols = [];
for (let token = this.endBinaryShift(text.length).token; token !== null; token = token.getPrevious()) {
symbols.unshift(token);
}
let bitArray = new BitArray();
// Add each token to the result.
for (const symbol of symbols) {
symbol.appendTo(bitArray, text);
}
// assert bitArray.getSize() === this.bitCount;
return bitArray;
}
/**
* @Override
*/
toString() {
return StringUtils.format('%s bits=%d bytes=%d', MODE_NAMES[this.mode], this.bitCount, this.binaryShiftByteCount);
}
static calculateBinaryShiftCost(state) {
if (state.binaryShiftByteCount > 62) {
return 21; // B/S with extended length
}
if (state.binaryShiftByteCount > 31) {
return 20; // two B/S
}
if (state.binaryShiftByteCount > 0) {
return 10; // one B/S
}
return 0;
}
}
State.INITIAL_STATE = new State(EMPTY_TOKEN, MODE_UPPER, 0, 0);
function static_CHAR_MAP(CHAR_MAP) {
const spaceCharCode = StringUtils.getCharCode(' ');
const pointCharCode = StringUtils.getCharCode('.');
const commaCharCode = StringUtils.getCharCode(',');
CHAR_MAP[MODE_UPPER][spaceCharCode] = 1;
const zUpperCharCode = StringUtils.getCharCode('Z');
const aUpperCharCode = StringUtils.getCharCode('A');
for (let c = aUpperCharCode; c <= zUpperCharCode; c++) {
CHAR_MAP[MODE_UPPER][c] = c - aUpperCharCode + 2;
}
CHAR_MAP[MODE_LOWER][spaceCharCode] = 1;
const zLowerCharCode = StringUtils.getCharCode('z');
const aLowerCharCode = StringUtils.getCharCode('a');
for (let c = aLowerCharCode; c <= zLowerCharCode; c++) {
CHAR_MAP[MODE_LOWER][c] = c - aLowerCharCode + 2;
}
CHAR_MAP[MODE_DIGIT][spaceCharCode] = 1;
const nineCharCode = StringUtils.getCharCode('9');
const zeroCharCode = StringUtils.getCharCode('0');
for (let c = zeroCharCode; c <= nineCharCode; c++) {
CHAR_MAP[MODE_DIGIT][c] = c - zeroCharCode + 2;
}
CHAR_MAP[MODE_DIGIT][commaCharCode] = 12;
CHAR_MAP[MODE_DIGIT][pointCharCode] = 13;
const mixedTable = [
'\x00',
' ',
'\x01',
'\x02',
'\x03',
'\x04',
'\x05',
'\x06',
'\x07',
'\b',
'\t',
'\n',
'\x0b',
'\f',
'\r',
'\x1b',
'\x1c',
'\x1d',
'\x1e',
'\x1f',
'@',
'\\',
'^',
'_',
'`',
'|',
'~',
'\x7f'
];
for (let i = 0; i < mixedTable.length; i++) {
CHAR_MAP[MODE_MIXED][StringUtils.getCharCode(mixedTable[i])] = i;
}
const punctTable = [
'\x00',
'\r',
'\x00',
'\x00',
'\x00',
'\x00',
'!',
'\'',
'#',
'$',
'%',
'&',
'\'',
'(',
')',
'*',
'+',
',',
'-',
'.',
'/',
':',
';',
'<',
'=',
'>',
'?',
'[',
']',
'{',
'}'
];
for (let i = 0; i < punctTable.length; i++) {
if (StringUtils.getCharCode(punctTable[i]) > 0) {
CHAR_MAP[MODE_PUNCT][StringUtils.getCharCode(punctTable[i])] = i;
}
}
return CHAR_MAP;
}
const CHAR_MAP = static_CHAR_MAP(Arrays.createInt32Array(5, 256));
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This produces nearly optimal encodings of text into the first-level of
* encoding used by Aztec code.
*
* It uses a dynamic algorithm. For each prefix of the string, it determines
* a set of encodings that could lead to this prefix. We repeatedly add a
* character and generate a new set of optimal encodings until we have read
* through the entire input.
*
* @author Frank Yellin
* @author Rustam Abdullaev
*/
/*public final*/ class HighLevelEncoder {
constructor(text) {
this.text = text;
}
/**
* @return text represented by this encoder encoded as a {@link BitArray}
*/
encode() {
const spaceCharCode = StringUtils.getCharCode(' ');
const lineBreakCharCode = StringUtils.getCharCode('\n');
let states = Collections.singletonList(State.INITIAL_STATE);
for (let index = 0; index < this.text.length; index++) {
let pairCode;
let nextChar = index + 1 < this.text.length ? this.text[index + 1] : 0;
switch (this.text[index]) {
case StringUtils.getCharCode('\r'):
pairCode = nextChar === lineBreakCharCode ? 2 : 0;
break;
case StringUtils.getCharCode('.'):
pairCode = nextChar === spaceCharCode ? 3 : 0;
break;
case StringUtils.getCharCode(','):
pairCode = nextChar === spaceCharCode ? 4 : 0;
break;
case StringUtils.getCharCode(':'):
pairCode = nextChar === spaceCharCode ? 5 : 0;
break;
default:
pairCode = 0;
}
if (pairCode > 0) {
// We have one of the four special PUNCT pairs. Treat them specially.
// Get a new set of states for the two new characters.
states = HighLevelEncoder.updateStateListForPair(states, index, pairCode);
index++;
}
else {
// Get a new set of states for the new character.
states = this.updateStateListForChar(states, index);
}
}
// We are left with a set of states. Find the shortest one.
const minState = Collections.min(states, (a, b) => {
return a.getBitCount() - b.getBitCount();
});
// Convert it to a bit array, and return.
return minState.toBitArray(this.text);
}
// We update a set of states for a new character by updating each state
// for the new character, merging the results, and then removing the
// non-optimal states.
updateStateListForChar(states, index) {
const result = [];
for (let state /*State*/ of states) {
this.updateStateForChar(state, index, result);
}
return HighLevelEncoder.simplifyStates(result);
}
// Return a set of states that represent the possible ways of updating this
// state for the next character. The resulting set of states are added to
// the "result" list.
updateStateForChar(state, index, result) {
let ch = (this.text[index] & 0xff);
let charInCurrentTable = CHAR_MAP[state.getMode()][ch] > 0;
let stateNoBinary = null;
for (let mode /*int*/ = 0; mode <= MODE_PUNCT; mode++) {
let charInMode = CHAR_MAP[mode][ch];
if (charInMode > 0) {
if (stateNoBinary == null) {
// Only create stateNoBinary the first time it's required.
stateNoBinary = state.endBinaryShift(index);
}
// Try generating the character by latching to its mode
if (!charInCurrentTable ||
mode === state.getMode() ||
mode === MODE_DIGIT) {
// If the character is in the current table, we don't want to latch to
// any other mode except possibly digit (which uses only 4 bits). Any
// other latch would be equally successful *after* this character, and
// so wouldn't save any bits.
const latchState = stateNoBinary.latchAndAppend(mode, charInMode);
result.push(latchState);
}
// Try generating the character by switching to its mode.
if (!charInCurrentTable &&
SHIFT_TABLE[state.getMode()][mode] >= 0) {
// It never makes sense to temporarily shift to another mode if the
// character exists in the current mode. That can never save bits.
const shiftState = stateNoBinary.shiftAndAppend(mode, charInMode);
result.push(shiftState);
}
}
}
if (state.getBinaryShiftByteCount() > 0 ||
CHAR_MAP[state.getMode()][ch] === 0) {
// It's never worthwhile to go into binary shift mode if you're not already
// in binary shift mode, and the character exists in your current mode.
// That can never save bits over just outputting the char in the current mode.
let binaryState = state.addBinaryShiftChar(index);
result.push(binaryState);
}
}
static updateStateListForPair(states, index, pairCode) {
const result = [];
for (let state /*State*/ of states) {
this.updateStateForPair(state, index, pairCode, result);
}
return this.simplifyStates(result);
}
static updateStateForPair(state, index, pairCode, result) {
let stateNoBinary = state.endBinaryShift(index);
// Possibility 1. Latch to C.MODE_PUNCT, and then append this code
result.push(stateNoBinary.latchAndAppend(MODE_PUNCT, pairCode));
if (state.getMode() !== MODE_PUNCT) {
// Possibility 2. Shift to C.MODE_PUNCT, and then append this code.
// Every state except C.MODE_PUNCT (handled above) can shift
result.push(stateNoBinary.shiftAndAppend(MODE_PUNCT, pairCode));
}
if (pairCode === 3 || pairCode === 4) {
// both characters are in DIGITS. Sometimes better to just add two digits
let digitState = stateNoBinary
.latchAndAppend(MODE_DIGIT, 16 - pairCode) // period or comma in DIGIT
.latchAndAppend(MODE_DIGIT, 1); // space in DIGIT
result.push(digitState);
}
if (state.getBinaryShiftByteCount() > 0) {
// It only makes sense to do the characters as binary if we're already
// in binary mode.
let binaryState = state
.addBinaryShiftChar(index)
.addBinaryShiftChar(index + 1);
result.push(binaryState);
}
}
static simplifyStates(states) {
let result = [];
for (const newState of states) {
let add = true;
for (const oldState of result) {
if (oldState.isBetterThanOrEqualTo(newState)) {
add = false;
break;
}
if (newState.isBetterThanOrEqualTo(oldState)) {
// iterator.remove();
result = result.filter(x => x !== oldState); // remove old state
}
}
if (add) {
result.push(newState);
}
}
return result;
}
}
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// package com.google.zxing.aztec.encoder;
// import com.google.zxing.common.BitArray;
// import com.google.zxing.common.BitMatrix;
// import com.google.zxing.common.reedsolomon.GenericGF;
// import com.google.zxing.common.reedsolomon.ReedSolomonEncoder;
/**
* Generates Aztec 2D barcodes.
*
* @author Rustam Abdullaev
*/
/*public final*/ class Encoder$1 {
constructor() {
}
/**
* Encodes the given binary content as an Aztec symbol
*
* @param data input data string
* @return Aztec symbol matrix with metadata
*/
static encodeBytes(data) {
return Encoder$1.encode(data, Encoder$1.DEFAULT_EC_PERCENT, Encoder$1.DEFAULT_AZTEC_LAYERS);
}
/**
* Encodes the given binary content as an Aztec symbol
*
* @param data input data string
* @param minECCPercent minimal percentage of error check words (According to ISO/IEC 24778:2008,
* a minimum of 23% + 3 words is recommended)
* @param userSpecifiedLayers if non-zero, a user-specified value for the number of layers
* @return Aztec symbol matrix with metadata
*/
static encode(data, minECCPercent, userSpecifiedLayers) {
// High-level encode
let bits = new HighLevelEncoder(data).encode();
// stuff bits and choose symbol size
let eccBits = Integer.truncDivision((bits.getSize() * minECCPercent), 100) + 11;
let totalSizeBits = bits.getSize() + eccBits;
let compact;
let layers;
let totalBitsInLayer;
let wordSize;
let stuffedBits;
if (userSpecifiedLayers !== Encoder$1.DEFAULT_AZTEC_LAYERS) {
compact = userSpecifiedLayers < 0;
layers = Math.abs(userSpecifiedLayers);
if (layers > (compact ? Encoder$1.MAX_NB_BITS_COMPACT : Encoder$1.MAX_NB_BITS)) {
throw new IllegalArgumentException(StringUtils.format('Illegal value %s for layers', userSpecifiedLayers));
}
totalBitsInLayer = Encoder$1.totalBitsInLayer(layers, compact);
wordSize = Encoder$1.WORD_SIZE[layers];
let usableBitsInLayers = totalBitsInLayer - (totalBitsInLayer % wordSize);
stuffedBits = Encoder$1.stuffBits(bits, wordSize);
if (stuffedBits.getSize() + eccBits > usableBitsInLayers) {
throw new IllegalArgumentException('Data to large for user specified layer');
}
if (compact && stuffedBits.getSize() > wordSize * 64) {
// Compact format only allows 64 data words, though C4 can hold more words than that
throw new IllegalArgumentException('Data to large for user specified layer');
}
}
else {
wordSize = 0;
stuffedBits = null;
// We look at the possible table sizes in the order Compact1, Compact2, Compact3,
// Compact4, Normal4,... Normal(i) for i < 4 isn't typically used since Compact(i+1)
// is the same size, but has more data.
for (let i /*int*/ = 0;; i++) {
if (i > Encoder$1.MAX_NB_BITS) {
throw new IllegalArgumentException('Data too large for an Aztec code');
}
compact = i <= 3;
layers = compact ? i + 1 : i;
totalBitsInLayer = Encoder$1.totalBitsInLayer(layers, compact);
if (totalSizeBits > totalBitsInLayer) {
continue;
}
// [Re]stuff the bits if this is the first opportunity, or if the
// wordSize has changed
if (stuffedBits == null || wordSize !== Encoder$1.WORD_SIZE[layers]) {
wordSize = Encoder$1.WORD_SIZE[layers];
stuffedBits = Encoder$1.stuffBits(bits, wordSize);
}
let usableBitsInLayers = totalBitsInLayer - (totalBitsInLayer % wordSize);
if (compact && stuffedBits.getSize() > wordSize * 64) {
// Compact format only allows 64 data words, though C4 can hold more words than that
continue;
}
if (stuffedBits.getSize() + eccBits <= usableBitsInLayers) {
break;
}
}
}
let messageBits = Encoder$1.generateCheckWords(stuffedBits, totalBitsInLayer, wordSize);
// generate mode message
let messageSizeInWords = stuffedBits.getSize() / wordSize;
let modeMessage = Encoder$1.generateModeMessage(compact, layers, messageSizeInWords);
// allocate symbol
let baseMatrixSize = (compact ? 11 : 14) + layers * 4; // not including alignment lines
let alignmentMap = new Int32Array(baseMatrixSize);
let matrixSize;
if (compact) {
// no alignment marks in compact mode, alignmentMap is a no-op
matrixSize = baseMatrixSize;
for (let i /*int*/ = 0; i < alignmentMap.length; i++) {
alignmentMap[i] = i;
}
}
else {
matrixSize = baseMatrixSize + 1 + 2 * Integer.truncDivision((Integer.truncDivision(baseMatrixSize, 2) - 1), 15);
let origCenter = Integer.truncDivision(baseMatrixSize, 2);
let center = Integer.truncDivision(matrixSize, 2);
for (let i /*int*/ = 0; i < origCenter; i++) {
let newOffset = i + Integer.truncDivision(i, 15);
alignmentMap[origCenter - i - 1] = center - newOffset - 1;
alignmentMap[origCenter + i] = center + newOffset + 1;
}
}
let matrix = new BitMatrix(matrixSize);
// draw data bits
for (let i /*int*/ = 0, rowOffset = 0; i < layers; i++) {
let rowSize = (layers - i) * 4 + (compact ? 9 : 12);
for (let j /*int*/ = 0; j < rowSize; j++) {
let columnOffset = j * 2;
for (let k /*int*/ = 0; k < 2; k++) {
if (messageBits.get(rowOffset + columnOffset + k)) {
matrix.set(alignmentMap[i * 2 + k], alignmentMap[i * 2 + j]);
}
if (messageBits.get(rowOffset + rowSize * 2 + columnOffset + k)) {
matrix.set(alignmentMap[i * 2 + j], alignmentMap[baseMatrixSize - 1 - i * 2 - k]);
}
if (messageBits.get(rowOffset + rowSize * 4 + columnOffset + k)) {
matrix.set(alignmentMap[baseMatrixSize - 1 - i * 2 - k], alignmentMap[baseMatrixSize - 1 - i * 2 - j]);
}
if (messageBits.get(rowOffset + rowSize * 6 + columnOffset + k)) {
matrix.set(alignmentMap[baseMatrixSize - 1 - i * 2 - j], alignmentMap[i * 2 + k]);
}
}
}
rowOffset += rowSize * 8;
}
// draw mode message
Encoder$1.drawModeMessage(matrix, compact, matrixSize, modeMessage);
// draw alignment marks
if (compact) {
Encoder$1.drawBullsEye(matrix, Integer.truncDivision(matrixSize, 2), 5);
}
else {
Encoder$1.drawBullsEye(matrix, Integer.truncDivision(matrixSize, 2), 7);
for (let i /*int*/ = 0, j = 0; i < Integer.truncDivision(baseMatrixSize, 2) - 1; i += 15, j += 16) {
for (let k /*int*/ = Integer.truncDivision(matrixSize, 2) & 1; k < matrixSize; k += 2) {
matrix.set(Integer.truncDivision(matrixSize, 2) - j, k);
matrix.set(Integer.truncDivision(matrixSize, 2) + j, k);
matrix.set(k, Integer.truncDivision(matrixSize, 2) - j);
matrix.set(k, Integer.truncDivision(matrixSize, 2) + j);
}
}
}
let aztec = new AztecCode();
aztec.setCompact(compact);
aztec.setSize(matrixSize);
aztec.setLayers(layers);
aztec.setCodeWords(messageSizeInWords);
aztec.setMatrix(matrix);
return aztec;
}
static drawBullsEye(matrix, center, size) {
for (let i /*int*/ = 0; i < size; i += 2) {
for (let j /*int*/ = center - i; j <= center + i; j++) {
matrix.set(j, center - i);
matrix.set(j, center + i);
matrix.set(center - i, j);
matrix.set(center + i, j);
}
}
matrix.set(center - size, center - size);
matrix.set(center - size + 1, center - size);
matrix.set(center - size, center - size + 1);
matrix.set(center + size, center - size);
matrix.set(center + size, center - size + 1);
matrix.set(center + size, center + size - 1);
}
static generateModeMessage(compact, layers, messageSizeInWords) {
let modeMessage = new BitArray();
if (compact) {
modeMessage.appendBits(layers - 1, 2);
modeMessage.appendBits(messageSizeInWords - 1, 6);
modeMessage = Encoder$1.generateCheckWords(modeMessage, 28, 4);
}
else {
modeMessage.appendBits(layers - 1, 5);
modeMessage.appendBits(messageSizeInWords - 1, 11);
modeMessage = Encoder$1.generateCheckWords(modeMessage, 40, 4);
}
return modeMessage;
}
static drawModeMessage(matrix, compact, matrixSize, modeMessage) {
let center = Integer.truncDivision(matrixSize, 2);
if (compact) {
for (let i /*int*/ = 0; i < 7; i++) {
let offset = center - 3 + i;
if (modeMessage.get(i)) {
matrix.set(offset, center - 5);
}
if (modeMessage.get(i + 7)) {
matrix.set(center + 5, offset);
}
if (modeMessage.get(20 - i)) {
matrix.set(offset, center + 5);
}
if (modeMessage.get(27 - i)) {
matrix.set(center - 5, offset);
}
}
}
else {
for (let i /*int*/ = 0; i < 10; i++) {
let offset = center - 5 + i + Integer.truncDivision(i, 5);
if (modeMessage.get(i)) {
matrix.set(offset, center - 7);
}
if (modeMessage.get(i + 10)) {
matrix.set(center + 7, offset);
}
if (modeMessage.get(29 - i)) {
matrix.set(offset, center + 7);
}
if (modeMessage.get(39 - i)) {
matrix.set(center - 7, offset);
}
}
}
}
static generateCheckWords(bitArray, totalBits, wordSize) {
// bitArray is guaranteed to be a multiple of the wordSize, so no padding needed
let messageSizeInWords = bitArray.getSize() / wordSize;
let rs = new ReedSolomonEncoder(Encoder$1.getGF(wordSize));
let totalWords = Integer.truncDivision(totalBits, wordSize);
let messageWords = Encoder$1.bitsToWords(bitArray, wordSize, totalWords);
rs.encode(messageWords, totalWords - messageSizeInWords);
let startPad = totalBits % wordSize;
let messageBits = new BitArray();
messageBits.appendBits(0, startPad);
for (const messageWord /*: int*/ of Array.from(messageWords)) {
messageBits.appendBits(messageWord, wordSize);
}
return messageBits;
}
static bitsToWords(stuffedBits, wordSize, totalWords) {
let message = new Int32Array(totalWords);
let i;
let n;
for (i = 0, n = stuffedBits.getSize() / wordSize; i < n; i++) {
let value = 0;
for (let j /*int*/ = 0; j < wordSize; j++) {
value |= stuffedBits.get(i * wordSize + j) ? (1 << wordSize - j - 1) : 0;
}
message[i] = value;
}
return message;
}
static getGF(wordSize) {
switch (wordSize) {
case 4:
return GenericGF.AZTEC_PARAM;
case 6:
return GenericGF.AZTEC_DATA_6;
case 8:
return GenericGF.AZTEC_DATA_8;
case 10:
return GenericGF.AZTEC_DATA_10;
case 12:
return GenericGF.AZTEC_DATA_12;
default:
throw new IllegalArgumentException('Unsupported word size ' + wordSize);
}
}
static stuffBits(bits, wordSize) {
let out = new BitArray();
let n = bits.getSize();
let mask = (1 << wordSize) - 2;
for (let i /*int*/ = 0; i < n; i += wordSize) {
let word = 0;
for (let j /*int*/ = 0; j < wordSize; j++) {
if (i + j >= n || bits.get(i + j)) {
word |= 1 << (wordSize - 1 - j);
}
}
if ((word & mask) === mask) {
out.appendBits(word & mask, wordSize);
i--;
}
else if ((word & mask) === 0) {
out.appendBits(word | 1, wordSize);
i--;
}
else {
out.appendBits(word, wordSize);
}
}
return out;
}
static totalBitsInLayer(layers, compact) {
return ((compact ? 88 : 112) + 16 * layers) * layers;
}
}
Encoder$1.DEFAULT_EC_PERCENT = 33; // default minimal percentage of error check words
Encoder$1.DEFAULT_AZTEC_LAYERS = 0;
Encoder$1.MAX_NB_BITS = 32;
Encoder$1.MAX_NB_BITS_COMPACT = 4;
Encoder$1.WORD_SIZE = Int32Array.from([
4, 6, 6, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12
]);
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Renders an Aztec code as a {@link BitMatrix}.
*/
/*public final*/ class AztecWriter {
// @Override
encode(contents, format, width, height) {
return this.encodeWithHints(contents, format, width, height, null);
}
// @Override
encodeWithHints(contents, format, width, height, hints) {
let charset = StandardCharsets.ISO_8859_1;
let eccPercent = Encoder$1.DEFAULT_EC_PERCENT;
let layers = Encoder$1.DEFAULT_AZTEC_LAYERS;
if (hints != null) {
if (hints.has(EncodeHintType$1.CHARACTER_SET)) {
charset = Charset.forName(hints.get(EncodeHintType$1.CHARACTER_SET).toString());
}
if (hints.has(EncodeHintType$1.ERROR_CORRECTION)) {
eccPercent = Integer.parseInt(hints.get(EncodeHintType$1.ERROR_CORRECTION).toString());
}
if (hints.has(EncodeHintType$1.AZTEC_LAYERS)) {
layers = Integer.parseInt(hints.get(EncodeHintType$1.AZTEC_LAYERS).toString());
}
}
return AztecWriter.encodeLayers(contents, format, width, height, charset, eccPercent, layers);
}
static encodeLayers(contents, format, width, height, charset, eccPercent, layers) {
if (format !== BarcodeFormat$1.AZTEC) {
throw new IllegalArgumentException('Can only encode AZTEC, but got ' + format);
}
let aztec = Encoder$1.encode(StringUtils.getBytes(contents, charset), eccPercent, layers);
return AztecWriter.renderResult(aztec, width, height);
}
static renderResult(code, width, height) {
let input = code.getMatrix();
if (input == null) {
throw new IllegalStateException();
}
let inputWidth = input.getWidth();
let inputHeight = input.getHeight();
let outputWidth = Math.max(width, inputWidth);
let outputHeight = Math.max(height, inputHeight);
let multiple = Math.min(outputWidth / inputWidth, outputHeight / inputHeight);
let leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
let topPadding = (outputHeight - (inputHeight * multiple)) / 2;
let output = new BitMatrix(outputWidth, outputHeight);
for (let inputY /*int*/ = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
// Write the contents of this row of the barcode
for (let inputX /*int*/ = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
if (input.get(inputX, inputY)) {
output.setRegion(outputX, outputY, multiple, multiple);
}
}
}
return output;
}
}
exports.AbstractExpandedDecoder = AbstractExpandedDecoder;
exports.ArgumentException = ArgumentException;
exports.ArithmeticException = ArithmeticException;
exports.AztecCode = AztecCode;
exports.AztecCodeReader = AztecReader;
exports.AztecCodeWriter = AztecWriter;
exports.AztecDecoder = Decoder;
exports.AztecDetector = Detector;
exports.AztecDetectorResult = AztecDetectorResult;
exports.AztecEncoder = Encoder$1;
exports.AztecHighLevelEncoder = HighLevelEncoder;
exports.AztecPoint = Point;
exports.BarcodeFormat = BarcodeFormat$1;
exports.Binarizer = Binarizer;
exports.BinaryBitmap = BinaryBitmap;
exports.BitArray = BitArray;
exports.BitMatrix = BitMatrix;
exports.BitSource = BitSource;
exports.BrowserAztecCodeReader = BrowserAztecCodeReader;
exports.BrowserBarcodeReader = BrowserBarcodeReader;
exports.BrowserCodeReader = BrowserCodeReader;
exports.BrowserDatamatrixCodeReader = BrowserDatamatrixCodeReader;
exports.BrowserMultiFormatReader = BrowserMultiFormatReader;
exports.BrowserPDF417Reader = BrowserPDF417Reader;
exports.BrowserQRCodeReader = BrowserQRCodeReader;
exports.BrowserQRCodeSvgWriter = BrowserQRCodeSvgWriter;
exports.CharacterSetECI = CharacterSetECI;
exports.ChecksumException = ChecksumException;
exports.Code128Reader = Code128Reader;
exports.Code39Reader = Code39Reader;
exports.DataMatrixDecodedBitStreamParser = DecodedBitStreamParser;
exports.DataMatrixReader = DataMatrixReader;
exports.DecodeHintType = DecodeHintType$1;
exports.DecoderResult = DecoderResult;
exports.DefaultGridSampler = DefaultGridSampler;
exports.DetectorResult = DetectorResult;
exports.EAN13Reader = EAN13Reader;
exports.EncodeHintType = EncodeHintType$1;
exports.Exception = Exception;
exports.FormatException = FormatException;
exports.GenericGF = GenericGF;
exports.GenericGFPoly = GenericGFPoly;
exports.GlobalHistogramBinarizer = GlobalHistogramBinarizer;
exports.GridSampler = GridSampler;
exports.GridSamplerInstance = GridSamplerInstance;
exports.HTMLCanvasElementLuminanceSource = HTMLCanvasElementLuminanceSource;
exports.HybridBinarizer = HybridBinarizer;
exports.ITFReader = ITFReader;
exports.IllegalArgumentException = IllegalArgumentException;
exports.IllegalStateException = IllegalStateException;
exports.InvertedLuminanceSource = InvertedLuminanceSource;
exports.LuminanceSource = LuminanceSource;
exports.MathUtils = MathUtils;
exports.MultiFormatOneDReader = MultiFormatOneDReader;
exports.MultiFormatReader = MultiFormatReader;
exports.MultiFormatWriter = MultiFormatWriter;
exports.NotFoundException = NotFoundException;
exports.OneDReader = OneDReader;
exports.PDF417DecodedBitStreamParser = DecodedBitStreamParser$2;
exports.PDF417DecoderErrorCorrection = ErrorCorrection;
exports.PDF417Reader = PDF417Reader;
exports.PDF417ResultMetadata = PDF417ResultMetadata;
exports.PerspectiveTransform = PerspectiveTransform;
exports.PlanarYUVLuminanceSource = PlanarYUVLuminanceSource;
exports.QRCodeByteMatrix = ByteMatrix;
exports.QRCodeDataMask = DataMask;
exports.QRCodeDecodedBitStreamParser = DecodedBitStreamParser$1;
exports.QRCodeDecoderErrorCorrectionLevel = ErrorCorrectionLevel;
exports.QRCodeDecoderFormatInformation = FormatInformation;
exports.QRCodeEncoder = Encoder;
exports.QRCodeEncoderQRCode = QRCode;
exports.QRCodeMaskUtil = MaskUtil;
exports.QRCodeMatrixUtil = MatrixUtil;
exports.QRCodeMode = Mode$1;
exports.QRCodeReader = QRCodeReader;
exports.QRCodeVersion = Version$1;
exports.QRCodeWriter = QRCodeWriter;
exports.RGBLuminanceSource = RGBLuminanceSource;
exports.RSS14Reader = RSS14Reader;
exports.RSSExpandedReader = RSSExpandedReader;
exports.ReaderException = ReaderException;
exports.ReedSolomonDecoder = ReedSolomonDecoder;
exports.ReedSolomonEncoder = ReedSolomonEncoder;
exports.ReedSolomonException = ReedSolomonException;
exports.Result = Result;
exports.ResultMetadataType = ResultMetadataType$1;
exports.ResultPoint = ResultPoint;
exports.StringUtils = StringUtils;
exports.UnsupportedOperationException = UnsupportedOperationException;
exports.VideoInputDevice = VideoInputDevice;
exports.WhiteRectangleDetector = WhiteRectangleDetector;
exports.WriterException = WriterException;
exports.ZXingArrays = Arrays;
exports.ZXingCharset = Charset;
exports.ZXingInteger = Integer;
exports.ZXingStandardCharsets = StandardCharsets;
exports.ZXingStringBuilder = StringBuilder;
exports.ZXingStringEncoding = StringEncoding;
exports.ZXingSystem = System;
exports.createAbstractExpandedDecoder = createDecoder;
Object.defineProperty(exports, '__esModule', { value: true });
})));
/***/ }),
/***/ 18139:
/***/ ((module) => {
// http://www.w3.org/TR/CSS21/grammar.html
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
var NEWLINE_REGEX = /\n/g;
var WHITESPACE_REGEX = /^\s*/;
// declaration
var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
var COLON_REGEX = /^:\s*/;
var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/;
var SEMICOLON_REGEX = /^[;\s]*/;
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
var TRIM_REGEX = /^\s+|\s+$/g;
// strings
var NEWLINE = '\n';
var FORWARD_SLASH = '/';
var ASTERISK = '*';
var EMPTY_STRING = '';
// types
var TYPE_COMMENT = 'comment';
var TYPE_DECLARATION = 'declaration';
/**
* @param {String} style
* @param {Object} [options]
* @return {Object[]}
* @throws {TypeError}
* @throws {Error}
*/
module.exports = function(style, options) {
if (typeof style !== 'string') {
throw new TypeError('First argument must be a string');
}
if (!style) return [];
options = options || {};
/**
* Positional.
*/
var lineno = 1;
var column = 1;
/**
* Update lineno and column based on `str`.
*
* @param {String} str
*/
function updatePosition(str) {
var lines = str.match(NEWLINE_REGEX);
if (lines) lineno += lines.length;
var i = str.lastIndexOf(NEWLINE);
column = ~i ? str.length - i : column + str.length;
}
/**
* Mark position and patch `node.position`.
*
* @return {Function}
*/
function position() {
var start = { line: lineno, column: column };
return function(node) {
node.position = new Position(start);
whitespace();
return node;
};
}
/**
* Store position information for a node.
*
* @constructor
* @property {Object} start
* @property {Object} end
* @property {undefined|String} source
*/
function Position(start) {
this.start = start;
this.end = { line: lineno, column: column };
this.source = options.source;
}
/**
* Non-enumerable source string.
*/
Position.prototype.content = style;
var errorsList = [];
/**
* Error `msg`.
*
* @param {String} msg
* @throws {Error}
*/
function error(msg) {
var err = new Error(
options.source + ':' + lineno + ':' + column + ': ' + msg
);
err.reason = msg;
err.filename = options.source;
err.line = lineno;
err.column = column;
err.source = style;
if (options.silent) {
errorsList.push(err);
} else {
throw err;
}
}
/**
* Match `re` and return captures.
*
* @param {RegExp} re
* @return {undefined|Array}
*/
function match(re) {
var m = re.exec(style);
if (!m) return;
var str = m[0];
updatePosition(str);
style = style.slice(str.length);
return m;
}
/**
* Parse whitespace.
*/
function whitespace() {
match(WHITESPACE_REGEX);
}
/**
* Parse comments.
*
* @param {Object[]} [rules]
* @return {Object[]}
*/
function comments(rules) {
var c;
rules = rules || [];
while ((c = comment())) {
if (c !== false) {
rules.push(c);
}
}
return rules;
}
/**
* Parse comment.
*
* @return {Object}
* @throws {Error}
*/
function comment() {
var pos = position();
if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
var i = 2;
while (
EMPTY_STRING != style.charAt(i) &&
(ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))
) {
++i;
}
i += 2;
if (EMPTY_STRING === style.charAt(i - 1)) {
return error('End of comment missing');
}
var str = style.slice(2, i - 2);
column += 2;
updatePosition(str);
style = style.slice(i);
column += 2;
return pos({
type: TYPE_COMMENT,
comment: str
});
}
/**
* Parse declaration.
*
* @return {Object}
* @throws {Error}
*/
function declaration() {
var pos = position();
// prop
var prop = match(PROPERTY_REGEX);
if (!prop) return;
comment();
// :
if (!match(COLON_REGEX)) return error("property missing ':'");
// val
var val = match(VALUE_REGEX);
var ret = pos({
type: TYPE_DECLARATION,
property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
value: val
? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))
: EMPTY_STRING
});
// ;
match(SEMICOLON_REGEX);
return ret;
}
/**
* Parse declarations.
*
* @return {Object[]}
*/
function declarations() {
var decls = [];
comments(decls);
// declarations
var decl;
while ((decl = declaration())) {
if (decl !== false) {
decls.push(decl);
comments(decls);
}
}
return decls;
}
whitespace();
return declarations();
};
/**
* Trim `str`.
*
* @param {String} str
* @return {String}
*/
function trim(str) {
return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
}
/***/ }),
/***/ 48738:
/***/ ((module) => {
/*!
* Determine if an object is a Buffer
*
* @author Feross Aboukhadijeh
* @license MIT
*/
module.exports = function isBuffer (obj) {
return obj != null && obj.constructor != null &&
typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
}
/***/ }),
/***/ 10646:
/***/ (function(module) {
/*! js-cookie v3.0.1 | MIT */
;
(function (global, factory) {
true ? module.exports = factory() :
0;
}(this, (function () { 'use strict';
/* eslint-disable no-var */
function assign (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
target[key] = source[key];
}
}
return target
}
/* eslint-enable no-var */
/* eslint-disable no-var */
var defaultConverter = {
read: function (value) {
if (value[0] === '"') {
value = value.slice(1, -1);
}
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
},
write: function (value) {
return encodeURIComponent(value).replace(
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
decodeURIComponent
)
}
};
/* eslint-enable no-var */
/* eslint-disable no-var */
function init (converter, defaultAttributes) {
function set (key, value, attributes) {
if (typeof document === 'undefined') {
return
}
attributes = assign({}, defaultAttributes, attributes);
if (typeof attributes.expires === 'number') {
attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
}
if (attributes.expires) {
attributes.expires = attributes.expires.toUTCString();
}
key = encodeURIComponent(key)
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
.replace(/[()]/g, escape);
var stringifiedAttributes = '';
for (var attributeName in attributes) {
if (!attributes[attributeName]) {
continue
}
stringifiedAttributes += '; ' + attributeName;
if (attributes[attributeName] === true) {
continue
}
// Considers RFC 6265 section 5.2:
// ...
// 3. If the remaining unparsed-attributes contains a %x3B (";")
// character:
// Consume the characters of the unparsed-attributes up to,
// not including, the first %x3B (";") character.
// ...
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
}
return (document.cookie =
key + '=' + converter.write(value, key) + stringifiedAttributes)
}
function get (key) {
if (typeof document === 'undefined' || (arguments.length && !key)) {
return
}
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all.
var cookies = document.cookie ? document.cookie.split('; ') : [];
var jar = {};
for (var i = 0; i < cookies.length; i++) {
var parts = cookies[i].split('=');
var value = parts.slice(1).join('=');
try {
var foundKey = decodeURIComponent(parts[0]);
jar[foundKey] = converter.read(value, foundKey);
if (key === foundKey) {
break
}
} catch (e) {}
}
return key ? jar[key] : jar
}
return Object.create(
{
set: set,
get: get,
remove: function (key, attributes) {
set(
key,
'',
assign({}, attributes, {
expires: -1
})
);
},
withAttributes: function (attributes) {
return init(this.converter, assign({}, this.attributes, attributes))
},
withConverter: function (converter) {
return init(assign({}, this.converter, converter), this.attributes)
}
},
{
attributes: { value: Object.freeze(defaultAttributes) },
converter: { value: Object.freeze(converter) }
}
)
}
var api = init(defaultConverter, { path: '/' });
/* eslint-enable no-var */
return api;
})));
/***/ }),
/***/ 62705:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var root = __webpack_require__(55639);
/** Built-in value references. */
var Symbol = root.Symbol;
module.exports = Symbol;
/***/ }),
/***/ 44239:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var Symbol = __webpack_require__(62705),
getRawTag = __webpack_require__(89607),
objectToString = __webpack_require__(2333);
/** `Object#toString` result references. */
var nullTag = '[object Null]',
undefinedTag = '[object Undefined]';
/** Built-in value references. */
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
/**
* The base implementation of `getTag` without fallbacks for buggy environments.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
function baseGetTag(value) {
if (value == null) {
return value === undefined ? undefinedTag : nullTag;
}
return (symToStringTag && symToStringTag in Object(value))
? getRawTag(value)
: objectToString(value);
}
module.exports = baseGetTag;
/***/ }),
/***/ 4107:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var trimmedEndIndex = __webpack_require__(67990);
/** Used to match leading whitespace. */
var reTrimStart = /^\s+/;
/**
* The base implementation of `_.trim`.
*
* @private
* @param {string} string The string to trim.
* @returns {string} Returns the trimmed string.
*/
function baseTrim(string) {
return string
? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
: string;
}
module.exports = baseTrim;
/***/ }),
/***/ 31957:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g;
module.exports = freeGlobal;
/***/ }),
/***/ 89607:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var Symbol = __webpack_require__(62705);
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString = objectProto.toString;
/** Built-in value references. */
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
/**
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the raw `toStringTag`.
*/
function getRawTag(value) {
var isOwn = hasOwnProperty.call(value, symToStringTag),
tag = value[symToStringTag];
try {
value[symToStringTag] = undefined;
var unmasked = true;
} catch (e) {}
var result = nativeObjectToString.call(value);
if (unmasked) {
if (isOwn) {
value[symToStringTag] = tag;
} else {
delete value[symToStringTag];
}
}
return result;
}
module.exports = getRawTag;
/***/ }),
/***/ 2333:
/***/ ((module) => {
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString = objectProto.toString;
/**
* Converts `value` to a string using `Object.prototype.toString`.
*
* @private
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
*/
function objectToString(value) {
return nativeObjectToString.call(value);
}
module.exports = objectToString;
/***/ }),
/***/ 55639:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var freeGlobal = __webpack_require__(31957);
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
module.exports = root;
/***/ }),
/***/ 67990:
/***/ ((module) => {
/** Used to match a single whitespace character. */
var reWhitespace = /\s/;
/**
* Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
* character of `string`.
*
* @private
* @param {string} string The string to inspect.
* @returns {number} Returns the index of the last non-whitespace character.
*/
function trimmedEndIndex(string) {
var index = string.length;
while (index-- && reWhitespace.test(string.charAt(index))) {}
return index;
}
module.exports = trimmedEndIndex;
/***/ }),
/***/ 23279:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var isObject = __webpack_require__(13218),
now = __webpack_require__(7771),
toNumber = __webpack_require__(14841);
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max,
nativeMin = Math.min;
/**
* Creates a debounced function that delays invoking `func` until after `wait`
* milliseconds have elapsed since the last time the debounced function was
* invoked. The debounced function comes with a `cancel` method to cancel
* delayed `func` invocations and a `flush` method to immediately invoke them.
* Provide `options` to indicate whether `func` should be invoked on the
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
* with the last arguments provided to the debounced function. Subsequent
* calls to the debounced function return the result of the last `func`
* invocation.
*
* **Note:** If `leading` and `trailing` options are `true`, `func` is
* invoked on the trailing edge of the timeout only if the debounced function
* is invoked more than once during the `wait` timeout.
*
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
*
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.debounce` and `_.throttle`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to debounce.
* @param {number} [wait=0] The number of milliseconds to delay.
* @param {Object} [options={}] The options object.
* @param {boolean} [options.leading=false]
* Specify invoking on the leading edge of the timeout.
* @param {number} [options.maxWait]
* The maximum time `func` is allowed to be delayed before it's invoked.
* @param {boolean} [options.trailing=true]
* Specify invoking on the trailing edge of the timeout.
* @returns {Function} Returns the new debounced function.
* @example
*
* // Avoid costly calculations while the window size is in flux.
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
*
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
* jQuery(element).on('click', _.debounce(sendMail, 300, {
* 'leading': true,
* 'trailing': false
* }));
*
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
* var source = new EventSource('/stream');
* jQuery(source).on('message', debounced);
*
* // Cancel the trailing debounced invocation.
* jQuery(window).on('popstate', debounced.cancel);
*/
function debounce(func, wait, options) {
var lastArgs,
lastThis,
maxWait,
result,
timerId,
lastCallTime,
lastInvokeTime = 0,
leading = false,
maxing = false,
trailing = true;
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
wait = toNumber(wait) || 0;
if (isObject(options)) {
leading = !!options.leading;
maxing = 'maxWait' in options;
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
function invokeFunc(time) {
var args = lastArgs,
thisArg = lastThis;
lastArgs = lastThis = undefined;
lastInvokeTime = time;
result = func.apply(thisArg, args);
return result;
}
function leadingEdge(time) {
// Reset any `maxWait` timer.
lastInvokeTime = time;
// Start the timer for the trailing edge.
timerId = setTimeout(timerExpired, wait);
// Invoke the leading edge.
return leading ? invokeFunc(time) : result;
}
function remainingWait(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime,
timeWaiting = wait - timeSinceLastCall;
return maxing
? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
: timeWaiting;
}
function shouldInvoke(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime;
// Either this is the first call, activity has stopped and we're at the
// trailing edge, the system time has gone backwards and we're treating
// it as the trailing edge, or we've hit the `maxWait` limit.
return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
}
function timerExpired() {
var time = now();
if (shouldInvoke(time)) {
return trailingEdge(time);
}
// Restart the timer.
timerId = setTimeout(timerExpired, remainingWait(time));
}
function trailingEdge(time) {
timerId = undefined;
// Only invoke if we have `lastArgs` which means `func` has been
// debounced at least once.
if (trailing && lastArgs) {
return invokeFunc(time);
}
lastArgs = lastThis = undefined;
return result;
}
function cancel() {
if (timerId !== undefined) {
clearTimeout(timerId);
}
lastInvokeTime = 0;
lastArgs = lastCallTime = lastThis = timerId = undefined;
}
function flush() {
return timerId === undefined ? result : trailingEdge(now());
}
function debounced() {
var time = now(),
isInvoking = shouldInvoke(time);
lastArgs = arguments;
lastThis = this;
lastCallTime = time;
if (isInvoking) {
if (timerId === undefined) {
return leadingEdge(lastCallTime);
}
if (maxing) {
// Handle invocations in a tight loop.
clearTimeout(timerId);
timerId = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTime);
}
}
if (timerId === undefined) {
timerId = setTimeout(timerExpired, wait);
}
return result;
}
debounced.cancel = cancel;
debounced.flush = flush;
return debounced;
}
module.exports = debounce;
/***/ }),
/***/ 13218:
/***/ ((module) => {
/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
function isObject(value) {
var type = typeof value;
return value != null && (type == 'object' || type == 'function');
}
module.exports = isObject;
/***/ }),
/***/ 37005:
/***/ ((module) => {
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return value != null && typeof value == 'object';
}
module.exports = isObjectLike;
/***/ }),
/***/ 33448:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var baseGetTag = __webpack_require__(44239),
isObjectLike = __webpack_require__(37005);
/** `Object#toString` result references. */
var symbolTag = '[object Symbol]';
/**
* Checks if `value` is classified as a `Symbol` primitive or object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
* // => true
*
* _.isSymbol('abc');
* // => false
*/
function isSymbol(value) {
return typeof value == 'symbol' ||
(isObjectLike(value) && baseGetTag(value) == symbolTag);
}
module.exports = isSymbol;
/***/ }),
/***/ 7771:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var root = __webpack_require__(55639);
/**
* Gets the timestamp of the number of milliseconds that have elapsed since
* the Unix epoch (1 January 1970 00:00:00 UTC).
*
* @static
* @memberOf _
* @since 2.4.0
* @category Date
* @returns {number} Returns the timestamp.
* @example
*
* _.defer(function(stamp) {
* console.log(_.now() - stamp);
* }, _.now());
* // => Logs the number of milliseconds it took for the deferred invocation.
*/
var now = function() {
return root.Date.now();
};
module.exports = now;
/***/ }),
/***/ 23493:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var debounce = __webpack_require__(23279),
isObject = __webpack_require__(13218);
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**
* Creates a throttled function that only invokes `func` at most once per
* every `wait` milliseconds. The throttled function comes with a `cancel`
* method to cancel delayed `func` invocations and a `flush` method to
* immediately invoke them. Provide `options` to indicate whether `func`
* should be invoked on the leading and/or trailing edge of the `wait`
* timeout. The `func` is invoked with the last arguments provided to the
* throttled function. Subsequent calls to the throttled function return the
* result of the last `func` invocation.
*
* **Note:** If `leading` and `trailing` options are `true`, `func` is
* invoked on the trailing edge of the timeout only if the throttled function
* is invoked more than once during the `wait` timeout.
*
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
*
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.throttle` and `_.debounce`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to throttle.
* @param {number} [wait=0] The number of milliseconds to throttle invocations to.
* @param {Object} [options={}] The options object.
* @param {boolean} [options.leading=true]
* Specify invoking on the leading edge of the timeout.
* @param {boolean} [options.trailing=true]
* Specify invoking on the trailing edge of the timeout.
* @returns {Function} Returns the new throttled function.
* @example
*
* // Avoid excessively updating the position while scrolling.
* jQuery(window).on('scroll', _.throttle(updatePosition, 100));
*
* // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
* var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
* jQuery(element).on('click', throttled);
*
* // Cancel the trailing throttled invocation.
* jQuery(window).on('popstate', throttled.cancel);
*/
function throttle(func, wait, options) {
var leading = true,
trailing = true;
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
if (isObject(options)) {
leading = 'leading' in options ? !!options.leading : leading;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
return debounce(func, wait, {
'leading': leading,
'maxWait': wait,
'trailing': trailing
});
}
module.exports = throttle;
/***/ }),
/***/ 14841:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var baseTrim = __webpack_require__(4107),
isObject = __webpack_require__(13218),
isSymbol = __webpack_require__(33448);
/** Used as references for various `Number` constants. */
var NAN = 0 / 0;
/** Used to detect bad signed hexadecimal string values. */
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
/** Used to detect binary string values. */
var reIsBinary = /^0b[01]+$/i;
/** Used to detect octal string values. */
var reIsOctal = /^0o[0-7]+$/i;
/** Built-in method references without a dependency on `root`. */
var freeParseInt = parseInt;
/**
* Converts `value` to a number.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to process.
* @returns {number} Returns the number.
* @example
*
* _.toNumber(3.2);
* // => 3.2
*
* _.toNumber(Number.MIN_VALUE);
* // => 5e-324
*
* _.toNumber(Infinity);
* // => Infinity
*
* _.toNumber('3.2');
* // => 3.2
*/
function toNumber(value) {
if (typeof value == 'number') {
return value;
}
if (isSymbol(value)) {
return NAN;
}
if (isObject(value)) {
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
value = isObject(other) ? (other + '') : other;
}
if (typeof value != 'string') {
return value === 0 ? value : +value;
}
value = baseTrim(value);
var isBinary = reIsBinary.test(value);
return (isBinary || reIsOctal.test(value))
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
: (reIsBadHex.test(value) ? NAN : +value);
}
module.exports = toNumber;
/***/ }),
/***/ 70631:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var hasMap = typeof Map === 'function' && Map.prototype;
var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
var mapForEach = hasMap && Map.prototype.forEach;
var hasSet = typeof Set === 'function' && Set.prototype;
var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null;
var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null;
var setForEach = hasSet && Set.prototype.forEach;
var hasWeakMap = typeof WeakMap === 'function' && WeakMap.prototype;
var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
var hasWeakSet = typeof WeakSet === 'function' && WeakSet.prototype;
var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
var hasWeakRef = typeof WeakRef === 'function' && WeakRef.prototype;
var weakRefDeref = hasWeakRef ? WeakRef.prototype.deref : null;
var booleanValueOf = Boolean.prototype.valueOf;
var objectToString = Object.prototype.toString;
var functionToString = Function.prototype.toString;
var $match = String.prototype.match;
var $slice = String.prototype.slice;
var $replace = String.prototype.replace;
var $toUpperCase = String.prototype.toUpperCase;
var $toLowerCase = String.prototype.toLowerCase;
var $test = RegExp.prototype.test;
var $concat = Array.prototype.concat;
var $join = Array.prototype.join;
var $arrSlice = Array.prototype.slice;
var $floor = Math.floor;
var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
var gOPS = Object.getOwnPropertySymbols;
var symToString = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol.prototype.toString : null;
var hasShammedSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'object';
// ie, `has-tostringtag/shams
var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (typeof Symbol.toStringTag === hasShammedSymbols ? 'object' : 'symbol')
? Symbol.toStringTag
: null;
var isEnumerable = Object.prototype.propertyIsEnumerable;
var gPO = (typeof Reflect === 'function' ? Reflect.getPrototypeOf : Object.getPrototypeOf) || (
[].__proto__ === Array.prototype // eslint-disable-line no-proto
? function (O) {
return O.__proto__; // eslint-disable-line no-proto
}
: null
);
function addNumericSeparator(num, str) {
if (
num === Infinity
|| num === -Infinity
|| num !== num
|| (num && num > -1000 && num < 1000)
|| $test.call(/e/, str)
) {
return str;
}
var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
if (typeof num === 'number') {
var int = num < 0 ? -$floor(-num) : $floor(num); // trunc(num)
if (int !== num) {
var intStr = String(int);
var dec = $slice.call(str, intStr.length + 1);
return $replace.call(intStr, sepRegex, '$&_') + '.' + $replace.call($replace.call(dec, /([0-9]{3})/g, '$&_'), /_$/, '');
}
}
return $replace.call(str, sepRegex, '$&_');
}
var utilInspect = __webpack_require__(24654);
var inspectCustom = utilInspect.custom;
var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null;
module.exports = function inspect_(obj, options, depth, seen) {
var opts = options || {};
if (has(opts, 'quoteStyle') && (opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double')) {
throw new TypeError('option "quoteStyle" must be "single" or "double"');
}
if (
has(opts, 'maxStringLength') && (typeof opts.maxStringLength === 'number'
? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity
: opts.maxStringLength !== null
)
) {
throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');
}
var customInspect = has(opts, 'customInspect') ? opts.customInspect : true;
if (typeof customInspect !== 'boolean' && customInspect !== 'symbol') {
throw new TypeError('option "customInspect", if provided, must be `true`, `false`, or `\'symbol\'`');
}
if (
has(opts, 'indent')
&& opts.indent !== null
&& opts.indent !== '\t'
&& !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)
) {
throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');
}
if (has(opts, 'numericSeparator') && typeof opts.numericSeparator !== 'boolean') {
throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');
}
var numericSeparator = opts.numericSeparator;
if (typeof obj === 'undefined') {
return 'undefined';
}
if (obj === null) {
return 'null';
}
if (typeof obj === 'boolean') {
return obj ? 'true' : 'false';
}
if (typeof obj === 'string') {
return inspectString(obj, opts);
}
if (typeof obj === 'number') {
if (obj === 0) {
return Infinity / obj > 0 ? '0' : '-0';
}
var str = String(obj);
return numericSeparator ? addNumericSeparator(obj, str) : str;
}
if (typeof obj === 'bigint') {
var bigIntStr = String(obj) + 'n';
return numericSeparator ? addNumericSeparator(obj, bigIntStr) : bigIntStr;
}
var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
if (typeof depth === 'undefined') { depth = 0; }
if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
return isArray(obj) ? '[Array]' : '[Object]';
}
var indent = getIndent(opts, depth);
if (typeof seen === 'undefined') {
seen = [];
} else if (indexOf(seen, obj) >= 0) {
return '[Circular]';
}
function inspect(value, from, noIndent) {
if (from) {
seen = $arrSlice.call(seen);
seen.push(from);
}
if (noIndent) {
var newOpts = {
depth: opts.depth
};
if (has(opts, 'quoteStyle')) {
newOpts.quoteStyle = opts.quoteStyle;
}
return inspect_(value, newOpts, depth + 1, seen);
}
return inspect_(value, opts, depth + 1, seen);
}
if (typeof obj === 'function' && !isRegExp(obj)) { // in older engines, regexes are callable
var name = nameOf(obj);
var keys = arrObjKeys(obj, inspect);
return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']' + (keys.length > 0 ? ' { ' + $join.call(keys, ', ') + ' }' : '');
}
if (isSymbol(obj)) {
var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, '$1') : symToString.call(obj);
return typeof obj === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString;
}
if (isElement(obj)) {
var s = '<' + $toLowerCase.call(String(obj.nodeName));
var attrs = obj.attributes || [];
for (var i = 0; i < attrs.length; i++) {
s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts);
}
s += '>';
if (obj.childNodes && obj.childNodes.length) { s += '...'; }
s += '' + $toLowerCase.call(String(obj.nodeName)) + '>';
return s;
}
if (isArray(obj)) {
if (obj.length === 0) { return '[]'; }
var xs = arrObjKeys(obj, inspect);
if (indent && !singleLineValues(xs)) {
return '[' + indentedJoin(xs, indent) + ']';
}
return '[ ' + $join.call(xs, ', ') + ' ]';
}
if (isError(obj)) {
var parts = arrObjKeys(obj, inspect);
if (!('cause' in Error.prototype) && 'cause' in obj && !isEnumerable.call(obj, 'cause')) {
return '{ [' + String(obj) + '] ' + $join.call($concat.call('[cause]: ' + inspect(obj.cause), parts), ', ') + ' }';
}
if (parts.length === 0) { return '[' + String(obj) + ']'; }
return '{ [' + String(obj) + '] ' + $join.call(parts, ', ') + ' }';
}
if (typeof obj === 'object' && customInspect) {
if (inspectSymbol && typeof obj[inspectSymbol] === 'function' && utilInspect) {
return utilInspect(obj, { depth: maxDepth - depth });
} else if (customInspect !== 'symbol' && typeof obj.inspect === 'function') {
return obj.inspect();
}
}
if (isMap(obj)) {
var mapParts = [];
mapForEach.call(obj, function (value, key) {
mapParts.push(inspect(key, obj, true) + ' => ' + inspect(value, obj));
});
return collectionOf('Map', mapSize.call(obj), mapParts, indent);
}
if (isSet(obj)) {
var setParts = [];
setForEach.call(obj, function (value) {
setParts.push(inspect(value, obj));
});
return collectionOf('Set', setSize.call(obj), setParts, indent);
}
if (isWeakMap(obj)) {
return weakCollectionOf('WeakMap');
}
if (isWeakSet(obj)) {
return weakCollectionOf('WeakSet');
}
if (isWeakRef(obj)) {
return weakCollectionOf('WeakRef');
}
if (isNumber(obj)) {
return markBoxed(inspect(Number(obj)));
}
if (isBigInt(obj)) {
return markBoxed(inspect(bigIntValueOf.call(obj)));
}
if (isBoolean(obj)) {
return markBoxed(booleanValueOf.call(obj));
}
if (isString(obj)) {
return markBoxed(inspect(String(obj)));
}
if (!isDate(obj) && !isRegExp(obj)) {
var ys = arrObjKeys(obj, inspect);
var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
var protoTag = obj instanceof Object ? '' : 'null prototype';
var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? 'Object' : '';
var constructorTag = isPlainObject || typeof obj.constructor !== 'function' ? '' : obj.constructor.name ? obj.constructor.name + ' ' : '';
var tag = constructorTag + (stringTag || protoTag ? '[' + $join.call($concat.call([], stringTag || [], protoTag || []), ': ') + '] ' : '');
if (ys.length === 0) { return tag + '{}'; }
if (indent) {
return tag + '{' + indentedJoin(ys, indent) + '}';
}
return tag + '{ ' + $join.call(ys, ', ') + ' }';
}
return String(obj);
};
function wrapQuotes(s, defaultStyle, opts) {
var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'";
return quoteChar + s + quoteChar;
}
function quote(s) {
return $replace.call(String(s), /"/g, '"');
}
function isArray(obj) { return toStr(obj) === '[object Array]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
function isDate(obj) { return toStr(obj) === '[object Date]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
function isRegExp(obj) { return toStr(obj) === '[object RegExp]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
function isError(obj) { return toStr(obj) === '[object Error]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
function isString(obj) { return toStr(obj) === '[object String]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
function isNumber(obj) { return toStr(obj) === '[object Number]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
function isBoolean(obj) { return toStr(obj) === '[object Boolean]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
// Symbol and BigInt do have Symbol.toStringTag by spec, so that can't be used to eliminate false positives
function isSymbol(obj) {
if (hasShammedSymbols) {
return obj && typeof obj === 'object' && obj instanceof Symbol;
}
if (typeof obj === 'symbol') {
return true;
}
if (!obj || typeof obj !== 'object' || !symToString) {
return false;
}
try {
symToString.call(obj);
return true;
} catch (e) {}
return false;
}
function isBigInt(obj) {
if (!obj || typeof obj !== 'object' || !bigIntValueOf) {
return false;
}
try {
bigIntValueOf.call(obj);
return true;
} catch (e) {}
return false;
}
var hasOwn = Object.prototype.hasOwnProperty || function (key) { return key in this; };
function has(obj, key) {
return hasOwn.call(obj, key);
}
function toStr(obj) {
return objectToString.call(obj);
}
function nameOf(f) {
if (f.name) { return f.name; }
var m = $match.call(functionToString.call(f), /^function\s*([\w$]+)/);
if (m) { return m[1]; }
return null;
}
function indexOf(xs, x) {
if (xs.indexOf) { return xs.indexOf(x); }
for (var i = 0, l = xs.length; i < l; i++) {
if (xs[i] === x) { return i; }
}
return -1;
}
function isMap(x) {
if (!mapSize || !x || typeof x !== 'object') {
return false;
}
try {
mapSize.call(x);
try {
setSize.call(x);
} catch (s) {
return true;
}
return x instanceof Map; // core-js workaround, pre-v2.5.0
} catch (e) {}
return false;
}
function isWeakMap(x) {
if (!weakMapHas || !x || typeof x !== 'object') {
return false;
}
try {
weakMapHas.call(x, weakMapHas);
try {
weakSetHas.call(x, weakSetHas);
} catch (s) {
return true;
}
return x instanceof WeakMap; // core-js workaround, pre-v2.5.0
} catch (e) {}
return false;
}
function isWeakRef(x) {
if (!weakRefDeref || !x || typeof x !== 'object') {
return false;
}
try {
weakRefDeref.call(x);
return true;
} catch (e) {}
return false;
}
function isSet(x) {
if (!setSize || !x || typeof x !== 'object') {
return false;
}
try {
setSize.call(x);
try {
mapSize.call(x);
} catch (m) {
return true;
}
return x instanceof Set; // core-js workaround, pre-v2.5.0
} catch (e) {}
return false;
}
function isWeakSet(x) {
if (!weakSetHas || !x || typeof x !== 'object') {
return false;
}
try {
weakSetHas.call(x, weakSetHas);
try {
weakMapHas.call(x, weakMapHas);
} catch (s) {
return true;
}
return x instanceof WeakSet; // core-js workaround, pre-v2.5.0
} catch (e) {}
return false;
}
function isElement(x) {
if (!x || typeof x !== 'object') { return false; }
if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {
return true;
}
return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function';
}
function inspectString(str, opts) {
if (str.length > opts.maxStringLength) {
var remaining = str.length - opts.maxStringLength;
var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : '');
return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer;
}
// eslint-disable-next-line no-control-regex
var s = $replace.call($replace.call(str, /(['\\])/g, '\\$1'), /[\x00-\x1f]/g, lowbyte);
return wrapQuotes(s, 'single', opts);
}
function lowbyte(c) {
var n = c.charCodeAt(0);
var x = {
8: 'b',
9: 't',
10: 'n',
12: 'f',
13: 'r'
}[n];
if (x) { return '\\' + x; }
return '\\x' + (n < 0x10 ? '0' : '') + $toUpperCase.call(n.toString(16));
}
function markBoxed(str) {
return 'Object(' + str + ')';
}
function weakCollectionOf(type) {
return type + ' { ? }';
}
function collectionOf(type, size, entries, indent) {
var joinedEntries = indent ? indentedJoin(entries, indent) : $join.call(entries, ', ');
return type + ' (' + size + ') {' + joinedEntries + '}';
}
function singleLineValues(xs) {
for (var i = 0; i < xs.length; i++) {
if (indexOf(xs[i], '\n') >= 0) {
return false;
}
}
return true;
}
function getIndent(opts, depth) {
var baseIndent;
if (opts.indent === '\t') {
baseIndent = '\t';
} else if (typeof opts.indent === 'number' && opts.indent > 0) {
baseIndent = $join.call(Array(opts.indent + 1), ' ');
} else {
return null;
}
return {
base: baseIndent,
prev: $join.call(Array(depth + 1), baseIndent)
};
}
function indentedJoin(xs, indent) {
if (xs.length === 0) { return ''; }
var lineJoiner = '\n' + indent.prev + indent.base;
return lineJoiner + $join.call(xs, ',' + lineJoiner) + '\n' + indent.prev;
}
function arrObjKeys(obj, inspect) {
var isArr = isArray(obj);
var xs = [];
if (isArr) {
xs.length = obj.length;
for (var i = 0; i < obj.length; i++) {
xs[i] = has(obj, i) ? inspect(obj[i], obj) : '';
}
}
var syms = typeof gOPS === 'function' ? gOPS(obj) : [];
var symMap;
if (hasShammedSymbols) {
symMap = {};
for (var k = 0; k < syms.length; k++) {
symMap['$' + syms[k]] = syms[k];
}
}
for (var key in obj) { // eslint-disable-line no-restricted-syntax
if (!has(obj, key)) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
if (isArr && String(Number(key)) === key && key < obj.length) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
if (hasShammedSymbols && symMap['$' + key] instanceof Symbol) {
// this is to prevent shammed Symbols, which are stored as strings, from being included in the string key section
continue; // eslint-disable-line no-restricted-syntax, no-continue
} else if ($test.call(/[^\w$]/, key)) {
xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));
} else {
xs.push(key + ': ' + inspect(obj[key], obj));
}
}
if (typeof gOPS === 'function') {
for (var j = 0; j < syms.length; j++) {
if (isEnumerable.call(obj, syms[j])) {
xs.push('[' + inspect(syms[j]) + ']: ' + inspect(obj[syms[j]], obj));
}
}
}
return xs;
}
/***/ }),
/***/ 34155:
/***/ ((module) => {
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function (name) { return [] }
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
/***/ }),
/***/ 92703:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var ReactPropTypesSecret = __webpack_require__(50414);
function emptyFunction() {}
function emptyFunctionWithReset() {}
emptyFunctionWithReset.resetWarningCache = emptyFunction;
module.exports = function() {
function shim(props, propName, componentName, location, propFullName, secret) {
if (secret === ReactPropTypesSecret) {
// It is still safe when called from React.
return;
}
var err = new Error(
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
'Use PropTypes.checkPropTypes() to call them. ' +
'Read more at http://fb.me/use-check-prop-types'
);
err.name = 'Invariant Violation';
throw err;
};
shim.isRequired = shim;
function getShim() {
return shim;
};
// Important!
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
var ReactPropTypes = {
array: shim,
bigint: shim,
bool: shim,
func: shim,
number: shim,
object: shim,
string: shim,
symbol: shim,
any: shim,
arrayOf: getShim,
element: shim,
elementType: shim,
instanceOf: getShim,
node: shim,
objectOf: getShim,
oneOf: getShim,
oneOfType: getShim,
shape: getShim,
exact: getShim,
checkPropTypes: emptyFunctionWithReset,
resetWarningCache: emptyFunction
};
ReactPropTypes.PropTypes = ReactPropTypes;
return ReactPropTypes;
};
/***/ }),
/***/ 45697:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
if (false) { var throwOnDirectAccess, ReactIs; } else {
// By explicitly using `prop-types` you are opting into new production behavior.
// http://fb.me/prop-types-in-prod
module.exports = __webpack_require__(92703)();
}
/***/ }),
/***/ 50414:
/***/ ((module) => {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
module.exports = ReactPropTypesSecret;
/***/ }),
/***/ 55798:
/***/ ((module) => {
"use strict";
var replace = String.prototype.replace;
var percentTwenties = /%20/g;
var Format = {
RFC1738: 'RFC1738',
RFC3986: 'RFC3986'
};
module.exports = {
'default': Format.RFC3986,
formatters: {
RFC1738: function (value) {
return replace.call(value, percentTwenties, '+');
},
RFC3986: function (value) {
return String(value);
}
},
RFC1738: Format.RFC1738,
RFC3986: Format.RFC3986
};
/***/ }),
/***/ 80129:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
var stringify = __webpack_require__(58261);
var parse = __webpack_require__(55235);
var formats = __webpack_require__(55798);
module.exports = {
formats: formats,
parse: parse,
stringify: stringify
};
/***/ }),
/***/ 55235:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
var utils = __webpack_require__(12769);
var has = Object.prototype.hasOwnProperty;
var isArray = Array.isArray;
var defaults = {
allowDots: false,
allowPrototypes: false,
allowSparse: false,
arrayLimit: 20,
charset: 'utf-8',
charsetSentinel: false,
comma: false,
decoder: utils.decode,
delimiter: '&',
depth: 5,
ignoreQueryPrefix: false,
interpretNumericEntities: false,
parameterLimit: 1000,
parseArrays: true,
plainObjects: false,
strictNullHandling: false
};
var interpretNumericEntities = function (str) {
return str.replace(/(\d+);/g, function ($0, numberStr) {
return String.fromCharCode(parseInt(numberStr, 10));
});
};
var parseArrayValue = function (val, options) {
if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
return val.split(',');
}
return val;
};
// This is what browsers will submit when the ✓ character occurs in an
// application/x-www-form-urlencoded body and the encoding of the page containing
// the form is iso-8859-1, or when the submitted form has an accept-charset
// attribute of iso-8859-1. Presumably also with other charsets that do not contain
// the ✓ character, such as us-ascii.
var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('✓')
// These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓')
var parseValues = function parseQueryStringValues(str, options) {
var obj = {};
var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
var parts = cleanStr.split(options.delimiter, limit);
var skipIndex = -1; // Keep track of where the utf8 sentinel was found
var i;
var charset = options.charset;
if (options.charsetSentinel) {
for (i = 0; i < parts.length; ++i) {
if (parts[i].indexOf('utf8=') === 0) {
if (parts[i] === charsetSentinel) {
charset = 'utf-8';
} else if (parts[i] === isoSentinel) {
charset = 'iso-8859-1';
}
skipIndex = i;
i = parts.length; // The eslint settings do not allow break;
}
}
}
for (i = 0; i < parts.length; ++i) {
if (i === skipIndex) {
continue;
}
var part = parts[i];
var bracketEqualsPos = part.indexOf(']=');
var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
var key, val;
if (pos === -1) {
key = options.decoder(part, defaults.decoder, charset, 'key');
val = options.strictNullHandling ? null : '';
} else {
key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key');
val = utils.maybeMap(
parseArrayValue(part.slice(pos + 1), options),
function (encodedVal) {
return options.decoder(encodedVal, defaults.decoder, charset, 'value');
}
);
}
if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
val = interpretNumericEntities(val);
}
if (part.indexOf('[]=') > -1) {
val = isArray(val) ? [val] : val;
}
if (has.call(obj, key)) {
obj[key] = utils.combine(obj[key], val);
} else {
obj[key] = val;
}
}
return obj;
};
var parseObject = function (chain, val, options, valuesParsed) {
var leaf = valuesParsed ? val : parseArrayValue(val, options);
for (var i = chain.length - 1; i >= 0; --i) {
var obj;
var root = chain[i];
if (root === '[]' && options.parseArrays) {
obj = [].concat(leaf);
} else {
obj = options.plainObjects ? Object.create(null) : {};
var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
var index = parseInt(cleanRoot, 10);
if (!options.parseArrays && cleanRoot === '') {
obj = { 0: leaf };
} else if (
!isNaN(index)
&& root !== cleanRoot
&& String(index) === cleanRoot
&& index >= 0
&& (options.parseArrays && index <= options.arrayLimit)
) {
obj = [];
obj[index] = leaf;
} else if (cleanRoot !== '__proto__') {
obj[cleanRoot] = leaf;
}
}
leaf = obj;
}
return leaf;
};
var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
if (!givenKey) {
return;
}
// Transform dot notation to bracket notation
var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
// The regex chunks
var brackets = /(\[[^[\]]*])/;
var child = /(\[[^[\]]*])/g;
// Get the parent
var segment = options.depth > 0 && brackets.exec(key);
var parent = segment ? key.slice(0, segment.index) : key;
// Stash the parent if it exists
var keys = [];
if (parent) {
// If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
if (!options.plainObjects && has.call(Object.prototype, parent)) {
if (!options.allowPrototypes) {
return;
}
}
keys.push(parent);
}
// Loop through children appending to the array until we hit depth
var i = 0;
while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
i += 1;
if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
if (!options.allowPrototypes) {
return;
}
}
keys.push(segment[1]);
}
// If there's a remainder, just add whatever is left
if (segment) {
keys.push('[' + key.slice(segment.index) + ']');
}
return parseObject(keys, val, options, valuesParsed);
};
var normalizeParseOptions = function normalizeParseOptions(opts) {
if (!opts) {
return defaults;
}
if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {
throw new TypeError('Decoder has to be a function.');
}
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
}
var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
return {
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse,
arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
charset: charset,
charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,
decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,
delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
// eslint-disable-next-line no-implicit-coercion, no-extra-parens
depth: (typeof opts.depth === 'number' || opts.depth === false) ? +opts.depth : defaults.depth,
ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,
parseArrays: opts.parseArrays !== false,
plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
};
};
module.exports = function (str, opts) {
var options = normalizeParseOptions(opts);
if (str === '' || str === null || typeof str === 'undefined') {
return options.plainObjects ? Object.create(null) : {};
}
var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
var obj = options.plainObjects ? Object.create(null) : {};
// Iterate over the keys and setup the new object
var keys = Object.keys(tempObj);
for (var i = 0; i < keys.length; ++i) {
var key = keys[i];
var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string');
obj = utils.merge(obj, newObj, options);
}
if (options.allowSparse === true) {
return obj;
}
return utils.compact(obj);
};
/***/ }),
/***/ 58261:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
var getSideChannel = __webpack_require__(37478);
var utils = __webpack_require__(12769);
var formats = __webpack_require__(55798);
var has = Object.prototype.hasOwnProperty;
var arrayPrefixGenerators = {
brackets: function brackets(prefix) {
return prefix + '[]';
},
comma: 'comma',
indices: function indices(prefix, key) {
return prefix + '[' + key + ']';
},
repeat: function repeat(prefix) {
return prefix;
}
};
var isArray = Array.isArray;
var split = String.prototype.split;
var push = Array.prototype.push;
var pushToArray = function (arr, valueOrArray) {
push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
};
var toISO = Date.prototype.toISOString;
var defaultFormat = formats['default'];
var defaults = {
addQueryPrefix: false,
allowDots: false,
charset: 'utf-8',
charsetSentinel: false,
delimiter: '&',
encode: true,
encoder: utils.encode,
encodeValuesOnly: false,
format: defaultFormat,
formatter: formats.formatters[defaultFormat],
// deprecated
indices: false,
serializeDate: function serializeDate(date) {
return toISO.call(date);
},
skipNulls: false,
strictNullHandling: false
};
var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
return typeof v === 'string'
|| typeof v === 'number'
|| typeof v === 'boolean'
|| typeof v === 'symbol'
|| typeof v === 'bigint';
};
var sentinel = {};
var stringify = function stringify(
object,
prefix,
generateArrayPrefix,
strictNullHandling,
skipNulls,
encoder,
filter,
sort,
allowDots,
serializeDate,
format,
formatter,
encodeValuesOnly,
charset,
sideChannel
) {
var obj = object;
var tmpSc = sideChannel;
var step = 0;
var findFlag = false;
while ((tmpSc = tmpSc.get(sentinel)) !== void undefined && !findFlag) {
// Where object last appeared in the ref tree
var pos = tmpSc.get(object);
step += 1;
if (typeof pos !== 'undefined') {
if (pos === step) {
throw new RangeError('Cyclic object value');
} else {
findFlag = true; // Break while
}
}
if (typeof tmpSc.get(sentinel) === 'undefined') {
step = 0;
}
}
if (typeof filter === 'function') {
obj = filter(prefix, obj);
} else if (obj instanceof Date) {
obj = serializeDate(obj);
} else if (generateArrayPrefix === 'comma' && isArray(obj)) {
obj = utils.maybeMap(obj, function (value) {
if (value instanceof Date) {
return serializeDate(value);
}
return value;
});
}
if (obj === null) {
if (strictNullHandling) {
return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key', format) : prefix;
}
obj = '';
}
if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) {
if (encoder) {
var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key', format);
if (generateArrayPrefix === 'comma' && encodeValuesOnly) {
var valuesArray = split.call(String(obj), ',');
var valuesJoined = '';
for (var i = 0; i < valuesArray.length; ++i) {
valuesJoined += (i === 0 ? '' : ',') + formatter(encoder(valuesArray[i], defaults.encoder, charset, 'value', format));
}
return [formatter(keyValue) + '=' + valuesJoined];
}
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))];
}
return [formatter(prefix) + '=' + formatter(String(obj))];
}
var values = [];
if (typeof obj === 'undefined') {
return values;
}
var objKeys;
if (generateArrayPrefix === 'comma' && isArray(obj)) {
// we need to join elements in
objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }];
} else if (isArray(filter)) {
objKeys = filter;
} else {
var keys = Object.keys(obj);
objKeys = sort ? keys.sort(sort) : keys;
}
for (var j = 0; j < objKeys.length; ++j) {
var key = objKeys[j];
var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
if (skipNulls && value === null) {
continue;
}
var keyPrefix = isArray(obj)
? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix
: prefix + (allowDots ? '.' + key : '[' + key + ']');
sideChannel.set(object, step);
var valueSideChannel = getSideChannel();
valueSideChannel.set(sentinel, sideChannel);
pushToArray(values, stringify(
value,
keyPrefix,
generateArrayPrefix,
strictNullHandling,
skipNulls,
encoder,
filter,
sort,
allowDots,
serializeDate,
format,
formatter,
encodeValuesOnly,
charset,
valueSideChannel
));
}
return values;
};
var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
if (!opts) {
return defaults;
}
if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {
throw new TypeError('Encoder has to be a function.');
}
var charset = opts.charset || defaults.charset;
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
}
var format = formats['default'];
if (typeof opts.format !== 'undefined') {
if (!has.call(formats.formatters, opts.format)) {
throw new TypeError('Unknown format option provided.');
}
format = opts.format;
}
var formatter = formats.formatters[format];
var filter = defaults.filter;
if (typeof opts.filter === 'function' || isArray(opts.filter)) {
filter = opts.filter;
}
return {
addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
charset: charset,
charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter,
encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode,
encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,
encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly,
filter: filter,
format: format,
formatter: formatter,
serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate,
skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls,
sort: typeof opts.sort === 'function' ? opts.sort : null,
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
};
};
module.exports = function (object, opts) {
var obj = object;
var options = normalizeStringifyOptions(opts);
var objKeys;
var filter;
if (typeof options.filter === 'function') {
filter = options.filter;
obj = filter('', obj);
} else if (isArray(options.filter)) {
filter = options.filter;
objKeys = filter;
}
var keys = [];
if (typeof obj !== 'object' || obj === null) {
return '';
}
var arrayFormat;
if (opts && opts.arrayFormat in arrayPrefixGenerators) {
arrayFormat = opts.arrayFormat;
} else if (opts && 'indices' in opts) {
arrayFormat = opts.indices ? 'indices' : 'repeat';
} else {
arrayFormat = 'indices';
}
var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
if (!objKeys) {
objKeys = Object.keys(obj);
}
if (options.sort) {
objKeys.sort(options.sort);
}
var sideChannel = getSideChannel();
for (var i = 0; i < objKeys.length; ++i) {
var key = objKeys[i];
if (options.skipNulls && obj[key] === null) {
continue;
}
pushToArray(keys, stringify(
obj[key],
key,
generateArrayPrefix,
options.strictNullHandling,
options.skipNulls,
options.encode ? options.encoder : null,
options.filter,
options.sort,
options.allowDots,
options.serializeDate,
options.format,
options.formatter,
options.encodeValuesOnly,
options.charset,
sideChannel
));
}
var joined = keys.join(options.delimiter);
var prefix = options.addQueryPrefix === true ? '?' : '';
if (options.charsetSentinel) {
if (options.charset === 'iso-8859-1') {
// encodeURIComponent('✓'), the "numeric entity" representation of a checkmark
prefix += 'utf8=%26%2310003%3B&';
} else {
// encodeURIComponent('✓')
prefix += 'utf8=%E2%9C%93&';
}
}
return joined.length > 0 ? prefix + joined : '';
};
/***/ }),
/***/ 12769:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
var formats = __webpack_require__(55798);
var has = Object.prototype.hasOwnProperty;
var isArray = Array.isArray;
var hexTable = (function () {
var array = [];
for (var i = 0; i < 256; ++i) {
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
}
return array;
}());
var compactQueue = function compactQueue(queue) {
while (queue.length > 1) {
var item = queue.pop();
var obj = item.obj[item.prop];
if (isArray(obj)) {
var compacted = [];
for (var j = 0; j < obj.length; ++j) {
if (typeof obj[j] !== 'undefined') {
compacted.push(obj[j]);
}
}
item.obj[item.prop] = compacted;
}
}
};
var arrayToObject = function arrayToObject(source, options) {
var obj = options && options.plainObjects ? Object.create(null) : {};
for (var i = 0; i < source.length; ++i) {
if (typeof source[i] !== 'undefined') {
obj[i] = source[i];
}
}
return obj;
};
var merge = function merge(target, source, options) {
/* eslint no-param-reassign: 0 */
if (!source) {
return target;
}
if (typeof source !== 'object') {
if (isArray(target)) {
target.push(source);
} else if (target && typeof target === 'object') {
if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
target[source] = true;
}
} else {
return [target, source];
}
return target;
}
if (!target || typeof target !== 'object') {
return [target].concat(source);
}
var mergeTarget = target;
if (isArray(target) && !isArray(source)) {
mergeTarget = arrayToObject(target, options);
}
if (isArray(target) && isArray(source)) {
source.forEach(function (item, i) {
if (has.call(target, i)) {
var targetItem = target[i];
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
target[i] = merge(targetItem, item, options);
} else {
target.push(item);
}
} else {
target[i] = item;
}
});
return target;
}
return Object.keys(source).reduce(function (acc, key) {
var value = source[key];
if (has.call(acc, key)) {
acc[key] = merge(acc[key], value, options);
} else {
acc[key] = value;
}
return acc;
}, mergeTarget);
};
var assign = function assignSingleSource(target, source) {
return Object.keys(source).reduce(function (acc, key) {
acc[key] = source[key];
return acc;
}, target);
};
var decode = function (str, decoder, charset) {
var strWithoutPlus = str.replace(/\+/g, ' ');
if (charset === 'iso-8859-1') {
// unescape never throws, no try...catch needed:
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
}
// utf-8
try {
return decodeURIComponent(strWithoutPlus);
} catch (e) {
return strWithoutPlus;
}
};
var encode = function encode(str, defaultEncoder, charset, kind, format) {
// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
// It has been adapted here for stricter adherence to RFC 3986
if (str.length === 0) {
return str;
}
var string = str;
if (typeof str === 'symbol') {
string = Symbol.prototype.toString.call(str);
} else if (typeof str !== 'string') {
string = String(str);
}
if (charset === 'iso-8859-1') {
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
});
}
var out = '';
for (var i = 0; i < string.length; ++i) {
var c = string.charCodeAt(i);
if (
c === 0x2D // -
|| c === 0x2E // .
|| c === 0x5F // _
|| c === 0x7E // ~
|| (c >= 0x30 && c <= 0x39) // 0-9
|| (c >= 0x41 && c <= 0x5A) // a-z
|| (c >= 0x61 && c <= 0x7A) // A-Z
|| (format === formats.RFC1738 && (c === 0x28 || c === 0x29)) // ( )
) {
out += string.charAt(i);
continue;
}
if (c < 0x80) {
out = out + hexTable[c];
continue;
}
if (c < 0x800) {
out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
continue;
}
if (c < 0xD800 || c >= 0xE000) {
out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
continue;
}
i += 1;
c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
/* eslint operator-linebreak: [2, "before"] */
out += hexTable[0xF0 | (c >> 18)]
+ hexTable[0x80 | ((c >> 12) & 0x3F)]
+ hexTable[0x80 | ((c >> 6) & 0x3F)]
+ hexTable[0x80 | (c & 0x3F)];
}
return out;
};
var compact = function compact(value) {
var queue = [{ obj: { o: value }, prop: 'o' }];
var refs = [];
for (var i = 0; i < queue.length; ++i) {
var item = queue[i];
var obj = item.obj[item.prop];
var keys = Object.keys(obj);
for (var j = 0; j < keys.length; ++j) {
var key = keys[j];
var val = obj[key];
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
queue.push({ obj: obj, prop: key });
refs.push(val);
}
}
}
compactQueue(queue);
return value;
};
var isRegExp = function isRegExp(obj) {
return Object.prototype.toString.call(obj) === '[object RegExp]';
};
var isBuffer = function isBuffer(obj) {
if (!obj || typeof obj !== 'object') {
return false;
}
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
};
var combine = function combine(a, b) {
return [].concat(a, b);
};
var maybeMap = function maybeMap(val, fn) {
if (isArray(val)) {
var mapped = [];
for (var i = 0; i < val.length; i += 1) {
mapped.push(fn(val[i]));
}
return mapped;
}
return fn(val);
};
module.exports = {
arrayToObject: arrayToObject,
assign: assign,
combine: combine,
compact: compact,
decode: decode,
encode: encode,
isBuffer: isBuffer,
isRegExp: isRegExp,
maybeMap: maybeMap,
merge: merge
};
/***/ }),
/***/ 9198:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
!function(e,t){ true?t(exports,__webpack_require__(67294),__webpack_require__(45697),__webpack_require__(94184),__webpack_require__(6881),__webpack_require__(7237),__webpack_require__(82266),__webpack_require__(24301),__webpack_require__(54937),__webpack_require__(57734),__webpack_require__(6151),__webpack_require__(61717),__webpack_require__(65984),__webpack_require__(34680),__webpack_require__(81570),__webpack_require__(32739),__webpack_require__(79185),__webpack_require__(30299),__webpack_require__(83071),__webpack_require__(94682),__webpack_require__(8530),__webpack_require__(33304),__webpack_require__(50522),__webpack_require__(96768),__webpack_require__(10010),__webpack_require__(23725),__webpack_require__(16992),__webpack_require__(49181),__webpack_require__(84938),__webpack_require__(24402),__webpack_require__(97418),__webpack_require__(37455),__webpack_require__(7862),__webpack_require__(35845),__webpack_require__(15134),__webpack_require__(9593),__webpack_require__(55744),__webpack_require__(42015),__webpack_require__(56981),__webpack_require__(86593),__webpack_require__(47159),__webpack_require__(33739),__webpack_require__(51609),__webpack_require__(2874),__webpack_require__(67828),__webpack_require__(72224),__webpack_require__(13476),__webpack_require__(93839),__webpack_require__(75684),__webpack_require__(3369),__webpack_require__(63868),__webpack_require__(87440),__webpack_require__(73109),__webpack_require__(45253),__webpack_require__(30688),__webpack_require__(43518),__webpack_require__(55483),__webpack_require__(85407),__webpack_require__(56824),__webpack_require__(14751),__webpack_require__(58949),__webpack_require__(73935),__webpack_require__(25025),__webpack_require__(47487)):0}(this,(function(e,t,r,n,a,o,s,i,p,c,l,d,u,h,f,m,y,g,D,v,k,w,b,S,M,C,_,Y,E,N,P,O,x,I,T,R,L,F,A,W,Q,q,K,B,H,j,V,U,$,z,G,J,X,Z,ee,te,re,ne,ae,oe,se,ie,pe,ce){"use strict";function le(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var de=le(t),ue=le(n),he=le(se),fe=le(ie);function me(e,t,r){return t=Ye(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Ne(e)}(e,ye()?Reflect.construct(t,r||[],Ye(e).constructor):t.apply(e,r))}function ye(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(ye=function(){return!!e})()}function ge(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function De(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r1&&void 0!==arguments[1]?arguments[1]:{},r=t.minDate,n=t.maxDate,a=t.excludeDates,o=t.excludeDateIntervals,s=t.includeDates,i=t.includeDateIntervals,p=t.filterDate;return pt(e,{minDate:r,maxDate:n})||a&&a.some((function(t){return Ue(e,t.date?t.date:t)}))||o&&o.some((function(t){var r=t.start,n=t.end;return re.isWithinInterval(e,{start:r,end:n})}))||s&&!s.some((function(t){return Ue(e,t)}))||i&&!i.some((function(t){var r=t.start,n=t.end;return re.isWithinInterval(e,{start:r,end:n})}))||p&&!p(Te(e))||!1}function tt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.excludeDates,n=t.excludeDateIntervals;return n&&n.length>0?n.some((function(t){var r=t.start,n=t.end;return re.isWithinInterval(e,{start:r,end:n})})):r&&r.some((function(t){return Ue(e,t.date?t.date:t)}))||!1}function rt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.minDate,n=t.maxDate,a=t.excludeDates,o=t.includeDates,s=t.filterDate;return pt(e,{minDate:K.startOfMonth(r),maxDate:U.endOfMonth(n)})||a&&a.some((function(t){return je(e,t)}))||o&&!o.some((function(t){return je(e,t)}))||s&&!s(Te(e))||!1}function nt(e,t,r,n){var a=Y.getYear(e),o=C.getMonth(e),s=Y.getYear(t),i=C.getMonth(t),p=Y.getYear(n);return a===s&&a===p?o<=r&&r<=i:a=r||pa:void 0}function at(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.minDate,n=t.maxDate,a=t.excludeDates,o=t.includeDates,s=t.filterDate;return pt(e,{minDate:r,maxDate:n})||a&&a.some((function(t){return Ve(e,t)}))||o&&!o.some((function(t){return Ve(e,t)}))||s&&!s(Te(e))||!1}function ot(e,t,r){if(!o.isValid(t)||!o.isValid(r))return!1;var n=Y.getYear(t),a=Y.getYear(r);return n<=e&&a>=e}function st(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.minDate,n=t.maxDate,a=t.excludeDates,o=t.includeDates,s=t.filterDate,i=new Date(e,0,1);return pt(i,{minDate:H.startOfYear(r),maxDate:$.endOfYear(n)})||a&&a.some((function(e){return He(i,e)}))||o&&!o.some((function(e){return He(i,e)}))||s&&!s(Te(i))||!1}function it(e,t,r,n){var a=Y.getYear(e),o=_.getQuarter(e),s=Y.getYear(t),i=_.getQuarter(t),p=Y.getYear(n);return a===s&&a===p?o<=r&&r<=i:a=r||pa:void 0}function pt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.minDate,n=t.maxDate;return r&&F.differenceInCalendarDays(e,r)<0||n&&F.differenceInCalendarDays(e,n)>0}function ct(e,t){return t.some((function(t){return w.getHours(t)===w.getHours(e)&&k.getMinutes(t)===k.getMinutes(e)}))}function lt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.excludeTimes,n=t.includeTimes,a=t.filterTime;return r&&ct(e,r)||n&&!ct(e,n)||a&&!a(e)||!1}function dt(e,t){var r=t.minTime,n=t.maxTime;if(!r||!n)throw new Error("Both minTime and maxTime props required");var a,o=Te(),s=O.setHours(P.setMinutes(o,k.getMinutes(e)),w.getHours(e)),i=O.setHours(P.setMinutes(o,k.getMinutes(r)),w.getHours(r)),p=O.setHours(P.setMinutes(o,k.getMinutes(n)),w.getHours(n));try{a=!re.isWithinInterval(s,{start:i,end:p})}catch(e){a=!1}return a}function ut(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.minDate,n=t.includeDates,a=y.subMonths(e,1);return r&&A.differenceInCalendarMonths(r,a)>0||n&&n.every((function(e){return A.differenceInCalendarMonths(e,a)>0}))||!1}function ht(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.maxDate,n=t.includeDates,a=d.addMonths(e,1);return r&&A.differenceInCalendarMonths(a,r)>0||n&&n.every((function(e){return A.differenceInCalendarMonths(a,e)>0}))||!1}function ft(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.minDate,n=t.includeDates,a=D.subYears(e,1);return r&&W.differenceInCalendarYears(r,a)>0||n&&n.every((function(e){return W.differenceInCalendarYears(e,a)>0}))||!1}function mt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.maxDate,n=t.includeDates,a=h.addYears(e,1);return r&&W.differenceInCalendarYears(a,r)>0||n&&n.every((function(e){return W.differenceInCalendarYears(a,e)>0}))||!1}function yt(e){var t=e.minDate,r=e.includeDates;if(r&&t){var n=r.filter((function(e){return F.differenceInCalendarDays(e,t)>=0}));return R.min(n)}return r?R.min(r):t}function gt(e){var t=e.maxDate,r=e.includeDates;if(r&&t){var n=r.filter((function(e){return F.differenceInCalendarDays(e,t)<=0}));return L.max(n)}return r?L.max(r):t}function Dt(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"react-datepicker__day--highlighted",r=new Map,n=0,o=e.length;n0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"react-datepicker__day--holidays",r=new Map;return e.forEach((function(e){var n=e.date,o=e.holidayName;if(a.isDate(n)){var s=Le(n,"MM.dd.yyyy"),i=r.get(s)||{};if(!("className"in i)||i.className!==t||(p=i.holidayNames,c=[o],p.length!==c.length||!p.every((function(e,t){return e===c[t]})))){var p,c;i.className=t;var l=i.holidayNames;i.holidayNames=l?[].concat(Pe(l),[o]):[o],r.set(s,i)}}})),r}function kt(e,t,r,n,a){for(var o=a.length,s=[],c=0;c1&&void 0!==arguments[1]?arguments[1]:xe,r=Math.ceil(Y.getYear(e)/t)*t;return{startPeriod:r-(t-1),endPeriod:r}}function St(e){var t=e.getSeconds(),r=e.getMilliseconds();return ne.toDate(e.getTime()-1e3*t-r)}function Mt(e){if(!a.isDate(e))throw new Error("Invalid date");var t=new Date(e);return t.setHours(0,0,0,0),t}function Ct(e,t){if(!a.isDate(e)||!a.isDate(t))throw new Error("Invalid date received");var r=Mt(e),n=Mt(t);return te.isBefore(r,n)}function _t(e,t,r,n){for(var a=[],o=0;o<2*t+1;o++){var s=e+t-o,i=!0;r&&(i=Y.getYear(r)<=s),n&&i&&(i=Y.getYear(n)>=s),i&&a.push(s)}return a}var Yt=function(e){function r(e){var n;we(this,r),Me(Ne(n=me(this,r,[e])),"renderOptions",(function(){var e=n.props.year,t=n.state.yearsList.map((function(t){return de.default.createElement("div",{className:e===t?"react-datepicker__year-option react-datepicker__year-option--selected_year":"react-datepicker__year-option",key:t,onClick:n.onChange.bind(Ne(n),t),"aria-selected":e===t?"true":void 0},e===t?de.default.createElement("span",{className:"react-datepicker__year-option--selected"},"✓"):"",t)})),r=n.props.minDate?Y.getYear(n.props.minDate):null,a=n.props.maxDate?Y.getYear(n.props.maxDate):null;return a&&n.state.yearsList.find((function(e){return e===a}))||t.unshift(de.default.createElement("div",{className:"react-datepicker__year-option",key:"upcoming",onClick:n.incrementYears},de.default.createElement("a",{className:"react-datepicker__navigation react-datepicker__navigation--years react-datepicker__navigation--years-upcoming"}))),r&&n.state.yearsList.find((function(e){return e===r}))||t.push(de.default.createElement("div",{className:"react-datepicker__year-option",key:"previous",onClick:n.decrementYears},de.default.createElement("a",{className:"react-datepicker__navigation react-datepicker__navigation--years react-datepicker__navigation--years-previous"}))),t})),Me(Ne(n),"onChange",(function(e){n.props.onChange(e)})),Me(Ne(n),"handleClickOutside",(function(){n.props.onCancel()})),Me(Ne(n),"shiftYears",(function(e){var t=n.state.yearsList.map((function(t){return t+e}));n.setState({yearsList:t})})),Me(Ne(n),"incrementYears",(function(){return n.shiftYears(1)})),Me(Ne(n),"decrementYears",(function(){return n.shiftYears(-1)}));var a=e.yearDropdownItemNumber,o=e.scrollableYearDropdown,s=a||(o?10:5);return n.state={yearsList:_t(n.props.year,s,n.props.minDate,n.props.maxDate)},n.dropdownRef=t.createRef(),n}return _e(r,e),Se(r,[{key:"componentDidMount",value:function(){var e=this.dropdownRef.current;if(e){var t=e.children?Array.from(e.children):null,r=t?t.find((function(e){return e.ariaSelected})):null;e.scrollTop=r?r.offsetTop+(r.clientHeight-e.clientHeight)/2:(e.scrollHeight-e.clientHeight)/2}}},{key:"render",value:function(){var e=ue.default({"react-datepicker__year-dropdown":!0,"react-datepicker__year-dropdown--scrollable":this.props.scrollableYearDropdown});return de.default.createElement("div",{className:e,ref:this.dropdownRef},this.renderOptions())}}]),r}(de.default.Component),Et=he.default(Yt),Nt=function(e){function t(){var e;we(this,t);for(var r=arguments.length,n=new Array(r),a=0;a0&&void 0!==arguments[0]?arguments[0]:{},n=!1;0===e.getTabIndex()&&!r.isInputFocused&&e.isSameDay(e.props.preSelection)&&(document.activeElement&&document.activeElement!==document.body||(n=!0),e.props.inline&&!e.props.shouldFocusDayInline&&(n=!1),e.props.containerRef&&e.props.containerRef.current&&e.props.containerRef.current.contains(document.activeElement)&&document.activeElement.classList.contains("react-datepicker__day")&&(n=!0),e.props.monthShowsDuplicateDaysEnd&&e.isAfterMonth()&&(n=!1),e.props.monthShowsDuplicateDaysStart&&e.isBeforeMonth()&&(n=!1)),n&&(null===(t=e.dayEl.current)||void 0===t||t.focus({preventScroll:!0}))})),Me(Ne(e),"renderDayContents",(function(){return e.props.monthShowsDuplicateDaysEnd&&e.isAfterMonth()||e.props.monthShowsDuplicateDaysStart&&e.isBeforeMonth()?null:e.props.renderDayContents?e.props.renderDayContents(S.getDate(e.props.day),e.props.day):S.getDate(e.props.day)})),Me(Ne(e),"render",(function(){return de.default.createElement("div",{ref:e.dayEl,className:e.getClassNames(e.props.day),onKeyDown:e.handleOnKeyDown,onClick:e.handleClick,onMouseEnter:e.handleMouseEnter,tabIndex:e.getTabIndex(),"aria-label":e.getAriaLabel(),role:"option",title:e.getTitle(),"aria-disabled":e.isDisabled(),"aria-current":e.isCurrentDay()?"date":void 0,"aria-selected":e.isSelected()||e.isInRange()},e.renderDayContents(),""!==e.getTitle()&&de.default.createElement("span",{className:"overlay"},e.getTitle()))})),e}return _e(t,e),Se(t,[{key:"componentDidMount",value:function(){this.handleFocusDay()}},{key:"componentDidUpdate",value:function(e){this.handleFocusDay(e)}}]),t}(de.default.Component),At=function(e){function t(){var e;we(this,t);for(var r=arguments.length,n=new Array(r),a=0;a0&&void 0!==arguments[0]?arguments[0]:{},r=!1;0===e.getTabIndex()&&!t.isInputFocused&&Ue(e.props.date,e.props.preSelection)&&(document.activeElement&&document.activeElement!==document.body||(r=!0),e.props.inline&&!e.props.shouldFocusDayInline&&(r=!1),e.props.containerRef&&e.props.containerRef.current&&e.props.containerRef.current.contains(document.activeElement)&&document.activeElement&&document.activeElement.classList.contains("react-datepicker__week-number")&&(r=!0)),r&&e.weekNumberEl.current&&e.weekNumberEl.current.focus({preventScroll:!0})})),e}return _e(t,e),Se(t,[{key:"componentDidMount",value:function(){this.handleFocusWeekNumber()}},{key:"componentDidUpdate",value:function(e){this.handleFocusWeekNumber(e)}},{key:"render",value:function(){var e=this.props,t=e.weekNumber,r=e.ariaLabelPrefix,n=void 0===r?"week ":r,a={"react-datepicker__week-number":!0,"react-datepicker__week-number--clickable":!!e.onClick,"react-datepicker__week-number--selected":Ue(this.props.date,this.props.selected),"react-datepicker__week-number--keyboard-selected":this.isKeyboardSelected()};return de.default.createElement("div",{ref:this.weekNumberEl,className:ue.default(a),"aria-label":"".concat(n," ").concat(this.props.weekNumber),onClick:this.handleClick,onKeyDown:this.handleOnKeyDown,tabIndex:this.getTabIndex()},t)}}],[{key:"defaultProps",get:function(){return{ariaLabelPrefix:"week "}}}]),t}(de.default.Component),Wt=function(e){function t(){var e;we(this,t);for(var r=arguments.length,n=new Array(r),a=0;a=6,i=!r&&!e.isWeekInMonth(o);if(s||i){if(!e.props.peekNextMonth)break;a=!0}}return t})),Me(Ne(e),"onMonthClick",(function(t,r){e.handleDayClick(Qe(x.setMonth(e.props.day,r)),t)})),Me(Ne(e),"onMonthMouseEnter",(function(t){e.handleDayMouseEnter(Qe(x.setMonth(e.props.day,t)))})),Me(Ne(e),"handleMonthNavigation",(function(t,r){e.isDisabled(r)||e.isExcluded(r)||(e.props.setPreSelection(r),e.MONTH_REFS[t].current&&e.MONTH_REFS[t].current.focus())})),Me(Ne(e),"onMonthKeyDown",(function(t,r){var n=e.props,a=n.selected,o=n.preSelection,s=n.disabledKeyboardNavigation,i=n.showTwoColumnMonthYearPicker,p=n.showFourColumnMonthYearPicker,c=n.setPreSelection,l=t.key;if("Tab"!==l&&t.preventDefault(),!s){var u=Ht(p,i),h=Bt[u].verticalNavigationOffset,f=Bt[u].grid;switch(l){case"Enter":e.onMonthClick(t,r),c(a);break;case"ArrowRight":e.handleMonthNavigation(11===r?0:r+1,d.addMonths(o,1));break;case"ArrowLeft":e.handleMonthNavigation(0===r?11:r-1,y.subMonths(o,1));break;case"ArrowUp":e.handleMonthNavigation(f[0].includes(r)?r+12-h:r-h,y.subMonths(o,h));break;case"ArrowDown":e.handleMonthNavigation(f[f.length-1].includes(r)?r-12+h:r+h,d.addMonths(o,h))}}})),Me(Ne(e),"onQuarterClick",(function(t,r){e.handleDayClick(Ke(I.setQuarter(e.props.day,r)),t)})),Me(Ne(e),"onQuarterMouseEnter",(function(t){e.handleDayMouseEnter(Ke(I.setQuarter(e.props.day,t)))})),Me(Ne(e),"handleQuarterNavigation",(function(t,r){e.isDisabled(r)||e.isExcluded(r)||(e.props.setPreSelection(r),e.QUARTER_REFS[t-1].current&&e.QUARTER_REFS[t-1].current.focus())})),Me(Ne(e),"onQuarterKeyDown",(function(t,r){var n=t.key;if(!e.props.disabledKeyboardNavigation)switch(n){case"Enter":e.onQuarterClick(t,r),e.props.setPreSelection(e.props.selected);break;case"ArrowRight":e.handleQuarterNavigation(4===r?1:r+1,u.addQuarters(e.props.preSelection,1));break;case"ArrowLeft":e.handleQuarterNavigation(1===r?4:r-1,g.subQuarters(e.props.preSelection,1))}})),Me(Ne(e),"getMonthClassNames",(function(t){var r=e.props,n=r.day,a=r.startDate,o=r.endDate,s=r.selected,i=r.minDate,p=r.maxDate,c=r.preSelection,l=r.monthClassName,d=r.excludeDates,u=r.includeDates,h=l?l(x.setMonth(n,t)):void 0,f=x.setMonth(n,t);return ue.default("react-datepicker__month-text","react-datepicker__month-".concat(t),h,{"react-datepicker__month-text--disabled":(i||p||d||u)&&rt(f,e.props),"react-datepicker__month-text--selected":e.isSelectedMonth(n,t,s),"react-datepicker__month-text--keyboard-selected":!e.props.disabledKeyboardNavigation&&C.getMonth(c)===t,"react-datepicker__month-text--in-selecting-range":e.isInSelectingRangeMonth(t),"react-datepicker__month-text--in-range":nt(a,o,t,n),"react-datepicker__month-text--range-start":e.isRangeStartMonth(t),"react-datepicker__month-text--range-end":e.isRangeEndMonth(t),"react-datepicker__month-text--selecting-range-start":e.isSelectingMonthRangeStart(t),"react-datepicker__month-text--selecting-range-end":e.isSelectingMonthRangeEnd(t),"react-datepicker__month-text--today":e.isCurrentMonth(n,t)})})),Me(Ne(e),"getTabIndex",(function(t){var r=C.getMonth(e.props.preSelection);return e.props.disabledKeyboardNavigation||t!==r?"-1":"0"})),Me(Ne(e),"getQuarterTabIndex",(function(t){var r=_.getQuarter(e.props.preSelection);return e.props.disabledKeyboardNavigation||t!==r?"-1":"0"})),Me(Ne(e),"getAriaLabel",(function(t){var r=e.props,n=r.chooseDayAriaLabelPrefix,a=void 0===n?"Choose":n,o=r.disabledDayAriaLabelPrefix,s=void 0===o?"Not available":o,i=r.day,p=x.setMonth(i,t),c=e.isDisabled(p)||e.isExcluded(p)?s:a;return"".concat(c," ").concat(Le(p,"MMMM yyyy"))})),Me(Ne(e),"getQuarterClassNames",(function(t){var r=e.props,n=r.day,a=r.startDate,o=r.endDate,s=r.selected,i=r.minDate,p=r.maxDate,c=r.preSelection,l=r.disabledKeyboardNavigation;return ue.default("react-datepicker__quarter-text","react-datepicker__quarter-".concat(t),{"react-datepicker__quarter-text--disabled":(i||p)&&at(I.setQuarter(n,t),e.props),"react-datepicker__quarter-text--selected":e.isSelectedQuarter(n,t,s),"react-datepicker__quarter-text--keyboard-selected":!l&&_.getQuarter(c)===t,"react-datepicker__quarter-text--in-selecting-range":e.isInSelectingRangeQuarter(t),"react-datepicker__quarter-text--in-range":it(a,o,t,n),"react-datepicker__quarter-text--range-start":e.isRangeStartQuarter(t),"react-datepicker__quarter-text--range-end":e.isRangeEndQuarter(t)})})),Me(Ne(e),"getMonthContent",(function(t){var r=e.props,n=r.showFullMonthYearPicker,a=r.renderMonthContent,o=r.locale,s=r.day,i=Ze(t,o),p=Xe(t,o);return a?a(t,i,p,s):n?p:i})),Me(Ne(e),"getQuarterContent",(function(t){var r=e.props,n=r.renderQuarterContent,a=function(e,t){return Le(I.setQuarter(Te(),e),"QQQ",t)}(t,r.locale);return n?n(t,a):a})),Me(Ne(e),"renderMonths",(function(){var t=e.props,r=t.showTwoColumnMonthYearPicker,n=t.showFourColumnMonthYearPicker,a=t.day,o=t.selected;return Bt[Ht(n,r)].grid.map((function(t,r){return de.default.createElement("div",{className:"react-datepicker__month-wrapper",key:r},t.map((function(t,r){return de.default.createElement("div",{ref:e.MONTH_REFS[t],key:r,onClick:function(r){e.onMonthClick(r,t)},onKeyDown:function(r){e.onMonthKeyDown(r,t)},onMouseEnter:function(){return e.onMonthMouseEnter(t)},tabIndex:e.getTabIndex(t),className:e.getMonthClassNames(t),role:"option","aria-label":e.getAriaLabel(t),"aria-current":e.isCurrentMonth(a,t)?"date":void 0,"aria-selected":e.isSelectedMonth(a,t,o)},e.getMonthContent(t))})))}))})),Me(Ne(e),"renderQuarters",(function(){var t=e.props,r=t.day,n=t.selected;return de.default.createElement("div",{className:"react-datepicker__quarter-wrapper"},[1,2,3,4].map((function(t,a){return de.default.createElement("div",{key:a,ref:e.QUARTER_REFS[a],role:"option",onClick:function(r){e.onQuarterClick(r,t)},onKeyDown:function(r){e.onQuarterKeyDown(r,t)},onMouseEnter:function(){return e.onQuarterMouseEnter(t)},className:e.getQuarterClassNames(t),"aria-selected":e.isSelectedQuarter(r,t,n),tabIndex:e.getQuarterTabIndex(t),"aria-current":e.isCurrentQuarter(r,t)?"date":void 0},e.getQuarterContent(t))})))})),Me(Ne(e),"getClassNames",(function(){var t=e.props,r=t.selectingDate,n=t.selectsStart,a=t.selectsEnd,o=t.showMonthYearPicker,s=t.showQuarterYearPicker,i=t.showWeekPicker;return ue.default("react-datepicker__month",{"react-datepicker__month--selecting-range":r&&(n||a)},{"react-datepicker__monthPicker":o},{"react-datepicker__quarterPicker":s},{"react-datepicker__weekPicker":i})})),e}return _e(t,e),Se(t,[{key:"render",value:function(){var e=this.props,t=e.showMonthYearPicker,r=e.showQuarterYearPicker,n=e.day,a=e.ariaLabelPrefix,o=void 0===a?"month ":a;return de.default.createElement("div",{className:this.getClassNames(),onMouseLeave:this.handleMouseLeave,"aria-label":"".concat(o," ").concat(Le(n,"yyyy-MM")),role:"listbox"},t?this.renderMonths():r?this.renderQuarters():this.renderWeeks())}}]),t}(de.default.Component),Vt=function(e){function t(){var e;we(this,t);for(var r=arguments.length,n=new Array(r),a=0;a0&&void 0!==arguments[0]?arguments[0]:{}).className||"").split(/\s+/);return Gt.some((function(t){return e.indexOf(t)>=0}))})(e.target)&&r.props.onDropdownFocus()})),Me(Ne(r),"getDateInView",(function(){var e=r.props,t=e.preSelection,n=e.selected,a=e.openToDate,o=yt(r.props),s=gt(r.props),i=Te(),p=a||n||t;return p||(o&&te.isBefore(i,o)?o:s&&ee.isAfter(i,s)?s:i)})),Me(Ne(r),"increaseMonth",(function(){r.setState((function(e){var t=e.date;return{date:d.addMonths(t,1)}}),(function(){return r.handleMonthChange(r.state.date)}))})),Me(Ne(r),"decreaseMonth",(function(){r.setState((function(e){var t=e.date;return{date:y.subMonths(t,1)}}),(function(){return r.handleMonthChange(r.state.date)}))})),Me(Ne(r),"handleDayClick",(function(e,t,n){r.props.onSelect(e,t,n),r.props.setPreSelection&&r.props.setPreSelection(e)})),Me(Ne(r),"handleDayMouseEnter",(function(e){r.setState({selectingDate:e}),r.props.onDayMouseEnter&&r.props.onDayMouseEnter(e)})),Me(Ne(r),"handleMonthMouseLeave",(function(){r.setState({selectingDate:null}),r.props.onMonthMouseLeave&&r.props.onMonthMouseLeave()})),Me(Ne(r),"handleYearMouseEnter",(function(e,t){r.setState({selectingDate:T.setYear(Te(),t)}),r.props.onYearMouseEnter&&r.props.onYearMouseEnter(e,t)})),Me(Ne(r),"handleYearMouseLeave",(function(e,t){r.props.onYearMouseLeave&&r.props.onYearMouseLeave(e,t)})),Me(Ne(r),"handleYearChange",(function(e){r.props.onYearChange&&(r.props.onYearChange(e),r.setState({isRenderAriaLiveMessage:!0})),r.props.adjustDateOnChange&&(r.props.onSelect&&r.props.onSelect(e),r.props.setOpen&&r.props.setOpen(!0)),r.props.setPreSelection&&r.props.setPreSelection(e)})),Me(Ne(r),"handleMonthChange",(function(e){r.handleCustomMonthChange(e),r.props.adjustDateOnChange&&(r.props.onSelect&&r.props.onSelect(e),r.props.setOpen&&r.props.setOpen(!0)),r.props.setPreSelection&&r.props.setPreSelection(e)})),Me(Ne(r),"handleCustomMonthChange",(function(e){r.props.onMonthChange&&(r.props.onMonthChange(e),r.setState({isRenderAriaLiveMessage:!0}))})),Me(Ne(r),"handleMonthYearChange",(function(e){r.handleYearChange(e),r.handleMonthChange(e)})),Me(Ne(r),"changeYear",(function(e){r.setState((function(t){var r=t.date;return{date:T.setYear(r,e)}}),(function(){return r.handleYearChange(r.state.date)}))})),Me(Ne(r),"changeMonth",(function(e){r.setState((function(t){var r=t.date;return{date:x.setMonth(r,e)}}),(function(){return r.handleMonthChange(r.state.date)}))})),Me(Ne(r),"changeMonthYear",(function(e){r.setState((function(t){var r=t.date;return{date:T.setYear(x.setMonth(r,C.getMonth(e)),Y.getYear(e))}}),(function(){return r.handleMonthYearChange(r.state.date)}))})),Me(Ne(r),"header",(function(){var e=We(arguments.length>0&&void 0!==arguments[0]?arguments[0]:r.state.date,r.props.locale,r.props.calendarStartDay),t=[];return r.props.showWeekNumbers&&t.push(de.default.createElement("div",{key:"W",className:"react-datepicker__day-name"},r.props.weekLabel||"#")),t.concat([0,1,2,3,4,5,6].map((function(t){var n=c.addDays(e,t),a=r.formatWeekday(n,r.props.locale),o=r.props.weekDayClassName?r.props.weekDayClassName(n):void 0;return de.default.createElement("div",{key:t,className:ue.default("react-datepicker__day-name",o)},a)})))})),Me(Ne(r),"formatWeekday",(function(e,t){return r.props.formatWeekDay?function(e,t,r){return t(Le(e,"EEEE",r))}(e,r.props.formatWeekDay,t):r.props.useWeekdaysShort?function(e,t){return Le(e,"EEE",t)}(e,t):function(e,t){return Le(e,"EEEEEE",t)}(e,t)})),Me(Ne(r),"decreaseYear",(function(){r.setState((function(e){var t=e.date;return{date:D.subYears(t,r.props.showYearPicker?r.props.yearItemNumber:1)}}),(function(){return r.handleYearChange(r.state.date)}))})),Me(Ne(r),"clearSelectingDate",(function(){r.setState({selectingDate:null})})),Me(Ne(r),"renderPreviousButton",(function(){if(!r.props.renderCustomHeader){var e;switch(!0){case r.props.showMonthYearPicker:e=ft(r.state.date,r.props);break;case r.props.showYearPicker:e=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.minDate,n=t.yearItemNumber,a=void 0===n?xe:n,o=bt(qe(D.subYears(e,a)),a).endPeriod,s=r&&Y.getYear(r);return s&&s>o||!1}(r.state.date,r.props);break;default:e=ut(r.state.date,r.props)}if((r.props.forceShowMonthNavigation||r.props.showDisabledMonthNavigation||!e)&&!r.props.showTimeSelectOnly){var t=["react-datepicker__navigation","react-datepicker__navigation--previous"],n=r.decreaseMonth;(r.props.showMonthYearPicker||r.props.showQuarterYearPicker||r.props.showYearPicker)&&(n=r.decreaseYear),e&&r.props.showDisabledMonthNavigation&&(t.push("react-datepicker__navigation--previous--disabled"),n=null);var a=r.props.showMonthYearPicker||r.props.showQuarterYearPicker||r.props.showYearPicker,o=r.props,s=o.previousMonthButtonLabel,i=o.previousYearButtonLabel,p=r.props,c=p.previousMonthAriaLabel,l=void 0===c?"string"==typeof s?s:"Previous Month":c,d=p.previousYearAriaLabel,u=void 0===d?"string"==typeof i?i:"Previous Year":d;return de.default.createElement("button",{type:"button",className:t.join(" "),onClick:n,onKeyDown:r.props.handleOnKeyDown,"aria-label":a?u:l},de.default.createElement("span",{className:["react-datepicker__navigation-icon","react-datepicker__navigation-icon--previous"].join(" ")},a?r.props.previousYearButtonLabel:r.props.previousMonthButtonLabel))}}})),Me(Ne(r),"increaseYear",(function(){r.setState((function(e){var t=e.date;return{date:h.addYears(t,r.props.showYearPicker?r.props.yearItemNumber:1)}}),(function(){return r.handleYearChange(r.state.date)}))})),Me(Ne(r),"renderNextButton",(function(){if(!r.props.renderCustomHeader){var e;switch(!0){case r.props.showMonthYearPicker:e=mt(r.state.date,r.props);break;case r.props.showYearPicker:e=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.maxDate,n=t.yearItemNumber,a=void 0===n?xe:n,o=bt(h.addYears(e,a),a).startPeriod,s=r&&Y.getYear(r);return s&&s0&&void 0!==arguments[0]?arguments[0]:r.state.date,t=["react-datepicker__current-month"];return r.props.showYearDropdown&&t.push("react-datepicker__current-month--hasYearDropdown"),r.props.showMonthDropdown&&t.push("react-datepicker__current-month--hasMonthDropdown"),r.props.showMonthYearDropdown&&t.push("react-datepicker__current-month--hasMonthYearDropdown"),de.default.createElement("div",{className:t.join(" ")},Le(e,r.props.dateFormat,r.props.locale))})),Me(Ne(r),"renderYearDropdown",(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(r.props.showYearDropdown&&!e)return de.default.createElement(Nt,{adjustDateOnChange:r.props.adjustDateOnChange,date:r.state.date,onSelect:r.props.onSelect,setOpen:r.props.setOpen,dropdownMode:r.props.dropdownMode,onChange:r.changeYear,minDate:r.props.minDate,maxDate:r.props.maxDate,year:Y.getYear(r.state.date),scrollableYearDropdown:r.props.scrollableYearDropdown,yearDropdownItemNumber:r.props.yearDropdownItemNumber})})),Me(Ne(r),"renderMonthDropdown",(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(r.props.showMonthDropdown&&!e)return de.default.createElement(xt,{dropdownMode:r.props.dropdownMode,locale:r.props.locale,onChange:r.changeMonth,month:C.getMonth(r.state.date),useShortMonthInDropdown:r.props.useShortMonthInDropdown})})),Me(Ne(r),"renderMonthYearDropdown",(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(r.props.showMonthYearDropdown&&!e)return de.default.createElement(Lt,{dropdownMode:r.props.dropdownMode,locale:r.props.locale,dateFormat:r.props.dateFormat,onChange:r.changeMonthYear,minDate:r.props.minDate,maxDate:r.props.maxDate,date:r.state.date,scrollableMonthYearDropdown:r.props.scrollableMonthYearDropdown})})),Me(Ne(r),"handleTodayButtonClick",(function(e){r.props.onSelect(Be(),e),r.props.setPreSelection&&r.props.setPreSelection(Be())})),Me(Ne(r),"renderTodayButton",(function(){if(r.props.todayButton&&!r.props.showTimeSelectOnly)return de.default.createElement("div",{className:"react-datepicker__today-button",onClick:function(e){return r.handleTodayButtonClick(e)}},r.props.todayButton)})),Me(Ne(r),"renderDefaultHeader",(function(e){var t=e.monthDate,n=e.i;return de.default.createElement("div",{className:"react-datepicker__header ".concat(r.props.showTimeSelect?"react-datepicker__header--has-time-select":"")},r.renderCurrentMonth(t),de.default.createElement("div",{className:"react-datepicker__header__dropdown react-datepicker__header__dropdown--".concat(r.props.dropdownMode),onFocus:r.handleDropdownFocus},r.renderMonthDropdown(0!==n),r.renderMonthYearDropdown(0!==n),r.renderYearDropdown(0!==n)),de.default.createElement("div",{className:"react-datepicker__day-names"},r.header(t)))})),Me(Ne(r),"renderCustomHeader",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.monthDate,n=e.i;if(r.props.showTimeSelect&&!r.state.monthContainer||r.props.showTimeSelectOnly)return null;var a=ut(r.state.date,r.props),o=ht(r.state.date,r.props),s=ft(r.state.date,r.props),i=mt(r.state.date,r.props),p=!r.props.showMonthYearPicker&&!r.props.showQuarterYearPicker&&!r.props.showYearPicker;return de.default.createElement("div",{className:"react-datepicker__header react-datepicker__header--custom",onFocus:r.props.onDropdownFocus},r.props.renderCustomHeader(De(De({},r.state),{},{customHeaderCount:n,monthDate:t,changeMonth:r.changeMonth,changeYear:r.changeYear,decreaseMonth:r.decreaseMonth,increaseMonth:r.increaseMonth,decreaseYear:r.decreaseYear,increaseYear:r.increaseYear,prevMonthButtonDisabled:a,nextMonthButtonDisabled:o,prevYearButtonDisabled:s,nextYearButtonDisabled:i})),p&&de.default.createElement("div",{className:"react-datepicker__day-names"},r.header(t)))})),Me(Ne(r),"renderYearHeader",(function(){var e=r.state.date,t=r.props,n=t.showYearPicker,a=bt(e,t.yearItemNumber),o=a.startPeriod,s=a.endPeriod;return de.default.createElement("div",{className:"react-datepicker__header react-datepicker-year-header"},n?"".concat(o," - ").concat(s):Y.getYear(e))})),Me(Ne(r),"renderHeader",(function(e){switch(!0){case void 0!==r.props.renderCustomHeader:return r.renderCustomHeader(e);case r.props.showMonthYearPicker||r.props.showQuarterYearPicker||r.props.showYearPicker:return r.renderYearHeader(e);default:return r.renderDefaultHeader(e)}})),Me(Ne(r),"renderMonths",(function(){var e;if(!r.props.showTimeSelectOnly&&!r.props.showYearPicker){for(var t=[],n=r.props.showPreviousMonths?r.props.monthsShown-1:0,a=y.subMonths(r.state.date,n),o=null!==(e=r.props.monthSelectedIn)&&void 0!==e?e:n,s=0;s0;t.push(de.default.createElement("div",{key:c,ref:function(e){r.monthContainer=e},className:"react-datepicker__month-container"},r.renderHeader({monthDate:p,i:s}),de.default.createElement(jt,{chooseDayAriaLabelPrefix:r.props.chooseDayAriaLabelPrefix,disabledDayAriaLabelPrefix:r.props.disabledDayAriaLabelPrefix,weekAriaLabelPrefix:r.props.weekAriaLabelPrefix,ariaLabelPrefix:r.props.monthAriaLabelPrefix,onChange:r.changeMonthYear,day:p,dayClassName:r.props.dayClassName,calendarStartDay:r.props.calendarStartDay,monthClassName:r.props.monthClassName,onDayClick:r.handleDayClick,handleOnKeyDown:r.props.handleOnDayKeyDown,onDayMouseEnter:r.handleDayMouseEnter,onMouseLeave:r.handleMonthMouseLeave,onWeekSelect:r.props.onWeekSelect,orderInDisplay:s,formatWeekNumber:r.props.formatWeekNumber,locale:r.props.locale,minDate:r.props.minDate,maxDate:r.props.maxDate,excludeDates:r.props.excludeDates,excludeDateIntervals:r.props.excludeDateIntervals,highlightDates:r.props.highlightDates,holidays:r.props.holidays,selectingDate:r.state.selectingDate,includeDates:r.props.includeDates,includeDateIntervals:r.props.includeDateIntervals,inline:r.props.inline,shouldFocusDayInline:r.props.shouldFocusDayInline,fixedHeight:r.props.fixedHeight,filterDate:r.props.filterDate,preSelection:r.props.preSelection,setPreSelection:r.props.setPreSelection,selected:r.props.selected,selectsStart:r.props.selectsStart,selectsEnd:r.props.selectsEnd,selectsRange:r.props.selectsRange,selectsDisabledDaysInRange:r.props.selectsDisabledDaysInRange,showWeekNumbers:r.props.showWeekNumbers,startDate:r.props.startDate,endDate:r.props.endDate,peekNextMonth:r.props.peekNextMonth,setOpen:r.props.setOpen,shouldCloseOnSelect:r.props.shouldCloseOnSelect,renderDayContents:r.props.renderDayContents,renderMonthContent:r.props.renderMonthContent,renderQuarterContent:r.props.renderQuarterContent,renderYearContent:r.props.renderYearContent,disabledKeyboardNavigation:r.props.disabledKeyboardNavigation,showMonthYearPicker:r.props.showMonthYearPicker,showFullMonthYearPicker:r.props.showFullMonthYearPicker,showTwoColumnMonthYearPicker:r.props.showTwoColumnMonthYearPicker,showFourColumnMonthYearPicker:r.props.showFourColumnMonthYearPicker,showYearPicker:r.props.showYearPicker,showQuarterYearPicker:r.props.showQuarterYearPicker,showWeekPicker:r.props.showWeekPicker,isInputFocused:r.props.isInputFocused,containerRef:r.containerRef,monthShowsDuplicateDaysEnd:l,monthShowsDuplicateDaysStart:u})))}return t}})),Me(Ne(r),"renderYears",(function(){if(!r.props.showTimeSelectOnly)return r.props.showYearPicker?de.default.createElement("div",{className:"react-datepicker__year--container"},r.renderHeader(),de.default.createElement(Ut,Ce({onDayClick:r.handleDayClick,selectingDate:r.state.selectingDate,clearSelectingDate:r.clearSelectingDate,date:r.state.date},r.props,{onYearMouseEnter:r.handleYearMouseEnter,onYearMouseLeave:r.handleYearMouseLeave}))):void 0})),Me(Ne(r),"renderTimeSection",(function(){if(r.props.showTimeSelect&&(r.state.monthContainer||r.props.showTimeSelectOnly))return de.default.createElement(Vt,{selected:r.props.selected,openToDate:r.props.openToDate,onChange:r.props.onTimeChange,timeClassName:r.props.timeClassName,format:r.props.timeFormat,includeTimes:r.props.includeTimes,intervals:r.props.timeIntervals,minTime:r.props.minTime,maxTime:r.props.maxTime,excludeTimes:r.props.excludeTimes,filterTime:r.props.filterTime,timeCaption:r.props.timeCaption,todayButton:r.props.todayButton,showMonthDropdown:r.props.showMonthDropdown,showMonthYearDropdown:r.props.showMonthYearDropdown,showYearDropdown:r.props.showYearDropdown,withPortal:r.props.withPortal,monthRef:r.state.monthContainer,injectTimes:r.props.injectTimes,locale:r.props.locale,handleOnKeyDown:r.props.handleOnKeyDown,showTimeSelectOnly:r.props.showTimeSelectOnly})})),Me(Ne(r),"renderInputTimeSection",(function(){var e=new Date(r.props.selected),t=Re(e)&&Boolean(r.props.selected)?"".concat(wt(e.getHours()),":").concat(wt(e.getMinutes())):"";if(r.props.showTimeInput)return de.default.createElement($t,{date:e,timeString:t,timeInputLabel:r.props.timeInputLabel,onChange:r.props.onTimeChange,customTimeInput:r.props.customTimeInput})})),Me(Ne(r),"renderAriaLiveRegion",(function(){var e,t=bt(r.state.date,r.props.yearItemNumber),n=t.startPeriod,a=t.endPeriod;return e=r.props.showYearPicker?"".concat(n," - ").concat(a):r.props.showMonthYearPicker||r.props.showQuarterYearPicker?Y.getYear(r.state.date):"".concat(Xe(C.getMonth(r.state.date),r.props.locale)," ").concat(Y.getYear(r.state.date)),de.default.createElement("span",{role:"alert","aria-live":"polite",className:"react-datepicker__aria-live"},r.state.isRenderAriaLiveMessage&&e)})),Me(Ne(r),"renderChildren",(function(){if(r.props.children)return de.default.createElement("div",{className:"react-datepicker__children-container"},r.props.children)})),r.containerRef=de.default.createRef(),r.state={date:r.getDateInView(),selectingDate:null,monthContainer:null,isRenderAriaLiveMessage:!1},r}return _e(t,e),Se(t,[{key:"componentDidMount",value:function(){var e=this;this.props.showTimeSelect&&(this.assignMonthContainer=void e.setState({monthContainer:e.monthContainer}))}},{key:"componentDidUpdate",value:function(e){var t=this;if(!this.props.preSelection||Ue(this.props.preSelection,e.preSelection)&&this.props.monthSelectedIn===e.monthSelectedIn)this.props.openToDate&&!Ue(this.props.openToDate,e.openToDate)&&this.setState({date:this.props.openToDate});else{var r=!je(this.state.date,this.props.preSelection);this.setState({date:this.props.preSelection},(function(){return r&&t.handleCustomMonthChange(t.state.date)}))}}},{key:"render",value:function(){var e=this.props.container||zt;return de.default.createElement("div",{style:{display:"contents"},ref:this.containerRef},de.default.createElement(e,{className:ue.default("react-datepicker",this.props.className,{"react-datepicker--time-only":this.props.showTimeSelectOnly})},this.renderAriaLiveRegion(),this.renderPreviousButton(),this.renderNextButton(),this.renderMonths(),this.renderYears(),this.renderTodayButton(),this.renderTimeSection(),this.renderInputTimeSection(),this.renderChildren()))}}],[{key:"defaultProps",get:function(){return{onDropdownFocus:function(){},monthsShown:1,forceShowMonthNavigation:!1,timeCaption:"Time",previousYearButtonLabel:"Previous Year",nextYearButtonLabel:"Next Year",previousMonthButtonLabel:"Previous Month",nextMonthButtonLabel:"Next Month",customTimeInput:null,yearItemNumber:xe}}}]),t}(de.default.Component),Xt=function(e){var t=e.icon,r=e.className,n=void 0===r?"":r,a=e.onClick,o="react-datepicker__calendar-icon";return de.default.isValidElement(t)?de.default.cloneElement(t,{className:"".concat(t.props.className||""," ").concat(o," ").concat(n),onClick:function(e){"function"==typeof t.props.onClick&&t.props.onClick(e),"function"==typeof a&&a(e)}}):"string"==typeof t?de.default.createElement("i",{className:"".concat(o," ").concat(t," ").concat(n),"aria-hidden":"true",onClick:a}):de.default.createElement("svg",{className:"".concat(o," ").concat(n),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",onClick:a},de.default.createElement("path",{d:"M96 32V64H48C21.5 64 0 85.5 0 112v48H448V112c0-26.5-21.5-48-48-48H352V32c0-17.7-14.3-32-32-32s-32 14.3-32 32V64H160V32c0-17.7-14.3-32-32-32S96 14.3 96 32zM448 192H0V464c0 26.5 21.5 48 48 48H400c26.5 0 48-21.5 48-48V192z"}))},Zt=function(e){function t(e){var r;return we(this,t),(r=me(this,t,[e])).el=document.createElement("div"),r}return _e(t,e),Se(t,[{key:"componentDidMount",value:function(){this.portalRoot=(this.props.portalHost||document).getElementById(this.props.portalId),this.portalRoot||(this.portalRoot=document.createElement("div"),this.portalRoot.setAttribute("id",this.props.portalId),(this.props.portalHost||document.body).appendChild(this.portalRoot)),this.portalRoot.appendChild(this.el)}},{key:"componentWillUnmount",value:function(){this.portalRoot.removeChild(this.el)}},{key:"render",value:function(){return fe.default.createPortal(this.props.children,this.el)}}]),t}(de.default.Component),er=function(e){return!e.disabled&&-1!==e.tabIndex},tr=function(e){function t(e){var r;return we(this,t),Me(Ne(r=me(this,t,[e])),"getTabChildren",(function(){return Array.prototype.slice.call(r.tabLoopRef.current.querySelectorAll("[tabindex], a, button, input, select, textarea"),1,-1).filter(er)})),Me(Ne(r),"handleFocusStart",(function(){var e=r.getTabChildren();e&&e.length>1&&e[e.length-1].focus()})),Me(Ne(r),"handleFocusEnd",(function(){var e=r.getTabChildren();e&&e.length>1&&e[0].focus()})),r.tabLoopRef=de.default.createRef(),r}return _e(t,e),Se(t,[{key:"render",value:function(){return this.props.enableTabLoop?de.default.createElement("div",{className:"react-datepicker__tab-loop",ref:this.tabLoopRef},de.default.createElement("div",{className:"react-datepicker__tab-loop__start",tabIndex:"0",onFocus:this.handleFocusStart}),this.props.children,de.default.createElement("div",{className:"react-datepicker__tab-loop__end",tabIndex:"0",onFocus:this.handleFocusEnd})):this.props.children}}],[{key:"defaultProps",get:function(){return{enableTabLoop:!0}}}]),t}(de.default.Component);var rr,nr,ar=function(e){function t(){return we(this,t),me(this,t,arguments)}return _e(t,e),Se(t,[{key:"render",value:function(){var e,t=this.props,r=t.className,n=t.wrapperClassName,a=t.hidePopper,o=t.popperComponent,s=t.targetComponent,i=t.enableTabLoop,p=t.popperOnKeyDown,c=t.portalId,l=t.portalHost,d=t.popperProps,u=t.showArrow;if(!a){var h=ue.default("react-datepicker-popper",r);e=de.default.createElement(tr,{enableTabLoop:i},de.default.createElement("div",{ref:d.refs.setFloating,style:d.floatingStyles,className:h,"data-placement":d.placement,onKeyDown:p},o,u&&de.default.createElement(pe.FloatingArrow,{ref:d.arrowRef,context:d.context,fill:"currentColor",strokeWidth:1,height:8,width:16,style:{transform:"translateY(-1px)"},className:"react-datepicker__triangle"})))}this.props.popperContainer&&(e=de.default.createElement(this.props.popperContainer,{},e)),c&&!a&&(e=de.default.createElement(Zt,{portalId:c,portalHost:l},e));var f=ue.default("react-datepicker-wrapper",n);return de.default.createElement(de.default.Fragment,null,de.default.createElement("div",{ref:d.refs.setReference,className:f},s),e)}}],[{key:"defaultProps",get:function(){return{hidePopper:!0}}}]),t}(de.default.Component),or=(rr=ar,(nr=function(e){var t=de.default.useRef(),r=pe.useFloating(De({open:!e.hidePopper,whileElementsMounted:pe.autoUpdate,placement:e.popperPlacement,middleware:[pe.flip({padding:15}),pe.offset(10),pe.arrow({element:t})].concat(Pe(e.popperModifiers))},e.popperProps));return de.default.createElement(rr,Ce({},e,{popperProps:De(De({},r),{},{arrowRef:t})}))}).defaultProps={popperModifiers:[],popperProps:{},hidePopper:!0},nr),sr="react-datepicker-ignore-onclickoutside",ir=he.default(Jt);var pr="Date input not valid.",cr=function(e){function t(e){var r;return we(this,t),Me(Ne(r=me(this,t,[e])),"getPreSelection",(function(){return r.props.openToDate?r.props.openToDate:r.props.selectsEnd&&r.props.startDate?r.props.startDate:r.props.selectsStart&&r.props.endDate?r.props.endDate:Te()})),Me(Ne(r),"modifyHolidays",(function(){var e;return null===(e=r.props.holidays)||void 0===e?void 0:e.reduce((function(e,t){var r=new Date(t.date);return o.isValid(r)?[].concat(Pe(e),[De(De({},t),{},{date:r})]):e}),[])})),Me(Ne(r),"calcInitialState",(function(){var e,t=r.getPreSelection(),n=yt(r.props),a=gt(r.props),o=n&&te.isBefore(t,Q.startOfDay(n))?n:a&&ee.isAfter(t,j.endOfDay(a))?a:t;return{open:r.props.startOpen||!1,preventFocus:!1,preSelection:null!==(e=r.props.selectsRange?r.props.startDate:r.props.selected)&&void 0!==e?e:o,highlightDates:Dt(r.props.highlightDates),focused:!1,shouldFocusDayInline:!1,isRenderAriaLiveMessage:!1}})),Me(Ne(r),"clearPreventFocusTimeout",(function(){r.preventFocusTimeout&&clearTimeout(r.preventFocusTimeout)})),Me(Ne(r),"setFocus",(function(){r.input&&r.input.focus&&r.input.focus({preventScroll:!0})})),Me(Ne(r),"setBlur",(function(){r.input&&r.input.blur&&r.input.blur(),r.cancelFocusInput()})),Me(Ne(r),"setOpen",(function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r.setState({open:e,preSelection:e&&r.state.open?r.state.preSelection:r.calcInitialState().preSelection,lastPreSelectChange:dr},(function(){e||r.setState((function(e){return{focused:!!t&&e.focused}}),(function(){!t&&r.setBlur(),r.setState({inputValue:null})}))}))})),Me(Ne(r),"inputOk",(function(){return a.isDate(r.state.preSelection)})),Me(Ne(r),"isCalendarOpen",(function(){return void 0===r.props.open?r.state.open&&!r.props.disabled&&!r.props.readOnly:r.props.open})),Me(Ne(r),"handleFocus",(function(e){r.state.preventFocus||(r.props.onFocus(e),r.props.preventOpenOnFocus||r.props.readOnly||r.setOpen(!0)),r.setState({focused:!0})})),Me(Ne(r),"sendFocusBackToInput",(function(){r.preventFocusTimeout&&r.clearPreventFocusTimeout(),r.setState({preventFocus:!0},(function(){r.preventFocusTimeout=setTimeout((function(){r.setFocus(),r.setState({preventFocus:!1})}))}))})),Me(Ne(r),"cancelFocusInput",(function(){clearTimeout(r.inputFocusTimeout),r.inputFocusTimeout=null})),Me(Ne(r),"deferFocusInput",(function(){r.cancelFocusInput(),r.inputFocusTimeout=setTimeout((function(){return r.setFocus()}),1)})),Me(Ne(r),"handleDropdownFocus",(function(){r.cancelFocusInput()})),Me(Ne(r),"handleBlur",(function(e){(!r.state.open||r.props.withPortal||r.props.showTimeInput)&&r.props.onBlur(e),r.setState({focused:!1})})),Me(Ne(r),"handleCalendarClickOutside",(function(e){r.props.inline||r.setOpen(!1),r.props.onClickOutside(e),r.props.withPortal&&e.preventDefault()})),Me(Ne(r),"handleChange",(function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&(d=ae.parse(o,i.slice(0,o.length),new Date,{useAdditionalWeekYearTokens:!0,useAdditionalDayOfYearTokens:!0})),Re(d)||(d=new Date(o))),Re(d)&&h?d:null));r.props.showTimeSelectOnly&&r.props.selected&&f&&!Ue(f,r.props.selected)&&(f=ce.set(r.props.selected,{hours:w.getHours(f),minutes:k.getMinutes(f),seconds:v.getSeconds(f)})),!f&&a.target.value||(r.props.showWeekPicker&&(f=We(f,r.props.locale,r.props.calendarStartDay)),r.setSelected(f,a,!0))}})),Me(Ne(r),"handleSelect",(function(e,t,n){if(r.props.shouldCloseOnSelect&&!r.props.showTimeSelect&&r.sendFocusBackToInput(),r.props.onChangeRaw&&r.props.onChangeRaw(t),r.props.showWeekPicker&&(e=We(e,r.props.locale,r.props.calendarStartDay)),r.setSelected(e,t,!1,n),r.props.showDateSelect&&r.setState({isRenderAriaLiveMessage:!0}),!r.props.shouldCloseOnSelect||r.props.showTimeSelect)r.setPreSelection(e);else if(!r.props.inline){r.props.selectsRange||r.setOpen(!1);var a=r.props,o=a.startDate,s=a.endDate;!o||s||Ct(e,o)||r.setOpen(!1)}})),Me(Ne(r),"setSelected",(function(e,t,n,a){var o=e;if(r.props.showYearPicker){if(null!==o&&st(Y.getYear(o),r.props))return}else if(r.props.showMonthYearPicker){if(null!==o&&rt(o,r.props))return}else if(null!==o&&et(o,r.props))return;var s=r.props,i=s.onChange,p=s.selectsRange,c=s.startDate,l=s.endDate;if(!$e(r.props.selected,o)||r.props.allowSameDay||p)if(null!==o&&(!r.props.selected||n&&(r.props.showTimeSelect||r.props.showTimeSelectOnly||r.props.showTimeInput)||(o=Ae(o,{hour:w.getHours(r.props.selected),minute:k.getMinutes(r.props.selected),second:v.getSeconds(r.props.selected)})),r.props.inline||r.setState({preSelection:o}),r.props.focusSelectedMonth||r.setState({monthSelectedIn:a})),p){var d=c&&!l,u=c&&l;!c&&!l?i([o,null],t):d&&(Ct(o,c)?i([o,null],t):i([c,o],t)),u&&i([o,null],t)}else i(o,t);n||(r.props.onSelect(o,t),r.setState({inputValue:null}))})),Me(Ne(r),"setPreSelection",(function(e){var t=void 0!==r.props.minDate,n=void 0!==r.props.maxDate,a=!0;if(e){r.props.showWeekPicker&&(e=We(e,r.props.locale,r.props.calendarStartDay));var o=Q.startOfDay(e);if(t&&n)a=ze(e,r.props.minDate,r.props.maxDate);else if(t){var s=Q.startOfDay(r.props.minDate);a=ee.isAfter(e,s)||$e(o,s)}else if(n){var i=j.endOfDay(r.props.maxDate);a=te.isBefore(e,i)||$e(o,i)}}a&&r.setState({preSelection:e})})),Me(Ne(r),"toggleCalendar",(function(){r.setOpen(!r.state.open)})),Me(Ne(r),"handleTimeChange",(function(e){var t=r.props.selected?r.props.selected:r.getPreSelection(),n=r.props.selected?e:Ae(t,{hour:w.getHours(e),minute:k.getMinutes(e)});r.setState({preSelection:n}),r.props.onChange(n),r.props.shouldCloseOnSelect&&(r.sendFocusBackToInput(),r.setOpen(!1)),r.props.showTimeInput&&r.setOpen(!0),(r.props.showTimeSelectOnly||r.props.showTimeSelect)&&r.setState({isRenderAriaLiveMessage:!0}),r.setState({inputValue:null})})),Me(Ne(r),"onInputClick",(function(){r.props.disabled||r.props.readOnly||r.setOpen(!0),r.props.onInputClick()})),Me(Ne(r),"onInputKeyDown",(function(e){r.props.onKeyDown(e);var t=e.key;if(r.state.open||r.props.inline||r.props.preventOpenOnFocus){if(r.state.open){if("ArrowDown"===t||"ArrowUp"===t){e.preventDefault();var n=r.props.showWeekPicker&&r.props.showWeekNumbers?'.react-datepicker__week-number[tabindex="0"]':'.react-datepicker__day[tabindex="0"]',a=r.calendar.componentNode&&r.calendar.componentNode.querySelector(n);return void(a&&a.focus({preventScroll:!0}))}var o=Te(r.state.preSelection);"Enter"===t?(e.preventDefault(),r.inputOk()&&r.state.lastPreSelectChange===dr?(r.handleSelect(o,e),!r.props.shouldCloseOnSelect&&r.setPreSelection(o)):r.setOpen(!1)):"Escape"===t?(e.preventDefault(),r.sendFocusBackToInput(),r.setOpen(!1)):"Tab"===t&&r.setOpen(!1),r.inputOk()||r.props.onInputError({code:1,msg:pr})}}else"ArrowDown"!==t&&"ArrowUp"!==t&&"Enter"!==t||r.onInputClick()})),Me(Ne(r),"onPortalKeyDown",(function(e){"Escape"===e.key&&(e.preventDefault(),r.setState({preventFocus:!0},(function(){r.setOpen(!1),setTimeout((function(){r.setFocus(),r.setState({preventFocus:!1})}))})))})),Me(Ne(r),"onDayKeyDown",(function(e){r.props.onKeyDown(e);var t,n=e.key,a=e.shiftKey,o=Te(r.state.preSelection);if("Enter"===n)e.preventDefault(),r.handleSelect(o,e),!r.props.shouldCloseOnSelect&&r.setPreSelection(o);else if("Escape"===n)e.preventDefault(),r.setOpen(!1),r.inputOk()||r.props.onInputError({code:1,msg:pr});else if(!r.props.disabledKeyboardNavigation){var s;switch(n){case"ArrowLeft":s=r.props.showWeekPicker?m.subWeeks(o,1):f.subDays(o,1);break;case"ArrowRight":s=r.props.showWeekPicker?l.addWeeks(o,1):c.addDays(o,1);break;case"ArrowUp":s=m.subWeeks(o,1);break;case"ArrowDown":s=l.addWeeks(o,1);break;case"PageUp":s=a?D.subYears(o,1):y.subMonths(o,1);break;case"PageDown":s=a?h.addYears(o,1):d.addMonths(o,1);break;case"Home":s=We(o,r.props.locale,r.props.calendarStartDay);break;case"End":t=o,s=V.endOfWeek(t);break;default:s=null}if(!s)return void(r.props.onInputError&&r.props.onInputError({code:1,msg:pr}));if(e.preventDefault(),r.setState({lastPreSelectChange:dr}),r.props.adjustDateOnChange&&r.setSelected(s),r.setPreSelection(s),r.props.inline){var i=C.getMonth(o),p=C.getMonth(s),u=Y.getYear(o),g=Y.getYear(s);i!==p||u!==g?r.setState({shouldFocusDayInline:!0}):r.setState({shouldFocusDayInline:!1})}}})),Me(Ne(r),"onPopperKeyDown",(function(e){"Escape"===e.key&&(e.preventDefault(),r.sendFocusBackToInput())})),Me(Ne(r),"onClearClick",(function(e){e&&e.preventDefault&&e.preventDefault(),r.sendFocusBackToInput(),r.props.selectsRange?r.props.onChange([null,null],e):r.props.onChange(null,e),r.setState({inputValue:null})})),Me(Ne(r),"clear",(function(){r.onClearClick()})),Me(Ne(r),"onScroll",(function(e){"boolean"==typeof r.props.closeOnScroll&&r.props.closeOnScroll?e.target!==document&&e.target!==document.documentElement&&e.target!==document.body||r.setOpen(!1):"function"==typeof r.props.closeOnScroll&&r.props.closeOnScroll(e)&&r.setOpen(!1)})),Me(Ne(r),"renderCalendar",(function(){return r.props.inline||r.isCalendarOpen()?de.default.createElement(ir,{ref:function(e){r.calendar=e},locale:r.props.locale,calendarStartDay:r.props.calendarStartDay,chooseDayAriaLabelPrefix:r.props.chooseDayAriaLabelPrefix,disabledDayAriaLabelPrefix:r.props.disabledDayAriaLabelPrefix,weekAriaLabelPrefix:r.props.weekAriaLabelPrefix,monthAriaLabelPrefix:r.props.monthAriaLabelPrefix,adjustDateOnChange:r.props.adjustDateOnChange,setOpen:r.setOpen,shouldCloseOnSelect:r.props.shouldCloseOnSelect,dateFormat:r.props.dateFormatCalendar,useWeekdaysShort:r.props.useWeekdaysShort,formatWeekDay:r.props.formatWeekDay,dropdownMode:r.props.dropdownMode,selected:r.props.selected,preSelection:r.state.preSelection,onSelect:r.handleSelect,onWeekSelect:r.props.onWeekSelect,openToDate:r.props.openToDate,minDate:r.props.minDate,maxDate:r.props.maxDate,selectsStart:r.props.selectsStart,selectsEnd:r.props.selectsEnd,selectsRange:r.props.selectsRange,startDate:r.props.startDate,endDate:r.props.endDate,excludeDates:r.props.excludeDates,excludeDateIntervals:r.props.excludeDateIntervals,filterDate:r.props.filterDate,onClickOutside:r.handleCalendarClickOutside,formatWeekNumber:r.props.formatWeekNumber,highlightDates:r.state.highlightDates,holidays:vt(r.modifyHolidays()),includeDates:r.props.includeDates,includeDateIntervals:r.props.includeDateIntervals,includeTimes:r.props.includeTimes,injectTimes:r.props.injectTimes,inline:r.props.inline,shouldFocusDayInline:r.state.shouldFocusDayInline,peekNextMonth:r.props.peekNextMonth,showMonthDropdown:r.props.showMonthDropdown,showPreviousMonths:r.props.showPreviousMonths,useShortMonthInDropdown:r.props.useShortMonthInDropdown,showMonthYearDropdown:r.props.showMonthYearDropdown,showWeekNumbers:r.props.showWeekNumbers,showYearDropdown:r.props.showYearDropdown,withPortal:r.props.withPortal,forceShowMonthNavigation:r.props.forceShowMonthNavigation,showDisabledMonthNavigation:r.props.showDisabledMonthNavigation,scrollableYearDropdown:r.props.scrollableYearDropdown,scrollableMonthYearDropdown:r.props.scrollableMonthYearDropdown,todayButton:r.props.todayButton,weekLabel:r.props.weekLabel,outsideClickIgnoreClass:sr,fixedHeight:r.props.fixedHeight,monthsShown:r.props.monthsShown,monthSelectedIn:r.state.monthSelectedIn,onDropdownFocus:r.handleDropdownFocus,onMonthChange:r.props.onMonthChange,onYearChange:r.props.onYearChange,dayClassName:r.props.dayClassName,weekDayClassName:r.props.weekDayClassName,monthClassName:r.props.monthClassName,timeClassName:r.props.timeClassName,showDateSelect:r.props.showDateSelect,showTimeSelect:r.props.showTimeSelect,showTimeSelectOnly:r.props.showTimeSelectOnly,onTimeChange:r.handleTimeChange,timeFormat:r.props.timeFormat,timeIntervals:r.props.timeIntervals,minTime:r.props.minTime,maxTime:r.props.maxTime,excludeTimes:r.props.excludeTimes,filterTime:r.props.filterTime,timeCaption:r.props.timeCaption,className:r.props.calendarClassName,container:r.props.calendarContainer,yearItemNumber:r.props.yearItemNumber,yearDropdownItemNumber:r.props.yearDropdownItemNumber,previousMonthAriaLabel:r.props.previousMonthAriaLabel,previousMonthButtonLabel:r.props.previousMonthButtonLabel,nextMonthAriaLabel:r.props.nextMonthAriaLabel,nextMonthButtonLabel:r.props.nextMonthButtonLabel,previousYearAriaLabel:r.props.previousYearAriaLabel,previousYearButtonLabel:r.props.previousYearButtonLabel,nextYearAriaLabel:r.props.nextYearAriaLabel,nextYearButtonLabel:r.props.nextYearButtonLabel,timeInputLabel:r.props.timeInputLabel,disabledKeyboardNavigation:r.props.disabledKeyboardNavigation,renderCustomHeader:r.props.renderCustomHeader,popperProps:r.props.popperProps,renderDayContents:r.props.renderDayContents,renderMonthContent:r.props.renderMonthContent,renderQuarterContent:r.props.renderQuarterContent,renderYearContent:r.props.renderYearContent,onDayMouseEnter:r.props.onDayMouseEnter,onMonthMouseLeave:r.props.onMonthMouseLeave,onYearMouseEnter:r.props.onYearMouseEnter,onYearMouseLeave:r.props.onYearMouseLeave,selectsDisabledDaysInRange:r.props.selectsDisabledDaysInRange,showTimeInput:r.props.showTimeInput,showMonthYearPicker:r.props.showMonthYearPicker,showFullMonthYearPicker:r.props.showFullMonthYearPicker,showTwoColumnMonthYearPicker:r.props.showTwoColumnMonthYearPicker,showFourColumnMonthYearPicker:r.props.showFourColumnMonthYearPicker,showYearPicker:r.props.showYearPicker,showQuarterYearPicker:r.props.showQuarterYearPicker,showWeekPicker:r.props.showWeekPicker,excludeScrollbar:r.props.excludeScrollbar,handleOnKeyDown:r.props.onKeyDown,handleOnDayKeyDown:r.onDayKeyDown,isInputFocused:r.state.focused,customTimeInput:r.props.customTimeInput,setPreSelection:r.setPreSelection},r.props.children):null})),Me(Ne(r),"renderAriaLiveRegion",(function(){var e,t=r.props,n=t.dateFormat,a=t.locale,o=r.props.showTimeInput||r.props.showTimeSelect?"PPPPp":"PPPP";return e=r.props.selectsRange?"Selected start date: ".concat(Fe(r.props.startDate,{dateFormat:o,locale:a}),". ").concat(r.props.endDate?"End date: "+Fe(r.props.endDate,{dateFormat:o,locale:a}):""):r.props.showTimeSelectOnly?"Selected time: ".concat(Fe(r.props.selected,{dateFormat:n,locale:a})):r.props.showYearPicker?"Selected year: ".concat(Fe(r.props.selected,{dateFormat:"yyyy",locale:a})):r.props.showMonthYearPicker?"Selected month: ".concat(Fe(r.props.selected,{dateFormat:"MMMM yyyy",locale:a})):r.props.showQuarterYearPicker?"Selected quarter: ".concat(Fe(r.props.selected,{dateFormat:"yyyy, QQQ",locale:a})):"Selected date: ".concat(Fe(r.props.selected,{dateFormat:o,locale:a})),de.default.createElement("span",{role:"alert","aria-live":"polite",className:"react-datepicker__aria-live"},e)})),Me(Ne(r),"renderDateInput",(function(){var e,t=ue.default(r.props.className,Me({},sr,r.state.open)),n=r.props.customInput||de.default.createElement("input",{type:"text"}),a=r.props.customInputRef||"ref",o="string"==typeof r.props.value?r.props.value:"string"==typeof r.state.inputValue?r.state.inputValue:r.props.selectsRange?function(e,t,r){if(!e)return"";var n=Fe(e,r),a=t?Fe(t,r):"";return"".concat(n," - ").concat(a)}(r.props.startDate,r.props.endDate,r.props):Fe(r.props.selected,r.props);return de.default.cloneElement(n,(Me(Me(Me(Me(Me(Me(Me(Me(Me(Me(e={},a,(function(e){r.input=e})),"value",o),"onBlur",r.handleBlur),"onChange",r.handleChange),"onClick",r.onInputClick),"onFocus",r.handleFocus),"onKeyDown",r.onInputKeyDown),"id",r.props.id),"name",r.props.name),"form",r.props.form),Me(Me(Me(Me(Me(Me(Me(Me(Me(Me(e,"autoFocus",r.props.autoFocus),"placeholder",r.props.placeholderText),"disabled",r.props.disabled),"autoComplete",r.props.autoComplete),"className",ue.default(n.props.className,t)),"title",r.props.title),"readOnly",r.props.readOnly),"required",r.props.required),"tabIndex",r.props.tabIndex),"aria-describedby",r.props.ariaDescribedBy),Me(Me(Me(e,"aria-invalid",r.props.ariaInvalid),"aria-labelledby",r.props.ariaLabelledBy),"aria-required",r.props.ariaRequired)))})),Me(Ne(r),"renderClearButton",(function(){var e=r.props,t=e.isClearable,n=e.disabled,a=e.selected,o=e.startDate,s=e.endDate,i=e.clearButtonTitle,p=e.clearButtonClassName,c=void 0===p?"":p,l=e.ariaLabelClose,d=void 0===l?"Close":l;return!t||null==a&&null==o&&null==s?null:de.default.createElement("button",{type:"button",className:ue.default("react-datepicker__close-icon",c,{"react-datepicker__close-icon--disabled":n}),disabled:n,"aria-label":d,onClick:r.onClearClick,title:i,tabIndex:-1})})),r.state=r.calcInitialState(),r.preventFocusTimeout=null,r}return _e(t,e),Se(t,[{key:"componentDidMount",value:function(){window.addEventListener("scroll",this.onScroll,!0)}},{key:"componentDidUpdate",value:function(e,t){var r,n;e.inline&&(r=e.selected,n=this.props.selected,r&&n?C.getMonth(r)!==C.getMonth(n)||Y.getYear(r)!==Y.getYear(n):r!==n)&&this.setPreSelection(this.props.selected),void 0!==this.state.monthSelectedIn&&e.monthsShown!==this.props.monthsShown&&this.setState({monthSelectedIn:0}),e.highlightDates!==this.props.highlightDates&&this.setState({highlightDates:Dt(this.props.highlightDates)}),t.focused||$e(e.selected,this.props.selected)||this.setState({inputValue:null}),t.open!==this.state.open&&(!1===t.open&&!0===this.state.open&&this.props.onCalendarOpen(),!0===t.open&&!1===this.state.open&&this.props.onCalendarClose())}},{key:"componentWillUnmount",value:function(){this.clearPreventFocusTimeout(),window.removeEventListener("scroll",this.onScroll,!0)}},{key:"renderInputContainer",value:function(){var e=this.props,t=e.showIcon,r=e.icon,n=e.calendarIconClassname,a=e.toggleCalendarOnIconClick,o=this.state.open;return de.default.createElement("div",{className:"react-datepicker__input-container".concat(t?" react-datepicker__view-calendar-icon":"")},t&&de.default.createElement(Xt,Ce({icon:r,className:"".concat(n," ").concat(o&&"react-datepicker-ignore-onclickoutside")},a?{onClick:this.toggleCalendar}:null)),this.state.isRenderAriaLiveMessage&&this.renderAriaLiveRegion(),this.renderDateInput(),this.renderClearButton())}},{key:"render",value:function(){var e=this.renderCalendar();if(this.props.inline)return e;if(this.props.withPortal){var t=this.state.open?de.default.createElement(tr,{enableTabLoop:this.props.enableTabLoop},de.default.createElement("div",{className:"react-datepicker__portal",tabIndex:-1,onKeyDown:this.onPortalKeyDown},e)):null;return this.state.open&&this.props.portalId&&(t=de.default.createElement(Zt,{portalId:this.props.portalId,portalHost:this.props.portalHost},t)),de.default.createElement("div",null,this.renderInputContainer(),t)}return de.default.createElement(or,{className:this.props.popperClassName,wrapperClassName:this.props.wrapperClassName,hidePopper:!this.isCalendarOpen(),portalId:this.props.portalId,portalHost:this.props.portalHost,popperModifiers:this.props.popperModifiers,targetComponent:this.renderInputContainer(),popperContainer:this.props.popperContainer,popperComponent:e,popperPlacement:this.props.popperPlacement,popperProps:this.props.popperProps,popperOnKeyDown:this.onPopperKeyDown,enableTabLoop:this.props.enableTabLoop,showArrow:this.props.showPopperArrow})}}],[{key:"defaultProps",get:function(){return{allowSameDay:!1,dateFormat:"MM/dd/yyyy",dateFormatCalendar:"LLLL yyyy",onChange:function(){},disabled:!1,disabledKeyboardNavigation:!1,dropdownMode:"scroll",onFocus:function(){},onBlur:function(){},onKeyDown:function(){},onInputClick:function(){},onSelect:function(){},onClickOutside:function(){},onMonthChange:function(){},onCalendarOpen:function(){},onCalendarClose:function(){},preventOpenOnFocus:!1,onYearChange:function(){},onInputError:function(){},monthsShown:1,readOnly:!1,withPortal:!1,selectsDisabledDaysInRange:!1,shouldCloseOnSelect:!0,showTimeSelect:!1,showTimeInput:!1,showPreviousMonths:!1,showMonthYearPicker:!1,showFullMonthYearPicker:!1,showTwoColumnMonthYearPicker:!1,showFourColumnMonthYearPicker:!1,showYearPicker:!1,showQuarterYearPicker:!1,showWeekPicker:!1,strictParsing:!1,timeIntervals:30,timeCaption:"Time",previousMonthAriaLabel:"Previous Month",previousMonthButtonLabel:"Previous Month",nextMonthAriaLabel:"Next Month",nextMonthButtonLabel:"Next Month",previousYearAriaLabel:"Previous Year",previousYearButtonLabel:"Previous Year",nextYearAriaLabel:"Next Year",nextYearButtonLabel:"Next Year",timeInputLabel:"Time",enableTabLoop:!0,yearItemNumber:xe,focusSelectedMonth:!1,showPopperArrow:!0,excludeScrollbar:!0,customTimeInput:null,calendarStartDay:void 0,toggleCalendarOnIconClick:!1}}}]),t}(de.default.Component),lr="input",dr="navigate";e.CalendarContainer=zt,e.default=cr,e.getDefaultLocale=Ge,e.registerLocale=function(e,t){var r="undefined"!=typeof window?window:globalThis;r.__localeData__||(r.__localeData__={}),r.__localeData__[e]=t},e.setDefaultLocale=function(e){("undefined"!=typeof window?window:globalThis).__localeId__=e},Object.defineProperty(e,"__esModule",{value:!0})}));
/***/ }),
/***/ 64448:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/*
Modernizr 3.0.0pre (Custom Build) | MIT
*/
var aa=__webpack_require__(67294),ca=__webpack_require__(63840);function p(a){for(var b="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=1;cb}return!1}function v(a,b,c,d,e,f,g){this.acceptsBooleans=2===b||3===b||4===b;this.attributeName=d;this.attributeNamespace=e;this.mustUseProperty=c;this.propertyName=a;this.type=b;this.sanitizeURL=f;this.removeEmptyString=g}var z={};
"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){z[a]=new v(a,0,!1,a,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var b=a[0];z[b]=new v(b,1,!1,a[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(a){z[a]=new v(a,2,!1,a.toLowerCase(),null,!1,!1)});
["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){z[a]=new v(a,2,!1,a,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(a){z[a]=new v(a,3,!1,a.toLowerCase(),null,!1,!1)});
["checked","multiple","muted","selected"].forEach(function(a){z[a]=new v(a,3,!0,a,null,!1,!1)});["capture","download"].forEach(function(a){z[a]=new v(a,4,!1,a,null,!1,!1)});["cols","rows","size","span"].forEach(function(a){z[a]=new v(a,6,!1,a,null,!1,!1)});["rowSpan","start"].forEach(function(a){z[a]=new v(a,5,!1,a.toLowerCase(),null,!1,!1)});var ra=/[\-:]([a-z])/g;function sa(a){return a[1].toUpperCase()}
"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(a){var b=a.replace(ra,
sa);z[b]=new v(b,1,!1,a,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var b=a.replace(ra,sa);z[b]=new v(b,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(a){var b=a.replace(ra,sa);z[b]=new v(b,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(a){z[a]=new v(a,1,!1,a.toLowerCase(),null,!1,!1)});
z.xlinkHref=new v("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(a){z[a]=new v(a,1,!1,a.toLowerCase(),null,!0,!0)});
function ta(a,b,c,d){var e=z.hasOwnProperty(b)?z[b]:null;if(null!==e?0!==e.type:d||!(2h||e[g]!==f[h]){var k="\n"+e[g].replace(" at new "," at ");a.displayName&&k.includes("")&&(k=k.replace("",a.displayName));return k}while(1<=g&&0<=h)}break}}}finally{Na=!1,Error.prepareStackTrace=c}return(a=a?a.displayName||a.name:"")?Ma(a):""}
function Pa(a){switch(a.tag){case 5:return Ma(a.type);case 16:return Ma("Lazy");case 13:return Ma("Suspense");case 19:return Ma("SuspenseList");case 0:case 2:case 15:return a=Oa(a.type,!1),a;case 11:return a=Oa(a.type.render,!1),a;case 1:return a=Oa(a.type,!0),a;default:return""}}
function Qa(a){if(null==a)return null;if("function"===typeof a)return a.displayName||a.name||null;if("string"===typeof a)return a;switch(a){case ya:return"Fragment";case wa:return"Portal";case Aa:return"Profiler";case za:return"StrictMode";case Ea:return"Suspense";case Fa:return"SuspenseList"}if("object"===typeof a)switch(a.$$typeof){case Ca:return(a.displayName||"Context")+".Consumer";case Ba:return(a._context.displayName||"Context")+".Provider";case Da:var b=a.render;a=a.displayName;a||(a=b.displayName||
b.name||"",a=""!==a?"ForwardRef("+a+")":"ForwardRef");return a;case Ga:return b=a.displayName||null,null!==b?b:Qa(a.type)||"Memo";case Ha:b=a._payload;a=a._init;try{return Qa(a(b))}catch(c){}}return null}
function Ra(a){var b=a.type;switch(a.tag){case 24:return"Cache";case 9:return(b.displayName||"Context")+".Consumer";case 10:return(b._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return a=b.render,a=a.displayName||a.name||"",b.displayName||(""!==a?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 5:return b;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Qa(b);case 8:return b===za?"StrictMode":"Mode";case 22:return"Offscreen";
case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if("function"===typeof b)return b.displayName||b.name||null;if("string"===typeof b)return b}return null}function Sa(a){switch(typeof a){case "boolean":case "number":case "string":case "undefined":return a;case "object":return a;default:return""}}
function Ta(a){var b=a.type;return(a=a.nodeName)&&"input"===a.toLowerCase()&&("checkbox"===b||"radio"===b)}
function Ua(a){var b=Ta(a)?"checked":"value",c=Object.getOwnPropertyDescriptor(a.constructor.prototype,b),d=""+a[b];if(!a.hasOwnProperty(b)&&"undefined"!==typeof c&&"function"===typeof c.get&&"function"===typeof c.set){var e=c.get,f=c.set;Object.defineProperty(a,b,{configurable:!0,get:function(){return e.call(this)},set:function(a){d=""+a;f.call(this,a)}});Object.defineProperty(a,b,{enumerable:c.enumerable});return{getValue:function(){return d},setValue:function(a){d=""+a},stopTracking:function(){a._valueTracker=
null;delete a[b]}}}}function Va(a){a._valueTracker||(a._valueTracker=Ua(a))}function Wa(a){if(!a)return!1;var b=a._valueTracker;if(!b)return!0;var c=b.getValue();var d="";a&&(d=Ta(a)?a.checked?"true":"false":a.value);a=d;return a!==c?(b.setValue(a),!0):!1}function Xa(a){a=a||("undefined"!==typeof document?document:void 0);if("undefined"===typeof a)return null;try{return a.activeElement||a.body}catch(b){return a.body}}
function Ya(a,b){var c=b.checked;return A({},b,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=c?c:a._wrapperState.initialChecked})}function Za(a,b){var c=null==b.defaultValue?"":b.defaultValue,d=null!=b.checked?b.checked:b.defaultChecked;c=Sa(null!=b.value?b.value:c);a._wrapperState={initialChecked:d,initialValue:c,controlled:"checkbox"===b.type||"radio"===b.type?null!=b.checked:null!=b.value}}function ab(a,b){b=b.checked;null!=b&&ta(a,"checked",b,!1)}
function bb(a,b){ab(a,b);var c=Sa(b.value),d=b.type;if(null!=c)if("number"===d){if(0===c&&""===a.value||a.value!=c)a.value=""+c}else a.value!==""+c&&(a.value=""+c);else if("submit"===d||"reset"===d){a.removeAttribute("value");return}b.hasOwnProperty("value")?cb(a,b.type,c):b.hasOwnProperty("defaultValue")&&cb(a,b.type,Sa(b.defaultValue));null==b.checked&&null!=b.defaultChecked&&(a.defaultChecked=!!b.defaultChecked)}
function db(a,b,c){if(b.hasOwnProperty("value")||b.hasOwnProperty("defaultValue")){var d=b.type;if(!("submit"!==d&&"reset"!==d||void 0!==b.value&&null!==b.value))return;b=""+a._wrapperState.initialValue;c||b===a.value||(a.value=b);a.defaultValue=b}c=a.name;""!==c&&(a.name="");a.defaultChecked=!!a._wrapperState.initialChecked;""!==c&&(a.name=c)}
function cb(a,b,c){if("number"!==b||Xa(a.ownerDocument)!==a)null==c?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+c&&(a.defaultValue=""+c)}var eb=Array.isArray;
function fb(a,b,c,d){a=a.options;if(b){b={};for(var e=0;e"+b.valueOf().toString()+"