quadqr-js 1.4.2 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,14 @@ const __qqr_geometry_js = (function () {
6
6
  const MIN_GEOMETRY_VERSION = 1;
7
7
  const MAX_GEOMETRY_VERSION = 40;
8
8
 
9
+ const ALIGNMENT_PROFILE_STANDARD_5 = "standard5";
10
+ const ALIGNMENT_PROFILE_LEGACY_3 = "compact3";
11
+
12
+ function normalizeAlignmentProfile(profile = ALIGNMENT_PROFILE_STANDARD_5) {
13
+ if (profile === ALIGNMENT_PROFILE_STANDARD_5 || profile === ALIGNMENT_PROFILE_LEGACY_3) return profile;
14
+ throw new Error(`Unsupported alignment profile ${profile}.`);
15
+ }
16
+
9
17
  // Index by version. Entry 0 is unused. Values are module indices of alignment
10
18
  // pattern centers, matching the standard QR Code version layout for v2..v40.
11
19
  const ALIGNMENT_PATTERN_AXES = Object.freeze([
@@ -72,9 +80,11 @@ function versionFromSize(size) {
72
80
  : null;
73
81
  }
74
82
 
75
- function alignmentPatternCentersForVersion(version) {
83
+ function alignmentPatternCentersForVersion(version, options = {}) {
76
84
  assertVersion(version);
77
85
  const size = sizeForVersion(version);
86
+ const requestedProfile = typeof options === "string" ? options : options.profile;
87
+ const profile = normalizeAlignmentProfile(requestedProfile ?? ALIGNMENT_PROFILE_STANDARD_5);
78
88
 
79
89
  if (version === 1) {
80
90
  const center = size - 4;
@@ -84,7 +94,8 @@ function alignmentPatternCentersForVersion(version) {
84
94
  size: 5,
85
95
  primary: true,
86
96
  bootstrap: true,
87
- separator: true
97
+ separator: true,
98
+ profile
88
99
  }];
89
100
  }
90
101
 
@@ -106,10 +117,13 @@ function alignmentPatternCentersForVersion(version) {
106
117
  centers.push({
107
118
  row,
108
119
  col,
109
- size: primary ? 5 : 3,
120
+ // Format v6 uses a real QR-style 5x5 black/white/black alignment eye
121
+ // everywhere. Legacy v5 kept compact 3x3 secondaries to save cells.
122
+ size: profile === ALIGNMENT_PROFILE_LEGACY_3 && !primary ? 3 : 5,
110
123
  primary,
111
124
  bootstrap: false,
112
- separator: false
125
+ separator: false,
126
+ profile
113
127
  });
114
128
  }
115
129
  }
@@ -117,8 +131,8 @@ function alignmentPatternCentersForVersion(version) {
117
131
  return centers;
118
132
  }
119
133
 
120
- function primaryAlignmentPatternForVersion(version) {
121
- const centers = alignmentPatternCentersForVersion(version);
134
+ function primaryAlignmentPatternForVersion(version, options = {}) {
135
+ const centers = alignmentPatternCentersForVersion(version, options);
122
136
  return centers.find((pattern) => pattern.primary) ?? centers[centers.length - 1];
123
137
  }
124
138
 
@@ -131,17 +145,17 @@ function alignmentPatternIsBlack(pattern, rowOffset, colOffset) {
131
145
  if (Math.abs(rowOffset) > radius || Math.abs(colOffset) > radius) return null;
132
146
 
133
147
  if (pattern.size === 3) {
134
- // Compact secondary marker: black 3x3 ring with a white center.
148
+ // Legacy format-v5 secondary marker: black 3x3 ring with a white center.
135
149
  return rowOffset !== 0 || colOffset !== 0;
136
150
  }
137
151
 
138
- // Primary 5x5 marker: black outer ring, white inner ring, black center.
152
+ // QR-style 5x5 marker: black outer ring, white inner ring, black center.
139
153
  const outer = Math.abs(rowOffset) === 2 || Math.abs(colOffset) === 2;
140
154
  const center = rowOffset === 0 && colOffset === 0;
141
155
  return outer || center;
142
156
  }
143
157
 
144
- return { sizeForVersion, versionFromSize, alignmentPatternCentersForVersion, primaryAlignmentPatternForVersion, alignmentPatternRadius, alignmentPatternIsBlack, MIN_GEOMETRY_VERSION, MAX_GEOMETRY_VERSION, ALIGNMENT_PATTERN_AXES };
158
+ return { normalizeAlignmentProfile, sizeForVersion, versionFromSize, alignmentPatternCentersForVersion, primaryAlignmentPatternForVersion, alignmentPatternRadius, alignmentPatternIsBlack, MIN_GEOMETRY_VERSION, MAX_GEOMETRY_VERSION, ALIGNMENT_PROFILE_STANDARD_5, ALIGNMENT_PROFILE_LEGACY_3, ALIGNMENT_PATTERN_AXES };
145
159
  })();
146
160
  const __qqr_reed_solomon_js = (function () {
147
161
 
@@ -920,7 +934,7 @@ const securityInternals = Object.freeze({
920
934
  return { bytesToHex, hexToBytes, normalizeRaw256Key, generateRaw256Key, estimateSecureEnvelopeOverhead, inspectSecureEnvelope, encryptSecurePayload, decryptSecurePayload, SECURE_PAYLOAD_VERSION, DEFAULT_PBKDF2_ITERATIONS, MIN_PBKDF2_ITERATIONS, MAX_PBKDF2_ITERATIONS, SECURITY_MODES, SECURITY_ALGORITHMS, securityInternals };
921
935
  })();
922
936
  const __qqr_vision_js = (function () {
923
- const { alignmentPatternCentersForVersion, alignmentPatternIsBlack, alignmentPatternRadius, primaryAlignmentPatternForVersion, sizeForVersion } = __qqr_geometry_js;
937
+ const { alignmentPatternCentersForVersion, alignmentPatternIsBlack, alignmentPatternRadius, primaryAlignmentPatternForVersion, ALIGNMENT_PROFILE_STANDARD_5, ALIGNMENT_PROFILE_LEGACY_3, sizeForVersion } = __qqr_geometry_js;
924
938
 
925
939
  function assert(condition, message) {
926
940
  if (!condition) throw new Error(message);
@@ -930,6 +944,19 @@ function clamp(value, min, max) {
930
944
  return Math.max(min, Math.min(max, value));
931
945
  }
932
946
 
947
+ let visionAccelerator = null;
948
+
949
+ // Repeated recovery stages often inspect the exact same captured ImageData.
950
+ // Cache immutable grayscale/binary preprocessing by ImageData identity so the
951
+ // stronger scanner can reuse work instead of rebuilding millions of pixels.
952
+ // WeakMap keeps camera frames collectible as soon as the scan finishes.
953
+ const binaryPreprocessCache = new WeakMap();
954
+ const autoColorGrayCache = new WeakMap();
955
+
956
+ function installVisionAccelerator(accelerator = null) {
957
+ visionAccelerator = accelerator && typeof accelerator.buildBinary === "function" ? accelerator : null;
958
+ }
959
+
933
960
  function pixelRgb(imageData, x, y) {
934
961
  const ix = clamp(Math.round(x), 0, imageData.width - 1);
935
962
  const iy = clamp(Math.round(y), 0, imageData.height - 1);
@@ -1025,54 +1052,140 @@ function binaryAtThreshold(gray, threshold) {
1025
1052
  return binary;
1026
1053
  }
1027
1054
 
1055
+ function hybridLocalBinary(gray, width, height) {
1056
+ // QR-specific local thresholding inspired by the same block strategy used by
1057
+ // ZXing's HybridBinarizer. It is intentionally a locator fallback, not a
1058
+ // replacement for QuadQR's color correction. 8x8 blocks + smoothed local
1059
+ // black points make finder rings survive shadows and screen gradients that
1060
+ // defeat one global threshold.
1061
+ const BLOCK = 8;
1062
+ const MIN_DIMENSION = 40;
1063
+ const MIN_DYNAMIC_RANGE = 24;
1064
+ if (width < MIN_DIMENSION || height < MIN_DIMENSION) return null;
1065
+
1066
+ const subWidth = Math.ceil(width / BLOCK);
1067
+ const subHeight = Math.ceil(height / BLOCK);
1068
+ const blackPoints = new Uint16Array(subWidth * subHeight);
1069
+ const maxXOffset = Math.max(0, width - BLOCK);
1070
+ const maxYOffset = Math.max(0, height - BLOCK);
1071
+
1072
+ for (let by = 0; by < subHeight; by++) {
1073
+ const y0 = Math.min(by * BLOCK, maxYOffset);
1074
+ for (let bx = 0; bx < subWidth; bx++) {
1075
+ const x0 = Math.min(bx * BLOCK, maxXOffset);
1076
+ let sum = 0;
1077
+ let min = 255;
1078
+ let max = 0;
1079
+ for (let yy = 0; yy < BLOCK; yy++) {
1080
+ const row = (y0 + yy) * width + x0;
1081
+ for (let xx = 0; xx < BLOCK; xx++) {
1082
+ const value = gray[row + xx];
1083
+ sum += value;
1084
+ if (value < min) min = value;
1085
+ if (value > max) max = value;
1086
+ }
1087
+ }
1088
+ let average = sum >> 6;
1089
+ if (max - min <= MIN_DYNAMIC_RANGE) {
1090
+ average = min >> 1;
1091
+ if (by > 0 && bx > 0) {
1092
+ const above = blackPoints[(by - 1) * subWidth + bx];
1093
+ const left = blackPoints[by * subWidth + bx - 1];
1094
+ const diag = blackPoints[(by - 1) * subWidth + bx - 1];
1095
+ const neighbor = (above + 2 * left + diag) >> 2;
1096
+ if (min < neighbor) average = neighbor;
1097
+ }
1098
+ }
1099
+ blackPoints[by * subWidth + bx] = average;
1100
+ }
1101
+ }
1102
+
1103
+ const binary = new Uint8Array(width * height);
1104
+ for (let by = 0; by < subHeight; by++) {
1105
+ const y0 = Math.min(by * BLOCK, maxYOffset);
1106
+ const centerY = clamp(by, 2, Math.max(2, subHeight - 3));
1107
+ for (let bx = 0; bx < subWidth; bx++) {
1108
+ const x0 = Math.min(bx * BLOCK, maxXOffset);
1109
+ const centerX = clamp(bx, 2, Math.max(2, subWidth - 3));
1110
+ let sum = 0;
1111
+ let count = 0;
1112
+ for (let oy = -2; oy <= 2; oy++) {
1113
+ const py = clamp(centerY + oy, 0, subHeight - 1);
1114
+ for (let ox = -2; ox <= 2; ox++) {
1115
+ const px = clamp(centerX + ox, 0, subWidth - 1);
1116
+ sum += blackPoints[py * subWidth + px];
1117
+ count++;
1118
+ }
1119
+ }
1120
+ const threshold = Math.round(sum / Math.max(1, count));
1121
+ for (let yy = 0; yy < BLOCK; yy++) {
1122
+ const y = y0 + yy;
1123
+ if (y >= height) break;
1124
+ const row = y * width;
1125
+ for (let xx = 0; xx < BLOCK; xx++) {
1126
+ const x = x0 + xx;
1127
+ if (x >= width) break;
1128
+ if (gray[row + x] <= threshold) binary[row + x] = 1;
1129
+ }
1130
+ }
1131
+ }
1132
+ }
1133
+ return binary;
1134
+ }
1135
+
1028
1136
  function buildBinary(imageData, options = {}) {
1029
1137
  const grayMode = options.grayMode ?? "luminance";
1138
+ const thresholdOffset = Math.round(Number(options.thresholdOffset) || 0);
1139
+ const canCache = imageData && typeof imageData === "object" && options.cache !== false;
1140
+ const cacheKey = `${grayMode}:${thresholdOffset}`;
1141
+ if (canCache) {
1142
+ const cached = binaryPreprocessCache.get(imageData)?.get(cacheKey);
1143
+ if (cached) return cached;
1144
+ }
1145
+
1146
+ let result;
1147
+ if (visionAccelerator) {
1148
+ try {
1149
+ const accelerated = visionAccelerator.buildBinary(imageData, {
1150
+ grayMode,
1151
+ thresholdOffset
1152
+ });
1153
+ if (accelerated?.gray && accelerated?.binary) {
1154
+ result = accelerated;
1155
+ if (canCache) {
1156
+ let entries = binaryPreprocessCache.get(imageData);
1157
+ if (!entries) binaryPreprocessCache.set(imageData, entries = new Map());
1158
+ entries.set(cacheKey, result);
1159
+ }
1160
+ return result;
1161
+ }
1162
+ } catch {
1163
+ // A WASM/runtime failure must never make scanning unavailable. Fall back
1164
+ // to the exact JavaScript implementation for this and future calls.
1165
+ visionAccelerator = null;
1166
+ }
1167
+ }
1168
+
1030
1169
  const gray = buildGray(imageData, grayMode);
1031
1170
  const baseThreshold = otsuThreshold(gray);
1032
1171
  const threshold = clamp(
1033
- Math.round(baseThreshold + (options.thresholdOffset ?? 0)),
1172
+ Math.round(baseThreshold + thresholdOffset),
1034
1173
  8,
1035
1174
  247
1036
1175
  );
1037
- return {
1176
+ result = {
1038
1177
  gray,
1039
1178
  binary: binaryAtThreshold(gray, threshold),
1040
1179
  threshold,
1041
1180
  baseThreshold,
1042
1181
  grayMode
1043
1182
  };
1044
- }
1045
-
1046
- function runsForRow(binary, width, row) {
1047
- const runs = [];
1048
- let color = binary[row * width];
1049
- let start = 0;
1050
- for (let x = 1; x < width; x++) {
1051
- const next = binary[row * width + x];
1052
- if (next !== color) {
1053
- runs.push({ color, start, length: x - start });
1054
- color = next;
1055
- start = x;
1056
- }
1057
- }
1058
- runs.push({ color, start, length: width - start });
1059
- return runs;
1060
- }
1061
-
1062
- function runsForColumn(binary, width, height, col) {
1063
- const runs = [];
1064
- let color = binary[col];
1065
- let start = 0;
1066
- for (let y = 1; y < height; y++) {
1067
- const next = binary[y * width + col];
1068
- if (next !== color) {
1069
- runs.push({ color, start, length: y - start });
1070
- color = next;
1071
- start = y;
1072
- }
1183
+ if (canCache) {
1184
+ let entries = binaryPreprocessCache.get(imageData);
1185
+ if (!entries) binaryPreprocessCache.set(imageData, entries = new Map());
1186
+ entries.set(cacheKey, result);
1073
1187
  }
1074
- runs.push({ color, start, length: height - start });
1075
- return runs;
1188
+ return result;
1076
1189
  }
1077
1190
 
1078
1191
  function finderRatioScore(lengths, toleranceScale = 1) {
@@ -1090,34 +1203,85 @@ function finderRatioScore(lengths, toleranceScale = 1) {
1090
1203
  return score;
1091
1204
  }
1092
1205
 
1093
- function findWindowContainingCoordinate(runs, coordinate, toleranceScale = 1) {
1094
- for (let i = 2; i < runs.length - 2; i++) {
1095
- const centerRun = runs[i];
1096
- if (centerRun.color !== 1) continue;
1097
- if (coordinate < centerRun.start || coordinate >= centerRun.start + centerRun.length) continue;
1098
- const window = runs.slice(i - 2, i + 3);
1099
- if (window.map((run) => run.color).join("") !== "10101") continue;
1100
- const score = finderRatioScore(window.map((run) => run.length), toleranceScale);
1101
- if (!Number.isFinite(score)) continue;
1102
- const first = window[0].start;
1103
- const total = window.reduce((sum, run) => sum + run.length, 0);
1104
- return {
1105
- center: first + total / 2,
1106
- moduleSize: total / 7,
1107
- score
1108
- };
1109
- }
1110
- return null;
1111
- }
1112
-
1113
- function crossCheckVertical(binary, width, height, x, y, toleranceScale = 1) {
1114
- const col = clamp(Math.round(x), 0, width - 1);
1115
- return findWindowContainingCoordinate(runsForColumn(binary, width, height, col), y, toleranceScale);
1116
- }
1117
-
1118
- function crossCheckHorizontal(binary, width, height, x, y, toleranceScale = 1) {
1119
- const row = clamp(Math.round(y), 0, height - 1);
1120
- return findWindowContainingCoordinate(runsForRow(binary, width, row), x, toleranceScale);
1206
+ function finderCenterFromEnd(stateCount, end) {
1207
+ return end - stateCount[4] - stateCount[3] - stateCount[2] / 2;
1208
+ }
1209
+
1210
+ function directCrossCheckVertical(binary, width, height, startY, centerX, maxCount, originalTotal, toleranceScale = 1) {
1211
+ const x = clamp(Math.round(centerX), 0, width - 1);
1212
+ const state = [0, 0, 0, 0, 0];
1213
+ let y = clamp(Math.round(startY), 0, height - 1);
1214
+
1215
+ while (y >= 0 && binary[y * width + x]) { state[2]++; y--; }
1216
+ if (y < 0) return null;
1217
+ while (y >= 0 && !binary[y * width + x] && state[1] <= maxCount) { state[1]++; y--; }
1218
+ if (y < 0 || state[1] > maxCount) return null;
1219
+ while (y >= 0 && binary[y * width + x] && state[0] <= maxCount) { state[0]++; y--; }
1220
+ if (state[0] > maxCount) return null;
1221
+
1222
+ y = clamp(Math.round(startY), 0, height - 1) + 1;
1223
+ while (y < height && binary[y * width + x]) { state[2]++; y++; }
1224
+ if (y === height) return null;
1225
+ while (y < height && !binary[y * width + x] && state[3] < maxCount) { state[3]++; y++; }
1226
+ if (y === height || state[3] >= maxCount) return null;
1227
+ while (y < height && binary[y * width + x] && state[4] < maxCount) { state[4]++; y++; }
1228
+ if (state[4] >= maxCount) return null;
1229
+
1230
+ const total = state.reduce((sum, value) => sum + value, 0);
1231
+ if (Math.abs(total - originalTotal) > originalTotal * 0.40) return null;
1232
+ const score = finderRatioScore(state, toleranceScale);
1233
+ if (!Number.isFinite(score)) return null;
1234
+ return { center: finderCenterFromEnd(state, y), moduleSize: total / 7, score };
1235
+ }
1236
+
1237
+ function directCrossCheckHorizontal(binary, width, height, startX, centerY, maxCount, originalTotal, toleranceScale = 1) {
1238
+ const y = clamp(Math.round(centerY), 0, height - 1);
1239
+ const row = y * width;
1240
+ const state = [0, 0, 0, 0, 0];
1241
+ let x = clamp(Math.round(startX), 0, width - 1);
1242
+
1243
+ while (x >= 0 && binary[row + x]) { state[2]++; x--; }
1244
+ if (x < 0) return null;
1245
+ while (x >= 0 && !binary[row + x] && state[1] <= maxCount) { state[1]++; x--; }
1246
+ if (x < 0 || state[1] > maxCount) return null;
1247
+ while (x >= 0 && binary[row + x] && state[0] <= maxCount) { state[0]++; x--; }
1248
+ if (state[0] > maxCount) return null;
1249
+
1250
+ x = clamp(Math.round(startX), 0, width - 1) + 1;
1251
+ while (x < width && binary[row + x]) { state[2]++; x++; }
1252
+ if (x === width) return null;
1253
+ while (x < width && !binary[row + x] && state[3] < maxCount) { state[3]++; x++; }
1254
+ if (x === width || state[3] >= maxCount) return null;
1255
+ while (x < width && binary[row + x] && state[4] < maxCount) { state[4]++; x++; }
1256
+ if (state[4] >= maxCount) return null;
1257
+
1258
+ const total = state.reduce((sum, value) => sum + value, 0);
1259
+ if (Math.abs(total - originalTotal) > originalTotal * 0.25) return null;
1260
+ const score = finderRatioScore(state, toleranceScale);
1261
+ if (!Number.isFinite(score)) return null;
1262
+ return { center: finderCenterFromEnd(state, x), moduleSize: total / 7, score };
1263
+ }
1264
+
1265
+ function directCrossCheckDiagonal(binary, width, height, centerX, centerY, toleranceScale = 1) {
1266
+ const cx = clamp(Math.round(centerX), 0, width - 1);
1267
+ const cy = clamp(Math.round(centerY), 0, height - 1);
1268
+ const state = [0, 0, 0, 0, 0];
1269
+ let step = 0;
1270
+ while (cx - step >= 0 && cy - step >= 0 && binary[(cy - step) * width + (cx - step)]) { state[2]++; step++; }
1271
+ if (!state[2]) return false;
1272
+ while (cx - step >= 0 && cy - step >= 0 && !binary[(cy - step) * width + (cx - step)]) { state[1]++; step++; }
1273
+ if (!state[1]) return false;
1274
+ while (cx - step >= 0 && cy - step >= 0 && binary[(cy - step) * width + (cx - step)]) { state[0]++; step++; }
1275
+ if (!state[0]) return false;
1276
+
1277
+ step = 1;
1278
+ while (cx + step < width && cy + step < height && binary[(cy + step) * width + (cx + step)]) { state[2]++; step++; }
1279
+ while (cx + step < width && cy + step < height && !binary[(cy + step) * width + (cx + step)]) { state[3]++; step++; }
1280
+ if (!state[3]) return false;
1281
+ while (cx + step < width && cy + step < height && binary[(cy + step) * width + (cx + step)]) { state[4]++; step++; }
1282
+ if (!state[4]) return false;
1283
+
1284
+ return Number.isFinite(finderRatioScore(state, toleranceScale * 1.35));
1121
1285
  }
1122
1286
 
1123
1287
  function clusterFinderCandidates(raw, minConfirmations = 2) {
@@ -1162,47 +1326,180 @@ function clusterFinderCandidates(raw, minConfirmations = 2) {
1162
1326
  }
1163
1327
 
1164
1328
  function detectFinderCandidates(binary, width, height, options = {}) {
1329
+ // Finder acquisition follows the same broad strategy that makes mature QR
1330
+ // readers feel immediate: scan a subset of rows for 1:1:3:1:1, then confirm
1331
+ // each hit directly across the orthogonal axes. Unlike the previous scanner,
1332
+ // this does not allocate complete run arrays for every row and column.
1165
1333
  const raw = [];
1166
- const rowStep = height > 1200 ? 2 : 1;
1167
1334
  const toleranceScale = options.toleranceScale ?? 1;
1168
1335
  const moduleSpreadLimit = options.moduleSpreadLimit ?? 0.45;
1169
1336
  const minConfirmations = options.minConfirmations ?? 2;
1337
+ const rowStep = Math.max(1, Math.round(options.rowStep ?? (height > 900 ? 2 : 1)));
1338
+ const diagonalCheck = options.diagonalCheck === true;
1339
+ const maxRawCandidates = Math.max(24, Math.round(options.maxRawCandidates ?? 160));
1340
+
1341
+ const handlePossibleCenter = (stateCount, y, endX) => {
1342
+ const ratioScore = finderRatioScore(stateCount, toleranceScale);
1343
+ if (!Number.isFinite(ratioScore)) return false;
1344
+ const total = stateCount.reduce((sum, value) => sum + value, 0);
1345
+ const centerX = finderCenterFromEnd(stateCount, endX);
1346
+ const maxCount = Math.max(2, Math.ceil(stateCount[2] * 1.25));
1347
+ const vertical = directCrossCheckVertical(binary, width, height, y, centerX, maxCount, total, toleranceScale);
1348
+ if (!vertical) return false;
1349
+ const horizontal = directCrossCheckHorizontal(binary, width, height, centerX, vertical.center, maxCount, total, toleranceScale);
1350
+ if (!horizontal) return false;
1351
+ if (diagonalCheck && !directCrossCheckDiagonal(binary, width, height, horizontal.center, vertical.center, toleranceScale)) return false;
1352
+
1353
+ const moduleSize = (total / 7 + vertical.moduleSize + horizontal.moduleSize) / 3;
1354
+ const moduleSpread = Math.max(
1355
+ Math.abs(moduleSize - total / 7),
1356
+ Math.abs(moduleSize - vertical.moduleSize),
1357
+ Math.abs(moduleSize - horizontal.moduleSize)
1358
+ ) / Math.max(0.01, moduleSize);
1359
+ if (moduleSpread > moduleSpreadLimit) return false;
1360
+
1361
+ raw.push({
1362
+ x: horizontal.center,
1363
+ y: vertical.center,
1364
+ moduleSize,
1365
+ score: ratioScore + vertical.score + horizontal.score
1366
+ });
1367
+ return true;
1368
+ };
1170
1369
 
1171
- for (let y = 0; y < height; y += rowStep) {
1172
- const runs = runsForRow(binary, width, y);
1173
- for (let i = 0; i <= runs.length - 5; i++) {
1174
- const window = runs.slice(i, i + 5);
1175
- if (window.map((run) => run.color).join("") !== "10101") continue;
1176
- const lengths = window.map((run) => run.length);
1177
- const ratioScore = finderRatioScore(lengths, toleranceScale);
1178
- if (!Number.isFinite(ratioScore)) continue;
1179
- const total = lengths.reduce((sum, value) => sum + value, 0);
1180
- const centerX = window[0].start + total / 2;
1181
- const vertical = crossCheckVertical(binary, width, height, centerX, y, toleranceScale);
1182
- if (!vertical) continue;
1183
- const horizontal = crossCheckHorizontal(binary, width, height, centerX, vertical.center, toleranceScale);
1184
- if (!horizontal) continue;
1185
-
1186
- const moduleSize = (total / 7 + vertical.moduleSize + horizontal.moduleSize) / 3;
1187
- const moduleSpread = Math.max(
1188
- Math.abs(moduleSize - total / 7),
1189
- Math.abs(moduleSize - vertical.moduleSize),
1190
- Math.abs(moduleSize - horizontal.moduleSize)
1191
- ) / moduleSize;
1192
- if (moduleSpread > moduleSpreadLimit) continue;
1193
-
1194
- raw.push({
1195
- x: horizontal.center,
1196
- y: vertical.center,
1197
- moduleSize,
1198
- score: ratioScore + vertical.score + horizontal.score
1199
- });
1370
+ for (let y = rowStep - 1; y < height; y += rowStep) {
1371
+ const state = [0, 0, 0, 0, 0];
1372
+ let currentState = 0;
1373
+ const row = y * width;
1374
+
1375
+ for (let x = 0; x < width; x++) {
1376
+ if (binary[row + x]) {
1377
+ if ((currentState & 1) === 1) currentState++;
1378
+ state[currentState]++;
1379
+ } else {
1380
+ if ((currentState & 1) === 0) {
1381
+ if (currentState === 4) {
1382
+ handlePossibleCenter(state, y, x);
1383
+ state[0] = state[2];
1384
+ state[1] = state[3];
1385
+ state[2] = state[4];
1386
+ state[3] = 1;
1387
+ state[4] = 0;
1388
+ currentState = 3;
1389
+ } else {
1390
+ currentState++;
1391
+ state[currentState]++;
1392
+ }
1393
+ } else {
1394
+ state[currentState]++;
1395
+ }
1396
+ }
1200
1397
  }
1398
+ if (currentState === 4) handlePossibleCenter(state, y, width);
1399
+ if (raw.length >= maxRawCandidates) break;
1201
1400
  }
1202
1401
 
1203
1402
  return clusterFinderCandidates(raw, minConfirmations);
1204
1403
  }
1205
1404
 
1405
+ function detectFinderCandidatesByComponents(binary, width, height, options = {}) {
1406
+ const visited = new Uint8Array(width * height);
1407
+ const stack = [];
1408
+ const candidates = [];
1409
+ const minArea = Math.max(16, Math.round(options.componentMinArea ?? 20));
1410
+ const minSpan = Math.max(5, Math.round(options.componentMinSpan ?? 7));
1411
+ const maxComponents = Math.max(64, Math.round(options.componentMaxCount ?? 600));
1412
+ let componentsSeen = 0;
1413
+
1414
+ const templateScore = (minX, minY, maxX, maxY) => {
1415
+ const spanX = maxX - minX + 1;
1416
+ const spanY = maxY - minY + 1;
1417
+ let matches = 0;
1418
+ let total = 0;
1419
+ for (let r = 0; r < 7; r++) {
1420
+ for (let c = 0; c < 7; c++) {
1421
+ const x = minX + ((c + 0.5) / 7) * spanX;
1422
+ const y = minY + ((r + 0.5) / 7) * spanY;
1423
+ const actual = sampleBinaryAt(binary, width, height, x, y);
1424
+ if (actual == null) continue;
1425
+ const expected = r === 0 || r === 6 || c === 0 || c === 6 || (r >= 2 && r <= 4 && c >= 2 && c <= 4);
1426
+ total++;
1427
+ if (Boolean(actual) === expected) matches++;
1428
+ }
1429
+ }
1430
+ return total ? matches / total : 0;
1431
+ };
1432
+
1433
+ for (let index = 0; index < binary.length; index++) {
1434
+ if (!binary[index] || visited[index]) continue;
1435
+ componentsSeen++;
1436
+ if (componentsSeen > maxComponents) break;
1437
+ visited[index] = 1;
1438
+ stack.length = 0;
1439
+ stack.push(index);
1440
+ let area = 0;
1441
+ let minX = width;
1442
+ let minY = height;
1443
+ let maxX = -1;
1444
+ let maxY = -1;
1445
+
1446
+ while (stack.length) {
1447
+ const current = stack.pop();
1448
+ const y = Math.floor(current / width);
1449
+ const x = current - y * width;
1450
+ area++;
1451
+ if (x < minX) minX = x;
1452
+ if (x > maxX) maxX = x;
1453
+ if (y < minY) minY = y;
1454
+ if (y > maxY) maxY = y;
1455
+
1456
+ if (x > 0) {
1457
+ const next = current - 1;
1458
+ if (binary[next] && !visited[next]) { visited[next] = 1; stack.push(next); }
1459
+ }
1460
+ if (x + 1 < width) {
1461
+ const next = current + 1;
1462
+ if (binary[next] && !visited[next]) { visited[next] = 1; stack.push(next); }
1463
+ }
1464
+ if (y > 0) {
1465
+ const next = current - width;
1466
+ if (binary[next] && !visited[next]) { visited[next] = 1; stack.push(next); }
1467
+ }
1468
+ if (y + 1 < height) {
1469
+ const next = current + width;
1470
+ if (binary[next] && !visited[next]) { visited[next] = 1; stack.push(next); }
1471
+ }
1472
+ }
1473
+
1474
+ const spanX = maxX - minX + 1;
1475
+ const spanY = maxY - minY + 1;
1476
+ if (area < minArea || spanX < minSpan || spanY < minSpan) continue;
1477
+ const aspect = spanX / spanY;
1478
+ if (aspect < 0.18 || aspect > 5.5) continue;
1479
+ const density = area / (spanX * spanY);
1480
+ if (density < 0.10 || density > 0.78) continue;
1481
+ const centerX = (minX + maxX) / 2;
1482
+ const centerY = (minY + maxY) / 2;
1483
+ if (sampleBinaryAt(binary, width, height, centerX, centerY) !== 1) continue;
1484
+ const score = templateScore(minX, minY, maxX, maxY);
1485
+ if (score < (options.componentTemplateThreshold ?? 0.63)) continue;
1486
+
1487
+ candidates.push({
1488
+ x: centerX,
1489
+ y: centerY,
1490
+ moduleSize: Math.max(0.75, Math.sqrt(area / 24)),
1491
+ score: (1 - score) * 3,
1492
+ componentScore: score,
1493
+ componentArea: area
1494
+ });
1495
+ }
1496
+
1497
+ return candidates.sort((a, b) =>
1498
+ (b.componentScore - a.componentScore) ||
1499
+ (b.componentArea - a.componentArea)
1500
+ ).slice(0, Math.max(3, Math.round(options.componentMaxCandidates ?? 12)));
1501
+ }
1502
+
1206
1503
  function recoverFinderSetFromTwo(binary, width, height, strongFinders, detector = {}) {
1207
1504
  if (strongFinders.length !== 2) return strongFinders;
1208
1505
  const moduleMean = (strongFinders[0].moduleSize + strongFinders[1].moduleSize) / 2;
@@ -1308,6 +1605,61 @@ function chooseFinderTriples(candidates, maxTriples = 16, options = {}) {
1308
1605
  return triples.slice(0, maxTriples);
1309
1606
  }
1310
1607
 
1608
+ function rayDistanceToImageBoundary(width, height, x, y, dx, dy) {
1609
+ let limit = Infinity;
1610
+ if (dx > 1e-9) limit = Math.min(limit, (width - 1 - x) / dx);
1611
+ else if (dx < -1e-9) limit = Math.min(limit, (0 - x) / dx);
1612
+ if (dy > 1e-9) limit = Math.min(limit, (height - 1 - y) / dy);
1613
+ else if (dy < -1e-9) limit = Math.min(limit, (0 - y) / dy);
1614
+ return Number.isFinite(limit) ? Math.max(0, limit) : 0;
1615
+ }
1616
+
1617
+ function finderHalfRunDistance(binary, width, height, center, direction) {
1618
+ const length = Math.hypot(direction.x, direction.y);
1619
+ if (length < 1e-6) return NaN;
1620
+ const dx = direction.x / length;
1621
+ const dy = direction.y / length;
1622
+ const maxDistance = rayDistanceToImageBoundary(width, height, center.x, center.y, dx, dy);
1623
+ let previous = sampleBinaryAt(binary, width, height, center.x, center.y);
1624
+ if (previous !== 1) return NaN;
1625
+ let transitions = 0;
1626
+ let lastDistance = 0;
1627
+ // Half-pixel stepping keeps the measured boundary stable at small module
1628
+ // sizes without becoming expensive. A finder needs only three transitions:
1629
+ // center black -> white ring -> black ring -> outside white.
1630
+ for (let distance = 0.5; distance <= maxDistance; distance += 0.5) {
1631
+ const value = sampleBinaryAt(binary, width, height, center.x + dx * distance, center.y + dy * distance);
1632
+ if (value == null) break;
1633
+ if (value !== previous) {
1634
+ transitions++;
1635
+ previous = value;
1636
+ if (transitions === 3) return distance;
1637
+ }
1638
+ lastDistance = distance;
1639
+ if (distance > 80 && transitions === 0) break;
1640
+ }
1641
+ return transitions >= 2 ? lastDistance : NaN;
1642
+ }
1643
+
1644
+ function directionalFinderModuleSize(binary, width, height, pattern, otherPattern) {
1645
+ const direction = { x: otherPattern.x - pattern.x, y: otherPattern.y - pattern.y };
1646
+ const forward = finderHalfRunDistance(binary, width, height, pattern, direction);
1647
+ const backward = finderHalfRunDistance(binary, width, height, pattern, { x: -direction.x, y: -direction.y });
1648
+ if (!Number.isFinite(forward) && !Number.isFinite(backward)) return NaN;
1649
+ if (!Number.isFinite(forward)) return (backward * 2) / 7;
1650
+ if (!Number.isFinite(backward)) return (forward * 2) / 7;
1651
+ return (forward + backward) / 7;
1652
+ }
1653
+
1654
+ function moduleSizeBetweenFinders(binary, width, height, a, b) {
1655
+ const fromA = directionalFinderModuleSize(binary, width, height, a, b);
1656
+ const fromB = directionalFinderModuleSize(binary, width, height, b, a);
1657
+ if (Number.isFinite(fromA) && Number.isFinite(fromB)) return (fromA + fromB) / 2;
1658
+ if (Number.isFinite(fromA)) return fromA;
1659
+ if (Number.isFinite(fromB)) return fromB;
1660
+ return (a.moduleSize + b.moduleSize) / 2;
1661
+ }
1662
+
1311
1663
  function nearestVersionFromEstimate(value, minVersion, maxVersion) {
1312
1664
  const candidates = [];
1313
1665
  for (let version = minVersion; version <= maxVersion; version++) {
@@ -1378,6 +1730,112 @@ function preciseAlignmentScore(binary, width, height, center, basisU, basisV, sc
1378
1730
  return total ? matches / total : 0;
1379
1731
  }
1380
1732
 
1733
+ // Fast 5x5 nested-eye probe used before the heavier alignment template search.
1734
+ // A standard 5x5 alignment pattern has a particularly strong signature along
1735
+ // its centre axes: black / white / black / white / black. We also probe the
1736
+ // inner and outer diagonals so random payload modules are much less likely to
1737
+ // impersonate an alignment eye. This is deliberately tiny: at most 17 binary
1738
+ // samples per candidate instead of a full 25/125-sample template evaluation.
1739
+ const FAST_ALIGNMENT_PROBES = Object.freeze([
1740
+ Object.freeze([0, 0, 1, 2.2]),
1741
+ Object.freeze([-1, 0, 0, 1.4]), Object.freeze([1, 0, 0, 1.4]),
1742
+ Object.freeze([0, -1, 0, 1.4]), Object.freeze([0, 1, 0, 1.4]),
1743
+ Object.freeze([-2, 0, 1, 1.2]), Object.freeze([2, 0, 1, 1.2]),
1744
+ Object.freeze([0, -2, 1, 1.2]), Object.freeze([0, 2, 1, 1.2]),
1745
+ Object.freeze([-1, -1, 0, 0.9]), Object.freeze([1, -1, 0, 0.9]),
1746
+ Object.freeze([-1, 1, 0, 0.9]), Object.freeze([1, 1, 0, 0.9]),
1747
+ Object.freeze([-2, -2, 1, 0.8]), Object.freeze([2, -2, 1, 0.8]),
1748
+ Object.freeze([-2, 2, 1, 0.8]), Object.freeze([2, 2, 1, 0.8])
1749
+ ]);
1750
+
1751
+ function fastNestedAlignmentScore(binary, width, height, center, basisU, basisV, scale) {
1752
+ let matched = 0;
1753
+ let total = 0;
1754
+ for (const [c, r, expected, weight] of FAST_ALIGNMENT_PROBES) {
1755
+ const x = center.x + basisU.x * c * scale + basisV.x * r * scale;
1756
+ const y = center.y + basisU.y * c * scale + basisV.y * r * scale;
1757
+ const value = sampleBinaryAt(binary, width, height, x, y);
1758
+ if (value === null) continue;
1759
+ total += weight;
1760
+ if (value === expected) matched += weight;
1761
+ }
1762
+ return total ? matched / total : 0;
1763
+ }
1764
+
1765
+ function searchNestedAlignmentFast(binary, width, height, predicted, basisU, basisV, target, options = {}) {
1766
+ if (target?.size !== 5 || options.fastAlignmentLocator === false) return null;
1767
+
1768
+ const inferredScale = clamp(Number(options.inferredTargetScale ?? 1), 0.5, 2.1);
1769
+ const radius = clamp(Number(options.radius ?? 5), 2.5, 18);
1770
+ const coarseStep = radius >= 14 ? 2 : radius >= 9 ? 1.5 : 1;
1771
+ const scales = [...new Set([
1772
+ Number((inferredScale * 0.78).toFixed(3)),
1773
+ Number((inferredScale * 0.90).toFixed(3)),
1774
+ Number(inferredScale.toFixed(3)),
1775
+ Number((inferredScale * 1.12).toFixed(3)),
1776
+ Number((inferredScale * 1.28).toFixed(3)),
1777
+ 0.75, 1, 1.25
1778
+ ])].filter((value) => value >= 0.48 && value <= 2.1);
1779
+
1780
+ const candidates = [];
1781
+ for (let offsetV = -radius; offsetV <= radius + 0.001; offsetV += coarseStep) {
1782
+ for (let offsetU = -radius; offsetU <= radius + 0.001; offsetU += coarseStep) {
1783
+ const center = {
1784
+ x: predicted.x + basisU.x * offsetU + basisV.x * offsetV,
1785
+ y: predicted.y + basisU.y * offsetU + basisV.y * offsetV
1786
+ };
1787
+ let bestScore = 0;
1788
+ let bestScale = 1;
1789
+ for (const scale of scales) {
1790
+ const score = fastNestedAlignmentScore(binary, width, height, center, basisU, basisV, scale);
1791
+ if (score > bestScore) {
1792
+ bestScore = score;
1793
+ bestScale = scale;
1794
+ }
1795
+ }
1796
+ // Keeping only plausible nested eyes makes the fine phase effectively
1797
+ // constant-time even on very dense symbols.
1798
+ if (bestScore >= (options.fastAlignmentSeedThreshold ?? 0.73)) {
1799
+ candidates.push({ score: bestScore, center, scale: bestScale, offsetU, offsetV });
1800
+ }
1801
+ }
1802
+ }
1803
+
1804
+ if (!candidates.length) return null;
1805
+ candidates.sort((a, b) => b.score - a.score);
1806
+ const fineSeeds = candidates.slice(0, Math.max(1, Math.round(options.fastAlignmentFineSeeds ?? 5)));
1807
+ const fineOffsets = [-0.75, -0.35, 0, 0.35, 0.75];
1808
+ let best = null;
1809
+
1810
+ for (const seed of fineSeeds) {
1811
+ const fineScales = [...new Set([
1812
+ Number((seed.scale * 0.90).toFixed(3)),
1813
+ Number((seed.scale * 0.96).toFixed(3)),
1814
+ Number(seed.scale.toFixed(3)),
1815
+ Number((seed.scale * 1.05).toFixed(3)),
1816
+ Number((seed.scale * 1.12).toFixed(3))
1817
+ ])].filter((value) => value >= 0.46 && value <= 2.15);
1818
+ for (const du of fineOffsets) {
1819
+ for (const dv of fineOffsets) {
1820
+ const offsetU = seed.offsetU + du;
1821
+ const offsetV = seed.offsetV + dv;
1822
+ const center = {
1823
+ x: predicted.x + basisU.x * offsetU + basisV.x * offsetV,
1824
+ y: predicted.y + basisU.y * offsetU + basisV.y * offsetV
1825
+ };
1826
+ for (const scale of fineScales) {
1827
+ const score = alignmentScore(binary, width, height, center, basisU, basisV, scale, target);
1828
+ if (!best || score > best.score) {
1829
+ best = { score, center, scale, offsetU, offsetV, broadSearch: radius > 4, fastNested: true };
1830
+ }
1831
+ }
1832
+ }
1833
+ }
1834
+ }
1835
+
1836
+ return best;
1837
+ }
1838
+
1381
1839
  function searchAlignment(binary, width, height, triple, version, options = {}) {
1382
1840
  const size = sizeForVersion(version);
1383
1841
  const separation = size - 7;
@@ -1389,7 +1847,7 @@ function searchAlignment(binary, width, height, triple, version, options = {}) {
1389
1847
  x: (triple.bl.x - triple.tl.x) / separation,
1390
1848
  y: (triple.bl.y - triple.tl.y) / separation
1391
1849
  };
1392
- const target = primaryAlignmentPatternForVersion(version);
1850
+ const target = primaryAlignmentPatternForVersion(version, { profile: options.alignmentProfile ?? ALIGNMENT_PROFILE_STANDARD_5 });
1393
1851
  const targetX = target.col + 0.5;
1394
1852
  const targetY = target.row + 0.5;
1395
1853
  const predicted = {
@@ -1397,11 +1855,6 @@ function searchAlignment(binary, width, height, triple, version, options = {}) {
1397
1855
  y: triple.tl.y + basisU.y * (targetX - 3.5) + basisV.y * (targetY - 3.5)
1398
1856
  };
1399
1857
 
1400
- const precise = options.preciseAlignment === true;
1401
- const localScoreFn = precise ? preciseAlignmentScore : alignmentScore;
1402
- const localOffsets = precise
1403
- ? [-2.5, -1.5, -0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75, 1.5, 2.5]
1404
- : [-2.5, -1.5, -0.75, 0, 0.75, 1.5, 2.5];
1405
1858
  const finderSizes = [triple.tl.moduleSize, triple.tr.moduleSize, triple.bl.moduleSize];
1406
1859
  const finderMin = Math.max(0.01, Math.min(...finderSizes));
1407
1860
  const finderMax = Math.max(...finderSizes);
@@ -1421,11 +1874,62 @@ function searchAlignment(binary, width, height, triple, version, options = {}) {
1421
1874
  Number((inferredTargetScale * 1.12).toFixed(3))
1422
1875
  ])].filter((scale) => scale >= 0.52 && scale <= 1.9);
1423
1876
 
1877
+ const cornerSkew = Math.max(0, 1 - (triple.orthogonality ?? 1));
1878
+ const projectiveSignal = Math.max(
1879
+ Math.max(0, finderScaleRatio - 1),
1880
+ Math.max(0, (triple.moduleSpread ?? 0) * 1.25),
1881
+ cornerSkew * 0.75
1882
+ );
1883
+
1884
+ // Try the nested-eye locator first. It searches a projective-sized region
1885
+ // using only a handful of binary samples per location and therefore remains
1886
+ // cheap even when the affine prediction is several modules off.
1887
+ const fastRadius = clamp(
1888
+ Number(options.fastAlignmentRadius ?? (3 + projectiveSignal * 13)),
1889
+ 3,
1890
+ options.fastAlignmentMaxRadius ?? 16
1891
+ );
1892
+ const fastNested = searchNestedAlignmentFast(
1893
+ binary,
1894
+ width,
1895
+ height,
1896
+ predicted,
1897
+ basisU,
1898
+ basisV,
1899
+ target,
1900
+ {
1901
+ ...options,
1902
+ inferredTargetScale,
1903
+ radius: fastRadius
1904
+ }
1905
+ );
1906
+
1907
+ const fastAccept = options.fastAlignmentAccept ?? (options.preciseAlignment ? 0.88 : 0.80);
1908
+ if (fastNested && fastNested.score >= fastAccept) {
1909
+ return {
1910
+ ...fastNested,
1911
+ basisU,
1912
+ basisV,
1913
+ predicted,
1914
+ target,
1915
+ finderScaleRatio,
1916
+ projectiveSignal
1917
+ };
1918
+ }
1919
+
1920
+ const precise = options.preciseAlignment === true;
1921
+ const localScoreFn = precise ? preciseAlignmentScore : alignmentScore;
1922
+ const localOffsets = precise
1923
+ ? [-2.5, -1.5, -0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75, 1.5, 2.5]
1924
+ : [-2.5, -1.5, -0.75, 0, 0.75, 1.5, 2.5];
1925
+
1424
1926
  const centerAt = (offsetU, offsetV) => ({
1425
1927
  x: predicted.x + basisU.x * offsetU + basisV.x * offsetV,
1426
1928
  y: predicted.y + basisU.y * offsetU + basisV.y * offsetV
1427
1929
  });
1428
- let best = { score: 0, center: predicted, scale: 1, offsetU: 0, offsetV: 0, broadSearch: false };
1930
+ let best = fastNested && fastNested.score > 0
1931
+ ? fastNested
1932
+ : { score: 0, center: predicted, scale: 1, offsetU: 0, offsetV: 0, broadSearch: false };
1429
1933
 
1430
1934
  const evaluateIntoBest = (offsetU, offsetV, scales, scoreFn, broadSearch = false) => {
1431
1935
  const center = centerAt(offsetU, offsetV);
@@ -1445,12 +1949,6 @@ function searchAlignment(binary, width, height, triple, version, options = {}) {
1445
1949
  // prediction even though all three finder patterns remain strong. Use a
1446
1950
  // bounded coarse-to-fine search only when the locator geometry signals that
1447
1951
  // projective foreshortening is present.
1448
- const cornerSkew = Math.max(0, 1 - (triple.orthogonality ?? 1));
1449
- const projectiveSignal = Math.max(
1450
- Math.max(0, finderScaleRatio - 1),
1451
- Math.max(0, (triple.moduleSpread ?? 0) * 1.25),
1452
- cornerSkew * 0.75
1453
- );
1454
1952
  const broadEnabled = options.perspectiveAlignmentRecovery !== false && (
1455
1953
  options.perspectiveRecovery === true ||
1456
1954
  projectiveSignal >= (options.perspectiveAlignmentSignalThreshold ?? 0.32)
@@ -1567,8 +2065,8 @@ function projectedAlignmentScore(binary, width, height, homography, pattern) {
1567
2065
  return total ? matches / total : 0;
1568
2066
  }
1569
2067
 
1570
- function scoreAlignmentGrid(binary, width, height, homography, version) {
1571
- const patterns = alignmentPatternCentersForVersion(version);
2068
+ function scoreAlignmentGrid(binary, width, height, homography, version, options = {}) {
2069
+ const patterns = alignmentPatternCentersForVersion(version, { profile: options.alignmentProfile ?? ALIGNMENT_PROFILE_STANDARD_5 });
1572
2070
  if (!patterns.length) return { score: 1, patternScores: [] };
1573
2071
  const patternScores = patterns.map((pattern) => ({
1574
2072
  row: pattern.row,
@@ -1661,7 +2159,7 @@ function refineHomographyWithAlignmentGrid(
1661
2159
  initialGrid,
1662
2160
  options = {}
1663
2161
  ) {
1664
- const patterns = alignmentPatternCentersForVersion(version);
2162
+ const patterns = alignmentPatternCentersForVersion(version, { profile: options.alignmentProfile ?? ALIGNMENT_PROFILE_STANDARD_5 });
1665
2163
  if (patterns.length <= 1 || options.alignmentRefinement === false) {
1666
2164
  return {
1667
2165
  homography: initialHomography,
@@ -1716,9 +2214,9 @@ function refineHomographyWithAlignmentGrid(
1716
2214
  x: candidate.pattern.col + 0.5,
1717
2215
  y: candidate.pattern.row + 0.5
1718
2216
  });
1719
- // A 3x3 marker carries less evidence than the 5x5 primary and the three
1720
- // finder patterns, so it helps average geometry without overpowering them.
1721
- weights.push(0.8 + candidate.score * 1.7);
2217
+ // Distributed 5x5 alignment eyes now carry stronger evidence while remaining
2218
+ // below the three primary finder patterns in the projective fit.
2219
+ weights.push(1.15 + candidate.score * 1.95);
1722
2220
  pointInfo.push({
1723
2221
  row: candidate.pattern.row,
1724
2222
  col: candidate.pattern.col,
@@ -1736,7 +2234,7 @@ function refineHomographyWithAlignmentGrid(
1736
2234
  return { homography: initialHomography, grid: initialGrid, refined: false, points: [] };
1737
2235
  }
1738
2236
 
1739
- const refinedGrid = scoreAlignmentGrid(binary, width, height, refinedHomography, version);
2237
+ const refinedGrid = scoreAlignmentGrid(binary, width, height, refinedHomography, version, options);
1740
2238
  const primaryBefore = primary
1741
2239
  ? projectedAlignmentScore(binary, width, height, initialHomography, primary)
1742
2240
  : 1;
@@ -1859,12 +2357,118 @@ function geometryCandidatesFromBinary(binary, width, height, finders, threshold,
1859
2357
  for (const triple of triples) {
1860
2358
  const legH = Math.hypot(triple.tr.x - triple.tl.x, triple.tr.y - triple.tl.y);
1861
2359
  const legV = Math.hypot(triple.bl.x - triple.tl.x, triple.bl.y - triple.tl.y);
1862
- const estimatedSize = ((legH + legV) / 2) / triple.moduleMean + 7;
1863
- const versions = nearestVersionFromEstimate(estimatedSize, minVersion, maxVersion).slice(0, 9);
2360
+ const moduleH = moduleSizeBetweenFinders(binary, width, height, triple.tl, triple.tr);
2361
+ const moduleV = moduleSizeBetweenFinders(binary, width, height, triple.tl, triple.bl);
2362
+ const estimatedSizeH = legH / Math.max(0.5, moduleH) + 7;
2363
+ const estimatedSizeV = legV / Math.max(0.5, moduleV) + 7;
2364
+ const estimateSpread = Math.abs(estimatedSizeH - estimatedSizeV);
2365
+ const fallbackEstimate = ((legH + legV) / 2) / triple.moduleMean + 7;
2366
+ const estimatedSize = Number.isFinite(estimatedSizeH) && Number.isFinite(estimatedSizeV)
2367
+ ? (estimatedSizeH + estimatedSizeV) / 2
2368
+ : fallbackEstimate;
2369
+ // Wrong finder triples often produce wildly different horizontal/vertical
2370
+ // module counts. Reject only the most implausible sets here; full projective
2371
+ // recovery remains intentionally permissive for real extreme camera angles.
2372
+ const maxEstimateSpread = options.maxDimensionEstimateSpread ?? (options.perspectiveRecovery ? 18 : 10);
2373
+ if (estimateSpread > maxEstimateSpread) continue;
2374
+ const versions = nearestVersionFromEstimate(estimatedSize, minVersion, maxVersion).slice(0, Math.max(1, Math.round(options.versionSearchLimit ?? 9)));
1864
2375
 
1865
2376
  for (const item of versions) {
1866
2377
  const version = item.version;
1867
2378
  const size = sizeForVersion(version);
2379
+
2380
+ // Near-front-facing symbols do not need to wait for a fourth locator.
2381
+ // With three reliable finder centres we already have an affine mapping.
2382
+ // Validate that cheap mapping against the distributed 5x5 alignment grid;
2383
+ // when it agrees strongly, return it immediately and let payload decoding
2384
+ // provide the final integrity check. Strongly projective symbols skip this
2385
+ // shortcut and continue into the full alignment/homography path below.
2386
+ const affineProjectiveSignal = Math.max(
2387
+ Math.max(0, triple.moduleSpread ?? 0),
2388
+ Math.max(0, 1 - (triple.orthogonality ?? 1)) * 0.85,
2389
+ Math.max(0, (triple.legRatio ?? 1) - 1) * 0.12
2390
+ );
2391
+ const allowAffineFastPath = options.finderAffineFastPath !== false &&
2392
+ options.preciseAlignment !== true &&
2393
+ options.perspectiveRecovery !== true &&
2394
+ item.error <= (options.finderAffineVersionError ?? 2.6) &&
2395
+ affineProjectiveSignal <= (options.finderAffineMaxProjectiveSignal ?? 0.24);
2396
+
2397
+ if (allowAffineFastPath) {
2398
+ const separation = size - 7;
2399
+ const basisU = {
2400
+ x: (triple.tr.x - triple.tl.x) / separation,
2401
+ y: (triple.tr.y - triple.tl.y) / separation
2402
+ };
2403
+ const basisV = {
2404
+ x: (triple.bl.x - triple.tl.x) / separation,
2405
+ y: (triple.bl.y - triple.tl.y) / separation
2406
+ };
2407
+ const target = primaryAlignmentPatternForVersion(version, {
2408
+ profile: options.alignmentProfile ?? ALIGNMENT_PROFILE_STANDARD_5
2409
+ });
2410
+ const targetX = target.col + 0.5;
2411
+ const targetY = target.row + 0.5;
2412
+ const predictedAlignment = {
2413
+ x: triple.tl.x + basisU.x * (targetX - 3.5) + basisV.x * (targetY - 3.5),
2414
+ y: triple.tl.y + basisU.y * (targetX - 3.5) + basisV.y * (targetY - 3.5)
2415
+ };
2416
+ const affineDest = [
2417
+ { x: 3.5, y: 3.5 },
2418
+ { x: size - 3.5, y: 3.5 },
2419
+ { x: 3.5, y: size - 3.5 },
2420
+ { x: targetX, y: targetY }
2421
+ ];
2422
+ const affineSrc = [
2423
+ { x: triple.tl.x, y: triple.tl.y },
2424
+ { x: triple.tr.x, y: triple.tr.y },
2425
+ { x: triple.bl.x, y: triple.bl.y },
2426
+ predictedAlignment
2427
+ ];
2428
+ try {
2429
+ const affineHomography = computeHomography(affineSrc, affineDest);
2430
+ const affineGrid = scoreAlignmentGrid(binary, width, height, affineHomography, version, options);
2431
+ if (affineGrid.score >= (options.finderAffineGridThreshold ?? 0.84)) {
2432
+ const versionPenalty = item.error / 4;
2433
+ geometries.push({
2434
+ version,
2435
+ size,
2436
+ sourcePoints: affineSrc,
2437
+ destinationPoints: affineDest,
2438
+ homography: affineHomography,
2439
+ finders: { topLeft: triple.tl, topRight: triple.tr, bottomLeft: triple.bl },
2440
+ alignment: {
2441
+ center: predictedAlignment,
2442
+ predicted: predictedAlignment,
2443
+ score: affineGrid.score,
2444
+ scale: 1,
2445
+ target: { row: target.row, col: target.col },
2446
+ patterns: affineGrid.patternScores.length,
2447
+ gridScore: affineGrid.score,
2448
+ initialGridScore: affineGrid.score,
2449
+ refined: false,
2450
+ refinementPoints: [],
2451
+ patternScores: affineGrid.patternScores,
2452
+ method: "finder-affine"
2453
+ },
2454
+ threshold,
2455
+ finderMethod: `${options.finderMethod ?? "finder"}-affine`,
2456
+ alignmentProfile: options.alignmentProfile ?? ALIGNMENT_PROFILE_STANDARD_5,
2457
+ estimatedSize,
2458
+ estimatedSizeH,
2459
+ estimatedSizeV,
2460
+ directionalModuleSizeH: moduleH,
2461
+ directionalModuleSizeV: moduleV,
2462
+ score: triple.score * (0.58 + 0.42 * affineGrid.score) / (1 + versionPenalty * 0.08),
2463
+ finderAffineFastPath: true
2464
+ });
2465
+ continue;
2466
+ }
2467
+ } catch {
2468
+ // Full alignment search below remains the authoritative path.
2469
+ }
2470
+ }
2471
+
1868
2472
  const alignment = searchAlignment(binary, width, height, triple, version, options);
1869
2473
  if (alignment.score < (options.alignmentThreshold ?? 0.72)) continue;
1870
2474
 
@@ -1889,7 +2493,7 @@ function geometryCandidatesFromBinary(binary, width, height, finders, threshold,
1889
2493
  continue;
1890
2494
  }
1891
2495
 
1892
- const initialAlignmentGrid = scoreAlignmentGrid(binary, width, height, homography, version);
2496
+ const initialAlignmentGrid = scoreAlignmentGrid(binary, width, height, homography, version, options);
1893
2497
  const alignmentGridThreshold = options.alignmentGridThreshold ?? 0.68;
1894
2498
  const refinementFloor = Math.max(0, alignmentGridThreshold - (options.alignmentRefineCandidateMargin ?? 0.10));
1895
2499
  const skipRefinementScore = options.alignmentRefineSkipScore ?? 0.985;
@@ -1942,7 +2546,12 @@ function geometryCandidatesFromBinary(binary, width, height, finders, threshold,
1942
2546
  },
1943
2547
  threshold,
1944
2548
  finderMethod: options.finderMethod,
2549
+ alignmentProfile: options.alignmentProfile ?? ALIGNMENT_PROFILE_STANDARD_5,
1945
2550
  estimatedSize,
2551
+ estimatedSizeH,
2552
+ estimatedSizeV,
2553
+ directionalModuleSizeH: moduleH,
2554
+ directionalModuleSizeV: moduleV,
1946
2555
  score
1947
2556
  });
1948
2557
  }
@@ -1991,6 +2600,7 @@ function pushFinderDiagnostic(options, finderMethod, threshold, finders, geometr
1991
2600
  alignmentScore: geometry.alignment.score,
1992
2601
  alignmentGridScore: geometry.alignment.gridScore,
1993
2602
  finderMethod: geometry.finderMethod,
2603
+ alignmentProfile: geometry.alignmentProfile,
1994
2604
  finders: {
1995
2605
  topLeft: { ...geometry.finders.topLeft },
1996
2606
  topRight: { ...geometry.finders.topRight },
@@ -2016,7 +2626,10 @@ function detectCodeGeometry(imageData, options = {}) {
2016
2626
  finderMethod: pass.finderMethod,
2017
2627
  perspectiveRecovery: recovery || options.perspectiveRecovery === true,
2018
2628
  alignmentThreshold: recovery ? 0.68 : 0.72,
2019
- alignmentGridThreshold: recovery ? 0.64 : 0.68
2629
+ alignmentGridThreshold: recovery ? 0.64 : 0.68,
2630
+ versionSearchLimit: recovery
2631
+ ? (options.recoveryVersionSearchLimit ?? 9)
2632
+ : (options.fastVersionSearchLimit ?? 4)
2020
2633
  };
2021
2634
  let geometries = geometryCandidatesFromBinary(
2022
2635
  pass.binary,
@@ -2024,9 +2637,38 @@ function detectCodeGeometry(imageData, options = {}) {
2024
2637
  height,
2025
2638
  finders,
2026
2639
  pass.threshold,
2027
- geometryOptions
2640
+ { ...geometryOptions, alignmentProfile: ALIGNMENT_PROFILE_STANDARD_5 }
2028
2641
  );
2029
2642
 
2643
+ // New format-v6 symbols use 5x5 alignment eyes. Only if that geometry does
2644
+ // not validate do we spend a compatibility attempt on format-v5's compact
2645
+ // 3x3 secondary markers. This keeps the modern path fast.
2646
+ if (!geometries.length && options.legacyAlignmentRecovery !== false && finders.length >= 3) {
2647
+ const legacyMethod = `${pass.finderMethod}-legacy-align`;
2648
+ const legacyOptions = {
2649
+ ...geometryOptions,
2650
+ finderMethod: legacyMethod,
2651
+ alignmentProfile: ALIGNMENT_PROFILE_LEGACY_3
2652
+ };
2653
+ geometries = geometryCandidatesFromBinary(
2654
+ pass.binary,
2655
+ width,
2656
+ height,
2657
+ finders,
2658
+ pass.threshold,
2659
+ legacyOptions
2660
+ );
2661
+ if (geometries.length) {
2662
+ pushFinderDiagnostic(
2663
+ { ...options, width, height, diagnosticLabel: `${options.diagnosticLabel ?? "normal"}-legacy-align` },
2664
+ legacyMethod,
2665
+ pass.threshold,
2666
+ finders,
2667
+ geometries
2668
+ );
2669
+ }
2670
+ }
2671
+
2030
2672
  pushFinderDiagnostic(
2031
2673
  { ...options, width, height },
2032
2674
  pass.finderMethod,
@@ -2073,9 +2715,123 @@ function detectCodeGeometry(imageData, options = {}) {
2073
2715
  finderMethod: "rgb-value-otsu",
2074
2716
  binary: valueInfo.binary,
2075
2717
  threshold: valueInfo.threshold,
2076
- detector: {}
2718
+ detector: {
2719
+ toleranceScale: options.finderToleranceScale ?? 1.0,
2720
+ moduleSpreadLimit: options.finderModuleSpreadLimit ?? 0.45,
2721
+ minConfirmations: options.finderMinConfirmations ?? 2,
2722
+ diagonalCheck: false
2723
+ }
2077
2724
  }, false);
2725
+ const fastEstimateMatched = fast.geometries.some((geometry) =>
2726
+ Math.abs(sizeForVersion(geometry.version) - geometry.estimatedSize) <= (options.fastDimensionAcceptance ?? 2.0)
2727
+ );
2728
+ if (fast.geometries.length && fastEstimateMatched) {
2729
+ return fast.geometries.slice(0, maxCandidates);
2730
+ }
2731
+
2732
+ // Seeing three finder patterns should immediately unlock perspective-aware
2733
+ // geometry. The previous first pass used stricter near-front-facing triple
2734
+ // limits, so a code could visibly have all three eyes yet still fall through
2735
+ // into color recovery. Reuse the exact same binary/finders with broader
2736
+ // projective geometry before doing any additional pixel processing.
2737
+ if (fast.finders.length >= 3) {
2738
+ const finderMethod = "rgb-value-otsu-projective";
2739
+ const projectiveGeometries = geometryCandidatesFromBinary(
2740
+ valueInfo.binary,
2741
+ width,
2742
+ height,
2743
+ fast.finders,
2744
+ valueInfo.threshold,
2745
+ {
2746
+ ...options,
2747
+ finderMethod,
2748
+ perspectiveRecovery: true,
2749
+ alignmentThreshold: 0.60,
2750
+ alignmentGridThreshold: 0.58,
2751
+ versionSearchLimit: options.fastPerspectiveVersionSearchLimit ?? 4,
2752
+ perspectiveAlignmentFineSeeds: options.fastPerspectiveAlignmentFineSeeds ?? 3,
2753
+ perspectiveAlignmentMaxRadius: options.fastPerspectiveAlignmentMaxRadius ?? 12
2754
+ }
2755
+ );
2756
+ pushFinderDiagnostic(
2757
+ { ...options, width, height, diagnosticLabel: `${options.diagnosticLabel ?? "normal"}-projective` },
2758
+ finderMethod,
2759
+ valueInfo.threshold,
2760
+ fast.finders,
2761
+ projectiveGeometries
2762
+ );
2763
+ if (projectiveGeometries.length) return projectiveGeometries.slice(0, maxCandidates);
2764
+ }
2765
+
2766
+ // Keep the original strict geometry as a fallback if the projective pass did
2767
+ // not produce anything better. This preserves historical behavior while
2768
+ // avoiding an early wrong-version lock-in when the directional size estimate
2769
+ // clearly points at another version.
2078
2770
  if (fast.geometries.length) return fast.geometries.slice(0, maxCandidates);
2771
+
2772
+ // A local block threshold is part of the normal locator path, not the heavy
2773
+ // color/damage recovery stack. It is especially effective when one finder is
2774
+ // under a shadow or a phone-screen gradient while the other two are bright.
2775
+ // At camera locator resolution this costs far less than escalating to a
2776
+ // high-resolution scan or running full-frame Auto Color.
2777
+ let localBinary = null;
2778
+ if (options.localFinderThreshold !== false && fast.finders.length < 3) {
2779
+ localBinary = hybridLocalBinary(valueInfo.gray, width, height);
2780
+ if (localBinary) {
2781
+ const local = evaluatePass({
2782
+ finderMethod: "rgb-value-hybrid-local",
2783
+ binary: localBinary,
2784
+ threshold: null,
2785
+ detector: {
2786
+ toleranceScale: 1.10,
2787
+ moduleSpreadLimit: 0.58,
2788
+ diagonalCheck: false
2789
+ }
2790
+ }, true);
2791
+ if (local.geometries.length) return local.geometries.slice(0, maxCandidates);
2792
+ }
2793
+ }
2794
+
2795
+ if (options.componentFinderFallback !== false && fast.finders.length < 3) {
2796
+ for (const [binary, method] of [
2797
+ [valueInfo.binary, "rgb-value-component"],
2798
+ [localBinary, "rgb-value-hybrid-component"]
2799
+ ]) {
2800
+ if (!binary) continue;
2801
+ const componentFinders = detectFinderCandidatesByComponents(binary, width, height, options);
2802
+ const merged = clusterFinderCandidates([
2803
+ ...fast.finders.map((finder) => ({ ...finder })),
2804
+ ...componentFinders
2805
+ ], 1);
2806
+ if (merged.length < 3) continue;
2807
+ const componentGeometries = geometryCandidatesFromBinary(
2808
+ binary,
2809
+ width,
2810
+ height,
2811
+ merged,
2812
+ method.includes("hybrid") ? null : valueInfo.threshold,
2813
+ {
2814
+ ...options,
2815
+ finderMethod: method,
2816
+ perspectiveRecovery: true,
2817
+ alignmentThreshold: 0.60,
2818
+ alignmentGridThreshold: 0.58,
2819
+ versionSearchLimit: options.fastPerspectiveVersionSearchLimit ?? 4,
2820
+ perspectiveAlignmentFineSeeds: options.fastPerspectiveAlignmentFineSeeds ?? 3,
2821
+ perspectiveAlignmentMaxRadius: options.fastPerspectiveAlignmentMaxRadius ?? 12
2822
+ }
2823
+ );
2824
+ pushFinderDiagnostic(
2825
+ { ...options, width, height, diagnosticLabel: `${options.diagnosticLabel ?? "normal"}-component` },
2826
+ method,
2827
+ method.includes("hybrid") ? null : valueInfo.threshold,
2828
+ merged,
2829
+ componentGeometries
2830
+ );
2831
+ if (componentGeometries.length) return componentGeometries.slice(0, maxCandidates);
2832
+ }
2833
+ }
2834
+
2079
2835
  if (options.finderRecovery === false) return [];
2080
2836
 
2081
2837
  // If the clean threshold already found exactly two strong locators, try the
@@ -2347,6 +3103,21 @@ function autoColorImageData(imageData, options = {}) {
2347
3103
  }
2348
3104
 
2349
3105
  function buildAutoColorValueGray(imageData, options = {}) {
3106
+ const canCache = imageData && typeof imageData === "object" && options.cache !== false;
3107
+ const cacheKey = [
3108
+ options.blackClip ?? 0.0001,
3109
+ options.whiteClip ?? "default",
3110
+ options.highlightPercentile ?? 0.95,
3111
+ options.outputHighlight ?? 190,
3112
+ options.analysisInset ?? 0,
3113
+ options.minimumInputRange ?? 72,
3114
+ options.targetSamples ?? "default"
3115
+ ].join(":");
3116
+ if (canCache) {
3117
+ const cached = autoColorGrayCache.get(imageData)?.get(cacheKey);
3118
+ if (cached) return cached;
3119
+ }
3120
+
2350
3121
  const levels = buildAutoColorLevels(imageData, options);
2351
3122
  const gray = new Uint8Array(imageData.width * imageData.height);
2352
3123
  for (let i = 0; i < gray.length; i++) {
@@ -2361,6 +3132,11 @@ function buildAutoColorValueGray(imageData, options = {}) {
2361
3132
  levels.mapChannel(b, 2)
2362
3133
  ));
2363
3134
  }
3135
+ if (canCache) {
3136
+ let entries = autoColorGrayCache.get(imageData);
3137
+ if (!entries) autoColorGrayCache.set(imageData, entries = new Map());
3138
+ entries.set(cacheKey, gray);
3139
+ }
2364
3140
  return gray;
2365
3141
  }
2366
3142
 
@@ -2513,6 +3289,14 @@ function samplePerspectiveMatrix(imageData, homography, size, options = {}) {
2513
3289
  return { rgbGrid };
2514
3290
  }
2515
3291
 
3292
+ /**
3293
+ * Sample the two protected regions of every Triangle16 module.
3294
+ *
3295
+ * Triangle16 uses a fixed "/" diagonal. Samples are intentionally placed well
3296
+ * inside the upper-left and lower-right triangles, away from the diagonal and
3297
+ * module borders. This makes the decoder much less sensitive to antialiasing,
3298
+ * blur, resampling and small homography errors than center sampling.
3299
+ */
2516
3300
  function rgbSampleSpread(values, center) {
2517
3301
  if (!values.length) return 0;
2518
3302
  return values.reduce((sum, rgb) => sum + Math.hypot(
@@ -2812,9 +3596,22 @@ const visionInternals = Object.freeze({
2812
3596
  luminance
2813
3597
  });
2814
3598
 
2815
- return { computeHomography, projectPoint, detectCodeGeometry, autoColorImageData, autoToneContrastColorRgbGrid, autoToneContrastColorImageData, samplePerspectiveMatrix, samplePerspectiveTriangleMatrix, sampleObservedPalette, spatiallyNormalizeRgbGrid, rectifyImageData, findActiveBounds, sampleAxisAlignedGrid, sampleAxisAlignedTriangleGrid, visionInternals };
3599
+ return { installVisionAccelerator, buildBinary, detectFinderCandidates, chooseFinderTriples, searchAlignment, computeHomography, projectPoint, detectCodeGeometry, autoColorImageData, autoToneContrastColorRgbGrid, autoToneContrastColorImageData, samplePerspectiveMatrix, samplePerspectiveTriangleMatrix, sampleObservedPalette, spatiallyNormalizeRgbGrid, rectifyImageData, findActiveBounds, sampleAxisAlignedGrid, sampleAxisAlignedTriangleGrid, visionInternals };
2816
3600
  })();
2817
3601
  const __qqr_deflate_js = (function () {
3602
+ /**
3603
+ * Small synchronous RFC 1951 raw-DEFLATE codec used by QuadQR Compression 3.0.
3604
+ *
3605
+ * The compressor intentionally emits fixed-Huffman blocks only. This keeps the
3606
+ * implementation compact, deterministic, dependency-free, and usable in both
3607
+ * browsers and Node.js while still allowing DEFLATE's 32 KiB window and
3608
+ * 258-byte matches to compress repetitive payloads far better than the legacy
3609
+ * QuadQR LZSS stream.
3610
+ *
3611
+ * The decoder accepts stored and fixed-Huffman blocks produced by this module.
3612
+ * Dynamic-Huffman input is intentionally rejected because QuadQR's envelope
3613
+ * only needs to decode streams created by its own compressor.
3614
+ */
2818
3615
 
2819
3616
  function assert(condition, message) {
2820
3617
  if (!condition) throw new Error(message);
@@ -3019,6 +3816,10 @@ function emitMatch(writer, length, distance) {
3019
3816
  if (dist.extraBits) writer.writeBits(dist.extraValue, dist.extraBits);
3020
3817
  }
3021
3818
 
3819
+ /**
3820
+ * Compress bytes as a raw RFC 1951 DEFLATE stream using one final
3821
+ * fixed-Huffman block. The function is synchronous and runtime-neutral.
3822
+ */
3022
3823
  function compressDeflatePayload(input, options = {}) {
3023
3824
  const bytes = asBytes(input);
3024
3825
  const level = normalizeDeflateLevel(
@@ -3128,6 +3929,7 @@ function readStoredBlock(reader, out) {
3128
3929
  for (let i = 0; i < len; i++) out.push(reader.bytes[reader.bytePos++]);
3129
3930
  }
3130
3931
 
3932
+ /** Decode raw DEFLATE streams produced by compressDeflatePayload(). */
3131
3933
  function decompressDeflatePayload(input, expectedLength = null) {
3132
3934
  const reader = new BitReader(input);
3133
3935
  const out = [];
@@ -3182,6 +3984,11 @@ function decompressDeflatePayload(input, expectedLength = null) {
3182
3984
  return { compressDeflatePayload, decompressDeflatePayload, DEFLATE_LEVEL_MIN, DEFLATE_LEVEL_MAX, DEFAULT_DEFLATE_LEVEL };
3183
3985
  })();
3184
3986
  const __qqr_brotli_js = (function () {
3987
+ /*
3988
+ * Vendored portable Brotli codec used by QuadQR Compression 3.0.
3989
+ * Based on brotli.js 1.3.3 (MIT) by Devon Govett and Google Brotli code.
3990
+ * Bundled into one dependency-free JavaScript module for browser + Node use.
3991
+ */
3185
3992
 
3186
3993
  const __brotliModules = Object.create(null);
3187
3994
  const __brotliCache = Object.create(null);
@@ -3189,6 +3996,12 @@ const __brotliCache = Object.create(null);
3189
3996
  __brotliModules["/compress.js"] = function(module, exports, require) {
3190
3997
  var brotli = require("/build/encode.js");
3191
3998
 
3999
+ /**
4000
+ * Compresses the given buffer
4001
+ * The second parameter is optional and specifies whether the buffer is
4002
+ * text or binary data (the default is binary).
4003
+ * Returns null on error
4004
+ */
3192
4005
  module.exports = function(buffer, opts) {
3193
4006
  // default to binary data
3194
4007
  var quality = 11;
@@ -3271,7 +4084,7 @@ case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:ca
3271
4084
  _sbrk:X,_time:function(a){var c=Date.now()/1E3|0;a&&(K[a>>2]=c);return c},_emscripten_memcpy_big:function(a,c,d){P.set(P.subarray(c,c+d),a);return a},_llvm_trap:function(){E("trap!")},_exit:function(a){Ra(a)},___assert_fail:function(a,c,d,e){F=!0;throw"Assertion failed: "+Q(a)+", at: "+[c?Q(c):"unknown filename",d,e?Q(e):"unknown function"]+" at "+qa();},STACKTOP:z,STACK_MAX:xa,tempDoublePtr:Ia,ABORT:F,cttz_i8:Sa};// EMSCRIPTEN_START_ASM
3272
4085
 
3273
4086
  var Y=(function(global,env,buffer) {
3274
- /* Legacy asm.js directive disabled for modern V8. */var a=new global.Int8Array(buffer);var b=new global.Int16Array(buffer);var c=new global.Int32Array(buffer);var d=new global.Uint8Array(buffer);var e=new global.Uint16Array(buffer);var f=new global.Uint32Array(buffer);var g=new global.Float32Array(buffer);var h=new global.Float64Array(buffer);var i=env.STACKTOP|0;var j=env.STACK_MAX|0;var k=env.tempDoublePtr|0;var l=env.ABORT|0;var m=env.cttz_i8|0;var n=0;var o=0;var p=0;var q=0;var r=global.NaN,s=global.Infinity;var t=0,u=0,v=0,w=0,x=0.0,y=0,z=0,A=0,B=0.0;var C=0;var D=0;var E=0;var F=0;var G=0;var H=0;var I=0;var J=0;var K=0;var L=0;var M=global.Math.floor;var N=global.Math.abs;var O=global.Math.sqrt;var P=global.Math.pow;var Q=global.Math.cos;var R=global.Math.sin;var S=global.Math.tan;var T=global.Math.acos;var U=global.Math.asin;var V=global.Math.atan;var W=global.Math.atan2;var X=global.Math.exp;var Y=global.Math.log;var Z=global.Math.ceil;var _=global.Math.imul;var $=global.Math.min;var aa=global.Math.clz32;var ba=env.abort;var ca=env.assert;var da=env.invoke_vii;var ea=env.invoke_iii;var fa=env.__exit;var ga=env._pthread_self;var ha=env._abort;var ia=env.___setErrNo;var ja=env._sysconf;var ka=env._sbrk;var la=env._time;var ma=env._emscripten_memcpy_big;var na=env._llvm_trap;var oa=env._exit;var pa=env.___assert_fail;var qa=0.0;
4087
+ var a=new global.Int8Array(buffer);var b=new global.Int16Array(buffer);var c=new global.Int32Array(buffer);var d=new global.Uint8Array(buffer);var e=new global.Uint16Array(buffer);var f=new global.Uint32Array(buffer);var g=new global.Float32Array(buffer);var h=new global.Float64Array(buffer);var i=env.STACKTOP|0;var j=env.STACK_MAX|0;var k=env.tempDoublePtr|0;var l=env.ABORT|0;var m=env.cttz_i8|0;var n=0;var o=0;var p=0;var q=0;var r=global.NaN,s=global.Infinity;var t=0,u=0,v=0,w=0,x=0.0,y=0,z=0,A=0,B=0.0;var C=0;var D=0;var E=0;var F=0;var G=0;var H=0;var I=0;var J=0;var K=0;var L=0;var M=global.Math.floor;var N=global.Math.abs;var O=global.Math.sqrt;var P=global.Math.pow;var Q=global.Math.cos;var R=global.Math.sin;var S=global.Math.tan;var T=global.Math.acos;var U=global.Math.asin;var V=global.Math.atan;var W=global.Math.atan2;var X=global.Math.exp;var Y=global.Math.log;var Z=global.Math.ceil;var _=global.Math.imul;var $=global.Math.min;var aa=global.Math.clz32;var ba=env.abort;var ca=env.assert;var da=env.invoke_vii;var ea=env.invoke_iii;var fa=env.__exit;var ga=env._pthread_self;var ha=env._abort;var ia=env.___setErrNo;var ja=env._sysconf;var ka=env._sbrk;var la=env._time;var ma=env._emscripten_memcpy_big;var na=env._llvm_trap;var oa=env._exit;var pa=env.___assert_fail;var qa=0.0;
3275
4088
  // EMSCRIPTEN_START_FUNCS
3276
4089
  function $a(e,f,g,h,j,k,l,m){e=e|0;f=f|0;g=g|0;h=h|0;j=j|0;k=k|0;l=l|0;m=m|0;var n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,D=0,E=0,F=0,G=0,H=0,I=0;G=i;i=i+16|0;F=G;c[F>>2]=0;c[F+4>>2]=0;c[F+8>>2]=0;c[F+12>>2]=0;E=0;D=0;while(1){if(!g)break;n=c[f+(D<<2)>>2]|0;if(!n)o=E;else{if(E>>>0<4)c[F+(E<<2)>>2]=D;o=E+1|0;g=g-n|0}E=o;D=D+1|0}if(E>>>0<2){n=c[l>>2]|0;p=m+(n>>>3)|0;g=d[p>>0]|0;n=cc(1,0,n&7|0)|0;o=C;n=g|n;g=p;a[g>>0]=n;a[g+1>>0]=n>>8;a[g+2>>0]=n>>16;a[g+3>>0]=n>>24;p=p+4|0;a[p>>0]=o;a[p+1>>0]=o>>8;a[p+2>>0]=o>>16;a[p+3>>0]=o>>24;p=(c[l>>2]|0)+4|0;c[l>>2]=p;o=c[F>>2]|0;g=m+(p>>>3)|0;n=d[g>>0]|0;m=bc(o|0,0,h|0)|0;if(!((m|0)==0&(C|0)==0))pa(406196,406218,54,406251);if(h>>>0>=57)pa(406267,406218,55,406251);D=cc(o|0,0,p&7|0)|0;F=C;D=n|D;m=g;E=m;a[E>>0]=D;a[E+1>>0]=D>>8;a[E+2>>0]=D>>16;a[E+3>>0]=D>>24;m=m+4|0;a[m>>0]=F;a[m+1>>0]=F>>8;a[m+2>>0]=F>>16;a[m+3>>0]=F>>24;c[l>>2]=(c[l>>2]|0)+h;a[j+o>>0]=0;b[k+(o<<1)>>1]=0;i=G;return}ac(j|0,0,D|0)|0;y=e+8|0;z=sa[c[e>>2]&1](c[y>>2]|0,D<<4|8)|0;A=z;if(!z)oa(1);B=1;while(1){g=D;n=A;a:while(1){do{if(!g)break a;g=g+-1|0;o=c[f+(g<<2)>>2]|0}while((o|0)==0);p=g&65535;if(o>>>0<B>>>0){c[n>>2]=B;b[n+4>>1]=-1;b[n+6>>1]=p}else{c[n>>2]=o;b[n+4>>1]=-1;b[n+6>>1]=p}n=n+8|0}x=n-A|0;w=x>>3;v=w+1|0;b:do if(w>>>0<13){s=1;while(1){if(s>>>0>=w>>>0)break b;r=z+(s<<3)|0;q=c[r>>2]|0;r=c[r+4>>2]|0;p=s;while(1){g=p;p=p+-1|0;o=z+(p<<3)|0;if(!(cb(q,c[o>>2]|0)|0))break;t=c[o+4>>2]|0;u=z+(g<<3)|0;c[u>>2]=c[o>>2];c[u+4>>2]=t;if(!p){g=0;break}}u=z+(g<<3)|0;c[u>>2]=q;c[u+4>>2]=r;s=s+1|0}}else{t=w>>>0<57?2:0;while(1){if((t|0)>=6)break b;g=c[19428+(t<<2)>>2]|0;u=g;while(1){if(u>>>0>=w>>>0)break;p=z+(u<<3)|0;o=c[p>>2]|0;p=c[p+4>>2]|0;s=u;while(1){if(s>>>0<g>>>0)break;q=s-g|0;r=z+(q<<3)|0;if(!(cb(o,c[r>>2]|0)|0))break;I=r;H=c[I+4>>2]|0;r=z+(s<<3)|0;c[r>>2]=c[I>>2];c[r+4>>2]=H;s=q}I=z+(s<<3)|0;c[I>>2]=o;c[I+4>>2]=p;u=u+1|0}t=t+1|0}}while(0);u=n;o=n;c[o>>2]=-1;c[o+4>>2]=-1;o=u+8|0;c[o>>2]=-1;c[o+4>>2]=-1;o=0;p=v;u=u+16|0;t=w;while(1){if((t|0)<=1)break;n=c[z+(o<<3)>>2]|0;g=c[z+(p<<3)>>2]|0;if(n>>>0>g>>>0){s=p+1|0;g=c[z+(s<<3)>>2]|0;r=o;q=p}else{r=o+1|0;n=c[z+(r<<3)>>2]|0;s=p;q=o}if(n>>>0>g>>>0){o=r;p=s+1|0;n=s}else{g=n;o=r+1|0;p=s;n=r}c[u+-8>>2]=(c[z+(q<<3)>>2]|0)+g;b[u+-4>>1]=q;b[u+-2>>1]=n;I=u;c[I>>2]=-1;c[I+4>>2]=-1;u=u+8|0;t=t+-1|0}if(Gb((x>>2)+-1|0,z,j,14)|0)break;B=B<<1}ra[c[e+4>>2]&1](c[y>>2]|0,z);Jb(j,D,k);x=c[l>>2]|0;v=m+(x>>>3)|0;w=d[v>>0]|0;x=x&7;if(E>>>0>=5){I=cc(1431655764,255,x|0)|0;n=C;I=w|I;g=v;t=g;a[t>>0]=I;a[t+1>>0]=I>>8;a[t+2>>0]=I>>16;a[t+3>>0]=I>>24;g=g+4|0;a[g>>0]=n;a[g+1>>0]=n>>8;a[g+2>>0]=n>>16;a[g+3>>0]=n>>24;g=(c[l>>2]|0)+40|0;c[l>>2]=g;n=0;t=8;c:while(1){while(1){if(n>>>0>=D>>>0){g=114;break c}u=a[j+n>>0]|0;s=1;o=n;while(1){o=o+1|0;if(o>>>0>=D>>>0)break;if((a[j+o>>0]|0)!=u<<24>>24)break;s=s+1|0}n=n+s|0;if(u<<24>>24)break;r=c[11564+(s<<2)>>2]|0;p=8+(s<<3)|0;o=c[p>>2]|0;p=c[p+4>>2]|0;q=m+(g>>>3)|0;I=bc(o|0,p|0,r|0)|0;if(!((I|0)==0&(C|0)==0)){g=99;break c}I=d[q>>0]|0;e=cc(o|0,p|0,g&7|0)|0;H=C;e=I|e;I=q;k=I;a[k>>0]=e;a[k+1>>0]=e>>8;a[k+2>>0]=e>>16;a[k+3>>0]=e>>24;I=I+4|0;a[I>>0]=H;a[I+1>>0]=H>>8;a[I+2>>0]=H>>16;a[I+3>>0]=H>>24;I=(c[l>>2]|0)+r|0;c[l>>2]=I;g=I}if(t<<24>>24==u<<24>>24)o=s;else{p=u&255;o=a[404394+p>>0]|0;p=c[14380+(p<<2)>>2]|0;q=m+(g>>>3)|0;I=bc(p|0,0,o&255|0)|0;if(!((I|0)==0&(C|0)==0)){g=103;break}H=d[q>>0]|0;k=cc(p|0,0,g&7|0)|0;I=C;k=H|k;g=q;H=g;a[H>>0]=k;a[H+1>>0]=k>>8;a[H+2>>0]=k>>16;a[H+3>>0]=k>>24;g=g+4|0;a[g>>0]=I;a[g+1>>0]=I>>8;a[g+2>>0]=I>>16;a[g+3>>0]=I>>24;g=(c[l>>2]|0)+(o&255)|0;c[l>>2]=g;o=s+-1|0}if(o>>>0>=3){q=o+-3|0;o=c[14452+(q<<2)>>2]|0;q=5640+(q<<3)|0;p=c[q>>2]|0;q=c[q+4>>2]|0;r=m+(g>>>3)|0;I=bc(p|0,q|0,o|0)|0;if(!((I|0)==0&(C|0)==0)){g=112;break}I=d[r>>0]|0;H=cc(p|0,q|0,g&7|0)|0;t=C;H=I|H;g=r;I=g;a[I>>0]=H;a[I+1>>0]=H>>8;a[I+2>>0]=H>>16;a[I+3>>0]=H>>24;g=g+4|0;a[g>>0]=t;a[g+1>>0]=t>>8;a[g+2>>0]=t>>16;a[g+3>>0]=t>>24;g=(c[l>>2]|0)+o|0;c[l>>2]=g;t=u;continue}t=u&255;s=404394+t|0;t=14380+(t<<2)|0;while(1){if(!o){t=u;continue c}p=a[s>>0]|0;q=c[t>>2]|0;r=m+(g>>>3)|0;I=bc(q|0,0,p&255|0)|0;if(!((I|0)==0&(C|0)==0)){g=109;break c}I=d[r>>0]|0;e=cc(q|0,0,g&7|0)|0;H=C;e=I|e;I=r;k=I;a[k>>0]=e;a[k+1>>0]=e>>8;a[k+2>>0]=e>>16;a[k+3>>0]=e>>24;I=I+4|0;a[I>>0]=H;a[I+1>>0]=H>>8;a[I+2>>0]=H>>16;a[I+3>>0]=H>>24;I=(c[l>>2]|0)+(p&255)|0;c[l>>2]=I;g=I;o=o+-1|0}}if((g|0)==99)pa(406196,406218,54,406251);else if((g|0)==103)pa(406196,406218,54,406251);else if((g|0)==109)pa(406196,406218,54,406251);else if((g|0)==112)pa(406196,406218,54,406251);else if((g|0)==114){i=G;return}}I=cc(1,0,x|0)|0;n=C;I=w|I;g=v;o=g;a[o>>0]=I;a[o+1>>0]=I>>8;a[o+2>>0]=I>>16;a[o+3>>0]=I>>24;g=g+4|0;a[g>>0]=n;a[g+1>>0]=n>>8;a[g+2>>0]=n>>16;a[g+3>>0]=n>>24;g=(c[l>>2]|0)+2|0;c[l>>2]=g;n=E+-1|0;o=m+(g>>>3)|0;if(!((n&-4|0)==0&0==0))pa(406196,406218,54,406251);t=d[o>>0]|0;I=cc(n|0,0,g&7|0)|0;p=C;I=t|I;t=o;r=t;a[r>>0]=I;a[r+1>>0]=I>>8;a[r+2>>0]=I>>16;a[r+3>>0]=I>>24;t=t+4|0;a[t>>0]=p;a[t+1>>0]=p>>8;a[t+2>>0]=p>>16;a[t+3>>0]=p>>24;t=(c[l>>2]|0)+2|0;c[l>>2]=t;p=E+-1|0;r=0;while(1){if((r|0)==(E|0))break;q=F+(r<<2)|0;g=r;while(1){s=g+1|0;if((g|0)==(p|0))break;g=F+(s<<2)|0;n=c[g>>2]|0;o=c[q>>2]|0;if((d[j+n>>0]|0)>=(d[j+o>>0]|0)){g=s;continue}c[g>>2]=o;c[q>>2]=n;g=s}r=r+1|0}switch(E|0){case 2:{g=c[F>>2]|0;n=m+(t>>>3)|0;o=d[n>>0]|0;if(!((bc(g|0,0,h|0)|0)==0&(C|0)==0))pa(406196,406218,54,406251);if(h>>>0>=57)pa(406267,406218,55,406251);I=cc(g|0,0,t&7|0)|0;g=C;I=o|I;o=n;n=o;a[n>>0]=I;a[n+1>>0]=I>>8;a[n+2>>0]=I>>16;a[n+3>>0]=I>>24;o=o+4|0;a[o>>0]=g;a[o+1>>0]=g>>8;a[o+2>>0]=g>>16;a[o+3>>0]=g>>24;o=(c[l>>2]|0)+h|0;c[l>>2]=o;n=c[F+4>>2]|0;g=m+(o>>>3)|0;if(!((bc(n|0,0,h|0)|0)==0&(C|0)==0))pa(406196,406218,54,406251);I=d[g>>0]|0;F=cc(n|0,0,o&7|0)|0;H=C;F=I|F;I=g;m=I;a[m>>0]=F;a[m+1>>0]=F>>8;a[m+2>>0]=F>>16;a[m+3>>0]=F>>24;I=I+4|0;a[I>>0]=H;a[I+1>>0]=H>>8;a[I+2>>0]=H>>16;a[I+3>>0]=H>>24;c[l>>2]=(c[l>>2]|0)+h;i=G;return}case 3:{g=c[F>>2]|0;n=m+(t>>>3)|0;o=d[n>>0]|0;if(!((bc(g|0,0,h|0)|0)==0&(C|0)==0))pa(406196,406218,54,406251);if(h>>>0>=57)pa(406267,406218,55,406251);g=cc(g|0,0,t&7|0)|0;I=C;o=o|g;g=n;n=g;a[n>>0]=o;a[n+1>>0]=o>>8;a[n+2>>0]=o>>16;a[n+3>>0]=o>>24;g=g+4|0;a[g>>0]=I;a[g+1>>0]=I>>8;a[g+2>>0]=I>>16;a[g+3>>0]=I>>24;g=(c[l>>2]|0)+h|0;c[l>>2]=g;n=c[F+4>>2]|0;o=m+(g>>>3)|0;if(!((bc(n|0,0,h|0)|0)==0&(C|0)==0))pa(406196,406218,54,406251);H=d[o>>0]|0;I=cc(n|0,0,g&7|0)|0;n=C;I=H|I;g=o;a[g>>0]=I;a[g+1>>0]=I>>8;a[g+2>>0]=I>>16;a[g+3>>0]=I>>24;o=o+4|0;a[o>>0]=n;a[o+1>>0]=n>>8;a[o+2>>0]=n>>16;a[o+3>>0]=n>>24;o=(c[l>>2]|0)+h|0;c[l>>2]=o;n=c[F+8>>2]|0;g=m+(o>>>3)|0;if(!((bc(n|0,0,h|0)|0)==0&(C|0)==0))pa(406196,406218,54,406251);I=d[g>>0]|0;F=cc(n|0,0,o&7|0)|0;H=C;F=I|F;I=g;m=I;a[m>>0]=F;a[m+1>>0]=F>>8;a[m+2>>0]=F>>16;a[m+3>>0]=F>>24;I=I+4|0;a[I>>0]=H;a[I+1>>0]=H>>8;a[I+2>>0]=H>>16;a[I+3>>0]=H>>24;c[l>>2]=(c[l>>2]|0)+h;i=G;return}default:{p=c[F>>2]|0;g=m+(t>>>3)|0;n=d[g>>0]|0;if(!((bc(p|0,0,h|0)|0)==0&(C|0)==0))pa(406196,406218,54,406251);if(h>>>0>=57)pa(406267,406218,55,406251);I=cc(p|0,0,t&7|0)|0;o=C;I=n|I;n=g;a[n>>0]=I;a[n+1>>0]=I>>8;a[n+2>>0]=I>>16;a[n+3>>0]=I>>24;g=g+4|0;a[g>>0]=o;a[g+1>>0]=o>>8;a[g+2>>0]=o>>16;a[g+3>>0]=o>>24;g=(c[l>>2]|0)+h|0;c[l>>2]=g;n=c[F+4>>2]|0;o=m+(g>>>3)|0;if(!((bc(n|0,0,h|0)|0)==0&(C|0)==0))pa(406196,406218,54,406251);H=d[o>>0]|0;I=cc(n|0,0,g&7|0)|0;n=C;I=H|I;g=o;o=g;a[o>>0]=I;a[o+1>>0]=I>>8;a[o+2>>0]=I>>16;a[o+3>>0]=I>>24;g=g+4|0;a[g>>0]=n;a[g+1>>0]=n>>8;a[g+2>>0]=n>>16;a[g+3>>0]=n>>24;g=(c[l>>2]|0)+h|0;c[l>>2]=g;n=c[F+8>>2]|0;o=m+(g>>>3)|0;if(!((bc(n|0,0,h|0)|0)==0&(C|0)==0))pa(406196,406218,54,406251);H=d[o>>0]|0;I=cc(n|0,0,g&7|0)|0;g=C;I=H|I;n=o;a[n>>0]=I;a[n+1>>0]=I>>8;a[n+2>>0]=I>>16;a[n+3>>0]=I>>24;o=o+4|0;a[o>>0]=g;a[o+1>>0]=g>>8;a[o+2>>0]=g>>16;a[o+3>>0]=g>>24;o=(c[l>>2]|0)+h|0;c[l>>2]=o;g=c[F+12>>2]|0;n=m+(o>>>3)|0;if(!((bc(g|0,0,h|0)|0)==0&(C|0)==0))pa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>2]|0)>>>0)break;v=t+(u>>>3)|0;w=d[v>>0]|0;if(!g){x=16;break}F=cc(o|0,0,u&7|0)|0;H=C;F=w|F;I=v;G=I;a[G>>0]=F;a[G+1>>0]=F>>8;a[G+2>>0]=F>>16;a[G+3>>0]=F>>24;I=I+4|0;a[I>>0]=H;a[I+1>>0]=H>>8;a[I+2>>0]=H>>16;a[I+3>>0]=H>>24;I=(c[s>>2]|0)+2|0;c[s>>2]=I;u=I;n=n+1|0}if((x|0)==16)pa(406196,406218,54,406251);I=r+76|0;g=c[I>>2]|0;v=r+92|0;u=c[v>>2]|0;if(!g)fb(u,6,y,s,t);else gb(b,c[r+72>>2]|0,g,u,y,s,t);H=r+84|0;g=c[H>>2]|0;m=r+108|0;u=c[m>>2]|0;if(!g)fb(u,2,y,s,t);else gb(b,c[r+80>>2]|0,g,u,y,s,t);w=c[r+88>>2]|0;v=c[v>>2]|0;n=c[S>>2]|0;g=_(v,n)|0;u=sa[c[b>>2]&1](c[P>>2]|0,g)|0;if(!u)oa(1);c[N>>2]=u;g=sa[c[b>>2]&1](c[P>>2]|0,g<<1)|0;if(!g)oa(1);c[O>>2]=g;g=w;u=0;while(1){if((u|0)==(v|0))break;G=_(u,n)|0;kb(g+(u*1040|0)|0,n,y,(c[N>>2]|0)+G|0,(c[O>>2]|0)+(G<<1)|0,s,t);u=u+1|0}v=c[r+96>>2]|0;w=c[r+100>>2]|0;n=c[Q>>2]|0;g=_(w,n)|0;u=sa[c[b>>2]&1](c[P>>2]|0,g)|0;if(!u)oa(1);c[L>>2]=u;g=sa[c[b>>2]&1](c[P>>2]|0,g<<1)|0;if(!g)oa(1);c[M>>2]=g;g=v;u=0;while(1){if((u|0)==(w|0))break;G=_(u,n)|0;kb(g+(u*2832|0)|0,n,y,(c[L>>2]|0)+G|0,(c[M>>2]|0)+(G<<1)|0,s,t);u=u+1|0}v=c[r+104>>2]|0;w=c[m>>2]|0;n=c[R>>2]|0;g=_(w,n)|0;u=sa[c[b>>2]&1](c[P>>2]|0,g)|0;if(!u)oa(1);c[J>>2]=u;g=sa[c[b>>2]&1](c[P>>2]|0,g<<1)|0;if(!g)oa(1);c[K>>2]=g;g=v;u=0;while(1){if((u|0)==(w|0))break;G=_(u,n)|0;kb(g+(u*2096|0)|0,n,y,(c[J>>2]|0)+G|0,(c[K>>2]|0)+(G<<1)|0,s,t);u=u+1|0}G=b+4|0;ra[c[G>>2]&1](c[P>>2]|0,y);F=r+80|0;E=r+72|0;u=j;g=k;D=0;a:while(1){if(D>>>0>=q>>>0){x=87;break}b=c[p+(D<<4)>>2]|0;n=c[p+(D<<4)+4>>2]|0;B=c[p+(D<<4)+8>>2]|0;k=c[p+(D<<4)+12>>2]|0;j=k&65535;A=k>>>16;z=k&65535;hb(Q,z,s,t);r=n&16777215;n=r^n>>>24;do if(b>>>0<6)w=b;else{if(b>>>0<130){y=b+-2|0;w=((aa(y|0)|0)^31)+-1|0;w=(w<<1)+(y>>>w)+2|0;break}if(b>>>0<2114){w=((aa(b+-66|0)|0)^31)+10|0;break}if(b>>>0<6210){w=21;break}w=b>>>0<22594?22:23}while(0);do if(n>>>0<10)v=n+65534|0;else{if(n>>>0<134){y=n+-6|0;v=((aa(y|0)|0)^31)+-1|0;v=(v<<1)+(y>>>v)+4|0;break}if(n>>>0>=2118){v=23;break}v=((aa(n+-70|0)|0)^31)+12|0}while(0);w=w&65535;x=c[17268+(w<<2)>>2]|0;w=b-(c[18788+(w<<2)>>2]|0)|0;m=v&65535;n=cc(n-(c[17364+(m<<2)>>2]|0)|0,0,x|0)|0;v=C;w=n|w;n=x+(c[17460+(m<<2)>>2]|0)|0;m=c[s>>2]|0;x=t+(m>>>3)|0;y=d[x>>0]|0;U=bc(w|0,v|0,n|0)|0;if(!((U|0)==0&(C|0)==0)){x=61;break}if(n>>>0>=57){x=63;break}w=cc(w|0,v|0,m&7|0)|0;m=C;w=y|w;U=x;y=U;a[y>>0]=w;a[y+1>>0]=w>>8;a[y+2>>0]=w>>16;a[y+3>>0]=w>>24;U=U+4|0;a[U>>0]=m;a[U+1>>0]=m>>8;a[U+2>>0]=m>>16;a[U+3>>0]=m>>24;c[s>>2]=(c[s>>2]|0)+n;b:do if(!(c[I>>2]|0)){v=f;w=b;while(1){if(!w)break b;hb(S,d[e+(v&h)>>0]|0,s,t);v=v+1|0;w=w+-1|0}}else{v=f;w=b;while(1){if(!w)break b;switch(o|0){case 0:{g=u&63;break}case 1:{g=(u&255)>>>2;break}case 2:{g=a[406969+(u&255)>>0]|a[406969+(g&255|256)>>0];break}case 3:{g=((d[407481+(u&255)>>0]|0)<<3)+(d[407481+(g&255)>>0]|0)&255;break}default:g=0}U=a[e+(v&h)>>0]|0;ib(S,U&255,g&255,c[E>>2]|0,s,t,6);g=u;u=U;v=v+1|0;w=w+-1|0}}while(0);y=f+b+r|0;do if(r){g=a[e+(y+-2&h)>>0]|0;u=a[e+(y+-1&h)>>0]|0;if((j&65535)<=127)break;m=B>>>24;x=B&16777215;if(!(c[H>>2]|0))hb(R,A,s,t);else{v=k&7;switch(z>>>6|0){case 7:case 4:case 2:case 0:{v=v>>>0<3?v:3;break}default:v=3}ib(R,A,v,c[F>>2]|0,s,t,2)}v=c[s>>2]|0;w=t+(v>>>3)|0;n=d[w>>0]|0;U=bc(x|0,0,m|0)|0;if(!((U|0)==0&(C|0)==0)){x=82;break a}if(B>>>0>=956301312){x=84;break a}z=cc(x|0,0,v&7|0)|0;B=C;z=n|z;U=w;A=U;a[A>>0]=z;a[A+1>>0]=z>>8;a[A+2>>0]=z>>16;a[A+3>>0]=z>>24;U=U+4|0;a[U>>0]=B;a[U+1>>0]=B>>8;a[U+2>>0]=B>>16;a[U+3>>0]=B>>24;c[s>>2]=(c[s>>2]|0)+m}while(0);f=y;D=D+1|0}if((x|0)==61)pa(406196,406218,54,406251);else if((x|0)==63)pa(406267,406218,55,406251);else if((x|0)==82)pa(406196,406218,54,406251);else if((x|0)==84)pa(406267,406218,55,406251);else if((x|0)==87){ra[c[G>>2]&1](c[P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0;k=d[j>>0]|0;o=bc(h|0,e|0,l|0)|0;if(!((o|0)==0&(C|0)==0))pa(406196,406218,54,406251);if(l>>>0>=57)pa(406267,406218,55,406251);m=cc(h|0,e|0,m&7|0)|0;o=C;m=k|m;h=j;n=h;a[n>>0]=m;a[n+1>>0]=m>>8;a[n+2>>0]=m>>16;a[n+3>>0]=m>>24;h=h+4|0;a[h>>0]=o;a[h+1>>0]=o>>8;a[h+2>>0]=o>>16;a[h+3>>0]=o>>24;h=(c[f>>2]|0)+l|0;c[f>>2]=h;if(b){i=p;return}g=g+(h>>>3)|0;o=d[g>>0]|0;b=g;a[b>>0]=o;a[b+1>>0]=o>>8;a[b+2>>0]=o>>16;a[b+3>>0]=o>>24;g=g+4|0;a[g>>0]=0;a[g+1>>0]=0;a[g+2>>0]=0;a[g+3>>0]=0;c[f>>2]=(c[f>>2]|0)+1;i=p;return}function eb(b,f,g,h){b=b|0;f=f|0;g=g|0;h=h|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;v=i;i=i+1136|0;u=v+104|0;t=v;j=c[b+8>>2]|0;m=c[b+12>>2]|0;r=c[b+16>>2]|0;s=c[b+4>>2]|0;ac(u|0,0,(s<<2)+8|0)|0;k=t;l=k+104|0;do{c[k>>2]=0;k=k+4|0}while((k|0)<(l|0));p=0;q=1;k=0;while(1){if((p|0)==(r|0))break;o=d[j+p>>0]|0;if((o|0)==(q+1|0))k=1;else k=(o|0)==(k|0)?0:o+2|0;if(p){n=u+(k<<2)|0;c[n>>2]=(c[n>>2]|0)+1}k=c[m+(p<<2)>>2]|0;if(k>>>0>176)n=k>>>0>752?20:14;else n=k>>>0>40?7:0;while(1){if(n>>>0>=25)break;l=n+1|0;if(k>>>0<(c[17556+(l<<3)>>2]|0)>>>0)break;else n=l}k=t+(n<<2)|0;c[k>>2]=(c[k>>2]|0)+1;k=q;p=p+1|0;q=o}nb(s+-1|0,g,h);if(s>>>0<=1){i=v;return}r=b+20|0;kb(u,s+2|0,f,b+28|0,b+286|0,g,h);kb(t,26,f,b+802|0,b+828|0,g,h);k=c[m>>2]|0;u=d[j>>0]|0;c[b+24>>2]=c[r>>2];c[r>>2]=u;if(k>>>0>176)l=k>>>0>752?20:14;else l=k>>>0>40?7:0;while(1){if(l>>>0>=25)break;j=l+1|0;if(k>>>0<(c[17556+(j<<3)>>2]|0)>>>0)break;else l=j}p=c[17556+(l<<3)+4>>2]|0;o=k-(c[17556+(l<<3)>>2]|0)|0;n=a[b+802+l>>0]|0;j=e[b+828+(l<<1)>>1]|0;k=c[g>>2]|0;l=h+(k>>>3)|0;m=d[l>>0]|0;b=bc(j|0,0,n&255|0)|0;if(!((b|0)==0&(C|0)==0))pa(406196,406218,54,406251);if((n&255)>=57)pa(406267,406218,55,406251);b=cc(j|0,0,k&7|0)|0;j=C;b=m|b;k=l;a[k>>0]=b;a[k+1>>0]=b>>8;a[k+2>>0]=b>>16;a[k+3>>0]=b>>24;l=l+4|0;a[l>>0]=j;a[l+1>>0]=j>>8;a[l+2>>0]=j>>16;a[l+3>>0]=j>>24;l=(c[g>>2]|0)+(n&255)|0;c[g>>2]=l;j=h+(l>>>3)|0;k=d[j>>0]|0;h=bc(o|0,0,p|0)|0;if(!((h|0)==0&(C|0)==0))pa(406196,406218,54,406251);f=cc(o|0,0,l&7|0)|0;b=C;f=k|f;h=j;u=h;a[u>>0]=f;a[u+1>>0]=f>>8;a[u+2>>0]=f>>16;a[u+3>>0]=f>>24;h=h+4|0;a[h>>0]=b;a[h+1>>0]=b>>8;a[h+2>>0]=b>>16;a[h+3>>0]=b>>24;c[g>>2]=(c[g>>2]|0)+p;i=v;return}function fb(b,f,g,h,j){b=b|0;f=f|0;g=g|0;h=h|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;x=i;i=i+1904|0;p=x;w=x+1632|0;v=x+1088|0;nb(b+-1|0,h,j);if(b>>>0<=1){i=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]|0)+(k&255)|0;c[h>>2]=k;l=a[p>>0]|0;m=e[g>>1]|0;n=j+(k>>>3)|0;o=d[n>>0]|0;y=bc(m|0,0,l&255|0)|0;if(!((y|0)==0&(C|0)==0)){k=14;break}if((l&255)>=57){k=16;break}k=cc(m|0,0,k&7|0)|0;m=C;o=o|k;k=n;y=k;a[y>>0]=o;a[y+1>>0]=o>>8;a[y+2>>0]=o>>16;a[y+3>>0]=o>>24;k=k+4|0;a[k>>0]=m;a[k+1>>0]=m>>8;a[k+2>>0]=m>>16;a[k+3>>0]=m>>24;k=(c[h>>2]|0)+(l&255)|0;c[h>>2]=k;l=j+(k>>>3)|0;m=d[l>>0]|0;if(!q){k=18;break}if(!r){k=20;break}y=cc(u|0,0,k&7|0)|0;o=C;m=m|y;y=l;n=y;a[n>>0]=m;a[n+1>>0]=m>>8;a[n+2>>0]=m>>16;a[n+3>>0]=m>>24;y=y+4|0;a[y>>0]=o;a[y+1>>0]=o>>8;a[y+2>>0]=o>>16;a[y+3>>0]=o>>24;c[h>>2]=(c[h>>2]|0)+t;s=s+1|0}if((k|0)==10)pa(406196,406218,54,406251);else if((k|0)==12)pa(406267,406218,55,406251);else if((k|0)==14)pa(406196,406218,54,406251);else if((k|0)==16)pa(406267,406218,55,406251);else if((k|0)==18)pa(406196,406218,54,406251);else if((k|0)==20)pa(406267,406218,55,406251);else if((k|0)==22){w=c[h>>2]|0;y=j+(w>>>3)|0;b=d[y>>0]|0;w=cc(1,0,w&7|0)|0;j=C;w=b|w;b=y;a[b>>0]=w;a[b+1>>0]=w>>8;a[b+2>>0]=w>>16;a[b+3>>0]=w>>24;y=y+4|0;a[y>>0]=j;a[y+1>>0]=j>>8;a[y+2>>0]=j>>16;a[y+3>>0]=j>>24;c[h>>2]=(c[h>>2]|0)+1;i=x;return}}function gb(b,f,g,h,j,k,l){b=b|0;f=f|0;g=g|0;h=h|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0;B=i;i=i+2160|0;r=B+1088|0;v=B;A=B+1888|0;z=B+1344|0;nb(h+-1|0,k,l);if((h|0)==1){i=B;return}x=b+8|0;y=sa[c[b>>2]&1](c[x>>2]|0,g<<2)|0;if(!y)oa(1);a:do if(!g)w=y;else{m=c[f>>2]|0;n=1;while(1){if((n|0)==(g|0))break;u=c[f+(n<<2)>>2]|0;m=u>>>0>m>>>0?u:m;n=n+1|0}if(m>>>0<256)o=0;else pa(405316,404333,616,405333);while(1){if(o>>>0>m>>>0)break;a[r+o>>0]=o;o=o+1|0}p=m+1|0;q=0;b:while(1){if(q>>>0>=g>>>0){w=y;break a}m=c[f+(q<<2)>>2]&255;o=0;while(1){if(o>>>0>=p>>>0)break b;if((a[r+o>>0]|0)==m<<24>>24)break;o=o+1|0}c[y+(q<<2)>>2]=o;n=a[r+o>>0]|0;m=o;while(1){if(!m)break;u=m+-1|0;a[r+m>>0]=a[r+u>>0]|0;m=u}a[r>>0]=n;q=q+1|0}pa(405354,404333,624,405333)}while(0);c[r>>2]=0;m=0;o=0;while(1){if(m>>>0>=g>>>0)break;while(1){if(m>>>0>=g>>>0){n=0;break}if(!(c[w+(m<<2)>>2]|0)){n=0;break}u=m+1|0;c[r>>2]=u;m=u}while(1){if(m>>>0>=g>>>0)break;if(c[w+(m<<2)>>2]|0)break;u=m+1|0;c[r>>2]=u;m=u;n=n+1|0}o=n>>>0>o>>>0?n:o}if(!o)u=0;else{u=(aa(o|0)|0)^31;u=u>>>0<6?u:6}c[r>>2]=0;p=2<<u;q=u+((512<<u)+-512)|0;f=p+-1|0;o=0;s=0;while(1){if(o>>>0>=g>>>0)break;if(s>>>0>o>>>0){t=38;break}m=c[w+(o<<2)>>2]|0;c:do if(!m){m=o;n=1;while(1){m=m+1|0;if(m>>>0>=g>>>0)break;if(c[w+(m<<2)>>2]|0)break;n=n+1|0}c[r>>2]=o+n;m=s;while(1){if(!n)break c;if(n>>>0<p>>>0)break;c[w+(m<<2)>>2]=q;m=m+1|0;n=n-f|0}s=(aa(n|0)|0)^31;c[w+(m<<2)>>2]=s|n-(1<<s)<<9;m=m+1|0}else{c[w+(s<<2)>>2]=m+u;c[r>>2]=(c[r>>2]|0)+1;m=s+1|0}while(0);o=c[r>>2]|0;s=m}if((t|0)==38)pa(405282,404333,656,405297);ac(v|0,0,1088)|0;m=0;while(1){if((m|0)==(s|0))break;t=v+((c[w+(m<<2)>>2]&511)<<2)|0;c[t>>2]=(c[t>>2]|0)+1;m=m+1|0}t=(u|0)!=0;f=c[k>>2]|0;m=l+(f>>>3)|0;g=d[m>>0]|0;f=cc(t&1|0,0,f&7|0)|0;r=C;f=g|f;g=m;a[g>>0]=f;a[g+1>>0]=f>>8;a[g+2>>0]=f>>16;a[g+3>>0]=f>>24;m=m+4|0;a[m>>0]=r;a[m+1>>0]=r>>8;a[m+2>>0]=r>>16;a[m+3>>0]=r>>24;m=(c[k>>2]|0)+1|0;c[k>>2]=m;do if(t){n=u+-1|0;o=l+(m>>>3)|0;p=d[o>>0]|0;if((n&-16|0)==0&0==0){f=cc(n|0,0,m&7|0)|0;r=C;f=p|f;t=o;g=t;a[g>>0]=f;a[g+1>>0]=f>>8;a[g+2>>0]=f>>16;a[g+3>>0]=f>>24;t=t+4|0;a[t>>0]=r;a[t+1>>0]=r>>8;a[t+2>>0]=r>>16;a[t+3>>0]=r>>24;c[k>>2]=(c[k>>2]|0)+4;break}else pa(406196,406218,54,406251)}while(0);kb(v,u+h|0,j,A,z,k,l);r=0;while(1){if(r>>>0>=s>>>0){t=70;break}g=c[w+(r<<2)>>2]|0;f=g&511;g=g>>>9;m=a[A+f>>0]|0;n=e[z+(f<<1)>>1]|0;o=c[k>>2]|0;p=l+(o>>>3)|0;q=d[p>>0]|0;j=bc(n|0,0,m&255|0)|0;if(!((j|0)==0&(C|0)==0)){t=60;break}if((m&255)>=57){t=62;break}t=cc(n|0,0,o&7|0)|0;h=C;t=q|t;j=p;v=j;a[v>>0]=t;a[v+1>>0]=t>>8;a[v+2>>0]=t>>16;a[v+3>>0]=t>>24;j=j+4|0;a[j>>0]=h;a[j+1>>0]=h>>8;a[j+2>>0]=h>>16;a[j+3>>0]=h>>24;m=(c[k>>2]|0)+(m&255)|0;c[k>>2]=m;if(!((f|0)==0|f>>>0>u>>>0)){n=l+(m>>>3)|0;o=d[n>>0]|0;j=bc(g|0,0,f|0)|0;if(!((j|0)==0&(C|0)==0)){t=65;break}if(f>>>0>=57){t=67;break}t=cc(g|0,0,m&7|0)|0;h=C;t=o|t;j=n;v=j;a[v>>0]=t;a[v+1>>0]=t>>8;a[v+2>>0]=t>>16;a[v+3>>0]=t>>24;j=j+4|0;a[j>>0]=h;a[j+1>>0]=h>>8;a[j+2>>0]=h>>16;a[j+3>>0]=h>>24;c[k>>2]=(c[k>>2]|0)+f}r=r+1|0}if((t|0)==60)pa(406196,406218,54,406251);else if((t|0)==62)pa(406267,406218,55,406251);else if((t|0)==65)pa(406196,406218,54,406251);else if((t|0)==67)pa(406267,406218,55,406251);else if((t|0)==70){w=c[k>>2]|0;l=l+(w>>>3)|0;z=d[l>>0]|0;w=cc(1,0,w&7|0)|0;A=C;w=z|w;z=l;a[z>>0]=w;a[z+1>>0]=w>>8;a[z+2>>0]=w>>16;a[z+3>>0]=w>>24;l=l+4|0;a[l>>0]=A;a[l+1>>0]=A>>8;a[l+2>>0]=A>>16;a[l+3>>0]=A>>24;c[k>>2]=(c[k>>2]|0)+1;ra[c[b+4>>2]&1](c[x>>2]|0,y);i=B;return}}function hb(b,f,g,h){b=b|0;f=f|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;s=b+884|0;i=c[s>>2]|0;do if(!i){p=b+880|0;j=(c[p>>2]|0)+1|0;c[p>>2]=j;p=c[(c[b+12>>2]|0)+(j<<2)>>2]|0;j=a[(c[b+8>>2]|0)+j>>0]|0;c[s>>2]=p;j=j&255;q=b+888|0;c[q>>2]=_(j,c[b>>2]|0)|0;k=b+20|0;l=c[k>>2]|0;i=b+24|0;if((j|0)==(l+1|0))m=1;else m=(j|0)==(c[i>>2]|0)?0:j+2|0;c[i>>2]=l;c[k>>2]=j;n=a[b+28+m>>0]|0;i=e[b+286+(m<<1)>>1]|0;j=c[g>>2]|0;k=h+(j>>>3)|0;l=d[k>>0]|0;o=bc(i|0,0,n&255|0)|0;if(!((o|0)==0&(C|0)==0))pa(406196,406218,54,406251);if((n&255)>=57)pa(406267,406218,55,406251);j=cc(i|0,0,j&7|0)|0;m=C;j=l|j;o=k;l=o;a[l>>0]=j;a[l+1>>0]=j>>8;a[l+2>>0]=j>>16;a[l+3>>0]=j>>24;o=o+4|0;a[o>>0]=m;a[o+1>>0]=m>>8;a[o+2>>0]=m>>16;a[o+3>>0]=m>>24;c[g>>2]=(c[g>>2]|0)+(n&255);if(p>>>0>176)j=p>>>0>752?20:14;else j=p>>>0>40?7:0;while(1){if(j>>>0>=25)break;i=j+1|0;if(p>>>0<(c[17556+(i<<3)>>2]|0)>>>0)break;else j=i}o=c[17556+(j<<3)+4>>2]|0;n=p-(c[17556+(j<<3)>>2]|0)|0;m=a[b+802+j>>0]|0;i=e[b+828+(j<<1)>>1]|0;j=c[g>>2]|0;k=h+(j>>>3)|0;l=d[k>>0]|0;p=bc(i|0,0,m&255|0)|0;if(!((p|0)==0&(C|0)==0))pa(406196,406218,54,406251);if((m&255)>=57)pa(406267,406218,55,406251);p=cc(i|0,0,j&7|0)|0;i=C;p=l|p;j=k;k=j;a[k>>0]=p;a[k+1>>0]=p>>8;a[k+2>>0]=p>>16;a[k+3>>0]=p>>24;j=j+4|0;a[j>>0]=i;a[j+1>>0]=i>>8;a[j+2>>0]=i>>16;a[j+3>>0]=i>>24;j=(c[g>>2]|0)+(m&255)|0;c[g>>2]=j;k=h+(j>>>3)|0;i=d[k>>0]|0;p=bc(n|0,0,o|0)|0;if((p|0)==0&(C|0)==0){n=cc(n|0,0,j&7|0)|0;t=C;n=i|n;r=k;p=r;a[p>>0]=n;a[p+1>>0]=n>>8;a[p+2>>0]=n>>16;a[p+3>>0]=n>>24;r=r+4|0;a[r>>0]=t;a[r+1>>0]=t>>8;a[r+2>>0]=t>>16;a[r+3>>0]=t>>24;c[g>>2]=(c[g>>2]|0)+o;r=q;t=c[s>>2]|0;break}else pa(406196,406218,54,406251)}else{r=b+888|0;t=i}while(0);c[s>>2]=t+-1;k=(c[r>>2]|0)+f|0;m=a[(c[b+892>>2]|0)+k>>0]|0;k=e[(c[b+896>>2]|0)+(k<<1)>>1]|0;l=c[g>>2]|0;i=h+(l>>>3)|0;j=d[i>>0]|0;h=bc(k|0,0,m&255|0)|0;if(!((h|0)==0&(C|0)==0))pa(406196,406218,54,406251);if((m&255)<57){t=cc(k|0,0,l&7|0)|0;b=C;t=j|t;h=i;f=h;a[f>>0]=t;a[f+1>>0]=t>>8;a[f+2>>0]=t>>16;a[f+3>>0]=t>>24;h=h+4|0;a[h>>0]=b;a[h+1>>0]=b>>8;a[h+2>>0]=b>>16;a[h+3>>0]=b>>24;c[g>>2]=(c[g>>2]|0)+(m&255);return}else pa(406267,406218,55,406251)}function ib(b,f,g,h,i,j,k){b=b|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;u=b+884|0;l=c[u>>2]|0;do if(!l){r=b+880|0;n=(c[r>>2]|0)+1|0;c[r>>2]=n;r=c[(c[b+12>>2]|0)+(n<<2)>>2]|0;n=a[(c[b+8>>2]|0)+n>>0]|0;c[u>>2]=r;n=n&255;s=b+888|0;c[s>>2]=n<<k;k=b+20|0;m=c[k>>2]|0;l=b+24|0;if((n|0)==(m+1|0))o=1;else o=(n|0)==(c[l>>2]|0)?0:n+2|0;c[l>>2]=m;c[k>>2]=n;p=a[b+28+o>>0]|0;l=e[b+286+(o<<1)>>1]|0;k=c[i>>2]|0;m=j+(k>>>3)|0;n=d[m>>0]|0;q=bc(l|0,0,p&255|0)|0;if(!((q|0)==0&(C|0)==0))pa(406196,406218,54,406251);if((p&255)>=57)pa(406267,406218,55,406251);k=cc(l|0,0,k&7|0)|0;o=C;k=n|k;q=m;n=q;a[n>>0]=k;a[n+1>>0]=k>>8;a[n+2>>0]=k>>16;a[n+3>>0]=k>>24;q=q+4|0;a[q>>0]=o;a[q+1>>0]=o>>8;a[q+2>>0]=o>>16;a[q+3>>0]=o>>24;c[i>>2]=(c[i>>2]|0)+(p&255);if(r>>>0>176)k=r>>>0>752?20:14;else k=r>>>0>40?7:0;while(1){if(k>>>0>=25)break;l=k+1|0;if(r>>>0<(c[17556+(l<<3)>>2]|0)>>>0)break;else k=l}q=c[17556+(k<<3)+4>>2]|0;p=r-(c[17556+(k<<3)>>2]|0)|0;o=a[b+802+k>>0]|0;l=e[b+828+(k<<1)>>1]|0;k=c[i>>2]|0;m=j+(k>>>3)|0;n=d[m>>0]|0;r=bc(l|0,0,o&255|0)|0;if(!((r|0)==0&(C|0)==0))pa(406196,406218,54,406251);if((o&255)>=57)pa(406267,406218,55,406251);r=cc(l|0,0,k&7|0)|0;k=C;r=n|r;l=m;m=l;a[m>>0]=r;a[m+1>>0]=r>>8;a[m+2>>0]=r>>16;a[m+3>>0]=r>>24;l=l+4|0;a[l>>0]=k;a[l+1>>0]=k>>8;a[l+2>>0]=k>>16;a[l+3>>0]=k>>24;l=(c[i>>2]|0)+(o&255)|0;c[i>>2]=l;k=j+(l>>>3)|0;m=d[k>>0]|0;r=bc(p|0,0,q|0)|0;if((r|0)==0&(C|0)==0){p=cc(p|0,0,l&7|0)|0;v=C;p=m|p;t=k;r=t;a[r>>0]=p;a[r+1>>0]=p>>8;a[r+2>>0]=p>>16;a[r+3>>0]=p>>24;t=t+4|0;a[t>>0]=v;a[t+1>>0]=v>>8;a[t+2>>0]=v>>16;a[t+3>>0]=v>>24;c[i>>2]=(c[i>>2]|0)+q;t=s;v=c[u>>2]|0;break}else pa(406196,406218,54,406251)}else{t=b+888|0;v=l}while(0);c[u>>2]=v+-1;m=(_(c[h+((c[t>>2]|0)+g<<2)>>2]|0,c[b>>2]|0)|0)+f|0;o=a[(c[b+892>>2]|0)+m>>0]|0;m=e[(c[b+896>>2]|0)+(m<<1)>>1]|0;n=c[i>>2]|0;l=j+(n>>>3)|0;k=d[l>>0]|0;j=bc(m|0,0,o&255|0)|0;if(!((j|0)==0&(C|0)==0))pa(406196,406218,54,406251);if((o&255)<57){h=cc(m|0,0,n&7|0)|0;b=C;h=k|h;j=l;f=j;a[f>>0]=h;a[f+1>>0]=h>>8;a[f+2>>0]=h>>16;a[f+3>>0]=h>>24;j=j+4|0;a[j>>0]=b;a[j+1>>0]=b>>8;a[j+2>>0]=b>>16;a[j+3>>0]=b>>24;c[i>>2]=(c[i>>2]|0)+(o&255);return}else pa(406267,406218,55,406251)}function jb(a,b,e,f,g,h,i,j){a=a|0;b=b|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;r=i+2816|0;s=h+1024|0;t=j+2080|0;q=0;while(1){if((q|0)==(g|0))break;o=c[f+(q<<4)>>2]|0;k=c[f+(q<<4)+4>>2]|0;l=c[f+(q<<4)+12>>2]|0;p=l&65535;n=l>>>16;l=i+((l&65535)<<2)|0;c[l>>2]=(c[l>>2]|0)+1;c[r>>2]=(c[r>>2]|0)+1;l=b;m=o;while(1){if(!m)break;u=h+((d[a+(l&e)>>0]|0)<<2)|0;c[u>>2]=(c[u>>2]|0)+1;c[s>>2]=(c[s>>2]|0)+1;l=l+1|0;m=m+-1|0}k=k&16777215;if((k|0)!=0&(p&65535)>127){u=j+(n<<2)|0;c[u>>2]=(c[u>>2]|0)+1;c[t>>2]=(c[t>>2]|0)+1}b=b+o+k|0;q=q+1|0}return}function kb(e,f,g,h,j,k,l){e=e|0;f=f|0;g=g|0;h=h|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0,p=0,q=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n>>8;a[m+2>>0]=n>>16;a[m+3>>0]=n>>24;m=(c[k>>2]|0)+2|0;c[k>>2]=m;n=p+-1|0;e=l+(m>>>3)|0;f=d[e>>0]|0;if(!((n&-4|0)==0&0==0))pa(406196,406218,54,406251);g=cc(n|0,0,m&7|0)|0;j=C;g=f|g;f=e;o=f;a[o>>0]=g;a[o+1>>0]=g>>8;a[o+2>>0]=g>>16;a[o+3>>0]=g>>24;f=f+4|0;a[f>>0]=j;a[f+1>>0]=j>>8;a[f+2>>0]=j>>16;a[f+3>>0]=j>>24;c[k>>2]=(c[k>>2]|0)+2;f=p+-1|0;j=0;while(1){if((j|0)==(p|0))break;g=q+(j<<2)|0;m=j;while(1){o=m+1|0;if((m|0)==(f|0))break;m=q+(o<<2)|0;n=c[m>>2]|0;e=c[g>>2]|0;if((d[h+n>>0]|0)>=(d[h+e>>0]|0)){m=o;continue}c[m>>2]=e;c[g>>2]=n;m=o}j=j+1|0}switch(p|0){case 2:{m=c[q>>2]|0;n=c[k>>2]|0;e=l+(n>>>3)|0;f=d[e>>0]|0;if(!((bc(m|0,0,r|0)|0)==0&(C|0)==0))pa(406196,406218,54,406251);if(r>>>0>=57)pa(406267,406218,55,406251);n=cc(m|0,0,n&7|0)|0;m=C;n=f|n;f=e;e=f;a[e>>0]=n;a[e+1>>0]=n>>8;a[e+2>>0]=n>>16;a[e+3>>0]=n>>24;f=f+4|0;a[f>>0]=m;a[f+1>>0]=m>>8;a[f+2>>0]=m>>16;a[f+3>>0]=m>>24;f=(c[k>>2]|0)+r|0;c[k>>2]=f;e=c[q+4>>2]|0;m=l+(f>>>3)|0;n=d[m>>0]|0;if(!((bc(e|0,0,r|0)|0)==0&(C|0)==0))pa(406196,406218,54,406251);p=cc(e|0,0,f&7|0)|0;q=C;p=n|p;l=m;h=l;a[h>>0]=p;a[h+1>>0]=p>>8;a[h+2>>0]=p>>16;a[h+3>>0]=p>>24;l=l+4|0;a[l>>0]=q;a[l+1>>0]=q>>8;a[l+2>>0]=q>>16;a[l+3>>0]=q>>24;c[k>>2]=(c[k>>2]|0)+r;i=s;return}case 3:{m=c[q>>2]|0;n=c[k>>2]|0;e=l+(n>>>3)|0;f=d[e>>0]|0;if(!((bc(m|0,0,r|0)|0)==0&(C|0)==0))pa(406196,406218,54,406251);if(r>>>0>=57)pa(406267,406218,55,406251);m=cc(m|0,0,n&7|0)|0;n=C;f=f|m;m=e;e=m;a[e>>0]=f;a[e+1>>0]=f>>8;a[e+2>>0]=f>>16;a[e+3>>0]=f>>24;m=m+4|0;a[m>>0]=n;a[m+1>>0]=n>>8;a[m+2>>0]=n>>16;a[m+3>>0]=n>>24;m=(c[k>>2]|0)+r|0;c[k>>2]=m;n=c[q+4>>2]|0;e=l+(m>>>3)|0;f=d[e>>0]|0;if(!((bc(n|0,0,r|0)|0)==0&(C|0)==0))pa(406196,406218,54,406251);n=cc(n|0,0,m&7|0)|0;m=C;n=f|n;f=e;e=f;a[e>>0]=n;a[e+1>>0]=n>>8;a[e+2>>0]=n>>16;a[e+3>>0]=n>>24;f=f+4|0;a[f>>0]=m;a[f+1>>0]=m>>8;a[f+2>>0]=m>>16;a[f+3>>0]=m>>24;f=(c[k>>2]|0)+r|0;c[k>>2]=f;e=c[q+8>>2]|0;m=l+(f>>>3)|0;n=d[m>>0]|0;if(!((bc(e|0,0,r|0)|0)==0&(C|0)==0))pa(406196,406218,54,406251);p=cc(e|0,0,f&7|0)|0;q=C;p=n|p;l=m;h=l;a[h>>0]=p;a[h+1>>0]=p>>8;a[h+2>>0]=p>>16;a[h+3>>0]=p>>24;l=l+4|0;a[l>>0]=q;a[l+1>>0]=q>>8;a[l+2>>0]=q>>16;a[l+3>>0]=q>>24;c[k>>2]=(c[k>>2]|0)+r;i=s;return}default:{m=c[q>>2]|0;n=c[k>>2]|0;e=l+(n>>>3)|0;f=d[e>>0]|0;if(!((bc(m|0,0,r|0)|0)==0&(C|0)==0))pa(406196,406218,54,406251);if(r>>>0>=57)pa(406267,406218,55,406251);m=cc(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q>>2]|0)>>0]|0)==1|0,0,o&7|0)|0;l=C;h=p|h;q=r;a[q>>0]=h;a[q+1>>0]=h>>8;a[q+2>>0]=h>>16;a[q+3>>0]=h>>24;r=r+4|0;a[r>>0]=l;a[r+1>>0]=l>>8;a[r+2>>0]=l>>16;a[r+3>>0]=l>>24;c[k>>2]=(c[k>>2]|0)+1;i=s;return}}}function lb(b,f,g,h,i,j,k,l,m,n,o,p,q){b=b|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=o|0;p=p|0;q=q|0;var r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,D=0,E=0;E=0;a:while(1){if(E>>>0>=i>>>0){f=42;break}y=c[h+(E<<4)>>2]|0;w=c[h+(E<<4)+4>>2]|0;D=c[h+(E<<4)+8>>2]|0;s=c[h+(E<<4)+12>>2]|0;A=s&65535;B=s>>>16;s=s&65535;r=a[l+s>>0]|0;s=e[m+(s<<1)>>1]|0;t=c[p>>2]|0;u=q+(t>>>3)|0;v=d[u>>0]|0;z=bc(s|0,0,r&255|0)|0;if(!((z|0)==0&(C|0)==0)){f=4;break}if((r&255)>=57){f=6;break}x=cc(s|0,0,t&7|0)|0;z=C;v=v|x;x=u;t=x;a[t>>0]=v;a[t+1>>0]=v>>8;a[t+2>>0]=v>>16;a[t+3>>0]=v>>24;x=x+4|0;a[x>>0]=z;a[x+1>>0]=z>>8;a[x+2>>0]=z>>16;a[x+3>>0]=z>>24;x=(c[p>>2]|0)+(r&255)|0;c[p>>2]=x;z=w&16777215;t=z^w>>>24;do if(y>>>0>=6){if(y>>>0<130){w=y+-2|0;s=((aa(w|0)|0)^31)+-1|0;s=(s<<1)+(w>>>s)+2|0;break}if(y>>>0<2114){s=((aa(y+-66|0)|0)^31)+10|0;break}if(y>>>0<6210)s=21;else s=y>>>0<22594?22:23}else s=y;while(0);do if(t>>>0>=10){if(t>>>0<134){w=t+-6|0;r=((aa(w|0)|0)^31)+-1|0;r=(r<<1)+(w>>>r)+4|0;break}if(t>>>0<2118)r=((aa(t+-70|0)|0)^31)+12|0;else r=23}else r=t+65534|0;while(0);s=s&65535;v=c[17268+(s<<2)>>2]|0;s=y-(c[18788+(s<<2)>>2]|0)|0;u=r&65535;t=cc(t-(c[17364+(u<<2)>>2]|0)|0,0,v|0)|0;r=C;s=t|s;t=v+(c[17460+(u<<2)>>2]|0)|0;u=q+(x>>>3)|0;v=d[u>>0]|0;w=bc(s|0,r|0,t|0)|0;if(!((w|0)==0&(C|0)==0)){f=21;break}if(t>>>0>=57){f=23;break}s=cc(s|0,r|0,x&7|0)|0;w=C;s=v|s;x=u;v=x;a[v>>0]=s;a[v+1>>0]=s>>8;a[v+2>>0]=s>>16;a[v+3>>0]=s>>24;x=x+4|0;a[x>>0]=w;a[x+1>>0]=w>>8;a[x+2>>0]=w>>16;a[x+3>>0]=w>>24;x=(c[p>>2]|0)+t|0;c[p>>2]=x;v=y;while(1){if(!v)break;s=d[b+(f&g)>>0]|0;r=a[j+s>>0]|0;s=e[k+(s<<1)>>1]|0;t=q+(x>>>3)|0;u=d[t>>0]|0;y=bc(s|0,0,r&255|0)|0;if(!((y|0)==0&(C|0)==0)){f=27;break a}if((r&255)>=57){f=29;break a}s=cc(s|0,0,x&7|0)|0;w=C;s=u|s;y=t;u=y;a[u>>0]=s;a[u+1>>0]=s>>8;a[u+2>>0]=s>>16;a[u+3>>0]=s>>24;y=y+4|0;a[y>>0]=w;a[y+1>>0]=w>>8;a[y+2>>0]=w>>16;a[y+3>>0]=w>>24;y=(c[p>>2]|0)+(r&255)|0;c[p>>2]=y;x=y;f=f+1|0;v=v+-1|0}f=f+z|0;if((z|0)!=0&(A&65535)>127){v=D>>>24;w=D&16777215;u=a[n+B>>0]|0;r=e[o+(B<<1)>>1]|0;s=q+(x>>>3)|0;t=d[s>>0]|0;B=bc(r|0,0,u&255|0)|0;if(!((B|0)==0&(C|0)==0)){f=33;break}if((u&255)>=57){f=35;break}r=cc(r|0,0,x&7|0)|0;B=C;t=t|r;r=s;s=r;a[s>>0]=t;a[s+1>>0]=t>>8;a[s+2>>0]=t>>16;a[s+3>>0]=t>>24;r=r+4|0;a[r>>0]=B;a[r+1>>0]=B>>8;a[r+2>>0]=B>>16;a[r+3>>0]=B>>24;r=(c[p>>2]|0)+(u&255)|0;c[p>>2]=r;s=q+(r>>>3)|0;t=d[s>>0]|0;B=bc(w|0,0,v|0)|0;if(!((B|0)==0&(C|0)==0)){f=37;break}if(D>>>0>=956301312){f=39;break}z=cc(w|0,0,r&7|0)|0;B=C;z=t|z;D=s;A=D;a[A>>0]=z;a[A+1>>0]=z>>8;a[A+2>>0]=z>>16;a[A+3>>0]=z>>24;D=D+4|0;a[D>>0]=B;a[D+1>>0]=B>>8;a[D+2>>0]=B>>16;a[D+3>>0]=B>>24;c[p>>2]=(c[p>>2]|0)+v}E=E+1|0}switch(f|0){case 4:{pa(406196,406218,54,406251);break}case 6:{pa(406267,406218,55,406251);break}case 21:{pa(406196,406218,54,406251);break}case 23:{pa(406267,406218,55,406251);break}case 27:{pa(406196,406218,54,406251);break}case 29:{pa(406267,406218,55,406251);break}case 33:{pa(406196,406218,54,406251);break}case 35:{pa(406267,406218,55,406251);break}case 37:{pa(406196,406218,54,406251);break}case 39:{pa(406267,406218,55,406251);break}case 42:return}}function mb(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0;if((a|0)!=1){i=(aa(a+-1|0)|0)^31;j=i+1|0;if(!a)pa(405225,404333,86,405236);else{g=j>>>0<16?4:(i+4|0)>>>2;k=j}if(a>>>0<16777217){h=g;l=k}else pa(405253,404333,87,405236);if(l>>>0<25)f=h;else pa(405273,404333,88,405236)}else f=4;c[e>>2]=f+-4;c[e+4>>2]=0;c[d>>2]=f<<2;d=b;c[d>>2]=a+-1;c[d+4>>2]=0;return}function nb(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k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var l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0,v=0,w=0;w=i;i=i+1040|0;t=w;if((d|0)==(e|0)){i=w;return}u=e>>>0<d>>>0;v=u?d:e;u=u?e:d;d=c[b+(u<<2)>>2]|0;e=c[b+(v<<2)>>2]|0;b=d+e|0;s=+(d>>>0);if(d>>>0<256)r=+g[19516+(d<<2)>>2];else r=+Xb(s);q=+(e>>>0);if(e>>>0<256)p=+g[19516+(e<<2)>>2];else p=+Xb(q);n=+(b>>>0);if(b>>>0<256)m=+g[19516+(b<<2)>>2];else m=+Xb(n);l=+h[a+(u*1040|0)+1032>>3];o=+h[a+(v*1040|0)+1032>>3];n=(s*r+q*p-n*m)*.5-l-o;if(c[a+(u*1040|0)+1024>>2]|0){d=c[a+(v*1040|0)+1024>>2]|0;if(d){if(c[k>>2]|0){l=+h[j+16>>3];if(l<0.0)m=0.0;else m=l}else m=1.e+99;dc(t|0,a+(u*1040|0)|0,1040)|0;b=t+1024|0;c[b>>2]=(c[b>>2]|0)+d;d=0;while(1){if((d|0)==256)break;b=t+(d<<2)|0;c[b>>2]=(c[b>>2]|0)+(c[a+(v*1040|0)+(d<<2)>>2]|0);d=d+1|0}l=+Wa(t);if(!(l<m-n)){i=w;return}}}else l=o;m=n+l;d=c[k>>2]|0;do if(d){n=+h[j+16>>3];if(n!=m){if(!(n>m))break}else if(((c[j+4>>2]|0)-(c[j>>2]|0)|0)>>>0<=(v-u|0)>>>0)break;if(d>>>0<f>>>0){f=j+(d*24|0)|0;c[f>>2]=c[j>>2];c[f+4>>2]=c[j+4>>2];c[f+8>>2]=c[j+8>>2];c[f+12>>2]=c[j+12>>2];c[f+16>>2]=c[j+16>>2];c[f+20>>2]=c[j+20>>2];c[k>>2]=(c[k>>2]|0)+1}c[j>>2]=u;c[j+4>>2]=v;h[j+8>>3]=l;h[j+16>>3]=m;i=w;return}while(0);if(d>>>0>=f>>>0){i=w;return}c[j+(d*24|0)>>2]=u;c[j+(d*24|0)+4>>2]=v;h[j+(d*24|0)+8>>3]=l;h[j+(d*24|0)+16>>3]=m;c[k>>2]=(c[k>>2]|0)+1;i=w;return}function pb(a,b,d,e,f,g,j,k,l){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0,u=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;F=i;i=i+32|0;E=F+24|0;D=F;c[E>>2]=0;m=g+-1|0;o=0;while(1){if((o|0)==(g|0))break;n=e+(o<<2)|0;q=o;while(1){p=q+1|0;if((q|0)==(m|0))break;ob(a,b,c[n>>2]|0,c[e+(p<<2)>>2]|0,l,f,E);q=p}o=o+1|0}x=f+16|0;y=f+4|0;z=f+8|0;m=g;v=0.0;w=1;a:while(1){u=m;while(1){m=m+-1|0;if(u>>>0<=w>>>0)break a;if(+h[x>>3]>=v){m=u;v=1.e+99;w=k;continue a}t=c[f>>2]|0;g=c[y>>2]|0;n=a+(t*1040|0)+1024|0;c[n>>2]=(c[n>>2]|0)+(c[a+(g*1040|0)+1024>>2]|0);n=0;while(1){if((n|0)==256)break;q=a+(t*1040|0)+(n<<2)|0;c[q>>2]=(c[q>>2]|0)+(c[a+(g*1040|0)+(n<<2)>>2]|0);n=n+1|0}h[a+(t*1040|0)+1032>>3]=+h[z>>3];o=b+(t<<2)|0;c[o>>2]=(c[o>>2]|0)+(c[b+(g<<2)>>2]|0);o=0;while(1){if((o|0)==(j|0)){o=0;break}n=d+(o<<2)|0;if((c[n>>2]|0)==(g|0))c[n>>2]=t;o=o+1|0}while(1){if(u>>>0<=o>>>0)break;n=e+(o<<2)|0;if((c[n>>2]|0)==(g|0)){A=22;break}o=o+1|0}if((A|0)==22){A=0;fc(n|0,e+(o+1<<2)|0,(u-o<<2)+-4|0)|0}p=c[E>>2]|0;n=0;q=0;while(1){if((q|0)==(p|0))break;o=f+(q*24|0)|0;if(((c[o>>2]|0)!=(t|0)?(B=c[f+(q*24|0)+4>>2]|0,(B|0)!=(t|0)):0)?(C=c[o>>2]|0,!((C|0)==(g|0)|(B|0)==(g|0))):0){r=+h[x>>3];s=+h[f+(q*24|0)+16>>3];if(r!=s)if(r>s)A=32;else A=33;else if(((c[y>>2]|0)-(c[f>>2]|0)|0)>>>0>(B-C|0)>>>0)A=32;else A=33;if((A|0)==32){A=0;c[D>>2]=c[f>>2];c[D+4>>2]=c[f+4>>2];c[D+8>>2]=c[f+8>>2];c[D+12>>2]=c[f+12>>2];c[D+16>>2]=c[f+16>>2];c[D+20>>2]=c[f+20>>2];c[f>>2]=c[o>>2];c[f+4>>2]=c[o+4>>2];c[f+8>>2]=c[o+8>>2];c[f+12>>2]=c[o+12>>2];c[f+16>>2]=c[o+16>>2];c[f+20>>2]=c[o+20>>2];o=f+(n*24|0)|0;c[o>>2]=c[D>>2];c[o+4>>2]=c[D+4>>2];c[o+8>>2]=c[D+8>>2];c[o+12>>2]=c[D+12>>2];c[o+16>>2]=c[D+16>>2];c[o+20>>2]=c[D+20>>2]}else if((A|0)==33){A=0;G=f+(n*24|0)|0;c[G>>2]=c[o>>2];c[G+4>>2]=c[o+4>>2];c[G+8>>2]=c[o+8>>2];c[G+12>>2]=c[o+12>>2];c[G+16>>2]=c[o+16>>2];c[G+20>>2]=c[o+20>>2]}n=n+1|0}q=q+1|0}c[E>>2]=n;n=0;while(1){if((n|0)==(m|0))break;ob(a,b,t,c[e+(n<<2)>>2]|0,l,f,E);n=n+1|0}u=u+-1|0}}i=F;return u|0}function qb(a,b,d,e,f,j,k){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;j=j|0;k=k|0;var l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0,v=0,w=0;w=i;i=i+2832|0;t=w;if((d|0)==(e|0)){i=w;return}u=e>>>0<d>>>0;v=u?d:e;u=u?e:d;d=c[b+(u<<2)>>2]|0;e=c[b+(v<<2)>>2]|0;b=d+e|0;s=+(d>>>0);if(d>>>0<256)r=+g[19516+(d<<2)>>2];else r=+Xb(s);q=+(e>>>0);if(e>>>0<256)p=+g[19516+(e<<2)>>2];else p=+Xb(q);n=+(b>>>0);if(b>>>0<256)m=+g[19516+(b<<2)>>2];else m=+Xb(n);l=+h[a+(u*2832|0)+2824>>3];o=+h[a+(v*2832|0)+2824>>3];n=(s*r+q*p-n*m)*.5-l-o;if(c[a+(u*2832|0)+2816>>2]|0){d=c[a+(v*2832|0)+2816>>2]|0;if(d){if(c[k>>2]|0){l=+h[j+16>>3];if(l<0.0)m=0.0;else m=l}else m=1.e+99;dc(t|0,a+(u*2832|0)|0,2832)|0;b=t+2816|0;c[b>>2]=(c[b>>2]|0)+d;d=0;while(1){if((d|0)==704)break;b=t+(d<<2)|0;c[b>>2]=(c[b>>2]|0)+(c[a+(v*2832|0)+(d<<2)>>2]|0);d=d+1|0}l=+Xa(t);if(!(l<m-n)){i=w;return}}}else l=o;m=n+l;d=c[k>>2]|0;do if(d){n=+h[j+16>>3];if(n!=m){if(!(n>m))break}else if(((c[j+4>>2]|0)-(c[j>>2]|0)|0)>>>0<=(v-u|0)>>>0)break;if(d>>>0<f>>>0){f=j+(d*24|0)|0;c[f>>2]=c[j>>2];c[f+4>>2]=c[j+4>>2];c[f+8>>2]=c[j+8>>2];c[f+12>>2]=c[j+12>>2];c[f+16>>2]=c[j+16>>2];c[f+20>>2]=c[j+20>>2];c[k>>2]=(c[k>>2]|0)+1}c[j>>2]=u;c[j+4>>2]=v;h[j+8>>3]=l;h[j+16>>3]=m;i=w;return}while(0);if(d>>>0>=f>>>0){i=w;return}c[j+(d*24|0)>>2]=u;c[j+(d*24|0)+4>>2]=v;h[j+(d*24|0)+8>>3]=l;h[j+(d*24|0)+16>>3]=m;c[k>>2]=(c[k>>2]|0)+1;i=w;return}function rb(a,b,d,e,f,g,j,k,l){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0,u=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;F=i;i=i+32|0;E=F+24|0;D=F;c[E>>2]=0;m=g+-1|0;o=0;while(1){if((o|0)==(g|0))break;n=e+(o<<2)|0;q=o;while(1){p=q+1|0;if((q|0)==(m|0))break;qb(a,b,c[n>>2]|0,c[e+(p<<2)>>2]|0,l,f,E);q=p}o=o+1|0}x=f+16|0;y=f+4|0;z=f+8|0;m=g;v=0.0;w=1;a:while(1){u=m;while(1){m=m+-1|0;if(u>>>0<=w>>>0)break a;if(+h[x>>3]>=v){m=u;v=1.e+99;w=k;continue a}t=c[f>>2]|0;g=c[y>>2]|0;n=a+(t*2832|0)+2816|0;c[n>>2]=(c[n>>2]|0)+(c[a+(g*2832|0)+2816>>2]|0);n=0;while(1){if((n|0)==704)break;q=a+(t*2832|0)+(n<<2)|0;c[q>>2]=(c[q>>2]|0)+(c[a+(g*2832|0)+(n<<2)>>2]|0);n=n+1|0}h[a+(t*2832|0)+2824>>3]=+h[z>>3];o=b+(t<<2)|0;c[o>>2]=(c[o>>2]|0)+(c[b+(g<<2)>>2]|0);o=0;while(1){if((o|0)==(j|0)){o=0;break}n=d+(o<<2)|0;if((c[n>>2]|0)==(g|0))c[n>>2]=t;o=o+1|0}while(1){if(u>>>0<=o>>>0)break;n=e+(o<<2)|0;if((c[n>>2]|0)==(g|0)){A=22;break}o=o+1|0}if((A|0)==22){A=0;fc(n|0,e+(o+1<<2)|0,(u-o<<2)+-4|0)|0}p=c[E>>2]|0;n=0;q=0;while(1){if((q|0)==(p|0))break;o=f+(q*24|0)|0;if(((c[o>>2]|0)!=(t|0)?(B=c[f+(q*24|0)+4>>2]|0,(B|0)!=(t|0)):0)?(C=c[o>>2]|0,!((C|0)==(g|0)|(B|0)==(g|0))):0){r=+h[x>>3];s=+h[f+(q*24|0)+16>>3];if(r!=s)if(r>s)A=32;else A=33;else if(((c[y>>2]|0)-(c[f>>2]|0)|0)>>>0>(B-C|0)>>>0)A=32;else A=33;if((A|0)==32){A=0;c[D>>2]=c[f>>2];c[D+4>>2]=c[f+4>>2];c[D+8>>2]=c[f+8>>2];c[D+12>>2]=c[f+12>>2];c[D+16>>2]=c[f+16>>2];c[D+20>>2]=c[f+20>>2];c[f>>2]=c[o>>2];c[f+4>>2]=c[o+4>>2];c[f+8>>2]=c[o+8>>2];c[f+12>>2]=c[o+12>>2];c[f+16>>2]=c[o+16>>2];c[f+20>>2]=c[o+20>>2];o=f+(n*24|0)|0;c[o>>2]=c[D>>2];c[o+4>>2]=c[D+4>>2];c[o+8>>2]=c[D+8>>2];c[o+12>>2]=c[D+12>>2];c[o+16>>2]=c[D+16>>2];c[o+20>>2]=c[D+20>>2]}else if((A|0)==33){A=0;G=f+(n*24|0)|0;c[G>>2]=c[o>>2];c[G+4>>2]=c[o+4>>2];c[G+8>>2]=c[o+8>>2];c[G+12>>2]=c[o+12>>2];c[G+16>>2]=c[o+16>>2];c[G+20>>2]=c[o+20>>2]}n=n+1|0}q=q+1|0}c[E>>2]=n;n=0;while(1){if((n|0)==(m|0))break;qb(a,b,t,c[e+(n<<2)>>2]|0,l,f,E);n=n+1|0}u=u+-1|0}}i=F;return u|0}function sb(a,b,d,e,f,j,k){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;j=j|0;k=k|0;var l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0,v=0,w=0;w=i;i=i+2096|0;t=w;if((d|0)==(e|0)){i=w;return}u=e>>>0<d>>>0;v=u?d:e;u=u?e:d;d=c[b+(u<<2)>>2]|0;e=c[b+(v<<2)>>2]|0;b=d+e|0;s=+(d>>>0);if(d>>>0<256)r=+g[19516+(d<<2)>>2];else r=+Xb(s);q=+(e>>>0);if(e>>>0<256)p=+g[19516+(e<<2)>>2];else p=+Xb(q);n=+(b>>>0);if(b>>>0<256)m=+g[19516+(b<<2)>>2];else m=+Xb(n);l=+h[a+(u*2096|0)+2088>>3];o=+h[a+(v*2096|0)+2088>>3];n=(s*r+q*p-n*m)*.5-l-o;if(c[a+(u*2096|0)+2080>>2]|0){d=c[a+(v*2096|0)+2080>>2]|0;if(d){if(c[k>>2]|0){l=+h[j+16>>3];if(l<0.0)m=0.0;else m=l}else m=1.e+99;dc(t|0,a+(u*2096|0)|0,2096)|0;b=t+2080|0;c[b>>2]=(c[b>>2]|0)+d;d=0;while(1){if((d|0)==520)break;b=t+(d<<2)|0;c[b>>2]=(c[b>>2]|0)+(c[a+(v*2096|0)+(d<<2)>>2]|0);d=d+1|0}l=+Ya(t);if(!(l<m-n)){i=w;return}}}else l=o;m=n+l;d=c[k>>2]|0;do if(d){n=+h[j+16>>3];if(n!=m){if(!(n>m))break}else if(((c[j+4>>2]|0)-(c[j>>2]|0)|0)>>>0<=(v-u|0)>>>0)break;if(d>>>0<f>>>0){f=j+(d*24|0)|0;c[f>>2]=c[j>>2];c[f+4>>2]=c[j+4>>2];c[f+8>>2]=c[j+8>>2];c[f+12>>2]=c[j+12>>2];c[f+16>>2]=c[j+16>>2];c[f+20>>2]=c[j+20>>2];c[k>>2]=(c[k>>2]|0)+1}c[j>>2]=u;c[j+4>>2]=v;h[j+8>>3]=l;h[j+16>>3]=m;i=w;return}while(0);if(d>>>0>=f>>>0){i=w;return}c[j+(d*24|0)>>2]=u;c[j+(d*24|0)+4>>2]=v;h[j+(d*24|0)+8>>3]=l;h[j+(d*24|0)+16>>3]=m;c[k>>2]=(c[k>>2]|0)+1;i=w;return}function tb(a,b,d,e,f,g,j,k,l){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0,u=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;F=i;i=i+32|0;E=F+24|0;D=F;c[E>>2]=0;m=g+-1|0;o=0;while(1){if((o|0)==(g|0))break;n=e+(o<<2)|0;q=o;while(1){p=q+1|0;if((q|0)==(m|0))break;sb(a,b,c[n>>2]|0,c[e+(p<<2)>>2]|0,l,f,E);q=p}o=o+1|0}x=f+16|0;y=f+4|0;z=f+8|0;m=g;v=0.0;w=1;a:while(1){u=m;while(1){m=m+-1|0;if(u>>>0<=w>>>0)break a;if(+h[x>>3]>=v){m=u;v=1.e+99;w=k;continue a}t=c[f>>2]|0;g=c[y>>2]|0;n=a+(t*2096|0)+2080|0;c[n>>2]=(c[n>>2]|0)+(c[a+(g*2096|0)+2080>>2]|0);n=0;while(1){if((n|0)==520)break;q=a+(t*2096|0)+(n<<2)|0;c[q>>2]=(c[q>>2]|0)+(c[a+(g*2096|0)+(n<<2)>>2]|0);n=n+1|0}h[a+(t*2096|0)+2088>>3]=+h[z>>3];o=b+(t<<2)|0;c[o>>2]=(c[o>>2]|0)+(c[b+(g<<2)>>2]|0);o=0;while(1){if((o|0)==(j|0)){o=0;break}n=d+(o<<2)|0;if((c[n>>2]|0)==(g|0))c[n>>2]=t;o=o+1|0}while(1){if(u>>>0<=o>>>0)break;n=e+(o<<2)|0;if((c[n>>2]|0)==(g|0)){A=22;break}o=o+1|0}if((A|0)==22){A=0;fc(n|0,e+(o+1<<2)|0,(u-o<<2)+-4|0)|0}p=c[E>>2]|0;n=0;q=0;while(1){if((q|0)==(p|0))break;o=f+(q*24|0)|0;if(((c[o>>2]|0)!=(t|0)?(B=c[f+(q*24|0)+4>>2]|0,(B|0)!=(t|0)):0)?(C=c[o>>2]|0,!((C|0)==(g|0)|(B|0)==(g|0))):0){r=+h[x>>3];s=+h[f+(q*24|0)+16>>3];if(r!=s)if(r>s)A=32;else A=33;else if(((c[y>>2]|0)-(c[f>>2]|0)|0)>>>0>(B-C|0)>>>0)A=32;else A=33;if((A|0)==32){A=0;c[D>>2]=c[f>>2];c[D+4>>2]=c[f+4>>2];c[D+8>>2]=c[f+8>>2];c[D+12>>2]=c[f+12>>2];c[D+16>>2]=c[f+16>>2];c[D+20>>2]=c[f+20>>2];c[f>>2]=c[o>>2];c[f+4>>2]=c[o+4>>2];c[f+8>>2]=c[o+8>>2];c[f+12>>2]=c[o+12>>2];c[f+16>>2]=c[o+16>>2];c[f+20>>2]=c[o+20>>2];o=f+(n*24|0)|0;c[o>>2]=c[D>>2];c[o+4>>2]=c[D+4>>2];c[o+8>>2]=c[D+8>>2];c[o+12>>2]=c[D+12>>2];c[o+16>>2]=c[D+16>>2];c[o+20>>2]=c[D+20>>2]}else if((A|0)==33){A=0;G=f+(n*24|0)|0;c[G>>2]=c[o>>2];c[G+4>>2]=c[o+4>>2];c[G+8>>2]=c[o+8>>2];c[G+12>>2]=c[o+12>>2];c[G+16>>2]=c[o+16>>2];c[G+20>>2]=c[o+20>>2]}n=n+1|0}q=q+1|0}c[E>>2]=n;n=0;while(1){if((n|0)==(m|0))break;sb(a,b,t,c[e+(n<<2)>>2]|0,l,f,E);n=n+1|0}u=u+-1|0}}i=F;return u|0}function ub(b,f,h,j,k,l,m,n,o,p,q,r){b=b|0;f=f|0;h=h|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=o|0;p=p|0;q=q|0;r=r|0;var s=0,t=0,u=0,v=0,w=0,x=0,y=0.0,z=0.0,A=0,B=0,D=0.0,E=0.0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0;xa=i;i=i+2304|0;ta=xa+512|0;sa=xa;va=xa+2048|0;ua=xa+1536|0;w=f;A=h>>>0<98304?h:98304;B=c[q>>2]|0;ra=64-((aa(l|0)|0)^31)|0;if(!l)pa(405532,405401,464,405439);if(l>>>0>=2147483649)pa(405605,405401,465,405439);s=l+-1|0;if(s&l)pa(405630,405401,467,405439);qa=bc(16777215,-1,ra|0)|0;if((s|0)!=(qa|0))pa(405667,405401,469,405439);if(!h){if(!j)pa(405466,405401,472,405439);b=r+(B>>>3)|0;k=d[b>>0]|0;va=cc(1,0,B&7|0)|0;wa=C;va=k|va;k=b;a[k>>0]=va;a[k+1>>0]=va>>8;a[k+2>>0]=va>>16;a[k+3>>0]=va>>24;b=b+4|0;a[b>>0]=wa;a[b+1>>0]=wa>>8;a[b+2>>0]=wa>>16;a[b+3>>0]=wa>>24;b=(c[q>>2]|0)+1|0;c[q>>2]=b;wa=r+(b>>>3)|0;r=d[wa>>0]|0;b=cc(1,0,b&7|0)|0;k=C;b=r|b;r=wa;a[r>>0]=b;a[r+1>>0]=b>>8;a[r+2>>0]=b>>16;a[r+3>>0]=b>>24;wa=wa+4|0;a[wa>>0]=k;a[wa+1>>0]=k>>8;a[wa+2>>0]=k>>16;a[wa+3>>0]=k>>24;c[q>>2]=(c[q>>2]|0)+8&-8;i=xa;return}vb(A,0,q,r);x=r+((c[q>>2]|0)>>>3)|0;qa=d[x>>0]|0;s=x;a[s>>0]=qa;a[s+1>>0]=qa>>8;a[s+2>>0]=qa>>16;a[s+3>>0]=qa>>24;x=x+4|0;a[x>>0]=0;a[x+1>>0]=0;a[x+2>>0]=0;a[x+3>>0]=0;c[q>>2]=(c[q>>2]|0)+13;x=wb(b,f,A,va,ua,q,r)|0;s=0;while(1){l=c[o>>2]|0;if((s|7)>>>0>=l>>>0)break;ma=c[q>>2]|0;qa=r+(ma>>>3)|0;na=d[qa>>0]|0;ma=cc(d[p+(s>>>3)>>0]|0,0,ma&7|0)|0;oa=C;ma=na|ma;na=qa;a[na>>0]=ma;a[na+1>>0]=ma>>8;a[na+2>>0]=ma>>16;a[na+3>>0]=ma>>24;qa=qa+4|0;a[qa>>0]=oa;a[qa+1>>0]=oa>>8;a[qa+2>>0]=oa>>16;a[qa+3>>0]=oa>>24;c[q>>2]=(c[q>>2]|0)+8;s=s+8|0}v=l&7;s=d[p+(l>>>3)>>0]|0;l=c[q>>2]|0;t=r+(l>>>3)|0;u=d[t>>0]|0;qa=bc(s|0,0,v|0)|0;if(!((qa|0)==0&(C|0)==0))pa(406196,406218,54,406251);ca=cc(s|0,0,l&7|0)|0;$=C;ca=u|ca;_=t;ba=_;a[ba>>0]=ca;a[ba+1>>0]=ca>>8;a[ba+2>>0]=ca>>16;a[ba+3>>0]=ca>>24;_=_+4|0;a[_>>0]=$;a[_+1>>0]=$>>8;a[_+2>>0]=$>>16;a[_+3>>0]=$>>24;c[q>>2]=(c[q>>2]|0)+v;_=f;$=m+61|0;ba=n+122|0;ca=sa+84|0;da=m+64|0;ea=n+128|0;fa=sa+256|0;ga=m+39|0;ha=n+78|0;ia=sa+188|0;ja=sa+256|0;ka=m+62|0;la=n+124|0;ma=sa+88|0;na=m+63|0;oa=n+126|0;qa=sa+92|0;l=h;s=w;u=A;t=x;a:while(1){X=B+3|0;Y=t>>>0>980;T=s;V=u;v=s;W=u;b:while(1){dc(sa|0,17764,512)|0;U=T;t=U+V|0;Z=t;c:do if(V>>>0>15){w=V+-5|0;S=l+-16|0;S=U+(w>>>0<S>>>0?w:S)|0;w=U+1|0;h=w;u=h;h=h+4|0;u=d[u>>0]|d[u+1>>0]<<8|d[u+2>>0]<<16|d[u+3>>0]<<24;h=d[h>>0]|d[h+1>>0]<<8|d[h+2>>0]<<16|d[h+3>>0]<<24;M=-1;while(1){u=lc(u|0,h|0,-1124073472,1979815)|0;u=bc(u|0,C|0,ra|0)|0;K=v;if(K>>>0>=w>>>0){wa=24;break a}G=0-M|0;Q=w;F=32;while(1){H=Q;h=F;F=F+1|0;R=Q;P=R;R=R+4|0;R=lc(d[P>>0]|d[P+1>>0]<<8|d[P+2>>0]<<16|d[P+3>>0]<<24|0,d[R>>0]|d[R+1>>0]<<8|d[R+2>>0]<<16|d[R+3>>0]<<24|0,-1124073472,1979815)|0;R=bc(R|0,C|0,ra|0)|0;if((u|0)!=(R|0)){wa=26;break a}x=Q+(h>>>5)|0;if(x>>>0>S>>>0)break c;A=x;h=A;A=A+4|0;A=lc(d[h>>0]|d[h+1>>0]<<8|d[h+2>>0]<<16|d[h+3>>0]<<24|0,d[A>>0]|d[A+1>>0]<<8|d[A+2>>0]<<16|d[A+3>>0]<<24|0,-1124073472,1979815)|0;A=bc(A|0,C|0,ra|0)|0;h=Q+G|0;if((d[Q>>0]|d[Q+1>>0]<<8|d[Q+2>>0]<<16|d[Q+3>>0]<<24|0)==(d[h>>0]|d[h+1>>0]<<8|d[h+2>>0]<<16|d[h+3>>0]<<24|0)?((G|0)<0?(a[Q+4>>0]|0)==(a[Q+(4-M)>>0]|0):0):0){wa=30;break}u=k+(u<<2)|0;w=c[u>>2]|0;h=f+w|0;if((w|0)<0){wa=32;break a}if(h>>>0>=Q>>>0){wa=34;break a}c[u>>2]=H-_;if((d[Q>>0]|d[Q+1>>0]<<8|d[Q+2>>0]<<16|d[Q+3>>0]<<24|0)!=(d[h>>0]|d[h+1>>0]<<8|d[h+2>>0]<<16|d[h+3>>0]<<24|0)){u=A;Q=x;continue}if((a[Q+4>>0]|0)==(a[f+(w+4)>>0]|0))break;else{u=A;Q=x}}if((wa|0)==30){wa=0;c[k+(u<<2)>>2]=H-_}x=h;R=U+(V+-4)|0;u=0;w=Q+5|0;while(1){if(w>>>0>R>>>0){P=u;u=w;break}P=h+(u+5)|0;if((d[w>>0]|d[w+1>>0]<<8|d[w+2>>0]<<16|d[w+3>>0]<<24|0)!=(d[P>>0]|d[P+1>>0]<<8|d[P+2>>0]<<16|d[P+3>>0]<<24|0)){P=u;u=w;break}u=u+4|0;w=w+4|0}while(1){if(u>>>0>=t>>>0)break;if((a[h+(P+5)>>0]|0)!=(a[u>>0]|0))break;P=P+1|0;u=u+1|0}L=P+5|0;I=H-x|0;J=H-v|0;N=Q+L|0;O=N;d:do if(L){x=L;A=Q;while(1){u=a[A>>0]|0;w=a[h>>0]|0;if(u<<24>>24!=w<<24>>24)break;x=x+-1|0;if(!x)break d;else{A=A+1|0;h=h+1|0}}if(u<<24>>24!=w<<24>>24){wa=48;break a}}while(0);do if(J>>>0>=6210){if(!(((v-s|0)*50|0)>>>0>J>>>0|Y^1)){wa=84;break b}if(J>>>0<22594){u=a[ka>>0]|0;v=e[la>>1]|0;h=c[q>>2]|0;w=r+(h>>>3)|0;x=d[w>>0]|0;H=bc(v|0,0,u&255|0)|0;if(!((H|0)==0&(C|0)==0)){wa=87;break a}if((u&255)>=57){wa=89;break a}H=cc(v|0,0,h&7|0)|0;h=C;H=x|H;v=w;w=v;a[w>>0]=H;a[w+1>>0]=H>>8;a[w+2>>0]=H>>16;a[w+3>>0]=H>>24;v=v+4|0;a[v>>0]=h;a[v+1>>0]=h>>8;a[v+2>>0]=h>>16;a[v+3>>0]=h>>24;u=(c[q>>2]|0)+(u&255)|0;c[q>>2]=u;v=J+-6210|0;h=r+(u>>>3)|0;w=d[h>>0]|0;if(!((v&-16384|0)==0&0==0)){wa=91;break a}F=cc(v|0,0,u&7|0)|0;H=C;F=w|F;A=h;G=A;a[G>>0]=F;a[G+1>>0]=F>>8;a[G+2>>0]=F>>16;a[G+3>>0]=F>>24;A=A+4|0;a[A>>0]=H;a[A+1>>0]=H>>8;a[A+2>>0]=H>>16;a[A+3>>0]=H>>24;c[q>>2]=(c[q>>2]|0)+14;c[ma>>2]=(c[ma>>2]|0)+1;A=0;break}else{u=a[na>>0]|0;v=e[oa>>1]|0;h=c[q>>2]|0;w=r+(h>>>3)|0;x=d[w>>0]|0;H=bc(v|0,0,u&255|0)|0;if(!((H|0)==0&(C|0)==0)){wa=94;break a}if((u&255)>=57){wa=96;break a}H=cc(v|0,0,h&7|0)|0;h=C;H=x|H;v=w;w=v;a[w>>0]=H;a[w+1>>0]=H>>8;a[w+2>>0]=H>>16;a[w+3>>0]=H>>24;v=v+4|0;a[v>>0]=h;a[v+1>>0]=h>>8;a[v+2>>0]=h>>16;a[v+3>>0]=h>>24;u=(c[q>>2]|0)+(u&255)|0;c[q>>2]=u;v=J+-22594|0;h=r+(u>>>3)|0;w=d[h>>0]|0;if(!((v&-16777216|0)==0&0==0)){wa=98;break a}F=cc(v|0,0,u&7|0)|0;H=C;F=w|F;A=h;G=A;a[G>>0]=F;a[G+1>>0]=F>>8;a[G+2>>0]=F>>16;a[G+3>>0]=F>>24;A=A+4|0;a[A>>0]=H;a[A+1>>0]=H>>8;a[A+2>>0]=H>>16;a[A+3>>0]=H>>24;c[q>>2]=(c[q>>2]|0)+24;c[qa>>2]=(c[qa>>2]|0)+1;A=0;break}}else{if(J>>>0<6){u=J+40|0;v=a[m+u>>0]|0;h=e[n+(u<<1)>>1]|0;w=c[q>>2]|0;x=r+(w>>>3)|0;A=d[x>>0]|0;H=bc(h|0,0,v&255|0)|0;if(!((H|0)==0&(C|0)==0)){wa=52;break a}if((v&255)>=57){wa=54;break a}F=cc(h|0,0,w&7|0)|0;H=C;F=A|F;A=x;G=A;a[G>>0]=F;a[G+1>>0]=F>>8;a[G+2>>0]=F>>16;a[G+3>>0]=F>>24;A=A+4|0;a[A>>0]=H;a[A+1>>0]=H>>8;a[A+2>>0]=H>>16;a[A+3>>0]=H>>24;c[q>>2]=(c[q>>2]|0)+(v&255);A=sa+(u<<2)|0;c[A>>2]=(c[A>>2]|0)+1;A=0;break}if(J>>>0<130){A=J+-2|0;G=((aa(A|0)|0)^31)+-1|0;F=A>>>G;H=(G<<1)+F+42|0;u=a[m+H>>0]|0;v=e[n+(H<<1)>>1]|0;h=c[q>>2]|0;w=r+(h>>>3)|0;x=d[w>>0]|0;ya=bc(v|0,0,u&255|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=58;break a}if((u&255)>=57){wa=60;break a}ya=cc(v|0,0,h&7|0)|0;v=C;ya=x|ya;h=w;a[h>>0]=ya;a[h+1>>0]=ya>>8;a[h+2>>0]=ya>>16;a[h+3>>0]=ya>>24;w=w+4|0;a[w>>0]=v;a[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+-66|0;F=(aa(A|0)|0)^31;G=F+50|0;u=a[m+G>>0]|0;v=e[n+(G<<1)>>1]|0;h=c[q>>2]|0;w=r+(h>>>3)|0;x=d[w>>0]|0;ya=bc(v|0,0,u&255|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=68;break a}if((u&255)>=57){wa=70;break a}ya=cc(v|0,0,h&7|0)|0;v=C;ya=x|ya;h=w;a[h>>0]=ya;a[h+1>>0]=ya>>8;a[h+2>>0]=ya>>16;a[h+3>>0]=ya>>24;w=w+4|0;a[w>>0]=v;a[w+1>>0]=v>>8;a[w+2>>0]=v>>16;a[w+3>>0]=v>>24;w=(c[q>>2]|0)+(u&255)|0;c[q>>2]=w;u=A-(1<<F)|0;v=r+(w>>>3)|0;h=d[v>>0]|0;ya=bc(u|0,0,F|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=72;break a}if(F>>>0>=57){wa=74;break a}x=cc(u|0,0,w&7|0)|0;ya=C;x=h|x;A=v;H=A;a[H>>0]=x;a[H+1>>0]=x>>8;a[H+2>>0]=x>>16;a[H+3>>0]=x>>24;A=A+4|0;a[A>>0]=ya;a[A+1>>0]=ya>>8;a[A+2>>0]=ya>>16;a[A+3>>0]=ya>>24;c[q>>2]=(c[q>>2]|0)+F;A=sa+(G<<2)|0;c[A>>2]=(c[A>>2]|0)+1;A=0}while(0);while(1){if(A>>>0>=J>>>0)break;v=d[K+A>>0]|0;u=a[va+v>>0]|0;v=e[ua+(v<<1)>>1]|0;h=c[q>>2]|0;w=r+(h>>>3)|0;x=d[w>>0]|0;ya=bc(v|0,0,u&255|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=102;break a}if((u&255)>=57){wa=104;break a}F=cc(v|0,0,h&7|0)|0;H=C;F=x|F;ya=w;G=ya;a[G>>0]=F;a[G+1>>0]=F>>8;a[G+2>>0]=F>>16;a[G+3>>0]=F>>24;ya=ya+4|0;a[ya>>0]=H;a[ya+1>>0]=H>>8;a[ya+2>>0]=H>>16;a[ya+3>>0]=H>>24;c[q>>2]=(c[q>>2]|0)+(u&255);A=A+1|0}if((I|0)==(M|0)){u=a[da>>0]|0;v=e[ea>>1]|0;h=c[q>>2]|0;w=r+(h>>>3)|0;x=d[w>>0]|0;ya=bc(v|0,0,u&255|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=108;break a}if((u&255)>=57){wa=110;break a}J=cc(v|0,0,h&7|0)|0;ya=C;J=x|J;I=w;K=I;a[K>>0]=J;a[K+1>>0]=J>>8;a[K+2>>0]=J>>16;a[K+3>>0]=J>>24;I=I+4|0;a[I>>0]=ya;a[I+1>>0]=ya>>8;a[I+2>>0]=ya>>16;a[I+3>>0]=ya>>24;c[q>>2]=(c[q>>2]|0)+(u&255);c[fa>>2]=(c[fa>>2]|0)+1;I=M}else{A=I+3|0;G=((aa(A|0)|0)^31)+-1|0;F=A>>>G&1;H=((G<<1)+-2|F)+80|0;u=a[m+H>>0]|0;v=e[n+(H<<1)>>1]|0;h=c[q>>2]|0;w=r+(h>>>3)|0;x=d[w>>0]|0;ya=bc(v|0,0,u&255|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=113;break a}if((u&255)>=57){wa=115;break a}ya=cc(v|0,0,h&7|0)|0;v=C;ya=x|ya;h=w;a[h>>0]=ya;a[h+1>>0]=ya>>8;a[h+2>>0]=ya>>16;a[h+3>>0]=ya>>24;w=w+4|0;a[w>>0]=v;a[w+1>>0]=v>>8;a[w+2>>0]=v>>16;a[w+3>>0]=v>>24;w=(c[q>>2]|0)+(u&255)|0;c[q>>2]=w;u=A-((F|2)<<G)|0;v=r+(w>>>3)|0;h=d[v>>0]|0;ya=bc(u|0,0,G|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=117;break a}if(G>>>0>=57){wa=119;break a}J=cc(u|0,0,w&7|0)|0;M=C;J=h|J;ya=v;K=ya;a[K>>0]=J;a[K+1>>0]=J>>8;a[K+2>>0]=J>>16;a[K+3>>0]=J>>24;ya=ya+4|0;a[ya>>0]=M;a[ya+1>>0]=M>>8;a[ya+2>>0]=M>>16;a[ya+3>>0]=M>>24;c[q>>2]=(c[q>>2]|0)+G;ya=sa+(H<<2)|0;c[ya>>2]=(c[ya>>2]|0)+1}do if(L>>>0<12){u=P+1|0;v=a[m+u>>0]|0;h=e[n+(u<<1)>>1]|0;w=c[q>>2]|0;x=r+(w>>>3)|0;A=d[x>>0]|0;ya=bc(h|0,0,v&255|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=123;break a}if((v&255)>=57){wa=125;break a}K=cc(h|0,0,w&7|0)|0;M=C;K=A|K;ya=x;L=ya;a[L>>0]=K;a[L+1>>0]=K>>8;a[L+2>>0]=K>>16;a[L+3>>0]=K>>24;ya=ya+4|0;a[ya>>0]=M;a[ya+1>>0]=M>>8;a[ya+2>>0]=M>>16;a[ya+3>>0]=M>>24;c[q>>2]=(c[q>>2]|0)+(v&255);ya=sa+(u<<2)|0;c[ya>>2]=(c[ya>>2]|0)+1}else{if(L>>>0<72){A=P+-3|0;G=((aa(A|0)|0)^31)+-1|0;F=A>>>G;H=(G<<1)+F+4|0;u=a[m+H>>0]|0;v=e[n+(H<<1)>>1]|0;h=c[q>>2]|0;w=r+(h>>>3)|0;x=d[w>>0]|0;ya=bc(v|0,0,u&255|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=129;break a}if((u&255)>=57){wa=131;break a}ya=cc(v|0,0,h&7|0)|0;v=C;ya=x|ya;h=w;a[h>>0]=ya;a[h+1>>0]=ya>>8;a[h+2>>0]=ya>>16;a[h+3>>0]=ya>>24;w=w+4|0;a[w>>0]=v;a[w+1>>0]=v>>8;a[w+2>>0]=v>>16;a[w+3>>0]=v>>24;w=(c[q>>2]|0)+(u&255)|0;c[q>>2]=w;u=A-(F<<G)|0;v=r+(w>>>3)|0;h=d[v>>0]|0;ya=bc(u|0,0,G|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=133;break a}if(G>>>0>=57){wa=135;break a}K=cc(u|0,0,w&7|0)|0;M=C;K=h|K;ya=v;L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ya+2>>0]=M>>16;a[ya+3>>0]=M>>24;c[q>>2]=(c[q>>2]|0)+(v&255);ya=sa+(F<<2)|0;c[ya>>2]=(c[ya>>2]|0)+1;c[ja>>2]=(c[ja>>2]|0)+1;break}if(L>>>0>=2120){u=a[ga>>0]|0;v=e[ha>>1]|0;h=c[q>>2]|0;w=r+(h>>>3)|0;x=d[w>>0]|0;ya=bc(v|0,0,u&255|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=162;break a}if((u&255)>=57){wa=164;break a}ya=cc(v|0,0,h&7|0)|0;h=C;ya=x|ya;v=w;w=v;a[w>>0]=ya;a[w+1>>0]=ya>>8;a[w+2>>0]=ya>>16;a[w+3>>0]=ya>>24;v=v+4|0;a[v>>0]=h;a[v+1>>0]=h>>8;a[v+2>>0]=h>>16;a[v+3>>0]=h>>24;u=(c[q>>2]|0)+(u&255)|0;c[q>>2]=u;v=P+-2115|0;h=r+(u>>>3)|0;w=d[h>>0]|0;if(!((v&-16777216|0)==0&0==0)){wa=166;break a}u=cc(v|0,0,u&7|0)|0;v=C;w=w|u;u=h;h=u;a[h>>0]=w;a[h+1>>0]=w>>8;a[h+2>>0]=w>>16;a[h+3>>0]=w>>24;u=u+4|0;a[u>>0]=v;a[u+1>>0]=v>>8;a[u+2>>0]=v>>16;a[u+3>>0]=v>>24;u=(c[q>>2]|0)+24|0;c[q>>2]=u;v=a[da>>0]|0;h=e[ea>>1]|0;w=r+(u>>>3)|0;x=d[w>>0]|0;ya=bc(h|0,0,v&255|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=168;break a}if((v&255)>=57){wa=170;break a}K=cc(h|0,0,u&7|0)|0;M=C;K=x|K;ya=w;L=ya;a[L>>0]=K;a[L+1>>0]=K>>8;a[L+2>>0]=K>>16;a[L+3>>0]=K>>24;ya=ya+4|0;a[ya>>0]=M;a[ya+1>>0]=M>>8;a[ya+2>>0]=M>>16;a[ya+3>>0]=M>>24;c[q>>2]=(c[q>>2]|0)+(v&255);c[ia>>2]=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]=(c[ya>>2]|0)+1;c[ja>>2]=(c[ja>>2]|0)+1}while(0);if(N>>>0>=S>>>0){v=O;break c}v=Q+(P+2)|0;ya=v;ya=d[ya>>0]|d[ya+1>>0]<<8|d[ya+2>>0]<<16|d[ya+3>>0]<<24;v=v+4|0;v=d[v>>0]|d[v+1>>0]<<8|d[v+2>>0]<<16|d[v+3>>0]<<24;Q=lc(ya|0,v|0,-1124073472,1979815)|0;Q=bc(Q|0,C|0,ra|0)|0;x=bc(ya|0,v|0,24)|0;x=lc(x|0,C|0,-1124073472,1979815)|0;x=bc(x|0,C|0,ra|0)|0;A=N-_|0;c[k+(Q<<2)>>2]=A+-3;Q=bc(ya|0,v|0,8)|0;Q=lc(Q|0,C|0,-1124073472,1979815)|0;Q=bc(Q|0,C|0,ra|0)|0;c[k+(Q<<2)>>2]=A+-2;v=bc(ya|0,v|0,16)|0;v=lc(v|0,C|0,-1124073472,1979815)|0;v=bc(v|0,C|0,ra|0)|0;c[k+(v<<2)>>2]=A+-1;x=k+(x<<2)|0;v=c[x>>2]|0;c[x>>2]=A;x=I;A=O;while(1){H=f+v|0;ya=A;u=A;if((d[ya>>0]|d[ya+1>>0]<<8|d[ya+2>>0]<<16|d[ya+3>>0]<<24|0)!=(d[H>>0]|d[H+1>>0]<<8|d[H+2>>0]<<16|d[H+3>>0]<<24|0))break;if((a[u+4>>0]|0)!=(a[f+(v+4)>>0]|0))break;w=v+5|0;v=0;h=u+5|0;while(1){if(h>>>0>R>>>0)break;ya=f+(w+v)|0;if((d[h>>0]|d[h+1>>0]<<8|d[h+2>>0]<<16|d[h+3>>0]<<24|0)!=(d[ya>>0]|d[ya+1>>0]<<8|d[ya+2>>0]<<16|d[ya+3>>0]<<24|0))break;v=v+4|0;h=h+4|0}while(1){if(h>>>0>=t>>>0)break;if((a[f+(w+v)>>0]|0)!=(a[h>>0]|0))break;v=v+1|0;h=h+1|0}G=v+5|0;K=u+G|0;M=K;L=A-H|0;do if(!G)wa=189;else{A=G;F=u;x=H;while(1){h=a[F>>0]|0;w=a[x>>0]|0;if(h<<24>>24!=w<<24>>24){wa=186;break}A=A+-1|0;if(!A)break;else{F=F+1|0;x=x+1|0}}if((wa|0)==186?(wa=0,h<<24>>24!=w<<24>>24):0){wa=187;break a}if(G>>>0<10){wa=189;break}if(G>>>0<134){G=v+-1|0;I=((aa(G|0)|0)^31)+-1|0;H=G>>>I;J=(I<<1)+H+20|0;h=a[m+J>>0]|0;w=e[n+(J<<1)>>1]|0;x=c[q>>2]|0;A=r+(x>>>3)|0;F=d[A>>0]|0;ya=bc(w|0,0,h&255|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=196;break a}if((h&255)>=57){wa=198;break a}ya=cc(w|0,0,x&7|0)|0;w=C;ya=F|ya;x=A;a[x>>0]=ya;a[x+1>>0]=ya>>8;a[x+2>>0]=ya>>16;a[x+3>>0]=ya>>24;A=A+4|0;a[A>>0]=w;a[A+1>>0]=w>>8;a[A+2>>0]=w>>16;a[A+3>>0]=w>>24;A=(c[q>>2]|0)+(h&255)|0;c[q>>2]=A;h=G-(H<<I)|0;w=r+(A>>>3)|0;x=d[w>>0]|0;ya=bc(h|0,0,I|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=200;break a}if(I>>>0>=57){wa=202;break a}O=cc(h|0,0,A&7|0)|0;Q=C;O=x|O;ya=w;P=ya;a[P>>0]=O;a[P+1>>0]=O>>8;a[P+2>>0]=O>>16;a[P+3>>0]=O>>24;ya=ya+4|0;a[ya>>0]=Q;a[ya+1>>0]=Q>>8;a[ya+2>>0]=Q>>16;a[ya+3>>0]=Q>>24;c[q>>2]=(c[q>>2]|0)+I;ya=sa+(J<<2)|0;c[ya>>2]=(c[ya>>2]|0)+1;break}if(G>>>0>=2118){h=a[ga>>0]|0;w=e[ha>>1]|0;x=c[q>>2]|0;A=r+(x>>>3)|0;F=d[A>>0]|0;ya=bc(w|0,0,h&255|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=215;break a}if((h&255)>=57){wa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==0)){wa=226;break a}if(I>>>0>=57){wa=228;break a}O=cc(h|0,0,A&7|0)|0;Q=C;O=x|O;ya=w;P=ya;a[P>>0]=O;a[P+1>>0]=O>>8;a[P+2>>0]=O>>16;a[P+3>>0]=O>>24;ya=ya+4|0;a[ya>>0]=Q;a[ya+1>>0]=Q>>8;a[ya+2>>0]=Q>>16;a[ya+3>>0]=Q>>24;c[q>>2]=(c[q>>2]|0)+I;ya=sa+(J<<2)|0;c[ya>>2]=(c[ya>>2]|0)+1;if(K>>>0>=S>>>0){v=M;break c}v=u+(v+2)|0;ya=v;ya=d[ya>>0]|d[ya+1>>0]<<8|d[ya+2>>0]<<16|d[ya+3>>0]<<24;v=v+4|0;v=d[v>>0]|d[v+1>>0]<<8|d[v+2>>0]<<16|d[v+3>>0]<<24;Q=lc(ya|0,v|0,-1124073472,1979815)|0;Q=bc(Q|0,C|0,ra|0)|0;x=bc(ya|0,v|0,24)|0;x=lc(x|0,C|0,-1124073472,1979815)|0;x=bc(x|0,C|0,ra|0)|0;A=K-_|0;c[k+(Q<<2)>>2]=A+-3;Q=bc(ya|0,v|0,8)|0;Q=lc(Q|0,C|0,-1124073472,1979815)|0;Q=bc(Q|0,C|0,ra|0)|0;c[k+(Q<<2)>>2]=A+-2;v=bc(ya|0,v|0,16)|0;v=lc(v|0,C|0,-1124073472,1979815)|0;v=bc(v|0,C|0,ra|0)|0;c[k+(v<<2)>>2]=A+-1;x=k+(x<<2)|0;v=c[x>>2]|0;c[x>>2]=A;x=L;A=M}w=u+1|0;h=w;u=h;h=h+4|0;u=d[u>>0]|d[u+1>>0]<<8|d[u+2>>0]<<16|d[u+3>>0]<<24;h=d[h>>0]|d[h+1>>0]<<8|d[h+2>>0]<<16|d[h+3>>0]<<24;M=x;v=A}}while(0);G=v;if(G>>>0>t>>>0){wa=233;break a}h=l-V|0;w=h>>>0<65536?h:65536;if((l|0)==(V|0)){l=0;wa=254;break}x=W+w|0;if(x>>>0>=1048577){l=h;wa=254;break}ac(ta|0,0,1024)|0;l=0;while(1){if(l>>>0>=w>>>0)break;ya=ta+(d[U+(V+l)>>0]<<2)|0;c[ya>>2]=(c[ya>>2]|0)+1;l=l+43|0}ya=w+42|0;l=(ya>>>0)/43|0;if(ya>>>0<11008){z=+(l>>>0);y=+g[19516+(l<<2)>>2]}else{y=+(l>>>0);z=y;y=+Xb(y)}E=(y+.5)*z+200.0;u=0;while(1){if((u|0)==256)break;l=c[ta+(u<<2)>>2]|0;z=+(l>>>0);D=+(d[va+u>>0]|0);if(l>>>0<256)y=+g[19516+(l<<2)>>2];else y=+Xb(z);E=E-z*(D+y);u=u+1|0}if(!(E>=0.0)){l=h;wa=254;break}if(W>>>0<=65536){wa=250;break a}l=20;t=x+-1|0;u=X;while(1){if(!l){l=h;T=Z;V=w;W=x;continue b}V=u&7;ya=8-V|0;ya=l>>>0<ya>>>0?l:ya;W=r+(u>>>3)|0;a[W>>0]=(t&(1<<ya)+-1)<<V|d[W>>0]&(-1<<V+ya|(1<<V)+255);l=l-ya|0;t=t>>>ya;u=u+ya|0}}e:do if((wa|0)==84){wa=0;ya=H-s|0;Z=r+(B>>>3)|0;a[Z>>0]=d[Z>>0]&(1<<(B&7))+255;c[q>>2]=B;vb(ya,1,q,r);Z=(c[q>>2]|0)+7|0;c[q>>2]=Z&-8;dc(r+(Z>>>3)|0,s|0,ya|0)|0;s=(c[q>>2]|0)+(ya<<3)|0;c[q>>2]=s;a[r+(s>>>3)>>0]=0;l=l+(T-H)|0;s=H}else if((wa|0)==254){wa=0;if(G>>>0<t>>>0){F=t-v|0;if(F>>>0>=6210){if(!(((v-s|0)*50|0)>>>0>F>>>0|Y^1)){ya=t-s|0;Y=r+(B>>>3)|0;a[Y>>0]=d[Y>>0]&(1<<(B&7))+255;c[q>>2]=B;vb(ya,1,q,r);Y=(c[q>>2]|0)+7|0;c[q>>2]=Y&-8;dc(r+(Y>>>3)|0,s|0,ya|0)|0;s=(c[q>>2]|0)+(ya<<3)|0;c[q>>2]=s;a[r+(s>>>3)>>0]=0;s=Z;break}if(F>>>0<22594){s=a[ka>>0]|0;t=e[la>>1]|0;u=c[q>>2]|0;v=r+(u>>>3)|0;h=d[v>>0]|0;ya=bc(t|0,0,s&255|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=299;break a}if((s&255)>=57){wa=301;break a}ya=cc(t|0,0,u&7|0)|0;u=C;ya=h|ya;t=v;v=t;a[v>>0]=ya;a[v+1>>0]=ya>>8;a[v+2>>0]=ya>>16;a[v+3>>0]=ya>>24;t=t+4|0;a[t>>0]=u;a[t+1>>0]=u>>8;a[t+2>>0]=u>>16;a[t+3>>0]=u>>24;s=(c[q>>2]|0)+(s&255)|0;c[q>>2]=s;t=F+-6210|0;u=r+(s>>>3)|0;v=d[u>>0]|0;if(!((t&-16384|0)==0&0==0)){wa=303;break a}X=cc(t|0,0,s&7|0)|0;ya=C;X=v|X;w=u;Y=w;a[Y>>0]=X;a[Y+1>>0]=X>>8;a[Y+2>>0]=X>>16;a[Y+3>>0]=X>>24;w=w+4|0;a[w>>0]=ya;a[w+1>>0]=ya>>8;a[w+2>>0]=ya>>16;a[w+3>>0]=ya>>24;c[q>>2]=(c[q>>2]|0)+14;c[ma>>2]=(c[ma>>2]|0)+1;w=0}else{s=a[na>>0]|0;t=e[oa>>1]|0;u=c[q>>2]|0;v=r+(u>>>3)|0;h=d[v>>0]|0;ya=bc(t|0,0,s&255|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=306;break a}if((s&255)>=57){wa=308;break a}ya=cc(t|0,0,u&7|0)|0;u=C;ya=h|ya;t=v;v=t;a[v>>0]=ya;a[v+1>>0]=ya>>8;a[v+2>>0]=ya>>16;a[v+3>>0]=ya>>24;t=t+4|0;a[t>>0]=u;a[t+1>>0]=u>>8;a[t+2>>0]=u>>16;a[t+3>>0]=u>>24;s=(c[q>>2]|0)+(s&255)|0;c[q>>2]=s;t=F+-22594|0;u=r+(s>>>3)|0;v=d[u>>0]|0;if(!((t&-16777216|0)==0&0==0)){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z;break e}t=d[G+w>>0]|0;s=a[va+t>>0]|0;t=e[ua+(t<<1)>>1]|0;u=c[q>>2]|0;v=r+(u>>>3)|0;h=d[v>>0]|0;ya=bc(t|0,0,s&255|0)|0;if(!((ya|0)==0&(C|0)==0)){wa=291;break a}if((s&255)>=57){wa=293;break a}W=cc(t|0,0,u&7|0)|0;Y=C;W=h|W;ya=v;X=ya;a[X>>0]=W;a[X+1>>0]=W>>8;a[X+2>>0]=W>>16;a[X+3>>0]=W>>24;ya=ya+4|0;a[ya>>0]=Y;a[ya+1>>0]=Y>>8;a[ya+2>>0]=Y>>16;a[ya+3>>0]=Y>>24;c[q>>2]=(c[q>>2]|0)+(s&255);w=w+1|0}}else s=Z}while(0);if(!l){wa=320;break}u=l>>>0<98304?l:98304;B=c[q>>2]|0;vb(u,0,q,r);t=r+((c[q>>2]|0)>>>3)|0;Z=d[t>>0]|0;ya=t;a[ya>>0]=Z;a[ya+1>>0]=Z>>8;a[ya+2>>0]=Z>>16;a[ya+3>>0]=Z>>24;t=t+4|0;a[t>>0]=0;a[t+1>>0]=0;a[t+2>>0]=0;a[t+3>>0]=0;c[q>>2]=(c[q>>2]|0)+13;t=wb(b,s,u,va,ua,q,r)|0;xb(sa,m,n,q,r)}switch(wa|0){case 24:{pa(405740,405401,539,405439);break}case 26:{pa(405474,405401,544,405439);break}case 32:{pa(405779,405401,559,405439);break}case 34:{pa(405800,405401,560,405439);break}case 48:{pa(405815,405401,579,405439);break}case 52:{pa(406196,406218,54,406251);break}case 54:{pa(406267,406218,55,406251);break}case 58:{pa(406196,406218,54,406251);break}case 60:{pa(406267,406218,55,406251);break}case 62:{pa(406196,406218,54,406251);break}case 64:{pa(406267,406218,55,406251);break}case 68:{pa(406196,406218,54,406251);break}case 70:{pa(406267,406218,55,406251);break}case 72:{pa(406196,406218,54,406251);break}case 74:{pa(406267,406218,55,406251);break}case 77:{pa(406196,406218,54,406251);break}case 79:{pa(406267,406218,55,406251);break}case 81:{pa(406196,406218,54,406251);break}case 87:{pa(406196,406218,54,406251);break}case 89:{pa(406267,406218,55,406251);break}case 91:{pa(406196,406218,54,406251);break}case 94:{pa(406196,406218,54,406251);break}case 96:{pa(406267,406218,55,406251);break}case 98:{pa(406196,406218,54,406251);break}case 102:{pa(406196,406218,54,406251);break}case 104:{pa(406267,406218,55,406251);break}case 108:{pa(406196,406218,54,406251);break}case 110:{pa(406267,406218,55,406251);break}case 113:{pa(406196,406218,54,406251);break}case 115:{pa(406267,406218,55,406251);break}case 117:{pa(406196,406218,54,406251);break}case 119:{pa(406267,406218,55,406251);break}case 123:{pa(406196,406218,54,406251);break}case 125:{pa(406267,406218,55,406251);break}case 129:{pa(406196,406218,54,406251);break}case 131:{pa(406267,406218,55,406251);break}case 133:{pa(406196,406218,54,406251);break}case 135:{pa(406267,406218,55,406251);break}case 139:{pa(406196,406218,54,406251);break}case 141:{pa(406267,406218,55,406251);break}case 143:{pa(406196,406218,54,406251);break}case 145:{pa(406267,406218,55,406251);break}case 149:{pa(406196,406218,54,406251);break}case 151:{pa(406267,406218,55,406251);break}case 153:{pa(406196,406218,54,406251);break}case 155:{pa(406267,406218,55,406251);break}case 157:{pa(406196,406218,54,406251);break}case 159:{pa(406267,406218,55,406251);break}case 162:{pa(406196,406218,54,406251);break}case 164:{pa(406267,406218,55,406251);break}case 166:{pa(406196,406218,54,406251);break}case 168:{pa(406196,406218,54,406251);break}case 170:{pa(406267,406218,55,406251);break}case 187:{pa(405815,405401,638,405439);break}case 190:{pa(406196,406218,54,406251);break}case 192:{pa(406267,406218,55,406251);break}case 196:{pa(406196,406218,54,406251);break}case 198:{pa(406267,406218,55,406251);break}case 200:{pa(406196,406218,54,406251);break}case 202:{pa(406267,406218,55,406251);break}case 206:{pa(406196,406218,54,406251);break}case 208:{pa(406267,406218,55,406251);break}case 210:{pa(406196,406218,54,406251);break}case 212:{pa(406267,406218,55,406251);break}case 215:{pa(406196,406218,54,406251);break}case 217:{pa(406267,406218,55,406251);break}case 219:{pa(406196,406218,54,406251);break}case 222:{pa(406196,406218,54,406251);break}case 224:{pa(406267,406218,55,406251);break}case 226:{pa(406196,406218,54,406251);break}case 228:{pa(406267,406218,55,406251);break}case 233:{pa(405853,405401,671,405439);break}case 250:{pa(405503,405401,681,405439);break}case 258:{pa(406196,406218,54,406251);break}case 260:{pa(406267,406218,55,406251);break}case 264:{pa(406196,406218,54,406251);break}case 266:{pa(406267,406218,55,406251);break}case 268:{pa(406196,406218,54,406251);break}case 270:{pa(406267,406218,55,406251);break}case 274:{pa(406196,406218,54,406251);break}case 276:{pa(406267,406218,55,406251);break}case 278:{pa(406196,406218,54,406251);break}case 280:{pa(406267,406218,55,406251);break}case 283:{pa(406196,406218,54,406251);break}case 285:{pa(406267,406218,55,406251);break}case 287:{pa(406196,406218,54,406251);break}case 291:{pa(406196,406218,54,406251);break}case 293:{pa(406267,406218,55,406251);break}case 299:{pa(406196,406218,54,406251);break}case 301:{pa(406267,406218,55,406251);break}case 303:{pa(406196,406218,54,406251);break}case 306:{pa(406196,406218,54,406251);break}case 308:{pa(406267,406218,55,406251);break}case 310:{pa(406196,406218,54,406251);break}case 314:{pa(406196,406218,54,406251);break}case 316:{pa(406267,406218,55,406251);break}case 320:if(j){b=c[q>>2]|0;wa=r+(b>>>3)|0;k=d[wa>>0]|0;b=cc(1,0,b&7|0)|0;ya=C;b=k|b;k=wa;a[k>>0]=b;a[k+1>>0]=b>>8;a[k+2>>0]=b>>16;a[k+3>>0]=b>>24;wa=wa+4|0;a[wa>>0]=ya;a[wa+1>>0]=ya>>8;a[wa+2>>0]=ya>>16;a[wa+3>>0]=ya>>24;wa=(c[q>>2]|0)+1|0;c[q>>2]=wa;ya=r+(wa>>>3)|0;k=d[ya>>0]|0;r=cc(1,0,wa&7|0)|0;wa=C;r=k|r;k=ya;a[k>>0]=r;a[k+1>>0]=r>>8;a[k+2>>0]=r>>16;a[k+3>>0]=r>>24;ya=ya+4|0;a[ya>>0]=wa;a[ya+1>>0]=wa>>8;a[ya+2>>0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=i;i=k;a[i>>0]=j;a[i+1>>0]=j>>8;a[i+2>>0]=j>>16;a[i+3>>0]=j>>24;k=k+4|0;a[k>>0]=h;a[k+1>>0]=h>>8;a[k+2>>0]=h>>16;a[k+3>>0]=h>>24;k=(c[f>>2]|0)+2|0;c[f>>2]=k;h=b+-1|0;i=g+(k>>>3)|0;j=d[i>>0]|0;if(!((h&-1048576|0)==0&0==0))pa(406196,406218,54,406251);h=cc(h|0,0,k&7|0)|0;b=C;h=j|h;k=i;j=k;a[j>>0]=h;a[j+1>>0]=h>>8;a[j+2>>0]=h>>16;a[j+3>>0]=h>>24;k=k+4|0;a[k>>0]=b;a[k+1>>0]=b>>8;a[k+2>>0]=b>>16;a[k+3>>0]=b>>24;k=(c[f>>2]|0)+20|0;c[f>>2]=k;e=e&1;b=k>>>3;g=g+b|0;b=a[g>>0]|0;b=b&255;k=k&7;k=cc(e|0,0,k|0)|0;e=C;k=b|k;b=g;a[b>>0]=k;a[b+1>>0]=k>>8;a[b+2>>0]=k>>16;a[b+3>>0]=k>>24;g=g+4|0;a[g>>0]=e;a[g+1>>0]=e>>8;a[g+2>>0]=e>>16;a[g+3>>0]=e>>24;g=c[f>>2]|0;g=g+1|0;c[f>>2]=g;return}}function wb(a,b,e,f,g,h,j){a=a|0;b=b|0;e=e|0;f=f|0;g=g|0;h=h|0;j=j|0;var k=0,l=0,m=0,n=0,o=0;n=i;i=i+1024|0;m=n;ac(m|0,0,1024)|0;a:do if(e>>>0<32768){k=0;while(1){if((k|0)==(e|0)){k=0;break}l=m+((d[b+k>>0]|0)<<2)|0;c[l>>2]=(c[l>>2]|0)+1;k=k+1|0}while(1){if((k|0)==256){l=e;break a}b=m+(k<<2)|0;o=c[b>>2]|0;l=(o>>>0<11?o:11)<<1;c[b>>2]=o+l;e=e+l|0;k=k+1|0}}else{k=0;while(1){if(k>>>0>=e>>>0)break;o=m+((d[b+k>>0]|0)<<2)|0;c[o>>2]=(c[o>>2]|0)+1;k=k+29|0}e=((e+28|0)>>>0)/29|0;k=0;while(1){if((k|0)==256){l=e;break a}l=m+(k<<2)|0;b=c[l>>2]|0;o=(b>>>0<11?b:11)<<1|1;c[l>>2]=b+o;e=e+o|0;k=k+1|0}}while(0);$a(a,m,l,8,f,g,h,j);e=0;b=0;while(1){if((b|0)==256)break;k=c[m+(b<<2)>>2]|0;if(k)e=e+(_(k,d[f+b>>0]|0)|0)|0;b=b+1|0}i=n;return ((e*125|0)>>>0)/(l>>>0)|0|0}function xb(e,f,g,h,j){e=e|0;f=f|0;g=g|0;h=h|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;s=i;i=i+1872|0;r=s+704|0;q=s;o=s+1736|0;ac(q|0,0,704)|0;Hb(e,64,15,r,f);p=f+64|0;Hb(e+256|0,64,14,r,p);l=q;m=f;n=l+24|0;do{a[l>>0]=a[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));l=f+40|0;k=l;l=l+4|0;l=d[l>>0]|d[l+1>>0]<<8|d[l+2>>0]<<16|d[l+3>>0]<<24;e=q+24|0;c[e>>2]=d[k>>0]|d[k+1>>0]<<8|d[k+2>>0]<<16|d[k+3>>0]<<24;c[e+4>>2]=l;e=f+24|0;l=e;k=l;l=l+4|0;l=d[l>>0]|d[l+1>>0]<<8|d[l+2>>0]<<16|d[l+3>>0]<<24;n=q+32|0;c[n>>2]=d[k>>0]|d[k+1>>0]<<8|d[k+2>>0]<<16|d[k+3>>0]<<24;c[n+4>>2]=l;n=f+48|0;l=n;n=n+4|0;n=d[n>>0]|d[n+1>>0]<<8|d[n+2>>0]<<16|d[n+3>>0]<<24;k=q+40|0;c[k>>2]=d[l>>0]|d[l+1>>0]<<8|d[l+2>>0]<<16|d[l+3>>0]<<24;c[k+4>>2]=n;k=f+32|0;n=k;l=n;n=n+4|0;n=d[n>>0]|d[n+1>>0]<<8|d[n+2>>0]<<16|d[n+3>>0]<<24;m=q+48|0;c[m>>2]=d[l>>0]|d[l+1>>0]<<8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ka+48|0;sa=Ka+96|0;ta=La+64|0;ua=Ka+112|0;va=La+96|0;wa=Ka+128|0;xa=Ma+64|0;ya=Na+32|0;za=Ma+128|0;Aa=Na+40|0;Ba=Ma+192|0;Ca=Ma+384|0;R=Sa;Da=Sa+1024|0;O=h;a:while(1){if(!j){Ua=155;break}P=j>>>0<131072?j:131072;c[Pa>>2]=Fa;Q=O+P|0;o=O;if(Ia){Ua=4;break}if(!Ja){Ua=6;break}if(!Ea){Ua=8;break}if(!S){Ua=10;break}b:do if(P>>>0>15){A=P+-6|0;N=j+-16|0;N=O+(A>>>0<N>>>0?A:N)|0;A=O+1|0;t=A;s=t;t=t+4|0;s=d[s>>0]|d[s+1>>0]<<8|d[s+2>>0]<<16|d[s+3>>0]<<24;t=d[t>>0]|d[t+1>>0]<<8|d[t+2>>0]<<16|d[t+3>>0]<<24;L=-1;x=Ga;while(1){s=lc(s|0,t|0,-1480785920,7733)|0;s=bc(s|0,C|0,Ha|0)|0;J=o;if(J>>>0>=A>>>0){Ua=15;break a}F=0-L|0;K=A;D=32;while(1){G=K;t=D;D=D+1|0;M=K;I=M;M=M+4|0;M=lc(d[I>>0]|d[I+1>>0]<<8|d[I+2>>0]<<16|d[I+3>>0]<<24|0,d[M>>0]|d[M+1>>0]<<8|d[M+2>>0]<<16|d[M+3>>0]<<24|0,-1480785920,7733)|0;M=bc(M|0,C|0,Ha|0)|0;if((s|0)!=(M|0)){Ua=17;break a}A=K+(t>>>5)|0;if(A>>>0>N>>>0)break b;B=A;t=B;B=B+4|0;B=lc(d[t>>0]|d[t+1>>0]<<8|d[t+2>>0]<<16|d[t+3>>0]<<24|0,d[B>>0]|d[B+1>>0]<<8|d[B+2>>0]<<16|d[B+3>>0]<<24|0,-1480785920,7733)|0;B=bc(B|0,C|0,Ha|0)|0;t=K+F|0;if(((d[K>>0]|d[K+1>>0]<<8|d[K+2>>0]<<16|d[K+3>>0]<<24|0)==(d[t>>0]|d[t+1>>0]<<8|d[t+2>>0]<<16|d[t+3>>0]<<24|0)?(a[K+4>>0]|0)==(a[K+(4-L)>>0]|0):0)?((F|0)<0?(a[K+5>>0]|0)==(a[K+(5-L)>>0]|0):0):0){Ua=22;break}s=n+(s<<2)|0;y=c[s>>2]|0;t=h+y|0;if((y|0)<0){Ua=24;break a}if(t>>>0>=K>>>0){Ua=26;break a}c[s>>2]=G-T;if((d[K>>0]|d[K+1>>0]<<8|d[K+2>>0]<<16|d[K+3>>0]<<24|0)!=(d[t>>0]|d[t+1>>0]<<8|d[t+2>>0]<<16|d[t+3>>0]<<24|0)){s=B;K=A;continue}if((a[K+4>>0]|0)!=(a[h+(y+4)>>0]|0)){s=B;K=A;continue}if((a[K+5>>0]|0)==(a[h+(y+5)>>0]|0))break;else{s=B;K=A}}if((Ua|0)==22){Ua=0;c[n+(s<<2)>>2]=G-T}A=t;M=O+(P+-4)|0;s=0;y=K+6|0;while(1){if(y>>>0>M>>>0){I=s;s=y;break}I=t+(s+6)|0;if((d[y>>0]|d[y+1>>0]<<8|d[y+2>>0]<<16|d[y+3>>0]<<24|0)!=(d[I>>0]|d[I+1>>0]<<8|d[I+2>>0]<<16|d[I+3>>0]<<24|0)){I=s;s=y;break}s=s+4|0;y=y+4|0}while(1){if(s>>>0>=Q>>>0)break;if((a[t+(I+6)>>0]|0)!=(a[s>>0]|0))break;I=I+1|0;s=s+1|0}H=I+6|0;y=G-A|0;F=G-o|0;G=K+H|0;o=G;c:do if(H){B=H;D=K;while(1){s=a[D>>0]|0;A=a[t>>0]|0;if(s<<24>>24!=A<<24>>24)break;B=B+-1|0;if(!B)break c;else{D=D+1|0;t=t+1|0}}if(s<<24>>24!=A<<24>>24){Ua=41;break a}}while(0);do if(F>>>0>=6){if(F>>>0<130){A=F+-2|0;D=((aa(A|0)|0)^31)+-1|0;B=A>>>D;c[c[Pa>>2]>>2]=(D<<1)+B+2|A-(B<<D)<<8;break}if(F>>>0<2114){B=F+-66|0;D=(aa(B|0)|0)^31;c[c[Pa>>2]>>2]=D+10|B-(1<<D)<<8;break}if(F>>>0<6210){c[c[Pa>>2]>>2]=(F<<8)+-541184|21;break}s=F<<8;if(F>>>0<22594){c[c[Pa>>2]>>2]=s+-1589760|22;break}else{c[c[Pa>>2]>>2]=s+-5784064|23;break}}else c[c[Pa>>2]>>2]=F;while(0);c[Pa>>2]=(c[Pa>>2]|0)+4;dc(x|0,J|0,F|0)|0;x=x+F|0;if((y|0)==(L|0)){c[c[Pa>>2]>>2]=64;s=c[Pa>>2]|0;y=L}else{J=y+3|0;s=((aa(J|0)|0)^31)+-1|0;L=J>>>s&1;c[c[Pa>>2]>>2]=((s<<1)+-2|L)+80|J-((L|2)<<s)<<8;s=c[Pa>>2]|0}s=s+4|0;c[Pa>>2]=s;do if(H>>>0>=12){if(H>>>0<72){H=I+-2|0;L=((aa(H|0)|0)^31)+-1|0;J=H>>>L;c[s>>2]=(L<<1)+J+28|H-(J<<L)<<8;c[Pa>>2]=(c[Pa>>2]|0)+4;break}if(H>>>0<136){L=I+-2|0;c[s>>2]=(L>>>5)+54|L<<8&7936;L=(c[Pa>>2]|0)+4|0;c[Pa>>2]=L;c[L>>2]=64;c[Pa>>2]=(c[Pa>>2]|0)+4;break}if(H>>>0<2120){J=I+-66|0;L=(aa(J|0)|0)^31;c[s>>2]=L+52|J-(1<<L)<<8;L=(c[Pa>>2]|0)+4|0;c[Pa>>2]=L;c[L>>2]=64;c[Pa>>2]=(c[Pa>>2]|0)+4;break}else{c[s>>2]=(H<<8)+-542720|63;L=(c[Pa>>2]|0)+4|0;c[Pa>>2]=L;c[L>>2]=64;c[Pa>>2]=(c[Pa>>2]|0)+4;break}}else{c[s>>2]=I+26;c[Pa>>2]=(c[Pa>>2]|0)+4}while(0);if(G>>>0>=N>>>0)break b;t=K+(I+1)|0;L=t;L=d[L>>0]|d[L+1>>0]<<8|d[L+2>>0]<<16|d[L+3>>0]<<24;t=t+4|0;t=d[t>>0]|d[t+1>>0]<<8|d[t+2>>0]<<16|d[t+3>>0]<<24;H=lc(L|0,t|0,-1480785920,7733)|0;H=bc(H|0,C|0,Ha|0)|0;J=G-T|0;c[n+(H<<2)>>2]=J+-5;H=bc(L|0,t|0,8)|0;H=lc(H|0,C|0,-1480785920,7733)|0;H=bc(H|0,C|0,Ha|0)|0;c[n+(H<<2)>>2]=J+-4;t=bc(L|0,t|0,16)|0;t=lc(t|0,C|0,-1480785920,7733)|0;t=bc(t|0,C|0,Ha|0)|0;c[n+(t<<2)>>2]=J+-3;t=K+(I+4)|0;K=t;K=d[K>>0]|d[K+1>>0]<<8|d[K+2>>0]<<16|d[K+3>>0]<<24;t=t+4|0;t=d[t>>0]|d[t+1>>0]<<8|d[t+2>>0]<<16|d[t+3>>0]<<24;L=bc(K|0,t|0,16)|0;L=lc(L|0,C|0,-1480785920,7733)|0;L=bc(L|0,C|0,Ha|0)|0;I=lc(K|0,t|0,-1480785920,7733)|0;I=bc(I|0,C|0,Ha|0)|0;c[n+(I<<2)>>2]=J+-2;t=bc(K|0,t|0,8)|0;t=lc(t|0,C|0,-1480785920,7733)|0;t=bc(t|0,C|0,Ha|0)|0;c[n+(t<<2)>>2]=J+-1;L=n+(L<<2)|0;t=c[L>>2]|0;c[L>>2]=J;while(1){B=h+t|0;L=o;s=o;if((d[L>>0]|d[L+1>>0]<<8|d[L+2>>0]<<16|d[L+3>>0]<<24|0)!=(d[B>>0]|d[B+1>>0]<<8|d[B+2>>0]<<16|d[B+3>>0]<<24|0))break;if((a[s+4>>0]|0)!=(a[h+(t+4)>>0]|0))break;if((a[s+5>>0]|0)!=(a[h+(t+5)>>0]|0))break;A=t+6|0;t=0;y=s+6|0;while(1){if(y>>>0>M>>>0)break;L=h+(A+t)|0;if((d[y>>0]|d[y+1>>0]<<8|d[y+2>>0]<<16|d[y+3>>0]<<24|0)!=(d[L>>0]|d[L+1>>0]<<8|d[L+2>>0]<<16|d[L+3>>0]<<24|0))break;t=t+4|0;y=y+4|0}while(1){if(y>>>0>=Q>>>0)break;if((a[h+(A+t)>>0]|0)!=(a[y>>0]|0))break;t=t+1|0;y=y+1|0}G=t+6|0;H=s+G|0;I=H;y=o-B|0;do if(G){D=G;F=s;while(1){o=a[F>>0]|0;A=a[B>>0]|0;if(o<<24>>24!=A<<24>>24){Ua=80;break}D=D+-1|0;if(!D)break;else{F=F+1|0;B=B+1|0}}if((Ua|0)==80?(Ua=0,o<<24>>24!=A<<24>>24):0){Ua=81;break a}if(G>>>0<10){Ua=83;break}if(G>>>0<134){L=((aa(t|0)|0)^31)+-1|0;K=t>>>L;c[c[Pa>>2]>>2]=(L<<1)+K+44|t-(K<<L)<<8;break}if(G>>>0<2118){K=t+-64|0;L=(aa(K|0)|0)^31;c[c[Pa>>2]>>2]=L+52|K-(1<<L)<<8;break}else{c[c[Pa>>2]>>2]=(G<<8)+-542208|63;break}}else Ua=83;while(0);if((Ua|0)==83){Ua=0;c[c[Pa>>2]>>2]=t+44}L=(c[Pa>>2]|0)+4|0;c[Pa>>2]=L;G=y+3|0;K=((aa(G|0)|0)^31)+-1|0;J=G>>>K&1;c[L>>2]=((K<<1)+-2|J)+80|G-((J|2)<<K)<<8;c[Pa>>2]=(c[Pa>>2]|0)+4;if(H>>>0>=N>>>0){o=I;break b}K=s+(t+1)|0;o=K;o=d[o>>0]|d[o+1>>0]<<8|d[o+2>>0]<<16|d[o+3>>0]<<24;K=K+4|0;K=d[K>>0]|d[K+1>>0]<<8|d[K+2>>0]<<16|d[K+3>>0]<<24;J=lc(o|0,K|0,-1480785920,7733)|0;J=bc(J|0,C|0,Ha|0)|0;L=H-T|0;c[n+(J<<2)>>2]=L+-5;J=bc(o|0,K|0,8)|0;J=lc(J|0,C|0,-1480785920,7733)|0;J=bc(J|0,C|0,Ha|0)|0;c[n+(J<<2)>>2]=L+-4;K=bc(o|0,K|0,16)|0;K=lc(K|0,C|0,-1480785920,7733)|0;K=bc(K|0,C|0,Ha|0)|0;c[n+(K<<2)>>2]=L+-3;t=s+(t+4)|0;K=t;K=d[K>>0]|d[K+1>>0]<<8|d[K+2>>0]<<16|d[K+3>>0]<<24;t=t+4|0;t=d[t>>0]|d[t+1>>0]<<8|d[t+2>>0]<<16|d[t+3>>0]<<24;o=bc(K|0,t|0,16)|0;o=lc(o|0,C|0,-1480785920,7733)|0;o=bc(o|0,C|0,Ha|0)|0;J=lc(K|0,t|0,-1480785920,7733)|0;J=bc(J|0,C|0,Ha|0)|0;c[n+(J<<2)>>2]=L+-2;t=bc(K|0,t|0,8)|0;t=lc(t|0,C|0,-1480785920,7733)|0;t=bc(t|0,C|0,Ha|0)|0;c[n+(t<<2)>>2]=L+-1;o=n+(o<<2)|0;t=c[o>>2]|0;c[o>>2]=L;o=I}A=s+1|0;t=A;s=t;t=t+4|0;s=d[s>>0]|d[s+1>>0]<<8|d[s+2>>0]<<16|d[s+3>>0]<<24;t=d[t>>0]|d[t+1>>0]<<8|d[t+2>>0]<<16|d[t+3>>0]<<24;L=y}}else x=Ga;while(0);t=o;if(t>>>0>Q>>>0){Ua=93;break}if(t>>>0<Q>>>0){o=Q-o|0;do if(o>>>0>=6){if(o>>>0<130){L=o+-2|0;N=((aa(L|0)|0)^31)+-1|0;M=L>>>N;c[c[Pa>>2]>>2]=(N<<1)+M+2|L-(M<<N)<<8;break}if(o>>>0<2114){M=o+-66|0;N=(aa(M|0)|0)^31;c[c[Pa>>2]>>2]=N+10|M-(1<<N)<<8;break}if(o>>>0<6210){c[c[Pa>>2]>>2]=(o<<8)+-541184|21;break}s=o<<8;if(o>>>0<22594){c[c[Pa>>2]>>2]=s+-1589760|22;break}else{c[c[Pa>>2]>>2]=s+-5784064|23;break}}else c[c[Pa>>2]>>2]=o;while(0);c[Pa>>2]=(c[Pa>>2]|0)+4;dc(x|0,t|0,o|0)|0;x=x+o|0}A=x-U|0;r=+(P>>>0);if(!(+(A>>>0)<r*.98)){ac(Sa|0,0,1024)|0;E=r*8.0*.98;o=0;while(1){if(o>>>0>=P>>>0){o=R;r=0.0;y=0;break}N=Sa+(d[O+o>>0]<<2)|0;c[N>>2]=(c[N>>2]|0)+1;o=o+43|0}while(1){if(o>>>0>=Da>>>0)break;s=c[o>>2]|0;u=+(s>>>0);if(s>>>0<256)z=+g[19516+(s<<2)>>2];else z=+Xb(u);t=c[o+4>>2]|0;v=+(t>>>0);if(t>>>0<256)w=+g[19516+(t<<2)>>2];else w=+Xb(v);o=o+8|0;r=r-u*z-v*w;y=y+s+t|0}z=E/43.0;v=+(y>>>0);if(!y)w=v;else{if(y>>>0<256)u=+g[19516+(y<<2)>>2];else u=+Xb(v);w=v;r=r+v*u}if(!((r<w?w:r)<z)){zb(P,1,p,q);N=(c[p>>2]|0)+7|0;c[p>>2]=N&-8;dc(q+(N>>>3)|0,O|0,P|0)|0;O=(c[p>>2]|0)+(P<<3)|0;c[p>>2]=O;a[q+(O>>>3)>>0]=0}else Ua=126}else Ua=126;if((Ua|0)==126){Ua=0;G=(c[Pa>>2]|0)-V>>2;zb(P,0,p,q);s=q+((c[p>>2]|0)>>>3)|0;O=d[s>>0]|0;t=s;a[t>>0]=O;a[t+1>>0]=O>>8;a[t+2>>0]=O>>16;a[t+3>>0]=O>>24;s=s+4|0;a[s>>0]=0;a[s+1>>0]=0;a[s+2>>0]=0;a[s+3>>0]=0;c[p>>2]=(c[p>>2]|0)+13;ac(Sa|0,0,1024)|0;s=Na;t=s+128|0;do{c[s>>2]=0;s=s+4|0}while((s|0)<(t|0));ac(Ka|0,0,256)|0;ac(Oa|0,0,512)|0;o=x-U|0;s=0;while(1){if((s|0)==(o|0))break;O=Sa+(d[m+s>>0]<<2)|0;c[O>>2]=(c[O>>2]|0)+1;s=s+1|0}$a(f,Sa,A,8,Ra,Qa,p,q);o=0;while(1){if((o|0)==(G|0))break;O=Oa+((c[l+(o<<2)>>2]&255)<<2)|0;c[O>>2]=(c[O>>2]|0)+1;o=o+1|0}c[W>>2]=(c[W>>2]|0)+1;c[X>>2]=(c[X>>2]|0)+1;c[Y>>2]=(c[Y>>2]|0)+1;c[Z>>2]=(c[Z>>2]|0)+1;ac(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t|0,0,s&255|0)|0;if(!((O|0)==0&(C|0)==0)){Ua=138;break a}if((s&255)>=57){Ua=140;break a}O=cc(t|0,0,x&7|0)|0;x=C;O=A|O;t=y;y=t;a[y>>0]=O;a[y+1>>0]=O>>8;a[y+2>>0]=O>>16;a[y+3>>0]=O>>24;t=t+4|0;a[t>>0]=x;a[t+1>>0]=x>>8;a[t+2>>0]=x>>16;a[t+3>>0]=x>>24;s=(c[p>>2]|0)+(s&255)|0;c[p>>2]=s;t=c[18276+(B<<2)>>2]|0;x=q+(s>>>3)|0;y=d[x>>0]|0;O=bc(D|0,0,t|0)|0;if(!((O|0)==0&(C|0)==0)){Ua=142;break a}M=cc(D|0,0,s&7|0)|0;O=C;M=y|M;s=x;N=s;a[N>>0]=M;a[N+1>>0]=M>>8;a[N+2>>0]=M>>16;a[N+3>>0]=M>>24;s=s+4|0;a[s>>0]=O;a[s+1>>0]=O>>8;a[s+2>>0]=O>>16;a[s+3>>0]=O>>24;s=(c[p>>2]|0)+t|0;c[p>>2]=s;d:do if(B>>>0<24){D=(c[18788+(B<<2)>>2]|0)+D|0;B=0;while(1){if(B>>>0>=D>>>0)break d;x=d[o>>0]|0;t=a[Ra+x>>0]|0;x=e[Qa+(x<<1)>>1]|0;y=q+(s>>>3)|0;A=d[y>>0]|0;O=bc(x|0,0,t&255|0)|0;if(!((O|0)==0&(C|0)==0)){Ua=147;break a}if((t&255)>=57){Ua=149;break a}L=cc(x|0,0,s&7|0)|0;N=C;L=A|L;O=y;M=O;a[M>>0]=L;a[M+1>>0]=L>>8;a[M+2>>0]=L>>16;a[M+3>>0]=L>>24;O=O+4|0;a[O>>0]=N;a[O+1>>0]=N>>8;a[O+2>>0]=N>>16;a[O+3>>0]=N>>24;O=(c[p>>2]|0)+(t&255)|0;c[p>>2]=O;o=o+1|0;s=O;B=B+1|0}}while(0);F=F+1|0}}j=j-P|0;O=Q}switch(Ua|0){case 4:{pa(405532,405543,251,405590);break}case 6:{pa(405605,405543,252,405590);break}case 8:{pa(405630,405543,254,405590);break}case 10:{pa(405667,405543,256,405590);break}case 15:{pa(405740,405543,289,405590);break}case 17:{pa(405755,405543,295,405590);break}case 24:{pa(405779,405543,309,405590);break}case 26:{pa(405800,405543,310,405590);break}case 41:{pa(405815,405543,329,405590);break}case 81:{pa(405815,405543,378,405590);break}case 93:{pa(405853,405543,415,405590);break}case 138:{pa(406196,406218,54,406251);break}case 140:{pa(406267,406218,55,406251);break}case 142:{pa(406196,406218,54,406251);break}case 147:{pa(406196,406218,54,406251);break}case 149:{pa(406267,406218,55,406251);break}case 155:{if(!k){i=Va;return}f=c[p>>2]|0;Ta=q+(f>>>3)|0;n=d[Ta>>0]|0;f=cc(1,0,f&7|0)|0;Ua=C;f=n|f;n=Ta;a[n>>0]=f;a[n+1>>0]=f>>8;a[n+2>>0]=f>>16;a[n+3>>0]=f>>24;Ta=Ta+4|0;a[Ta>>0]=Ua;a[Ta+1>>0]=Ua>>8;a[Ta+2>>0]=Ua>>16;a[Ta+3>>0]=Ua>>24;Ta=(c[p>>2]|0)+1|0;c[p>>2]=Ta;Ua=q+(Ta>>>3)|0;n=d[Ua>>0]|0;q=cc(1,0,Ta&7|0)|0;Ta=C;q=n|q;n=Ua;a[n>>0]=q;a[n+1>>0]=q>>8;a[n+2>>0]=q>>16;a[n+3>>0]=q>>24;Ua=Ua+4|0;a[Ua>>0]=Ta;a[Ua+1>>0]=Ta>>8;a[Ua+2>>0]=Ta>>16;a[Ua+3>>0]=Ta>>24;c[p>>2]=(c[p>>2]|0)+8&-8;i=Va;return}}}function zb(b,e,f,g){b=b|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0;h=g+((c[f>>2]|0)>>>3)|0;j=d[h>>0]|0;i=h;a[i>>0]=j;a[i+1>>0]=j>>8;a[i+2>>0]=j>>16;a[i+3>>0]=j>>24;h=h+4|0;a[h>>0]=0;a[h+1>>0]=0;a[h+2>>0]=0;a[h+3>>0]=0;h=(c[f>>2]|0)+1|0;c[f>>2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ab=c[n>>2]|0;l=ab;b:do if(!ab){do if((o|0)==131072){l=e+24|0;m=sa[c[N>>2]&1](c[l>>2]|0,524288)|0;if(!m)oa(1);c[n>>2]=m;l=sa[c[N>>2]&1](c[l>>2]|0,131072)|0;if(l){c[e+5212>>2]=l;l=c[n>>2]|0;if(!l)break;else{p=l;break b}}else oa(1)}while(0);l=e+24|0;m=sa[c[N>>2]&1](c[l>>2]|0,o<<2)|0;if(!m)oa(1);l=sa[c[N>>2]&1](c[l>>2]|0,o)|0;if(!l)oa(1);else{p=m;n=l;L=m;K=l;ab=20;break a}}else p=l;while(0);n=c[e+5212>>2]|0;L=0;K=0;ab=20;break}default:O=0}while(0);do if((ab|0)==20){v=e+193|0;w=e+5220|0;x=e+196|0;y=e+200|0;z=e+20|0;A=e+24|0;B=e+192|0;D=e+4308|0;E=e+4436|0;F=e+5204|0;G=e+4692|0;H=e+5216|0;I=e+5224|0;J=(k|0)==0;c:while(1){l=c[bb>>2]|0;while(1){if((l|0)==1?(a[v>>0]|0)!=0:0){ab=24;break}m=c[w>>2]|0;if(m)break;if(l){ab=49;break c}u=c[f>>2]|0;s=M>>>0<u>>>0?M:u;u=(u|0)==(s|0)?1:0;l=(s<<1)+502|0;c[db>>2]=d[v>>0];if(l>>>0>(c[h>>2]|0)>>>0){m=c[y>>2]|0;if((c[x>>2]|0)>>>0<l>>>0){ra[c[z>>2]&1](c[A>>2]|0,m);c[y>>2]=0;m=sa[c[N>>2]&1](c[A>>2]|0,l)|0;if(!m){ab=34;break c}c[y>>2]=m;c[x>>2]=l;t=0}else t=0}else{t=1;m=c[j>>2]|0}a[m>>0]=a[B>>0]|0;l=Cb(e,c[cb>>2]|0,s,eb)|0;o=c[g>>2]|0;q=u<<24>>24!=0;r=c[eb>>2]|0;if(!(c[cb>>2]|0))ub(N,o,s,q,l,r,D,E,F,G,db,m);else yb(N,o,s,q,p,n,l,r,db,m);c[g>>2]=(c[g>>2]|0)+s;c[f>>2]=(c[f>>2]|0)-s;o=c[db>>2]|0;q=o>>>3;if(t<<24>>24){l=c[h>>2]|0;if(q>>>0>l>>>0){ab=41;break c}if(!((o&7|0)==0|q>>>0<l>>>0)){ab=43;break c}c[j>>2]=(c[j>>2]|0)+q;c[h>>2]=(c[h>>2]|0)-q;l=(c[I>>2]|0)+q|0;c[I>>2]=l;if(!J)c[k>>2]=l}else{c[H>>2]=m;c[w>>2]=q}a[B>>0]=a[m+((c[db>>2]|0)>>>3)>>0]|0;a[v>>0]=c[db>>2]&7;if(!(u<<24>>24))continue c;c[bb>>2]=2;l=2}if((ab|0)==24){ab=0;Eb(e);continue}l=c[h>>2]|0;if(!l){ab=49;break}l=m>>>0<l>>>0?m:l;dc(c[j>>2]|0,c[H>>2]|0,l|0)|0;c[j>>2]=(c[j>>2]|0)+l;c[h>>2]=(c[h>>2]|0)-l;c[H>>2]=(c[H>>2]|0)+l;c[w>>2]=(c[w>>2]|0)-l;l=(c[I>>2]|0)+l|0;c[I>>2]=l;if(J)continue;c[k>>2]=l}if((ab|0)==34)oa(1);else if((ab|0)==41)pa(406280,406053,1436,406308);else if((ab|0)==43)pa(406340,406053,1437,406308);else if((ab|0)==49){ra[c[z>>2]&1](c[A>>2]|0,L);ra[c[z>>2]&1](c[A>>2]|0,K);if((c[bb>>2]|0)!=1){O=1;break}if(c[w>>2]|0){O=1;break}c[bb>>2]=0;c[H>>2]=0;O=1;break}}while(0);k=O;i=fb;return k|0}Xa=e+80|0;Ya=e+152|0;x=e+12|0;y=e+193|0;z=e+5220|0;A=e+5216|0;B=e+16|0;D=e+116|0;E=e+92|0;F=e+5236|0;G=e+5208|0;H=e+24|0;I=e+5212|0;J=e+196|0;K=e+200|0;L=e+20|0;M=e+24|0;N=e+192|0;O=e+4308|0;P=e+4436|0;Q=e+5204|0;R=e+4692|0;S=e+128|0;T=e+120|0;U=e+124|0;V=e+20|0;W=e+160|0;X=e+136|0;Y=e+132|0;Z=e+4|0;_=e+72|0;$=e+8|0;ba=e+144|0;ca=e+28|0;da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(a[y>>0]|0)!=0:0){Eb(e);continue}m=c[z>>2]|0;o=(m|0)==0;if(!o){l=c[h>>2]|0;if(!l){ab=234;break}l=m>>>0<l>>>0?m:l;dc(c[j>>2]|0,c[A>>2]|0,l|0)|0;c[j>>2]=(c[j>>2]|0)+l;c[h>>2]=(c[h>>2]|0)-l;c[A>>2]=(c[A>>2]|0)+l;c[z>>2]=(c[z>>2]|0)-l;l=(c[ya>>2]|0)+l|0;c[ya>>2]=l;if(za)continue;c[k>>2]=l;continue}if(l){ab=234;break}w=(c[f>>2]|0)==0?1:0;o=Xa;n=c[o>>2]|0;o=c[o+4>>2]|0;q=Ya;p=c[q>>2]|0;q=c[q+4>>2]|0;s=$b(n|0,o|0,p|0,q|0)|0;l=C;if(q>>>0>0|(q|0)==0&p>>>0>3221225471){r=bc(p|0,q|0,30)|0;r=p&1073741823|((r&1^1)<<30)+1073741824}else r=p;if(!(Bb(e)|0)){ab=231;break}u=c[D>>2]|0;v=c[E>>2]|0;if(a[F>>0]&1){ab=231;break}t=w<<24>>24==0;if(!t)a[F>>0]=1;if(Bb(e)|0)m=1<<c[x>>2];else m=0;if(l>>>0>0|(l|0)==0&s>>>0>m>>>0){ab=231;break}l=c[cb>>2]|0;if((l|0)==1)if(!(c[G>>2]|0)){l=sa[c[B>>2]&1](c[H>>2]|0,524288)|0;if(!l){ab=108;break}c[G>>2]=l;l=sa[c[B>>2]&1](c[H>>2]|0,131072)|0;if(!l){ab=110;break}c[I>>2]=l;l=c[cb>>2]|0;ab=112}else ab=114;else ab=112;e:do if((ab|0)==112){ab=0;if((l|0)!=0?(l|0)!=1:0){m=c[S>>2]|0;l=m+(s>>>1)+1|0;if(l>>>0>(c[T>>2]|0)>>>0){l=l+((s>>>2)+16)|0;c[T>>2]=l;l=sa[c[B>>2]&1](c[H>>2]|0,l<<4)|0;if(!l){ab=127;break d}m=c[U>>2]|0;if(m){dc(l|0,m|0,c[S>>2]<<4|0)|0;ra[c[V>>2]&1](c[H>>2]|0,c[U>>2]|0);c[U>>2]=0}c[U>>2]=l;m=c[S>>2]|0}else l=c[U>>2]|0;m=l+(m<<4)|0;l=c[Z>>2]|0;f:do switch(l|0){case 10:{Ha(B,s,r,w<<24>>24!=0,u,v,e,c[_>>2]|0,W,X,m,S,Y);break}case 11:{Ia(B,s,r,w<<24>>24!=0,u,v,e,c[_>>2]|0,W,X,m,S,Y);break}default:{if((l|0)>9)break f;do if((l|0)<5)ab=139;else{if((c[xa>>2]|0)>=17){ab=139;break}if((l|0)<7)break;l=(l|0)<9?41:42;ab=139}while(0);g:do if((ab|0)==139){ab=0;do switch(l|0){case 40:break g;case 2:{Ja(B,s,r,w<<24>>24!=0,u,v,e,c[ca>>2]|0,W,X,m,S,Y);break f}case 3:{Ka(B,s,r,w<<24>>24!=0,u,v,e,c[da>>2]|0,W,X,m,S,Y);break f}case 4:{La(B,s,r,w<<24>>24!=0,u,v,e,c[ea>>2]|0,W,X,m,S,Y);break f}case 5:{Ma(B,s,r,w<<24>>24!=0,u,v,e,c[fa>>2]|0,W,X,m,S,Y);break f}case 6:{Na(B,s,r,w<<24>>24!=0,u,v,e,c[ga>>2]|0,W,X,m,S,Y);break f}case 7:{Oa(B,s,r,w<<24>>24!=0,u,v,e,c[ha>>2]|0,W,X,m,S,Y);break f}case 8:{Pa(B,s,r,w<<24>>24!=0,u,v,e,c[ia>>2]|0,W,X,m,S,Y);break f}case 9:{Qa(B,s,r,w<<24>>24!=0,u,v,e,c[ja>>2]|0,W,X,m,S,Y);break f}case 41:{Sa(B,s,r,w<<24>>24!=0,u,v,e,c[la>>2]|0,W,X,m,S,Y);break f}case 42:{Ta(B,s,r,w<<24>>24!=0,u,v,e,c[ma>>2]|0,W,X,m,S,Y);break f}default:break f}while(0)}while(0);Ra(B,s,r,w<<24>>24!=0,u,v,e,c[ka>>2]|0,W,X,m,S,Y)}}while(0);n=c[$>>2]|0;m=c[x>>2]|0;m=((n|0)>(m|0)?n:m)+1|0;m=1<<((m|0)<24?m:24);n=m>>>3;s=Xa;o=ba;o=$b(c[s>>2]|0,c[s+4>>2]|0,c[o>>2]|0,c[o+4>>2]|0)|0;if(Bb(e)|0)q=1<<c[x>>2];else q=0;l=c[cb>>2]|0;if((l|0)<4)p=((c[Y>>2]|0)+(c[S>>2]|0)|0)>>>0>12286;else p=0;do if(!(t^1|p|(o+q|0)>>>0>m>>>0)){if((c[Y>>2]|0)>>>0>=n>>>0)break;if((c[S>>2]|0)>>>0>=n>>>0)break;n=Ya;m=c[n>>2]|0;n=c[n+4>>2]|0;if(n>>>0>0|(n|0)==0&m>>>0>3221225471){v=bc(m|0,n|0,30)|0;m=m&1073741823|((v&1^1)<<30)+1073741824}o=Xa;n=c[o>>2]|0;o=c[o+4>>2]|0;if(o>>>0>0|(o|0)==0&n>>>0>3221225471){p=bc(n|0,o|0,30)|0;p=n&1073741823|((p&1^1)<<30)+1073741824}else p=n;v=Ya;c[v>>2]=n;c[v+4>>2]=o;h:do if(p>>>0<m>>>0){i:do if((l|0)<=9){do if((l|0)<5)ab=168;else{if((c[na>>2]|0)>=17){ab=168;break}if((l|0)<7)break;l=(l|0)<9?41:42;ab=168}while(0);j:do if((ab|0)==168){ab=0;do switch(l|0){case 10:break i;case 40:break j;case 2:{v=c[ca>>2]|0;a[v+262148>>0]=1;c[v+262152>>2]=0;c[v+262156>>2]=0;break h}case 3:{v=c[da>>2]|0;a[v+262152>>0]=1;c[v+262156>>2]=0;c[v+262160>>2]=0;break h}case 4:{v=c[ea>>2]|0;a[v+524304>>0]=1;c[v+524308>>2]=0;c[v+524312>>2]=0;break h}case 5:{v=c[fa>>2]|0;a[v+1081344>>0]=1;c[v+1081348>>2]=0;c[v+1081352>>2]=0;break h}case 6:{v=c[ga>>2]|0;a[v+2129920>>0]=1;c[v+2129924>>2]=0;c[v+2129928>>2]=0;break h}case 7:{v=c[ha>>2]|0;a[v+8454144>>0]=1;c[v+8454148>>2]=0;c[v+8454152>>2]=0;break h}case 8:{v=c[ia>>2]|0;a[v+16842752>>0]=1;c[v+16842756>>2]=0;c[v+16842760>>2]=0;break h}case 9:{v=c[ja>>2]|0;a[v+33619968>>0]=1;c[v+33619972>>2]=0;c[v+33619976>>2]=0;break h}case 41:{v=c[la>>2]|0;a[v+524290>>0]=1;c[v+524292>>2]=0;c[v+524296>>2]=0;break h}case 42:{v=c[ma>>2]|0;a[v+1311744>>0]=1;c[v+1311748>>2]=0;c[v+1311752>>2]=0;break h}default:break h}while(0)}while(0);v=c[ka>>2]|0;a[v+524290>>0]=1;c[v+524292>>2]=0;c[v+524296>>2]=0;break h}while(0);a[(c[_>>2]|0)+524304>>0]=1}while(0);c[z>>2]=0;break e}while(0);l=c[X>>2]|0;if(l){m=c[S>>2]|0;c[S>>2]=m+1;s=c[U>>2]|0;c[s+(m<<4)>>2]=l;c[s+(m<<4)+4>>2]=67108864;c[s+(m<<4)+8>>2]=0;b[s+(m<<4)+14>>1]=16;m=s+(m<<4)+12|0;do if(l>>>0>=6){if(l>>>0<130){s=l+-2|0;l=((aa(s|0)|0)^31)+-1|0;l=(l<<1)+(s>>>l)+2|0;break}if(l>>>0<2114){l=((aa(l+-66|0)|0)^31)+10|0;break}if(l>>>0<6210){l=21;break}l=l>>>0<22594?22:23}while(0);s=l&65535;b[m>>1]=b[88156+((s>>>3)*3<<1)>>1]|(s<<3&56|2)&65535;c[Y>>2]=(c[Y>>2]|0)+(c[X>>2]|0);c[X>>2]=0}m=Xa;l=c[m>>2]|0;m=c[m+4>>2]|0;o=ba;n=c[o>>2]|0;o=c[o+4>>2]|0;if(t&((l|0)==(n|0)&(m|0)==(o|0))){c[z>>2]=0;break}if(m>>>0<o>>>0|(m|0)==(o|0)&l>>>0<n>>>0){ab=194;break d}if(!(m>>>0>o>>>0|(m|0)==(o|0)&l>>>0>n>>>0|t^1)){ab=196;break d}n=$b(l|0,m|0,n|0,o|0)|0;t=C;if(!(t>>>0<0|(t|0)==0&n>>>0<16777217)){ab=198;break d}l=(n<<1)+502|0;if((c[J>>2]|0)>>>0<l>>>0){ra[c[L>>2]&1](c[M>>2]|0,c[K>>2]|0);c[K>>2]=0;t=sa[c[B>>2]&1](c[M>>2]|0,l)|0;m=t;if(!t){ab=202;break d}c[K>>2]=m;c[J>>2]=l}else m=c[K>>2]|0;c[$a>>2]=d[y>>0];p=m;a[p>>0]=a[N>>0]|0;q=u;o=ba;Db(B,q,v,c[o>>2]|0,c[o+4>>2]|0,n,w<<24>>24!=0,e,a[qa>>0]|0,a[ta>>0]|0,c[Y>>2]|0,c[S>>2]|0,c[U>>2]|0,ua,W,$a,p);a[N>>0]=a[p+((c[$a>>2]|0)>>>3)>>0]|0;a[y>>0]=c[$a>>2]&7;p=Xa;o=c[p>>2]|0;p=c[p+4>>2]|0;n=ba;c[n>>2]=o;c[n+4>>2]=p;n=Ya;l=c[n>>2]|0;n=c[n+4>>2]|0;if(n>>>0>0|(n|0)==0&l>>>0>3221225471){u=bc(l|0,n|0,30)|0;l=l&1073741823|((u&1^1)<<30)+1073741824}if(p>>>0>0|(p|0)==0&o>>>0>3221225471){n=bc(o|0,p|0,30)|0;n=o&1073741823|((n&1^1)<<30)+1073741824}else n=o;u=Ya;c[u>>2]=o;c[u+4>>2]=p;k:do if(n>>>0<l>>>0){l=c[cb>>2]|0;l:do if((l|0)<=9){do if((l|0)<5)ab=214;else{if((c[na>>2]|0)>=17){ab=214;break}if((l|0)<7)break;l=(l|0)<9?41:42;ab=214}while(0);m:do if((ab|0)==214){ab=0;do switch(l|0){case 10:break l;case 40:break m;case 2:{u=c[ca>>2]|0;a[u+262148>>0]=1;c[u+262152>>2]=0;c[u+262156>>2]=0;break k}case 3:{u=c[da>>2]|0;a[u+262152>>0]=1;c[u+262156>>2]=0;c[u+262160>>2]=0;break k}case 4:{u=c[ea>>2]|0;a[u+524304>>0]=1;c[u+524308>>2]=0;c[u+524312>>2]=0;break k}case 5:{u=c[fa>>2]|0;a[u+1081344>>0]=1;c[u+1081348>>2]=0;c[u+1081352>>2]=0;break k}case 6:{u=c[ga>>2]|0;a[u+2129920>>0]=1;c[u+2129924>>2]=0;c[u+2129928>>2]=0;break k}case 7:{u=c[ha>>2]|0;a[u+8454144>>0]=1;c[u+8454148>>2]=0;c[u+8454152>>2]=0;break k}case 8:{u=c[ia>>2]|0;a[u+16842752>>0]=1;c[u+16842756>>2]=0;c[u+16842760>>2]=0;break k}case 9:{u=c[ja>>2]|0;a[u+33619968>>0]=1;c[u+33619972>>2]=0;c[u+33619976>>2]=0;break k}case 41:{u=c[la>>2]|0;a[u+524290>>0]=1;c[u+524292>>2]=0;c[u+524296>>2]=0;break k}case 42:{u=c[ma>>2]|0;a[u+1311744>>0]=1;c[u+1311748>>2]=0;c[u+1311752>>2]=0;break k}default:break k}while(0)}while(0);u=c[ka>>2]|0;a[u+524290>>0]=1;c[u+524292>>2]=0;c[u+524296>>2]=0;break k}while(0);a[(c[_>>2]|0)+524304>>0]=1}while(0);n=ba;l=c[n>>2]|0;n=c[n+4>>2]|0;do if(!((l|0)==0&(n|0)==0)){a[qa>>0]=a[q+(l+-1&v)>>0]|0;if(!(n>>>0>0|(n|0)==0&l>>>0>1))break;u=ec(l|0,n|0,-2,0)|0;a[ta>>0]=a[q+(u&v)>>0]|0}while(0);c[S>>2]=0;c[Y>>2]=0;c[va>>2]=c[wa>>2];c[va+4>>2]=c[wa+4>>2];c[va+8>>2]=c[wa+8>>2];c[va+12>>2]=c[wa+12>>2];c[A>>2]=m;c[z>>2]=(c[$a>>2]|0)>>>3}else ab=114}while(0);do if((ab|0)==114){c[db>>2]=d[y>>0];if(!((n|0)==(p|0)&(o|0)==(q|0)^1|t^1)){c[z>>2]=0;break}m=(s<<1)+502|0;l=c[K>>2]|0;if((c[J>>2]|0)>>>0<m>>>0){ra[c[L>>2]&1](c[M>>2]|0,l);c[K>>2]=0;l=sa[c[B>>2]&1](c[M>>2]|0,m)|0;if(!l){ab=118;break d}c[K>>2]=l;c[J>>2]=m;n=l}else n=l;a[n>>0]=a[N>>0]|0;o=Cb(e,c[cb>>2]|0,s,eb)|0;l=u+(r&v)|0;m=w<<24>>24!=0;if(!(c[cb>>2]|0))ub(B,l,s,m,o,c[eb>>2]|0,O,P,Q,R,db,n);else yb(B,l,s,m,c[G>>2]|0,c[I>>2]|0,o,c[eb>>2]|0,db,n);a[N>>0]=a[n+((c[db>>2]|0)>>>3)>>0]|0;a[y>>0]=c[db>>2]&7;u=Xa;v=c[u+4>>2]|0;ab=Ya;c[ab>>2]=c[u>>2];c[ab+4>>2]=v;c[A>>2]=n;c[z>>2]=(c[db>>2]|0)>>>3}while(0);if(!(w<<24>>24))continue;c[bb>>2]=2}switch(ab|0){case 62:{oa(1);break}case 71:{oa(1);break}case 108:{oa(1);break}case 110:{oa(1);break}case 118:{oa(1);break}case 127:{oa(1);break}case 194:{pa(406017,406053,906,406080);break}case 196:{pa(406103,406053,907,406080);break}case 198:{pa(406149,406053,908,406080);break}case 202:{oa(1);break}case 231:{k=0;i=fb;return k|0}case 234:{if(n^1|o^1){k=1;i=fb;return k|0}c[bb>>2]=0;c[A>>2]=0;k=1;i=fb;return k|0}}return 0}function Bb(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;k=b+5237|0;if(a[k>>0]&1)return 1;e=c[b+4>>2]|0;if((e|0)>=0)if((e|0)>11)h=11;else i=4;else{e=0;i=4}if((i|0)==4)h=e;c[b+4>>2]=h;e=b+8|0;f=c[e>>2]|0;if((f|0)>=10){if((f|0)>24){c[e>>2]=24;f=24}}else{c[e>>2]=10;f=10}g=b+12|0;e=c[g>>2]|0;i=(h|0)==0;do if(h>>>0>=2)if((h|0)<4)e=14;else{if(!e){if(!((h|0)>8&(f|0)>16)){e=16;break}e=(f|0)>18?18:f;break}if((e|0)>=16){if((e|0)>24){e=24;break}}else e=16}else e=f;while(0);c[g>>2]=e;g=1<<((f|0)>(e|0)?f:e)+1;c[b+88>>2]=g;c[b+92>>2]=g+-1;e=1<<e;c[b+96>>2]=e;c[b+100>>2]=g+e;e=b+192|0;g=b+193|0;a:do switch(f|0){case 16:{a[e>>0]=0;a[g>>0]=1;break}case 17:{a[e>>0]=1;a[g>>0]=7;break}default:if((f|0)>17){a[e>>0]=(f<<1)+222|1;a[g>>0]=4;break a}else{a[e>>0]=(f<<4)+128|1;a[g>>0]=7;break a}}while(0);b:do if(i){g=b+4436|0;h=b+4692|0;i=b+5204|0;d=b+4308|0;e=406473;f=d+128|0;do{a[d>>0]=a[e>>0]|0;d=d+1|0;e=e+1|0}while((d|0)<(f|0));dc(g|0,88174,256)|0;d=h;e=406601;f=d+57|0;do{a[d>>0]=a[e>>0]|0;d=d+1|0;e=e+1|0}while((d|0)<(f|0));c[i>>2]=448}else{e=b+16|0;g=b+28|0;c:do if((h|0)>9){f=g;i=65}else{do if((h|0)>=5&(f|0)<17)if((h|0)<7){f=g;i=56;break}else{h=(h|0)<9?41:42;i=31;break}else i=31;while(0);d:do if((i|0)==31){f=g;e:do switch(h|0){case 10:{i=65;break c}case 40:{i=56;break d}case 2:{d=sa[c[e>>2]&1](c[b+24>>2]|0,262160)|0;if(!d)oa(1);else{c[g>>2]=d;d=f;i=69;break e}break}case 3:{d=sa[c[e>>2]&1](c[b+24>>2]|0,262164)|0;if(!d)oa(1);else{c[b+32>>2]=d;d=f;i=70;break e}break}case 4:{d=sa[c[e>>2]&1](c[b+24>>2]|0,524316)|0;if(!d)oa(1);else{c[b+36>>2]=d;d=f;i=71;break e}break}case 5:{d=sa[c[e>>2]&1](c[b+24>>2]|0,1081356)|0;if(!d)oa(1);else{c[b+40>>2]=d;d=f;i=72;break e}break}case 6:{d=sa[c[e>>2]&1](c[b+24>>2]|0,2129932)|0;if(!d)oa(1);else{c[b+44>>2]=d;d=f;i=73;break e}break}case 7:{d=sa[c[e>>2]&1](c[b+24>>2]|0,8454156)|0;if(!d)oa(1);else{c[b+48>>2]=d;d=f;i=74;break e}break}case 8:{d=sa[c[e>>2]&1](c[b+24>>2]|0,16842764)|0;if(!d)oa(1);else{c[b+52>>2]=d;d=f;i=75;break e}break}case 9:{d=sa[c[e>>2]&1](c[b+24>>2]|0,33619980)|0;if(!d)oa(1);else{c[b+56>>2]=d;d=f;i=76;break e}break}case 41:{d=sa[c[e>>2]&1](c[b+24>>2]|0,524304)|0;if(!d)oa(1);else{c[b+64>>2]=d;d=f;i=78;break e}break}case 42:{d=sa[c[e>>2]&1](c[b+24>>2]|0,1311760)|0;if(!d)oa(1);else{c[b+68>>2]=d;d=f;i=79;break e}break}default:{d=f;switch(h|0){case 10:break c;case 40:{j=d;break d}case 2:{i=69;break}case 3:{i=70;break}case 4:{i=71;break}case 5:{i=72;break}case 6:{i=73;break}case 7:{i=74;break}case 8:{i=75;break}case 9:{i=76;break}case 41:{i=78;break}case 42:{i=79;break}default:break b}}}while(0);switch(i|0){case 69:{b=c[d>>2]|0;a[b+262148>>0]=1;c[b+262152>>2]=0;c[b+262156>>2]=0;break b}case 70:{b=c[d+4>>2]|0;a[b+262152>>0]=1;c[b+262156>>2]=0;c[b+262160>>2]=0;break b}case 71:{b=c[d+8>>2]|0;a[b+524304>>0]=1;c[b+524308>>2]=0;c[b+524312>>2]=0;break b}case 72:{b=c[d+12>>2]|0;a[b+1081344>>0]=1;c[b+1081348>>2]=0;c[b+1081352>>2]=0;break b}case 73:{b=c[d+16>>2]|0;a[b+2129920>>0]=1;c[b+2129924>>2]=0;c[b+2129928>>2]=0;break b}case 74:{b=c[d+20>>2]|0;a[b+8454144>>0]=1;c[b+8454148>>2]=0;c[b+8454152>>2]=0;break b}case 75:{b=c[d+24>>2]|0;a[b+16842752>>0]=1;c[b+16842756>>2]=0;c[b+16842760>>2]=0;break b}case 76:{b=c[d+28>>2]|0;a[b+33619968>>0]=1;c[b+33619972>>2]=0;c[b+33619976>>2]=0;break b}case 78:{b=c[d+36>>2]|0;a[b+524290>>0]=1;c[b+524292>>2]=0;c[b+524296>>2]=0;break b}case 79:{b=c[d+40>>2]|0;a[b+1311744>>0]=1;c[b+1311748>>2]=0;c[b+1311752>>2]=0;break b}}}while(0);do if((i|0)==56){d=sa[c[e>>2]&1](c[b+24>>2]|0,524304)|0;if(!d)oa(1);else{c[b+60>>2]=d;j=f;break}}while(0);b=c[j+32>>2]|0;a[b+524290>>0]=1;c[b+524292>>2]=0;c[b+524296>>2]=0;break b}while(0);do if((i|0)==65){e=sa[c[e>>2]&1](c[b+24>>2]|0,524308)|0;if(!e)oa(1);else{c[f+44>>2]=e;d=c[f+44>>2]|0;c[d+524292>>2]=0;c[d+524300>>2]=0;a[d+524304>>0]=1;d=f;break}}while(0);a[(c[d+44>>2]|0)+524304>>0]=1}while(0);a[k>>0]=1;return 1}function Cb(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;b=(b|0)==0?32768:131072;f=256;while(1){if(!(f>>>0<b>>>0&f>>>0<d>>>0))break;f=f<<1}do if(f>>>0>=1025){b=a+4304|0;if(f>>>0<=(c[b>>2]|0)>>>0){g=c[a+4300>>2]|0;break}c[b>>2]=f;d=a+4300|0;b=a+24|0;ra[c[a+20>>2]&1](c[b>>2]|0,c[d>>2]|0);c[d>>2]=0;a=sa[c[a+16>>2]&1](c[b>>2]|0,f<<2)|0;b=a;if(!a)oa(1);else{c[d>>2]=b;g=b;break}}else g=a+204|0;while(0);c[e>>2]=f;ac(g|0,0,f<<2|0)|0;return g|0}
3277
4090
  function Pa(f,g,h,j,k,l,m,n,o,p,q,r,s){f=f|0;g=g|0;h=h|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=o|0;p=p|0;q=q|0;r=r|0;s=s|0;var t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,$=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0;qa=i;i=i+32|0;oa=qa+16|0;pa=qa;ma=(1<<c[m+8>>2])+-16|0;v=c[p>>2]|0;na=h+g|0;la=g>>>0>3?na+-3|0:h;ka=m+4|0;ja=(c[ka>>2]|0)<9?64:512;u=ja+h|0;if((((h|0)==0^1|j^1)^1)&g>>>0<513){f=0;while(1){if((f|0)==(g|0))break;ia=k+f|0;b[n+((_(d[ia>>0]|d[ia+1>>0]<<8|d[ia+2>>0]<<16|d[ia+3>>0]<<24,506832829)|0)>>>17<<1)>>1]=0;f=f+1|0}if(g){a[n+16842752>>0]=0;t=8}}else{f=n+16842752|0;if(!(a[f>>0]&1))t=8;else{ac(n|0,0,65536)|0;a[f>>0]=0;t=8}}if((t|0)==8?g>>>0>2&h>>>0>2:0){ga=h+-3|0;ha=k+(ga&l)|0;ha=(_(d[ha>>0]|d[ha+1>>0]<<8|d[ha+2>>0]<<16|d[ha+3>>0]<<24,506832829)|0)>>>17;ia=n+(ha<<1)|0;c[n+65536+((e[ia>>1]&127|ha<<7)<<2)>>2]=ga;b[ia>>1]=(b[ia>>1]|0)+1<<16>>16;ia=h+-2|0;ha=k+(ia&l)|0;ha=(_(d[ha>>0]|d[ha+1>>0]<<8|d[ha+2>>0]<<16|d[ha+3>>0]<<24,506832829)|0)>>>17;ga=n+(ha<<1)|0;c[n+65536+((e[ga>>1]&127|ha<<7)<<2)>>2]=ia;b[ga>>1]=(b[ga>>1]|0)+1<<16>>16;ga=h+-1|0;ha=k+(ga&l)|0;ha=(_(d[ha>>0]|d[ha+1>>0]<<8|d[ha+2>>0]<<16|d[ha+3>>0]<<24,506832829)|0)>>>17;ia=n+(ha<<1)|0;c[n+65536+((e[ia>>1]&127|ha<<7)<<2)>>2]=ga;b[ia>>1]=(b[ia>>1]|0)+1<<16>>16}P=oa+4|0;Q=oa+8|0;R=oa+12|0;S=oa+4|0;T=oa+8|0;U=oa+12|0;V=n+16842760|0;W=n+16842756|0;X=ja<<2;Y=na+-4|0;Z=na+-3|0;$=pa+12|0;ba=pa+4|0;ca=pa+8|0;da=pa+4|0;ea=pa+8|0;fa=pa+12|0;ga=o+8|0;ha=o+12|0;ia=o+4|0;m=h;O=q;f=v;a:while(1){M=O;N=u+X|0;b:while(1){L=na-m|0;if((m+4|0)>>>0>=na>>>0)break a;J=m>>>0<ma>>>0?m:ma;c[oa>>2]=0;c[P>>2]=0;c[Q>>2]=0;c[R>>2]=4240;K=m&l;g=c[oa>>2]|0;c[oa>>2]=0;c[S>>2]=0;I=k+K|0;H=K+L|0;G=k+H|0;F=I;H=k+(H+-4)|0;y=4240;j=0;x=0;while(1){if((x|0)==10)break;w=(c[o+(c[11372+(x<<2)>>2]<<2)>>2]|0)+(c[11436+(x<<2)>>2]|0)|0;t=m-w|0;do if(((!(t>>>0>=m>>>0|w>>>0>J>>>0)?(ra=t&l,sa=K+g|0,sa>>>0<=l>>>0):0)?(ta=ra+g|0,ta>>>0<=l>>>0):0)?(a[k+sa>>0]|0)==(a[k+ta>>0]|0):0){v=0;t=F;while(1){h=t;if(h>>>0>H>>>0)break;D=t;E=k+(ra+v)|0;if((d[D>>0]|d[D+1>>0]<<8|d[D+2>>0]<<16|d[D+3>>0]<<24|0)!=(d[E>>0]|d[E+1>>0]<<8|d[E+2>>0]<<16|d[E+3>>0]<<24|0))break;v=v+4|0;t=h+4|0}while(1){if(t>>>0>=G>>>0)break;if((a[k+(ra+v)>>0]|0)!=(a[t>>0]|0))break;v=v+1|0;t=t+1|0}if(v>>>0<=2?!((v|0)==2&x>>>0<2):0){t=y;break}t=(v*540|0)+(c[11500+(x<<2)>>2]|0)|0;if(y>>>0<t>>>0){c[oa>>2]=v;c[T>>2]=w;c[U>>2]=t;g=v;j=1}else t=y}else t=y;while(0);y=t;x=x+1|0}D=(_(d[I>>0]|d[I+1>>0]<<8|d[I+2>>0]<<16|d[I+3>>0]<<24,506832829)|0)>>>17;C=D<<7;D=n+(D<<1)|0;E=b[D>>1]|0;t=E&65535;E=(E&65535)>128?t+-128|0:0;c:while(1){B=K+g|0;A=B>>>0>l>>>0;B=k+B|0;while(1){if(t>>>0<=E>>>0)break c;t=t+-1|0;h=c[n+65536+((C|t&127)<<2)>>2]|0;z=m-h|0;if(z>>>0>J>>>0)break c;x=h&l;if(A)continue;h=x+g|0;if(h>>>0>l>>>0)continue;if((a[B>>0]|0)==(a[k+h>>0]|0)){w=0;h=F}else continue;while(1){v=h;if(v>>>0>H>>>0)break;Ia=h;Ha=k+(x+w)|0;if((d[Ia>>0]|d[Ia+1>>0]<<8|d[Ia+2>>0]<<16|d[Ia+3>>0]<<24|0)!=(d[Ha>>0]|d[Ha+1>>0]<<8|d[Ha+2>>0]<<16|d[Ha+3>>0]<<24|0))break;w=w+4|0;h=v+4|0}while(1){if(h>>>0>=G>>>0)break;if((a[k+(x+w)>>0]|0)!=(a[h>>0]|0))break;w=w+1|0;h=h+1|0}if(w>>>0<=3)continue;h=(w*540|0)+3840+(_((aa(z|0)|0)^31,-120)|0)|0;if(y>>>0<h>>>0)break}c[oa>>2]=w;c[T>>2]=z;c[U>>2]=h;g=w;y=h;j=1}Ia=b[D>>1]|0;c[n+65536+((C|Ia&127)<<2)>>2]=m;b[D>>1]=Ia+1<<16>>16;if(!(j&1)){if((c[V>>2]|0)>>>0<(c[W>>2]|0)>>>7>>>0)j=0;else{x=0;j=0;w=(_(d[I>>0]|d[I+1>>0]<<8|d[I+2>>0]<<16|d[I+3>>0]<<24,506832829)|0)>>>18<<1;while(1){if((x|0)==2)break;Ia=b[21084+(w<<1)>>1]|0;t=Ia&65535;c[W>>2]=(c[W>>2]|0)+1;if(Ia<<16>>16!=0?(ua=t&31,va=t>>>5,wa=(c[11272+(ua<<2)>>2]|0)+(_(ua,va)|0)|0,ua>>>0<=L>>>0):0){g=wa+ua|0;v=280811+g|0;g=280811+(g+-4)|0;h=0;t=280811+wa|0;while(1){if(t>>>0>g>>>0)break;Ia=k+(K+h)|0;if((d[t>>0]|d[t+1>>0]<<8|d[t+2>>0]<<16|d[t+3>>0]<<24|0)!=(d[Ia>>0]|d[Ia+1>>0]<<8|d[Ia+2>>0]<<16|d[Ia+3>>0]<<24|0))break;h=h+4|0;t=t+4|0}while(1){if(t>>>0>=v>>>0)break;if((a[k+(K+h)>>0]|0)!=(a[t>>0]|0))break;h=h+1|0;t=t+1|0}if(!((h+10|0)>>>0<=ua>>>0|(h|0)==0)?(xa=J+va+1+(d[407930+(ua-h)>>0]<<d[280786+ua>>0])|0,ya=(h*540|0)+3840+(_((aa(xa|0)|0)^31,-120)|0)|0,ya>>>0>=(c[U>>2]|0)>>>0):0){c[oa>>2]=h;c[S>>2]=ua^h;c[T>>2]=xa;c[U>>2]=ya;c[V>>2]=(c[V>>2]|0)+1;j=1}}x=x+1|0;w=w+1|0}j=(j&1)!=0}j=j&1}if(j&1){M=0;x=f;break}f=f+1|0;t=m+1|0;if(t>>>0<=u>>>0){m=t;continue}if(t>>>0>N>>>0){j=m+17|0;j=j>>>0<Y>>>0?j:Y;m=t;while(1){if(m>>>0>=j>>>0)continue b;Ha=k+(m&l)|0;Ha=(_(d[Ha>>0]|d[Ha+1>>0]<<8|d[Ha+2>>0]<<16|d[Ha+3>>0]<<24,506832829)|0)>>>17;Ia=n+(Ha<<1)|0;c[n+65536+((e[Ia>>1]&127|Ha<<7)<<2)>>2]=m;b[Ia>>1]=(b[Ia>>1]|0)+1<<16>>16;m=m+4|0;f=f+4|0}}else{j=m+9|0;j=j>>>0<Z>>>0?j:Z;m=t;while(1){if(m>>>0>=j>>>0)continue b;Ha=k+(m&l)|0;Ha=(_(d[Ha>>0]|d[Ha+1>>0]<<8|d[Ha+2>>0]<<16|d[Ha+3>>0]<<24,506832829)|0)>>>17;Ia=n+(Ha<<1)|0;c[n+65536+((e[Ia>>1]&127|Ha<<7)<<2)>>2]=m;b[Ia>>1]=(b[Ia>>1]|0)+1<<16>>16;m=m+2|0;f=f+2|0}}}while(1){L=L+-1|0;if((c[ka>>2]|0)<5){f=(c[oa>>2]|0)+-1|0;f=f>>>0<L>>>0?f:L}else f=0;c[pa>>2]=f;c[ba>>2]=0;c[ca>>2]=0;c[$>>2]=4240;y=m+1|0;J=y>>>0<ma>>>0?y:ma;K=y&l;t=c[pa>>2]|0;c[pa>>2]=0;c[da>>2]=0;I=k+K|0;H=K+L|0;G=k+H|0;F=I;H=k+(H+-4)|0;w=4240;f=0;v=0;while(1){if((v|0)==10)break;h=(c[o+(c[11372+(v<<2)>>2]<<2)>>2]|0)+(c[11436+(v<<2)>>2]|0)|0;j=y-h|0;do if(((!(j>>>0>=y>>>0|h>>>0>J>>>0)?(za=j&l,Aa=K+t|0,Aa>>>0<=l>>>0):0)?(Ba=za+t|0,Ba>>>0<=l>>>0):0)?(a[k+Aa>>0]|0)==(a[k+Ba>>0]|0):0){u=0;j=F;while(1){g=j;if(g>>>0>H>>>0)break;Ha=j;Ia=k+(za+u)|0;if((d[Ha>>0]|d[Ha+1>>0]<<8|d[Ha+2>>0]<<16|d[Ha+3>>0]<<24|0)!=(d[Ia>>0]|d[Ia+1>>0]<<8|d[Ia+2>>0]<<16|d[Ia+3>>0]<<24|0))break;u=u+4|0;j=g+4|0}while(1){if(j>>>0>=G>>>0)break;if((a[k+(za+u)>>0]|0)!=(a[j>>0]|0))break;u=u+1|0;j=j+1|0}if(u>>>0<=2?!((u|0)==2&v>>>0<2):0){j=w;break}j=(u*540|0)+(c[11500+(v<<2)>>2]|0)|0;if(w>>>0<j>>>0){c[pa>>2]=u;c[ea>>2]=h;c[fa>>2]=j;t=u;f=1}else j=w}else j=w;while(0);w=j;v=v+1|0}D=(_(d[I>>0]|d[I+1>>0]<<8|d[I+2>>0]<<16|d[I+3>>0]<<24,506832829)|0)>>>17;C=D<<7;D=n+(D<<1)|0;E=b[D>>1]|0;j=E&65535;E=(E&65535)>128?j+-128|0:0;d:while(1){B=K+t|0;A=B>>>0>l>>>0;B=k+B|0;while(1){if(j>>>0<=E>>>0)break d;j=j+-1|0;g=c[n+65536+((C|j&127)<<2)>>2]|0;z=y-g|0;if(z>>>0>J>>>0)break d;v=g&l;if(A)continue;g=v+t|0;if(g>>>0>l>>>0)continue;if((a[B>>0]|0)==(a[k+g>>0]|0)){h=0;g=F}else continue;while(1){u=g;if(u>>>0>H>>>0)break;Ha=g;Ia=k+(v+h)|0;if((d[Ha>>0]|d[Ha+1>>0]<<8|d[Ha+2>>0]<<16|d[Ha+3>>0]<<24|0)!=(d[Ia>>0]|d[Ia+1>>0]<<8|d[Ia+2>>0]<<16|d[Ia+3>>0]<<24|0))break;h=h+4|0;g=u+4|0}while(1){if(g>>>0>=G>>>0)break;if((a[k+(v+h)>>0]|0)!=(a[g>>0]|0))break;h=h+1|0;g=g+1|0}if(h>>>0<=3)continue;g=(h*540|0)+3840+(_((aa(z|0)|0)^31,-120)|0)|0;if(w>>>0<g>>>0)break}c[pa>>2]=h;c[ea>>2]=z;c[fa>>2]=g;t=h;w=g;f=1}Ia=b[D>>1]|0;c[n+65536+((C|Ia&127)<<2)>>2]=y;b[D>>1]=Ia+1<<16>>16;if(!(f&1)){if((c[V>>2]|0)>>>0<(c[W>>2]|0)>>>7>>>0)f=0;else{v=0;f=0;h=(_(d[I>>0]|d[I+1>>0]<<8|d[I+2>>0]<<16|d[I+3>>0]<<24,506832829)|0)>>>18<<1;while(1){if((v|0)==2)break;Ia=b[21084+(h<<1)>>1]|0;j=Ia&65535;c[W>>2]=(c[W>>2]|0)+1;if(Ia<<16>>16!=0?(Ca=j&31,Da=j>>>5,Ea=(c[11272+(Ca<<2)>>2]|0)+(_(Ca,Da)|0)|0,Ca>>>0<=L>>>0):0){t=Ea+Ca|0;u=280811+t|0;t=280811+(t+-4)|0;g=0;j=280811+Ea|0;while(1){if(j>>>0>t>>>0)break;Ia=k+(K+g)|0;if((d[j>>0]|d[j+1>>0]<<8|d[j+2>>0]<<16|d[j+3>>0]<<24|0)!=(d[Ia>>0]|d[Ia+1>>0]<<8|d[Ia+2>>0]<<16|d[Ia+3>>0]<<24|0))break;g=g+4|0;j=j+4|0}while(1){if(j>>>0>=u>>>0)break;if((a[k+(K+g)>>0]|0)!=(a[j>>0]|0))break;g=g+1|0;j=j+1|0}if(!((g+10|0)>>>0<=Ca>>>0|(g|0)==0)?(Fa=J+Da+1+(d[407930+(Ca-g)>>0]<<d[280786+Ca>>0])|0,Ga=(g*540|0)+3840+(_((aa(Fa|0)|0)^31,-120)|0)|0,Ga>>>0>=(c[fa>>2]|0)>>>0):0){c[pa>>2]=g;c[da>>2]=Ca^g;c[ea>>2]=Fa;c[fa>>2]=Ga;c[V>>2]=(c[V>>2]|0)+1;f=1}}v=v+1|0;h=h+1|0}f=(f&1)!=0}f=f&1}if(!(f&1)){y=m;break}if((c[$>>2]|0)>>>0<((c[R>>2]|0)+700|0)>>>0){y=m;break}f=x+1|0;c[oa>>2]=c[pa>>2];c[oa+4>>2]=c[pa+4>>2];c[oa+8>>2]=c[pa+8>>2];c[oa+12>>2]=c[pa+12>>2];M=M+1|0;if(!((M|0)<4&(m+5|0)>>>0<na>>>0)){x=f;break}else{m=y;x=f}}m=c[oa>>2]|0;u=y+(m<<1)+ja|0;f=c[Q>>2]|0;e:do if(f>>>0<=(y>>>0<ma>>>0?y:ma)>>>0){g=f+3|0;Ia=c[o>>2]|0;j=g-Ia|0;t=c[ia>>2]|0;g=g-t|0;if((f|0)==(Ia|0))f=0;else{f:do if((f|0)!=(t|0)){do if(j>>>0<7)f=158663784>>>(j<<2)&15;else{if(g>>>0<7){f=266017486>>>(g<<2)&15;break}if((f|0)==(c[ga>>2]|0)){f=2;break f}if((f|0)==(c[ha>>2]|0)){f=3;break f}f=f+15|0}while(0);if(!f)break e}else f=1;while(0);c[ha>>2]=c[ga>>2];c[ga>>2]=c[ia>>2];c[ia>>2]=c[o>>2];c[o>>2]=c[Q>>2];m=c[oa>>2]|0}}else f=f+15|0;while(0);w=O+16|0;Ia=c[P>>2]|0;j=m^Ia;c[O>>2]=x;c[O+4>>2]=m|Ia<<24;m=O+14|0;if(f>>>0<16){f=f&65535;b[m>>1]=f;m=0}else{N=f+-12|0;Ia=((aa(N|0)|0)^31)+-1|0;Ha=N>>>Ia&1;f=((Ia<<1)+65534|Ha)+16&65535;b[m>>1]=f;m=Ia<<24|N-((Ha|2)<<Ia)}c[O+8>>2]=m;h=f<<16>>16==0;v=O+12|0;do if(x>>>0>=6){if(x>>>0<130){Ia=x+-2|0;g=((aa(Ia|0)|0)^31)+-1|0;g=(g<<1)+(Ia>>>g)+2&65535;break}if(x>>>0<2114){g=((aa(x+-66|0)|0)^31)+10&65535;break}if(x>>>0<6210)g=21;else g=x>>>0<22594?22:23}else g=x&65535;while(0);do if(j>>>0>=10){if(j>>>0<134){Ia=j+-6|0;f=((aa(Ia|0)|0)^31)+-1|0;f=(f<<1)+(Ia>>>f)+4&65535;break}if(j>>>0<2118)f=((aa(j+-70|0)|0)^31)+12&65535;else f=23}else f=j+65534&65535;while(0);m=f&65535;j=g&65535;t=m&7|j<<3&56;if(h&(g&65535)<8&(f&65535)<16)f=((f&65535)<8?t:t|64)&65535;else f=b[88156+((m>>>3)+((j>>>3)*3|0)<<1)>>1]|t&65535;b[v>>1]=f;c[s>>2]=(c[s>>2]|0)+x;f=y+(c[oa>>2]|0)|0;f=f>>>0<la>>>0?f:la;m=y+2|0;while(1){if(m>>>0>=f>>>0)break;Ha=k+(m&l)|0;Ha=(_(d[Ha>>0]|d[Ha+1>>0]<<8|d[Ha+2>>0]<<16|d[Ha+3>>0]<<24,506832829)|0)>>>17;Ia=n+(Ha<<1)|0;c[n+65536+((e[Ia>>1]&127|Ha<<7)<<2)>>2]=m;b[Ia>>1]=(b[Ia>>1]|0)+1<<16>>16;m=m+1|0}m=y+(c[oa>>2]|0)|0;O=w;f=0}c[p>>2]=f+L;c[r>>2]=(c[r>>2]|0)+(M-q>>4);i=qa;return}function Qa(f,g,h,j,k,l,m,n,o,p,q,r,s){f=f|0;g=g|0;h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832829)|0)>>>17;ga=n+(ha<<1)|0;c[n+65536+((e[ga>>1]&255|ha<<8)<<2)>>2]=ia;b[ga>>1]=(b[ga>>1]|0)+1<<16>>16;ga=h+-1|0;ha=k+(ga&l)|0;ha=(_(d[ha>>0]|d[ha+1>>0]<<8|d[ha+2>>0]<<16|d[ha+3>>0]<<24,506832829)|0)>>>17;ia=n+(ha<<1)|0;c[n+65536+((e[ia>>1]&255|ha<<8)<<2)>>2]=ga;b[ia>>1]=(b[ia>>1]|0)+1<<16>>16}P=oa+4|0;Q=oa+8|0;R=oa+12|0;S=oa+4|0;T=oa+8|0;U=oa+12|0;V=n+33619976|0;W=n+33619972|0;X=ja<<2;Y=na+-4|0;Z=na+-3|0;$=pa+12|0;ba=pa+4|0;ca=pa+8|0;da=pa+4|0;ea=pa+8|0;fa=pa+12|0;ga=o+8|0;ha=o+12|0;ia=o+4|0;m=h;O=q;f=v;a:while(1){M=O;N=u+X|0;b:while(1){L=na-m|0;if((m+4|0)>>>0>=na>>>0)break a;J=m>>>0<ma>>>0?m:ma;c[oa>>2]=0;c[P>>2]=0;c[Q>>2]=0;c[R>>2]=4240;K=m&l;g=c[oa>>2]|0;c[oa>>2]=0;c[S>>2]=0;I=k+K|0;H=K+L|0;G=k+H|0;F=I;H=k+(H+-4)|0;y=4240;j=0;x=0;while(1){if((x|0)==16)break;w=(c[o+(c[11372+(x<<2)>>2]<<2)>>2]|0)+(c[11436+(x<<2)>>2]|0)|0;t=m-w|0;do if(((!(t>>>0>=m>>>0|w>>>0>J>>>0)?(ra=t&l,sa=K+g|0,sa>>>0<=l>>>0):0)?(ta=ra+g|0,ta>>>0<=l>>>0):0)?(a[k+sa>>0]|0)==(a[k+ta>>0]|0):0){v=0;t=F;while(1){h=t;if(h>>>0>H>>>0)break;D=t;E=k+(ra+v)|0;if((d[D>>0]|d[D+1>>0]<<8|d[D+2>>0]<<16|d[D+3>>0]<<24|0)!=(d[E>>0]|d[E+1>>0]<<8|d[E+2>>0]<<16|d[E+3>>0]<<24|0))break;v=v+4|0;t=h+4|0}while(1){if(t>>>0>=G>>>0)break;if((a[k+(ra+v)>>0]|0)!=(a[t>>0]|0))break;v=v+1|0;t=t+1|0}if(v>>>0<=2?!((v|0)==2&x>>>0<2):0){t=y;break}t=(v*540|0)+(c[11500+(x<<2)>>2]|0)|0;if(y>>>0<t>>>0){c[oa>>2]=v;c[T>>2]=w;c[U>>2]=t;g=v;j=1}else t=y}else t=y;while(0);y=t;x=x+1|0}D=(_(d[I>>0]|d[I+1>>0]<<8|d[I+2>>0]<<16|d[I+3>>0]<<24,506832829)|0)>>>17;C=D<<8;D=n+(D<<1)|0;E=b[D>>1]|0;t=E&65535;E=(E&65535)>256?t+-256|0:0;c:while(1){B=K+g|0;A=B>>>0>l>>>0;B=k+B|0;while(1){if(t>>>0<=E>>>0)break c;t=t+-1|0;h=c[n+65536+((C|t&255)<<2)>>2]|0;z=m-h|0;if(z>>>0>J>>>0)break c;x=h&l;if(A)continue;h=x+g|0;if(h>>>0>l>>>0)continue;if((a[B>>0]|0)==(a[k+h>>0]|0)){w=0;h=F}else continue;while(1){v=h;if(v>>>0>H>>>0)break;Ia=h;Ha=k+(x+w)|0;if((d[Ia>>0]|d[Ia+1>>0]<<8|d[Ia+2>>0]<<16|d[Ia+3>>0]<<24|0)!=(d[Ha>>0]|d[Ha+1>>0]<<8|d[Ha+2>>0]<<16|d[Ha+3>>0]<<24|0))break;w=w+4|0;h=v+4|0}while(1){if(h>>>0>=G>>>0)break;if((a[k+(x+w)>>0]|0)!=(a[h>>0]|0))break;w=w+1|0;h=h+1|0}if(w>>>0<=3)continue;h=(w*540|0)+3840+(_((aa(z|0)|0)^31,-120)|0)|0;if(y>>>0<h>>>0)break}c[oa>>2]=w;c[T>>2]=z;c[U>>2]=h;g=w;y=h;j=1}Ia=b[D>>1]|0;c[n+65536+((C|Ia&255)<<2)>>2]=m;b[D>>1]=Ia+1<<16>>16;if(!(j&1)){if((c[V>>2]|0)>>>0<(c[W>>2]|0)>>>7>>>0)j=0;else{x=0;j=0;w=(_(d[I>>0]|d[I+1>>0]<<8|d[I+2>>0]<<16|d[I+3>>0]<<24,506832829)|0)>>>18<<1;while(1){if((x|0)==2)break;Ia=b[21084+(w<<1)>>1]|0;t=Ia&65535;c[W>>2]=(c[W>>2]|0)+1;if(Ia<<16>>16!=0?(ua=t&31,va=t>>>5,wa=(c[11272+(ua<<2)>>2]|0)+(_(ua,va)|0)|0,ua>>>0<=L>>>0):0){g=wa+ua|0;v=280811+g|0;g=280811+(g+-4)|0;h=0;t=280811+wa|0;while(1){if(t>>>0>g>>>0)break;Ia=k+(K+h)|0;if((d[t>>0]|d[t+1>>0]<<8|d[t+2>>0]<<16|d[t+3>>0]<<24|0)!=(d[Ia>>0]|d[Ia+1>>0]<<8|d[Ia+2>>0]<<16|d[Ia+3>>0]<<24|0))break;h=h+4|0;t=t+4|0}while(1){if(t>>>0>=v>>>0)break;if((a[k+(K+h)>>0]|0)!=(a[t>>0]|0))break;h=h+1|0;t=t+1|0}if(!((h+10|0)>>>0<=ua>>>0|(h|0)==0)?(xa=J+va+1+(d[407930+(ua-h)>>0]<<d[280786+ua>>0])|0,ya=(h*540|0)+3840+(_((aa(xa|0)|0)^31,-120)|0)|0,ya>>>0>=(c[U>>2]|0)>>>0):0){c[oa>>2]=h;c[S>>2]=ua^h;c[T>>2]=xa;c[U>>2]=ya;c[V>>2]=(c[V>>2]|0)+1;j=1}}x=x+1|0;w=w+1|0}j=(j&1)!=0}j=j&1}if(j&1){M=0;x=f;break}f=f+1|0;t=m+1|0;if(t>>>0<=u>>>0){m=t;continue}if(t>>>0>N>>>0){j=m+17|0;j=j>>>0<Y>>>0?j:Y;m=t;while(1){if(m>>>0>=j>>>0)continue b;Ha=k+(m&l)|0;Ha=(_(d[Ha>>0]|d[Ha+1>>0]<<8|d[Ha+2>>0]<<16|d[Ha+3>>0]<<24,506832829)|0)>>>17;Ia=n+(Ha<<1)|0;c[n+65536+((e[Ia>>1]&255|Ha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>>0<=2?!((u|0)==2&v>>>0<2):0){j=w;break}j=(u*540|0)+(c[11500+(v<<2)>>2]|0)|0;if(w>>>0<j>>>0){c[pa>>2]=u;c[ea>>2]=h;c[fa>>2]=j;t=u;f=1}else j=w}else j=w;while(0);w=j;v=v+1|0}D=(_(d[I>>0]|d[I+1>>0]<<8|d[I+2>>0]<<16|d[I+3>>0]<<24,506832829)|0)>>>17;C=D<<8;D=n+(D<<1)|0;E=b[D>>1]|0;j=E&65535;E=(E&65535)>256?j+-256|0:0;d:while(1){B=K+t|0;A=B>>>0>l>>>0;B=k+B|0;while(1){if(j>>>0<=E>>>0)break d;j=j+-1|0;g=c[n+65536+((C|j&255)<<2)>>2]|0;z=y-g|0;if(z>>>0>J>>>0)break d;v=g&l;if(A)continue;g=v+t|0;if(g>>>0>l>>>0)continue;if((a[B>>0]|0)==(a[k+g>>0]|0)){h=0;g=F}else continue;while(1){u=g;if(u>>>0>H>>>0)break;Ha=g;Ia=k+(v+h)|0;if((d[Ha>>0]|d[Ha+1>>0]<<8|d[Ha+2>>0]<<16|d[Ha+3>>0]<<24|0)!=(d[Ia>>0]|d[Ia+1>>0]<<8|d[Ia+2>>0]<<16|d[Ia+3>>0]<<24|0))break;h=h+4|0;g=u+4|0}while(1){if(g>>>0>=G>>>0)break;if((a[k+(v+h)>>0]|0)!=(a[g>>0]|0))break;h=h+1|0;g=g+1|0}if(h>>>0<=3)continue;g=(h*540|0)+3840+(_((aa(z|0)|0)^31,-120)|0)|0;if(w>>>0<g>>>0)break}c[pa>>2]=h;c[ea>>2]=z;c[fa>>2]=g;t=h;w=g;f=1}Ia=b[D>>1]|0;c[n+65536+((C|Ia&255)<<2)>>2]=y;b[D>>1]=Ia+1<<16>>16;if(!(f&1)){if((c[V>>2]|0)>>>0<(c[W>>2]|0)>>>7>>>0)f=0;else{v=0;f=0;h=(_(d[I>>0]|d[I+1>>0]<<8|d[I+2>>0]<<16|d[I+3>>0]<<24,506832829)|0)>>>18<<1;while(1){if((v|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t|0;if((f|0)==(Ia|0))f=0;else{f:do if((f|0)!=(t|0)){do if(j>>>0<7)f=158663784>>>(j<<2)&15;else{if(g>>>0<7){f=266017486>>>(g<<2)&15;break}if((f|0)==(c[ga>>2]|0)){f=2;break f}if((f|0)==(c[ha>>2]|0)){f=3;break f}f=f+15|0}while(0);if(!f)break e}else f=1;while(0);c[ha>>2]=c[ga>>2];c[ga>>2]=c[ia>>2];c[ia>>2]=c[o>>2];c[o>>2]=c[Q>>2];m=c[oa>>2]|0}}else f=f+15|0;while(0);w=O+16|0;Ia=c[P>>2]|0;j=m^Ia;c[O>>2]=x;c[O+4>>2]=m|Ia<<24;m=O+14|0;if(f>>>0<16){f=f&65535;b[m>>1]=f;m=0}else{N=f+-12|0;Ia=((aa(N|0)|0)^31)+-1|0;Ha=N>>>Ia&1;f=((Ia<<1)+65534|Ha)+16&65535;b[m>>1]=f;m=Ia<<24|N-((Ha|2)<<Ia)}c[O+8>>2]=m;h=f<<16>>16==0;v=O+12|0;do if(x>>>0>=6){if(x>>>0<130){Ia=x+-2|0;g=((aa(Ia|0)|0)^31)+-1|0;g=(g<<1)+(Ia>>>g)+2&65535;break}if(x>>>0<2114){g=((aa(x+-66|0)|0)^31)+10&65535;break}if(x>>>0<6210)g=21;else g=x>>>0<22594?22:23}else g=x&65535;while(0);do if(j>>>0>=10){if(j>>>0<134){Ia=j+-6|0;f=((aa(Ia|0)|0)^31)+-1|0;f=(f<<1)+(Ia>>>f)+4&65535;break}if(j>>>0<2118)f=((aa(j+-70|0)|0)^31)+12&65535;else f=23}else f=j+65534&65535;while(0);m=f&65535;j=g&65535;t=m&7|j<<3&56;if(h&(g&65535)<8&(f&65535)<16)f=((f&65535)<8?t:t|64)&65535;else f=b[88156+((m>>>3)+((j>>>3)*3|0)<<1)>>1]|t&65535;b[v>>1]=f;c[s>>2]=(c[s>>2]|0)+x;f=y+(c[oa>>2]|0)|0;f=f>>>0<la>>>0?f:la;m=y+2|0;while(1){if(m>>>0>=f>>>0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1|0}ac(n+196608|0,0,65536)|0;b[n+524288>>1]=0;if(g){a[n+524290>>0]=0;ra=8}}else{f=n+524290|0;if(!(a[f>>0]&1))ra=8;else{ac(n|0,-52,131072)|0;b[n+524288>>1]=0;a[f>>0]=0;ac(n+131072|0,0,131072)|0;ra=8}}if((ra|0)==8?g>>>0>2&h>>>0>2:0){da=h+-3|0;ga=k+(da&l)|0;ga=(_(d[ga>>0]|d[ga+1>>0]<<8|d[ga+2>>0]<<16|d[ga+3>>0]<<24,506832829)|0)>>>17;ea=n+524288|0;fa=b[ea>>1]|0;b[ea>>1]=fa+1<<16>>16;ha=fa&65535;ia=n+(ga<<2)|0;ca=da-(c[ia>>2]|0)|0;a[(da&65535)+(n+196608)>>0]=ga;b[n+262144+(ha<<2)>>1]=ca>>>0>65535?65535:ca;ga=n+131072+(ga<<1)|0;b[n+262144+(ha<<2)+2>>1]=b[ga>>1]|0;c[ia>>2]=da;b[ga>>1]=fa;ga=h+-2|0;fa=k+(ga&l)|0;fa=(_(d[fa>>0]|d[fa+1>>0]<<8|d[fa+2>>0]<<16|d[fa+3>>0]<<24,506832829)|0)>>>17;ia=b[ea>>1]|0;b[ea>>1]=ia+1<<16>>16;da=ia&65535;ha=n+(fa<<2)|0;ca=ga-(c[ha>>2]|0)|0;a[(ga&65535)+(n+196608)>>0]=fa;b[n+262144+(da<<2)>>1]=ca>>>0>65535?65535:ca;fa=n+131072+(fa<<1)|0;b[n+262144+(da<<2)+2>>1]=b[fa>>1]|0;c[ha>>2]=ga;b[fa>>1]=ia;fa=h+-1|0;ia=k+(fa&l)|0;ia=(_(d[ia>>0]|d[ia+1>>0]<<8|d[ia+2>>0]<<16|d[ia+3>>0]<<24,506832829)|0)>>>17;ha=b[ea>>1]|0;b[ea>>1]=ha+1<<16>>16;ea=ha&65535;ga=n+(ia<<2)|0;da=fa-(c[ga>>2]|0)|0;a[(fa&65535)+(n+196608)>>0]=ia;b[n+262144+(ea<<2)>>1]=da>>>0>65535?65535:da;ia=n+131072+(ia<<1)|0;b[n+262144+(ea<<2)+2>>1]=b[ia>>1]|0;c[ga>>2]=fa;b[ia>>1]=ha}O=pa+4|0;P=pa+8|0;Q=pa+12|0;R=pa+4|0;S=pa+8|0;T=pa+12|0;U=n+524288|0;V=n+524296|0;W=n+524292|0;X=ja<<2;Y=oa+-4|0;Z=oa+-3|0;$=qa+12|0;ba=qa+4|0;ca=qa+8|0;da=qa+4|0;ea=qa+8|0;fa=qa+12|0;ga=o+8|0;ha=o+12|0;ia=o+4|0;m=h;N=q;f=u;a:while(1){L=N;M=t+X|0;b:while(1){K=oa-m|0;if((m+4|0)>>>0>=oa>>>0)break a;I=m>>>0<na>>>0?m:na;c[pa>>2]=0;c[O>>2]=0;c[P>>2]=0;c[Q>>2]=4240;J=m&l;z=c[pa>>2]|0;H=k+J|0;B=(_(d[H>>0]|d[H+1>>0]<<8|d[H+2>>0]<<16|d[H+3>>0]<<24,506832829)|0)>>>17;y=B&255;c[pa>>2]=0;c[R>>2]=0;G=J+K|0;F=k+G|0;E=H;G=k+(G+-4)|0;h=4240;j=0;A=0;while(1){if((A|0)==4)break;x=(c[o+(c[11372+(A<<2)>>2]<<2)>>2]|0)+(c[11436+(A<<2)>>2]|0)|0;g=m-x|0;if(!A)if(g>>>0>=m>>>0|x>>>0>I>>>0)g=z;else ra=17;else if((g>>>0<m>>>0?(a[(g&65535)+(n+196608)>>0]|0)==y<<24>>24:0)^1|x>>>0>I>>>0)g=z;else ra=17;if((ra|0)==17){ra=0;w=g&l;g=0;u=E;while(1){v=u;if(v>>>0>G>>>0)break;C=u;D=k+(w+g)|0;if((d[C>>0]|d[C+1>>0]<<8|d[C+2>>0]<<16|d[C+3>>0]<<24|0)!=(d[D>>0]|d[D+1>>0]<<8|d[D+2>>0]<<16|d[D+3>>0]<<24|0))break;g=g+4|0;u=v+4|0}while(1){if(u>>>0>=F>>>0)break;if((a[k+(w+g)>>0]|0)!=(a[u>>0]|0))break;g=g+1|0;u=u+1|0}if(g>>>0>1?(ta=(g*540|0)+(c[11500+(A<<2)>>2]|0)|0,h>>>0<ta>>>0):0){c[pa>>2]=g;c[S>>2]=x;c[T>>2]=ta;h=ta;j=1}else g=z}z=g;A=A+1|0}w=0;u=m-(c[n+(B<<2)>>2]|0)|0;v=c[ka>>2]|0;g=e[n+131072+(B<<1)>>1]|0;c:while(1){D=J+z|0;C=D>>>0>l>>>0;D=k+D|0;x=w;y=u;A=v;B=g;while(1){w=A;A=A+-1|0;if(!w)break c;x=x+y|0;if(x>>>0>I>>>0)break c;w=m-x&l;y=B;B=e[n+262144+(B<<2)+2>>1]|0;y=e[n+262144+(y<<2)>>1]|0;if(C)continue;g=w+z|0;if(g>>>0>l>>>0)continue;if((a[D>>0]|0)==(a[k+g>>0]|0)){v=0;g=E}else continue;while(1){u=g;if(u>>>0>G>>>0)break;Ga=g;Fa=k+(w+v)|0;if((d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24|0)!=(d[Fa>>0]|d[Fa+1>>0]<<8|d[Fa+2>>0]<<16|d[Fa+3>>0]<<24|0))break;v=v+4|0;g=u+4|0}while(1){if(g>>>0>=F>>>0)break;if((a[k+(w+v)>>0]|0)!=(a[g>>0]|0))break;v=v+1|0;g=g+1|0}if(v>>>0<=3)continue;g=(v*540|0)+3840+(_((aa(x|0)|0)^31,-120)|0)|0;if(h>>>0<g>>>0)break}c[pa>>2]=v;c[S>>2]=x;c[T>>2]=g;w=x;z=v;h=g;u=y;v=A;j=1;g=B}Ga=(_(d[H>>0]|d[H+1>>0]<<8|d[H+2>>0]<<16|d[H+3>>0]<<24,506832829)|0)>>>17;Fa=b[U>>1]|0;b[U>>1]=Fa+1<<16>>16;F=Fa&65535;G=n+(Ga<<2)|0;E=m-(c[G>>2]|0)|0;a[(m&65535)+(n+196608)>>0]=Ga;b[n+262144+(F<<2)>>1]=E>>>0>65535?65535:E;Ga=n+131072+(Ga<<1)|0;b[n+262144+(F<<2)+2>>1]=b[Ga>>1]|0;c[G>>2]=m;b[Ga>>1]=Fa;if(!(j&1)){if((c[V>>2]|0)>>>0<(c[W>>2]|0)>>>7>>>0)j=0;else{x=0;j=0;w=(_(d[H>>0]|d[H+1>>0]<<8|d[H+2>>0]<<16|d[H+3>>0]<<24,506832829)|0)>>>18<<1;while(1){if((x|0)==2)break;Ga=b[21084+(w<<1)>>1]|0;g=Ga&65535;c[W>>2]=(c[W>>2]|0)+1;if(Ga<<16>>16!=0?(ua=g&31,va=g>>>5,wa=(c[11272+(ua<<2)>>2]|0)+(_(ua,va)|0)|0,ua>>>0<=K>>>0):0){h=wa+ua|0;v=280811+h|0;h=280811+(h+-4)|0;u=0;g=280811+wa|0;while(1){if(g>>>0>h>>>0)break;Ga=k+(J+u)|0;if((d[g>>0]|d[g+1>>0]<<8|d[g+2>>0]<<16|d[g+3>>0]<<24|0)!=(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24|0))break;u=u+4|0;g=g+4|0}while(1){if(g>>>0>=v>>>0)break;if((a[k+(J+u)>>0]|0)!=(a[g>>0]|0))break;u=u+1|0;g=g+1|0}if(!((u+10|0)>>>0<=ua>>>0|(u|0)==0)?(xa=I+va+1+(d[407930+(ua-u)>>0]<<d[280786+ua>>0])|0,ya=(u*540|0)+3840+(_((aa(xa|0)|0)^31,-120)|0)|0,ya>>>0>=(c[T>>2]|0)>>>0):0){c[pa>>2]=u;c[R>>2]=ua^u;c[S>>2]=xa;c[T>>2]=ya;c[V>>2]=(c[V>>2]|0)+1;j=1}}x=x+1|0;w=w+1|0}j=(j&1)!=0}j=j&1}if(j&1){L=0;x=f;break}f=f+1|0;g=m+1|0;if(g>>>0<=t>>>0){m=g;continue}if(g>>>0>M>>>0){j=m+17|0;j=j>>>0<Y>>>0?j:Y;m=g;while(1){if(m>>>0>=j>>>0)continue b;Ga=k+(m&l)|0;Ga=(_(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24,506832829)|0)>>>17;Fa=b[U>>1]|0;b[U>>1]=Fa+1<<16>>16;J=Fa&65535;K=n+(Ga<<2)|0;I=m-(c[K>>2]|0)|0;a[(m&65535)+(n+196608)>>0]=Ga;b[n+262144+(J<<2)>>1]=I>>>0>65535?65535:I;Ga=n+131072+(Ga<<1)|0;b[n+262144+(J<<2)+2>>1]=b[Ga>>1]|0;c[K>>2]=m;b[Ga>>1]=Fa;m=m+4|0;f=f+4|0}}else{j=m+9|0;j=j>>>0<Z>>>0?j:Z;m=g;while(1){if(m>>>0>=j>>>0)continue b;Ga=k+(m&l)|0;Ga=(_(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24,506832829)|0)>>>17;Fa=b[U>>1]|0;b[U>>1]=Fa+1<<16>>16;J=Fa&65535;K=n+(Ga<<2)|0;I=m-(c[K>>2]|0)|0;a[(m&65535)+(n+196608)>>0]=Ga;b[n+262144+(J<<2)>>1]=I>>>0>65535?65535:I;Ga=n+131072+(Ga<<1)|0;b[n+262144+(J<<2)+2>>1]=b[Ga>>1]|0;c[K>>2]=m;b[Ga>>1]=Fa;m=m+2|0;f=f+2|0}}}while(1){K=K+-1|0;if((c[la>>2]|0)<5){f=(c[pa>>2]|0)+-1|0;f=f>>>0<K>>>0?f:K}else f=0;c[qa>>2]=f;c[ba>>2]=0;c[ca>>2]=0;c[$>>2]=4240;y=m+1|0;I=y>>>0<na>>>0?y:na;J=y&l;z=c[qa>>2]|0;H=k+J|0;B=(_(d[H>>0]|d[H+1>>0]<<8|d[H+2>>0]<<16|d[H+3>>0]<<24,506832829)|0)>>>17;w=B&255;c[qa>>2]=0;c[da>>2]=0;G=J+K|0;F=k+G|0;E=H;G=k+(G+-4)|0;g=4240;f=0;A=0;while(1){if((A|0)==4)break;v=(c[o+(c[11372+(A<<2)>>2]<<2)>>2]|0)+(c[11436+(A<<2)>>2]|0)|0;j=y-v|0;if(!A)if(j>>>0>=y>>>0|v>>>0>I>>>0)j=z;else ra=71;else if((j>>>0<y>>>0?(a[(j&65535)+(n+196608)>>0]|0)==w<<24>>24:0)^1|v>>>0>I>>>0)j=z;else ra=71;if((ra|0)==71){ra=0;u=j&l;j=0;t=E;while(1){h=t;if(h>>>0>G>>>0)break;Fa=t;Ga=k+(u+j)|0;if((d[Fa>>0]|d[Fa+1>>0]<<8|d[Fa+2>>0]<<16|d[Fa+3>>0]<<24|0)!=(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24|0))break;j=j+4|0;t=h+4|0}while(1){if(t>>>0>=F>>>0)break;if((a[k+(u+j)>>0]|0)!=(a[t>>0]|0))break;j=j+1|0;t=t+1|0}if(j>>>0>1?(za=(j*540|0)+(c[11500+(A<<2)>>2]|0)|0,g>>>0<za>>>0):0){c[qa>>2]=j;c[ea>>2]=v;c[fa>>2]=za;g=za;f=1}else j=z}z=j;A=A+1|0}u=0;t=y-(c[n+(B<<2)>>2]|0)|0;h=c[ka>>2]|0;j=e[n+131072+(B<<1)>>1]|0;d:while(1){D=J+z|0;C=D>>>0>l>>>0;D=k+D|0;v=u;w=t;A=h;B=j;while(1){Ga=A;A=A+-1|0;if(!Ga)break d;v=v+w|0;if(v>>>0>I>>>0)break d;u=y-v&l;w=B;B=e[n+262144+(B<<2)+2>>1]|0;w=e[n+262144+(w<<2)>>1]|0;if(C)continue;j=u+z|0;if(j>>>0>l>>>0)continue;if((a[D>>0]|0)==(a[k+j>>0]|0)){h=0;j=E}else continue;while(1){t=j;if(t>>>0>G>>>0)break;Fa=j;Ga=k+(u+h)|0;if((d[Fa>>0]|d[Fa+1>>0]<<8|d[Fa+2>>0]<<16|d[Fa+3>>0]<<24|0)!=(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24|0))break;h=h+4|0;j=t+4|0}while(1){if(j>>>0>=F>>>0)break;if((a[k+(u+h)>>0]|0)!=(a[j>>0]|0))break;h=h+1|0;j=j+1|0}if(h>>>0<=3)continue;j=(h*540|0)+3840+(_((aa(v|0)|0)^31,-120)|0)|0;if(g>>>0<j>>>0)break}c[qa>>2]=h;c[ea>>2]=v;c[fa>>2]=j;u=v;z=h;g=j;t=w;h=A;f=1;j=B}Ga=(_(d[H>>0]|d[H+1>>0]<<8|d[H+2>>0]<<16|d[H+3>>0]<<24,506832829)|0)>>>17;Fa=b[U>>1]|0;b[U>>1]=Fa+1<<16>>16;G=Fa&65535;M=n+(Ga<<2)|0;F=y-(c[M>>2]|0)|0;a[(y&65535)+(n+196608)>>0]=Ga;b[n+262144+(G<<2)>>1]=F>>>0>65535?65535:F;Ga=n+131072+(Ga<<1)|0;b[n+262144+(G<<2)+2>>1]=b[Ga>>1]|0;c[M>>2]=y;b[Ga>>1]=Fa;if(!(f&1)){if((c[V>>2]|0)>>>0<(c[W>>2]|0)>>>7>>>0)f=0;else{v=0;f=0;u=(_(d[H>>0]|d[H+1>>0]<<8|d[H+2>>0]<<16|d[H+3>>0]<<24,506832829)|0)>>>18<<1;while(1){if((v|0)==2)break;Ga=b[21084+(u<<1)>>1]|0;j=Ga&65535;c[W>>2]=(c[W>>2]|0)+1;if(Ga<<16>>16!=0?(Aa=j&31,Ba=j>>>5,Ca=(c[11272+(Aa<<2)>>2]|0)+(_(Aa,Ba)|0)|0,Aa>>>0<=K>>>0):0){g=Ca+Aa|0;h=280811+g|0;g=280811+(g+-4)|0;t=0;j=280811+Ca|0;while(1){if(j>>>0>g>>>0)break;Ga=k+(J+t)|0;if((d[j>>0]|d[j+1>>0]<<8|d[j+2>>0]<<16|d[j+3>>0]<<24|0)!=(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24|0))break;t=t+4|0;j=j+4|0}while(1){if(j>>>0>=h>>>0)break;if((a[k+(J+t)>>0]|0)!=(a[j>>0]|0))break;t=t+1|0;j=j+1|0}if(!((t+10|0)>>>0<=Aa>>>0|(t|0)==0)?(Da=I+Ba+1+(d[407930+(Aa-t)>>0]<<d[280786+Aa>>0])|0,Ea=(t*540|0)+3840+(_((aa(Da|0)|0)^31,-120)|0)|0,Ea>>>0>=(c[fa>>2]|0)>>>0):0){c[qa>>2]=t;c[da>>2]=Aa^t;c[ea>>2]=Da;c[fa>>2]=Ea;c[V>>2]=(c[V>>2]|0)+1;f=1}}v=v+1|0;u=u+1|0}f=(f&1)!=0}f=f&1}if(!(f&1)){y=m;break}if((c[$>>2]|0)>>>0<((c[Q>>2]|0)+700|0)>>>0){y=m;break}f=x+1|0;c[pa>>2]=c[qa>>2];c[pa+4>>2]=c[qa+4>>2];c[pa+8>>2]=c[qa+8>>2];c[pa+12>>2]=c[qa+12>>2];L=L+1|0;if(!((L|0)<4&(m+5|0)>>>0<oa>>>0)){x=f;break}else{m=y;x=f}}m=c[pa>>2]|0;t=y+(m<<1)+ja|0;f=c[P>>2]|0;e:do if(f>>>0<=(y>>>0<na>>>0?y:na)>>>0){h=f+3|0;Ga=c[o>>2]|0;j=h-Ga|0;g=c[ia>>2]|0;h=h-g|0;if((f|0)==(Ga|0))f=0;else{f:do if((f|0)!=(g|0)){do if(j>>>0<7)f=158663784>>>(j<<2)&15;else{if(h>>>0<7){f=266017486>>>(h<<2)&15;break}if((f|0)==(c[ga>>2]|0)){f=2;break f}if((f|0)==(c[ha>>2]|0)){f=3;break f}f=f+15|0}while(0);if(!f)break e}else f=1;while(0);c[ha>>2]=c[ga>>2];c[ga>>2]=c[ia>>2];c[ia>>2]=c[o>>2];c[o>>2]=c[P>>2];m=c[pa>>2]|0}}else f=f+15|0;while(0);w=N+16|0;Ga=c[O>>2]|0;j=m^Ga;c[N>>2]=x;c[N+4>>2]=m|Ga<<24;m=N+14|0;if(f>>>0<16){f=f&65535;b[m>>1]=f;m=0}else{M=f+-12|0;Ga=((aa(M|0)|0)^31)+-1|0;Fa=M>>>Ga&1;f=((Ga<<1)+65534|Fa)+16&65535;b[m>>1]=f;m=Ga<<24|M-((Fa|2)<<Ga)}c[N+8>>2]=m;u=f<<16>>16==0;v=N+12|0;do if(x>>>0>=6){if(x>>>0<130){Ga=x+-2|0;h=((aa(Ga|0)|0)^31)+-1|0;h=(h<<1)+(Ga>>>h)+2&65535;break}if(x>>>0<2114){h=((aa(x+-66|0)|0)^31)+10&65535;break}if(x>>>0<6210)h=21;else h=x>>>0<22594?22:23}else h=x&65535;while(0);do if(j>>>0>=10){if(j>>>0<134){Ga=j+-6|0;f=((aa(Ga|0)|0)^31)+-1|0;f=(f<<1)+(Ga>>>f)+4&65535;break}if(j>>>0<2118)f=((aa(j+-70|0)|0)^31)+12&65535;else f=23}else f=j+65534&65535;while(0);m=f&65535;j=h&65535;g=m&7|j<<3&56;if(u&(h&65535)<8&(f&65535)<16)f=((f&65535)<8?g:g|64)&65535;else f=b[88156+((m>>>3)+((j>>>3)*3|0)<<1)>>1]|g&65535;b[v>>1]=f;c[s>>2]=(c[s>>2]|0)+x;f=y+(c[pa>>2]|0)|0;f=f>>>0<ma>>>0?f:ma;m=y+2|0;while(1){if(m>>>0>=f>>>0)break;Ga=k+(m&l)|0;Ga=(_(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24,506832829)|0)>>>17;Fa=b[U>>1]|0;b[U>>1]=Fa+1<<16>>16;M=Fa&65535;N=n+(Ga<<2)|0;L=m-(c[N>>2]|0)|0;a[(m&65535)+(n+196608)>>0]=Ga;b[n+262144+(M<<2)>>1]=L>>>0>65535?65535:L;Ga=n+131072+(Ga<<1)|0;b[n+262144+(M<<2)+2>>1]=b[Ga>>1]|0;c[N>>2]=m;b[Ga>>1]=Fa;m=m+1|0}m=y+(c[pa>>2]|0)|0;N=w;f=0}c[p>>2]=f+K;c[r>>2]=(c[r>>2]|0)+(L-q>>4);i=sa;return}function Sa(f,g,h,j,k,l,m,n,o,p,q,r,s){f=f|0;g=g|0;h=h|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=o|0;p=p|0;q=q|0;r=r|0;s=s|0;var t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,$=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0;sa=i;i=i+32|0;pa=sa+16|0;qa=sa;na=(1<<c[m+8>>2])+-16|0;u=c[p>>2]|0;oa=h+g|0;ma=g>>>0>3?oa+-3|0:h;la=m+4|0;ia=c[la>>2]|0;ja=(ia|0)<9?64:512;t=ja+h|0;ka=n+524300|0;c[ka>>2]=((ia|0)>6?7:8)<<ia+-4;if((((h|0)==0^1|j^1)^1)&g>>>0<513){f=0;while(1){if((f|0)==(g|0))break;ia=k+f|0;ia=(_(d[ia>>0]|d[ia+1>>0]<<8|d[ia+2>>0]<<16|d[ia+3>>0]<<24,506832829)|0)>>>17;c[n+(ia<<2)>>2]=-858993460;b[n+131072+(ia<<1)>>1]=-13108;f=f+1|0}ac(n+196608|0,0,65536)|0;b[n+524288>>1]=0;if(g){a[n+524290>>0]=0;ra=8}}else{f=n+524290|0;if(!(a[f>>0]&1))ra=8;else{ac(n|0,-52,131072)|0;b[n+524288>>1]=0;a[f>>0]=0;ac(n+131072|0,0,131072)|0;ra=8}}if((ra|0)==8?g>>>0>2&h>>>0>2:0){da=h+-3|0;ga=k+(da&l)|0;ga=(_(d[ga>>0]|d[ga+1>>0]<<8|d[ga+2>>0]<<16|d[ga+3>>0]<<24,506832829)|0)>>>17;ea=n+524288|0;fa=b[ea>>1]|0;b[ea>>1]=fa+1<<16>>16;ha=fa&65535;ia=n+(ga<<2)|0;ca=da-(c[ia>>2]|0)|0;a[(da&65535)+(n+196608)>>0]=ga;b[n+262144+(ha<<2)>>1]=ca>>>0>65535?65535:ca;ga=n+131072+(ga<<1)|0;b[n+262144+(ha<<2)+2>>1]=b[ga>>1]|0;c[ia>>2]=da;b[ga>>1]=fa;ga=h+-2|0;fa=k+(ga&l)|0;fa=(_(d[fa>>0]|d[fa+1>>0]<<8|d[fa+2>>0]<<16|d[fa+3>>0]<<24,506832829)|0)>>>17;ia=b[ea>>1]|0;b[ea>>1]=ia+1<<16>>16;da=ia&65535;ha=n+(fa<<2)|0;ca=ga-(c[ha>>2]|0)|0;a[(ga&65535)+(n+196608)>>0]=fa;b[n+262144+(da<<2)>>1]=ca>>>0>65535?65535:ca;fa=n+131072+(fa<<1)|0;b[n+262144+(da<<2)+2>>1]=b[fa>>1]|0;c[ha>>2]=ga;b[fa>>1]=ia;fa=h+-1|0;ia=k+(fa&l)|0;ia=(_(d[ia>>0]|d[ia+1>>0]<<8|d[ia+2>>0]<<16|d[ia+3>>0]<<24,506832829)|0)>>>17;ha=b[ea>>1]|0;b[ea>>1]=ha+1<<16>>16;ea=ha&65535;ga=n+(ia<<2)|0;da=fa-(c[ga>>2]|0)|0;a[(fa&65535)+(n+196608)>>0]=ia;b[n+262144+(ea<<2)>>1]=da>>>0>65535?65535:da;ia=n+131072+(ia<<1)|0;b[n+262144+(ea<<2)+2>>1]=b[ia>>1]|0;c[ga>>2]=fa;b[ia>>1]=ha}O=pa+4|0;P=pa+8|0;Q=pa+12|0;R=pa+4|0;S=pa+8|0;T=pa+12|0;U=n+524288|0;V=n+524296|0;W=n+524292|0;X=ja<<2;Y=oa+-4|0;Z=oa+-3|0;$=qa+12|0;ba=qa+4|0;ca=qa+8|0;da=qa+4|0;ea=qa+8|0;fa=qa+12|0;ga=o+8|0;ha=o+12|0;ia=o+4|0;m=h;N=q;f=u;a:while(1){L=N;M=t+X|0;b:while(1){K=oa-m|0;if((m+4|0)>>>0>=oa>>>0)break a;I=m>>>0<na>>>0?m:na;c[pa>>2]=0;c[O>>2]=0;c[P>>2]=0;c[Q>>2]=4240;J=m&l;z=c[pa>>2]|0;H=k+J|0;B=(_(d[H>>0]|d[H+1>>0]<<8|d[H+2>>0]<<16|d[H+3>>0]<<24,506832829)|0)>>>17;y=B&255;c[pa>>2]=0;c[R>>2]=0;G=J+K|0;F=k+G|0;E=H;G=k+(G+-4)|0;h=4240;j=0;A=0;while(1){if((A|0)==10)break;x=(c[o+(c[11372+(A<<2)>>2]<<2)>>2]|0)+(c[11436+(A<<2)>>2]|0)|0;g=m-x|0;if(!A)if(g>>>0>=m>>>0|x>>>0>I>>>0)g=z;else ra=17;else if((g>>>0<m>>>0?(a[(g&65535)+(n+196608)>>0]|0)==y<<24>>24:0)^1|x>>>0>I>>>0)g=z;else ra=17;if((ra|0)==17){ra=0;w=g&l;g=0;u=E;while(1){v=u;if(v>>>0>G>>>0)break;C=u;D=k+(w+g)|0;if((d[C>>0]|d[C+1>>0]<<8|d[C+2>>0]<<16|d[C+3>>0]<<24|0)!=(d[D>>0]|d[D+1>>0]<<8|d[D+2>>0]<<16|d[D+3>>0]<<24|0))break;g=g+4|0;u=v+4|0}while(1){if(u>>>0>=F>>>0)break;if((a[k+(w+g)>>0]|0)!=(a[u>>0]|0))break;g=g+1|0;u=u+1|0}if(g>>>0>1?(ta=(g*540|0)+(c[11500+(A<<2)>>2]|0)|0,h>>>0<ta>>>0):0){c[pa>>2]=g;c[S>>2]=x;c[T>>2]=ta;h=ta;j=1}else g=z}z=g;A=A+1|0}w=0;u=m-(c[n+(B<<2)>>2]|0)|0;v=c[ka>>2]|0;g=e[n+131072+(B<<1)>>1]|0;c:while(1){D=J+z|0;C=D>>>0>l>>>0;D=k+D|0;x=w;y=u;A=v;B=g;while(1){w=A;A=A+-1|0;if(!w)break c;x=x+y|0;if(x>>>0>I>>>0)break c;w=m-x&l;y=B;B=e[n+262144+(B<<2)+2>>1]|0;y=e[n+262144+(y<<2)>>1]|0;if(C)continue;g=w+z|0;if(g>>>0>l>>>0)continue;if((a[D>>0]|0)==(a[k+g>>0]|0)){v=0;g=E}else continue;while(1){u=g;if(u>>>0>G>>>0)break;Ga=g;Fa=k+(w+v)|0;if((d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24|0)!=(d[Fa>>0]|d[Fa+1>>0]<<8|d[Fa+2>>0]<<16|d[Fa+3>>0]<<24|0))break;v=v+4|0;g=u+4|0}while(1){if(g>>>0>=F>>>0)break;if((a[k+(w+v)>>0]|0)!=(a[g>>0]|0))break;v=v+1|0;g=g+1|0}if(v>>>0<=3)continue;g=(v*540|0)+3840+(_((aa(x|0)|0)^31,-120)|0)|0;if(h>>>0<g>>>0)break}c[pa>>2]=v;c[S>>2]=x;c[T>>2]=g;w=x;z=v;h=g;u=y;v=A;j=1;g=B}Ga=(_(d[H>>0]|d[H+1>>0]<<8|d[H+2>>0]<<16|d[H+3>>0]<<24,506832829)|0)>>>17;Fa=b[U>>1]|0;b[U>>1]=Fa+1<<16>>16;F=Fa&65535;G=n+(Ga<<2)|0;E=m-(c[G>>2]|0)|0;a[(m&65535)+(n+196608)>>0]=Ga;b[n+262144+(F<<2)>>1]=E>>>0>65535?65535:E;Ga=n+131072+(Ga<<1)|0;b[n+262144+(F<<2)+2>>1]=b[Ga>>1]|0;c[G>>2]=m;b[Ga>>1]=Fa;if(!(j&1)){if((c[V>>2]|0)>>>0<(c[W>>2]|0)>>>7>>>0)j=0;else{x=0;j=0;w=(_(d[H>>0]|d[H+1>>0]<<8|d[H+2>>0]<<16|d[H+3>>0]<<24,506832829)|0)>>>18<<1;while(1){if((x|0)==2)break;Ga=b[21084+(w<<1)>>1]|0;g=Ga&65535;c[W>>2]=(c[W>>2]|0)+1;if(Ga<<16>>16!=0?(ua=g&31,va=g>>>5,wa=(c[11272+(ua<<2)>>2]|0)+(_(ua,va)|0)|0,ua>>>0<=K>>>0):0){h=wa+ua|0;v=280811+h|0;h=280811+(h+-4)|0;u=0;g=280811+wa|0;while(1){if(g>>>0>h>>>0)break;Ga=k+(J+u)|0;if((d[g>>0]|d[g+1>>0]<<8|d[g+2>>0]<<16|d[g+3>>0]<<24|0)!=(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24|0))break;u=u+4|0;g=g+4|0}while(1){if(g>>>0>=v>>>0)break;if((a[k+(J+u)>>0]|0)!=(a[g>>0]|0))break;u=u+1|0;g=g+1|0}if(!((u+10|0)>>>0<=ua>>>0|(u|0)==0)?(xa=I+va+1+(d[407930+(ua-u)>>0]<<d[280786+ua>>0])|0,ya=(u*540|0)+3840+(_((aa(xa|0)|0)^31,-120)|0)|0,ya>>>0>=(c[T>>2]|0)>>>0):0){c[pa>>2]=u;c[R>>2]=ua^u;c[S>>2]=xa;c[T>>2]=ya;c[V>>2]=(c[V>>2]|0)+1;j=1}}x=x+1|0;w=w+1|0}j=(j&1)!=0}j=j&1}if(j&1){L=0;x=f;break}f=f+1|0;g=m+1|0;if(g>>>0<=t>>>0){m=g;continue}if(g>>>0>M>>>0){j=m+17|0;j=j>>>0<Y>>>0?j:Y;m=g;while(1){if(m>>>0>=j>>>0)continue b;Ga=k+(m&l)|0;Ga=(_(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24,506832829)|0)>>>17;Fa=b[U>>1]|0;b[U>>1]=Fa+1<<16>>16;J=Fa&65535;K=n+(Ga<<2)|0;I=m-(c[K>>2]|0)|0;a[(m&65535)+(n+196608)>>0]=Ga;b[n+262144+(J<<2)>>1]=I>>>0>65535?65535:I;Ga=n+131072+(Ga<<1)|0;b[n+262144+(J<<2)+2>>1]=b[Ga>>1]|0;c[K>>2]=m;b[Ga>>1]=Fa;m=m+4|0;f=f+4|0}}else{j=m+9|0;j=j>>>0<Z>>>0?j:Z;m=g;while(1){if(m>>>0>=j>>>0)continue b;Ga=k+(m&l)|0;Ga=(_(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24,506832829)|0)>>>17;Fa=b[U>>1]|0;b[U>>1]=Fa+1<<16>>16;J=Fa&65535;K=n+(Ga<<2)|0;I=m-(c[K>>2]|0)|0;a[(m&65535)+(n+196608)>>0]=Ga;b[n+262144+(J<<2)>>1]=I>>>0>65535?65535:I;Ga=n+131072+(Ga<<1)|0;b[n+262144+(J<<2)+2>>1]=b[Ga>>1]|0;c[K>>2]=m;b[Ga>>1]=Fa;m=m+2|0;f=f+2|0}}}while(1){K=K+-1|0;if((c[la>>2]|0)<5){f=(c[pa>>2]|0)+-1|0;f=f>>>0<K>>>0?f:K}else f=0;c[qa>>2]=f;c[ba>>2]=0;c[ca>>2]=0;c[$>>2]=4240;y=m+1|0;I=y>>>0<na>>>0?y:na;J=y&l;z=c[qa>>2]|0;H=k+J|0;B=(_(d[H>>0]|d[H+1>>0]<<8|d[H+2>>0]<<16|d[H+3>>0]<<24,506832829)|0)>>>17;w=B&255;c[qa>>2]=0;c[da>>2]=0;G=J+K|0;F=k+G|0;E=H;G=k+(G+-4)|0;g=4240;f=0;A=0;while(1){if((A|0)==10)break;v=(c[o+(c[11372+(A<<2)>>2]<<2)>>2]|0)+(c[11436+(A<<2)>>2]|0)|0;j=y-v|0;if(!A)if(j>>>0>=y>>>0|v>>>0>I>>>0)j=z;else ra=71;else if((j>>>0<y>>>0?(a[(j&65535)+(n+196608)>>0]|0)==w<<24>>24:0)^1|v>>>0>I>>>0)j=z;else ra=71;if((ra|0)==71){ra=0;u=j&l;j=0;t=E;while(1){h=t;if(h>>>0>G>>>0)break;Fa=t;Ga=k+(u+j)|0;if((d[Fa>>0]|d[Fa+1>>0]<<8|d[Fa+2>>0]<<16|d[Fa+3>>0]<<24|0)!=(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24|0))break;j=j+4|0;t=h+4|0}while(1){if(t>>>0>=F>>>0)break;if((a[k+(u+j)>>0]|0)!=(a[t>>0]|0))break;j=j+1|0;t=t+1|0}if(j>>>0>1?(za=(j*540|0)+(c[11500+(A<<2)>>2]|0)|0,g>>>0<za>>>0):0){c[qa>>2]=j;c[ea>>2]=v;c[fa>>2]=za;g=za;f=1}else j=z}z=j;A=A+1|0}u=0;t=y-(c[n+(B<<2)>>2]|0)|0;h=c[ka>>2]|0;j=e[n+131072+(B<<1)>>1]|0;d:while(1){D=J+z|0;C=D>>>0>l>>>0;D=k+D|0;v=u;w=t;A=h;B=j;while(1){Ga=A;A=A+-1|0;if(!Ga)break d;v=v+w|0;if(v>>>0>I>>>0)break d;u=y-v&l;w=B;B=e[n+262144+(B<<2)+2>>1]|0;w=e[n+262144+(w<<2)>>1]|0;if(C)continue;j=u+z|0;if(j>>>0>l>>>0)continue;if((a[D>>0]|0)==(a[k+j>>0]|0)){h=0;j=E}else continue;while(1){t=j;if(t>>>0>G>>>0)break;Fa=j;Ga=k+(u+h)|0;if((d[Fa>>0]|d[Fa+1>>0]<<8|d[Fa+2>>0]<<16|d[Fa+3>>0]<<24|0)!=(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24|0))break;h=h+4|0;j=t+4|0}while(1){if(j>>>0>=F>>>0)break;if((a[k+(u+h)>>0]|0)!=(a[j>>0]|0))break;h=h+1|0;j=j+1|0}if(h>>>0<=3)continue;j=(h*540|0)+3840+(_((aa(v|0)|0)^31,-120)|0)|0;if(g>>>0<j>>>0)break}c[qa>>2]=h;c[ea>>2]=v;c[fa>>2]=j;u=v;z=h;g=j;t=w;h=A;f=1;j=B}Ga=(_(d[H>>0]|d[H+1>>0]<<8|d[H+2>>0]<<16|d[H+3>>0]<<24,506832829)|0)>>>17;Fa=b[U>>1]|0;b[U>>1]=Fa+1<<16>>16;G=Fa&65535;M=n+(Ga<<2)|0;F=y-(c[M>>2]|0)|0;a[(y&65535)+(n+196608)>>0]=Ga;b[n+262144+(G<<2)>>1]=F>>>0>65535?65535:F;Ga=n+131072+(Ga<<1)|0;b[n+262144+(G<<2)+2>>1]=b[Ga>>1]|0;c[M>>2]=y;b[Ga>>1]=Fa;if(!(f&1)){if((c[V>>2]|0)>>>0<(c[W>>2]|0)>>>7>>>0)f=0;else{v=0;f=0;u=(_(d[H>>0]|d[H+1>>0]<<8|d[H+2>>0]<<16|d[H+3>>0]<<24,506832829)|0)>>>18<<1;while(1){if((v|0)==2)break;Ga=b[21084+(u<<1)>>1]|0;j=Ga&65535;c[W>>2]=(c[W>>2]|0)+1;if(Ga<<16>>16!=0?(Aa=j&31,Ba=j>>>5,Ca=(c[11272+(Aa<<2)>>2]|0)+(_(Aa,Ba)|0)|0,Aa>>>0<=K>>>0):0){g=Ca+Aa|0;h=280811+g|0;g=280811+(g+-4)|0;t=0;j=280811+Ca|0;while(1){if(j>>>0>g>>>0)break;Ga=k+(J+t)|0;if((d[j>>0]|d[j+1>>0]<<8|d[j+2>>0]<<16|d[j+3>>0]<<24|0)!=(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24|0))break;t=t+4|0;j=j+4|0}while(1){if(j>>>0>=h>>>0)break;if((a[k+(J+t)>>0]|0)!=(a[j>>0]|0))break;t=t+1|0;j=j+1|0}if(!((t+10|0)>>>0<=Aa>>>0|(t|0)==0)?(Da=I+Ba+1+(d[407930+(Aa-t)>>0]<<d[280786+Aa>>0])|0,Ea=(t*540|0)+3840+(_((aa(Da|0)|0)^31,-120)|0)|0,Ea>>>0>=(c[fa>>2]|0)>>>0):0){c[qa>>2]=t;c[da>>2]=Aa^t;c[ea>>2]=Da;c[fa>>2]=Ea;c[V>>2]=(c[V>>2]|0)+1;f=1}}v=v+1|0;u=u+1|0}f=(f&1)!=0}f=f&1}if(!(f&1)){y=m;break}if((c[$>>2]|0)>>>0<((c[Q>>2]|0)+700|0)>>>0){y=m;break}f=x+1|0;c[pa>>2]=c[qa>>2];c[pa+4>>2]=c[qa+4>>2];c[pa+8>>2]=c[qa+8>>2];c[pa+12>>2]=c[qa+12>>2];L=L+1|0;if(!((L|0)<4&(m+5|0)>>>0<oa>>>0)){x=f;break}else{m=y;x=f}}m=c[pa>>2]|0;t=y+(m<<1)+ja|0;f=c[P>>2]|0;e:do if(f>>>0<=(y>>>0<na>>>0?y:na)>>>0){h=f+3|0;Ga=c[o>>2]|0;j=h-Ga|0;g=c[ia>>2]|0;h=h-g|0;if((f|0)==(Ga|0))f=0;else{f:do if((f|0)!=(g|0)){do if(j>>>0<7)f=158663784>>>(j<<2)&15;else{if(h>>>0<7){f=266017486>>>(h<<2)&15;break}if((f|0)==(c[ga>>2]|0)){f=2;break f}if((f|0)==(c[ha>>2]|0)){f=3;break f}f=f+15|0}while(0);if(!f)break e}else f=1;while(0);c[ha>>2]=c[ga>>2];c[ga>>2]=c[ia>>2];c[ia>>2]=c[o>>2];c[o>>2]=c[P>>2];m=c[pa>>2]|0}}else f=f+15|0;while(0);w=N+16|0;Ga=c[O>>2]|0;j=m^Ga;c[N>>2]=x;c[N+4>>2]=m|Ga<<24;m=N+14|0;if(f>>>0<16){f=f&65535;b[m>>1]=f;m=0}else{M=f+-12|0;Ga=((aa(M|0)|0)^31)+-1|0;Fa=M>>>Ga&1;f=((Ga<<1)+65534|Fa)+16&65535;b[m>>1]=f;m=Ga<<24|M-((Fa|2)<<Ga)}c[N+8>>2]=m;u=f<<16>>16==0;v=N+12|0;do if(x>>>0>=6){if(x>>>0<130){Ga=x+-2|0;h=((aa(Ga|0)|0)^31)+-1|0;h=(h<<1)+(Ga>>>h)+2&65535;break}if(x>>>0<2114){h=((aa(x+-66|0)|0)^31)+10&65535;break}if(x>>>0<6210)h=21;else h=x>>>0<22594?22:23}else h=x&65535;while(0);do if(j>>>0>=10){if(j>>>0<134){Ga=j+-6|0;f=((aa(Ga|0)|0)^31)+-1|0;f=(f<<1)+(Ga>>>f)+4&65535;break}if(j>>>0<2118)f=((aa(j+-70|0)|0)^31)+12&65535;else f=23}else f=j+65534&65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+16|0;qa=ra;na=(1<<c[m+8>>2])+-16|0;u=c[p>>2]|0;oa=h+g|0;ma=g>>>0>3?oa+-3|0:h;la=m+4|0;ia=c[la>>2]|0;ja=(ia|0)<9?64:512;t=ja+h|0;ka=n+1311756|0;c[ka>>2]=((ia|0)>6?7:8)<<ia+-4;if((((h|0)==0^1|j^1)^1)&g>>>0<513){f=0;while(1){if((f|0)==(g|0))break;ia=k+f|0;ia=(_(d[ia>>0]|d[ia+1>>0]<<8|d[ia+2>>0]<<16|d[ia+3>>0]<<24,506832829)|0)>>>17;c[n+(ia<<2)>>2]=-858993460;b[n+131072+(ia<<1)>>1]=-13108;f=f+1|0}ac(n+196608|0,0,65536)|0;ac(n+1310720|0,0,1024)|0;if(g){a[n+1311744>>0]=0;Ea=8}}else if(!(a[n+1311744>>0]&1))Ea=8;else{ac(n|0,-52,131072)|0;ac(n+131072|0,0,131072)|0;ac(n+1310720|0,0,1025)|0;Ea=8}if((Ea|0)==8?g>>>0>2&h>>>0>2:0){ea=h+-3|0;ga=k+(ea&l)|0;ga=(_(d[ga>>0]|d[ga+1>>0]<<8|d[ga+2>>0]<<16|d[ga+3>>0]<<24,506832829)|0)>>>17;ia=ga&511;ha=n+1310720+(ia<<1)|0;fa=b[ha>>1]|0;b[ha>>1]=fa+1<<16>>16;fa=fa&511;ha=n+(ga<<2)|0;da=ea-(c[ha>>2]|0)|0;a[(ea&65535)+(n+196608)>>0]=ga;b[n+262144+(ia<<11)+(fa<<2)>>1]=da>>>0>65535?65535:da;ga=n+131072+(ga<<1)|0;b[n+262144+(ia<<11)+(fa<<2)+2>>1]=b[ga>>1]|0;c[ha>>2]=ea;b[ga>>1]=fa;ga=h+-2|0;fa=k+(ga&l)|0;fa=(_(d[fa>>0]|d[fa+1>>0]<<8|d[fa+2>>0]<<16|d[fa+3>>0]<<24,506832829)|0)>>>17;ha=fa&511;ea=n+1310720+(ha<<1)|0;ia=b[ea>>1]|0;b[ea>>1]=ia+1<<16>>16;ia=ia&511;ea=n+(fa<<2)|0;da=ga-(c[ea>>2]|0)|0;a[(ga&65535)+(n+196608)>>0]=fa;b[n+262144+(ha<<11)+(ia<<2)>>1]=da>>>0>65535?65535:da;fa=n+131072+(fa<<1)|0;b[n+262144+(ha<<11)+(ia<<2)+2>>1]=b[fa>>1]|0;c[ea>>2]=ga;b[fa>>1]=ia;fa=h+-1|0;ia=k+(fa&l)|0;ia=(_(d[ia>>0]|d[ia+1>>0]<<8|d[ia+2>>0]<<16|d[ia+3>>0]<<24,506832829)|0)>>>17;ea=ia&511;ga=n+1310720+(ea<<1)|0;ha=b[ga>>1]|0;b[ga>>1]=ha+1<<16>>16;ha=ha&511;ga=n+(ia<<2)|0;da=fa-(c[ga>>2]|0)|0;a[(fa&65535)+(n+196608)>>0]=ia;b[n+262144+(ea<<11)+(ha<<2)>>1]=da>>>0>65535?65535:da;ia=n+131072+(ia<<1)|0;b[n+262144+(ea<<11)+(ha<<2)+2>>1]=b[ia>>1]|0;c[ga>>2]=fa;b[ia>>1]=ha}P=pa+4|0;Q=pa+8|0;R=pa+12|0;S=pa+4|0;T=pa+8|0;U=pa+12|0;V=n+1311752|0;W=n+1311748|0;X=ja<<2;Y=oa+-4|0;Z=oa+-3|0;$=qa+12|0;ba=qa+4|0;ca=qa+8|0;da=qa+4|0;ea=qa+8|0;fa=qa+12|0;ga=o+8|0;ha=o+12|0;ia=o+4|0;m=h;O=q;f=u;a:while(1){M=O;N=t+X|0;b:while(1){L=oa-m|0;if((m+4|0)>>>0>=oa>>>0)break a;J=m>>>0<na>>>0?m:na;c[pa>>2]=0;c[P>>2]=0;c[Q>>2]=0;c[R>>2]=4240;K=m&l;A=c[pa>>2]|0;I=k+K|0;B=(_(d[I>>0]|d[I+1>>0]<<8|d[I+2>>0]<<16|d[I+3>>0]<<24,506832829)|0)>>>17;y=B&255;c[pa>>2]=0;c[S>>2]=0;H=K+L|0;G=k+H|0;F=I;H=k+(H+-4)|0;h=4240;j=0;z=0;while(1){if((z|0)==16)break;x=(c[o+(c[11372+(z<<2)>>2]<<2)>>2]|0)+(c[11436+(z<<2)>>2]|0)|0;g=m-x|0;if(!z)if(g>>>0>=m>>>0|x>>>0>J>>>0)g=A;else Ea=17;else if((g>>>0<m>>>0?(a[(g&65535)+(n+196608)>>0]|0)==y<<24>>24:0)^1|x>>>0>J>>>0)g=A;else Ea=17;if((Ea|0)==17){Ea=0;w=g&l;g=0;u=F;while(1){v=u;if(v>>>0>H>>>0)break;D=u;E=k+(w+g)|0;if((d[D>>0]|d[D+1>>0]<<8|d[D+2>>0]<<16|d[D+3>>0]<<24|0)!=(d[E>>0]|d[E+1>>0]<<8|d[E+2>>0]<<16|d[E+3>>0]<<24|0))break;g=g+4|0;u=v+4|0}while(1){if(u>>>0>=G>>>0)break;if((a[k+(w+g)>>0]|0)!=(a[u>>0]|0))break;g=g+1|0;u=u+1|0}if(g>>>0>1?(sa=(g*540|0)+(c[11500+(z<<2)>>2]|0)|0,h>>>0<sa>>>0):0){c[pa>>2]=g;c[T>>2]=x;c[U>>2]=sa;h=sa;j=1}else g=A}A=g;z=z+1|0}E=B&511;w=0;u=m-(c[n+(B<<2)>>2]|0)|0;v=c[ka>>2]|0;g=e[n+131072+(B<<1)>>1]|0;c:while(1){D=K+A|0;C=D>>>0>l>>>0;D=k+D|0;x=w;y=u;z=v;B=g;while(1){w=z;z=z+-1|0;if(!w)break c;x=x+y|0;if(x>>>0>J>>>0)break c;w=m-x&l;y=B;B=e[n+262144+(E<<11)+(B<<2)+2>>1]|0;y=e[n+262144+(E<<11)+(y<<2)>>1]|0;if(C)continue;g=w+A|0;if(g>>>0>l>>>0)continue;if((a[D>>0]|0)==(a[k+g>>0]|0)){v=0;g=F}else continue;while(1){u=g;if(u>>>0>H>>>0)break;Ga=g;Fa=k+(w+v)|0;if((d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24|0)!=(d[Fa>>0]|d[Fa+1>>0]<<8|d[Fa+2>>0]<<16|d[Fa+3>>0]<<24|0))break;v=v+4|0;g=u+4|0}while(1){if(g>>>0>=G>>>0)break;if((a[k+(w+v)>>0]|0)!=(a[g>>0]|0))break;v=v+1|0;g=g+1|0}if(v>>>0<=3)continue;g=(v*540|0)+3840+(_((aa(x|0)|0)^31,-120)|0)|0;if(h>>>0<g>>>0)break}c[pa>>2]=v;c[T>>2]=x;c[U>>2]=g;w=x;A=v;h=g;u=y;v=z;j=1;g=B}Ga=(_(d[I>>0]|d[I+1>>0]<<8|d[I+2>>0]<<16|d[I+3>>0]<<24,506832829)|0)>>>17;G=Ga&511;H=n+1310720+(G<<1)|0;Fa=b[H>>1]|0;b[H>>1]=Fa+1<<16>>16;Fa=Fa&511;H=n+(Ga<<2)|0;F=m-(c[H>>2]|0)|0;a[(m&65535)+(n+196608)>>0]=Ga;b[n+262144+(G<<11)+(Fa<<2)>>1]=F>>>0>65535?65535:F;Ga=n+131072+(Ga<<1)|0;b[n+262144+(G<<11)+(Fa<<2)+2>>1]=b[Ga>>1]|0;c[H>>2]=m;b[Ga>>1]=Fa;if(!(j&1)){if((c[V>>2]|0)>>>0<(c[W>>2]|0)>>>7>>>0)j=0;else{x=0;j=0;w=(_(d[I>>0]|d[I+1>>0]<<8|d[I+2>>0]<<16|d[I+3>>0]<<24,506832829)|0)>>>18<<1;while(1){if((x|0)==2)break;Ga=b[21084+(w<<1)>>1]|0;g=Ga&65535;c[W>>2]=(c[W>>2]|0)+1;if(Ga<<16>>16!=0?(ta=g&31,ua=g>>>5,va=(c[11272+(ta<<2)>>2]|0)+(_(ta,ua)|0)|0,ta>>>0<=L>>>0):0){h=va+ta|0;v=280811+h|0;h=280811+(h+-4)|0;u=0;g=280811+va|0;while(1){if(g>>>0>h>>>0)break;Ga=k+(K+u)|0;if((d[g>>0]|d[g+1>>0]<<8|d[g+2>>0]<<16|d[g+3>>0]<<24|0)!=(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24|0))break;u=u+4|0;g=g+4|0}while(1){if(g>>>0>=v>>>0)break;if((a[k+(K+u)>>0]|0)!=(a[g>>0]|0))break;u=u+1|0;g=g+1|0}if(!((u+10|0)>>>0<=ta>>>0|(u|0)==0)?(wa=J+ua+1+(d[407930+(ta-u)>>0]<<d[280786+ta>>0])|0,xa=(u*540|0)+3840+(_((aa(wa|0)|0)^31,-120)|0)|0,xa>>>0>=(c[U>>2]|0)>>>0):0){c[pa>>2]=u;c[S>>2]=ta^u;c[T>>2]=wa;c[U>>2]=xa;c[V>>2]=(c[V>>2]|0)+1;j=1}}x=x+1|0;w=w+1|0}j=(j&1)!=0}j=j&1}if(j&1){M=0;x=f;break}f=f+1|0;g=m+1|0;if(g>>>0<=t>>>0){m=g;continue}if(g>>>0>N>>>0){j=m+17|0;j=j>>>0<Y>>>0?j:Y;m=g;while(1){if(m>>>0>=j>>>0)continue b;Ga=k+(m&l)|0;Ga=(_(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24,506832829)|0)>>>17;K=Ga&511;L=n+1310720+(K<<1)|0;Fa=b[L>>1]|0;b[L>>1]=Fa+1<<16>>16;Fa=Fa&511;L=n+(Ga<<2)|0;J=m-(c[L>>2]|0)|0;a[(m&65535)+(n+196608)>>0]=Ga;b[n+262144+(K<<11)+(Fa<<2)>>1]=J>>>0>65535?65535:J;Ga=n+131072+(Ga<<1)|0;b[n+262144+(K<<11)+(Fa<<2)+2>>1]=b[Ga>>1]|0;c[L>>2]=m;b[Ga>>1]=Fa;m=m+4|0;f=f+4|0}}else{j=m+9|0;j=j>>>0<Z>>>0?j:Z;m=g;while(1){if(m>>>0>=j>>>0)continue b;Ga=k+(m&l)|0;Ga=(_(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24,506832829)|0)>>>17;K=Ga&511;L=n+1310720+(K<<1)|0;Fa=b[L>>1]|0;b[L>>1]=Fa+1<<16>>16;Fa=Fa&511;L=n+(Ga<<2)|0;J=m-(c[L>>2]|0)|0;a[(m&65535)+(n+196608)>>0]=Ga;b[n+262144+(K<<11)+(Fa<<2)>>1]=J>>>0>65535?65535:J;Ga=n+131072+(Ga<<1)|0;b[n+262144+(K<<11)+(Fa<<2)+2>>1]=b[Ga>>1]|0;c[L>>2]=m;b[Ga>>1]=Fa;m=m+2|0;f=f+2|0}}}while(1){L=L+-1|0;if((c[la>>2]|0)<5){f=(c[pa>>2]|0)+-1|0;f=f>>>0<L>>>0?f:L}else f=0;c[qa>>2]=f;c[ba>>2]=0;c[ca>>2]=0;c[$>>2]=4240;y=m+1|0;J=y>>>0<na>>>0?y:na;K=y&l;A=c[qa>>2]|0;I=k+K|0;B=(_(d[I>>0]|d[I+1>>0]<<8|d[I+2>>0]<<16|d[I+3>>0]<<24,506832829)|0)>>>17;w=B&255;c[qa>>2]=0;c[da>>2]=0;H=K+L|0;G=k+H|0;F=I;H=k+(H+-4)|0;g=4240;f=0;z=0;while(1){if((z|0)==16)break;v=(c[o+(c[11372+(z<<2)>>2]<<2)>>2]|0)+(c[11436+(z<<2)>>2]|0)|0;j=y-v|0;if(!z)if(j>>>0>=y>>>0|v>>>0>J>>>0)j=A;else Ea=71;else if((j>>>0<y>>>0?(a[(j&65535)+(n+196608)>>0]|0)==w<<24>>24:0)^1|v>>>0>J>>>0)j=A;else Ea=71;if((Ea|0)==71){Ea=0;u=j&l;j=0;t=F;while(1){h=t;if(h>>>0>H>>>0)break;Fa=t;Ga=k+(u+j)|0;if((d[Fa>>0]|d[Fa+1>>0]<<8|d[Fa+2>>0]<<16|d[Fa+3>>0]<<24|0)!=(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24|0))break;j=j+4|0;t=h+4|0}while(1){if(t>>>0>=G>>>0)break;if((a[k+(u+j)>>0]|0)!=(a[t>>0]|0))break;j=j+1|0;t=t+1|0}if(j>>>0>1?(ya=(j*540|0)+(c[11500+(z<<2)>>2]|0)|0,g>>>0<ya>>>0):0){c[qa>>2]=j;c[ea>>2]=v;c[fa>>2]=ya;g=ya;f=1}else j=A}A=j;z=z+1|0}E=B&511;u=0;t=y-(c[n+(B<<2)>>2]|0)|0;h=c[ka>>2]|0;j=e[n+131072+(B<<1)>>1]|0;d:while(1){D=K+A|0;C=D>>>0>l>>>0;D=k+D|0;v=u;w=t;z=h;B=j;while(1){Ga=z;z=z+-1|0;if(!Ga)break d;v=v+w|0;if(v>>>0>J>>>0)break d;u=y-v&l;w=B;B=e[n+262144+(E<<11)+(B<<2)+2>>1]|0;w=e[n+262144+(E<<11)+(w<<2)>>1]|0;if(C)continue;j=u+A|0;if(j>>>0>l>>>0)continue;if((a[D>>0]|0)==(a[k+j>>0]|0)){h=0;j=F}else continue;while(1){t=j;if(t>>>0>H>>>0)break;Fa=j;Ga=k+(u+h)|0;if((d[Fa>>0]|d[Fa+1>>0]<<8|d[Fa+2>>0]<<16|d[Fa+3>>0]<<24|0)!=(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24|0))break;h=h+4|0;j=t+4|0}while(1){if(j>>>0>=G>>>0)break;if((a[k+(u+h)>>0]|0)!=(a[j>>0]|0))break;h=h+1|0;j=j+1|0}if(h>>>0<=3)continue;j=(h*540|0)+3840+(_((aa(v|0)|0)^31,-120)|0)|0;if(g>>>0<j>>>0)break}c[qa>>2]=h;c[ea>>2]=v;c[fa>>2]=j;u=v;A=h;g=j;t=w;h=z;f=1;j=B}Ga=(_(d[I>>0]|d[I+1>>0]<<8|d[I+2>>0]<<16|d[I+3>>0]<<24,506832829)|0)>>>17;H=Ga&511;N=n+1310720+(H<<1)|0;Fa=b[N>>1]|0;b[N>>1]=Fa+1<<16>>16;Fa=Fa&511;N=n+(Ga<<2)|0;G=y-(c[N>>2]|0)|0;a[(y&65535)+(n+196608)>>0]=Ga;b[n+262144+(H<<11)+(Fa<<2)>>1]=G>>>0>65535?65535:G;Ga=n+131072+(Ga<<1)|0;b[n+262144+(H<<11)+(Fa<<2)+2>>1]=b[Ga>>1]|0;c[N>>2]=y;b[Ga>>1]=Fa;if(!(f&1)){if((c[V>>2]|0)>>>0<(c[W>>2]|0)>>>7>>>0)f=0;else{v=0;f=0;u=(_(d[I>>0]|d[I+1>>0]<<8|d[I+2>>0]<<16|d[I+3>>0]<<24,506832829)|0)>>>18<<1;while(1){if((v|0)==2)break;Ga=b[21084+(u<<1)>>1]|0;j=Ga&65535;c[W>>2]=(c[W>>2]|0)+1;if(Ga<<16>>16!=0?(za=j&31,Aa=j>>>5,Ba=(c[11272+(za<<2)>>2]|0)+(_(za,Aa)|0)|0,za>>>0<=L>>>0):0){g=Ba+za|0;h=280811+g|0;g=280811+(g+-4)|0;t=0;j=280811+Ba|0;while(1){if(j>>>0>g>>>0)break;Ga=k+(K+t)|0;if((d[j>>0]|d[j+1>>0]<<8|d[j+2>>0]<<16|d[j+3>>0]<<24|0)!=(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24|0))break;t=t+4|0;j=j+4|0}while(1){if(j>>>0>=h>>>0)break;if((a[k+(K+t)>>0]|0)!=(a[j>>0]|0))break;t=t+1|0;j=j+1|0}if(!((t+10|0)>>>0<=za>>>0|(t|0)==0)?(Ca=J+Aa+1+(d[407930+(za-t)>>0]<<d[280786+za>>0])|0,Da=(t*540|0)+3840+(_((aa(Ca|0)|0)^31,-120)|0)|0,Da>>>0>=(c[fa>>2]|0)>>>0):0){c[qa>>2]=t;c[da>>2]=za^t;c[ea>>2]=Ca;c[fa>>2]=Da;c[V>>2]=(c[V>>2]|0)+1;f=1}}v=v+1|0;u=u+1|0}f=(f&1)!=0}f=f&1}if(!(f&1)){y=m;break}if((c[$>>2]|0)>>>0<((c[R>>2]|0)+700|0)>>>0){y=m;break}f=x+1|0;c[pa>>2]=c[qa>>2];c[pa+4>>2]=c[qa+4>>2];c[pa+8>>2]=c[qa+8>>2];c[pa+12>>2]=c[qa+12>>2];M=M+1|0;if(!((M|0)<4&(m+5|0)>>>0<oa>>>0)){x=f;break}else{m=y;x=f}}m=c[pa>>2]|0;t=y+(m<<1)+ja|0;f=c[Q>>2]|0;e:do if(f>>>0<=(y>>>0<na>>>0?y:na)>>>0){h=f+3|0;Ga=c[o>>2]|0;j=h-Ga|0;g=c[ia>>2]|0;h=h-g|0;if((f|0)==(Ga|0))f=0;else{f:do if((f|0)!=(g|0)){do if(j>>>0<7)f=158663784>>>(j<<2)&15;else{if(h>>>0<7){f=266017486>>>(h<<2)&15;break}if((f|0)==(c[ga>>2]|0)){f=2;break f}if((f|0)==(c[ha>>2]|0)){f=3;break f}f=f+15|0}while(0);if(!f)break e}else f=1;while(0);c[ha>>2]=c[ga>>2];c[ga>>2]=c[ia>>2];c[ia>>2]=c[o>>2];c[o>>2]=c[Q>>2];m=c[pa>>2]|0}}else f=f+15|0;while(0);w=O+16|0;Ga=c[P>>2]|0;j=m^Ga;c[O>>2]=x;c[O+4>>2]=m|Ga<<24;m=O+14|0;if(f>>>0<16){f=f&65535;b[m>>1]=f;m=0}else{N=f+-12|0;Ga=((aa(N|0)|0)^31)+-1|0;Fa=N>>>Ga&1;f=((Ga<<1)+65534|Fa)+16&65535;b[m>>1]=f;m=Ga<<24|N-((Fa|2)<<Ga)}c[O+8>>2]=m;u=f<<16>>16==0;v=O+12|0;do if(x>>>0>=6){if(x>>>0<130){Ga=x+-2|0;h=((aa(Ga|0)|0)^31)+-1|0;h=(h<<1)+(Ga>>>h)+2&65535;break}if(x>>>0<2114){h=((aa(x+-66|0)|0)^31)+10&65535;break}if(x>>>0<6210)h=21;else h=x>>>0<22594?22:23}else h=x&65535;while(0);do if(j>>>0>=10){if(j>>>0<134){Ga=j+-6|0;f=((aa(Ga|0)|0)^31)+-1|0;f=(f<<1)+(Ga>>>f)+4&65535;break}if(j>>>0<2118)f=((aa(j+-70|0)|0)^31)+12&65535;else f=23}else f=j+65534&65535;while(0);m=f&65535;j=h&65535;g=m&7|j<<3&56;if(u&(h&65535)<8&(f&65535)<16)f=((f&65535)<8?g:g|64)&65535;else f=b[88156+((m>>>3)+((j>>>3)*3|0)<<1)>>1]|g&65535;b[v>>1]=f;c[s>>2]=(c[s>>2]|0)+x;f=y+(c[pa>>2]|0)|0;f=f>>>0<ma>>>0?f:ma;m=y+2|0;while(1){if(m>>>0>=f>>>0)break;Ga=k+(m&l)|0;Ga=(_(d[Ga>>0]|d[Ga+1>>0]<<8|d[Ga+2>>0]<<16|d[Ga+3>>0]<<24,506832829)|0)>>>17;N=Ga&511;O=n+1310720+(N<<1)|0;Fa=b[O>>1]|0;b[O>>1]=Fa+1<<16>>16;Fa=Fa&511;O=n+(Ga<<2)|0;M=m-(c[O>>2]|0)|0;a[(m&65535)+(n+196608)>>0]=Ga;b[n+262144+(N<<11)+(Fa<<2)>>1]=M>>>0>65535?65535:M;Ga=n+131072+(Ga<<1)|0;b[n+262144+(N<<11)+(Fa<<2)+2>>1]=b[Ga>>1]|0;c[O>>2]=m;b[Ga>>1]=Fa;m=m+1|0}m=y+(c[pa>>2]|0)|0;O=w;f=0}c[p>>2]=f+L;c[r>>2]=(c[r>>2]|0)+(M-q>>4);i=ra;return}function Ua(b,d,e,f,g,h){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0;j=d+524304|0;if(!(a[j>>0]&1))return;e=1<<c[e+8>>2];c[d>>2]=e+-1;e=1-e|0;c[d+524296>>2]=e;i=0;while(1){if((i|0)==131072)break;c[d+4+(i<<2)>>2]=e;i=i+1|0}if((f|0)==0^1|h^1)g=(c[d>>2]|0)+1|0;h=d+524300|0;do if(g>>>0>(c[h>>2]|0)>>>0){i=d+524292|0;e=b+8|0;ra[c[b+4>>2]&1](c[e>>2]|0,c[i>>2]|0);c[i>>2]=0;e=sa[c[b>>2]&1](c[e>>2]|0,g<<3)|0;if(!e)oa(1);else{c[i>>2]=e;c[h>>2]=g;break}}while(0);a[j>>0]=0;return}function Va(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0,h=0,i=0.0,j=0.0,k=0;f=0;h=0;while(1){if((f|0)==(b|0))break;k=h+(c[a+(f<<2)>>2]|0)|0;f=f+1|0;h=k}if(h>>>0<256)e=+g[19516+(h<<2)>>2];else e=+Xb(+(h>>>0));j=e+2.0;h=0;while(1){if((h|0)==(b|0))break;f=c[a+(h<<2)>>2]|0;if(f){if(f>>>0<256)i=+g[19516+(f<<2)>>2];else i=+Xb(+(f>>>0));i=e-i;f=d+(h<<2)|0;g[f>>2]=i;if(i<1.0)g[f>>2]=1.0}else g[d+(h<<2)>>2]=j;h=h+1|0}return}function Wa(a){a=a|0;var b=0.0,d=0,e=0.0,f=0,h=0.0,j=0.0,k=0.0,l=0,m=0,n=0,o=0.0,p=0,q=0.0,r=0,s=0;s=i;i=i+112|0;m=s+88|0;p=s+72|0;r=s;n=c[a+1024>>2]|0;if(!n){q=12.0;i=s;return +q}else{f=0;l=0}while(1){if(l>>>0>=256){d=f;break}if(c[a+(l<<2)>>2]|0){c[m+(f<<2)>>2]=l;d=f+1|0;if((f|0)>3)break}else d=f;f=d;l=l+1|0}switch(d|0){case 2:{q=+(n>>>0)+20.0;i=s;return +q}case 3:{p=c[a+(c[m>>2]<<2)>>2]|0;n=c[a+(c[m+4>>2]<<2)>>2]|0;a=c[a+(c[m+8>>2]<<2)>>2]|0;r=n>>>0>a>>>0?n:a;q=+(p+n+a<<1>>>0)+28.0-+((p>>>0>r>>>0?p:r)>>>0);i=s;return +q}case 4:{d=0;while(1){if((d|0)==4){n=0;break}c[p+(d<<2)>>2]=c[a+(c[m+(d<<2)>>2]<<2)>>2];d=d+1|0}while(1){if((n|0)==4)break;m=p+(n<<2)|0;d=n;while(1){a=d+1|0;if((d|0)==3)break;d=p+(a<<2)|0;f=c[d>>2]|0;l=c[m>>2]|0;if(f>>>0<=l>>>0){d=a;continue}c[d>>2]=l;c[m>>2]=f;d=a}n=n+1|0}a=(c[p+8>>2]|0)+(c[p+12>>2]|0)|0;r=c[p>>2]|0;q=+((a*3|0)>>>0)+37.0+ +(r+(c[p+4>>2]|0)<<1>>>0)-+((a>>>0>r>>>0?a:r)>>>0);i=s;return +q}case 1:{q=12.0;i=s;return +q}default:{d=r;f=d+72|0;do{c[d>>2]=0;d=d+4|0}while((d|0)<(f|0));if(n>>>0<256)h=+g[19516+(n<<2)>>2];else h=+Xb(+(n>>>0));m=r+68|0;b=0.0;d=0;n=1;a:while(1){q=b;b:while(1){while(1){if(d>>>0>=256)break a;f=c[a+(d<<2)>>2]|0;if(!f){l=1;f=d}else break b;while(1){f=f+1|0;if(f>>>0>=256)break;if(c[a+(f<<2)>>2]|0)break;l=l+1|0}d=d+l|0;if((d|0)==256)break a;if(l>>>0>=3)break;c[r>>2]=(c[r>>2]|0)+l}b=q;f=l+-2|0;while(1){if(!f){q=b;continue b}c[m>>2]=(c[m>>2]|0)+1;b=b+3.0;f=f>>>3}}if(f>>>0<256){e=+(f>>>0);b=+g[19516+(f<<2)>>2]}else{b=+(f>>>0);e=b;b=+Xb(b)}b=h-b;p=~~(b+.5)>>>0;p=p>>>0>15?15:p;l=r+(p<<2)|0;c[l>>2]=(c[l>>2]|0)+1;b=q+e*b;d=d+1|0;n=p>>>0>n>>>0?p:n}o=+(((n<<1)+18|0)>>>0);m=r+72|0;d=r;b=0.0;n=0;while(1){if(d>>>0>=m>>>0)break;f=c[d>>2]|0;e=+(f>>>0);if(f>>>0<256)k=+g[19516+(f<<2)>>2];else k=+Xb(e);l=c[d+4>>2]|0;h=+(l>>>0);if(l>>>0<256)j=+g[19516+(l<<2)>>2];else j=+Xb(h);d=d+8|0;b=b-e*k-h*j;n=n+f+l|0}k=q+o;j=+(n>>>0);if(!n)h=j;else{if(n>>>0<256)e=+g[19516+(n<<2)>>2];else e=+Xb(j);h=j;b=b+j*e}q=k+(b<h?h:b);i=s;return +q}}return 0.0}function Xa(a){a=a|0;var b=0.0,d=0,e=0.0,f=0,h=0.0,j=0.0,k=0.0,l=0,m=0,n=0,o=0.0,p=0,q=0.0,r=0,s=0;s=i;i=i+112|0;m=s+88|0;p=s+72|0;r=s;n=c[a+2816>>2]|0;if(!n){q=12.0;i=s;return +q}else{f=0;l=0}while(1){if(l>>>0>=704){d=f;break}if(c[a+(l<<2)>>2]|0){c[m+(f<<2)>>2]=l;d=f+1|0;if((f|0)>3)break}else d=f;f=d;l=l+1|0}switch(d|0){case 2:{q=+(n>>>0)+20.0;i=s;return +q}case 3:{p=c[a+(c[m>>2]<<2)>>2]|0;n=c[a+(c[m+4>>2]<<2)>>2]|0;a=c[a+(c[m+8>>2]<<2)>>2]|0;r=n>>>0>a>>>0?n:a;q=+(p+n+a<<1>>>0)+28.0-+((p>>>0>r>>>0?p:r)>>>0);i=s;return +q}case 4:{d=0;while(1){if((d|0)==4){n=0;break}c[p+(d<<2)>>2]=c[a+(c[m+(d<<2)>>2]<<2)>>2];d=d+1|0}while(1){if((n|0)==4)break;m=p+(n<<2)|0;d=n;while(1){a=d+1|0;if((d|0)==3)break;d=p+(a<<2)|0;f=c[d>>2]|0;l=c[m>>2]|0;if(f>>>0<=l>>>0){d=a;continue}c[d>>2]=l;c[m>>2]=f;d=a}n=n+1|0}a=(c[p+8>>2]|0)+(c[p+12>>2]|0)|0;r=c[p>>2]|0;q=+((a*3|0)>>>0)+37.0+ +(r+(c[p+4>>2]|0)<<1>>>0)-+((a>>>0>r>>>0?a:r)>>>0);i=s;return +q}case 1:{q=12.0;i=s;return +q}default:{d=r;f=d+72|0;do{c[d>>2]=0;d=d+4|0}while((d|0)<(f|0));if(n>>>0<256)h=+g[19516+(n<<2)>>2];else h=+Xb(+(n>>>0));m=r+68|0;b=0.0;d=0;n=1;a:while(1){q=b;b:while(1){while(1){if(d>>>0>=704)break a;f=c[a+(d<<2)>>2]|0;if(!f){l=1;f=d}else break b;while(1){f=f+1|0;if(f>>>0>=704)break;if(c[a+(f<<2)>>2]|0)break;l=l+1|0}d=d+l|0;if((d|0)==704)break a;if(l>>>0>=3)break;c[r>>2]=(c[r>>2]|0)+l}b=q;f=l+-2|0;while(1){if(!f){q=b;continue b}c[m>>2]=(c[m>>2]|0)+1;b=b+3.0;f=f>>>3}}if(f>>>0<256){e=+(f>>>0);b=+g[19516+(f<<2)>>2]}else{b=+(f>>>0);e=b;b=+Xb(b)}b=h-b;p=~~(b+.5)>>>0;p=p>>>0>15?15:p;l=r+(p<<2)|0;c[l>>2]=(c[l>>2]|0)+1;b=q+e*b;d=d+1|0;n=p>>>0>n>>>0?p:n}o=+(((n<<1)+18|0)>>>0);m=r+72|0;d=r;b=0.0;n=0;while(1){if(d>>>0>=m>>>0)break;f=c[d>>2]|0;e=+(f>>>0);if(f>>>0<256)k=+g[19516+(f<<2)>>2];else k=+Xb(e);l=c[d+4>>2]|0;h=+(l>>>0);if(l>>>0<256)j=+g[19516+(l<<2)>>2];else j=+Xb(h);d=d+8|0;b=b-e*k-h*j;n=n+f+l|0}k=q+o;j=+(n>>>0);if(!n)h=j;else{if(n>>>0<256)e=+g[19516+(n<<2)>>2];else e=+Xb(j);h=j;b=b+j*e}q=k+(b<h?h:b);i=s;return +q}}return 0.0}function Ya(a){a=a|0;var b=0.0,d=0,e=0.0,f=0,h=0.0,j=0.0,k=0.0,l=0,m=0,n=0,o=0.0,p=0,q=0.0,r=0,s=0;s=i;i=i+112|0;m=s+88|0;p=s+72|0;r=s;n=c[a+2080>>2]|0;if(!n){q=12.0;i=s;return +q}else{f=0;l=0}while(1){if(l>>>0>=520){d=f;break}if(c[a+(l<<2)>>2]|0){c[m+(f<<2)>>2]=l;d=f+1|0;if((f|0)>3)break}else d=f;f=d;l=l+1|0}switch(d|0){case 2:{q=+(n>>>0)+20.0;i=s;return +q}case 3:{p=c[a+(c[m>>2]<<2)>>2]|0;n=c[a+(c[m+4>>2]<<2)>>2]|0;a=c[a+(c[m+8>>2]<<2)>>2]|0;r=n>>>0>a>>>0?n:a;q=+(p+n+a<<1>>>0)+28.0-+((p>>>0>r>>>0?p:r)>>>0);i=s;return +q}case 4:{d=0;while(1){if((d|0)==4){n=0;break}c[p+(d<<2)>>2]=c[a+(c[m+(d<<2)>>2]<<2)>>2];d=d+1|0}while(1){if((n|0)==4)break;m=p+(n<<2)|0;d=n;while(1){a=d+1|0;if((d|0)==3)break;d=p+(a<<2)|0;f=c[d>>2]|0;l=c[m>>2]|0;if(f>>>0<=l>>>0){d=a;continue}c[d>>2]=l;c[m>>2]=f;d=a}n=n+1|0}a=(c[p+8>>2]|0)+(c[p+12>>2]|0)|0;r=c[p>>2]|0;q=+((a*3|0)>>>0)+37.0+ +(r+(c[p+4>>2]|0)<<1>>>0)-+((a>>>0>r>>>0?a:r)>>>0);i=s;return +q}case 1:{q=12.0;i=s;return +q}default:{d=r;f=d+72|0;do{c[d>>2]=0;d=d+4|0}while((d|0)<(f|0));if(n>>>0<256)h=+g[19516+(n<<2)>>2];else h=+Xb(+(n>>>0));m=r+68|0;b=0.0;d=0;n=1;a:while(1){q=b;b:while(1){while(1){if(d>>>0>=520)break a;f=c[a+(d<<2)>>2]|0;if(!f){l=1;f=d}else break b;while(1){f=f+1|0;if(f>>>0>=520)break;if(c[a+(f<<2)>>2]|0)break;l=l+1|0}d=d+l|0;if((d|0)==520)break a;if(l>>>0>=3)break;c[r>>2]=(c[r>>2]|0)+l}b=q;f=l+-2|0;while(1){if(!f){q=b;continue b}c[m>>2]=(c[m>>2]|0)+1;b=b+3.0;f=f>>>3}}if(f>>>0<256){e=+(f>>>0);b=+g[19516+(f<<2)>>2]}else{b=+(f>>>0);e=b;b=+Xb(b)}b=h-b;p=~~(b+.5)>>>0;p=p>>>0>15?15:p;l=r+(p<<2)|0;c[l>>2]=(c[l>>2]|0)+1;b=q+e*b;d=d+1|0;n=p>>>0>n>>>0?p:n}o=+(((n<<1)+18|0)>>>0);m=r+72|0;d=r;b=0.0;n=0;while(1){if(d>>>0>=m>>>0)break;f=c[d>>2]|0;e=+(f>>>0);if(f>>>0<256)k=+g[19516+(f<<2)>>2];else k=+Xb(e);l=c[d+4>>2]|0;h=+(l>>>0);if(l>>>0<256)j=+g[19516+(l<<2)>>2];else j=+Xb(h);d=d+8|0;b=b-e*k-h*j;n=n+f+l|0}k=q+o;j=+(n>>>0);if(!n)h=j;else{if(n>>>0<256)e=+g[19516+(n<<2)>>2];else e=+Xb(j);h=j;b=b+j*e}q=k+(b<h?h:b);i=s;return +q}}return 0.0}function Za(f,j,k,l,m,n,o,p,q,r){f=f|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=o|0;p=p|0;q=q|0;r=r|0;var t=0,u=0,v=0,w=0,x=0,y=0.0,z=0.0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,$=0,aa=0,ba=0.0;aa=i;i=i+6688|0;Z=aa+2832|0;Y=aa;V=aa+6432|0;T=aa+6176|0;W=aa+5920|0;U=aa+5664|0;t=0;K=0;while(1){if((t|0)==(k|0))break;$=K+(c[j+(t<<4)>>2]|0)|0;t=t+1|0;K=$}$=f+8|0;R=sa[c[f>>2]&1](c[$>>2]|0,K)|0;if(!R)oa(1);x=n+1|0;v=0;w=0;while(1){t=m&n;if((w|0)==(k|0))break;m=c[j+(w<<4)>>2]|0;if((t+m|0)>>>0>n>>>0){Q=x-t|0;dc(R+v|0,l+t|0,Q|0)|0;t=0;u=m-Q|0;m=v+Q|0}else{u=m;m=v}if(u){dc(R+m|0,l+t|0,u|0)|0;m=m+u|0}v=m;m=t+u+(c[j+(w<<4)+4>>2]&16777215)|0;w=w+1|0}B=((K>>>0)/544|0)+1|0;B=B>>>0>100?100:B;do if(K){if(K>>>0<128){w=p+16|0;m=c[w>>2]|0;x=p+4|0;t=c[x>>2]|0;u=t+1|0;if(m>>>0<u>>>0){v=(m|0)==0?u:m;while(1){if(v>>>0>=u>>>0)break;v=v<<1}m=sa[c[f>>2]&1](c[$>>2]|0,v)|0;if(!m)oa(1);u=c[w>>2]|0;t=p+8|0;if(u)dc(m|0,c[t>>2]|0,u|0)|0;ra[c[f+4>>2]&1](c[$>>2]|0,c[t>>2]|0);c[t>>2]=m;c[w>>2]=v;t=c[x>>2]|0}w=p+20|0;m=c[w>>2]|0;u=t+1|0;if(m>>>0<u>>>0){v=(m|0)==0?u:m;while(1){if(v>>>0>=u>>>0)break;v=v<<1}t=sa[c[f>>2]&1](c[$>>2]|0,v<<2)|0;if(!t)oa(1);u=c[w>>2]|0;m=p+12|0;if(u)dc(t|0,c[m>>2]|0,u<<2|0)|0;ra[c[f+4>>2]&1](c[$>>2]|0,c[m>>2]|0);c[m>>2]=t;c[w>>2]=v;t=c[x>>2]|0}else m=p+12|0;c[p>>2]=1;a[(c[p+8>>2]|0)+t>>0]=0;c[(c[m>>2]|0)+(c[x>>2]<<2)>>2]=K;c[x>>2]=(c[x>>2]|0)+1;break}J=sa[c[f>>2]&1](c[$>>2]|0,B*1040|0)|0;if(!J)oa(1);t=0;while(1){if((t|0)==(B|0))break;ac(J+(t*1040|0)|0,0,1024)|0;c[J+(t*1040|0)+1024>>2]=0;h[J+(t*1040|0)+1032>>3]=s;t=t+1|0}w=(K>>>0)/(B>>>0)|0;x=K+-71|0;m=7;l=0;while(1){if((l|0)==(B|0))break;t=((_(K,l)|0)>>>0)/(B>>>0)|0;if(l){m=m*16807|0;m=(m|0)==0?1:m;t=t+((m>>>0)%(w>>>0)|0)|0}u=J+(l*1040|0)+1024|0;c[u>>2]=(c[u>>2]|0)+70;u=71;v=R+((t+70|0)>>>0<K>>>0?t:x)|0;while(1){t=u+-1|0;if(!t)break;u=J+(l*1040|0)+(d[v>>0]<<2)|0;c[u>>2]=(c[u>>2]|0)+1;u=t;v=v+1|0}l=l+1|0}c[Z>>2]=7;u=((K<<1>>>0)/70|0)+100+B+-1|0;u=u-((u>>>0)%(B>>>0)|0)|0;v=Y+1024|0;w=Y+1032|0;x=K>>>0>70;l=K+-69|0;n=Y+1024|0;A=0;while(1){if(A>>>0>=u>>>0)break;ac(Y|0,0,1028)|0;h[w>>3]=s;if(x){m=(c[Z>>2]|0)*16807|0;Q=(m|0)==0;c[Z>>2]=Q?1:m;t=70;m=((Q?1:m)>>>0)%(l>>>0)|0}else{t=K;m=0}c[n>>2]=(c[n>>2]|0)+t;t=t+1|0;m=R+m|0;while(1){t=t+-1|0;if(!t)break;Q=Y+(d[m>>0]<<2)|0;c[Q>>2]=(c[Q>>2]|0)+1;m=m+1|0}t=(A>>>0)%(B>>>0)|0;m=J+(t*1040|0)+1024|0;c[m>>2]=(c[m>>2]|0)+(c[v>>2]|0);m=0;while(1){if((m|0)==256)break;Q=J+(t*1040|0)+(m<<2)|0;c[Q>>2]=(c[Q>>2]|0)+(c[Y+(m<<2)>>2]|0);m=m+1|0}A=A+1|0}Q=sa[c[f>>2]&1](c[$>>2]|0,K)|0;if(!Q)oa(1);F=sa[c[f>>2]&1](c[$>>2]|0,B<<11)|0;if(!F)oa(1);G=sa[c[f>>2]&1](c[$>>2]|0,B<<3)|0;if(!G)oa(1);H=_(K,(B+7|0)>>>3)|0;H=sa[c[f>>2]&1](c[$>>2]|0,H)|0;if(!H)oa(1);I=sa[c[f>>2]&1](c[$>>2]|0,B<<1)|0;if(!I)oa(1);C=(c[o+4>>2]|0)<11?3:10;D=K+-1|0;E=Q+D|0;O=0;A=0;a:while(1){if(A>>>0>=C>>>0){l=136;break}n=(B+7|0)>>>3;if(B>>>0>=257){l=73;break}b:do if(B>>>0<2){t=0;while(1){if((t|0)==(K|0)){v=1;break b}a[Q+t>>0]=0;t=t+1|0}}else{ac(F|0,0,B<<11|0)|0;m=0;while(1){if((m|0)==(B|0)){t=256;break}t=c[J+(m*1040|0)+1024>>2]|0;if(t>>>0<256)y=+g[19516+(t<<2)>>2];else y=+Xb(+(t>>>0));h[F+(m<<3)>>3]=y;m=m+1|0}c:while(1){if(!t)break;t=t+-1|0;u=_(t,B)|0;v=0;while(1){if((v|0)==(B|0))continue c;z=+h[F+(v<<3)>>3];m=c[J+(v*1040|0)+(t<<2)>>2]|0;do if(m)if(m>>>0<256){y=+g[19516+(m<<2)>>2];break}else{y=+Xb(+(m>>>0));break}else y=-2.0;while(0);h[F+(u+v<<3)>>3]=z-y;v=v+1|0}}ac(G|0,0,B<<3|0)|0;ac(H|0,0,_(K,n)|0)|0;v=0;while(1){if(v>>>0>=K>>>0)break;t=_(d[R+v>>0]|0,B)|0;m=Q+v|0;z=1.e+99;u=0;while(1){if((u|0)==(B|0))break;O=G+(u<<3)|0;y=+h[O>>3]+ +h[F+(t+u<<3)>>3];h[O>>3]=y;if(y<z)a[m>>0]=u;else y=z;z=y;u=u+1|0}m=_(v,n)|0;if(v>>>0<2e3)y=(+(v>>>0)*.07/2.0e3+.77)*28.1;else y=28.1;u=0;while(1){if(u>>>0>=B>>>0)break;t=G+(u<<3)|0;ba=+h[t>>3]-z;h[t>>3]=ba;if(ba>=y){h[t>>3]=y;t=u>>>3;if(t>>>0>=n>>>0){l=104;break a}O=H+(m+t)|0;a[O>>0]=a[O>>0]|1<<(u&7)&255}u=u+1|0}v=v+1|0}m=_(D,n)|0;v=D;t=a[E>>0]|0;u=1;while(1){if(!v){v=u;break b}w=t&255;x=w>>>3;if(x>>>0>=n>>>0){l=111;break a}l=v+-1|0;m=m-n|0;v=Q+l|0;if((a[H+(m+x)>>0]&(1<<(w&7)&255))<<24>>24){N=a[v>>0]|0;O=t<<24>>24==N<<24>>24;t=O?t:N;u=O?u:u+1|0}a[v>>0]=t;v=l}}while(0);t=0;while(1){if((t|0)==(B|0)){t=0;u=0;break}b[I+(t<<1)>>1]=256;t=t+1|0}while(1){if(u>>>0>=K>>>0){m=0;break}m=d[Q+u>>0]|0;if(m>>>0>=B>>>0){l=120;break a}m=I+(m<<1)|0;if((b[m>>1]|0)==256){b[m>>1]=t;t=t+1<<16>>16}u=u+1|0}while(1){if(m>>>0>=K>>>0)break;N=Q+m|0;O=b[I+(d[N>>0]<<1)>>1]|0;a[N>>0]=O;if((O&255)>>>0>=B>>>0){l=126;break a}m=m+1|0}u=t&65535;if(u>>>0>B>>>0){l=129;break}t=t&65535;m=0;while(1){if((m|0)==(t|0)){t=0;break}ac(J+(m*1040|0)|0,0,1024)|0;c[J+(m*1040|0)+1024>>2]=0;h[J+(m*1040|0)+1032>>3]=s;m=m+1|0}while(1){if((t|0)==(K|0))break;O=d[Q+t>>0]|0;N=J+(O*1040|0)+(d[R+t>>0]<<2)|0;c[N>>2]=(c[N>>2]|0)+1;O=J+(O*1040|0)+1024|0;c[O>>2]=(c[O>>2]|0)+1;t=t+1|0}O=v;B=u;A=A+1|0}if((l|0)==73)pa(404083,403848,80,404281);else if((l|0)==104)pa(404124,403848,130,404281);else if((l|0)==111)pa(404145,403848,141,404281);else if((l|0)==120)pa(404005,403848,165,404260);else if((l|0)==126)pa(404005,403848,172,404260);else if((l|0)==129)pa(404057,403848,174,404260);else if((l|0)==136){N=f+4|0;ra[c[N>>2]&1](c[$>>2]|0,F);ra[c[N>>2]&1](c[$>>2]|0,G);ra[c[N>>2]&1](c[$>>2]|0,H);ra[c[N>>2]&1](c[$>>2]|0,I);ra[c[N>>2]&1](c[$>>2]|0,J);t=O<<2;L=sa[c[f>>2]&1](c[$>>2]|0,t)|0;if(!L)oa(1);M=sa[c[f>>2]&1](c[$>>2]|0,t)|0;if(!M)oa(1);x=((O<<4)+1008|0)>>>6;J=sa[c[f>>2]&1](c[$>>2]|0,x*1040|0)|0;v=J;if(!J)oa(1);J=sa[c[f>>2]&1](c[$>>2]|0,x<<2)|0;w=J;if(!J)oa(1);G=sa[c[f>>2]&1](c[$>>2]|0,(O>>>0<64?O:64)*1040|0)|0;if(!G)oa(1);H=sa[c[f>>2]&1](c[$>>2]|0,49176)|0;if(!H)oa(1);ac(V|0,0,256)|0;ac(T|0,0,256)|0;ac(W|0,0,256)|0;ac(U|0,0,256)|0;ac(M|0,0,t|0)|0;m=0;u=0;while(1){if(u>>>0>=K>>>0)break;if(m>>>0>=O>>>0){l=151;break}t=M+(m<<2)|0;c[t>>2]=(c[t>>2]|0)+1;t=u+1|0;if((t|0)!=(K|0)?(a[Q+u>>0]|0)==(a[Q+t>>0]|0):0){u=t;continue}m=m+1|0;u=t}if((l|0)==151)pa(403825,403848,231,404239);if((m|0)!=(O|0))pa(403911,403848,237,404239);C=x;B=x;J=0;t=0;F=0;while(1){if(O>>>0<=F>>>0){l=193;break}E=O-F|0;E=E>>>0<64?E:64;n=0;while(1){if((n|0)==(E|0))break;u=G+(n*1040|0)|0;ac(u|0,0,1024)|0;x=G+(n*1040|0)+1024|0;c[x>>2]=0;h[G+(n*1040|0)+1032>>3]=s;l=M+(F+n<<2)|0;m=0;while(1){if(m>>>0>=(c[l>>2]|0)>>>0)break;K=G+(n*1040|0)+(d[R+t>>0]<<2)|0;c[K>>2]=(c[K>>2]|0)+1;c[x>>2]=(c[x>>2]|0)+1;t=t+1|0;m=m+1|0}h[G+(n*1040|0)+1032>>3]=+Wa(u);c[T+(n<<2)>>2]=n;c[W+(n<<2)>>2]=n;c[V+(n<<2)>>2]=1;n=n+1|0}D=pb(G,V,W,T,H,E,E,64,2048)|0;m=J+D|0;if(C>>>0<m>>>0){u=(C|0)==0;x=u?m:C;while(1){if(x>>>0>=m>>>0)break;x=x<<1}m=sa[c[f>>2]&1](c[$>>2]|0,x*1040|0)|0;if(!m){l=170;break}if(!u)dc(m|0,v|0,C*1040|0)|0;ra[c[N>>2]&1](c[$>>2]|0,v);v=m;C=x}m=J+D|0;if(B>>>0<m>>>0){u=(B|0)==0;x=u?m:B;while(1){if(x>>>0>=m>>>0)break;x=x<<1}m=sa[c[f>>2]&1](c[$>>2]|0,x<<2)|0;if(!m){l=179;break}if(!u)dc(m|0,w|0,B<<2|0)|0;ra[c[N>>2]&1](c[$>>2]|0,w);w=m;B=x}m=v;u=w;A=D+J|0;x=J;l=J;n=0;while(1){if((n|0)==(D|0)){m=0;break}K=T+(n<<2)|0;I=c[K>>2]|0;dc(m+(x*1040|0)|0,G+(I*1040|0)|0,1040)|0;c[u+(l<<2)>>2]=c[V+(I<<2)>>2];c[U+(c[K>>2]<<2)>>2]=n;x=x+1|0;l=l+1|0;n=n+1|0}while(1){if((m|0)==(E|0))break;c[L+(F+m<<2)>>2]=J+(c[U+(c[W+(m<<2)>>2]<<2)>>2]|0);m=m+1|0}m=D+J|0;if((J+D|0)!=(m|0)){l=189;break}if((m|0)!=(A|0)){l=191;break}J=m;F=F+64|0}if((l|0)==170)oa(1);else if((l|0)==179)oa(1);else if((l|0)==189)pa(403935,403848,273,404239);else if((l|0)==191)pa(403969,403848,274,404239);else if((l|0)==193){ra[c[N>>2]&1](c[$>>2]|0,G);K=J<<6;u=_(J>>>1,J)|0;u=K>>>0<u>>>0?K:u;do if((u+1|0)>>>0>2049){ra[c[N>>2]&1](c[$>>2]|0,H);t=sa[c[f>>2]&1](c[$>>2]|0,(u*24|0)+24|0)|0;if(t){P=t;break}oa(1)}else P=H;while(0);m=J<<2;I=sa[c[f>>2]&1](c[$>>2]|0,m)|0;if(!I)oa(1);t=0;while(1){if((t|0)==(J|0))break;c[I+(t<<2)>>2]=t;t=t+1|0}H=v;G=pb(H,w,L,I,P,J,O,256,u)|0;ra[c[N>>2]&1](c[$>>2]|0,P);ra[c[N>>2]&1](c[$>>2]|0,w);K=sa[c[f>>2]&1](c[$>>2]|0,m)|0;if(!K)oa(1);t=0;while(1){if((t|0)==(J|0))break;c[K+(t<<2)>>2]=-1;t=t+1|0}B=Y+1024|0;C=Y+1032|0;D=Z+1024|0;E=Z+1024|0;t=0;m=0;F=0;while(1){if((F|0)==(O|0))break;ac(Y|0,0,1028)|0;h[C>>3]=s;u=M+(F<<2)|0;w=0;A=m;m=0;while(1){if(m>>>0>=(c[u>>2]|0)>>>0)break;w=Y+(d[R+A>>0]<<2)|0;c[w>>2]=(c[w>>2]|0)+1;w=(c[B>>2]|0)+1|0;c[B>>2]=w;A=A+1|0;m=m+1|0}u=c[((F|0)==0?L:L+(F+-1<<2)|0)>>2]|0;n=(w|0)==0;if(n)y=0.0;else{dc(Z|0,Y|0,1040)|0;c[E>>2]=(c[E>>2]|0)+(c[H+(u*1040|0)+1024>>2]|0);m=0;while(1){if((m|0)==256)break;P=Z+(m<<2)|0;c[P>>2]=(c[P>>2]|0)+(c[H+(u*1040|0)+(m<<2)>>2]|0);m=m+1|0}y=+Wa(Z);y=y-+h[H+(u*1040|0)+1032>>3]}m=u;l=0;while(1){if((l|0)==(G|0))break;x=I+(l<<2)|0;u=c[x>>2]|0;if(n)z=0.0;else{dc(Z|0,Y|0,1040)|0;c[D>>2]=(c[D>>2]|0)+(c[H+(u*1040|0)+1024>>2]|0);w=0;while(1){if((w|0)==256)break;P=Z+(w<<2)|0;c[P>>2]=(c[P>>2]|0)+(c[H+(u*1040|0)+(w<<2)>>2]|0);w=w+1|0}z=+Wa(Z);z=z-+h[H+(u*1040|0)+1032>>3]}if(z<y){y=z;m=c[x>>2]|0}l=l+1|0}c[L+(F<<2)>>2]=m;m=K+(m<<2)|0;if((c[m>>2]|0)==-1){c[m>>2]=t;t=t+1|0}m=A;F=F+1|0}ra[c[N>>2]&1](c[$>>2]|0,I);ra[c[N>>2]&1](c[$>>2]|0,v);w=p+16|0;t=c[w>>2]|0;if(t>>>0<O>>>0){v=(t|0)==0?O:t;while(1){if(v>>>0>=O>>>0)break;v=v<<1}m=sa[c[f>>2]&1](c[$>>2]|0,v)|0;if(!m)oa(1);u=c[w>>2]|0;t=p+8|0;if(u)dc(m|0,c[t>>2]|0,u|0)|0;ra[c[N>>2]&1](c[$>>2]|0,c[t>>2]|0);c[t>>2]=m;c[w>>2]=v}w=p+20|0;t=c[w>>2]|0;if(t>>>0<O>>>0){v=(t|0)==0?O:t;while(1){if(v>>>0>=O>>>0)break;v=v<<1}m=sa[c[f>>2]&1](c[$>>2]|0,v<<2)|0;if(!m)oa(1);u=c[w>>2]|0;t=p+12|0;if(u)dc(m|0,c[t>>2]|0,u<<2|0)|0;ra[c[N>>2]&1](c[$>>2]|0,c[t>>2]|0);c[t>>2]=m;c[w>>2]=v}else t=p+12|0;w=p+8|0;l=0;m=0;n=0;u=0;while(1){if((u|0)==(O|0))break;v=m+(c[M+(u<<2)>>2]|0)|0;x=u+1|0;m=c[L+(u<<2)>>2]|0;if((x|0)!=(O|0)?(m|0)==(c[L+(x<<2)>>2]|0):0){m=v;u=x;continue}u=c[K+(m<<2)>>2]|0;P=u&255;a[(c[w>>2]|0)+l>>0]=P;c[(c[t>>2]|0)+(l<<2)>>2]=v;l=l+1|0;m=0;n=((n&255)>(P&255)?n&255:u&255)&255;u=x}c[p+4>>2]=l;c[p>>2]=(n&255)+1;ra[c[N>>2]&1](c[$>>2]|0,K);ra[c[N>>2]&1](c[$>>2]|0,M);ra[c[N>>2]&1](c[$>>2]|0,L);ra[c[N>>2]&1](c[$>>2]|0,Q);break}}}else c[p>>2]=1;while(0);p=f+4|0;ra[c[p>>2]&1](c[$>>2]|0,R);P=k<<1;Q=sa[c[f>>2]&1](c[$>>2]|0,P)|0;if(!Q)oa(1);t=0;while(1){if((t|0)==(k|0))break;b[Q+(t<<1)>>1]=b[j+(t<<4)+12>>1]|0;t=t+1|0}C=((k>>>0)/530|0)+1|0;C=C>>>0>50?50:C;do if(k){if(k>>>0<128){w=q+16|0;m=c[w>>2]|0;x=q+4|0;t=c[x>>2]|0;u=t+1|0;if(m>>>0<u>>>0){v=(m|0)==0?u:m;while(1){if(v>>>0>=u>>>0)break;v=v<<1}m=sa[c[f>>2]&1](c[$>>2]|0,v)|0;if(!m)oa(1);u=c[w>>2]|0;t=q+8|0;if(u)dc(m|0,c[t>>2]|0,u|0)|0;ra[c[p>>2]&1](c[$>>2]|0,c[t>>2]|0);c[t>>2]=m;c[w>>2]=v;t=c[x>>2]|0}w=q+20|0;m=c[w>>2]|0;u=t+1|0;if(m>>>0<u>>>0){v=(m|0)==0?u:m;while(1){if(v>>>0>=u>>>0)break;v=v<<1}t=sa[c[f>>2]&1](c[$>>2]|0,v<<2)|0;if(!t)oa(1);u=c[w>>2]|0;m=q+12|0;if(u)dc(t|0,c[m>>2]|0,u<<2|0)|0;ra[c[p>>2]&1](c[$>>2]|0,c[m>>2]|0);c[m>>2]=t;c[w>>2]=v;t=c[x>>2]|0}else m=q+12|0;c[q>>2]=1;a[(c[q+8>>2]|0)+t>>0]=0;c[(c[m>>2]|0)+(c[x>>2]<<2)>>2]=k;c[x>>2]=(c[x>>2]|0)+1;break}J=sa[c[f>>2]&1](c[$>>2]|0,C*2832|0)|0;if(!J)oa(1);t=0;while(1){if((t|0)==(C|0))break;ac(J+(t*2832|0)|0,0,2816)|0;c[J+(t*2832|0)+2816>>2]=0;h[J+(t*2832|0)+2824>>3]=s;t=t+1|0}v=(k>>>0)/(C>>>0)|0;w=k+-41|0;m=7;x=0;while(1){if((x|0)==(C|0))break;t=((_(x,k)|0)>>>0)/(C>>>0)|0;if(x){m=m*16807|0;m=(m|0)==0?1:m;t=t+((m>>>0)%(v>>>0)|0)|0}u=J+(x*2832|0)+2816|0;c[u>>2]=(c[u>>2]|0)+40;u=Q+(((t+40|0)>>>0<k>>>0?t:w)<<1)|0;t=41;while(1){t=t+-1|0;if(!t)break;R=J+(x*2832|0)+(e[u>>1]<<2)|0;c[R>>2]=(c[R>>2]|0)+1;u=u+2|0}x=x+1|0}c[Z>>2]=7;v=((P>>>0)/40|0)+100+C+-1|0;v=v-((v>>>0)%(C>>>0)|0)|0;w=Y+2816|0;x=Y+2824|0;l=k>>>0>40;n=k+-39|0;A=Y+2816|0;B=0;while(1){if(B>>>0>=v>>>0)break;ac(Y|0,0,2820)|0;h[x>>3]=s;if(l){t=(c[Z>>2]|0)*16807|0;R=(t|0)==0;c[Z>>2]=R?1:t;m=40;t=((R?1:t)>>>0)%(n>>>0)|0}else{m=k;t=0}c[A>>2]=(c[A>>2]|0)+m;u=Q+(t<<1)|0;t=m+1|0;while(1){t=t+-1|0;if(!t)break;R=Y+(e[u>>1]<<2)|0;c[R>>2]=(c[R>>2]|0)+1;u=u+2|0}t=(B>>>0)%(C>>>0)|0;m=J+(t*2832|0)+2816|0;c[m>>2]=(c[m>>2]|0)+(c[w>>2]|0);m=0;while(1){if((m|0)==704)break;R=J+(t*2832|0)+(m<<2)|0;c[R>>2]=(c[R>>2]|0)+(c[Y+(m<<2)>>2]|0);m=m+1|0}B=B+1|0}O=sa[c[f>>2]&1](c[$>>2]|0,k)|0;if(!O)oa(1);F=sa[c[f>>2]&1](c[$>>2]|0,C*5632|0)|0;if(!F)oa(1);G=sa[c[f>>2]&1](c[$>>2]|0,C<<3)|0;if(!G)oa(1);H=_((C+7|0)>>>3,k)|0;H=sa[c[f>>2]&1](c[$>>2]|0,H)|0;if(!H)oa(1);I=sa[c[f>>2]&1](c[$>>2]|0,C<<1)|0;if(!I)oa(1);B=(c[o+4>>2]|0)<11?3:10;D=k+-1|0;E=O+D|0;N=0;A=0;d:while(1){if(A>>>0>=B>>>0){l=382;break}n=(C+7|0)>>>3;if(C>>>0>=257){l=319;break}e:do if(C>>>0<2){t=0;while(1){if((t|0)==(k|0)){v=1;break e}a[O+t>>0]=0;t=t+1|0}}else{ac(F|0,0,C*5632|0)|0;m=0;while(1){if((m|0)==(C|0)){t=704;break}t=c[J+(m*2832|0)+2816>>2]|0;if(t>>>0<256)y=+g[19516+(t<<2)>>2];else y=+Xb(+(t>>>0));h[F+(m<<3)>>3]=y;m=m+1|0}f:while(1){if(!t)break;t=t+-1|0;u=_(t,C)|0;v=0;while(1){if((v|0)==(C|0))continue f;z=+h[F+(v<<3)>>3];m=c[J+(v*2832|0)+(t<<2)>>2]|0;do if(m)if(m>>>0<256){y=+g[19516+(m<<2)>>2];break}else{y=+Xb(+(m>>>0));break}else y=-2.0;while(0);h[F+(u+v<<3)>>3]=z-y;v=v+1|0}}ac(G|0,0,C<<3|0)|0;ac(H|0,0,_(n,k)|0)|0;v=0;while(1){if(v>>>0>=k>>>0)break;t=_(e[Q+(v<<1)>>1]|0,C)|0;m=O+v|0;z=1.e+99;u=0;while(1){if((u|0)==(C|0))break;R=G+(u<<3)|0;y=+h[R>>3]+ +h[F+(t+u<<3)>>3];h[R>>3]=y;if(y<z)a[m>>0]=u;else y=z;z=y;u=u+1|0}m=_(v,n)|0;if(v>>>0<2e3)y=(+(v>>>0)*.07/2.0e3+.77)*13.5;else y=13.5;u=0;while(1){if(u>>>0>=C>>>0)break;t=G+(u<<3)|0;ba=+h[t>>3]-z;h[t>>3]=ba;if(ba>=y){h[t>>3]=y;t=u>>>3;if(t>>>0>=n>>>0){l=350;break d}R=H+(m+t)|0;a[R>>0]=a[R>>0]|1<<(u&7)&255}u=u+1|0}v=v+1|0}m=_(D,n)|0;v=D;t=a[E>>0]|0;u=1;while(1){if(!v){v=u;break e}w=t&255;x=w>>>3;if(x>>>0>=n>>>0){l=357;break d}l=v+-1|0;m=m-n|0;v=O+l|0;if((a[H+(m+x)>>0]&(1<<(w&7)&255))<<24>>24){N=a[v>>0]|0;R=t<<24>>24==N<<24>>24;t=R?t:N;u=R?u:u+1|0}a[v>>0]=t;v=l}}while(0);t=0;while(1){if((t|0)==(C|0)){t=0;u=0;break}b[I+(t<<1)>>1]=256;t=t+1|0}while(1){if(u>>>0>=k>>>0){m=0;break}m=d[O+u>>0]|0;if(m>>>0>=C>>>0){l=366;break d}m=I+(m<<1)|0;if((b[m>>1]|0)==256){b[m>>1]=t;t=t+1<<16>>16}u=u+1|0}while(1){if(m>>>0>=k>>>0)break;N=O+m|0;R=b[I+(d[N>>0]<<1)>>1]|0;a[N>>0]=R;if((R&255)>>>0>=C>>>0){l=372;break d}m=m+1|0}u=t&65535;if(u>>>0>C>>>0){l=375;break}t=t&65535;m=0;while(1){if((m|0)==(t|0)){t=0;break}ac(J+(m*2832|0)|0,0,2816)|0;c[J+(m*2832|0)+2816>>2]=0;h[J+(m*2832|0)+2824>>3]=s;m=m+1|0}while(1){if((t|0)==(k|0))break;R=d[O+t>>0]|0;N=J+(R*2832|0)+(e[Q+(t<<1)>>1]<<2)|0;c[N>>2]=(c[N>>2]|0)+1;R=J+(R*2832|0)+2816|0;c[R>>2]=(c[R>>2]|0)+1;t=t+1|0}N=v;C=u;A=A+1|0}if((l|0)==319)pa(404083,403848,80,404221);else if((l|0)==350)pa(404124,403848,130,404221);else if((l|0)==357)pa(404145,403848,141,404221);else if((l|0)==366)pa(404005,403848,165,404200);else if((l|0)==372)pa(404005,403848,172,404200);else if((l|0)==375)pa(404057,403848,174,404200);else if((l|0)==382){ra[c[p>>2]&1](c[$>>2]|0,F);ra[c[p>>2]&1](c[$>>2]|0,G);ra[c[p>>2]&1](c[$>>2]|0,H);ra[c[p>>2]&1](c[$>>2]|0,I);ra[c[p>>2]&1](c[$>>2]|0,J);t=N<<2;L=sa[c[f>>2]&1](c[$>>2]|0,t)|0;if(!L)oa(1);M=sa[c[f>>2]&1](c[$>>2]|0,t)|0;if(!M)oa(1);x=((N<<4)+1008|0)>>>6;R=sa[c[f>>2]&1](c[$>>2]|0,x*2832|0)|0;v=R;if(!R)oa(1);R=sa[c[f>>2]&1](c[$>>2]|0,x<<2)|0;w=R;if(!R)oa(1);G=sa[c[f>>2]&1](c[$>>2]|0,(N>>>0<64?N:64)*2832|0)|0;if(!G)oa(1);H=sa[c[f>>2]&1](c[$>>2]|0,49176)|0;if(!H)oa(1);ac(V|0,0,256)|0;ac(T|0,0,256)|0;ac(W|0,0,256)|0;ac(U|0,0,256)|0;ac(M|0,0,t|0)|0;m=0;u=0;while(1){if(u>>>0>=k>>>0)break;if(m>>>0>=N>>>0){l=397;break}t=M+(m<<2)|0;c[t>>2]=(c[t>>2]|0)+1;t=u+1|0;if((t|0)!=(k|0)?(a[O+u>>0]|0)==(a[O+t>>0]|0):0){u=t;continue}m=m+1|0;u=t}if((l|0)==397)pa(403825,403848,231,404179);if((m|0)!=(N|0))pa(403911,403848,237,404179);C=x;B=x;J=0;t=0;F=0;while(1){if(N>>>0<=F>>>0){l=439;break}E=N-F|0;E=E>>>0<64?E:64;n=0;while(1){if((n|0)==(E|0))break;u=G+(n*2832|0)|0;ac(u|0,0,2816)|0;x=G+(n*2832|0)+2816|0;c[x>>2]=0;h[G+(n*2832|0)+2824>>3]=s;l=M+(F+n<<2)|0;m=0;while(1){if(m>>>0>=(c[l>>2]|0)>>>0)break;R=G+(n*2832|0)+(e[Q+(t<<1)>>1]<<2)|0;c[R>>2]=(c[R>>2]|0)+1;c[x>>2]=(c[x>>2]|0)+1;t=t+1|0;m=m+1|0}h[G+(n*2832|0)+2824>>3]=+Xa(u);c[T+(n<<2)>>2]=n;c[W+(n<<2)>>2]=n;c[V+(n<<2)>>2]=1;n=n+1|0}D=rb(G,V,W,T,H,E,E,64,2048)|0;m=J+D|0;if(C>>>0<m>>>0){u=(C|0)==0;x=u?m:C;while(1){if(x>>>0>=m>>>0)break;x=x<<1}m=sa[c[f>>2]&1](c[$>>2]|0,x*2832|0)|0;if(!m){l=416;break}if(!u)dc(m|0,v|0,C*2832|0)|0;ra[c[p>>2]&1](c[$>>2]|0,v);v=m;C=x}m=J+D|0;if(B>>>0<m>>>0){u=(B|0)==0;x=u?m:B;while(1){if(x>>>0>=m>>>0)break;x=x<<1}m=sa[c[f>>2]&1](c[$>>2]|0,x<<2)|0;if(!m){l=425;break}if(!u)dc(m|0,w|0,B<<2|0)|0;ra[c[p>>2]&1](c[$>>2]|0,w);w=m;B=x}m=v;u=w;A=D+J|0;x=J;l=J;n=0;while(1){if((n|0)==(D|0)){m=0;break}R=T+(n<<2)|0;K=c[R>>2]|0;dc(m+(x*2832|0)|0,G+(K*2832|0)|0,2832)|0;c[u+(l<<2)>>2]=c[V+(K<<2)>>2];c[U+(c[R>>2]<<2)>>2]=n;x=x+1|0;l=l+1|0;n=n+1|0}while(1){if((m|0)==(E|0))break;c[L+(F+m<<2)>>2]=J+(c[U+(c[W+(m<<2)>>2]<<2)>>2]|0);m=m+1|0}m=D+J|0;if((J+D|0)!=(m|0)){l=435;break}if((m|0)!=(A|0)){l=437;break}J=m;F=F+64|0}if((l|0)==416)oa(1);else if((l|0)==425)oa(1);else if((l|0)==435)pa(403935,403848,273,404179);else if((l|0)==437)pa(403969,403848,274,404179);else if((l|0)==439){ra[c[p>>2]&1](c[$>>2]|0,G);R=J<<6;u=_(J>>>1,J)|0;u=R>>>0<u>>>0?R:u;do if((u+1|0)>>>0>2049){ra[c[p>>2]&1](c[$>>2]|0,H);t=sa[c[f>>2]&1](c[$>>2]|0,(u*24|0)+24|0)|0;if(t){S=t;break}oa(1)}else S=H;while(0);m=J<<2;I=sa[c[f>>2]&1](c[$>>2]|0,m)|0;if(!I)oa(1);t=0;while(1){if((t|0)==(J|0))break;c[I+(t<<2)>>2]=t;t=t+1|0}H=v;G=rb(H,w,L,I,S,J,N,256,u)|0;ra[c[p>>2]&1](c[$>>2]|0,S);ra[c[p>>2]&1](c[$>>2]|0,w);K=sa[c[f>>2]&1](c[$>>2]|0,m)|0;if(!K)oa(1);t=0;while(1){if((t|0)==(J|0))break;c[K+(t<<2)>>2]=-1;t=t+1|0}B=Y+2816|0;C=Y+2824|0;D=Z+2816|0;E=Z+2816|0;t=0;m=0;F=0;while(1){if((F|0)==(N|0))break;ac(Y|0,0,2820)|0;h[C>>3]=s;u=M+(F<<2)|0;w=0;A=m;m=0;while(1){if(m>>>0>=(c[u>>2]|0)>>>0)break;w=Y+(e[Q+(A<<1)>>1]<<2)|0;c[w>>2]=(c[w>>2]|0)+1;w=(c[B>>2]|0)+1|0;c[B>>2]=w;A=A+1|0;m=m+1|0}u=c[((F|0)==0?L:L+(F+-1<<2)|0)>>2]|0;n=(w|0)==0;if(n)y=0.0;else{dc(Z|0,Y|0,2832)|0;c[E>>2]=(c[E>>2]|0)+(c[H+(u*2832|0)+2816>>2]|0);m=0;while(1){if((m|0)==704)break;S=Z+(m<<2)|0;c[S>>2]=(c[S>>2]|0)+(c[H+(u*2832|0)+(m<<2)>>2]|0);m=m+1|0}y=+Xa(Z);y=y-+h[H+(u*2832|0)+2824>>3]}m=u;l=0;while(1){if((l|0)==(G|0))break;x=I+(l<<2)|0;u=c[x>>2]|0;if(n)z=0.0;else{dc(Z|0,Y|0,2832)|0;c[D>>2]=(c[D>>2]|0)+(c[H+(u*2832|0)+2816>>2]|0);w=0;while(1){if((w|0)==704)break;S=Z+(w<<2)|0;c[S>>2]=(c[S>>2]|0)+(c[H+(u*2832|0)+(w<<2)>>2]|0);w=w+1|0}z=+Xa(Z);z=z-+h[H+(u*2832|0)+2824>>3]}if(z<y){y=z;m=c[x>>2]|0}l=l+1|0}c[L+(F<<2)>>2]=m;m=K+(m<<2)|0;if((c[m>>2]|0)==-1){c[m>>2]=t;t=t+1|0}m=A;F=F+1|0}ra[c[p>>2]&1](c[$>>2]|0,I);ra[c[p>>2]&1](c[$>>2]|0,v);w=q+16|0;t=c[w>>2]|0;if(t>>>0<N>>>0){v=(t|0)==0?N:t;while(1){if(v>>>0>=N>>>0)break;v=v<<1}m=sa[c[f>>2]&1](c[$>>2]|0,v)|0;if(!m)oa(1);u=c[w>>2]|0;t=q+8|0;if(u)dc(m|0,c[t>>2]|0,u|0)|0;ra[c[p>>2]&1](c[$>>2]|0,c[t>>2]|0);c[t>>2]=m;c[w>>2]=v}w=q+20|0;t=c[w>>2]|0;if(t>>>0<N>>>0){v=(t|0)==0?N:t;while(1){if(v>>>0>=N>>>0)break;v=v<<1}m=sa[c[f>>2]&1](c[$>>2]|0,v<<2)|0;if(!m)oa(1);u=c[w>>2]|0;t=q+12|0;if(u)dc(m|0,c[t>>2]|0,u<<2|0)|0;ra[c[p>>2]&1](c[$>>2]|0,c[t>>2]|0);c[t>>2]=m;c[w>>2]=v}else t=q+12|0;w=q+8|0;l=0;m=0;n=0;u=0;while(1){if((u|0)==(N|0))break;v=m+(c[M+(u<<2)>>2]|0)|0;x=u+1|0;m=c[L+(u<<2)>>2]|0;if((x|0)!=(N|0)?(m|0)==(c[L+(x<<2)>>2]|0):0){m=v;u=x;continue}u=c[K+(m<<2)>>2]|0;S=u&255;a[(c[w>>2]|0)+l>>0]=S;c[(c[t>>2]|0)+(l<<2)>>2]=v;l=l+1|0;m=0;n=((n&255)>(S&255)?n&255:u&255)&255;u=x}c[q+4>>2]=l;c[q>>2]=(n&255)+1;ra[c[p>>2]&1](c[$>>2]|0,K);ra[c[p>>2]&1](c[$>>2]|0,M);ra[c[p>>2]&1](c[$>>2]|0,L);ra[c[p>>2]&1](c[$>>2]|0,O);break}}}else c[q>>2]=1;while(0);ra[c[p>>2]&1](c[$>>2]|0,Q);P=sa[c[f>>2]&1](c[$>>2]|0,P)|0;if(!P)oa(1);K=0;m=0;while(1){if((m|0)==(k|0))break;if((c[j+(m<<4)+4>>2]&16777215|0)!=0?(e[j+(m<<4)+12>>1]|0)>127:0){b[P+(K<<1)>>1]=b[j+(m<<4)+14>>1]|0;t=K+1|0}else t=K;K=t;m=m+1|0}C=((K>>>0)/544|0)+1|0;C=C>>>0>50?50:C;if(!K){c[r>>2]=1;f=c[p>>2]|0;r=c[$>>2]|0;ra[f&1](r,P);i=aa;return}if(K>>>0<128){w=r+16|0;m=c[w>>2]|0;x=r+4|0;t=c[x>>2]|0;u=t+1|0;if(m>>>0<u>>>0){v=(m|0)==0?u:m;while(1){if(v>>>0>=u>>>0)break;v=v<<1}m=sa[c[f>>2]&1](c[$>>2]|0,v)|0;if(!m)oa(1);u=c[w>>2]|0;t=r+8|0;if(u)dc(m|0,c[t>>2]|0,u|0)|0;ra[c[p>>2]&1](c[$>>2]|0,c[t>>2]|0);c[t>>2]=m;c[w>>2]=v;t=c[x>>2]|0}w=r+20|0;m=c[w>>2]|0;u=t+1|0;if(m>>>0<u>>>0){v=(m|0)==0?u:m;while(1){if(v>>>0>=u>>>0)break;v=v<<1}t=sa[c[f>>2]&1](c[$>>2]|0,v<<2)|0;if(!t)oa(1);u=c[w>>2]|0;m=r+12|0;if(u)dc(t|0,c[m>>2]|0,u<<2|0)|0;ra[c[p>>2]&1](c[$>>2]|0,c[m>>2]|0);c[m>>2]=t;c[w>>2]=v;t=c[x>>2]|0}else m=r+12|0;c[r>>2]=1;a[(c[r+8>>2]|0)+t>>0]=0;c[(c[m>>2]|0)+(c[x>>2]<<2)>>2]=K;c[x>>2]=(c[x>>2]|0)+1;f=c[p>>2]|0;r=c[$>>2]|0;ra[f&1](r,P);i=aa;return}J=sa[c[f>>2]&1](c[$>>2]|0,C*2096|0)|0;if(!J)oa(1);t=0;while(1){if((t|0)==(C|0))break;ac(J+(t*2096|0)|0,0,2080)|0;c[J+(t*2096|0)+2080>>2]=0;h[J+(t*2096|0)+2088>>3]=s;t=t+1|0}v=(K>>>0)/(C>>>0)|0;w=K+-41|0;m=7;x=0;while(1){if((x|0)==(C|0))break;t=((_(K,x)|0)>>>0)/(C>>>0)|0;if(x){m=m*16807|0;m=(m|0)==0?1:m;t=t+((m>>>0)%(v>>>0)|0)|0}u=J+(x*2096|0)+2080|0;c[u>>2]=(c[u>>2]|0)+40;u=P+(((t+40|0)>>>0<K>>>0?t:w)<<1)|0;t=41;while(1){t=t+-1|0;if(!t)break;k=J+(x*2096|0)+(e[u>>1]<<2)|0;c[k>>2]=(c[k>>2]|0)+1;u=u+2|0}x=x+1|0}c[Z>>2]=7;v=((K<<1>>>0)/40|0)+100+C+-1|0;v=v-((v>>>0)%(C>>>0)|0)|0;w=Y+2080|0;x=Y+2088|0;l=K>>>0>40;n=K+-39|0;A=Y+2080|0;B=0;while(1){if(B>>>0>=v>>>0)break;ac(Y|0,0,2084)|0;h[x>>3]=s;if(l){t=(c[Z>>2]|0)*16807|0;k=(t|0)==0;c[Z>>2]=k?1:t;m=40;t=((k?1:t)>>>0)%(n>>>0)|0}else{m=K;t=0}c[A>>2]=(c[A>>2]|0)+m;u=P+(t<<1)|0;t=m+1|0;while(1){t=t+-1|0;if(!t)break;k=Y+(e[u>>1]<<2)|0;c[k>>2]=(c[k>>2]|0)+1;u=u+2|0}t=(B>>>0)%(C>>>0)|0;m=J+(t*2096|0)+2080|0;c[m>>2]=(c[m>>2]|0)+(c[w>>2]|0);m=0;while(1){if((m|0)==520)break;k=J+(t*2096|0)+(m<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[Y+(m<<2)>>2]|0);m=m+1|0}B=B+1|0}O=sa[c[f>>2]&1](c[$>>2]|0,K)|0;if(!O)oa(1);F=sa[c[f>>2]&1](c[$>>2]|0,C*4160|0)|0;if(!F)oa(1);G=sa[c[f>>2]&1](c[$>>2]|0,C<<3)|0;if(!G)oa(1);H=_(K,(C+7|0)>>>3)|0;H=sa[c[f>>2]&1](c[$>>2]|0,H)|0;if(!H)oa(1);I=sa[c[f>>2]&1](c[$>>2]|0,C<<1)|0;if(!I)oa(1);B=(c[o+4>>2]|0)<11?3:10;D=K+-1|0;E=O+D|0;N=0;A=0;g:while(1){if(A>>>0>=B>>>0){l=631;break}n=(C+7|0)>>>3;if(C>>>0>=257){l=568;break}h:do if(C>>>0<2){t=0;while(1){if((t|0)==(K|0)){v=1;break h}a[O+t>>0]=0;t=t+1|0}}else{ac(F|0,0,C*4160|0)|0;m=0;while(1){if((m|0)==(C|0)){t=520;break}t=c[J+(m*2096|0)+2080>>2]|0;if(t>>>0<256)y=+g[19516+(t<<2)>>2];else y=+Xb(+(t>>>0));h[F+(m<<3)>>3]=y;m=m+1|0}i:while(1){if(!t)break;t=t+-1|0;u=_(t,C)|0;v=0;while(1){if((v|0)==(C|0))continue i;z=+h[F+(v<<3)>>3];m=c[J+(v*2096|0)+(t<<2)>>2]|0;do if(m)if(m>>>0<256){y=+g[19516+(m<<2)>>2];break}else{y=+Xb(+(m>>>0));break}else y=-2.0;while(0);h[F+(u+v<<3)>>3]=z-y;v=v+1|0}}ac(G|0,0,C<<3|0)|0;ac(H|0,0,_(K,n)|0)|0;v=0;while(1){if(v>>>0>=K>>>0)break;t=_(e[P+(v<<1)>>1]|0,C)|0;m=O+v|0;z=1.e+99;u=0;while(1){if((u|0)==(C|0))break;o=G+(u<<3)|0;y=+h[o>>3]+ +h[F+(t+u<<3)>>3];h[o>>3]=y;if(y<z)a[m>>0]=u;else y=z;z=y;u=u+1|0}m=_(v,n)|0;if(v>>>0<2e3)y=(+(v>>>0)*.07/2.0e3+.77)*14.6;else y=14.6;u=0;while(1){if(u>>>0>=C>>>0)break;t=G+(u<<3)|0;ba=+h[t>>3]-z;h[t>>3]=ba;if(ba>=y){h[t>>3]=y;t=u>>>3;if(t>>>0>=n>>>0){l=599;break g}o=H+(m+t)|0;a[o>>0]=a[o>>0]|1<<(u&7)&255}u=u+1|0}v=v+1|0}m=_(D,n)|0;v=D;t=a[E>>0]|0;u=1;while(1){if(!v){v=u;break h}w=t&255;x=w>>>3;if(x>>>0>=n>>>0){l=606;break g}l=v+-1|0;m=m-n|0;v=O+l|0;if((a[H+(m+x)>>0]&(1<<(w&7)&255))<<24>>24){k=a[v>>0]|0;o=t<<24>>24==k<<24>>24;t=o?t:k;u=o?u:u+1|0}a[v>>0]=t;v=l}}while(0);t=0;while(1){if((t|0)==(C|0)){t=0;u=0;break}b[I+(t<<1)>>1]=256;t=t+1|0}while(1){if(u>>>0>=K>>>0){m=0;break}m=d[O+u>>0]|0;if(m>>>0>=C>>>0){l=615;break g}m=I+(m<<1)|0;if((b[m>>1]|0)==256){b[m>>1]=t;t=t+1<<16>>16}u=u+1|0}while(1){if(m>>>0>=K>>>0)break;k=O+m|0;o=b[I+(d[k>>0]<<1)>>1]|0;a[k>>0]=o;if((o&255)>>>0>=C>>>0){l=621;break g}m=m+1|0}u=t&65535;if(u>>>0>C>>>0){l=624;break}t=t&65535;m=0;while(1){if((m|0)==(t|0)){t=0;break}ac(J+(m*2096|0)|0,0,2080)|0;c[J+(m*2096|0)+2080>>2]=0;h[J+(m*2096|0)+2088>>3]=s;m=m+1|0}while(1){if((t|0)==(K|0))break;o=d[O+t>>0]|0;k=J+(o*2096|0)+(e[P+(t<<1)>>1]<<2)|0;c[k>>2]=(c[k>>2]|0)+1;o=J+(o*2096|0)+2080|0;c[o>>2]=(c[o>>2]|0)+1;t=t+1|0}N=v;C=u;A=A+1|0}if((l|0)==568)pa(404083,403848,80,404105);else if((l|0)==599)pa(404124,403848,130,404105);else if((l|0)==606)pa(404145,403848,141,404105);else if((l|0)==615)pa(404005,403848,165,404035);else if((l|0)==621)pa(404005,403848,172,404035);else if((l|0)==624)pa(404057,403848,174,404035);else if((l|0)==631){ra[c[p>>2]&1](c[$>>2]|0,F);ra[c[p>>2]&1](c[$>>2]|0,G);ra[c[p>>2]&1](c[$>>2]|0,H);ra[c[p>>2]&1](c[$>>2]|0,I);ra[c[p>>2]&1](c[$>>2]|0,J);t=N<<2;L=sa[c[f>>2]&1](c[$>>2]|0,t)|0;if(!L)oa(1);M=sa[c[f>>2]&1](c[$>>2]|0,t)|0;if(!M)oa(1);x=((N<<4)+1008|0)>>>6;o=sa[c[f>>2]&1](c[$>>2]|0,x*2096|0)|0;v=o;if(!o)oa(1);o=sa[c[f>>2]&1](c[$>>2]|0,x<<2)|0;w=o;if(!o)oa(1);G=sa[c[f>>2]&1](c[$>>2]|0,(N>>>0<64?N:64)*2096|0)|0;if(!G)oa(1);H=sa[c[f>>2]&1](c[$>>2]|0,49176)|0;if(!H)oa(1);ac(V|0,0,256)|0;ac(T|0,0,256)|0;ac(W|0,0,256)|0;ac(U|0,0,256)|0;ac(M|0,0,t|0)|0;m=0;u=0;while(1){if(u>>>0>=K>>>0)break;if(m>>>0>=N>>>0){l=646;break}t=M+(m<<2)|0;c[t>>2]=(c[t>>2]|0)+1;t=u+1|0;if((t|0)!=(K|0)?(a[O+u>>0]|0)==(a[O+t>>0]|0):0){u=t;continue}m=m+1|0;u=t}if((l|0)==646)pa(403825,403848,231,403889);if((m|0)!=(N|0))pa(403911,403848,237,403889);C=x;B=x;K=0;t=0;F=0;while(1){if(N>>>0<=F>>>0){l=688;break}E=N-F|0;E=E>>>0<64?E:64;n=0;while(1){if((n|0)==(E|0))break;u=G+(n*2096|0)|0;ac(u|0,0,2080)|0;x=G+(n*2096|0)+2080|0;c[x>>2]=0;h[G+(n*2096|0)+2088>>3]=s;l=M+(F+n<<2)|0;m=0;while(1){if(m>>>0>=(c[l>>2]|0)>>>0)break;o=G+(n*2096|0)+(e[P+(t<<1)>>1]<<2)|0;c[o>>2]=(c[o>>2]|0)+1;c[x>>2]=(c[x>>2]|0)+1;t=t+1|0;m=m+1|0}h[G+(n*2096|0)+2088>>3]=+Ya(u);c[T+(n<<2)>>2]=n;c[W+(n<<2)>>2]=n;c[V+(n<<2)>>2]=1;n=n+1|0}D=tb(G,V,W,T,H,E,E,64,2048)|0;m=K+D|0;if(C>>>0<m>>>0){u=(C|0)==0;x=u?m:C;while(1){if(x>>>0>=m>>>0)break;x=x<<1}m=sa[c[f>>2]&1](c[$>>2]|0,x*2096|0)|0;if(!m){l=665;break}if(!u)dc(m|0,v|0,C*2096|0)|0;ra[c[p>>2]&1](c[$>>2]|0,v);v=m;C=x}m=K+D|0;if(B>>>0<m>>>0){u=(B|0)==0;x=u?m:B;while(1){if(x>>>0>=m>>>0)break;x=x<<1}m=sa[c[f>>2]&1](c[$>>2]|0,x<<2)|0;if(!m){l=674;break}if(!u)dc(m|0,w|0,B<<2|0)|0;ra[c[p>>2]&1](c[$>>2]|0,w);w=m;B=x}m=v;u=w;A=D+K|0;x=K;l=K;n=0;while(1){if((n|0)==(D|0)){m=0;break}o=T+(n<<2)|0;k=c[o>>2]|0;dc(m+(x*2096|0)|0,G+(k*2096|0)|0,2096)|0;c[u+(l<<2)>>2]=c[V+(k<<2)>>2];c[U+(c[o>>2]<<2)>>2]=n;x=x+1|0;l=l+1|0;n=n+1|0}while(1){if((m|0)==(E|0))break;c[L+(F+m<<2)>>2]=K+(c[U+(c[W+(m<<2)>>2]<<2)>>2]|0);m=m+1|0}m=D+K|0;if((K+D|0)!=(m|0)){l=684;break}if((m|0)!=(A|0)){l=686;break}K=m;F=F+64|0}if((l|0)==665)oa(1);else if((l|0)==674)oa(1);else if((l|0)==684)pa(403935,403848,273,403889);else if((l|0)==686)pa(403969,403848,274,403889);else if((l|0)==688){ra[c[p>>2]&1](c[$>>2]|0,G);W=K<<6;u=_(K>>>1,K)|0;u=W>>>0<u>>>0?W:u;do if((u+1|0)>>>0>2049){ra[c[p>>2]&1](c[$>>2]|0,H);t=sa[c[f>>2]&1](c[$>>2]|0,(u*24|0)+24|0)|0;if(t){X=t;break}oa(1)}else X=H;while(0);m=K<<2;I=sa[c[f>>2]&1](c[$>>2]|0,m)|0;if(!I)oa(1);t=0;while(1){if((t|0)==(K|0))break;c[I+(t<<2)>>2]=t;t=t+1|0}H=v;G=tb(H,w,L,I,X,K,N,256,u)|0;ra[c[p>>2]&1](c[$>>2]|0,X);ra[c[p>>2]&1](c[$>>2]|0,w);J=sa[c[f>>2]&1](c[$>>2]|0,m)|0;if(!J)oa(1);t=0;while(1){if((t|0)==(K|0))break;c[J+(t<<2)>>2]=-1;t=t+1|0}B=Y+2080|0;C=Y+2088|0;D=Z+2080|0;E=Z+2080|0;t=0;m=0;F=0;while(1){if((F|0)==(N|0))break;ac(Y|0,0,2084)|0;h[C>>3]=s;u=M+(F<<2)|0;w=0;A=m;m=0;while(1){if(m>>>0>=(c[u>>2]|0)>>>0)break;w=Y+(e[P+(A<<1)>>1]<<2)|0;c[w>>2]=(c[w>>2]|0)+1;w=(c[B>>2]|0)+1|0;c[B>>2]=w;A=A+1|0;m=m+1|0}u=c[((F|0)==0?L:L+(F+-1<<2)|0)>>2]|0;n=(w|0)==0;if(n)y=0.0;else{dc(Z|0,Y|0,2096)|0;c[E>>2]=(c[E>>2]|0)+(c[H+(u*2096|0)+2080>>2]|0);m=0;while(1){if((m|0)==520)break;X=Z+(m<<2)|0;c[X>>2]=(c[X>>2]|0)+(c[H+(u*2096|0)+(m<<2)>>2]|0);m=m+1|0}y=+Ya(Z);y=y-+h[H+(u*2096|0)+2088>>3]}m=u;l=0;while(1){if((l|0)==(G|0))break;x=I+(l<<2)|0;u=c[x>>2]|0;if(n)z=0.0;else{dc(Z|0,Y|0,2096)|0;c[D>>2]=(c[D>>2]|0)+(c[H+(u*2096|0)+2080>>2]|0);w=0;while(1){if((w|0)==520)break;X=Z+(w<<2)|0;c[X>>2]=(c[X>>2]|0)+(c[H+(u*2096|0)+(w<<2)>>2]|0);w=w+1|0}z=+Ya(Z);z=z-+h[H+(u*2096|0)+2088>>3]}if(z<y){y=z;m=c[x>>2]|0}l=l+1|0}c[L+(F<<2)>>2]=m;m=J+(m<<2)|0;if((c[m>>2]|0)==-1){c[m>>2]=t;t=t+1|0}m=A;F=F+1|0}ra[c[p>>2]&1](c[$>>2]|0,I);ra[c[p>>2]&1](c[$>>2]|0,v);w=r+16|0;t=c[w>>2]|0;if(t>>>0<N>>>0){v=(t|0)==0?N:t;while(1){if(v>>>0>=N>>>0)break;v=v<<1}m=sa[c[f>>2]&1](c[$>>2]|0,v)|0;if(!m)oa(1);u=c[w>>2]|0;t=r+8|0;if(u)dc(m|0,c[t>>2]|0,u|0)|0;ra[c[p>>2]&1](c[$>>2]|0,c[t>>2]|0);c[t>>2]=m;c[w>>2]=v}w=r+20|0;t=c[w>>2]|0;if(t>>>0<N>>>0){v=(t|0)==0?N:t;while(1){if(v>>>0>=N>>>0)break;v=v<<1}m=sa[c[f>>2]&1](c[$>>2]|0,v<<2)|0;if(!m)oa(1);u=c[w>>2]|0;t=r+12|0;if(u)dc(m|0,c[t>>2]|0,u<<2|0)|0;ra[c[p>>2]&1](c[$>>2]|0,c[t>>2]|0);c[t>>2]=m;c[w>>2]=v}else t=r+12|0;w=r+8|0;l=0;m=0;n=0;u=0;while(1){if((u|0)==(N|0))break;v=m+(c[M+(u<<2)>>2]|0)|0;x=u+1|0;m=c[L+(u<<2)>>2]|0;if((x|0)!=(N|0)?(m|0)==(c[L+(x<<2)>>2]|0):0){m=v;u=x;continue}u=c[J+(m<<2)>>2]|0;f=u&255;a[(c[w>>2]|0)+l>>0]=f;c[(c[t>>2]|0)+(l<<2)>>2]=v;l=l+1|0;m=0;n=((n&255)>(f&255)?n&255:u&255)&255;u=x}c[r+4>>2]=l;c[r>>2]=(n&255)+1;ra[c[p>>2]&1](c[$>>2]|0,J);ra[c[p>>2]&1](c[$>>2]|0,M);ra[c[p>>2]&1](c[$>>2]|0,L);ra[c[p>>2]&1](c[$>>2]|0,O);f=c[p>>2]|0;r=c[$>>2]|0;ra[f&1](r,P);i=aa;return}}}function _a(b,f,g,h,j){b=b|0;f=f|0;g=g|0;h=h|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,D=0;A=i;i=i+1552|0;y=A+840|0;z=A+136|0;v=A+72|0;w=A+112|0;x=A+76|0;t=A;c[v>>2]=0;l=w;m=l+18|0;do{a[l>>0]=0;l=l+1|0}while((l|0)<(m|0));l=t;m=l+72|0;do{c[l>>2]=0;l=l+4|0}while((l|0)<(m|0));if(f>>>0<705){s=f;k=0}else pa(404299,404333,308,404371);while(1){if(k>>>0>=f>>>0)break;if(a[b+(f-k+-1)>>0]|0)break;s=s+-1|0;k=k+1|0}if(f>>>0>50){m=1;f=1;q=0;n=0;o=0;while(1){if(q>>>0>=s>>>0)break;l=a[b+q>>0]|0;p=1;k=q;while(1){k=k+1|0;if(k>>>0>=s>>>0)break;if((a[b+k>>0]|0)!=l<<24>>24)break;p=p+1|0}if(p>>>0>2){r=l<<24>>24==0;f=r?f+1|0:f;k=r?o+p|0:o;if(p>>>0>3?!r:0){m=m+1|0;l=n+p|0}else l=n}else{l=n;k=o}q=q+p|0;n=l;o=k}k=n>>>0>m<<1>>>0&1;f=o>>>0>f<<1>>>0&1}else{k=0;f=0}r=f<<24>>24==0;p=k<<24>>24==0;n=8;q=0;a:while(1){if(q>>>0>=s>>>0)break;o=a[b+q>>0]|0;l=o<<24>>24==0;if(l)if(r){f=1;u=30}else{k=q;f=1;u=23}else if(p){f=1;u=43}else{k=q;f=1;u=23}b:do if((u|0)==23){while(1){u=0;k=k+1|0;if(k>>>0>=s>>>0)break;if((a[b+k>>0]|0)!=o<<24>>24)break;f=f+1|0;u=23}if(!l)if(!f){u=42;break a}else{u=43;break}if((f|0)!=11)if(f>>>0<3){u=30;break}else m=f;else{a[y+(c[v>>2]|0)>>0]=0;a[z+(c[v>>2]|0)>>0]=0;c[v>>2]=(c[v>>2]|0)+1;m=10}l=c[v>>2]|0;k=l;m=m+-3|0;while(1){a[y+k>>0]=17;a[z+(c[v>>2]|0)>>0]=m&7;k=(c[v>>2]|0)+1|0;c[v>>2]=k;m=m>>>3;if(!m){m=l;break}m=m+-1|0}while(1){k=k+-1|0;if(m>>>0>=k>>>0)break;D=y+m|0;B=a[D>>0]|0;o=y+k|0;a[D>>0]=a[o>>0]|0;a[o>>0]=B;m=m+1|0}k=c[v>>2]|0;while(1){k=k+-1|0;if(l>>>0>=k>>>0){k=n;break b}o=z+l|0;B=a[o>>0]|0;D=z+k|0;a[o>>0]=a[D>>0]|0;a[D>>0]=B;l=l+1|0}}while(0);c:do if((u|0)==30){u=0;k=0;while(1){if((k|0)==(f|0)){k=n;break c}a[y+(c[v>>2]|0)>>0]=0;a[z+(c[v>>2]|0)>>0]=0;c[v>>2]=(c[v>>2]|0)+1;k=k+1|0}}else if((u|0)==43){u=0;if(n<<24>>24==o<<24>>24)k=f;else{a[y+(c[v>>2]|0)>>0]=o;a[z+(c[v>>2]|0)>>0]=0;c[v>>2]=(c[v>>2]|0)+1;k=f+-1|0}if((k|0)==7){a[y+(c[v>>2]|0)>>0]=o;a[z+(c[v>>2]|0)>>0]=0;c[v>>2]=(c[v>>2]|0)+1;k=k+-1|0}if(k>>>0<3){l=0;while(1){if((l|0)==(k|0)){k=o;break c}a[y+(c[v>>2]|0)>>0]=o;a[z+(c[v>>2]|0)>>0]=0;c[v>>2]=(c[v>>2]|0)+1;l=l+1|0}}l=c[v>>2]|0;n=l;m=k+-3|0;while(1){a[y+n>>0]=16;a[z+(c[v>>2]|0)>>0]=m&3;k=(c[v>>2]|0)+1|0;c[v>>2]=k;m=m>>>2;if(!m){m=l;break}n=k;m=m+-1|0}while(1){k=k+-1|0;if(m>>>0>=k>>>0)break;n=y+m|0;B=a[n>>0]|0;D=y+k|0;a[n>>0]=a[D>>0]|0;a[D>>0]=B;m=m+1|0}k=c[v>>2]|0;while(1){k=k+-1|0;if(l>>>0>=k>>>0){k=o;break c}n=z+l|0;B=a[n>>0]|0;D=z+k|0;a[n>>0]=a[D>>0]|0;a[D>>0]=B;l=l+1|0}}while(0);n=k;q=q+f|0}if((u|0)==42)pa(406724,406674,168,406740);f=c[v>>2]|0;k=0;while(1){if((k|0)==(f|0)){r=0;k=0;l=0;break}D=t+(d[y+k>>0]<<2)|0;c[D>>2]=(c[D>>2]|0)+1;k=k+1|0}while(1){if(l>>>0>=18){q=k;break}if(c[t+(l<<2)>>2]|0)if(k)if((k|0)==1){q=2;break}else f=r;else{f=l;k=1}else f=r;r=f;l=l+1|0}Hb(t,18,5,g,w);Jb(w,18,x);d:do if((q|0)>1){k=18;while(1){if(!k)break d;f=k+-1|0;if(!(a[w+(d[405371+f>>0]|0)>>0]|0))k=f;else break}}else k=18;while(0);if((a[w+1>>0]|0)==0?(a[w+2>>0]|0)==0:0)f=(a[w+3>>0]|0)==0?3:2;else f=0;g=c[h>>2]|0;p=j+(g>>>3)|0;B=d[p>>0]|0;g=cc(f|0,0,g&7|0)|0;D=C;g=B|g;B=p;a[B>>0]=g;a[B+1>>0]=g>>8;a[B+2>>0]=g>>16;a[B+3>>0]=g>>24;p=p+4|0;a[p>>0]=D;a[p+1>>0]=D>>8;a[p+2>>0]=D>>16;a[p+3>>0]=D>>24;p=(c[h>>2]|0)+2|0;c[h>>2]=p;while(1){if(f>>>0>=k>>>0)break;m=d[w+(d[405371+f>>0]|0)>>0]|0;l=a[405389+m>>0]|0;m=d[405395+m>>0]|0;n=j+(p>>>3)|0;o=d[n>>0]|0;D=bc(m|0,0,l&255|0)|0;if(!((D|0)==0&(C|0)==0)){u=76;break}t=cc(m|0,0,p&7|0)|0;B=C;t=o|t;D=n;g=D;a[g>>0]=t;a[g+1>>0]=t>>8;a[g+2>>0]=t>>16;a[g+3>>0]=t>>24;D=D+4|0;a[D>>0]=B;a[D+1>>0]=B>>8;a[D+2>>0]=B>>16;a[D+3>>0]=B>>24;D=(c[h>>2]|0)+(l&255)|0;c[h>>2]=D;p=D;f=f+1|0}if((u|0)==76)pa(406196,406218,54,406251);if((q|0)==1)a[w+r>>0]=0;p=c[v>>2]|0;q=0;e:while(1){if(q>>>0>=p>>>0){u=94;break}o=d[y+q>>0]|0;f=a[w+o>>0]|0;k=e[x+(o<<1)>>1]|0;l=c[h>>2]|0;m=j+(l>>>3)|0;n=d[m>>0]|0;D=bc(k|0,0,f&255|0)|0;if(!((D|0)==0&(C|0)==0)){u=83;break}if((f&255)>=57){u=85;break}v=cc(k|0,0,l&7|0)|0;D=C;v=n|v;B=m;a[B>>0]=v;a[B+1>>0]=v>>8;a[B+2>>0]=v>>16;a[B+3>>0]=v>>24;m=m+4|0;a[m>>0]=D;a[m+1>>0]=D>>8;a[m+2>>0]=D>>16;a[m+3>>0]=D>>24;m=(c[h>>2]|0)+(f&255)|0;c[h>>2]=m;switch(o|0){case 16:{f=d[z+q>>0]|0;k=j+(m>>>3)|0;l=d[k>>0]|0;if(!((f&252|0)==0&0==0)){u=88;break e}u=cc(f|0,0,m&7|0)|0;B=C;u=l|u;D=k;v=D;a[v>>0]=u;a[v+1>>0]=u>>8;a[v+2>>0]=u>>16;a[v+3>>0]=u>>24;D=D+4|0;a[D>>0]=B;a[D+1>>0]=B>>8;a[D+2>>0]=B>>16;a[D+3>>0]=B>>24;c[h>>2]=(c[h>>2]|0)+2;break}case 17:{f=d[z+q>>0]|0;k=j+(m>>>3)|0;l=d[k>>0]|0;if(!((f&248|0)==0&0==0)){u=91;break e}u=cc(f|0,0,m&7|0)|0;B=C;u=l|u;D=k;v=D;a[v>>0]=u;a[v+1>>0]=u>>8;a[v+2>>0]=u>>16;a[v+3>>0]=u>>24;D=D+4|0;a[D>>0]=B;a[D+1>>0]=B>>8;a[D+2>>0]=B>>16;a[D+3>>0]=B>>24;c[h>>2]=(c[h>>2]|0)+3;break}default:{}}q=q+1|0}if((u|0)==83)pa(406196,406218,54,406251);else if((u|0)==85)pa(406267,406218,55,406251);else if((u|0)==88)pa(406196,406218,54,406251);else if((u|0)==91)pa(406196,406218,54,406251);else if((u|0)==94){i=A;return}}
@@ -3298,20 +4111,6 @@ module.exports = b;
3298
4111
  };
3299
4112
 
3300
4113
  __brotliModules["/dec/decode.js"] = function(module, exports, require) {
3301
- /* Copyright 2013 Google Inc. All Rights Reserved.
3302
-
3303
- Licensed under the Apache License, Version 2.0 (the "License");
3304
- you may not use this file except in compliance with the License.
3305
- You may obtain a copy of the License at
3306
-
3307
- http://www.apache.org/licenses/LICENSE-2.0
3308
-
3309
- Unless required by applicable law or agreed to in writing, software
3310
- distributed under the License is distributed on an "AS IS" BASIS,
3311
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3312
- See the License for the specific language governing permissions and
3313
- limitations under the License.
3314
- */
3315
4114
 
3316
4115
  var BrotliInput = require("/dec/streams.js").BrotliInput;
3317
4116
  var BrotliOutput = require("/dec/streams.js").BrotliOutput;
@@ -3333,8 +4132,7 @@ var kDistanceContextBits = 2;
3333
4132
 
3334
4133
  var HUFFMAN_TABLE_BITS = 8;
3335
4134
  var HUFFMAN_TABLE_MASK = 0xff;
3336
- /* Maximum possible Huffman table size for an alphabet size of 704, max code
3337
- * length 15 and root table bits 8. */
4135
+
3338
4136
  var HUFFMAN_MAX_TABLE_SIZE = 1080;
3339
4137
 
3340
4138
  var CODE_LENGTH_CODES = 18;
@@ -3375,7 +4173,6 @@ function DecodeWindowBits(br) {
3375
4173
  return 17;
3376
4174
  }
3377
4175
 
3378
- /* Decodes a number in the range [0..255], by reading 1 - 11 bits. */
3379
4176
  function DecodeVarLenUint8(br) {
3380
4177
  if (br.readBits(1)) {
3381
4178
  var nbits = br.readBits(3);
@@ -3443,7 +4240,6 @@ function DecodeMetaBlockLength(br) {
3443
4240
  return out;
3444
4241
  }
3445
4242
 
3446
- /* Decodes the next Huffman code from bit-stream. */
3447
4243
  function ReadSymbol(table, index, br) {
3448
4244
  var start_index = index;
3449
4245
 
@@ -3537,12 +4333,9 @@ function ReadHuffmanCode(alphabet_size, tables, table, br) {
3537
4333
 
3538
4334
  br.readMoreInput();
3539
4335
 
3540
- /* simple_code_or_skip is used as follows:
3541
- 1 for simple code;
3542
- 0 for no skipping, 2 skips 2 code lengths, 3 skips 3 code lengths */
3543
4336
  simple_code_or_skip = br.readBits(2);
3544
4337
  if (simple_code_or_skip === 1) {
3545
- /* Read symbols, codes & code lengths directly. */
4338
+
3546
4339
  var i;
3547
4340
  var max_bits_counter = alphabet_size - 1;
3548
4341
  var max_bits = 0;
@@ -3593,12 +4386,12 @@ function ReadHuffmanCode(alphabet_size, tables, table, br) {
3593
4386
  }
3594
4387
  break;
3595
4388
  }
3596
- } else { /* Decode Huffman-coded code lengths. */
4389
+ } else {
3597
4390
  var i;
3598
4391
  var code_length_code_lengths = new Uint8Array(CODE_LENGTH_CODES);
3599
4392
  var space = 32;
3600
4393
  var num_codes = 0;
3601
- /* Static Huffman code for the code length code lengths */
4394
+
3602
4395
  var huff = [
3603
4396
  new HuffmanCode(2, 0), new HuffmanCode(2, 4), new HuffmanCode(2, 3), new HuffmanCode(3, 2),
3604
4397
  new HuffmanCode(2, 0), new HuffmanCode(2, 4), new HuffmanCode(2, 3), new HuffmanCode(4, 1),
@@ -3675,7 +4468,6 @@ function InverseMoveToFrontTransform(v, v_len) {
3675
4468
  }
3676
4469
  }
3677
4470
 
3678
- /* Contains a collection of huffman trees with the same alphabet size. */
3679
4471
  function HuffmanTreeGroup(alphabet_size, num_htrees) {
3680
4472
  this.alphabet_size = alphabet_size;
3681
4473
  this.num_htrees = num_htrees;
@@ -3776,7 +4568,6 @@ function CopyUncompressedBlockToOutput(output, len, pos, ringbuffer, ringbuffer_
3776
4568
  var br_pos = br.pos_ & BrotliBitReader.IBUF_MASK;
3777
4569
  var nbytes;
3778
4570
 
3779
- /* For short lengths copy byte-by-byte */
3780
4571
  if (len < 8 || br.bit_pos_ + (len << 3) < br.bit_end_pos_) {
3781
4572
  while (len-- > 0) {
3782
4573
  br.readMoreInput();
@@ -3793,7 +4584,6 @@ function CopyUncompressedBlockToOutput(output, len, pos, ringbuffer, ringbuffer_
3793
4584
  throw new Error('[CopyUncompressedBlockToOutput] br.bit_end_pos_ < 32');
3794
4585
  }
3795
4586
 
3796
- /* Copy remaining 0-4 bytes from br.val_ to ringbuffer. */
3797
4587
  while (br.bit_pos_ < 32) {
3798
4588
  ringbuffer[rb_pos] = (br.val_ >>> br.bit_pos_);
3799
4589
  br.bit_pos_ += 8;
@@ -3801,7 +4591,6 @@ function CopyUncompressedBlockToOutput(output, len, pos, ringbuffer, ringbuffer_
3801
4591
  --len;
3802
4592
  }
3803
4593
 
3804
- /* Copy remaining bytes from br.buf_ to ringbuffer. */
3805
4594
  nbytes = (br.bit_end_pos_ - br.bit_pos_) >> 3;
3806
4595
  if (br_pos + nbytes > BrotliBitReader.IBUF_MASK) {
3807
4596
  var tail = BrotliBitReader.IBUF_MASK + 1 - br_pos;
@@ -3820,8 +4609,6 @@ function CopyUncompressedBlockToOutput(output, len, pos, ringbuffer, ringbuffer_
3820
4609
  rb_pos += nbytes;
3821
4610
  len -= nbytes;
3822
4611
 
3823
- /* If we wrote past the logical end of the ringbuffer, copy the tail of the
3824
- ringbuffer to its beginning and flush the ringbuffer to the output. */
3825
4612
  if (rb_pos >= rb_size) {
3826
4613
  output.write(ringbuffer, rb_size);
3827
4614
  rb_pos -= rb_size;
@@ -3829,9 +4616,6 @@ function CopyUncompressedBlockToOutput(output, len, pos, ringbuffer, ringbuffer_
3829
4616
  ringbuffer[x] = ringbuffer[rb_size + x];
3830
4617
  }
3831
4618
 
3832
- /* If we have more to copy than the remaining size of the ringbuffer, then we
3833
- first fill the ringbuffer from the input and then flush the ringbuffer to
3834
- the output */
3835
4619
  while (rb_pos + len >= rb_size) {
3836
4620
  nbytes = rb_size - rb_pos;
3837
4621
  if (br.input_.read(ringbuffer, rb_pos, nbytes) < nbytes) {
@@ -3842,18 +4626,13 @@ function CopyUncompressedBlockToOutput(output, len, pos, ringbuffer, ringbuffer_
3842
4626
  rb_pos = 0;
3843
4627
  }
3844
4628
 
3845
- /* Copy straight from the input onto the ringbuffer. The ringbuffer will be
3846
- flushed to the output at a later time. */
3847
4629
  if (br.input_.read(ringbuffer, rb_pos, len) < len) {
3848
4630
  throw new Error('[CopyUncompressedBlockToOutput] not enough bytes');
3849
4631
  }
3850
4632
 
3851
- /* Restore the state of the bit reader. */
3852
4633
  br.reset();
3853
4634
  }
3854
4635
 
3855
- /* Advances the bit reader position to the next byte boundary and verifies
3856
- that any skipped bits are set to zero. */
3857
4636
  function JumpToByteBoundary(br) {
3858
4637
  var new_bit_pos = (br.bit_pos_ + 7) & ~7;
3859
4638
  var pad_bits = br.readBits(new_bit_pos - br.bit_pos_);
@@ -3902,11 +4681,10 @@ function BrotliDecompress(input, output) {
3902
4681
  var ringbuffer_mask;
3903
4682
  var ringbuffer;
3904
4683
  var ringbuffer_end;
3905
- /* This ring buffer holds a few past copy distances that will be used by */
3906
- /* some special distance codes. */
4684
+
3907
4685
  var dist_rb = [ 16, 15, 11, 4 ];
3908
4686
  var dist_rb_idx = 0;
3909
- /* The previous 2 bytes used for context. */
4687
+
3910
4688
  var prev_byte1 = 0;
3911
4689
  var prev_byte2 = 0;
3912
4690
  var hgroup = [new HuffmanTreeGroup(0, 0), new HuffmanTreeGroup(0, 0), new HuffmanTreeGroup(0, 0)];
@@ -3914,15 +4692,10 @@ function BrotliDecompress(input, output) {
3914
4692
  var block_len_trees;
3915
4693
  var br;
3916
4694
 
3917
- /* We need the slack region for the following reasons:
3918
- - always doing two 8-byte copies for fast backward copying
3919
- - transforms
3920
- - flushing the input ringbuffer when decoding uncompressed blocks */
3921
4695
  var kRingBufferWriteAheadSlack = 128 + BrotliBitReader.READ_SIZE;
3922
4696
 
3923
4697
  br = new BrotliBitReader(input);
3924
4698
 
3925
- /* Decode window size. */
3926
4699
  window_bits = DecodeWindowBits(br);
3927
4700
  max_backward_distance = (1 << window_bits) - 16;
3928
4701
 
@@ -3976,7 +4749,7 @@ function BrotliDecompress(input, output) {
3976
4749
  var _out = DecodeMetaBlockLength(br);
3977
4750
  meta_block_remaining_len = _out.meta_block_length;
3978
4751
  if (pos + meta_block_remaining_len > output.buffer.length) {
3979
- /* We need to grow the output buffer to fit the additional data. */
4752
+
3980
4753
  var tmp = new Uint8Array( pos + meta_block_remaining_len );
3981
4754
  tmp.set( output.buffer );
3982
4755
  output.buffer = tmp;
@@ -3989,7 +4762,7 @@ function BrotliDecompress(input, output) {
3989
4762
 
3990
4763
  for (; meta_block_remaining_len > 0; --meta_block_remaining_len) {
3991
4764
  br.readMoreInput();
3992
- /* Read one byte and ignore it. */
4765
+
3993
4766
  br.readBits(8);
3994
4767
  }
3995
4768
 
@@ -4153,8 +4926,6 @@ function BrotliDecompress(input, output) {
4153
4926
  }
4154
4927
  }
4155
4928
 
4156
- /* Convert the distance code to the actual distance by possibly looking */
4157
- /* up past distnaces from the ringbuffer. */
4158
4929
  distance = TranslateShortCodes(distance_code, dist_rb, dist_rb_idx);
4159
4930
  if (distance < 0) {
4160
4931
  throw new Error('[BrotliDecompress] invalid distance');
@@ -4219,14 +4990,10 @@ function BrotliDecompress(input, output) {
4219
4990
  }
4220
4991
  }
4221
4992
 
4222
- /* When we get here, we must have inserted at least one literal and */
4223
- /* made a copy of at least length two, therefore accessing the last 2 */
4224
- /* bytes is valid. */
4225
4993
  prev_byte1 = ringbuffer[(pos - 1) & ringbuffer_mask];
4226
4994
  prev_byte2 = ringbuffer[(pos - 2) & ringbuffer_mask];
4227
4995
  }
4228
4996
 
4229
- /* Protect pos from overflow, wrap it around at every GB of input data */
4230
4997
  pos &= 0x3fffffff;
4231
4998
  }
4232
4999
 
@@ -4445,6 +5212,22 @@ exports.BrotliOutput = BrotliOutput;
4445
5212
  };
4446
5213
 
4447
5214
  __brotliModules["/dec/bit_reader.js"] = function(module, exports, require) {
5215
+ /* Copyright 2013 Google Inc. All Rights Reserved.
5216
+
5217
+ Licensed under the Apache License, Version 2.0 (the "License");
5218
+ you may not use this file except in compliance with the License.
5219
+ You may obtain a copy of the License at
5220
+
5221
+ http://www.apache.org/licenses/LICENSE-2.0
5222
+
5223
+ Unless required by applicable law or agreed to in writing, software
5224
+ distributed under the License is distributed on an "AS IS" BASIS,
5225
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5226
+ See the License for the specific language governing permissions and
5227
+ limitations under the License.
5228
+
5229
+ Bit reading helpers
5230
+ */
4448
5231
 
4449
5232
  var BROTLI_READ_SIZE = 4096;
4450
5233
  var BROTLI_IBUF_SIZE = (2 * BROTLI_READ_SIZE + 32);
@@ -4455,9 +5238,11 @@ var kBitMask = new Uint32Array([
4455
5238
  65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215
4456
5239
  ]);
4457
5240
 
5241
+ /* Input byte buffer, consist of a ringbuffer and a "slack" region where */
5242
+ /* bytes from the start of the ringbuffer are copied. */
4458
5243
  function BrotliBitReader(input) {
4459
5244
  this.buf_ = new Uint8Array(BROTLI_IBUF_SIZE);
4460
- this.input_ = input;
5245
+ this.input_ = input; /* input callback */
4461
5246
 
4462
5247
  this.reset();
4463
5248
  }
@@ -4466,12 +5251,12 @@ BrotliBitReader.READ_SIZE = BROTLI_READ_SIZE;
4466
5251
  BrotliBitReader.IBUF_MASK = BROTLI_IBUF_MASK;
4467
5252
 
4468
5253
  BrotliBitReader.prototype.reset = function() {
4469
- this.buf_ptr_ = 0;
4470
- this.val_ = 0;
4471
- this.pos_ = 0;
4472
- this.bit_pos_ = 0;
4473
- this.bit_end_pos_ = 0;
4474
- this.eos_ = 0;
5254
+ this.buf_ptr_ = 0; /* next input will write here */
5255
+ this.val_ = 0; /* pre-fetched bits */
5256
+ this.pos_ = 0; /* byte position in stream */
5257
+ this.bit_pos_ = 0; /* current bit-reading position in val_ */
5258
+ this.bit_end_pos_ = 0; /* bit-reading end position from LSB of val_ */
5259
+ this.eos_ = 0; /* input stream is finished */
4475
5260
 
4476
5261
  this.readMoreInput();
4477
5262
  for (var i = 0; i < 4; i++) {
@@ -4482,6 +5267,18 @@ BrotliBitReader.prototype.reset = function() {
4482
5267
  return this.bit_end_pos_ > 0;
4483
5268
  };
4484
5269
 
5270
+ /* Fills up the input ringbuffer by calling the input callback.
5271
+
5272
+ Does nothing if there are at least 32 bytes present after current position.
5273
+
5274
+ Returns 0 if either:
5275
+ - the input callback returned an error, or
5276
+ - there is no more input and the position is past the end of the stream.
5277
+
5278
+ After encountering the end of the input stream, 32 additional zero bytes are
5279
+ copied to the ringbuffer, therefore it is safe to call this function after
5280
+ every 32 bytes of input is read.
5281
+ */
4485
5282
  BrotliBitReader.prototype.readMoreInput = function() {
4486
5283
  if (this.bit_end_pos_ > 256) {
4487
5284
  return;
@@ -4497,13 +5294,13 @@ BrotliBitReader.prototype.readMoreInput = function() {
4497
5294
 
4498
5295
  if (bytes_read < BROTLI_READ_SIZE) {
4499
5296
  this.eos_ = 1;
4500
-
5297
+ /* Store 32 bytes of zero after the stream end. */
4501
5298
  for (var p = 0; p < 32; p++)
4502
5299
  this.buf_[dst + bytes_read + p] = 0;
4503
5300
  }
4504
5301
 
4505
5302
  if (dst === 0) {
4506
-
5303
+ /* Copy the head of the ringbuffer to the slack region. */
4507
5304
  for (var p = 0; p < 32; p++)
4508
5305
  this.buf_[(BROTLI_READ_SIZE << 1) + p] = this.buf_[p];
4509
5306
 
@@ -4516,6 +5313,7 @@ BrotliBitReader.prototype.readMoreInput = function() {
4516
5313
  }
4517
5314
  };
4518
5315
 
5316
+ /* Guarantees that there are at least 24 bits in the buffer. */
4519
5317
  BrotliBitReader.prototype.fillBitWindow = function() {
4520
5318
  while (this.bit_pos_ >= 8) {
4521
5319
  this.val_ >>>= 8;
@@ -4526,6 +5324,7 @@ BrotliBitReader.prototype.fillBitWindow = function() {
4526
5324
  }
4527
5325
  };
4528
5326
 
5327
+ /* Reads the specified number of bits from Read Buffer. */
4529
5328
  BrotliBitReader.prototype.readBits = function(n_bits) {
4530
5329
  if (32 - this.bit_pos_ < n_bits) {
4531
5330
  this.fillBitWindow();
@@ -4541,6 +5340,22 @@ module.exports = BrotliBitReader;
4541
5340
  };
4542
5341
 
4543
5342
  __brotliModules["/dec/dictionary.js"] = function(module, exports, require) {
5343
+ /* Copyright 2013 Google Inc. All Rights Reserved.
5344
+
5345
+ Licensed under the Apache License, Version 2.0 (the "License");
5346
+ you may not use this file except in compliance with the License.
5347
+ You may obtain a copy of the License at
5348
+
5349
+ http://www.apache.org/licenses/LICENSE-2.0
5350
+
5351
+ Unless required by applicable law or agreed to in writing, software
5352
+ distributed under the License is distributed on an "AS IS" BASIS,
5353
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5354
+ See the License for the specific language governing permissions and
5355
+ limitations under the License.
5356
+
5357
+ Collection of static dictionary words.
5358
+ */
4544
5359
 
4545
5360
  var data = require("/dec/dictionary-browser.js");
4546
5361
  exports.init = function() {
@@ -4566,14 +5381,16 @@ exports.maxDictionaryWordLength = 24;
4566
5381
 
4567
5382
  __brotliModules["/dec/huffman.js"] = function(module, exports, require) {
4568
5383
  function HuffmanCode(bits, value) {
4569
- this.bits = bits;
4570
- this.value = value;
5384
+ this.bits = bits; /* number of bits used for this symbol */
5385
+ this.value = value; /* symbol value or table offset */
4571
5386
  }
4572
5387
 
4573
5388
  exports.HuffmanCode = HuffmanCode;
4574
5389
 
4575
5390
  var MAX_LENGTH = 15;
4576
5391
 
5392
+ /* Returns reverse(reverse(key, len) + 1, len), where reverse(key, len) is the
5393
+ bit-wise reversal of the len least significant bits of key. */
4577
5394
  function GetNextKey(key, len) {
4578
5395
  var step = 1 << (len - 1);
4579
5396
  while (key & step) {
@@ -4582,6 +5399,8 @@ function GetNextKey(key, len) {
4582
5399
  return (key & (step - 1)) + step;
4583
5400
  }
4584
5401
 
5402
+ /* Stores code in table[0], table[step], table[2*step], ..., table[end] */
5403
+ /* Assumes that end is an integer multiple of step */
4585
5404
  function ReplicateValue(table, i, step, end, code) {
4586
5405
  do {
4587
5406
  end -= step;
@@ -4589,6 +5408,9 @@ function ReplicateValue(table, i, step, end, code) {
4589
5408
  } while (end > 0);
4590
5409
  }
4591
5410
 
5411
+ /* Returns the table width of the next 2nd level table. count is the histogram
5412
+ of bit lengths for the remaining symbols, len is the code length of the next
5413
+ processed symbol */
4592
5414
  function NextTableBitSize(count, len, root_bits) {
4593
5415
  var left = 1 << (len - root_bits);
4594
5416
  while (len < MAX_LENGTH) {
@@ -4602,31 +5424,34 @@ function NextTableBitSize(count, len, root_bits) {
4602
5424
 
4603
5425
  exports.BrotliBuildHuffmanTable = function(root_table, table, root_bits, code_lengths, code_lengths_size) {
4604
5426
  var start_table = table;
4605
- var code;
4606
- var len;
4607
- var symbol;
4608
- var key;
4609
- var step;
4610
- var low;
4611
- var mask;
4612
- var table_bits;
4613
- var table_size;
4614
- var total_size;
4615
- var sorted;
4616
- var count = new Int32Array(MAX_LENGTH + 1);
4617
- var offset = new Int32Array(MAX_LENGTH + 1);
5427
+ var code; /* current table entry */
5428
+ var len; /* current code length */
5429
+ var symbol; /* symbol index in original or sorted table */
5430
+ var key; /* reversed prefix code */
5431
+ var step; /* step size to replicate values in current table */
5432
+ var low; /* low bits for current root entry */
5433
+ var mask; /* mask for low bits */
5434
+ var table_bits; /* key length of current table */
5435
+ var table_size; /* size of current table */
5436
+ var total_size; /* sum of root table size and 2nd level table sizes */
5437
+ var sorted; /* symbols sorted by code length */
5438
+ var count = new Int32Array(MAX_LENGTH + 1); /* number of codes of each length */
5439
+ var offset = new Int32Array(MAX_LENGTH + 1); /* offsets in sorted table for each length */
4618
5440
 
4619
5441
  sorted = new Int32Array(code_lengths_size);
4620
5442
 
5443
+ /* build histogram of code lengths */
4621
5444
  for (symbol = 0; symbol < code_lengths_size; symbol++) {
4622
5445
  count[code_lengths[symbol]]++;
4623
5446
  }
4624
5447
 
5448
+ /* generate offsets into sorted symbol table by code length */
4625
5449
  offset[1] = 0;
4626
5450
  for (len = 1; len < MAX_LENGTH; len++) {
4627
5451
  offset[len + 1] = offset[len] + count[len];
4628
5452
  }
4629
5453
 
5454
+ /* sort symbols by length, by symbol order within each length */
4630
5455
  for (symbol = 0; symbol < code_lengths_size; symbol++) {
4631
5456
  if (code_lengths[symbol] !== 0) {
4632
5457
  sorted[offset[code_lengths[symbol]]++] = symbol;
@@ -4637,6 +5462,7 @@ exports.BrotliBuildHuffmanTable = function(root_table, table, root_bits, code_le
4637
5462
  table_size = 1 << table_bits;
4638
5463
  total_size = table_size;
4639
5464
 
5465
+ /* special case code with only one value */
4640
5466
  if (offset[MAX_LENGTH] === 1) {
4641
5467
  for (key = 0; key < total_size; ++key) {
4642
5468
  root_table[table + key] = new HuffmanCode(0, sorted[0] & 0xffff);
@@ -4645,6 +5471,7 @@ exports.BrotliBuildHuffmanTable = function(root_table, table, root_bits, code_le
4645
5471
  return total_size;
4646
5472
  }
4647
5473
 
5474
+ /* fill in root table */
4648
5475
  key = 0;
4649
5476
  symbol = 0;
4650
5477
  for (len = 1, step = 2; len <= root_bits; ++len, step <<= 1) {
@@ -4655,6 +5482,7 @@ exports.BrotliBuildHuffmanTable = function(root_table, table, root_bits, code_le
4655
5482
  }
4656
5483
  }
4657
5484
 
5485
+ /* fill in 2nd level tables and add pointers to root table */
4658
5486
  mask = total_size - 1;
4659
5487
  low = -1;
4660
5488
  for (len = root_bits + 1, step = 2; len <= MAX_LENGTH; ++len, step <<= 1) {
@@ -4679,6 +5507,111 @@ exports.BrotliBuildHuffmanTable = function(root_table, table, root_bits, code_le
4679
5507
  };
4680
5508
 
4681
5509
  __brotliModules["/dec/context.js"] = function(module, exports, require) {
5510
+ /* Copyright 2013 Google Inc. All Rights Reserved.
5511
+
5512
+ Licensed under the Apache License, Version 2.0 (the "License");
5513
+ you may not use this file except in compliance with the License.
5514
+ You may obtain a copy of the License at
5515
+
5516
+ http://www.apache.org/licenses/LICENSE-2.0
5517
+
5518
+ Unless required by applicable law or agreed to in writing, software
5519
+ distributed under the License is distributed on an "AS IS" BASIS,
5520
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5521
+ See the License for the specific language governing permissions and
5522
+ limitations under the License.
5523
+
5524
+ Lookup table to map the previous two bytes to a context id.
5525
+
5526
+ There are four different context modeling modes defined here:
5527
+ CONTEXT_LSB6: context id is the least significant 6 bits of the last byte,
5528
+ CONTEXT_MSB6: context id is the most significant 6 bits of the last byte,
5529
+ CONTEXT_UTF8: second-order context model tuned for UTF8-encoded text,
5530
+ CONTEXT_SIGNED: second-order context model tuned for signed integers.
5531
+
5532
+ The context id for the UTF8 context model is calculated as follows. If p1
5533
+ and p2 are the previous two bytes, we calcualte the context as
5534
+
5535
+ context = kContextLookup[p1] | kContextLookup[p2 + 256].
5536
+
5537
+ If the previous two bytes are ASCII characters (i.e. < 128), this will be
5538
+ equivalent to
5539
+
5540
+ context = 4 * context1(p1) + context2(p2),
5541
+
5542
+ where context1 is based on the previous byte in the following way:
5543
+
5544
+ 0 : non-ASCII control
5545
+ 1 : \t, \n, \r
5546
+ 2 : space
5547
+ 3 : other punctuation
5548
+ 4 : " '
5549
+ 5 : %
5550
+ 6 : ( < [ {
5551
+ 7 : ) > ] }
5552
+ 8 : , ; :
5553
+ 9 : .
5554
+ 10 : =
5555
+ 11 : number
5556
+ 12 : upper-case vowel
5557
+ 13 : upper-case consonant
5558
+ 14 : lower-case vowel
5559
+ 15 : lower-case consonant
5560
+
5561
+ and context2 is based on the second last byte:
5562
+
5563
+ 0 : control, space
5564
+ 1 : punctuation
5565
+ 2 : upper-case letter, number
5566
+ 3 : lower-case letter
5567
+
5568
+ If the last byte is ASCII, and the second last byte is not (in a valid UTF8
5569
+ stream it will be a continuation byte, value between 128 and 191), the
5570
+ context is the same as if the second last byte was an ASCII control or space.
5571
+
5572
+ If the last byte is a UTF8 lead byte (value >= 192), then the next byte will
5573
+ be a continuation byte and the context id is 2 or 3 depending on the LSB of
5574
+ the last byte and to a lesser extent on the second last byte if it is ASCII.
5575
+
5576
+ If the last byte is a UTF8 continuation byte, the second last byte can be:
5577
+ - continuation byte: the next byte is probably ASCII or lead byte (assuming
5578
+ 4-byte UTF8 characters are rare) and the context id is 0 or 1.
5579
+ - lead byte (192 - 207): next byte is ASCII or lead byte, context is 0 or 1
5580
+ - lead byte (208 - 255): next byte is continuation byte, context is 2 or 3
5581
+
5582
+ The possible value combinations of the previous two bytes, the range of
5583
+ context ids and the type of the next byte is summarized in the table below:
5584
+
5585
+ |--------\-----------------------------------------------------------------|
5586
+ | \ Last byte |
5587
+ | Second \---------------------------------------------------------------|
5588
+ | last byte \ ASCII | cont. byte | lead byte |
5589
+ | \ (0-127) | (128-191) | (192-) |
5590
+ |=============|===================|=====================|==================|
5591
+ | ASCII | next: ASCII/lead | not valid | next: cont. |
5592
+ | (0-127) | context: 4 - 63 | | context: 2 - 3 |
5593
+ |-------------|-------------------|---------------------|------------------|
5594
+ | cont. byte | next: ASCII/lead | next: ASCII/lead | next: cont. |
5595
+ | (128-191) | context: 4 - 63 | context: 0 - 1 | context: 2 - 3 |
5596
+ |-------------|-------------------|---------------------|------------------|
5597
+ | lead byte | not valid | next: ASCII/lead | not valid |
5598
+ | (192-207) | | context: 0 - 1 | |
5599
+ |-------------|-------------------|---------------------|------------------|
5600
+ | lead byte | not valid | next: cont. | not valid |
5601
+ | (208-) | | context: 2 - 3 | |
5602
+ |-------------|-------------------|---------------------|------------------|
5603
+
5604
+ The context id for the signed context mode is calculated as:
5605
+
5606
+ context = (kContextLookup[512 + p1] << 3) | kContextLookup[512 + p2].
5607
+
5608
+ For any context modeling modes, the context ids can be calculated by |-ing
5609
+ together two lookups from one table using context model dependent offsets:
5610
+
5611
+ context = kContextLookup[offset1 + p1] | kContextLookup[offset2 + p2].
5612
+
5613
+ where offset1 and offset2 are dependent on the context mode.
5614
+ */
4682
5615
 
4683
5616
  var CONTEXT_LSB6 = 0;
4684
5617
  var CONTEXT_MSB6 = 1;
@@ -5171,13 +6104,14 @@ return { compressBrotliPayload, decompressBrotliPayload, BROTLI_QUALITY_MIN, BRO
5171
6104
  })();
5172
6105
  const __qqr_quadqr_js = (function () {
5173
6106
  const { MAX_CODEWORD_SYMBOLS, rsEncode, rsDecode } = __qqr_reed_solomon_js;
5174
- const { alignmentPatternCentersForVersion, alignmentPatternIsBlack, alignmentPatternRadius, sizeForVersion, versionFromSize } = __qqr_geometry_js;
6107
+ const { alignmentPatternCentersForVersion, alignmentPatternIsBlack, alignmentPatternRadius, ALIGNMENT_PROFILE_STANDARD_5, ALIGNMENT_PROFILE_LEGACY_3, sizeForVersion, versionFromSize } = __qqr_geometry_js;
5175
6108
  const { detectCodeGeometry, computeHomography, projectPoint, samplePerspectiveMatrix, samplePerspectiveTriangleMatrix, rectifyImageData, sampleObservedPalette, spatiallyNormalizeRgbGrid, autoToneContrastColorRgbGrid, autoToneContrastColorImageData, autoColorImageData, findActiveBounds, sampleAxisAlignedGrid, sampleAxisAlignedTriangleGrid } = __qqr_vision_js;
5176
6109
  const { decryptSecurePayload, encryptSecurePayload, inspectSecureEnvelope, SECURITY_MODES, SECURITY_ALGORITHMS, SECURE_PAYLOAD_VERSION, DEFAULT_PBKDF2_ITERATIONS, generateRaw256Key, normalizeRaw256Key, bytesToHex, estimateSecureEnvelopeOverhead } = __qqr_security_js;
5177
6110
  const { compressDeflatePayload: compressDeflateBytes, decompressDeflatePayload: decompressDeflateBytes, DEFAULT_DEFLATE_LEVEL, DEFLATE_LEVEL_MIN, DEFLATE_LEVEL_MAX } = __qqr_deflate_js;
5178
6111
  const { compressBrotliPayload: compressBrotliBytes, decompressBrotliPayload: decompressBrotliBytes, DEFAULT_BROTLI_QUALITY, BROTLI_QUALITY_MIN, BROTLI_QUALITY_MAX } = __qqr_brotli_js;
5179
6112
 
5180
- const FORMAT_VERSION = 5;
6113
+ const FORMAT_VERSION = 6;
6114
+ const LEGACY_FORMAT_VERSION = 5;
5181
6115
  const MIN_VERSION = 1;
5182
6116
  const MAX_VERSION = 40;
5183
6117
  const DEFAULT_ECC_LEVEL = "M";
@@ -6232,7 +7166,7 @@ function getEffectiveEcc(version, eccLevel) {
6232
7166
  return version === COMPACT_VERSION ? COMPACT_ECC_LEVELS[normalized] : ECC_LEVELS[normalized];
6233
7167
  }
6234
7168
 
6235
- function makeHeader(payloadLength, flags, version) {
7169
+ function makeHeader(payloadLength, flags, version, formatVersion = FORMAT_VERSION) {
6236
7170
  assert(payloadLength >= 0 && payloadLength <= 0xffffffff, "Payload is too large.");
6237
7171
 
6238
7172
  if (version === COMPACT_VERSION) {
@@ -6247,7 +7181,7 @@ function makeHeader(payloadLength, flags, version) {
6247
7181
 
6248
7182
  const header = new Uint8Array(HEADER_BYTES);
6249
7183
  header.set(MAGIC, 0);
6250
- header[4] = FORMAT_VERSION;
7184
+ header[4] = formatVersion;
6251
7185
  header[5] = flags & 0xff;
6252
7186
  header.set(u32be(payloadLength), 6);
6253
7187
  return header;
@@ -6269,14 +7203,22 @@ function parseHeader(header, version) {
6269
7203
  return { flags: header[1], payloadLength: header[2] };
6270
7204
  }
6271
7205
 
6272
- if (!magicMatches(header) || header[4] !== FORMAT_VERSION) {
7206
+ const formatVersion = header[4];
7207
+ if (!magicMatches(header) || (formatVersion !== FORMAT_VERSION && formatVersion !== LEGACY_FORMAT_VERSION)) {
6273
7208
  throw new Error("QuadQR magic/version mismatch.");
6274
7209
  }
6275
- return { flags: header[5], payloadLength: readU32be(header, 6) };
7210
+ return { formatVersion, flags: header[5], payloadLength: readU32be(header, 6) };
7211
+ }
7212
+
7213
+ function alignmentProfileForFormat(formatVersion = FORMAT_VERSION) {
7214
+ return formatVersion === LEGACY_FORMAT_VERSION
7215
+ ? ALIGNMENT_PROFILE_LEGACY_3
7216
+ : ALIGNMENT_PROFILE_STANDARD_5;
6276
7217
  }
6277
7218
 
6278
- function createLayout(version) {
7219
+ function createLayout(version, options = {}) {
6279
7220
  validateVersion(version);
7221
+ const alignmentProfile = options.alignmentProfile ?? alignmentProfileForFormat(options.formatVersion ?? FORMAT_VERSION);
6280
7222
  const size = sizeForVersion(version);
6281
7223
  const matrix = make2D(size, CELL.WHITE);
6282
7224
  const reserved = make2D(size, false);
@@ -6404,7 +7346,7 @@ function createLayout(version) {
6404
7346
  reserveAndSet(row, 6, row % 2 === 0 ? CELL.BLACK : CELL.WHITE);
6405
7347
  }
6406
7348
 
6407
- const alignments = alignmentPatternCentersForVersion(version).map(drawAlignmentPattern);
7349
+ const alignments = alignmentPatternCentersForVersion(version, { profile: alignmentProfile }).map(drawAlignmentPattern);
6408
7350
  const alignment = alignments[alignments.length - 1];
6409
7351
  const calibrationStrip = drawCalibrationStrip();
6410
7352
 
@@ -6428,6 +7370,7 @@ function createLayout(version) {
6428
7370
  return {
6429
7371
  version,
6430
7372
  size,
7373
+ alignmentProfile,
6431
7374
  matrix,
6432
7375
  reserved,
6433
7376
  dataPositions,
@@ -7065,8 +8008,8 @@ function alignmentPatternMismatchRatio(matrix, pattern) {
7065
8008
  return mismatches / total;
7066
8009
  }
7067
8010
 
7068
- function alignmentGridMismatchRatio(matrix, version) {
7069
- const patterns = alignmentPatternCentersForVersion(version);
8011
+ function alignmentGridMismatchRatio(matrix, version, alignmentProfile = ALIGNMENT_PROFILE_STANDARD_5) {
8012
+ const patterns = alignmentPatternCentersForVersion(version, { profile: alignmentProfile });
7070
8013
  let weightedMismatch = 0;
7071
8014
  let totalWeight = 0;
7072
8015
  for (const pattern of patterns) {
@@ -7078,7 +8021,7 @@ function alignmentGridMismatchRatio(matrix, version) {
7078
8021
  return totalWeight ? weightedMismatch / totalWeight : 0;
7079
8022
  }
7080
8023
 
7081
- function validateStructure(matrix, tolerance = 0) {
8024
+ function validateStructure(matrix, tolerance = 0, alignmentProfile = ALIGNMENT_PROFILE_STANDARD_5) {
7082
8025
  const size = matrix.length;
7083
8026
  if (size < 21 || matrix.some((row) => row.length !== size)) return false;
7084
8027
  const version = versionFromSize(size);
@@ -7091,11 +8034,11 @@ function validateStructure(matrix, tolerance = 0) {
7091
8034
  if (finderRatios.some((ratio) => ratio > tolerance)) return false;
7092
8035
 
7093
8036
  const alignmentTolerance = Math.max(tolerance, 0.12);
7094
- const primary = alignmentPatternCentersForVersion(version).at(-1);
8037
+ const primary = alignmentPatternCentersForVersion(version, { profile: alignmentProfile }).at(-1);
7095
8038
  if (primary && alignmentPatternMismatchRatio(matrix, primary) > alignmentTolerance) {
7096
8039
  return false;
7097
8040
  }
7098
- if (alignmentGridMismatchRatio(matrix, version) > alignmentTolerance) return false;
8041
+ if (alignmentGridMismatchRatio(matrix, version, alignmentProfile) > alignmentTolerance) return false;
7099
8042
  return true;
7100
8043
  }
7101
8044
 
@@ -7283,13 +8226,13 @@ function decodeProtectedBody(rawCells, payloadLength, eccLevel, version, rawConf
7283
8226
  };
7284
8227
  }
7285
8228
 
7286
- function decodeCanonical(matrix, rotation, tolerance = 0, confidenceMatrix = null, options = {}) {
8229
+ function decodeCanonicalWithProfile(matrix, rotation, tolerance = 0, confidenceMatrix = null, options = {}, alignmentProfile = ALIGNMENT_PROFILE_STANDARD_5) {
7287
8230
  const size = matrix.length;
7288
8231
  const version = versionFromSize(size);
7289
8232
  if (!version) throw new Error(`Unsupported matrix size ${size}.`);
7290
- if (!validateStructure(matrix, tolerance)) throw new Error("QuadQR finder/alignment structure does not match.");
8233
+ if (!validateStructure(matrix, tolerance, alignmentProfile)) throw new Error("QuadQR finder/alignment structure does not match.");
7291
8234
 
7292
- const layout = createLayout(version);
8235
+ const layout = createLayout(version, { alignmentProfile });
7293
8236
  const errors = [];
7294
8237
  const hintedEncoding = options.cellEncodingHint != null
7295
8238
  ? normalizeCellEncoding(options.cellEncodingHint)
@@ -7339,6 +8282,10 @@ function decodeCanonical(matrix, rotation, tolerance = 0, confidenceMatrix = nul
7339
8282
  );
7340
8283
  const header = headerDecoded.header;
7341
8284
  const flags = headerDecoded.flags;
8285
+ const decodedFormatVersion = headerDecoded.formatVersion ?? FORMAT_VERSION;
8286
+ if (version >= 7 && alignmentProfileForFormat(decodedFormatVersion) !== alignmentProfile) {
8287
+ throw new Error(`Format v${decodedFormatVersion} uses a different alignment profile.`);
8288
+ }
7342
8289
  const declaredCellEncoding = cellEncodingFromFlags(flags);
7343
8290
  if (declaredCellEncoding !== cellEncoding) {
7344
8291
  throw new Error(`Header declares ${declaredCellEncoding}, not ${cellEncoding}.`);
@@ -7376,10 +8323,11 @@ function decodeCanonical(matrix, rotation, tolerance = 0, confidenceMatrix = nul
7376
8323
  return {
7377
8324
  ok: true,
7378
8325
  format: "QuadQR",
7379
- formatVersion: FORMAT_VERSION,
8326
+ formatVersion: decodedFormatVersion,
7380
8327
  version,
7381
8328
  size,
7382
8329
  alignmentPatterns: layout.alignments.length,
8330
+ alignmentProfile,
7383
8331
  maskId,
7384
8332
  rotation,
7385
8333
  flags,
@@ -7427,17 +8375,42 @@ function decodeCanonical(matrix, rotation, tolerance = 0, confidenceMatrix = nul
7427
8375
  throw new Error(`QuadQR decode failed. ${errors.join(" | ")}`);
7428
8376
  }
7429
8377
 
8378
+ function decodeCanonical(matrix, rotation, tolerance = 0, confidenceMatrix = null, options = {}) {
8379
+ const hinted = options.alignmentProfileHint;
8380
+ const profiles = hinted
8381
+ ? [hinted]
8382
+ : [ALIGNMENT_PROFILE_STANDARD_5, ALIGNMENT_PROFILE_LEGACY_3];
8383
+ const errors = [];
8384
+ for (const alignmentProfile of profiles) {
8385
+ try {
8386
+ return decodeCanonicalWithProfile(matrix, rotation, tolerance, confidenceMatrix, options, alignmentProfile);
8387
+ } catch (error) {
8388
+ errors.push(`${alignmentProfile}: ${error.message}`);
8389
+ }
8390
+ }
8391
+ throw new Error(`QuadQR decode failed for all alignment profiles. ${errors.join(" | ")}`);
8392
+ }
8393
+
7430
8394
  function trySoftMatrixDecode(matrix, alternatives, confidenceMatrix, degrees, tolerance, options = {}) {
7431
8395
  if (!alternatives || !confidenceMatrix || options.softDecoding === false) return null;
7432
8396
  const version = versionFromSize(matrix.length);
7433
8397
  if (!version) return null;
7434
8398
  const layout = createLayout(version);
8399
+ const legacyLayout = createLayout(version, { alignmentProfile: ALIGNMENT_PROFILE_LEGACY_3 });
8400
+ const softPositions = [];
8401
+ const seenSoftPositions = new Set();
8402
+ for (const [row, col] of [...layout.dataPositions, ...legacyLayout.dataPositions]) {
8403
+ const key = `${row},${col}`;
8404
+ if (seenSoftPositions.has(key)) continue;
8405
+ seenSoftPositions.add(key);
8406
+ softPositions.push([row, col]);
8407
+ }
7435
8408
  const threshold = clampNumber(options.softDecodeConfidence ?? 0.72, 0.05, 0.95);
7436
8409
  const maxCells = Math.max(2, Math.min(16, Math.round(options.softDecodeMaxCells ?? 10)));
7437
8410
  const pairCells = Math.max(2, Math.min(maxCells, Math.round(options.softDecodePairCells ?? 6)));
7438
8411
  const ranked = [];
7439
8412
 
7440
- for (const [row, col] of layout.dataPositions) {
8413
+ for (const [row, col] of softPositions) {
7441
8414
  const alternative = alternatives[row]?.[col];
7442
8415
  const confidence = confidenceMatrix[row]?.[col] ?? 1;
7443
8416
  if (!Number.isInteger(alternative) || alternative === matrix[row][col] || confidence > threshold) continue;
@@ -8785,27 +9758,31 @@ function paletteClassifierAttempts(observedPalette) {
8785
9758
  }
8786
9759
 
8787
9760
  function tryPerspectiveScan(imageData, options) {
8788
- const geometryCandidates = detectCodeGeometry(imageData, {
8789
- minVersion: options.minVersion ?? MIN_VERSION,
8790
- maxVersion: options.maxVersion ?? MAX_VERSION,
8791
- maxCandidates: options.maxGeometryCandidates ?? 8,
8792
- finderRecovery: options.finderRecovery,
8793
- finderAutoColorBlackClip: options.finderAutoColorBlackClip,
8794
- finderAutoColorWhiteClip: options.finderAutoColorWhiteClip,
8795
- finderAutoColorHighlightPercentile: options.finderAutoColorHighlightPercentile,
8796
- finderAutoColorOutputHighlight: options.finderAutoColorOutputHighlight,
8797
- finderAutoColorAnalysisInset: options.finderAutoColorAnalysisInset,
8798
- finderAutoColorMinimumInputRange: options.finderAutoColorMinimumInputRange,
8799
- finderAutoColorTargetSamples: options.finderAutoColorTargetSamples,
8800
- preciseAlignment: options.preciseAlignment,
8801
- diagnostics: options._visionDiagnostics,
8802
- diagnosticLabel: options._diagnosticLabel ?? "normal"
8803
- });
9761
+ const geometryCandidates = Array.isArray(options._geometryCandidatesOverride) && options._geometryCandidatesOverride.length
9762
+ ? options._geometryCandidatesOverride
9763
+ : detectCodeGeometry(imageData, {
9764
+ minVersion: options.minVersion ?? MIN_VERSION,
9765
+ maxVersion: options.maxVersion ?? MAX_VERSION,
9766
+ maxCandidates: options.maxGeometryCandidates ?? 8,
9767
+ finderRecovery: options.finderRecovery,
9768
+ finderAutoColorBlackClip: options.finderAutoColorBlackClip,
9769
+ finderAutoColorWhiteClip: options.finderAutoColorWhiteClip,
9770
+ finderAutoColorHighlightPercentile: options.finderAutoColorHighlightPercentile,
9771
+ finderAutoColorOutputHighlight: options.finderAutoColorOutputHighlight,
9772
+ finderAutoColorAnalysisInset: options.finderAutoColorAnalysisInset,
9773
+ finderAutoColorMinimumInputRange: options.finderAutoColorMinimumInputRange,
9774
+ finderAutoColorTargetSamples: options.finderAutoColorTargetSamples,
9775
+ preciseAlignment: options.preciseAlignment,
9776
+ diagnostics: options._visionDiagnostics,
9777
+ diagnosticLabel: options._diagnosticLabel ?? "normal"
9778
+ });
8804
9779
  if (Array.isArray(options._geometryCollector)) options._geometryCollector.push(...geometryCandidates);
8805
9780
  const results = [];
8806
9781
 
8807
9782
  for (const geometry of geometryCandidates) {
8808
- const layout = createLayout(geometry.version);
9783
+ const layout = createLayout(geometry.version, {
9784
+ alignmentProfile: geometry.alignmentProfile ?? ALIGNMENT_PROFILE_STANDARD_5
9785
+ });
8809
9786
  const sampleProfiles = [{
8810
9787
  sampleMode: options.sampleMode ?? "cross",
8811
9788
  sampleRadius: options.sampleRadius ?? 0.16,
@@ -8842,7 +9819,7 @@ function tryPerspectiveScan(imageData, options) {
8842
9819
  continue;
8843
9820
  }
8844
9821
 
8845
- const tryAttempt = (attempt, rgbGrid, metadata = {}) => {
9822
+ const tryAttempt = (attempt, rgbGrid, metadata = {}, allowSoftDecoding = options.softDecoding !== false) => {
8846
9823
  const activeObservedPalette = metadata.observedPalette ?? observedPalette;
8847
9824
  const activeSamplingMode = metadata.samplingMode ?? profile.sampleMode;
8848
9825
  const classified = classifySampledRgbGrid(rgbGrid, attempt.classifier, layout);
@@ -8867,6 +9844,9 @@ function tryPerspectiveScan(imageData, options) {
8867
9844
  structureTolerance: options.structureTolerance ?? 0.18,
8868
9845
  cellConfidence: classified.confidence,
8869
9846
  cellAlternatives: classified.alternatives,
9847
+ cellEncodingHint: CELL_ENCODINGS.RGBW,
9848
+ alignmentProfileHint: geometry.alignmentProfile ?? ALIGNMENT_PROFILE_STANDARD_5,
9849
+ softDecoding: allowSoftDecoding,
8870
9850
  maxErasureConfidence: options.maxErasureConfidence
8871
9851
  });
8872
9852
  if (decoded.version !== geometry.version) return false;
@@ -8895,7 +9875,7 @@ function tryPerspectiveScan(imageData, options) {
8895
9875
  }
8896
9876
  };
8897
9877
 
8898
- const tryTriangleAttempt = (attempt, metadata = {}) => {
9878
+ const tryTriangleAttempt = (attempt, metadata = {}, allowSoftDecoding = options.softDecoding !== false) => {
8899
9879
  if (!triangleSampled?.triangleGrid) return false;
8900
9880
  const activeObservedPalette = metadata.observedPalette ?? observedPalette;
8901
9881
  const activeSamplingMode = metadata.samplingMode ?? `${profile.sampleMode}-triangle16`;
@@ -8928,6 +9908,8 @@ function tryPerspectiveScan(imageData, options) {
8928
9908
  cellConfidence: classified.confidence,
8929
9909
  cellAlternatives: classified.alternatives,
8930
9910
  cellEncodingHint: CELL_ENCODINGS.TRIANGLE16,
9911
+ alignmentProfileHint: geometry.alignmentProfile ?? ALIGNMENT_PROFILE_STANDARD_5,
9912
+ softDecoding: allowSoftDecoding,
8931
9913
  maxErasureConfidence: options.maxErasureConfidence
8932
9914
  });
8933
9915
  if (decoded.version !== geometry.version) return false;
@@ -8956,21 +9938,38 @@ function tryPerspectiveScan(imageData, options) {
8956
9938
  // Fast path: preserve the original observed-RGB classifier first, then
8957
9939
  // try per-channel white balancing. Most clean frames stop here without
8958
9940
  // paying for the more expensive spatial normalization fallback.
8959
- for (const attempt of paletteClassifierAttempts(observedPalette)) {
8960
- if (tryAttempt(attempt, sampled.rgbGrid) || tryTriangleAttempt(attempt)) {
9941
+ const basePaletteAttempts = paletteClassifierAttempts(observedPalette);
9942
+ for (const attempt of basePaletteAttempts) {
9943
+ if (tryAttempt(attempt, sampled.rgbGrid, {}, false) || tryTriangleAttempt(attempt, {}, false)) {
8961
9944
  geometryDecoded = true;
8962
9945
  break;
8963
9946
  }
8964
9947
  }
9948
+ // Spectrum ECC soft decoding is intentionally deferred until every cheap
9949
+ // hard classifier has had a chance. This preserves the exact recovery
9950
+ // candidates while avoiding expensive second-hypothesis RS searches when
9951
+ // a later normal color model can decode the frame immediately.
9952
+ if (!geometryDecoded && options.softDecoding !== false) {
9953
+ for (const attempt of basePaletteAttempts) {
9954
+ if (tryAttempt(attempt, sampled.rgbGrid, {}, true) || tryTriangleAttempt(attempt, {}, true)) {
9955
+ geometryDecoded = true;
9956
+ break;
9957
+ }
9958
+ }
9959
+ }
8965
9960
 
8966
9961
  if (!geometryDecoded && options.spatialColorNormalization !== false) {
8967
9962
  try {
8968
9963
  const normalizedGrid = spatiallyNormalizeRgbGrid(sampled.rgbGrid, layout.calibration);
8969
9964
  const normalizedPalette = sampleObservedPalette(normalizedGrid, layout.calibration, { robust: true });
8970
- geometryDecoded = tryAttempt({
9965
+ const spatialAttempt = {
8971
9966
  classifier: classifierFromPaletteRgb(normalizedPalette, "raw"),
8972
9967
  colorNormalization: "spatial-white-balanced"
8973
- }, normalizedGrid);
9968
+ };
9969
+ geometryDecoded = tryAttempt(spatialAttempt, normalizedGrid, {}, false);
9970
+ if (!geometryDecoded && options.softDecoding !== false) {
9971
+ geometryDecoded = tryAttempt(spatialAttempt, normalizedGrid, {}, true);
9972
+ }
8974
9973
  } catch {
8975
9974
  // Continue to the recovery profile below.
8976
9975
  }
@@ -8987,20 +9986,32 @@ function tryPerspectiveScan(imageData, options) {
8987
9986
  saturation: options.autoEnhanceSaturation
8988
9987
  });
8989
9988
  const enhancedPalette = sampleObservedPalette(enhancedGrid, layout.calibration, { robust: true });
8990
- for (const attempt of paletteClassifierAttempts(enhancedPalette)) {
8991
- const recoveredAttempt = {
8992
- ...attempt,
8993
- colorNormalization: `auto-tone-contrast-color/${attempt.colorNormalization}`
8994
- };
9989
+ const enhancedAttempts = paletteClassifierAttempts(enhancedPalette).map((attempt) => ({
9990
+ ...attempt,
9991
+ colorNormalization: `auto-tone-contrast-color/${attempt.colorNormalization}`
9992
+ }));
9993
+ for (const recoveredAttempt of enhancedAttempts) {
8995
9994
  if (tryAttempt(recoveredAttempt, enhancedGrid, {
8996
9995
  observedPalette: enhancedPalette,
8997
9996
  autoEnhanced: true,
8998
9997
  recoveryMode: "module-grid-auto-tone-contrast-color"
8999
- })) {
9998
+ }, false)) {
9000
9999
  geometryDecoded = true;
9001
10000
  break;
9002
10001
  }
9003
10002
  }
10003
+ if (!geometryDecoded && options.softDecoding !== false) {
10004
+ for (const recoveredAttempt of enhancedAttempts) {
10005
+ if (tryAttempt(recoveredAttempt, enhancedGrid, {
10006
+ observedPalette: enhancedPalette,
10007
+ autoEnhanced: true,
10008
+ recoveryMode: "module-grid-auto-tone-contrast-color"
10009
+ }, true)) {
10010
+ geometryDecoded = true;
10011
+ break;
10012
+ }
10013
+ }
10014
+ }
9004
10015
  } catch {
9005
10016
  // Continue to the QR-region pixel recovery below.
9006
10017
  }
@@ -9045,21 +10056,34 @@ function tryPerspectiveScan(imageData, options) {
9045
10056
  layout.calibration,
9046
10057
  { robust: true }
9047
10058
  );
9048
- for (const attempt of paletteClassifierAttempts(enhancedPalette)) {
9049
- const recoveredAttempt = {
9050
- ...attempt,
9051
- colorNormalization: `rectified-auto-tone-contrast-color/${attempt.colorNormalization}`
9052
- };
10059
+ const rectifiedAttempts = paletteClassifierAttempts(enhancedPalette).map((attempt) => ({
10060
+ ...attempt,
10061
+ colorNormalization: `rectified-auto-tone-contrast-color/${attempt.colorNormalization}`
10062
+ }));
10063
+ for (const recoveredAttempt of rectifiedAttempts) {
9053
10064
  if (tryAttempt(recoveredAttempt, enhancedSampled.rgbGrid, {
9054
10065
  observedPalette: enhancedPalette,
9055
10066
  samplingMode: "rectified-auto-enhance",
9056
10067
  autoEnhanced: true,
9057
10068
  recoveryMode: "rectified-auto-tone-contrast-color"
9058
- })) {
10069
+ }, false)) {
9059
10070
  geometryDecoded = true;
9060
10071
  break;
9061
10072
  }
9062
10073
  }
10074
+ if (!geometryDecoded && options.softDecoding !== false) {
10075
+ for (const recoveredAttempt of rectifiedAttempts) {
10076
+ if (tryAttempt(recoveredAttempt, enhancedSampled.rgbGrid, {
10077
+ observedPalette: enhancedPalette,
10078
+ samplingMode: "rectified-auto-enhance",
10079
+ autoEnhanced: true,
10080
+ recoveryMode: "rectified-auto-tone-contrast-color"
10081
+ }, true)) {
10082
+ geometryDecoded = true;
10083
+ break;
10084
+ }
10085
+ }
10086
+ }
9063
10087
  } catch {
9064
10088
  // Geometry refinement remains available as the final bounded fallback.
9065
10089
  }
@@ -9068,6 +10092,15 @@ function tryPerspectiveScan(imageData, options) {
9068
10092
  if (geometryDecoded) break;
9069
10093
  }
9070
10094
 
10095
+ // A decoded QuadQR has already passed structural validation, Spectrum ECC,
10096
+ // and the payload CRC. Continuing through every lower-ranked geometry after
10097
+ // that point used to spend most of the camera scan time proving the same
10098
+ // frame again. Return the first authenticated decode immediately. An opt-in
10099
+ // diagnostic mode can still collect every successful geometry if needed.
10100
+ if (geometryDecoded && options.collectAllGeometryResults !== true) {
10101
+ return results[results.length - 1] ?? null;
10102
+ }
10103
+
9071
10104
  // Slow-path geometry micro-refinement. Finder/alignment detection can be
9072
10105
  // correct while a soft-focus or smeared camera shifts the effective module
9073
10106
  // centres by a small fraction of a cell. Clean scans never reach this code.
@@ -9214,6 +10247,7 @@ function tryPerspectiveScan(imageData, options) {
9214
10247
  cellConfidence: candidate.classified.confidence,
9215
10248
  cellAlternatives: candidate.classified.alternatives,
9216
10249
  cellEncodingHint: candidate.cellEncoding,
10250
+ alignmentProfileHint: geometry.alignmentProfile ?? ALIGNMENT_PROFILE_STANDARD_5,
9217
10251
  maxErasureConfidence: options.maxErasureConfidence
9218
10252
  });
9219
10253
  if (decoded.version !== geometry.version) continue;
@@ -9242,6 +10276,10 @@ function tryPerspectiveScan(imageData, options) {
9242
10276
  }
9243
10277
  }
9244
10278
  }
10279
+
10280
+ if (geometryDecoded && options.collectAllGeometryResults !== true) {
10281
+ return results[results.length - 1] ?? null;
10282
+ }
9245
10283
  }
9246
10284
 
9247
10285
  results.sort((a, b) =>
@@ -10059,6 +11097,38 @@ function scanImageData(imageData, options = {}) {
10059
11097
  };
10060
11098
 
10061
11099
  if (options.perspective !== false) {
11100
+ const geometryHints = Array.isArray(options._geometryHints)
11101
+ ? options._geometryHints.filter((item) => item?.homography && Number.isInteger(item.version)).slice(0, 2)
11102
+ : [];
11103
+ if (geometryHints.length) {
11104
+ try {
11105
+ const hinted = tryPerspectiveScan(imageData, {
11106
+ ...scanOptions,
11107
+ _diagnosticLabel: options._diagnosticLabel ? `${options._diagnosticLabel}-geometry-reuse` : "geometry-reuse",
11108
+ _geometryCandidatesOverride: geometryHints,
11109
+ _geometryCollector: [],
11110
+ _observationCollector: [],
11111
+ adaptiveSampling: options._geometryReuseAdaptiveSampling ?? false,
11112
+ geometryRefinement: false
11113
+ });
11114
+ if (hinted) {
11115
+ geometryCollector.push(hinted.geometry ?? geometryHints[0]);
11116
+ return decorateScanResult({
11117
+ ...hinted,
11118
+ geometryReused: true,
11119
+ recoveryMode: hinted.recoveryMode ?? "geometry-reuse"
11120
+ }, debugContext, options);
11121
+ }
11122
+ } catch {
11123
+ // A stale geometry hint is expected when the camera/code moves. The
11124
+ // camera worker can request a hint-only attempt when it is reusing
11125
+ // low-resolution locator geometry on a higher-detail frame.
11126
+ }
11127
+ if (options._geometryHintOnly === true) {
11128
+ throw new Error("Geometry hint did not decode this frame.");
11129
+ }
11130
+ }
11131
+
10062
11132
  const perspective = tryPerspectiveScan(imageData, scanOptions);
10063
11133
  if (perspective) return decorateScanResult(perspective, debugContext, options);
10064
11134
  }
@@ -10384,6 +11454,21 @@ function scanVideoFrame(video, options = {}) {
10384
11454
  _visionDiagnostics: visionDiagnostics
10385
11455
  });
10386
11456
  normalizeFrameDiagnostics(options._frameDiagnostics, source, width, height, visionDiagnostics);
11457
+ if (options._frameDiagnostics && result?.geometry && !options._frameDiagnostics.geometry) {
11458
+ const geometry = result.geometry;
11459
+ options._frameDiagnostics.geometry = geometry;
11460
+ options._frameDiagnostics.geometryReused = Boolean(result.geometryReused);
11461
+ if (geometry.finders) {
11462
+ const reusedFinders = [
11463
+ geometry.finders.topLeft,
11464
+ geometry.finders.topRight,
11465
+ geometry.finders.bottomLeft
11466
+ ].filter(Boolean);
11467
+ options._frameDiagnostics.finders = reusedFinders;
11468
+ options._frameDiagnostics.finderCount = reusedFinders.length;
11469
+ if (result.geometryReused) options._frameDiagnostics.finderMethod = "geometry-reuse";
11470
+ }
11471
+ }
10387
11472
  if (!source.cropped) return result;
10388
11473
  return {
10389
11474
  ...result,
@@ -10536,7 +11621,7 @@ async function improveCameraTrack(stream) {
10536
11621
  }
10537
11622
  }
10538
11623
 
10539
- async function startCameraScanner(video, options = {}) {
11624
+ async function startCameraScannerMainThread(video, options = {}) {
10540
11625
  assert(typeof navigator !== "undefined" && navigator.mediaDevices?.getUserMedia, "Camera API is unavailable.");
10541
11626
  assert(video, "A video element is required.");
10542
11627
 
@@ -10545,8 +11630,8 @@ async function startCameraScanner(video, options = {}) {
10545
11630
  audio: false,
10546
11631
  video: {
10547
11632
  facingMode: { ideal: "environment" },
10548
- width: { ideal: 1920 },
10549
- height: { ideal: 1080 },
11633
+ width: { ideal: 1280 },
11634
+ height: { ideal: 720 },
10550
11635
  frameRate: { ideal: 30 }
10551
11636
  }
10552
11637
  }
@@ -10558,7 +11643,11 @@ async function startCameraScanner(video, options = {}) {
10558
11643
  video.muted = true;
10559
11644
  await video.play();
10560
11645
 
10561
- const scanInterval = Math.max(80, options.scanInterval ?? 180);
11646
+ // Keep scanning responsive without queueing stale camera frames. The old
11647
+ // 180 ms post-scan timeout made effective cadence equal scan time + 180 ms.
11648
+ // The scheduler below measures from scan start and uses real video frames
11649
+ // when requestVideoFrameCallback() is available.
11650
+ const scanInterval = Math.max(24, Number(options.scanInterval ?? 80));
10562
11651
  const scratchCanvas = document.createElement("canvas");
10563
11652
  const highResolutionCanvas = document.createElement("canvas");
10564
11653
  const multiFrameEnabled = options.multiFrame !== false;
@@ -10569,16 +11658,23 @@ async function startCameraScanner(video, options = {}) {
10569
11658
  const cameraAutoEnhanceEvery = Math.max(1, Math.round(options.cameraAutoEnhanceEvery ?? 2));
10570
11659
  const cameraFinderRecoveryEvery = Math.max(1, Math.round(options.cameraFinderRecoveryEvery ?? 2));
10571
11660
  const cameraHighResolutionEvery = Math.max(1, Math.round(options.cameraHighResolutionEvery ?? 2));
10572
- const baseCameraMaxDimension = Math.max(480, Math.round(options.maxDimension ?? 1080));
11661
+ const baseCameraMaxDimension = Math.max(480, Math.round(options.maxDimension ?? 640));
10573
11662
  const cameraHighResolutionMaxDimension = Math.max(
10574
11663
  baseCameraMaxDimension,
10575
- Math.round(options.cameraHighResolutionMaxDimension ?? 1600)
11664
+ Math.round(options.cameraHighResolutionMaxDimension ?? 960)
10576
11665
  );
10577
11666
  let missStreak = 0;
10578
11667
  let stopped = false;
10579
11668
  let busy = false;
10580
11669
  let timer = null;
11670
+ let frameCallbackId = null;
11671
+ let lastScanStartedAt = -Infinity;
10581
11672
  let frameNumber = 0;
11673
+ let cameraGeometryHint = null;
11674
+ let cameraGeometryHintMisses = 0;
11675
+ const cameraGeometryReuseMaxMisses = Math.max(1, Math.round(options.cameraGeometryReuseMaxMisses ?? 5));
11676
+ const useVideoFrameCallback = options.useVideoFrameCallback !== false &&
11677
+ typeof video.requestVideoFrameCallback === "function";
10582
11678
 
10583
11679
  const diagnosticsEnabled = typeof options.onDiagnostic === "function";
10584
11680
  const emitDiagnostic = (event) => {
@@ -10613,6 +11709,12 @@ async function startCameraScanner(video, options = {}) {
10613
11709
  const stop = () => {
10614
11710
  stopped = true;
10615
11711
  if (timer) clearTimeout(timer);
11712
+ if (frameCallbackId != null && typeof video.cancelVideoFrameCallback === "function") {
11713
+ try { video.cancelVideoFrameCallback(frameCallbackId); } catch {}
11714
+ }
11715
+ timer = null;
11716
+ frameCallbackId = null;
11717
+ cameraGeometryHint = null;
10616
11718
  observationHistory.clear();
10617
11719
  for (const track of stream.getTracks()) track.stop();
10618
11720
  if (video.srcObject === stream) video.srcObject = null;
@@ -10621,9 +11723,30 @@ async function startCameraScanner(video, options = {}) {
10621
11723
  const scanNow = () => scanVideoFrame(video, {
10622
11724
  ...options,
10623
11725
  maxDimension: baseCameraMaxDimension,
10624
- canvas: scratchCanvas
11726
+ canvas: scratchCanvas,
11727
+ _geometryHints: options.cameraGeometryReuse === false || !cameraGeometryHint ? undefined : [cameraGeometryHint]
10625
11728
  });
10626
11729
 
11730
+ const updateCameraGeometryHint = (frameDiagnostics, result = null) => {
11731
+ if (options.cameraGeometryReuse === false) {
11732
+ cameraGeometryHint = null;
11733
+ return;
11734
+ }
11735
+ const geometry = result?.geometry ?? frameDiagnostics?.geometry ?? null;
11736
+ if (geometry?.homography && Number.isInteger(geometry.version)) {
11737
+ cameraGeometryHint = geometry;
11738
+ cameraGeometryHintMisses = 0;
11739
+ return;
11740
+ }
11741
+ if (cameraGeometryHint) {
11742
+ cameraGeometryHintMisses++;
11743
+ if (cameraGeometryHintMisses >= cameraGeometryReuseMaxMisses) {
11744
+ cameraGeometryHint = null;
11745
+ cameraGeometryHintMisses = 0;
11746
+ }
11747
+ }
11748
+ };
11749
+
10627
11750
  const emitResult = (result, capturedFrame = null, diagnostic = null) => {
10628
11751
  const frameMeta = capturedFrame?.imageData ? {
10629
11752
  frame: frameNumber,
@@ -10701,6 +11824,33 @@ async function startCameraScanner(video, options = {}) {
10701
11824
  }
10702
11825
  };
10703
11826
 
11827
+ const scheduleNextScan = () => {
11828
+ if (stopped) return;
11829
+ const runWhenDue = () => {
11830
+ frameCallbackId = null;
11831
+ if (stopped) return;
11832
+ const remaining = scanInterval - (nowMs() - lastScanStartedAt);
11833
+ if (remaining > 1) {
11834
+ timer = setTimeout(() => {
11835
+ timer = null;
11836
+ scheduleNextScan();
11837
+ }, remaining);
11838
+ return;
11839
+ }
11840
+ void loop();
11841
+ };
11842
+
11843
+ if (useVideoFrameCallback) {
11844
+ frameCallbackId = video.requestVideoFrameCallback(runWhenDue);
11845
+ } else {
11846
+ const remaining = Math.max(0, scanInterval - (nowMs() - lastScanStartedAt));
11847
+ timer = setTimeout(() => {
11848
+ timer = null;
11849
+ runWhenDue();
11850
+ }, remaining);
11851
+ }
11852
+ };
11853
+
10704
11854
  const loop = async () => {
10705
11855
  if (stopped) return;
10706
11856
  if (!busy && video.readyState >= 2) {
@@ -10710,6 +11860,7 @@ async function startCameraScanner(video, options = {}) {
10710
11860
  const frameDiagnostics = {};
10711
11861
  const capturedFrame = {};
10712
11862
  const frameStarted = nowMs();
11863
+ lastScanStartedAt = frameStarted;
10713
11864
  let allowAutoEnhance = false;
10714
11865
  let allowFinderRecovery = false;
10715
11866
  try {
@@ -10737,11 +11888,13 @@ async function startCameraScanner(video, options = {}) {
10737
11888
  fullFrameAutoEnhanceRecovery: options.fullFrameAutoEnhanceRecovery ?? false,
10738
11889
  maxDimension: baseCameraMaxDimension,
10739
11890
  canvas: scratchCanvas,
11891
+ _geometryHints: options.cameraGeometryReuse === false || !cameraGeometryHint ? undefined : [cameraGeometryHint],
10740
11892
  _capturedFrame: capturedFrame,
10741
11893
  _observationCollector: observations,
10742
11894
  _frameDiagnostics: frameDiagnostics
10743
11895
  });
10744
11896
  const elapsedMs = nowMs() - frameStarted;
11897
+ updateCameraGeometryHint(frameDiagnostics, result);
10745
11898
  emitDiagnostic({
10746
11899
  type: "frame",
10747
11900
  state: "decoded",
@@ -10763,6 +11916,7 @@ async function startCameraScanner(video, options = {}) {
10763
11916
  if (emitResult(result, capturedFrame, frameDiagnostics)) return;
10764
11917
  } catch (error) {
10765
11918
  missStreak++;
11919
+ updateCameraGeometryHint(frameDiagnostics);
10766
11920
  const fastElapsedMs = nowMs() - frameStarted;
10767
11921
  emitDiagnostic({
10768
11922
  type: "frame",
@@ -10778,7 +11932,7 @@ async function startCameraScanner(video, options = {}) {
10778
11932
 
10779
11933
  // Geometry-aware high-resolution retry. A dense QuadQR can look large
10780
11934
  // enough in the preview while each individual module has become too
10781
- // small after the normal 1080 px scanner cap. If the fast pass already
11935
+ // small after the normal 640 px scanner cap. If the fast pass already
10782
11936
  // sees at least two convincing finders, spend one bounded retry on a
10783
11937
  // higher-resolution copy of the visible camera ROI. Empty frames and
10784
11938
  // ordinary small codes never pay this cost.
@@ -11084,13 +12238,569 @@ async function startCameraScanner(video, options = {}) {
11084
12238
  busy = false;
11085
12239
  }
11086
12240
  }
11087
- timer = setTimeout(loop, scanInterval);
12241
+ scheduleNextScan();
11088
12242
  };
11089
12243
 
11090
- timer = setTimeout(loop, 0);
12244
+ scheduleNextScan();
11091
12245
  return { stream, stop, scanNow, video };
11092
12246
  }
11093
12247
 
12248
+ function cameraWorkerSupported(options = {}) {
12249
+ if (options.cameraWorker === false) return false;
12250
+ return typeof Worker === "function" &&
12251
+ typeof createImageBitmap === "function" &&
12252
+ typeof OffscreenCanvas === "function";
12253
+ }
12254
+
12255
+ function serializableCameraWorkerOptions(options = {}) {
12256
+ const skip = new Set([
12257
+ "canvas",
12258
+ "constraints",
12259
+ "onDecode",
12260
+ "onDiagnostic",
12261
+ "onResult",
12262
+ "onScanMiss",
12263
+ "cameraWorkerUrl"
12264
+ ]);
12265
+ const out = {};
12266
+ for (const [key, value] of Object.entries(options)) {
12267
+ if (skip.has(key) || typeof value === "function" || value == null) continue;
12268
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
12269
+ out[key] = value;
12270
+ continue;
12271
+ }
12272
+ if (Array.isArray(value)) {
12273
+ out[key] = value.map((item) => {
12274
+ if (item && typeof item === "object") return { ...item };
12275
+ return item;
12276
+ });
12277
+ continue;
12278
+ }
12279
+ if (Object.getPrototypeOf(value) === Object.prototype) out[key] = { ...value };
12280
+ }
12281
+ return out;
12282
+ }
12283
+
12284
+ function resolveCameraWorkerUrl(options = {}) {
12285
+ if (options.cameraWorkerUrl) {
12286
+ return new URL(
12287
+ options.cameraWorkerUrl,
12288
+ typeof document !== "undefined" ? document.baseURI : (__qqrScriptSrc || (typeof location !== 'undefined' ? location.href : ''))
12289
+ );
12290
+ }
12291
+ return new URL("./camera-scanner-worker.js", (__qqrScriptSrc || (typeof location !== 'undefined' ? location.href : '')));
12292
+ }
12293
+
12294
+ async function initializeCameraWorker(options = {}) {
12295
+ const worker = new Worker(resolveCameraWorkerUrl(options), {
12296
+ type: "module",
12297
+ name: "quadqr-camera-scanner"
12298
+ });
12299
+ let sequence = 0;
12300
+ const pending = new Map();
12301
+ let fatalError = null;
12302
+
12303
+ const rejectPending = (error) => {
12304
+ fatalError = error instanceof Error ? error : new Error(String(error));
12305
+ for (const { reject } of pending.values()) reject(fatalError);
12306
+ pending.clear();
12307
+ };
12308
+
12309
+ worker.addEventListener("message", (event) => {
12310
+ const message = event.data ?? {};
12311
+ const entry = pending.get(message.id);
12312
+ if (!entry) return;
12313
+ pending.delete(message.id);
12314
+ if (message.ok) entry.resolve(message.result);
12315
+ else {
12316
+ const error = new Error(message.error?.message ?? "QuadQR camera worker failed.");
12317
+ error.name = message.error?.name ?? "Error";
12318
+ error.stack = message.error?.stack ?? error.stack;
12319
+ error.debug = message.error?.debug ?? null;
12320
+ entry.reject(error);
12321
+ }
12322
+ });
12323
+ worker.addEventListener("error", (event) => {
12324
+ rejectPending(new Error(event?.message || "QuadQR camera worker crashed."));
12325
+ });
12326
+ worker.addEventListener("messageerror", () => {
12327
+ rejectPending(new Error("QuadQR camera worker returned an unreadable message."));
12328
+ });
12329
+
12330
+ const request = (type, payload = {}, transfer = []) => {
12331
+ if (fatalError) return Promise.reject(fatalError);
12332
+ const id = `qqr-camera-${++sequence}`;
12333
+ return new Promise((resolve, reject) => {
12334
+ pending.set(id, { resolve, reject });
12335
+ try {
12336
+ worker.postMessage({ id, type, ...payload }, transfer);
12337
+ } catch (error) {
12338
+ pending.delete(id);
12339
+ reject(error);
12340
+ }
12341
+ });
12342
+ };
12343
+
12344
+ try {
12345
+ const state = await request("init", { options: serializableCameraWorkerOptions(options) });
12346
+ if (!state?.offscreenCanvas) throw new Error("OffscreenCanvas is unavailable in the QuadQR camera worker.");
12347
+ return {
12348
+ worker,
12349
+ state,
12350
+ request,
12351
+ terminate() {
12352
+ rejectPending(new Error("QuadQR camera worker stopped."));
12353
+ worker.terminate();
12354
+ }
12355
+ };
12356
+ } catch (error) {
12357
+ worker.terminate();
12358
+ throw error;
12359
+ }
12360
+ }
12361
+
12362
+ async function captureCameraBitmap(video, source, maxDimension) {
12363
+ const cap = Math.max(1, Math.round(maxDimension));
12364
+ const videoWidth = Math.max(1, Math.round(video.videoWidth || source.width || 1));
12365
+ const videoHeight = Math.max(1, Math.round(video.videoHeight || source.height || 1));
12366
+ const sx = clampNumber(Math.round(source.x || 0), 0, Math.max(0, videoWidth - 1));
12367
+ const sy = clampNumber(Math.round(source.y || 0), 0, Math.max(0, videoHeight - 1));
12368
+ const sw = Math.max(1, Math.min(videoWidth - sx, Math.round(source.width || videoWidth)));
12369
+ const sh = Math.max(1, Math.min(videoHeight - sy, Math.round(source.height || videoHeight)));
12370
+ const scale = Math.min(1, cap / Math.max(sw, sh));
12371
+ const width = Math.max(1, Math.round(sw * scale));
12372
+ const height = Math.max(1, Math.round(sh * scale));
12373
+
12374
+ // Crop and resize before crossing the worker boundary. Previously every
12375
+ // 640px scan transferred a full 1080p camera bitmap and only then shrank it
12376
+ // inside OffscreenCanvas. On phones that creates unnecessary GPU/memory
12377
+ // pressure and can delay fresh-frame acquisition even though decoding is
12378
+ // off-thread. The fallback preserves compatibility with browsers that do not
12379
+ // implement the resize overload for video-backed ImageBitmap creation.
12380
+ try {
12381
+ const bitmap = await createImageBitmap(video, sx, sy, sw, sh, {
12382
+ resizeWidth: width,
12383
+ resizeHeight: height,
12384
+ resizeQuality: "medium"
12385
+ });
12386
+ return {
12387
+ bitmap,
12388
+ source: { x: 0, y: 0, width: bitmap.width, height: bitmap.height, cropped: Boolean(source.cropped) },
12389
+ originalSource: { ...source },
12390
+ preScaled: true
12391
+ };
12392
+ } catch {
12393
+ const bitmap = await createImageBitmap(video);
12394
+ return {
12395
+ bitmap,
12396
+ source: { ...source },
12397
+ originalSource: { ...source },
12398
+ preScaled: false
12399
+ };
12400
+ }
12401
+ }
12402
+
12403
+ function maximumFinderCount(workerResult) {
12404
+ let count = 0;
12405
+ for (const diagnostic of workerResult?.diagnostics ?? []) {
12406
+ count = Math.max(
12407
+ count,
12408
+ Number(diagnostic?.finderCount) || 0,
12409
+ Number(diagnostic?.bestPass?.finderCount) || 0
12410
+ );
12411
+ for (const pass of diagnostic?.finderPasses ?? []) {
12412
+ count = Math.max(count, Number(pass?.finderCount) || 0);
12413
+ }
12414
+ }
12415
+ return count;
12416
+ }
12417
+
12418
+ async function startCameraScannerWorker(video, options = {}) {
12419
+ assert(typeof navigator !== "undefined" && navigator.mediaDevices?.getUserMedia, "Camera API is unavailable.");
12420
+ assert(video, "A video element is required.");
12421
+
12422
+ // Keep fresh-frame scanning independent from the expensive damaged/color
12423
+ // recovery pipeline. Finder detection itself remains JavaScript; WASM is
12424
+ // only an optional grayscale/binary + CRC accelerator beneath both workers.
12425
+ // The fast worker can therefore inspect the newest frame even while the
12426
+ // recovery worker is spending hundreds of milliseconds on an older difficult
12427
+ // frame. No recovery method is removed.
12428
+ const fastWorkerOptions = {
12429
+ ...options,
12430
+ cameraPipelineMode: "fast",
12431
+ cameraHighResolutionRecovery: false,
12432
+ cameraAutoColorRecovery: false,
12433
+ autoEnhanceRecovery: false,
12434
+ fullFrameAutoEnhanceRecovery: false,
12435
+ multiFrame: false
12436
+ };
12437
+ const fastWorkerClient = await initializeCameraWorker(fastWorkerOptions);
12438
+
12439
+ let stream = null;
12440
+ try {
12441
+ stream = await navigator.mediaDevices.getUserMedia(
12442
+ options.constraints ?? {
12443
+ audio: false,
12444
+ video: {
12445
+ facingMode: { ideal: "environment" },
12446
+ width: { ideal: 1280 },
12447
+ height: { ideal: 720 },
12448
+ frameRate: { ideal: 30 }
12449
+ }
12450
+ }
12451
+ );
12452
+ await improveCameraTrack(stream);
12453
+
12454
+ video.srcObject = stream;
12455
+ video.setAttribute("playsinline", "");
12456
+ video.muted = true;
12457
+ await video.play();
12458
+ } catch (error) {
12459
+ fastWorkerClient.terminate();
12460
+ for (const track of stream?.getTracks?.() ?? []) track.stop();
12461
+ if (video.srcObject === stream) video.srcObject = null;
12462
+ throw error;
12463
+ }
12464
+
12465
+ const scanInterval = Math.max(24, Number(options.scanInterval ?? 33));
12466
+ const fastCaptureMaxDimension = Math.max(480, Math.round(options.maxDimension ?? 640));
12467
+ const recoveryCaptureMaxDimension = Math.max(
12468
+ fastCaptureMaxDimension,
12469
+ Math.round(options.cameraHighResolutionMaxDimension ?? 960)
12470
+ );
12471
+ const recoveryStrongFinderInterval = Math.max(80, Number(options.cameraRecoveryStrongFinderInterval ?? 120));
12472
+ const recoveryWeakFinderInterval = Math.max(recoveryStrongFinderInterval, Number(options.cameraRecoveryWeakFinderInterval ?? 260));
12473
+ const recoveryNoFinderInterval = Math.max(recoveryWeakFinderInterval, Number(options.cameraRecoveryNoFinderInterval ?? 850));
12474
+ const useVideoFrameCallback = options.useVideoFrameCallback !== false &&
12475
+ typeof video.requestVideoFrameCallback === "function";
12476
+
12477
+ let stopped = false;
12478
+ let busy = false;
12479
+ let recoveryBusy = false;
12480
+ let recoveryWorkerClient = null;
12481
+ let recoveryWorkerPromise = null;
12482
+ let recoveryWorkerFailed = false;
12483
+ let timer = null;
12484
+ let frameCallbackId = null;
12485
+ let lastScanStartedAt = -Infinity;
12486
+ let lastRecoveryStartedAt = -Infinity;
12487
+ let frameNumber = 0;
12488
+ let requestToken = 0;
12489
+ let recoveryToken = 0;
12490
+
12491
+ const diagnosticsEnabled = typeof options.onDiagnostic === "function";
12492
+ const emitDiagnostic = (event) => {
12493
+ if (!diagnosticsEnabled) return;
12494
+ try {
12495
+ options.onDiagnostic({
12496
+ timestamp: Date.now(),
12497
+ frame: event?.frame ?? frameNumber,
12498
+ cameraWorker: true,
12499
+ ...event
12500
+ });
12501
+ } catch {
12502
+ // Diagnostics are UI-only and must never interrupt scanning.
12503
+ }
12504
+ };
12505
+
12506
+ const ensureRecoveryWorker = async () => {
12507
+ if (recoveryWorkerClient) return recoveryWorkerClient;
12508
+ if (recoveryWorkerFailed) return null;
12509
+ if (!recoveryWorkerPromise) {
12510
+ recoveryWorkerPromise = initializeCameraWorker({ ...options, cameraPipelineMode: "full" })
12511
+ .then((client) => {
12512
+ if (stopped) {
12513
+ client.terminate();
12514
+ return null;
12515
+ }
12516
+ recoveryWorkerClient = client;
12517
+ return client;
12518
+ })
12519
+ .catch((error) => {
12520
+ recoveryWorkerFailed = true;
12521
+ emitDiagnostic({
12522
+ type: "recovery-worker-error",
12523
+ state: "fallback",
12524
+ method: "camera-fast-worker",
12525
+ message: `Parallel recovery worker unavailable · fast scanner remains active (${error?.message ?? String(error)})`
12526
+ });
12527
+ return null;
12528
+ })
12529
+ .finally(() => {
12530
+ recoveryWorkerPromise = null;
12531
+ });
12532
+ }
12533
+ return recoveryWorkerPromise;
12534
+ };
12535
+
12536
+ const track = stream.getVideoTracks?.()[0];
12537
+ const settings = track?.getSettings?.() ?? {};
12538
+ emitDiagnostic({
12539
+ type: "camera-ready",
12540
+ method: "camera-dual-worker",
12541
+ message: `Camera ready · ${settings.width ?? video.videoWidth}×${settings.height ?? video.videoHeight} · fast fresh-frame scanner + parallel recovery`,
12542
+ camera: {
12543
+ width: settings.width ?? video.videoWidth,
12544
+ height: settings.height ?? video.videoHeight,
12545
+ frameRate: settings.frameRate ?? null,
12546
+ facingMode: settings.facingMode ?? null
12547
+ },
12548
+ worker: fastWorkerClient.state,
12549
+ scanMaxDimension: fastCaptureMaxDimension,
12550
+ recoveryMaxDimension: recoveryCaptureMaxDimension
12551
+ });
12552
+
12553
+ const stop = () => {
12554
+ if (stopped) return;
12555
+ stopped = true;
12556
+ requestToken++;
12557
+ recoveryToken++;
12558
+ if (timer) clearTimeout(timer);
12559
+ if (frameCallbackId != null && typeof video.cancelVideoFrameCallback === "function") {
12560
+ try { video.cancelVideoFrameCallback(frameCallbackId); } catch {}
12561
+ }
12562
+ timer = null;
12563
+ frameCallbackId = null;
12564
+ fastWorkerClient.terminate();
12565
+ if (recoveryWorkerClient) {
12566
+ recoveryWorkerClient.terminate();
12567
+ recoveryWorkerClient = null;
12568
+ } else if (recoveryWorkerPromise) {
12569
+ void recoveryWorkerPromise.then((client) => client?.terminate()).catch(() => {});
12570
+ }
12571
+ for (const cameraTrack of stream.getTracks()) cameraTrack.stop();
12572
+ if (video.srcObject === stream) video.srcObject = null;
12573
+ };
12574
+
12575
+ // Preserve the historical immediate/manual helper as a synchronous scan of
12576
+ // the current video element. The continuous scanner itself stays off-thread.
12577
+ const scanNow = () => scanVideoFrame(video, {
12578
+ ...options,
12579
+ maxDimension: fastCaptureMaxDimension
12580
+ });
12581
+
12582
+ const emitResult = (result, frameMeta = null) => {
12583
+ if (stopped) return true;
12584
+ const normalizedMeta = frameMeta
12585
+ ? { frame: frameMeta.frame ?? frameNumber, ...frameMeta }
12586
+ : null;
12587
+ options.onResult?.(result, normalizedMeta);
12588
+ options.onDecode?.(result, normalizedMeta);
12589
+ if (options.stopOnResult ?? true) {
12590
+ stop();
12591
+ return true;
12592
+ }
12593
+ return false;
12594
+ };
12595
+
12596
+ const runRecovery = async (triggerFrame, finderCount) => {
12597
+ if (stopped || recoveryBusy) return;
12598
+ recoveryBusy = true;
12599
+ lastRecoveryStartedAt = nowMs();
12600
+ const token = ++recoveryToken;
12601
+ let bitmap = null;
12602
+ try {
12603
+ const client = await ensureRecoveryWorker();
12604
+ if (stopped || token !== recoveryToken) return;
12605
+ const recoveryClient = client ?? fastWorkerClient;
12606
+ const singleWorkerFallback = !client;
12607
+
12608
+ // Capture only after the recovery execution path is ready. This guarantees
12609
+ // the expensive path receives a fresh frame rather than a bitmap that sat
12610
+ // in memory while a recovery worker was starting.
12611
+ const visibleSource = visibleVideoSourceRect(video, options);
12612
+ const captured = await captureCameraBitmap(video, visibleSource, recoveryCaptureMaxDimension);
12613
+ bitmap = captured.bitmap;
12614
+ if (stopped || token !== recoveryToken) {
12615
+ bitmap.close?.();
12616
+ return;
12617
+ }
12618
+
12619
+ emitDiagnostic({
12620
+ type: "recovery-dispatch",
12621
+ state: "trying",
12622
+ method: "parallel-full-recovery",
12623
+ frame: triggerFrame,
12624
+ finderCount,
12625
+ message: finderCount > 0
12626
+ ? `Fast frame saw ${finderCount} finder${finderCount === 1 ? "" : "s"} · full recovery running in parallel`
12627
+ : "Periodic full recovery running in parallel while fast fresh-frame scanning continues"
12628
+ });
12629
+
12630
+ const recoveryPayload = { bitmap, source: captured.source, frame: triggerFrame };
12631
+ if (singleWorkerFallback) recoveryPayload.options = serializableCameraWorkerOptions(options);
12632
+ const workerResult = await recoveryClient.request(
12633
+ singleWorkerFallback ? "scan-full" : "scan",
12634
+ recoveryPayload,
12635
+ [bitmap]
12636
+ );
12637
+ bitmap = null;
12638
+ if (stopped || token !== recoveryToken) return;
12639
+
12640
+ for (const diagnostic of workerResult?.diagnostics ?? []) {
12641
+ emitDiagnostic({
12642
+ ...diagnostic,
12643
+ recoveryWorker: !singleWorkerFallback,
12644
+ singleWorkerRecoveryFallback: singleWorkerFallback,
12645
+ frame: triggerFrame
12646
+ });
12647
+ }
12648
+ if (workerResult?.ok) {
12649
+ emitResult(workerResult.result, { ...workerResult.frameMeta, frame: triggerFrame });
12650
+ }
12651
+ } catch (error) {
12652
+ try { bitmap?.close?.(); } catch {}
12653
+ if (!stopped) {
12654
+ emitDiagnostic({
12655
+ type: "recovery-worker-error",
12656
+ state: "error",
12657
+ method: "parallel-full-recovery",
12658
+ frame: triggerFrame,
12659
+ message: error?.message ?? String(error)
12660
+ });
12661
+ }
12662
+ } finally {
12663
+ recoveryBusy = false;
12664
+ }
12665
+ };
12666
+
12667
+ const maybeDispatchRecovery = (workerResult, triggerFrame) => {
12668
+ if (stopped || recoveryBusy) return;
12669
+ const finderCount = maximumFinderCount(workerResult);
12670
+ const elapsed = nowMs() - lastRecoveryStartedAt;
12671
+ const minimumInterval = finderCount >= 2
12672
+ ? recoveryStrongFinderInterval
12673
+ : finderCount === 1
12674
+ ? recoveryWeakFinderInterval
12675
+ : recoveryNoFinderInterval;
12676
+ if (elapsed >= minimumInterval) void runRecovery(triggerFrame, finderCount);
12677
+ };
12678
+
12679
+ const scheduleNextScan = () => {
12680
+ if (stopped) return;
12681
+ const runWhenDue = () => {
12682
+ frameCallbackId = null;
12683
+ if (stopped) return;
12684
+ const remaining = scanInterval - (nowMs() - lastScanStartedAt);
12685
+ if (remaining > 1) {
12686
+ timer = setTimeout(() => {
12687
+ timer = null;
12688
+ scheduleNextScan();
12689
+ }, remaining);
12690
+ return;
12691
+ }
12692
+ void loop();
12693
+ };
12694
+
12695
+ if (useVideoFrameCallback) {
12696
+ frameCallbackId = video.requestVideoFrameCallback(runWhenDue);
12697
+ } else {
12698
+ const remaining = Math.max(0, scanInterval - (nowMs() - lastScanStartedAt));
12699
+ timer = setTimeout(() => {
12700
+ timer = null;
12701
+ runWhenDue();
12702
+ }, remaining);
12703
+ }
12704
+ };
12705
+
12706
+ const loop = async () => {
12707
+ if (stopped) return;
12708
+ if (!busy && video.readyState >= 2) {
12709
+ busy = true;
12710
+ frameNumber++;
12711
+ const currentFrame = frameNumber;
12712
+ lastScanStartedAt = nowMs();
12713
+ const token = ++requestToken;
12714
+ let bitmap = null;
12715
+ try {
12716
+ const visibleSource = visibleVideoSourceRect(video, options);
12717
+ const captured = await captureCameraBitmap(video, visibleSource, fastCaptureMaxDimension);
12718
+ bitmap = captured.bitmap;
12719
+ if (stopped || token !== requestToken) {
12720
+ bitmap.close?.();
12721
+ return;
12722
+ }
12723
+ const workerResult = await fastWorkerClient.request(
12724
+ "scan",
12725
+ { bitmap, source: captured.source, frame: currentFrame },
12726
+ [bitmap]
12727
+ );
12728
+ bitmap = null;
12729
+ if (stopped || token !== requestToken) return;
12730
+
12731
+ for (const diagnostic of workerResult?.diagnostics ?? []) {
12732
+ emitDiagnostic({ ...diagnostic, fastWorker: true, frame: currentFrame });
12733
+ }
12734
+ if (workerResult?.ok) {
12735
+ if (emitResult(workerResult.result, { ...workerResult.frameMeta, frame: currentFrame })) return;
12736
+ } else {
12737
+ // Full perspective/color/damage recovery runs independently. Do not
12738
+ // await it here: the next camera callback must remain free to inspect
12739
+ // a newer frame immediately.
12740
+ maybeDispatchRecovery(workerResult, currentFrame);
12741
+ const error = new Error(workerResult?.error?.message ?? "Unable to decode QuadQR frame.");
12742
+ error.name = workerResult?.error?.name ?? "Error";
12743
+ error.debug = workerResult?.error?.debug ?? null;
12744
+ options.onScanMiss?.(error);
12745
+ }
12746
+ } catch (error) {
12747
+ try { bitmap?.close?.(); } catch {}
12748
+ if (!stopped) {
12749
+ emitDiagnostic({
12750
+ type: "worker-error",
12751
+ state: "error",
12752
+ method: "camera-fast-worker",
12753
+ frame: currentFrame,
12754
+ message: error?.message ?? String(error)
12755
+ });
12756
+ options.onScanMiss?.(error);
12757
+ }
12758
+ } finally {
12759
+ busy = false;
12760
+ }
12761
+ }
12762
+ scheduleNextScan();
12763
+ };
12764
+
12765
+ scheduleNextScan();
12766
+ return {
12767
+ stream,
12768
+ stop,
12769
+ scanNow,
12770
+ video,
12771
+ worker: true,
12772
+ workerMode: "dual-pipeline",
12773
+ workerState: fastWorkerClient.state
12774
+ };
12775
+ }
12776
+
12777
+ /**
12778
+ * Start continuous camera scanning. Modern browsers use a dedicated module
12779
+ * worker by default so the complete recovery pipeline can remain enabled
12780
+ * without blocking rendering/input. Unsupported/CSP-restricted environments
12781
+ * automatically fall back to the original main-thread scanner.
12782
+ */
12783
+ async function startCameraScanner(video, options = {}) {
12784
+ if (cameraWorkerSupported(options)) {
12785
+ try {
12786
+ return await startCameraScannerWorker(video, options);
12787
+ } catch (error) {
12788
+ if (options.cameraWorkerRequired) throw error;
12789
+ try {
12790
+ options.onDiagnostic?.({
12791
+ timestamp: Date.now(),
12792
+ frame: 0,
12793
+ type: "worker-fallback",
12794
+ state: "fallback",
12795
+ method: "camera-main-thread",
12796
+ message: `Background scanner unavailable · using main-thread fallback (${error?.message ?? String(error)})`
12797
+ });
12798
+ } catch {}
12799
+ }
12800
+ }
12801
+ return startCameraScannerMainThread(video, options);
12802
+ }
12803
+
11094
12804
  function rectifyDetectedCode(imageData, options = {}) {
11095
12805
  const candidates = detectCodeGeometry(imageData, {
11096
12806
  minVersion: options.minVersion ?? MIN_VERSION,
@@ -11154,7 +12864,7 @@ const internals = Object.freeze({
11154
12864
  SECURE_FLAG
11155
12865
  });
11156
12866
 
11157
- return { compressPayload, decompressPayload, compressDeflatePayload, decompressDeflatePayload, compressBrotliPayload, decompressBrotliPayload, deriveSigningKeyId, generateSigningKeyPair, installCrc32Accelerator, crc32, getVersionInfo, encodeText, encodeBytes, encodeUint8Array, encodeSignedBytes, encodeSignedText, encodeSecureText, encodeSecureBytes, decryptDecoded, decodeMatrix, decodeUint8Array, verifyDecodedSignature, estimateSafeLogoSize, findMaxSafeLogoSize, getPrintGuidance, renderToCanvas, renderToImageData, renderToSVG, applyStressDistortion, runImageStressTest, runReliabilityLab, runPerspectiveSweep, assessScanability, debugScanImageData, scanImageData, scanFile, scanVideoFrame, startCameraScanner, rectifyDetectedCode, rotateMatrix, FORMAT_VERSION, MIN_VERSION, MAX_VERSION, DEFAULT_ECC_LEVEL, RENDER_MODES, CELL_ENCODINGS, PRINT_PALETTE, COMPRESSION_MODES, LZ_LEVEL_MIN, LZ_LEVEL_MAX, DEFAULT_LZ_LEVEL, COMPRESSION_LEVELS, SIGNATURE_ALGORITHMS, CELL, DEFAULT_PALETTE, RENDER_STYLES, ECC_LEVELS, STRESS_PROFILES, RELIABILITY_PROFILES, internals, SECURITY_MODES, SECURITY_ALGORITHMS, SECURE_PAYLOAD_VERSION, DEFAULT_PBKDF2_ITERATIONS, generateRaw256Key, normalizeRaw256Key, bytesToHex };
12867
+ return { compressPayload, decompressPayload, compressDeflatePayload, decompressDeflatePayload, compressBrotliPayload, decompressBrotliPayload, deriveSigningKeyId, generateSigningKeyPair, installCrc32Accelerator, crc32, getVersionInfo, encodeText, encodeBytes, encodeUint8Array, encodeSignedBytes, encodeSignedText, encodeSecureText, encodeSecureBytes, decryptDecoded, decodeMatrix, decodeUint8Array, verifyDecodedSignature, estimateSafeLogoSize, findMaxSafeLogoSize, getPrintGuidance, renderToCanvas, renderToImageData, renderToSVG, applyStressDistortion, runImageStressTest, runReliabilityLab, runPerspectiveSweep, assessScanability, debugScanImageData, scanImageData, scanFile, scanVideoFrame, startCameraScanner, rectifyDetectedCode, rotateMatrix, FORMAT_VERSION, LEGACY_FORMAT_VERSION, MIN_VERSION, MAX_VERSION, DEFAULT_ECC_LEVEL, RENDER_MODES, CELL_ENCODINGS, PRINT_PALETTE, COMPRESSION_MODES, LZ_LEVEL_MIN, LZ_LEVEL_MAX, DEFAULT_LZ_LEVEL, COMPRESSION_LEVELS, SIGNATURE_ALGORITHMS, CELL, DEFAULT_PALETTE, RENDER_STYLES, ECC_LEVELS, STRESS_PROFILES, RELIABILITY_PROFILES, internals, SECURITY_MODES, SECURITY_ALGORITHMS, SECURE_PAYLOAD_VERSION, DEFAULT_PBKDF2_ITERATIONS, generateRaw256Key, normalizeRaw256Key, bytesToHex };
11158
12868
  })();
11159
12869
  const QuadQR = __qqr_quadqr_js;
11160
12870
 
@@ -11175,19 +12885,67 @@ QuadQR.initWasm = async function initWasm(options = {}) {
11175
12885
  const instance = result.instance;
11176
12886
  const memory = instance.exports.memory;
11177
12887
  const crc32Bytes = instance.exports.crc32_bytes;
12888
+ const buildBinaryRgba = instance.exports.build_binary_rgba;
11178
12889
  const heapExport = instance.exports.__heap_base;
11179
12890
  const heapBase = Number((heapExport && heapExport.value) || heapExport || 65536);
11180
12891
  if (!(memory instanceof WebAssembly.Memory) || typeof crc32Bytes !== "function") {
11181
12892
  throw new Error("QuadQR WASM exports are invalid.");
11182
12893
  }
12894
+ const ensureMemory = function (required) {
12895
+ if (required > memory.buffer.byteLength) memory.grow(Math.ceil((required - memory.buffer.byteLength) / 65536));
12896
+ };
11183
12897
  QuadQR.installCrc32Accelerator(function (input) {
11184
- const data = input instanceof Uint8Array ? input : new Uint8Array(input);
12898
+ const data = input instanceof Uint8Array
12899
+ ? input
12900
+ : ArrayBuffer.isView(input)
12901
+ ? new Uint8Array(input.buffer, input.byteOffset, input.byteLength)
12902
+ : new Uint8Array(input);
11185
12903
  const required = heapBase + data.length;
11186
- if (required > memory.buffer.byteLength) memory.grow(Math.ceil((required - memory.buffer.byteLength) / 65536));
12904
+ ensureMemory(required);
11187
12905
  new Uint8Array(memory.buffer, heapBase, data.length).set(data);
11188
12906
  return crc32Bytes(heapBase, data.length) >>> 0;
11189
12907
  });
11190
- return Object.freeze({ enabled: true, module: "quadqr-core", accelerators: Object.freeze(["crc32"]), bytes: bytes.length });
12908
+ const accelerators = ["crc32"];
12909
+ if (typeof buildBinaryRgba === "function") {
12910
+ const align16 = function (value) { return (value + 15) & ~15; };
12911
+ __qqr_vision_js.installVisionAccelerator({
12912
+ buildBinary: function (imageData, scanOptions = {}) {
12913
+ const width = Number(imageData && imageData.width) || 0;
12914
+ const height = Number(imageData && imageData.height) || 0;
12915
+ const pixels = width * height;
12916
+ if (!pixels || !imageData || !imageData.data || imageData.data.length < pixels * 4) {
12917
+ throw new Error("Valid ImageData is required for WASM preprocessing.");
12918
+ }
12919
+ const raw = imageData.data;
12920
+ const rgba = raw instanceof Uint8Array
12921
+ ? raw
12922
+ : new Uint8Array(raw.buffer, raw.byteOffset, raw.byteLength);
12923
+ const rgbaBytes = pixels * 4;
12924
+ const inputPtr = align16(heapBase);
12925
+ const grayPtr = align16(inputPtr + rgbaBytes);
12926
+ const binaryPtr = align16(grayPtr + pixels);
12927
+ ensureMemory(binaryPtr + pixels);
12928
+ new Uint8Array(memory.buffer, inputPtr, rgbaBytes).set(rgba.subarray(0, rgbaBytes));
12929
+ const mode = scanOptions.grayMode === "value" ? 0 : 1;
12930
+ const offset = Math.round(Number(scanOptions.thresholdOffset) || 0);
12931
+ const packed = buildBinaryRgba(inputPtr, pixels, mode, offset, grayPtr, binaryPtr) >>> 0;
12932
+ const gray = new Uint8Array(pixels);
12933
+ const binary = new Uint8Array(pixels);
12934
+ gray.set(new Uint8Array(memory.buffer, grayPtr, pixels));
12935
+ binary.set(new Uint8Array(memory.buffer, binaryPtr, pixels));
12936
+ return {
12937
+ gray: gray,
12938
+ binary: binary,
12939
+ threshold: packed & 255,
12940
+ baseThreshold: (packed >>> 8) & 255,
12941
+ grayMode: scanOptions.grayMode || "luminance",
12942
+ accelerated: "wasm"
12943
+ };
12944
+ }
12945
+ });
12946
+ accelerators.push("scanner-preprocess");
12947
+ }
12948
+ return Object.freeze({ enabled: true, module: "quadqr-core", accelerators: Object.freeze(accelerators), bytes: bytes.length });
11191
12949
  };
11192
12950
  global.QuadQR = QuadQR;
11193
12951
  })(typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : this);