1!(function (t, e) { 2 'object' == typeof exports && 'undefined' != typeof module 3 ? e(exports) 4 : 'function' == typeof define && define.amd 5 ? define(['exports'], e) 6 : e(((t = 'undefined' != typeof globalThis ? globalThis : t || self).ZXing = {})); 7})(this, function (t) { 8 'use strict'; 9 /*! ***************************************************************************** 10 Copyright (c) Microsoft Corporation. All rights reserved. 11 Licensed under the Apache License, Version 2.0 (the "License"); you may not use 12 this file except in compliance with the License. You may obtain a copy of the 13 License at http://www.apache.org/licenses/LICENSE-2.0 14 15 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 17 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 18 MERCHANTABLITY OR NON-INFRINGEMENT. 19 20 See the Apache Version 2.0 License for specific language governing permissions 21 and limitations under the License. 22 ***************************************************************************** */ var e = 23 Object.setPrototypeOf || 24 ({ __proto__: [] } instanceof Array && 25 function (t, e) { 26 t.__proto__ = e; 27 }) || 28 function (t, e) { 29 for (var r in e) e.hasOwnProperty(r) && (t[r] = e[r]); 30 }; 31 var r, 32 n = (function (t) { 33 function r(e) { 34 var r, 35 n, 36 i, 37 s = this.constructor, 38 o = t.call(this, e) || this; 39 return ( 40 Object.defineProperty(o, 'name', { value: s.name, enumerable: !1 }), 41 (r = o), 42 (n = s.prototype), 43 (i = Object.setPrototypeOf) ? i(r, n) : (r.__proto__ = n), 44 (function (t, e) { 45 void 0 === e && (e = t.constructor); 46 var r = Error.captureStackTrace; 47 r && r(t, e); 48 })(o), 49 o 50 ); 51 } 52 return ( 53 (function (t, r) { 54 function n() { 55 this.constructor = t; 56 } 57 e(t, r), (t.prototype = null === r ? Object.create(r) : ((n.prototype = r.prototype), new n())); 58 })(r, t), 59 r 60 ); 61 })(Error); 62 class i extends n { 63 constructor(t) { 64 super(t), (this.message = t); 65 } 66 getKind() { 67 return this.constructor.kind; 68 } 69 } 70 i.kind = 'Exception'; 71 class s extends i {} 72 s.kind = 'ArgumentException'; 73 class o extends i {} 74 o.kind = 'IllegalArgumentException'; 75 class a { 76 constructor(t) { 77 if (((this.binarizer = t), null === t)) throw new o('Binarizer must be non-null.'); 78 } 79 getWidth() { 80 return this.binarizer.getWidth(); 81 } 82 getHeight() { 83 return this.binarizer.getHeight(); 84 } 85 getBlackRow(t, e) { 86 return this.binarizer.getBlackRow(t, e); 87 } 88 getBlackMatrix() { 89 return ( 90 (null !== this.matrix && void 0 !== this.matrix) || (this.matrix = this.binarizer.getBlackMatrix()), this.matrix 91 ); 92 } 93 isCropSupported() { 94 return this.binarizer.getLuminanceSource().isCropSupported(); 95 } 96 crop(t, e, r, n) { 97 const i = this.binarizer.getLuminanceSource().crop(t, e, r, n); 98 return new a(this.binarizer.createBinarizer(i)); 99 } 100 isRotateSupported() { 101 return this.binarizer.getLuminanceSource().isRotateSupported(); 102 } 103 rotateCounterClockwise() { 104 const t = this.binarizer.getLuminanceSource().rotateCounterClockwise(); 105 return new a(this.binarizer.createBinarizer(t)); 106 } 107 rotateCounterClockwise45() { 108 const t = this.binarizer.getLuminanceSource().rotateCounterClockwise45(); 109 return new a(this.binarizer.createBinarizer(t)); 110 } 111 toString() { 112 try { 113 return this.getBlackMatrix().toString(); 114 } catch (t) { 115 return ''; 116 } 117 } 118 } 119 class l extends i { 120 static getChecksumInstance() { 121 return new l(); 122 } 123 } 124 l.kind = 'ChecksumException'; 125 class h { 126 constructor(t) { 127 this.source = t; 128 } 129 getLuminanceSource() { 130 return this.source; 131 } 132 getWidth() { 133 return this.source.getWidth(); 134 } 135 getHeight() { 136 return this.source.getHeight(); 137 } 138 } 139 class c { 140 static arraycopy(t, e, r, n, i) { 141 for (; i--; ) r[n++] = t[e++]; 142 } 143 static currentTimeMillis() { 144 return Date.now(); 145 } 146 } 147 class u extends i {} 148 u.kind = 'IndexOutOfBoundsException'; 149 class d extends u { 150 constructor(t, e) { 151 super(e), (this.index = t), (this.message = e); 152 } 153 } 154 d.kind = 'ArrayIndexOutOfBoundsException'; 155 class g { 156 static fill(t, e) { 157 for (let r = 0, n = t.length; r < n; r++) t[r] = e; 158 } 159 static fillWithin(t, e, r, n) { 160 g.rangeCheck(t.length, e, r); 161 for (let i = e; i < r; i++) t[i] = n; 162 } 163 static rangeCheck(t, e, r) { 164 if (e > r) throw new o('fromIndex(' + e + ') > toIndex(' + r + ')'); 165 if (e < 0) throw new d(e); 166 if (r > t) throw new d(r); 167 } 168 static asList(...t) { 169 return t; 170 } 171 static create(t, e, r) { 172 return Array.from({ length: t }).map((t) => Array.from({ length: e }).fill(r)); 173 } 174 static createInt32Array(t, e, r) { 175 return Array.from({ length: t }).map((t) => Int32Array.from({ length: e }).fill(r)); 176 } 177 static equals(t, e) { 178 if (!t) return !1; 179 if (!e) return !1; 180 if (!t.length) return !1; 181 if (!e.length) return !1; 182 if (t.length !== e.length) return !1; 183 for (let r = 0, n = t.length; r < n; r++) if (t[r] !== e[r]) return !1; 184 return !0; 185 } 186 static hashCode(t) { 187 if (null === t) return 0; 188 let e = 1; 189 for (const r of t) e = 31 * e + r; 190 return e; 191 } 192 static fillUint8Array(t, e) { 193 for (let r = 0; r !== t.length; r++) t[r] = e; 194 } 195 static copyOf(t, e) { 196 return t.slice(0, e); 197 } 198 static copyOfUint8Array(t, e) { 199 if (t.length <= e) { 200 const r = new Uint8Array(e); 201 return r.set(t), r; 202 } 203 return t.slice(0, e); 204 } 205 static copyOfRange(t, e, r) { 206 const n = r - e, 207 i = new Int32Array(n);
208 return c.arraycopy(t, e, i, 0, n), i; 209 } 210 static binarySearch(t, e, r) { 211 void 0 === r && (r = g.numberComparator); 212 let n = 0, 213 i = t.length - 1; 214 for (; n <= i; ) { 215 const s = (i + n) >> 1, 216 o = r(e, t[s]); 217 if (o > 0) n = s + 1; 218 else { 219 if (!(o < 0)) return s; 220 i = s - 1; 221 } 222 } 223 return -n - 1; 224 } 225 static numberComparator(t, e) { 226 return t - e; 227 } 228 } 229 class f { 230 static numberOfTrailingZeros(t) { 231 let e; 232 if (0 === t) return 32; 233 let r = 31; 234 return ( 235 (e = t << 16), 236 0 !== e && ((r -= 16), (t = e)), 237 (e = t << 8), 238 0 !== e && ((r -= 8), (t = e)), 239 (e = t << 4), 240 0 !== e && ((r -= 4), (t = e)), 241 (e = t << 2), 242 0 !== e && ((r -= 2), (t = e)), 243 r - ((t << 1) >>> 31) 244 ); 245 } 246 static numberOfLeadingZeros(t) { 247 if (0 === t) return 32; 248 let e = 1; 249 return ( 250 t >>> 16 == 0 && ((e += 16), (t <<= 16)), 251 t >>> 24 == 0 && ((e += 8), (t <<= 8)), 252 t >>> 28 == 0 && ((e += 4), (t <<= 4)), 253 t >>> 30 == 0 && ((e += 2), (t <<= 2)), 254 (e -= t >>> 31), 255 e 256 ); 257 } 258 static toHexString(t) { 259 return t.toString(16); 260 } 261 static toBinaryString(t) { 262 return String(parseInt(String(t), 2)); 263 } 264 static bitCount(t) { 265 return ( 266 (t = ((t = (858993459 & (t -= (t >>> 1) & 1431655765)) + ((t >>> 2) & 858993459)) + (t >>> 4)) & 252645135), 267 (t += t >>> 8), 268 63 & (t += t >>> 16) 269 ); 270 } 271 static truncDivision(t, e) { 272 return Math.trunc(t / e); 273 } 274 static parseInt(t, e) { 275 return parseInt(t, e); 276 } 277 } 278 (f.MIN_VALUE_32_BITS = -2147483648), (f.MAX_VALUE = Number.MAX_SAFE_INTEGER); 279 class w { 280 constructor(t, e) { 281 void 0 === t 282 ? ((this.size = 0), (this.bits = new Int32Array(1))) 283 : ((this.size = t), (this.bits = null == e ? w.makeArray(t) : e)); 284 } 285 getSize() { 286 return this.size; 287 } 288 getSizeInBytes() { 289 return Math.floor((this.size + 7) / 8); 290 } 291 ensureCapacity(t) { 292 if (t > 32 * this.bits.length) { 293 const e = w.makeArray(t); 294 c.arraycopy(this.bits, 0, e, 0, this.bits.length), (this.bits = e); 295 } 296 } 297 get(t) { 298 return 0 != (this.bits[Math.floor(t / 32)] & (1 << (31 & t))); 299 } 300 set(t) { 301 this.bits[Math.floor(t / 32)] |= 1 << (31 & t); 302 } 303 flip(t) { 304 this.bits[Math.floor(t / 32)] ^= 1 << (31 & t); 305 } 306 getNextSet(t) { 307 const e = this.size; 308 if (t >= e) return e; 309 const r = this.bits; 310 let n = Math.floor(t / 32), 311 i = r[n]; 312 i &= ~((1 << (31 & t)) - 1); 313 const s = r.length; 314 for (; 0 === i; ) { 315 if (++n === s) return e; 316 i = r[n]; 317 } 318 const o = 32 * n + f.numberOfTrailingZeros(i); 319 return o > e ? e : o; 320 } 321 getNextUnset(t) { 322 const e = this.size; 323 if (t >= e) return e; 324 const r = this.bits; 325 let n = Math.floor(t / 32), 326 i = ~r[n]; 327 i &= ~((1 << (31 & t)) - 1); 328 const s = r.length; 329 for (; 0 === i; ) { 330 if (++n === s) return e; 331 i = ~r[n]; 332 } 333 const o = 32 * n + f.numberOfTrailingZeros(i); 334 return o > e ? e : o; 335 } 336 setBulk(t, e) { 337 this.bits[Math.floor(t / 32)] = e; 338 } 339 setRange(t, e) { 340 if (e < t || t < 0 || e > this.size) throw new o(); 341 if (e === t) return; 342 e--; 343 const r = Math.floor(t / 32), 344 n = Math.floor(e / 32), 345 i = this.bits; 346 for (let s = r; s <= n; s++) { 347 const o = (2 << (s < n ? 31 : 31 & e)) - (1 << (s > r ? 0 : 31 & t)); 348 i[s] |= o; 349 } 350 } 351 clear() { 352 const t = this.bits.length, 353 e = this.bits; 354 for (let r = 0; r < t; r++) e[r] = 0; 355 } 356 isRange(t, e, r) { 357 if (e < t || t < 0 || e > this.size) throw new o(); 358 if (e === t) return !0; 359 e--; 360 const n = Math.floor(t / 32), 361 i = Math.floor(e / 32), 362 s = this.bits; 363 for (let o = n; o <= i; o++) { 364 const a = ((2 << (o < i ? 31 : 31 & e)) - (1 << (o > n ? 0 : 31 & t))) & 4294967295; 365 if ((s[o] & a) !== (r ? a : 0)) return !1; 366 } 367 return !0; 368 } 369 appendBit(t) { 370 this.ensureCapacity(this.size + 1), 371 t && (this.bits[Math.floor(this.size / 32)] |= 1 << (31 & this.size)), 372 this.size++; 373 } 374 appendBits(t, e) { 375 if (e < 0 || e > 32) throw new o('Num bits must be between 0 and 32'); 376 this.ensureCapacity(this.size + e); 377 for (let r = e; r > 0; r--) this.appendBit(1 == ((t >> (r - 1)) & 1)); 378 } 379 appendBitArray(t) { 380 const e = t.size; 381 this.ensureCapacity(this.size + e); 382 for (let r = 0; r < e; r++) this.appendBit(t.get(r)); 383 } 384 xor(t) { 385 if (this.size !== t.size) throw new o("Sizes don't match"); 386 const e = this.bits; 387 for (let r = 0, n = e.length; r < n; r++) e[r] ^= t.bits[r]; 388 } 389 toBytes(t, e, r, n) { 390 for (let i = 0; i < n; i++) { 391 let n = 0; 392 for (let e = 0; e < 8; e++) this.get(t) && (n |= 1 << (7 - e)), t++; 393 e[r + i] = n; 394 } 395 } 396 getBitArray() { 397 return this.bits; 398 } 399 reverse() { 400 const t = new Int32Array(this.bits.length), 401 e = Math.floor((this.size - 1) / 32), 402 r = e + 1, 403 n = this.bits; 404 for (let i = 0; i < r; i++) { 405 let r = n[i];
406 (r = ((r >> 1) & 1431655765) | ((1431655765 & r) << 1)), 407 (r = ((r >> 2) & 858993459) | ((858993459 & r) << 2)), 408 (r = ((r >> 4) & 252645135) | ((252645135 & r) << 4)), 409 (r = ((r >> 8) & 16711935) | ((16711935 & r) << 8)), 410 (r = ((r >> 16) & 65535) | ((65535 & r) << 16)), 411 (t[e - i] = r); 412 } 413 if (this.size !== 32 * r) { 414 const e = 32 * r - this.size; 415 let n = t[0] >>> e; 416 for (let i = 1; i < r; i++) { 417 const r = t[i]; 418 (n |= r << (32 - e)), (t[i - 1] = n), (n = r >>> e); 419 } 420 t[r - 1] = n; 421 } 422 this.bits = t; 423 } 424 static makeArray(t) { 425 return new Int32Array(Math.floor((t + 31) / 32)); 426 } 427 equals(t) { 428 if (!(t instanceof w)) return !1; 429 const e = t; 430 return this.size === e.size && g.equals(this.bits, e.bits); 431 } 432 hashCode() { 433 return 31 * this.size + g.hashCode(this.bits); 434 } 435 toString() { 436 let t = ''; 437 for (let e = 0, r = this.size; e < r; e++) 0 == (7 & e) && (t += ' '), (t += this.get(e) ? 'X' : '.'); 438 return t; 439 } 440 clone() { 441 return new w(this.size, this.bits.slice()); 442 } 443 } 444 !(function (t) { 445 (t[(t.OTHER = 0)] = 'OTHER'), 446 (t[(t.PURE_BARCODE = 1)] = 'PURE_BARCODE'), 447 (t[(t.POSSIBLE_FORMATS = 2)] = 'POSSIBLE_FORMATS'), 448 (t[(t.TRY_HARDER = 3)] = 'TRY_HARDER'), 449 (t[(t.CHARACTER_SET = 4)] = 'CHARACTER_SET'), 450 (t[(t.ALLOWED_LENGTHS = 5)] = 'ALLOWED_LENGTHS'), 451 (t[(t.ASSUME_CODE_39_CHECK_DIGIT = 6)] = 'ASSUME_CODE_39_CHECK_DIGIT'), 452 (t[(t.ASSUME_GS1 = 7)] = 'ASSUME_GS1'), 453 (t[(t.RETURN_CODABAR_START_END = 8)] = 'RETURN_CODABAR_START_END'), 454 (t[(t.NEED_RESULT_POINT_CALLBACK = 9)] = 'NEED_RESULT_POINT_CALLBACK'), 455 (t[(t.ALLOWED_EAN_EXTENSIONS = 10)] = 'ALLOWED_EAN_EXTENSIONS'); 456 })(r || (r = {})); 457 var A, 458 C = r; 459 class E extends i { 460 static getFormatInstance() { 461 return new E(); 462 } 463 } 464 (E.kind = 'FormatException'), 465 (function (t) { 466 (t[(t.Cp437 = 0)] = 'Cp437'), 467 (t[(t.ISO8859_1 = 1)] = 'ISO8859_1'), 468 (t[(t.ISO8859_2 = 2)] = 'ISO8859_2'), 469 (t[(t.ISO8859_3 = 3)] = 'ISO8859_3'), 470 (t[(t.ISO8859_4 = 4)] = 'ISO8859_4'), 471 (t[(t.ISO8859_5 = 5)] = 'ISO8859_5'), 472 (t[(t.ISO8859_6 = 6)] = 'ISO8859_6'), 473 (t[(t.ISO8859_7 = 7)] = 'ISO8859_7'), 474 (t[(t.ISO8859_8 = 8)] = 'ISO8859_8'), 475 (t[(t.ISO8859_9 = 9)] = 'ISO8859_9'), 476 (t[(t.ISO8859_10 = 10)] = 'ISO8859_10'), 477 (t[(t.ISO8859_11 = 11)] = 'ISO8859_11'), 478 (t[(t.ISO8859_13 = 12)] = 'ISO8859_13'), 479 (t[(t.ISO8859_14 = 13)] = 'ISO8859_14'), 480 (t[(t.ISO8859_15 = 14)] = 'ISO8859_15'), 481 (t[(t.ISO8859_16 = 15)] = 'ISO8859_16'), 482 (t[(t.SJIS = 16)] = 'SJIS'), 483 (t[(t.Cp1250 = 17)] = 'Cp1250'), 484 (t[(t.Cp1251 = 18)] = 'Cp1251'), 485 (t[(t.Cp1252 = 19)] = 'Cp1252'), 486 (t[(t.Cp1256 = 20)] = 'Cp1256'), 487 (t[(t.UnicodeBigUnmarked = 21)] = 'UnicodeBigUnmarked'), 488 (t[(t.UTF8 = 22)] = 'UTF8'), 489 (t[(t.ASCII = 23)] = 'ASCII'), 490 (t[(t.Big5 = 24)] = 'Big5'), 491 (t[(t.GB18030 = 25)] = 'GB18030'), 492 (t[(t.EUC_KR = 26)] = 'EUC_KR'); 493 })(A || (A = {})); 494 class m { 495 constructor(t, e, r, ...n) { 496 (this.valueIdentifier = t), 497 (this.name = r), 498 (this.values = 'number' == typeof e ? Int32Array.from([e]) : e), 499 (this.otherEncodingNames = n), 500 m.VALUE_IDENTIFIER_TO_ECI.set(t, this), 501 m.NAME_TO_ECI.set(r, this); 502 const i = this.values; 503 for (let t = 0, e = i.length; t !== e; t++) { 504 const e = i[t]; 505 m.VALUES_TO_ECI.set(e, this); 506 } 507 for (const t of n) m.NAME_TO_ECI.set(t, this); 508 } 509 getValueIdentifier() { 510 return this.valueIdentifier; 511 } 512 getName() { 513 return this.name; 514 } 515 getValue() { 516 return this.values[0]; 517 } 518 static getCharacterSetECIByValue(t) { 519 if (t < 0 || t >= 900) throw new E('incorect value'); 520 const e = m.VALUES_TO_ECI.get(t); 521 if (void 0 === e) throw new E('incorect value'); 522 return e; 523 } 524 static getCharacterSetECIByName(t) { 525 const e = m.NAME_TO_ECI.get(t); 526 if (void 0 === e) throw new E('incorect value'); 527 return e; 528 } 529 equals(t) { 530 if (!(t instanceof m)) return !1; 531 const e = t; 532 return this.getName() === e.getName(); 533 } 534 } 535 (m.VALUE_IDENTIFIER_TO_ECI = new Map()), 536 (m.VALUES_TO_ECI = new Map()), 537 (m.NAME_TO_ECI = new Map()), 538 (m.Cp437 = new m(A.Cp437, Int32Array.from([0, 2]), 'Cp437')), 539 (m.ISO8859_1 = new m(A.ISO8859_1, Int32Array.from([1, 3]), 'ISO-8859-1', 'ISO88591', 'ISO8859_1')), 540 (m.ISO8859_2 = new m(A.ISO8859_2, 4, 'ISO-8859-2', 'ISO88592', 'ISO8859_2')), 541 (m.ISO8859_3 = new m(A.ISO8859_3, 5, 'ISO-8859-3', 'ISO88593', 'ISO8859_3')), 542 (m.ISO8859_4 = new m(A.ISO8859_4, 6, 'ISO-8859-4', 'ISO88594', 'ISO8859_4')), 543 (m.ISO8859_5 = new m(A.ISO8859_5, 7, 'ISO-8859-5', 'ISO88595', 'ISO8859_5')), 544 (m.ISO8859_6 = new m(A.ISO8859_6, 8, 'ISO-8859-6', 'ISO88596', 'ISO8859_6')), 545 (m.ISO8859_7 = new m(A.ISO8859_7, 9, 'ISO-8859-7', 'ISO88597', 'ISO8859_7')), 546 (m.ISO8859_8 = new m(A.ISO8859_8, 10, 'ISO-8859-8', 'ISO88598', 'ISO8859_8')), 547 (m.ISO8859_9 = new m(A.ISO8859_9, 11, 'ISO-8859-9', 'ISO88599', 'ISO8859_9')), 548 (m.ISO8859_10 = new m(A.ISO8859_10, 12, 'ISO-8859-10', 'ISO885910', 'ISO8859_10')), 549 (m.ISO8859_11 = new m(A.ISO8859_11, 13, 'ISO-8859-11', 'ISO885911', 'ISO8859_11')), 550 (m.ISO8859_13 = new m(A.ISO8859_13, 15, 'ISO-8859-13', 'ISO885913', 'ISO8859_13')), 551 (m.ISO8859_14 = new m(A.ISO8859_14, 16, 'ISO-8859-14', 'ISO885914', 'ISO8859_14')), 552 (m.ISO8859_15 = new m(A.ISO8859_15, 17, 'ISO-8859-15', 'ISO885915', 'ISO8859_15')), 553 (m.ISO8859_16 = new m(A.ISO8859_16, 18, 'ISO-8859-16', 'ISO885916', 'ISO8859_16')), 554 (m.SJIS = new m(A.SJIS, 20, 'SJIS', 'Shift_JIS')), 555 (m.Cp1250 = new m(A.Cp1250, 21, 'Cp1250', 'windows-1250')), 556 (m.Cp1251 = new m(A.Cp1251, 22, 'Cp1251', 'windows-1251')), 557 (m.Cp1252 = new m(A.Cp1252, 23, 'Cp1252', 'windows-1252')), 558 (m.Cp1256 = new m(A.Cp1256, 24, 'Cp1256', 'windows-1256')), 559 (m.UnicodeBigUnmarked = new m(A.UnicodeBigUnmarked, 25, 'UnicodeBigUnmarked', 'UTF-16BE', 'UnicodeBig')), 560 (m.UTF8 = new m(A.UTF8, 26, 'UTF8', 'UTF-8')), 561 (m.ASCII = new m(A.ASCII, Int32Array.from([27, 170]), 'ASCII', 'US-ASCII')), 562 (m.Big5 = new m(A.Big5, 28, 'Big5')), 563 (m.GB18030 = new m(A.GB18030, 29, 'GB18030', 'GB2312', 'EUC_CN', 'GBK')), 564 (m.EUC_KR = new m(A.EUC_KR, 30, 'EUC_KR', 'EUC-KR')); 565 class _ extends i {} 566 _.kind = 'UnsupportedOperationException'; 567 class I { 568 static decode(t, e) { 569 const r = this.encodingName(e); 570 return this.customDecoder 571 ? this.customDecoder(t, r) 572 : 'undefined' == typeof TextDecoder || this.shouldDecodeOnFallback(r) 573 ? this.decodeFallback(t, r) 574 : new TextDecoder(r).decode(t); 575 } 576 static shouldDecodeOnFallback(t) { 577 return !I.isBrowser() && 'ISO-8859-1' === t; 578 } 579 static encode(t, e) { 580 const r = this.encodingName(e); 581 return this.customEncoder
582 ? this.customEncoder(t, r) 583 : 'undefined' == typeof TextEncoder 584 ? this.encodeFallback(t) 585 : new TextEncoder().encode(t); 586 } 587 static isBrowser() { 588 return 'undefined' != typeof window && '[object Window]' === {}.toString.call(window); 589 } 590 static encodingName(t) { 591 return 'string' == typeof t ? t : t.getName(); 592 } 593 static encodingCharacterSet(t) { 594 return t instanceof m ? t : m.getCharacterSetECIByName(t); 595 } 596 static decodeFallback(t, e) { 597 const r = this.encodingCharacterSet(e); 598 if (I.isDecodeFallbackSupported(r)) { 599 let e = ''; 600 for (let r = 0, n = t.length; r < n; r++) { 601 let n = t[r].toString(16); 602 n.length < 2 && (n = '0' + n), (e += '%' + n); 603 } 604 return decodeURIComponent(e); 605 } 606 if (r.equals(m.UnicodeBigUnmarked)) return String.fromCharCode.apply(null, new Uint16Array(t.buffer)); 607 throw new _(`Encoding ${this.encodingName(e)} not supported by fallback.`); 608 } 609 static isDecodeFallbackSupported(t) { 610 return t.equals(m.UTF8) || t.equals(m.ISO8859_1) || t.equals(m.ASCII); 611 } 612 static encodeFallback(t) { 613 const e = btoa(unescape(encodeURIComponent(t))).split(''), 614 r = []; 615 for (let t = 0; t < e.length; t++) r.push(e[t].charCodeAt(0)); 616 return new Uint8Array(r); 617 } 618 } 619 class S { 620 static castAsNonUtf8Char(t, e = null) { 621 const r = e ? e.getName() : this.ISO88591; 622 return I.decode(new Uint8Array([t]), r); 623 } 624 static guessEncoding(t, e) { 625 if (null != e && void 0 !== e.get(C.CHARACTER_SET)) return e.get(C.CHARACTER_SET).toString(); 626 const r = t.length; 627 let n = !0, 628 i = !0, 629 s = !0, 630 o = 0, 631 a = 0, 632 l = 0, 633 h = 0, 634 c = 0, 635 u = 0, 636 d = 0, 637 g = 0, 638 f = 0, 639 w = 0, 640 A = 0; 641 const E = t.length > 3 && 239 === t[0] && 187 === t[1] && 191 === t[2]; 642 for (let e = 0; e < r && (n || i || s); e++) { 643 const r = 255 & t[e]; 644 s && 645 (o > 0 646 ? 0 == (128 & r) 647 ? (s = !1) 648 : o-- 649 : 0 != (128 & r) && 650 (0 == (64 & r) 651 ? (s = !1) 652 : (o++, 0 == (32 & r) ? a++ : (o++, 0 == (16 & r) ? l++ : (o++, 0 == (8 & r) ? h++ : (s = !1)))))), 653 n && (r > 127 && r < 160 ? (n = !1) : r > 159 && (r < 192 || 215 === r || 247 === r) && A++), 654 i && 655 (c > 0 656 ? r < 64 || 127 === r || r > 252 657 ? (i = !1) 658 : c-- 659 : 128 === r || 160 === r || r > 239 660 ? (i = !1) 661 : r > 160 && r < 224 662 ? (u++, (g = 0), d++, d > f && (f = d)) 663 : r > 127 664 ? (c++, (d = 0), g++, g > w && (w = g)) 665 : ((d = 0), (g = 0))); 666 } 667 return ( 668 s && o > 0 && (s = !1), 669 i && c > 0 && (i = !1), 670 s && (E || a + l + h > 0) 671 ? S.UTF8 672 : i && (S.ASSUME_SHIFT_JIS || f >= 3 || w >= 3) 673 ? S.SHIFT_JIS 674 : n && i 675 ? (2 === f && 2 === u) || 10 * A >= r 676 ? S.SHIFT_JIS 677 : S.ISO88591 678 : n 679 ? S.ISO88591 680 : i 681 ? S.SHIFT_JIS 682 : s 683 ? S.UTF8 684 : S.PLATFORM_DEFAULT_ENCODING 685 ); 686 } 687 static format(t, ...e) { 688 let r = -1; 689 return t.replace(/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g, function (t, n, i, s, o, a) { 690 if ('%%' === t) return '%'; 691 if (void 0 === e[++r]) return; 692 t = s ? parseInt(s.substr(1)) : void 0; 693 let l, 694 h = o ? parseInt(o.substr(1)) : void 0; 695 switch (a) { 696 case 's': 697 l = e[r]; 698 break; 699 case 'c': 700 l = e[r][0]; 701 break; 702 case 'f': 703 l = parseFloat(e[r]).toFixed(t); 704 break; 705 case 'p': 706 l = parseFloat(e[r]).toPrecision(t); 707 break; 708 case 'e': 709 l = parseFloat(e[r]).toExponential(t); 710 break; 711 case 'x': 712 l = parseInt(e[r]).toString(h || 16); 713 break; 714 case 'd': 715 l = parseFloat(parseInt(e[r], h || 10).toPrecision(t)).toFixed(0); 716 } 717 l = 'object' == typeof l ? JSON.stringify(l) : (+l).toString(h); 718 let c = parseInt(i), 719 u = i && i[0] + '' == '0' ? '0' : ' '; 720 for (; l.length < c; ) l = void 0 !== n ? l + u : u + l; 721 return l; 722 }); 723 } 724 static getBytes(t, e) { 725 return I.encode(t, e); 726 } 727 static getCharCode(t, e = 0) { 728 return t.charCodeAt(e); 729 } 730 static getCharAt(t) { 731 return String.fromCharCode(t); 732 } 733 } 734 (S.SHIFT_JIS = m.SJIS.getName()), 735 (S.GB2312 = 'GB2312'), 736 (S.ISO88591 = m.ISO8859_1.getName()), 737 (S.EUC_JP = 'EUC_JP'), 738 (S.UTF8 = m.UTF8.getName()), 739 (S.PLATFORM_DEFAULT_ENCODING = S.UTF8), 740 (S.ASSUME_SHIFT_JIS = !1); 741 class p { 742 constructor(t = '') { 743 this.value = t; 744 } 745 enableDecoding(t) { 746 return (this.encoding = t), this; 747 } 748 append(t) { 749 return ( 750 'string' == typeof t 751 ? (this.value += t.toString()) 752 : this.encoding 753 ? (this.value += S.castAsNonUtf8Char(t, this.encoding)) 754 : (this.value += String.fromCharCode(t)), 755 this 756 ); 757 } 758 appendChars(t, e, r) { 759 for (let n = e; e < e + r; n++) this.append(t[n]); 760 return this; 761 } 762 length() { 763 return this.value.length; 764 } 765 charAt(t) { 766 return this.value.charAt(t); 767 } 768 deleteCharAt(t) { 769 this.value = this.value.substr(0, t) + this.value.substring(t + 1); 770 } 771 setCharAt(t, e) { 772 this.value = this.value.substr(0, t) + e + this.value.substr(t + 1); 773 } 774 substring(t, e) { 775 return this.value.substring(t, e); 776 }
777 setLengthToZero() { 778 this.value = ''; 779 } 780 toString() { 781 return this.value; 782 } 783 insert(t, e) { 784 this.value = this.value.substr(0, t) + e + this.value.substr(t + e.length); 785 } 786 } 787 class T { 788 constructor(t, e, r, n) { 789 if ( 790 ((this.width = t), 791 (this.height = e), 792 (this.rowSize = r), 793 (this.bits = n), 794 null == e && (e = t), 795 (this.height = e), 796 t < 1 || e < 1) 797 ) 798 throw new o('Both dimensions must be greater than 0'); 799 null == r && (r = Math.floor((t + 31) / 32)), 800 (this.rowSize = r), 801 null == n && (this.bits = new Int32Array(this.rowSize * this.height)); 802 } 803 static parseFromBooleanArray(t) { 804 const e = t.length, 805 r = t[0].length, 806 n = new T(r, e); 807 for (let i = 0; i < e; i++) { 808 const e = t[i]; 809 for (let t = 0; t < r; t++) e[t] && n.set(t, i); 810 } 811 return n; 812 } 813 static parseFromString(t, e, r) { 814 if (null === t) throw new o('stringRepresentation cannot be null'); 815 const n = new Array(t.length); 816 let i = 0, 817 s = 0, 818 a = -1, 819 l = 0, 820 h = 0; 821 for (; h < t.length; ) 822 if ('\n' === t.charAt(h) || '\r' === t.charAt(h)) { 823 if (i > s) { 824 if (-1 === a) a = i - s; 825 else if (i - s !== a) throw new o('row lengths do not match'); 826 (s = i), l++; 827 } 828 h++; 829 } else if (t.substring(h, h + e.length) === e) (h += e.length), (n[i] = !0), i++; 830 else { 831 if (t.substring(h, h + r.length) !== r) throw new o('illegal character encountered: ' + t.substring(h)); 832 (h += r.length), (n[i] = !1), i++; 833 } 834 if (i > s) { 835 if (-1 === a) a = i - s; 836 else if (i - s !== a) throw new o('row lengths do not match'); 837 l++; 838 } 839 const c = new T(a, l); 840 for (let t = 0; t < i; t++) n[t] && c.set(Math.floor(t % a), Math.floor(t / a)); 841 return c; 842 } 843 get(t, e) { 844 const r = e * this.rowSize + Math.floor(t / 32); 845 return 0 != ((this.bits[r] >>> (31 & t)) & 1); 846 } 847 set(t, e) { 848 const r = e * this.rowSize + Math.floor(t / 32); 849 this.bits[r] |= (1 << (31 & t)) & 4294967295; 850 } 851 unset(t, e) { 852 const r = e * this.rowSize + Math.floor(t / 32); 853 this.bits[r] &= ~((1 << (31 & t)) & 4294967295); 854 } 855 flip(t, e) { 856 const r = e * this.rowSize + Math.floor(t / 32); 857 this.bits[r] ^= (1 << (31 & t)) & 4294967295; 858 } 859 xor(t) { 860 if (this.width !== t.getWidth() || this.height !== t.getHeight() || this.rowSize !== t.getRowSize()) 861 throw new o('input matrix dimensions do not match'); 862 const e = new w(Math.floor(this.width / 32) + 1), 863 r = this.rowSize, 864 n = this.bits; 865 for (let i = 0, s = this.height; i < s; i++) { 866 const s = i * r, 867 o = t.getRow(i, e).getBitArray(); 868 for (let t = 0; t < r; t++) n[s + t] ^= o[t]; 869 } 870 } 871 clear() { 872 const t = this.bits, 873 e = t.length; 874 for (let r = 0; r < e; r++) t[r] = 0; 875 } 876 setRegion(t, e, r, n) { 877 if (e < 0 || t < 0) throw new o('Left and top must be nonnegative'); 878 if (n < 1 || r < 1) throw new o('Height and width must be at least 1'); 879 const i = t + r, 880 s = e + n; 881 if (s > this.height || i > this.width) throw new o('The region must fit inside the matrix'); 882 const a = this.rowSize, 883 l = this.bits; 884 for (let r = e; r < s; r++) { 885 const e = r * a; 886 for (let r = t; r < i; r++) l[e + Math.floor(r / 32)] |= (1 << (31 & r)) & 4294967295; 887 } 888 } 889 getRow(t, e) { 890 null == e || e.getSize() < this.width ? (e = new w(this.width)) : e.clear(); 891 const r = this.rowSize, 892 n = this.bits, 893 i = t * r; 894 for (let t = 0; t < r; t++) e.setBulk(32 * t, n[i + t]); 895 return e; 896 } 897 setRow(t, e) { 898 c.arraycopy(e.getBitArray(), 0, this.bits, t * this.rowSize, this.rowSize); 899 } 900 rotate180() { 901 const t = this.getWidth(), 902 e = this.getHeight(); 903 let r = new w(t), 904 n = new w(t); 905 for (let t = 0, i = Math.floor((e + 1) / 2); t < i; t++) 906 (r = this.getRow(t, r)), 907 (n = this.getRow(e - 1 - t, n)), 908 r.reverse(), 909 n.reverse(), 910 this.setRow(t, n), 911 this.setRow(e - 1 - t, r); 912 } 913 getEnclosingRectangle() { 914 const t = this.width, 915 e = this.height, 916 r = this.rowSize, 917 n = this.bits; 918 let i = t, 919 s = e, 920 o = -1, 921 a = -1; 922 for (let t = 0; t < e; t++) 923 for (let e = 0; e < r; e++) { 924 const l = n[t * r + e]; 925 if (0 !== l) { 926 if ((t < s && (s = t), t > a && (a = t), 32 * e < i)) { 927 let t = 0; 928 for (; 0 == ((l << (31 - t)) & 4294967295); ) t++; 929 32 * e + t < i && (i = 32 * e + t); 930 } 931 if (32 * e + 31 > o) { 932 let t = 31; 933 for (; l >>> t == 0; ) t--; 934 32 * e + t > o && (o = 32 * e + t); 935 } 936 } 937 } 938 return o < i || a < s ? null : Int32Array.from([i, s, o - i + 1, a - s + 1]); 939 } 940 getTopLeftOnBit() { 941 const t = this.rowSize, 942 e = this.bits; 943 let r = 0; 944 for (; r < e.length && 0 === e[r]; ) r++; 945 if (r === e.length) return null; 946 const n = r / t; 947 let i = (r % t) * 32; 948 const s = e[r]; 949 let o = 0; 950 for (; 0 == ((s << (31 - o)) & 4294967295); ) o++; 951 return (i += o), Int32Array.from([i, n]); 952 } 953 getBottomRightOnBit() { 954 const t = this.rowSize, 955 e = this.bits; 956 let r = e.length - 1; 957 for (; r >= 0 && 0 === e[r]; ) r--; 958 if (r < 0) return null; 959 const n = Math.floor(r / t); 960 let i = 32 * Math.floor(r % t); 961 const s = e[r]; 962 let o = 31; 963 for (; s >>> o == 0; ) o--; 964 return (i += o), Int32Array.from([i, n]); 965 } 966 getWidth() { 967 return this.width; 968 } 969 getHeight() { 970 return this.height; 971 } 972 getRowSize() { 973 return this.rowSize; 974 } 975 equals(t) { 976 if (!(t instanceof T)) return !1; 977 const e = t; 978 return ( 979 this.width === e.width && this.height === e.height && this.rowSize === e.rowSize && g.equals(this.bits, e.bits) 980 ); 981 } 982 hashCode() { 983 let t = this.width; 984 return ( 985 (t = 31 * t + this.width), 986 (t = 31 * t + this.height), 987 (t = 31 * t + this.rowSize), 988 (t = 31 * t + g.hashCode(this.bits)), 989 t 990 ); 991 } 992 toString(t = 'X ', e = ' ', r = '\n') { 993 return this.buildToString(t, e, r); 994 } 995 buildToString(t, e, r) { 996 let n = new p(); 997 for (let i = 0, s = this.height; i < s; i++) { 998 for (let r = 0, s = this.width; r < s; r++) n.append(this.get(r, i) ? t : e); 999 n.append(r); 1000 } 1001 return n.toString(); 1002 } 1003 clone() { 1004 return new T(this.width, this.height, this.rowSize, this.bits.slice()); 1005 } 1006 } 1007 class R extends i { 1008 static getNotFoundInstance() { 1009 return new R(); 1010 } 1011 } 1012 R.kind = 'NotFoundException'; 1013 class N extends h { 1014 constructor(t) { 1015 super(t), (this.luminances = N.EMPTY), (this.buckets = new Int32Array(N.LUMINANCE_BUCKETS)); 1016 } 1017 getBlackRow(t, e) { 1018 const r = this.getLuminanceSource(), 1019 n = r.getWidth(); 1020 null == e || e.getSize() < n ? (e = new w(n)) : e.clear(), this.initArrays(n); 1021 const i = r.getRow(t, this.luminances), 1022 s = this.buckets; 1023 for (let t = 0; t < n; t++) s[(255 & i[t]) >> N.LUMINANCE_SHIFT]++; 1024 const o = N.estimateBlackPoint(s); 1025 if (n < 3) for (let t = 0; t < n; t++) (255 & i[t]) < o && e.set(t); 1026 else { 1027 let t = 255 & i[0], 1028 r = 255 & i[1]; 1029 for (let s = 1; s < n - 1; s++) { 1030 const n = 255 & i[s + 1];
1031 (4 * r - t - n) / 2 < o && e.set(s), (t = r), (r = n); 1032 } 1033 } 1034 return e; 1035 } 1036 getBlackMatrix() { 1037 const t = this.getLuminanceSource(), 1038 e = t.getWidth(), 1039 r = t.getHeight(), 1040 n = new T(e, r); 1041 this.initArrays(e); 1042 const i = this.buckets; 1043 for (let n = 1; n < 5; n++) { 1044 const s = Math.floor((r * n) / 5), 1045 o = t.getRow(s, this.luminances), 1046 a = Math.floor((4 * e) / 5); 1047 for (let t = Math.floor(e / 5); t < a; t++) { 1048 i[(255 & o[t]) >> N.LUMINANCE_SHIFT]++; 1049 } 1050 } 1051 const s = N.estimateBlackPoint(i), 1052 o = t.getMatrix(); 1053 for (let t = 0; t < r; t++) { 1054 const r = t * e; 1055 for (let i = 0; i < e; i++) { 1056 (255 & o[r + i]) < s && n.set(i, t); 1057 } 1058 } 1059 return n; 1060 } 1061 createBinarizer(t) { 1062 return new N(t); 1063 } 1064 initArrays(t) { 1065 this.luminances.length < t && (this.luminances = new Uint8ClampedArray(t)); 1066 const e = this.buckets; 1067 for (let t = 0; t < N.LUMINANCE_BUCKETS; t++) e[t] = 0; 1068 } 1069 static estimateBlackPoint(t) { 1070 const e = t.length; 1071 let r = 0, 1072 n = 0, 1073 i = 0; 1074 for (let s = 0; s < e; s++) t[s] > i && ((n = s), (i = t[s])), t[s] > r && (r = t[s]); 1075 let s = 0, 1076 o = 0; 1077 for (let r = 0; r < e; r++) { 1078 const e = r - n, 1079 i = t[r] * e * e; 1080 i > o && ((s = r), (o = i)); 1081 } 1082 if (n > s) { 1083 const t = n; 1084 (n = s), (s = t); 1085 } 1086 if (s - n <= e / 16) throw new R(); 1087 let a = s - 1, 1088 l = -1;
1089 for (let e = s - 1; e > n; e--) { 1090 const i = e - n, 1091 o = i * i * (s - e) * (r - t[e]); 1092 o > l && ((a = e), (l = o)); 1093 } 1094 return a << N.LUMINANCE_SHIFT; 1095 } 1096 } 1097 (N.LUMINANCE_BITS = 5), 1098 (N.LUMINANCE_SHIFT = 8 - N.LUMINANCE_BITS), 1099 (N.LUMINANCE_BUCKETS = 1 << N.LUMINANCE_BITS), 1100 (N.EMPTY = Uint8ClampedArray.from([0])); 1101 class D extends N { 1102 constructor(t) { 1103 super(t), (this.matrix = null); 1104 } 1105 getBlackMatrix() { 1106 if (null !== this.matrix) return this.matrix; 1107 const t = this.getLuminanceSource(), 1108 e = t.getWidth(), 1109 r = t.getHeight(); 1110 if (e >= D.MINIMUM_DIMENSION && r >= D.MINIMUM_DIMENSION) { 1111 const n = t.getMatrix(); 1112 let i = e >> D.BLOCK_SIZE_POWER; 1113 0 != (e & D.BLOCK_SIZE_MASK) && i++; 1114 let s = r >> D.BLOCK_SIZE_POWER; 1115 0 != (r & D.BLOCK_SIZE_MASK) && s++; 1116 const o = D.calculateBlackPoints(n, i, s, e, r), 1117 a = new T(e, r); 1118 D.calculateThresholdForBlock(n, i, s, e, r, o, a), (this.matrix = a); 1119 } else this.matrix = super.getBlackMatrix(); 1120 return this.matrix; 1121 } 1122 createBinarizer(t) { 1123 return new D(t); 1124 } 1125 static calculateThresholdForBlock(t, e, r, n, i, s, o) { 1126 const a = i - D.BLOCK_SIZE, 1127 l = n - D.BLOCK_SIZE; 1128 for (let i = 0; i < r; i++) { 1129 let h = i << D.BLOCK_SIZE_POWER; 1130 h > a && (h = a); 1131 const c = D.cap(i, 2, r - 3); 1132 for (let r = 0; r < e; r++) { 1133 let i = r << D.BLOCK_SIZE_POWER; 1134 i > l && (i = l); 1135 const a = D.cap(r, 2, e - 3); 1136 let u = 0; 1137 for (let t = -2; t <= 2; t++) { 1138 const e = s[c + t]; 1139 u += e[a - 2] + e[a - 1] + e[a] + e[a + 1] + e[a + 2]; 1140 } 1141 const d = u / 25; 1142 D.thresholdBlock(t, i, h, d, n, o); 1143 } 1144 } 1145 } 1146 static cap(t, e, r) { 1147 return t < e ? e : t > r ? r : t; 1148 } 1149 static thresholdBlock(t, e, r, n, i, s) { 1150 for (let o = 0, a = r * i + e; o < D.BLOCK_SIZE; o++, a += i) 1151 for (let i = 0; i < D.BLOCK_SIZE; i++) (255 & t[a + i]) <= n && s.set(e + i, r + o); 1152 } 1153 static calculateBlackPoints(t, e, r, n, i) { 1154 const s = i - D.BLOCK_SIZE, 1155 o = n - D.BLOCK_SIZE, 1156 a = new Array(r); 1157 for (let i = 0; i < r; i++) { 1158 a[i] = new Int32Array(e); 1159 let r = i << D.BLOCK_SIZE_POWER; 1160 r > s && (r = s); 1161 for (let s = 0; s < e; s++) { 1162 let e = s << D.BLOCK_SIZE_POWER; 1163 e > o && (e = o); 1164 let l = 0, 1165 h = 255, 1166 c = 0; 1167 for (let i = 0, s = r * n + e; i < D.BLOCK_SIZE; i++, s += n) { 1168 for (let e = 0; e < D.BLOCK_SIZE; e++) { 1169 const r = 255 & t[s + e]; 1170 (l += r), r < h && (h = r), r > c && (c = r); 1171 } 1172 if (c - h > D.MIN_DYNAMIC_RANGE) 1173 for (i++, s += n; i < D.BLOCK_SIZE; i++, s += n) 1174 for (let e = 0; e < D.BLOCK_SIZE; e++) l += 255 & t[s + e]; 1175 } 1176 let u = l >> (2 * D.BLOCK_SIZE_POWER); 1177 if (c - h <= D.MIN_DYNAMIC_RANGE && ((u = h / 2), i > 0 && s > 0)) { 1178 const t = (a[i - 1][s] + 2 * a[i][s - 1] + a[i - 1][s - 1]) / 4; 1179 h < t && (u = t); 1180 } 1181 a[i][s] = u; 1182 } 1183 } 1184 return a; 1185 } 1186 } 1187 (D.BLOCK_SIZE_POWER = 3), 1188 (D.BLOCK_SIZE = 1 << D.BLOCK_SIZE_POWER), 1189 (D.BLOCK_SIZE_MASK = D.BLOCK_SIZE - 1), 1190 (D.MINIMUM_DIMENSION = 5 * D.BLOCK_SIZE), 1191 (D.MIN_DYNAMIC_RANGE = 24); 1192 class y { 1193 constructor(t, e) { 1194 (this.width = t), (this.height = e); 1195 } 1196 getWidth() { 1197 return this.width; 1198 } 1199 getHeight() { 1200 return this.height; 1201 } 1202 isCropSupported() { 1203 return !1; 1204 } 1205 crop(t, e, r, n) { 1206 throw new _('This luminance source does not support cropping.'); 1207 } 1208 isRotateSupported() { 1209 return !1; 1210 } 1211 rotateCounterClockwise() { 1212 throw new _('This luminance source does not support rotation by 90 degrees.'); 1213 } 1214 rotateCounterClockwise45() { 1215 throw new _('This luminance source does not support rotation by 45 degrees.'); 1216 } 1217 toString() { 1218 const t = new Uint8ClampedArray(this.width); 1219 let e = new p(); 1220 for (let r = 0; r < this.height; r++) { 1221 const n = this.getRow(r, t); 1222 for (let t = 0; t < this.width; t++) { 1223 const r = 255 & n[t]; 1224 let i; 1225 (i = r < 64 ? '#' : r < 128 ? '+' : r < 192 ? '.' : ' '), e.append(i); 1226 } 1227 e.append('\n'); 1228 } 1229 return e.toString(); 1230 } 1231 } 1232 class O extends y { 1233 constructor(t) { 1234 super(t.getWidth(), t.getHeight()), (this.delegate = t); 1235 } 1236 getRow(t, e) { 1237 const r = this.delegate.getRow(t, e), 1238 n = this.getWidth(); 1239 for (let t = 0; t < n; t++) r[t] = 255 - (255 & r[t]); 1240 return r; 1241 } 1242 getMatrix() { 1243 const t = this.delegate.getMatrix(), 1244 e = this.getWidth() * this.getHeight(), 1245 r = new Uint8ClampedArray(e); 1246 for (let n = 0; n < e;
1246 n++) r[n] = 255 - (255 & t[n]); 1247 return r; 1248 } 1249 isCropSupported() { 1250 return this.delegate.isCropSupported(); 1251 } 1252 crop(t, e, r, n) { 1253 return new O(this.delegate.crop(t, e, r, n)); 1254 } 1255 isRotateSupported() { 1256 return this.delegate.isRotateSupported(); 1257 } 1258 invert() { 1259 return this.delegate; 1260 } 1261 rotateCounterClockwise() { 1262 return new O(this.delegate.rotateCounterClockwise()); 1263 } 1264 rotateCounterClockwise45() { 1265 return new O(this.delegate.rotateCounterClockwise45()); 1266 } 1267 } 1268 class M extends y { 1269 constructor(t) { 1270 super(t.width, t.height), 1271 (this.canvas = t), 1272 (this.tempCanvasElement = null), 1273 (this.buffer = M.makeBufferFromCanvasImageData(t)); 1274 } 1275 static makeBufferFromCanvasImageData(t) { 1276 const e = t.getContext('2d').getImageData(0, 0, t.width, t.height); 1277 return M.toGrayscaleBuffer(e.data, t.width, t.height); 1278 } 1279 static toGrayscaleBuffer(t, e, r) { 1280 const n = new Uint8ClampedArray(e * r); 1281 for (let e = 0, r = 0, i = t.length; e < i; e += 4, r++) { 1282 let i; 1283 if (0 === t[e + 3]) i = 255; 1284 else { 1285 i = (306 * t[e] + 601 * t[e + 1] + 117 * t[e + 2] + 512) >> 10; 1286 } 1287 n[r] = i; 1288 } 1289 return n; 1290 } 1291 getRow(t, e) { 1292 if (t < 0 || t >= this.getHeight()) throw new o('Requested row is outside the image: ' + t); 1293 const r = this.getWidth(), 1294 n = t * r; 1295 return ( 1296 null === e 1297 ? (e = this.buffer.slice(n, n + r)) 1298 : (e.length < r && (e = new Uint8ClampedArray(r)), e.set(this.buffer.slice(n, n + r))), 1299 e 1300 ); 1301 } 1302 getMatrix() { 1303 return this.buffer; 1304 } 1305 isCropSupported() { 1306 return !0; 1307 } 1308 crop(t, e, r, n) { 1309 return super.crop(t, e, r, n), this; 1310 } 1311 isRotateSupported() { 1312 return !0; 1313 } 1314 rotateCounterClockwise() { 1315 return this.rotate(-90), this; 1316 } 1317 rotateCounterClockwise45() { 1318 return this.rotate(-45), this; 1319 } 1320 getTempCanvasElement() { 1321 if (null === this.tempCanvasElement) { 1322 const t = this.canvas.ownerDocument.createElement('canvas'); 1323 (t.width = this.canvas.width), (t.height = this.canvas.height), (this.tempCanvasElement = t); 1324 } 1325 return this.tempCanvasElement; 1326 } 1327 rotate(t) { 1328 const e = this.getTempCanvasElement(), 1329 r = e.getContext('2d'), 1330 n = t * M.DEGREE_TO_RADIANS, 1331 i = this.canvas.width, 1332 s = this.canvas.height, 1333 o = Math.ceil(Math.abs(Math.cos(n)) * i + Math.abs(Math.sin(n)) * s), 1334 a = Math.ceil(Math.abs(Math.sin(n)) * i + Math.abs(Math.cos(n)) * s); 1335 return ( 1336 (e.width = o), 1337 (e.height = a), 1338 r.translate(o / 2, a / 2), 1339 r.rotate(n), 1340 r.drawImage(this.canvas, i / -2, s / -2), 1341 (this.buffer = M.makeBufferFromCanvasImageData(e)), 1342 this 1343 ); 1344 } 1345 invert() { 1346 return new O(this); 1347 } 1348 } 1349 M.DEGREE_TO_RADIANS = Math.PI / 180; 1350 class B { 1351 constructor(t, e, r) { 1352 (this.deviceId = t), (this.label = e), (this.kind = 'videoinput'), (this.groupId = r || void 0); 1353 } 1354 toJSON() { 1355 return { kind: this.kind, groupId: this.groupId, deviceId: this.deviceId, label: this.label }; 1356 } 1357 } 1358 var b, 1359 P = 1360 (globalThis || global || self || window 1361 ? (globalThis || global || self || window || void 0).__awaiter 1362 : void 0) || 1363 function (t, e, r, n) { 1364 return new (r || (r = Promise))(function (i, s) { 1365 function o(t) { 1366 try { 1367 l(n.next(t)); 1368 } catch (t) { 1369 s(t); 1370 } 1371 } 1372 function a(t) { 1373 try { 1374 l(n.throw(t)); 1375 } catch (t) { 1376 s(t); 1377 } 1378 } 1379 function l(t) { 1380 var e; 1381 t.done 1382 ? i(t.value) 1383 : ((e = t.value), 1384 e instanceof r 1385 ? e 1386 : new r(function (t) { 1387 t(e); 1388 })).then(o, a); 1389 } 1390 l((n = n.apply(t, e || [])).next()); 1391 }); 1392 }; 1393 class L { 1394 constructor(t, e = 500, r) { 1395 (this.reader = t), 1396 (this.timeBetweenScansMillis = e), 1397 (this._hints = r), 1398 (this._stopContinuousDecode = !1), 1399 (this._stopAsyncDecode = !1), 1400 (this._timeBetweenDecodingAttempts = 0); 1401 } 1402 get hasNavigator() { 1403 return 'undefined' != typeof navigator; 1404 } 1405 get isMediaDevicesSuported() { 1406 return this.hasNavigator && !!navigator.mediaDevices; 1407 } 1408 get canEnumerateDevices() { 1409 return !(!this.isMediaDevicesSuported || !navigator.mediaDevices.enumerateDevices); 1410 } 1411 get timeBetweenDecodingAttempts() { 1412 return this._timeBetweenDecodingAttempts; 1413 } 1414 set timeBetweenDecodingAttempts(t) { 1415 this._timeBetweenDecodingAttempts = t < 0 ? 0 : t; 1416 } 1417 set hints(t) { 1418 this._hints = t || null; 1419 } 1420 get hints() { 1421 return this._hints; 1422 } 1423 listVideoInputDevices() { 1424 return P(this, void 0, void 0, function* () { 1425 if (!this.hasNavigator) throw new Error("Can't enumerate devices, navigator is not present."); 1426 if (!this.canEnumerateDevices) throw new Error("Can't enumerate devices, method not supported."); 1427 const t = yield navigator.mediaDevices.enumerateDevices(), 1428 e = []; 1429 for (const r of t) { 1430 const t = 'video' === r.kind ? 'videoinput' : r.kind; 1431 if ('videoinput' !== t) continue; 1432 const n = { 1433 deviceId: r.deviceId || r.id, 1434 label: r.label || 'Video device ' + (e.length + 1), 1435 kind: t, 1436 groupId: r.groupId, 1437 }; 1438 e.push(n); 1439 } 1440 return e; 1441 }); 1442 } 1443 getVideoInputDevices() { 1444 return P(this, void 0, void 0, function* () { 1445 return (yield this.listVideoInputDevices()).map((t) => new B(t.deviceId, t.label)); 1446 }); 1447 } 1448 findDeviceById(t) { 1449 return P(this, void 0, void 0, function* () { 1450 const e = yield this.listVideoInputDevices(); 1451 return e ? e.find((e) => e.deviceId === t) : null; 1452 }); 1453 } 1454 decodeFromInputVideoDevice(t, e) { 1455 return P(this, void 0, void 0, function* () { 1456 return yield this.decodeOnceFromVideoDevice(t, e); 1457 }); 1458 } 1459 decodeOnceFromVideoDevice(t, e) { 1460 return P(this, void 0, void 0, function* () { 1461 let r; 1462 this.reset(), (r = t ? { deviceId: { exact: t } } : { facingMode: 'environment' }); 1463 const n = { video: r }; 1464 return yield this.decodeOnceFromConstraints(n, e); 1465 }); 1466 } 1467 decodeOnceFromConstraints(t, e) { 1468 return P(this, void 0, void 0, function* () { 1469 const r = yield navigator.mediaDevices.getUserMedia(t); 1470 return yield this.decodeOnceFromStream(r, e); 1471 }); 1472 } 1473 decodeOnceFromStream(t, e) { 1474 return P(this, void 0, void 0, function* () { 1475 this.reset(); 1476 const r = yield this.attachStreamToVideo(t, e); 1477 return yield this.decodeOnce(r); 1478 }); 1479 } 1480 decodeFromInputVideoDeviceContinuously(t, e, r) { 1481 return P(this, void 0, void 0, function* () { 1482 return yield this.decodeFromVideoDevice(t, e, r); 1483 }); 1484 } 1485 decodeFromVideoDevice(t, e, r) { 1486 return P(this, void 0, void 0, function* () { 1487 let n; 1488 n = t ? { deviceId: { exact: t } } : { facingMode: 'environment' }; 1489 const i = { video: n }; 1490 return yield this.decodeFromConstraints(i, e, r); 1491 }); 1492 } 1493 decodeFromConstraints(t, e, r) { 1494 return P(this, void 0, void 0, function* () { 1495 const n = yield navigator.mediaDevices.getUserMedia(t); 1496 return yield this.decodeFromStream(n, e, r); 1497 }); 1498 } 1499 decodeFromStream(t, e, r) { 1500 return P(this, void 0, void 0, function* () { 1501 this.reset(); 1502 const n = yield this.attachStreamToVideo(t, e); 1503 return yield this.decodeContinuously(n, r); 1504 }); 1505 } 1506 stopAsyncDecode() { 1507 this._stopAsyncDecode = !0; 1508 } 1509 stopContinuousDecode() { 1510 this._stopContinuousDecode = !0; 1511 } 1512 attachStreamToVideo(t, e) { 1513 return P(this, void 0, void 0, function* () { 1514 const r = this.prepareVideoElement(e); 1515 return ( 1516 this.addVideoSource(r, t), (this.videoElement = r), (this.stream = t), yield this.playVideoOnLoadAsync(r), r 1517 ); 1518 }); 1519 } 1520 playVideoOnLoadAsync(t) { 1521 return new Promise((e, r) => this.playVideoOnLoad(t, () => e())); 1522 } 1523 playVideoOnLoad(t, e) { 1524 (this.videoEndedListener = () => this.stopStreams()), 1525 (this.videoCanPlayListener = () => this.tryPlayVideo(t)), 1526 t.addEventListener('ended', this.videoEndedListener), 1527 t.addEventListener('canplay', this.videoCanPlayListener), 1528 t.addEventListener('playing', e), 1529 this.tryPlayVideo(t); 1530 } 1531 isVideoPlaying(t) { 1532 return t.currentTime > 0 && !t.paused && !t.ended && t.readyState > 2; 1533 } 1534 tryPlayVideo(t) { 1535 return P(this, void 0, void 0, function* () { 1536 if (this.isVideoPlaying(t)) console.warn('Trying to play video that is already playing.'); 1537 else 1538 try { 1539 yield t.play(); 1540 } catch (t) { 1541 console.warn('It was not possible to play the video.'); 1542 } 1543 }); 1544 } 1545 getMediaElement(t, e) { 1546 const r = document.getElementById(t); 1547 if (!r) throw new s(`element with id '${t}' not found`); 1548 if (r.nodeName.toLowerCase() !== e.toLowerCase()) throw new s(`element with id '${t}' must be an ${e} element`); 1549 return r; 1550 } 1551 decodeFromImage(t, e) { 1552 if (!t && !e) throw new s('either imageElement with a src set or an url must be provided'); 1553 return e && !t ? this.decodeFromImageUrl(e) : this.decodeFromImageElement(t); 1554 } 1555 decodeFromVideo(t, e) { 1556 if (!t && !e) throw new s('Either an element with a src set or an URL must be provided'); 1557 return e && !t ? this.decodeFromVideoUrl(e) : this.decodeFromVideoElement(t); 1558 } 1559 decodeFromVideoContinuously(t, e, r) { 1560 if (void 0 === t && void 0 === e) throw new s('Either an element with a src set or an URL must be provided'); 1561 return e && !t ? this.decodeFromVideoUrlContinuously(e, r) : this.decodeFromVideoElementContinuously(t, r); 1562 } 1563 decodeFromImageElement(t) { 1564 if (!t) throw new s('An image element must be provided.'); 1565 this.reset(); 1566 const e = this.prepareImageElement(t); 1567 let r; 1568 return ( 1569 (this.imageElement = e), 1570 (r = this.isImageLoaded(e) ? this.decodeOnce(e, !1, !0) : this._decodeOnLoadImage(e)), 1571 r 1572 ); 1573 } 1574 decodeFromVideoElement(t) { 1575 const e = this._decodeFromVideoElementSetup(t); 1576 return this._decodeOnLoadVideo(e); 1577 } 1578 decodeFromVideoElementContinuously(t, e) { 1579 const r = this._decodeFromVideoElementSetup(t); 1580 return this._decodeOnLoadVideoContinuously(r, e); 1581 } 1582 _decodeFromVideoElementSetup(t) { 1583 if (!t) throw new s('A video element must be provided.'); 1584 this.reset(); 1585 const e = this.prepareVideoElement(t); 1586 return (this.videoElement = e), e; 1587 } 1588 decodeFromImageUrl(t) { 1589 if (!t) throw new s('An URL must be provided.'); 1590 this.reset(); 1591 const e = this.prepareImageElement(); 1592 this.imageElement = e; 1593 const r = this._decodeOnLoadImage(e); 1594 return (e.src = t), r; 1595 } 1596 decodeFromVideoUrl(t) { 1597 if (!t) throw new s('An URL must be provided.'); 1598 this.reset(); 1599 const e = this.prepareVideoElement(), 1600 r = this.decodeFromVideoElement(e); 1601 return (e.src = t), r; 1602 } 1603 decodeFromVideoUrlContinuously(t, e) { 1604 if (!t) throw new s('An URL must be provided.'); 1605 this.reset(); 1606 const r = this.prepareVideoElement(), 1607 n = this.decodeFromVideoElementContinuously(r, e); 1608 return (r.src = t), n; 1609 } 1610 _decodeOnLoadImage(t) { 1611 return new Promise((e, r) => { 1612 (this.imageLoadedListener = () => this.decodeOnce(t, !1, !0).then(e, r)), 1613 t.addEventListener('load', this.imageLoadedListener); 1614 }); 1615 } 1616 _decodeOnLoadVideo(t) { 1617 return P(this, void 0, void 0, function* () { 1618 return yield this.playVideoOnLoadAsync(t), yield this.decodeOnce(t); 1619 }); 1620 } 1621 _decodeOnLoadVideoContinuously(t, e) { 1622 return P(this, void 0, void 0, function* () { 1623 yield this.playVideoOnLoadAsync(t), this.decodeContinuously(t, e); 1624 }); 1625 } 1626 isImageLoaded(t) {
1627 return !!t.complete && 0 !== t.naturalWidth; 1628 } 1629 prepareImageElement(t) { 1630 let e; 1631 return ( 1632 void 0 === t && ((e = document.createElement('img')), (e.width = 200), (e.height = 200)), 1633 'string' == typeof t && (e = this.getMediaElement(t, 'img')), 1634 t instanceof HTMLImageElement && (e = t), 1635 e 1636 ); 1637 } 1638 prepareVideoElement(t) { 1639 let e; 1640 return ( 1641 t || 1642 'undefined' == typeof document || 1643 ((e = document.createElement('video')), (e.width = 200), (e.height = 200)), 1644 'string' == typeof t && (e = this.getMediaElement(t, 'video')), 1645 t instanceof HTMLVideoElement && (e = t), 1646 e.setAttribute('autoplay', 'true'), 1647 e.setAttribute('muted', 'true'), 1648 e.setAttribute('playsinline', 'true'), 1649 e 1650 ); 1651 } 1652 decodeOnce(t, e = !0, r = !0) { 1653 this._stopAsyncDecode = !1; 1654 const n = (i, s) => { 1655 if (this._stopAsyncDecode) 1656 return ( 1657 s(new R('Video stream has ended before any code could be detected.')), void (this._stopAsyncDecode = void 0) 1658 ); 1659 try { 1660 i(this.decode(t)); 1661 } catch (t) { 1662 const o = (t instanceof l || t instanceof E) && r; 1663 if ((e && t instanceof R) || o) return setTimeout(n, this._timeBetweenDecodingAttempts, i, s); 1664 s(t); 1665 } 1666 }; 1667 return new Promise((t, e) => n(t, e)); 1668 } 1669 decodeContinuously(t, e) { 1670 this._stopContinuousDecode = !1; 1671 const r = () => { 1672 if (this._stopContinuousDecode) this._stopContinuousDecode = void 0; 1673 else 1674 try { 1675 const n = this.decode(t); 1676 e(n, null), setTimeout(r, this.timeBetweenScansMillis); 1677 } catch (t) { 1678 e(null, t); 1679 const n = t instanceof R; 1680 (t instanceof l || t instanceof E || n) && setTimeout(r, this._timeBetweenDecodingAttempts); 1681 } 1682 }; 1683 r(); 1684 } 1685 decode(t) { 1686 const e = this.createBinaryBitmap(t); 1687 return this.decodeBitmap(e); 1688 } 1689 createBinaryBitmap(t) { 1690 const e = this.getCaptureCanvasContext(t); 1691 this.drawImageOnCanvas(e, t); 1692 const r = this.getCaptureCanvas(t), 1693 n = new M(r), 1694 i = new D(n); 1695 return new a(i); 1696 } 1697 getCaptureCanvasContext(t) { 1698 if (!this.captureCanvasContext) { 1699 const e = this.getCaptureCanvas(t).getContext('2d'); 1700 this.captureCanvasContext = e; 1701 } 1702 return this.captureCanvasContext; 1703 } 1704 getCaptureCanvas(t) { 1705 if (!this.captureCanvas) { 1706 const e = this.createCaptureCanvas(t); 1707 this.captureCanvas = e; 1708 } 1709 return this.captureCanvas; 1710 } 1711 drawImageOnCanvas(t, e) { 1712 t.drawImage(e, 0, 0); 1713 } 1714 decodeBitmap(t) { 1715 return this.reader.decode(t, this._hints); 1716 } 1717 createCaptureCanvas(t) { 1718 if ('undefined' == typeof document) return this._destroyCaptureCanvas(), null; 1719 const e = document.createElement('canvas'); 1720 let r, n; 1721 return ( 1722 void 0 !== t && 1723 (t instanceof HTMLVideoElement 1724 ? ((r = t.videoWidth), (n = t.videoHeight)) 1725 : t instanceof HTMLImageElement && ((r = t.naturalWidth || t.width), (n = t.naturalHeight || t.height))), 1726 (e.style.width = r + 'px'), 1727 (e.style.height = n + 'px'), 1728 (e.width = r), 1729 (e.height = n), 1730 e 1731 ); 1732 } 1733 stopStreams() { 1734 this.stream && (this.stream.getVideoTracks().forEach((t) => t.stop()), (this.stream = void 0)), 1735 !1 === this._stopAsyncDecode && this.stopAsyncDecode(), 1736 !1 === this._stopContinuousDecode && this.stopContinuousDecode(); 1737 } 1738 reset() { 1739 this.stopStreams(), this._destroyVideoElement(), this._destroyImageElement(), this._destroyCaptureCanvas(); 1740 } 1741 _destroyVideoElement() { 1742 this.videoElement && 1743 (void 0 !== this.videoEndedListener && this.videoElement.removeEventListener('ended', this.videoEndedListener), 1744 void 0 !== this.videoPlayingEventListener && 1745 this.videoElement.removeEventListener('playing', this.videoPlayingEventListener), 1746 void 0 !== this.videoCanPlayListener && 1747 this.videoElement.removeEventListener('loadedmetadata', this.videoCanPlayListener), 1748 this.cleanVideoSource(this.videoElement), 1749 (this.videoElement = void 0)); 1750 } 1751 _destroyImageElement() { 1752 this.imageElement && 1753 (void 0 !== this.imageLoadedListener && this.imageElement.removeEventListener('load', this.imageLoadedListener), 1754 (this.imageElement.src = void 0), 1755 this.imageElement.removeAttribute('src'), 1756 (this.imageElement = void 0)); 1757 } 1758 _destroyCaptureCanvas() { 1759 (this.captureCanvasContext = void 0), (this.captureCanvas = void 0); 1760 } 1761 addVideoSource(t, e) {
1762 try { 1763 t.srcObject = e; 1764 } catch (r) { 1765 t.src = URL.createObjectURL(e); 1766 } 1767 } 1768 cleanVideoSource(t) { 1769 try { 1770 t.srcObject = null; 1771 } catch (e) { 1772 t.src = ''; 1773 } 1774 this.videoElement.removeAttribute('src'); 1775 } 1776 } 1777 class F { 1778 constructor(t, e, r = null == e ? 0 : 8 * e.length, n, i, s = c.currentTimeMillis()) { 1779 (this.text = t), 1780 (this.rawBytes = e), 1781 (this.numBits = r), 1782 (this.resultPoints = n), 1783 (this.format = i), 1784 (this.timestamp = s), 1785 (this.text = t), 1786 (this.rawBytes = e), 1787 (this.numBits = null == r ? (null == e ? 0 : 8 * e.length) : r), 1788 (this.resultPoints = n), 1789 (this.format = i), 1790 (this.resultMetadata = null), 1791 (this.timestamp = null == s ? c.currentTimeMillis() : s); 1792 } 1793 getText() { 1794 return this.text; 1795 } 1796 getRawBytes() { 1797 return this.rawBytes; 1798 } 1799 getNumBits() { 1800 return this.numBits; 1801 } 1802 getResultPoints() { 1803 return this.resultPoints; 1804 } 1805 getBarcodeFormat() { 1806 return this.format; 1807 } 1808 getResultMetadata() { 1809 return this.resultMetadata; 1810 } 1811 putMetadata(t, e) { 1812 null === this.resultMetadata && (this.resultMetadata = new Map()), this.resultMetadata.set(t, e); 1813 } 1814 putAllMetadata(t) { 1815 null !== t && (null === this.resultMetadata ? (this.resultMetadata = t) : (this.resultMetadata = new Map(t))); 1816 } 1817 addResultPoints(t) { 1818 const e = this.resultPoints; 1819 if (null === e) this.resultPoints = t; 1820 else if (null !== t && t.length > 0) { 1821 const r = new Array(e.length + t.length); 1822 c.arraycopy(e, 0, r, 0, e.length), c.arraycopy(t, 0, r, e.length, t.length), (this.resultPoints = r); 1823 } 1824 } 1825 getTimestamp() { 1826 return this.timestamp; 1827 } 1828 toString() { 1829 return this.text; 1830 } 1831 } 1832 !(function (t) { 1833 (t[(t.AZTEC = 0)] = 'AZTEC'), 1834 (t[(t.CODABAR = 1)] = 'CODABAR'), 1835 (t[(t.CODE_39 = 2)] = 'CODE_39'), 1836 (t[(t.CODE_93 = 3)] = 'CODE_93'), 1837 (t[(t.CODE_128 = 4)] = 'CODE_128'), 1838 (t[(t.DATA_MATRIX = 5)] = 'DATA_MATRIX'), 1839 (t[(t.EAN_8 = 6)] = 'EAN_8'), 1840 (t[(t.EAN_13 = 7)] = 'EAN_13'), 1841 (t[(t.ITF = 8)] = 'ITF'), 1842 (t[(t.MAXICODE = 9)] = 'MAXICODE'), 1843 (t[(t.PDF_417 = 10)] = 'PDF_417'), 1844 (t[(t.QR_CODE = 11)] = 'QR_CODE'), 1845 (t[(t.RSS_14 = 12)] = 'RSS_14'), 1846 (t[(t.RSS_EXPANDED = 13)] = 'RSS_EXPANDED'), 1847 (t[(t.UPC_A = 14)] = 'UPC_A'), 1848 (t[(t.UPC_E = 15)] = 'UPC_E'), 1849 (t[(t.UPC_EAN_EXTENSION = 16)] = 'UPC_EAN_EXTENSION'); 1850 })(b || (b = {})); 1851 var k, 1852 v = b; 1853 !(function (t) { 1854 (t[(t.OTHER = 0)] = 'OTHER'), 1855 (t[(t.ORIENTATION = 1)] = 'ORIENTATION'), 1856 (t[(t.BYTE_SEGMENTS = 2)] = 'BYTE_SEGMENTS'), 1857 (t[(t.ERROR_CORRECTION_LEVEL = 3)] = 'ERROR_CORRECTION_LEVEL'), 1858 (t[(t.ISSUE_NUMBER = 4)] = 'ISSUE_NUMBER'),
1859 (t[(t.SUGGESTED_PRICE = 5)] = 'SUGGESTED_PRICE'), 1860 (t[(t.POSSIBLE_COUNTRY = 6)] = 'POSSIBLE_COUNTRY'), 1861 (t[(t.UPC_EAN_EXTENSION = 7)] = 'UPC_EAN_EXTENSION'), 1862 (t[(t.PDF417_EXTRA_METADATA = 8)] = 'PDF417_EXTRA_METADATA'), 1863 (t[(t.STRUCTURED_APPEND_SEQUENCE = 9)] = 'STRUCTURED_APPEND_SEQUENCE'), 1864 (t[(t.STRUCTURED_APPEND_PARITY = 10)] = 'STRUCTURED_APPEND_PARITY'); 1865 })(k || (k = {})); 1866 var x, 1867 V, 1868 U, 1869 H, 1870 G, 1871 X, 1872 W = k; 1873 class z { 1874 constructor(t, e, r, n, i = -1, s = -1) { 1875 (this.rawBytes = t), 1876 (this.text = e), 1877 (this.byteSegments = r), 1878 (this.ecLevel = n), 1879 (this.structuredAppendSequenceNumber = i), 1880 (this.structuredAppendParity = s), 1881 (this.numBits = null == t ? 0 : 8 * t.length); 1882 } 1883 getRawBytes() { 1884 return this.rawBytes; 1885 } 1886 getNumBits() { 1887 return this.numBits; 1888 } 1889 setNumBits(t) { 1890 this.numBits = t; 1891 } 1892 getText() { 1893 return this.text; 1894 } 1895 getByteSegments() { 1896 return this.byteSegments; 1897 } 1898 getECLevel() { 1899 return this.ecLevel; 1900 } 1901 getErrorsCorrected() { 1902 return this.errorsCorrected; 1903 } 1904 setErrorsCorrected(t) { 1905 this.errorsCorrected = t; 1906 } 1907 getErasures() { 1908 return this.erasures; 1909 } 1910 setErasures(t) { 1911 this.erasures = t; 1912 } 1913 getOther() { 1914 return this.other; 1915 } 1916 setOther(t) { 1917 this.other = t; 1918 } 1919 hasStructuredAppend() { 1920 return this.structuredAppendParity >= 0 && this.structuredAppendSequenceNumber >= 0; 1921 } 1922 getStructuredAppendParity() { 1923 return this.structuredAppendParity; 1924 } 1925 getStructuredAppendSequenceNumber() { 1926 return this.structuredAppendSequenceNumber; 1927 } 1928 } 1929 class Y { 1930 exp(t) { 1931 return this.expTable[t]; 1932 } 1933 log(t) { 1934 if (0 === t) throw new o(); 1935 return this.logTable[t]; 1936 } 1937 static addOrSubtract(t, e) { 1938 return t ^ e; 1939 } 1940 } 1941 class Z { 1942 constructor(t, e) { 1943 if (0 === e.length) throw new o(); 1944 this.field = t; 1945 const r = e.length; 1946 if (r > 1 && 0 === e[0]) { 1947 let t = 1; 1948 for (; t < r && 0 === e[t]; ) t++; 1949 t === r 1950 ? (this.coefficients = Int32Array.from([0])) 1951 : ((this.coefficients = new Int32Array(r - t)), 1952 c.arraycopy(e, t, this.coefficients, 0, this.coefficients.length)); 1953 } else this.coefficients = e; 1954 } 1955 getCoefficients() { 1956 return this.coefficients; 1957 } 1958 getDegree() { 1959 return this.coefficients.length - 1; 1960 } 1961 isZero() { 1962 return 0 === this.coefficients[0]; 1963 } 1964 getCoefficient(t) { 1965 return this.coefficients[this.coefficients.length - 1 - t]; 1966 } 1967 evaluateAt(t) { 1968 if (0 === t) return this.getCoefficient(0); 1969 const e = this.coefficients; 1970 let r; 1971 if (1 === t) { 1972 r = 0; 1973 for (let t = 0, n = e.length; t !== n; t++) { 1974 const n = e[t]; 1975 r = Y.addOrSubtract(r, n); 1976 } 1977 return r; 1978 } 1979 r = e[0]; 1980 const n = e.length, 1981 i = this.field; 1982 for (let s = 1; s < n; s++) r = Y.addOrSubtract(i.multiply(t, r), e[s]); 1983 return r; 1984 } 1985 addOrSubtract(t) { 1986 if (!this.field.equals(t.field)) throw new o('GenericGFPolys do not have same GenericGF field'); 1987 if (this.isZero()) return t; 1988 if (t.isZero()) return this; 1989 let e = this.coefficients, 1990 r = t.coefficients; 1991 if (e.length > r.length) { 1992 const t = e; 1993 (e = r), (r = t); 1994 } 1995 let n = new Int32Array(r.length); 1996 const i = r.length - e.length; 1997 c.arraycopy(r, 0, n, 0, i); 1998 for (let t = i; t < r.length; t++) n[t] = Y.addOrSubtract(e[t - i], r[t]); 1999 return new Z(this.field, n); 2000 } 2001 multiply(t) { 2002 if (!this.field.equals(t.field)) throw new o('GenericGFPolys do not have same GenericGF field'); 2003 if (this.isZero() || t.isZero()) return this.field.getZero(); 2004 const e = this.coefficients, 2005 r = e.length, 2006 n = t.coefficients, 2007 i = n.length, 2008 s = new Int32Array(r + i - 1), 2009 a = this.field; 2010 for (let t = 0; t < r; t++) { 2011 const r = e[t]; 2012 for (let e = 0; e < i; e++) s[t + e] = Y.addOrSubtract(s[t + e], a.multiply(r, n[e])); 2013 } 2014 return new Z(a, s); 2015 } 2016 multiplyScalar(t) { 2017 if (0 === t) return this.field.getZero(); 2018 if (1 === t) return this; 2019 const e = this.coefficients.length, 2020 r = this.field, 2021 n = new Int32Array(e), 2022 i = this.coefficients; 2023 for (let s = 0; s < e; s++) n[s] = r.multiply(i[s], t); 2024 return new Z(r, n); 2025 } 2026 multiplyByMonomial(t, e) { 2027 if (t < 0) throw new o(); 2028 if (0 === e) return this.field.getZero(); 2029 const r = this.coefficients, 2030 n = r.length, 2031 i = new Int32Array(n + t), 2032 s = this.field; 2033 for (let t = 0; t < n; t++) i[t] = s.multiply(r[t], e); 2034 return new Z(s, i); 2035 } 2036 divide(t) { 2037 if (!this.field.equals(t.field)) throw new o('GenericGFPolys do n
2037ot have same GenericGF field'); 2038 if (t.isZero()) throw new o('Divide by 0'); 2039 const e = this.field; 2040 let r = e.getZero(), 2041 n = this; 2042 const i = t.getCoefficient(t.getDegree()), 2043 s = e.inverse(i); 2044 for (; n.getDegree() >= t.getDegree() && !n.isZero(); ) { 2045 const i = n.getDegree() - t.getDegree(), 2046 o = e.multiply(n.getCoefficient(n.getDegree()), s), 2047 a = t.multiplyByMonomial(i, o), 2048 l = e.buildMonomial(i, o); 2049 (r = r.addOrSubtract(l)), (n = n.addOrSubtract(a)); 2050 } 2051 return [r, n]; 2052 } 2053 toString() { 2054 let t = ''; 2055 for (let e = this.getDegree(); e >= 0; e--) { 2056 let r = this.getCoefficient(e); 2057 if (0 !== r) { 2058 if ((r < 0 ? ((t += ' - '), (r = -r)) : t.length > 0 && (t += ' + '), 0 === e || 1 !== r)) { 2059 const e = this.field.log(r); 2060 0 === e ? (t += '1') : 1 === e ? (t += 'a') : ((t += 'a^'), (t += e)); 2061 } 2062 0 !== e && (1 === e ? (t += 'x') : ((t += 'x^'), (t += e))); 2063 } 2064 } 2065 return t; 2066 } 2067 } 2068 class K extends i {} 2069 K.kind = 'ArithmeticException'; 2070 class q extends Y { 2071 constructor(t, e, r) { 2072 super(), (this.primitive = t), (this.size = e), (this.generatorBase = r); 2073 const n = new Int32Array(e); 2074 let i = 1; 2075 for (let r = 0; r < e; r++) (n[r] = i), (i *= 2), i >= e && ((i ^= t), (i &= e - 1)); 2076 this.expTable = n; 2077 const s = new Int32Array(e); 2078 for (let t = 0; t < e - 1; t++) s[n[t]] = t; 2079 (this.logTable = s), 2080 (this.zero = new Z(this, Int32Array.from([0]))), 2081 (this.one = new Z(this, Int32Array.from([1]))); 2082 } 2083 getZero() { 2084 return this.zero; 2085 } 2086 getOne() { 2087 return this.one; 2088 } 2089 buildMonomial(t, e) { 2090 if (t < 0) throw new o(); 2091 if (0 === e) return this.zero; 2092 const r = new Int32Array(t + 1); 2093 return (r[0] = e), new Z(this, r); 2094 } 2095 inverse(t) { 2096 if (0 === t) throw new K(); 2097 return this.expTable[this.size - this.logTable[t] - 1]; 2098 } 2099 multiply(t, e) { 2100 return 0 === t || 0 === e ? 0 : this.expTable[(this.logTable[t] + this.logTable[e]) % (this.size - 1)]; 2101 } 2102 getSize() { 2103 return this.size; 2104 } 2105 getGeneratorBase() { 2106 return this.generatorBase; 2107 } 2108 toString() { 2109 return 'GF(0x' + f.toHexString(this.primitive) + ',' + this.size + ')'; 2110 } 2111 equals(t) { 2112 return t === this; 2113 } 2114 } 2115 (q.AZTEC_DATA_12 = new q(4201, 4096, 1)), 2116 (q.AZTEC_DATA_10 = new q(1033, 1024, 1)), 2117 (q.AZTEC_DATA_6 = new q(67, 64, 1)), 2118 (q.AZTEC_PARAM = new q(19, 16, 1)), 2119 (q.QR_CODE_FIELD_256 = new q(285, 256, 0)), 2120 (q.DATA_MATRIX_FIELD_256 = new q(301, 256, 1)), 2121 (q.AZTEC_DATA_8 = q.DATA_MATRIX_FIELD_256), 2122 (q.MAXICODE_FIELD_64 = q.AZTEC_DATA_6); 2123 class Q extends i {} 2124 Q.kind = 'ReedSolomonException'; 2125 class j extends i {} 2126 j.kind = 'IllegalStateException'; 2127 class J { 2128 constructor(t) { 2129 this.field = t; 2130 } 2131 decode(t, e) { 2132 const r = this.field, 2133 n = new Z(r, t), 2134 i = new Int32Array(e); 2135 let s = !0; 2136 for (let t = 0; t < e; t++) { 2137 const e = n.evaluateAt(r.exp(t + r.getGeneratorBase())); 2138 (i[i.length - 1 - t] = e), 0 !== e && (s = !1); 2139 } 2140 if (s) return; 2141 const o = new Z(r, i), 2142 a = this.runEuclideanAlgorithm(r.buildMonomial(e, 1), o, e), 2143 l = a[0], 2144 h = a[1], 2145 c = this.findErrorLocations(l), 2146 u = this.findErrorMagnitudes(h, c); 2147 for (let e = 0; e < c.length; e++) { 2148 const n = t.length - 1 - r.log(c[e]); 2149 if (n < 0) throw new Q('Bad error location'); 2150 t[n] = q.addOrSubtract(t[n], u[e]); 2151 } 2152 } 2153 runEuclideanAlgorithm(t, e, r) { 2154 if (t.getDegree() < e.getDegree()) { 2155 const r = t; 2156 (t = e), (e = r); 2157 } 2158 const n = this.field; 2159 let i = t, 2160 s = e, 2161 o = n.getZero(), 2162 a = n.getOne(); 2163 for (; s.getDegree() >= ((r / 2) | 0); ) { 2164 let t = i, 2165 e = o; 2166 if (((i = s), (o = a), i.isZero())) throw new Q('r_{i-1} was zero'); 2167 s = t; 2168 let r = n.getZero(); 2169 const l = i.getCoefficient(i.getDegree()), 2170 h = n.inverse(l); 2171 for (; s.getDegree() >= i.getDegree() && !s.isZero(); ) { 2172 const t = s.getDegree() - i.getDegree(), 2173 e = n.multiply(s.getCoefficient(s.getDegree()), h); 2174 (r = r.addOrSubtract(n.buildMonomial(t, e))), (s = s.addOrSubtract(i.multiplyByMonomial(t, e))); 2175 } 2176 if (((a = r.multiply(o).addOrSubtract(e)), s.getDegree() >= i.getDegree())) 2177 throw new j('Division algorithm failed to reduce polynomial?'); 2178 } 2179 const l = a.getCoefficient(0); 2180 if (0 === l) throw new Q('sigmaTilde(0) was zero'); 2181 const h = n.inverse(l); 2182 return [a.multiplyScalar(h), s.multiplyScalar(h)]; 2183 } 2184 findErrorLocations(t) { 2185 const e = t.getDegree(); 2186 if (1 === e) return Int32Array.from([t.getCoefficient(1)]); 2187 const r = new Int32Array(e); 2188 let n = 0; 2189 const i = this.field; 2190 for (let s = 1; s < i.getSize() && n < e; s++) 0 === t.evaluateAt(s) && ((r[n] = i.inverse(s)), n++); 2191 if (n !== e) throw new Q('Error locator degree does not match number of roots'); 2192 return r; 2193 } 2194 findErrorMagnitudes(t, e) { 2195 const r = e.length, 2196 n = new Int32Array(r), 2197 i = this.field; 2198 for (let s = 0; s < r; s++) { 2199 const o = i.inverse(e[s]); 2200 let a = 1; 2201 for (let t = 0; t < r; t++) 2202 if (s !== t) { 2203 const r = i.multiply(e[t], o), 2204 n = 0 == (1 & r) ? 1 | r : -2 & r; 2205 a = i.multiply(a, n); 2206 } 2207 (n[s] = i.multiply(t.evaluateAt(o), i.inverse(a))), 0 !== i.getGeneratorBase() && (n[s] = i.multiply(n[s], o)); 2208 } 2209 return n; 2210 } 2211 } 2212 !(function (t) { 2213 (t[(t.UPPER = 0)] = 'UPPER'), 2214 (t[(t.LOWER = 1)] = 'LOWER'), 2215 (t[(t.MIXED = 2)] = 'MIXED'), 2216 (t[(t.DIGIT = 3)] = 'DIGIT'), 2217 (t[(t.PUNCT = 4)] = 'PUNCT'), 2218 (t[(t.BINARY = 5)] = 'BINARY'); 2219 })(x || (x = {})); 2220 class $ { 2221 decode(t) { 2222 this.ddata = t; 2223 let e = t.getBits(), 2224 r = this.extractBits(e), 2225 n = this.correctBits(r), 2226 i = $.convertBoolArrayToByteArray(n), 2227 s = $.getEncodedData(n), 2228 o = new z(i, s, null, null); 2229 return o.setNumBits(n.length), o; 2230 } 2231 static highLevelDecode(t) { 2232 return this.getEncodedData(t); 2233 } 2234 static getEncodedData(t) { 2235 let e = t.length, 2236 r = x.UPPER, 2237 n = x.UPPER, 2238 i = '', 2239 s = 0; 2240 for (; s < e; ) 2241 if (n === x.BINARY) { 2242 if (e - s < 5) break; 2243 let o = $.readCode(t, s, 5); 2244 if (((s += 5), 0 === o)) { 2245 if (e - s < 11) break; 2246 (o = $.readCode(t, s, 11) + 31), (s += 11); 2247 } 2248 for (let r = 0; r < o; r++) { 2249 if (e - s < 8) { 2250 s = e; 2251 break; 2252 } 2253 const r = $.readCode(t, s, 8); 2254 (i += S.castAsNonUtf8Char(r)), (s += 8); 2255 } 2256 n = r; 2257 } else { 2258 let o = n === x.DIGIT ? 4 : 5; 2259 if (e - s < o) break; 2260 let a = $.readCode(t, s, o); 2261 s += o; 2262 let l = $.getCharacter(n, a); 2263 l.startsWith('CTRL_') 2264 ? ((r = n), (n = $.getTable(l.charAt(5))), 'L' === l.charAt(6) && (r = n)) 2265 : ((i += l), (n = r)); 2266 } 2267 return i; 2268 } 2269 static getTable(t) { 2270 switch (t) { 2271 case 'L': 2272 return x.LOWER; 2273 case 'P': 2274 return x.PUNCT; 2275 case 'M': 2276 return x.MIXED; 2277 case 'D': 2278 return x.DIGIT; 2279 case 'B': 2280 return x.BINARY; 2281 case 'U': 2282 default: 2283 return x.UPPER; 2284 } 2285 } 2286 static getCharacter(t, e) { 2287 switch (t) { 2288 case x.UPPER: 2289 return $.UPPER_TABLE[e]; 2290 case x.LOWER: 2291 return $.LOWER_TABLE[e]; 2292 case x.MIXED: 2293 return $.MIXED_TABLE[e];
2294 case x.PUNCT: 2295 return $.PUNCT_TABLE[e]; 2296 case x.DIGIT: 2297 return $.DIGIT_TABLE[e]; 2298 default: 2299 throw new j('Bad table'); 2300 } 2301 } 2302 correctBits(t) { 2303 let e, r; 2304 this.ddata.getNbLayers() <= 2 2305 ? ((r = 6), (e = q.AZTEC_DATA_6)) 2306 : this.ddata.getNbLayers() <= 8 2307 ? ((r = 8), (e = q.AZTEC_DATA_8)) 2308 : this.ddata.getNbLayers() <= 22 2309 ? ((r = 10), (e = q.AZTEC_DATA_10)) 2310 : ((r = 12), (e = q.AZTEC_DATA_12)); 2311 let n = this.ddata.getNbDatablocks(), 2312 i = t.length / r; 2313 if (i < n) throw new E(); 2314 let s = t.length % r, 2315 o = new Int32Array(i); 2316 for (let e = 0; e < i; e++, s += r) o[e] = $.readCode(t, s, r); 2317 try { 2318 new J(e).decode(o, i - n); 2319 } catch (t) { 2320 throw new E(t); 2321 } 2322 let a = (1 << r) - 1, 2323 l = 0; 2324 for (let t = 0; t < n; t++) { 2325 let e = o[t]; 2326 if (0 === e || e === a) throw new E(); 2327 (1 !== e && e !== a - 1) || l++; 2328 } 2329 let h = new Array(n * r - l), 2330 c = 0; 2331 for (let t = 0; t < n; t++) { 2332 let e = o[t]; 2333 if (1 === e || e === a - 1) h.fill(e > 1, c, c + r - 1), (c += r - 1); 2334 else for (let t = r - 1; t >= 0; --t) h[c++] = 0 != (e & (1 << t)); 2335 } 2336 return h; 2337 } 2338 extractBits(t) { 2339 let e = this.ddata.isCompact(), 2340 r = this.ddata.getNbLayers(), 2341 n = (e ? 11 : 14) + 4 * r, 2342 i = new Int32Array(n), 2343 s = new Array(this.totalBitsInLayer(r, e)); 2344 if (e) for (let t = 0; t < i.length; t++) i[t] = t; 2345 else { 2346 let t = n + 1 + 2 * f.truncDivision(f.truncDivision(n, 2) - 1, 15), 2347 e = n / 2, 2348 r = f.truncDivision(t, 2); 2349 for (let t = 0; t < e; t++) { 2350 let n = t + f.truncDivision(t, 15);
2351 (i[e - t - 1] = r - n - 1), (i[e + t] = r + n + 1); 2352 } 2353 } 2354 for (let o = 0, a = 0; o < r; o++) { 2355 let l = 4 * (r - o) + (e ? 9 : 12), 2356 h = 2 * o, 2357 c = n - 1 - h; 2358 for (let e = 0; e < l; e++) { 2359 let r = 2 * e; 2360 for (let n = 0; n < 2; n++) 2361 (s[a + r + n] = t.get(i[h + n], i[h + e])), 2362 (s[a + 2 * l + r + n] = t.get(i[h + e], i[c - n])), 2363 (s[a + 4 * l + r + n] = t.get(i[c - n], i[c - e])), 2364 (s[a + 6 * l + r + n] = t.get(i[c - e], i[h + n])); 2365 } 2366 a += 8 * l; 2367 } 2368 return s; 2369 } 2370 static readCode(t, e, r) { 2371 let n = 0; 2372 for (let i = e; i < e + r; i++) (n <<= 1), t[i] && (n |= 1); 2373 return n; 2374 } 2375 static readByte(t, e) { 2376 let r = t.length - e; 2377 return r >= 8 ? $.readCode(t, e, 8) : $.readCode(t, e, r) << (8 - r); 2378 } 2379 static convertBoolArrayToByteArray(t) { 2380 let e = new Uint8Array((t.length + 7) / 8); 2381 for (let r = 0; r < e.length; r++) e[r] = $.readByte(t, 8 * r); 2382 return e; 2383 } 2384 totalBitsInLayer(t, e) { 2385 return ((e ? 88 : 112) + 16 * t) * t; 2386 } 2387 } 2388 ($.UPPER_TABLE = [ 2389 'CTRL_PS', 2390 ' ', 2391 'A', 2392 'B', 2393 'C', 2394 'D', 2395 'E', 2396 'F', 2397 'G', 2398 'H', 2399 'I', 2400 'J', 2401 'K', 2402 'L', 2403 'M', 2404 'N', 2405 'O', 2406 'P', 2407 'Q', 2408 'R', 2409 'S', 2410 'T', 2411 'U', 2412 'V', 2413 'W', 2414 'X', 2415 'Y', 2416 'Z', 2417 'CTRL_LL', 2418 'CTRL_ML', 2419 'CTRL_DL', 2420 'CTRL_BS', 2421 ]), 2422 ($.LOWER_TABLE = [ 2423 'CTRL_PS', 2424 ' ', 2425 'a', 2426 'b', 2427 'c', 2428 'd', 2429 'e', 2430 'f', 2431 'g', 2432 'h', 2433 'i', 2434 'j', 2435 'k', 2436 'l', 2437 'm', 2438 'n', 2439 'o', 2440 'p', 2441 'q', 2442 'r', 2443 's', 2444 't', 2445 'u', 2446 'v', 2447 'w', 2448 'x', 2449 'y', 2450 'z', 2451 'CTRL_US', 2452 'CTRL_ML', 2453 'CTRL_DL', 2454 'CTRL_BS', 2455 ]), 2456 ($.MIXED_TABLE = [ 2457 'CTRL_PS', 2458 ' ', 2459 '\\1', 2460 '\\2', 2461 '\\3', 2462 '\\4', 2463 '\\5', 2464 '\\6', 2465 '\\7', 2466 '\b', 2467 '\t', 2468 '\n', 2469 '\\13', 2470 '\f', 2471 '\r', 2472 '\\33', 2473 '\\34', 2474 '\\35', 2475 '\\36', 2476 '\\37', 2477 '@', 2478 '\\', 2479 '^', 2480 '_', 2481 '`', 2482 '|', 2483 '~', 2484 '\\177', 2485 'CTRL_LL', 2486 'CTRL_UL', 2487 'CTRL_PL', 2488 'CTRL_BS', 2489 ]), 2490 ($.PUNCT_TABLE = [ 2491 '', 2492 '\r', 2493 '\r\n', 2494 '. ', 2495 ', ', 2496 ': ', 2497 '!', 2498 '"', 2499 '#', 2500 '$', 2501 '%', 2502 '&', 2503 "'", 2504 '(', 2505 ')', 2506 '*', 2507 '+', 2508 ',', 2509 '-', 2510 '.', 2511 '/', 2512 ':', 2513 ';', 2514 '<', 2515 '=', 2516 '>', 2517 '?', 2518 '[', 2519 ']', 2520 '{', 2521 '}', 2522 'CTRL_UL', 2523 ]), 2524 ($.DIGIT_TABLE = [ 2525 'CTRL_PS', 2526 ' ', 2527 '0', 2528 '1', 2529 '2', 2530 '3', 2531 '4', 2532 '5', 2533 '6', 2534 '7', 2535 '8', 2536 '9', 2537 ',', 2538 '.', 2539 'CTRL_UL', 2540 'CTRL_US', 2541 ]); 2542 class tt { 2543 constructor() {} 2544 static round(t) { 2545 return NaN === t 2546 ? 0 2547 : t <= Number.MIN_SAFE_INTEGER 2548 ? Number.MIN_SAFE_INTEGER 2549 : t >= Number.MAX_SAFE_INTEGER 2550 ? Number.MAX_SAFE_INTEGER 2551 : (t + (t < 0 ? -0.5 : 0.5)) | 0; 2552 } 2553 static distance(t, e, r, n) { 2554 const i = t - r, 2555 s = e - n; 2556 return Math.sqrt(i * i + s * s); 2557 } 2558 static sum(t) { 2559 let e = 0; 2560 for (let r = 0, n = t.length; r !== n; r++) { 2561 e += t[r]; 2562 } 2563 return e; 2564 } 2565 } 2566 class et { 2567 static floatToIntBits(t) { 2568 return t; 2569 } 2570 } 2571 et.MAX_VALUE = Number.MAX_SAFE_INTEGER; 2572 class rt { 2573 constructor(t, e) { 2574 (this.x = t), (this.y = e); 2575 } 2576 getX() { 2577 return this.x; 2578 } 2579 getY() { 2580 return this.y; 2581 } 2582 equals(t) { 2583 if (t instanceof rt) { 2584 const e = t; 2585 return this.x === e.x && this.y === e.y; 2586 } 2587 return !1; 2588 } 2589 hashCode() {
2590 return 31 * et.floatToIntBits(this.x) + et.floatToIntBits(this.y); 2591 } 2592 toString() { 2593 return '(' + this.x + ',' + this.y + ')'; 2594 } 2595 static orderBestPatterns(t) { 2596 const e = this.distance(t[0], t[1]), 2597 r = this.distance(t[1], t[2]), 2598 n = this.distance(t[0], t[2]); 2599 let i, s, o; 2600 if ( 2601 (r >= e && r >= n 2602 ? ((s = t[0]), (i = t[1]), (o = t[2])) 2603 : n >= r && n >= e 2604 ? ((s = t[1]), (i = t[0]), (o = t[2])) 2605 : ((s = t[2]), (i = t[0]), (o = t[1])), 2606 this.crossProductZ(i, s, o) < 0) 2607 ) { 2608 const t = i; 2609 (i = o), (o = t); 2610 } 2611 (t[0] = i), (t[1] = s), (t[2] = o); 2612 } 2613 static distance(t, e) { 2614 return tt.distance(t.x, t.y, e.x, e.y); 2615 } 2616 static crossProductZ(t, e, r) { 2617 const n = e.x, 2618 i = e.y; 2619 return (r.x - n) * (t.y - i) - (r.y - i) * (t.x - n); 2620 } 2621 } 2622 class nt { 2623 constructor(t, e) { 2624 (this.bits = t), (this.points = e); 2625 } 2626 getBits() { 2627 return this.bits; 2628 } 2629 getPoints() { 2630 return this.points; 2631 } 2632 } 2633 class it extends nt { 2634 constructor(t, e, r, n, i) { 2635 super(t, e), (this.compact = r), (this.nbDatablocks = n), (this.nbLayers = i); 2636 } 2637 getNbLayers() { 2638 return this.nbLayers; 2639 } 2640 getNbDatablocks() { 2641 return this.nbDatablocks; 2642 } 2643 isCompact() { 2644 return this.compact; 2645 } 2646 } 2647 class st { 2648 constructor(t, e, r, n) { 2649 (this.image = t), 2650 (this.height = t.getHeight()), 2651 (this.width = t.getWidth()), 2652 null == e && (e = st.INIT_SIZE), 2653 null == r && (r = (t.getWidth() / 2) | 0), 2654 null == n && (n = (t.getHeight() / 2) | 0); 2655 const i = (e / 2) | 0; 2656 if ( 2657 ((this.leftInit = r - i), 2658 (this.rightInit = r + i), 2659 (this.upInit = n - i), 2660 (this.downInit = n + i), 2661 this.upInit < 0 || this.leftInit < 0 || this.downInit >= this.height || this.rightInit >= this.width) 2662 ) 2663 throw new R(); 2664 } 2665 detect() { 2666 let t = this.leftInit, 2667 e = this.rightInit, 2668 r = this.upInit, 2669 n = this.downInit, 2670 i = !1, 2671 s = !0, 2672 o = !1, 2673 a = !1, 2674 l = !1, 2675 h = !1, 2676 c = !1; 2677 const u = this.width, 2678 d = this.height; 2679 for (; s; ) { 2680 s = !1; 2681 let g = !0; 2682 for (; (g || !a) && e < u; ) 2683 (g = this.containsBlackPoint(r, n, e, !1)), g ? (e++, (s = !0), (a = !0)) : a || e++; 2684 if (e >= u) { 2685 i = !0; 2686 break; 2687 } 2688 let f = !0; 2689 for (; (f || !l) && n < d; ) 2690 (f = this.containsBlackPoint(t, e, n, !0)), f ? (n++, (s = !0), (l = !0)) : l || n++; 2691 if (n >= d) { 2692 i = !0; 2693 break; 2694 } 2695 let w = !0; 2696 for (; (w || !h) && t >= 0; ) 2697 (w = this.containsBlackPoint(r, n, t, !1)), w ? (t--, (s = !0), (h = !0)) : h || t--; 2698 if (t < 0) { 2699 i = !0; 2700 break; 2701 } 2702 let A = !0; 2703 for (; (A || !c) && r >= 0; ) 2704 (A = this.containsBlackPoint(t, e, r, !0)), A ? (r--, (s = !0), (c = !0)) : c || r--; 2705 if (r < 0) { 2706 i = !0; 2707 break; 2708 } 2709 s && (o = !0); 2710 } 2711 if (!i && o) { 2712 const i = e - t; 2713 let s = null; 2714 for (let e = 1; null === s && e < i; e++) s = this.getBlackPointOnSegment(t, n - e, t + e, n); 2715 if (null == s) throw new R(); 2716 let o = null; 2717 for (let e = 1; null === o && e < i; e++) o = this.getBlackPointOnSegment(t, r + e, t + e, r); 2718 if (null == o) throw new R(); 2719 let a = null; 2720 for (let t = 1; null === a && t < i; t++) a = this.getBlackPointOnSegment(e, r + t, e - t, r); 2721 if (null == a) throw new R(); 2722 let l = null; 2723 for (let t = 1; null === l && t < i; t++) l = this.getBlackPointOnSegment(e, n - t, e - t, n); 2724 if (null == l) throw new R(); 2725 return this.centerEdges(l, s, a, o); 2726 } 2727 throw new R(); 2728 } 2729 getBlackPointOnSegment(t, e, r, n) { 2730 const i = tt.round(tt.distance(t, e, r, n)), 2731 s = (r - t) / i, 2732 o = (n - e) / i, 2733 a = this.image; 2734 for (let r = 0; r < i; r++) { 2735 const n = tt.round(t + r * s), 2736 i = tt.round(e + r * o); 2737 if (a.get(n, i)) return new rt(n, i); 2738 } 2739 return null; 2740 } 2741 centerEdges(t, e, r, n) { 2742 const i = t.getX(), 2743 s = t.getY(), 2744 o = e.getX(), 2745 a = e.getY(), 2746 l = r.getX(), 2747 h = r.getY(), 2748 c = n.getX(), 2749 u = n.getY(), 2750 d = st.CORR; 2751 return i < this.width / 2 2752 ? [new rt(c - d, u + d), new rt(o + d, a + d), new rt(l - d, h - d), new rt(i + d, s - d)] 2753 : [new rt(c + d, u + d), new rt(o + d, a - d), new rt(l - d, h + d), new rt(i - d, s - d)]; 2754 } 2755 containsBlackPoint(t, e, r, n) { 2756 const i = this.image; 2757 if (n) { 2758 for (let n = t; n <= e; n++) if (i.get(n, r)) return !0; 2759 } else for (let n = t; n <= e; n++) if (i.get(r, n)) return !0; 2760 return !1; 2761 } 2762 } 2763 (st.INIT_SIZE = 10), (st.CORR = 1); 2764 class ot { 2765 static checkAndNudgePoints(t, e) { 2766 const r = t.getWidth(), 2767 n = t.getHeight(); 2768 let i = !0; 2769 for (let t = 0; t < e.length && i; t += 2) { 2770 const s = Math.floor(e[t]), 2771 o = Math.floor(e[t + 1]); 2772 if (s < -1 || s > r || o < -1 || o > n) throw new R(); 2773 (i = !1), 2774 -1 === s ? ((e[t] = 0), (i = !0)) : s === r && ((e[t] = r - 1), (i = !0)), 2775 -1 === o ? ((e[t + 1] = 0), (i = !0)) : o === n && ((e[t + 1] = n - 1), (i = !0)); 2776 } 2777 i = !0; 2778 for (let t = e.length - 2; t >= 0 && i; t -= 2) { 2779 const s = Math.floor(e[t]), 2780 o = Math.floor(e[t + 1]); 2781 if (s < -1 || s > r || o < -1 || o > n) throw new R(); 2782 (i = !1), 2783 -1 === s ? ((e[t] = 0), (i = !0)) : s === r && ((e[t] = r - 1), (i = !0)), 2784 -1 === o ? ((e[t + 1] = 0), (i = !0)) : o === n && ((e[t + 1] = n - 1), (i = !0)); 2785 } 2786 } 2787 } 2788 class at { 2789 constructor(t, e, r, n, i, s, o, a, l) { 2790 (this.a11 = t), 2791 (this.a21 = e), 2792 (this.a31 = r), 2793 (this.a12 = n), 2794 (this.a22 = i), 2795 (this.a32 = s), 2796 (this.a13 = o), 2797 (this.a23 = a), 2798 (this.a33 = l); 2799 } 2800 static quadrilateralToQuadrilateral(t, e, r, n, i, s, o, a, l, h, c, u, d, g, f, w) { 2801 const A = at.quadrilateralToSquare(t, e, r, n, i, s, o, a); 2802 return at.squareToQuadrilateral(l, h, c, u, d, g, f, w).times(A); 2803 } 2804 transformPoints(t) { 2805 const e = t.length, 2806 r = this.a11, 2807 n = this.a12, 2808 i = this.a13, 2809 s = this.a21, 2810 o = this.a22, 2811 a = this.a23, 2812 l = this.a31, 2813 h = this.a32, 2814 c = this.a33; 2815 for (let u = 0; u < e; u += 2) { 2816 const e = t[u], 2817 d = t[u + 1], 2818 g = i * e + a * d + c; 2819 (t[u] = (r * e + s * d + l) / g), (t[u + 1] = (n * e + o * d + h) / g); 2820 } 2821 } 2822 transformPointsWithValues(t, e) { 2823 const r = this.a11, 2824 n = this.a12, 2825 i = this.a13, 2826 s = this.a21, 2827 o = this.a22, 2828 a = this.a23, 2829 l = this.a31, 2830 h = this.a32, 2831 c = this.a33, 2832 u = t.length; 2833 for (let d = 0; d < u; d++) { 2834 const u = t[d], 2835 g = e[d], 2836 f = i * u + a * g + c;
2837 (t[d] = (r * u + s * g + l) / f), (e[d] = (n * u + o * g + h) / f); 2838 } 2839 } 2840 static squareToQuadrilateral(t, e, r, n, i, s, o, a) { 2841 const l = t - r + i - o, 2842 h = e - n + s - a; 2843 if (0 === l && 0 === h) return new at(r - t, i - r, t, n - e, s - n, e, 0, 0, 1); 2844 { 2845 const c = r - i, 2846 u = o - i, 2847 d = n - s, 2848 g = a - s, 2849 f = c * g - u * d, 2850 w = (l * g - u * h) / f, 2851 A = (c * h - l * d) / f; 2852 return new at(r - t + w * r, o - t + A * o, t, n - e + w * n, a - e + A * a, e, w, A, 1); 2853 } 2854 } 2855 static quadrilateralToSquare(t, e, r, n, i, s, o, a) { 2856 return at.squareToQuadrilateral(t, e, r, n, i, s, o, a).buildAdjoint(); 2857 } 2858 buildAdjoint() { 2859 return new at( 2860 this.a22 * this.a33 - this.a23 * this.a32, 2861 this.a23 * this.a31 - this.a21 * this.a33, 2862 this.a21 * this.a32 - this.a22 * this.a31, 2863 this.a13 * this.a32 - this.a12 * this.a33, 2864 this.a11 * this.a33 - this.a13 * this.a31, 2865 this.a12 * this.a31 - this.a11 * this.a32, 2866 this.a12 * this.a23 - this.a13 * this.a22, 2867 this.a13 * this.a21 - this.a11 * this.a23, 2868 this.a11 * this.a22 - this.a12 * this.a21, 2869 ); 2870 } 2871 times(t) { 2872 return new at( 2873 this.a11 * t.a11 + this.a21 * t.a12 + this.a31 * t.a13, 2874 this.a11 * t.a21 + this.a21 * t.a22 + this.a31 * t.a23, 2875 this.a11 * t.a31 + this.a21 * t.a32 + this.a31 * t.a33, 2876 this.a12 * t.a11 + this.a22 * t.a12 + this.a32 * t.a13, 2877 this.a12 * t.a21 + this.a22 * t.a22 + this.a32 * t.a23, 2878 this.a12 * t.a31 + this.a22 * t.a32 + this.a32 * t.a33, 2879 this.a13 * t.a11 + this.a23 * t.a12 + this.a33 * t.a13, 2880 this.a13 * t.a21 + this.a23 * t.a22 + this.a33 * t.a23, 2881 this.a13 * t.a31 + this.a23 * t.a32 + this.a33 * t.a33, 2882 ); 2883 } 2884 } 2885 class lt extends ot { 2886 sampleGrid(t, e, r, n, i, s, o, a, l, h, c, u, d, g, f, w, A, C, E) { 2887 const m = at.quadrilateralToQuadrilateral(n, i, s, o, a, l, h, c, u, d, g, f, w, A, C, E); 2888 return this.sampleGridWithTransform(t, e, r, m); 2889 } 2890 sampleGridWithTransform(t, e, r, n) { 2891 if (e <= 0 || r <= 0) throw new R(); 2892 const i = new T(e, r), 2893 s = new Float32Array(2 * e); 2894 for (let e = 0; e < r; e++) { 2895 const r = s.length, 2896 o = e + 0.5; 2897 for (let t = 0; t < r; t += 2) (s[t] = t / 2 + 0.5), (s[t + 1] = o); 2898 n.transformPoints(s), ot.checkAndNudgePoints(t, s); 2899 try { 2900 for (let n = 0; n < r; n += 2) t.get(Math.floor(s[n]), Math.floor(s[n + 1])) && i.set(n / 2, e); 2901 } catch (t) { 2902 throw new R(); 2903 } 2904 } 2905 return i; 2906 } 2907 } 2908 class ht { 2909 static setGridSampler(t) { 2910 ht.gridSampler = t; 2911 } 2912 static getInstance() { 2913 return ht.gridSampler; 2914 } 2915 } 2916 ht.gridSampler = new lt(); 2917 class ct { 2918 constructor(t, e) { 2919 (this.x = t), (this.y = e); 2920 } 2921 toResultPoint() { 2922 return new rt(this.getX(), this.getY()); 2923 } 2924 getX() { 2925 return this.x; 2926 } 2927 getY() { 2928 return this.y; 2929 } 2930 } 2931 class ut { 2932 constructor(t) { 2933 (this.EXPECTED_CORNER_BITS = new Int32Array([3808, 476, 2107, 1799])), (this.image = t); 2934 } 2935 detect() { 2936 return this.detectMirror(!1); 2937 } 2938 detectMirror(t) { 2939 let e = this.getMatrixCenter(), 2940 r = this.getBullsEyeCorners(e); 2941 if (t) { 2942 let t = r[0]; 2943 (r[0] = r[2]), (r[2] = t); 2944 } 2945 this.extractParameters(r); 2946 let n = this.sampleGrid( 2947 this.image, 2948 r[this.shift % 4], 2949 r[(this.shift + 1) % 4], 2950 r[(this.shift + 2) % 4], 2951 r[(this.shift + 3) % 4], 2952 ), 2953 i = this.getMatrixCornerPoints(r); 2954 return new it(n, i, this.compact, this.nbDataBlocks, this.nbLayers); 2955 } 2956 extractParameters(t) { 2957 if (!(this.isValidPoint(t[0]) && this.isValidPoint(t[1]) && this.isValidPoint(t[2]) && this.isValidPoint(t[3]))) 2958 throw new R(); 2959 let e = 2 * this.nbCenterLayers, 2960 r = new Int32Array([ 2961 this.sampleLine(t[0], t[1], e), 2962 this.sampleLine(t[1], t[2], e), 2963 this.sampleLine(t[2], t[3], e), 2964 this.sampleLine(t[3], t[0], e), 2965 ]); 2966 this.shift = this.getRotation(r, e); 2967 let n = 0; 2968 for (let t = 0; t < 4; t++) { 2969 let e = r[(this.shift + t) % 4]; 2970 this.compact ? ((n <<= 7), (n += (e >> 1) & 127)) : ((n <<= 10), (n += ((e >> 2) & 992) + ((e >> 1) & 31))); 2971 } 2972 let i = this.getCorrectedParameterData(n, this.compact); 2973 this.compact 2974 ? ((this.nbLayers = 1 + (i >> 6)), (this.nbDataBlocks = 1 + (63 & i))) 2975 : ((this.nbLayers = 1 + (i >> 11)), (this.nbDataBlocks = 1 + (2047 & i))); 2976 } 2977 getRotation(t, e) { 2978 let r = 0; 2979 t.forEach((t, n, i) => { 2980 r = (r << 3) + (((t >> (e - 2)) << 1) + (1 & t));
2981 }), 2982 (r = ((1 & r) << 11) + (r >> 1)); 2983 for (let t = 0; t < 4; t++) if (f.bitCount(r ^ this.EXPECTED_CORNER_BITS[t]) <= 2) return t; 2984 throw new R(); 2985 } 2986 getCorrectedParameterData(t, e) { 2987 let r, n; 2988 e ? ((r = 7), (n = 2)) : ((r = 10), (n = 4)); 2989 let i = r - n, 2990 s = new Int32Array(r); 2991 for (let e = r - 1; e >= 0; --e) (s[e] = 15 & t), (t >>= 4); 2992 try { 2993 new J(q.AZTEC_PARAM).decode(s, i); 2994 } catch (t) { 2995 throw new R(); 2996 } 2997 let o = 0; 2998 for (let t = 0; t < n; t++) o = (o << 4) + s[t]; 2999 return o; 3000 } 3001 getBullsEyeCorners(t) { 3002 let e = t, 3003 r = t, 3004 n = t, 3005 i = t, 3006 s = !0; 3007 for (this.nbCenterLayers = 1; this.nbCenterLayers < 9; this.nbCenterLayers++) { 3008 let t = this.getFirstDifferent(e, s, 1, -1), 3009 o = this.getFirstDifferent(r, s, 1, 1), 3010 a = this.getFirstDifferent(n, s, -1, 1), 3011 l = this.getFirstDifferent(i, s, -1, -1); 3012 if (this.nbCenterLayers > 2) { 3013 let r = 3014 (this.distancePoint(l, t) * this.nbCenterLayers) / (this.distancePoint(i, e) * (this.nbCenterLayers + 2)); 3015 if (r < 0.75 || r > 1.25 || !this.isWhiteOrBlackRectangle(t, o, a, l)) break; 3016 } 3017 (e = t), (r = o), (n = a), (i = l), (s = !s); 3018 } 3019 if (5 !== this.nbCenterLayers && 7 !== this.nbCenterLayers) throw new R(); 3020 this.compact = 5 === this.nbCenterLayers; 3021 let o = new rt(e.getX() + 0.5, e.getY() - 0.5), 3022 a = new rt(r.getX() + 0.5, r.getY() + 0.5), 3023 l = new rt(n.getX() - 0.5, n.getY() + 0.5), 3024 h = new rt(i.getX() - 0.5, i.getY() - 0.5); 3025 return this.expandSquare([o, a, l, h], 2 * this.nbCenterLayers - 3, 2 * this.nbCenterLayers); 3026 } 3027 getMatrixCenter() { 3028 let t, e, r, n; 3029 try { 3030 let i = new st(this.image).detect(); 3031 (t = i[0]), (e = i[1]), (r = i[2]), (n = i[3]); 3032 } catch (i) { 3033 let s = this.image.getWidth() / 2, 3034 o = this.image.getHeight() / 2; 3035 (t = this.getFirstDifferent(new ct(s + 7, o - 7), !1, 1, -1).toResultPoint()), 3036 (e = this.getFirstDifferent(new ct(s + 7, o + 7), !1, 1, 1).toResultPoint()), 3037 (r = this.getFirstDifferent(new ct(s - 7, o + 7), !1, -1, 1).toResultPoint()), 3038 (n = this.getFirstDifferent(new ct(s - 7, o - 7), !1, -1, -1).toResultPoint()); 3039 } 3040 let i = tt.round((t.getX() + n.getX() + e.getX() + r.getX()) / 4), 3041 s = tt.round((t.getY() + n.getY() + e.getY() + r.getY()) / 4); 3042 try { 3043 let o = new st(this.image, 15, i, s).detect(); 3044 (t = o[0]), (e = o[1]), (r = o[2]), (n = o[3]); 3045 } catch (o) { 3046 (t = this.getFirstDifferent(new ct(i + 7, s - 7), !1, 1, -1).toResultPoint()), 3047 (e = this.getFirstDifferent(new ct(i + 7, s + 7), !1, 1, 1).toResultPoint()), 3048 (r = this.getFirstDifferent(new ct(i - 7, s + 7), !1, -1, 1).toResultPoint()), 3049 (n = this.getFirstDifferent(new ct(i - 7, s - 7), !1, -1, -1).toResultPoint()); 3050 } 3051 return ( 3052 (i = tt.round((t.getX() + n.getX() + e.getX() + r.getX()) / 4)), 3053 (s = tt.round((t.getY() + n.getY() + e.getY() + r.getY()) / 4)), 3054 new ct(i, s) 3055 ); 3056 } 3057 getMatrixCornerPoints(t) { 3058 return this.expandSquare(t, 2 * this.nbCenterLayers, this.getDimension()); 3059 } 3060 sampleGrid(t, e, r, n, i) { 3061 let s = ht.getInstance(), 3062 o = this.getDimension(), 3063 a = o / 2 - this.nbCenterLayers, 3064 l = o / 2 + this.nbCenterLayers; 3065 return s.sampleGrid( 3066 t, 3067 o, 3068 o, 3069 a, 3070 a, 3071 l, 3072 a, 3073 l, 3074 l, 3075 a, 3076 l, 3077 e.getX(), 3078 e.getY(), 3079 r.getX(), 3080 r.getY(), 3081 n.getX(), 3082 n.getY(), 3083 i.getX(), 3084 i.getY(), 3085 ); 3086 } 3087 sampleLine(t, e, r) { 3088 let n = 0, 3089 i = this.distanceResultPoint(t, e), 3090 s = i / r, 3091 o = t.getX(), 3092 a = t.getY(), 3093 l = (s * (e.getX() - t.getX())) / i, 3094 h = (s * (e.getY() - t.getY())) / i; 3095 for (let t = 0; t < r; t++) this.image.get(tt.round(o + t * l), tt.round(a + t * h)) && (n |= 1 << (r - t - 1)); 3096 return n; 3097 } 3098 isWhiteOrBlackRectangle(t, e, r, n) { 3099 (t = new ct(t.getX() - 3, t.getY() + 3)), 3100 (e = new ct(e.getX() - 3, e.getY() - 3)), 3101 (r = new ct(r.getX() + 3, r.getY() - 3)), 3102 (n = new ct(n.getX() + 3, n.getY() + 3)); 3103 let i = this.getColor(n, t); 3104 if (0 === i) return !1; 3105 let s = this.getColor(t, e); 3106 return s === i && ((s = this.getColor(e, r)), s === i && ((s = this.getColor(r, n)), s === i)); 3107 } 3108 getColor(t, e) { 3109 let r = this.distancePoint(t, e), 3110 n = (e.getX() - t.getX()) / r, 3111 i = (e.getY() - t.getY()) / r, 3112 s = 0, 3113 o = t.getX(), 3114 a = t.getY(), 3115 l = this.image.get(t.getX(), t.getY()), 3116 h = Math.ceil(r); 3117 for (let t = 0; t < h; t++) (o += n), (a += i), this.image.get(tt.round(o), tt.round(a)) !== l && s++; 3118 let c = s / r; 3119 return c > 0.1 && c < 0.9 ? 0 : c <= 0.1 === l ? 1 : -1; 3120 } 3121 getFirstDifferent(t, e, r, n) { 3122 let i = t.getX() + r, 3123 s = t.getY() + n; 3124 for (; this.isValid(i, s) && this.image.get(i, s) === e; ) (i += r), (s += n); 3125 for (i -= r, s -= n; this.isValid(i, s) && this.image.get(i, s) === e; ) i += r; 3126 for (i -= r; this.isValid(i, s) && this.image.get(i, s) === e; ) s += n; 3127 return (s -= n), new ct(i, s); 3128 } 3129 expandSquare(t, e, r) { 3130 let n = r / (2 * e), 3131 i = t[0].getX() - t[2].getX(), 3132 s = t[0].getY() - t[2].getY(), 3133 o = (t[0].getX() + t[2].getX()) / 2, 3134 a = (t[0].getY() + t[2].getY()) / 2, 3135 l = new rt(o + n * i, a + n * s), 3136 h = new rt(o - n * i, a - n * s); 3137 return ( 3138 (i = t[1].getX() - t[3].getX()), 3139 (s = t[1].getY() - t[3].getY()), 3140 (o = (t[1].getX() + t[3].getX()) / 2), 3141 (a = (t[1].getY() + t[3].getY()) / 2), 3142 [l, new rt(o + n * i, a + n * s), h, new rt(o - n * i, a - n * s)] 3143 ); 3144 } 3145 isValid(t, e) { 3146 return t >= 0 && t < this.image.getWidth() && e > 0 && e < this.image.getHeight(); 3147 } 3148 isValidPoint(t) { 3149 let e = tt.round(t.getX()), 3150 r = tt.round(t.getY()); 3151 return this.isValid(e, r); 3152 } 3153 distancePoint(t, e) { 3154 return tt.distance(t.getX(), t.getY(), e.getX(), e.getY()); 3155 } 3156 distanceResultPoint(t, e) { 3157 return tt.distance(t.getX(), t.getY(), e.getX(), e.getY()); 3158 } 3159 getDimension() { 3160 return this.compact 3161 ? 4 * this.nbLayers + 11 3162 : this.nbLayers <= 4 3163 ? 4 * this.nbLayers + 15 3164 : 4 * this.nbLayers + 2 * (f.truncDivision(this.nbLayers - 4, 8) + 1) + 15; 3165 } 3166 } 3167 class dt { 3168 decode(t, e = null) { 3169 let r = null, 3170 n = new ut(t.getBlackMatrix()), 3171 i = null, 3172 s = null;
3173 try { 3174 let t = n.detectMirror(!1); 3175 (i = t.getPoints()), this.reportFoundResultPoints(e, i), (s = new $().decode(t)); 3176 } catch (t) { 3177 r = t; 3178 } 3179 if (null == s) 3180 try { 3181 let t = n.detectMirror(!0); 3182 (i = t.getPoints()), this.reportFoundResultPoints(e, i), (s = new $().decode(t)); 3183 } catch (t) { 3184 if (null != r) throw r; 3185 throw t; 3186 } 3187 let o = new F(s.getText(), s.getRawBytes(), s.getNumBits(), i, v.AZTEC, c.currentTimeMillis()), 3188 a = s.getByteSegments(); 3189 null != a && o.putMetadata(W.BYTE_SEGMENTS, a); 3190 let l = s.getECLevel(); 3191 return null != l && o.putMetadata(W.ERROR_CORRECTION_LEVEL, l), o; 3192 } 3193 reportFoundResultPoints(t, e) { 3194 if (null != t) { 3195 let r = t.get(C.NEED_RESULT_POINT_CALLBACK); 3196 null != r && 3197 e.forEach((t, e, n) => { 3198 r.foundPossibleResultPoint(t); 3199 }); 3200 } 3201 } 3202 reset() {} 3203 } 3204 class gt { 3205 decode(t, e) { 3206 try { 3207 return this.doDecode(t, e); 3208 } catch (r) { 3209 if (e && !0 === e.get(C.TRY_HARDER) && t.isRotateSupported()) { 3210 const r = t.rotateCounterClockwise(), 3211 n = this.doDecode(r, e), 3212 i = n.getResultMetadata(); 3213 let s = 270; 3214 null !== i && !0 === i.get(W.ORIENTATION) && (s += i.get(W.ORIENTATION) % 360), 3215 n.putMetadata(W.ORIENTATION, s); 3216 const o = n.getResultPoints(); 3217 if (null !== o) { 3218 const t = r.getHeight(); 3219 for (let e = 0; e < o.length; e++) o[e] = new rt(t - o[e].getY() - 1, o[e].getX()); 3220 } 3221 return n; 3222 } 3223 throw new R(); 3224 } 3225 } 3226 reset() {} 3227 doDecode(t, e) { 3228 const r = t.getWidth(), 3229 n = t.getHeight(); 3230 let i = new w(r); 3231 const s = e && !0 === e.get(C.TRY_HARDER), 3232 o = Math.max(1, n >> (s ? 8 : 5)); 3233 let a; 3234 a = s ? n : 15; 3235 const l = Math.trunc(n / 2); 3236 for (let s = 0; s < a; s++) { 3237 const a = Math.trunc((s + 1) / 2), 3238 h = l + o * (0 == (1 & s) ? a : -a); 3239 if (h < 0 || h >= n) break; 3240 try { 3241 i = t.getBlackRow(h, i); 3242 } catch (t) { 3243 continue; 3244 } 3245 for (let t = 0; t < 2; t++) { 3246 if (1 === t && (i.reverse(), e && !0 === e.get(C.NEED_RESULT_POINT_CALLBACK))) { 3247 const t = new Map(); 3248 e.forEach((e, r) => t.set(r, e)), t.delete(C.NEED_RESULT_POINT_CALLBACK), (e = t); 3249 } 3250 try { 3251 const n = this.decodeRow(h, i, e); 3252 if (1 === t) { 3253 n.putMetadata(W.ORIENTATION, 180); 3254 const t = n.getResultPoints(); 3255 null !== t && 3256 ((t[0] = new rt(r - t[0].getX() - 1, t[0].getY())), (t[1] = new rt(r - t[1].getX() - 1, t[1].getY()))); 3257 } 3258 return n; 3259 } catch (t) {} 3260 } 3261 } 3262 throw new R(); 3263 } 3264 static recordPattern(t, e, r) { 3265 const n = r.length; 3266 for (let t = 0; t < n; t++) r[t] = 0; 3267 const i = t.getSize(); 3268 if (e >= i) throw new R(); 3269 let s = !t.get(e), 3270 o = 0, 3271 a = e; 3272 for (; a < i; ) { 3273 if (t.get(a) !== s) r[o]++; 3274 else { 3275 if (++o === n) break; 3276 (r[o] = 1), (s = !s); 3277 } 3278 a++; 3279 } 3280 if (o !== n && (o !== n - 1 || a !== i)) throw new R(); 3281 } 3282 static recordPatternInReverse(t, e, r) { 3283 let n = r.length, 3284 i = t.get(e); 3285 for (; e > 0 && n >= 0; ) t.get(--e) !== i && (n--, (i = !i)); 3286 if (n >= 0) throw new R(); 3287 gt.recordPattern(t, e + 1, r); 3288 } 3289 static patternMatchVariance(t, e, r) { 3290 const n = t.length; 3291 let i = 0, 3292 s = 0; 3293 for (let r = 0; r < n; r++) (i += t[r]), (s += e[r]); 3294 if (i < s) return Number.POSITIVE_INFINITY; 3295 const o = i / s; 3296 r *= o; 3297 let a = 0; 3298 for (let i = 0; i < n; i++) { 3299 const n = t[i], 3300 s = e[i] * o, 3301 l = n > s ? n - s : s - n; 3302 if (l > r) return Number.POSITIVE_INFINITY; 3303 a += l; 3304 } 3305 return a / i; 3306 } 3307 } 3308 class ft extends gt { 3309 static findStartPattern(t) { 3310 const e = t.getSize(), 3311 r = t.getNextSet(0); 3312 let n = 0, 3313 i = Int32Array.from([0, 0, 0, 0, 0, 0]), 3314 s = r, 3315 o = !1; 3316 for (let a = r; a < e; a++) 3317 if (t.get(a) !== o) i[n]++; 3318 else { 3319 if (5 === n) {
3320 let e = ft.MAX_AVG_VARIANCE, 3321 r = -1; 3322 for (let t = ft.CODE_START_A; t <= ft.CODE_START_C; t++) { 3323 const n = gt.patternMatchVariance(i, ft.CODE_PATTERNS[t], ft.MAX_INDIVIDUAL_VARIANCE); 3324 n < e && ((e = n), (r = t)); 3325 } 3326 if (r >= 0 && t.isRange(Math.max(0, s - (a - s) / 2), s, !1)) return Int32Array.from([s, a, r]); 3327 (s += i[0] + i[1]), (i = i.slice(2, i.length - 1)), (i[n - 1] = 0), (i[n] = 0), n--; 3328 } else n++; 3329 (i[n] = 1), (o = !o); 3330 } 3331 throw new R(); 3332 } 3333 static decodeCode(t, e, r) { 3334 gt.recordPattern(t, r, e); 3335 let n = ft.MAX_AVG_VARIANCE, 3336 i = -1; 3337 for (let t = 0; t < ft.CODE_PATTERNS.length; t++) { 3338 const r = ft.CODE_PATTERNS[t], 3339 s = this.patternMatchVariance(e, r, ft.MAX_INDIVIDUAL_VARIANCE); 3340 s < n && ((n = s), (i = t)); 3341 } 3342 if (i >= 0) return i; 3343 throw new R(); 3344 } 3345 decodeRow(t, e, r) { 3346 const n = r && !0 === r.get(C.ASSUME_GS1), 3347 i = ft.findStartPattern(e), 3348 s = i[2]; 3349 let o = 0; 3350 const a = new Uint8Array(20); 3351 let h; 3352 switch (((a[o++] = s), s)) { 3353 case ft.CODE_START_A: 3354 h = ft.CODE_CODE_A; 3355 break; 3356 case ft.CODE_START_B: 3357 h = ft.CODE_CODE_B; 3358 break; 3359 case ft.CODE_START_C: 3360 h = ft.CODE_CODE_C; 3361 break; 3362 default: 3363 throw new E(); 3364 } 3365 let c = !1, 3366 u = !1, 3367 d = '', 3368 g = i[0], 3369 f = i[1]; 3370 const w = Int32Array.from([0, 0, 0, 0, 0, 0]); 3371 let A = 0, 3372 m = 0, 3373 _ = s, 3374 I = 0, 3375 S = !0, 3376 p = !1, 3377 T = !1; 3378 for (; !c; ) { 3379 const t = u; 3380 switch ( 3381 ((u = !1), 3382 (A = m), 3383 (m = ft.decodeCode(e, w, f)), 3384 (a[o++] = m), 3385 m !== ft.CODE_STOP && (S = !0), 3386 m !== ft.CODE_STOP && (I++, (_ += I * m)), 3387 (g = f), 3388 (f += w.reduce((t, e) => t + e, 0)), 3389 m) 3390 ) { 3391 case ft.CODE_START_A: 3392 case ft.CODE_START_B: 3393 case ft.CODE_START_C: 3394 throw new E(); 3395 } 3396 switch (h) { 3397 case ft.CODE_CODE_A: 3398 if (m < 64) 3399 (d += 3400 T === p 3401 ? String.fromCharCode(' '.charCodeAt(0) + m) 3402 : String.fromCharCode(' '.charCodeAt(0) + m + 128)), 3403 (T = !1); 3404 else if (m < 96) (d += T === p ? String.fromCharCode(m - 64) : String.fromCharCode(m + 64)), (T = !1); 3405 else 3406 switch ((m !== ft.CODE_STOP && (S = !1), m)) { 3407 case ft.CODE_FNC_1: 3408 n && (0 === d.length ? (d += ']C1') : (d += String.fromCharCode(29))); 3409 break; 3410 case ft.CODE_FNC_2: 3411 case ft.CODE_FNC_3: 3412 break; 3413 case ft.CODE_FNC_4_A: 3414 !p && T ? ((p = !0), (T = !1)) : p && T ? ((p = !1), (T = !1)) : (T = !0); 3415 break; 3416 case ft.CODE_SHIFT: 3417 (u = !0), (h = ft.CODE_CODE_B); 3418 break; 3419 case ft.CODE_CODE_B: 3420 h = ft.CODE_CODE_B; 3421 break; 3422 case ft.CODE_CODE_C: 3423 h = ft.CODE_CODE_C; 3424 break; 3425 case ft.CODE_STOP: 3426 c = !0; 3427 } 3428 break; 3429 case ft.CODE_CODE_B: 3430 if (m < 96) 3431 (d += 3432 T === p 3433 ? String.fromCharCode(' '.charCodeAt(0) + m) 3434 : String.fromCharCode(' '.charCodeAt(0) + m + 128)), 3435 (T = !1); 3436 else 3437 switch ((m !== ft.CODE_STOP && (S = !1), m)) { 3438 case ft.CODE_FNC_1: 3439 n && (0 === d.length ? (d += ']C1') : (d += String.fromCharCode(29))); 3440 break; 3441 case ft.CODE_FNC_2: 3442 case ft.CODE_FNC_3: 3443 break; 3444 case ft.CODE_FNC_4_B: 3445 !p && T ? ((p = !0), (T = !1)) : p && T ? ((p = !1), (T = !1)) : (T = !0); 3446 break; 3447 case ft.CODE_SHIFT: 3448 (u = !0), (h = ft.CODE_CODE_A); 3449 break; 3450 case ft.CODE_CODE_A: 3451 h = ft.CODE_CODE_A; 3452 break; 3453 case ft.CODE_CODE_C: 3454 h = ft.CODE_CODE_C; 3455 break; 3456 case ft.CODE_STOP: 3457 c = !0; 3458 } 3459 break; 3460 case ft.CODE_CODE_C: 3461 if (m < 100) m < 10 && (d += '0'), (d += m); 3462 else 3463 switch ((m !== ft.CODE_STOP && (S = !1), m)) { 3464 case ft.CODE_FNC_1: 3465 n && (0 === d.length ? (d += ']C1') : (d += String.fromCharCode(29))); 3466 break; 3467 case ft.CODE_CODE_A: 3468 h = ft.CODE_CODE_A; 3469 break; 3470 case ft.CODE_CODE_B: 3471 h = ft.CODE_CODE_B; 3472 break; 3473 case ft.CODE_STOP: 3474 c = !0; 3475 } 3476 } 3477 t && (h = h === ft.CODE_CODE_A ? ft.CODE_CODE_B : ft.CODE_CODE_A); 3478 } 3479 const N = f - g; 3480 if (((f = e.getNextUnset(f)), !e.isRange(f, Math.min(e.getSize(), f + (f - g) / 2), !1))) throw new R(); 3481 if (((_ -= I * A), _ % 103 !== A)) throw new l(); 3482 const D = d.length; 3483 if (0 === D) throw new R(); 3484 D > 0 && S && (d = h === ft.CODE_CODE_C ? d.substring(0, D - 2) : d.substring(0, D - 1)); 3485 const y = (i[1] + i[0]) / 2, 3486 O = g + N / 2, 3487 M = a.length, 3488 B = new Uint8Array(M); 3489 for (let t = 0; t < M; t++) B[t] = a[t]; 3490 const b = [new rt(y, t), new rt(O, t)]; 3491 return new F(d, B, 0, b, v.CODE_128, new Date().getTime()); 3492 } 3493 } 3494 (ft.CODE_PATTERNS = [ 3495 Int32Array.from([2, 1, 2, 2, 2, 2]), 3496 Int32Array.from([2, 2, 2, 1, 2, 2]), 3497 Int32Array.from([2, 2, 2, 2, 2, 1]), 3498 Int32Array.from([1, 2, 1, 2, 2, 3]), 3499 Int32Array.from([1, 2, 1, 3, 2, 2]), 3500 Int32Array.from([1, 3, 1, 2, 2, 2]), 3501 Int32Array.from([1, 2, 2, 2, 1, 3]), 3502 Int32Array.from([1, 2, 2, 3, 1, 2]), 3503 Int32Array.from([1, 3, 2, 2, 1, 2]), 3504 Int32Array.from([2, 2, 1, 2, 1, 3]), 3505 Int32Array.from([2, 2, 1, 3, 1, 2]), 3506 Int32Array.from([2, 3, 1, 2, 1, 2]), 3507 Int32Array.from([1, 1, 2, 2, 3, 2]), 3508 Int32Array.from([1, 2, 2, 1, 3, 2]), 3509 Int32Array.from([1, 2, 2, 2, 3, 1]), 3510 Int32Array.from([1, 1, 3, 2, 2, 2]), 3511 Int32Array.from([1, 2, 3, 1, 2, 2]), 3512 Int32Array.from([1, 2, 3, 2, 2, 1]), 3513 Int32Array.from([2, 2, 3, 2, 1, 1]), 3514 Int32Array.from([2, 2, 1, 1, 3, 2]), 3515 Int32Array.from([2, 2, 1, 2, 3, 1]), 3516 Int32Array.from([2, 1, 3, 2, 1, 2]), 3517 Int32Array.from([2, 2, 3, 1, 1, 2]), 3518 Int32Array.from([3, 1, 2, 1, 3, 1]), 3519 Int32Array.from([3, 1, 1, 2, 2, 2]), 3520 Int32Array.from([3, 2, 1, 1, 2, 2]), 3521 Int32Array.from([3, 2, 1, 2, 2, 1]), 3522 Int32Array.from([3, 1, 2, 2, 1, 2]), 3523 Int32Array.from([3, 2, 2, 1, 1, 2]), 3524 Int32Array.from([3, 2, 2, 2, 1, 1]), 3525 Int32Array.from([2, 1, 2, 1, 2, 3]), 3526 Int32Array.from([2, 1, 2, 3, 2, 1]), 3527 Int32Array.from([2, 3, 2, 1, 2, 1]), 3528 Int32Array.from([1, 1, 1, 3, 2, 3]), 3529 Int32Array.from([1, 3, 1, 1, 2, 3]), 3530 Int32Array.from([1, 3, 1, 3, 2, 1]), 3531 Int32Array.from([1, 1, 2, 3, 1, 3]), 3532 Int32Array.from([1, 3, 2, 1, 1, 3]), 3533 Int32Array.from([1, 3, 2, 3, 1, 1]), 3534 Int32Array.from([2, 1, 1, 3, 1, 3]), 3535 Int32Array.from([2, 3, 1, 1, 1, 3]), 3536 Int32Array.from([2, 3, 1, 3, 1, 1]), 3537 Int32Array.from([1, 1, 2, 1, 3, 3]), 3538 Int32Array.from([1, 1, 2, 3, 3, 1]), 3539 Int32Array.from([1, 3, 2, 1, 3, 1]), 3540 Int32Array.from([1, 1, 3, 1, 2, 3]), 3541 Int32Array.from([1, 1, 3, 3, 2, 1]), 3542 Int32Array.from([1, 3, 3, 1, 2, 1]), 3543 Int32Array.from([3, 1, 3, 1, 2, 1]), 3544 Int32Array.from([2, 1, 1, 3, 3, 1]), 3545 Int32Array.from([2, 3, 1, 1, 3, 1]), 3546 Int32Array.from([2, 1, 3, 1, 1, 3]), 3547 Int32Array.from([2, 1, 3, 3, 1, 1]), 3548 Int32Array.from([2, 1, 3, 1, 3, 1]), 3549 Int32Array.from([3, 1, 1, 1, 2, 3]), 3550 Int32Array.from([3, 1, 1, 3, 2, 1]), 3551 Int32Array.from([3, 3, 1, 1, 2, 1]), 3552 Int32Array.from([3, 1, 2, 1, 1, 3]), 3553 Int32Array.from([3, 1, 2, 3, 1, 1]), 3554 Int32Array.from([3, 3, 2, 1, 1, 1]), 3555 Int32Array.from([3, 1, 4, 1, 1, 1]), 3556 Int32Array.from([2, 2, 1, 4, 1, 1]), 3557 Int32Array.from([4, 3, 1, 1, 1, 1]), 3558 Int32Array.from([1, 1, 1, 2, 2, 4]), 3559 Int32Array.from([1, 1, 1, 4, 2, 2]), 3560 Int32Array.from([1, 2, 1, 1, 2, 4]), 3561 Int32Array.from([1, 2, 1, 4, 2, 1]), 3562 Int32Array.from([1, 4, 1, 1, 2, 2]), 3563 Int32Array.from([1, 4, 1, 2, 2, 1]), 3564 Int32Array.from([1, 1, 2, 2, 1, 4]), 3565 Int32Array.from([1, 1, 2, 4, 1, 2]), 3566 Int32Array.from([1, 2, 2, 1, 1, 4]), 3567 Int32Array.from([1, 2, 2, 4, 1, 1]), 3568 Int32Array.from([1, 4, 2, 1, 1, 2]), 3569 Int32Array.from([1, 4, 2, 2, 1, 1]), 3570 Int32Array.from([2, 4, 1, 2, 1, 1]), 3571 Int32Array.from([2, 2, 1, 1, 1, 4]), 3572 Int32Array.from([4, 1, 3, 1, 1, 1]), 3573 Int32Array.from([2, 4, 1, 1, 1, 2]), 3574 Int32Array.from([1, 3, 4, 1, 1, 1]), 3575 Int32Array.from([1, 1, 1, 2, 4, 2]), 3576 Int32Array.from([1, 2, 1, 1, 4, 2]), 3577 Int32Array.from([1, 2, 1, 2, 4, 1]), 3578 Int32Array.from([1, 1, 4, 2, 1, 2]), 3579 Int32Array.from([1, 2, 4, 1, 1, 2]), 3580 Int32Array.from([1, 2, 4, 2, 1, 1]), 3581 Int32Array.from([4, 1, 1, 2, 1, 2]), 3582 Int32Array.from([4, 2, 1, 1, 1, 2]), 3583 Int32Array.from([4, 2, 1, 2, 1, 1]), 3584 Int32Array.from([2, 1, 2, 1, 4, 1]), 3585 Int32Array.from([2, 1, 4, 1, 2, 1]), 3586 Int32Array.from([4, 1, 2, 1, 2, 1]), 3587 Int32Array.from([1, 1, 1, 1, 4, 3]), 3588 Int32Array.from([1, 1, 1, 3, 4, 1]), 3589 Int32Array.from([1, 3, 1, 1, 4, 1]), 3590 Int32Array.from([1, 1, 4, 1, 1, 3]), 3591 Int32Array.from([1, 1, 4, 3, 1, 1]), 3592 Int32Array.from([4, 1, 1, 1, 1, 3]), 3593 Int32Array.from([4, 1, 1, 3, 1, 1]), 3594 Int32Array.from([1, 1, 3, 1, 4, 1]), 3595 Int32Array.from([1, 1, 4, 1, 3, 1]), 3596 Int32Array.from([3, 1, 1, 1, 4, 1]), 3597 Int32Array.from([4, 1, 1, 1, 3, 1]), 3598 Int32Array.from([2, 1, 1, 4, 1, 2]), 3599 Int32Array.from([2, 1, 1, 2, 1, 4]), 3600 Int32Array.from([2, 1, 1, 2, 3, 2]), 3601 Int32Array.from([2, 3, 3, 1, 1, 1, 2]), 3602 ]), 3603 (ft.MAX_AVG_VARIANCE = 0.25),
3604 (ft.MAX_INDIVIDUAL_VARIANCE = 0.7), 3605 (ft.CODE_SHIFT = 98), 3606 (ft.CODE_CODE_C = 99), 3607 (ft.CODE_CODE_B = 100), 3608 (ft.CODE_CODE_A = 101), 3609 (ft.CODE_FNC_1 = 102), 3610 (ft.CODE_FNC_2 = 97), 3611 (ft.CODE_FNC_3 = 96), 3612 (ft.CODE_FNC_4_A = 101), 3613 (ft.CODE_FNC_4_B = 100), 3614 (ft.CODE_START_A = 103), 3615 (ft.CODE_START_B = 104), 3616 (ft.CODE_START_C = 105), 3617 (ft.CODE_STOP = 106); 3618 class wt extends gt { 3619 constructor(t = !1, e = !1) { 3620 super(), 3621 (this.usingCheckDigit = t), 3622 (this.extendedMode = e), 3623 (this.decodeRowResult = ''), 3624 (this.counters = new Int32Array(9)); 3625 } 3626 decodeRow(t, e, r) { 3627 let n = this.counters; 3628 n.fill(0), (this.decodeRowResult = ''); 3629 let i, 3630 s, 3631 o = wt.findAsteriskPattern(e, n), 3632 a = e.getNextSet(o[1]), 3633 h = e.getSize(); 3634 do { 3635 wt.recordPattern(e, a, n); 3636 let t = wt.toNarrowWidePattern(n); 3637 if (t < 0) throw new R(); 3638 (i = wt.patternToChar(t)), (this.decodeRowResult += i), (s = a); 3639 for (let t of n) a += t; 3640 a = e.getNextSet(a); 3641 } while ('*' !== i); 3642 this.decodeRowResult = this.decodeRowResult.substring(0, this.decodeRowResult.length - 1); 3643 let c, 3644 u = 0; 3645 for (let t of n) u += t; 3646 if (a !== h && 2 * (a - s - u) < u) throw new R(); 3647 if (this.usingCheckDigit) { 3648 let t = this.decodeRowResult.length - 1, 3649 e = 0; 3650 for (let r = 0; r < t; r++) e += wt.ALPHABET_STRING.indexOf(this.decodeRowResult.charAt(r)); 3651 if (this.decodeRowResult.charAt(t) !== wt.ALPHABET_STRING.charAt(e % 43)) throw new l(); 3652 this.decodeRowResult = this.decodeRowResult.substring(0, t); 3653 } 3654 if (0 === this.decodeRowResult.length) throw new R(); 3655 c = this.extendedMode ? wt.decodeExtended(this.decodeRowResult) : this.decodeRowResult; 3656 let d = (o[1] + o[0]) / 2, 3657 g = s + u / 2; 3658 return new F(c, null, 0, [new rt(d, t), new rt(g, t)], v.CODE_39, new Date().getTime()); 3659 } 3660 static findAsteriskPattern(t, e) { 3661 let r = t.getSize(), 3662 n = t.getNextSet(0), 3663 i = 0, 3664 s = n, 3665 o = !1, 3666 a = e.length; 3667 for (let l = n; l < r; l++) 3668 if (t.get(l) !== o) e[i]++; 3669 else { 3670 if (i === a - 1) { 3671 if ( 3672 this.toNarrowWidePattern(e) === wt.ASTERISK_ENCODING && 3673 t.isRange(Math.max(0, s - Math.floor((l - s) / 2)), s, !1) 3674 ) 3675 return [s, l]; 3676 (s += e[0] + e[1]), e.copyWithin(0, 2, 2 + i - 1), (e[i - 1] = 0), (e[i] = 0), i--; 3677 } else i++; 3678 (e[i] = 1), (o = !o); 3679 } 3680 throw new R(); 3681 } 3682 static toNarrowWidePattern(t) { 3683 let e, 3684 r = t.length, 3685 n = 0; 3686 do { 3687 let i = 2147483647; 3688 for (let e of t) e < i && e > n && (i = e); 3689 (n = i), (e = 0); 3690 let s = 0, 3691 o = 0; 3692 for (let i = 0; i < r; i++) { 3693 let a = t[i]; 3694 a > n && ((o |= 1 << (r - 1 - i)), e++, (s += a)); 3695 } 3696 if (3 === e) { 3697 for (let i = 0; i < r && e > 0; i++) { 3698 let r = t[i]; 3699 if (r > n && (e--, 2 * r >= s)) return -1; 3700 } 3701 return o; 3702 } 3703 } while (e > 3); 3704 return -1; 3705 } 3706 static patternToChar(t) { 3707 for (let e = 0; e < wt.CHARACTER_ENCODINGS.length; e++) 3708 if (wt.CHARACTER_ENCODINGS[e] === t) return wt.ALPHABET_STRING.charAt(e); 3709 if (t === wt.ASTERISK_ENCODING) return '*'; 3710 throw new R(); 3711 } 3712 static decodeExtended(t) { 3713 let e = t.length, 3714 r = ''; 3715 for (let n = 0; n < e; n++) { 3716 let e = t.charAt(n); 3717 if ('+' === e || '$' === e || '%' === e || '/' === e) { 3718 let i = t.charAt(n + 1), 3719 s = '\0'; 3720 switch (e) { 3721 case '+': 3722 if (!(i >= 'A' && i <= 'Z')) throw new E(); 3723 s = String.fromCharCode(i.charCodeAt(0) + 32); 3724 break; 3725 case '$': 3726 if (!(i >= 'A' && i <= 'Z')) throw new E(); 3727 s = String.fromCharCode(i.charCodeAt(0) - 64); 3728 break; 3729 case '%': 3730 if (i >= 'A' && i <= 'E') s = String.fromCharCode(i.charCodeAt(0) - 38); 3731 else if (i >= 'F' && i <= 'J') s = String.fromCharCode(i.charCodeAt(0) - 11);
3732 else if (i >= 'K' && i <= 'O') s = String.fromCharCode(i.charCodeAt(0) + 16); 3733 else if (i >= 'P' && i <= 'T') s = String.fromCharCode(i.charCodeAt(0) + 43); 3734 else if ('U' === i) s = '\0'; 3735 else if ('V' === i) s = '@'; 3736 else if ('W' === i) s = '`'; 3737 else { 3738 if ('X' !== i && 'Y' !== i && 'Z' !== i) throw new E(); 3739 s = '�'; 3740 } 3741 break; 3742 case '/': 3743 if (i >= 'A' && i <= 'O') s = String.fromCharCode(i.charCodeAt(0) - 32); 3744 else { 3745 if ('Z' !== i) throw new E(); 3746 s = ':'; 3747 } 3748 } 3749 (r += s), n++; 3750 } else r += e; 3751 } 3752 return r; 3753 } 3754 } 3755 (wt.ALPHABET_STRING = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%'), 3756 (wt.CHARACTER_ENCODINGS = [ 3757 52, 289, 97, 352, 49, 304, 112, 37, 292, 100, 265, 73, 328, 25, 280, 88, 13, 268, 76, 28, 259, 67, 322, 19, 274, 3758 82, 7, 262, 70, 22, 385, 193, 448, 145, 400, 208, 133, 388, 196, 168, 162, 138, 42, 3759 ]), 3760 (wt.ASTERISK_ENCODING = 148); 3761 class At extends gt { 3762 constructor() { 3763 super(...arguments), (this.narrowLineWidth = -1); 3764 } 3765 decodeRow(t, e, r) { 3766 let n = this.decodeStart(e), 3767 i = this.decodeEnd(e), 3768 s = new p(); 3769 At.decodeMiddle(e, n[1], i[0], s); 3770 let o = s.toString(), 3771 a = null; 3772 null != r && (a = r.get(C.ALLOWED_LENGTHS)), null == a && (a = At.DEFAULT_ALLOWED_LENGTHS); 3773 let l = o.length, 3774 h = !1, 3775 c = 0; 3776 for (let t of a) { 3777 if (l === t) { 3778 h = !0; 3779 break; 3780 } 3781 t > c && (c = t); 3782 } 3783 if ((!h && l > c && (h = !0), !h)) throw new E(); 3784 const u = [new rt(n[1], t), new rt(i[0], t)]; 3785 return new F(o, null, 0, u, v.ITF, new Date().getTime()); 3786 } 3787 static decodeMiddle(t, e, r, n) { 3788 let i = new Int32Array(10), 3789 s = new Int32Array(5), 3790 o = new Int32Array(5); 3791 for (i.fill(0), s.fill(0), o.fill(0); e < r; ) { 3792 gt.recordPattern(t, e, i); 3793 for (let t = 0; t < 5; t++) { 3794 let e = 2 * t; 3795 (s[t] = i[e]), (o[t] = i[e + 1]); 3796 } 3797 let r = At.decodeDigit(s); 3798 n.append(r.toString()), 3799 (r = this.decodeDigit(o)), 3800 n.append(r.toString()), 3801 i.forEach(function (t) { 3802 e += t; 3803 }); 3804 } 3805 } 3806 decodeStart(t) { 3807 let e = At.skipWhiteSpace(t), 3808 r = At.findGuardPattern(t, e, At.START_PATTERN); 3809 return (this.narrowLineWidth = (r[1] - r[0]) / 4), this.validateQuietZone(t, r[0]), r; 3810 } 3811 validateQuietZone(t, e) { 3812 let r = 10 * this.narrowLineWidth; 3813 r = r < e ? r : e; 3814 for (let n = e - 1; r > 0 && n >= 0 && !t.get(n); n--) r--; 3815 if (0 !== r) throw new R(); 3816 } 3817 static skipWhiteSpace(t) { 3818 const e = t.getSize(), 3819 r = t.getNextSet(0); 3820 if (r === e) throw new R(); 3821 return r; 3822 } 3823 decodeEnd(t) { 3824 t.reverse(); 3825 try { 3826 let e, 3827 r = At.skipWhiteSpace(t); 3828 try { 3829 e = At.findGuardPattern(t, r, At.END_PATTERN_REVERSED[0]); 3830 } catch (n) { 3831 n instanceof R && (e = At.findGuardPattern(t, r, At.END_PATTERN_REVERSED[1])); 3832 } 3833 this.validateQuietZone(t, e[0]); 3834 let n = e[0]; 3835 return (e[0] = t.getSize() - e[1]), (e[1] = t.getSize() - n), e; 3836 } finally { 3837 t.reverse(); 3838 } 3839 } 3840 static findGuardPattern(t, e, r) { 3841 let n = r.length, 3842 i = new Int32Array(n), 3843 s = t.getSize(), 3844 o = !1, 3845 a = 0, 3846 l = e; 3847 i.fill(0); 3848 for (let h = e; h < s; h++) 3849 if (t.get(h) !== o) i[a]++; 3850 else { 3851 if (a === n - 1) { 3852 if (gt.patternMatchVariance(i, r, At.MAX_INDIVIDUAL_VARIANCE) < At.MAX_AVG_VARIANCE) return [l, h]; 3853 (l += i[0] + i[1]), c.arraycopy(i, 2, i, 0, a - 1), (i[a - 1] = 0), (i[a] = 0), a--; 3854 } else a++; 3855 (i[a] = 1), (o = !o); 3856 } 3857 throw new R(); 3858 } 3859 static decodeDigit(t) { 3860 let e = At.MAX_AVG_VARIANCE, 3861 r = -1, 3862 n = At.PATTERNS.length; 3863 for (let i = 0; i < n; i++) { 3864 let n = At.PATTERNS[i], 3865 s = gt.patternMatchVariance(t, n, At.MAX_INDIVIDUAL_VARIA
3865NCE); 3866 s < e ? ((e = s), (r = i)) : s === e && (r = -1); 3867 } 3868 if (r >= 0) return r % 10; 3869 throw new R(); 3870 } 3871 } 3872 (At.PATTERNS = [ 3873 Int32Array.from([1, 1, 2, 2, 1]), 3874 Int32Array.from([2, 1, 1, 1, 2]), 3875 Int32Array.from([1, 2, 1, 1, 2]), 3876 Int32Array.from([2, 2, 1, 1, 1]), 3877 Int32Array.from([1, 1, 2, 1, 2]), 3878 Int32Array.from([2, 1, 2, 1, 1]), 3879 Int32Array.from([1, 2, 2, 1, 1]), 3880 Int32Array.from([1, 1, 1, 2, 2]), 3881 Int32Array.from([2, 1, 1, 2, 1]), 3882 Int32Array.from([1, 2, 1, 2, 1]), 3883 Int32Array.from([1, 1, 3, 3, 1]), 3884 Int32Array.from([3, 1, 1, 1, 3]), 3885 Int32Array.from([1, 3, 1, 1, 3]), 3886 Int32Array.from([3, 3, 1, 1, 1]), 3887 Int32Array.from([1, 1, 3, 1, 3]), 3888 Int32Array.from([3, 1, 3, 1, 1]), 3889 Int32Array.from([1, 3, 3, 1, 1]), 3890 Int32Array.from([1, 1, 1, 3, 3]), 3891 Int32Array.from([3, 1, 1, 3, 1]), 3892 Int32Array.from([1, 3, 1, 3, 1]), 3893 ]), 3894 (At.MAX_AVG_VARIANCE = 0.38), 3895 (At.MAX_INDIVIDUAL_VARIANCE = 0.5), 3896 (At.DEFAULT_ALLOWED_LENGTHS = [6, 8, 10, 12, 14]), 3897 (At.START_PATTERN = Int32Array.from([1, 1, 1, 1])), 3898 (At.END_PATTERN_REVERSED = [Int32Array.from([1, 1, 2]), Int32Array.from([1, 1, 3])]); 3899 class Ct extends gt { 3900 constructor() { 3901 super(...arguments), (this.decodeRowStringBuffer = ''); 3902 } 3903 static findStartGuardPattern(t) { 3904 let e, 3905 r = !1, 3906 n = 0, 3907 i = Int32Array.from([0, 0, 0]); 3908 for (; !r; ) { 3909 (i = Int32Array.from([0, 0, 0])), (e = Ct.findGuardPattern(t, n, !1, this.START_END_PATTERN, i)); 3910 let s = e[0]; 3911 n = e[1]; 3912 let o = s - (n - s); 3913 o >= 0 && (r = t.isRange(o, s, !1)); 3914 } 3915 return e; 3916 } 3917 static checkChecksum(t) { 3918 return Ct.checkStandardUPCEANChecksum(t); 3919 } 3920 static checkStandardUPCEANChecksum(t) { 3921 let e = t.length; 3922 if (0 === e) return !1; 3923 let r = parseInt(t.charAt(e - 1), 10); 3924 return Ct.getStandardUPCEANChecksum(t.substring(0, e - 1)) === r; 3925 } 3926 static getStandardUPCEANChecksum(t) { 3927 let e = t.length, 3928 r = 0; 3929 for (let n = e - 1; n >= 0; n -= 2) { 3930 let e = t.charAt(n).charCodeAt(0) - '0'.charCodeAt(0); 3931 if (e < 0 || e > 9) throw new E(); 3932 r += e; 3933 } 3934 r *= 3; 3935 for (let n = e - 2; n >= 0; n -= 2) { 3936 let e = t.charAt(n).charCodeAt(0) - '0'.charCodeAt(0); 3937 if (e < 0 || e > 9) throw new E(); 3938 r += e; 3939 } 3940 return (1e3 - r) % 10; 3941 } 3942 static decodeEnd(t, e) { 3943 return Ct.findGuardPattern(t, e, !1, Ct.START_END_PATTERN, new Int32Array(Ct.START_END_PATTERN.length).fill(0)); 3944 } 3945 static findGuardPatternWithoutCounters(t, e, r, n) { 3946 return this.findGuardPattern(t, e, r, n, new Int32Array(n.length)); 3947 } 3948 static findGuardPattern(t, e, r, n, i) { 3949 let s = t.getSize(), 3950 o = 0, 3951 a = (e = r ? t.getNextUnset(e) : t.getNextSet(e)), 3952 l = n.length, 3953 h = r; 3954 for (let r = e; r < s; r++) 3955 if (t.get(r) !== h) i[o]++; 3956 else { 3957 if (o === l - 1) { 3958 if (gt.patternMatchVariance(i, n, Ct.MAX_INDIVIDUAL_VARIANCE) < Ct.MAX_AVG_VARIANCE) 3959 return Int32Array.from([a, r]); 3960 a += i[0] + i[1]; 3961 let t = i.slice(2, i.length - 1); 3962 for (let e = 0; e < o - 1; e++) i[e] = t[e]; 3963 (i[o - 1] = 0), (i[o] = 0), o--; 3964 } else o++; 3965 (i[o] = 1), (h = !h); 3966 } 3967 throw new R(); 3968 } 3969 static decodeDigit(t, e, r, n) { 3970 this.recordPattern(t, r, e); 3971 let i = this.MAX_AVG_VARIANCE, 3972 s = -1, 3973 o = n.length; 3974 for (let t = 0; t < o; t++) { 3975 let r = n[t], 3976 o = gt.patternMatchVariance(e, r, Ct.MAX_INDIVIDUAL_VARIANCE); 3977 o < i && ((i = o), (s = t)); 3978 } 3979 if (s >= 0) return s; 3980 throw new R(); 3981 } 3982 } 3983 (Ct.MAX_AVG_VARIANCE = 0.48), 3984 (Ct.MAX_INDIVIDUAL_VARIANCE = 0.7), 3985 (Ct.START_END_PATTERN = Int32Array.from([1, 1, 1])), 3986 (Ct.MIDDLE_PATTERN = Int32Array.from([1, 1, 1, 1, 1])), 3987 (Ct.END_PATTERN = Int32Array.from([1, 1, 1, 1, 1, 1])), 3988 (Ct.L_PATTERNS = [ 3989 Int32Array.from([3, 2, 1, 1]), 3990 Int32Array.from([2, 2, 2, 1]), 3991 Int32Array.from([2, 1, 2, 2]), 3992 Int32Array.from([1, 4, 1, 1]), 3993 Int32Array.from([1, 1, 3, 2]), 3994 Int32Array.from([1, 2, 3, 1]), 3995 Int32Array.from([1, 1, 1, 4]), 3996 Int32Array.from([1, 3, 1, 2]), 3997 Int32Array.from([1, 2, 1, 3]), 3998 Int32Array.from([3, 1, 1, 2]), 3999 ]); 4000 class Et { 4001 constructor() { 4002 (this.CHECK_DIGIT_ENCODINGS = [24, 20, 18, 17, 12, 6, 3, 10, 9, 5]), 4003 (this.decodeMiddleCounters = Int32Array.from([0, 0, 0, 0])), 4004 (this.decodeRowStringBuffer = ''); 4005 } 4006 decodeRow(t, e, r) { 4007 let n = this.decodeRowStringBuffer, 4008 i = this.decodeMiddle(e, r, n), 4009 s = n.toString(), 4010 o = Et.parseExtensionString(s), 4011 a = [new rt((r[0] + r[1]) / 2, t), new rt(i, t)], 4012 l = new F(s, null, 0, a, v.UPC_EAN_EXTENSION, new Date().getTime()); 4013 return null != o && l.putAllMetadata(o), l; 4014 } 4015 decodeMiddle(t, e, r) { 4016 let n = this.decodeMiddleCounters; 4017 (n[0] = 0), (n[1] = 0), (n[2] = 0), (n[3] = 0); 4018 let i = t.getSize(), 4019 s = e[1], 4020 o = 0; 4021 for (let e = 0; e < 5 && s < i; e++) { 4022 let i = Ct.decodeDigit(t, n, s, Ct.L_AND_G_PATTERNS); 4023 r += String.fromCharCode('0'.charCodeAt(0) + (i % 10)); 4024 for (let t of n) s += t; 4025 i >= 10 && (o |= 1 << (4 - e)), 4 !== e && ((s = t.getNextSet(s)), (s = t.getNextUnset(s))); 4026 } 4027 if (5 !== r.length) throw new R(); 4028 let a = this.determineCheckDigit(o); 4029 if (Et.extensionChecksum(r.toString()) !== a) throw new R(); 4030 return s; 4031 } 4032 static extensionChecksum(t) { 4033 let e = t.length, 4034 r = 0; 4035 for (let n = e - 2; n >= 0;
4035 n -= 2) r += t.charAt(n).charCodeAt(0) - '0'.charCodeAt(0); 4036 r *= 3; 4037 for (let n = e - 1; n >= 0; n -= 2) r += t.charAt(n).charCodeAt(0) - '0'.charCodeAt(0); 4038 return (r *= 3), r % 10; 4039 } 4040 determineCheckDigit(t) { 4041 for (let e = 0; e < 10; e++) if (t === this.CHECK_DIGIT_ENCODINGS[e]) return e; 4042 throw new R(); 4043 } 4044 static parseExtensionString(t) { 4045 if (5 !== t.length) return null; 4046 let e = Et.parseExtension5String(t); 4047 return null == e ? null : new Map([[W.SUGGESTED_PRICE, e]]); 4048 } 4049 static parseExtension5String(t) { 4050 let e; 4051 switch (t.charAt(0)) { 4052 case '0': 4053 e = '£'; 4054 break; 4055 case '5': 4056 e = '$'; 4057 break; 4058 case '9': 4059 switch (t) { 4060 case '90000': 4061 return null; 4062 case '99991': 4063 return '0.00'; 4064 case '99990': 4065 return 'Used'; 4066 } 4067 e = ''; 4068 break; 4069 default: 4070 e = ''; 4071 } 4072 let r = parseInt(t.substring(1)), 4073 n = r % 100; 4074 return e + (r / 100).toString() + '.' + (n < 10 ? '0' + n : n.toString()); 4075 } 4076 } 4077 class mt { 4078 constructor() { 4079 (this.decodeMiddleCounters = Int32Array.from([0, 0, 0, 0])), (this.decodeRowStringBuffer = ''); 4080 } 4081 decodeRow(t, e, r) { 4082 let n = this.decodeRowStringBuffer, 4083 i = this.decodeMiddle(e, r, n), 4084 s = n.toString(), 4085 o = mt.parseExtensionString(s), 4086 a = [new rt((r[0] + r[1]) / 2, t), new rt(i, t)], 4087 l = new F(s, null, 0, a, v.UPC_EAN_EXTENSION, new Date().getTime()); 4088 return null != o && l.putAllMetadata(o), l; 4089 } 4090 decodeMiddle(t, e, r) { 4091 let n = this.decodeMiddleCounters; 4092 (n[0] = 0), (n[1] = 0), (n[2] = 0), (n[3] = 0); 4093 let i = t.getSize(), 4094 s = e[1], 4095 o = 0; 4096 for (let e = 0; e < 2 && s < i; e++) { 4097 let i = Ct.decodeDigit(t, n, s, Ct.L_AND_G_PATTERNS); 4098 r += String.fromCharCode('0'.charCodeAt(0) + (i % 10)); 4099 for (let t of n) s += t; 4100 i >= 10 && (o |= 1 << (1 - e)), 1 !== e && ((s = t.getNextSet(s)), (s = t.getNextUnset(s))); 4101 } 4102 if (2 !== r.length) throw new R(); 4103 if (parseInt(r.toString()) % 4 !== o) throw new R(); 4104 return s; 4105 } 4106 static parseExtensionString(t) { 4107 return 2 !== t.length ? null : new Map([[W.ISSUE_NUMBER, parseInt(t)]]); 4108 } 4109 } 4110 class _t { 4111 static decodeRow(t, e, r) { 4112 let n = Ct.findGuardPattern( 4113 e, 4114 r, 4115 !1, 4116 this.EXTENSION_START_PATTERN, 4117 new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0), 4118 ); 4119 try { 4120 return new Et().decodeRow(t, e, n); 4121 } catch (r) { 4122 return new mt().decodeRow(t, e, n); 4123 } 4124 } 4125 } 4126 _t.EXTENSION_START_PATTERN = Int32Array.from([1, 1, 2]); 4127 class It extends Ct { 4128 constructor() { 4129 super(), (this.decodeRowStringBuffer = ''), (It.L_AND_G_PATTERNS = It.L_PATTERNS.map((t) => Int32Array.from(t))); 4130 for (let t = 10; t < 20; t++) { 4131 let e = It.L_PATTERNS[t - 10], 4132 r = new Int32Array(e.length); 4133 for (let t = 0; t < e.length; t++) r[t] = e[e.length - t - 1]; 4134 It.L_AND_G_PATTERNS[t] = r; 4135 } 4136 } 4137 decodeRow(t, e, r) { 4138 let n = It.findStartGuardPattern(e), 4139 i = null == r ? null : r.get(C.NEED_RESULT_POINT_CALLBACK); 4140 if (null != i) { 4141 const e = new rt((n[0] + n[1]) / 2, t); 4142 i.foundPossibleResultPoint(e); 4143 } 4144 let s = this.decodeMiddle(e, n, this.decodeRowStringBuffer), 4145 o = s.rowOffset, 4146 a = s.resultString; 4147 if (null != i) { 4148 const e = new rt(o, t); 4149 i.foundPossibleResultPoint(e); 4150 } 4151 let h = It.decodeEnd(e, o); 4152 if (null != i) { 4153 const e = new rt((h[0] + h[1]) / 2, t); 4154 i.foundPossibleResultPoint(e); 4155 } 4156 let c = h[1], 4157 u = c + (c - h[0]); 4158 if (u >= e.getSize() || !e.isRange(c, u, !1)) throw new R(); 4159 let d = a.toString(); 4160 if (d.length < 8) throw new E(); 4161 if (!It.checkChecksum(d)) throw new l(); 4162 let g = (n[1] + n[0]) / 2, 4163 f = (h[1] + h[0]) / 2, 4164 w = this.getBarcodeFormat(), 4165 A = [new rt(g, t), new rt(f, t)], 4166 m = new F(d, null, 0, A, w, new Date().getTime()), 4167 _ = 0;
4168 try { 4169 let r = _t.decodeRow(t, e, h[1]); 4170 m.putMetadata(W.UPC_EAN_EXTENSION, r.getText()), 4171 m.putAllMetadata(r.getResultMetadata()), 4172 m.addResultPoints(r.getResultPoints()), 4173 (_ = r.getText().length); 4174 } catch (t) {} 4175 let I = null == r ? null : r.get(C.ALLOWED_EAN_EXTENSIONS); 4176 if (null != I) { 4177 let t = !1; 4178 for (let e in I) 4179 if (_.toString() === e) { 4180 t = !0; 4181 break; 4182 } 4183 if (!t) throw new R(); 4184 } 4185 return w === v.EAN_13 || v.UPC_A, m; 4186 } 4187 static checkChecksum(t) { 4188 return It.checkStandardUPCEANChecksum(t); 4189 } 4190 static checkStandardUPCEANChecksum(t) { 4191 let e = t.length; 4192 if (0 === e) return !1; 4193 let r = parseInt(t.charAt(e - 1), 10); 4194 return It.getStandardUPCEANChecksum(t.substring(0, e - 1)) === r; 4195 } 4196 static getStandardUPCEANChecksum(t) { 4197 let e = t.length, 4198 r = 0; 4199 for (let n = e - 1; n >= 0; n -= 2) { 4200 let e = t.charAt(n).charCodeAt(0) - '0'.charCodeAt(0); 4201 if (e < 0 || e > 9) throw new E(); 4202 r += e; 4203 } 4204 r *= 3; 4205 for (let n = e - 2; n >= 0; n -= 2) { 4206 let e = t.charAt(n).charCodeAt(0) - '0'.charCodeAt(0); 4207 if (e < 0 || e > 9) throw new E(); 4208 r += e; 4209 } 4210 return (1e3 - r) % 10; 4211 } 4212 static decodeEnd(t, e) { 4213 return It.findGuardPattern(t, e, !1, It.START_END_PATTERN, new Int32Array(It.START_END_PATTERN.length).fill(0)); 4214 } 4215 } 4216 class St extends It { 4217 constructor() { 4218 super(), (this.decodeMiddleCounters = Int32Array.from([0, 0, 0, 0])); 4219 } 4220 decodeMiddle(t, e, r) { 4221 let n = this.decodeMiddleCounters; 4222 (n[0] = 0), (n[1] = 0), (n[2] = 0), (n[3] = 0); 4223 let i = t.getSize(), 4224 s = e[1], 4225 o = 0; 4226 for (let e = 0; e < 6 && s < i; e++) { 4227 let i = It.decodeDigit(t, n, s, It.L_AND_G_PATTERNS); 4228 r += String.fromCharCode('0'.charCodeAt(0) + (i % 10)); 4229 for (let t of n) s += t; 4230 i >= 10 && (o |= 1 << (5 - e)); 4231 } 4232 (r = St.determineFirstDigit(r, o)), 4233 (s = It.findGuardPattern(t, s, !0, It.MIDDLE_PATTERN, new Int32Array(It.MIDDLE_PATTERN.length).fill(0))[1]); 4234 for (let e = 0; e < 6 && s < i; e++) { 4235 let e = It.decodeDigit(t, n, s, It.L_PATTERNS); 4236 r += String.fromCharCode('0'.charCodeAt(0) + e); 4237 for (let t of n) s += t; 4238 } 4239 return { rowOffset: s, resultString: r }; 4240 } 4241 getBarcodeFormat() { 4242 return v.EAN_13; 4243 } 4244 static determineFirstDigit(t, e) { 4245 for (let r = 0; r < 10; r++) 4246 if (e === this.FIRST_DIGIT_ENCODINGS[r]) return (t = String.fromCharCode('0'.charCodeAt(0) + r) + t); 4247 throw new R(); 4248 } 4249 } 4250 St.FIRST_DIGIT_ENCODINGS = [0, 11, 13, 14, 19, 25, 28, 21, 22, 26]; 4251 class pt extends It { 4252 constructor() { 4253 super(), (this.decodeMiddleCounters = Int32Array.from([0, 0, 0, 0])); 4254 } 4255 decodeMiddle(t, e, r) { 4256 const n = this.decodeMiddleCounters; 4257 (n[0] = 0), (n[1] = 0), (n[2] = 0), (n[3] = 0); 4258 let i = t.getSize(), 4259 s = e[1]; 4260 for (let e = 0; e < 4 && s < i; e++) { 4261 let e = It.decodeDigit(t, n, s, It.L_PATTERNS); 4262 r += String.fromCharCode('0'.charCodeAt(0) + e); 4263 for (let t of n) s += t; 4264 } 4265 s = It.findGuardPattern(t, s, !0, It.MIDDLE_PATTERN, new Int32Array(It.MIDDLE_PATTERN.length).fill(0))[1]; 4266 for (let e = 0; e < 4 && s < i; e++) { 4267 let e = It.decodeDigit(t, n, s, It.L_PATTERNS); 4268 r += String.fromCharCode('0'.charCodeAt(0) + e); 4269 for (let t of n) s += t; 4270 } 4271 return { rowOffset: s, resultString: r }; 4272 } 4273 getBarcodeFormat() { 4274 return v.EAN_8; 4275 } 4276 } 4277 class Tt extends It { 4278 constructor() { 4279 super(...arguments), (this.ean13Reader = new St()); 4280 } 4281 getBarcodeFormat() { 4282 return v.UPC_A; 4283 } 4284 decode(t, e) { 4285 return this.maybeReturnResult(this.ean13Reader.decode(t)); 4286 } 4287 decodeRow(t, e, r) { 4288 return this.maybeReturnResult(this.ean13Reader.decodeRow(t, e, r)); 4289 } 4290 decodeMiddle(t, e, r) { 4291 return this.ean13Reader.decodeMiddle(t, e, r); 4292 } 4293 maybeReturnResult(t) { 4294 let e = t.getText(); 4295 if ('0' === e.charAt(0)) { 4296 let r = new F(e.substring(1), null, null, t.getResultPoints(), v.UPC_A); 4297 return null != t.getResultMetadata() && r.putAllMetadata(t.getResultMetadata()), r; 4298 } 4299 throw new R(); 4300 } 4301 reset() { 4302 this.ean13Reader.reset(); 4303 } 4304 } 4305 class Rt extends It { 4306 constructor() { 4307 super(), (this.decodeMiddleCounters = new Int32Array(4)); 4308 } 4309 decodeMiddle(t, e, r) { 4310 const n = this.decodeMiddleCounters.map((t) => t); 4311 (n[0] = 0), (n[1] = 0), (n[2] = 0), (n[3] = 0); 4312 const i = t.getSize(); 4313 let s = e[1], 4314 o = 0; 4315 for (let e = 0; e < 6 && s < i; e++) { 4316 const i = Rt.decodeDigit(t, n, s, Rt.L_AND_G_PATTERNS); 4317 r += String.fromCharCode('0'.charCodeAt(0) + (i % 10)); 4318 for (let t of n) s += t; 4319 i >= 10 && (o |= 1 << (5 - e)); 4320 } 4321 return Rt.determineNumSysAndCheckDigit(new p(r), o), s; 4322 } 4323 decodeEnd(t, e) { 4324 return Rt.findGuardPatternWithoutCounters(t, e, !0, Rt.MIDDLE_END_PATTERN); 4325 } 4326 checkChecksum(t) { 4327 return It.checkChecksum(Rt.convertUPCEtoUPCA(t)); 4328 } 4329 static determineNumSysAndCheckDigit(t, e) { 4330 for (let r = 0; r <= 1; r++) 4331 for (let n = 0; n < 10; n++) 4332 if (e === this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[r][n]) return t.insert(0, '0' + r), void t.append('0' + n); 4333 throw R.getNotFoundInstance(); 4334 } 4335 getBarcodeFormat() { 4336 return v.UPC_E; 4337 } 4338 static convertUPCEtoUPCA(t) { 4339 const e = t 4340 .slice(1, 7) 4341 .split('') 4342 .map((t) => t.charCodeAt(0)), 4343 r = new p(); 4344 r.append(t.charAt(0)); 4345 let n = e[5]; 4346 switch (n) { 4347 case 0: 4348 case 1: 4349 case 2: 4350 r.appendChars(e, 0, 2), r.append(n), r.append('0000'), r.appendChars(e, 2, 3); 4351 break; 4352 case 3: 4353 r.appendChars(e, 0, 3), r.append('00000'), r.appendChars(e, 3, 2); 4354 break; 4355 case 4: 4356 r.appendChars(e, 0, 4), r.append('00000'), r.append(e[4]); 4357 break; 4358 default: 4359 r.appendChars(e, 0, 5), r.append('0000'), r.append(n); 4360 } 4361 return t.length >= 8 && r.append(t.charAt(7)), r.toString(); 4362 } 4363 } 4364 (Rt.MIDDLE_END_PATTERN = Int32Array.from([1, 1, 1, 1, 1, 1])), 4365 (Rt.NUMSYS_AND_CHECK_DIGIT_PATTERNS = [ 4366 Int32Array.from([56, 52, 50, 49, 44, 38, 35, 42, 41, 37]),
4367 Int32Array.from([7, 11, 13, 14, 19, 25, 28, 21, 22, 1]), 4368 ]); 4369 class Nt extends gt { 4370 constructor(t) { 4371 super(); 4372 let e = null == t ? null : t.get(C.POSSIBLE_FORMATS), 4373 r = []; 4374 null != e && 4375 (e.indexOf(v.EAN_13) > -1 ? r.push(new St()) : e.indexOf(v.UPC_A) > -1 && r.push(new Tt()), 4376 e.indexOf(v.EAN_8) > -1 && r.push(new pt()), 4377 e.indexOf(v.UPC_E) > -1 && r.push(new Rt())), 4378 0 === r.length && (r.push(new St()), r.push(new pt()), r.push(new Rt())), 4379 (this.readers = r); 4380 } 4381 decodeRow(t, e, r) { 4382 for (let n of this.readers) 4383 try { 4384 const i = n.decodeRow(t, e, r), 4385 s = i.getBarcodeFormat() === v.EAN_13 && '0' === i.getText().charAt(0), 4386 o = null == r ? null : r.get(C.POSSIBLE_FORMATS), 4387 a = null == o || o.includes(v.UPC_A); 4388 if (s && a) { 4389 const t = i.getRawBytes(), 4390 e = new F(i.getText().substring(1), t, t.length, i.getResultPoints(), v.UPC_A); 4391 return e.putAllMetadata(i.getResultMetadata()), e; 4392 } 4393 return i; 4394 } catch (t) {} 4395 throw new R(); 4396 } 4397 reset() { 4398 for (let t of this.readers) t.reset(); 4399 } 4400 } 4401 class Dt extends gt { 4402 constructor() { 4403 super(), 4404 (this.decodeFinderCounters = new Int32Array(4)), 4405 (this.dataCharacterCounters = new Int32Array(8)), 4406 (this.oddRoundingErrors = new Array(4)), 4407 (this.evenRoundingErrors = new Array(4)), 4408 (this.oddCounts = new Array(this.dataCharacterCounters.length / 2)), 4409 (this.evenCounts = new Array(this.dataCharacterCounters.length / 2)); 4410 } 4411 getDecodeFinderCounters() { 4412 return this.decodeFinderCounters; 4413 } 4414 getDataCharacterCounters() { 4415 return this.dataCharacterCounters; 4416 } 4417 getOddRoundingErrors() { 4418 return this.oddRoundingErrors; 4419 } 4420 getEvenRoundingErrors() { 4421 return this.evenRoundingErrors; 4422 } 4423 getOddCounts() { 4424 return this.oddCounts; 4425 } 4426 getEvenCounts() { 4427 return this.evenCounts; 4428 } 4429 parseFinderValue(t, e) { 4430 for (let r = 0; r < e.length; r++) 4431 if (gt.patternMatchVariance(t, e[r], Dt.MAX_INDIVIDUAL_VARIANCE) < Dt.MAX_AVG_VARIANCE) return r; 4432 throw new R(); 4433 } 4434 static count(t) { 4435 return tt.sum(new Int32Array(t)); 4436 } 4437 static increment(t, e) { 4438 let r = 0, 4439 n = e[0]; 4440 for (let i = 1; i < t.length; i++) e[i] > n && ((n = e[i]), (r = i)); 4441 t[r]++; 4442 } 4443 static decrement(t, e) { 4444 let r = 0, 4445 n = e[0]; 4446 for (let i = 1; i < t.length; i++) e[i] < n && ((n = e[i]), (r = i)); 4447 t[r]--; 4448 } 4449 static isFinderPattern(t) { 4450 let e = t[0] + t[1], 4451 r = e / (e + t[2] + t[3]); 4452 if (r >= Dt.MIN_FINDER_PATTERN_RATIO && r <= Dt.MAX_FINDER_PATTERN_RATIO) { 4453 let e = Number.MAX_SAFE_INTEGER, 4454 r = Number.MIN_SAFE_INTEGER; 4455 for (let n of t) n > r && (r = n), n < e && (e = n); 4456 return r < 10 * e; 4457 } 4458 return !1; 4459 } 4460 } 4461 (Dt.MAX_AVG_VARIANCE = 0.2), 4462 (Dt.MAX_INDIVIDUAL_VARIANCE = 0.45), 4463 (Dt.MIN_FINDER_PATTERN_RATIO = 9.5 / 12), 4464 (Dt.MAX_FINDER_PATTERN_RATIO = 12.5 / 14); 4465 class yt { 4466 constructor(t, e) { 4467 (this.value = t), (this.checksumPortion = e); 4468 } 4469 getValue() { 4470 return this.value; 4471 } 4472 getChecksumPortion() { 4473 return this.checksumPortion; 4474 } 4475 toString() { 4476 return this.value + '(' + this.checksumPortion + ')'; 4477 } 4478 equals(t) { 4479 if (!(t instanceof yt)) return !1; 4480 const e = t; 4481 return this.value === e.value && this.checksumPortion === e.checksumPortion; 4482 } 4483 hashCode() { 4484 return this.value ^ this.checksumPortion; 4485 } 4486 } 4487 class Ot { 4488 constructor(t, e, r, n, i) { 4489 (this.value = t), 4490 (this.startEnd = e), 4491 (this.value = t), 4492 (this.startEnd = e), 4493 (this.resultPoints = new Array()), 4494 this.resultPoints.push(new rt(r, i)), 4495 this.resultPoints.push(new rt(n, i)); 4496 } 4497 getValue() { 4498 return this.value; 4499 } 4500 getStartEnd() { 4501 return this.startEnd; 4502 } 4503 getResultPoints() { 4504 return this.resultPoints; 4505 } 4506 equals(t) { 4507 if (!(t instanceof Ot)) return !1; 4508 const e = t; 4509 return this.value === e.value; 4510 } 4511 hashCode() { 4512 return this.value; 4513 } 4514 } 4515 class Mt { 4516 constructor() {} 4517 static getRSSvalue(t, e, r) { 4518 let n = 0; 4519 for (let e of t) n += e; 4520 let i = 0, 4521 s = 0, 4522 o = t.length; 4523 for (let a = 0; a < o - 1; a++) { 4524 let l; 4525 for (l = 1, s |= 1 << a; l < t[a]; l++, s &= ~(1 << a)) { 4526 let t = Mt.combins(n - l - 1, o - a - 2); 4527 if ( 4528 (r && 0 === s && n - l - (o - a - 1) >= o - a - 1 && (t -= Mt.combins(n - l - (o - a), o - a - 2)), 4529 o - a - 1 > 1) 4530 ) { 4531 let r = 0; 4532 for (let t = n - l - (o - a - 2); t > e; t--) r += Mt.combins(n - l - t - 1, o - a - 3); 4533 t -= r * (o - 1 - a); 4534 } else n - l > e && t--; 4535 i += t; 4536 } 4537 n -= l; 4538 } 4539 return i; 4540 } 4541 static combins(t, e) { 4542 let r, n; 4543 t - e > e ? ((n = e), (r = t - e)) : ((n = t - e), (r = e)); 4544 let i = 1, 4545 s = 1; 4546 for (let e = t; e > r; e--) (i *= e), s <= n && ((i /= s), s++); 4547 for (; s <= n; ) (i /= s), s++; 4548 return i; 4549 } 4550 } 4551 class Bt { 4552 constructor(t, e) { 4553 e ? (this.decodedInformation = null) : ((this.finished = t), (this.decodedInformation = e)); 4554 } 4555 getDecodedInformation() { 4556 return this.decodedInformation; 4557 } 4558 isFinished() { 4559 return this.finished; 4560 } 4561 } 4562 class bt { 4563 constructor(t) { 4564 this.newPosition = t; 4565 } 4566 getNewPosition() { 4567 return this.newPosition; 4568 } 4569 } 4570 class Pt extends bt { 4571 constructor(t, e) { 4572 super(t), (this.value = e); 4573 } 4574 getValue() { 4575 return this.value; 4576 } 4577 isFNC1() { 4578 return this.value === Pt.FNC1; 4579 } 4580 } 4581 Pt.FNC1 = '$'; 4582 class Lt extends bt { 4583 constructor(t, e, r) { 4584 super(t), 4585 r 4586 ? ((this.remaining = !0), (this.remainingValue = this.remainingValue)) 4587 : ((this.remaining = !1), (this.remainingValue = 0)), 4588 (this.newString = e); 4589 } 4590 getNewString() { 4591 return this.newString; 4592 } 4593 isRemaining() { 4594 return this.remaining; 4595 } 4596 getRemainingValue() { 4597 return this.remainingValue; 4598 } 4599 } 4600 class Ft extends bt { 4601 constructor(t, e, r) { 4602 if ((super(t), e < 0 || e > 10 || r < 0 || r > 10)) throw new E(); 4603 (this.firstDigit = e), (this.secondDigit = r); 4604 } 4605 getFirstDigit() { 4606 return this.firstDigit; 4607 } 4608 getSecondDigit() { 4609 return this.secondDigit; 4610 } 4611 getValue() { 4612 return 10 * this.firstDigit + this.secondDigit; 4613 } 4614 isFirstDigitFNC1() { 4615 return this.firstDigit === Ft.FNC1; 4616 } 4617 isSecondDigitFNC1() { 4618 return this.secondDigit === Ft.FNC1; 4619 } 4620 isAnyFNC1() { 4621 return this.firstDigit === Ft.FNC1 || this.secondDigit === Ft.FNC1; 4622 } 4623 } 4624 Ft.FNC1 = 10; 4625 class kt { 4626 constructor() {} 4627 static parseFieldsInGeneralPurpose(t) { 4628 if (!t) return null; 4629 if (t.length < 2) throw new R(); 4630 let e = t.substring(0, 2); 4631 for (let r of kt.TWO_DIGIT_DATA_LENGTH) 4632 if (r[0] === e) 4633 return r[1] === kt.VARIABLE_LENGTH ? kt.processVariableAI(2, r[2], t) : kt.process
4633FixedAI(2, r[1], t); 4634 if (t.length < 3) throw new R(); 4635 let r = t.substring(0, 3); 4636 for (let e of kt.THREE_DIGIT_DATA_LENGTH) 4637 if (e[0] === r) 4638 return e[1] === kt.VARIABLE_LENGTH ? kt.processVariableAI(3, e[2], t) : kt.processFixedAI(3, e[1], t); 4639 for (let e of kt.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH) 4640 if (e[0] === r) 4641 return e[1] === kt.VARIABLE_LENGTH ? kt.processVariableAI(4, e[2], t) : kt.processFixedAI(4, e[1], t); 4642 if (t.length < 4) throw new R(); 4643 let n = t.substring(0, 4); 4644 for (let e of kt.FOUR_DIGIT_DATA_LENGTH) 4645 if (e[0] === n) 4646 return e[1] === kt.VARIABLE_LENGTH ? kt.processVariableAI(4, e[2], t) : kt.processFixedAI(4, e[1], t); 4647 throw new R(); 4648 } 4649 static processFixedAI(t, e, r) { 4650 if (r.length < t) throw new R(); 4651 let n = r.substring(0, t); 4652 if (r.length < t + e) throw new R(); 4653 let i = r.substring(t, t + e), 4654 s = r.substring(t + e), 4655 o = '(' + n + ')' + i, 4656 a = kt.parseFieldsInGeneralPurpose(s); 4657 return null == a ? o : o + a; 4658 } 4659 static processVariableAI(t, e, r) { 4660 let n, 4661 i = r.substring(0, t); 4662 n = r.length < t + e ? r.length : t + e; 4663 let s = r.substring(t, n), 4664 o = r.substring(n), 4665 a = '(' + i + ')' + s, 4666 l = kt.parseFieldsInGeneralPurpose(o); 4667 return null == l ? a : a + l; 4668 } 4669 } 4670 (kt.VARIABLE_LENGTH = []), 4671 (kt.TWO_DIGIT_DATA_LENGTH = [ 4672 ['00', 18], 4673 ['01', 14], 4674 ['02', 14], 4675 ['10', kt.VARIABLE_LENGTH, 20], 4676 ['11', 6], 4677 ['12', 6], 4678 ['13', 6], 4679 ['15', 6], 4680 ['17', 6], 4681 ['20', 2], 4682 ['21', kt.VARIABLE_LENGTH, 20], 4683 ['22', kt.VARIABLE_LENGTH, 29], 4684 ['30', kt.VARIABLE_LENGTH, 8], 4685 ['37', kt.VARIABLE_LENGTH, 8], 4686 ['90', kt.VARIABLE_LENGTH, 30], 4687 ['91', kt.VARIABLE_LENGTH, 30], 4688 ['92', kt.VARIABLE_LENGTH, 30], 4689 ['93', kt.VARIABLE_LENGTH, 30], 4690 ['94', kt.VARIABLE_LENGTH, 30], 4691 ['95', kt.VARIABLE_LENGTH, 30], 4692 ['96', kt.VARIABLE_LENGTH, 30], 4693 ['97', kt.VARIABLE_LENGTH, 3], 4694 ['98', kt.VARIABLE_LENGTH, 30], 4695 ['99', kt.VARIABLE_LENGTH, 30], 4696 ]), 4697 (kt.THREE_DIGIT_DATA_LENGTH = [ 4698 ['240', kt.VARIABLE_LENGTH, 30], 4699 ['241', kt.VARIABLE_LENGTH, 30], 4700 ['242', kt.VARIABLE_LENGTH, 6], 4701 ['250', kt.VARIABLE_LENGTH, 30], 4702 ['251', kt.VARIABLE_LENGTH, 30], 4703 ['253', kt.VARIABLE_LENGTH, 17], 4704 ['254', kt.VARIABLE_LENGTH, 20], 4705 ['400', kt.VARIABLE_LENGTH, 30], 4706 ['401', kt.VARIABLE_LENGTH, 30], 4707 ['402', 17], 4708 ['403', kt.VARIABLE_LENGTH, 30], 4709 ['410', 13], 4710 ['411', 13], 4711 ['412', 13], 4712 ['413', 13], 4713 ['414', 13], 4714 ['420', kt.VARIABLE_LENGTH, 20], 4715 ['421', kt.VARIABLE_LENGTH, 15], 4716 ['422', 3], 4717 ['423', kt.VARIABLE_LENGTH, 15], 4718 ['424', 3], 4719 ['425', 3], 4720 ['426', 3], 4721 ]), 4722 (kt.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH = [ 4723 ['310', 6], 4724 ['311', 6], 4725 ['312', 6], 4726 ['313', 6], 4727 ['314', 6], 4728 ['315', 6], 4729 ['316', 6], 4730 ['320', 6], 4731 ['321', 6], 4732 ['322', 6], 4733 ['323', 6], 4734 ['324', 6], 4735 ['325', 6], 4736 ['326', 6], 4737 ['327', 6], 4738 ['328', 6], 4739 ['329', 6], 4740 ['330', 6], 4741 ['331', 6], 4742 ['332', 6], 4743 ['333', 6], 4744 ['334', 6], 4745 ['335', 6], 4746 ['336', 6], 4747 ['340', 6], 4748 ['341', 6], 4749 ['342', 6], 4750 ['343', 6], 4751 ['344', 6], 4752 ['345', 6], 4753 ['346', 6], 4754 ['347', 6], 4755 ['348', 6], 4756 ['349', 6], 4757 ['350', 6], 4758 ['351', 6], 4759 ['352', 6], 4760 ['353', 6], 4761 ['354', 6], 4762 ['355', 6], 4763 ['356', 6], 4764 ['357', 6], 4765 ['360', 6], 4766 ['361', 6], 4767 ['362', 6], 4768 ['363', 6], 4769 ['364', 6], 4770 ['365', 6], 4771 ['366', 6], 4772 ['367', 6], 4773 ['368', 6], 4774 ['369', 6], 4775 ['390', kt.VARIABLE_LENGTH, 15], 4776 ['391', kt.VARIABLE_LENGTH, 18], 4777 ['392', kt.VARIABLE_LENGTH, 15], 4778 ['393', kt.VARIABLE_LENGTH, 18], 4779 ['703', kt.VARIABLE_LENGTH, 30], 4780 ]), 4781 (kt.FOUR_DIGIT_DATA_LENGTH = [ 4782 ['7001', 13], 4783 ['7002', kt.VARIABLE_LENGTH, 30], 4784 ['7003', 10], 4785 ['8001', 14], 4786 ['8002', kt.VARIABLE_LENGTH, 20], 4787 ['8003', kt.VARIABLE_LENGTH, 30], 4788 ['8004', kt.VARIABLE_LENGTH, 30], 4789 ['8005', 6], 4790 ['8006', 18], 4791 ['8007', kt.VARIABLE_LENGTH, 30], 4792 ['8008', kt.VARIABLE_LENGTH, 12], 4793 ['8018', 18], 4794 ['8020', kt.VARIABLE_LENGTH, 25], 4795 ['8100', 6], 4796 ['8101', 10], 4797 ['8102', 2], 4798 ['8110', kt.VARIABLE_LENGTH, 70], 4799 ['8200', kt.VARIABLE_LENGTH, 70], 4800 ]); 4801 class vt { 4802 constructor(t) { 4803 (this.buffer = new p()), (this.information = t); 4804 } 4805 decodeAllCodes(t, e) { 4806 let r = e, 4807 n = null; 4808 for (;;) { 4809 let e = this.decodeGeneralPurposeField(r, n), 4810 i = kt.parseFieldsInGeneralPurpose(e.getNewString()); 4811 if ( 4812 (null != i && t.append(i), 4813 (n = e.isRemaining() ? '' + e.getRemainingValue() : null), 4814 r === e.getNewPosition()) 4815 ) 4816 break; 4817 r = e.getNewPosition(); 4818 } 4819 return t.toString(); 4820 } 4821 isStillNumeric(t) { 4822 if (t + 7 > this.information.getSize()) return t + 4 <= this.information.getSize(); 4823 for (let e = t; e < t + 3; ++e) if (this.information.get(e)) return !0; 4824 return this.information.get(t + 3); 4825 } 4826 decodeNumeric(t) { 4827 if (t + 7 > this.information.getSize()) { 4828 let e = this.extractNumericValueFromBitArray(t, 4); 4829 return new Ft(this.information.getSize(), 0 === e ? Ft.FNC1 : e - 1, Ft.FNC1); 4830 } 4831 let e = this.extractNumericValueFromBitArray(t, 7); 4832 return new Ft(t + 7, (e - 8) / 11, (e - 8) % 11); 4833 } 4834 extractNumericValueFromBitArray(t, e) { 4835 return vt.extractNumericValueFromBitArray(this.information, t, e); 4836 } 4837 static extractNumericValueFromBitArray(t, e, r) { 4838 let n = 0; 4839 for (let i = 0; i < r; ++i) t.get(e + i) && (n |= 1 << (r - i - 1)); 4840 return n; 4841 } 4842 decodeGeneralPurposeField(t, e) { 4843 this.buffer.setLengthToZero(), null != e && this.buffer.append(e), this.current.setPosition(t); 4844 let r = this.parseBlocks(); 4845 return null != r && r.isRemaining() 4846 ? new Lt(this.current.getPosition(), this.buffer.toString(), r.getRemainingValue()) 4847 : new Lt(this.current.getPosition(), this.buffer.toString()); 4848 } 4849 parseBlocks() { 4850 let t, e; 4851 do { 4852 let r = this.current.getPosition(); 4853 if ( 4854 (this.current.isAlpha() 4855 ? ((e = this.parseAlphaBlock()), (t = e.isFinished())) 4856 : this.current.isIsoIec646() 4857 ? ((e = this.parseIsoIec646Block()), (t = e.isFinished())) 4858 : ((e = this.parseNumericBlock()), (t = e.isFinished())), 4859 !(r !== this.current.getPosition()) && !t) 4860 ) 4861 break; 4862 } while (!t); 4863 return e.getDecodedInformation(); 4864 } 4865 parseNumericBlock() { 4866 for (; this.isStillNumeric(this.current.getPosition()); ) { 4867 let t = this.decodeNumeric(this.current.getPosition()); 4868 if ((this.current.setPosition(t.getNewPosition()), t.isFirstDigitFNC1())) { 4869 let e; 4870 return ( 4871 (e = t.isSecondDigitFNC1() 4872 ? new Lt(this.current.getPosition(), this.buffer.toString()) 4873 : new Lt(this.current.getPosition(), this.buffer.toString(), t.getSecondDigit())), 4874 new Bt(!0, e) 4875 ); 4876 } 4877 if ((this.buffer.append(t.getFirstDigit()), t.isSecondDigitFNC1())) { 4878 let t = new Lt(this.current.getPosition(), this.buffer.toString()); 4879 return new Bt(!0, t); 4880 } 4881 this.buffer.append(t.getSecondDigit()); 4882 } 4883 return ( 4884 this.isNumericToAlphaNumericLatch(this.current.getPosition()) && 4885 (this.current.setAlpha(), this.current.incrementPosition(4)), 4886 new Bt(!1) 4887 ); 4888 } 4889 parseIsoIec646Block() { 4890 for (; this.isStillIsoIec646(this.current.getPosition()); ) { 4891 let t = this.decodeIsoIec646(this.current.getPosition()); 4892 if ((this.current.setPosition(t.getNewPosition()), t.isFNC1())) { 4893 let t = new Lt(this.current.getPosition(), this.buffer.toString()); 4894 return new Bt(!0, t); 4895 } 4896 this.buffer.append(t.getValue()); 4897 } 4898 return ( 4899 this.isAlphaOr646ToNumericLatch(this.current.getPosition()) 4900 ? (this.current.incrementPosition(3), this.current.setNumeric()) 4901 : this.isAlphaTo646ToAlphaLatch(this.current.getPosition()) && 4902 (this.current.getPosition() + 5 < this.information.getSize() 4903 ? this.current.incrementPosition(5) 4904 : this.current.setPosition(this.information.getSize()), 4905 this.current.setAlpha()), 4906 new Bt(!1) 4907 ); 4908 } 4909 parseAlphaBlock() { 4910 for (; this.isStillAlpha(this.current.getPosition()); ) { 4911 let t = this.decodeAlphanumeric(this.current.getPosition()); 4912 if ((this.current.setPosition(t.getNewPosition()), t.isFNC1())) { 4913 let t = new Lt(this.current.getPosition(), this.buffer.toString()); 4914 return new Bt(!0, t); 4915 } 4916 this.buffer.append(t.getValue()); 4917 } 4918 return ( 4919 this.isAlphaOr646ToNumericLatch(this.current.getPosition()) 4920 ? (this.current.incrementPosition(3), this.current.setNumeric()) 4921 : this.isAlphaTo646ToAlphaLatch(this.current.getPosition()) && 4922 (this.current.getPosition() + 5 < this.information.getSize() 4923 ? this.current.incrementPosition(5) 4924 : this.current.setPosition(this.information.getSize()), 4925 this.current.setIsoIec646()), 4926 new Bt(!1) 4927 ); 4928 } 4929 isStillIsoIec646(t) { 4930 if (t + 5 > this.information.getSize()) return !1; 4931 let e = this.extractNumericValueFromBitArray(t, 5); 4932 if (e >= 5 && e < 16) return !0; 4933 if (t + 7 > this.information.getSize()) return !1; 4934 let r = this.extractNumericValueFromBitArray(t, 7); 4935 if (r >= 64 && r < 116) return !0; 4936 if (t + 8 > this.information.getSize()) return !1; 4937 let n = this.extractNumericValueFromBitArray(t, 8); 4938 return n >= 232 && n < 253; 4939 } 4940 decodeIsoIec646(t) { 4941 let e = this.extractNumericValueFromBitArray(t, 5); 4942 if (15 === e) return new Pt(t + 5, Pt.FNC1); 4943 if (e >= 5 && e < 15) return new Pt(t + 5, '0' + (e - 5)); 4944 let r, 4945 n = this.extractNumericValueFromBitArray(t, 7); 4946 if (n >= 64 && n < 90) return new Pt(t + 7, '' + (n + 1)); 4947 if (n >= 90 && n < 116) return new Pt(t + 7, '' + (n + 7)); 4948 switch (this.extractNumericValueFromBitArray(t, 8)) { 4949 case 232: 4950 r = '!'; 4951 break; 4952 case 233: 4953 r = '"'; 4954 break; 4955 case 234: 4956 r = '%'; 4957 break; 4958 case 235: 4959 r = '&'; 4960 break; 4961 case 236: 4962 r = "'"; 4963 break; 4964 case 237: 4965 r = '('; 4966 break; 4967 case 238: 4968 r = ')'; 4969 break; 4970 case 239: 4971 r = '*'; 4972 break; 4973 case 240: 4974 r = '+'; 4975 break; 4976 case 241: 4977 r = ','; 4978 break; 4979 case 242: 4980 r = '-'; 4981 break; 4982 case 243: 4983 r = '.'; 4984 break; 4985 case 244: 4986 r = '/'; 4987 break; 4988 case 245: 4989 r = ':'; 4990 break; 4991 case 246: 4992 r = ';'; 4993 break; 4994 case 247: 4995 r = '<'; 4996 break; 4997 case 248: 4998 r = '='; 4999 break; 5000 case 249: 5001 r = '>'; 5002 break; 5003 case 250: 5004 r = '?'; 5005 break; 5006 case 251: 5007 r = '_'; 5008 break; 5009 case 252: 5010 r = ' '; 5011 break; 5012 default: 5013 throw new E(); 5014 } 5015 return new Pt(t + 8, r); 5016 } 5017 isStillAlpha(t) { 5018 if (t + 5 > this.information.getSize()) return !1; 5019 let e = this.extractNumericValueFromBitArray(t, 5); 5020 if (e >= 5 && e < 16) return !0; 5021 if (t + 6 > this.information.getSize()) return !1; 5022 let r = this.extractNumericValueFromBitArray(t, 6); 5023 return r >= 16 && r < 63; 5024 } 5025 decodeAlphanumeric(t) { 5026 let e = this.extractNumericValueFromBitArray(t, 5); 5027 if (15 === e) return new Pt(t + 5, Pt.FNC1); 5028 if (e >= 5 && e < 15) return new Pt(t + 5, '0' + (e - 5)); 5029 let r, 5030 n = this.extractNumericValueFromBitArray(t, 6); 5031 if (n >= 32 && n < 58) return new Pt(t + 6, '' + (n + 33)); 5032 switch (n) { 5033 case 58: 5034 r = '*'; 5035 break; 5036 case 59: 5037 r = ','; 5038 break; 5039 case 60: 5040 r = '-'; 5041 break; 5042 case 61: 5043 r = '.'; 5044 break; 5045 case 62: 5046 r = '/'; 5047 break; 5048 default: 5049 throw new j('Decoding invalid alphanumeric value: ' + n); 5050 } 5051 return new Pt(t + 6, r); 5052 } 5053 isAlphaTo646ToAlphaLatch(t) { 5054 if (t + 1 > this.information.getSize()) return !1; 5055 for (let e = 0; e < 5 && e + t < this.information.getSize(); ++e) 5056 if (2 === e) { 5057 if (!this.information.get(t + 2)) return !1; 5058 } else if (this.information.get(t + e)) return !1; 5059 return !0; 5060 } 5061 isAlphaOr646ToNumericLatch(t) { 5062 if (t + 3 > this.information.getSize()) return !1; 5063 for (let e = t; e < t + 3; ++e) if (this.information.get(e)) return !1; 5064 return !0; 5065 } 5066 isNumericToAlphaNumericLatch(t) { 5067 if (t + 1 > this.information.getSize()) return !1; 5068 for (let e = 0; e < 4 && e + t < this.information.getSize(); ++e) if (this.information.get(t + e)) return !1; 5069 return !0; 5070 } 5071 } 5072 class xt { 5073 constructor(t) { 5074 (this.information = t), (this.generalDecoder = new vt(t)); 5075 } 5076 getInformation() { 5077 return this.information; 5078 } 5079 getGeneralDecoder() { 5080 return this.generalDecoder; 5081 } 5082 } 5083 class Vt extends xt { 5084 constructor(t) { 5085 super(t); 5086 } 5087 encodeCompressedGtin(t, e) { 5088 t.append('(01)'); 5089 let r = t.length(); 5090 t.append('9'), this.encodeCompressedGtinWithoutAI(t, e, r); 5091 } 5092 encodeCompressedGtinWithoutAI(t, e, r) { 5093 for (let r = 0; r < 4; ++r) { 5094 let n = this.getGeneralDecoder().extractNumericValueFromBitArray(e + 10 * r, 10); 5095 n / 100 == 0 && t.append('0'), n / 10 == 0 && t.append('0'), t.append(n); 5096 } 5097 Vt.appendCheckDigit(t, r); 5098 } 5099 static appendCheckDigit(t, e) { 5100 let r = 0; 5101 for (let n = 0; n < 13; n++) { 5102 let i = t.charAt(n + e).charCodeAt(0) - '0'.charCodeAt(0); 5103 r += 0 == (1 & n) ? 3 * i : i; 5104 } 5105 (r = 10 - (r % 10)), 10 === r && (r = 0), t.append(r); 5106 } 5107 } 5108 Vt.GTIN_SIZE = 40; 5109 class Ut extends Vt { 5110 constructor(t) { 5111 super(t); 5112 } 5113 parseInformation() { 5114 let t = new p(); 5115 t.append('(01)'); 5116 let e = t.length(), 5117 r = this.getGeneralDecoder().extractNumericValueFromBitArray(Ut.HEADER_SIZE, 4); 5118 return ( 5119 t.append(r), 5120 this.encodeCompressedGtinWithoutAI(t, Ut.HEADER_SIZE + 4, e), 5121 this.getGeneralDecoder().decodeAllCodes(t, Ut.HEADER_SIZE + 44) 5122 ); 5123 } 5124 } 5125 Ut.HEADER_SIZE = 4; 5126 class Ht extends xt { 5127 constructor(t) { 5128 super(t); 5129 } 5130 parseInformation() { 5131 let t = new p(); 5132 return this.getGeneralDecoder().decodeAllCodes(t, Ht.HEADER_SIZE); 5133 } 5134 } 5135 Ht.HEADER_SIZE = 5;
5136 class Gt extends Vt { 5137 constructor(t) { 5138 super(t); 5139 } 5140 encodeCompressedWeight(t, e, r) { 5141 let n = this.getGeneralDecoder().extractNumericValueFromBitArray(e, r); 5142 this.addWeightCode(t, n); 5143 let i = this.checkWeight(n), 5144 s = 1e5; 5145 for (let e = 0; e < 5; ++e) i / s == 0 && t.append('0'), (s /= 10); 5146 t.append(i); 5147 } 5148 } 5149 class Xt extends Gt { 5150 constructor(t) { 5151 super(t); 5152 } 5153 parseInformation() { 5154 if (this.getInformation().getSize() != Xt.HEADER_SIZE + Gt.GTIN_SIZE + Xt.WEIGHT_SIZE) throw new R(); 5155 let t = new p(); 5156 return ( 5157 this.encodeCompressedGtin(t, Xt.HEADER_SIZE), 5158 this.encodeCompressedWeight(t, Xt.HEADER_SIZE + Gt.GTIN_SIZE, Xt.WEIGHT_SIZE), 5159 t.toString() 5160 ); 5161 } 5162 } 5163 (Xt.HEADER_SIZE = 5), (Xt.WEIGHT_SIZE = 15); 5164 class Wt extends Xt { 5165 constructor(t) { 5166 super(t); 5167 } 5168 addWeightCode(t, e) { 5169 t.append('(3103)'); 5170 } 5171 checkWeight(t) { 5172 return t; 5173 } 5174 } 5175 class zt extends Xt { 5176 constructor(t) { 5177 super(t); 5178 } 5179 addWeightCode(t, e) { 5180 e < 1e4 ? t.append('(3202)') : t.append('(3203)'); 5181 } 5182 checkWeight(t) { 5183 return t < 1e4 ? t : t - 1e4; 5184 } 5185 } 5186 class Yt extends Vt { 5187 constructor(t) { 5188 super(t); 5189 } 5190 parseInformation() { 5191 if (this.getInformation().getSize() < Yt.HEADER_SIZE + Vt.GTIN_SIZE) throw new R(); 5192 let t = new p(); 5193 this.encodeCompressedGtin(t, Yt.HEADER_SIZE); 5194 let e = this.getGeneralDecoder().extractNumericValueFromBitArray( 5195 Yt.HEADER_SIZE + Vt.GTIN_SIZE, 5196 Yt.LAST_DIGIT_SIZE, 5197 ); 5198 t.append('(392'), t.append(e), t.append(')'); 5199 let r = this.getGeneralDecoder().decodeGeneralPurposeField( 5200 Yt.HEADER_SIZE + Vt.GTIN_SIZE + Yt.LAST_DIGIT_SIZE, 5201 null, 5202 ); 5203 return t.append(r.getNewString()), t.toString(); 5204 } 5205 } 5206 (Yt.HEADER_SIZE = 8), (Yt.LAST_DIGIT_SIZE = 2); 5207 class Zt extends Vt { 5208 constructor(t) { 5209 super(t); 5210 } 5211 parseInformation() { 5212 if (this.getInformation().getSize() < Zt.HEADER_SIZE + Vt.GTIN_SIZE) throw new R(); 5213 let t = new p(); 5214 this.encodeCompressedGtin(t, Zt.HEADER_SIZE); 5215 let e = this.getGeneralDecoder().extractNumericValueFromBitArray( 5216 Zt.HEADER_SIZE + Vt.GTIN_SIZE, 5217 Zt.LAST_DIGIT_SIZE, 5218 ); 5219 t.append('(393'), t.append(e), t.append(')'); 5220 let r = this.getGeneralDecoder().extractNumericValueFromBitArray( 5221 Zt.HEADER_SIZE + Vt.GTIN_SIZE + Zt.LAST_DIGIT_SIZE, 5222 Zt.FIRST_THREE_DIGITS_SIZE, 5223 ); 5224 r / 100 == 0 && t.append('0'), r / 10 == 0 && t.append('0'), t.append(r); 5225 let n = this.getGeneralDecoder().decodeGeneralPurposeField( 5226 Zt.HEADER_SIZE + Vt.GTIN_SIZE + Zt.LAST_DIGIT_SIZE + Zt.FIRST_THREE_DIGITS_SIZE, 5227 null, 5228 ); 5229 return t.append(n.getNewString()), t.toString(); 5230 } 5231 } 5232 (Zt.HEADER_SIZE = 8), (Zt.LAST_DIGIT_SIZE = 2), (Zt.FIRST_THREE_DIGITS_SIZE = 10); 5233 class Kt extends Gt { 5234 constructor(t, e, r) { 5235 super(t), (this.dateCode = r), (this.firstAIdigits = e); 5236 } 5237 parseInformation() { 5238 if (this.getInformation().getSize() != Kt.HEADER_SIZE + Kt.GTIN_SIZE + Kt.WEIGHT_SIZE + Kt.DATE_SIZE) 5239 throw new R(); 5240 let t = new p(); 5241 return ( 5242 this.encodeCompressedGtin(t, Kt.HEADER_SIZE), 5243 this.encodeCompressedWeight(t, Kt.HEADER_SIZE + Kt.GTIN_SIZE, Kt.WEIGHT_SIZE), 5244 this.encodeCompressedDate(t, Kt.HEADER_SIZE + Kt.GTIN_SIZE + Kt.WEIGHT_SIZE), 5245 t.toString() 5246 ); 5247 } 5248 encodeCompressedDate(t, e) { 5249 let r = this.getGeneralDecoder().extractNumericValueFromBitArray(e, Kt.DATE_SIZE); 5250 if (38400 == r) return; 5251 t.append('('), t.append(this.dateCode), t.append(')'); 5252 let n = r % 32; 5253 r /= 32; 5254 let i = (r % 12) + 1; 5255 r /= 12; 5256 let s = r; 5257 s / 10 == 0 && t.append('0'), 5258 t.append(s), 5259 i / 10 == 0 && t.append('0'), 5260 t.append(i), 5261 n / 10 == 0 && t.append('0'), 5262 t.append(n); 5263 } 5264 addWeightCode(t, e) { 5265 t.append('('), t.append(this.firstAIdigits), t.append(e / 1e5), t.append(')'); 5266 } 5267 checkWeight(t) { 5268 return t % 1e5; 5269 } 5270 } 5271 function qt(t) { 5272 try { 5273 if (t.get(1)) return new Ut(t); 5274 if (!t.get(2)) return new Ht(t); 5275 switch (vt.extractNumericValueFromBitArray(t, 1, 4)) { 5276 case 4: 5277 return new Wt(t); 5278 case 5: 5279 return new zt(t); 5280 } 5281 switch (vt.extractNumericValueFromBitArray(t, 1, 5)) { 5282 case 12: 5283 return new Yt(t); 5284 case 13: 5285 return new Zt(t); 5286 } 5287 switch (vt.extractNumericValueFromBitArray(t, 1, 7)) { 5288 case 56: 5289 return new Kt(t, '310', '11'); 5290 case 57: 5291 return new Kt(t, '320', '11'); 5292 case 58: 5293 return new Kt(t, '310', '13'); 5294 case 59: 5295 return new Kt(t, '320', '13'); 5296 case 60: 5297 return new Kt(t, '310', '15'); 5298 case 61: 5299 return new Kt(t, '320', '15'); 5300 case 62: 5301 return new Kt(t, '310', '17'); 5302 case 63: 5303 return new Kt(t, '320', '17'); 5304 } 5305 } catch (e) { 5306 throw (console.log(e), new j('unknown decoder: ' + t)); 5307 } 5308 } 5309 (Kt.HEADER_SIZE = 8), (Kt.WEIGHT_SIZE = 20), (Kt.DATE_SIZE = 16); 5310 class Qt { 5311 constructor(t, e, r, n) { 5312 (this.leftchar = t), (this.rightchar = e), (this.finderpattern = r), (this.maybeLast = n); 5313 } 5314 mayBeLast() { 5315 return this.maybeLast; 5316 } 5317 getLeftChar() { 5318 return this.leftchar; 5319 } 5320 getRightChar() { 5321 return this.rightchar; 5322 } 5323 getFinderPattern() { 5324 return this.finderpattern; 5325 } 5326 mustBeLast() { 5327 return null == this.rightchar; 5328 } 5329 toString() { 5330 return ( 5331 '[ ' + 5332 this.leftchar + 5333 ', ' + 5334 this.rightchar + 5335 ' : ' + 5336 (null == this.finderpattern ? 'null' : this.finderpattern.getValue()) + 5337 ' ]' 5338 ); 5339 } 5340 static equals(t, e) { 5341 return ( 5342 t instanceof Qt && 5343 Qt.equalsOrNull(t.leftchar, e.leftchar) && 5344 Qt.equalsOrNull(t.rightchar, e.rightchar) && 5345 Qt.equalsOrNull(t.finderpattern, e.finderpattern) 5346 ); 5347 } 5348 static equalsOrNull(t, e) { 5349 return null === t ? null === e : Qt.equals(t, e); 5350 } 5351 hashCode() { 5352 return this.leftchar.getValue() ^ this.rightchar.getValue() ^ this.finderpattern.getValue(); 5353 } 5354 } 5355 class jt { 5356 constructor(t, e, r) { 5357 (this.pairs = t), (this.rowNumber = e), (this.wasReversed = r); 5358 } 5359 getPairs() { 5360 return this.pairs; 5361 } 5362 getRowNumber() { 5363 return this.rowNumber; 5364 } 5365 isReversed() { 5366 return this.wasReversed; 5367 } 5368 isEquivalent(t) { 5369 return this.checkEqualitity(this, t); 5370 } 5371 toString() { 5372 return '{ ' + this.pairs + ' }'; 5373 } 5374 equals(t, e) { 5375 return t instanceof jt && this.checkEqualitity(t, e) && t.wasReversed === e.wasReversed; 5376 } 5377 checkEqualitity(t, e) { 5378 if (!t || !e) return; 5379 let r; 5380 return ( 5381 t.forEach((t, n) => { 5382 e.forEach((e) => { 5383 t.getLeftChar().getValue() === e.getLeftChar().getValue() && 5384 t.getRightChar().getValue() === e.getRightChar().getValue() && 5385 t.getFinderPatter().getValue() === e.getFinderPatter().getValue() && 5386 (r = !0); 5387 }); 5388 }), 5389 r 5390 ); 5391 } 5392 } 5393 class Jt extends Dt { 5394 constructor() { 5395 super(...arguments), (this.pairs = new Array(Jt.MAX_PAIRS)), (this.rows = new Array()), (this.startEnd = [2]); 5396 } 5397 decodeRow(t, e, r) { 5398 (this.pairs.length = 0), (this.startFromEven = !1);
5399 try { 5400 return Jt.constructResult(this.decodeRow2pairs(t, e)); 5401 } catch (t) {} 5402 return (this.pairs.length = 0), (this.startFromEven = !0), Jt.constructResult(this.decodeRow2pairs(t, e)); 5403 } 5404 reset() { 5405 (this.pairs.length = 0), (this.rows.length = 0); 5406 } 5407 decodeRow2pairs(t, e) { 5408 let r, 5409 n = !1; 5410 for (; !n; ) 5411 try { 5412 this.pairs.push(this.retrieveNextPair(e, this.pairs, t)); 5413 } catch (t) { 5414 if (t instanceof R) { 5415 if (!this.pairs.length) throw new R(); 5416 n = !0; 5417 } 5418 } 5419 if (this.checkChecksum()) return this.pairs; 5420 if (((r = !!this.rows.length), this.storeRow(t, !1), r)) { 5421 let t = this.checkRowsBoolean(!1); 5422 if (null != t) return t; 5423 if (((t = this.checkRowsBoolean(!0)), null != t)) return t; 5424 } 5425 throw new R(); 5426 } 5427 checkRowsBoolean(t) { 5428 if (this.rows.length > 25) return (this.rows.length = 0), null; 5429 (this.pairs.length = 0), t && (this.rows = this.rows.reverse()); 5430 let e = null; 5431 try { 5432 e = this.checkRows(new Array(), 0); 5433 } catch (t) { 5434 console.log(t); 5435 } 5436 return t && (this.rows = this.rows.reverse()), e; 5437 } 5438 checkRows(t, e) { 5439 for (let r = e; r < this.rows.length; r++) { 5440 let e = this.rows[r]; 5441 this.pairs.length = 0; 5442 for (let e of t) this.pairs.push(e.getPairs()); 5443 if ((this.pairs.push(e.getPairs()), !Jt.isValidSequence(this.pairs))) continue; 5444 if (this.checkChecksum()) return this.pairs; 5445 let n = new Array(t); 5446 n.push(e); 5447 try { 5448 return this.checkRows(n, r + 1); 5449 } catch (t) { 5450 console.log(t); 5451 } 5452 } 5453 throw new R(); 5454 } 5455 static isValidSequence(t) { 5456 for (let e of Jt.FINDER_PATTERN_SEQUENCES) { 5457 if (t.length > e.length) continue; 5458 let r = !0; 5459 for (let n = 0; n < t.length; n++) 5460 if (t[n].getFinderPattern().getValue() != e[n]) { 5461 r = !1; 5462 break; 5463 } 5464 if (r) return !0; 5465 } 5466 return !1; 5467 } 5468 storeRow(t, e) { 5469 let r = 0, 5470 n = !1, 5471 i = !1; 5472 for (; r < this.rows.length; ) { 5473 let e = this.rows[r]; 5474 if (e.getRowNumber() > t) { 5475 i = e.isEquivalent(this.pairs); 5476 break; 5477 } 5478 (n = e.isEquivalent(this.pairs)), r++; 5479 } 5480 i || 5481 n || 5482 Jt.isPartialRow(this.pairs, this.rows) || 5483 (this.rows.push(r, new jt(this.pairs, t, e)), this.removePartialRows(this.pairs, this.rows)); 5484 } 5485 removePartialRows(t, e) { 5486 for (let r of e) 5487 if (r.getPairs().length !== t.length) for (let e of r.getPairs()) for (let r of t) if (Qt.equals(e, r)) break; 5488 } 5489 static isPartialRow(t, e) { 5490 for (let r of e) { 5491 let e = !0; 5492 for (let n of t) { 5493 let t = !1; 5494 for (let e of r.getPairs()) 5495 if (n.equals(e)) { 5496 t = !0; 5497 break; 5498 } 5499 if (!t) { 5500 e = !1; 5501 break; 5502 } 5503 } 5504 if (e) return !0; 5505 } 5506 return !1; 5507 } 5508 getRows() { 5509 return this.rows; 5510 } 5511 static constructResult(t) { 5512 let e = qt( 5513 class { 5514 static buildBitArray(t) { 5515 let e = 2 * t.length - 1; 5516 null == t[t.length - 1].getRightChar() && (e -= 1); 5517 let r = new w(12 * e), 5518 n = 0, 5519 i = t[0].getRightChar().getValue(); 5520 for (let t = 11; t >= 0; --t) 0 != (i & (1 << t)) && r.set(n), n++; 5521 for (let e = 1; e < t.length; ++e) { 5522 let i = t[e], 5523 s = i.getLeftChar().getValue(); 5524 for (let t = 11; t >= 0; --t) 0 != (s & (1 << t)) && r.set(n), n++; 5525 if (null != i.getRightChar()) { 5526 let t = i.getRightChar().getValue(); 5527 for (let e = 11; e >= 0; --e) 0 != (t & (1 << e)) && r.set(n), n++; 5528 } 5529 } 5530 return r; 5531 } 5532 }.buildBitArray(t), 5533 ).parseInformation(), 5534 r = t[0].getFinderPattern().getResultPoints(), 5535 n = t[t.length - 1].getFinderPattern().getResultPoints(), 5536 i = [r[0], r[1], n[0], n[1]]; 5537 return new F(e, null, null, i, v.RSS_EXPANDED, null); 5538 } 5539 checkChecksum() { 5540 let t = this.pairs.get(0), 5541 e = t.getLeftChar(), 5542 r = t.getRightChar(); 5543 if (null == r) return !1; 5544 let n = r.getChecksumPortion(), 5545 i = 2; 5546 for (let t = 1; t < this.pairs.size(); ++t) { 5547 let e = this.pairs.get(t); 5548 (n += e.getLeftChar().getChecksumPortion()), i++; 5549 let r = e.getRightChar(); 5550 null != r && ((n += r.getChecksumPortion()), i++); 5551 } 5552 return (n %= 211), 211 * (i - 4) + n == e.getValue(); 5553 } 5554 static getNextSecondBar(t, e) { 5555 let r; 5556 return ( 5557 t.get(e) ? ((r = t.getNextUnset(e)), (r = t.getNextSet(r))) : ((r = t.getNextSet(e)), (r = t.getNextUnset(r))), 5558 r 5559 ); 5560 } 5561 retrieveNextPair(t, e, r) { 5562 let n, 5563 i = e.length % 2 == 0; 5564 this.startFromEven && (i = !i); 5565 let s = !0, 5566 o = -1; 5567 do { 5568 this.findNextPair(t, e, o), 5569 (n = this.parseFoundFinderPattern(t, r, i)), 5570 null == n ? (o = Jt.getNextSecondBar(t, this.startEnd[0])) : (s = !1); 5571 } while (s); 5572 let a, 5573 l = this.decodeDataCharacter(t, n, i, !0); 5574 if (!this.isEmptyPair(e) && e[e.length - 1].mustBeLast()) throw new R();
5575 try { 5576 a = this.decodeDataCharacter(t, n, i, !1); 5577 } catch (t) { 5578 (a = null), console.log(t); 5579 } 5580 return new Qt(l, a, n, !0); 5581 } 5582 isEmptyPair(t) { 5583 return 0 === t.length; 5584 } 5585 findNextPair(t, e, r) { 5586 let n = this.getDecodeFinderCounters(); 5587 (n[0] = 0), (n[1] = 0), (n[2] = 0), (n[3] = 0); 5588 let i, 5589 s = t.getSize(); 5590 if (r >= 0) i = r; 5591 else if (this.isEmptyPair(e)) i = 0; 5592 else { 5593 i = e[e.length - 1].getFinderPattern().getStartEnd()[1]; 5594 } 5595 let o = e.length % 2 != 0; 5596 this.startFromEven && (o = !o); 5597 let a = !1; 5598 for (; i < s && ((a = !t.get(i)), a); ) i++; 5599 let l = 0, 5600 h = i; 5601 for (let e = i; e < s; e++) 5602 if (t.get(e) != a) n[l]++; 5603 else { 5604 if (3 == l) { 5605 if ((o && Jt.reverseCounters(n), Jt.isFinderPattern(n))) 5606 return (this.startEnd[0] = h), void (this.startEnd[1] = e); 5607 o && Jt.reverseCounters(n), (h += n[0] + n[1]), (n[0] = n[2]), (n[1] = n[3]), (n[2] = 0), (n[3] = 0), l--; 5608 } else l++; 5609 (n[l] = 1), (a = !a); 5610 } 5611 throw new R(); 5612 } 5613 static reverseCounters(t) { 5614 let e = t.length; 5615 for (let r = 0; r < e / 2; ++r) { 5616 let n = t[r]; 5617 (t[r] = t[e - r - 1]), (t[e - r - 1] = n); 5618 } 5619 } 5620 parseFoundFinderPattern(t, e, r) { 5621 let n, i, s; 5622 if (r) { 5623 let e = this.startEnd[0] - 1; 5624 for (; e >= 0 && !t.get(e); ) e--; 5625 e++, (n = this.startEnd[0] - e), (i = e), (s = this.startEnd[1]); 5626 } else (i = this.startEnd[0]), (s = t.getNextUnset(this.startEnd[1] + 1)), (n = s - this.startEnd[1]); 5627 let o, 5628 a = this.getDecodeFinderCounters(); 5629 c.arraycopy(a, 0, a, 1, a.length - 1), (a[0] = n); 5630 try { 5631 o = this.parseFinderValue(a, Jt.FINDER_PATTERNS); 5632 } catch (t) { 5633 return null; 5634 } 5635 return new Ot(o, [i, s], i, s, e); 5636 } 5637 decodeDataCharacter(t, e, r, n) { 5638 let i = this.getDataCharacterCounters(); 5639 for (let t = 0; t < i.length; t++) i[t] = 0; 5640 if (n) Jt.recordPatternInReverse(t, e.getStartEnd()[0], i); 5641 else { 5642 Jt.recordPattern(t, e.getStartEnd()[1], i); 5643 for (let t = 0, e = i.length - 1; t < e; t++, e--) { 5644 let r = i[t]; 5645 (i[t] = i[e]), (i[e] = r); 5646 } 5647 } 5648 let s = tt.sum(new Int32Array(i)) / 17, 5649 o = (e.getStartEnd()[1] - e.getStartEnd()[0]) / 15; 5650 if (Math.abs(s - o) / o > 0.3) throw new R(); 5651 let a = this.getOddCounts(), 5652 l = this.getEvenCounts(), 5653 h = this.getOddRoundingErrors(), 5654 c = this.getEvenRoundingErrors(); 5655 for (let t = 0; t < i.length; t++) { 5656 let e = (1 * i[t]) / s, 5657 r = e + 0.5; 5658 if (r < 1) { 5659 if (e < 0.3) throw new R(); 5660 r = 1; 5661 } else if (r > 8) { 5662 if (e > 8.7) throw new R(); 5663 r = 8; 5664 } 5665 let n = t / 2; 5666 0 == (1 & t) ? ((a[n] = r), (h[n] = e - r)) : ((l[n] = r), (c[n] = e - r)); 5667 } 5668 this.adjustOddEvenCounts(17); 5669 let u = 4 * e.getValue() + (r ? 0 : 2) + (n ? 0 : 1) - 1, 5670 d = 0, 5671 g = 0; 5672 for (let t = a.length - 1; t >= 0; t--) { 5673 if (Jt.isNotA1left(e, r, n)) { 5674 let e = Jt.WEIGHTS[u][2 * t]; 5675 g += a[t] * e; 5676 } 5677 d += a[t]; 5678 } 5679 let f = 0; 5680 for (let t = l.length - 1; t >= 0; t--) 5681 if (Jt.isNotA1left(e, r, n)) { 5682 let e = Jt.WEIGHTS[u][2 * t + 1]; 5683 f += l[t] * e; 5684 } 5685 let w = g + f; 5686 if (0 != (1 & d) || d > 13 || d < 4) throw new R(); 5687 let A = (13 - d) / 2, 5688 C = Jt.SYMBOL_WIDEST[A], 5689 E = 9 - C, 5690 m = Mt.getRSSvalue(a, C, !0), 5691 _ = Mt.getRSSvalue(l, E, !1), 5692 I = Jt.EVEN_TOTAL_SUBSET[A], 5693 S = Jt.GSUM[A]; 5694 return new yt(m * I + _ + S, w); 5695 } 5696 static isNotA1left(t, e, r) { 5697 return !(0 == t.getValue() && e && r); 5698 } 5699 adjustOddEvenCounts(t) { 5700 let e = tt.sum(new Int32Array(this.getOddCounts())), 5701 r = tt.sum(new Int32Array(this.getEvenCounts())), 5702 n = !1, 5703 i = !1; 5704 e > 13 ? (i = !0) : e < 4 && (n = !0);
5705 let s = !1, 5706 o = !1; 5707 r > 13 ? (o = !0) : r < 4 && (s = !0); 5708 let a = e + r - t, 5709 l = 1 == (1 & e), 5710 h = 0 == (1 & r); 5711 if (1 == a) 5712 if (l) { 5713 if (h) throw new R(); 5714 i = !0; 5715 } else { 5716 if (!h) throw new R(); 5717 o = !0; 5718 } 5719 else if (-1 == a) 5720 if (l) { 5721 if (h) throw new R(); 5722 n = !0; 5723 } else { 5724 if (!h) throw new R(); 5725 s = !0; 5726 } 5727 else { 5728 if (0 != a) throw new R(); 5729 if (l) { 5730 if (!h) throw new R(); 5731 e < r ? ((n = !0), (o = !0)) : ((i = !0), (s = !0)); 5732 } else if (h) throw new R(); 5733 } 5734 if (n) { 5735 if (i) throw new R(); 5736 Jt.increment(this.getOddCounts(), this.getOddRoundingErrors()); 5737 } 5738 if ((i && Jt.decrement(this.getOddCounts(), this.getOddRoundingErrors()), s)) { 5739 if (o) throw new R(); 5740 Jt.increment(this.getEvenCounts(), this.getOddRoundingErrors()); 5741 } 5742 o && Jt.decrement(this.getEvenCounts(), this.getEvenRoundingErrors()); 5743 } 5744 } 5745 (Jt.SYMBOL_WIDEST = [7, 5, 4, 3, 1]), 5746 (Jt.EVEN_TOTAL_SUBSET = [4, 20, 52, 104, 204]), 5747 (Jt.GSUM = [0, 348, 1388, 2948, 3988]), 5748 (Jt.FINDER_PATTERNS = [ 5749 Int32Array.from([1, 8, 4, 1]), 5750 Int32Array.from([3, 6, 4, 1]), 5751 Int32Array.from([3, 4, 6, 1]), 5752 Int32Array.from([3, 2, 8, 1]), 5753 Int32Array.from([2, 6, 5, 1]), 5754 Int32Array.from([2, 2, 9, 1]), 5755 ]), 5756 (Jt.WEIGHTS = [ 5757 [1, 3, 9, 27, 81, 32, 96, 77], 5758 [20, 60, 180, 118, 143, 7, 21, 63], 5759 [189, 145, 13, 39, 117, 140, 209, 205], 5760 [193, 157, 49, 147, 19, 57, 171, 91], 5761 [62, 186, 136, 197, 169, 85, 44, 132], 5762 [185, 133, 188, 142, 4, 12, 36, 108], 5763 [113, 128, 173, 97, 80, 29, 87, 50], 5764 [150, 28, 84, 41, 123, 158, 52, 156], 5765 [46, 138, 203, 187, 139, 206, 196, 166], 5766 [76, 17, 51, 153, 37, 111, 122, 155], 5767 [43, 129, 176, 106, 107, 110, 119, 146], 5768 [16, 48, 144, 10, 30, 90, 59, 177], 5769 [109, 116, 137, 200, 178, 112, 125, 164], 5770 [70, 210, 208, 202, 184, 130, 179, 115], 5771 [134, 191, 151, 31, 93, 68, 204, 190], 5772 [148, 22, 66, 198, 172, 94, 71, 2], 5773 [6, 18, 54, 162, 64, 192, 154, 40], 5774 [120, 149, 25, 75, 14, 42, 126, 167], 5775 [79, 26, 78, 23, 69, 207, 199, 175], 5776 [103, 98, 83, 38, 114, 131, 182, 124], 5777 [161, 61, 183, 127, 170, 88, 53, 159], 5778 [55, 165, 73, 8, 24, 72, 5, 15], 5779 [45, 135, 194, 160, 58, 174, 100, 89], 5780 ]), 5781 (Jt.FINDER_PAT_A = 0), 5782 (Jt.FINDER_PAT_B = 1), 5783 (Jt.FINDER_PAT_C = 2), 5784 (Jt.FINDER_PAT_D = 3), 5785 (Jt.FINDER_PAT_E = 4), 5786 (Jt.FINDER_PAT_F = 5), 5787 (Jt.FINDER_PATTERN_SEQUENCES = [ 5788 [Jt.FINDER_PAT_A, Jt.FINDER_PAT_A], 5789 [Jt.FINDER_PAT_A, Jt.FINDER_PAT_B, Jt.FINDER_PAT_B], 5790 [Jt.FINDER_PAT_A, Jt.FINDER_PAT_C, Jt.FINDER_PAT_B, Jt.FINDER_PAT_D], 5791 [Jt.FINDER_PAT_A, Jt.FINDER_PAT_E, Jt.FINDER_PAT_B, Jt.FINDER_PAT_D, Jt.FINDER_PAT_C], 5792 [Jt.FINDER_PAT_A, Jt.FINDER_PAT_E, Jt.FINDER_PAT_B, Jt.FINDER_PAT_D, Jt.FINDER_PAT_D, Jt.FINDER_PAT_F], 5793 [ 5794 Jt.FINDER_PAT_A, 5795 Jt.FINDER_PAT_E, 5796 Jt.FINDER_PAT_B, 5797 Jt.FINDER_PAT_D, 5798 Jt.FINDER_PAT_E, 5799 Jt.FINDER_PAT_F, 5800 Jt.FINDER_PAT_F, 5801 ], 5802 [ 5803 Jt.FINDER_PAT_A, 5804 Jt.FINDER_PAT_A, 5805 Jt.FINDER_PAT_B, 5806 Jt.FINDER_PAT_B, 5807 Jt.FINDER_PAT_C, 5808 Jt.FINDER_PAT_C, 5809 Jt.FINDER_PAT_D, 5810 Jt.FINDER_PAT_D, 5811 ], 5812 [ 5813 Jt.FINDER_PAT_A, 5814 Jt.FINDER_PAT_A, 5815 Jt.FINDER_PAT_B, 5816 Jt.FINDER_PAT_B, 5817 Jt.FINDER_PAT_C, 5818 Jt.FINDER_PAT_C, 5819 Jt.FINDER_PAT_D, 5820 Jt.FINDER_PAT_E, 5821 Jt.FINDER_PAT_E, 5822 ], 5823 [ 5824 Jt.FINDER_PAT_A, 5825 Jt.FINDER_PAT_A, 5826 Jt.FINDER_PAT_B, 5827 Jt.FINDER_PAT_B, 5828 Jt.FINDER_PAT_C, 5829 Jt.FINDER_PAT_C, 5830 Jt.FINDER_PAT_D, 5831 Jt.FINDER_PAT_E, 5832 Jt.FINDER_PAT_F, 5833 Jt.FINDER_PAT_F, 5834 ], 5835 [ 5836 Jt.FINDER_PAT_A, 5837 Jt.FINDER_PAT_A, 5838 Jt.FINDER_PAT_B, 5839 Jt.FINDER_PAT_B, 5840 Jt.FINDER_PAT_C, 5841 Jt.FINDER_PAT_D, 5842 Jt.FINDER_PAT_D, 5843 Jt.FINDER_PAT_E, 5844 Jt.FINDER_PAT_E, 5845 Jt.FINDER_PAT_F, 5846 Jt.FINDER_PAT_F, 5847 ], 5848 ]), 5849 (Jt.MAX_PAIRS = 11);
5850 class $t extends yt { 5851 constructor(t, e, r) { 5852 super(t, e), (this.count = 0), (this.finderPattern = r); 5853 } 5854 getFinderPattern() { 5855 return this.finderPattern; 5856 } 5857 getCount() { 5858 return this.count; 5859 } 5860 incrementCount() { 5861 this.count++; 5862 } 5863 } 5864 class te extends Dt { 5865 constructor() { 5866 super(...arguments), (this.possibleLeftPairs = []), (this.possibleRightPairs = []); 5867 } 5868 decodeRow(t, e, r) { 5869 const n = this.decodePair(e, !1, t, r); 5870 te.addOrTally(this.possibleLeftPairs, n), e.reverse(); 5871 let i = this.decodePair(e, !0, t, r); 5872 te.addOrTally(this.possibleRightPairs, i), e.reverse(); 5873 for (let t of this.possibleLeftPairs) 5874 if (t.getCount() > 1) 5875 for (let e of this.possibleRightPairs) 5876 if (e.getCount() > 1 && te.checkChecksum(t, e)) return te.constructResult(t, e); 5877 throw new R(); 5878 } 5879 static addOrTally(t, e) { 5880 if (null == e) return; 5881 let r = !1; 5882 for (let n of t) 5883 if (n.getValue() === e.getValue()) { 5884 n.incrementCount(), (r = !0); 5885 break; 5886 } 5887 r || t.push(e); 5888 } 5889 reset() { 5890 (this.possibleLeftPairs.length = 0), (this.possibleRightPairs.length = 0); 5891 } 5892 static constructResult(t, e) { 5893 let r = 4537077 * t.getValue() + e.getValue(), 5894 n = new String(r).toString(), 5895 i = new p(); 5896 for (let t = 13 - n.length; t > 0; t--) i.append('0'); 5897 i.append(n); 5898 let s = 0; 5899 for (let t = 0; t < 13; t++) { 5900 let e = i.charAt(t).charCodeAt(0) - '0'.charCodeAt(0); 5901 s += 0 == (1 & t) ? 3 * e : e; 5902 } 5903 (s = 10 - (s % 10)), 10 === s && (s = 0), i.append(s.toString()); 5904 let o = t.getFinderPattern().getResultPoints(), 5905 a = e.getFinderPattern().getResultPoints(); 5906 return new F(i.toString(), null, 0, [o[0], o[1], a[0], a[1]], v.RSS_14, new Date().getTime()); 5907 } 5908 static checkChecksum(t, e) { 5909 let r = (t.getChecksumPortion() + 16 * e.getChecksumPortion()) % 79, 5910 n = 9 * t.getFinderPattern().getValue() + e.getFinderPattern().getValue(); 5911 return n > 72 && n--, n > 8 && n--, r === n; 5912 } 5913 decodePair(t, e, r, n) { 5914 try { 5915 let i = this.findFinderPattern(t, e), 5916 s = this.parseFoundFinderPattern(t, r, e, i), 5917 o = null == n ? null : n.get(C.NEED_RESULT_POINT_CALLBACK); 5918 if (null != o) { 5919 let n = (i[0] + i[1]) / 2; 5920 e && (n = t.getSize() - 1 - n), o.foundPossibleResultPoint(new rt(n, r)); 5921 } 5922 let a = this.decodeDataCharacter(t, s, !0), 5923 l = this.decodeDataCharacter(t, s, !1); 5924 return new $t(1597 * a.getValue() + l.getValue(), a.getChecksumPortion() + 4 * l.getChecksumPortion(), s); 5925 } catch (t) { 5926 return null; 5927 } 5928 } 5929 decodeDataCharacter(t, e, r) { 5930 let n = this.getDataCharacterCounters(); 5931 for (let t = 0; t < n.length; t++) n[t] = 0; 5932 if (r) gt.recordPatternInReverse(t, e.getStartEnd()[0], n); 5933 else { 5934 gt.recordPattern(t, e.getStartEnd()[1] + 1, n); 5935 for (let t = 0, e = n.length - 1; t < e; t++, e--) { 5936 let r = n[t]; 5937 (n[t] = n[e]), (n[e] = r); 5938 } 5939 } 5940 let i = r ? 16 : 15, 5941 s = tt.sum(new Int32Array(n)) / i, 5942 o = this.getOddCounts(), 5943 a = this.getEvenCounts(), 5944 l = this.getOddRoundingErrors(), 5945 h = this.getEvenRoundingErrors(); 5946 for (let t = 0; t < n.length; t++) { 5947 let e = n[t] / s, 5948 r = Math.floor(e + 0.5); 5949 r < 1 ? (r = 1) : r > 8 && (r = 8); 5950 let i = Math.floor(t / 2); 5951 0 == (1 & t) ? ((o[i] = r), (l[i] = e - r)) : ((a[i] = r), (h[i] = e - r)); 5952 } 5953 this.adjustOddEvenCounts(r, i); 5954 let c = 0, 5955 u = 0; 5956 for (let t = o.length - 1; t >= 0; t--) (u *= 9), (u += o[t]), (c += o[t]); 5957 let d = 0, 5958 g = 0; 5959 for (let t = a.length - 1; t >= 0; t--) (d *= 9), (d += a[t]), (g += a[t]); 5960 let f = u + 3 * d; 5961 if (r) { 5962 if (0 != (1 & c) || c > 12 || c < 4) throw new R(); 5963 let t = (12 - c) / 2, 5964 e = te.OUTSIDE_ODD_WIDEST[t], 5965 r = 9 - e, 5966 n = Mt.getRSSvalue(o, e, !1),
5967 i = Mt.getRSSvalue(a, r, !0), 5968 s = te.OUTSIDE_EVEN_TOTAL_SUBSET[t], 5969 l = te.OUTSIDE_GSUM[t]; 5970 return new yt(n * s + i + l, f); 5971 } 5972 { 5973 if (0 != (1 & g) || g > 10 || g < 4) throw new R(); 5974 let t = (10 - g) / 2, 5975 e = te.INSIDE_ODD_WIDEST[t], 5976 r = 9 - e, 5977 n = Mt.getRSSvalue(o, e, !0), 5978 i = Mt.getRSSvalue(a, r, !1), 5979 s = te.INSIDE_ODD_TOTAL_SUBSET[t], 5980 l = te.INSIDE_GSUM[t]; 5981 return new yt(i * s + n + l, f); 5982 } 5983 } 5984 findFinderPattern(t, e) { 5985 let r = this.getDecodeFinderCounters(); 5986 (r[0] = 0), (r[1] = 0), (r[2] = 0), (r[3] = 0); 5987 let n = t.getSize(), 5988 i = !1, 5989 s = 0; 5990 for (; s < n && ((i = !t.get(s)), e !== i); ) s++; 5991 let o = 0, 5992 a = s; 5993 for (let e = s; e < n; e++) 5994 if (t.get(e) !== i) r[o]++; 5995 else { 5996 if (3 === o) { 5997 if (Dt.isFinderPattern(r)) return [a, e]; 5998 (a += r[0] + r[1]), (r[0] = r[2]), (r[1] = r[3]), (r[2] = 0), (r[3] = 0), o--; 5999 } else o++; 6000 (r[o] = 1), (i = !i); 6001 } 6002 throw new R(); 6003 } 6004 parseFoundFinderPattern(t, e, r, n) { 6005 let i = t.get(n[0]), 6006 s = n[0] - 1; 6007 for (; s >= 0 && i !== t.get(s); ) s--; 6008 s++; 6009 const o = n[0] - s, 6010 a = this.getDecodeFinderCounters(), 6011 l = new Int32Array(a.length); 6012 c.arraycopy(a, 0, l, 1, a.length - 1), (l[0] = o); 6013 const h = this.parseFinderValue(l, te.FINDER_PATTERNS); 6014 let u = s, 6015 d = n[1]; 6016 return r && ((u = t.getSize() - 1 - u), (d = t.getSize() - 1 - d)), new Ot(h, [s, n[1]], u, d, e); 6017 } 6018 adjustOddEvenCounts(t, e) { 6019 let r = tt.sum(new Int32Array(this.getOddCounts())), 6020 n = tt.sum(new Int32Array(this.getEvenCounts())), 6021 i = !1, 6022 s = !1, 6023 o = !1, 6024 a = !1; 6025 t 6026 ? (r > 12 ? (s = !0) : r < 4 && (i = !0), n > 12 ? (a = !0) : n < 4 && (o = !0)) 6027 : (r > 11 ? (s = !0) : r < 5 && (i = !0), n > 10 ? (a = !0) : n < 4 && (o = !0)); 6028 let l = r + n - e, 6029 h = (1 & r) == (t ? 1 : 0), 6030 c = 1 == (1 & n); 6031 if (1 === l) 6032 if (h) { 6033 if (c) throw new R(); 6034 s = !0; 6035 } else { 6036 if (!c) throw new R(); 6037 a = !0; 6038 } 6039 else if (-1 === l) 6040 if (h) { 6041 if (c) throw new R(); 6042 i = !0; 6043 } else { 6044 if (!c) throw new R(); 6045 o = !0; 6046 } 6047 else { 6048 if (0 !== l) throw new R(); 6049 if (h) { 6050 if (!c) throw new R(); 6051 r < n ? ((i = !0), (a = !0)) : ((s = !0), (o = !0)); 6052 } else if (c) throw new R(); 6053 } 6054 if (i) { 6055 if (s) throw new R(); 6056 Dt.increment(this.getOddCounts(), this.getOddRoundingErrors()); 6057 } 6058 if ((s && Dt.decrement(this.getOddCounts(), this.getOddRoundingErrors()), o)) { 6059 if (a) throw new R(); 6060 Dt.increment(this.getEvenCounts(), this.getOddRoundingErrors()); 6061 } 6062 a && Dt.decrement(this.getEvenCounts(), this.getEvenRoundingErrors()); 6063 } 6064 } 6065 (te.OUTSIDE_EVEN_TOTAL_SUBSET = [1, 10, 34, 70, 126]), 6066 (te.INSIDE_ODD_TOTAL_SUBSET = [4, 20, 48, 81]), 6067 (te.OUTSIDE_GSUM = [0, 161, 961, 2015, 2715]), 6068 (te.INSIDE_GSUM = [0, 336, 1036, 1516]), 6069 (te.OUTSIDE_ODD_WIDEST = [8, 6, 4, 3, 1]), 6070 (te.INSIDE_ODD_WIDEST = [2, 4, 6, 8]), 6071 (te.FINDER_PATTERNS = [ 6072 Int32Array.from([3, 8, 2, 1]), 6073 Int32Array.from([3, 5, 5, 1]), 6074 Int32Array.from([3, 3, 7, 1]), 6075 Int32Array.from([3, 1, 9, 1]), 6076 Int32Array.from([2, 7, 4, 1]), 6077 Int32Array.from([2, 5, 6, 1]), 6078 Int32Array.from([2, 3, 8, 1]), 6079 Int32Array.from([1, 5, 7, 1]), 6080 Int32Array.from([1, 3, 9, 1]), 6081 ]); 6082 class ee extends gt { 6083 constructor(t) { 6084 super(), (this.readers = []); 6085 const e = t ? t.get(C.POSSIBLE_FORMATS) : null, 6086 r = t && void 0 !== t.get(C.ASSUME_CODE_39_CHECK_DIGIT); 6087 e && 6088 ((e.includes(v.EAN_13) || e.includes(v.UPC_A) || e.includes(v.EAN_8) || e.includes(v.UPC_E)) && 6089 this.readers.push(new Nt(t)), 6090 e.includes(v.CODE_39) && this.readers.push(new wt(r)), 6091 e.includes(v.CODE_128) && this.readers.push(new ft()), 6092 e.includes(v.ITF) && this.readers.push(new At()), 6093 e.includes(v.RSS_14) && this.readers.push(new te()), 6094 e.includes(v.RSS_EXPANDED) && 6095 (console.warn('RSS Expanded reader IS NOT ready for production yet! use at your own risk.'), 6096 this.readers.push(new Jt()))), 6097 0 === this.readers.length && 6098 (this.readers.push(new Nt(t)), 6099 this.readers.push(new wt()), 6100 this.readers.push(new Nt(t)), 6101 this.readers.push(new ft()), 6102 this.readers.push(new At()), 6103 this.readers.push(new te())); 6104 } 6105 decodeRow(t, e, r) { 6106 for (let n = 0; n < this.readers.length; n++) 6107 try { 6108 return this.readers[n].decodeRow(t, e, r); 6109 } catch (t) {} 6110 throw new R(); 6111 } 6112 reset() {
6113 this.readers.forEach((t) => t.reset()); 6114 } 6115 } 6116 class re { 6117 constructor(t, e, r) { 6118 (this.ecCodewords = t), (this.ecBlocks = [e]), r && this.ecBlocks.push(r); 6119 } 6120 getECCodewords() { 6121 return this.ecCodewords; 6122 } 6123 getECBlocks() { 6124 return this.ecBlocks; 6125 } 6126 } 6127 class ne { 6128 constructor(t, e) { 6129 (this.count = t), (this.dataCodewords = e); 6130 } 6131 getCount() { 6132 return this.count; 6133 } 6134 getDataCodewords() { 6135 return this.dataCodewords; 6136 } 6137 } 6138 class ie { 6139 constructor(t, e, r, n, i, s) { 6140 (this.versionNumber = t), 6141 (this.symbolSizeRows = e), 6142 (this.symbolSizeColumns = r), 6143 (this.dataRegionSizeRows = n), 6144 (this.dataRegionSizeColumns = i), 6145 (this.ecBlocks = s); 6146 let o = 0; 6147 const a = s.getECCodewords(), 6148 l = s.getECBlocks(); 6149 for (let t of l) o += t.getCount() * (t.getDataCodewords() + a); 6150 this.totalCodewords = o; 6151 } 6152 getVersionNumber() { 6153 return this.versionNumber; 6154 } 6155 getSymbolSizeRows() { 6156 return this.symbolSizeRows; 6157 } 6158 getSymbolSizeColumns() { 6159 return this.symbolSizeColumns; 6160 } 6161 getDataRegionSizeRows() { 6162 return this.dataRegionSizeRows; 6163 } 6164 getDataRegionSizeColumns() { 6165 return this.dataRegionSizeColumns; 6166 } 6167 getTotalCodewords() { 6168 return this.totalCodewords; 6169 } 6170 getECBlocks() { 6171 return this.ecBlocks; 6172 } 6173 static getVersionForDimensions(t, e) { 6174 if (0 != (1 & t) || 0 != (1 & e)) throw new E(); 6175 for (let r of ie.VERSIONS) if (r.symbolSizeRows === t && r.symbolSizeColumns === e) return r; 6176 throw new E(); 6177 } 6178 toString() { 6179 return '' + this.versionNumber; 6180 } 6181 static buildVersions() { 6182 return [ 6183 new ie(1, 10, 10, 8, 8, new re(5, new ne(1, 3))), 6184 new ie(2, 12, 12, 10, 10, new re(7, new ne(1, 5))), 6185 new ie(3, 14, 14, 12, 12, new re(10, new ne(1, 8))), 6186 new ie(4, 16, 16, 14, 14, new re(12, new ne(1, 12))), 6187 new ie(5, 18, 18, 16, 16, new re(14, new ne(1, 18))), 6188 new ie(6, 20, 20, 18, 18, new re(18, new ne(1, 22))), 6189 new ie(7, 22, 22, 20, 20, new re(20, new ne(1, 30))), 6190 new ie(8, 24, 24, 22, 22, new re(24, new ne(1, 36))), 6191 new ie(9, 26, 26, 24, 24, new re(28, new ne(1, 44))), 6192 new ie(10, 32, 32, 14, 14, new re(36, new ne(1, 62))), 6193 new ie(11, 36, 36, 16, 16, new re(42, new ne(1, 86))), 6194 new ie(12, 40, 40, 18, 18, new re(48, new ne(1, 114))), 6195 new ie(13, 44, 44, 20, 20, new re(56, new ne(1, 144))), 6196 new ie(14, 48, 48, 22, 22, new re(68, new ne(1, 174))), 6197 new ie(15, 52, 52, 24, 24, new re(42, new ne(2, 102))), 6198 new ie(16, 64, 64, 14, 14, new re(56, new ne(2, 140))), 6199 new ie(17, 72, 72, 16, 16, new re(36, new ne(4, 92))), 6200 new ie(18, 80, 80, 18, 18, new re(48, new ne(4, 114))), 6201 new ie(19, 88, 88, 20, 20, new re(56, new ne(4, 144))), 6202 new ie(20, 96, 96, 22, 22, new re(68, new ne(4, 174))), 6203 new ie(21, 104, 104, 24, 24, new re(56, new ne(6, 136))), 6204 new ie(22, 120, 120, 18, 18, new re(68, new ne(6, 175))), 6205 new ie(23, 132, 132, 20, 20, new re(62, new ne(8, 163))), 6206 new ie(24, 144, 144, 22, 22, new re(62, new ne(8, 156), new ne(2, 155))), 6207 new ie(25, 8, 18, 6, 16, new re(7, new ne(1, 5))), 6208 new ie(26, 8, 32, 6, 14, new re(11, new ne(1, 10))), 6209 new ie(27, 12, 26, 10, 24, new re(14, new ne(1, 16))), 6210 new ie(28, 12, 36, 10, 16, new re(18, new ne(1, 22))), 6211 new ie(29, 16, 36, 14, 16, new re(24, new ne(1, 32))), 6212 new ie(30, 16, 48, 14, 22, new re(28, new ne(1, 49))), 6213 ]; 6214 } 6215 } 6216 ie.VERSIONS = ie.buildVersions(); 6217 class se { 6218 constructor(t) { 6219 const e = t.getHeight(); 6220 if (e < 8 || e > 144 || 0 != (1 & e)) throw new E(); 6221 (this.version = se.readVersion(t)), 6222 (this.mappingBitMatrix = this.extractDataRegion(t)), 6223 (this.readMappingMatrix = new T(this.mappingBitMatrix.getWidth(), this.mappingBitMatrix.getHeight())); 6224 } 6225 getVersion() { 6226 return this.version; 6227 } 6228 static readVersion(t) { 6229 const e = t.getHeight(), 6230 r = t.getWidth(); 6231 return ie.getVersionForDimensions(e, r); 6232 } 6233 readCodewords() { 6234 const t = new Int8Array(this.version.getTotalCodewords()); 6235 let e = 0, 6236 r = 4, 6237 n = 0; 6238 const i = this.mappingBitMatrix.getHeight(), 6239 s = this.mappingBitMatrix.getWidth(); 6240 let o = !1, 6241 a = !1, 6242 l = !1, 6243 h = !1; 6244 do { 6245 if (r !== i || 0 !== n || o) 6246 if (r !== i - 2 || 0 !== n || 0 == (3 & s) || a) 6247 if (r !== i + 4 || 2 !== n || 0 != (7 & s) || l) 6248 if (r !== i - 2 || 0 !== n || 4 != (7 & s) || h) { 6249 do { 6250 r < i && n >= 0 && !this.readMappingMatrix.get(n, r) && (t[e++] = 255 & this.readUtah(r, n, i, s)), 6251 (r -= 2), 6252 (n += 2); 6253 } while (r >= 0 && n < s); 6254 (r += 1), (n += 3); 6255 do { 6256 r >= 0 && n < s && !this.readMappingMatrix.get(n, r) && (t[e++] = 255 & this.readUtah(r, n, i, s)), 6257 (r += 2), 6258 (n -= 2); 6259 } while (r < i && n >= 0); 6260 (r += 3), (n += 1); 6261 } else (t[e++] = 255 & this.readCorner4(i, s)), (r -= 2), (n += 2), (h = !0);
6262 else (t[e++] = 255 & this.readCorner3(i, s)), (r -= 2), (n += 2), (l = !0); 6263 else (t[e++] = 255 & this.readCorner2(i, s)), (r -= 2), (n += 2), (a = !0); 6264 else (t[e++] = 255 & this.readCorner1(i, s)), (r -= 2), (n += 2), (o = !0); 6265 } while (r < i || n < s); 6266 if (e !== this.version.getTotalCodewords()) throw new E(); 6267 return t; 6268 } 6269 readModule(t, e, r, n) { 6270 return ( 6271 t < 0 && ((t += r), (e += 4 - ((r + 4) & 7))), 6272 e < 0 && ((e += n), (t += 4 - ((n + 4) & 7))), 6273 this.readMappingMatrix.set(e, t), 6274 this.mappingBitMatrix.get(e, t) 6275 ); 6276 } 6277 readUtah(t, e, r, n) { 6278 let i = 0; 6279 return ( 6280 this.readModule(t - 2, e - 2, r, n) && (i |= 1), 6281 (i <<= 1), 6282 this.readModule(t - 2, e - 1, r, n) && (i |= 1), 6283 (i <<= 1), 6284 this.readModule(t - 1, e - 2, r, n) && (i |= 1), 6285 (i <<= 1), 6286 this.readModule(t - 1, e - 1, r, n) && (i |= 1), 6287 (i <<= 1), 6288 this.readModule(t - 1, e, r, n) && (i |= 1), 6289 (i <<= 1), 6290 this.readModule(t, e - 2, r, n) && (i |= 1), 6291 (i <<= 1), 6292 this.readModule(t, e - 1, r, n) && (i |= 1), 6293 (i <<= 1), 6294 this.readModule(t, e, r, n) && (i |= 1), 6295 i 6296 ); 6297 } 6298 readCorner1(t, e) { 6299 let r = 0; 6300 return ( 6301 this.readModule(t - 1, 0, t, e) && (r |= 1), 6302 (r <<= 1), 6303 this.readModule(t - 1, 1, t, e) && (r |= 1), 6304 (r <<= 1), 6305 this.readModule(t - 1, 2, t, e) && (r |= 1), 6306 (r <<= 1), 6307 this.readModule(0, e - 2, t, e) && (r |= 1), 6308 (r <<= 1), 6309 this.readModule(0, e - 1, t, e) && (r |= 1), 6310 (r <<= 1), 6311 this.readModule(1, e - 1, t, e) && (r |= 1), 6312 (r <<= 1), 6313 this.readModule(2, e - 1, t, e) && (r |= 1), 6314 (r <<= 1), 6315 this.readModule(3, e - 1, t, e) && (r |= 1), 6316 r 6317 ); 6318 } 6319 readCorner2(t, e) { 6320 let r = 0; 6321 return ( 6322 this.readModule(t - 3, 0, t, e) && (r |= 1), 6323 (r <<= 1), 6324 this.readModule(t - 2, 0, t, e) && (r |= 1), 6325 (r <<= 1), 6326 this.readModule(t - 1, 0, t, e) && (r |= 1), 6327 (r <<= 1), 6328 this.readModule(0, e - 4, t, e) && (r |= 1), 6329 (r <<= 1), 6330 this.readModule(0, e - 3, t, e) && (r |= 1), 6331 (r <<= 1), 6332 this.readModule(0, e - 2, t, e) && (r |= 1), 6333 (r <<= 1), 6334 this.readModule(0, e - 1, t, e) && (r |= 1), 6335 (r <<= 1), 6336 this.readModule(1, e - 1, t, e) && (r |= 1), 6337 r 6338 ); 6339 } 6340 readCorner3(t, e) { 6341 let r = 0; 6342 return ( 6343 this.readModule(t - 1, 0, t, e) && (r |= 1), 6344 (r <<= 1), 6345 this.readModule(t - 1, e - 1, t, e) && (r |= 1), 6346 (r <<= 1), 6347 this.readModule(0, e - 3, t, e) && (r |= 1), 6348 (r <<= 1), 6349 this.readModule(0, e - 2, t, e) && (r |= 1), 6350 (r <<= 1), 6351 this.readModule(0, e - 1, t, e) && (r |= 1), 6352 (r <<= 1), 6353 this.readModule(1, e - 3, t, e) && (r |= 1), 6354 (r <<= 1), 6355 this.readModule(1, e - 2, t, e) && (r |= 1), 6356 (r <<= 1), 6357 this.readModule(1, e - 1, t, e) && (r |= 1), 6358 r 6359 ); 6360 } 6361 readCorner4(t, e) { 6362 let r = 0; 6363 return ( 6364 this.readModule(t - 3, 0, t, e) && (r |= 1), 6365 (r <<= 1), 6366 this.readModule(t - 2, 0, t, e) && (r |= 1), 6367 (r <<= 1), 6368 this.readModule(t - 1, 0, t, e) && (r |= 1), 6369 (r <<= 1), 6370 this.readModule(0, e - 2, t, e) && (r |= 1), 6371 (r <<= 1), 6372 this.readModule(0, e - 1, t, e) && (r |= 1), 6373 (r <<= 1), 6374 this.readModule(1, e - 1, t, e) && (r |= 1), 6375 (r <<= 1), 6376 this.readModule(2, e - 1, t, e) && (r |= 1), 6377 (r <<= 1), 6378 this.readModule(3, e - 1, t, e) && (r |= 1), 6379 r 6380 ); 6381 } 6382 extractDataRegion(t) { 6383 const e = this.version.getSymbolSizeRows(), 6384 r = this.version.getSymbolSizeColumns(); 6385 if (t.getHeight() !== e) throw new o('Dimension of bitMatrix must match the version size'); 6386 const n = this.version.getDataRegionSizeRows(), 6387 i = this.version.getDataRegionSizeColumns(), 6388 s = (e / n) | 0, 6389 a = (r / i) | 0, 6390 l = new T(a * i, s * n); 6391 for (let e = 0; e < s; ++e) { 6392 const r = e * n; 6393 for (let s = 0; s < a; ++s) { 6394 const o = s * i; 6395 for (let a = 0; a < n; ++a) { 6396 const h = e * (n + 2) + 1 + a, 6397 c = r + a; 6398 for (let e = 0; e < i; ++e) { 6399 const r = s * (i + 2) + 1 + e; 6400 if (t.get(r, h)) { 6401 const t = o + e; 6402 l.set(t, c); 6403 } 6404 } 6405 } 6406 } 6407 } 6408 return l; 6409 } 6410 } 6411 class oe { 6412 constructor(t, e) { 6413 (this.numDataCodewords = t), (this.codewords = e); 6414 } 6415 static getDataBlocks(t, e) { 6416 const r = e.getECBlocks(); 6417 let n = 0; 6418 const i = r.getECBlocks(); 6419 for (let t of i) n += t.getCount(); 6420 const s = new Array(n);
6421 let a = 0; 6422 for (let t of i) 6423 for (let e = 0; e < t.getCount(); e++) { 6424 const e = t.getDataCodewords(), 6425 n = r.getECCodewords() + e; 6426 s[a++] = new oe(e, new Uint8Array(n)); 6427 } 6428 const l = s[0].codewords.length - r.getECCodewords(), 6429 h = l - 1; 6430 let c = 0; 6431 for (let e = 0; e < h; e++) for (let r = 0; r < a; r++) s[r].codewords[e] = t[c++]; 6432 const u = 24 === e.getVersionNumber(), 6433 d = u ? 8 : a; 6434 for (let e = 0; e < d; e++) s[e].codewords[l - 1] = t[c++]; 6435 const g = s[0].codewords.length; 6436 for (let e = l; e < g; e++) 6437 for (let r = 0; r < a; r++) { 6438 const n = u ? (r + 8) % a : r, 6439 i = u && n > 7 ? e - 1 : e; 6440 s[n].codewords[i] = t[c++]; 6441 } 6442 if (c !== t.length) throw new o(); 6443 return s; 6444 } 6445 getNumDataCodewords() { 6446 return this.numDataCodewords; 6447 } 6448 getCodewords() { 6449 return this.codewords; 6450 } 6451 } 6452 class ae { 6453 constructor(t) { 6454 (this.bytes = t), (this.byteOffset = 0), (this.bitOffset = 0); 6455 } 6456 getBitOffset() { 6457 return this.bitOffset; 6458 } 6459 getByteOffset() { 6460 return this.byteOffset; 6461 } 6462 readBits(t) { 6463 if (t < 1 || t > 32 || t > this.available()) throw new o('' + t); 6464 let e = 0, 6465 r = this.bitOffset, 6466 n = this.byteOffset; 6467 const i = this.bytes; 6468 if (r > 0) { 6469 const s = 8 - r, 6470 o = t < s ? t : s, 6471 a = s - o, 6472 l = (255 >> (8 - o)) << a; 6473 (e = (i[n] & l) >> a), (t -= o), (r += o), 8 === r && ((r = 0), n++); 6474 } 6475 if (t > 0) { 6476 for (; t >= 8; ) (e = (e << 8) | (255 & i[n])), n++, (t -= 8); 6477 if (t > 0) { 6478 const s = 8 - t, 6479 o = (255 >> s) << s; 6480 (e = (e << t) | ((i[n] & o) >> s)), (r += t); 6481 } 6482 } 6483 return (this.bitOffset = r), (this.byteOffset = n), e; 6484 } 6485 available() { 6486 return 8 * (this.bytes.length - this.byteOffset) - this.bitOffset; 6487 } 6488 } 6489 !(function (t) { 6490 (t[(t.PAD_ENCODE = 0)] = 'PAD_ENCODE'), 6491 (t[(t.ASCII_ENCODE = 1)] = 'ASCII_ENCODE'), 6492 (t[(t.C40_ENCODE = 2)] = 'C40_ENCODE'), 6493 (t[(t.TEXT_ENCODE = 3)] = 'TEXT_ENCODE'), 6494 (t[(t.ANSIX12_ENCODE = 4)] = 'ANSIX12_ENCODE'), 6495 (t[(t.EDIFACT_ENCODE = 5)] = 'EDIFACT_ENCODE'), 6496 (t[(t.BASE256_ENCODE = 6)] = 'BASE256_ENCODE'); 6497 })(V || (V = {})); 6498 class le { 6499 static decode(t) { 6500 const e = new ae(t), 6501 r = new p(), 6502 n = new p(), 6503 i = new Array(); 6504 let s = V.ASCII_ENCODE; 6505 do { 6506 if (s === V.ASCII_ENCODE) s = this.decodeAsciiSegment(e, r, n); 6507 else { 6508 switch (s) { 6509 case V.C40_ENCODE: 6510 this.decodeC40Segment(e, r); 6511 break; 6512 case V.TEXT_ENCODE: 6513 this.decodeTextSegment(e, r); 6514 break; 6515 case V.ANSIX12_ENCODE: 6516 this.decodeAnsiX12Segment(e, r); 6517 break; 6518 case V.EDIFACT_ENCODE: 6519 this.decodeEdifactSegment(e, r); 6520 break; 6521 case V.BASE256_ENCODE: 6522 this.decodeBase256Segment(e, r, i); 6523 break; 6524 default: 6525 throw new E(); 6526 } 6527 s = V.ASCII_ENCODE; 6528 } 6529 } while (s !== V.PAD_ENCODE && e.available() > 0); 6530 return n.length() > 0 && r.append(n.toString()), new z(t, r.toString(), 0 === i.length ? null : i, null); 6531 } 6532 static decodeAsciiSegment(t, e, r) { 6533 let n = !1; 6534 do { 6535 let i = t.readBits(8); 6536 if (0 === i) throw new E(); 6537 if (i <= 128) return n && (i += 128), e.append(String.fromCharCode(i - 1)), V.ASCII_ENCODE; 6538 if (129 === i) return V.PAD_ENCODE; 6539 if (i <= 229) { 6540 const t = i - 130; 6541 t < 10 && e.append('0'), e.append('' + t); 6542 } else 6543 switch (i) { 6544 case 230: 6545 return V.C40_ENCODE; 6546 case 231: 6547 return V.BASE256_ENCODE; 6548 case 232: 6549 e.append(String.fromCharCode(29)); 6550 break; 6551 case 233: 6552 case 234: 6553 break; 6554 case 235: 6555 n = !0; 6556 break; 6557 case 236: 6558 e.append('[)>�05�'), r.insert(0, '��'); 6559 break; 6560 case 237: 6561 e.append('[)>�06�'), r.insert(0, '��'); 6562 break; 6563 case 238: 6564 return V.ANSIX12_ENCODE; 6565 case 239: 6566 return V.TEXT_ENCODE; 6567 case 240: 6568 return V.EDIFACT_ENCODE; 6569 case 241: 6570 break; 6571 default: 6572 if (254 !== i || 0 !== t.available()) throw new E(); 6573 } 6574 } while (t.available() > 0); 6575 return V.ASCII_ENCODE; 6576 } 6577 static decodeC40Segment(t, e) { 6578 let r = !1; 6579 const n = []; 6580 let i = 0; 6581 do { 6582 if (8 === t.available()) return; 6583 const s = t.readBits(8); 6584 if (254 === s) return; 6585 this.parseTwoBytes(s, t.readBits(8), n); 6586 for (let t = 0; t < 3; t++) { 6587 const s = n[t]; 6588 switch (i) { 6589 case 0: 6590 if (s < 3) i = s + 1; 6591 else { 6592 if (!(s < this.C40_BASIC_SET_CHARS.length)) throw new E(); 6593 { 6594 const t = this.C40_BASIC_SET_CHARS[s]; 6595 r ? (e.append(String.fromCharCode(t.charCodeAt(0) + 128)), (r = !1)) : e.append(t); 6596 } 6597 } 6598 break; 6599 case 1: 6600 r ? (e.append(String.fromCharCode(s + 128)), (r = !1)) : e.append(String.fromCharCode(s)), (i = 0); 6601 break; 6602 case 2: 6603 if (s < this.C40_SHIFT2_SET_CHARS.length) { 6604 const t = this.C40_SHIFT2_SET_CHARS[s]; 6605 r ? (e.append(String.fromCharCode(t.charCodeAt(0) + 128)), (r = !1)) : e.append(t); 6606 } else 6607 switch (s) { 6608 case 27: 6609 e.append(String.fromCharCode(29)); 6610 break; 6611 case 30: 6612 r = !0; 6613 break; 6614 default: 6615 throw new E(); 6616 } 6617 i = 0; 6618 break; 6619 case 3: 6620 r ? (e.append(String.fromCharCode(s + 224)), (r = !1)) : e.append(String.fromCharCode(s + 96)), (i = 0); 6621 break; 6622 default: 6623 throw new E(); 6624 } 6625 } 6626 } while (t.available() > 0); 6627 } 6628 static decodeTextSegment(t, e) { 6629 let r = !1, 6630 n = [], 6631 i = 0; 6632 do { 6633 if (8 === t.available()) return; 6634 const s = t.readBits(8); 6635 if (254 === s) return; 6636 this.parseTwoBytes(s, t.readBits(8), n); 6637 for (let t = 0; t < 3; t++) { 6638 const s = n[t]; 6639 switch (i) { 6640 case 0: 6641 if (s < 3) i = s + 1; 6642 else { 6643 if (!(s < this.TEXT_BASIC_SET_CHARS.length)) throw new E(); 6644 { 6645 const t = this.TEXT_BASIC_SET_CHARS[s]; 6646 r ? (e.append(String.fromCharCode(t.charCodeAt(0) + 128)), (r = !1)) : e.append(t); 6647 } 6648 } 6649 break; 6650 case 1: 6651 r ? (e.append(String.fromCharCode(s + 128)), (r = !1)) : e.append(String.fromCharCode(s)), (i = 0); 6652 break; 6653 case 2: 6654 if (s < this.TEXT_SHIFT2_SET_CHARS.length) { 6655 const t = this.TEXT_SHIFT2_SET_CHARS[s]; 6656 r ? (e.append(String.fromCharCode(t.charCodeAt(0) + 128)), (r = !1)) : e.append(t); 6657 } else 6658 switch (s) { 6659 case 27: 6660 e.append(String.fromCharCode(29)); 6661 break; 6662 case 30: 6663 r = !0; 6664 break; 6665 default: 6666 throw new E(); 6667 } 6668 i = 0; 6669 break; 6670 case 3: 6671 if (!(s < this.TEXT_SHIFT3_SET_CHARS.length)) throw new E(); 6672 { 6673 const t = this.TEXT_SHIFT3_SET_CHARS[s]; 6674 r ? (e.append(String.fromCharCode(t.charCodeAt(0) + 128)), (r = !1)) : e.append(t), (i = 0); 6675 } 6676 break; 6677 default: 6678 throw new E(); 6679 } 6680 } 6681 } while (t.available() > 0); 6682 } 6683 static decodeAnsiX12Segment(t, e) { 6684 const r = []; 6685 do { 6686 if (8 === t.available()) return; 6687 const n = t.readBits(8); 6688 if (254 === n) return; 6689 this.parseTwoBytes(n, t.readBits(8), r); 6690 for (let t = 0; t < 3; t++) { 6691 const n = r[t]; 6692 switch (n) { 6693 case 0: 6694 e.append('\r'); 6695 break; 6696 case 1: 6697 e.append('*'); 6698 break; 6699 case 2: 6700 e.append('>'); 6701 break; 6702 case 3: 6703 e.append(' '); 6704 break; 6705 default: 6706 if (n < 14) e.append(String.fromCharCode(n + 44));
6707 else { 6708 if (!(n < 40)) throw new E(); 6709 e.append(String.fromCharCode(n + 51)); 6710 } 6711 } 6712 } 6713 } while (t.available() > 0); 6714 } 6715 static parseTwoBytes(t, e, r) { 6716 let n = (t << 8) + e - 1, 6717 i = Math.floor(n / 1600); 6718 (r[0] = i), (n -= 1600 * i), (i = Math.floor(n / 40)), (r[1] = i), (r[2] = n - 40 * i); 6719 } 6720 static decodeEdifactSegment(t, e) { 6721 do { 6722 if (t.available() <= 16) return; 6723 for (let r = 0; r < 4; r++) { 6724 let r = t.readBits(6); 6725 if (31 === r) { 6726 const e = 8 - t.getBitOffset(); 6727 return void (8 !== e && t.readBits(e)); 6728 } 6729 0 == (32 & r) && (r |= 64), e.append(String.fromCharCode(r)); 6730 } 6731 } while (t.available() > 0); 6732 } 6733 static decodeBase256Segment(t, e, r) { 6734 let n = 1 + t.getByteOffset(); 6735 const i = this.unrandomize255State(t.readBits(8), n++); 6736 let s; 6737 if ( 6738 ((s = 6739 0 === i 6740 ? (t.available() / 8) | 0 6741 : i < 250 6742 ? i 6743 : 250 * (i - 249) + this.unrandomize255State(t.readBits(8), n++)), 6744 s < 0) 6745 ) 6746 throw new E(); 6747 const o = new Uint8Array(s); 6748 for (let e = 0; e < s; e++) { 6749 if (t.available() < 8) throw new E(); 6750 o[e] = this.unrandomize255State(t.readBits(8), n++); 6751 } 6752 r.push(o); 6753 try { 6754 e.append(I.decode(o, S.ISO88591)); 6755 } catch (t) { 6756 throw new j('Platform does not support required encoding: ' + t.message); 6757 } 6758 } 6759 static unrandomize255State(t, e) { 6760 const r = t - (((149 * e) % 255) + 1); 6761 return r >= 0 ? r : r + 256; 6762 } 6763 } 6764 (le.C40_BASIC_SET_CHARS = [ 6765 '*', 6766 '*', 6767 '*', 6768 ' ', 6769 '0', 6770 '1', 6771 '2', 6772 '3', 6773 '4', 6774 '5', 6775 '6', 6776 '7', 6777 '8', 6778 '9', 6779 'A', 6780 'B', 6781 'C', 6782 'D', 6783 'E', 6784 'F', 6785 'G', 6786 'H', 6787 'I', 6788 'J', 6789 'K', 6790 'L', 6791 'M', 6792 'N', 6793 'O', 6794 'P', 6795 'Q', 6796 'R', 6797 'S', 6798 'T', 6799 'U', 6800 'V', 6801 'W', 6802 'X', 6803 'Y', 6804 'Z', 6805 ]), 6806 (le.C40_SHIFT2_SET_CHARS = [ 6807 '!', 6808 '"', 6809 '#', 6810 '$', 6811 '%', 6812 '&', 6813 "'", 6814 '(', 6815 ')', 6816 '*', 6817 '+', 6818 ',', 6819 '-', 6820 '.', 6821 '/', 6822 ':', 6823 ';', 6824 '<', 6825 '=', 6826 '>', 6827 '?', 6828 '@', 6829 '[', 6830 '\\', 6831 ']', 6832 '^', 6833 '_', 6834 ]), 6835 (le.TEXT_BASIC_SET_CHARS = [ 6836 '*', 6837 '*', 6838 '*', 6839 ' ', 6840 '0', 6841 '1', 6842 '2', 6843 '3', 6844 '4', 6845 '5', 6846 '6', 6847 '7', 6848 '8', 6849 '9', 6850 'a', 6851 'b', 6852 'c', 6853 'd', 6854 'e', 6855 'f', 6856 'g', 6857 'h', 6858 'i', 6859 'j', 6860 'k', 6861 'l', 6862 'm', 6863 'n', 6864 'o', 6865 'p', 6866 'q', 6867 'r', 6868 's', 6869 't', 6870 'u', 6871 'v', 6872 'w', 6873 'x', 6874 'y', 6875 'z', 6876 ]), 6877 (le.TEXT_SHIFT2_SET_CHARS = le.C40_SHIFT2_SET_CHARS), 6878 (le.TEXT_SHIFT3_SET_CHARS = [ 6879 '`', 6880 'A', 6881 'B', 6882 'C', 6883 'D', 6884 'E', 6885 'F', 6886 'G', 6887 'H', 6888 'I', 6889 'J', 6890 'K', 6891 'L', 6892 'M', 6893 'N', 6894 'O', 6895 'P', 6896 'Q', 6897 'R', 6898 'S', 6899 'T', 6900 'U', 6901 'V', 6902 'W', 6903 'X', 6904 'Y', 6905 'Z', 6906 '{', 6907 '|', 6908 '}', 6909 '~', 6910 String.fromCharCode(127), 6911 ]); 6912 class he { 6913 constructor() { 6914 this.rsDecoder = new J(q.DATA_MATRIX_FIELD_256); 6915 } 6916 decode(t) { 6917 const e = new se(t), 6918 r = e.getVersion(), 6919 n = e.readCodewords(), 6920 i = oe.getDataBlocks(n, r); 6921 let s = 0; 6922 for (let t of i) s += t.getNumDataCodewords(); 6923 const o = new Uint8Array(s), 6924 a = i.length; 6925 for (let t = 0; t < a; t++) { 6926 const e = i[t], 6927 r = e.getCodewords(), 6928 n = e.getNumDataCodewords(); 6929 this.correctErrors(r, n); 6930 for (let e = 0; e < n; e++) o[e * a + t] = r[e]; 6931 } 6932 return le.decode(o); 6933 } 6934 correctErrors(t, e) { 6935 const r = new Int32Array(t);
6936 try { 6937 this.rsDecoder.decode(r, t.length - e); 6938 } catch (t) { 6939 throw new l(); 6940 } 6941 for (let n = 0; n < e; n++) t[n] = r[n]; 6942 } 6943 } 6944 class ce { 6945 constructor(t) { 6946 (this.image = t), (this.rectangleDetector = new st(this.image)); 6947 } 6948 detect() { 6949 const t = this.rectangleDetector.detect(); 6950 let e = this.detectSolid1(t); 6951 if (((e = this.detectSolid2(e)), (e[3] = this.correctTopRight(e)), !e[3])) throw new R(); 6952 e = this.shiftToModuleCenter(e); 6953 const r = e[0], 6954 n = e[1], 6955 i = e[2], 6956 s = e[3]; 6957 let o = this.transitionsBetween(r, s) + 1, 6958 a = this.transitionsBetween(i, s) + 1; 6959 1 == (1 & o) && (o += 1), 1 == (1 & a) && (a += 1), 4 * o < 7 * a && 4 * a < 7 * o && (o = a = Math.max(o, a)); 6960 let l = ce.sampleGrid(this.image, r, n, i, s, o, a); 6961 return new nt(l, [r, n, i, s]); 6962 } 6963 static shiftPoint(t, e, r) { 6964 let n = (e.getX() - t.getX()) / (r + 1), 6965 i = (e.getY() - t.getY()) / (r + 1); 6966 return new rt(t.getX() + n, t.getY() + i); 6967 } 6968 static moveAway(t, e, r) { 6969 let n = t.getX(), 6970 i = t.getY(); 6971 return n < e ? (n -= 1) : (n += 1), i < r ? (i -= 1) : (i += 1), new rt(n, i); 6972 } 6973 detectSolid1(t) { 6974 let e = t[0], 6975 r = t[1], 6976 n = t[3], 6977 i = t[2], 6978 s = this.transitionsBetween(e, r), 6979 o = this.transitionsBetween(r, n), 6980 a = this.transitionsBetween(n, i), 6981 l = this.transitionsBetween(i, e), 6982 h = s, 6983 c = [i, e, r, n]; 6984 return ( 6985 h > o && ((h = o), (c[0] = e), (c[1] = r), (c[2] = n), (c[3] = i)), 6986 h > a && ((h = a), (c[0] = r), (c[1] = n), (c[2] = i), (c[3] = e)), 6987 h > l && ((c[0] = n), (c[1] = i), (c[2] = e), (c[3] = r)), 6988 c 6989 ); 6990 } 6991 detectSolid2(t) { 6992 let e = t[0], 6993 r = t[1], 6994 n = t[2], 6995 i = t[3], 6996 s = this.transitionsBetween(e, i), 6997 o = ce.shiftPoint(r, n, 4 * (s + 1)), 6998 a = ce.shiftPoint(n, r, 4 * (s + 1)); 6999 return ( 7000 this.transitionsBetween(o, e) < this.transitionsBetween(a, i) 7001 ? ((t[0] = e), (t[1] = r), (t[2] = n), (t[3] = i)) 7002 : ((t[0] = r), (t[1] = n), (t[2] = i), (t[3] = e)), 7003 t 7004 ); 7005 } 7006 correctTopRight(t) { 7007 let e = t[0], 7008 r = t[1], 7009 n = t[2], 7010 i = t[3], 7011 s = this.transitionsBetween(e, i), 7012 o = this.transitionsBetween(r, i), 7013 a = ce.shiftPoint(e, r, 4 * (o + 1)), 7014 l = ce.shiftPoint(n, r, 4 * (s + 1)); 7015 (s = this.transitionsBetween(a, i)), (o = this.transitionsBetween(l, i)); 7016 let h = new rt(i.getX() + (n.getX() - r.getX()) / (s + 1), i.getY() + (n.getY() - r.getY()) / (s + 1)), 7017 c = new rt(i.getX() + (e.getX() - r.getX()) / (o + 1), i.getY() + (e.getY() - r.getY()) / (o + 1)); 7018 return this.isValid(h) 7019 ? this.isValid(c) 7020 ? this.transitionsBetween(a, h) + this.transitionsBetween(l, h) > 7021 this.transitionsBetween(a, c) + this.transitionsBetween(l, c) 7022 ? h 7023 : c 7024 : h 7025 : this.isValid(c) 7026 ? c 7027 : null; 7028 } 7029 shiftToModuleCenter(t) { 7030 let e = t[0], 7031 r = t[1], 7032 n = t[2], 7033 i = t[3], 7034 s = this.transitionsBetween(e, i) + 1, 7035 o = this.transitionsBetween(n, i) + 1, 7036 a = ce.shiftPoint(e, r, 4 * o), 7037 l = ce.shiftPoint(n, r, 4 * s); 7038 (s = this.transitionsBetween(a, i) + 1), 7039 (o = this.transitionsBetween(l, i) + 1), 7040 1 == (1 & s) && (s += 1), 7041 1 == (1 & o) && (o += 1); 7042 let h, 7043 c, 7044 u = (e.getX() + r.getX() + n.getX() + i.getX()) / 4, 7045 d = (e.getY() + r.getY() + n.getY() + i.getY()) / 4; 7046 return ( 7047 (e = ce.moveAway(e, u, d)), 7048 (r = ce.moveAway(r, u, d)), 7049 (n = ce.moveAway(n, u, d)), 7050 (i = ce.moveAway(i, u, d)), 7051 (a = ce.shiftPoint(e, r, 4 * o)), 7052 (a = ce.shiftPoint(a, i, 4 * s)), 7053 (h = ce.shiftPoint(r, e, 4 * o)), 7054 (h = ce.shiftPoint(h, n, 4 * s)), 7055 (l = ce.shiftPoint(n, i, 4 * o)), 7056 (l = ce.shiftPoint(l, r, 4 * s)), 7057 (c = ce.shiftPoint(i, n, 4 * o)), 7058 (c = ce.shiftPoint(c, e, 4 * s)), 7059 [a, h, l, c] 7060 ); 7061 } 7062 isValid(t) { 7063 return t.getX() >= 0 && t.getX() < this.image.getWidth() && t.getY() > 0 && t.getY() < this.image.getHeight(); 7064 } 7065 static sampleGrid(t, e, r, n, i, s, o) { 7066 return ht 7067 .getInstance() 7068 .sampleGrid( 7069 t, 7070 s, 7071 o, 7072 0.5, 7073 0.5, 7074 s - 0.5, 7075 0.5, 7076 s - 0.5, 7077 o - 0.5, 7078 0.5, 7079 o - 0.5, 7080 e.getX(), 7081 e.getY(), 7082 i.getX(), 7083 i.getY(), 7084 n.getX(), 7085 n.getY(), 7086 r.getX(), 7087 r.getY(), 7088 ); 7089 } 7090 transitionsBetween(t, e) { 7091 let r = Math.trunc(t.getX()), 7092 n = Math.trunc(t.getY()), 7093 i = Math.trunc(e.getX()), 7094 s = Math.trunc(e.getY()), 7095 o = Math.abs(s - n) > Math.abs(i - r); 7096 if (o) { 7097 let t = r; 7098 (r = n), (n = t), (t = i), (i = s), (s = t); 7099 } 7100 let a = Math.abs(i - r), 7101 l = Math.abs(s - n), 7102 h = -a / 2, 7103 c = n < s ? 1 : -1, 7104 u = r < i ? 1 : -1, 7105 d = 0, 7106 g = this.image.get(o ? n : r, o ? r : n); 7107 for (let t = r, e = n; t !== i; t += u) { 7108 let r = this.image.get(o ? e : t, o ? t : e); 7109 if ((r !== g && (d++, (g = r)), (h += l), h > 0)) { 7110 if (e === s) break; 7111 (e += c), (h -= a); 7112 } 7113 } 7114 return d; 7115 } 7116 } 7117 class ue { 7118 constructor() { 7119 this.decoder = new he(); 7120 } 7121 decode(t, e = null) { 7122 let r, n; 7123 if (null != e && e.has(C.PURE_BARCODE)) { 7124 const e = ue.extractPureBits(t.getBlackMatrix()); 7125 (r = this.decoder.decode(e)), (n = ue.NO_POINTS); 7126 } else { 7127 const e = new ce(t.getBlackMatrix()).detect(); 7128 (r = this.decoder.decode(e.getBits())), (n = e.getPoints()); 7129 } 7130 const i = r.getRawBytes(), 7131 s = new F(r.getText(), i, 8 * i.length, n, v.DATA_MATRIX, c.currentTimeMillis()), 7132 o = r.getByteSegments(); 7133 null != o && s.putMetadata(W.BYTE_SEGMENTS, o); 7134 const a = r.getECLevel(); 7135 return null != a && s.putMetadata(W.ERROR_CORRECTION_LEVEL, a), s; 7136 } 7137 reset() {} 7138 static extractPureBits(t) { 7139 const e = t.getTopLeftOnBit(), 7140 r = t.getBottomRightOnBit(); 7141 if (null == e || null == r) throw new R(); 7142 const n = this.moduleSize(e, t); 7143 let i = e[1]; 7144 const s = r[1]; 7145 let o = e[0];
7146 const a = (r[0] - o + 1) / n, 7147 l = (s - i + 1) / n; 7148 if (a <= 0 || l <= 0) throw new R(); 7149 const h = n / 2; 7150 (i += h), (o += h); 7151 const c = new T(a, l); 7152 for (let e = 0; e < l; e++) { 7153 const r = i + e * n; 7154 for (let i = 0; i < a; i++) t.get(o + i * n, r) && c.set(i, e); 7155 } 7156 return c; 7157 } 7158 static moduleSize(t, e) { 7159 const r = e.getWidth(); 7160 let n = t[0]; 7161 const i = t[1]; 7162 for (; n < r && e.get(n, i); ) n++; 7163 if (n === r) throw new R(); 7164 const s = n - t[0]; 7165 if (0 === s) throw new R(); 7166 return s; 7167 } 7168 } 7169 ue.NO_POINTS = []; 7170 !(function (t) { 7171 (t[(t.L = 0)] = 'L'), (t[(t.M = 1)] = 'M'), (t[(t.Q = 2)] = 'Q'), (t[(t.H = 3)] = 'H'); 7172 })(U || (U = {})); 7173 class de { 7174 constructor(t, e, r) { 7175 (this.value = t), (this.stringValue = e), (this.bits = r), de.FOR_BITS.set(r, this), de.FOR_VALUE.set(t, this); 7176 } 7177 getValue() { 7178 return this.value; 7179 } 7180 getBits() { 7181 return this.bits; 7182 } 7183 static fromString(t) { 7184 switch (t) { 7185 case 'L': 7186 return de.L; 7187 case 'M': 7188 return de.M; 7189 case 'Q': 7190 return de.Q; 7191 case 'H': 7192 return de.H; 7193 default: 7194 throw new s(t + 'not available'); 7195 } 7196 } 7197 toString() { 7198 return this.stringValue; 7199 } 7200 equals(t) { 7201 if (!(t instanceof de)) return !1; 7202 const e = t; 7203 return this.value === e.value; 7204 } 7205 static forBits(t) { 7206 if (t < 0 || t >= de.FOR_BITS.size) throw new o(); 7207 return de.FOR_BITS.get(t); 7208 } 7209 } 7210 (de.FOR_BITS = new Map()), 7211 (de.FOR_VALUE = new Map()), 7212 (de.L = new de(U.L, 'L', 1)), 7213 (de.M = new de(U.M, 'M', 0)), 7214 (de.Q = new de(U.Q, 'Q', 3)), 7215 (de.H = new de(U.H, 'H', 2)); 7216 class ge { 7217 constructor(t) { 7218 (this.errorCorrectionLevel = de.forBits((t >> 3) & 3)), (this.dataMask = 7 & t); 7219 } 7220 static numBitsDiffering(t, e) { 7221 return f.bitCount(t ^ e); 7222 } 7223 static decodeFormatInformation(t, e) { 7224 const r = ge.doDecodeFormatInformation(t, e); 7225 return null !== r ? r : ge.doDecodeFormatInformation(t ^ ge.FORMAT_INFO_MASK_QR, e ^ ge.FORMAT_INFO_MASK_QR); 7226 } 7227 static doDecodeFormatInformation(t, e) { 7228 let r = Number.MAX_SAFE_INTEGER, 7229 n = 0; 7230 for (const i of ge.FORMAT_INFO_DECODE_LOOKUP) { 7231 const s = i[0]; 7232 if (s === t || s === e) return new ge(i[1]); 7233 let o = ge.numBitsDiffering(t, s); 7234 o < r && ((n = i[1]), (r = o)), t !== e && ((o = ge.numBitsDiffering(e, s)), o < r && ((n = i[1]), (r = o))); 7235 } 7236 return r <= 3 ? new ge(n) : null; 7237 } 7238 getErrorCorrectionLevel() { 7239 return this.errorCorrectionLevel; 7240 } 7241 getDataMask() { 7242 return this.dataMask; 7243 } 7244 hashCode() { 7245 return (this.errorCorrectionLevel.getBits() << 3) | this.dataMask; 7246 } 7247 equals(t) { 7248 if (!(t instanceof ge)) return !1; 7249 const e = t; 7250 return this.errorCorrectionLevel === e.errorCorrectionLevel && this.dataMask === e.dataMask; 7251 } 7252 } 7253 (ge.FORMAT_INFO_MASK_QR = 21522), 7254 (ge.FORMAT_INFO_DECODE_LOOKUP = [ 7255 Int32Array.from([21522, 0]), 7256 Int32Array.from([20773, 1]), 7257 Int32Array.from([24188, 2]), 7258 Int32Array.from([23371, 3]), 7259 Int32Array.from([17913, 4]), 7260 Int32Array.from([16590, 5]), 7261 Int32Array.from([20375, 6]), 7262 Int32Array.from([19104, 7]), 7263 Int32Array.from([30660, 8]), 7264 Int32Array.from([29427, 9]), 7265 Int32Array.from([32170, 10]), 7266 Int32Array.from([30877, 11]), 7267 Int32Array.from([26159, 12]), 7268 Int32Array.from([25368, 13]), 7269 Int32Array.from([27713, 14]), 7270 Int32Array.from([26998, 15]), 7271 Int32Array.from([5769, 16]), 7272 Int32Array.from([5054, 17]), 7273 Int32Array.from([7399, 18]), 7274 Int32Array.from([6608, 19]), 7275 Int32Array.from([1890, 20]), 7276 Int32Array.from([597, 21]), 7277 Int32Array.from([3340, 22]), 7278 Int32Array.from([2107, 23]), 7279 Int32Array.from([13663, 24]), 7280 Int32Array.from([12392, 25]), 7281 Int32Array.from([16177, 26]), 7282 Int32Array.from([14854, 27]), 7283 Int32Array.from([9396, 28]), 7284 Int32Array.from([8579, 29]), 7285 Int32Array.from([11994, 30]), 7286 Int32Array.from([11245, 31]), 7287 ]); 7288 class fe { 7289 constructor(t, ...e) { 7290 (this.ecCodewordsPerBlock = t), (this.ecBlocks = e); 7291 } 7292 getECCodewordsPerBlock() { 7293 return this.ecCodewordsPerBlock; 7294 } 7295 getNumBlocks() { 7296 let t = 0; 7297 const e = this.ecBlocks; 7298 for (const r of e) t += r.getCount(); 7299 return t; 7300 } 7301 getTotalECCodewords() { 7302 return this.ecCodewordsPerBlock * this.getNumBlocks(); 7303 } 7304 getECBlocks() { 7305 return this.ecBlocks; 7306 } 7307 } 7308 class we { 7309 constructor(t, e) { 7310 (this.count = t), (this.dataCodewords = e); 7311 } 7312 getCount() { 7313 return this.count; 7314 } 7315 getDataCodewords() { 7316 return this.dataCodewords; 7317 } 7318 } 7319 class Ae { 7320 constructor(t, e, ...r) { 7321 (this.versionNumber = t), (this.alignmentPatternCenters = e), (this.ecBlocks = r); 7322 let n = 0; 7323 const i = r[0].getECCodewordsPerBlock(), 7324 s = r[0].getECBlocks(); 7325 for (const t of s) n += t.getCount() * (t.getDataCodewords() + i); 7326 this.totalCodewords = n; 7327 } 7328 getVersionNumber() { 7329 return this.versionNumber; 7330 } 7331 getAlignmentPatternCenters() { 7332 return this.alignmentPatternCenters; 7333 } 7334 getTotalCodewords() { 7335 return this.totalCodewords; 7336 } 7337 getDimensionForVersion() { 7338 return 17 + 4 * this.versionNumber; 7339 } 7340 getECBlocksForLevel(t) { 7341 return this.ecBlocks[t.getValue()]; 7342 } 7343 static getProvisionalVersionForDimension(t) { 7344 if (t % 4 != 1) throw new E();
7345 try { 7346 return this.getVersionForNumber((t - 17) / 4); 7347 } catch (t) { 7348 throw new E(); 7349 } 7350 } 7351 static getVersionForNumber(t) { 7352 if (t < 1 || t > 40) throw new o(); 7353 return Ae.VERSIONS[t - 1]; 7354 } 7355 static decodeVersionInformation(t) { 7356 let e = Number.MAX_SAFE_INTEGER, 7357 r = 0; 7358 for (let n = 0; n < Ae.VERSION_DECODE_INFO.length; n++) { 7359 const i = Ae.VERSION_DECODE_INFO[n]; 7360 if (i === t) return Ae.getVersionForNumber(n + 7); 7361 const s = ge.numBitsDiffering(t, i); 7362 s < e && ((r = n + 7), (e = s)); 7363 } 7364 return e <= 3 ? Ae.getVersionForNumber(r) : null; 7365 } 7366 buildFunctionPattern() { 7367 const t = this.getDimensionForVersion(), 7368 e = new T(t); 7369 e.setRegion(0, 0, 9, 9), e.setRegion(t - 8, 0, 8, 9), e.setRegion(0, t - 8, 9, 8); 7370 const r = this.alignmentPatternCenters.length; 7371 for (let t = 0; t < r; t++) { 7372 const n = this.alignmentPatternCenters[t] - 2; 7373 for (let i = 0; i < r; i++) 7374 (0 === t && (0 === i || i === r - 1)) || 7375 (t === r - 1 && 0 === i) || 7376 e.setRegion(this.alignmentPatternCenters[i] - 2, n, 5, 5); 7377 } 7378 return ( 7379 e.setRegion(6, 9, 1, t - 17), 7380 e.setRegion(9, 6, t - 17, 1), 7381 this.versionNumber > 6 && (e.setRegion(t - 11, 0, 3, 6), e.setRegion(0, t - 11, 6, 3)), 7382 e 7383 ); 7384 } 7385 toString() { 7386 return '' + this.versionNumber; 7387 } 7388 } 7389 (Ae.VERSION_DECODE_INFO = Int32Array.from([ 7390 31892, 34236, 39577, 42195, 48118, 51042, 55367, 58893, 63784, 68472, 70749, 76311, 79154, 84390, 87683, 92361, 7391 96236, 102084, 102881, 110507, 110734, 117786, 119615, 126325, 127568, 133589, 136944, 141498, 145311, 150283, 7392 152622, 158308, 161089, 167017, 7393 ])), 7394 (Ae.VERSIONS = [ 7395 new Ae( 7396 1, 7397 new Int32Array(0), 7398 new fe(7, new we(1, 19)), 7399 new fe(10, new we(1, 16)), 7400 new fe(13, new we(1, 13)), 7401 new fe(17, new we(1, 9)), 7402 ), 7403 new Ae( 7404 2, 7405 Int32Array.from([6, 18]), 7406 new fe(10, new we(1, 34)), 7407 new fe(16, new we(1, 28)), 7408 new fe(22, new we(1, 22)), 7409 new fe(28, new we(1, 16)), 7410 ), 7411 new Ae( 7412 3, 7413 Int32Array.from([6, 22]), 7414 new fe(15, new we(1, 55)), 7415 new fe(26, new we(1, 44)), 7416 new fe(18, new we(2, 17)), 7417 new fe(22, new we(2, 13)), 7418 ), 7419 new Ae( 7420 4, 7421 Int32Array.from([6, 26]), 7422 new fe(20, new we(1, 80)), 7423 new fe(18, new we(2, 32)), 7424 new fe(26, new we(2, 24)), 7425 new fe(16, new we(4, 9)), 7426 ), 7427 new Ae( 7428 5, 7429 Int32Array.from([6, 30]), 7430 new fe(26, new we(1, 108)), 7431 new fe(24, new we(2, 43)), 7432 new fe(18, new we(2, 15), new we(2, 16)), 7433 new fe(22, new we(2, 11), new we(2, 12)), 7434 ), 7435 new Ae( 7436 6, 7437 Int32Array.from([6, 34]), 7438 new fe(18, new we(2, 68)), 7439 new fe(16, new we(4, 27)), 7440 new fe(24, new we(4, 19)), 7441 new fe(28, new we(4, 15)), 7442 ), 7443 new Ae( 7444 7, 7445 Int32Array.from([6, 22, 38]), 7446 new fe(20, new we(2, 78)), 7447 new fe(18, new we(4, 31)), 7448 new fe(18, new we(2, 14), new we(4, 15)), 7449 new fe(26, new we(4, 13), new we(1, 14)), 7450 ), 7451 new Ae( 7452 8, 7453 Int32Array.from([6, 24, 42]), 7454 new fe(24, new we(2, 97)), 7455 new fe(22, new we(2, 38), new we(2, 39)), 7456 new fe(22, new we(4, 18), new we(2, 19)), 7457 new fe(26, new we(4, 14), new we(2, 15)), 7458 ), 7459 new Ae( 7460 9, 7461 Int32Array.from([6, 26, 46]), 7462 new fe(30, new we(2, 116)), 7463 new fe(22, new we(3, 36), new we(2, 37)), 7464 new fe(20, new we(4, 16), new we(4, 17)), 7465 new fe(24, new we(4, 12), new we(4, 13)), 7466 ), 7467 new Ae( 7468 10, 7469 Int32Array.from([6, 28, 50]), 7470 new fe(18, new we(2, 68), new we(2, 69)), 7471 new fe(26, new we(4, 43), new we(1, 44)), 7472 new fe(24, new we(6, 19), new we(2, 20)), 7473 new fe(28, new we(6, 15), new we(2, 16)), 7474 ), 7475 new Ae( 7476 11, 7477 Int32Array.from([6, 30, 54]), 7478 new fe(20, new we(4, 81)), 7479 new fe(30, new we(1, 50), new we(4, 51)), 7480 new fe(28, new we(4, 22), new we(4, 23)), 7481 new fe(24, new we(3, 12), new we(8, 13)), 7482 ), 7483 new Ae( 7484 12, 7485 Int32Array.from([6, 32, 58]), 7486 new fe(24, new we(2, 92), new we(2, 93)), 7487 new fe(22, new we(6, 36), new we(2, 37)), 7488 new fe(26, new we(4, 20), new we(6, 21)), 7489 new fe(28, new we(7, 14), new we(4, 15)), 7490 ), 7491 new Ae( 7492 13, 7493 Int32Array.from([6, 34, 62]), 7494 new fe(26, new we(4, 107)), 7495 new fe(22, new we(8, 37), new we(1, 38)), 7496 new fe(24, new we(8, 20), new we(4, 21)), 7497 new fe(22, new we(12, 11), new we(4, 12)), 7498 ), 7499 new Ae( 7500 14, 7501 Int32Array.from([6, 26, 46, 66]), 7502 new fe(30, new we(3, 115), new we(1, 116)), 7503 new fe(24, new we(4, 40), new we(5, 41)), 7504 new fe(20, new we(11, 16), new we(5, 17)), 7505 new fe(24, new we(11, 12), new we(5, 13)), 7506 ), 7507 new Ae( 7508 15, 7509 Int32Array.from([6, 26, 48, 70]), 7510 new fe(22, new we(5, 87), new we(1, 88)), 7511 new fe(24, new we(5, 41), new we(5, 42)), 7512 new fe(30, new we(5, 24), new we(7, 25)), 7513 new fe(24, new we(11, 12), new we(7, 13)), 7514 ), 7515 new Ae( 7516 16, 7517 Int32Array.from([6, 26, 50, 74]), 7518 new fe(24, new we(5, 98), new we(1, 99)), 7519 new fe(28, new we(7, 45), new we(3, 46)), 7520 new fe(24, new we(15, 19), new we(2, 20)), 7521 new fe(30, new we(3, 15), new we(13, 16)), 7522 ), 7523 new Ae( 7524 17, 7525 Int32Array.from([6, 30, 54, 78]),
7526 new fe(28, new we(1, 107), new we(5, 108)), 7527 new fe(28, new we(10, 46), new we(1, 47)), 7528 new fe(28, new we(1, 22), new we(15, 23)), 7529 new fe(28, new we(2, 14), new we(17, 15)), 7530 ), 7531 new Ae( 7532 18, 7533 Int32Array.from([6, 30, 56, 82]), 7534 new fe(30, new we(5, 120), new we(1, 121)), 7535 new fe(26, new we(9, 43), new we(4, 44)), 7536 new fe(28, new we(17, 22), new we(1, 23)), 7537 new fe(28, new we(2, 14), new we(19, 15)), 7538 ), 7539 new Ae( 7540 19, 7541 Int32Array.from([6, 30, 58, 86]), 7542 new fe(28, new we(3, 113), new we(4, 114)), 7543 new fe(26, new we(3, 44), new we(11, 45)), 7544 new fe(26, new we(17, 21), new we(4, 22)), 7545 new fe(26, new we(9, 13), new we(16, 14)), 7546 ), 7547 new Ae( 7548 20, 7549 Int32Array.from([6, 34, 62, 90]), 7550 new fe(28, new we(3, 107), new we(5, 108)), 7551 new fe(26, new we(3, 41), new we(13, 42)), 7552 new fe(30, new we(15, 24), new we(5, 25)), 7553 new fe(28, new we(15, 15), new we(10, 16)), 7554 ), 7555 new Ae( 7556 21, 7557 Int32Array.from([6, 28, 50, 72, 94]), 7558 new fe(28, new we(4, 116), new we(4, 117)), 7559 new fe(26, new we(17, 42)), 7560 new fe(28, new we(17, 22), new we(6, 23)), 7561 new fe(30, new we(19, 16), new we(6, 17)), 7562 ), 7563 new Ae( 7564 22, 7565 Int32Array.from([6, 26, 50, 74, 98]), 7566 new fe(28, new we(2, 111), new we(7, 112)), 7567 new fe(28, new we(17, 46)), 7568 new fe(30, new we(7, 24), new we(16, 25)), 7569 new fe(24, new we(34, 13)), 7570 ), 7571 new Ae( 7572 23, 7573 Int32Array.from([6, 30, 54, 78, 102]), 7574 new fe(30, new we(4, 121), new we(5, 122)), 7575 new fe(28, new we(4, 47), new we(14, 48)), 7576 new fe(30, new we(11, 24), new we(14, 25)), 7577 new fe(30, new we(16, 15), new we(14, 16)), 7578 ), 7579 new Ae( 7580 24, 7581 Int32Array.from([6, 28, 54, 80, 106]), 7582 new fe(30, new we(6, 117), new we(4, 118)), 7583 new fe(28, new we(6, 45), new we(14, 46)), 7584 new fe(30, new we(11, 24), new we(16, 25)), 7585 new fe(30, new we(30, 16), new we(2, 17)), 7586 ), 7587 new Ae( 7588 25, 7589 Int32Array.from([6, 32, 58, 84, 110]), 7590 new fe(26, new we(8, 106), new we(4, 107)), 7591 new fe(28, new we(8, 47), new we(13, 48)), 7592 new fe(30, new we(7, 24), new we(22, 25)), 7593 new fe(30, new we(22, 15), new we(13, 16)), 7594 ), 7595 new Ae( 7596 26, 7597 Int32Array.from([6, 30, 58, 86, 114]), 7598 new fe(28, new we(10, 114), new we(2, 115)), 7599 new fe(28, new we(19, 46), new we(4, 47)), 7600 new fe(28, new we(28, 22), new we(6, 23)), 7601 new fe(30, new we(33, 16), new we(4, 17)), 7602 ), 7603 new Ae( 7604 27, 7605 Int32Array.from([6, 34, 62, 90, 118]), 7606 new fe(30, new we(8, 122), new we(4, 123)), 7607 new fe(28, new we(22, 45), new we(3, 46)), 7608 new fe(30, new we(8, 23), new we(26, 24)), 7609 new fe(30, new we(12, 15), new we(28, 16)), 7610 ), 7611 new Ae( 7612 28, 7613 Int32Array.from([6, 26, 50, 74, 98, 122]), 7614 new fe(30, new we(3, 117), new we(10, 118)), 7615 new fe(28, new we(3, 45), new we(23, 46)), 7616 new fe(30, new we(4, 24), new we(31, 25)), 7617 new fe(30, new we(11, 15), new we(31, 16)), 7618 ), 7619 new Ae( 7620 29, 7621 Int32Array.from([6, 30, 54, 78, 102, 126]), 7622 new fe(30, new we(7, 116), new we(7, 117)), 7623 new fe(28, new we(21, 45), new we(7, 46)), 7624 new fe(30, new we(1, 23), new we(37, 24)), 7625 new fe(30, new we(19, 15), new we(26, 16)), 7626 ), 7627 new Ae( 7628 30, 7629 Int32Array.from([6, 26, 52, 78, 104, 130]), 7630 new fe(30, new we(5, 115), new we(10, 116)), 7631 new fe(28, new we(19, 47), new we(10, 48)), 7632 new fe(30, new we(15, 24), new we(25, 25)), 7633 new fe(30, new we(23, 15), new we(25, 16)), 7634 ), 7635 new Ae( 7636 31, 7637 Int32Array.from([6, 30, 56, 82, 108, 134]),
7638 new fe(30, new we(13, 115), new we(3, 116)), 7639 new fe(28, new we(2, 46), new we(29, 47)), 7640 new fe(30, new we(42, 24), new we(1, 25)), 7641 new fe(30, new we(23, 15), new we(28, 16)), 7642 ), 7643 new Ae( 7644 32, 7645 Int32Array.from([6, 34, 60, 86, 112, 138]), 7646 new fe(30, new we(17, 115)), 7647 new fe(28, new we(10, 46), new we(23, 47)), 7648 new fe(30, new we(10, 24), new we(35, 25)), 7649 new fe(30, new we(19, 15), new we(35, 16)), 7650 ), 7651 new Ae( 7652 33, 7653 Int32Array.from([6, 30, 58, 86, 114, 142]), 7654 new fe(30, new we(17, 115), new we(1, 116)), 7655 new fe(28, new we(14, 46), new we(21, 47)), 7656 new fe(30, new we(29, 24), new we(19, 25)), 7657 new fe(30, new we(11, 15), new we(46, 16)), 7658 ), 7659 new Ae( 7660 34, 7661 Int32Array.from([6, 34, 62, 90, 118, 146]), 7662 new fe(30, new we(13, 115), new we(6, 116)), 7663 new fe(28, new we(14, 46), new we(23, 47)), 7664 new fe(30, new we(44, 24), new we(7, 25)), 7665 new fe(30, new we(59, 16), new we(1, 17)), 7666 ), 7667 new Ae( 7668 35, 7669 Int32Array.from([6, 30, 54, 78, 102, 126, 150]), 7670 new fe(30, new we(12, 121), new we(7, 122)), 7671 new fe(28, new we(12, 47), new we(26, 48)), 7672 new fe(30, new we(39, 24), new we(14, 25)), 7673 new fe(30, new we(22, 15), new we(41, 16)), 7674 ), 7675 new Ae( 7676 36, 7677 Int32Array.from([6, 24, 50, 76, 102, 128, 154]), 7678 new fe(30, new we(6, 121), new we(14, 122)), 7679 new fe(28, new we(6, 47), new we(34, 48)), 7680 new fe(30, new we(46, 24), new we(10, 25)), 7681 new fe(30, new we(2, 15), new we(64, 16)), 7682 ), 7683 new Ae( 7684 37, 7685 Int32Array.from([6, 28, 54, 80, 106, 132, 158]), 7686 new fe(30, new we(17, 122), new we(4, 123)), 7687 new fe(28, new we(29, 46), new we(14, 47)), 7688 new fe(30, new we(49, 24), new we(10, 25)), 7689 new fe(30, new we(24, 15), new we(46, 16)), 7690 ), 7691 new Ae( 7692 38, 7693 Int32Array.from([6, 32, 58, 84, 110, 136, 162]), 7694 new fe(30, new we(4, 122), new we(18, 123)), 7695 new fe(28, new we(13, 46), new we(32, 47)), 7696 new fe(30, new we(48, 24), new we(14, 25)), 7697 new fe(30, new we(42, 15), new we(32, 16)), 7698 ), 7699 new Ae( 7700 39, 7701 Int32Array.from([6, 26, 54, 82, 110, 138, 166]), 7702 new fe(30, new we(20, 117), new we(4, 118)), 7703 new fe(28, new we(40, 47), new we(7, 48)), 7704 new fe(30, new we(43, 24), new we(22, 25)), 7705 new fe(30, new we(10, 15), new we(67, 16)), 7706 ), 7707 new Ae( 7708 40, 7709 Int32Array.from([6, 30, 58, 86, 114, 142, 170]), 7710 new fe(30, new we(19, 118), new we(6, 119)), 7711 new fe(28, new we(18, 47), new we(31, 48)), 7712 new fe(30, new we(34, 24), new we(34, 25)), 7713 new fe(30, new we(20, 15), new we(61, 16)), 7714 ), 7715 ]), 7716 (function (t) { 7717 (t[(t.DATA_MASK_000 = 0)] = 'DATA_MASK_000'), 7718 (t[(t.DATA_MASK_001 = 1)] = 'DATA_MASK_001'), 7719 (t[(t.DATA_MASK_010 = 2)] = 'DATA_MASK_010'), 7720 (t[(t.DATA_MASK_011 = 3)] = 'DATA_MASK_011'), 7721 (t[(t.DATA_MASK_100 = 4)] = 'DATA_MASK_100'), 7722 (t[(t.DATA_MASK_101 = 5)] = 'DATA_MASK_101'), 7723 (t[(t.DATA_MASK_110 = 6)] = 'DATA_MASK_110'), 7724 (t[(t.DATA_MASK_111 = 7)] = 'DATA_MASK_111'); 7725 })(H || (H = {})); 7726 class Ce { 7727 constructor(t, e) { 7728 (this.value = t), (this.isMasked = e); 7729 } 7730 unmaskBitMatrix(t, e) { 7731 for (let r = 0; r < e; r++) for (let n = 0; n < e; n++) this.isMasked(r, n) && t.flip(n, r); 7732 } 7733 } 7734 Ce.values = new Map([ 7735 [H.DATA_MASK_000, new Ce(H.DATA_MASK_000, (t, e) => 0 == ((t + e) & 1))], 7736 [H.DATA_MASK_001, new Ce(H.DATA_MASK_001, (t, e) => 0 == (1 & t))], 7737 [H.DATA_MASK_010, new Ce(H.DATA_MASK_010, (t, e) => e % 3 == 0)], 7738 [H.DATA_MASK_011, new Ce(H.DATA_MASK_011, (t, e) => (t + e) % 3 == 0)], 7739 [H.DATA_MASK_100, new Ce(H.DATA_MASK_100, (t, e) => 0 == ((Math.floor(t / 2) + Math.floor(e / 3)) & 1))], 7740 [H.DATA_MASK_101, new Ce(H.DATA_MASK_101, (t, e) => (t * e) % 6 == 0)], 7741 [H.DATA_MASK_110, new Ce(H.DATA_MASK_110, (t, e) => (t * e) % 6 < 3)], 7742 [H.DATA_MASK_111, new Ce(H.DATA_MASK_111, (t, e) => 0 == ((t + e + ((t * e) % 3)) & 1))], 7743 ]); 7744 class Ee { 7745 constructor(t) { 7746 const e = t.getHeight(); 7747 if (e < 21 || 1 != (3 & e)) throw new E(); 7748 this.bitMatrix = t; 7749 } 7750 readFormatInformation() { 7751 if (null !== this.parsedFormatInfo && void 0 !== this.parsedFormatInfo) return this.parsedFormatInfo; 7752 let t = 0; 7753 for (let e = 0; e < 6; e++) t = this.copyBit(e, 8, t); 7754 (t = this.copyBit(7, 8, t)), (t = this.copyBit(8, 8, t)), (t = this.copyBit(8, 7, t));
7755 for (let e = 5; e >= 0; e--) t = this.copyBit(8, e, t); 7756 const e = this.bitMatrix.getHeight(); 7757 let r = 0; 7758 const n = e - 7; 7759 for (let t = e - 1; t >= n; t--) r = this.copyBit(8, t, r); 7760 for (let t = e - 8; t < e; t++) r = this.copyBit(t, 8, r); 7761 if (((this.parsedFormatInfo = ge.decodeFormatInformation(t, r)), null !== this.parsedFormatInfo)) 7762 return this.parsedFormatInfo; 7763 throw new E(); 7764 } 7765 readVersion() { 7766 if (null !== this.parsedVersion && void 0 !== this.parsedVersion) return this.parsedVersion; 7767 const t = this.bitMatrix.getHeight(), 7768 e = Math.floor((t - 17) / 4); 7769 if (e <= 6) return Ae.getVersionForNumber(e); 7770 let r = 0; 7771 const n = t - 11; 7772 for (let e = 5; e >= 0; e--) for (let i = t - 9; i >= n; i--) r = this.copyBit(i, e, r); 7773 let i = Ae.decodeVersionInformation(r); 7774 if (null !== i && i.getDimensionForVersion() === t) return (this.parsedVersion = i), i; 7775 r = 0; 7776 for (let e = 5; e >= 0; e--) for (let i = t - 9; i >= n; i--) r = this.copyBit(e, i, r); 7777 if (((i = Ae.decodeVersionInformation(r)), null !== i && i.getDimensionForVersion() === t)) 7778 return (this.parsedVersion = i), i; 7779 throw new E(); 7780 } 7781 copyBit(t, e, r) { 7782 return (this.isMirror ? this.bitMatrix.get(e, t) : this.bitMatrix.get(t, e)) ? (r << 1) | 1 : r << 1; 7783 } 7784 readCodewords() { 7785 const t = this.readFormatInformation(), 7786 e = this.readVersion(), 7787 r = Ce.values.get(t.getDataMask()), 7788 n = this.bitMatrix.getHeight(); 7789 r.unmaskBitMatrix(this.bitMatrix, n); 7790 const i = e.buildFunctionPattern(); 7791 let s = !0; 7792 const o = new Uint8Array(e.getTotalCodewords()); 7793 let a = 0, 7794 l = 0, 7795 h = 0; 7796 for (let t = n - 1; t > 0; t -= 2) { 7797 6 === t && t--; 7798 for (let e = 0; e < n; e++) { 7799 const r = s ? n - 1 - e : e; 7800 for (let e = 0; e < 2; e++) 7801 i.get(t - e, r) || 7802 (h++, (l <<= 1), this.bitMatrix.get(t - e, r) && (l |= 1), 8 === h && ((o[a++] = l), (h = 0), (l = 0))); 7803 } 7804 s = !s; 7805 } 7806 if (a !== e.getTotalCodewords()) throw new E(); 7807 return o; 7808 } 7809 remask() { 7810 if (null === this.parsedFormatInfo) return; 7811 const t = Ce.values[this.parsedFormatInfo.getDataMask()], 7812 e = this.bitMatrix.getHeight(); 7813 t.unmaskBitMatrix(this.bitMatrix, e); 7814 } 7815 setMirror(t) { 7816 (this.parsedVersion = null), (this.parsedFormatInfo = null), (this.isMirror = t); 7817 } 7818 mirror() { 7819 const t = this.bitMatrix; 7820 for (let e = 0, r = t.getWidth(); e < r; e++) 7821 for (let r = e + 1, n = t.getHeight(); r < n; r++) t.get(e, r) !== t.get(r, e) && (t.flip(r, e), t.flip(e, r)); 7822 } 7823 } 7824 class me { 7825 constructor(t, e) { 7826 (this.numDataCodewords = t), (this.codewords = e); 7827 } 7828 static getDataBlocks(t, e, r) { 7829 if (t.length !== e.getTotalCodewords()) throw new o(); 7830 const n = e.getECBlocksForLevel(r); 7831 let i = 0; 7832 const s = n.getECBlocks(); 7833 for (const t of s) i += t.getCount(); 7834 const a = new Array(i); 7835 let l = 0; 7836 for (const t of s) 7837 for (let e = 0; e < t.getCount(); e++) { 7838 const e = t.getDataCodewords(), 7839 r = n.getECCodewordsPerBlock() + e; 7840 a[l++] = new me(e, new Uint8Array(r)); 7841 } 7842 const h = a[0].codewords.length; 7843 let c = a.length - 1; 7844 for (; c >= 0; ) { 7845 if (a[c].codewords.length === h) break; 7846 c--; 7847 } 7848 c++; 7849 const u = h - n.getECCodewordsPerBlock(); 7850 let d = 0; 7851 for (let e = 0; e < u; e++) for (let r = 0; r < l; r++) a[r].codewords[e] = t[d++]; 7852 for (let e = c; e < l; e++) a[e].codewords[u] = t[d++]; 7853 const g = a[0].codewords.length; 7854 for (let e = u; e < g; e++) 7855 for (let r = 0; r < l; r++) { 7856 const n = r < c ? e : e + 1; 7857 a[r].codewords[n] = t[d++]; 7858 } 7859 return a; 7860 } 7861 getNumDataCodewords() { 7862 return this.numDataCodewords; 7863 } 7864 getCodewords() {
7865 return this.codewords; 7866 } 7867 } 7868 !(function (t) { 7869 (t[(t.TERMINATOR = 0)] = 'TERMINATOR'), 7870 (t[(t.NUMERIC = 1)] = 'NUMERIC'), 7871 (t[(t.ALPHANUMERIC = 2)] = 'ALPHANUMERIC'), 7872 (t[(t.STRUCTURED_APPEND = 3)] = 'STRUCTURED_APPEND'), 7873 (t[(t.BYTE = 4)] = 'BYTE'), 7874 (t[(t.ECI = 5)] = 'ECI'), 7875 (t[(t.KANJI = 6)] = 'KANJI'), 7876 (t[(t.FNC1_FIRST_POSITION = 7)] = 'FNC1_FIRST_POSITION'), 7877 (t[(t.FNC1_SECOND_POSITION = 8)] = 'FNC1_SECOND_POSITION'), 7878 (t[(t.HANZI = 9)] = 'HANZI'); 7879 })(G || (G = {})); 7880 class _e { 7881 constructor(t, e, r, n) { 7882 (this.value = t), 7883 (this.stringValue = e), 7884 (this.characterCountBitsForVersions = r), 7885 (this.bits = n), 7886 _e.FOR_BITS.set(n, this), 7887 _e.FOR_VALUE.set(t, this); 7888 } 7889 static forBits(t) { 7890 const e = _e.FOR_BITS.get(t); 7891 if (void 0 === e) throw new o(); 7892 return e; 7893 } 7894 getCharacterCountBits(t) { 7895 const e = t.getVersionNumber(); 7896 let r; 7897 return (r = e <= 9 ? 0 : e <= 26 ? 1 : 2), this.characterCountBitsForVersions[r]; 7898 } 7899 getValue() { 7900 return this.value; 7901 } 7902 getBits() { 7903 return this.bits; 7904 } 7905 equals(t) { 7906 if (!(t instanceof _e)) return !1; 7907 const e = t; 7908 return this.value === e.value; 7909 } 7910 toString() { 7911 return this.stringValue; 7912 } 7913 } 7914 (_e.FOR_BITS = new Map()), 7915 (_e.FOR_VALUE = new Map()), 7916 (_e.TERMINATOR = new _e(G.TERMINATOR, 'TERMINATOR', Int32Array.from([0, 0, 0]), 0)), 7917 (_e.NUMERIC = new _e(G.NUMERIC, 'NUMERIC', Int32Array.from([10, 12, 14]), 1)), 7918 (_e.ALPHANUMERIC = new _e(G.ALPHANUMERIC, 'ALPHANUMERIC', Int32Array.from([9, 11, 13]), 2)), 7919 (_e.STRUCTURED_APPEND = new _e(G.STRUCTURED_APPEND, 'STRUCTURED_APPEND', Int32Array.from([0, 0, 0]), 3)), 7920 (_e.BYTE = new _e(G.BYTE, 'BYTE', Int32Array.from([8, 16, 16]), 4)), 7921 (_e.ECI = new _e(G.ECI, 'ECI', Int32Array.from([0, 0, 0]), 7)), 7922 (_e.KANJI = new _e(G.KANJI, 'KANJI', Int32Array.from([8, 10, 12]), 8)), 7923 (_e.FNC1_FIRST_POSITION = new _e(G.FNC1_FIRST_POSITION, 'FNC1_FIRST_POSITION', Int32Array.from([0, 0, 0]), 5)), 7924 (_e.FNC1_SECOND_POSITION = new _e(G.FNC1_SECOND_POSITION, 'FNC1_SECOND_POSITION', Int32Array.from([0, 0, 0]), 9)), 7925 (_e.HANZI = new _e(G.HANZI, 'HANZI', Int32Array.from([8, 10, 12]), 13)); 7926 class Ie { 7927 static decode(t, e, r, n) { 7928 const i = new ae(t); 7929 let s = new p(); 7930 const o = new Array(); 7931 let a = -1, 7932 l = -1; 7933 try { 7934 let t, 7935 r = null, 7936 h = !1; 7937 do { 7938 if (i.available() < 4) t = _e.TERMINATOR; 7939 else { 7940 const e = i.readBits(4); 7941 t = _e.forBits(e); 7942 } 7943 switch (t) { 7944 case _e.TERMINATOR: 7945 break; 7946 case _e.FNC1_FIRST_POSITION: 7947 case _e.FNC1_SECOND_POSITION: 7948 h = !0; 7949 break; 7950 case _e.STRUCTURED_APPEND: 7951 if (i.available() < 16) throw new E(); 7952 (a = i.readBits(8)), (l = i.readBits(8)); 7953 break; 7954 case _e.ECI: 7955 const c = Ie.parseECIValue(i); 7956 if (((r = m.getCharacterSetECIByValue(c)), null === r)) throw new E(); 7957 break; 7958 case _e.HANZI: 7959 const u = i.readBits(4), 7960 d = i.readBits(t.getCharacterCountBits(e)); 7961 u === Ie.GB2312_SUBSET && Ie.decodeHanziSegment(i, s, d); 7962 break; 7963 default: 7964 const g = i.readBits(t.getCharacterCountBits(e)); 7965 switch (t) { 7966 case _e.NUMERIC: 7967 Ie.decodeNumericSegment(i, s, g); 7968 break; 7969 case _e.ALPHANUMERIC: 7970 Ie.decodeAlphanumericSegment(i, s, g, h); 7971 break; 7972 case _e.BYTE: 7973 Ie.decodeByteSegment(i, s, g, r, o, n); 7974 break; 7975 case _e.KANJI: 7976 Ie.decodeKanjiSegment(i, s, g); 7977 break; 7978 default: 7979 throw new E(); 7980 } 7981 } 7982 } while (t !== _e.TERMINATOR); 7983 } catch (t) { 7984 throw new E(); 7985 } 7986 return new z(t, s.toString(), 0 === o.length ? null : o, null === r ? null : r.toString(), a, l); 7987 } 7988 static decodeHanziSegment(t, e, r) { 7989 if (13 * r > t.available()) throw new E(); 7990 const n = new Uint8Array(2 * r); 7991 let i = 0; 7992 for (; r > 0; ) { 7993 const e = t.readBits(13); 7994 let s = (((e / 96) << 8) & 4294967295) | e % 96; 7995 (s += s < 959 ? 41377 : 42657), (n[i] = (s >> 8) & 255), (n[i + 1] = 255 & s), (i += 2), r--; 7996 }
7997 try { 7998 e.append(I.decode(n, S.GB2312)); 7999 } catch (t) { 8000 throw new E(t); 8001 } 8002 } 8003 static decodeKanjiSegment(t, e, r) { 8004 if (13 * r > t.available()) throw new E(); 8005 const n = new Uint8Array(2 * r); 8006 let i = 0; 8007 for (; r > 0; ) { 8008 const e = t.readBits(13); 8009 let s = (((e / 192) << 8) & 4294967295) | e % 192; 8010 (s += s < 7936 ? 33088 : 49472), (n[i] = s >> 8), (n[i + 1] = s), (i += 2), r--; 8011 } 8012 try { 8013 e.append(I.decode(n, S.SHIFT_JIS)); 8014 } catch (t) { 8015 throw new E(t); 8016 } 8017 } 8018 static decodeByteSegment(t, e, r, n, i, s) { 8019 if (8 * r > t.available()) throw new E(); 8020 const o = new Uint8Array(r); 8021 for (let e = 0; e < r; e++) o[e] = t.readBits(8); 8022 let a; 8023 a = null === n ? S.guessEncoding(o, s) : n.getName(); 8024 try { 8025 e.append(I.decode(o, a)); 8026 } catch (t) { 8027 throw new E(t); 8028 } 8029 i.push(o); 8030 } 8031 static toAlphaNumericChar(t) { 8032 if (t >= Ie.ALPHANUMERIC_CHARS.length) throw new E(); 8033 return Ie.ALPHANUMERIC_CHARS[t]; 8034 } 8035 static decodeAlphanumericSegment(t, e, r, n) { 8036 const i = e.length(); 8037 for (; r > 1; ) { 8038 if (t.available() < 11) throw new E(); 8039 const n = t.readBits(11); 8040 e.append(Ie.toAlphaNumericChar(Math.floor(n / 45))), e.append(Ie.toAlphaNumericChar(n % 45)), (r -= 2); 8041 } 8042 if (1 === r) { 8043 if (t.available() < 6) throw new E(); 8044 e.append(Ie.toAlphaNumericChar(t.readBits(6))); 8045 } 8046 if (n) 8047 for (let t = i; t < e.length(); t++) 8048 '%' === e.charAt(t) && 8049 (t < e.length() - 1 && '%' === e.charAt(t + 1) 8050 ? e.deleteCharAt(t + 1) 8051 : e.setCharAt(t, String.fromCharCode(29))); 8052 } 8053 static decodeNumericSegment(t, e, r) { 8054 for (; r >= 3; ) { 8055 if (t.available() < 10) throw new E(); 8056 const n = t.readBits(10); 8057 if (n >= 1e3) throw new E(); 8058 e.append(Ie.toAlphaNumericChar(Math.floor(n / 100))), 8059 e.append(Ie.toAlphaNumericChar(Math.floor(n / 10) % 10)), 8060 e.append(Ie.toAlphaNumericChar(n % 10)), 8061 (r -= 3); 8062 } 8063 if (2 === r) { 8064 if (t.available() < 7) throw new E(); 8065 const r = t.readBits(7); 8066 if (r >= 100) throw new E(); 8067 e.append(Ie.toAlphaNumericChar(Math.floor(r / 10))), e.append(Ie.toAlphaNumericChar(r % 10)); 8068 } else if (1 === r) { 8069 if (t.available() < 4) throw new E(); 8070 const r = t.readBits(4); 8071 if (r >= 10) throw new E(); 8072 e.append(Ie.toAlphaNumericChar(r)); 8073 } 8074 } 8075 static parseECIValue(t) { 8076 const e = t.readBits(8); 8077 if (0 == (128 & e)) return 127 & e; 8078 if (128 == (192 & e)) { 8079 return (((63 & e) << 8) & 4294967295) | t.readBits(8); 8080 } 8081 if (192 == (224 & e)) { 8082 return (((31 & e) << 16) & 4294967295) | t.readBits(16); 8083 } 8084 throw new E(); 8085 } 8086 } 8087 (Ie.ALPHANUMERIC_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:'), (Ie.GB2312_SUBSET = 1); 8088 class Se { 8089 constructor(t) { 8090 this.mirrored = t; 8091 } 8092 isMirrored() { 8093 return this.mirrored; 8094 } 8095 applyMirroredCorrection(t) { 8096 if (!this.mirrored || null === t || t.length < 3) return; 8097 const e = t[0]; 8098 (t[0] = t[2]), (t[2] = e); 8099 } 8100 } 8101 class pe { 8102 constructor() { 8103 this.rsDecoder = new J(q.QR_CODE_FIELD_256); 8104 } 8105 decodeBooleanArray(t, e) { 8106 return this.decodeBitMatrix(T.parseFromBooleanArray(t), e); 8107 } 8108 decodeBitMatrix(t, e) { 8109 const r = new Ee(t); 8110 let n = null; 8111 try { 8112 return this.decodeBitMatrixParser(r, e); 8113 } catch (t) { 8114 n = t; 8115 } 8116 try { 8117 r.remask(), r.setMirror(!0), r.readVersion(), r.readFormatInformation(), r.mirror(); 8118 const t = this.decodeBitMatrixParser(r, e); 8119 return t.setOther(new Se(!0)), t; 8120 } catch (t) { 8121 if (null !== n) throw n; 8122 throw t; 8123 } 8124 } 8125 decodeBitMatrixParser(t, e) { 8126 const r = t.readVersion(), 8127 n = t.readFormatInformation().getErrorCorrectionLevel(), 8128 i = t.readCodewords(), 8129 s = me.getDataBlocks(i, r, n); 8130 let o = 0; 8131 for (const t of s) o += t.getNumDataCodewords(); 8132 const a = new Uint8Array(o); 8133 let l = 0; 8134 for (const t of s) { 8135 const e = t.getCodewords(), 8136 r = t.getNumDataCodewords(); 8137 this.correctErrors(e, r); 8138 for (let t = 0; t < r; t++) a[l++] = e[t]; 8139 } 8140 return Ie.decode(a, r, n, e); 8141 } 8142 correctErrors(t, e) { 8143 const r = new Int32Array(t);
8144 try { 8145 this.rsDecoder.decode(r, t.length - e); 8146 } catch (t) { 8147 throw new l(); 8148 } 8149 for (let n = 0; n < e; n++) t[n] = r[n]; 8150 } 8151 } 8152 class Te extends rt { 8153 constructor(t, e, r) { 8154 super(t, e), (this.estimatedModuleSize = r); 8155 } 8156 aboutEquals(t, e, r) { 8157 if (Math.abs(e - this.getY()) <= t && Math.abs(r - this.getX()) <= t) { 8158 const e = Math.abs(t - this.estimatedModuleSize); 8159 return e <= 1 || e <= this.estimatedModuleSize; 8160 } 8161 return !1; 8162 } 8163 combineEstimate(t, e, r) { 8164 const n = (this.getX() + e) / 2, 8165 i = (this.getY() + t) / 2, 8166 s = (this.estimatedModuleSize + r) / 2; 8167 return new Te(n, i, s); 8168 } 8169 } 8170 class Re { 8171 constructor(t, e, r, n, i, s, o) { 8172 (this.image = t), 8173 (this.startX = e), 8174 (this.startY = r), 8175 (this.width = n), 8176 (this.height = i), 8177 (this.moduleSize = s), 8178 (this.resultPointCallback = o), 8179 (this.possibleCenters = []), 8180 (this.crossCheckStateCount = new Int32Array(3)); 8181 } 8182 find() { 8183 const t = this.startX, 8184 e = this.height, 8185 r = t + this.width, 8186 n = this.startY + e / 2, 8187 i = new Int32Array(3), 8188 s = this.image; 8189 for (let o = 0; o < e; o++) { 8190 const e = n + (0 == (1 & o) ? Math.floor((o + 1) / 2) : -Math.floor((o + 1) / 2)); 8191 (i[0] = 0), (i[1] = 0), (i[2] = 0); 8192 let a = t; 8193 for (; a < r && !s.get(a, e); ) a++; 8194 let l = 0; 8195 for (; a < r; ) { 8196 if (s.get(a, e)) 8197 if (1 === l) i[1]++; 8198 else if (2 === l) { 8199 if (this.foundPatternCross(i)) { 8200 const t = this.handlePossibleCenter(i, e, a); 8201 if (null !== t) return t; 8202 } 8203 (i[0] = i[2]), (i[1] = 1), (i[2] = 0), (l = 1); 8204 } else i[++l]++; 8205 else 1 === l && l++, i[l]++; 8206 a++; 8207 } 8208 if (this.foundPatternCross(i)) { 8209 const t = this.handlePossibleCenter(i, e, r); 8210 if (null !== t) return t; 8211 } 8212 } 8213 if (0 !== this.possibleCenters.length) return this.possibleCenters[0]; 8214 throw new R(); 8215 } 8216 static centerFromEnd(t, e) { 8217 return e - t[2] - t[1] / 2; 8218 } 8219 foundPatternCross(t) { 8220 const e = this.moduleSize, 8221 r = e / 2; 8222 for (let n = 0; n < 3; n++) if (Math.abs(e - t[n]) >= r) return !1; 8223 return !0; 8224 } 8225 crossCheckVertical(t, e, r, n) { 8226 const i = this.image, 8227 s = i.getHeight(), 8228 o = this.crossCheckStateCount; 8229 (o[0] = 0), (o[1] = 0), (o[2] = 0); 8230 let a = t; 8231 for (; a >= 0 && i.get(e, a) && o[1] <= r; ) o[1]++, a--; 8232 if (a < 0 || o[1] > r) return NaN; 8233 for (; a >= 0 && !i.get(e, a) && o[0] <= r; ) o[0]++, a--; 8234 if (o[0] > r) return NaN; 8235 for (a = t + 1; a < s && i.get(e, a) && o[1] <= r; ) o[1]++, a++; 8236 if (a === s || o[1] > r) return NaN; 8237 for (; a < s && !i.get(e, a) && o[2] <= r; ) o[2]++, a++; 8238 if (o[2] > r) return NaN; 8239 const l = o[0] + o[1] + o[2]; 8240 return 5 * Math.abs(l - n) >= 2 * n ? NaN : this.foundPatternCross(o) ? Re.centerFromEnd(o, a) : NaN; 8241 } 8242 handlePossibleCenter(t, e, r) { 8243 const n = t[0] + t[1] + t[2], 8244 i = Re.centerFromEnd(t, r), 8245 s = this.crossCheckVertical(e, i, 2 * t[1], n); 8246 if (!isNaN(s)) { 8247 const e = (t[0] + t[1] + t[2]) / 3; 8248 for (const t of this.possibleCenters) if (t.aboutEquals(e, s, i)) return t.combineEstimate(s, i, e); 8249 const r = new Te(i, s, e); 8250 this.possibleCenters.push(r), 8251 null !== this.resultPointCallback && 8252 void 0 !== this.resultPointCallback && 8253 this.resultPointCallback.foundPossibleResultPoint(r); 8254 } 8255 return null; 8256 } 8257 } 8258 class Ne extends rt { 8259 constructor(t, e, r, n) { 8260 super(t, e), (this.estimatedModuleSize = r), (this.count = n), void 0 === n && (this.count = 1); 8261 } 8262 getEstimatedModuleSize() { 8263 return this.estimatedModuleSize; 8264 } 8265 getCount() { 8266 return this.count; 8267 } 8268 aboutEquals(t, e, r) { 8269 if (Math.abs(e - this.getY()) <= t && Math.abs(r - this.getX()) <= t) { 8270 const e = Math.abs(t - this.estimatedModuleSize); 8271 return e <= 1 || e <= this.estimatedModuleSize; 8272 } 8273 return !1; 8274 } 8275 combineEstimate(t, e, r) { 8276 const n = this.count + 1, 8277 i = (this.count * this.getX() + e) / n, 8278 s = (this.count * this.getY() + t) / n, 8279 o = (this.count * this.estimatedModuleSize + r) / n; 8280 return new Ne(i, s, o, n); 8281 } 8282 } 8283 class De { 8284 constructor(t) { 8285 (this.bottomLeft = t[0]), (this.topLeft = t[1]), (this.topRight = t[2]); 8286 } 8287 getBottomLeft() { 8288 return this.bottomLeft; 8289 } 8290 getTopLeft() { 8291 return this.topLeft; 8292 } 8293 getTopRight() { 8294 return this.topRight; 8295 } 8296 } 8297 class ye { 8298 constructor(t, e) { 8299 (this.image = t), 8300 (this.resultPointCallback = e), 8301 (this.possibleCenters = []), 8302 (this.crossCheckStateCount = new Int32Array(5)), 8303 (this.resultPointCallback = e); 8304 } 8305 getImage() { 8306 return this.image; 8307 } 8308 getPossibleCenters() { 8309 return this.possibleCenters; 8310 } 8311 find(t) { 8312 const e = null != t && void 0 !== t.get(C.TRY_HARDER), 8313 r = null != t && void 0 !== t.get(C.PURE_BARCODE), 8314 n = this.image, 8315 i = n.getHeight(), 8316 s = n.getWidth(); 8317 let o = Math.floor((3 * i) / (4 * ye.MAX_MODULES)); 8318 (o < ye.MIN_SKIP || e) && (o = ye.MIN_SKIP); 8319 let a = !1; 8320 const l = new Int32Array(5); 8321 for (let t = o - 1; t < i && !a; t += o) { 8322 (l[0] = 0), (l[1] = 0), (l[2] = 0), (l[3] = 0), (l[4] = 0); 8323 let e = 0; 8324 for (let i = 0; i < s; i++) 8325 if (n.get(i, t)) 1 == (1 & e) && e++, l[e]++; 8326 else if (0 == (1 & e)) 8327 if (4 === e) 8328 if (ye.foundPatternCross(l)) { 8329 if (!0 !== this.handlePossibleCenter(l, t, i, r)) { 8330 (l[0] = l[2]), (l[1] = l[3]), (l[2] = l[4]), (l[3] = 1), (l[4] = 0), (e = 3); 8331 continue; 8332 } 8333 if (((o = 2), !0 === this.hasSkipped)) a = this.haveMultiplyConfirmedCenters(); 8334 else { 8335 const e = this.findRowSkip(); 8336 e > l[2] && ((t += e - l[2] - o), (i = s - 1)); 8337 } 8338 (e = 0), (l[0] = 0), (l[1] = 0), (l[2] = 0), (l[3] = 0), (l[4] = 0); 8339 } else (l[0] = l[2]), (l[1] = l[3]), (l[2] = l[4]), (l[3] = 1), (l[4] = 0), (e = 3); 8340 else l[++e]++; 8341 else l[e]++; 8342 if (ye.foundPatternCross(l)) { 8343 !0 === this.handlePossibleCenter(l, t, s, r) && 8344 ((o = l[0]), this.hasSkipped && (a = this.haveMultiplyConfirmedCenters())); 8345 } 8346 } 8347 const h = this.selectBestPatterns(); 8348 return rt.orderBestPatterns(h), new De(h); 8349 } 8350 static centerFromEnd(t, e) { 8351 return e - t[4] - t[3] - t[2] / 2; 8352 }
vendor: 4,258 bytes, lines 8353-8455
8353 static foundPatternCross(t) { 8354 let e = 0; 8355 for (let r = 0; r < 5; r++) { 8356 const n = t[r]; 8357 if (0 === n) return !1; 8358 e += n; 8359 } 8360 if (e < 7) return !1; 8361 const r = e / 7, 8362 n = r / 2; 8363 return ( 8364 Math.abs(r - t[0]) < n && 8365 Math.abs(r - t[1]) < n && 8366 Math.abs(3 * r - t[2]) < 3 * n && 8367 Math.abs(r - t[3]) < n && 8368 Math.abs(r - t[4]) < n 8369 ); 8370 } 8371 getCrossCheckStateCount() { 8372 const t = this.crossCheckStateCount; 8373 return (t[0] = 0), (t[1] = 0), (t[2] = 0), (t[3] = 0), (t[4] = 0), t; 8374 } 8375 crossCheckDiagonal(t, e, r, n) { 8376 const i = this.getCrossCheckStateCount(); 8377 let s = 0; 8378 const o = this.image; 8379 for (; t >= s && e >= s && o.get(e - s, t - s); ) i[2]++, s++; 8380 if (t < s || e < s) return !1; 8381 for (; t >= s && e >= s && !o.get(e - s, t - s) && i[1] <= r; ) i[1]++, s++; 8382 if (t < s || e < s || i[1] > r) return !1; 8383 for (; t >= s && e >= s && o.get(e - s, t - s) && i[0] <= r; ) i[0]++, s++; 8384 if (i[0] > r) return !1; 8385 const a = o.getHeight(), 8386 l = o.getWidth(); 8387 for (s = 1; t + s < a && e + s < l && o.get(e + s, t + s); ) i[2]++, s++; 8388 if (t + s >= a || e + s >= l) return !1; 8389 for (; t + s < a && e + s < l && !o.get(e + s, t + s) && i[3] < r; ) i[3]++, s++; 8390 if (t + s >= a || e + s >= l || i[3] >= r) return !1; 8391 for (; t + s < a && e + s < l && o.get(e + s, t + s) && i[4] < r; ) i[4]++, s++; 8392 if (i[4] >= r) return !1; 8393 const h = i[0] + i[1] + i[2] + i[3] + i[4]; 8394 return Math.abs(h - n) < 2 * n && ye.foundPatternCross(i); 8395 } 8396 crossCheckVertical(t, e, r, n) { 8397 const i = this.image, 8398 s = i.getHeight(), 8399 o = this.getCrossCheckStateCount(); 8400 let a = t; 8401 for (; a >= 0 && i.get(e, a); ) o[2]++, a--; 8402 if (a < 0) return NaN; 8403 for (; a >= 0 && !i.get(e, a) && o[1] <= r; ) o[1]++, a--; 8404 if (a < 0 || o[1] > r) return NaN; 8405 for (; a >= 0 && i.get(e, a) && o[0] <= r; ) o[0]++, a--; 8406 if (o[0] > r) return NaN; 8407 for (a = t + 1; a < s && i.get(e, a); ) o[2]++, a++; 8408 if (a === s) return NaN; 8409 for (; a < s && !i.get(e, a) && o[3] < r; ) o[3]++, a++; 8410 if (a === s || o[3] >= r) return NaN; 8411 for (; a < s && i.get(e, a) && o[4] < r; ) o[4]++, a++; 8412 if (o[4] >= r) return NaN; 8413 const l = o[0] + o[1] + o[2] + o[3] + o[4]; 8414 return 5 * Math.abs(l - n) >= 2 * n ? NaN : ye.foundPatternCross(o) ? ye.centerFromEnd(o, a) : NaN; 8415 } 8416 crossCheckHorizontal(t, e, r, n) { 8417 const i = this.image, 8418 s = i.getWidth(), 8419 o = this.getCrossCheckStateCount(); 8420 let a = t; 8421 for (; a >= 0 && i.get(a, e); ) o[2]++, a--; 8422 if (a < 0) return NaN; 8423 for (; a >= 0 && !i.get(a, e) && o[1] <= r; ) o[1]++, a--; 8424 if (a < 0 || o[1] > r) return NaN; 8425 for (; a >= 0 && i.get(a, e) && o[0] <= r; ) o[0]++, a--; 8426 if (o[0] > r) return NaN; 8427 for (a = t + 1; a < s && i.get(a, e); ) o[2]++, a++; 8428 if (a === s) return NaN; 8429 for (; a < s && !i.get(a, e) && o[3] < r; ) o[3]++, a++; 8430 if (a === s || o[3] >= r) return NaN; 8431 for (; a < s && i.get(a, e) && o[4] < r; ) o[4]++, a++; 8432 if (o[4] >= r) return NaN; 8433 const l = o[0] + o[1] + o[2] + o[3] + o[4]; 8434 return 5 * Math.abs(l - n) >= n ? NaN : ye.foundPatternCross(o) ? ye.centerFromEnd(o, a) : NaN; 8435 } 8436 handlePossibleCenter(t, e, r, n) { 8437 const i = t[0] + t[1] + t[2] + t[3] + t[4]; 8438 let s = ye.centerFromEnd(t, r), 8439 o = this.crossCheckVertical(e, Math.floor(s), t[2], i); 8440 if ( 8441 !isNaN(o) && 8442 ((s = this.crossCheckHorizontal(Math.floor(s), Math.floor(o), t[2], i)), 8443 !isNaN(s) && (!n || this.crossCheckDiagonal(Math.floor(o), Math.floor(s), t[2], i))) 8444 ) { 8445 const t = i / 7; 8446 let e = !1; 8447 const r = this.possibleCenters; 8448 for (let n = 0, i = r.length; n < i; n++) { 8449 const i = r[n]; 8450 if (i.aboutEquals(t, o, s)) { 8451 (r[n] = i.combineEstimate(o, s, t)), (e = !0); 8452 break; 8453 } 8454 } 8455 if (!e) {
8456 const e = new Ne(s, o, t); 8457 r.push(e), 8458 null !== this.resultPointCallback && 8459 void 0 !== this.resultPointCallback && 8460 this.resultPointCallback.foundPossibleResultPoint(e); 8461 } 8462 return !0; 8463 } 8464 return !1; 8465 } 8466 findRowSkip() { 8467 if (this.possibleCenters.length <= 1) return 0; 8468 let t = null; 8469 for (const e of this.possibleCenters) 8470 if (e.getCount() >= ye.CENTER_QUORUM) { 8471 if (null != t) 8472 return ( 8473 (this.hasSkipped = !0), Math.floor((Math.abs(t.getX() - e.getX()) - Math.abs(t.getY() - e.getY())) / 2) 8474 ); 8475 t = e; 8476 } 8477 return 0; 8478 } 8479 haveMultiplyConfirmedCenters() { 8480 let t = 0, 8481 e = 0; 8482 const r = this.possibleCenters.length; 8483 for (const r of this.possibleCenters) 8484 r.getCount() >= ye.CENTER_QUORUM && (t++, (e += r.getEstimatedModuleSize())); 8485 if (t < 3) return !1; 8486 const n = e / r; 8487 let i = 0; 8488 for (const t of this.possibleCenters) i += Math.abs(t.getEstimatedModuleSize() - n); 8489 return i <= 0.05 * e; 8490 } 8491 selectBestPatterns() { 8492 const t = this.possibleCenters.length; 8493 if (t < 3) throw new R(); 8494 const e = this.possibleCenters; 8495 let r; 8496 if (t > 3) { 8497 let n = 0, 8498 i = 0; 8499 for (const t of this.possibleCenters) { 8500 const e = t.getEstimatedModuleSize(); 8501 (n += e), (i += e * e); 8502 } 8503 r = n / t; 8504 let s = Math.sqrt(i / t - r * r); 8505 e.sort((t, e) => { 8506 const n = Math.abs(e.getEstimatedModuleSize() - r), 8507 i = Math.abs(t.getEstimatedModuleSize() - r); 8508 return n < i ? -1 : n > i ? 1 : 0; 8509 }); 8510 const o = Math.max(0.2 * r, s); 8511 for (let t = 0; t < e.length && e.length > 3; t++) { 8512 const n = e[t]; 8513 Math.abs(n.getEstimatedModuleSize() - r) > o && (e.splice(t, 1), t--); 8514 } 8515 } 8516 if (e.length > 3) { 8517 let t = 0; 8518 for (const r of e) t += r.getEstimatedModuleSize(); 8519 (r = t / e.length), 8520 e.sort((t, e) => { 8521 if (e.getCount() === t.getCount()) { 8522 const n = Math.abs(e.getEstimatedModuleSize() - r), 8523 i = Math.abs(t.getEstimatedModuleSize() - r); 8524 return n < i ? 1 : n > i ? -1 : 0; 8525 } 8526 return e.getCount() - t.getCount(); 8527 }), 8528 e.splice(3); 8529 } 8530 return [e[0], e[1], e[2]]; 8531 } 8532 } 8533 (ye.CENTER_QUORUM = 2), (ye.MIN_SKIP = 3), (ye.MAX_MODULES = 57); 8534 class Oe { 8535 constructor(t) { 8536 this.image = t; 8537 } 8538 getImage() { 8539 return this.image; 8540 } 8541 getResultPointCallback() { 8542 return this.resultPointCallback; 8543 } 8544 detect(t) { 8545 this.resultPointCallback = null == t ? null : t.get(C.NEED_RESULT_POINT_CALLBACK); 8546 const e = new ye(this.image, this.resultPointCallback).find(t); 8547 return this.processFinderPatternInfo(e); 8548 } 8549 processFinderPatternInfo(t) { 8550 const e = t.getTopLeft(), 8551 r = t.getTopRight(), 8552 n = t.getBottomLeft(), 8553 i = this.calculateModuleSize(e, r, n); 8554 if (i < 1) throw new R('No pattern found in proccess finder.'); 8555 const s = Oe.computeDimension(e, r, n, i), 8556 o = Ae.getProvisionalVersionForDimension(s), 8557 a = o.getDimensionForVersion() - 7; 8558 let l = null; 8559 if (o.getAlignmentPatternCenters().length > 0) { 8560 const t = r.getX() - e.getX() + n.getX(), 8561 s = r.getY() - e.getY() + n.getY(), 8562 o = 1 - 3 / a, 8563 h = Math.floor(e.getX() + o * (t - e.getX())), 8564 c = Math.floor(e.getY() + o * (s - e.getY())); 8565 for (let t = 4; t <= 16; t <<= 1) 8566 try { 8567 l = this.findAlignmentInRegion(i, h, c, t); 8568 break; 8569 } catch (t) { 8570 if (!(t instanceof R)) throw t; 8571 } 8572 } 8573 const h = Oe.createTransform(e, r, n, l, s), 8574 c = Oe.sampleGrid(this.image, h, s); 8575 let u; 8576 return (u = null === l ? [n, e, r] : [n, e, r, l]), new nt(c, u); 8577 } 8578 static createTransform(t, e, r, n, i) {
8579 const s = i - 3.5; 8580 let o, a, l, h; 8581 return ( 8582 null !== n 8583 ? ((o = n.getX()), (a = n.getY()), (l = s - 3), (h = l)) 8584 : ((o = e.getX() - t.getX() + r.getX()), (a = e.getY() - t.getY() + r.getY()), (l = s), (h = s)), 8585 at.quadrilateralToQuadrilateral( 8586 3.5, 8587 3.5, 8588 s, 8589 3.5, 8590 l, 8591 h, 8592 3.5, 8593 s, 8594 t.getX(), 8595 t.getY(), 8596 e.getX(), 8597 e.getY(), 8598 o, 8599 a, 8600 r.getX(), 8601 r.getY(), 8602 ) 8603 ); 8604 } 8605 static sampleGrid(t, e, r) { 8606 return ht.getInstance().sampleGridWithTransform(t, r, r, e); 8607 } 8608 static computeDimension(t, e, r, n) { 8609 const i = tt.round(rt.distance(t, e) / n), 8610 s = tt.round(rt.distance(t, r) / n); 8611 let o = Math.floor((i + s) / 2) + 7; 8612 switch (3 & o) { 8613 case 0: 8614 o++; 8615 break; 8616 case 2: 8617 o--; 8618 break; 8619 case 3: 8620 throw new R('Dimensions could be not found.'); 8621 } 8622 return o; 8623 } 8624 calculateModuleSize(t, e, r) { 8625 return (this.calculateModuleSizeOneWay(t, e) + this.calculateModuleSizeOneWay(t, r)) / 2; 8626 } 8627 calculateModuleSizeOneWay(t, e) { 8628 const r = this.sizeOfBlackWhiteBlackRunBothWays( 8629 Math.floor(t.getX()), 8630 Math.floor(t.getY()), 8631 Math.floor(e.getX()), 8632 Math.floor(e.getY()), 8633 ), 8634 n = this.sizeOfBlackWhiteBlackRunBothWays( 8635 Math.floor(e.getX()), 8636 Math.floor(e.getY()), 8637 Math.floor(t.getX()), 8638 Math.floor(t.getY()), 8639 ); 8640 return isNaN(r) ? n / 7 : isNaN(n) ? r / 7 : (r + n) / 14; 8641 } 8642 sizeOfBlackWhiteBlackRunBothWays(t, e, r, n) { 8643 let i = this.sizeOfBlackWhiteBlackRun(t, e, r, n), 8644 s = 1, 8645 o = t - (r - t); 8646 o < 0 8647 ? ((s = t / (t - o)), (o = 0)) 8648 : o >= this.image.getWidth() && 8649 ((s = (this.image.getWidth() - 1 - t) / (o - t)), (o = this.image.getWidth() - 1)); 8650 let a = Math.floor(e - (n - e) * s); 8651 return ( 8652 (s = 1), 8653 a < 0 8654 ? ((s = e / (e - a)), (a = 0)) 8655 : a >= this.image.getHeight() && 8656 ((s = (this.image.getHeight() - 1 - e) / (a - e)), (a = this.image.getHeight() - 1)), 8657 (o = Math.floor(t + (o - t) * s)), 8658 (i += this.sizeOfBlackWhiteBlackRun(t, e, o, a)), 8659 i - 1 8660 ); 8661 } 8662 sizeOfBlackWhiteBlackRun(t, e, r, n) { 8663 const i = Math.abs(n - e) > Math.abs(r - t); 8664 if (i) { 8665 let i = t; 8666 (t = e), (e = i), (i = r), (r = n), (n = i); 8667 } 8668 const s = Math.abs(r - t), 8669 o = Math.abs(n - e); 8670 let a = -s / 2; 8671 const l = t < r ? 1 : -1, 8672 h = e < n ? 1 : -1; 8673 let c = 0; 8674 const u = r + l; 8675 for (let r = t, d = e; r !== u; r += l) { 8676 const l = i ? d : r, 8677 u = i ? r : d; 8678 if ((1 === c) === this.image.get(l, u)) { 8679 if (2 === c) return tt.distance(r, d, t, e); 8680 c++; 8681 } 8682 if (((a += o), a > 0)) { 8683 if (d === n) break; 8684 (d += h), (a -= s); 8685 } 8686 } 8687 return 2 === c ? tt.distance(r + l, n, t, e) : NaN; 8688 } 8689 findAlignmentInRegion(t, e, r, n) { 8690 const i = Math.floor(n * t), 8691 s = Math.max(0, e - i), 8692 o = Math.min(this.image.getWidth() - 1, e + i); 8693 if (o - s < 3 * t) throw new R('Alignment top exceeds estimated module size.'); 8694 const a = Math.max(0, r - i), 8695 l = Math.min(this.image.getHeight() - 1, r + i); 8696 if (l - a < 3 * t) throw new R('Alignment bottom exceeds estimated module size.'); 8697 return new Re(this.image, s, a, o - s, l - a, t, this.resultPointCallback).find(); 8698 } 8699 } 8700 class Me { 8701 constructor() { 8702 this.decoder = new pe(); 8703 } 8704 getDecoder() { 8705 return this.decoder; 8706 } 8707 decode(t, e) { 8708 let r, n; 8709 if (null != e && void 0 !== e.get(C.PURE_BARCODE)) { 8710 const i = Me.extractPureBits(t.getBlackMatrix()); 8711 (r = this.decoder.decodeBitMatrix(i, e)), (n = Me.NO_POINTS); 8712 } else { 8713 const i = new Oe(t.getBlackMatrix()).detect(e); 8714 (r = this.decoder.decodeBitMatrix(i.getBits(), e)), (n = i.getPoints()); 8715 } 8716 r.getOther() instanceof Se && r.getOther().applyMirroredCorrection(n); 8717 const i = new F(r.getText(), r.getRawBytes(), void 0, n, v.QR_CODE, void 0), 8718 s = r.getByteSegments(); 8719 null !== s && i.putMetadata(W.BYTE_SEGMENTS, s); 8720 const o = r.getECLevel(); 8721 return ( 8722 null !== o && i.putMetadata(W.ERROR_CORRECTION_LEVEL, o),
8723 r.hasStructuredAppend() && 8724 (i.putMetadata(W.STRUCTURED_APPEND_SEQUENCE, r.getStructuredAppendSequenceNumber()), 8725 i.putMetadata(W.STRUCTURED_APPEND_PARITY, r.getStructuredAppendParity())), 8726 i 8727 ); 8728 } 8729 reset() {} 8730 static extractPureBits(t) { 8731 const e = t.getTopLeftOnBit(), 8732 r = t.getBottomRightOnBit(); 8733 if (null === e || null === r) throw new R(); 8734 const n = this.moduleSize(e, t); 8735 let i = e[1], 8736 s = r[1], 8737 o = e[0], 8738 a = r[0]; 8739 if (o >= a || i >= s) throw new R(); 8740 if (s - i != a - o && ((a = o + (s - i)), a >= t.getWidth())) throw new R(); 8741 const l = Math.round((a - o + 1) / n), 8742 h = Math.round((s - i + 1) / n); 8743 if (l <= 0 || h <= 0) throw new R(); 8744 if (h !== l) throw new R(); 8745 const c = Math.floor(n / 2); 8746 (i += c), (o += c); 8747 const u = o + Math.floor((l - 1) * n) - a; 8748 if (u > 0) { 8749 if (u > c) throw new R(); 8750 o -= u; 8751 } 8752 const d = i + Math.floor((h - 1) * n) - s; 8753 if (d > 0) { 8754 if (d > c) throw new R(); 8755 i -= d; 8756 } 8757 const g = new T(l, h); 8758 for (let e = 0; e < h; e++) { 8759 const r = i + Math.floor(e * n); 8760 for (let i = 0; i < l; i++) t.get(o + Math.floor(i * n), r) && g.set(i, e); 8761 } 8762 return g; 8763 } 8764 static moduleSize(t, e) { 8765 const r = e.getHeight(), 8766 n = e.getWidth(); 8767 let i = t[0], 8768 s = t[1], 8769 o = !0, 8770 a = 0; 8771 for (; i < n && s < r; ) { 8772 if (o !== e.get(i, s)) { 8773 if (5 == ++a) break; 8774 o = !o; 8775 } 8776 i++, s++; 8777 } 8778 if (i === n || s === r) throw new R(); 8779 return (i - t[0]) / 7; 8780 } 8781 } 8782 Me.NO_POINTS = new Array(); 8783 class Be { 8784 PDF417Common() {} 8785 static getBitCountSum(t) { 8786 return tt.sum(t); 8787 } 8788 static toIntArray(t) { 8789 if (null == t || !t.length) return Be.EMPTY_INT_ARRAY; 8790 const e = new Int32Array(t.length); 8791 let r = 0; 8792 for (const n of t) e[r++] = n; 8793 return e; 8794 } 8795 static getCodeword(t) { 8796 const e = g.binarySearch(Be.SYMBOL_TABLE, 262143 & t); 8797 return e < 0 ? -1 : (Be.CODEWORD_TABLE[e] - 1) % Be.NUMBER_OF_CODEWORDS; 8798 } 8799 } 8800 (Be.NUMBER_OF_CODEWORDS = 929), 8801 (Be.MAX_CODEWORDS_IN_BARCODE = Be.NUMBER_OF_CODEWORDS - 1), 8802 (Be.MIN_ROWS_IN_BARCODE = 3), 8803 (Be.MAX_ROWS_IN_BARCODE = 90), 8804 (Be.MODULES_IN_CODEWORD = 17), 8805 (Be.MODULES_IN_STOP_PATTERN = 18), 8806 (Be.BARS_IN_MODULE = 8), 8807 (Be.EMPTY_INT_ARRAY = new Int32Array([])), 8808 (Be.SYMBOL_TABLE = Int32Array.from([ 8809 66142, 66170, 66206, 66236, 66290, 66292, 66350, 66382, 66396, 66454, 66470, 66476, 66594, 66600, 66614, 66626, 8810 66628, 66632, 66640, 66654, 66662, 66668, 66682, 66690, 66718, 66720, 66748, 66758, 66776, 66798, 66802, 66804, 8811 66820, 66824, 66832, 66846, 66848, 66876, 66880, 66936, 66950, 66956, 66968, 66992, 67006, 67022, 67036, 67042, 8812 67044, 67048, 67062, 67118, 67150, 67164, 67214, 67228, 67256, 67294, 67322, 67350, 67366, 67372, 67398, 67404, 8813 67416, 67438, 67474, 67476, 67490, 67492, 67496, 67510, 67618, 67624, 67650, 67656, 67664, 67678, 67686, 67692, 8814 67706, 67714, 67716, 67728, 67742, 67744, 67772, 67782, 67788, 67800, 67822, 67826, 67828, 67842, 67848, 67870, 8815 67872, 67900, 67904, 67960, 67974, 67992, 68016, 68030, 68046, 68060, 68066, 68068, 68072, 68086, 68104, 68112, 8816 68126, 68128, 68156, 68160, 68216, 68336, 68358, 68364, 68376, 68400, 68414, 68448, 68476, 68494, 68508, 68536, 8817 68546, 68548, 68552, 68560, 68574, 68582, 68588, 68654, 68686, 68700, 68706, 68708, 68712, 68726, 68750, 68764, 8818 68792, 68802, 68804, 68808, 68816, 68830, 68838, 68844, 68858, 68878, 68892, 68920, 68976, 68990, 68994, 68996, 8819 69e3, 69008, 69022, 69024, 69052, 69062, 69068, 69080, 69102, 69106, 69108, 69142, 69158, 69164, 69190, 69208, 8820 69230, 69254, 69260, 69272, 69296, 69310, 69326, 69340, 69386, 69394, 69396, 69410, 69416, 69430, 69442, 69444, 8821 69448, 69456, 69470, 69478, 69484, 69554, 69556, 69666, 69672, 69698, 69704, 69712, 69726, 69754, 69762, 69764, 8822 69776, 69790, 69792, 69820, 69830, 69836, 69848, 69870, 69874, 69876, 69890, 69918, 69920, 69948, 69952, 70008, 8823 70022, 70040, 70064, 70078, 70094, 70108, 70114, 70116, 70120, 70134, 70152, 70174, 70176, 70264, 70384, 70412, 8824 70448, 70462, 70496, 70524, 70542, 70556, 70584, 70594, 70600, 70608, 70622, 70630, 70636, 70664, 70672, 70686, 8825 70688, 70716, 70720, 70776, 70896, 71136, 71180, 71192, 71216, 71230, 71264, 71292, 71360, 71416, 71452, 71480, 8826 71536, 71550, 71554, 71556, 71560, 71568, 71582, 71584, 71612, 71622, 71628, 71640, 71662, 71726, 71732, 71758, 8827 71772, 71778, 71780, 71784, 71798, 71822, 71836, 71864, 71874, 71880, 71888, 71902, 71910, 71916, 71930, 71950, 8828 71964, 71992, 72048, 72062, 72066, 72068, 72080, 72094, 72096, 72124, 72134, 72140, 72152, 72174, 72178, 72180, 8829 72206, 72220, 72248, 72304, 72318, 72416, 72444, 72456, 72464, 72478, 72480, 72508, 72512, 72568, 72588, 72600, 8830 72624, 72638, 72654, 72668, 72674, 72676, 72680, 72694, 72726, 72742, 72748, 72774, 72780, 72792, 72814, 72838, 8831 72856, 72880, 72894, 72910, 72924, 72930, 72932, 72936, 72950, 72966, 72972, 72984, 73008, 73022, 73056, 73084, 8832 73102, 73116, 73144, 73156, 73160, 73168, 73182, 73190, 73196, 73210, 73226, 73234, 73236, 73250, 73252, 73256, 8833 73270, 73282, 73284, 73296, 73310, 73318, 73324, 73346, 73348, 73352, 73360, 73374, 73376, 73404, 73414, 73420, 8834 73432, 73454, 73498, 73518, 73522, 73524, 73550, 73564, 73570, 73572, 73576, 73590, 73800, 73822, 73858, 73860, 8835 73872, 73886, 73888, 73916, 73944, 73970, 73972, 73992, 74014, 74016, 74044, 74048, 74104, 74118, 74136, 74160, 8836 74174, 74210, 74212, 74216, 74230, 74244, 74256, 74270, 74272, 74360, 74480, 74502, 74508, 74544, 74558, 74592, 8837 74620, 74638, 74652, 74680, 74690, 74696, 74704, 74726, 74732, 74782, 74784, 74812, 74992, 75232, 75288, 75326, 8838 75360, 75388, 75456, 75512, 75576, 75632, 75646, 75650, 75652, 75664, 75678, 75680, 75708, 75718, 75724, 75736, 8839 75758, 75808, 75836, 75840, 75896, 76016, 76256, 76736, 76824, 76848, 76862, 76896, 76924, 76992, 77048, 77296, 8840 77340, 77368, 77424, 77438, 77536, 77564, 77572, 77576, 77584, 77600, 77628, 77632, 77688, 77702, 77708, 77720, 8841 77744, 77758, 77774, 77788, 77870, 77902, 77916, 77922, 77928, 77966, 77980, 78008, 78018, 78024, 78032, 78046, 8842 78060, 78074, 78094, 78136, 78192, 78206, 78210, 78212, 78224, 78238, 78240, 78268, 78278, 78284, 78296, 78322, 8843 78324, 78350, 78364, 78448, 78462, 78560, 78588, 78600, 78622, 78624, 78652, 78656, 78712, 78726, 78744, 78768,
8844 78782, 78798, 78812, 78818, 78820, 78824, 78838, 78862, 78876, 78904, 78960, 78974, 79072, 79100, 79296, 79352, 8845 79368, 79376, 79390, 79392, 79420, 79424, 79480, 79600, 79628, 79640, 79664, 79678, 79712, 79740, 79772, 79800, 8846 79810, 79812, 79816, 79824, 79838, 79846, 79852, 79894, 79910, 79916, 79942, 79948, 79960, 79982, 79988, 80006, 8847 80024, 80048, 80062, 80078, 80092, 80098, 80100, 80104, 80134, 80140, 80176, 80190, 80224, 80252, 80270, 80284, 8848 80312, 80328, 80336, 80350, 80358, 80364, 80378, 80390, 80396, 80408, 80432, 80446, 80480, 80508, 80576, 80632, 8849 80654, 80668, 80696, 80752, 80766, 80776, 80784, 80798, 80800, 80828, 80844, 80856, 80878, 80882, 80884, 80914, 8850 80916, 80930, 80932, 80936, 80950, 80962, 80968, 80976, 80990, 80998, 81004, 81026, 81028, 81040, 81054, 81056, 8851 81084, 81094, 81100, 81112, 81134, 81154, 81156, 81160, 81168, 81182, 81184, 81212, 81216, 81272, 81286, 81292, 8852 81304, 81328, 81342, 81358, 81372, 81380, 81384, 81398, 81434, 81454, 81458, 81460, 81486, 81500, 81506, 81508, 8853 81512, 81526, 81550, 81564, 81592, 81602, 81604, 81608, 81616, 81630, 81638, 81644, 81702, 81708, 81722, 81734, 8854 81740, 81752, 81774, 81778, 81780, 82050, 82078, 82080, 82108, 82180, 82184, 82192, 82206, 82208, 82236, 82240, 8855 82296, 82316, 82328, 82352, 82366, 82402, 82404, 82408, 82440, 82448, 82462, 82464, 82492, 82496, 82552, 82672, 8856 82694, 82700, 82712, 82736, 82750, 82784, 82812, 82830, 82882, 82884, 82888, 82896, 82918, 82924, 82952, 82960, 8857 82974, 82976, 83004, 83008, 83064, 83184, 83424, 83468, 83480, 83504, 83518, 83552, 83580, 83648, 83704, 83740, 8858 83768, 83824, 83838, 83842, 83844, 83848, 83856, 83872, 83900, 83910, 83916, 83928, 83950, 83984, 84e3, 84028, 8859 84032, 84088, 84208, 84448, 84928, 85040, 85054, 85088, 85116, 85184, 85240, 85488, 85560, 85616, 85630, 85728, 8860 85756, 85764, 85768, 85776, 85790, 85792, 85820, 85824, 85880, 85894, 85900, 85912, 85936, 85966, 85980, 86048, 8861 86080, 86136, 86256, 86496, 86976, 88160, 88188, 88256, 88312, 88560, 89056, 89200, 89214, 89312, 89340, 89536, 8862 89592, 89608, 89616, 89632, 89664, 89720, 89840, 89868, 89880, 89904, 89952, 89980, 89998, 90012, 90040, 90190, 8863 90204, 90254, 90268, 90296, 90306, 90308, 90312, 90334, 90382, 90396, 90424, 90480, 90494, 90500, 90504, 90512, 8864 90526, 90528, 90556, 90566, 90572, 90584, 90610, 90612, 90638, 90652, 90680, 90736, 90750, 90848, 90876, 90884, 8865 90888, 90896, 90910, 90912, 90940, 90944, 91e3, 91014, 91020, 91032, 91056, 91070, 91086, 91100, 91106, 91108, 8866 91112, 91126, 91150, 91164, 91192, 91248, 91262, 91360, 91388, 91584, 91640, 91664, 91678, 91680, 91708, 91712, 8867 91768, 91888, 91928, 91952, 91966, 92e3, 92028, 92046, 92060, 92088, 92098, 92100, 92104, 92112, 92126, 92134, 8868 92140, 92188, 92216, 92272, 92384, 92412, 92608, 92664, 93168, 93200, 93214, 93216, 93244, 93248, 93304, 93424, 8869 93664, 93720, 93744, 93758, 93792, 93820, 93888, 93944, 93980, 94008, 94064, 94078, 94084, 94088, 94096, 94110, 8870 94112, 94140, 94150, 94156, 94168, 94246, 94252, 94278, 94284, 94296, 94318, 94342, 94348, 94360, 94384, 94398, 8871 94414, 94428, 94440, 94470, 94476, 94488, 94512, 94526, 94560, 94588, 94606, 94620, 94648, 94658, 94660, 94664, 8872 94672, 94686, 94694, 94700, 94714, 94726, 94732, 94744, 94768, 94782, 94816, 94844, 94912, 94968, 94990, 95004, 8873 95032, 95088, 95102, 95112, 95120, 95134, 95136, 95164, 95180, 95192, 95214, 95218, 95220, 95244, 95256, 95280, 8874 95294, 95328, 95356, 95424, 95480, 95728, 95758, 95772, 95800, 95856, 95870, 95968, 95996, 96008, 96016, 96030, 8875 96032, 96060, 96064, 96120, 96152, 96176, 96190, 96220, 96226, 96228, 96232, 96290, 96292, 96296, 96310, 96322, 8876 96324, 96328, 96336, 96350, 96358, 96364, 96386, 96388, 96392, 96400, 96414, 96416, 96444, 96454, 96460, 96472, 8877 96494, 96498, 96500, 96514, 96516, 96520, 96528, 96542, 96544, 96572, 96576, 96632, 96646, 96652, 96664, 96688, 8878 96702, 96718, 96732, 96738, 96740, 96744, 96758, 96772, 96776, 96784, 96798, 96800, 96828, 96832, 96888, 97008, 8879 97030, 97036, 97048, 97072, 97086, 97120, 97148, 97166, 97180, 97208, 97220, 97224, 97232, 97246, 97254, 97260,
8880 97326, 97330, 97332, 97358, 97372, 97378, 97380, 97384, 97398, 97422, 97436, 97464, 97474, 97476, 97480, 97488, 8881 97502, 97510, 97516, 97550, 97564, 97592, 97648, 97666, 97668, 97672, 97680, 97694, 97696, 97724, 97734, 97740, 8882 97752, 97774, 97830, 97836, 97850, 97862, 97868, 97880, 97902, 97906, 97908, 97926, 97932, 97944, 97968, 97998, 8883 98012, 98018, 98020, 98024, 98038, 98618, 98674, 98676, 98838, 98854, 98874, 98892, 98904, 98926, 98930, 98932, 8884 98968, 99006, 99042, 99044, 99048, 99062, 99166, 99194, 99246, 99286, 99350, 99366, 99372, 99386, 99398, 99416, 8885 99438, 99442, 99444, 99462, 99504, 99518, 99534, 99548, 99554, 99556, 99560, 99574, 99590, 99596, 99608, 99632, 8886 99646, 99680, 99708, 99726, 99740, 99768, 99778, 99780, 99784, 99792, 99806, 99814, 99820, 99834, 99858, 99860, 8887 99874, 99880, 99894, 99906, 99920, 99934, 99962, 99970, 99972, 99976, 99984, 99998, 1e5, 100028, 100038, 100044, 8888 100056, 100078, 100082, 100084, 100142, 100174, 100188, 100246, 100262, 100268, 100306, 100308, 100390, 100396, 8889 100410, 100422, 100428, 100440, 100462, 100466, 100468, 100486, 100504, 100528, 100542, 100558, 100572, 100578, 8890 100580, 100584, 100598, 100620, 100656, 100670, 100704, 100732, 100750, 100792, 100802, 100808, 100816, 100830, 8891 100838, 100844, 100858, 100888, 100912, 100926, 100960, 100988, 101056, 101112, 101148, 101176, 101232, 101246, 8892 101250, 101252, 101256, 101264, 101278, 101280, 101308, 101318, 101324, 101336, 101358, 101362, 101364, 101410, 8893 101412, 101416, 101430, 101442, 101448, 101456, 101470, 101478, 101498, 101506, 101508, 101520, 101534, 101536, 8894 101564, 101580, 101618, 101620, 101636, 101640, 101648, 101662, 101664, 101692, 101696, 101752, 101766, 101784, 8895 101838, 101858, 101860, 101864, 101934, 101938, 101940, 101966, 101980, 101986, 101988, 101992, 102030, 102044, 8896 102072, 102082, 102084, 102088, 102096, 102138, 102166, 102182, 102188, 102214, 102220, 102232, 102254, 102282, 8897 102290, 102292, 102306, 102308, 102312, 102326, 102444, 102458, 102470, 102476, 102488, 102514, 102516, 102534, 8898 102552, 102576, 102590, 102606, 102620, 102626, 102632, 102646, 102662, 102668, 102704, 102718, 102752, 102780, 8899 102798, 102812, 102840, 102850, 102856, 102864, 102878, 102886, 102892, 102906, 102936, 102974, 103008, 103036, 8900 103104, 103160, 103224, 103280, 103294, 103298, 103300, 103312, 103326, 103328, 103356, 103366, 103372, 103384, 8901 103406, 103410, 103412, 103472, 103486, 103520, 103548, 103616, 103672, 103920, 103992, 104048, 104062, 104160, 8902 104188, 104194, 104196, 104200, 104208, 104224, 104252, 104256, 104312, 104326, 104332, 104344, 104368, 104382, 8903 104398, 104412, 104418, 104420, 104424, 104482, 104484, 104514, 104520, 104528, 104542, 104550, 104570, 104578, 8904 104580, 104592, 104606, 104608, 104636, 104652, 104690, 104692, 104706, 104712, 104734, 104736, 104764, 104768, 8905 104824, 104838, 104856, 104910, 104930, 104932, 104936, 104968, 104976, 104990, 104992, 105020, 105024, 105080, 8906 105200, 105240, 105278, 105312, 105372, 105410, 105412, 105416, 105424, 105446, 105518, 105524, 105550, 105564, 8907 105570, 105572, 105576, 105614, 105628, 105656, 105666, 105672, 105680, 105702, 105722, 105742, 105756, 105784, 8908 105840, 105854, 105858, 105860, 105864, 105872, 105888, 105932, 105970, 105972, 106006, 106022, 106028, 106054, 8909 106060, 106072, 106100, 106118, 106124, 106136, 106160, 106174, 106190, 106210, 106212, 106216, 106250, 106258, 8910 106260, 106274, 106276, 106280, 106306, 106308, 106312, 106320, 106334, 106348, 106394, 106414, 106418, 106420, 8911 106566, 106572, 106610, 106612, 106630, 106636, 106648, 106672, 106686, 106722, 106724, 106728, 106742, 106758, 8912 106764, 106776, 106800, 106814, 106848, 106876, 106894, 106908, 106936, 106946, 106948, 106952, 106960, 106974, 8913 106982, 106988, 107032, 107056, 107070, 107104, 107132, 107200, 107256, 107292, 107320, 107376, 107390, 107394, 8914 107396, 107400, 107408, 107422, 107424, 107452, 107462, 107468, 107480, 107502, 107506, 107508, 107544, 107568,
8915 107582, 107616, 107644, 107712, 107768, 108016, 108060, 108088, 108144, 108158, 108256, 108284, 108290, 108292, 8916 108296, 108304, 108318, 108320, 108348, 108352, 108408, 108422, 108428, 108440, 108464, 108478, 108494, 108508, 8917 108514, 108516, 108520, 108592, 108640, 108668, 108736, 108792, 109040, 109536, 109680, 109694, 109792, 109820, 8918 110016, 110072, 110084, 110088, 110096, 110112, 110140, 110144, 110200, 110320, 110342, 110348, 110360, 110384, 8919 110398, 110432, 110460, 110478, 110492, 110520, 110532, 110536, 110544, 110558, 110658, 110686, 110714, 110722, 8920 110724, 110728, 110736, 110750, 110752, 110780, 110796, 110834, 110836, 110850, 110852, 110856, 110864, 110878, 8921 110880, 110908, 110912, 110968, 110982, 111e3, 111054, 111074, 111076, 111080, 111108, 111112, 111120, 111134, 8922 111136, 111164, 111168, 111224, 111344, 111372, 111422, 111456, 111516, 111554, 111556, 111560, 111568, 111590, 8923 111632, 111646, 111648, 111676, 111680, 111736, 111856, 112096, 112152, 112224, 112252, 112320, 112440, 112514, 8924 112516, 112520, 112528, 112542, 112544, 112588, 112686, 112718, 112732, 112782, 112796, 112824, 112834, 112836, 8925 112840, 112848, 112870, 112890, 112910, 112924, 112952, 113008, 113022, 113026, 113028, 113032, 113040, 113054, 8926 113056, 113100, 113138, 113140, 113166, 113180, 113208, 113264, 113278, 113376, 113404, 113416, 113424, 113440, 8927 113468, 113472, 113560, 113614, 113634, 113636, 113640, 113686, 113702, 113708, 113734, 113740, 113752, 113778, 8928 113780, 113798, 113804, 113816, 113840, 113854, 113870, 113890, 113892, 113896, 113926, 113932, 113944, 113968, 8929 113982, 114016, 114044, 114076, 114114, 114116, 114120, 114128, 114150, 114170, 114194, 114196, 114210, 114212, 8930 114216, 114242, 114244, 114248, 114256, 114270, 114278, 114306, 114308, 114312, 114320, 114334, 114336, 114364, 8931 114380, 114420, 114458, 114478, 114482, 114484, 114510, 114524, 114530, 114532, 114536, 114842, 114866, 114868, 8932 114970, 114994, 114996, 115042, 115044, 115048, 115062, 115130, 115226, 115250, 115252, 115278, 115292, 115298, 8933 115300, 115304, 115318, 115342, 115394, 115396, 115400, 115408, 115422, 115430, 115436, 115450, 115478, 115494, 8934 115514, 115526, 115532, 115570, 115572, 115738, 115758, 115762, 115764, 115790, 115804, 115810, 115812, 115816, 8935 115830, 115854, 115868, 115896, 115906, 115912, 115920, 115934, 115942, 115948, 115962, 115996, 116024, 116080, 8936 116094, 116098, 116100, 116104, 116112, 116126, 116128, 116156, 116166, 116172, 116184, 116206, 116210, 116212, 8937 116246, 116262, 116268, 116282, 116294, 116300, 116312, 116334, 116338, 116340, 116358, 116364, 116376, 116400, 8938 116414, 116430, 116444, 116450, 116452, 116456, 116498, 116500, 116514, 116520, 116534, 116546, 116548, 116552, 8939 116560, 116574, 116582, 116588, 116602, 116654, 116694, 116714, 116762, 116782, 116786, 116788, 116814, 116828, 8940 116834, 116836, 116840, 116854, 116878, 116892, 116920, 116930, 116936, 116944, 116958, 116966, 116972, 116986, 8941 117006, 117048, 117104, 117118, 117122, 117124, 117136, 117150, 117152, 117180, 117190, 117196, 117208, 117230, 8942 117234, 117236, 117304, 117360, 117374, 117472, 117500, 117506, 117508, 117512, 117520, 117536, 117564, 117568, 8943 117624, 117638, 117644, 117656, 117680, 117694, 117710, 117724, 117730, 117732, 117736, 117750, 117782, 117798, 8944 117804, 117818, 117830, 117848, 117874, 117876, 117894, 117936, 117950, 117966, 117986, 117988, 117992, 118022, 8945 118028, 118040, 118064, 118078, 118112, 118140, 118172, 118210, 118212, 118216, 118224, 118238, 118246, 118266, 8946 118306, 118312, 118338, 118352, 118366, 118374, 118394, 118402, 118404, 118408, 118416, 118430, 118432, 118460, 8947 118476, 118514, 118516, 118574, 118578, 118580, 118606, 118620, 118626, 118628, 118632, 118678, 118694, 118700, 8948 118730, 118738, 118740, 118830, 118834, 118836, 118862, 118876, 118882, 118884, 118888, 118902, 118926, 118940, 8949 118968, 118978, 118980, 118984, 118992, 119006, 119014, 119020, 119034, 119068, 119096, 119152, 119166, 119170, 8950 119172, 119176, 119184, 119198, 119200, 119228, 119238, 119244, 119256, 119278,
8950119282, 119284, 119324, 119352, 8951 119408, 119422, 119520, 119548, 119554, 119556, 119560, 119568, 119582, 119584, 119612, 119616, 119672, 119686, 8952 119692, 119704, 119728, 119742, 119758, 119772, 119778, 119780, 119784, 119798, 119920, 119934, 120032, 120060, 8953 120256, 120312, 120324, 120328, 120336, 120352, 120384, 120440, 120560, 120582, 120588, 120600, 120624, 120638, 8954 120672, 120700, 120718, 120732, 120760, 120770, 120772, 120776, 120784, 120798, 120806, 120812, 120870, 120876, 8955 120890, 120902, 120908, 120920, 120946, 120948, 120966, 120972, 120984, 121008, 121022, 121038, 121058, 121060, 8956 121064, 121078, 121100, 121112, 121136, 121150, 121184, 121212, 121244, 121282, 121284, 121288, 121296, 121318, 8957 121338, 121356, 121368, 121392, 121406, 121440, 121468, 121536, 121592, 121656, 121730, 121732, 121736, 121744, 8958 121758, 121760, 121804, 121842, 121844, 121890, 121922, 121924, 121928, 121936, 121950, 121958, 121978, 121986, 8959 121988, 121992, 122e3, 122014, 122016, 122044, 122060, 122098, 122100, 122116, 122120, 122128, 122142, 122144, 8960 122172, 122176, 122232, 122246, 122264, 122318, 122338, 122340, 122344, 122414, 122418, 122420, 122446, 122460, 8961 122466, 122468, 122472, 122510, 122524, 122552, 122562, 122564, 122568, 122576, 122598, 122618, 122646, 122662, 8962 122668, 122694, 122700, 122712, 122738, 122740, 122762, 122770, 122772, 122786, 122788, 122792, 123018, 123026, 8963 123028, 123042, 123044, 123048, 123062, 123098, 123146, 123154, 123156, 123170, 123172, 123176, 123190, 123202, 8964 123204, 123208, 123216, 123238, 123244, 123258, 123290, 123314, 123316, 123402, 123410, 123412, 123426, 123428, 8965 123432, 123446, 123458, 123464, 123472, 123486, 123494, 123500, 123514, 123522, 123524, 123528, 123536, 123552, 8966 123580, 123590, 123596, 123608, 123630, 123634, 123636, 123674, 123698, 123700, 123740, 123746, 123748, 123752, 8967 123834, 123914, 123922, 123924, 123938, 123944, 123958, 123970, 123976, 123984, 123998, 124006, 124012, 124026, 8968 124034, 124036, 124048, 124062, 124064, 124092, 124102, 124108, 124120, 124142, 124146, 124148, 124162, 124164, 8969 124168, 124176, 124190, 124192, 124220, 124224, 124280, 124294, 124300, 124312, 124336, 124350, 124366, 124380, 8970 124386, 124388, 124392, 124406, 124442, 124462, 124466, 124468, 124494, 124508, 124514, 124520, 124558, 124572, 8971 124600, 124610, 124612, 124616, 124624, 124646, 124666, 124694, 124710, 124716, 124730, 124742, 124748, 124760, 8972 124786, 124788, 124818, 124820, 124834, 124836, 124840, 124854, 124946, 124948, 124962, 124964, 124968, 124982, 8973 124994, 124996, 125e3, 125008, 125022, 125030, 125036, 125050, 125058, 125060, 125064, 125072, 125086, 125088, 8974 125116, 125126, 125132, 125144, 125166, 125170, 125172, 125186, 125188, 125192, 125200, 125216, 125244, 125248, 8975 125304, 125318, 125324, 125336, 125360, 125374, 125390, 125404, 125410, 125412, 125416, 125430, 125444, 125448, 8976 125456, 125472, 125504, 125560, 125680, 125702, 125708, 12572
89760, 125744, 125758, 125792, 125820, 125838, 125852, 8977 125880, 125890, 125892, 125896, 125904, 125918, 125926, 125932, 125978, 125998, 126002, 126004, 126030, 126044, 8978 126050, 126052, 126056, 126094, 126108, 126136, 126146, 126148, 126152, 126160, 126182, 126202, 126222, 126236, 8979 126264, 126320, 126334, 126338, 126340, 126344, 126352, 126366, 126368, 126412, 126450, 126452, 126486, 126502, 8980 126508, 126522, 126534, 126540, 126552, 126574, 126578, 126580, 126598, 126604, 126616, 126640, 126654, 126670, 8981 126684, 126690, 126692, 126696, 126738, 126754, 126756, 126760, 126774, 126786, 126788, 126792, 126800, 126814, 8982 126822, 126828, 126842, 126894, 126898, 126900, 126934, 127126, 127142, 127148, 127162, 127178, 127186, 127188, 8983 127254, 127270, 127276, 127290, 127302, 127308, 127320, 127342, 127346, 127348, 127370, 127378, 127380, 127394, 8984 127396, 127400, 127450, 127510, 127526, 127532, 127546, 127558, 127576, 127598, 127602, 127604, 127622, 127628, 8985 127640, 127664, 127678, 127694, 127708, 127714, 127716, 127720, 127734, 127754, 127762, 127764, 127778, 127784, 8986 127810, 127812, 127816, 127824, 127838, 127846, 127866, 127898, 127918, 127922, 127924, 128022, 128038, 128044, 8987 128058, 128070, 128076, 128088, 128110, 128114, 128116, 128134, 128140, 128152, 128176, 128190, 128206, 128220, 8988 128226, 128228, 128232, 128246, 128262, 128268, 128280, 128304, 128318, 128352, 128380, 128398, 128412, 128440, 8989 128450, 128452, 128456, 128464, 128478, 128486, 128492, 128506, 128522, 128530, 128532, 128546, 128548, 128552, 8990 128566, 128578, 128580, 128584, 128592, 128606, 128614, 128634, 128642, 128644, 128648, 128656, 128670, 128672, 8991 128700, 128716, 128754, 128756, 128794, 128814, 128818, 128820, 128846, 128860, 128866, 128868, 128872, 128886, 8992 128918, 128934, 128940, 128954, 128978, 128980, 129178, 129198, 129202, 129204, 129238, 129258, 129306, 129326, 8993 129330, 129332, 129358, 129372, 129378, 129380, 129384, 129398, 129430, 129446, 129452, 129466, 129482, 129490, 8994 129492, 129562, 129582, 129586, 129588, 129614, 129628, 129634, 129636, 129640, 129654, 129678, 129692, 129720, 8995 129730, 129732, 129736, 129744, 129758, 129766, 129772, 129814, 129830, 129836, 129850, 129862, 129868, 129880, 8996 129902, 129906, 129908, 129930, 129938, 129940, 129954, 129956, 129960, 129974, 130010, 8997 ])), 8998 (Be.CODEWORD_TABLE = Int32Array.from([ 8999 2627, 1819, 2622, 2621, 1813, 1812, 2729, 2724, 2723, 2779, 2774, 2773, 902, 896, 908, 868, 865, 861, 859, 2511, 9000 873, 871, 1780, 835, 2493, 825, 2491, 842, 837, 844, 1764, 1762, 811, 810, 809, 2483, 807, 2482, 806, 2480, 815, 9001 814, 813, 812, 2484, 817, 816, 1745, 1744, 1742, 1746, 2655, 2637, 2635, 2626, 2625, 2623, 2628, 1820, 2752, 2739, 9002 2737, 2728, 2727, 2725, 2730, 2785, 2783, 2778, 2777, 2775, 2780, 787, 781, 747, 739, 736, 2413, 754, 752, 1719,
9003 692, 689, 681, 2371, 678, 2369, 700, 697, 694, 703, 1688, 1686, 642, 638, 2343, 631, 2341, 627, 2338, 651, 646, 9004 643, 2345, 654, 652, 1652, 1650, 1647, 1654, 601, 599, 2322, 596, 2321, 594, 2319, 2317, 611, 610, 608, 606, 2324, 9005 603, 2323, 615, 614, 612, 1617, 1616, 1614, 1612, 616, 1619, 1618, 2575, 2538, 2536, 905, 901, 898, 909, 2509, 9006 2507, 2504, 870, 867, 864, 860, 2512, 875, 872, 1781, 2490, 2489, 2487, 2485, 1748, 836, 834, 832, 830, 2494, 827, 9007 2492, 843, 841, 839, 845, 1765, 1763, 2701, 2676, 2674, 2653, 2648, 2656, 2634, 2633, 2631, 2629, 1821, 2638, 9008 2636, 2770, 2763, 2761, 2750, 2745, 2753, 2736, 2735, 2733, 2731, 1848, 2740, 2738, 2786, 2784, 591, 588, 576, 9009 569, 566, 2296, 1590, 537, 534, 526, 2276, 522, 2274, 545, 542, 539, 548, 1572, 1570, 481, 2245, 466, 2242, 462, 9010 2239, 492, 485, 482, 2249, 496, 494, 1534, 1531, 1528, 1538, 413, 2196, 406, 2191, 2188, 425, 419, 2202, 415, 9011 2199, 432, 430, 427, 1472, 1467, 1464, 433, 1476, 1474, 368, 367, 2160, 365, 2159, 362, 2157, 2155, 2152, 378, 9012 377, 375, 2166, 372, 2165, 369, 2162, 383, 381, 379, 2168, 1419, 1418, 1416, 1414, 385, 1411, 384, 1423, 1422, 9013 1420, 1424, 2461, 802, 2441, 2439, 790, 786, 783, 794, 2409, 2406, 2403, 750, 742, 738, 2414, 756, 753, 1720, 9014 2367, 2365, 2362, 2359, 1663, 693, 691, 684, 2373, 680, 2370, 702, 699, 696, 704, 1690, 1687, 2337, 2336, 2334, 9015 2332, 1624, 2329, 1622, 640, 637, 2344, 634, 2342, 630, 2340, 650, 648, 645, 2346, 655, 653, 1653, 1651, 1649, 9016 1655, 2612, 2597, 2595, 2571, 2568, 2565, 2576, 2534, 2529, 2526, 1787, 2540, 2537, 907, 904, 900, 910, 2503, 9017 2502, 2500, 2498, 1768, 2495, 1767, 2510, 2508, 2506, 869, 866, 863, 2513, 876, 874, 1782, 2720, 2713, 2711, 2697, 9018 2694, 2691, 2702, 2672, 2670, 2664, 1828, 2678, 2675, 2647, 2646, 2644, 2642, 1823, 2639, 1822, 2654, 2652, 2650, 9019 2657, 2771, 1855, 2765, 2762, 1850, 1849, 2751, 2749, 2747, 2754, 353, 2148, 344, 342, 336, 2142, 332, 2140, 345, 9020 1375, 1373, 306, 2130, 299, 2128, 295, 2125, 319, 314, 311, 2132, 1354, 1352, 1349, 1356, 262, 257, 2101, 253, 9021 2096, 2093, 274, 273, 267, 2107, 263, 2104, 280, 278, 275, 1316, 1311, 1308, 1320, 1318, 2052, 202, 2050, 2044, 9022 2040, 219, 2063, 212, 2060, 208, 2055, 224, 221, 2066, 1260, 1258, 1252, 231, 1248, 229, 1266, 1264, 1261, 1268, 9023 155, 1998, 153, 1996, 1994, 1991, 1988, 165, 164, 2007, 162, 2006, 159, 2003, 2e3, 172, 171, 169, 2012, 166, 2010, 9024 1186, 1184, 1182, 1179, 175, 1176, 173, 1192, 1191, 1189, 1187, 176, 1194, 1193, 2313, 2307, 2305, 592, 589, 2294, 9025 2292, 2289, 578, 572, 568, 2297, 580, 1591, 2272, 2267, 2264, 1547, 538, 536, 529, 2278, 525, 2275, 547, 544, 541, 9026 1574, 1571, 2237, 2235, 2229, 1493, 2225, 1489, 478, 2247, 470, 2244, 465, 2241, 493, 488, 484, 2250, 498, 495, 9027 1536, 1533, 1530, 1539, 2187, 2186, 2184, 2182, 1432, 2179, 1430, 2176, 1427, 414, 412, 2197, 409, 2195, 405, 9028 2193, 2190, 426, 424, 421, 2203, 418, 2201, 431, 429, 1473, 1471, 1469, 1466, 434, 1477, 1475, 2478, 2472, 2470, 9029 2459, 2457, 2454, 2462, 803, 2437, 2432, 2429, 1726, 2443, 2440, 792, 789, 785, 2401, 2399, 2393, 1702, 2389, 9030 1699, 2411, 2408, 2405, 745, 741, 2415, 758, 755, 1721, 2358, 2357, 2355, 2353, 1661, 2350, 1660, 2347, 1657, 9031 2368, 2366, 2364, 2361, 1666, 690, 687, 2374, 683, 2372, 701, 698, 705, 1691, 1689, 2619, 2617, 2610, 2608, 2605, 9032 2613, 2593, 2588, 2585, 1803, 2599, 2596, 2563, 2561, 2555, 1797, 2551, 1795, 2573, 2570, 2567, 2577, 2525, 2524, 9033 2522, 2520, 1786, 2517, 1785, 2514, 1783, 2535, 2533, 2531, 2528, 1788, 2541, 2539, 906, 903, 911, 2721, 1844, 9034 2715, 2712, 1838, 1836, 2699, 2696, 2693, 2703, 1827, 1826, 1824, 2673, 2671, 2669, 2666, 1829, 2679, 2677, 1858, 9035 1857, 2772, 1854, 1853, 1851, 1856, 2766, 2764, 143, 1987, 139, 1986, 135, 133, 131, 1984, 128, 1983, 125, 1981, 9036 138, 137, 136, 1985, 1133, 1132, 1130, 112, 110, 1974, 107, 1973, 104, 1971, 1969, 122, 121, 119, 117, 1977, 114, 9037 1976, 124, 1115, 1114, 1112, 1110, 1117, 1116, 84, 83, 1953, 81, 1952, 78, 1950, 1948, 1945, 94, 93, 91, 1959, 88, 9038 1958, 85, 1955, 99, 97, 95, 1961, 1086, 1085, 1083, 1081, 1078, 100, 1090, 1089, 1087, 1091, 49, 47, 1917, 44, 9039 1915, 1913, 1910, 1907, 59, 1926, 56, 1925, 53, 1922, 1919, 66, 64, 1931, 61, 1929, 1042, 1040, 1038, 71, 1035, 9040 70, 1032, 68, 1048, 1047, 1045, 1043, 1050, 1049, 12, 10, 1869, 1867, 1864, 1861, 21, 1880, 19, 1877, 1874, 1871, 9041 28, 1888, 25, 1886, 22, 1883, 982, 980, 977, 974, 32, 30, 99
90411, 989, 987, 984, 34, 995, 994, 992, 2151, 2150, 2147, 9042 2146, 2144, 356, 355, 354, 2149, 2139, 2138, 2136, 2134, 1359, 343, 341, 338, 2143, 335, 2141, 348, 347, 346, 9043 1376, 1374, 2124, 2123, 2121, 2119, 1326, 2116, 1324, 310, 308, 305, 2131, 302, 2129, 298, 2127, 320, 318, 316, 9044 313, 2133, 322, 321, 1355, 1353, 1351, 1357, 2092, 2091, 2089, 2087, 1276, 2084, 1274, 2081, 1271, 259, 2102, 256, 9045 2100, 252, 2098, 2095, 272, 269, 2108, 266, 2106, 281, 279, 277, 1317, 1315, 1313, 1310, 282, 1321, 1319, 2039, 9046 2037, 2035, 2032, 1203, 2029, 1200, 1197, 207, 2053, 205, 2051, 201, 2049, 2046, 2043, 220, 218, 2064, 215, 2062, 9047 211, 2059, 228, 226, 223, 2069, 1259, 1257, 1254, 232, 1251, 230, 1267, 1265, 1263, 2316, 2315, 2312, 2311, 2309, 9048 2314, 2304, 2303, 2301, 2299, 1593, 2308, 2306, 590, 2288, 2287, 2285, 2283, 1578, 2280, 1577, 2295, 2293, 2291, 9049 579, 577, 574, 571, 2298, 582, 581, 1592, 2263, 2262, 2260, 2258, 1545, 2255, 1544, 2252, 1541, 2273, 2271, 2269, 9050 2266, 1550, 535, 532, 2279, 528, 2277, 546, 543, 549, 1575, 1573, 2224, 2222, 2220, 1486, 2217, 1485, 2214, 1482, 9051 1479, 2238, 2236, 2234, 2231, 1496, 2228, 1492, 480, 477, 2248, 473, 2246, 469, 2243, 490, 487, 2251, 497, 1537, 9052 1535, 1532, 2477, 2476, 2474, 2479, 2469, 2468, 2466, 2464, 1730, 2473, 2471, 2453, 2452, 2450, 2448, 1729, 2445, 9053 1728, 2460, 2458, 2456, 2463, 805, 804, 2428, 2427, 2425, 2423, 1725, 2420, 1724, 2417, 1722, 2438, 2436, 2434, 9054 2431, 1727, 2444, 2442, 793, 791, 788, 795, 2388, 2386, 2384, 1697, 2381, 1696, 2378, 1694, 1692, 2402, 2400, 9055 2398, 2395, 1703, 2392, 1701, 2412, 2410, 2407, 751, 748, 744, 2416, 759, 757, 1807, 2620, 2618, 1806, 1805, 2611, 9056 2609, 2607, 2614, 1802, 1801, 1799, 2594, 2592, 2590, 2587, 1804, 2600, 2598, 1794, 1793, 1791, 1789, 2564, 2562, 9057 2560, 2557, 1798, 2554, 1796, 2574, 2572, 2569, 2578, 1847, 1846, 2722, 1843, 1842, 1840, 1845, 2716, 2714, 1835, 9058 1834, 1832, 1830, 1839, 1837, 2700, 2698, 2695, 2704, 1817, 1811, 1810, 897, 862, 1777, 829, 826, 838, 1760, 1758, 9059 808, 2481, 1741, 1740, 1738, 1743, 2624, 1818, 2726, 2776, 782, 740, 737, 1715, 686, 679, 695, 1682, 1680, 639, 9060 628, 2339, 647, 644, 1645, 1643, 1640, 1648, 602, 600, 597, 595, 2320, 593, 2318, 609, 607, 604, 1611, 1610, 1608, 9061 1606, 613, 1615, 1613, 2328, 926, 924, 892, 886, 899, 857, 850, 2505, 1778, 824, 823, 821, 819, 2488, 818, 2486, 9062 833, 831, 828, 840, 1761, 1759, 2649, 2632, 2630, 2746, 2734, 2732, 2782, 2781, 570, 567, 1587, 531, 527, 523, 9063 540, 1566, 1564, 476, 467, 463, 2240, 486, 483, 1524, 1521, 1518, 1529, 411, 403, 2192, 399, 2189, 423, 416, 1462, 9064 1457, 1454, 428, 1468, 1465, 2210, 366, 363, 2158, 360, 2156, 357, 2153, 376, 373, 370, 2163, 1410, 1409, 1407, 9065 1405, 382, 1402, 380, 1417, 1415, 1412, 1421, 2175, 2174, 777, 774, 771, 784, 732, 725, 722, 2404, 743, 1716, 676, 9066 674, 668, 2363, 665, 2360, 685, 1684, 1681, 626, 624, 622, 2335, 620, 2333, 617, 2330, 641, 635, 649, 1646, 1644, 9067 1642, 2566, 928, 925, 2530, 2527, 894, 891, 888, 2501, 2499, 2496, 858, 856, 854, 851, 1779, 2692, 2668, 2665, 9068 2645, 2643, 2640, 2651, 2768, 2759, 2757, 2744, 2743, 2741, 2748, 352, 1382, 340, 337, 333, 1371, 1369, 307, 300, 9069 296, 2126, 315, 312, 1347, 1342, 1350, 261, 258, 250, 2097, 246, 2094, 271, 268, 264, 1306, 1301, 1298, 276, 1312, 9070 1309, 2115, 203, 2048, 195, 2045, 191, 2041, 213, 209, 2056, 1246, 1244, 1238, 225, 1234, 222, 1256, 1253, 1249, 9071 1262, 2080, 2079, 154, 1997, 150, 1995, 147, 1992, 1989, 163, 160, 2004, 156, 2001, 1175, 1174, 1172, 1170, 1167, 9072 170, 1164, 167, 1185, 1183, 1180, 1177, 174, 1190, 1188, 2025, 2024, 2022, 587, 586, 564, 559, 556, 2290, 573, 9073 1588, 520, 518, 512, 2268, 508, 2265, 530, 1568, 1565, 461, 457, 2233, 450, 2230, 446, 2226, 479, 471, 489, 1526, 9074 1523, 1520, 397, 395, 2185, 392, 2183, 389, 2180, 2177, 410, 2194, 402, 422, 1463, 1461, 1459, 1456, 1470, 2455, 9075 799, 2433, 2430, 779, 776, 773, 2397, 2394, 2390, 734, 728, 724, 746, 1717, 2356, 2354, 2351, 2348, 1658, 677, 9076 675, 673, 670, 667, 688, 1685, 1683, 2606, 2589, 2586, 2559, 2556, 2552, 927, 2523, 2521, 2518, 2515, 1784, 2532, 9077 895, 893, 890, 2718, 2709, 2707, 2689, 2687, 2684, 2663, 2662, 2660, 2658, 1825, 2667, 2769, 1852, 2760, 2758, 9078 142, 141, 1139, 1138, 134, 132, 129, 126, 1982, 1129, 1128, 1126, 1131, 113,
9078111, 108, 105, 1972, 101, 1970, 120, 9079 118, 115, 1109, 1108, 1106, 1104, 123, 1113, 1111, 82, 79, 1951, 75, 1949, 72, 1946, 92, 89, 86, 1956, 1077, 1076, 9080 1074, 1072, 98, 1069, 96, 1084, 1082, 1079, 1088, 1968, 1967, 48, 45, 1916, 42, 1914, 39, 1911, 1908, 60, 57, 54, 9081 1923, 50, 1920, 1031, 1030, 1028, 1026, 67, 1023, 65, 1020, 62, 1041, 1039, 1036, 1033, 69, 1046, 1044, 1944, 9082 1943, 1941, 11, 9, 1868, 7, 1865, 1862, 1859, 20, 1878, 16, 1875, 13, 1872, 970, 968, 966, 963, 29, 960, 26, 23, 9083 983, 981, 978, 975, 33, 971, 31, 990, 988, 985, 1906, 1904, 1902, 993, 351, 2145, 1383, 331, 330, 328, 326, 2137, 9084 323, 2135, 339, 1372, 1370, 294, 293, 291, 289, 2122, 286, 2120, 283, 2117, 309, 303, 317, 1348, 1346, 1344, 245, 9085 244, 242, 2090, 239, 2088, 236, 2085, 2082, 260, 2099, 249, 270, 1307, 1305, 1303, 1300, 1314, 189, 2038, 186, 9086 2036, 183, 2033, 2030, 2026, 206, 198, 2047, 194, 216, 1247, 1245, 1243, 1240, 227, 1237, 1255, 2310, 2302, 2300, 9087 2286, 2284, 2281, 565, 563, 561, 558, 575, 1589, 2261, 2259, 2256, 2253, 1542, 521, 519, 517, 514, 2270, 511, 533, 9088 1569, 1567, 2223, 2221, 2218, 2215, 1483, 2211, 1480, 459, 456, 453, 2232, 449, 474, 491, 1527, 1525, 1522, 2475, 9089 2467, 2465, 2451, 2449, 2446, 801, 800, 2426, 2424, 2421, 2418, 1723, 2435, 780, 778, 775, 2387, 2385, 2382, 2379, 9090 1695, 2375, 1693, 2396, 735, 733, 730, 727, 749, 1718, 2616, 2615, 2604, 2603, 2601, 2584, 2583, 2581, 2579, 1800, 9091 2591, 2550, 2549, 2547, 2545, 1792, 2542, 1790, 2558, 929, 2719, 1841, 2710, 2708, 1833, 1831, 2690, 2688, 2686, 9092 1815, 1809, 1808, 1774, 1756, 1754, 1737, 1736, 1734, 1739, 1816, 1711, 1676, 1674, 633, 629, 1638, 1636, 1633, 9093 1641, 598, 1605, 1604, 1602, 1600, 605, 1609, 1607, 2327, 887, 853, 1775, 822, 820, 1757, 1755, 1584, 524, 1560, 9094 1558, 468, 464, 1514, 1511, 1508, 1519, 408, 404, 400, 1452, 1447, 1444, 417, 1458, 1455, 2208, 364, 361, 358, 9095 2154, 1401, 1400, 1398, 1396, 374, 1393, 371, 1408, 1406, 1403, 1413, 2173, 2172, 772, 726, 723, 1712, 672, 669, 9096 666, 682, 1678, 1675, 625, 623, 621, 618, 2331, 636, 632, 1639, 1637, 1635, 920, 918, 884, 880, 889, 849, 848, 9097 847, 846, 2497, 855, 852, 1776, 2641, 2742, 2787, 1380, 334, 1367, 1365, 301, 297, 1340, 1338, 1335, 1343, 255, 9098 251, 247, 1296, 1291, 1288, 265, 1302, 1299, 2113, 204, 196, 192, 2042, 1232, 1230, 1224, 214, 1220, 210, 1242, 9099 1239, 1235, 1250, 2077, 2075, 151, 148, 1993, 144, 1990, 1163, 1162, 1160, 1158, 1155, 161, 1152, 157, 1173, 1171, 9100 1168, 1165, 168, 1181, 1178, 2021, 2020, 2018, 2023, 585, 560, 557, 1585, 516, 509, 1562, 1559, 458, 447, 2227, 9101 472, 1516, 1513, 1510, 398, 396, 393, 390, 2181, 386, 2178, 407, 1453, 1451, 1449, 1446, 420, 1460, 2209, 769, 9102 764, 720, 712, 2391, 729, 1713, 664, 663, 661, 659, 2352, 656, 2349, 671, 1679, 1677, 2553, 922, 919, 2519, 2516, 9103 885, 883, 881, 2685, 2661, 2659, 2767, 2756, 2755, 140, 1137, 1136, 130, 127, 1125, 1124, 1122, 1127, 109, 106, 9104 102, 1103, 1102, 1100, 1098, 116, 1107, 1105, 1980, 80, 76, 73, 1947, 1068, 1067, 1065, 1063, 90, 1060, 87, 1075, 9105 1073, 1070, 1080, 1966, 1965, 46, 43, 40, 1912, 36, 1909, 1019, 1018, 1016, 1014, 58, 1011, 55, 1008, 51, 1029, 9106 1027, 1024, 1021, 63, 1037, 1034, 1940, 1939, 1937, 1942, 8, 1866, 4, 1863, 1, 1860, 956, 954, 952, 949, 946, 17, 9107 14, 969, 967, 964, 961, 27, 957, 24, 979, 976, 972, 1901, 1900, 1898, 1896, 986, 1905, 1903, 350, 349, 1381, 329, 9108 327, 324, 1368, 1366, 292, 290, 287, 284, 2118, 304, 1341, 1339, 1337, 1345, 243, 240, 237, 2086, 233, 2083, 254, 9109 1297, 1295, 1293, 1290, 1304, 2114, 190, 187, 184, 2034, 180, 2031, 177, 2027, 199, 1233, 1231, 1229, 1226, 217, 9110 1223, 1241, 2078, 2076, 584, 555, 554, 552, 550, 2282, 562, 1586, 507, 506, 504, 502, 2257, 499, 2254, 515, 1563, 9111 1561, 445, 443, 441, 2219, 438, 2216, 435, 2212, 460, 454, 475, 1517, 1515, 1512, 2447, 798, 797, 2422, 2419, 770, 9112 768, 766, 2383, 2380, 2376, 721, 719, 717, 714, 731, 1714, 2602, 2582, 2580, 2548, 2546, 2543, 923, 921, 2717, 9113 2706, 2705, 2683, 2682, 2680, 1771, 1752, 1750, 1733, 1732, 1731, 1735, 1814, 1707, 1670, 1668, 1631, 1629, 1626, 9114 1634, 1599, 1598, 1596, 1594, 1603, 1601, 2326, 1772, 1753, 1751, 1581, 1554, 1552, 1504, 1501, 1498, 1509, 1442, 9115 1437, 1434, 401, 1448, 1445, 2206, 1392, 1391, 1389, 1387, 1384, 359, 1399, 1397, 1394, 1404, 2171, 2170, 1708, 9116 1672, 1669, 619, 1632, 1630, 1628, 1773, 1378, 1363, 1361, 1333, 1328, 1336, 1286, 1281, 1278, 248, 1292, 1289, 9117 2111, 1218, 1216, 1210, 197, 1206, 193, 1228, 1225, 1221, 1236, 2073, 2071, 1151, 1150, 1148, 1146, 152, 1143, 9118 149, 1140, 145, 1161, 1159, 1156, 1153, 158, 1169, 1166, 2017, 2016, 2014, 2019, 1582, 510, 1556, 1553, 452, 448, 9119 1506, 1500, 394, 391, 387, 1443, 1441, 1439, 1436, 1450, 2207, 765, 716, 713, 1709, 662, 660, 657, 1673, 1671, 9120 916, 914, 879, 878, 877, 882, 1135, 1134, 1121, 1120, 1118, 1123, 1097, 1096, 1094, 1092, 103, 1101, 1099, 1979, 9121 1059, 1058, 1056, 1054, 77, 1051, 74, 1066, 1064, 1061, 1071, 1964, 1963, 1007, 1006, 1004, 1002, 999, 41, 996, 9122 37, 1017, 1015, 1012, 1009, 52, 1025, 1022, 1936, 1935, 1933, 1938, 942, 940, 938, 935, 932, 5, 2, 955, 953, 950, 9123 947, 18, 943, 15, 965, 962, 958, 1895, 1894, 1892, 1890, 973, 1899, 1897, 1379, 325, 1364, 1362, 288, 285, 1334, 9124 1332, 1330, 241, 238, 234, 1287, 1285, 1283, 1280, 1294, 2112, 188, 185, 181, 178, 2028, 1219, 1217, 1215, 1212, 9125 200, 1209, 1227, 2074, 2072, 583, 553, 551, 1583, 505, 503, 500, 513, 1557, 1555, 444, 442, 439, 436, 2213, 455, 9126 451, 1507, 1505, 1502, 796, 763, 762, 760, 767, 711, 710, 708, 706, 2377, 718, 715, 1710, 2544, 917, 915, 2681, 9127 1627, 1597, 1595, 2325, 1769, 1749, 1747, 1499, 1438, 1435, 2204, 1390, 1388, 1385, 1395, 2169, 2167, 1704, 1665, 9128 1662, 1625, 1623, 1620, 1770, 1329, 1282, 1279, 2109, 1214, 1207, 1222, 2068, 2065, 1149, 1147, 1144,
91281141, 146, 9129 1157, 1154, 2013, 2011, 2008, 2015, 1579, 1549, 1546, 1495, 1487, 1433, 1431, 1428, 1425, 388, 1440, 2205, 1705, 9130 658, 1667, 1664, 1119, 1095, 1093, 1978, 1057, 1055, 1052, 1062, 1962, 1960, 1005, 1003, 1e3, 997, 38, 1013, 1010, 9131 1932, 1930, 1927, 1934, 941, 939, 936, 933, 6, 930, 3, 951, 948, 944, 1889, 1887, 1884, 1881, 959, 1893, 1891, 35, 9132 1377, 1360, 1358, 1327, 1325, 1322, 1331, 1277, 1275, 1272, 1269, 235, 1284, 2110, 1205, 1204, 1201, 1198, 182, 9133 1195, 179, 1213, 2070, 2067, 1580, 501, 1551, 1548, 440, 437, 1497, 1494, 1490, 1503, 761, 709, 707, 1706, 913, 9134 912, 2198, 1386, 2164, 2161, 1621, 1766, 2103, 1208, 2058, 2054, 1145, 1142, 2005, 2002, 1999, 2009, 1488, 1429, 9135 1426, 2200, 1698, 1659, 1656, 1975, 1053, 1957, 1954, 1001, 998, 1924, 1921, 1918, 1928, 937, 934, 931, 1879, 9136 1876, 1873, 1870, 945, 1885, 1882, 1323, 1273, 1270, 2105, 1202, 1199, 1196, 1211, 2061, 2057, 1576, 1543, 1540, 9137 1484, 1481, 1478, 1491, 1700, 9138 ])); 9139 class be { 9140 constructor(t, e) { 9141 (this.bits = t), (this.points = e); 9142 } 9143 getBits() { 9144 return this.bits; 9145 } 9146 getPoints() { 9147 return this.points; 9148 } 9149 } 9150 class Pe { 9151 static detectMultiple(t, e, r) { 9152 let n = t.getBlackMatrix(), 9153 i = Pe.detect(r, n); 9154 return i.length || ((n = n.clone()), n.rotate180(), (i = Pe.detect(r, n))), new be(n, i); 9155 } 9156 static detect(t, e) { 9157 const r = new Array(); 9158 let n = 0, 9159 i = 0, 9160 s = !1; 9161 for (; n < e.getHeight(); ) { 9162 const o = Pe.findVertices(e, n, i); 9163 if (null != o[0] || null != o[3]) { 9164 if (((s = !0), r.push(o), !t)) break; 9165 null != o[2] 9166 ? ((i = Math.trunc(o[2].getX())), (n = Math.trunc(o[2].getY()))) 9167 : ((i = Math.trunc(o[4].getX())), (n = Math.trunc(o[4].getY()))); 9168 } else { 9169 if (!s) break; 9170 (s = !1), (i = 0); 9171 for (const t of r) 9172 null != t[1] && (n = Math.trunc(Math.max(n, t[1].getY()))), 9173 null != t[3] && (n = Math.max(n, Math.trunc(t[3].getY()))); 9174 n += Pe.ROW_STEP; 9175 } 9176 } 9177 return r; 9178 } 9179 static findVertices(t, e, r) { 9180 const n = t.getHeight(), 9181 i = t.getWidth(), 9182 s = new Array(8); 9183 return ( 9184 Pe.copyToResult(s, Pe.findRowsWithPattern(t, n, i, e, r, Pe.START_PATTERN), Pe.INDEXES_START_PATTERN), 9185 null != s[4] && ((r = Math.trunc(s[4].getX())), (e = Math.trunc(s[4].getY()))), 9186 Pe.copyToResult(s, Pe.findRowsWithPattern(t, n, i, e, r, Pe.STOP_PATTERN), Pe.INDEXES_STOP_PATTERN), 9187 s 9188 ); 9189 } 9190 static copyToResult(t, e, r) { 9191 for (let n = 0; n < r.length; n++) t[r[n]] = e[n]; 9192 } 9193 static findRowsWithPattern(t, e, r, n, i, s) { 9194 const o = new Array(4); 9195 let a = !1; 9196 const l = new Int32Array(s.length); 9197 for (; n < e; n += Pe.ROW_STEP) { 9198 let e = Pe.findGuardPattern(t, i, n, r, !1, s, l); 9199 if (null != e) { 9200 for (; n > 0; ) { 9201 const o = Pe.findGuardPattern(t, i, --n, r, !1, s, l); 9202 if (null == o) { 9203 n++; 9204 break; 9205 } 9206 e = o; 9207 } 9208 (o[0] = new rt(e[0], n)), (o[1] = new rt(e[1], n)), (a = !0); 9209 break; 9210 } 9211 } 9212 let h = n + 1; 9213 if (a) { 9214 let n = 0, 9215 i = Int32Array.from([Math.trunc(o[0].getX()), Math.trunc(o[1].getX())]); 9216 for (; h < e; h++) { 9217 const e = Pe.findGuardPattern(t, i[0], h, r, !1, s, l); 9218 if (null != e && Math.abs(i[0] - e[0]) < Pe.MAX_PATTERN_DRIFT && Math.abs(i[1] - e[1]) < Pe.MAX_PATTERN_DRIFT) 9219 (i = e), (n = 0); 9220 else { 9221 if (n > Pe.SKIPPED_ROW_COUNT_MAX) break; 9222 n++; 9223 } 9224 } 9225 (h -= n + 1), (o[2] = new rt(i[0], h)), (o[3] = new rt(i[1], h)); 9226 } 9227 return h - n < Pe.BARCODE_MIN_HEIGHT && g.fill(o, null), o; 9228 } 9229 static findGuardPattern(t, e, r, n, i, s, o) { 9230 g.fillWithin(o, 0, o.length, 0); 9231 let a = e, 9232 l = 0; 9233 for (; t.get(a, r) && a > 0 && l++ < Pe.MAX_PIXEL_DRIFT; ) a--; 9234 let h = a, 9235 u = 0, 9236 d = s.length; 9237 for (let e = i; h < n; h++) { 9238 if (t.get(h, r) !== e) o[u]++; 9239 else { 9240 if (u === d - 1) { 9241 if (Pe.patternMatchVariance(o, s, Pe.MAX_INDIVIDUAL_VARIA
9241NCE) < Pe.MAX_AVG_VARIANCE) 9242 return new Int32Array([a, h]); 9243 (a += o[0] + o[1]), c.arraycopy(o, 2, o, 0, u - 1), (o[u - 1] = 0), (o[u] = 0), u--; 9244 } else u++; 9245 (o[u] = 1), (e = !e); 9246 } 9247 } 9248 return u === d - 1 && Pe.patternMatchVariance(o, s, Pe.MAX_INDIVIDUAL_VARIANCE) < Pe.MAX_AVG_VARIANCE 9249 ? new Int32Array([a, h - 1]) 9250 : null; 9251 } 9252 static patternMatchVariance(t, e, r) { 9253 let n = t.length, 9254 i = 0, 9255 s = 0; 9256 for (let r = 0; r < n; r++) (i += t[r]), (s += e[r]); 9257 if (i < s) return 1 / 0; 9258 let o = i / s; 9259 r *= o; 9260 let a = 0; 9261 for (let i = 0; i < n; i++) { 9262 let n = t[i], 9263 s = e[i] * o, 9264 l = n > s ? n - s : s - n; 9265 if (l > r) return 1 / 0; 9266 a += l; 9267 } 9268 return a / i; 9269 } 9270 } 9271 (Pe.INDEXES_START_PATTERN = Int32Array.from([0, 4, 1, 5])), 9272 (Pe.INDEXES_STOP_PATTERN = Int32Array.from([6, 2, 7, 3])), 9273 (Pe.MAX_AVG_VARIANCE = 0.42), 9274 (Pe.MAX_INDIVIDUAL_VARIANCE = 0.8), 9275 (Pe.START_PATTERN = Int32Array.from([8, 1, 1, 1, 1, 1, 1, 3])), 9276 (Pe.STOP_PATTERN = Int32Array.from([7, 1, 1, 3, 1, 1, 1, 2, 1])), 9277 (Pe.MAX_PIXEL_DRIFT = 3), 9278 (Pe.MAX_PATTERN_DRIFT = 5), 9279 (Pe.SKIPPED_ROW_COUNT_MAX = 25), 9280 (Pe.ROW_STEP = 5), 9281 (Pe.BARCODE_MIN_HEIGHT = 10); 9282 class Le { 9283 constructor(t, e) { 9284 if (0 === e.length) throw new o(); 9285 this.field = t; 9286 let r = e.length; 9287 if (r > 1 && 0 === e[0]) { 9288 let t = 1; 9289 for (; t < r && 0 === e[t]; ) t++; 9290 t === r 9291 ? (this.coefficients = new Int32Array([0])) 9292 : ((this.coefficients = new Int32Array(r - t)), 9293 c.arraycopy(e, t, this.coefficients, 0, this.coefficients.length)); 9294 } else this.coefficients = e; 9295 } 9296 getCoefficients() { 9297 return this.coefficients; 9298 } 9299 getDegree() { 9300 return this.coefficients.length - 1; 9301 } 9302 isZero() { 9303 return 0 === this.coefficients[0]; 9304 } 9305 getCoefficient(t) { 9306 return this.coefficients[this.coefficients.length - 1 - t]; 9307 } 9308 evaluateAt(t) { 9309 if (0 === t) return this.getCoefficient(0); 9310 if (1 === t) { 9311 let t = 0; 9312 for (let e of this.coefficients) t = this.field.add(t, e); 9313 return t; 9314 } 9315 let e = this.coefficients[0], 9316 r = this.coefficients.length; 9317 for (let n = 1; n < r; n++) e = this.field.add(this.field.multiply(t, e), this.coefficients[n]); 9318 return e; 9319 } 9320 add(t) { 9321 if (!this.field.equals(t.field)) throw new o('ModulusPolys do not have same ModulusGF field'); 9322 if (this.isZero()) return t; 9323 if (t.isZero()) return this; 9324 let e = this.coefficients, 9325 r = t.coefficients; 9326 if (e.length > r.length) { 9327 let t = e; 9328 (e = r), (r = t); 9329 } 9330 let n = new Int32Array(r.length), 9331 i = r.length - e.length; 9332 c.arraycopy(r, 0, n, 0, i); 9333 for (let t = i; t < r.length; t++) n[t] = this.field.add(e[t - i], r[t]); 9334 return new Le(this.field, n); 9335 } 9336 subtract(t) { 9337 if (!this.field.equals(t.field)) throw new o('ModulusPolys do not have same ModulusGF field'); 9338 return t.isZero() ? this : this.add(t.negative()); 9339 } 9340 multiply(t) { 9341 return t instanceof Le ? this.multiplyOther(t) : this.multiplyScalar(t); 9342 } 9343 multiplyOther(t) { 9344 if (!this.field.equals(t.field)) throw new o('ModulusPolys do not have same ModulusGF field'); 9345 if (this.isZero() || t.isZero()) return new Le(this.field, new Int32Array([0])); 9346 let e = this.coefficients, 9347 r = e.length, 9348 n = t.coefficients, 9349 i = n.length, 9350 s = new Int32Array(r + i - 1); 9351 for (let t = 0; t < r; t++) { 9352 let r = e[t]; 9353 for (let e = 0; e < i; e++) s[t + e] = this.field.add(s[t + e], this.field.multiply(r, n[e])); 9354 } 9355 return new Le(this.field, s); 9356 } 9357 negative() { 9358 let t = this.coefficients.length, 9359 e = new Int32Array(t); 9360 for (let r = 0; r < t; r++) e[r] = this.field.subtract(0, this.coefficients[r]); 9361 return new Le(this.field, e); 9362 } 9363 multiplyScalar(t) { 9364 if (0 === t) return new Le(this.field, new Int32Array([0])); 9365 if (1 === t) return this; 9366 let e = this.coefficients.length, 9367 r = new Int32Array(e); 9368 for (let n = 0; n < e; n++) r[n] = this.field.multiply(this.coefficients[n], t); 9369 return new Le(this.field, r); 9370 } 9371 multiplyByMonomial(t, e) { 9372 if (t < 0) throw new o(); 9373 if (0 === e) return new Le(this.field, new Int32Array([0])); 9374 let r = this.coefficients.length, 9375 n = new Int32Array(r + t); 9376 for (let t = 0; t < r; t++) n[t] = this.field.multiply(this.coefficients[t], e); 9377 return new Le(this.field, n); 9378 } 9379 toString() { 9380 let t = new p(); 9381 for (let e = this.getDegree(); e >= 0; e--) { 9382 let r = this.getCoefficient(e); 9383 0 !== r && 9384 (r < 0 ? (t.append(' - '), (r = -r)) : t.length() > 0 && t.append(' + '), 9385 (0 !== e && 1 === r) || t.append(r), 9386 0 !== e && (1 === e ? t.append('x') : (t.append('x^'), t.append(e)))); 9387 } 9388 return t.toString(); 9389 } 9390 } 9391 class Fe extends class { 9392 add(t, e) { 9393 return (t + e) % this.modulus; 9394 } 9395 subtract(t, e) { 9396 return (this.modulus + t - e) % this.modulus; 9397 } 9398 exp(t) { 9399 return this.expTable[t]; 9400 } 9401 log(t) { 9402 if (0 === t) throw new o(); 9403 return this.logTable[t]; 9404 } 9405 inverse(t) { 9406 if (0 === t) throw new K(); 9407 return this.expTable[this.modulus - this.logTable[t] - 1]; 9408 } 9409 multiply(t, e) { 9410 return 0 === t || 0 === e ? 0 : this.expTable[(this.logTable[t] + this.logTable[e]) % (this.modulus - 1)]; 9411 } 9412 getSize() { 9413 return this.modulus; 9414 } 9415 equals(t) { 9416 return t === this; 9417 } 9418 } { 9419 constructor(t, e) { 9420 super(), (this.modulus = t), (this.expTable = new Int32Array(t)), (this.logTable = new Int32Array(t)); 9421 let r = 1; 9422 for (let n = 0; n < t; n++) (this.expTable[n] = r), (r = (r * e) % t); 9423 for (let e = 0; e < t - 1; e++) this.logTable[this.expTable[e]] = e; 9424 (this.zero = new Le(this, new Int32Array([0]))), (this.one = new Le(this, new Int32Array([1]))); 9425 } 9426 getZero() { 9427 return this.zero; 9428 } 9429 getOne() { 9430 return this.one; 9431 } 9432 buildMonomial(t, e) { 9433 if (t < 0) throw new o(); 9434 if (0 === e) return this.zero; 9435 let r = new Int32Array(t + 1); 9436 return (r[0] = e), new Le(this, r); 9437 } 9438 } 9439 Fe.PDF417_GF = new Fe(Be.NUMBER_OF_CODEWORDS, 3); 9440 class ke { 9441 constructor() { 9442 this.field = Fe.PDF417_GF; 9443 } 9444 decode(t, e, r) { 9445 let n = new Le(this.field, t), 9446 i = new Int32Array(e), 9447 s = !1; 9448 for (let t = e; t > 0; t--) { 9449 let r = n.evaluateAt(this.field.exp(t)); 9450 (i[e - t] = r), 0 !== r && (s = !0);
9451 } 9452 if (!s) return 0; 9453 let o = this.field.getOne(); 9454 if (null != r) 9455 for (const e of r) { 9456 let r = this.field.exp(t.length - 1 - e), 9457 n = new Le(this.field, new Int32Array([this.field.subtract(0, r), 1])); 9458 o = o.multiply(n); 9459 } 9460 let a = new Le(this.field, i), 9461 h = this.runEuclideanAlgorithm(this.field.buildMonomial(e, 1), a, e), 9462 c = h[0], 9463 u = h[1], 9464 d = this.findErrorLocations(c), 9465 g = this.findErrorMagnitudes(u, c, d); 9466 for (let e = 0; e < d.length; e++) { 9467 let r = t.length - 1 - this.field.log(d[e]); 9468 if (r < 0) throw l.getChecksumInstance(); 9469 t[r] = this.field.subtract(t[r], g[e]); 9470 } 9471 return d.length; 9472 } 9473 runEuclideanAlgorithm(t, e, r) { 9474 if (t.getDegree() < e.getDegree()) { 9475 let r = t; 9476 (t = e), (e = r); 9477 } 9478 let n = t, 9479 i = e, 9480 s = this.field.getZero(), 9481 o = this.field.getOne(); 9482 for (; i.getDegree() >= Math.round(r / 2); ) { 9483 let t = n, 9484 e = s; 9485 if (((n = i), (s = o), n.isZero())) throw l.getChecksumInstance(); 9486 i = t; 9487 let r = this.field.getZero(), 9488 a = n.getCoefficient(n.getDegree()), 9489 h = this.field.inverse(a); 9490 for (; i.getDegree() >= n.getDegree() && !i.isZero(); ) { 9491 let t = i.getDegree() - n.getDegree(), 9492 e = this.field.multiply(i.getCoefficient(i.getDegree()), h); 9493 (r = r.add(this.field.buildMonomial(t, e))), (i = i.subtract(n.multiplyByMonomial(t, e))); 9494 } 9495 o = r.multiply(s).subtract(e).negative(); 9496 } 9497 let a = o.getCoefficient(0); 9498 if (0 === a) throw l.getChecksumInstance(); 9499 let h = this.field.inverse(a); 9500 return [o.multiply(h), i.multiply(h)]; 9501 } 9502 findErrorLocations(t) { 9503 let e = t.getDegree(), 9504 r = new Int32Array(e), 9505 n = 0; 9506 for (let i = 1; i < this.field.getSize() && n < e; i++) 9507 0 === t.evaluateAt(i) && ((r[n] = this.field.inverse(i)), n++); 9508 if (n !== e) throw l.getChecksumInstance(); 9509 return r; 9510 } 9511 findErrorMagnitudes(t, e, r) { 9512 let n = e.getDegree(), 9513 i = new Int32Array(n);
9514 for (let t = 1; t <= n; t++) i[n - t] = this.field.multiply(t, e.getCoefficient(t)); 9515 let s = new Le(this.field, i), 9516 o = r.length, 9517 a = new Int32Array(o); 9518 for (let e = 0; e < o; e++) { 9519 let n = this.field.inverse(r[e]), 9520 i = this.field.subtract(0, t.evaluateAt(n)), 9521 o = this.field.inverse(s.evaluateAt(n)); 9522 a[e] = this.field.multiply(i, o); 9523 } 9524 return a; 9525 } 9526 } 9527 class ve { 9528 constructor(t, e, r, n, i) { 9529 t instanceof ve ? this.constructor_2(t) : this.constructor_1(t, e, r, n, i); 9530 } 9531 constructor_1(t, e, r, n, i) { 9532 const s = null == e || null == r, 9533 o = null == n || null == i; 9534 if (s && o) throw new R(); 9535 s 9536 ? ((e = new rt(0, n.getY())), (r = new rt(0, i.getY()))) 9537 : o && ((n = new rt(t.getWidth() - 1, e.getY())), (i = new rt(t.getWidth() - 1, r.getY()))), 9538 (this.image = t), 9539 (this.topLeft = e), 9540 (this.bottomLeft = r), 9541 (this.topRight = n), 9542 (this.bottomRight = i), 9543 (this.minX = Math.trunc(Math.min(e.getX(), r.getX()))), 9544 (this.maxX = Math.trunc(Math.max(n.getX(), i.getX()))), 9545 (this.minY = Math.trunc(Math.min(e.getY(), n.getY()))), 9546 (this.maxY = Math.trunc(Math.max(r.getY(), i.getY()))); 9547 } 9548 constructor_2(t) { 9549 (this.image = t.image), 9550 (this.topLeft = t.getTopLeft()), 9551 (this.bottomLeft = t.getBottomLeft()), 9552 (this.topRight = t.getTopRight()), 9553 (this.bottomRight = t.getBottomRight()), 9554 (this.minX = t.getMinX()), 9555 (this.maxX = t.getMaxX()), 9556 (this.minY = t.getMinY()), 9557 (this.maxY = t.getMaxY()); 9558 } 9559 static merge(t, e) { 9560 return null == t ? e : null == e ? t : new ve(t.image, t.topLeft, t.bottomLeft, e.topRight, e.bottomRight); 9561 } 9562 addMissingRows(t, e, r) { 9563 let n = this.topLeft, 9564 i = this.bottomLeft, 9565 s = this.topRight, 9566 o = this.bottomRight; 9567 if (t > 0) { 9568 let e = r ? this.topLeft : this.topRight, 9569 i = Math.trunc(e.getY() - t); 9570 i < 0 && (i = 0); 9571 let o = new rt(e.getX(), i); 9572 r ? (n = o) : (s = o); 9573 } 9574 if (e > 0) { 9575 let t = r ? this.bottomLeft : this.bottomRight, 9576 n = Math.trunc(t.getY() + e); 9577 n >= this.image.getHeight() && (n = this.image.getHeight() - 1); 9578 let s = new rt(t.getX(), n); 9579 r ? (i = s) : (o = s); 9580 } 9581 return new ve(this.image, n, i, s, o); 9582 } 9583 getMinX() { 9584 return this.minX; 9585 } 9586 getMaxX() { 9587 return this.maxX; 9588 } 9589 getMinY() { 9590 return this.minY; 9591 } 9592 getMaxY() { 9593 return this.maxY; 9594 } 9595 getTopLeft() { 9596 return this.topLeft; 9597 } 9598 getTopRight() { 9599 return this.topRight; 9600 } 9601 getBottomLeft() { 9602 return this.bottomLeft; 9603 } 9604 getBottomRight() { 9605 return this.bottomRight; 9606 } 9607 } 9608 class xe { 9609 constructor(t, e, r, n) { 9610 (this.columnCount = t), 9611 (this.errorCorrectionLevel = n), 9612 (this.rowCountUpperPart = e), 9613 (this.rowCountLowerPart = r), 9614 (this.rowCount = e + r); 9615 } 9616 getColumnCount() { 9617 return this.columnCount; 9618 } 9619 getErrorCorrectionLevel() { 9620 return this.errorCorrectionLevel; 9621 } 9622 getRowCount() { 9623 return this.rowCount; 9624 } 9625 getRowCountUpperPart() { 9626 return this.rowCountUpperPart; 9627 } 9628 getRowCountLowerPart() { 9629 return this.rowCountLowerPart; 9630 } 9631 } 9632 class Ve { 9633 constructor() { 9634 this.buffer = ''; 9635 } 9636 static form(t, e) { 9637 let r = -1; 9638 return t.replace(/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g, function (t, n, i, s, o, a) { 9639 if ('%%' === t) return '%'; 9640 if (void 0 === e[++r]) return; 9641 t = s ? parseInt(s.substr(1)) : void 0; 9642 let l, 9643 h = o ? parseInt(o.substr(1)) : void 0; 9644 switch (a) { 9645 case 's': 9646 l = e[r]; 9647 break; 9648 case 'c': 9649 l = e[r][0]; 9650 break; 9651 case 'f': 9652 l = parseFloat(e[r]).toFixed(t); 9653 break; 9654 case 'p': 9655 l = parseFloat(e[r]).toPrecision(t); 9656 break; 9657 case 'e': 9658 l = parseFloat(e[r]).toExponential(t); 9659 break; 9660 case 'x': 9661 l = parseInt(e[r]).toString(h || 16); 9662 break; 9663 case 'd': 9664 l = parseFloat(parseInt(e[r], h || 10).toPrecision(t)).toFixed(0); 9665 } 9666 l = 'object' == typeof l ? JSON.stringify(l) : (+l).toString(h); 9667 let c = parseInt(i), 9668 u = i && i[0] + '' == '0' ? '0' : ' '; 9669 for (; l.length < c; ) l = void 0 !== n ? l + u : u + l; 9670 return l; 9671 }); 9672 } 9673 format(t, ...e) { 9674 this.buffer += Ve.form(t, e); 9675 } 9676 toString() { 9677 return this.buffer; 9678 } 9679 } 9680 class Ue { 9681 constructor(t) { 9682 (this.boundingBox = new ve(t)), (this.codewords = new Array(t.getMaxY() - t.getMinY() + 1)); 9683 } 9684 getCodewordNearby(t) { 9685 let e = this.getCodeword(t); 9686 if (null != e) return e; 9687 for (let r = 1; r < Ue.MAX_NEARBY_DISTANCE; r++) { 9688 let n = this.imageRowToCodewordIndex(t) - r; 9689 if (n >
9689= 0 && ((e = this.codewords[n]), null != e)) return e; 9690 if ( 9691 ((n = this.imageRowToCodewordIndex(t) + r), n < this.codewords.length && ((e = this.codewords[n]), null != e)) 9692 ) 9693 return e; 9694 } 9695 return null; 9696 } 9697 imageRowToCodewordIndex(t) { 9698 return t - this.boundingBox.getMinY(); 9699 } 9700 setCodeword(t, e) { 9701 this.codewords[this.imageRowToCodewordIndex(t)] = e; 9702 } 9703 getCodeword(t) { 9704 return this.codewords[this.imageRowToCodewordIndex(t)]; 9705 } 9706 getBoundingBox() { 9707 return this.boundingBox; 9708 } 9709 getCodewords() { 9710 return this.codewords; 9711 } 9712 toString() { 9713 const t = new Ve(); 9714 let e = 0; 9715 for (const r of this.codewords) 9716 null != r ? t.format('%3d: %3d|%3d%n', e++, r.getRowNumber(), r.getValue()) : t.format('%3d: | %n', e++); 9717 return t.toString(); 9718 } 9719 } 9720 Ue.MAX_NEARBY_DISTANCE = 5; 9721 class He { 9722 constructor() { 9723 this.values = new Map(); 9724 } 9725 setValue(t) { 9726 t = Math.trunc(t); 9727 let e = this.values.get(t); 9728 null == e && (e = 0), e++, this.values.set(t, e); 9729 } 9730 getValue() { 9731 let t = -1, 9732 e = new Array(); 9733 for (const [r, n] of this.values.entries()) { 9734 const i = { getKey: () => r, getValue: () => n }; 9735 i.getValue() > t 9736 ? ((t = i.getValue()), (e = []), e.push(i.getKey())) 9737 : i.getValue() === t && e.push(i.getKey()); 9738 } 9739 return Be.toIntArray(e); 9740 } 9741 getConfidence(t) { 9742 return this.values.get(t); 9743 } 9744 } 9745 class Ge extends Ue { 9746 constructor(t, e) { 9747 super(t), (this._isLeft = e); 9748 } 9749 setRowNumbers() { 9750 for (let t of this.getCodewords()) null != t && t.setRowNumberAsRowIndicatorColumn(); 9751 } 9752 adjustCompleteIndicatorColumnRowNumbers(t) { 9753 let e = this.getCodewords(); 9754 this.setRowNumbers(), this.removeIncorrectCodewords(e, t); 9755 let r = this.getBoundingBox(), 9756 n = this._isLeft ? r.getTopLeft() : r.getTopRight(), 9757 i = this._isLeft ? r.getBottomLeft() : r.getBottomRight(), 9758 s = this.imageRowToCodewordIndex(Math.trunc(n.getY())), 9759 o = this.imageRowToCodewordIndex(Math.trunc(i.getY())), 9760 a = -1, 9761 l = 1, 9762 h = 0; 9763 for (let r = s; r < o; r++) { 9764 if (null == e[r]) continue; 9765 let n = e[r], 9766 i = n.getRowNumber() - a; 9767 if (0 === i) h++; 9768 else if (1 === i) (l = Math.max(l, h)), (h = 1), (a = n.getRowNumber()); 9769 else if (i < 0 || n.getRowNumber() >= t.getRowCount() || i > r) e[r] = null; 9770 else { 9771 let t; 9772 t = l > 2 ? (l - 2) * i : i; 9773 let s = t >= r; 9774 for (let n = 1; n <= t && !s; n++) s = null != e[r - n]; 9775 s ? (e[r] = null) : ((a = n.getRowNumber()), (h = 1)); 9776 } 9777 } 9778 } 9779 getRowHeights() { 9780 let t = this.getBarcodeMetadata(); 9781 if (null == t) return null; 9782 this.adjustIncompleteIndicatorColumnRowNumbers(t); 9783 let e = new Int32Array(t.getRowCount()); 9784 for (let t of this.getCodewords()) 9785 if (null != t) { 9786 let r = t.getRowNumber(); 9787 if (r >= e.length) continue; 9788 e[r]++; 9789 } 9790 return e; 9791 } 9792 adjustIncompleteIndicatorColumnRowNumbers(t) { 9793 let e = this.getBoundingBox(), 9794 r = this._isLeft ? e.getTopLeft() : e.getTopRight(), 9795 n = this._isLeft ? e.getBottomLeft() : e.getBottomRight(), 9796 i = this.imageRowToCodewordIndex(Math.trunc(r.getY())), 9797 s = this.imageRowToCodewordIndex(Math.trunc(n.getY())), 9798 o = this.getCodewords(), 9799 a = -1; 9800 for (let e = i; e < s; e++) { 9801 if (null == o[e]) continue; 9802 let r = o[e]; 9803 r.setRowNumberAsRowIndicatorColumn(); 9804 let n = r.getRowNumber() - a; 9805 0 === n || 9806 (1 === n 9807 ? (a = r.getRowNumber()) 9808 : r.getRowNumber() >= t.getRowCount() 9809 ? (o[e] = null) 9810 : (a = r.getRowNumber())); 9811 } 9812 } 9813 getBarcodeMetadata() { 9814 let t = this.getCodewords(), 9815 e = new He(), 9816 r = new He(), 9817 n = new He(), 9818 i = new He(); 9819 for (let s of t) { 9820 if (null == s) continue; 9821 s.setRowNumberAsRowIndicatorColumn(); 9822 let t = s.getValue() % 30, 9823 o = s.getRowNumber(); 9824 switch ((this._isLeft || (o += 2), o % 3)) { 9825 case 0: 9826 r.setValue(3 * t + 1); 9827 break; 9828 case 1: 9829 i.setValue(t / 3), n.setValue(t % 3); 9830 break; 9831 case 2: 9832 e.setValue(t + 1); 9833 } 9834 } 9835 if ( 9836 0 === e.getValue().length || 9837 0 === r.getValue().length || 9838 0 === n.getValue().length || 9839 0 === i.getValue().length || 9840 e.getValue()[0] < 1 || 9841 r.getValue()[0] + n.getValue()[0] < Be.MIN_ROWS_IN_BARCODE || 9842 r.getValue()[0] + n.getValue()[0] > Be.MAX_ROWS_IN_BARCODE 9843 ) 9844 return null; 9845 let s = new xe(e.getValue()[0], r.getValue()[0], n.getValue()[0], i.getValue()[0]); 9846 return this.removeIncorrectCodewords(t, s), s;
9847 } 9848 removeIncorrectCodewords(t, e) { 9849 for (let r = 0; r < t.length; r++) { 9850 let n = t[r]; 9851 if (null == t[r]) continue; 9852 let i = n.getValue() % 30, 9853 s = n.getRowNumber(); 9854 if (s > e.getRowCount()) t[r] = null; 9855 else 9856 switch ((this._isLeft || (s += 2), s % 3)) { 9857 case 0: 9858 3 * i + 1 !== e.getRowCountUpperPart() && (t[r] = null); 9859 break; 9860 case 1: 9861 (Math.trunc(i / 3) === e.getErrorCorrectionLevel() && i % 3 === e.getRowCountLowerPart()) || 9862 (t[r] = null); 9863 break; 9864 case 2: 9865 i + 1 !== e.getColumnCount() && (t[r] = null); 9866 } 9867 } 9868 } 9869 isLeft() { 9870 return this._isLeft; 9871 } 9872 toString() { 9873 return 'IsLeft: ' + this._isLeft + '\n' + super.toString(); 9874 } 9875 } 9876 class Xe { 9877 constructor(t, e) { 9878 (this.ADJUST_ROW_NUMBER_SKIP = 2), 9879 (this.barcodeMetadata = t), 9880 (this.barcodeColumnCount = t.getColumnCount()), 9881 (this.boundingBox = e), 9882 (this.detectionResultColumns = new Array(this.barcodeColumnCount + 2)); 9883 } 9884 getDetectionResultColumns() { 9885 this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]), 9886 this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount + 1]); 9887 let t, 9888 e = Be.MAX_CODEWORDS_IN_BARCODE; 9889 do { 9890 (t = e), (e = this.adjustRowNumbersAndGetCount()); 9891 } while (e > 0 && e < t); 9892 return this.detectionResultColumns; 9893 } 9894 adjustIndicatorColumnRowNumbers(t) { 9895 null != t && t.adjustCompleteIndicatorColumnRowNumbers(this.barcodeMetadata); 9896 } 9897 adjustRowNumbersAndGetCount() { 9898 let t = this.adjustRowNumbersByRow(); 9899 if (0 === t) return 0; 9900 for (let t = 1; t < this.barcodeColumnCount + 1; t++) { 9901 let e = this.detectionResultColumns[t].getCodewords(); 9902 for (let r = 0; r < e.length; r++) null != e[r] && (e[r].hasValidRowNumber() || this.adjustRowNumbers(t, r, e)); 9903 } 9904 return t; 9905 } 9906 adjustRowNumbersByRow() { 9907 return this.adjustRowNumbersFromBothRI(), this.adjustRowNumbersFromLRI() + this.adjustRowNumbersFromRRI(); 9908 } 9909 adjustRowNumbersFromBothRI() { 9910 if (null == this.detectionResultColumns[0] || null == this.detectionResultColumns[this.barcodeColumnCount + 1]) 9911 return; 9912 let t = this.detectionResultColumns[0].getCodewords(), 9913 e = this.detectionResultColumns[this.barcodeColumnCount + 1].getCodewords(); 9914 for (let r = 0; r < t.length; r++) 9915 if (null != t[r] && null != e[r] && t[r].getRowNumber() === e[r].getRowNumber()) 9916 for (let e = 1; e <= this.barcodeColumnCount; e++) { 9917 let n = this.detectionResultColumns[e].getCodewords()[r]; 9918 null != n && 9919 (n.setRowNumber(t[r].getRowNumber()), 9920 n.hasValidRowNumber() || (this.detectionResultColumns[e].getCodewords()[r] = null)); 9921 } 9922 } 9923 adjustRowNumbersFromRRI() { 9924 if (null == this.detectionResultColumns[this.barcodeColumnCount + 1]) return 0; 9925 let t = 0, 9926 e = this.detectionResultColumns[this.barcodeColumnCount + 1].getCodewords(); 9927 for (let r = 0; r < e.length; r++) { 9928 if (null == e[r]) continue; 9929 let n = e[r].getRowNumber(), 9930 i = 0; 9931 for (let e = this.barcodeColumnCount + 1; e > 0 && i < this.ADJUST_ROW_NUMBER_SKIP; e--) { 9932 let s = this.detectionResultColumns[e].getCodewords()[r]; 9933 null != s && ((i = Xe.adjustRowNumberIfValid(n, i, s)), s.hasValidRowNumber() || t++); 9934 } 9935 } 9936 return t; 9937 } 9938 adjustRowNumbersFromLRI() { 9939 if (null == this.detectionResultColumns[0]) return 0; 9940 let t = 0, 9941 e = this.detectionResultColumns[0].getCodewords(); 9942 for (let r = 0; r < e.length; r++) { 9943 if (null == e[r]) continue; 9944 let n = e[r].getRowNumber(), 9945 i = 0; 9946 for (let e = 1; e < this.barcodeColumnCount + 1 && i < this.ADJUST_ROW_NUMBER_SKIP; e++) { 9947 let s = this.detectionResultColumns[e].getCodewords()[r]; 9948 null != s && ((i = Xe.adjustRowNumberIfValid(n, i, s)), s.hasValidRowNumber() || t++); 9949 } 9950 } 9951 return t; 9952 } 9953 static adjustRowNumberIfValid(t, e, r) { 9954 return null == r || r.hasValidRowNumber() || (r.isValidRowNumber(t) ? (r.setRowNumber(t), (e = 0)) : ++e), e; 9955 } 9956 adjustRowNumbers(t, e, r) { 9957 let n = r[e], 9958 i = this.detectionResultColumns[t - 1].getCodewords(), 9959 s = i; 9960 null != this.detectionResultColumns[t + 1] && (s = this.detectionResultColumns[t + 1].getCodewords()); 9961 let o = new Array(14); 9962 (o[2] = i[e]), 9963 (o[3] = s[e]), 9964 e > 0 && ((o[0] = r[e - 1]), (o[4] = i[e - 1]), (o[5] = s[e - 1])), 9965 e >
9965 1 && ((o[8] = r[e - 2]), (o[10] = i[e - 2]), (o[11] = s[e - 2])), 9966 e < r.length - 1 && ((o[1] = r[e + 1]), (o[6] = i[e + 1]), (o[7] = s[e + 1])), 9967 e < r.length - 2 && ((o[9] = r[e + 2]), (o[12] = i[e + 2]), (o[13] = s[e + 2])); 9968 for (let t of o) if (Xe.adjustRowNumber(n, t)) return; 9969 } 9970 static adjustRowNumber(t, e) { 9971 return ( 9972 null != e && 9973 !(!e.hasValidRowNumber() || e.getBucket() !== t.getBucket()) && 9974 (t.setRowNumber(e.getRowNumber()), !0) 9975 ); 9976 } 9977 getBarcodeColumnCount() { 9978 return this.barcodeColumnCount; 9979 } 9980 getBarcodeRowCount() { 9981 return this.barcodeMetadata.getRowCount(); 9982 } 9983 getBarcodeECLevel() { 9984 return this.barcodeMetadata.getErrorCorrectionLevel(); 9985 } 9986 setBoundingBox(t) { 9987 this.boundingBox = t; 9988 } 9989 getBoundingBox() { 9990 return this.boundingBox; 9991 } 9992 setDetectionResultColumn(t, e) { 9993 this.detectionResultColumns[t] = e; 9994 } 9995 getDetectionResultColumn(t) { 9996 return this.detectionResultColumns[t]; 9997 } 9998 toString() { 9999 let t = this.detectionResultColumns[0]; 10000 null == t && (t = this.detectionResultColumns[this.barcodeColumnCount + 1]); 10001 let e = new Ve(); 10002 for (let r = 0; r < t.getCodewords().length; r++) { 10003 e.format('CW %3d:', r); 10004 for (let t = 0; t < this.barcodeColumnCount + 2; t++) { 10005 if (null == this.detectionResultColumns[t]) { 10006 e.format(' | '); 10007 continue; 10008 } 10009 let n = this.detectionResultColumns[t].getCodewords()[r]; 10010 null != n ? e.format(' %3d|%3d', n.getRowNumber(), n.getValue()) : e.format(' | '); 10011 } 10012 e.format('%n'); 10013 } 10014 return e.toString(); 10015 } 10016 } 10017 class We { 10018 constructor(t, e, r, n) { 10019 (this.rowNumber = We.BARCODE_ROW_UNKNOWN), 10020 (this.startX = Math.trunc(t)), 10021 (this.endX = Math.trunc(e)), 10022 (this.bucket = Math.trunc(r)), 10023 (this.value = Math.trunc(n)); 10024 } 10025 hasValidRowNumber() { 10026 return this.isValidRowNumber(this.rowNumber); 10027 } 10028 isValidRowNumber(t) { 10029 return t !== We.BARCODE_ROW_UNKNOWN && this.bucket === (t % 3) * 3; 10030 } 10031 setRowNumberAsRowIndicatorColumn() { 10032 this.rowNumber = Math.trunc(3 * Math.trunc(this.value / 30) + Math.trunc(this.bucket / 3)); 10033 } 10034 getWidth() { 10035 return this.endX - this.startX; 10036 } 10037 getStartX() { 10038 return this.startX; 10039 } 10040 getEndX() { 10041 return this.endX; 10042 } 10043 getBucket() { 10044 return this.bucket; 10045 } 10046 getValue() { 10047 return this.value; 10048 } 10049 getRowNumber() { 10050 return this.rowNumber; 10051 } 10052 setRowNumber(t) { 10053 this.rowNumber = t; 10054 } 10055 toString() { 10056 return this.rowNumber + '|' + this.value; 10057 } 10058 } 10059 We.BARCODE_ROW_UNKNOWN = -1; 10060 class ze { 10061 static initialize() { 10062 for (let t = 0; t < Be.SYMBOL_TABLE.length; t++) { 10063 let e = Be.SYMBOL_TABLE[t], 10064 r = 1 & e; 10065 for (let n = 0; n < Be.BARS_IN_MODULE; n++) { 10066 let i = 0; 10067 for (; (1 & e) === r; ) (i += 1), (e >>= 1); 10068 (r = 1 & e), 10069 ze.RATIOS_TABLE[t] || (ze.RATIOS_TABLE[t] = new Array(Be.BARS_IN_MODULE)), 10070 (ze.RATIOS_TABLE[t][Be.BARS_IN_MODULE - n - 1] = Math.fround(i / Be.MODULES_IN_CODEWORD)); 10071 } 10072 } 10073 this.bSymbolTableReady = !0; 10074 } 10075 static getDecodedValue(t) { 10076 let e = ze.getDecodedCodewordValue(ze.sampleBitCounts(t)); 10077 return -1 !== e ? e : ze.getClosestDecodedValue(t); 10078 } 10079 static sampleBitCounts(t) { 10080 let e = tt.sum(t), 10081 r = new Int32Array(Be.BARS_IN_MODULE), 10082 n = 0, 10083 i = 0; 10084 for (let s = 0; s < Be.MODULES_IN_CODEWORD; s++) { 10085 let o = e / (2 * Be.MODULES_IN_CODEWORD) + (s * e) / Be.MODULES_IN_CODEWORD; 10086 i + t[n] <= o && ((i += t[n]), n++), r[n]++; 10087 } 10088 return r; 10089 } 10090 static getDecodedCodewordValue(t) { 10091 let e = ze.getBitValue(t); 10092 return -1 === Be.getCodeword(e) ? -1 : e; 10093 } 10094 static getBitValue(t) { 10095 let e = 0; 10096 for (let r = 0; r < t.length; r++) for (let n = 0; n < t[r]; n++) e = (e << 1) | (r % 2 == 0 ? 1 : 0); 10097 return Math.trunc(e); 10098 } 10099 static getClosestDecodedValue(t) { 10100 let e = tt.sum(t), 10101 r = new Array(Be.BARS_IN_MODULE); 10102 if (e > 1) for (let n = 0; n < r.length; n++) r[n] = Math.fround(t[n] / e); 10103 let n = et.MAX_VALUE, 10104 i = -1; 10105 this.bSymbolTableReady || ze.initialize(); 10106 for (let t = 0; t < ze.RATIOS_TABLE.length; t++) { 10107 let e = 0, 10108 s = ze.RATIOS_TABLE[t]; 10109 for (let t = 0; t < Be.BARS_IN_MODULE; t++) { 10110 let i = Math.fround(s[t] - r[t]); 10111 if (((e += Math.fround(i * i)), e >= n)) break; 10112 } 10113 e < n && ((n = e), (i = Be.SYMBOL_TABLE[t])); 10114 } 10115 return i; 10116 } 10117 } 10118 (ze.bSymbolTableReady = !1), 10119 (ze.RATIOS_TABLE = new Array(Be.SYMBOL_TABLE.length).map((t) => new Array(Be.BARS_IN_MODULE))); 10120 class Ye { 10121 constructor() { 10122 (this.segmentCount = -1), (this.fileSize = -1), (this.timestamp = -1), (this.checksum = -1); 10123 } 10124 getSegmentIndex() { 10125 return this.segmentIndex; 10126 } 10127 setSegmentIndex(t) { 10128 this.segmentIndex = t; 10129 } 10130 getFileId() { 10131 return this.fileId; 10132 } 10133 setFileId(t) { 10134 this.fileId = t; 10135 } 10136 getOptionalData() { 10137 return this.optionalData; 10138 } 10139 setOptionalData(t) { 10140 this.optionalData = t; 10141 } 10142 isLastSegment() { 10143 return this.lastSegment; 10144 }
10145 setLastSegment(t) { 10146 this.lastSegment = t; 10147 } 10148 getSegmentCount() { 10149 return this.segmentCount; 10150 } 10151 setSegmentCount(t) { 10152 this.segmentCount = t; 10153 } 10154 getSender() { 10155 return this.sender || null; 10156 } 10157 setSender(t) { 10158 this.sender = t; 10159 } 10160 getAddressee() { 10161 return this.addressee || null; 10162 } 10163 setAddressee(t) { 10164 this.addressee = t; 10165 } 10166 getFileName() { 10167 return this.fileName; 10168 } 10169 setFileName(t) { 10170 this.fileName = t; 10171 } 10172 getFileSize() { 10173 return this.fileSize; 10174 } 10175 setFileSize(t) { 10176 this.fileSize = t; 10177 } 10178 getChecksum() { 10179 return this.checksum; 10180 } 10181 setChecksum(t) { 10182 this.checksum = t; 10183 } 10184 getTimestamp() { 10185 return this.timestamp; 10186 } 10187 setTimestamp(t) { 10188 this.timestamp = t; 10189 } 10190 } 10191 class Ze { 10192 static parseLong(t, e) { 10193 return parseInt(t, e); 10194 } 10195 } 10196 class Ke extends i {} 10197 Ke.kind = 'NullPointerException'; 10198 class qe extends i {} 10199 class Qe extends class { 10200 writeBytes(t) { 10201 this.writeBytesOffset(t, 0, t.length); 10202 } 10203 writeBytesOffset(t, e, r) { 10204 if (null == t) throw new Ke(); 10205 if (e < 0 || e > t.length || r < 0 || e + r > t.length || e + r < 0) throw new u(); 10206 if (0 !== r) for (let n = 0; n < r; n++) this.write(t[e + n]); 10207 } 10208 flush() {} 10209 close() {} 10210 } { 10211 constructor(t = 32) {
10212 if ((super(), (this.count = 0), t < 0)) throw new o('Negative initial size: ' + t); 10213 this.buf = new Uint8Array(t); 10214 } 10215 ensureCapacity(t) { 10216 t - this.buf.length > 0 && this.grow(t); 10217 } 10218 grow(t) { 10219 let e = this.buf.length << 1; 10220 if ((e - t < 0 && (e = t), e < 0)) { 10221 if (t < 0) throw new qe(); 10222 e = f.MAX_VALUE; 10223 } 10224 this.buf = g.copyOfUint8Array(this.buf, e); 10225 } 10226 write(t) { 10227 this.ensureCapacity(this.count + 1), (this.buf[this.count] = t), (this.count += 1); 10228 } 10229 writeBytesOffset(t, e, r) { 10230 if (e < 0 || e > t.length || r < 0 || e + r - t.length > 0) throw new u(); 10231 this.ensureCapacity(this.count + r), c.arraycopy(t, e, this.buf, this.count, r), (this.count += r); 10232 } 10233 writeTo(t) { 10234 t.writeBytesOffset(this.buf, 0, this.count); 10235 } 10236 reset() { 10237 this.count = 0; 10238 } 10239 toByteArray() { 10240 return g.copyOfUint8Array(this.buf, this.count); 10241 } 10242 size() { 10243 return this.count; 10244 } 10245 toString(t) { 10246 return t ? ('string' == typeof t ? this.toString_string(t) : this.toString_number(t)) : this.toString_void(); 10247 } 10248 toString_void() { 10249 return new String(this.buf).toString(); 10250 } 10251 toString_string(t) { 10252 return new String(this.buf).toString(); 10253 } 10254 toString_number(t) { 10255 return new String(this.buf).toString(); 10256 } 10257 close() {} 10258 } 10259 function je() { 10260 if ('undefined' != typeof window) return window.BigInt || null; 10261 if ('undefined' != typeof global) return global.BigInt || null; 10262 if ('undefined' != typeof self) return self.BigInt || null; 10263 throw new Error("Can't search globals for BigInt!"); 10264 } 10265 let Je; 10266 function $e(t) { 10267 if ((void 0 === Je && (Je = je()), null === Je)) throw new Error('BigInt is not supported!'); 10268 return Je(t); 10269 } 10270 !(function (t) { 10271 (t[(t.ALPHA = 0)] = 'ALPHA'), 10272 (t[(t.LOWER = 1)] = 'LOWER'), 10273 (t[(t.MIXED = 2)] = 'MIXED'), 10274 (t[(t.PUNCT = 3)] = 'PUNCT'), 10275 (t[(t.ALPHA_SHIFT = 4)] = 'ALPHA_SHIFT'), 10276 (t[(t.PUNCT_SHIFT = 5)] = 'PUNCT_SHIFT'); 10277 })(X || (X = {})); 10278 class tr { 10279 static decode(t, e) { 10280 let r = new p(''), 10281 n = m.ISO8859_1; 10282 r.enableDecoding(n); 10283 let i = 1, 10284 s = t[i++], 10285 o = new Ye(); 10286 for (; i < t[0]; ) { 10287 switch (s) { 10288 case tr.TEXT_COMPACTION_MODE_LATCH: 10289 i = tr.textCompaction(t, i, r); 10290 break; 10291 case tr.BYTE_COMPACTION_MODE_LATCH: 10292 case tr.BYTE_COMPACTION_MODE_LATCH_6: 10293 i = tr.byteCompaction(s, t, n, i, r); 10294 break; 10295 case tr.MODE_SHIFT_TO_BYTE_COMPACTION_MODE: 10296 r.append(t[i++]); 10297 break; 10298 case tr.NUMERIC_COMPACTION_MODE_LATCH: 10299 i = tr.numericCompaction(t, i, r); 10300 break; 10301 case tr.ECI_CHARSET: 10302 m.getCharacterSetECIByValue(t[i++]); 10303 break; 10304 case tr.ECI_GENERAL_PURPOSE: 10305 i += 2; 10306 break; 10307 case tr.ECI_USER_DEFINED: 10308 i++; 10309 break; 10310 case tr.BEGIN_MACRO_PDF417_CONTROL_BLOCK: 10311 i = tr.decodeMacroBlock(t, i, o); 10312 break; 10313 case tr.BEGIN_MACRO_PDF417_OPTIONAL_FIELD: 10314 case tr.MACRO_PDF417_TERMINATOR: 10315 throw new E(); 10316 default: 10317 i--, (i = tr.textCompaction(t, i, r)); 10318 } 10319 if (!(i < t.length)) throw E.getFormatInstance(); 10320 s = t[i++]; 10321 } 10322 if (0 === r.length()) throw E.getFormatInstance(); 10323 let a = new z(null, r.toString(), null, e); 10324 return a.setOther(o), a; 10325 } 10326 static decodeMacroBlock(t, e, r) { 10327 if (e + tr.NUMBER_OF_SEQUENCE_CODEWORDS > t[0]) throw E.getFormatInstance(); 10328 let n = new Int32Array(tr.NUMBER_OF_SEQUENCE_CODEWORDS); 10329 for (let r = 0; r < tr.NUMBER_OF_SEQUENCE_CODEWORDS; r++, e++) n[r] = t[e]; 10330 r.setSegmentIndex(f.parseInt(tr.decodeBase900toBase10(n, tr.NUMBER_OF_SEQUENCE_CODEWORDS))); 10331 let i = new p(); 10332 (e = tr.textCompaction(t, e, i)), r.setFileId(i.toString()); 10333 let s = -1; 10334 for (t[e] === tr.BEGIN_MACRO_PDF417_OPTIONAL_FIELD && (s = e + 1); e < t[0]; ) 10335 switch (t[e]) { 10336 case tr.BEGIN_MACRO_PDF417_OPTIONAL_FIELD: 10337 switch (t[++e]) { 10338 case tr.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME: 10339 let n = new p(); 10340 (e = tr.textCompaction(t, e + 1, n)), r.setFileName(n.toString()); 10341 break; 10342 case tr.MACRO_PDF417_OPTIONAL_FIELD_SENDER: 10343 let i = new p(); 10344 (e = tr.textCompaction(t, e + 1, i)), r.setSender(i.toString()); 10345 break; 10346 case tr.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE: 10347 let s = new p(); 10348 (e = tr.textCompaction(t, e + 1, s)), r.setAddressee(s.toString()); 10349 break; 10350 case tr.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT: 10351 let o = new p(); 10352 (e = tr.numericCompaction(t, e + 1, o)), r.setSegmentCount(f.parseInt(o.toString())); 10353 break; 10354 case tr.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP: 10355 let a = new p(); 10356 (e = tr.numericCompaction(t, e + 1, a)), r.setTimestamp(Ze.parseLong(a.toString())); 10357 break; 10358 case tr.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM: 10359 let l = new p(); 10360 (e = tr.numericCompaction(t, e + 1, l)), r.setChecksum(f.parseInt(l.toString())); 10361 break; 10362 case tr.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE: 10363 let h = new p(); 10364 (e = tr.numericCompaction(t, e + 1, h)), r.setFileSize(Ze.parseLong(h.toString())); 10365 break; 10366 default: 10367 throw E.getFormatInstance(); 10368 } 10369 break; 10370 case tr.MACRO_PDF417_TERMINATOR: 10371 e++, r.setLastSegment(!0); 10372 break; 10373 default: 10374 throw E.getFormatInstance(); 10375 } 10376 if (-1 !== s) { 10377 let n = e - s; 10378 r.isLastSegment() && n--, r.setOptionalData(g.copyOfRange(t, s, s + n)); 10379 } 10380 return e; 10381 } 10382 static textCompaction(t, e, r) { 10383 let n = new Int32Array(2 * (t[0] - e)), 10384 i = new Int32Array(2 * (t[0] - e)), 10385 s = 0, 10386 o = !1; 10387 for (; e < t[0] && !o; ) { 10388 let r = t[e++]; 10389 if (r < tr.TEXT_COMPACTION_MODE_LATCH) (n[s] = r / 30), (n[s + 1] = r % 30), (s += 2); 10390 else 10391 switch (r) { 10392 case tr.TEXT_COMPACTION_MODE_LATCH: 10393 n[s++] = tr.TEXT_COMPACTION_MODE_LATCH; 10394 break; 10395 case tr.BYTE_COMPACTION_MODE_LATCH: 10396 case tr.BYTE_COMPACTION_MODE_LATCH_6: 10397 case tr.NUMERIC_COMPACTION_MODE_LATCH: 10398 case tr.BEGIN_MACRO_PDF417_CONTROL_BLOCK: 10399 case tr.BEGIN_MACRO_PDF417_OPTIONAL_FIELD: 10400 case tr.MACRO_PDF417_TERMINATOR: 10401 e--, (o = !0);
10402 break; 10403 case tr.MODE_SHIFT_TO_BYTE_COMPACTION_MODE: 10404 (n[s] = tr.MODE_SHIFT_TO_BYTE_COMPACTION_MODE), (r = t[e++]), (i[s] = r), s++; 10405 } 10406 } 10407 return tr.decodeTextCompaction(n, i, s, r), e; 10408 } 10409 static decodeTextCompaction(t, e, r, n) { 10410 let i = X.ALPHA, 10411 s = X.ALPHA, 10412 o = 0; 10413 for (; o < r; ) { 10414 let r = t[o], 10415 a = ''; 10416 switch (i) { 10417 case X.ALPHA: 10418 if (r < 26) a = String.fromCharCode(65 + r); 10419 else 10420 switch (r) { 10421 case 26: 10422 a = ' '; 10423 break; 10424 case tr.LL: 10425 i = X.LOWER; 10426 break; 10427 case tr.ML: 10428 i = X.MIXED; 10429 break; 10430 case tr.PS: 10431 (s = i), (i = X.PUNCT_SHIFT); 10432 break; 10433 case tr.MODE_SHIFT_TO_BYTE_COMPACTION_MODE: 10434 n.append(e[o]); 10435 break; 10436 case tr.TEXT_COMPACTION_MODE_LATCH: 10437 i = X.ALPHA; 10438 } 10439 break; 10440 case X.LOWER: 10441 if (r < 26) a = String.fromCharCode(97 + r); 10442 else 10443 switch (r) { 10444 case 26: 10445 a = ' '; 10446 break; 10447 case tr.AS: 10448 (s = i), (i = X.ALPHA_SHIFT); 10449 break; 10450 case tr.ML: 10451 i = X.MIXED; 10452 break; 10453 case tr.PS: 10454 (s = i), (i = X.PUNCT_SHIFT); 10455 break; 10456 case tr.MODE_SHIFT_TO_BYTE_COMPACTION_MODE: 10457 n.append(e[o]); 10458 break; 10459 case tr.TEXT_COMPACTION_MODE_LATCH: 10460 i = X.ALPHA; 10461 } 10462 break; 10463 case X.MIXED: 10464 if (r < tr.PL) a = tr.MIXED_CHARS[r]; 10465 else 10466 switch (r) { 10467 case tr.PL: 10468 i = X.PUNCT; 10469 break; 10470 case 26: 10471 a = ' '; 10472 break; 10473 case tr.LL: 10474 i = X.LOWER; 10475 break; 10476 case tr.AL: 10477 i = X.ALPHA; 10478 break; 10479 case tr.PS: 10480 (s = i), (i = X.PUNCT_SHIFT); 10481 break; 10482 case tr.MODE_SHIFT_TO_BYTE_COMPACTION_MODE: 10483 n.append(e[o]); 10484 break; 10485 case tr.TEXT_COMPACTION_MODE_LATCH: 10486 i = X.ALPHA; 10487 } 10488 break; 10489 case X.PUNCT: 10490 if (r < tr.PAL) a = tr.PUNCT_CHARS[r]; 10491 else 10492 switch (r) { 10493 case tr.PAL: 10494 i = X.ALPHA; 10495 break; 10496 case tr.MODE_SHIFT_TO_BYTE_COMPACTION_MODE: 10497 n.append(e[o]); 10498 break; 10499 case tr.TEXT_COMPACTION_MODE_LATCH: 10500 i = X.ALPHA; 10501 } 10502 break; 10503 case X.ALPHA_SHIFT: 10504 if (((i = s), r < 26)) a = String.fromCharCode(65 + r); 10505 else 10506 switch (r) { 10507 case 26: 10508 a = ' '; 10509 break; 10510 case tr.TEXT_COMPACTION_MODE_LATCH: 10511 i = X.ALPHA; 10512 } 10513 break; 10514 case X.PUNCT_SHIFT: 10515 if (((i = s), r < tr.PAL)) a = tr.PUNCT_CHARS[r]; 10516 else 10517 switch (r) { 10518 case tr.PAL: 10519 i = X.ALPHA; 10520 break; 10521 case tr.MODE_SHIFT_TO_BYTE_COMPACTION_MODE: 10522 n.append(e[o]); 10523 break; 10524 case tr.TEXT_COMPACTION_MODE_LATCH: 10525 i = X.ALPHA; 10526 } 10527 } 10528 '' !== a && n.append(a), o++; 10529 } 10530 } 10531 static byteCompaction(t, e, r, n, i) { 10532 let s = new Qe(), 10533 o = 0, 10534 a = 0, 10535 l = !1; 10536 switch (t) { 10537 case tr.BYTE_COMPACTION_MODE_LATCH: 10538 let t = new Int32Array(6), 10539 r = e[n++]; 10540 for (; n < e[0] && !l; ) 10541 switch (((t[o++] = r), (a = 900 * a + r), (r = e[n++]), r)) { 10542 case tr.TEXT_COMPACTION_MODE_LATCH: 10543 case tr.BYTE_COMPACTION_MODE_LATCH: 10544 case tr.NUMERIC_COMPACTION_MODE_LATCH: 10545 case tr.BYTE_COMPACTION_MODE_LATCH_6: 10546 case tr.BEGIN_MACRO_PDF417_CONTROL_BLOCK: 10547 case tr.BEGIN_MACRO_PDF417_OPTIONAL_FIELD: 10548 case tr.MACRO_PDF417_TERMINATOR: 10549 n--, (l = !0); 10550 break; 10551 default: 10552 if (o % 5 == 0 && o > 0) { 10553 for (let t = 0; t < 6; ++t) s.write(Number($e(a) >> $e(8 * (5 - t)))); 10554 (a = 0), (o = 0); 10555 } 10556 } 10557 n === e[0] && r < tr.TEXT_COMPACTION_MODE_LATCH && (t[o++] = r); 10558 for (let e = 0; e < o; e++) s.write(t[e]); 10559 break; 10560 case tr.BYTE_COMPACTION_MODE_LATCH_6: 10561 for (; n < e[0] && !l; ) { 10562 let t = e[n++]; 10563 if (t < tr.TEXT_COMPACTION_MODE_LATCH) o++, (a = 900 * a + t); 10564 else 10565 switch (t) { 10566 case tr.TEXT_COMPACTION_MODE_LATCH: 10567 case tr.BYTE_COMPACTION_MODE_LATCH: 10568 case tr.NUMERIC_COMPACTION_MODE_LATCH: 10569 case tr.BYTE_COMPACTION_MODE_LATCH_6: 10570 case tr.BEGIN_MACRO_PDF417_CONTROL_BLOCK: 10571 case tr.BEGIN_MACRO_PDF417_OPTIONAL_FIELD: 10572 case tr.MACRO_PDF417_TERMINATOR: 10573 n--, (l = !0); 10574 } 10575 if (o % 5 == 0 && o > 0) { 10576 for (let t = 0; t < 6; ++t) s.write(Number($e(a) >> $e(8 * (5 - t)))); 10577 (a = 0), (o = 0); 10578 } 10579 } 10580 } 10581 return i.append(I.decode(s.toByteArray(), r)), n; 10582 } 10583 static numericCompaction(t, e, r) { 10584 let n = 0, 10585 i = !1, 10586 s = new Int32Array(tr.MAX_NUMERIC_CODEWORDS); 10587 for (; e < t[0] && !i; ) { 10588 let o = t[e++]; 10589 if ((e === t[0] && (i = !0), o < tr.TEXT_COMPACTION_MODE_LATCH)) (s[n] = o), n++; 10590 else 10591 switch (o) { 10592 case tr.TEXT_COMPACTION_MODE_LATCH: 10593 case tr.BYTE_COMPACTION_MODE_LATCH: 10594 case tr.BYTE_COMPACTION_MODE_LATCH_6: 10595 case tr.BEGIN_MACRO_PDF417_CONTROL_BLOCK: 10596 case tr.BEGIN_MACRO_PDF417_OPTIONAL_FIELD: 10597 case tr.MACRO_PDF417_TERMINATOR: 10598 e--, (i = !0);
10599 } 10600 (n % tr.MAX_NUMERIC_CODEWORDS == 0 || o === tr.NUMERIC_COMPACTION_MODE_LATCH || i) && 10601 n > 0 && 10602 (r.append(tr.decodeBase900toBase10(s, n)), (n = 0)); 10603 } 10604 return e; 10605 } 10606 static decodeBase900toBase10(t, e) { 10607 let r = $e(0); 10608 for (let n = 0; n < e; n++) r += tr.EXP900[e - n - 1] * $e(t[n]); 10609 let n = r.toString(); 10610 if ('1' !== n.charAt(0)) throw new E(); 10611 return n.substring(1); 10612 } 10613 } 10614 (tr.TEXT_COMPACTION_MODE_LATCH = 900), 10615 (tr.BYTE_COMPACTION_MODE_LATCH = 901), 10616 (tr.NUMERIC_COMPACTION_MODE_LATCH = 902), 10617 (tr.BYTE_COMPACTION_MODE_LATCH_6 = 924), 10618 (tr.ECI_USER_DEFINED = 925), 10619 (tr.ECI_GENERAL_PURPOSE = 926), 10620 (tr.ECI_CHARSET = 927), 10621 (tr.BEGIN_MACRO_PDF417_CONTROL_BLOCK = 928), 10622 (tr.BEGIN_MACRO_PDF417_OPTIONAL_FIELD = 923), 10623 (tr.MACRO_PDF417_TERMINATOR = 922), 10624 (tr.MODE_SHIFT_TO_BYTE_COMPACTION_MODE = 913), 10625 (tr.MAX_NUMERIC_CODEWORDS = 15), 10626 (tr.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME = 0), 10627 (tr.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT = 1), 10628 (tr.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP = 2), 10629 (tr.MACRO_PDF417_OPTIONAL_FIELD_SENDER = 3), 10630 (tr.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE = 4), 10631 (tr.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE = 5), 10632 (tr.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM = 6), 10633 (tr.PL = 25), 10634 (tr.LL = 27), 10635 (tr.AS = 27), 10636 (tr.ML = 28), 10637 (tr.AL = 28), 10638 (tr.PS = 29), 10639 (tr.PAL = 29), 10640 (tr.PUNCT_CHARS = ';<>@[\\]_`~!\r\t,:\n-.$/"|*()?{}\''), 10641 (tr.MIXED_CHARS = '0123456789&\r\t,:#-.$/+%*=^'), 10642 (tr.EXP900 = je() 10643 ? (function () { 10644 let t = []; 10645 t[0] = $e(1); 10646 let e = $e(900); 10647 t[1] = e; 10648 for (let r = 2; r < 16; r++) t[r] = t[r - 1] * e; 10649 return t; 10650 })() 10651 : []), 10652 (tr.NUMBER_OF_SEQUENCE_CODEWORDS = 2); 10653 class er { 10654 constructor() {} 10655 static decode(t, e, r, n, i, s, o) { 10656 let a, 10657 l = new ve(t, e, r, n, i), 10658 h = null, 10659 c = null; 10660 for (let r = !0; ; r = !1) { 10661 if ( 10662 (null != e && (h = er.getRowIndicatorColumn(t, l, e, !0, s, o)), 10663 null != n && (c = er.getRowIndicatorColumn(t, l, n, !1, s, o)), 10664 (a = er.merge(h, c)), 10665 null == a) 10666 ) 10667 throw R.getNotFoundInstance(); 10668 let i = a.getBoundingBox(); 10669 if (!r || null == i || !(i.getMinY() < l.getMinY() || i.getMaxY() > l.getMaxY())) break; 10670 l = i; 10671 } 10672 a.setBoundingBox(l); 10673 let u = a.getBarcodeColumnCount() + 1; 10674 a.setDetectionResultColumn(0, h), a.setDetectionResultColumn(u, c); 10675 let d = null != h; 10676 for (let e = 1; e <= u; e++) { 10677 let r, 10678 n = d ? e : u - e; 10679 if (void 0 !== a.getDetectionResultColumn(n)) continue; 10680 (r = 0 === n || n === u ? new Ge(l, 0 === n) : new Ue(l)), a.setDetectionResultColumn(n, r); 10681 let i = -1, 10682 h = i; 10683 for (let e = l.getMinY(); e <= l.getMaxY(); e++) { 10684 if (((i = er.getStartColumn(a, n, e, d)), i < 0 || i > l.getMaxX())) { 10685 if (-1 === h) continue; 10686 i = h; 10687 } 10688 let c = er.detectCodeword(t, l.getMinX(), l.getMaxX(), d, i, e, s, o); 10689 null != c && (r.setCodeword(e, c), (h = i), (s = Math.min(s, c.getWidth())), (o = Math.max(o, c.getWidth()))); 10690 } 10691 } 10692 return er.createDecoderResult(a); 10693 } 10694 static merge(t, e) { 10695 if (null == t && null == e) return null; 10696 let r = er.getBarcodeMetadata(t, e); 10697 if (null == r) return null; 10698 let n = ve.merge(er.adjustBoundingBox(t), er.adjustBoundingBox(e)); 10699 return new Xe(r, n); 10700 } 10701 static adjustBoundingBox(t) { 10702 if (null == t) return null; 10703 let e = t.getRowHeights(); 10704 if (null == e) return null; 10705 let r = er.getMax(e), 10706 n = 0; 10707 for (let t of e) if (((n += r - t), t > 0)) break; 10708 let i = t.getCodewords(); 10709 for (let t = 0; n > 0 && null == i[t]; t++) n--; 10710 let s = 0; 10711 for (let t = e.length - 1; t >= 0 && ((s += r - e[t]), !(e[t] >
10711 0)); t--); 10712 for (let t = i.length - 1; s > 0 && null == i[t]; t--) s--; 10713 return t.getBoundingBox().addMissingRows(n, s, t.isLeft()); 10714 } 10715 static getMax(t) { 10716 let e = -1; 10717 for (let r of t) e = Math.max(e, r); 10718 return e; 10719 } 10720 static getBarcodeMetadata(t, e) { 10721 let r, n; 10722 return null == t || null == (r = t.getBarcodeMetadata()) 10723 ? null == e 10724 ? null 10725 : e.getBarcodeMetadata() 10726 : null == e || null == (n = e.getBarcodeMetadata()) 10727 ? r 10728 : r.getColumnCount() !== n.getColumnCount() && 10729 r.getErrorCorrectionLevel() !== n.getErrorCorrectionLevel() && 10730 r.getRowCount() !== n.getRowCount() 10731 ? null 10732 : r; 10733 } 10734 static getRowIndicatorColumn(t, e, r, n, i, s) { 10735 let o = new Ge(e, n); 10736 for (let a = 0; a < 2; a++) { 10737 let l = 0 === a ? 1 : -1, 10738 h = Math.trunc(Math.trunc(r.getX())); 10739 for (let a = Math.trunc(Math.trunc(r.getY())); a <= e.getMaxY() && a >= e.getMinY(); a += l) { 10740 let e = er.detectCodeword(t, 0, t.getWidth(), n, h, a, i, s); 10741 null != e && (o.setCodeword(a, e), (h = n ? e.getStartX() : e.getEndX())); 10742 } 10743 } 10744 return o; 10745 } 10746 static adjustCodewordCount(t, e) { 10747 let r = e[0][1], 10748 n = r.getValue(), 10749 i = t.getBarcodeColumnCount() * t.getBarcodeRowCount() - er.getNumberOfECCodeWords(t.getBarcodeECLevel()); 10750 if (0 === n.length) { 10751 if (i < 1 || i > Be.MAX_CODEWORDS_IN_BARCODE) throw R.getNotFoundInstance(); 10752 r.setValue(i); 10753 } else n[0] !== i && r.setValue(i); 10754 } 10755 static createDecoderResult(t) { 10756 let e = er.createBarcodeMatrix(t); 10757 er.adjustCodewordCount(t, e); 10758 let r = new Array(), 10759 n = new Int32Array(t.getBarcodeRowCount() * t.getBarcodeColumnCount()), 10760 i = [], 10761 s = new Array(); 10762 for (let o = 0; o < t.getBarcodeRowCount(); o++) 10763 for (let a = 0; a < t.getBarcodeColumnCount(); a++) { 10764 let l = e[o][a + 1].getValue(), 10765 h = o * t.getBarcodeColumnCount() + a; 10766 0 === l.length ? r.push(h) : 1 === l.length ? (n[h] = l[0]) : (s.push(h), i.push(l)); 10767 } 10768 let o = new Array(i.length); 10769 for (let t = 0; t < o.length; t++) o[t] = i[t]; 10770 return er.createDecoderResultFromAmbiguousValues(t.getBarcodeECLevel(), n, Be.toIntArray(r), Be.toIntArray(s), o); 10771 } 10772 static createDecoderResultFromAmbiguousValues(t, e, r, n, i) { 10773 let s = new Int32Array(n.length), 10774 o = 100; 10775 for (; o-- > 0; ) { 10776 for (let t = 0; t < s.length; t++) e[n[t]] = i[t][s[t]]; 10777 try { 10778 return er.decodeCodewords(e, t, r); 10779 } catch (t) { 10780 if (!(t instanceof l)) throw t; 10781 } 10782 if (0 === s.length) throw l.getChecksumInstance(); 10783 for (let t = 0; t < s.length; t++) { 10784 if (s[t] < i[t].length - 1) { 10785 s[t]++; 10786 break; 10787 } 10788 if (((s[t] = 0), t === s.length - 1)) throw l.getChecksumInstance(); 10789 } 10790 } 10791 throw l.getChecksumInstance(); 10792 } 10793 static createBarcodeMatrix(t) { 10794 let e = Array.from({ length: t.getBarcodeRowCount() }, () => new Array(t.getBarcodeColumnCount() + 2)); 10795 for (let t = 0; t < e.length; t++) for (let r = 0; r < e[t].length; r++) e[t][r] = new He(); 10796 let r = 0; 10797 for (let n of t.getDetectionResultColumns()) { 10798 if (null != n) 10799 for (let t of n.getCodewords()) 10800 if (null != t) { 10801 let n = t.getRowNumber(); 10802 if (n >= 0) { 10803 if (n >= e.length) continue; 10804 e[n][r].setValue(t.getValue()); 10805 } 10806 } 10807 r++; 10808 } 10809 return e; 10810 } 10811 static isValidBarcodeColumn(t, e) { 10812 return e >= 0 && e <= t.getBarcodeColumnCount() + 1; 10813 } 10814 static getStartColumn(t, e, r, n) { 10815 let i = n ? 1 : -1, 10816 s = null; 10817 if ((er.isValidBarcodeColumn(t, e - i) && (s = t.getDetectionResultColumn(e - i).getCodeword(r)), null != s)) 10818 return n ? s.getEndX() : s.getStartX(); 10819 if (((s = t.getDetectionResultColumn(e).getCodewordNearby(r)), null != s)) return n ? s.getStartX() : s.getEndX(); 10820 if ( 10821 (er.isValidBarcodeColumn(t, e - i) && (s = t.getDetectionResultColumn(e - i).getCodewordNearby(r)), null != s) 10822 ) 10823 return n ? s.getEndX() : s.getStartX(); 10824 let o = 0; 10825 for (; er.isValidBarcodeColumn(t, e - i); ) { 10826 e -= i; 10827 for (let r of t.getDetectionResultColumn(e).getCodewords()) 10828 if (null != r) return (n ? r.getEndX() : r.getStartX()) + i * o * (r.getEndX() - r.getStartX()); 10829 o++; 10830 } 10831 return n ? t.getBoundingBox().getMinX() : t.getBoundingBox().getMaxX(); 10832 } 10833 static detectCodeword(t, e, r, n, i, s, o, a) { 10834 i = er.adjustCodewordStartColumn(t, e, r, n, i, s); 10835 let l, 10836 h = er.getModuleBitCount(t, e, r, n, i, s); 10837 if (null == h) return null; 10838 let c = tt.sum(h); 10839 if (n) l = i + c; 10840 else { 10841 for (let t = 0; t < h.length / 2; t++) { 10842 let e = h[t]; 10843 (h[t] = h[h.length - 1 - t]), (h[h.length - 1 - t] = e); 10844 } 10845 (l = i), (i = l - c); 10846 } 10847 if (!er.checkCodewordSkew(c, o, a)) return null; 10848 let u = ze.getDecodedValue(h), 10849 d = Be.getCodeword(u); 10850 return -1 === d ? null : new We(i, l, er.getCodewordBucketNumber(u), d); 10851 } 10852 static getModuleBitCount(t, e, r, n, i, s) { 10853 let o = i, 10854 a = new Int32Array(8), 10855 l = 0, 10856 h = n ? 1 : -1, 10857 c = n; 10858 for (; (n ? o < r : o >= e) && l < a.length; ) t.get(o, s) === c ? (a[l]++, (o += h)) : (l++, (c = !c)); 10859 return l === a.length || (o === (n ? r : e) && l === a.length - 1) ? a : null; 10860 } 10861 static getNumberOfECCodeWords(t) { 10862 return 2 << t; 10863 } 10864 static adjustCodewordStartColumn(t, e, r, n, i, s) { 10865 let o = i, 10866 a = n ? -1 : 1; 10867 for (let l = 0; l < 2; l++) { 10868 for (; (n ? o >= e : o < r) && n === t.get(o, s); ) { 10869 if (Math.abs(i - o) > er.CODEWORD_SKEW_SIZE) return i; 10870 o += a; 10871 } 10872 (a = -a), (n = !n); 10873 } 10874 return o; 10875 } 10876 static checkCodewordSkew(t, e, r) { 10877 return e - er.CODEWORD_SKEW_SIZE <= t && t <= r + er.CODEWORD_SKEW_SIZE; 10878 } 10879 static decodeCodewords(t, e, r) { 10880 if (0 === t.length) throw E.getFormatInstance(); 10881 let n = 1 << (e + 1), 10882 i = er.correctErrors(t, r, n); 10883 er.verifyCodewordCount(t, n); 10884 let s = tr.decode(t, '' + e); 10885 return s.setErrorsCorrected(i), s.setErasures(r.length), s; 10886 } 10887 static correctErrors(t, e, r) { 10888 if ((null != e && e.length > r / 2 + er.MAX_ERRORS) || r < 0 || r > er.MAX_EC_CODEWORDS) 10889 throw l.getChecksumInstance(); 10890 return er.errorCorrection.decode(t, r, e); 10891 } 10892 static verifyCodewordCount(t, e) { 10893 if (t.length < 4) throw E.getFormatInstance(); 10894 let r = t[0]; 10895 if (r > t.length) throw E.getFormatInstance(); 10896 if (0 === r) { 10897 if (!(e < t.length)) throw E.getFormatInstance(); 10898 t[0] = t.length - e; 10899 } 10900 } 10901 static getBitCountForCodeword(t) { 10902 let e = new Int32Array(8), 10903 r = 0, 10904 n = e.length - 1; 10905 for (; !((1 & t) !== r && ((r = 1 & t), n--, n < 0)); ) e[n]++, (t >>= 1); 10906 return e; 10907 } 10908 static getCodewordBucketNumber(t) { 10909 return t instanceof Int32Array 10910 ? this.getCodewordBucketNumber_Int32Array(t) 10911 : this.getCodewordBucketNumber_number(t); 10912 } 10913 static getCodewordBucketNumber_number(t) { 10914 return er.getCodewordBucketNumber(er.getBitCountForCodeword(t)); 10915 } 10916 static getCodewordBucketNumber_Int32Array(t) { 10917 return (t[0] - t[2] + t[4] - t[6] + 9) % 9; 10918 } 10919 static toString(t) { 10920 let e = new Ve(); 10921 for (let r = 0; r < t.length; r++) { 10922 e.format('Row %2d: ', r); 10923 for (let n = 0; n < t[r].length; n++) { 10924 let i = t[r][n]; 10925 0 === i.getValue().length 10926 ? e.format(' ', null) 10927 : e.format('%4d(%2d)', i.getValue()[0], i.getConfidence(i.getValue()[0])); 10928 } 10929 e.format('%n'); 10930 } 10931 return e.toString(); 10932 } 10933 } 10934 (er.CODEWORD_SKEW_SIZE = 2), (er.MAX_ERRORS = 3), (er.MAX_EC_CODEWORDS = 512), (er.errorCorrection = new ke()); 10935 class rr { 10936 decode(t, e = null) { 10937 let r = rr.decode(t, e, !1); 10938 if (null == r || 0 === r.length || null == r[0]) throw R.getNotFoundInstance(); 10939 return r[0]; 10940 } 10941 decodeMultiple(t, e = null) {
10942 try { 10943 return rr.decode(t, e, !0); 10944 } catch (t) { 10945 if (t instanceof E || t instanceof l) throw R.getNotFoundInstance(); 10946 throw t; 10947 } 10948 } 10949 static decode(t, e, r) { 10950 const n = new Array(), 10951 i = Pe.detectMultiple(t, e, r); 10952 for (const t of i.getPoints()) { 10953 const e = er.decode(i.getBits(), t[4], t[5], t[6], t[7], rr.getMinCodewordWidth(t), rr.getMaxCodewordWidth(t)), 10954 r = new F(e.getText(), e.getRawBytes(), void 0, t, v.PDF_417); 10955 r.putMetadata(W.ERROR_CORRECTION_LEVEL, e.getECLevel()); 10956 const s = e.getOther(); 10957 null != s && r.putMetadata(W.PDF417_EXTRA_METADATA, s), n.push(r); 10958 } 10959 return n.map((t) => t); 10960 } 10961 static getMaxWidth(t, e) { 10962 return null == t || null == e ? 0 : Math.trunc(Math.abs(t.getX() - e.getX())); 10963 } 10964 static getMinWidth(t, e) { 10965 return null == t || null == e ? f.MAX_VALUE : Math.trunc(Math.abs(t.getX() - e.getX())); 10966 } 10967 static getMaxCodewordWidth(t) { 10968 return Math.floor( 10969 Math.max( 10970 Math.max( 10971 rr.getMaxWidth(t[0], t[4]), 10972 (rr.getMaxWidth(t[6], t[2]) * Be.MODULES_IN_CODEWORD) / Be.MODULES_IN_STOP_PATTERN, 10973 ), 10974 Math.max( 10975 rr.getMaxWidth(t[1], t[5]), 10976 (rr.getMaxWidth(t[7], t[3]) * Be.MODULES_IN_CODEWORD) / Be.MODULES_IN_STOP_PATTERN, 10977 ), 10978 ), 10979 ); 10980 } 10981 static getMinCodewordWidth(t) { 10982 return Math.floor( 10983 Math.min( 10984 Math.min( 10985 rr.getMinWidth(t[0], t[4]), 10986 (rr.getMinWidth(t[6], t[2]) * Be.MODULES_IN_CODEWORD) / Be.MODULES_IN_STOP_PATTERN, 10987 ), 10988 Math.min( 10989 rr.getMinWidth(t[1], t[5]), 10990 (rr.getMinWidth(t[7], t[3]) * Be.MODULES_IN_CODEWORD) / Be.MODULES_IN_STOP_PATTERN, 10991 ), 10992 ), 10993 ); 10994 } 10995 reset() {} 10996 } 10997 class nr extends i {} 10998 nr.kind = 'ReaderException'; 10999 class ir { 11000 decode(t, e) { 11001 return this.setHints(e), this.decodeInternal(t); 11002 } 11003 decodeWithState(t) { 11004 return (null !== this.readers && void 0 !== this.readers) || this.setHints(null), this.decodeInternal(t); 11005 } 11006 setHints(t) { 11007 this.hints = t; 11008 const e = null != t && void 0 !== t.get(C.TRY_HARDER), 11009 r = null == t ? null : t.get(C.POSSIBLE_FORMATS), 11010 n = new Array(); 11011 if (null != r) { 11012 const i = r.some( 11013 (t) => 11014 t === v.UPC_A || 11015 t === v.UPC_E || 11016 t === v.EAN_13 || 11017 t === v.EAN_8 || 11018 t === v.CODABAR || 11019 t === v.CODE_39 || 11020 t === v.CODE_93 || 11021 t === v.CODE_128 || 11022 t === v.ITF || 11023 t === v.RSS_14 || 11024 t === v.RSS_EXPANDED, 11025 ); 11026 i && !e && n.push(new ee(t)), 11027 r.includes(v.QR_CODE) && n.push(new Me()), 11028 r.includes(v.DATA_MATRIX) && n.push(new ue()), 11029 r.includes(v.AZTEC) && n.push(new dt()), 11030 r.includes(v.PDF_417) && n.push(new rr()), 11031 i && e && n.push(new ee(t)); 11032 } 11033 0 === n.length && 11034 (e || n.push(new ee(t)), 11035 n.push(new Me()), 11036 n.push(new ue()), 11037 n.push(new dt()), 11038 n.push(new rr()), 11039 e && n.push(new ee(t))), 11040 (this.readers = n); 11041 } 11042 reset() { 11043 if (null !== this.readers) for (const t of this.readers) t.reset(); 11044 } 11045 decodeInternal(t) { 11046 if (null === this.readers) throw new nr('No readers where selected, nothing can be read.'); 11047 for (const e of this.readers) 11048 try { 11049 return e.decode(t, this.hints); 11050 } catch (t) { 11051 if (t instanceof nr) continue; 11052 } 11053 throw new R('No MultiFormat Readers were able to detect the code.'); 11054 } 11055 } 11056 var sr; 11057 !(function (t) { 11058 (t[(t.ERROR_CORRECTION = 0)] = 'ERROR_CORRECTION'), 11059 (t[(t.CHARACTER_SET = 1)] = 'CHARACTER_SET'), 11060 (t[(t.DATA_MATRIX_SHAPE = 2)] = 'DATA_MATRIX_SHAPE'), 11061 (t[(t.MIN_SIZE = 3)] = 'MIN_SIZE'), 11062 (t[(t.MAX_SIZE = 4)] = 'MAX_SIZE'), 11063 (t[(t.MARGIN = 5)] = 'MARGIN'), 11064 (t[(t.PDF417_COMPACT = 6)] = 'PDF417_COMPACT'), 11065 (t[(t.PDF417_COMPACTION = 7)] = 'PDF417_COMPACTION'), 11066 (t[(t.PDF417_DIMENSIONS = 8)] = 'PDF417_DIMENSIONS'), 11067 (t[(t.AZTEC_LAYERS = 9)] = 'AZTEC_LAYERS'), 11068 (t[(t.QR_VERSION = 10)] = 'QR_VERSION'); 11069 })(sr || (sr = {})); 11070 var or = sr; 11071 class ar { 11072 constructor(t) { 11073 (this.field = t), (this.cachedGenerators = []), this.cachedGenerators.push(new Z(t, Int32Array.from([1]))); 11074 } 11075 buildGenerator(t) { 11076 const e = this.cachedGenerators; 11077 if (t >= e.length) { 11078 let r = e[e.length - 1]; 11079 const n = this.field; 11080 for (let i = e.length; i <= t; i++) { 11081 const t = r.multiply(new Z(n, Int32Array.from([1, n.exp(i - 1 + n.getGeneratorBase())]))); 11082 e.push(t), (r = t); 11083 } 11084 } 11085 return e[t]; 11086 } 11087 encode(t, e) { 11088 if (0 === e) throw new o('No error correction bytes'); 11089 const r = t.length - e; 11090 if (r <= 0) throw new o('No data bytes provided'); 11091 const n = this.buildGenerator(e), 11092 i = new Int32Array(r); 11093 c.arraycopy(t, 0, i, 0, r); 11094 let s = new Z(this.field, i); 11095 s = s.multiplyByMonomial(e, 1); 11096 const a = s.divide(n)[1].getCoefficients(), 11097 l = e - a.length; 11098 for (let e = 0; e < l; e++) t[r + e] = 0; 11099 c.arraycopy(a, 0, t, r + l, a.length); 11100 } 11101 } 11102 class lr { 11103 constructor() {} 11104 static applyMaskPenaltyRule1(t) {
11105 return lr.applyMaskPenaltyRule1Internal(t, !0) + lr.applyMaskPenaltyRule1Internal(t, !1); 11106 } 11107 static applyMaskPenaltyRule2(t) { 11108 let e = 0; 11109 const r = t.getArray(), 11110 n = t.getWidth(), 11111 i = t.getHeight(); 11112 for (let t = 0; t < i - 1; t++) { 11113 const i = r[t]; 11114 for (let s = 0; s < n - 1; s++) { 11115 const n = i[s]; 11116 n === i[s + 1] && n === r[t + 1][s] && n === r[t + 1][s + 1] && e++; 11117 } 11118 } 11119 return lr.N2 * e; 11120 } 11121 static applyMaskPenaltyRule3(t) { 11122 let e = 0; 11123 const r = t.getArray(), 11124 n = t.getWidth(), 11125 i = t.getHeight(); 11126 for (let t = 0; t < i; t++) 11127 for (let s = 0; s < n; s++) { 11128 const o = r[t]; 11129 s + 6 < n && 11130 1 === o[s] && 11131 0 === o[s + 1] && 11132 1 === o[s + 2] && 11133 1 === o[s + 3] && 11134 1 === o[s + 4] && 11135 0 === o[s + 5] && 11136 1 === o[s + 6] && 11137 (lr.isWhiteHorizontal(o, s - 4, s) || lr.isWhiteHorizontal(o, s + 7, s + 11)) && 11138 e++, 11139 t + 6 < i && 11140 1 === r[t][s] && 11141 0 === r[t + 1][s] && 11142 1 === r[t + 2][s] && 11143 1 === r[t + 3][s] && 11144 1 === r[t + 4][s] && 11145 0 === r[t + 5][s] && 11146 1 === r[t + 6][s] && 11147 (lr.isWhiteVertical(r, s, t - 4, t) || lr.isWhiteVertical(r, s, t + 7, t + 11)) && 11148 e++; 11149 } 11150 return e * lr.N3; 11151 } 11152 static isWhiteHorizontal(t, e, r) { 11153 (e = Math.max(e, 0)), (r = Math.min(r, t.length)); 11154 for (let n = e; n < r; n++) if (1 === t[n]) return !1; 11155 return !0; 11156 } 11157 static isWhiteVertical(t, e, r, n) { 11158 (r = Math.max(r, 0)), (n = Math.min(n, t.length)); 11159 for (let i = r; i < n; i++) if (1 === t[i][e]) return !1; 11160 return !0; 11161 } 11162 static applyMaskPenaltyRule4(t) { 11163 let e = 0; 11164 const r = t.getArray(), 11165 n = t.getWidth(), 11166 i = t.getHeight(); 11167 for (let t = 0; t < i; t++) { 11168 const i = r[t]; 11169 for (let t = 0; t < n; t++) 1 === i[t] && e++; 11170 } 11171 const s = t.getHeight() * t.getWidth(); 11172 return Math.floor((10 * Math.abs(2 * e - s)) / s) * lr.N4; 11173 } 11174 static getDataMaskBit(t, e, r) { 11175 let n, i; 11176 switch (t) { 11177 case 0: 11178 n = (r + e) & 1; 11179 break; 11180 case 1: 11181 n = 1 & r; 11182 break; 11183 case 2: 11184 n = e % 3; 11185 break; 11186 case 3: 11187 n = (r + e) % 3; 11188 break; 11189 case 4: 11190 n = (Math.floor(r / 2) + Math.floor(e / 3)) & 1; 11191 break; 11192 case 5: 11193 (i = r * e), (n = (1 & i) + (i % 3)); 11194 break; 11195 case 6: 11196 (i = r * e), (n = ((1 & i) + (i % 3)) & 1); 11197 break; 11198 case 7: 11199 (i = r * e), (n = ((i % 3) + ((r + e) & 1)) & 1); 11200 break; 11201 default: 11202 throw new o('Invalid mask pattern: ' + t); 11203 } 11204 return 0 === n; 11205 } 11206 static applyMaskPenaltyRule1Internal(t, e) { 11207 let r = 0; 11208 const n = e ? t.getHeight() : t.getWidth(), 11209 i = e ? t.getWidth() : t.getHeight(), 11210 s = t.getArray(); 11211 for (let t = 0; t < n; t++) { 11212 let n = 0, 11213 o = -1; 11214 for (let a = 0; a < i; a++) { 11215 const i = e ? s[t][a] : s[a][t]; 11216 i === o ? n++ : (n >= 5 && (r += lr.N1 + (n - 5)), (n = 1), (o = i)); 11217 } 11218 n >= 5 && (r += lr.N1 + (n - 5)); 11219 } 11220 return r; 11221 } 11222 } 11223 (lr.N1 = 3), (lr.N2 = 3), (lr.N3 = 40), (lr.N4 = 10); 11224 class hr { 11225 constructor(t, e) { 11226 (this.width = t), (this.height = e); 11227 const r = new Array(e); 11228 for (let n = 0; n !== e; n++) r[n] = new Uint8Array(t); 11229 this.bytes = r; 11230 } 11231 getHeight() { 11232 return this.height; 11233 } 11234 getWidth() { 11235 return this.width; 11236 } 11237 get(t, e) { 11238 return this.bytes[e][t]; 11239 } 11240 getArray() { 11241 return this.bytes; 11242 } 11243 setNumber(t, e, r) { 11244 this.bytes[e][t] = r; 11245 } 11246 setBoolean(t, e, r) { 11247 this.bytes[e][t] = r ? 1 : 0; 11248 } 11249 clear(t) {
11250 for (const e of this.bytes) g.fill(e, t); 11251 } 11252 equals(t) { 11253 if (!(t instanceof hr)) return !1; 11254 const e = t; 11255 if (this.width !== e.width) return !1; 11256 if (this.height !== e.height) return !1; 11257 for (let t = 0, r = this.height; t < r; ++t) { 11258 const r = this.bytes[t], 11259 n = e.bytes[t]; 11260 for (let t = 0, e = this.width; t < e; ++t) if (r[t] !== n[t]) return !1; 11261 } 11262 return !0; 11263 } 11264 toString() { 11265 const t = new p(); 11266 for (let e = 0, r = this.height; e < r; ++e) { 11267 const r = this.bytes[e]; 11268 for (let e = 0, n = this.width; e < n; ++e) 11269 switch (r[e]) { 11270 case 0: 11271 t.append(' 0'); 11272 break; 11273 case 1: 11274 t.append(' 1'); 11275 break; 11276 default: 11277 t.append(' '); 11278 } 11279 t.append('\n'); 11280 } 11281 return t.toString(); 11282 } 11283 } 11284 class cr { 11285 constructor() { 11286 this.maskPattern = -1; 11287 } 11288 getMode() { 11289 return this.mode; 11290 } 11291 getECLevel() { 11292 return this.ecLevel; 11293 } 11294 getVersion() { 11295 return this.version; 11296 } 11297 getMaskPattern() { 11298 return this.maskPattern; 11299 } 11300 getMatrix() { 11301 return this.matrix; 11302 } 11303 toString() { 11304 const t = new p(); 11305 return ( 11306 t.append('<<\n'), 11307 t.append(' mode: '), 11308 t.append(this.mode ? this.mode.toString() : 'null'), 11309 t.append('\n ecLevel: '), 11310 t.append(this.ecLevel ? this.ecLevel.toString() : 'null'), 11311 t.append('\n version: '), 11312 t.append(this.version ? this.version.toString() : 'null'), 11313 t.append('\n maskPattern: '), 11314 t.append(this.maskPattern.toString()), 11315 this.matrix ? (t.append('\n matrix:\n'), t.append(this.matrix.toString())) : t.append('\n matrix: null\n'), 11316 t.append('>>\n'), 11317 t.toString() 11318 ); 11319 } 11320 setMode(t) { 11321 this.mode = t; 11322 } 11323 setECLevel(t) { 11324 this.ecLevel = t; 11325 } 11326 setVersion(t) { 11327 this.version = t; 11328 } 11329 setMaskPattern(t) { 11330 this.maskPattern = t; 11331 } 11332 setMatrix(t) { 11333 this.matrix = t; 11334 } 11335 static isValidMaskPattern(t) { 11336 return t >= 0 && t < cr.NUM_MASK_PATTERNS; 11337 } 11338 } 11339 cr.NUM_MASK_PATTERNS = 8; 11340 class ur extends i {} 11341 ur.kind = 'WriterException'; 11342 class dr { 11343 constructor() {} 11344 static clearMatrix(t) { 11345 t.clear(255); 11346 } 11347 static buildMatrix(t, e, r, n, i) { 11348 dr.clearMatrix(i), 11349 dr.embedBasicPatterns(r, i), 11350 dr.embedTypeInfo(e, n, i), 11351 dr.maybeEmbedVersionInfo(r, i), 11352 dr.embedDataBits(t, n, i); 11353 } 11354 static embedBasicPatterns(t, e) { 11355 dr.embedPositionDetectionPatternsAndSeparators(e), 11356 dr.embedDarkDotAtLeftBottomCorner(e), 11357 dr.maybeEmbedPositionAdjustmentPatterns(t, e), 11358 dr.embedTimingPatterns(e); 11359 } 11360 static embedTypeInfo(t, e, r) { 11361 const n = new w(); 11362 dr.makeTypeInfoBits(t, e, n); 11363 for (let t = 0, e = n.getSize(); t < e; ++t) { 11364 const e = n.get(n.getSize() - 1 - t), 11365 i = dr.TYPE_INFO_COORDINATES[t], 11366 s = i[0], 11367 o = i[1]; 11368 if ((r.setBoolean(s, o, e), t < 8)) { 11369 const n = r.getWidth() - t - 1, 11370 i = 8; 11371 r.setBoolean(n, i, e); 11372 } else { 11373 const n = 8, 11374 i = r.getHeight() - 7 + (t - 8); 11375 r.setBoolean(n, i, e); 11376 } 11377 } 11378 } 11379 static maybeEmbedVersionInfo(t, e) { 11380 if (t.getVersionNumber() < 7) return; 11381 const r = new w(); 11382 dr.makeVersionInfoBits(t, r); 11383 let n = 17; 11384 for (let t = 0; t < 6; ++t) 11385 for (let i = 0; i < 3; ++i) { 11386 const s = r.get(n); 11387 n--, e.setBoolean(t, e.getHeight() - 11 + i, s), e.setBoolean(e.getHeight() - 11 + i, t, s); 11388 } 11389 } 11390 static embedDataBits(t, e, r) { 11391 let n = 0, 11392 i = -1, 11393 s = r.getWidth() - 1, 11394 o = r.getHeight() - 1; 11395 for (; s > 0; ) { 11396 for (6 === s && (s -= 1); o >= 0 && o < r.getHeight(); ) { 11397 for (let i = 0; i < 2; ++i) { 11398 const a = s - i; 11399 if (!dr.isEmpty(r.get(a, o))) continue; 11400 let l; 11401 n < t.getSize() ? ((l = t.get(n)), ++n) : (l = !1), 11402 255 !== e && lr.getDataMaskBit(e, a, o) && (l = !l), 11403 r.setBoolean(a, o, l); 11404 } 11405 o += i; 11406 }
11407 (i = -i), (o += i), (s -= 2); 11408 } 11409 if (n !== t.getSize()) throw new ur('Not all bits consumed: ' + n + '/' + t.getSize()); 11410 } 11411 static findMSBSet(t) { 11412 return 32 - f.numberOfLeadingZeros(t); 11413 } 11414 static calculateBCHCode(t, e) { 11415 if (0 === e) throw new o('0 polynomial'); 11416 const r = dr.findMSBSet(e); 11417 for (t <<= r - 1; dr.findMSBSet(t) >= r; ) t ^= e << (dr.findMSBSet(t) - r); 11418 return t; 11419 } 11420 static makeTypeInfoBits(t, e, r) { 11421 if (!cr.isValidMaskPattern(e)) throw new ur('Invalid mask pattern'); 11422 const n = (t.getBits() << 3) | e; 11423 r.appendBits(n, 5); 11424 const i = dr.calculateBCHCode(n, dr.TYPE_INFO_POLY); 11425 r.appendBits(i, 10); 11426 const s = new w(); 11427 if ((s.appendBits(dr.TYPE_INFO_MASK_PATTERN, 15), r.xor(s), 15 !== r.getSize())) 11428 throw new ur('should not happen but we got: ' + r.getSize()); 11429 } 11430 static makeVersionInfoBits(t, e) { 11431 e.appendBits(t.getVersionNumber(), 6); 11432 const r = dr.calculateBCHCode(t.getVersionNumber(), dr.VERSION_INFO_POLY); 11433 if ((e.appendBits(r, 12), 18 !== e.getSize())) throw new ur('should not happen but we got: ' + e.getSize()); 11434 } 11435 static isEmpty(t) { 11436 return 255 === t; 11437 } 11438 static embedTimingPatterns(t) { 11439 for (let e = 8; e < t.getWidth() - 8; ++e) { 11440 const r = (e + 1) % 2; 11441 dr.isEmpty(t.get(e, 6)) && t.setNumber(e, 6, r), dr.isEmpty(t.get(6, e)) && t.setNumber(6, e, r); 11442 } 11443 } 11444 static embedDarkDotAtLeftBottomCorner(t) { 11445 if (0 === t.get(8, t.getHeight() - 8)) throw new ur(); 11446 t.setNumber(8, t.getHeight() - 8, 1); 11447 } 11448 static embedHorizontalSeparationPattern(t, e, r) { 11449 for (let n = 0; n < 8; ++n) { 11450 if (!dr.isEmpty(r.get(t + n, e))) throw new ur(); 11451 r.setNumber(t + n, e, 0); 11452 } 11453 } 11454 static embedVerticalSeparationPattern(t, e, r) { 11455 for (let n = 0; n < 7; ++n) { 11456 if (!dr.isEmpty(r.get(t, e + n))) throw new ur(); 11457 r.setNumber(t, e + n, 0); 11458 } 11459 } 11460 static embedPositionAdjustmentPattern(t, e, r) { 11461 for (let n = 0; n < 5; ++n) { 11462 const i = dr.POSITION_ADJUSTMENT_PATTERN[n]; 11463 for (let s = 0; s < 5; ++s) r.setNumber(t + s, e + n, i[s]); 11464 } 11465 } 11466 static embedPositionDetectionPattern(t, e, r) { 11467 for (let n = 0; n < 7; ++n) { 11468 const i = dr.POSITION_DETECTION_PATTERN[n]; 11469 for (let s = 0; s < 7; ++s) r.setNumber(t + s, e + n, i[s]); 11470 } 11471 } 11472 static embedPositionDetectionPatternsAndSeparators(t) { 11473 const e = dr.POSITION_DETECTION_PATTERN[0].length; 11474 dr.embedPositionDetectionPattern(0, 0, t), 11475 dr.embedPositionDetectionPattern(t.getWidth() - e, 0, t), 11476 dr.embedPositionDetectionPattern(0, t.getWidth() - e, t); 11477 dr.embedHorizontalSeparationPattern(0, 7, t), 11478 dr.embedHorizontalSeparationPattern(t.getWidth() - 8, 7, t), 11479 dr.embedHorizontalSeparationPattern(0, t.getWidth() - 8, t); 11480 dr.embedVerticalSeparationPattern(7, 0, t), 11481 dr.embedVerticalSeparationPattern(t.getHeight() - 7 - 1, 0, t), 11482 dr.embedVerticalSeparationPattern(7, t.getHeight() - 7, t); 11483 } 11484 static maybeEmbedPositionAdjustmentPatterns(t, e) { 11485 if (t.getVersionNumber() < 2) return; 11486 const r = t.getVersionNumber() - 1, 11487 n = dr.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[r]; 11488 for (let t = 0, r = n.length; t !== r; t++) { 11489 const i = n[t]; 11490 if (i >= 0) 11491 for (let t = 0; t !== r; t++) { 11492 const r = n[t]; 11493 r >= 0 && dr.isEmpty(e.get(r, i)) && dr.embedPositionAdjustmentPattern(r - 2, i - 2, e); 11494 } 11495 } 11496 } 11497 } 11498 (dr.POSITION_DETECTION_PATTERN = Array.from([ 11499 Int32Array.from([1, 1, 1, 1, 1, 1, 1]), 11500 Int32Array.from([1, 0, 0, 0, 0, 0, 1]), 11501 Int32Array.from([1, 0, 1, 1, 1, 0, 1]), 11502 Int32Array.from([1, 0, 1, 1, 1, 0, 1]), 11503 Int32Array.from([1, 0, 1, 1, 1, 0, 1]), 11504 Int32Array.from([1, 0, 0, 0, 0, 0, 1]), 11505 Int32Array.from([1, 1, 1, 1, 1, 1, 1]), 11506 ])), 11507 (dr.POSITION_ADJUSTMENT_PATTERN = Array.from([ 11508 Int32Array.from([1, 1, 1, 1, 1]), 11509 Int32Array.from([1, 0, 0, 0, 1]), 11510 Int32Array.from([1, 0, 1, 0, 1]), 11511 Int32Array.from([1, 0, 0, 0, 1]), 11512 Int32Array.from([1, 1, 1, 1, 1]), 11513 ])), 11514 (dr.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE = Array.from([ 11515 Int32Array.from([-1, -1, -1, -1, -1, -1, -1]), 11516 Int32Array.from([6, 18, -1, -1, -1, -1, -1]), 11517 Int32Array.from([6, 22, -1, -1, -1, -1, -1]), 11518 Int32Array.from([6, 26, -1, -1, -1, -1, -1]), 11519 Int32Array.from([6, 30, -1, -1, -1, -1, -1]), 11520 Int32Array.from([6, 34, -1, -1, -1, -1, -1]), 11521 Int32Array.from([6, 22, 38, -1, -1, -1, -1]), 11522 Int32Array.from([6, 24, 42, -1, -1, -1, -1]), 11523 Int32Array.from([6, 26, 46, -1, -1, -1, -1]), 11524 Int32Array.from([6, 28, 50, -1, -1, -1, -1]), 11525 Int32Array.from([6, 30, 54, -1, -1, -1, -1]), 11526 Int32Array.from([6, 32, 58, -1, -1, -1, -1]), 11527 Int32Array.from([6, 34, 62, -1, -1, -1, -1]), 11528 Int32Array.from([6, 26, 46, 66, -1, -1, -1]), 11529 Int32Array.from([6, 26, 48, 70, -1, -1, -1]), 11530 Int32Array.from([6, 26, 50, 74, -1, -1, -1]), 11531 Int32Array.from([6, 30, 54, 78, -1, -1, -1]), 11532 Int32Array.from([6, 30, 56, 82, -1, -1, -1]), 11533 Int32Array.from([6, 30, 58, 86, -1, -1, -1]), 11534 Int32Array.from([6, 34, 62, 90, -1, -1, -1]), 11535 Int32Array.from([6, 28, 50, 72, 94, -1, -1]), 11536 Int32Array.from([6, 26, 50, 74, 98, -1, -1]), 11537 Int32Array.from([6, 30, 54, 78, 102, -1, -1]), 11538 Int32Array.from([6, 28, 54, 80, 106, -1, -1]), 11539 Int32Array.from([6, 32, 58, 84, 110, -1, -1]), 11540 Int32Array.from([6, 30, 58, 86, 114, -1, -1]), 11541 Int32Array.from([6, 34, 62, 90, 118, -1, -1]), 11542 Int32Array.from([6, 26, 50, 74, 98, 122, -1]), 11543 Int32Array.from([6, 30, 54, 78, 102, 126, -1]), 11544 Int32Array.from([6, 26, 52, 78, 104, 130, -1]), 11545 Int32Array.from([6, 30, 56, 82, 108, 134, -1]), 11546 Int32Array.from([6, 34, 60, 86, 112, 138, -1]), 11547 Int32Array.from([6, 30, 58, 86, 114, 142, -1]), 11548 Int32Array.from([6, 34, 62, 90, 118, 146, -1]), 11549 Int32Array.from([6, 30, 54, 78, 102, 126, 150]), 11550 Int32Array.from([6, 24, 50, 76, 102, 128, 154]), 11551 Int32Array.from([6, 28, 54, 80, 106, 132, 158]), 11552 Int32Array.from([6, 32, 58, 84, 110, 136, 162]), 11553 Int32Array.from([6, 26, 54, 82, 110, 138, 166]), 11554 Int32Array.from([6, 30, 58, 86, 114, 142, 170]), 11555 ])), 11556 (dr.TYPE_INFO_COORDINATES = Array.from([ 11557 Int32Array.from([8, 0]), 11558 Int32Array.from([8, 1]), 11559 Int32Array.from([8, 2]), 11560 Int32Array.from([8, 3]), 11561 Int32Array.from([8, 4]), 11562 Int32Array.from([8, 5]), 11563 Int32Array.from([8, 7]), 11564 Int32Array.from([8, 8]), 11565 Int32Array.from([7, 8]), 11566 Int32Array.from([5, 8]), 11567 Int32Array.from([4, 8]), 11568 Int32Array.from([3, 8]), 11569 Int32Array.from([2, 8]), 11570 Int32Array.from([1, 8]), 11571 Int32Array.from([0, 8]), 11572 ])), 11573 (dr.VERSION_INFO_POLY = 7973), 11574 (dr.TYPE_INFO_POLY = 1335), 11575 (dr.TYPE_INFO_MASK_PATTERN = 21522); 11576 class gr { 11577 constructor(t, e) { 11578 (this.dataBytes = t), (this.errorCorrectionBytes = e); 11579 } 11580 getDataBytes() { 11581 return this.dataBytes; 11582 } 11583 getErrorCorrectionBytes() { 11584 return this.errorCorrectionBytes; 11585 } 11586 } 11587 class fr { 11588 constructor() {} 11589 static calculateMaskPenalty(t) { 11590 return (
11591 lr.applyMaskPenaltyRule1(t) + 11592 lr.applyMaskPenaltyRule2(t) + 11593 lr.applyMaskPenaltyRule3(t) + 11594 lr.applyMaskPenaltyRule4(t) 11595 ); 11596 } 11597 static encode(t, e, r = null) { 11598 let n = fr.DEFAULT_BYTE_MODE_ENCODING; 11599 const i = null !== r && void 0 !== r.get(or.CHARACTER_SET); 11600 i && (n = r.get(or.CHARACTER_SET).toString()); 11601 const s = this.chooseMode(t, n), 11602 o = new w(); 11603 if (s === _e.BYTE && (i || fr.DEFAULT_BYTE_MODE_ENCODING !== n)) { 11604 const t = m.getCharacterSetECIByName(n); 11605 void 0 !== t && this.appendECI(t, o); 11606 } 11607 this.appendModeInfo(s, o); 11608 const a = new w(); 11609 let l; 11610 if ((this.appendBytes(t, s, a, n), null !== r && void 0 !== r.get(or.QR_VERSION))) { 11611 const t = Number.parseInt(r.get(or.QR_VERSION).toString(), 10); 11612 l = Ae.getVersionForNumber(t); 11613 const n = this.calculateBitsNeeded(s, o, a, l); 11614 if (!this.willFit(n, l, e)) throw new ur('Data too big for requested version'); 11615 } else l = this.recommendVersion(e, s, o, a); 11616 const h = new w(); 11617 h.appendBitArray(o); 11618 const c = s === _e.BYTE ? a.getSizeInBytes() : t.length; 11619 this.appendLengthInfo(c, l, s, h), h.appendBitArray(a); 11620 const u = l.getECBlocksForLevel(e), 11621 d = l.getTotalCodewords() - u.getTotalECCodewords(); 11622 this.terminateBits(d, h); 11623 const g = this.interleaveWithECBytes(h, l.getTotalCodewords(), d, u.getNumBlocks()), 11624 f = new cr(); 11625 f.setECLevel(e), f.setMode(s), f.setVersion(l); 11626 const A = l.getDimensionForVersion(), 11627 C = new hr(A, A), 11628 E = this.chooseMaskPattern(g, e, l, C); 11629 return f.setMaskPattern(E), dr.buildMatrix(g, e, l, E, C), f.setMatr
11629ix(C), f; 11630 } 11631 static recommendVersion(t, e, r, n) { 11632 const i = this.calculateBitsNeeded(e, r, n, Ae.getVersionForNumber(1)), 11633 s = this.chooseVersion(i, t), 11634 o = this.calculateBitsNeeded(e, r, n, s); 11635 return this.chooseVersion(o, t); 11636 } 11637 static calculateBitsNeeded(t, e, r, n) { 11638 return e.getSize() + t.getCharacterCountBits(n) + r.getSize(); 11639 } 11640 static getAlphanumericCode(t) { 11641 return t < fr.ALPHANUMERIC_TABLE.length ? fr.ALPHANUMERIC_TABLE[t] : -1; 11642 } 11643 static chooseMode(t, e = null) { 11644 if (m.SJIS.getName() === e && this.isOnlyDoubleByteKanji(t)) return _e.KANJI; 11645 let r = !1, 11646 n = !1; 11647 for (let e = 0, i = t.length; e < i; ++e) { 11648 const i = t.charAt(e); 11649 if (fr.isDigit(i)) r = !0; 11650 else { 11651 if (-1 === this.getAlphanumericCode(i.charCodeAt(0))) return _e.BYTE; 11652 n = !0; 11653 } 11654 } 11655 return n ? _e.ALPHANUMERIC : r ? _e.NUMERIC : _e.BYTE; 11656 } 11657 static isOnlyDoubleByteKanji(t) { 11658 let e; 11659 try { 11660 e = I.encode(t, m.SJIS); 11661 } catch (t) { 11662 return !1; 11663 } 11664 const r = e.length; 11665 if (r % 2 != 0) return !1; 11666 for (let t = 0; t < r; t += 2) { 11667 const r = 255 & e[t]; 11668 if ((r < 129 || r > 159) && (r < 224 || r > 235)) return !1; 11669 } 11670 return !0; 11671 } 11672 static chooseMaskPattern(t, e, r, n) { 11673 let i = Number.MAX_SAFE_INTEGER, 11674 s = -1; 11675 for (let o = 0; o < cr.NUM_MASK_PATTERNS; o++) { 11676 dr.buildMatrix(t, e, r, o, n); 11677 let a = this.calculateMaskPenalty(n); 11678 a < i && ((i = a), (s = o)); 11679 } 11680 return s; 11681 } 11682 static chooseVersion(t, e) { 11683 for (let r = 1; r <= 40; r++) { 11684 const n = Ae.getVersionForNumber(r); 11685 if (fr.willFit(t, n, e)) return n; 11686 } 11687 throw new ur('Data too big'); 11688 } 11689 static willFit(t, e, r) { 11690 return e.getTotalCodewords() - e.getECBlocksForLevel(r).getTotalECCodewords() >= (t + 7) / 8; 11691 } 11692 static terminateBits(t, e) { 11693 const r = 8 * t; 11694 if (e.getSize() > r) throw new ur('data bits cannot fit in the QR Code' + e.getSize() + ' > ' + r); 11695 for (let t = 0; t < 4 && e.getSize() < r; ++t) e.appendBit(!1); 11696 const n = 7 & e.getSize(); 11697 if (n > 0) for (let t = n; t < 8; t++) e.appendBit(!1); 11698 const i = t - e.getSizeInBytes(); 11699 for (let t = 0; t < i; ++t) e.appendBits(0 == (1 & t) ? 236 : 17, 8); 11700 if (e.getSize() !== r) throw new ur('Bits size does not equal capacity'); 11701 } 11702 static getNumDataBytesAndNumECBytesForBlockID(t, e, r, n, i, s) { 11703 if (n >= r) throw new ur('Block ID too large'); 11704 const o = t % r, 11705 a = r - o, 11706 l = Math.floor(t / r), 11707 h = l + 1, 11708 c = Math.floor(e / r), 11709 u = c + 1, 11710 d = l - c, 11711 g = h - u; 11712 if (d !== g) throw new ur('EC bytes mismatch'); 11713 if (r !== a + o) throw new ur('RS blocks mismatch'); 11714 if (t !== (c + d) * a + (u + g) * o) throw new ur('Total bytes mismatch'); 11715 n < a ? ((i[0] = c), (s[0] = d)) : ((i[0] = u), (s[0] = g)); 11716 } 11717 static interleaveWithECBytes(t, e, r, n) { 11718 if (t.getSizeInBytes() !== r) throw new ur('Number of bits and data bytes does not match'); 11719 let i = 0, 11720 s = 0, 11721 o = 0; 11722 const a = new Array(); 11723 for (let l = 0; l < n; ++l) { 11724 const h = new Int32Array(1), 11725 c = new Int32Array(1); 11726 fr.getNumDataBytesAndNumECBytesForBlockID(e, r, n, l, h, c); 11727 const u = h[0], 11728 d = new Uint8Array(u); 11729 t.toBytes(8 * i, d, 0, u); 11730 const g = fr.generateECBytes(d, c[0]); 11731 a.push(new gr(d, g)), (s = Math.max(s, u)), (o = Math.max(o, g.length)), (i += h[0]); 11732 } 11733 if (r !== i) throw new ur('Data bytes does not match offset'); 11734 const l = new w(); 11735 for (let t = 0; t < s; ++t) 11736 for (const e of a) { 11737 const r = e.getDataBytes(); 11738 t < r.length && l.appendBits(r[t], 8); 11739 } 11740 for (let t = 0; t < o; ++t) 11741 for (const e of a) { 11742 const r = e.getErrorCorrectionBytes(); 11743 t < r.length && l.appendBits(r[t], 8); 11744 } 11745 if (e !== l.getSizeInBytes()) 11746 throw new ur('Interleaving error: ' + e + ' and ' + l.getSizeInBytes() + ' differ.'); 11747 return l; 11748 } 11749 static generateECBytes(t, e) { 11750 const r = t.length, 11751 n = new Int32Array(r + e); 11752 for (let e = 0; e < r; e++) n[e] = 255 & t[e]; 11753 new ar(q.QR_CODE_FIELD_256).encode(n, e); 11754 const i = new Uint8Array(e); 11755 for (let t = 0; t < e; t++) i[t] = n[r + t]; 11756 return i; 11757 } 11758 static appendModeInfo(t, e) { 11759 e.appendBits(t.getBits(), 4); 11760 } 11761 static appendLengthInfo(t, e, r, n) { 11762 const i = r.getCharacterCountBits(e); 11763 if (t >= 1 << i) throw new ur(t + ' is bigger than ' + ((1 << i) - 1)); 11764 n.appendBits(t, i); 11765 } 11766 static appendBytes(t, e, r, n) { 11767 switch (e) { 11768 case _e.NUMERIC: 11769 fr.appendNumericBytes(t, r); 11770 break; 11771 case _e.ALPHANUMERIC: 11772 fr.appendAlphanumericBytes(t, r); 11773 break; 11774 case _e.BYTE: 11775 fr.append8BitBytes(t, r, n); 11776 break; 11777 case _e.KANJI: 11778 fr.appendKanjiBytes(t, r); 11779 break; 11780 default: 11781 throw new ur('Invalid mode: ' + e); 11782 } 11783 } 11784 static getDigit(t) { 11785 return t.charCodeAt(0) - 48; 11786 } 11787 static isDigit(t) { 11788 const e = fr.getDigit(t); 11789 return e >= 0 && e <= 9; 11790 } 11791 static appendNumericBytes(t, e) { 11792 const r = t.length; 11793 let n = 0; 11794 for (; n < r; ) { 11795 const i = fr.getDigit(t.charAt(n)); 11796 if (n + 2 < r) { 11797 const r = fr.getDigit(t.charAt(n + 1)), 11798 s = fr.getDigit(t.charAt(n + 2)); 11799 e.appendBits(100 * i + 10 * r + s, 10), (n += 3); 11800 } else if (n + 1 < r) { 11801 const r = fr.getDigit(t.charAt(n + 1)); 11802 e.appendBits(10 * i + r, 7), (n += 2); 11803 } else e.appendBits(i, 4), n++; 11804 } 11805 } 11806 static appendAlphanumericBytes(t, e) { 11807 const r = t.length; 11808 let n = 0; 11809 for (; n < r; ) { 11810 const i = fr.getAlphanumericCode(t.charCodeAt(n)); 11811 if (-1 === i) throw new ur(); 11812 if (n + 1 < r) { 11813 const r = fr.getAlphanumericCode(t.charCodeAt(n + 1)); 11814 if (-1 === r) throw new ur(); 11815 e.appendBits(45 * i + r, 11), (n += 2); 11816 } else e.appendBits(i, 6), n++; 11817 } 11818 } 11819 static append8BitBytes(t, e, r) { 11820 let n;
11821 try { 11822 n = I.encode(t, r); 11823 } catch (t) { 11824 throw new ur(t); 11825 } 11826 for (let t = 0, r = n.length; t !== r; t++) { 11827 const r = n[t]; 11828 e.appendBits(r, 8); 11829 } 11830 } 11831 static appendKanjiBytes(t, e) { 11832 let r; 11833 try { 11834 r = I.encode(t, m.SJIS); 11835 } catch (t) { 11836 throw new ur(t); 11837 } 11838 const n = r.length; 11839 for (let t = 0; t < n; t += 2) { 11840 const n = (((255 & r[t]) << 8) & 4294967295) | (255 & r[t + 1]); 11841 let i = -1; 11842 if ((n >= 33088 && n <= 40956 ? (i = n - 33088) : n >= 57408 && n <= 60351 && (i = n - 49472), -1 === i)) 11843 throw new ur('Invalid byte sequence'); 11844 const s = 192 * (i >> 8) + (255 & i); 11845 e.appendBits(s, 13); 11846 } 11847 } 11848 static appendECI(t, e) { 11849 e.appendBits(_e.ECI.getBits(), 4), e.appendBits(t.getValue(), 8); 11850 } 11851 } 11852 (fr.ALPHANUMERIC_TABLE = Int32Array.from([ 11853 -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, 11854 -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, 11855 -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, 11856 34, 35, -1, -1, -1, -1, -1, 11857 ])), 11858 (fr.DEFAULT_BYTE_MODE_ENCODING = m.UTF8.getName()); 11859 class wr { 11860 write(t, e, r, n = null) { 11861 if (0 === t.length) throw new o('Found empty contents'); 11862 if (e < 0 || r < 0) throw new o('Requested dimensions are too small: ' + e + 'x' + r); 11863 let i = de.L, 11864 s = wr.QUIET_ZONE_SIZE; 11865 null !== n && 11866 (void 0 !== n.get(or.ERROR_CORRECTION) && (i = de.fromString(n.get(or.ERROR_CORRECTION).toString())), 11867 void 0 !== n.get(or.MARGIN) && (s = Number.parseInt(n.get(or.MARGIN).toString(), 10))); 11868 const a = fr.encode(t, i, n); 11869 return this.renderResult(a, e, r, s); 11870 } 11871 writeToDom(t, e, r, n, i = null) { 11872 'string' == typeof t && (t = document.querySelector(t)); 11873 const s = this.write(e, r, n, i); 11874 t && t.appendChild(s); 11875 } 11876 renderResult(t, e, r, n) { 11877 const i = t.getMatrix(); 11878 if (null === i) throw new j(); 11879 const s = i.getWidth(), 11880 o = i.getHeight(), 11881 a = s + 2 * n, 11882 l = o + 2 * n, 11883 h = Math.max(e, a), 11884 c = Math.max(r, l), 11885 u = Math.min(Math.floor(h / a), Math.floor(c / l)), 11886 d = Math.floor((h - s * u) / 2), 11887 g = Math.floor((c - o * u) / 2), 11888 f = this.createSVGElement(h, c); 11889 for (let t = 0, e = g; t < o; t++, e += u) 11890 for (let r = 0, n = d; r < s; r++, n += u) 11891 if (1 === i.get(r, t)) { 11892 const t = this.createSvgRectElement(n, e, u, u); 11893 f.appendChild(t); 11894 } 11895 return f; 11896 } 11897 createSVGElement(t, e) { 11898 const r = document.createElementNS(wr.SVG_NS, 'svg'); 11899 return r.setAttributeNS(null, 'height', t.toString()), r.setAttributeNS(null, 'width', e.toString()), r; 11900 } 11901 createSvgRectElement(t, e, r, n) { 11902 const i = document.createElementNS(wr.SVG_NS, 'rect'); 11903 return ( 11904 i.setAttributeNS(null, 'x', t.toString()), 11905 i.setAttributeNS(null, 'y', e.toString()), 11906 i.setAttributeNS(null, 'height', r.toString()), 11907 i.setAttributeNS(null, 'width', n.toString()), 11908 i.setAttributeNS(null, 'fill', '#000000'), 11909 i 11910 ); 11911 } 11912 } 11913 (wr.QUIET_ZONE_SIZE = 4), (wr.SVG_NS = 'http://www.w3.org/2000/svg'); 11914 class Ar { 11915 encode(t, e, r, n, i) { 11916 if (0 === t.length) throw new o('Found empty contents'); 11917 if (e !== v.QR_CODE) throw new o('Can only encode QR_CODE, but got ' + e); 11918 if (r < 0 || n < 0) throw new o(`Requested dimensions are too small: ${r}x${n}`); 11919 let s = de.L, 11920 a = Ar.QUIET_ZONE_SIZE; 11921 null !== i && 11922 (void 0 !== i.get(or.ERROR_CORRECTION) && (s = de.fromString(i.get(or.ERROR_CORRECTION).toString())), 11923 void 0 !== i.get(or.MARGIN) && (a = Number.parseInt(i.get(or.MARGIN).toString(), 10))); 11924 const l = fr.encode(t, s, i); 11925 return Ar.renderResult(l, r, n, a); 11926 } 11927 static renderResult(t, e, r, n) { 11928 const i = t.getMatrix(); 11929 if (null === i) throw new j(); 11930 const s = i.getWidth(), 11931 o = i.getHeight(), 11932 a = s + 2 * n, 11933 l = o + 2 * n, 11934 h = Math.max(e, a), 11935 c = Math.max(r, l), 11936 u = Math.min(Math.floor(h / a), Math.floor(c / l)), 11937 d = Math.floor((h - s * u) / 2), 11938 g = Math.floor((c - o * u) / 2),
11939 f = new T(h, c); 11940 for (let t = 0, e = g; t < o; t++, e += u) 11941 for (let r = 0, n = d; r < s; r++, n += u) 1 === i.get(r, t) && f.setRegion(n, e, u, u); 11942 return f; 11943 } 11944 } 11945 Ar.QUIET_ZONE_SIZE = 4; 11946 class Cr extends y { 11947 constructor(t, e, r, n, i, s, a, l) { 11948 if ( 11949 (super(s, a), 11950 (this.yuvData = t), 11951 (this.dataWidth = e), 11952 (this.dataHeight = r), 11953 (this.left = n), 11954 (this.top = i), 11955 n + s > e || i + a > r) 11956 ) 11957 throw new o('Crop rectangle does not fit within image data.'); 11958 l && this.reverseHorizontal(s, a); 11959 } 11960 getRow(t, e) { 11961 if (t < 0 || t >= this.getHeight()) throw new o('Requested row is outside the image: ' + t); 11962 const r = this.getWidth(); 11963 (null == e || e.length < r) && (e = new Uint8ClampedArray(r)); 11964 const n = (t + this.top) * this.dataWidth + this.left; 11965 return c.arraycopy(this.yuvData, n, e, 0, r), e; 11966 } 11967 getMatrix() { 11968 const t = this.getWidth(), 11969 e = this.getHeight(); 11970 if (t === this.dataWidth && e === this.dataHeight) return this.yuvData; 11971 const r = t * e, 11972 n = new Uint8ClampedArray(r); 11973 let i = this.top * this.dataWidth + this.left; 11974 if (t === this.dataWidth) return c.arraycopy(this.yuvData, i, n, 0, r), n; 11975 for (let r = 0; r < e; r++) { 11976 const e = r * t; 11977 c.arraycopy(this.yuvData, i, n, e, t), (i += this.dataWidth); 11978 } 11979 return n; 11980 } 11981 isCropSupported() { 11982 return !0; 11983 } 11984 crop(t, e, r, n) { 11985 return new Cr(this.yuvData, this.dataWidth, this.dataHeight, this.left + t, this.top + e, r, n, !1); 11986 } 11987 renderThumbnail() { 11988 const t = this.getWidth() / Cr.THUMBNAIL_SCALE_FACTOR, 11989 e = this.getHeight() / Cr.THUMBNAIL_SCALE_FACTOR, 11990 r = new Int32Array(t * e), 11991 n = this.yuvData; 11992 let i = this.top * this.dataWidth + this.left; 11993 for (let s = 0; s < e; s++) { 11994 const e = s * t; 11995 for (let s = 0; s < t; s++) { 11996 const t = 255 & n[i + s * Cr.THUMBNAIL_SCALE_FACTOR]; 11997 r[e + s] = 4278190080 | (65793 * t); 11998 } 11999 i += this.dataWidth * Cr.THUMBNAIL_SCALE_FACTOR; 12000 } 12001 return r; 12002 } 12003 getThumbnailWidth() { 12004 return this.getWidth() / Cr.THUMBNAIL_SCALE_FACTOR; 12005 } 12006 getThumbnailHeight() { 12007 return this.getHeight() / Cr.THUMBNAIL_SCALE_FACTOR; 12008 } 12009 reverseHorizontal(t, e) { 12010 const r = this.yuvData; 12011 for (let n = 0, i = this.top * this.dataWidth + this.left; n < e; n++, i += this.dataWidth) { 12012 const e = i + t / 2; 12013 for (let n = i, s = i + t - 1; n < e; n++, s--) { 12014 const t = r[n]; 12015 (r[n] = r[s]), (r[s] = t); 12016 } 12017 } 12018 } 12019 invert() { 12020 return new O(this); 12021 } 12022 } 12023 Cr.THUMBNAIL_SCALE_FACTOR = 2; 12024 class Er extends y { 12025 constructor(t, e, r, n, i, s, a) { 12026 if ( 12027 (super(e, r), 12028 (this.dataWidth = n), 12029 (this.dataHeight = i), 12030 (this.left = s), 12031 (this.top = a), 12032 4 === t.BYTES_PER_ELEMENT) 12033 ) { 12034 const n = e * r, 12035 i = new Uint8ClampedArray(n); 12036 for (let e = 0; e < n; e++) { 12037 const r = t[e], 12038 n = (r >> 16) & 255, 12039 s = (r >> 7) & 510, 12040 o = 255 & r; 12041 i[e] = ((n + s + o) / 4) & 255; 12042 } 12043 this.luminances = i; 12044 } else this.luminances = t; 12045 if ( 12046 (void 0 === n && (this.dataWidth = e), 12047 void 0 === i && (this.dataHeight = r), 12048 void 0 === s && (this.left = 0), 12049 void 0 === a && (this.top = 0), 12050 this.left + e > this.dataWidth || this.top + r > this.dataHeight) 12051 ) 12052 throw new o('Crop rectangle does not fit within image data.'); 12053 } 12054 getRow(t, e) { 12055 if (t < 0 || t >= this.getHeight()) throw new o('Requested row is outside the image: ' + t); 12056 const r = this.getWidth(); 12057 (null == e || e.length < r) && (e = new Uint8ClampedArray(r)); 12058 const n = (t + this.top) * this.dataWidth + this.left; 12059 return c.arraycopy(this.luminances, n, e, 0, r), e; 12060 } 12061 getMatrix() { 12062 const t = this.getWidth(), 12063 e = this.getHeight(); 12064 if (t === this.dataWidth && e === this.dataHeight) return this.luminances; 12065 const r = t * e, 12066 n = new Uint8ClampedArray(r); 12067 let i = this.top * this.dataWidth + this.left; 12068 if (t === this.dataWidth) return c.arraycopy(this.luminances, i, n, 0, r), n; 12069 for (let r = 0; r < e; r++) { 12070 const e = r * t; 12071 c.arraycopy(this.luminances, i, n, e, t), (i += this.dataWidth); 12072 } 12073 return n; 12074 } 12075 isCropSupported() { 12076 return !0; 12077 } 12078 crop(t, e, r, n) { 12079 return new Er(this.luminances, r, n, this.dataWidth, this.dataHeight, this.left + t, this.top + e); 12080 } 12081 invert() { 12082 return new O(this); 12083 } 12084 } 12085 class mr extends m { 12086 static forName(t) { 12087 return this.getCharacterSetECIByName(t); 12088 } 12089 } 12090 class _r {} 12091 _r.ISO_8859_1 = m.ISO8859_1; 12092 class Ir { 12093 isCompact() { 12094 return this.compact; 12095 } 12096 setCompact(t) { 12097 this.compact = t; 12098 } 12099 getSize() { 12100 return this.size; 12101 } 12102 setSize(t) { 12103 this.size = t; 12104 } 12105 getLayers() { 12106 return this.layers; 12107 }
12108 setLayers(t) { 12109 this.layers = t; 12110 } 12111 getCodeWords() { 12112 return this.codeWords; 12113 } 12114 setCodeWords(t) { 12115 this.codeWords = t; 12116 } 12117 getMatrix() { 12118 return this.matrix; 12119 } 12120 setMatrix(t) { 12121 this.matrix = t; 12122 } 12123 } 12124 class Sr { 12125 static singletonList(t) { 12126 return [t]; 12127 } 12128 static min(t, e) { 12129 return t.sort(e)[0]; 12130 } 12131 } 12132 class pr extends class { 12133 constructor(t) { 12134 this.previous = t; 12135 } 12136 getPrevious() { 12137 return this.previous; 12138 } 12139 } { 12140 constructor(t, e, r) { 12141 super(t), (this.value = e), (this.bitCount = r); 12142 } 12143 appendTo(t, e) { 12144 t.appendBits(this.value, this.bitCount); 12145 } 12146 add(t, e) { 12147 return new pr(this, t, e); 12148 } 12149 addBinaryShift(t, e) { 12150 return ( 12151 console.warn('addBinaryShift on SimpleToken, this simply returns a copy of this token'), new pr(this, t, e) 12152 ); 12153 } 12154 toString() { 12155 let t = this.value & ((1 << this.bitCount) - 1); 12156 return (t |= 1 << this.bitCount), '<' + f.toBinaryString(t | (1 << this.bitCount)).substring(1) + '>'; 12157 } 12158 } 12159 class Tr extends pr { 12160 constructor(t, e, r) { 12161 super(t, 0, 0), (this.binaryShiftStart = e), (this.binaryShiftByteCount = r); 12162 } 12163 appendTo(t, e) { 12164 for (let r = 0; r < this.binaryShiftByteCount; r++) 12165 (0 === r || (31 === r && this.binaryShiftByteCount <= 62)) && 12166 (t.appendBits(31, 5), 12167 this.binaryShiftByteCount > 62 12168 ? t.appendBits(this.binaryShiftByteCount - 31, 16) 12169 : 0 === r 12170 ? t.appendBits(Math.min(this.binaryShiftByteCount, 31), 5) 12171 : t.appendBits(this.binaryShiftByteCount - 31, 5)), 12172 t.appendBits(e[this.binaryShiftStart + r], 8); 12173 } 12174 addBinaryShift(t, e) { 12175 return new Tr(this, t, e); 12176 } 12177 toString() { 12178 return '<' + this.binaryShiftStart + '::' + (this.binaryShiftStart + this.binaryShiftByteCount - 1) + '>'; 12179 } 12180 } 12181 function Rr(t, e, r) { 12182 return new pr(t, e, r); 12183 } 12184 const Nr = ['UPPER', 'LOWER', 'DIGIT', 'MIXED', 'PUNCT'], 12185 Dr = new pr(null, 0, 0), 12186 yr = [ 12187 Int32Array.from([0, 327708, 327710, 327709, 656318]), 12188 Int32Array.from([590318, 0, 327710, 327709, 656318]), 12189 Int32Array.from([262158, 590300, 0, 590301, 932798]), 12190 Int32Array.from([327709, 327708, 656318, 0, 327710]), 12191 Int32Array.from([327711, 656380, 656382, 656381, 0]), 12192 ]; 12193 const Or = (function (t) { 12194 for (let e of t) g.fill(e, -1); 12195 return (t[0][4] = 0), (t[1][4] = 0), (t[1][0] = 28), (t[3][4] = 0), (t[2][4] = 0), (t[2][0] = 15), t; 12196 })(g.createInt32Array(6, 6)); 12197 class Mr { 12198 constructor(t, e, r, n) { 12199 (this.token = t), (this.mode = e), (this.binaryShiftByteCount = r), (this.bitCount = n); 12200 } 12201 getMode() { 12202 return this.mode; 12203 } 12204 getToken() { 12205 return this.token; 12206 } 12207 getBinaryShiftByteCount() { 12208 return this.binaryShiftByteCount; 12209 } 12210 getBitCount() { 12211 return this.bitCount; 12212 } 12213 latchAndAppend(t, e) { 12214 let r = this.bitCount, 12215 n = this.token; 12216 if (t !== this.mode) { 12217 let e = yr[this.mode][t]; 12218 (n = Rr(n, 65535 & e, e >> 16)), (r += e >> 16); 12219 } 12220 let i = 2 === t ? 4 : 5; 12221 return (n = Rr(n, e, i)), new Mr(n, t, 0, r + i); 12222 } 12223 shiftAndAppend(t, e) { 12224 let r = this.token, 12225 n = 2 === this.mode ? 4 : 5; 12226 return (r = Rr(r, Or[this.mode][t], n)), (r = Rr(r, e, 5)), new Mr(r, this.mode, 0, this.bitCount + n + 5); 12227 } 12228 addBinaryShiftChar(t) { 12229 let e = this.token, 12230 r = this.mode, 12231 n = this.bitCount; 12232 if (4 === this.mode || 2 === this.mode) { 12233 let t = yr[r][0]; 12234 (e = Rr(e, 65535 & t, t >> 16)), (n += t >> 16), (r = 0); 12235 } 12236 let i = 12237 0 === this.binaryShiftByteCount || 31 === this.binaryShiftByteCount 12238 ? 18 12239 : 62 === this.binaryShiftByteCount 12240 ? 9 12241 : 8, 12242 s = new Mr(e, r, this.binaryShiftByteCount + 1, n + i); 12243 return 2078 === s.binaryShiftByteCount && (s = s.endBinaryShift(t + 1)), s; 12244 } 12245 endBinaryShift(t) { 12246 if (0 === this.binaryShiftByteCount) return this; 12247 let e = this.token; 12248 return ( 12249 (e = (function (t, e, r) { 12250 return new Tr(t, e, r); 12251 })(e, t - this.binaryShiftByteCount, this.binaryShiftByteCount)), 12252 new Mr(e, this.mode, 0, this.bitCount) 12253 ); 12254 } 12255 isBetterThanOrEqualTo(t) { 12256 let e = this.bitCount + (yr[this.mode][t.mode] >> 16); 12257 return ( 12258 this.binaryShiftByteCount < t.binaryShiftByteCount 12259 ? (e += Mr.calculateBinaryShiftCost(t) - Mr.calculateBinaryShiftCost(this)) 12260 : this.binaryShiftByteCount > t.binaryShiftByteCount && t.binaryShiftByteCount > 0 && (e += 10),
12261 e <= t.bitCount 12262 ); 12263 } 12264 toBitArray(t) { 12265 let e = []; 12266 for (let r = this.endBinaryShift(t.length).token; null !== r; r = r.getPrevious()) e.unshift(r); 12267 let r = new w(); 12268 for (const n of e) n.appendTo(r, t); 12269 return r; 12270 } 12271 toString() { 12272 return S.format('%s bits=%d bytes=%d', Nr[this.mode], this.bitCount, this.binaryShiftByteCount); 12273 } 12274 static calculateBinaryShiftCost(t) { 12275 return t.binaryShiftByteCount > 62 ? 21 : t.binaryShiftByteCount > 31 ? 20 : t.binaryShiftByteCount > 0 ? 10 : 0; 12276 } 12277 } 12278 Mr.INITIAL_STATE = new Mr(Dr, 0, 0, 0); 12279 const Br = (function (t) { 12280 const e = S.getCharCode(' '), 12281 r = S.getCharCode('.'), 12282 n = S.getCharCode(','); 12283 t[0][e] = 1; 12284 const i = S.getCharCode('Z'), 12285 s = S.getCharCode('A'); 12286 for (let e = s; e <= i; e++) t[0][e] = e - s + 2; 12287 t[1][e] = 1; 12288 const o = S.getCharCode('z'), 12289 a = S.getCharCode('a'); 12290 for (let e = a; e <= o; e++) t[1][e] = e - a + 2; 12291 t[2][e] = 1; 12292 const l = S.getCharCode('9'), 12293 h = S.getCharCode('0'); 12294 for (let e = h; e <= l; e++) t[2][e] = e - h + 2; 12295 (t[2][n] = 12), (t[2][r] = 13); 12296 const c = [ 12297 '\0', 12298 ' ', 12299 '�', 12300 '�', 12301 '�', 12302 '�', 12303 '�', 12304 '�', 12305 '�', 12306 '\b', 12307 '\t', 12308 '\n', 12309 '\v', 12310 '\f', 12311 '\r', 12312 '�', 12313 '�', 12314 '�', 12315 '�', 12316 '�', 12317 '@', 12318 '\\', 12319 '^', 12320 '_', 12321 '`', 12322 '|', 12323 '~', 12324 '�', 12325 ]; 12326 for (let e = 0; e < c.length; e++) t[3][S.getCharCode(c[e])] = e; 12327 const u = [ 12328 '\0', 12329 '\r', 12330 '\0', 12331 '\0', 12332 '\0', 12333 '\0', 12334 '!', 12335 "'", 12336 '#', 12337 '$', 12338 '%', 12339 '&', 12340 "'", 12341 '(', 12342 ')', 12343 '*', 12344 '+', 12345 ',', 12346 '-', 12347 '.', 12348 '/', 12349 ':', 12350 ';', 12351 '<', 12352 '=', 12353 '>', 12354 '?', 12355 '[', 12356 ']', 12357 '{', 12358 '}', 12359 ]; 12360 for (let e = 0; e < u.length; e++) S.getCharCode(u[e]) > 0 && (t[4][S.getCharCode(u[e])] = e); 12361 return t; 12362 })(g.createInt32Array(5, 256)); 12363 class br { 12364 constructor(t) { 12365 this.text = t; 12366 } 12367 encode() { 12368 const t = S.getCharCode(' '), 12369 e = S.getCharCode('\n'); 12370 let r = Sr.singletonList(Mr.INITIAL_STATE); 12371 for (let n = 0; n < this.text.length; n++) { 12372 let i, 12373 s = n + 1 < this.text.length ? this.text[n + 1] : 0; 12374 switch (this.text[n]) { 12375 case S.getCharCode('\r'): 12376 i = s === e ? 2 : 0; 12377 break; 12378 case S.getCharCode('.'): 12379 i = s === t ? 3 : 0; 12380 break; 12381 case S.getCharCode(','): 12382 i = s === t ? 4 : 0; 12383 break; 12384 case S.getCharCode(':'): 12385 i = s === t ? 5 : 0; 12386 break; 12387 default: 12388 i = 0; 12389 } 12390 i > 0 ? ((r = br.updateStateListForPair(r, n, i)), n++) : (r = this.updateStateListForChar(r, n)); 12391 } 12392 return Sr.min(r, (t, e) => t.getBitCount() - e.getBitCount()).toBitArray(this.text); 12393 } 12394 updateStateListForChar(t, e) { 12395 const r = []; 12396 for (let n of t) this.updateStateForChar(n, e, r); 12397 return br.simplifyStates(r); 12398 } 12399 updateStateForChar(t, e, r) { 12400 let n = 255 & this.text[e], 12401 i = Br[t.getMode()][n] > 0, 12402 s = null; 12403 for (let o = 0; o <= 4; o++) { 12404 let a = Br[o][n]; 12405 if (a > 0) { 12406 if ((null == s && (s = t.endBinaryShift(e)), !i || o === t.getMode() || 2 === o)) { 12407 const t = s.latchAndAppend(o, a); 12408 r.push(t); 12409 } 12410 if (!i && Or[t.getMode()][o] >= 0) { 12411 const t = s.shiftAndAppend(o, a); 12412 r.push(t); 12413 } 12414 } 12415 } 12416 if (t.getBinaryShiftByteCount() > 0 || 0 === Br[t.getMode()][n]) { 12417 let n = t.addBinaryShiftChar(e); 12418 r.push(n); 12419 } 12420 } 12421 static updateStateListForPair(t, e, r) { 12422 const n = []; 12423 for (let i of t) this.updateStateForPair(i, e, r, n); 12424 return this.simplifyStates(n); 12425 } 12426 static updateStateForPair(t, e, r, n) { 12427 let i = t.endBinaryShift(e); 12428 if ((n.push(i.latchAndAppend(4, r)), 4 !== t.getMode() && n.push(i.shiftAndAppend(4, r)), 3 === r || 4 === r)) { 12429 let t = i.latchAndAppend(2, 16 - r).latchAndAppend(2, 1); 12430 n.push(t); 12431 } 12432 if (t.getBinaryShiftByteCount() > 0) { 12433 let r = t.addBinaryShiftChar(e).addBinaryShiftChar(e + 1); 12434 n.push(r); 12435 } 12436 } 12437 static simplifyStates(t) { 12438 let e = []; 12439 for (const r of t) { 12440 let t = !0; 12441 for (const n of e) { 12442 if (n.isBetterThanOrEqualTo(r)) { 12443 t = !1; 12444 break; 12445 } 12446 r.isBetterThanOrEqualTo(n) && (e = e.filter((t) => t !== n)); 12447 } 12448 t && e.push(r); 12449 } 12450 return e; 12451 } 12452 } 12453 class Pr { 12454 constructor() {} 12455 static encodeBytes(t) { 12456 return Pr.encode(t, Pr.DEFAULT_EC_PERCENT, Pr.DEFAULT_AZTEC_LAYERS); 12457 } 12458 static encode(t, e, r) { 12459 let n, 12460 i, 12461 s, 12462 a, 12463 l, 12464 h = new br(t).encode(), 12465 c = f.truncDivision(h.getSize() * e, 100) + 11, 12466 u = h.getSize() + c; 12467 if (r !== Pr.DEFAULT_AZTEC_LAYERS) { 12468 if (((n = r < 0), (i = Math.abs(r)), i > (n ? Pr.MAX_NB_BITS_COMPACT : Pr.MAX_NB_BITS))) 12469 throw new o(S.format('Illegal value %s for layers', r)); 12470 (s = Pr.totalBitsInLayer(i, n)), (a = Pr.WORD_SIZE[i]); 12471 let t = s - (s % a); 12472 if (((l = Pr.stuffBits(h, a)), l.getSize() + c > t)) throw new o('Data to large for user specified layer'); 12473 if (n && l.getSize() > 64 * a) throw new o('Data to large for user specified layer'); 12474 } else { 12475 (a = 0), (l = null); 12476 for (let t = 0; ; t++) { 12477 if (t > Pr.MAX_NB_BITS) throw new o('Data too large for an Aztec code'); 12478 if (((n = t <= 3), (i = n ? t + 1 : t), (s = Pr.totalBitsInLayer(i, n)), u > s)) continue; 12479 (null != l && a === Pr.WORD_SIZE[i]) || ((a = Pr.WORD_SIZE[i]), (l = Pr.stuffBits(h, a)));
12480 let e = s - (s % a); 12481 if (!(n && l.getSize() > 64 * a) && l.getSize() + c <= e) break; 12482 } 12483 } 12484 let d, 12485 g = Pr.generateCheckWords(l, s, a), 12486 w = l.getSize() / a, 12487 A = Pr.generateModeMessage(n, i, w), 12488 C = (n ? 11 : 14) + 4 * i, 12489 E = new Int32Array(C); 12490 if (n) { 12491 d = C; 12492 for (let t = 0; t < E.length; t++) E[t] = t; 12493 } else { 12494 d = C + 1 + 2 * f.truncDivision(f.truncDivision(C, 2) - 1, 15); 12495 let t = f.truncDivision(C, 2), 12496 e = f.truncDivision(d, 2); 12497 for (let r = 0; r < t; r++) { 12498 let n = r + f.truncDivision(r, 15); 12499 (E[t - r - 1] = e - n - 1), (E[t + r] = e + n + 1); 12500 } 12501 } 12502 let m = new T(d); 12503 for (let t = 0, e = 0; t < i; t++) { 12504 let r = 4 * (i - t) + (n ? 9 : 12); 12505 for (let n = 0; n < r; n++) { 12506 let i = 2 * n; 12507 for (let s = 0; s < 2; s++) 12508 g.get(e + i + s) && m.set(E[2 * t + s], E[2 * t + n]), 12509 g.get(e + 2 * r + i + s) && m.set(E[2 * t + n], E[C - 1 - 2 * t - s]), 12510 g.get(e + 4 * r + i + s) && m.set(E[C - 1 - 2 * t - s], E[C - 1 - 2 * t - n]), 12511 g.get(e + 6 * r + i + s) && m.set(E[C - 1 - 2 * t - n], E[2 * t + s]); 12512 } 12513 e += 8 * r; 12514 } 12515 if ((Pr.drawModeMessage(m, n, d, A), n)) Pr.drawBullsEye(m, f.truncDivision(d, 2), 5); 12516 else { 12517 Pr.drawBullsEye(m, f.truncDivision(d, 2), 7); 12518 for (let t = 0, e = 0; t < f.truncDivision(C, 2) - 1; t += 15, e += 16) 12519 for (let t = 1 & f.truncDivision(d, 2); t < d; t += 2) 12520 m.set(f.truncDivision(d, 2) - e, t), 12521 m.set(f.truncDivision(d, 2) + e, t), 12522 m.set(t, f.truncDivision(d, 2) - e), 12523 m.set(t, f.truncDivision(d, 2) + e); 12524 } 12525 let _ = new Ir(); 12526 return _.setCompact(n), _.setSize(d), _.setLayers(i), _.setCodeWords(w), _.setMatrix(m), _; 12527 } 12528 static drawBullsEye(t, e, r) { 12529 for (let n = 0; n < r; n += 2) 12530 for (let r = e - n; r <= e + n; r++) t.set(r, e - n), t.set(r, e + n), t.set(e - n, r), t.set(e + n, r); 12531 t.set(e - r, e - r), 12532 t.set(e - r + 1, e - r), 12533 t.set(e - r, e - r + 1), 12534 t.set(e + r, e - r), 12535 t.set(e + r, e - r + 1), 12536 t.set(e + r, e + r - 1); 12537 } 12538 static generateModeMessage(t, e, r) { 12539 let n = new w(); 12540 return ( 12541 t 12542 ? (n.appendBits(e - 1, 2), n.appendBits(r - 1, 6), (n = Pr.generateCheckWords(n, 28, 4))) 12543 : (n.appendBits(e - 1, 5), n.appendBits(r - 1, 11), (n = Pr.generateCheckWords(n, 40, 4))), 12544 n 12545 ); 12546 } 12547 static drawModeMessage(t, e, r, n) { 12548 let i = f.truncDivision(r, 2); 12549 if (e) 12550 for (let e = 0; e < 7; e++) { 12551 let r = i - 3 + e; 12552 n.get(e) && t.set(r, i - 5), 12553 n.get(e + 7) && t.set(i + 5, r), 12554 n.get(20 - e) && t.set(r, i + 5), 12555 n.get(27 - e) && t.set(i - 5, r); 12556 } 12557 else 12558 for (let e = 0; e < 10; e++) { 12559 let r = i - 5 + e + f.truncDivision(e, 5); 12560 n.get(e) && t.set(r, i - 7), 12561 n.get(e + 10) && t.set(i + 7, r), 12562 n.get(29 - e) && t.set(r, i + 7), 12563 n.get(39 - e) && t.set(i - 7, r); 12564 } 12565 } 12566 static generateCheckWords(t, e, r) { 12567 let n = t.getSize() / r, 12568 i = new ar(Pr.getGF(r)), 12569 s = f.truncDivision(e, r), 12570 o = Pr.bitsToWords(t, r, s); 12571 i.encode(o, s - n); 12572 let a = e % r, 12573 l = new w(); 12574 l.appendBits(0, a); 12575 for (const t of Array.from(o)) l.appendBits(t, r); 12576 return l; 12577 } 12578 static bitsToWords(t, e, r) { 12579 let n, 12580 i, 12581 s = new Int32Array(r); 12582 for (n = 0, i = t.getSize() / e; n < i; n++) { 12583 let r = 0; 12584 for (let i = 0; i < e; i++) r |= t.get(n * e + i) ? 1 << (e - i - 1) : 0; 12585 s[n] = r; 12586 } 12587 return s; 12588 } 12589 static getGF(t) { 12590 switch (t) { 12591 case 4: 12592 return q.AZTEC_PARAM; 12593 case 6: 12594 return q.AZTEC_DATA_6; 12595 case 8: 12596 return q.AZTEC_DATA_8; 12597 case 10: 12598 return q.AZTEC_DATA_10; 12599 case 12: 12600 return q.AZTEC_DATA_12; 12601 default: 12602 throw new o('Unsupported word size ' + t); 12603 } 12604 } 12605 static stuffBits(t, e) { 12606 let r = new w(), 12607 n = t.getSize(), 12608 i = (1 << e) - 2; 12609 for (let s = 0; s < n; s += e) { 12610 let o = 0; 12611 for (let r = 0; r < e; r++) (s + r >= n || t.get(s + r)) && (o |= 1 << (e - 1 - r)); 12612 (o & i) === i 12613 ? (r.appendBits(o & i, e), s--) 12614 : 0 == (o & i) 12615 ? (r.appendBits(1 | o, e), s--) 12616 : r.appendBits(o, e); 12617 } 12618 return r; 12619 } 12620 static totalBitsInLayer(t, e) { 12621 return ((e ? 88 : 112) + 16 * t) * t; 12622 } 12623 } 12624 (Pr.DEFAULT_EC_PERCENT = 33), 12625 (Pr.DEFAULT_AZTEC_LAYERS = 0), 12626 (Pr.MAX_NB_BITS = 32), 12627 (Pr.MAX_NB_BITS_COMPACT = 4), 12628 (Pr.WORD_SIZE = Int32Array.from([ 12629 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, 12630 12, 12, 12631 ])); 12632 class Lr { 12633 encode(t, e, r, n) { 12634 return this.encodeWithHints(t, e, r, n, null); 12635 } 12636 encodeWithHints(t, e, r, n, i) { 12637 let s = _r.ISO_8859_1, 12638 o = Pr.DEFAULT_EC_PERCENT, 12639 a = Pr.DEFAULT_AZTEC_LAYERS; 12640 return ( 12641 null != i && 12642 (i.has(or.CHARACTER_SET) && (s = mr.forName(i.get(or.CHARACTER_SET).toString())), 12643 i.has(or.ERROR_CORRECTION) && (o = f.parseInt(i.get(or.ERROR_CORRECTION).toString())), 12644 i.has(or.AZTEC_LAYERS) && (a = f.parseInt(i.get(or.AZTEC_LAYERS).toString()))), 12645 Lr.encodeLayers(t, e, r, n, s, o, a) 12646 ); 12647 } 12648 static encodeLayers(t, e, r, n, i, s, a) { 12649 if (e !== v.AZTEC) throw new o('Can only encode AZTEC, but got ' + e); 12650 let l = Pr.encode(S.getBytes(t, i), s, a); 12651 return Lr.renderResult(l, r, n); 12652 } 12653 static renderResult(t, e, r) { 12654 let n = t.getMatrix(); 12655 if (null == n) throw new j(); 12656 let i = n.getWidth(), 12657 s = n.getHeight(), 12658 o = Math.max(e, i), 12659 a = Math.max(r, s), 12660 l = Math.min(o / i, a / s), 12661 h = (o - i * l) / 2, 12662 c = (a - s * l) / 2, 12663 u = new T(o, a); 12664 for (let t = 0, e = c; t < s; t++, e += l) 12665 for (let r = 0, s = h; r < i; r++, s += l) n.get(r, t) && u.setRegion(s, e, l, l); 12666 return u; 12667 } 12668 } 12669 (t.AbstractExpandedDecoder = xt), 12670 (t.ArgumentException = s), 12671 (t.ArithmeticException = K), 12672 (t.AztecCode = Ir), 12673 (t.AztecCodeReader = dt), 12674 (t.AztecCodeWriter = Lr), 12675 (t.AztecDecoder = $), 12676 (t.AztecDetector = ut), 12677 (t.AztecDetectorResult = it), 12678 (t.AztecEncoder = Pr), 12679 (t.AztecHighLevelEncoder = br), 12680 (t.AztecPoint = ct), 12681 (t.BarcodeFormat = v), 12682 (t.Binarizer = h), 12683 (t.BinaryBitmap = a), 12684 (t.BitArray = w), 12685 (t.BitMatrix = T), 12686 (t.BitSource = ae), 12687 (t.BrowserAztecCodeReader = class extends L { 12688 constructor(t = 500) { 12689 super(new dt(), t); 12690 } 12691 }), 12692 (t.BrowserBarcodeReader = class extends L { 12693 constructor(t = 500, e) { 12694 super(new ee(e), t, e); 12695 } 12696 }), 12697 (t.BrowserCodeReader = L), 12698 (t.BrowserDatamatrixCodeReader = class extends L { 12699 constructor(t = 500) { 12700 super(new ue(), t); 12701 } 12702 }), 12703 (t.BrowserMultiFormatReader = class extends L { 12704 constructor(t = null, e = 500) { 12705 const r = new ir(); 12706 r.setHints(t), super(r, e); 12707 } 12708 decodeBitmap(t) { 12709 return this.reader.decodeWithState(t); 12710 } 12711 }), 12712 (t.BrowserPDF417Reader = class extends L { 12713 constructor(t = 500) { 12714 super(new rr(), t); 12715 } 12716 }), 12717 (t.BrowserQRCodeReader = class extends L { 12718 constructor(t = 500) { 12719 super(new Me(), t); 12720 } 12721 }), 12722 (t.BrowserQRCodeSvgWriter = wr), 12723 (t.CharacterSetECI = m), 12724 (t.ChecksumException = l), 12725 (t.Code128Reader = ft), 12726 (t.Code39Reader = wt), 12727 (t.DataMatrixDecodedBitStreamParser = le), 12728 (t.DataMatrixReader = ue), 12729 (t.DecodeHintType = C), 12730 (t.DecoderResult = z), 12731 (t.DefaultGridSampler = lt), 12732 (t.DetectorResult = nt), 12733 (t.EAN13Reader = St), 12734 (t.EncodeHintType = or), 12735 (t.Exception = i), 12736 (t.FormatException = E), 12737 (t.GenericGF = q), 12738 (t.GenericGFPoly = Z), 12739 (t.GlobalHistogramBinarizer = N), 12740 (t.GridSampler = ot), 12741 (t.GridSamplerInstance = ht), 12742 (t.HTMLCanvasElementLuminanceSource = M), 12743 (t.HybridBinarizer = D), 12744 (t.ITFReader = At), 12745 (t.IllegalArgumentException = o), 12746 (t.IllegalStateException = j), 12747 (t.InvertedLuminanceSource = O), 12748 (t.LuminanceSource = y), 12749 (t.MathUtils = tt), 12750 (t.MultiFormatOneDReader = ee), 12751 (t.MultiFormatReader = ir), 12752 (t.MultiFormatWriter = class { 12753 encode(t, e, r, n, i) { 12754 let s; 12755 switch (e) { 12756 case v.QR_CODE: 12757 s = new Ar(); 12758 break; 12759 default: 12760 throw new o('No encoder available for format ' + e); 12761 } 12762 return s.encode(t, e, r, n, i); 12763 } 12764 }), 12765 (t.NotFoundException = R), 12766 (t.OneDReader = gt), 12767 (t.PDF417DecodedBitStreamParser = tr), 12768 (t.PDF417DecoderErrorCorrection = ke), 12769 (t.PDF417Reader = rr), 12770 (t.PDF417ResultMetadata = Ye), 12771 (t.PerspectiveTransform = at), 12772 (t.PlanarYUVLuminanceSource = Cr), 12773 (t.QRCodeByteMatrix = hr), 12774 (t.QRCodeDataMask = Ce), 12775 (t.QRCodeDecodedBitStreamParser = Ie), 12776 (t.QRCodeDecoderErrorCorrectionLevel = de), 12777 (t.QRCodeDecoderFormatInformation = ge), 12778 (t.QRCodeEncoder = fr), 12779 (t.QRCodeEncoderQRCode = cr), 12780 (t.QRCodeMaskUtil = lr), 12781 (t.QRCodeMatrixUtil = dr), 12782 (t.QRCodeMode = _e), 12783 (t.QRCodeReader = Me), 12784 (t.QRCodeVersion = Ae), 12785 (t.QRCodeWriter = Ar), 12786 (t.RGBLuminanceSource = Er), 12787 (t.RSS14Reader = te), 12788 (t.RSSExpandedReader = Jt), 12789 (t.ReaderException = nr), 12790 (t.ReedSolomonDecoder = J), 12791 (t.ReedSolomonEncoder = ar), 12792 (t.ReedSolomonException = Q),
12793 (t.Result = F), 12794 (t.ResultMetadataType = W), 12795 (t.ResultPoint = rt), 12796 (t.StringUtils = S), 12797 (t.UnsupportedOperationException = _), 12798 (t.VideoInputDevice = B), 12799 (t.WhiteRectangleDetector = st), 12800 (t.WriterException = ur), 12801 (t.ZXingArrays = g), 12802 (t.ZXingCharset = mr), 12803 (t.ZXingInteger = f), 12804 (t.ZXingStandardCharsets = _r), 12805 (t.ZXingStringBuilder = p), 12806 (t.ZXingStringEncoding = I), 12807 (t.ZXingSystem = c), 12808 (t.createAbstractExpandedDecoder = qt), 12809 Object.defineProperty(t, '__esModule', { value: !0 }); 12810});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.