Fix File
•
/
home
/
sportsfe...
/
httpdocs
/
wp-conte...
/
plugins
/
embedpre...
/
assets
/
pdf
/
build
•
File:
pdf.worker.js
•
Content:
this._decodeType7Shading(reader); patchMesh = true; break; default: unreachable("Unsupported mesh type."); break; } if (patchMesh) { this._updateBounds(); for (let i = 0, ii = this.figures.length; i < ii; i++) { this._buildFigureFromPatch(i); } } this._updateBounds(); this._packData(); } _decodeType4Shading(reader) { const coords = this.coords; const colors = this.colors; const operators = []; const ps = []; let verticesLeft = 0; while (reader.hasData) { const f = reader.readFlag(); const coord = reader.readCoordinate(); const color = reader.readComponents(); if (verticesLeft === 0) { if (!(0 <= f && f <= 2)) { throw new FormatError("Unknown type4 flag"); } switch (f) { case 0: verticesLeft = 3; break; case 1: ps.push(ps.at(-2), ps.at(-1)); verticesLeft = 1; break; case 2: ps.push(ps.at(-3), ps.at(-1)); verticesLeft = 1; break; } operators.push(f); } ps.push(coords.length); coords.push(coord); colors.push(color); verticesLeft--; reader.align(); } this.figures.push({ type: "triangles", coords: new Int32Array(ps), colors: new Int32Array(ps) }); } _decodeType5Shading(reader, verticesPerRow) { const coords = this.coords; const colors = this.colors; const ps = []; while (reader.hasData) { const coord = reader.readCoordinate(); const color = reader.readComponents(); ps.push(coords.length); coords.push(coord); colors.push(color); } this.figures.push({ type: "lattice", coords: new Int32Array(ps), colors: new Int32Array(ps), verticesPerRow }); } _decodeType6Shading(reader) { const coords = this.coords; const colors = this.colors; const ps = new Int32Array(16); const cs = new Int32Array(4); while (reader.hasData) { const f = reader.readFlag(); if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } const pi = coords.length; for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } let tmp1, tmp2, tmp3, tmp4; switch (f) { case 0: ps[12] = pi + 3; ps[13] = pi + 4; ps[14] = pi + 5; ps[15] = pi + 6; ps[8] = pi + 2; ps[11] = pi + 7; ps[4] = pi + 1; ps[7] = pi + 8; ps[0] = pi; ps[1] = pi + 11; ps[2] = pi + 10; ps[3] = pi + 9; cs[2] = ci + 1; cs[3] = ci + 2; cs[0] = ci; cs[1] = ci + 3; break; case 1: tmp1 = ps[12]; tmp2 = ps[13]; tmp3 = ps[14]; tmp4 = ps[15]; ps[12] = tmp4; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2; ps[8] = tmp3; ps[11] = pi + 3; ps[4] = tmp2; ps[7] = pi + 4; ps[0] = tmp1; ps[1] = pi + 7; ps[2] = pi + 6; ps[3] = pi + 5; tmp1 = cs[2]; tmp2 = cs[3]; cs[2] = tmp2; cs[3] = ci; cs[0] = tmp1; cs[1] = ci + 1; break; case 2: tmp1 = ps[15]; tmp2 = ps[11]; ps[12] = ps[3]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2; ps[8] = ps[7]; ps[11] = pi + 3; ps[4] = tmp2; ps[7] = pi + 4; ps[0] = tmp1; ps[1] = pi + 7; ps[2] = pi + 6; ps[3] = pi + 5; tmp1 = cs[3]; cs[2] = cs[1]; cs[3] = ci; cs[0] = tmp1; cs[1] = ci + 1; break; case 3: ps[12] = ps[0]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2; ps[8] = ps[1]; ps[11] = pi + 3; ps[4] = ps[2]; ps[7] = pi + 4; ps[0] = ps[3]; ps[1] = pi + 7; ps[2] = pi + 6; ps[3] = pi + 5; cs[2] = cs[0]; cs[3] = ci; cs[0] = cs[1]; cs[1] = ci + 1; break; } ps[5] = coords.length; coords.push([(-4 * coords[ps[0]][0] - coords[ps[15]][0] + 6 * (coords[ps[4]][0] + coords[ps[1]][0]) - 2 * (coords[ps[12]][0] + coords[ps[3]][0]) + 3 * (coords[ps[13]][0] + coords[ps[7]][0])) / 9, (-4 * coords[ps[0]][1] - coords[ps[15]][1] + 6 * (coords[ps[4]][1] + coords[ps[1]][1]) - 2 * (coords[ps[12]][1] + coords[ps[3]][1]) + 3 * (coords[ps[13]][1] + coords[ps[7]][1])) / 9]); ps[6] = coords.length; coords.push([(-4 * coords[ps[3]][0] - coords[ps[12]][0] + 6 * (coords[ps[2]][0] + coords[ps[7]][0]) - 2 * (coords[ps[0]][0] + coords[ps[15]][0]) + 3 * (coords[ps[4]][0] + coords[ps[14]][0])) / 9, (-4 * coords[ps[3]][1] - coords[ps[12]][1] + 6 * (coords[ps[2]][1] + coords[ps[7]][1]) - 2 * (coords[ps[0]][1] + coords[ps[15]][1]) + 3 * (coords[ps[4]][1] + coords[ps[14]][1])) / 9]); ps[9] = coords.length; coords.push([(-4 * coords[ps[12]][0] - coords[ps[3]][0] + 6 * (coords[ps[8]][0] + coords[ps[13]][0]) - 2 * (coords[ps[0]][0] + coords[ps[15]][0]) + 3 * (coords[ps[11]][0] + coords[ps[1]][0])) / 9, (-4 * coords[ps[12]][1] - coords[ps[3]][1] + 6 * (coords[ps[8]][1] + coords[ps[13]][1]) - 2 * (coords[ps[0]][1] + coords[ps[15]][1]) + 3 * (coords[ps[11]][1] + coords[ps[1]][1])) / 9]); ps[10] = coords.length; coords.push([(-4 * coords[ps[15]][0] - coords[ps[0]][0] + 6 * (coords[ps[11]][0] + coords[ps[14]][0]) - 2 * (coords[ps[12]][0] + coords[ps[3]][0]) + 3 * (coords[ps[2]][0] + coords[ps[8]][0])) / 9, (-4 * coords[ps[15]][1] - coords[ps[0]][1] + 6 * (coords[ps[11]][1] + coords[ps[14]][1]) - 2 * (coords[ps[12]][1] + coords[ps[3]][1]) + 3 * (coords[ps[2]][1] + coords[ps[8]][1])) / 9]); this.figures.push({ type: "patch", coords: new Int32Array(ps), colors: new Int32Array(cs) }); } } _decodeType7Shading(reader) { const coords = this.coords; const colors = this.colors; const ps = new Int32Array(16); const cs = new Int32Array(4); while (reader.hasData) { const f = reader.readFlag(); if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } const pi = coords.length; for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } let tmp1, tmp2, tmp3, tmp4; switch (f) { case 0: ps[12] = pi + 3; ps[13] = pi + 4; ps[14] = pi + 5; ps[15] = pi + 6; ps[8] = pi + 2; ps[9] = pi + 13; ps[10] = pi + 14; ps[11] = pi + 7; ps[4] = pi + 1; ps[5] = pi + 12; ps[6] = pi + 15; ps[7] = pi + 8; ps[0] = pi; ps[1] = pi + 11; ps[2] = pi + 10; ps[3] = pi + 9; cs[2] = ci + 1; cs[3] = ci + 2; cs[0] = ci; cs[1] = ci + 3; break; case 1: tmp1 = ps[12]; tmp2 = ps[13]; tmp3 = ps[14]; tmp4 = ps[15]; ps[12] = tmp4; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2; ps[8] = tmp3; ps[9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3; ps[4] = tmp2; ps[5] = pi + 8; ps[6] = pi + 11; ps[7] = pi + 4; ps[0] = tmp1; ps[1] = pi + 7; ps[2] = pi + 6; ps[3] = pi + 5; tmp1 = cs[2]; tmp2 = cs[3]; cs[2] = tmp2; cs[3] = ci; cs[0] = tmp1; cs[1] = ci + 1; break; case 2: tmp1 = ps[15]; tmp2 = ps[11]; ps[12] = ps[3]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2; ps[8] = ps[7]; ps[9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3; ps[4] = tmp2; ps[5] = pi + 8; ps[6] = pi + 11; ps[7] = pi + 4; ps[0] = tmp1; ps[1] = pi + 7; ps[2] = pi + 6; ps[3] = pi + 5; tmp1 = cs[3]; cs[2] = cs[1]; cs[3] = ci; cs[0] = tmp1; cs[1] = ci + 1; break; case 3: ps[12] = ps[0]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2; ps[8] = ps[1]; ps[9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3; ps[4] = ps[2]; ps[5] = pi + 8; ps[6] = pi + 11; ps[7] = pi + 4; ps[0] = ps[3]; ps[1] = pi + 7; ps[2] = pi + 6; ps[3] = pi + 5; cs[2] = cs[0]; cs[3] = ci; cs[0] = cs[1]; cs[1] = ci + 1; break; } this.figures.push({ type: "patch", coords: new Int32Array(ps), colors: new Int32Array(cs) }); } } _buildFigureFromPatch(index) { const figure = this.figures[index]; assert(figure.type === "patch", "Unexpected patch mesh figure"); const coords = this.coords, colors = this.colors; const pi = figure.coords; const ci = figure.colors; const figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]); const figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]); const figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]); const figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]); let splitXBy = Math.ceil((figureMaxX - figureMinX) * MeshShading.TRIANGLE_DENSITY / (this.bounds[2] - this.bounds[0])); splitXBy = Math.max(MeshShading.MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MeshShading.MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy)); let splitYBy = Math.ceil((figureMaxY - figureMinY) * MeshShading.TRIANGLE_DENSITY / (this.bounds[3] - this.bounds[1])); splitYBy = Math.max(MeshShading.MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MeshShading.MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy)); const verticesPerRow = splitXBy + 1; const figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow); const figureColors = new Int32Array((splitYBy + 1) * verticesPerRow); let k = 0; const cl = new Uint8Array(3), cr = new Uint8Array(3); const c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]]; const bRow = getB(splitYBy), bCol = getB(splitXBy); for (let row = 0; row <= splitYBy; row++) { cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0; cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0; cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0; cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0; cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0; cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0; for (let col = 0; col <= splitXBy; col++, k++) { if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) { continue; } let x = 0, y = 0; let q = 0; for (let i = 0; i <= 3; i++) { for (let j = 0; j <= 3; j++, q++) { const m = bRow[row][i] * bCol[col][j]; x += coords[pi[q]][0] * m; y += coords[pi[q]][1] * m; } } figureCoords[k] = coords.length; coords.push([x, y]); figureColors[k] = colors.length; const newColor = new Uint8Array(3); newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0; newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0; newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0; colors.push(newColor); } } figureCoords[0] = pi[0]; figureColors[0] = ci[0]; figureCoords[splitXBy] = pi[3]; figureColors[splitXBy] = ci[1]; figureCoords[verticesPerRow * splitYBy] = pi[12]; figureColors[verticesPerRow * splitYBy] = ci[2]; figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15]; figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3]; this.figures[index] = { type: "lattice", coords: figureCoords, colors: figureColors, verticesPerRow }; } _updateBounds() { let minX = this.coords[0][0], minY = this.coords[0][1], maxX = minX, maxY = minY; for (let i = 1, ii = this.coords.length; i < ii; i++) { const x = this.coords[i][0], y = this.coords[i][1]; minX = minX > x ? x : minX; minY = minY > y ? y : minY; maxX = maxX < x ? x : maxX; maxY = maxY < y ? y : maxY; } this.bounds = [minX, minY, maxX, maxY]; } _packData() { let i, ii, j, jj; const coords = this.coords; const coordsPacked = new Float32Array(coords.length * 2); for (i = 0, j = 0, ii = coords.length; i < ii; i++) { const xy = coords[i]; coordsPacked[j++] = xy[0]; coordsPacked[j++] = xy[1]; } this.coords = coordsPacked; const colors = this.colors; const colorsPacked = new Uint8Array(colors.length * 3); for (i = 0, j = 0, ii = colors.length; i < ii; i++) { const c = colors[i]; colorsPacked[j++] = c[0]; colorsPacked[j++] = c[1]; colorsPacked[j++] = c[2]; } this.colors = colorsPacked; const figures = this.figures; for (i = 0, ii = figures.length; i < ii; i++) { const figure = figures[i], ps = figure.coords, cs = figure.colors; for (j = 0, jj = ps.length; j < jj; j++) { ps[j] *= 2; cs[j] *= 3; } } } getIR() { const { bounds } = this; if (bounds[2] - bounds[0] === 0 || bounds[3] - bounds[1] === 0) { throw new FormatError(`Invalid MeshShading bounds: [${bounds}].`); } return ["Mesh", this.shadingType, this.coords, this.colors, this.figures, bounds, this.bbox, this.background]; } } class DummyShading extends BaseShading { getIR() { return ["Dummy"]; } } function getTilingPatternIR(operatorList, dict, color) { const matrix = lookupMatrix(dict.getArray("Matrix"), IDENTITY_MATRIX); const bbox = lookupNormalRect(dict.getArray("BBox"), null); if (!bbox || bbox[2] - bbox[0] === 0 || bbox[3] - bbox[1] === 0) { throw new FormatError(`Invalid getTilingPatternIR /BBox array.`); } const xstep = dict.get("XStep"); if (typeof xstep !== "number") { throw new FormatError(`Invalid getTilingPatternIR /XStep value.`); } const ystep = dict.get("YStep"); if (typeof ystep !== "number") { throw new FormatError(`Invalid getTilingPatternIR /YStep value.`); } const paintType = dict.get("PaintType"); if (!Number.isInteger(paintType)) { throw new FormatError(`Invalid getTilingPatternIR /PaintType value.`); } const tilingType = dict.get("TilingType"); if (!Number.isInteger(tilingType)) { throw new FormatError(`Invalid getTilingPatternIR /TilingType value.`); } return ["TilingPattern", color, operatorList, matrix, bbox, xstep, ystep, paintType, tilingType]; } ;// CONCATENATED MODULE: ./src/core/calibri_factors.js const CalibriBoldFactors = [1.3877, 1, 1, 1, 0.97801, 0.92482, 0.89552, 0.91133, 0.81988, 0.97566, 0.98152, 0.93548, 0.93548, 1.2798, 0.85284, 0.92794, 1, 0.96134, 1.54657, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.82845, 0.82845, 0.85284, 0.85284, 0.85284, 0.75859, 0.92138, 0.83908, 0.7762, 0.73293, 0.87289, 0.73133, 0.7514, 0.81921, 0.87356, 0.95958, 0.59526, 0.75727, 0.69225, 1.04924, 0.9121, 0.86943, 0.79795, 0.88198, 0.77958, 0.70864, 0.81055, 0.90399, 0.88653, 0.96017, 0.82577, 0.77892, 0.78257, 0.97507, 1.54657, 0.97507, 0.85284, 0.89552, 0.90176, 0.88762, 0.8785, 0.75241, 0.8785, 0.90518, 0.95015, 0.77618, 0.8785, 0.88401, 0.91916, 0.86304, 0.88401, 0.91488, 0.8785, 0.8801, 0.8785, 0.8785, 0.91343, 0.7173, 1.04106, 0.8785, 0.85075, 0.95794, 0.82616, 0.85162, 0.79492, 0.88331, 1.69808, 0.88331, 0.85284, 0.97801, 0.89552, 0.91133, 0.89552, 0.91133, 1.7801, 0.89552, 1.24487, 1.13254, 1.12401, 0.96839, 0.85284, 0.68787, 0.70645, 0.85592, 0.90747, 1.01466, 1.0088, 0.90323, 1, 1.07463, 1, 0.91056, 0.75806, 1.19118, 0.96839, 0.78864, 0.82845, 0.84133, 0.75859, 0.83908, 0.83908, 0.83908, 0.83908, 0.83908, 0.83908, 0.77539, 0.73293, 0.73133, 0.73133, 0.73133, 0.73133, 0.95958, 0.95958, 0.95958, 0.95958, 0.88506, 0.9121, 0.86943, 0.86943, 0.86943, 0.86943, 0.86943, 0.85284, 0.87508, 0.90399, 0.90399, 0.90399, 0.90399, 0.77892, 0.79795, 0.90807, 0.88762, 0.88762, 0.88762, 0.88762, 0.88762, 0.88762, 0.8715, 0.75241, 0.90518, 0.90518, 0.90518, 0.90518, 0.88401, 0.88401, 0.88401, 0.88401, 0.8785, 0.8785, 0.8801, 0.8801, 0.8801, 0.8801, 0.8801, 0.90747, 0.89049, 0.8785, 0.8785, 0.8785, 0.8785, 0.85162, 0.8785, 0.85162, 0.83908, 0.88762, 0.83908, 0.88762, 0.83908, 0.88762, 0.73293, 0.75241, 0.73293, 0.75241, 0.73293, 0.75241, 0.73293, 0.75241, 0.87289, 0.83016, 0.88506, 0.93125, 0.73133, 0.90518, 0.73133, 0.90518, 0.73133, 0.90518, 0.73133, 0.90518, 0.73133, 0.90518, 0.81921, 0.77618, 0.81921, 0.77618, 0.81921, 0.77618, 1, 1, 0.87356, 0.8785, 0.91075, 0.89608, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.76229, 0.90167, 0.59526, 0.91916, 1, 1, 0.86304, 0.69225, 0.88401, 1, 1, 0.70424, 0.79468, 0.91926, 0.88175, 0.70823, 0.94903, 0.9121, 0.8785, 1, 1, 0.9121, 0.8785, 0.87802, 0.88656, 0.8785, 0.86943, 0.8801, 0.86943, 0.8801, 0.86943, 0.8801, 0.87402, 0.89291, 0.77958, 0.91343, 1, 1, 0.77958, 0.91343, 0.70864, 0.7173, 0.70864, 0.7173, 0.70864, 0.7173, 0.70864, 0.7173, 1, 1, 0.81055, 0.75841, 0.81055, 1.06452, 0.90399, 0.8785, 0.90399, 0.8785, 0.90399, 0.8785, 0.90399, 0.8785, 0.90399, 0.8785, 0.90399, 0.8785, 0.96017, 0.95794, 0.77892, 0.85162, 0.77892, 0.78257, 0.79492, 0.78257, 0.79492, 0.78257, 0.79492, 0.9297, 0.56892, 0.83908, 0.88762, 0.77539, 0.8715, 0.87508, 0.89049, 1, 1, 0.81055, 1.04106, 1.20528, 1.20528, 1, 1.15543, 0.70674, 0.98387, 0.94721, 1.33431, 1.45894, 0.95161, 1.06303, 0.83908, 0.80352, 0.57184, 0.6965, 0.56289, 0.82001, 0.56029, 0.81235, 1.02988, 0.83908, 0.7762, 0.68156, 0.80367, 0.73133, 0.78257, 0.87356, 0.86943, 0.95958, 0.75727, 0.89019, 1.04924, 0.9121, 0.7648, 0.86943, 0.87356, 0.79795, 0.78275, 0.81055, 0.77892, 0.9762, 0.82577, 0.99819, 0.84896, 0.95958, 0.77892, 0.96108, 1.01407, 0.89049, 1.02988, 0.94211, 0.96108, 0.8936, 0.84021, 0.87842, 0.96399, 0.79109, 0.89049, 1.00813, 1.02988, 0.86077, 0.87445, 0.92099, 0.84723, 0.86513, 0.8801, 0.75638, 0.85714, 0.78216, 0.79586, 0.87965, 0.94211, 0.97747, 0.78287, 0.97926, 0.84971, 1.02988, 0.94211, 0.8801, 0.94211, 0.84971, 0.73133, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90264, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90518, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90548, 1, 1, 1, 1, 1, 1, 0.96017, 0.95794, 0.96017, 0.95794, 0.96017, 0.95794, 0.77892, 0.85162, 1, 1, 0.89552, 0.90527, 1, 0.90363, 0.92794, 0.92794, 0.92794, 0.92794, 0.87012, 0.87012, 0.87012, 0.89552, 0.89552, 1.42259, 0.71143, 1.06152, 1, 1, 1.03372, 1.03372, 0.97171, 1.4956, 2.2807, 0.93835, 0.83406, 0.91133, 0.84107, 0.91133, 1, 1, 1, 0.72021, 1, 1.23108, 0.83489, 0.88525, 0.88525, 0.81499, 0.90527, 1.81055, 0.90527, 1.81055, 1.31006, 1.53711, 0.94434, 1.08696, 1, 0.95018, 0.77192, 0.85284, 0.90747, 1.17534, 0.69825, 0.9716, 1.37077, 0.90747, 0.90747, 0.85356, 0.90747, 0.90747, 1.44947, 0.85284, 0.8941, 0.8941, 0.70572, 0.8, 0.70572, 0.70572, 0.70572, 0.70572, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.99862, 0.99862, 1, 1, 1, 1, 1, 1.08004, 0.91027, 1, 1, 1, 0.99862, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90727, 0.90727, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; const CalibriBoldMetrics = { lineHeight: 1.2207, lineGap: 0.2207 }; const CalibriBoldItalicFactors = [1.3877, 1, 1, 1, 0.97801, 0.92482, 0.89552, 0.91133, 0.81988, 0.97566, 0.98152, 0.93548, 0.93548, 1.2798, 0.85284, 0.92794, 1, 0.96134, 1.56239, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.82845, 0.82845, 0.85284, 0.85284, 0.85284, 0.75859, 0.92138, 0.83908, 0.7762, 0.71805, 0.87289, 0.73133, 0.7514, 0.81921, 0.87356, 0.95958, 0.59526, 0.75727, 0.69225, 1.04924, 0.90872, 0.85938, 0.79795, 0.87068, 0.77958, 0.69766, 0.81055, 0.90399, 0.88653, 0.96068, 0.82577, 0.77892, 0.78257, 0.97507, 1.529, 0.97507, 0.85284, 0.89552, 0.90176, 0.94908, 0.86411, 0.74012, 0.86411, 0.88323, 0.95015, 0.86411, 0.86331, 0.88401, 0.91916, 0.86304, 0.88401, 0.9039, 0.86331, 0.86331, 0.86411, 0.86411, 0.90464, 0.70852, 1.04106, 0.86331, 0.84372, 0.95794, 0.82616, 0.84548, 0.79492, 0.88331, 1.69808, 0.88331, 0.85284, 0.97801, 0.89552, 0.91133, 0.89552, 0.91133, 1.7801, 0.89552, 1.24487, 1.13254, 1.19129, 0.96839, 0.85284, 0.68787, 0.70645, 0.85592, 0.90747, 1.01466, 1.0088, 0.90323, 1, 1.07463, 1, 0.91056, 0.75806, 1.19118, 0.96839, 0.78864, 0.82845, 0.84133, 0.75859, 0.83908, 0.83908, 0.83908, 0.83908, 0.83908, 0.83908, 0.77539, 0.71805, 0.73133, 0.73133, 0.73133, 0.73133, 0.95958, 0.95958, 0.95958, 0.95958, 0.88506, 0.90872, 0.85938, 0.85938, 0.85938, 0.85938, 0.85938, 0.85284, 0.87068, 0.90399, 0.90399, 0.90399, 0.90399, 0.77892, 0.79795, 0.90807, 0.94908, 0.94908, 0.94908, 0.94908, 0.94908, 0.94908, 0.85887, 0.74012, 0.88323, 0.88323, 0.88323, 0.88323, 0.88401, 0.88401, 0.88401, 0.88401, 0.8785, 0.86331, 0.86331, 0.86331, 0.86331, 0.86331, 0.86331, 0.90747, 0.89049, 0.86331, 0.86331, 0.86331, 0.86331, 0.84548, 0.86411, 0.84548, 0.83908, 0.94908, 0.83908, 0.94908, 0.83908, 0.94908, 0.71805, 0.74012, 0.71805, 0.74012, 0.71805, 0.74012, 0.71805, 0.74012, 0.87289, 0.79538, 0.88506, 0.92726, 0.73133, 0.88323, 0.73133, 0.88323, 0.73133, 0.88323, 0.73133, 0.88323, 0.73133, 0.88323, 0.81921, 0.86411, 0.81921, 0.86411, 0.81921, 0.86411, 1, 1, 0.87356, 0.86331, 0.91075, 0.8777, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.76467, 0.90167, 0.59526, 0.91916, 1, 1, 0.86304, 0.69225, 0.88401, 1, 1, 0.70424, 0.77312, 0.91926, 0.88175, 0.70823, 0.94903, 0.90872, 0.86331, 1, 1, 0.90872, 0.86331, 0.86906, 0.88116, 0.86331, 0.85938, 0.86331, 0.85938, 0.86331, 0.85938, 0.86331, 0.87402, 0.86549, 0.77958, 0.90464, 1, 1, 0.77958, 0.90464, 0.69766, 0.70852, 0.69766, 0.70852, 0.69766, 0.70852, 0.69766, 0.70852, 1, 1, 0.81055, 0.75841, 0.81055, 1.06452, 0.90399, 0.86331, 0.90399, 0.86331, 0.90399, 0.86331, 0.90399, 0.86331, 0.90399, 0.86331, 0.90399, 0.86331, 0.96068, 0.95794, 0.77892, 0.84548, 0.77892, 0.78257, 0.79492, 0.78257, 0.79492, 0.78257, 0.79492, 0.9297, 0.56892, 0.83908, 0.94908, 0.77539, 0.85887, 0.87068, 0.89049, 1, 1, 0.81055, 1.04106, 1.20528, 1.20528, 1, 1.15543, 0.70088, 0.98387, 0.94721, 1.33431, 1.45894, 0.95161, 1.48387, 0.83908, 0.80352, 0.57118, 0.6965, 0.56347, 0.79179, 0.55853, 0.80346, 1.02988, 0.83908, 0.7762, 0.67174, 0.86036, 0.73133, 0.78257, 0.87356, 0.86441, 0.95958, 0.75727, 0.89019, 1.04924, 0.90872, 0.74889, 0.85938, 0.87891, 0.79795, 0.7957, 0.81055, 0.77892, 0.97447, 0.82577, 0.97466, 0.87179, 0.95958, 0.77892, 0.94252, 0.95612, 0.8753, 1.02988, 0.92733, 0.94252, 0.87411, 0.84021, 0.8728, 0.95612, 0.74081, 0.8753, 1.02189, 1.02988, 0.84814, 0.87445, 0.91822, 0.84723, 0.85668, 0.86331, 0.81344, 0.87581, 0.76422, 0.82046, 0.96057, 0.92733, 0.99375, 0.78022, 0.95452, 0.86015, 1.02988, 0.92733, 0.86331, 0.92733, 0.86015, 0.73133, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90631, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.88323, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.85174, 1, 1, 1, 1, 1, 1, 0.96068, 0.95794, 0.96068, 0.95794, 0.96068, 0.95794, 0.77892, 0.84548, 1, 1, 0.89552, 0.90527, 1, 0.90363, 0.92794, 0.92794, 0.92794, 0.89807, 0.87012, 0.87012, 0.87012, 0.89552, 0.89552, 1.42259, 0.71094, 1.06152, 1, 1, 1.03372, 1.03372, 0.97171, 1.4956, 2.2807, 0.92972, 0.83406, 0.91133, 0.83326, 0.91133, 1, 1, 1, 0.72021, 1, 1.23108, 0.83489, 0.88525, 0.88525, 0.81499, 0.90616, 1.81055, 0.90527, 1.81055, 1.3107, 1.53711, 0.94434, 1.08696, 1, 0.95018, 0.77192, 0.85284, 0.90747, 1.17534, 0.69825, 0.9716, 1.37077, 0.90747, 0.90747, 0.85356, 0.90747, 0.90747, 1.44947, 0.85284, 0.8941, 0.8941, 0.70572, 0.8, 0.70572, 0.70572, 0.70572, 0.70572, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.99862, 0.99862, 1, 1, 1, 1, 1, 1.08004, 0.91027, 1, 1, 1, 0.99862, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90727, 0.90727, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; const CalibriBoldItalicMetrics = { lineHeight: 1.2207, lineGap: 0.2207 }; const CalibriItalicFactors = [1.3877, 1, 1, 1, 1.17223, 1.1293, 0.89552, 0.91133, 0.80395, 1.02269, 1.15601, 0.91056, 0.91056, 1.2798, 0.85284, 0.89807, 1, 0.90861, 1.39543, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.96309, 0.96309, 0.85284, 0.85284, 0.85284, 0.83319, 0.88071, 0.8675, 0.81552, 0.72346, 0.85193, 0.73206, 0.7522, 0.81105, 0.86275, 0.90685, 0.6377, 0.77892, 0.75593, 1.02638, 0.89249, 0.84118, 0.77452, 0.85374, 0.75186, 0.67789, 0.79776, 0.88844, 0.85066, 0.94309, 0.77818, 0.7306, 0.76659, 1.10369, 1.38313, 1.10369, 1.06139, 0.89552, 0.8739, 0.9245, 0.9245, 0.83203, 0.9245, 0.85865, 1.09842, 0.9245, 0.9245, 1.03297, 1.07692, 0.90918, 1.03297, 0.94959, 0.9245, 0.92274, 0.9245, 0.9245, 1.02933, 0.77832, 1.20562, 0.9245, 0.8916, 0.98986, 0.86621, 0.89453, 0.79004, 0.94152, 1.77256, 0.94152, 0.85284, 0.97801, 0.89552, 0.91133, 0.89552, 0.91133, 1.91729, 0.89552, 1.17889, 1.13254, 1.16359, 0.92098, 0.85284, 0.68787, 0.71353, 0.84737, 0.90747, 1.0088, 1.0044, 0.87683, 1, 1.09091, 1, 0.92229, 0.739, 1.15642, 0.92098, 0.76288, 0.80504, 0.80972, 0.75859, 0.8675, 0.8675, 0.8675, 0.8675, 0.8675, 0.8675, 0.76318, 0.72346, 0.73206, 0.73206, 0.73206, 0.73206, 0.90685, 0.90685, 0.90685, 0.90685, 0.86477, 0.89249, 0.84118, 0.84118, 0.84118, 0.84118, 0.84118, 0.85284, 0.84557, 0.88844, 0.88844, 0.88844, 0.88844, 0.7306, 0.77452, 0.86331, 0.9245, 0.9245, 0.9245, 0.9245, 0.9245, 0.9245, 0.84843, 0.83203, 0.85865, 0.85865, 0.85865, 0.85865, 0.82601, 0.82601, 0.82601, 0.82601, 0.94469, 0.9245, 0.92274, 0.92274, 0.92274, 0.92274, 0.92274, 0.90747, 0.86651, 0.9245, 0.9245, 0.9245, 0.9245, 0.89453, 0.9245, 0.89453, 0.8675, 0.9245, 0.8675, 0.9245, 0.8675, 0.9245, 0.72346, 0.83203, 0.72346, 0.83203, 0.72346, 0.83203, 0.72346, 0.83203, 0.85193, 0.8875, 0.86477, 0.99034, 0.73206, 0.85865, 0.73206, 0.85865, 0.73206, 0.85865, 0.73206, 0.85865, 0.73206, 0.85865, 0.81105, 0.9245, 0.81105, 0.9245, 0.81105, 0.9245, 1, 1, 0.86275, 0.9245, 0.90872, 0.93591, 0.90685, 0.82601, 0.90685, 0.82601, 0.90685, 0.82601, 0.90685, 1.03297, 0.90685, 0.82601, 0.77896, 1.05611, 0.6377, 1.07692, 1, 1, 0.90918, 0.75593, 1.03297, 1, 1, 0.76032, 0.9375, 0.98156, 0.93407, 0.77261, 1.11429, 0.89249, 0.9245, 1, 1, 0.89249, 0.9245, 0.92534, 0.86698, 0.9245, 0.84118, 0.92274, 0.84118, 0.92274, 0.84118, 0.92274, 0.8667, 0.86291, 0.75186, 1.02933, 1, 1, 0.75186, 1.02933, 0.67789, 0.77832, 0.67789, 0.77832, 0.67789, 0.77832, 0.67789, 0.77832, 1, 1, 0.79776, 0.97655, 0.79776, 1.23023, 0.88844, 0.9245, 0.88844, 0.9245, 0.88844, 0.9245, 0.88844, 0.9245, 0.88844, 0.9245, 0.88844, 0.9245, 0.94309, 0.98986, 0.7306, 0.89453, 0.7306, 0.76659, 0.79004, 0.76659, 0.79004, 0.76659, 0.79004, 1.09231, 0.54873, 0.8675, 0.9245, 0.76318, 0.84843, 0.84557, 0.86651, 1, 1, 0.79776, 1.20562, 1.18622, 1.18622, 1, 1.1437, 0.67009, 0.96334, 0.93695, 1.35191, 1.40909, 0.95161, 1.48387, 0.8675, 0.90861, 0.6192, 0.7363, 0.64824, 0.82411, 0.56321, 0.85696, 1.23516, 0.8675, 0.81552, 0.7286, 0.84134, 0.73206, 0.76659, 0.86275, 0.84369, 0.90685, 0.77892, 0.85871, 1.02638, 0.89249, 0.75828, 0.84118, 0.85984, 0.77452, 0.76466, 0.79776, 0.7306, 0.90782, 0.77818, 0.903, 0.87291, 0.90685, 0.7306, 0.99058, 1.03667, 0.94635, 1.23516, 0.9849, 0.99058, 0.92393, 0.8916, 0.942, 1.03667, 0.75026, 0.94635, 1.0297, 1.23516, 0.90918, 0.94048, 0.98217, 0.89746, 0.84153, 0.92274, 0.82507, 0.88832, 0.84438, 0.88178, 1.03525, 0.9849, 1.00225, 0.78086, 0.97248, 0.89404, 1.23516, 0.9849, 0.92274, 0.9849, 0.89404, 0.73206, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.89693, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.85865, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90933, 1, 1, 1, 1, 1, 1, 0.94309, 0.98986, 0.94309, 0.98986, 0.94309, 0.98986, 0.7306, 0.89453, 1, 1, 0.89552, 0.90527, 1, 0.90186, 1.12308, 1.12308, 1.12308, 1.12308, 1.2566, 1.2566, 1.2566, 0.89552, 0.89552, 1.42259, 0.68994, 1.03809, 1, 1, 1.0176, 1.0176, 1.11523, 1.4956, 2.01462, 0.97858, 0.82616, 0.91133, 0.83437, 0.91133, 1, 1, 1, 0.70508, 1, 1.23108, 0.79801, 0.84426, 0.84426, 0.774, 0.90572, 1.81055, 0.90749, 1.81055, 1.28809, 1.55469, 0.94434, 1.07806, 1, 0.97094, 0.7589, 0.85284, 0.90747, 1.19658, 0.69825, 0.97622, 1.33512, 0.90747, 0.90747, 0.85284, 0.90747, 0.90747, 1.44947, 0.85284, 0.8941, 0.8941, 0.70572, 0.8, 0.70572, 0.70572, 0.70572, 0.70572, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.99862, 0.99862, 1, 1, 1, 1, 1, 1.0336, 0.91027, 1, 1, 1, 0.99862, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.05859, 1.05859, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; const CalibriItalicMetrics = { lineHeight: 1.2207, lineGap: 0.2207 }; const CalibriRegularFactors = [1.3877, 1, 1, 1, 1.17223, 1.1293, 0.89552, 0.91133, 0.80395, 1.02269, 1.15601, 0.91056, 0.91056, 1.2798, 0.85284, 0.89807, 1, 0.90861, 1.39016, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.96309, 0.96309, 0.85284, 0.85284, 0.85284, 0.83319, 0.88071, 0.8675, 0.81552, 0.73834, 0.85193, 0.73206, 0.7522, 0.81105, 0.86275, 0.90685, 0.6377, 0.77892, 0.75593, 1.02638, 0.89385, 0.85122, 0.77452, 0.86503, 0.75186, 0.68887, 0.79776, 0.88844, 0.85066, 0.94258, 0.77818, 0.7306, 0.76659, 1.10369, 1.39016, 1.10369, 1.06139, 0.89552, 0.8739, 0.86128, 0.94469, 0.8457, 0.94469, 0.89464, 1.09842, 0.84636, 0.94469, 1.03297, 1.07692, 0.90918, 1.03297, 0.95897, 0.94469, 0.9482, 0.94469, 0.94469, 1.04692, 0.78223, 1.20562, 0.94469, 0.90332, 0.98986, 0.86621, 0.90527, 0.79004, 0.94152, 1.77256, 0.94152, 0.85284, 0.97801, 0.89552, 0.91133, 0.89552, 0.91133, 1.91729, 0.89552, 1.17889, 1.13254, 1.08707, 0.92098, 0.85284, 0.68787, 0.71353, 0.84737, 0.90747, 1.0088, 1.0044, 0.87683, 1, 1.09091, 1, 0.92229, 0.739, 1.15642, 0.92098, 0.76288, 0.80504, 0.80972, 0.75859, 0.8675, 0.8675, 0.8675, 0.8675, 0.8675, 0.8675, 0.76318, 0.73834, 0.73206, 0.73206, 0.73206, 0.73206, 0.90685, 0.90685, 0.90685, 0.90685, 0.86477, 0.89385, 0.85122, 0.85122, 0.85122, 0.85122, 0.85122, 0.85284, 0.85311, 0.88844, 0.88844, 0.88844, 0.88844, 0.7306, 0.77452, 0.86331, 0.86128, 0.86128, 0.86128, 0.86128, 0.86128, 0.86128, 0.8693, 0.8457, 0.89464, 0.89464, 0.89464, 0.89464, 0.82601, 0.82601, 0.82601, 0.82601, 0.94469, 0.94469, 0.9482, 0.9482, 0.9482, 0.9482, 0.9482, 0.90747, 0.86651, 0.94469, 0.94469, 0.94469, 0.94469, 0.90527, 0.94469, 0.90527, 0.8675, 0.86128, 0.8675, 0.86128, 0.8675, 0.86128, 0.73834, 0.8457, 0.73834, 0.8457, 0.73834, 0.8457, 0.73834, 0.8457, 0.85193, 0.92454, 0.86477, 0.9921, 0.73206, 0.89464, 0.73206, 0.89464, 0.73206, 0.89464, 0.73206, 0.89464, 0.73206, 0.89464, 0.81105, 0.84636, 0.81105, 0.84636, 0.81105, 0.84636, 1, 1, 0.86275, 0.94469, 0.90872, 0.95786, 0.90685, 0.82601, 0.90685, 0.82601, 0.90685, 0.82601, 0.90685, 1.03297, 0.90685, 0.82601, 0.77741, 1.05611, 0.6377, 1.07692, 1, 1, 0.90918, 0.75593, 1.03297, 1, 1, 0.76032, 0.90452, 0.98156, 1.11842, 0.77261, 1.11429, 0.89385, 0.94469, 1, 1, 0.89385, 0.94469, 0.95877, 0.86901, 0.94469, 0.85122, 0.9482, 0.85122, 0.9482, 0.85122, 0.9482, 0.8667, 0.90016, 0.75186, 1.04692, 1, 1, 0.75186, 1.04692, 0.68887, 0.78223, 0.68887, 0.78223, 0.68887, 0.78223, 0.68887, 0.78223, 1, 1, 0.79776, 0.92188, 0.79776, 1.23023, 0.88844, 0.94469, 0.88844, 0.94469, 0.88844, 0.94469, 0.88844, 0.94469, 0.88844, 0.94469, 0.88844, 0.94469, 0.94258, 0.98986, 0.7306, 0.90527, 0.7306, 0.76659, 0.79004, 0.76659, 0.79004, 0.76659, 0.79004, 1.09231, 0.54873, 0.8675, 0.86128, 0.76318, 0.8693, 0.85311, 0.86651, 1, 1, 0.79776, 1.20562, 1.18622, 1.18622, 1, 1.1437, 0.67742, 0.96334, 0.93695, 1.35191, 1.40909, 0.95161, 1.48387, 0.86686, 0.90861, 0.62267, 0.74359, 0.65649, 0.85498, 0.56963, 0.88254, 1.23516, 0.8675, 0.81552, 0.75443, 0.84503, 0.73206, 0.76659, 0.86275, 0.85122, 0.90685, 0.77892, 0.85746, 1.02638, 0.89385, 0.75657, 0.85122, 0.86275, 0.77452, 0.74171, 0.79776, 0.7306, 0.95165, 0.77818, 0.89772, 0.88831, 0.90685, 0.7306, 0.98142, 1.02191, 0.96576, 1.23516, 0.99018, 0.98142, 0.9236, 0.89258, 0.94035, 1.02191, 0.78848, 0.96576, 0.9561, 1.23516, 0.90918, 0.92578, 0.95424, 0.89746, 0.83969, 0.9482, 0.80113, 0.89442, 0.85208, 0.86155, 0.98022, 0.99018, 1.00452, 0.81209, 0.99247, 0.89181, 1.23516, 0.99018, 0.9482, 0.99018, 0.89181, 0.73206, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.88844, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.89464, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.96766, 1, 1, 1, 1, 1, 1, 0.94258, 0.98986, 0.94258, 0.98986, 0.94258, 0.98986, 0.7306, 0.90527, 1, 1, 0.89552, 0.90527, 1, 0.90186, 1.12308, 1.12308, 1.12308, 1.12308, 1.2566, 1.2566, 1.2566, 0.89552, 0.89552, 1.42259, 0.69043, 1.03809, 1, 1, 1.0176, 1.0176, 1.11523, 1.4956, 2.01462, 0.99331, 0.82616, 0.91133, 0.84286, 0.91133, 1, 1, 1, 0.70508, 1, 1.23108, 0.79801, 0.84426, 0.84426, 0.774, 0.90527, 1.81055, 0.90527, 1.81055, 1.28809, 1.55469, 0.94434, 1.07806, 1, 0.97094, 0.7589, 0.85284, 0.90747, 1.19658, 0.69825, 0.97622, 1.33512, 0.90747, 0.90747, 0.85356, 0.90747, 0.90747, 1.44947, 0.85284, 0.8941, 0.8941, 0.70572, 0.8, 0.70572, 0.70572, 0.70572, 0.70572, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.99862, 0.99862, 1, 1, 1, 1, 1, 1.0336, 0.91027, 1, 1, 1, 0.99862, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.05859, 1.05859, 1, 1, 1, 1.07185, 0.99413, 0.96334, 1.08065, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; const CalibriRegularMetrics = { lineHeight: 1.2207, lineGap: 0.2207 }; ;// CONCATENATED MODULE: ./src/core/helvetica_factors.js const HelveticaBoldFactors = [0.76116, 1, 1, 1.0006, 0.99998, 0.99974, 0.99973, 0.99973, 0.99982, 0.99977, 1.00087, 0.99998, 0.99998, 0.99959, 1.00003, 1.0006, 0.99998, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99998, 1, 1.00003, 1.00003, 1.00003, 1.00026, 0.9999, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00026, 1.00022, 0.99977, 1.0006, 0.99973, 0.99977, 1.00026, 0.99999, 0.99977, 1.00022, 1.00001, 1.00022, 0.99977, 1.00001, 1.00026, 0.99977, 1.00001, 1.00016, 1.00001, 1.00001, 1.00026, 0.99998, 1.0006, 0.99998, 1.00003, 0.99973, 0.99998, 0.99973, 1.00026, 0.99973, 1.00026, 0.99973, 0.99998, 1.00026, 1.00026, 1.0006, 1.0006, 0.99973, 1.0006, 0.99982, 1.00026, 1.00026, 1.00026, 1.00026, 0.99959, 0.99973, 0.99998, 1.00026, 0.99973, 1.00022, 0.99973, 0.99973, 1, 0.99959, 1.00077, 0.99959, 1.00003, 0.99998, 0.99973, 0.99973, 0.99973, 0.99973, 1.00077, 0.99973, 0.99998, 1.00025, 0.99968, 0.99973, 1.00003, 1.00025, 0.60299, 1.00024, 1.06409, 1, 1, 0.99998, 1, 0.99973, 1.0006, 0.99998, 1, 0.99936, 0.99973, 1.00002, 1.00002, 1.00002, 1.00026, 0.99977, 0.99977, 0.99977, 0.99977, 0.99977, 0.99977, 1, 0.99977, 1.00001, 1.00001, 1.00001, 1.00001, 1.0006, 1.0006, 1.0006, 1.0006, 0.99977, 0.99977, 1.00022, 1.00022, 1.00022, 1.00022, 1.00022, 1.00003, 1.00022, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00001, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99982, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.06409, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 0.99973, 1.00026, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 1.03374, 0.99977, 1.00026, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.00042, 0.99973, 0.99973, 1.0006, 0.99977, 0.99973, 0.99973, 1.00026, 1.0006, 1.00026, 1.0006, 1.00026, 1.03828, 1.00026, 0.99999, 1.00026, 1.0006, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.9993, 0.9998, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1, 1.00016, 0.99977, 0.99959, 0.99977, 0.99959, 0.99977, 0.99959, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00026, 0.99998, 1.00026, 0.8121, 1.00026, 0.99998, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 1.00016, 1.00022, 1.00001, 0.99973, 1.00001, 1.00026, 1, 1.00026, 1, 1.00026, 1, 1.0006, 0.99973, 0.99977, 0.99973, 1, 0.99982, 1.00022, 1.00026, 1.00001, 0.99973, 1.00026, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 1.00034, 0.99977, 1, 0.99997, 1.00026, 1.00078, 1.00036, 0.99973, 1.00013, 1.0006, 0.99977, 0.99977, 0.99988, 0.85148, 1.00001, 1.00026, 0.99977, 1.00022, 1.0006, 0.99977, 1.00001, 0.99999, 0.99977, 1.00069, 1.00022, 0.99977, 1.00001, 0.99984, 1.00026, 1.00001, 1.00024, 1.00001, 0.9999, 1, 1.0006, 1.00001, 1.00041, 0.99962, 1.00026, 1.0006, 0.99995, 1.00041, 0.99942, 0.99973, 0.99927, 1.00082, 0.99902, 1.00026, 1.00087, 1.0006, 1.00069, 0.99973, 0.99867, 0.99973, 0.9993, 1.00026, 1.00049, 1.00056, 1, 0.99988, 0.99935, 0.99995, 0.99954, 1.00055, 0.99945, 1.00032, 1.0006, 0.99995, 1.00026, 0.99995, 1.00032, 1.00001, 1.00008, 0.99971, 1.00019, 0.9994, 1.00001, 1.0006, 1.00044, 0.99973, 1.00023, 1.00047, 1, 0.99942, 0.99561, 0.99989, 1.00035, 0.99977, 1.00035, 0.99977, 1.00019, 0.99944, 1.00001, 1.00021, 0.99926, 1.00035, 1.00035, 0.99942, 1.00048, 0.99999, 0.99977, 1.00022, 1.00035, 1.00001, 0.99977, 1.00026, 0.99989, 1.00057, 1.00001, 0.99936, 1.00052, 1.00012, 0.99996, 1.00043, 1, 1.00035, 0.9994, 0.99976, 1.00035, 0.99973, 1.00052, 1.00041, 1.00119, 1.00037, 0.99973, 1.00002, 0.99986, 1.00041, 1.00041, 0.99902, 0.9996, 1.00034, 0.99999, 1.00026, 0.99999, 1.00026, 0.99973, 1.00052, 0.99973, 1, 0.99973, 1.00041, 1.00075, 0.9994, 1.0003, 0.99999, 1, 1.00041, 0.99955, 1, 0.99915, 0.99973, 0.99973, 1.00026, 1.00119, 0.99955, 0.99973, 1.0006, 0.99911, 1.0006, 1.00026, 0.99972, 1.00026, 0.99902, 1.00041, 0.99973, 0.99999, 1, 1, 1.00038, 1.0005, 1.00016, 1.00022, 1.00016, 1.00022, 1.00016, 1.00022, 1.00001, 0.99973, 1, 1, 0.99973, 1, 1, 0.99955, 1.0006, 1.0006, 1.0006, 1.0006, 1, 1, 1, 0.99973, 0.99973, 0.99972, 1, 1, 1.00106, 0.99999, 0.99998, 0.99998, 0.99999, 0.99998, 1.66475, 1, 0.99973, 0.99973, 1.00023, 0.99973, 0.99971, 1.00047, 1.00023, 1, 0.99991, 0.99984, 1.00002, 1.00002, 1.00002, 1.00002, 1, 1, 1, 1, 1, 1, 1, 0.99972, 1, 1.20985, 1.39713, 1.00003, 1.00031, 1.00015, 1, 0.99561, 1.00027, 1.00031, 1.00031, 0.99915, 1.00031, 1.00031, 0.99999, 1.00003, 0.99999, 0.99999, 1.41144, 1.6, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.40579, 1.40579, 1.36625, 0.99999, 1, 0.99861, 0.99861, 1, 1.00026, 1.00026, 1.00026, 1.00026, 0.99972, 0.99999, 0.99999, 0.99999, 0.99999, 1.40483, 1, 0.99977, 1.00054, 1, 1, 0.99953, 0.99962, 1.00042, 0.9995, 1, 1, 1, 1, 1, 1, 1, 1, 0.99998, 0.99998, 0.99998, 0.99998, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; const HelveticaBoldMetrics = { lineHeight: 1.2, lineGap: 0.2 }; const HelveticaBoldItalicFactors = [0.76116, 1, 1, 1.0006, 0.99998, 0.99974, 0.99973, 0.99973, 0.99982, 0.99977, 1.00087, 0.99998, 0.99998, 0.99959, 1.00003, 1.0006, 0.99998, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99998, 1, 1.00003, 1.00003, 1.00003, 1.00026, 0.9999, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00026, 1.00022, 0.99977, 1.0006, 0.99973, 0.99977, 1.00026, 0.99999, 0.99977, 1.00022, 1.00001, 1.00022, 0.99977, 1.00001, 1.00026, 0.99977, 1.00001, 1.00016, 1.00001, 1.00001, 1.00026, 0.99998, 1.0006, 0.99998, 1.00003, 0.99973, 0.99998, 0.99973, 1.00026, 0.99973, 1.00026, 0.99973, 0.99998, 1.00026, 1.00026, 1.0006, 1.0006, 0.99973, 1.0006, 0.99982, 1.00026, 1.00026, 1.00026, 1.00026, 0.99959, 0.99973, 0.99998, 1.00026, 0.99973, 1.00022, 0.99973, 0.99973, 1, 0.99959, 1.00077, 0.99959, 1.00003, 0.99998, 0.99973, 0.99973, 0.99973, 0.99973, 1.00077, 0.99973, 0.99998, 1.00025, 0.99968, 0.99973, 1.00003, 1.00025, 0.60299, 1.00024, 1.06409, 1, 1, 0.99998, 1, 0.99973, 1.0006, 0.99998, 1, 0.99936, 0.99973, 1.00002, 1.00002, 1.00002, 1.00026, 0.99977, 0.99977, 0.99977, 0.99977, 0.99977, 0.99977, 1, 0.99977, 1.00001, 1.00001, 1.00001, 1.00001, 1.0006, 1.0006, 1.0006, 1.0006, 0.99977, 0.99977, 1.00022, 1.00022, 1.00022, 1.00022, 1.00022, 1.00003, 1.00022, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00001, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99982, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.06409, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 0.99973, 1.00026, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 1.0044, 0.99977, 1.00026, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 0.99971, 0.99973, 0.99973, 1.0006, 0.99977, 0.99973, 0.99973, 1.00026, 1.0006, 1.00026, 1.0006, 1.00026, 1.01011, 1.00026, 0.99999, 1.00026, 1.0006, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.9993, 0.9998, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1, 1.00016, 0.99977, 0.99959, 0.99977, 0.99959, 0.99977, 0.99959, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00026, 0.99998, 1.00026, 0.8121, 1.00026, 0.99998, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 1.00016, 1.00022, 1.00001, 0.99973, 1.00001, 1.00026, 1, 1.00026, 1, 1.00026, 1, 1.0006, 0.99973, 0.99977, 0.99973, 1, 0.99982, 1.00022, 1.00026, 1.00001, 0.99973, 1.00026, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99977, 1, 1, 1.00026, 0.99969, 0.99972, 0.99981, 0.9998, 1.0006, 0.99977, 0.99977, 1.00022, 0.91155, 1.00001, 1.00026, 0.99977, 1.00022, 1.0006, 0.99977, 1.00001, 0.99999, 0.99977, 0.99966, 1.00022, 1.00032, 1.00001, 0.99944, 1.00026, 1.00001, 0.99968, 1.00001, 1.00047, 1, 1.0006, 1.00001, 0.99981, 1.00101, 1.00026, 1.0006, 0.99948, 0.99981, 1.00064, 0.99973, 0.99942, 1.00101, 1.00061, 1.00026, 1.00069, 1.0006, 1.00014, 0.99973, 1.01322, 0.99973, 1.00065, 1.00026, 1.00012, 0.99923, 1, 1.00064, 1.00076, 0.99948, 1.00055, 1.00063, 1.00007, 0.99943, 1.0006, 0.99948, 1.00026, 0.99948, 0.99943, 1.00001, 1.00001, 1.00029, 1.00038, 1.00035, 1.00001, 1.0006, 1.0006, 0.99973, 0.99978, 1.00001, 1.00057, 0.99989, 0.99967, 0.99964, 0.99967, 0.99977, 0.99999, 0.99977, 1.00038, 0.99977, 1.00001, 0.99973, 1.00066, 0.99967, 0.99967, 1.00041, 0.99998, 0.99999, 0.99977, 1.00022, 0.99967, 1.00001, 0.99977, 1.00026, 0.99964, 1.00031, 1.00001, 0.99999, 0.99999, 1, 1.00023, 1, 1, 0.99999, 1.00035, 1.00001, 0.99999, 0.99973, 0.99977, 0.99999, 1.00058, 0.99973, 0.99973, 0.99955, 0.9995, 1.00026, 1.00026, 1.00032, 0.99989, 1.00034, 0.99999, 1.00026, 1.00026, 1.00026, 0.99973, 0.45998, 0.99973, 1.00026, 0.99973, 1.00001, 0.99999, 0.99982, 0.99994, 0.99996, 1, 1.00042, 1.00044, 1.00029, 1.00023, 0.99973, 0.99973, 1.00026, 0.99949, 1.00002, 0.99973, 1.0006, 1.0006, 1.0006, 0.99975, 1.00026, 1.00026, 1.00032, 0.98685, 0.99973, 1.00026, 1, 1, 0.99966, 1.00044, 1.00016, 1.00022, 1.00016, 1.00022, 1.00016, 1.00022, 1.00001, 0.99973, 1, 1, 0.99973, 1, 1, 0.99955, 1.0006, 1.0006, 1.0006, 1.0006, 1, 1, 1, 0.99973, 0.99973, 0.99972, 1, 1, 1.00106, 0.99999, 0.99998, 0.99998, 0.99999, 0.99998, 1.66475, 1, 0.99973, 0.99973, 1, 0.99973, 0.99971, 0.99978, 1, 1, 0.99991, 0.99984, 1.00002, 1.00002, 1.00002, 1.00002, 1.00098, 1, 1, 1, 1.00049, 1, 1, 0.99972, 1, 1.20985, 1.39713, 1.00003, 1.00031, 1.00015, 1, 0.99561, 1.00027, 1.00031, 1.00031, 0.99915, 1.00031, 1.00031, 0.99999, 1.00003, 0.99999, 0.99999, 1.41144, 1.6, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.40579, 1.40579, 1.36625, 0.99999, 1, 0.99861, 0.99861, 1, 1.00026, 1.00026, 1.00026, 1.00026, 0.99972, 0.99999, 0.99999, 0.99999, 0.99999, 1.40483, 1, 0.99977, 1.00054, 1, 1, 0.99953, 0.99962, 1.00042, 0.9995, 1, 1, 1, 1, 1, 1, 1, 1, 0.99998, 0.99998, 0.99998, 0.99998, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; const HelveticaBoldItalicMetrics = { lineHeight: 1.35, lineGap: 0.2 }; const HelveticaItalicFactors = [0.76116, 1, 1, 1.0006, 1.0006, 1.00006, 0.99973, 0.99973, 0.99982, 1.00001, 1.00043, 0.99998, 0.99998, 0.99959, 1.00003, 1.0006, 0.99998, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1, 1.00003, 1.00003, 1.00003, 0.99973, 0.99987, 1.00001, 1.00001, 0.99977, 0.99977, 1.00001, 1.00026, 1.00022, 0.99977, 1.0006, 1, 1.00001, 0.99973, 0.99999, 0.99977, 1.00022, 1.00001, 1.00022, 0.99977, 1.00001, 1.00026, 0.99977, 1.00001, 1.00016, 1.00001, 1.00001, 1.00026, 1.0006, 1.0006, 1.0006, 0.99949, 0.99973, 0.99998, 0.99973, 0.99973, 1, 0.99973, 0.99973, 1.0006, 0.99973, 0.99973, 0.99924, 0.99924, 1, 0.99924, 0.99999, 0.99973, 0.99973, 0.99973, 0.99973, 0.99998, 1, 1.0006, 0.99973, 1, 0.99977, 1, 1, 1, 1.00005, 1.0009, 1.00005, 1.00003, 0.99998, 0.99973, 0.99973, 0.99973, 0.99973, 1.0009, 0.99973, 0.99998, 1.00025, 0.99968, 0.99973, 1.00003, 1.00025, 0.60299, 1.00024, 1.06409, 1, 1, 0.99998, 1, 0.9998, 1.0006, 0.99998, 1, 0.99936, 0.99973, 1.00002, 1.00002, 1.00002, 1.00026, 1.00001, 1.00001, 1.00001, 1.00001, 1.00001, 1.00001, 1, 0.99977, 1.00001, 1.00001, 1.00001, 1.00001, 1.0006, 1.0006, 1.0006, 1.0006, 0.99977, 0.99977, 1.00022, 1.00022, 1.00022, 1.00022, 1.00022, 1.00003, 1.00022, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00001, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99982, 1, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.06409, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 1, 0.99973, 1, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 0.99977, 1, 0.99977, 1, 0.99977, 1, 0.99977, 1, 0.99977, 1.0288, 0.99977, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 0.99924, 1.0006, 1.0006, 0.99946, 1.00034, 1, 0.99924, 1.00001, 1, 1, 0.99973, 0.99924, 0.99973, 0.99924, 0.99973, 1.06311, 0.99973, 1.00024, 0.99973, 0.99924, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 1.00041, 0.9998, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1, 1.00016, 0.99977, 0.99998, 0.99977, 0.99998, 0.99977, 0.99998, 1.00001, 1, 1.00001, 1, 1.00001, 1, 1.00001, 1, 1.00026, 1.0006, 1.00026, 0.89547, 1.00026, 1.0006, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 1.00016, 0.99977, 1.00001, 1, 1.00001, 1.00026, 1, 1.00026, 1, 1.00026, 1, 0.99924, 0.99973, 1.00001, 0.99973, 1, 0.99982, 1.00022, 1.00026, 1.00001, 1, 1.00026, 1.0006, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 1.00001, 1, 1.00054, 0.99977, 1.00084, 1.00007, 0.99973, 1.00013, 0.99924, 1.00001, 1.00001, 0.99945, 0.91221, 1.00001, 1.00026, 0.99977, 1.00022, 1.0006, 1.00001, 1.00001, 0.99999, 0.99977, 0.99933, 1.00022, 1.00054, 1.00001, 1.00065, 1.00026, 1.00001, 1.0001, 1.00001, 1.00052, 1, 1.0006, 1.00001, 0.99945, 0.99897, 0.99968, 0.99924, 1.00036, 0.99945, 0.99949, 1, 1.0006, 0.99897, 0.99918, 0.99968, 0.99911, 0.99924, 1, 0.99962, 1.01487, 1, 1.0005, 0.99973, 1.00012, 1.00043, 1, 0.99995, 0.99994, 1.00036, 0.99947, 1.00019, 1.00063, 1.00025, 0.99924, 1.00036, 0.99973, 1.00036, 1.00025, 1.00001, 1.00001, 1.00027, 1.0001, 1.00068, 1.00001, 1.0006, 1.0006, 1, 1.00008, 0.99957, 0.99972, 0.9994, 0.99954, 0.99975, 1.00051, 1.00001, 1.00019, 1.00001, 1.0001, 0.99986, 1.00001, 1.00001, 1.00038, 0.99954, 0.99954, 0.9994, 1.00066, 0.99999, 0.99977, 1.00022, 1.00054, 1.00001, 0.99977, 1.00026, 0.99975, 1.0001, 1.00001, 0.99993, 0.9995, 0.99955, 1.00016, 0.99978, 0.99974, 1.00019, 1.00022, 0.99955, 1.00053, 0.99973, 1.00089, 1.00005, 0.99967, 1.00048, 0.99973, 1.00002, 1.00034, 0.99973, 0.99973, 0.99964, 1.00006, 1.00066, 0.99947, 0.99973, 0.98894, 0.99973, 1, 0.44898, 1, 0.99946, 1, 1.00039, 1.00082, 0.99991, 0.99991, 0.99985, 1.00022, 1.00023, 1.00061, 1.00006, 0.99966, 0.99973, 0.99973, 0.99973, 1.00019, 1.0008, 1, 0.99924, 0.99924, 0.99924, 0.99983, 1.00044, 0.99973, 0.99964, 0.98332, 1, 0.99973, 1, 1, 0.99962, 0.99895, 1.00016, 0.99977, 1.00016, 0.99977, 1.00016, 0.99977, 1.00001, 1, 1, 1, 0.99973, 1, 1, 0.99955, 0.99924, 0.99924, 0.99924, 0.99924, 0.99998, 0.99998, 0.99998, 0.99973, 0.99973, 0.99972, 1, 1, 1.00267, 0.99999, 0.99998, 0.99998, 1, 0.99998, 1.66475, 1, 0.99973, 0.99973, 1.00023, 0.99973, 1.00423, 0.99925, 0.99999, 1, 0.99991, 0.99984, 1.00002, 1.00002, 1.00002, 1.00002, 1.00049, 1, 1.00245, 1, 1, 1, 1, 0.96329, 1, 1.20985, 1.39713, 1.00003, 0.8254, 1.00015, 1, 1.00035, 1.00027, 1.00031, 1.00031, 1.00003, 1.00031, 1.00031, 0.99999, 1.00003, 0.99999, 0.99999, 1.41144, 1.6, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.40579, 1.40579, 1.36625, 0.99999, 1, 0.99861, 0.99861, 1, 1.00026, 1.00026, 1.00026, 1.00026, 0.95317, 0.99999, 0.99999, 0.99999, 0.99999, 1.40483, 1, 0.99977, 1.00054, 1, 1, 0.99953, 0.99962, 1.00042, 0.9995, 1, 1, 1, 1, 1, 1, 1, 1, 0.99998, 0.99998, 0.99998, 0.99998, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; const HelveticaItalicMetrics = { lineHeight: 1.35, lineGap: 0.2 }; const HelveticaRegularFactors = [0.76116, 1, 1, 1.0006, 1.0006, 1.00006, 0.99973, 0.99973, 0.99982, 1.00001, 1.00043, 0.99998, 0.99998, 0.99959, 1.00003, 1.0006, 0.99998, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1, 1.00003, 1.00003, 1.00003, 0.99973, 0.99987, 1.00001, 1.00001, 0.99977, 0.99977, 1.00001, 1.00026, 1.00022, 0.99977, 1.0006, 1, 1.00001, 0.99973, 0.99999, 0.99977, 1.00022, 1.00001, 1.00022, 0.99977, 1.00001, 1.00026, 0.99977, 1.00001, 1.00016, 1.00001, 1.00001, 1.00026, 1.0006, 1.0006, 1.0006, 0.99949, 0.99973, 0.99998, 0.99973, 0.99973, 1, 0.99973, 0.99973, 1.0006, 0.99973, 0.99973, 0.99924, 0.99924, 1, 0.99924, 0.99999, 0.99973, 0.99973, 0.99973, 0.99973, 0.99998, 1, 1.0006, 0.99973, 1, 0.99977, 1, 1, 1, 1.00005, 1.0009, 1.00005, 1.00003, 0.99998, 0.99973, 0.99973, 0.99973, 0.99973, 1.0009, 0.99973, 0.99998, 1.00025, 0.99968, 0.99973, 1.00003, 1.00025, 0.60299, 1.00024, 1.06409, 1, 1, 0.99998, 1, 0.9998, 1.0006, 0.99998, 1, 0.99936, 0.99973, 1.00002, 1.00002, 1.00002, 1.00026, 1.00001, 1.00001, 1.00001, 1.00001, 1.00001, 1.00001, 1, 0.99977, 1.00001, 1.00001, 1.00001, 1.00001, 1.0006, 1.0006, 1.0006, 1.0006, 0.99977, 0.99977, 1.00022, 1.00022, 1.00022, 1.00022, 1.00022, 1.00003, 1.00022, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00001, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99982, 1, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.06409, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 1, 0.99973, 1, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 0.99977, 1, 0.99977, 1, 0.99977, 1, 0.99977, 1, 0.99977, 1.04596, 0.99977, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 0.99924, 1.0006, 1.0006, 1.00019, 1.00034, 1, 0.99924, 1.00001, 1, 1, 0.99973, 0.99924, 0.99973, 0.99924, 0.99973, 1.02572, 0.99973, 1.00005, 0.99973, 0.99924, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99999, 0.9998, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1, 1.00016, 0.99977, 0.99998, 0.99977, 0.99998, 0.99977, 0.99998, 1.00001, 1, 1.00001, 1, 1.00001, 1, 1.00001, 1, 1.00026, 1.0006, 1.00026, 0.84533, 1.00026, 1.0006, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 1.00016, 0.99977, 1.00001, 1, 1.00001, 1.00026, 1, 1.00026, 1, 1.00026, 1, 0.99924, 0.99973, 1.00001, 0.99973, 1, 0.99982, 1.00022, 1.00026, 1.00001, 1, 1.00026, 1.0006, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99928, 1, 0.99977, 1.00013, 1.00055, 0.99947, 0.99945, 0.99941, 0.99924, 1.00001, 1.00001, 1.0004, 0.91621, 1.00001, 1.00026, 0.99977, 1.00022, 1.0006, 1.00001, 1.00005, 0.99999, 0.99977, 1.00015, 1.00022, 0.99977, 1.00001, 0.99973, 1.00026, 1.00001, 1.00019, 1.00001, 0.99946, 1, 1.0006, 1.00001, 0.99978, 1.00045, 0.99973, 0.99924, 1.00023, 0.99978, 0.99966, 1, 1.00065, 1.00045, 1.00019, 0.99973, 0.99973, 0.99924, 1, 1, 0.96499, 1, 1.00055, 0.99973, 1.00008, 1.00027, 1, 0.9997, 0.99995, 1.00023, 0.99933, 1.00019, 1.00015, 1.00031, 0.99924, 1.00023, 0.99973, 1.00023, 1.00031, 1.00001, 0.99928, 1.00029, 1.00092, 1.00035, 1.00001, 1.0006, 1.0006, 1, 0.99988, 0.99975, 1, 1.00082, 0.99561, 0.9996, 1.00035, 1.00001, 0.99962, 1.00001, 1.00092, 0.99964, 1.00001, 0.99963, 0.99999, 1.00035, 1.00035, 1.00082, 0.99962, 0.99999, 0.99977, 1.00022, 1.00035, 1.00001, 0.99977, 1.00026, 0.9996, 0.99967, 1.00001, 1.00034, 1.00074, 1.00054, 1.00053, 1.00063, 0.99971, 0.99962, 1.00035, 0.99975, 0.99977, 0.99973, 1.00043, 0.99953, 1.0007, 0.99915, 0.99973, 1.00008, 0.99892, 1.00073, 1.00073, 1.00114, 0.99915, 1.00073, 0.99955, 0.99973, 1.00092, 0.99973, 1, 0.99998, 1, 1.0003, 1, 1.00043, 1.00001, 0.99969, 1.0003, 1, 1.00035, 1.00001, 0.9995, 1, 1.00092, 0.99973, 0.99973, 0.99973, 1.0007, 0.9995, 1, 0.99924, 1.0006, 0.99924, 0.99972, 1.00062, 0.99973, 1.00114, 1.00073, 1, 0.99955, 1, 1, 1.00047, 0.99968, 1.00016, 0.99977, 1.00016, 0.99977, 1.00016, 0.99977, 1.00001, 1, 1, 1, 0.99973, 1, 1, 0.99955, 0.99924, 0.99924, 0.99924, 0.99924, 0.99998, 0.99998, 0.99998, 0.99973, 0.99973, 0.99972, 1, 1, 1.00267, 0.99999, 0.99998, 0.99998, 1, 0.99998, 1.66475, 1, 0.99973, 0.99973, 1.00023, 0.99973, 0.99971, 0.99925, 1.00023, 1, 0.99991, 0.99984, 1.00002, 1.00002, 1.00002, 1.00002, 1, 1, 1, 1, 1, 1, 1, 0.96329, 1, 1.20985, 1.39713, 1.00003, 0.8254, 1.00015, 1, 1.00035, 1.00027, 1.00031, 1.00031, 0.99915, 1.00031, 1.00031, 0.99999, 1.00003, 0.99999, 0.99999, 1.41144, 1.6, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.40579, 1.40579, 1.36625, 0.99999, 1, 0.99861, 0.99861, 1, 1.00026, 1.00026, 1.00026, 1.00026, 0.95317, 0.99999, 0.99999, 0.99999, 0.99999, 1.40483, 1, 0.99977, 1.00054, 1, 1, 0.99953, 0.99962, 1.00042, 0.9995, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; const HelveticaRegularMetrics = { lineHeight: 1.2, lineGap: 0.2 }; ;// CONCATENATED MODULE: ./src/core/liberationsans_widths.js const LiberationSansBoldWidths = [365, 0, 333, 278, 333, 474, 556, 556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556, 278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389, 584, 333, 556, 556, 556, 556, 280, 556, 333, 737, 370, 556, 584, 737, 552, 400, 549, 333, 333, 333, 576, 556, 278, 333, 333, 365, 556, 834, 834, 834, 611, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 556, 556, 556, 556, 556, 278, 278, 278, 278, 611, 611, 611, 611, 611, 611, 611, 549, 611, 611, 611, 611, 611, 556, 611, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 719, 722, 611, 667, 556, 667, 556, 667, 556, 667, 556, 667, 556, 778, 611, 778, 611, 778, 611, 778, 611, 722, 611, 722, 611, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 785, 556, 556, 278, 722, 556, 556, 611, 278, 611, 278, 611, 385, 611, 479, 611, 278, 722, 611, 722, 611, 722, 611, 708, 723, 611, 778, 611, 778, 611, 778, 611, 1000, 944, 722, 389, 722, 389, 722, 389, 667, 556, 667, 556, 667, 556, 667, 556, 611, 333, 611, 479, 611, 333, 722, 611, 722, 611, 722, 611, 722, 611, 722, 611, 722, 611, 944, 778, 667, 556, 667, 611, 500, 611, 500, 611, 500, 278, 556, 722, 556, 1000, 889, 778, 611, 667, 556, 611, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 465, 722, 333, 853, 906, 474, 825, 927, 838, 278, 722, 722, 601, 719, 667, 611, 722, 778, 278, 722, 667, 833, 722, 644, 778, 722, 667, 600, 611, 667, 821, 667, 809, 802, 278, 667, 615, 451, 611, 278, 582, 615, 610, 556, 606, 475, 460, 611, 541, 278, 558, 556, 612, 556, 445, 611, 766, 619, 520, 684, 446, 582, 715, 576, 753, 845, 278, 582, 611, 582, 845, 667, 669, 885, 567, 711, 667, 278, 276, 556, 1094, 1062, 875, 610, 722, 622, 719, 722, 719, 722, 567, 712, 667, 904, 626, 719, 719, 610, 702, 833, 722, 778, 719, 667, 722, 611, 622, 854, 667, 730, 703, 1005, 1019, 870, 979, 719, 711, 1031, 719, 556, 618, 615, 417, 635, 556, 709, 497, 615, 615, 500, 635, 740, 604, 611, 604, 611, 556, 490, 556, 875, 556, 615, 581, 833, 844, 729, 854, 615, 552, 854, 583, 556, 556, 611, 417, 552, 556, 278, 281, 278, 969, 906, 611, 500, 615, 556, 604, 778, 611, 487, 447, 944, 778, 944, 778, 944, 778, 667, 556, 333, 333, 556, 1000, 1000, 552, 278, 278, 278, 278, 500, 500, 500, 556, 556, 350, 1000, 1000, 240, 479, 333, 333, 604, 333, 167, 396, 556, 556, 1094, 556, 885, 489, 1115, 1000, 768, 600, 834, 834, 834, 834, 1000, 500, 1000, 500, 1000, 500, 500, 494, 612, 823, 713, 584, 549, 713, 979, 722, 274, 549, 549, 583, 549, 549, 604, 584, 604, 604, 708, 625, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 729, 604, 604, 354, 354, 1000, 990, 990, 990, 990, 494, 604, 604, 604, 604, 354, 1021, 1052, 917, 750, 750, 531, 656, 594, 510, 500, 750, 750, 611, 611, 333, 333, 333, 333, 333, 333, 333, 333, 222, 222, 333, 333, 333, 333, 333, 333, 333, 333]; const LiberationSansBoldMapping = [-1, -1, -1, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 402, 506, 507, 508, 509, 510, 511, 536, 537, 538, 539, 710, 711, 713, 728, 729, 730, 731, 732, 733, 900, 901, 902, 903, 904, 905, 906, 908, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1138, 1139, 1168, 1169, 7808, 7809, 7810, 7811, 7812, 7813, 7922, 7923, 8208, 8209, 8211, 8212, 8213, 8215, 8216, 8217, 8218, 8219, 8220, 8221, 8222, 8224, 8225, 8226, 8230, 8240, 8242, 8243, 8249, 8250, 8252, 8254, 8260, 8319, 8355, 8356, 8359, 8364, 8453, 8467, 8470, 8482, 8486, 8494, 8539, 8540, 8541, 8542, 8592, 8593, 8594, 8595, 8596, 8597, 8616, 8706, 8710, 8719, 8721, 8722, 8730, 8734, 8735, 8745, 8747, 8776, 8800, 8801, 8804, 8805, 8962, 8976, 8992, 8993, 9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9552, 9553, 9554, 9555, 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9564, 9565, 9566, 9567, 9568, 9569, 9570, 9571, 9572, 9573, 9574, 9575, 9576, 9577, 9578, 9579, 9580, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 9632, 9633, 9642, 9643, 9644, 9650, 9658, 9660, 9668, 9674, 9675, 9679, 9688, 9689, 9702, 9786, 9787, 9788, 9792, 9794, 9824, 9827, 9829, 9830, 9834, 9835, 9836, 61441, 61442, 61445, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]; const LiberationSansBoldItalicWidths = [365, 0, 333, 278, 333, 474, 556, 556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556, 278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389, 584, 333, 556, 556, 556, 556, 280, 556, 333, 737, 370, 556, 584, 737, 552, 400, 549, 333, 333, 333, 576, 556, 278, 333, 333, 365, 556, 834, 834, 834, 611, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 556, 556, 556, 556, 556, 278, 278, 278, 278, 611, 611, 611, 611, 611, 611, 611, 549, 611, 611, 611, 611, 611, 556, 611, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 740, 722, 611, 667, 556, 667, 556, 667, 556, 667, 556, 667, 556, 778, 611, 778, 611, 778, 611, 778, 611, 722, 611, 722, 611, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 782, 556, 556, 278, 722, 556, 556, 611, 278, 611, 278, 611, 396, 611, 479, 611, 278, 722, 611, 722, 611, 722, 611, 708, 723, 611, 778, 611, 778, 611, 778, 611, 1000, 944, 722, 389, 722, 389, 722, 389, 667, 556, 667, 556, 667, 556, 667, 556, 611, 333, 611, 479, 611, 333, 722, 611, 722, 611, 722, 611, 722, 611, 722, 611, 722, 611, 944, 778, 667, 556, 667, 611, 500, 611, 500, 611, 500, 278, 556, 722, 556, 1000, 889, 778, 611, 667, 556, 611, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 722, 333, 854, 906, 473, 844, 930, 847, 278, 722, 722, 610, 671, 667, 611, 722, 778, 278, 722, 667, 833, 722, 657, 778, 718, 667, 590, 611, 667, 822, 667, 829, 781, 278, 667, 620, 479, 611, 278, 591, 620, 621, 556, 610, 479, 492, 611, 558, 278, 566, 556, 603, 556, 450, 611, 712, 605, 532, 664, 409, 591, 704, 578, 773, 834, 278, 591, 611, 591, 834, 667, 667, 886, 614, 719, 667, 278, 278, 556, 1094, 1042, 854, 622, 719, 677, 719, 722, 708, 722, 614, 722, 667, 927, 643, 719, 719, 615, 687, 833, 722, 778, 719, 667, 722, 611, 677, 781, 667, 729, 708, 979, 989, 854, 1000, 708, 719, 1042, 729, 556, 619, 604, 534, 618, 556, 736, 510, 611, 611, 507, 622, 740, 604, 611, 611, 611, 556, 889, 556, 885, 556, 646, 583, 889, 935, 707, 854, 594, 552, 865, 589, 556, 556, 611, 469, 563, 556, 278, 278, 278, 969, 906, 611, 507, 619, 556, 611, 778, 611, 575, 467, 944, 778, 944, 778, 944, 778, 667, 556, 333, 333, 556, 1000, 1000, 552, 278, 278, 278, 278, 500, 500, 500, 556, 556, 350, 1000, 1000, 240, 479, 333, 333, 604, 333, 167, 396, 556, 556, 1104, 556, 885, 516, 1146, 1000, 768, 600, 834, 834, 834, 834, 999, 500, 1000, 500, 1000, 500, 500, 494, 612, 823, 713, 584, 549, 713, 979, 722, 274, 549, 549, 583, 549, 549, 604, 584, 604, 604, 708, 625, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 729, 604, 604, 354, 354, 1000, 990, 990, 990, 990, 494, 604, 604, 604, 604, 354, 1021, 1052, 917, 750, 750, 531, 656, 594, 510, 500, 750, 750, 611, 611, 333, 333, 333, 333, 333, 333, 333, 333, 222, 222, 333, 333, 333, 333, 333, 333, 333, 333]; const LiberationSansBoldItalicMapping = [-1, -1, -1, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 402, 506, 507, 508, 509, 510, 511, 536, 537, 538, 539, 710, 711, 713, 728, 729, 730, 731, 732, 733, 900, 901, 902, 903, 904, 905, 906, 908, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1138, 1139, 1168, 1169, 7808, 7809, 7810, 7811, 7812, 7813, 7922, 7923, 8208, 8209, 8211, 8212, 8213, 8215, 8216, 8217, 8218, 8219, 8220, 8221, 8222, 8224, 8225, 8226, 8230, 8240, 8242, 8243, 8249, 8250, 8252, 8254, 8260, 8319, 8355, 8356, 8359, 8364, 8453, 8467, 8470, 8482, 8486, 8494, 8539, 8540, 8541, 8542, 8592, 8593, 8594, 8595, 8596, 8597, 8616, 8706, 8710, 8719, 8721, 8722, 8730, 8734, 8735, 8745, 8747, 8776, 8800, 8801, 8804, 8805, 8962, 8976, 8992, 8993, 9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9552, 9553, 9554, 9555, 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9564, 9565, 9566, 9567, 9568, 9569, 9570, 9571, 9572, 9573, 9574, 9575, 9576, 9577, 9578, 9579, 9580, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 9632, 9633, 9642, 9643, 9644, 9650, 9658, 9660, 9668, 9674, 9675, 9679, 9688, 9689, 9702, 9786, 9787, 9788, 9792, 9794, 9824, 9827, 9829, 9830, 9834, 9835, 9836, 61441, 61442, 61445, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]; const LiberationSansItalicWidths = [365, 0, 333, 278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556, 1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 278, 278, 278, 469, 556, 333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584, 333, 556, 556, 556, 556, 260, 556, 333, 737, 370, 556, 584, 737, 552, 400, 549, 333, 333, 333, 576, 537, 278, 333, 333, 365, 556, 834, 834, 834, 611, 667, 667, 667, 667, 667, 667, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 500, 556, 556, 556, 556, 278, 278, 278, 278, 556, 556, 556, 556, 556, 556, 556, 549, 611, 556, 556, 556, 556, 500, 556, 500, 667, 556, 667, 556, 667, 556, 722, 500, 722, 500, 722, 500, 722, 500, 722, 625, 722, 556, 667, 556, 667, 556, 667, 556, 667, 556, 667, 556, 778, 556, 778, 556, 778, 556, 778, 556, 722, 556, 722, 556, 278, 278, 278, 278, 278, 278, 278, 222, 278, 278, 733, 444, 500, 222, 667, 500, 500, 556, 222, 556, 222, 556, 281, 556, 400, 556, 222, 722, 556, 722, 556, 722, 556, 615, 723, 556, 778, 556, 778, 556, 778, 556, 1000, 944, 722, 333, 722, 333, 722, 333, 667, 500, 667, 500, 667, 500, 667, 500, 611, 278, 611, 354, 611, 278, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 944, 722, 667, 500, 667, 611, 500, 611, 500, 611, 500, 222, 556, 667, 556, 1000, 889, 778, 611, 667, 500, 611, 278, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 667, 278, 789, 846, 389, 794, 865, 775, 222, 667, 667, 570, 671, 667, 611, 722, 778, 278, 667, 667, 833, 722, 648, 778, 725, 667, 600, 611, 667, 837, 667, 831, 761, 278, 667, 570, 439, 555, 222, 550, 570, 571, 500, 556, 439, 463, 555, 542, 222, 500, 492, 548, 500, 447, 556, 670, 573, 486, 603, 374, 550, 652, 546, 728, 779, 222, 550, 556, 550, 779, 667, 667, 843, 544, 708, 667, 278, 278, 500, 1066, 982, 844, 589, 715, 639, 724, 667, 651, 667, 544, 704, 667, 917, 614, 715, 715, 589, 686, 833, 722, 778, 725, 667, 722, 611, 639, 795, 667, 727, 673, 920, 923, 805, 886, 651, 694, 1022, 682, 556, 562, 522, 493, 553, 556, 688, 465, 556, 556, 472, 564, 686, 550, 556, 556, 556, 500, 833, 500, 835, 500, 572, 518, 830, 851, 621, 736, 526, 492, 752, 534, 556, 556, 556, 378, 496, 500, 222, 222, 222, 910, 828, 556, 472, 565, 500, 556, 778, 556, 492, 339, 944, 722, 944, 722, 944, 722, 667, 500, 333, 333, 556, 1000, 1000, 552, 222, 222, 222, 222, 333, 333, 333, 556, 556, 350, 1000, 1000, 188, 354, 333, 333, 500, 333, 167, 365, 556, 556, 1094, 556, 885, 323, 1083, 1000, 768, 600, 834, 834, 834, 834, 1000, 500, 998, 500, 1000, 500, 500, 494, 612, 823, 713, 584, 549, 713, 979, 719, 274, 549, 549, 584, 549, 549, 604, 584, 604, 604, 708, 625, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 729, 604, 604, 354, 354, 1000, 990, 990, 990, 990, 494, 604, 604, 604, 604, 354, 1021, 1052, 917, 750, 750, 531, 656, 594, 510, 500, 750, 750, 500, 500, 333, 333, 333, 333, 333, 333, 333, 333, 222, 222, 294, 294, 324, 324, 316, 328, 398, 285]; const LiberationSansItalicMapping = [-1, -1, -1, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 402, 506, 507, 508, 509, 510, 511, 536, 537, 538, 539, 710, 711, 713, 728, 729, 730, 731, 732, 733, 900, 901, 902, 903, 904, 905, 906, 908, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1138, 1139, 1168, 1169, 7808, 7809, 7810, 7811, 7812, 7813, 7922, 7923, 8208, 8209, 8211, 8212, 8213, 8215, 8216, 8217, 8218, 8219, 8220, 8221, 8222, 8224, 8225, 8226, 8230, 8240, 8242, 8243, 8249, 8250, 8252, 8254, 8260, 8319, 8355, 8356, 8359, 8364, 8453, 8467, 8470, 8482, 8486, 8494, 8539, 8540, 8541, 8542, 8592, 8593, 8594, 8595, 8596, 8597, 8616, 8706, 8710, 8719, 8721, 8722, 8730, 8734, 8735, 8745, 8747, 8776, 8800, 8801, 8804, 8805, 8962, 8976, 8992, 8993, 9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9552, 9553, 9554, 9555, 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9564, 9565, 9566, 9567, 9568, 9569, 9570, 9571, 9572, 9573, 9574, 9575, 9576, 9577, 9578, 9579, 9580, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 9632, 9633, 9642, 9643, 9644, 9650, 9658, 9660, 9668, 9674, 9675, 9679, 9688, 9689, 9702, 9786, 9787, 9788, 9792, 9794, 9824, 9827, 9829, 9830, 9834, 9835, 9836, 61441, 61442, 61445, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]; const LiberationSansRegularWidths = [365, 0, 333, 278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556, 1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 278, 278, 278, 469, 556, 333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584, 333, 556, 556, 556, 556, 260, 556, 333, 737, 370, 556, 584, 737, 552, 400, 549, 333, 333, 333, 576, 537, 278, 333, 333, 365, 556, 834, 834, 834, 611, 667, 667, 667, 667, 667, 667, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 500, 556, 556, 556, 556, 278, 278, 278, 278, 556, 556, 556, 556, 556, 556, 556, 549, 611, 556, 556, 556, 556, 500, 556, 500, 667, 556, 667, 556, 667, 556, 722, 500, 722, 500, 722, 500, 722, 500, 722, 615, 722, 556, 667, 556, 667, 556, 667, 556, 667, 556, 667, 556, 778, 556, 778, 556, 778, 556, 778, 556, 722, 556, 722, 556, 278, 278, 278, 278, 278, 278, 278, 222, 278, 278, 735, 444, 500, 222, 667, 500, 500, 556, 222, 556, 222, 556, 292, 556, 334, 556, 222, 722, 556, 722, 556, 722, 556, 604, 723, 556, 778, 556, 778, 556, 778, 556, 1000, 944, 722, 333, 722, 333, 722, 333, 667, 500, 667, 500, 667, 500, 667, 500, 611, 278, 611, 375, 611, 278, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 944, 722, 667, 500, 667, 611, 500, 611, 500, 611, 500, 222, 556, 667, 556, 1000, 889, 778, 611, 667, 500, 611, 278, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 667, 278, 784, 838, 384, 774, 855, 752, 222, 667, 667, 551, 668, 667, 611, 722, 778, 278, 667, 668, 833, 722, 650, 778, 722, 667, 618, 611, 667, 798, 667, 835, 748, 278, 667, 578, 446, 556, 222, 547, 578, 575, 500, 557, 446, 441, 556, 556, 222, 500, 500, 576, 500, 448, 556, 690, 569, 482, 617, 395, 547, 648, 525, 713, 781, 222, 547, 556, 547, 781, 667, 667, 865, 542, 719, 667, 278, 278, 500, 1057, 1010, 854, 583, 722, 635, 719, 667, 656, 667, 542, 677, 667, 923, 604, 719, 719, 583, 656, 833, 722, 778, 719, 667, 722, 611, 635, 760, 667, 740, 667, 917, 938, 792, 885, 656, 719, 1010, 722, 556, 573, 531, 365, 583, 556, 669, 458, 559, 559, 438, 583, 688, 552, 556, 542, 556, 500, 458, 500, 823, 500, 573, 521, 802, 823, 625, 719, 521, 510, 750, 542, 556, 556, 556, 365, 510, 500, 222, 278, 222, 906, 812, 556, 438, 559, 500, 552, 778, 556, 489, 411, 944, 722, 944, 722, 944, 722, 667, 500, 333, 333, 556, 1000, 1000, 552, 222, 222, 222, 222, 333, 333, 333, 556, 556, 350, 1000, 1000, 188, 354, 333, 333, 500, 333, 167, 365, 556, 556, 1094, 556, 885, 323, 1073, 1000, 768, 600, 834, 834, 834, 834, 1000, 500, 1000, 500, 1000, 500, 500, 494, 612, 823, 713, 584, 549, 713, 979, 719, 274, 549, 549, 583, 549, 549, 604, 584, 604, 604, 708, 625, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 729, 604, 604, 354, 354, 1000, 990, 990, 990, 990, 494, 604, 604, 604, 604, 354, 1021, 1052, 917, 750, 750, 531, 656, 594, 510, 500, 750, 750, 500, 500, 333, 333, 333, 333, 333, 333, 333, 333, 222, 222, 294, 294, 324, 324, 316, 328, 398, 285]; const LiberationSansRegularMapping = [-1, -1, -1, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 402, 506, 507, 508, 509, 510, 511, 536, 537, 538, 539, 710, 711, 713, 728, 729, 730, 731, 732, 733, 900, 901, 902, 903, 904, 905, 906, 908, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1138, 1139, 1168, 1169, 7808, 7809, 7810, 7811, 7812, 7813, 7922, 7923, 8208, 8209, 8211, 8212, 8213, 8215, 8216, 8217, 8218, 8219, 8220, 8221, 8222, 8224, 8225, 8226, 8230, 8240, 8242, 8243, 8249, 8250, 8252, 8254, 8260, 8319, 8355, 8356, 8359, 8364, 8453, 8467, 8470, 8482, 8486, 8494, 8539, 8540, 8541, 8542, 8592, 8593, 8594, 8595, 8596, 8597, 8616, 8706, 8710, 8719, 8721, 8722, 8730, 8734, 8735, 8745, 8747, 8776, 8800, 8801, 8804, 8805, 8962, 8976, 8992, 8993, 9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9552, 9553, 9554, 9555, 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9564, 9565, 9566, 9567, 9568, 9569, 9570, 9571, 9572, 9573, 9574, 9575, 9576, 9577, 9578, 9579, 9580, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 9632, 9633, 9642, 9643, 9644, 9650, 9658, 9660, 9668, 9674, 9675, 9679, 9688, 9689, 9702, 9786, 9787, 9788, 9792, 9794, 9824, 9827, 9829, 9830, 9834, 9835, 9836, 61441, 61442, 61445, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]; ;// CONCATENATED MODULE: ./src/core/myriadpro_factors.js const MyriadProBoldFactors = [1.36898, 1, 1, 0.72706, 0.80479, 0.83734, 0.98894, 0.99793, 0.9897, 0.93884, 0.86209, 0.94292, 0.94292, 1.16661, 1.02058, 0.93582, 0.96694, 0.93582, 1.19137, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.78076, 0.78076, 1.02058, 1.02058, 1.02058, 0.72851, 0.78966, 0.90838, 0.83637, 0.82391, 0.96376, 0.80061, 0.86275, 0.8768, 0.95407, 1.0258, 0.73901, 0.85022, 0.83655, 1.0156, 0.95546, 0.92179, 0.87107, 0.92179, 0.82114, 0.8096, 0.89713, 0.94438, 0.95353, 0.94083, 0.91905, 0.90406, 0.9446, 0.94292, 1.18777, 0.94292, 1.02058, 0.89903, 0.90088, 0.94938, 0.97898, 0.81093, 0.97571, 0.94938, 1.024, 0.9577, 0.95933, 0.98621, 1.0474, 0.97455, 0.98981, 0.9672, 0.95933, 0.9446, 0.97898, 0.97407, 0.97646, 0.78036, 1.10208, 0.95442, 0.95298, 0.97579, 0.9332, 0.94039, 0.938, 0.80687, 1.01149, 0.80687, 1.02058, 0.80479, 0.99793, 0.99793, 0.99793, 0.99793, 1.01149, 1.00872, 0.90088, 0.91882, 1.0213, 0.8361, 1.02058, 0.62295, 0.54324, 0.89022, 1.08595, 1, 1, 0.90088, 1, 0.97455, 0.93582, 0.90088, 1, 1.05686, 0.8361, 0.99642, 0.99642, 0.99642, 0.72851, 0.90838, 0.90838, 0.90838, 0.90838, 0.90838, 0.90838, 0.868, 0.82391, 0.80061, 0.80061, 0.80061, 0.80061, 1.0258, 1.0258, 1.0258, 1.0258, 0.97484, 0.95546, 0.92179, 0.92179, 0.92179, 0.92179, 0.92179, 1.02058, 0.92179, 0.94438, 0.94438, 0.94438, 0.94438, 0.90406, 0.86958, 0.98225, 0.94938, 0.94938, 0.94938, 0.94938, 0.94938, 0.94938, 0.9031, 0.81093, 0.94938, 0.94938, 0.94938, 0.94938, 0.98621, 0.98621, 0.98621, 0.98621, 0.93969, 0.95933, 0.9446, 0.9446, 0.9446, 0.9446, 0.9446, 1.08595, 0.9446, 0.95442, 0.95442, 0.95442, 0.95442, 0.94039, 0.97898, 0.94039, 0.90838, 0.94938, 0.90838, 0.94938, 0.90838, 0.94938, 0.82391, 0.81093, 0.82391, 0.81093, 0.82391, 0.81093, 0.82391, 0.81093, 0.96376, 0.84313, 0.97484, 0.97571, 0.80061, 0.94938, 0.80061, 0.94938, 0.80061, 0.94938, 0.80061, 0.94938, 0.80061, 0.94938, 0.8768, 0.9577, 0.8768, 0.9577, 0.8768, 0.9577, 1, 1, 0.95407, 0.95933, 0.97069, 0.95933, 1.0258, 0.98621, 1.0258, 0.98621, 1.0258, 0.98621, 1.0258, 0.98621, 1.0258, 0.98621, 0.887, 1.01591, 0.73901, 1.0474, 1, 1, 0.97455, 0.83655, 0.98981, 1, 1, 0.83655, 0.73977, 0.83655, 0.73903, 0.84638, 1.033, 0.95546, 0.95933, 1, 1, 0.95546, 0.95933, 0.8271, 0.95417, 0.95933, 0.92179, 0.9446, 0.92179, 0.9446, 0.92179, 0.9446, 0.936, 0.91964, 0.82114, 0.97646, 1, 1, 0.82114, 0.97646, 0.8096, 0.78036, 0.8096, 0.78036, 1, 1, 0.8096, 0.78036, 1, 1, 0.89713, 0.77452, 0.89713, 1.10208, 0.94438, 0.95442, 0.94438, 0.95442, 0.94438, 0.95442, 0.94438, 0.95442, 0.94438, 0.95442, 0.94438, 0.95442, 0.94083, 0.97579, 0.90406, 0.94039, 0.90406, 0.9446, 0.938, 0.9446, 0.938, 0.9446, 0.938, 1, 0.99793, 0.90838, 0.94938, 0.868, 0.9031, 0.92179, 0.9446, 1, 1, 0.89713, 1.10208, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90989, 0.9358, 0.91945, 0.83181, 0.75261, 0.87992, 0.82976, 0.96034, 0.83689, 0.97268, 1.0078, 0.90838, 0.83637, 0.8019, 0.90157, 0.80061, 0.9446, 0.95407, 0.92436, 1.0258, 0.85022, 0.97153, 1.0156, 0.95546, 0.89192, 0.92179, 0.92361, 0.87107, 0.96318, 0.89713, 0.93704, 0.95638, 0.91905, 0.91709, 0.92796, 1.0258, 0.93704, 0.94836, 1.0373, 0.95933, 1.0078, 0.95871, 0.94836, 0.96174, 0.92601, 0.9498, 0.98607, 0.95776, 0.95933, 1.05453, 1.0078, 0.98275, 0.9314, 0.95617, 0.91701, 1.05993, 0.9446, 0.78367, 0.9553, 1, 0.86832, 1.0128, 0.95871, 0.99394, 0.87548, 0.96361, 0.86774, 1.0078, 0.95871, 0.9446, 0.95871, 0.86774, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.94083, 0.97579, 0.94083, 0.97579, 0.94083, 0.97579, 0.90406, 0.94039, 0.96694, 1, 0.89903, 1, 1, 1, 0.93582, 0.93582, 0.93582, 1, 0.908, 0.908, 0.918, 0.94219, 0.94219, 0.96544, 1, 1.285, 1, 1, 0.81079, 0.81079, 1, 1, 0.74854, 1, 1, 1, 1, 0.99793, 1, 1, 1, 0.65, 1, 1.36145, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.17173, 1, 0.80535, 0.76169, 1.02058, 1.0732, 1.05486, 1, 1, 1.30692, 1.08595, 1.08595, 1, 1.08595, 1.08595, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.16161, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; const MyriadProBoldMetrics = { lineHeight: 1.2, lineGap: 0.2 }; const MyriadProBoldItalicFactors = [1.36898, 1, 1, 0.66227, 0.80779, 0.81625, 0.97276, 0.97276, 0.97733, 0.92222, 0.83266, 0.94292, 0.94292, 1.16148, 1.02058, 0.93582, 0.96694, 0.93582, 1.17337, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.78076, 0.78076, 1.02058, 1.02058, 1.02058, 0.71541, 0.76813, 0.85576, 0.80591, 0.80729, 0.94299, 0.77512, 0.83655, 0.86523, 0.92222, 0.98621, 0.71743, 0.81698, 0.79726, 0.98558, 0.92222, 0.90637, 0.83809, 0.90637, 0.80729, 0.76463, 0.86275, 0.90699, 0.91605, 0.9154, 0.85308, 0.85458, 0.90531, 0.94292, 1.21296, 0.94292, 1.02058, 0.89903, 1.18616, 0.99613, 0.91677, 0.78216, 0.91677, 0.90083, 0.98796, 0.9135, 0.92168, 0.95381, 0.98981, 0.95298, 0.95381, 0.93459, 0.92168, 0.91513, 0.92004, 0.91677, 0.95077, 0.748, 1.04502, 0.91677, 0.92061, 0.94236, 0.89544, 0.89364, 0.9, 0.80687, 0.8578, 0.80687, 1.02058, 0.80779, 0.97276, 0.97276, 0.97276, 0.97276, 0.8578, 0.99973, 1.18616, 0.91339, 1.08074, 0.82891, 1.02058, 0.55509, 0.71526, 0.89022, 1.08595, 1, 1, 1.18616, 1, 0.96736, 0.93582, 1.18616, 1, 1.04864, 0.82711, 0.99043, 0.99043, 0.99043, 0.71541, 0.85576, 0.85576, 0.85576, 0.85576, 0.85576, 0.85576, 0.845, 0.80729, 0.77512, 0.77512, 0.77512, 0.77512, 0.98621, 0.98621, 0.98621, 0.98621, 0.95961, 0.92222, 0.90637, 0.90637, 0.90637, 0.90637, 0.90637, 1.02058, 0.90251, 0.90699, 0.90699, 0.90699, 0.90699, 0.85458, 0.83659, 0.94951, 0.99613, 0.99613, 0.99613, 0.99613, 0.99613, 0.99613, 0.85811, 0.78216, 0.90083, 0.90083, 0.90083, 0.90083, 0.95381, 0.95381, 0.95381, 0.95381, 0.9135, 0.92168, 0.91513, 0.91513, 0.91513, 0.91513, 0.91513, 1.08595, 0.91677, 0.91677, 0.91677, 0.91677, 0.91677, 0.89364, 0.92332, 0.89364, 0.85576, 0.99613, 0.85576, 0.99613, 0.85576, 0.99613, 0.80729, 0.78216, 0.80729, 0.78216, 0.80729, 0.78216, 0.80729, 0.78216, 0.94299, 0.76783, 0.95961, 0.91677, 0.77512, 0.90083, 0.77512, 0.90083, 0.77512, 0.90083, 0.77512, 0.90083, 0.77512, 0.90083, 0.86523, 0.9135, 0.86523, 0.9135, 0.86523, 0.9135, 1, 1, 0.92222, 0.92168, 0.92222, 0.92168, 0.98621, 0.95381, 0.98621, 0.95381, 0.98621, 0.95381, 0.98621, 0.95381, 0.98621, 0.95381, 0.86036, 0.97096, 0.71743, 0.98981, 1, 1, 0.95298, 0.79726, 0.95381, 1, 1, 0.79726, 0.6894, 0.79726, 0.74321, 0.81691, 1.0006, 0.92222, 0.92168, 1, 1, 0.92222, 0.92168, 0.79464, 0.92098, 0.92168, 0.90637, 0.91513, 0.90637, 0.91513, 0.90637, 0.91513, 0.909, 0.87514, 0.80729, 0.95077, 1, 1, 0.80729, 0.95077, 0.76463, 0.748, 0.76463, 0.748, 1, 1, 0.76463, 0.748, 1, 1, 0.86275, 0.72651, 0.86275, 1.04502, 0.90699, 0.91677, 0.90699, 0.91677, 0.90699, 0.91677, 0.90699, 0.91677, 0.90699, 0.91677, 0.90699, 0.91677, 0.9154, 0.94236, 0.85458, 0.89364, 0.85458, 0.90531, 0.9, 0.90531, 0.9, 0.90531, 0.9, 1, 0.97276, 0.85576, 0.99613, 0.845, 0.85811, 0.90251, 0.91677, 1, 1, 0.86275, 1.04502, 1.18616, 1.18616, 1.18616, 1.18616, 1.18616, 1.18616, 1.18616, 1.18616, 1.18616, 1.00899, 1.30628, 0.85576, 0.80178, 0.66862, 0.7927, 0.69323, 0.88127, 0.72459, 0.89711, 0.95381, 0.85576, 0.80591, 0.7805, 0.94729, 0.77512, 0.90531, 0.92222, 0.90637, 0.98621, 0.81698, 0.92655, 0.98558, 0.92222, 0.85359, 0.90637, 0.90976, 0.83809, 0.94523, 0.86275, 0.83509, 0.93157, 0.85308, 0.83392, 0.92346, 0.98621, 0.83509, 0.92886, 0.91324, 0.92168, 0.95381, 0.90646, 0.92886, 0.90557, 0.86847, 0.90276, 0.91324, 0.86842, 0.92168, 0.99531, 0.95381, 0.9224, 0.85408, 0.92699, 0.86847, 1.0051, 0.91513, 0.80487, 0.93481, 1, 0.88159, 1.05214, 0.90646, 0.97355, 0.81539, 0.89398, 0.85923, 0.95381, 0.90646, 0.91513, 0.90646, 0.85923, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9154, 0.94236, 0.9154, 0.94236, 0.9154, 0.94236, 0.85458, 0.89364, 0.96694, 1, 0.89903, 1, 1, 1, 0.91782, 0.91782, 0.91782, 1, 0.896, 0.896, 0.896, 0.9332, 0.9332, 0.95973, 1, 1.26, 1, 1, 0.80479, 0.80178, 1, 1, 0.85633, 1, 1, 1, 1, 0.97276, 1, 1, 1, 0.698, 1, 1.36145, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.14542, 1, 0.79199, 0.78694, 1.02058, 1.03493, 1.05486, 1, 1, 1.23026, 1.08595, 1.08595, 1, 1.08595, 1.08595, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.20006, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; const MyriadProBoldItalicMetrics = { lineHeight: 1.2, lineGap: 0.2 }; const MyriadProItalicFactors = [1.36898, 1, 1, 0.65507, 0.84943, 0.85639, 0.88465, 0.88465, 0.86936, 0.88307, 0.86948, 0.85283, 0.85283, 1.06383, 1.02058, 0.75945, 0.9219, 0.75945, 1.17337, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.75945, 0.75945, 1.02058, 1.02058, 1.02058, 0.69046, 0.70926, 0.85158, 0.77812, 0.76852, 0.89591, 0.70466, 0.76125, 0.80094, 0.86822, 0.83864, 0.728, 0.77212, 0.79475, 0.93637, 0.87514, 0.8588, 0.76013, 0.8588, 0.72421, 0.69866, 0.77598, 0.85991, 0.80811, 0.87832, 0.78112, 0.77512, 0.8562, 1.0222, 1.18417, 1.0222, 1.27014, 0.89903, 1.15012, 0.93859, 0.94399, 0.846, 0.94399, 0.81453, 1.0186, 0.94219, 0.96017, 1.03075, 1.02175, 0.912, 1.03075, 0.96998, 0.96017, 0.93859, 0.94399, 0.94399, 0.95493, 0.746, 1.12658, 0.94578, 0.91, 0.979, 0.882, 0.882, 0.83, 0.85034, 0.83537, 0.85034, 1.02058, 0.70869, 0.88465, 0.88465, 0.88465, 0.88465, 0.83537, 0.90083, 1.15012, 0.9161, 0.94565, 0.73541, 1.02058, 0.53609, 0.69353, 0.79519, 1.08595, 1, 1, 1.15012, 1, 0.91974, 0.75945, 1.15012, 1, 0.9446, 0.73361, 0.9005, 0.9005, 0.9005, 0.62864, 0.85158, 0.85158, 0.85158, 0.85158, 0.85158, 0.85158, 0.773, 0.76852, 0.70466, 0.70466, 0.70466, 0.70466, 0.83864, 0.83864, 0.83864, 0.83864, 0.90561, 0.87514, 0.8588, 0.8588, 0.8588, 0.8588, 0.8588, 1.02058, 0.85751, 0.85991, 0.85991, 0.85991, 0.85991, 0.77512, 0.76013, 0.88075, 0.93859, 0.93859, 0.93859, 0.93859, 0.93859, 0.93859, 0.8075, 0.846, 0.81453, 0.81453, 0.81453, 0.81453, 0.82424, 0.82424, 0.82424, 0.82424, 0.9278, 0.96017, 0.93859, 0.93859, 0.93859, 0.93859, 0.93859, 1.08595, 0.8562, 0.94578, 0.94578, 0.94578, 0.94578, 0.882, 0.94578, 0.882, 0.85158, 0.93859, 0.85158, 0.93859, 0.85158, 0.93859, 0.76852, 0.846, 0.76852, 0.846, 0.76852, 0.846, 0.76852, 0.846, 0.89591, 0.8544, 0.90561, 0.94399, 0.70466, 0.81453, 0.70466, 0.81453, 0.70466, 0.81453, 0.70466, 0.81453, 0.70466, 0.81453, 0.80094, 0.94219, 0.80094, 0.94219, 0.80094, 0.94219, 1, 1, 0.86822, 0.96017, 0.86822, 0.96017, 0.83864, 0.82424, 0.83864, 0.82424, 0.83864, 0.82424, 0.83864, 1.03075, 0.83864, 0.82424, 0.81402, 1.02738, 0.728, 1.02175, 1, 1, 0.912, 0.79475, 1.03075, 1, 1, 0.79475, 0.83911, 0.79475, 0.66266, 0.80553, 1.06676, 0.87514, 0.96017, 1, 1, 0.87514, 0.96017, 0.86865, 0.87396, 0.96017, 0.8588, 0.93859, 0.8588, 0.93859, 0.8588, 0.93859, 0.867, 0.84759, 0.72421, 0.95493, 1, 1, 0.72421, 0.95493, 0.69866, 0.746, 0.69866, 0.746, 1, 1, 0.69866, 0.746, 1, 1, 0.77598, 0.88417, 0.77598, 1.12658, 0.85991, 0.94578, 0.85991, 0.94578, 0.85991, 0.94578, 0.85991, 0.94578, 0.85991, 0.94578, 0.85991, 0.94578, 0.87832, 0.979, 0.77512, 0.882, 0.77512, 0.8562, 0.83, 0.8562, 0.83, 0.8562, 0.83, 1, 0.88465, 0.85158, 0.93859, 0.773, 0.8075, 0.85751, 0.8562, 1, 1, 0.77598, 1.12658, 1.15012, 1.15012, 1.15012, 1.15012, 1.15012, 1.15313, 1.15012, 1.15012, 1.15012, 1.08106, 1.03901, 0.85158, 0.77025, 0.62264, 0.7646, 0.65351, 0.86026, 0.69461, 0.89947, 1.03075, 0.85158, 0.77812, 0.76449, 0.88836, 0.70466, 0.8562, 0.86822, 0.8588, 0.83864, 0.77212, 0.85308, 0.93637, 0.87514, 0.82352, 0.8588, 0.85701, 0.76013, 0.89058, 0.77598, 0.8156, 0.82565, 0.78112, 0.77899, 0.89386, 0.83864, 0.8156, 0.9486, 0.92388, 0.96186, 1.03075, 0.91123, 0.9486, 0.93298, 0.878, 0.93942, 0.92388, 0.84596, 0.96186, 0.95119, 1.03075, 0.922, 0.88787, 0.95829, 0.88, 0.93559, 0.93859, 0.78815, 0.93758, 1, 0.89217, 1.03737, 0.91123, 0.93969, 0.77487, 0.85769, 0.86799, 1.03075, 0.91123, 0.93859, 0.91123, 0.86799, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.87832, 0.979, 0.87832, 0.979, 0.87832, 0.979, 0.77512, 0.882, 0.9219, 1, 0.89903, 1, 1, 1, 0.87321, 0.87321, 0.87321, 1, 1.027, 1.027, 1.027, 0.86847, 0.86847, 0.79121, 1, 1.124, 1, 1, 0.73572, 0.73572, 1, 1, 0.85034, 1, 1, 1, 1, 0.88465, 1, 1, 1, 0.669, 1, 1.36145, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.04828, 1, 0.74948, 0.75187, 1.02058, 0.98391, 1.02119, 1, 1, 1.06233, 1.08595, 1.08595, 1, 1.08595, 1.08595, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.05233, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; const MyriadProItalicMetrics = { lineHeight: 1.2, lineGap: 0.2 }; const MyriadProRegularFactors = [1.36898, 1, 1, 0.76305, 0.82784, 0.94935, 0.89364, 0.92241, 0.89073, 0.90706, 0.98472, 0.85283, 0.85283, 1.0664, 1.02058, 0.74505, 0.9219, 0.74505, 1.23456, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.74505, 0.74505, 1.02058, 1.02058, 1.02058, 0.73002, 0.72601, 0.91755, 0.8126, 0.80314, 0.92222, 0.73764, 0.79726, 0.83051, 0.90284, 0.86023, 0.74, 0.8126, 0.84869, 0.96518, 0.91115, 0.8858, 0.79761, 0.8858, 0.74498, 0.73914, 0.81363, 0.89591, 0.83659, 0.89633, 0.85608, 0.8111, 0.90531, 1.0222, 1.22736, 1.0222, 1.27014, 0.89903, 0.90088, 0.86667, 1.0231, 0.896, 1.01411, 0.90083, 1.05099, 1.00512, 0.99793, 1.05326, 1.09377, 0.938, 1.06226, 1.00119, 0.99793, 0.98714, 1.0231, 1.01231, 0.98196, 0.792, 1.19137, 0.99074, 0.962, 1.01915, 0.926, 0.942, 0.856, 0.85034, 0.92006, 0.85034, 1.02058, 0.69067, 0.92241, 0.92241, 0.92241, 0.92241, 0.92006, 0.9332, 0.90088, 0.91882, 0.93484, 0.75339, 1.02058, 0.56866, 0.54324, 0.79519, 1.08595, 1, 1, 0.90088, 1, 0.95325, 0.74505, 0.90088, 1, 0.97198, 0.75339, 0.91009, 0.91009, 0.91009, 0.66466, 0.91755, 0.91755, 0.91755, 0.91755, 0.91755, 0.91755, 0.788, 0.80314, 0.73764, 0.73764, 0.73764, 0.73764, 0.86023, 0.86023, 0.86023, 0.86023, 0.92915, 0.91115, 0.8858, 0.8858, 0.8858, 0.8858, 0.8858, 1.02058, 0.8858, 0.89591, 0.89591, 0.89591, 0.89591, 0.8111, 0.79611, 0.89713, 0.86667, 0.86667, 0.86667, 0.86667, 0.86667, 0.86667, 0.86936, 0.896, 0.90083, 0.90083, 0.90083, 0.90083, 0.84224, 0.84224, 0.84224, 0.84224, 0.97276, 0.99793, 0.98714, 0.98714, 0.98714, 0.98714, 0.98714, 1.08595, 0.89876, 0.99074, 0.99074, 0.99074, 0.99074, 0.942, 1.0231, 0.942, 0.91755, 0.86667, 0.91755, 0.86667, 0.91755, 0.86667, 0.80314, 0.896, 0.80314, 0.896, 0.80314, 0.896, 0.80314, 0.896, 0.92222, 0.93372, 0.92915, 1.01411, 0.73764, 0.90083, 0.73764, 0.90083, 0.73764, 0.90083, 0.73764, 0.90083, 0.73764, 0.90083, 0.83051, 1.00512, 0.83051, 1.00512, 0.83051, 1.00512, 1, 1, 0.90284, 0.99793, 0.90976, 0.99793, 0.86023, 0.84224, 0.86023, 0.84224, 0.86023, 0.84224, 0.86023, 1.05326, 0.86023, 0.84224, 0.82873, 1.07469, 0.74, 1.09377, 1, 1, 0.938, 0.84869, 1.06226, 1, 1, 0.84869, 0.83704, 0.84869, 0.81441, 0.85588, 1.08927, 0.91115, 0.99793, 1, 1, 0.91115, 0.99793, 0.91887, 0.90991, 0.99793, 0.8858, 0.98714, 0.8858, 0.98714, 0.8858, 0.98714, 0.894, 0.91434, 0.74498, 0.98196, 1, 1, 0.74498, 0.98196, 0.73914, 0.792, 0.73914, 0.792, 1, 1, 0.73914, 0.792, 1, 1, 0.81363, 0.904, 0.81363, 1.19137, 0.89591, 0.99074, 0.89591, 0.99074, 0.89591, 0.99074, 0.89591, 0.99074, 0.89591, 0.99074, 0.89591, 0.99074, 0.89633, 1.01915, 0.8111, 0.942, 0.8111, 0.90531, 0.856, 0.90531, 0.856, 0.90531, 0.856, 1, 0.92241, 0.91755, 0.86667, 0.788, 0.86936, 0.8858, 0.89876, 1, 1, 0.81363, 1.19137, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90388, 1.03901, 0.92138, 0.78105, 0.7154, 0.86169, 0.80513, 0.94007, 0.82528, 0.98612, 1.06226, 0.91755, 0.8126, 0.81884, 0.92819, 0.73764, 0.90531, 0.90284, 0.8858, 0.86023, 0.8126, 0.91172, 0.96518, 0.91115, 0.83089, 0.8858, 0.87791, 0.79761, 0.89297, 0.81363, 0.88157, 0.89992, 0.85608, 0.81992, 0.94307, 0.86023, 0.88157, 0.95308, 0.98699, 0.99793, 1.06226, 0.95817, 0.95308, 0.97358, 0.928, 0.98088, 0.98699, 0.92761, 0.99793, 0.96017, 1.06226, 0.986, 0.944, 0.95978, 0.938, 0.96705, 0.98714, 0.80442, 0.98972, 1, 0.89762, 1.04552, 0.95817, 0.99007, 0.87064, 0.91879, 0.88888, 1.06226, 0.95817, 0.98714, 0.95817, 0.88888, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.89633, 1.01915, 0.89633, 1.01915, 0.89633, 1.01915, 0.8111, 0.942, 0.9219, 1, 0.89903, 1, 1, 1, 0.93173, 0.93173, 0.93173, 1, 1.06304, 1.06304, 1.06904, 0.89903, 0.89903, 0.80549, 1, 1.156, 1, 1, 0.76575, 0.76575, 1, 1, 0.72458, 1, 1, 1, 1, 0.92241, 1, 1, 1, 0.619, 1, 1.36145, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.07257, 1, 0.74705, 0.71119, 1.02058, 1.024, 1.02119, 1, 1, 1.1536, 1.08595, 1.08595, 1, 1.08595, 1.08595, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.05638, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; const MyriadProRegularMetrics = { lineHeight: 1.2, lineGap: 0.2 }; ;// CONCATENATED MODULE: ./src/core/segoeui_factors.js const SegoeuiBoldFactors = [1.76738, 1, 1, 0.99297, 0.9824, 1.04016, 1.06497, 1.03424, 0.97529, 1.17647, 1.23203, 1.1085, 1.1085, 1.16939, 1.2107, 0.9754, 1.21408, 0.9754, 1.59578, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 0.81378, 0.81378, 1.2107, 1.2107, 1.2107, 0.71703, 0.97847, 0.97363, 0.88776, 0.8641, 1.02096, 0.79795, 0.85132, 0.914, 1.06085, 1.1406, 0.8007, 0.89858, 0.83693, 1.14889, 1.09398, 0.97489, 0.92094, 0.97489, 0.90399, 0.84041, 0.95923, 1.00135, 1, 1.06467, 0.98243, 0.90996, 0.99361, 1.1085, 1.56942, 1.1085, 1.2107, 0.74627, 0.94282, 0.96752, 1.01519, 0.86304, 1.01359, 0.97278, 1.15103, 1.01359, 0.98561, 1.02285, 1.02285, 1.00527, 1.02285, 1.0302, 0.99041, 1.0008, 1.01519, 1.01359, 1.02258, 0.79104, 1.16862, 0.99041, 0.97454, 1.02511, 0.99298, 0.96752, 0.95801, 0.94856, 1.16579, 0.94856, 1.2107, 0.9824, 1.03424, 1.03424, 1, 1.03424, 1.16579, 0.8727, 1.3871, 1.18622, 1.10818, 1.04478, 1.2107, 1.18622, 0.75155, 0.94994, 1.28826, 1.21408, 1.21408, 0.91056, 1, 0.91572, 0.9754, 0.64663, 1.18328, 1.24866, 1.04478, 1.14169, 1.15749, 1.17389, 0.71703, 0.97363, 0.97363, 0.97363, 0.97363, 0.97363, 0.97363, 0.93506, 0.8641, 0.79795, 0.79795, 0.79795, 0.79795, 1.1406, 1.1406, 1.1406, 1.1406, 1.02096, 1.09398, 0.97426, 0.97426, 0.97426, 0.97426, 0.97426, 1.2107, 0.97489, 1.00135, 1.00135, 1.00135, 1.00135, 0.90996, 0.92094, 1.02798, 0.96752, 0.96752, 0.96752, 0.96752, 0.96752, 0.96752, 0.93136, 0.86304, 0.97278, 0.97278, 0.97278, 0.97278, 1.02285, 1.02285, 1.02285, 1.02285, 0.97122, 0.99041, 1, 1, 1, 1, 1, 1.28826, 1.0008, 0.99041, 0.99041, 0.99041, 0.99041, 0.96752, 1.01519, 0.96752, 0.97363, 0.96752, 0.97363, 0.96752, 0.97363, 0.96752, 0.8641, 0.86304, 0.8641, 0.86304, 0.8641, 0.86304, 0.8641, 0.86304, 1.02096, 1.03057, 1.02096, 1.03517, 0.79795, 0.97278, 0.79795, 0.97278, 0.79795, 0.97278, 0.79795, 0.97278, 0.79795, 0.97278, 0.914, 1.01359, 0.914, 1.01359, 0.914, 1.01359, 1, 1, 1.06085, 0.98561, 1.06085, 1.00879, 1.1406, 1.02285, 1.1406, 1.02285, 1.1406, 1.02285, 1.1406, 1.02285, 1.1406, 1.02285, 0.97138, 1.08692, 0.8007, 1.02285, 1, 1, 1.00527, 0.83693, 1.02285, 1, 1, 0.83693, 0.9455, 0.83693, 0.90418, 0.83693, 1.13005, 1.09398, 0.99041, 1, 1, 1.09398, 0.99041, 0.96692, 1.09251, 0.99041, 0.97489, 1.0008, 0.97489, 1.0008, 0.97489, 1.0008, 0.93994, 0.97931, 0.90399, 1.02258, 1, 1, 0.90399, 1.02258, 0.84041, 0.79104, 0.84041, 0.79104, 0.84041, 0.79104, 0.84041, 0.79104, 1, 1, 0.95923, 1.07034, 0.95923, 1.16862, 1.00135, 0.99041, 1.00135, 0.99041, 1.00135, 0.99041, 1.00135, 0.99041, 1.00135, 0.99041, 1.00135, 0.99041, 1.06467, 1.02511, 0.90996, 0.96752, 0.90996, 0.99361, 0.95801, 0.99361, 0.95801, 0.99361, 0.95801, 1.07733, 1.03424, 0.97363, 0.96752, 0.93506, 0.93136, 0.97489, 1.0008, 1, 1, 0.95923, 1.16862, 1.15103, 1.15103, 1.01173, 1.03959, 0.75953, 0.81378, 0.79912, 1.15103, 1.21994, 0.95161, 0.87815, 1.01149, 0.81525, 0.7676, 0.98167, 1.01134, 1.02546, 0.84097, 1.03089, 1.18102, 0.97363, 0.88776, 0.85134, 0.97826, 0.79795, 0.99361, 1.06085, 0.97489, 1.1406, 0.89858, 1.0388, 1.14889, 1.09398, 0.86039, 0.97489, 1.0595, 0.92094, 0.94793, 0.95923, 0.90996, 0.99346, 0.98243, 1.02112, 0.95493, 1.1406, 0.90996, 1.03574, 1.02597, 1.0008, 1.18102, 1.06628, 1.03574, 1.0192, 1.01932, 1.00886, 0.97531, 1.0106, 1.0008, 1.13189, 1.18102, 1.02277, 0.98683, 1.0016, 0.99561, 1.07237, 1.0008, 0.90434, 0.99921, 0.93803, 0.8965, 1.23085, 1.06628, 1.04983, 0.96268, 1.0499, 0.98439, 1.18102, 1.06628, 1.0008, 1.06628, 0.98439, 0.79795, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.09466, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.97278, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.02065, 1, 1, 1, 1, 1, 1, 1.06467, 1.02511, 1.06467, 1.02511, 1.06467, 1.02511, 0.90996, 0.96752, 1, 1.21408, 0.89903, 1, 1, 0.75155, 1.04394, 1.04394, 1.04394, 1.04394, 0.98633, 0.98633, 0.98633, 0.73047, 0.73047, 1.20642, 0.91211, 1.25635, 1.222, 1.02956, 1.03372, 1.03372, 0.96039, 1.24633, 1, 1.12454, 0.93503, 1.03424, 1.19687, 1.03424, 1, 1, 1, 0.771, 1, 1, 1.15749, 1.15749, 1.15749, 1.10948, 0.86279, 0.94434, 0.86279, 0.94434, 0.86182, 1, 1, 1.16897, 1, 0.96085, 0.90137, 1.2107, 1.18416, 1.13973, 0.69825, 0.9716, 2.10339, 1.29004, 1.29004, 1.21172, 1.29004, 1.29004, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.42603, 1, 0.99862, 0.99862, 1, 0.87025, 0.87025, 0.87025, 0.87025, 1.18874, 1.42603, 1, 1.42603, 1.42603, 0.99862, 1, 1, 1, 1, 1, 1.2886, 1.04315, 1.15296, 1.34163, 1, 1, 1, 1.09193, 1.09193, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; const SegoeuiBoldMetrics = { lineHeight: 1.33008, lineGap: 0 }; const SegoeuiBoldItalicFactors = [1.76738, 1, 1, 0.98946, 1.03959, 1.04016, 1.02809, 1.036, 0.97639, 1.10953, 1.23203, 1.11144, 1.11144, 1.16939, 1.21237, 0.9754, 1.21261, 0.9754, 1.59754, 1.036, 1.036, 1.036, 1.036, 1.036, 1.036, 1.036, 1.036, 1.036, 1.036, 0.81378, 0.81378, 1.21237, 1.21237, 1.21237, 0.73541, 0.97847, 0.97363, 0.89723, 0.87897, 1.0426, 0.79429, 0.85292, 0.91149, 1.05815, 1.1406, 0.79631, 0.90128, 0.83853, 1.04396, 1.10615, 0.97552, 0.94436, 0.97552, 0.88641, 0.80527, 0.96083, 1.00135, 1, 1.06777, 0.9817, 0.91142, 0.99361, 1.11144, 1.57293, 1.11144, 1.21237, 0.74627, 1.31818, 1.06585, 0.97042, 0.83055, 0.97042, 0.93503, 1.1261, 0.97042, 0.97922, 1.14236, 0.94552, 1.01054, 1.14236, 1.02471, 0.97922, 0.94165, 0.97042, 0.97042, 1.0276, 0.78929, 1.1261, 0.97922, 0.95874, 1.02197, 0.98507, 0.96752, 0.97168, 0.95107, 1.16579, 0.95107, 1.21237, 1.03959, 1.036, 1.036, 1, 1.036, 1.16579, 0.87357, 1.31818, 1.18754, 1.26781, 1.05356, 1.21237, 1.18622, 0.79487, 0.94994, 1.29004, 1.24047, 1.24047, 1.31818, 1, 0.91484, 0.9754, 1.31818, 1.1349, 1.24866, 1.05356, 1.13934, 1.15574, 1.17389, 0.73541, 0.97363, 0.97363, 0.97363, 0.97363, 0.97363, 0.97363, 0.94385, 0.87897, 0.79429, 0.79429, 0.79429, 0.79429, 1.1406, 1.1406, 1.1406, 1.1406, 1.0426, 1.10615, 0.97552, 0.97552, 0.97552, 0.97552, 0.97552, 1.21237, 0.97552, 1.00135, 1.00135, 1.00135, 1.00135, 0.91142, 0.94436, 0.98721, 1.06585, 1.06585, 1.06585, 1.06585, 1.06585, 1.06585, 0.96705, 0.83055, 0.93503, 0.93503, 0.93503, 0.93503, 1.14236, 1.14236, 1.14236, 1.14236, 0.93125, 0.97922, 0.94165, 0.94165, 0.94165, 0.94165, 0.94165, 1.29004, 0.94165, 0.97922, 0.97922, 0.97922, 0.97922, 0.96752, 0.97042, 0.96752, 0.97363, 1.06585, 0.97363, 1.06585, 0.97363, 1.06585, 0.87897, 0.83055, 0.87897, 0.83055, 0.87897, 0.83055, 0.87897, 0.83055, 1.0426, 1.0033, 1.0426, 0.97042, 0.79429, 0.93503, 0.79429, 0.93503, 0.79429, 0.93503, 0.79429, 0.93503, 0.79429, 0.93503, 0.91149, 0.97042, 0.91149, 0.97042, 0.91149, 0.97042, 1, 1, 1.05815, 0.97922, 1.05815, 0.97922, 1.1406, 1.14236, 1.1406, 1.14236, 1.1406, 1.14236, 1.1406, 1.14236, 1.1406, 1.14236, 0.97441, 1.04302, 0.79631, 1.01582, 1, 1, 1.01054, 0.83853, 1.14236, 1, 1, 0.83853, 1.09125, 0.83853, 0.90418, 0.83853, 1.19508, 1.10615, 0.97922, 1, 1, 1.10615, 0.97922, 1.01034, 1.10466, 0.97922, 0.97552, 0.94165, 0.97552, 0.94165, 0.97552, 0.94165, 0.91602, 0.91981, 0.88641, 1.0276, 1, 1, 0.88641, 1.0276, 0.80527, 0.78929, 0.80527, 0.78929, 0.80527, 0.78929, 0.80527, 0.78929, 1, 1, 0.96083, 1.05403, 0.95923, 1.16862, 1.00135, 0.97922, 1.00135, 0.97922, 1.00135, 0.97922, 1.00135, 0.97922, 1.00135, 0.97922, 1.00135, 0.97922, 1.06777, 1.02197, 0.91142, 0.96752, 0.91142, 0.99361, 0.97168, 0.99361, 0.97168, 0.99361, 0.97168, 1.23199, 1.036, 0.97363, 1.06585, 0.94385, 0.96705, 0.97552, 0.94165, 1, 1, 0.96083, 1.1261, 1.31818, 1.31818, 1.31818, 1.31818, 1.31818, 1.31818, 1.31818, 1.31818, 1.31818, 0.95161, 1.27126, 1.00811, 0.83284, 0.77702, 0.99137, 0.95253, 1.0347, 0.86142, 1.07205, 1.14236, 0.97363, 0.89723, 0.86869, 1.09818, 0.79429, 0.99361, 1.05815, 0.97552, 1.1406, 0.90128, 1.06662, 1.04396, 1.10615, 0.84918, 0.97552, 1.04694, 0.94436, 0.98015, 0.96083, 0.91142, 1.00356, 0.9817, 1.01945, 0.98999, 1.1406, 0.91142, 1.04961, 0.9898, 1.00639, 1.14236, 1.07514, 1.04961, 0.99607, 1.02897, 1.008, 0.9898, 0.95134, 1.00639, 1.11121, 1.14236, 1.00518, 0.97981, 1.02186, 1, 1.08578, 0.94165, 0.99314, 0.98387, 0.93028, 0.93377, 1.35125, 1.07514, 1.10687, 0.93491, 1.04232, 1.00351, 1.14236, 1.07514, 0.94165, 1.07514, 1.00351, 0.79429, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.09097, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.93503, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.96609, 1, 1, 1, 1, 1, 1, 1.06777, 1.02197, 1.06777, 1.02197, 1.06777, 1.02197, 0.91142, 0.96752, 1, 1.21261, 0.89903, 1, 1, 0.75155, 1.04745, 1.04745, 1.04745, 1.04394, 0.98633, 0.98633, 0.98633, 0.72959, 0.72959, 1.20502, 0.91406, 1.26514, 1.222, 1.02956, 1.03372, 1.03372, 0.96039, 1.24633, 1, 1.09125, 0.93327, 1.03336, 1.16541, 1.036, 1, 1, 1, 0.771, 1, 1, 1.15574, 1.15574, 1.15574, 1.15574, 0.86364, 0.94434, 0.86279, 0.94434, 0.86224, 1, 1, 1.16798, 1, 0.96085, 0.90068, 1.21237, 1.18416, 1.13904, 0.69825, 0.9716, 2.10339, 1.29004, 1.29004, 1.21339, 1.29004, 1.29004, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.42603, 1, 0.99862, 0.99862, 1, 0.87025, 0.87025, 0.87025, 0.87025, 1.18775, 1.42603, 1, 1.42603, 1.42603, 0.99862, 1, 1, 1, 1, 1, 1.2886, 1.04315, 1.15296, 1.34163, 1, 1, 1, 1.13269, 1.13269, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; const SegoeuiBoldItalicMetrics = { lineHeight: 1.33008, lineGap: 0 }; const SegoeuiItalicFactors = [1.76738, 1, 1, 0.98946, 1.14763, 1.05365, 1.06234, 0.96927, 0.92586, 1.15373, 1.18414, 0.91349, 0.91349, 1.07403, 1.17308, 0.78383, 1.20088, 0.78383, 1.42531, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.78383, 0.78383, 1.17308, 1.17308, 1.17308, 0.77349, 0.94565, 0.94729, 0.85944, 0.88506, 0.9858, 0.74817, 0.80016, 0.88449, 0.98039, 0.95782, 0.69238, 0.89898, 0.83231, 0.98183, 1.03989, 0.96924, 0.86237, 0.96924, 0.80595, 0.74524, 0.86091, 0.95402, 0.94143, 0.98448, 0.8858, 0.83089, 0.93285, 1.0949, 1.39016, 1.0949, 1.45994, 0.74627, 1.04839, 0.97454, 0.97454, 0.87207, 0.97454, 0.87533, 1.06151, 0.97454, 1.00176, 1.16484, 1.08132, 0.98047, 1.16484, 1.02989, 1.01054, 0.96225, 0.97454, 0.97454, 1.06598, 0.79004, 1.16344, 1.00351, 0.94629, 0.9973, 0.91016, 0.96777, 0.9043, 0.91082, 0.92481, 0.91082, 1.17308, 0.95748, 0.96927, 0.96927, 1, 0.96927, 0.92481, 0.80597, 1.04839, 1.23393, 1.1781, 0.9245, 1.17308, 1.20808, 0.63218, 0.94261, 1.24822, 1.09971, 1.09971, 1.04839, 1, 0.85273, 0.78032, 1.04839, 1.09971, 1.22326, 0.9245, 1.09836, 1.13525, 1.15222, 0.70424, 0.94729, 0.94729, 0.94729, 0.94729, 0.94729, 0.94729, 0.85498, 0.88506, 0.74817, 0.74817, 0.74817, 0.74817, 0.95782, 0.95782, 0.95782, 0.95782, 0.9858, 1.03989, 0.96924, 0.96924, 0.96924, 0.96924, 0.96924, 1.17308, 0.96924, 0.95402, 0.95402, 0.95402, 0.95402, 0.83089, 0.86237, 0.88409, 0.97454, 0.97454, 0.97454, 0.97454, 0.97454, 0.97454, 0.92916, 0.87207, 0.87533, 0.87533, 0.87533, 0.87533, 0.93146, 0.93146, 0.93146, 0.93146, 0.93854, 1.01054, 0.96225, 0.96225, 0.96225, 0.96225, 0.96225, 1.24822, 0.8761, 1.00351, 1.00351, 1.00351, 1.00351, 0.96777, 0.97454, 0.96777, 0.94729, 0.97454, 0.94729, 0.97454, 0.94729, 0.97454, 0.88506, 0.87207, 0.88506, 0.87207, 0.88506, 0.87207, 0.88506, 0.87207, 0.9858, 0.95391, 0.9858, 0.97454, 0.74817, 0.87533, 0.74817, 0.87533, 0.74817, 0.87533, 0.74817, 0.87533, 0.74817, 0.87533, 0.88449, 0.97454, 0.88449, 0.97454, 0.88449, 0.97454, 1, 1, 0.98039, 1.00176, 0.98039, 1.00176, 0.95782, 0.93146, 0.95782, 0.93146, 0.95782, 0.93146, 0.95782, 1.16484, 0.95782, 0.93146, 0.84421, 1.12761, 0.69238, 1.08132, 1, 1, 0.98047, 0.83231, 1.16484, 1, 1, 0.84723, 1.04861, 0.84723, 0.78755, 0.83231, 1.23736, 1.03989, 1.01054, 1, 1, 1.03989, 1.01054, 0.9857, 1.03849, 1.01054, 0.96924, 0.96225, 0.96924, 0.96225, 0.96924, 0.96225, 0.92383, 0.90171, 0.80595, 1.06598, 1, 1, 0.80595, 1.06598, 0.74524, 0.79004, 0.74524, 0.79004, 0.74524, 0.79004, 0.74524, 0.79004, 1, 1, 0.86091, 1.02759, 0.85771, 1.16344, 0.95402, 1.00351, 0.95402, 1.00351, 0.95402, 1.00351, 0.95402, 1.00351, 0.95402, 1.00351, 0.95402, 1.00351, 0.98448, 0.9973, 0.83089, 0.96777, 0.83089, 0.93285, 0.9043, 0.93285, 0.9043, 0.93285, 0.9043, 1.31868, 0.96927, 0.94729, 0.97454, 0.85498, 0.92916, 0.96924, 0.8761, 1, 1, 0.86091, 1.16344, 1.04839, 1.04839, 1.04839, 1.04839, 1.04839, 1.04839, 1.04839, 1.04839, 1.04839, 0.81965, 0.81965, 0.94729, 0.78032, 0.71022, 0.90883, 0.84171, 0.99877, 0.77596, 1.05734, 1.2, 0.94729, 0.85944, 0.82791, 0.9607, 0.74817, 0.93285, 0.98039, 0.96924, 0.95782, 0.89898, 0.98316, 0.98183, 1.03989, 0.78614, 0.96924, 0.97642, 0.86237, 0.86075, 0.86091, 0.83089, 0.90082, 0.8858, 0.97296, 1.01284, 0.95782, 0.83089, 1.0976, 1.04, 1.03342, 1.2, 1.0675, 1.0976, 0.98205, 1.03809, 1.05097, 1.04, 0.95364, 1.03342, 1.05401, 1.2, 1.02148, 1.0119, 1.04724, 1.0127, 1.02732, 0.96225, 0.8965, 0.97783, 0.93574, 0.94818, 1.30679, 1.0675, 1.11826, 0.99821, 1.0557, 1.0326, 1.2, 1.0675, 0.96225, 1.0675, 1.0326, 0.74817, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.03754, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.87533, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.98705, 1, 1, 1, 1, 1, 1, 0.98448, 0.9973, 0.98448, 0.9973, 0.98448, 0.9973, 0.83089, 0.96777, 1, 1.20088, 0.89903, 1, 1, 0.75155, 0.94945, 0.94945, 0.94945, 0.94945, 1.12317, 1.12317, 1.12317, 0.67603, 0.67603, 1.15621, 0.73584, 1.21191, 1.22135, 1.06483, 0.94868, 0.94868, 0.95996, 1.24633, 1, 1.07497, 0.87709, 0.96927, 1.01473, 0.96927, 1, 1, 1, 0.77295, 1, 1, 1.09836, 1.09836, 1.09836, 1.01522, 0.86321, 0.94434, 0.8649, 0.94434, 0.86182, 1, 1, 1.083, 1, 0.91578, 0.86438, 1.17308, 1.18416, 1.14589, 0.69825, 0.97622, 1.96791, 1.24822, 1.24822, 1.17308, 1.24822, 1.24822, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.42603, 1, 0.99862, 0.99862, 1, 0.87025, 0.87025, 0.87025, 0.87025, 1.17984, 1.42603, 1, 1.42603, 1.42603, 0.99862, 1, 1, 1, 1, 1, 1.2886, 1.04315, 1.15296, 1.34163, 1, 1, 1, 1.10742, 1.10742, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; const SegoeuiItalicMetrics = { lineHeight: 1.33008, lineGap: 0 }; const SegoeuiRegularFactors = [1.76738, 1, 1, 0.98594, 1.02285, 1.10454, 1.06234, 0.96927, 0.92037, 1.19985, 1.2046, 0.90616, 0.90616, 1.07152, 1.1714, 0.78032, 1.20088, 0.78032, 1.40246, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.78032, 0.78032, 1.1714, 1.1714, 1.1714, 0.80597, 0.94084, 0.96706, 0.85944, 0.85734, 0.97093, 0.75842, 0.79936, 0.88198, 0.9831, 0.95782, 0.71387, 0.86969, 0.84636, 1.07796, 1.03584, 0.96924, 0.83968, 0.96924, 0.82826, 0.79649, 0.85771, 0.95132, 0.93119, 0.98965, 0.88433, 0.8287, 0.93365, 1.08612, 1.3638, 1.08612, 1.45786, 0.74627, 0.80499, 0.91484, 1.05707, 0.92383, 1.05882, 0.9403, 1.12654, 1.05882, 1.01756, 1.09011, 1.09011, 0.99414, 1.09011, 1.034, 1.01756, 1.05356, 1.05707, 1.05882, 1.04399, 0.84863, 1.21968, 1.01756, 0.95801, 1.00068, 0.91797, 0.96777, 0.9043, 0.90351, 0.92105, 0.90351, 1.1714, 0.85337, 0.96927, 0.96927, 0.99912, 0.96927, 0.92105, 0.80597, 1.2434, 1.20808, 1.05937, 0.90957, 1.1714, 1.20808, 0.75155, 0.94261, 1.24644, 1.09971, 1.09971, 0.84751, 1, 0.85273, 0.78032, 0.61584, 1.05425, 1.17914, 0.90957, 1.08665, 1.11593, 1.14169, 0.73381, 0.96706, 0.96706, 0.96706, 0.96706, 0.96706, 0.96706, 0.86035, 0.85734, 0.75842, 0.75842, 0.75842, 0.75842, 0.95782, 0.95782, 0.95782, 0.95782, 0.97093, 1.03584, 0.96924, 0.96924, 0.96924, 0.96924, 0.96924, 1.1714, 0.96924, 0.95132, 0.95132, 0.95132, 0.95132, 0.8287, 0.83968, 0.89049, 0.91484, 0.91484, 0.91484, 0.91484, 0.91484, 0.91484, 0.93575, 0.92383, 0.9403, 0.9403, 0.9403, 0.9403, 0.8717, 0.8717, 0.8717, 0.8717, 1.00527, 1.01756, 1.05356, 1.05356, 1.05356, 1.05356, 1.05356, 1.24644, 0.95923, 1.01756, 1.01756, 1.01756, 1.01756, 0.96777, 1.05707, 0.96777, 0.96706, 0.91484, 0.96706, 0.91484, 0.96706, 0.91484, 0.85734, 0.92383, 0.85734, 0.92383, 0.85734, 0.92383, 0.85734, 0.92383, 0.97093, 1.0969, 0.97093, 1.05882, 0.75842, 0.9403, 0.75842, 0.9403, 0.75842, 0.9403, 0.75842, 0.9403, 0.75842, 0.9403, 0.88198, 1.05882, 0.88198, 1.05882, 0.88198, 1.05882, 1, 1, 0.9831, 1.01756, 0.9831, 1.01756, 0.95782, 0.8717, 0.95782, 0.8717, 0.95782, 0.8717, 0.95782, 1.09011, 0.95782, 0.8717, 0.84784, 1.11551, 0.71387, 1.09011, 1, 1, 0.99414, 0.84636, 1.09011, 1, 1, 0.84636, 1.0536, 0.84636, 0.94298, 0.84636, 1.23297, 1.03584, 1.01756, 1, 1, 1.03584, 1.01756, 1.00323, 1.03444, 1.01756, 0.96924, 1.05356, 0.96924, 1.05356, 0.96924, 1.05356, 0.93066, 0.98293, 0.82826, 1.04399, 1, 1, 0.82826, 1.04399, 0.79649, 0.84863, 0.79649, 0.84863, 0.79649, 0.84863, 0.79649, 0.84863, 1, 1, 0.85771, 1.17318, 0.85771, 1.21968, 0.95132, 1.01756, 0.95132, 1.01756, 0.95132, 1.01756, 0.95132, 1.01756, 0.95132, 1.01756, 0.95132, 1.01756, 0.98965, 1.00068, 0.8287, 0.96777, 0.8287, 0.93365, 0.9043, 0.93365, 0.9043, 0.93365, 0.9043, 1.08571, 0.96927, 0.96706, 0.91484, 0.86035, 0.93575, 0.96924, 0.95923, 1, 1, 0.85771, 1.21968, 1.11437, 1.11437, 0.93109, 0.91202, 0.60411, 0.84164, 0.55572, 1.01173, 0.97361, 0.81818, 0.81818, 0.96635, 0.78032, 0.72727, 0.92366, 0.98601, 1.03405, 0.77968, 1.09799, 1.2, 0.96706, 0.85944, 0.85638, 0.96491, 0.75842, 0.93365, 0.9831, 0.96924, 0.95782, 0.86969, 0.94152, 1.07796, 1.03584, 0.78437, 0.96924, 0.98715, 0.83968, 0.83491, 0.85771, 0.8287, 0.94492, 0.88433, 0.9287, 1.0098, 0.95782, 0.8287, 1.0625, 0.98248, 1.03424, 1.2, 1.01071, 1.0625, 0.95246, 1.03809, 1.04912, 0.98248, 1.00221, 1.03424, 1.05443, 1.2, 1.04785, 0.99609, 1.00169, 1.05176, 0.99346, 1.05356, 0.9087, 1.03004, 0.95542, 0.93117, 1.23362, 1.01071, 1.07831, 1.02512, 1.05205, 1.03502, 1.2, 1.01071, 1.05356, 1.01071, 1.03502, 0.75842, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.03719, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9403, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.04021, 1, 1, 1, 1, 1, 1, 0.98965, 1.00068, 0.98965, 1.00068, 0.98965, 1.00068, 0.8287, 0.96777, 1, 1.20088, 0.89903, 1, 1, 0.75155, 1.03077, 1.03077, 1.03077, 1.03077, 1.13196, 1.13196, 1.13196, 0.67428, 0.67428, 1.16039, 0.73291, 1.20996, 1.22135, 1.06483, 0.94868, 0.94868, 0.95996, 1.24633, 1, 1.07497, 0.87796, 0.96927, 1.01518, 0.96927, 1, 1, 1, 0.77295, 1, 1, 1.10539, 1.10539, 1.11358, 1.06967, 0.86279, 0.94434, 0.86279, 0.94434, 0.86182, 1, 1, 1.083, 1, 0.91578, 0.86507, 1.1714, 1.18416, 1.14589, 0.69825, 0.97622, 1.9697, 1.24822, 1.24822, 1.17238, 1.24822, 1.24822, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.42603, 1, 0.99862, 0.99862, 1, 0.87025, 0.87025, 0.87025, 0.87025, 1.18083, 1.42603, 1, 1.42603, 1.42603, 0.99862, 1, 1, 1, 1, 1, 1.2886, 1.04315, 1.15296, 1.34163, 1, 1, 1, 1.10938, 1.10938, 1, 1, 1, 1.05425, 1.09971, 1.09971, 1.09971, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; const SegoeuiRegularMetrics = { lineHeight: 1.33008, lineGap: 0 }; ;// CONCATENATED MODULE: ./src/core/xfa_fonts.js const getXFAFontMap = getLookupTableFactory(function (t) { t["MyriadPro-Regular"] = t["PdfJS-Fallback-Regular"] = { name: "LiberationSans-Regular", factors: MyriadProRegularFactors, baseWidths: LiberationSansRegularWidths, baseMapping: LiberationSansRegularMapping, metrics: MyriadProRegularMetrics }; t["MyriadPro-Bold"] = t["PdfJS-Fallback-Bold"] = { name: "LiberationSans-Bold", factors: MyriadProBoldFactors, baseWidths: LiberationSansBoldWidths, baseMapping: LiberationSansBoldMapping, metrics: MyriadProBoldMetrics }; t["MyriadPro-It"] = t["MyriadPro-Italic"] = t["PdfJS-Fallback-Italic"] = { name: "LiberationSans-Italic", factors: MyriadProItalicFactors, baseWidths: LiberationSansItalicWidths, baseMapping: LiberationSansItalicMapping, metrics: MyriadProItalicMetrics }; t["MyriadPro-BoldIt"] = t["MyriadPro-BoldItalic"] = t["PdfJS-Fallback-BoldItalic"] = { name: "LiberationSans-BoldItalic", factors: MyriadProBoldItalicFactors, baseWidths: LiberationSansBoldItalicWidths, baseMapping: LiberationSansBoldItalicMapping, metrics: MyriadProBoldItalicMetrics }; t.ArialMT = t.Arial = t["Arial-Regular"] = { name: "LiberationSans-Regular", baseWidths: LiberationSansRegularWidths, baseMapping: LiberationSansRegularMapping }; t["Arial-BoldMT"] = t["Arial-Bold"] = { name: "LiberationSans-Bold", baseWidths: LiberationSansBoldWidths, baseMapping: LiberationSansBoldMapping }; t["Arial-ItalicMT"] = t["Arial-Italic"] = { name: "LiberationSans-Italic", baseWidths: LiberationSansItalicWidths, baseMapping: LiberationSansItalicMapping }; t["Arial-BoldItalicMT"] = t["Arial-BoldItalic"] = { name: "LiberationSans-BoldItalic", baseWidths: LiberationSansBoldItalicWidths, baseMapping: LiberationSansBoldItalicMapping }; t["Calibri-Regular"] = { name: "LiberationSans-Regular", factors: CalibriRegularFactors, baseWidths: LiberationSansRegularWidths, baseMapping: LiberationSansRegularMapping, metrics: CalibriRegularMetrics }; t["Calibri-Bold"] = { name: "LiberationSans-Bold", factors: CalibriBoldFactors, baseWidths: LiberationSansBoldWidths, baseMapping: LiberationSansBoldMapping, metrics: CalibriBoldMetrics }; t["Calibri-Italic"] = { name: "LiberationSans-Italic", factors: CalibriItalicFactors, baseWidths: LiberationSansItalicWidths, baseMapping: LiberationSansItalicMapping, metrics: CalibriItalicMetrics }; t["Calibri-BoldItalic"] = { name: "LiberationSans-BoldItalic", factors: CalibriBoldItalicFactors, baseWidths: LiberationSansBoldItalicWidths, baseMapping: LiberationSansBoldItalicMapping, metrics: CalibriBoldItalicMetrics }; t["Segoeui-Regular"] = { name: "LiberationSans-Regular", factors: SegoeuiRegularFactors, baseWidths: LiberationSansRegularWidths, baseMapping: LiberationSansRegularMapping, metrics: SegoeuiRegularMetrics }; t["Segoeui-Bold"] = { name: "LiberationSans-Bold", factors: SegoeuiBoldFactors, baseWidths: LiberationSansBoldWidths, baseMapping: LiberationSansBoldMapping, metrics: SegoeuiBoldMetrics }; t["Segoeui-Italic"] = { name: "LiberationSans-Italic", factors: SegoeuiItalicFactors, baseWidths: LiberationSansItalicWidths, baseMapping: LiberationSansItalicMapping, metrics: SegoeuiItalicMetrics }; t["Segoeui-BoldItalic"] = { name: "LiberationSans-BoldItalic", factors: SegoeuiBoldItalicFactors, baseWidths: LiberationSansBoldItalicWidths, baseMapping: LiberationSansBoldItalicMapping, metrics: SegoeuiBoldItalicMetrics }; t["Helvetica-Regular"] = t.Helvetica = { name: "LiberationSans-Regular", factors: HelveticaRegularFactors, baseWidths: LiberationSansRegularWidths, baseMapping: LiberationSansRegularMapping, metrics: HelveticaRegularMetrics }; t["Helvetica-Bold"] = { name: "LiberationSans-Bold", factors: HelveticaBoldFactors, baseWidths: LiberationSansBoldWidths, baseMapping: LiberationSansBoldMapping, metrics: HelveticaBoldMetrics }; t["Helvetica-Italic"] = { name: "LiberationSans-Italic", factors: HelveticaItalicFactors, baseWidths: LiberationSansItalicWidths, baseMapping: LiberationSansItalicMapping, metrics: HelveticaItalicMetrics }; t["Helvetica-BoldItalic"] = { name: "LiberationSans-BoldItalic", factors: HelveticaBoldItalicFactors, baseWidths: LiberationSansBoldItalicWidths, baseMapping: LiberationSansBoldItalicMapping, metrics: HelveticaBoldItalicMetrics }; }); function getXfaFontName(name) { const fontName = normalizeFontName(name); const fontMap = getXFAFontMap(); return fontMap[fontName]; } function getXfaFontWidths(name) { const info = getXfaFontName(name); if (!info) { return null; } const { baseWidths, baseMapping, factors } = info; const rescaledBaseWidths = !factors ? baseWidths : baseWidths.map((w, i) => w * factors[i]); let currentCode = -2; let currentArray; const newWidths = []; for (const [unicode, glyphIndex] of baseMapping.map((charUnicode, index) => [charUnicode, index]).sort(([unicode1], [unicode2]) => unicode1 - unicode2)) { if (unicode === -1) { continue; } if (unicode === currentCode + 1) { currentArray.push(rescaledBaseWidths[glyphIndex]); currentCode += 1; } else { currentCode = unicode; currentArray = [rescaledBaseWidths[glyphIndex]]; newWidths.push(unicode, currentArray); } } return newWidths; } function getXfaFontDict(name) { const widths = getXfaFontWidths(name); const dict = new Dict(null); dict.set("BaseFont", Name.get(name)); dict.set("Type", Name.get("Font")); dict.set("Subtype", Name.get("CIDFontType2")); dict.set("Encoding", Name.get("Identity-H")); dict.set("CIDToGIDMap", Name.get("Identity")); dict.set("W", widths); dict.set("FirstChar", widths[0]); dict.set("LastChar", widths.at(-2) + widths.at(-1).length - 1); const descriptor = new Dict(null); dict.set("FontDescriptor", descriptor); const systemInfo = new Dict(null); systemInfo.set("Ordering", "Identity"); systemInfo.set("Registry", "Adobe"); systemInfo.set("Supplement", 0); dict.set("CIDSystemInfo", systemInfo); return dict; } ;// CONCATENATED MODULE: ./src/core/ps_parser.js class PostScriptParser { constructor(lexer) { this.lexer = lexer; this.operators = []; this.token = null; this.prev = null; } nextToken() { this.prev = this.token; this.token = this.lexer.getToken(); } accept(type) { if (this.token.type === type) { this.nextToken(); return true; } return false; } expect(type) { if (this.accept(type)) { return true; } throw new FormatError(`Unexpected symbol: found ${this.token.type} expected ${type}.`); } parse() { this.nextToken(); this.expect(PostScriptTokenTypes.LBRACE); this.parseBlock(); this.expect(PostScriptTokenTypes.RBRACE); return this.operators; } parseBlock() { while (true) { if (this.accept(PostScriptTokenTypes.NUMBER)) { this.operators.push(this.prev.value); } else if (this.accept(PostScriptTokenTypes.OPERATOR)) { this.operators.push(this.prev.value); } else if (this.accept(PostScriptTokenTypes.LBRACE)) { this.parseCondition(); } else { return; } } } parseCondition() { const conditionLocation = this.operators.length; this.operators.push(null, null); this.parseBlock(); this.expect(PostScriptTokenTypes.RBRACE); if (this.accept(PostScriptTokenTypes.IF)) { this.operators[conditionLocation] = this.operators.length; this.operators[conditionLocation + 1] = "jz"; } else if (this.accept(PostScriptTokenTypes.LBRACE)) { const jumpLocation = this.operators.length; this.operators.push(null, null); const endOfTrue = this.operators.length; this.parseBlock(); this.expect(PostScriptTokenTypes.RBRACE); this.expect(PostScriptTokenTypes.IFELSE); this.operators[jumpLocation] = this.operators.length; this.operators[jumpLocation + 1] = "j"; this.operators[conditionLocation] = endOfTrue; this.operators[conditionLocation + 1] = "jz"; } else { throw new FormatError("PS Function: error parsing conditional."); } } } const PostScriptTokenTypes = { LBRACE: 0, RBRACE: 1, NUMBER: 2, OPERATOR: 3, IF: 4, IFELSE: 5 }; class PostScriptToken { static get opCache() { return shadow(this, "opCache", Object.create(null)); } constructor(type, value) { this.type = type; this.value = value; } static getOperator(op) { return PostScriptToken.opCache[op] ||= new PostScriptToken(PostScriptTokenTypes.OPERATOR, op); } static get LBRACE() { return shadow(this, "LBRACE", new PostScriptToken(PostScriptTokenTypes.LBRACE, "{")); } static get RBRACE() { return shadow(this, "RBRACE", new PostScriptToken(PostScriptTokenTypes.RBRACE, "}")); } static get IF() { return shadow(this, "IF", new PostScriptToken(PostScriptTokenTypes.IF, "IF")); } static get IFELSE() { return shadow(this, "IFELSE", new PostScriptToken(PostScriptTokenTypes.IFELSE, "IFELSE")); } } class PostScriptLexer { constructor(stream) { this.stream = stream; this.nextChar(); this.strBuf = []; } nextChar() { return this.currentChar = this.stream.getByte(); } getToken() { let comment = false; let ch = this.currentChar; while (true) { if (ch < 0) { return EOF; } if (comment) { if (ch === 0x0a || ch === 0x0d) { comment = false; } } else if (ch === 0x25) { comment = true; } else if (!isWhiteSpace(ch)) { break; } ch = this.nextChar(); } switch (ch | 0) { case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: case 0x2b: case 0x2d: case 0x2e: return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber()); case 0x7b: this.nextChar(); return PostScriptToken.LBRACE; case 0x7d: this.nextChar(); return PostScriptToken.RBRACE; } const strBuf = this.strBuf; strBuf.length = 0; strBuf[0] = String.fromCharCode(ch); while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5a || ch >= 0x61 && ch <= 0x7a)) { strBuf.push(String.fromCharCode(ch)); } const str = strBuf.join(""); switch (str.toLowerCase()) { case "if": return PostScriptToken.IF; case "ifelse": return PostScriptToken.IFELSE; default: return PostScriptToken.getOperator(str); } } getNumber() { let ch = this.currentChar; const strBuf = this.strBuf; strBuf.length = 0; strBuf[0] = String.fromCharCode(ch); while ((ch = this.nextChar()) >= 0) { if (ch >= 0x30 && ch <= 0x39 || ch === 0x2d || ch === 0x2e) { strBuf.push(String.fromCharCode(ch)); } else { break; } } const value = parseFloat(strBuf.join("")); if (isNaN(value)) { throw new FormatError(`Invalid floating point number: ${value}`); } return value; } } ;// CONCATENATED MODULE: ./src/core/image_utils.js class BaseLocalCache { constructor(options) { if (this.constructor === BaseLocalCache) { unreachable("Cannot initialize BaseLocalCache."); } this._onlyRefs = options?.onlyRefs === true; if (!this._onlyRefs) { this._nameRefMap = new Map(); this._imageMap = new Map(); } this._imageCache = new RefSetCache(); } getByName(name) { if (this._onlyRefs) { unreachable("Should not call `getByName` method."); } const ref = this._nameRefMap.get(name); if (ref) { return this.getByRef(ref); } return this._imageMap.get(name) || null; } getByRef(ref) { return this._imageCache.get(ref) || null; } set(name, ref, data) { unreachable("Abstract method `set` called."); } } class LocalImageCache extends BaseLocalCache { set(name, ref = null, data) { if (typeof name !== "string") { throw new Error('LocalImageCache.set - expected "name" argument.'); } if (ref) { if (this._imageCache.has(ref)) { return; } this._nameRefMap.set(name, ref); this._imageCache.put(ref, data); return; } if (this._imageMap.has(name)) { return; } this._imageMap.set(name, data); } } class LocalColorSpaceCache extends BaseLocalCache { set(name = null, ref = null, data) { if (typeof name !== "string" && !ref) { throw new Error('LocalColorSpaceCache.set - expected "name" and/or "ref" argument.'); } if (ref) { if (this._imageCache.has(ref)) { return; } if (name !== null) { this._nameRefMap.set(name, ref); } this._imageCache.put(ref, data); return; } if (this._imageMap.has(name)) { return; } this._imageMap.set(name, data); } } class LocalFunctionCache extends BaseLocalCache { constructor(options) { super({ onlyRefs: true }); } set(name = null, ref, data) { if (!ref) { throw new Error('LocalFunctionCache.set - expected "ref" argument.'); } if (this._imageCache.has(ref)) { return; } this._imageCache.put(ref, data); } } class LocalGStateCache extends BaseLocalCache { set(name, ref = null, data) { if (typeof name !== "string") { throw new Error('LocalGStateCache.set - expected "name" argument.'); } if (ref) { if (this._imageCache.has(ref)) { return; } this._nameRefMap.set(name, ref); this._imageCache.put(ref, data); return; } if (this._imageMap.has(name)) { return; } this._imageMap.set(name, data); } } class LocalTilingPatternCache extends BaseLocalCache { constructor(options) { super({ onlyRefs: true }); } set(name = null, ref, data) { if (!ref) { throw new Error('LocalTilingPatternCache.set - expected "ref" argument.'); } if (this._imageCache.has(ref)) { return; } this._imageCache.put(ref, data); } } class RegionalImageCache extends BaseLocalCache { constructor(options) { super({ onlyRefs: true }); } set(name = null, ref, data) { if (!ref) { throw new Error('RegionalImageCache.set - expected "ref" argument.'); } if (this._imageCache.has(ref)) { return; } this._imageCache.put(ref, data); } } class GlobalImageCache { static NUM_PAGES_THRESHOLD = 2; static MIN_IMAGES_TO_CACHE = 10; static MAX_BYTE_SIZE = 5 * MAX_IMAGE_SIZE_TO_CACHE; #decodeFailedSet = new RefSet(); constructor() { this._refCache = new RefSetCache(); this._imageCache = new RefSetCache(); } get #byteSize() { let byteSize = 0; for (const imageData of this._imageCache) { byteSize += imageData.byteSize; } return byteSize; } get #cacheLimitReached() { if (this._imageCache.size < GlobalImageCache.MIN_IMAGES_TO_CACHE) { return false; } if (this.#byteSize < GlobalImageCache.MAX_BYTE_SIZE) { return false; } return true; } shouldCache(ref, pageIndex) { let pageIndexSet = this._refCache.get(ref); if (!pageIndexSet) { pageIndexSet = new Set(); this._refCache.put(ref, pageIndexSet); } pageIndexSet.add(pageIndex); if (pageIndexSet.size < GlobalImageCache.NUM_PAGES_THRESHOLD) { return false; } if (!this._imageCache.has(ref) && this.#cacheLimitReached) { return false; } return true; } addDecodeFailed(ref) { this.#decodeFailedSet.put(ref); } hasDecodeFailed(ref) { return this.#decodeFailedSet.has(ref); } addByteSize(ref, byteSize) { const imageData = this._imageCache.get(ref); if (!imageData) { return; } if (imageData.byteSize) { return; } imageData.byteSize = byteSize; } getData(ref, pageIndex) { const pageIndexSet = this._refCache.get(ref); if (!pageIndexSet) { return null; } if (pageIndexSet.size < GlobalImageCache.NUM_PAGES_THRESHOLD) { return null; } const imageData = this._imageCache.get(ref); if (!imageData) { return null; } pageIndexSet.add(pageIndex); return imageData; } setData(ref, data) { if (!this._refCache.has(ref)) { throw new Error('GlobalImageCache.setData - expected "shouldCache" to have been called.'); } if (this._imageCache.has(ref)) { return; } if (this.#cacheLimitReached) { warn("GlobalImageCache.setData - cache limit reached."); return; } this._imageCache.put(ref, data); } clear(onlyData = false) { if (!onlyData) { this.#decodeFailedSet.clear(); this._refCache.clear(); } this._imageCache.clear(); } } ;// CONCATENATED MODULE: ./src/core/function.js class PDFFunctionFactory { constructor({ xref, isEvalSupported = true }) { this.xref = xref; this.isEvalSupported = isEvalSupported !== false; } create(fn) { const cachedFunction = this.getCached(fn); if (cachedFunction) { return cachedFunction; } const parsedFunction = PDFFunction.parse({ xref: this.xref, isEvalSupported: this.isEvalSupported, fn: fn instanceof Ref ? this.xref.fetch(fn) : fn }); this._cache(fn, parsedFunction); return parsedFunction; } createFromArray(fnObj) { const cachedFunction = this.getCached(fnObj); if (cachedFunction) { return cachedFunction; } const parsedFunction = PDFFunction.parseArray({ xref: this.xref, isEvalSupported: this.isEvalSupported, fnObj: fnObj instanceof Ref ? this.xref.fetch(fnObj) : fnObj }); this._cache(fnObj, parsedFunction); return parsedFunction; } getCached(cacheKey) { let fnRef; if (cacheKey instanceof Ref) { fnRef = cacheKey; } else if (cacheKey instanceof Dict) { fnRef = cacheKey.objId; } else if (cacheKey instanceof BaseStream) { fnRef = cacheKey.dict?.objId; } if (fnRef) { const localFunction = this._localFunctionCache.getByRef(fnRef); if (localFunction) { return localFunction; } } return null; } _cache(cacheKey, parsedFunction) { if (!parsedFunction) { throw new Error('PDFFunctionFactory._cache - expected "parsedFunction" argument.'); } let fnRef; if (cacheKey instanceof Ref) { fnRef = cacheKey; } else if (cacheKey instanceof Dict) { fnRef = cacheKey.objId; } else if (cacheKey instanceof BaseStream) { fnRef = cacheKey.dict?.objId; } if (fnRef) { this._localFunctionCache.set(null, fnRef, parsedFunction); } } get _localFunctionCache() { return shadow(this, "_localFunctionCache", new LocalFunctionCache()); } } function toNumberArray(arr) { if (!Array.isArray(arr)) { return null; } if (!isNumberArray(arr, null)) { return arr.map(x => +x); } return arr; } class PDFFunction { static getSampleArray(size, outputSize, bps, stream) { let i, ii; let length = 1; for (i = 0, ii = size.length; i < ii; i++) { length *= size[i]; } length *= outputSize; const array = new Array(length); let codeSize = 0; let codeBuf = 0; const sampleMul = 1.0 / (2.0 ** bps - 1); const strBytes = stream.getBytes((length * bps + 7) / 8); let strIdx = 0; for (i = 0; i < length; i++) { while (codeSize < bps) { codeBuf <<= 8; codeBuf |= strBytes[strIdx++]; codeSize += 8; } codeSize -= bps; array[i] = (codeBuf >> codeSize) * sampleMul; codeBuf &= (1 << codeSize) - 1; } return array; } static parse({ xref, isEvalSupported, fn }) { const dict = fn.dict || fn; const typeNum = dict.get("FunctionType"); switch (typeNum) { case 0: return this.constructSampled({ xref, isEvalSupported, fn, dict }); case 1: break; case 2: return this.constructInterpolated({ xref, isEvalSupported, dict }); case 3: return this.constructStiched({ xref, isEvalSupported, dict }); case 4: return this.constructPostScript({ xref, isEvalSupported, fn, dict }); } throw new FormatError("Unknown type of function"); } static parseArray({ xref, isEvalSupported, fnObj }) { if (!Array.isArray(fnObj)) { return this.parse({ xref, isEvalSupported, fn: fnObj }); } const fnArray = []; for (const fn of fnObj) { fnArray.push(this.parse({ xref, isEvalSupported, fn: xref.fetchIfRef(fn) })); } return function (src, srcOffset, dest, destOffset) { for (let i = 0, ii = fnArray.length; i < ii; i++) { fnArray[i](src, srcOffset, dest, destOffset + i); } }; } static constructSampled({ xref, isEvalSupported, fn, dict }) { function toMultiArray(arr) { const inputLength = arr.length; const out = []; let index = 0; for (let i = 0; i < inputLength; i += 2) { out[index++] = [arr[i], arr[i + 1]]; } return out; } function interpolate(x, xmin, xmax, ymin, ymax) { return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin)); } let domain = toNumberArray(dict.getArray("Domain")); let range = toNumberArray(dict.getArray("Range")); if (!domain || !range) { throw new FormatError("No domain or range"); } const inputSize = domain.length / 2; const outputSize = range.length / 2; domain = toMultiArray(domain); range = toMultiArray(range); const size = toNumberArray(dict.getArray("Size")); const bps = dict.get("BitsPerSample"); const order = dict.get("Order") || 1; if (order !== 1) { info("No support for cubic spline interpolation: " + order); } let encode = toNumberArray(dict.getArray("Encode")); if (!encode) { encode = []; for (let i = 0; i < inputSize; ++i) { encode.push([0, size[i] - 1]); } } else { encode = toMultiArray(encode); } let decode = toNumberArray(dict.getArray("Decode")); decode = !decode ? range : toMultiArray(decode); const samples = this.getSampleArray(size, outputSize, bps, fn); return function constructSampledFn(src, srcOffset, dest, destOffset) { const cubeVertices = 1 << inputSize; const cubeN = new Float64Array(cubeVertices); const cubeVertex = new Uint32Array(cubeVertices); let i, j; for (j = 0; j < cubeVertices; j++) { cubeN[j] = 1; } let k = outputSize, pos = 1; for (i = 0; i < inputSize; ++i) { const domain_2i = domain[i][0]; const domain_2i_1 = domain[i][1]; const xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1); let e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]); const size_i = size[i]; e = Math.min(Math.max(e, 0), size_i - 1); const e0 = e < size_i - 1 ? Math.floor(e) : e - 1; const n0 = e0 + 1 - e; const n1 = e - e0; const offset0 = e0 * k; const offset1 = offset0 + k; for (j = 0; j < cubeVertices; j++) { if (j & pos) { cubeN[j] *= n1; cubeVertex[j] += offset1; } else { cubeN[j] *= n0; cubeVertex[j] += offset0; } } k *= size_i; pos <<= 1; } for (j = 0; j < outputSize; ++j) { let rj = 0; for (i = 0; i < cubeVertices; i++) { rj += samples[cubeVertex[i] + j] * cubeN[i]; } rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]); dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]); } }; } static constructInterpolated({ xref, isEvalSupported, dict }) { const c0 = toNumberArray(dict.getArray("C0")) || [0]; const c1 = toNumberArray(dict.getArray("C1")) || [1]; const n = dict.get("N"); const diff = []; for (let i = 0, ii = c0.length; i < ii; ++i) { diff.push(c1[i] - c0[i]); } const length = diff.length; return function constructInterpolatedFn(src, srcOffset, dest, destOffset) { const x = n === 1 ? src[srcOffset] : src[srcOffset] ** n; for (let j = 0; j < length; ++j) { dest[destOffset + j] = c0[j] + x * diff[j]; } }; } static constructStiched({ xref, isEvalSupported, dict }) { const domain = toNumberArray(dict.getArray("Domain")); if (!domain) { throw new FormatError("No domain"); } const inputSize = domain.length / 2; if (inputSize !== 1) { throw new FormatError("Bad domain for stiched function"); } const fns = []; for (const fn of dict.get("Functions")) { fns.push(this.parse({ xref, isEvalSupported, fn: xref.fetchIfRef(fn) })); } const bounds = toNumberArray(dict.getArray("Bounds")); const encode = toNumberArray(dict.getArray("Encode")); const tmpBuf = new Float32Array(1); return function constructStichedFn(src, srcOffset, dest, destOffset) { const clip = function constructStichedFromIRClip(v, min, max) { if (v > max) { v = max; } else if (v < min) { v = min; } return v; }; const v = clip(src[srcOffset], domain[0], domain[1]); const length = bounds.length; let i; for (i = 0; i < length; ++i) { if (v < bounds[i]) { break; } } let dmin = domain[0]; if (i > 0) { dmin = bounds[i - 1]; } let dmax = domain[1]; if (i < bounds.length) { dmax = bounds[i]; } const rmin = encode[2 * i]; const rmax = encode[2 * i + 1]; tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin); fns[i](tmpBuf, 0, dest, destOffset); }; } static constructPostScript({ xref, isEvalSupported, fn, dict }) { const domain = toNumberArray(dict.getArray("Domain")); const range = toNumberArray(dict.getArray("Range")); if (!domain) { throw new FormatError("No domain."); } if (!range) { throw new FormatError("No range."); } const lexer = new PostScriptLexer(fn); const parser = new PostScriptParser(lexer); const code = parser.parse(); if (isEvalSupported && FeatureTest.isEvalSupported) { const compiled = new PostScriptCompiler().compile(code, domain, range); if (compiled) { return new Function("src", "srcOffset", "dest", "destOffset", compiled); } } info("Unable to compile PS function"); const numOutputs = range.length >> 1; const numInputs = domain.length >> 1; const evaluator = new PostScriptEvaluator(code); const cache = Object.create(null); const MAX_CACHE_SIZE = 2048 * 4; let cache_available = MAX_CACHE_SIZE; const tmpBuf = new Float32Array(numInputs); return function constructPostScriptFn(src, srcOffset, dest, destOffset) { let i, value; let key = ""; const input = tmpBuf; for (i = 0; i < numInputs; i++) { value = src[srcOffset + i]; input[i] = value; key += value + "_"; } const cachedValue = cache[key]; if (cachedValue !== undefined) { dest.set(cachedValue, destOffset); return; } const output = new Float32Array(numOutputs); const stack = evaluator.execute(input); const stackIndex = stack.length - numOutputs; for (i = 0; i < numOutputs; i++) { value = stack[stackIndex + i]; let bound = range[i * 2]; if (value < bound) { value = bound; } else { bound = range[i * 2 + 1]; if (value > bound) { value = bound; } } output[i] = value; } if (cache_available > 0) { cache_available--; cache[key] = output; } dest.set(output, destOffset); }; } } function isPDFFunction(v) { let fnDict; if (v instanceof Dict) { fnDict = v; } else if (v instanceof BaseStream) { fnDict = v.dict; } else { return false; } return fnDict.has("FunctionType"); } class PostScriptStack { static MAX_STACK_SIZE = 100; constructor(initialStack) { this.stack = initialStack ? Array.from(initialStack) : []; } push(value) { if (this.stack.length >= PostScriptStack.MAX_STACK_SIZE) { throw new Error("PostScript function stack overflow."); } this.stack.push(value); } pop() { if (this.stack.length <= 0) { throw new Error("PostScript function stack underflow."); } return this.stack.pop(); } copy(n) { if (this.stack.length + n >= PostScriptStack.MAX_STACK_SIZE) { throw new Error("PostScript function stack overflow."); } const stack = this.stack; for (let i = stack.length - n, j = n - 1; j >= 0; j--, i++) { stack.push(stack[i]); } } index(n) { this.push(this.stack[this.stack.length - n - 1]); } roll(n, p) { const stack = this.stack; const l = stack.length - n; const r = stack.length - 1; const c = l + (p - Math.floor(p / n) * n); for (let i = l, j = r; i < j; i++, j--) { const t = stack[i]; stack[i] = stack[j]; stack[j] = t; } for (let i = l, j = c - 1; i < j; i++, j--) { const t = stack[i]; stack[i] = stack[j]; stack[j] = t; } for (let i = c, j = r; i < j; i++, j--) { const t = stack[i]; stack[i] = stack[j]; stack[j] = t; } } } class PostScriptEvaluator { constructor(operators) { this.operators = operators; } execute(initialStack) { const stack = new PostScriptStack(initialStack); let counter = 0; const operators = this.operators; const length = operators.length; let operator, a, b; while (counter < length) { operator = operators[counter++]; if (typeof operator === "number") { stack.push(operator); continue; } switch (operator) { case "jz": b = stack.pop(); a = stack.pop(); if (!a) { counter = b; } break; case "j": a = stack.pop(); counter = a; break; case "abs": a = stack.pop(); stack.push(Math.abs(a)); break; case "add": b = stack.pop(); a = stack.pop(); stack.push(a + b); break; case "and": b = stack.pop(); a = stack.pop(); if (typeof a === "boolean" && typeof b === "boolean") { stack.push(a && b); } else { stack.push(a & b); } break; case "atan": b = stack.pop(); a = stack.pop(); a = Math.atan2(a, b) / Math.PI * 180; if (a < 0) { a += 360; } stack.push(a); break; case "bitshift": b = stack.pop(); a = stack.pop(); if (a > 0) { stack.push(a << b); } else { stack.push(a >> b); } break; case "ceiling": a = stack.pop(); stack.push(Math.ceil(a)); break; case "copy": a = stack.pop(); stack.copy(a); break; case "cos": a = stack.pop(); stack.push(Math.cos(a % 360 / 180 * Math.PI)); break; case "cvi": a = stack.pop() | 0; stack.push(a); break; case "cvr": break; case "div": b = stack.pop(); a = stack.pop(); stack.push(a / b); break; case "dup": stack.copy(1); break; case "eq": b = stack.pop(); a = stack.pop(); stack.push(a === b); break; case "exch": stack.roll(2, 1); break; case "exp": b = stack.pop(); a = stack.pop(); stack.push(a ** b); break; case "false": stack.push(false); break; case "floor": a = stack.pop(); stack.push(Math.floor(a)); break; case "ge": b = stack.pop(); a = stack.pop(); stack.push(a >= b); break; case "gt": b = stack.pop(); a = stack.pop(); stack.push(a > b); break; case "idiv": b = stack.pop(); a = stack.pop(); stack.push(a / b | 0); break; case "index": a = stack.pop(); stack.index(a); break; case "le": b = stack.pop(); a = stack.pop(); stack.push(a <= b); break; case "ln": a = stack.pop(); stack.push(Math.log(a)); break; case "log": a = stack.pop(); stack.push(Math.log10(a)); break; case "lt": b = stack.pop(); a = stack.pop(); stack.push(a < b); break; case "mod": b = stack.pop(); a = stack.pop(); stack.push(a % b); break; case "mul": b = stack.pop(); a = stack.pop(); stack.push(a * b); break; case "ne": b = stack.pop(); a = stack.pop(); stack.push(a !== b); break; case "neg": a = stack.pop(); stack.push(-a); break; case "not": a = stack.pop(); if (typeof a === "boolean") { stack.push(!a); } else { stack.push(~a); } break; case "or": b = stack.pop(); a = stack.pop(); if (typeof a === "boolean" && typeof b === "boolean") { stack.push(a || b); } else { stack.push(a | b); } break; case "pop": stack.pop(); break; case "roll": b = stack.pop(); a = stack.pop(); stack.roll(a, b); break; case "round": a = stack.pop(); stack.push(Math.round(a)); break; case "sin": a = stack.pop(); stack.push(Math.sin(a % 360 / 180 * Math.PI)); break; case "sqrt": a = stack.pop(); stack.push(Math.sqrt(a)); break; case "sub": b = stack.pop(); a = stack.pop(); stack.push(a - b); break; case "true": stack.push(true); break; case "truncate": a = stack.pop(); a = a < 0 ? Math.ceil(a) : Math.floor(a); stack.push(a); break; case "xor": b = stack.pop(); a = stack.pop(); if (typeof a === "boolean" && typeof b === "boolean") { stack.push(a !== b); } else { stack.push(a ^ b); } break; default: throw new FormatError(`Unknown operator ${operator}`); } } return stack.stack; } } class AstNode { constructor(type) { this.type = type; } visit(visitor) { unreachable("abstract method"); } } class AstArgument extends AstNode { constructor(index, min, max) { super("args"); this.index = index; this.min = min; this.max = max; } visit(visitor) { visitor.visitArgument(this); } } class AstLiteral extends AstNode { constructor(number) { super("literal"); this.number = number; this.min = number; this.max = number; } visit(visitor) { visitor.visitLiteral(this); } } class AstBinaryOperation extends AstNode { constructor(op, arg1, arg2, min, max) { super("binary"); this.op = op; this.arg1 = arg1; this.arg2 = arg2; this.min = min; this.max = max; } visit(visitor) { visitor.visitBinaryOperation(this); } } class AstMin extends AstNode { constructor(arg, max) { super("max"); this.arg = arg; this.min = arg.min; this.max = max; } visit(visitor) { visitor.visitMin(this); } } class AstVariable extends AstNode { constructor(index, min, max) { super("var"); this.index = index; this.min = min; this.max = max; } visit(visitor) { visitor.visitVariable(this); } } class AstVariableDefinition extends AstNode { constructor(variable, arg) { super("definition"); this.variable = variable; this.arg = arg; } visit(visitor) { visitor.visitVariableDefinition(this); } } class ExpressionBuilderVisitor { constructor() { this.parts = []; } visitArgument(arg) { this.parts.push("Math.max(", arg.min, ", Math.min(", arg.max, ", src[srcOffset + ", arg.index, "]))"); } visitVariable(variable) { this.parts.push("v", variable.index); } visitLiteral(literal) { this.parts.push(literal.number); } visitBinaryOperation(operation) { this.parts.push("("); operation.arg1.visit(this); this.parts.push(" ", operation.op, " "); operation.arg2.visit(this); this.parts.push(")"); } visitVariableDefinition(definition) { this.parts.push("var "); definition.variable.visit(this); this.parts.push(" = "); definition.arg.visit(this); this.parts.push(";"); } visitMin(max) { this.parts.push("Math.min("); max.arg.visit(this); this.parts.push(", ", max.max, ")"); } toString() { return this.parts.join(""); } } function buildAddOperation(num1, num2) { if (num2.type === "literal" && num2.number === 0) { return num1; } if (num1.type === "literal" && num1.number === 0) { return num2; } if (num2.type === "literal" && num1.type === "literal") { return new AstLiteral(num1.number + num2.number); } return new AstBinaryOperation("+", num1, num2, num1.min + num2.min, num1.max + num2.max); } function buildMulOperation(num1, num2) { if (num2.type === "literal") { if (num2.number === 0) { return new AstLiteral(0); } else if (num2.number === 1) { return num1; } else if (num1.type === "literal") { return new AstLiteral(num1.number * num2.number); } } if (num1.type === "literal") { if (num1.number === 0) { return new AstLiteral(0); } else if (num1.number === 1) { return num2; } } const min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max); const max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max); return new AstBinaryOperation("*", num1, num2, min, max); } function buildSubOperation(num1, num2) { if (num2.type === "literal") { if (num2.number === 0) { return num1; } else if (num1.type === "literal") { return new AstLiteral(num1.number - num2.number); } } if (num2.type === "binary" && num2.op === "-" && num1.type === "literal" && num1.number === 1 && num2.arg1.type === "literal" && num2.arg1.number === 1) { return num2.arg2; } return new AstBinaryOperation("-", num1, num2, num1.min - num2.max, num1.max - num2.min); } function buildMinOperation(num1, max) { if (num1.min >= max) { return new AstLiteral(max); } else if (num1.max <= max) { return num1; } return new AstMin(num1, max); } class PostScriptCompiler { compile(code, domain, range) { const stack = []; const instructions = []; const inputSize = domain.length >> 1, outputSize = range.length >> 1; let lastRegister = 0; let n, j; let num1, num2, ast1, ast2, tmpVar, item; for (let i = 0; i < inputSize; i++) { stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1])); } for (let i = 0, ii = code.length; i < ii; i++) { item = code[i]; if (typeof item === "number") { stack.push(new AstLiteral(item)); continue; } switch (item) { case "add": if (stack.length < 2) { return null; } num2 = stack.pop(); num1 = stack.pop(); stack.push(buildAddOperation(num1, num2)); break; case "cvr": if (stack.length < 1) { return null; } break; case "mul": if (stack.length < 2) { return null; } num2 = stack.pop(); num1 = stack.pop(); stack.push(buildMulOperation(num1, num2)); break; case "sub": if (stack.length < 2) { return null; } num2 = stack.pop(); num1 = stack.pop(); stack.push(buildSubOperation(num1, num2)); break; case "exch": if (stack.length < 2) { return null; } ast1 = stack.pop(); ast2 = stack.pop(); stack.push(ast1, ast2); break; case "pop": if (stack.length < 1) { return null; } stack.pop(); break; case "index": if (stack.length < 1) { return null; } num1 = stack.pop(); if (num1.type !== "literal") { return null; } n = num1.number; if (n < 0 || !Number.isInteger(n) || stack.length < n) { return null; } ast1 = stack[stack.length - n - 1]; if (ast1.type === "literal" || ast1.type === "var") { stack.push(ast1); break; } tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max); stack[stack.length - n - 1] = tmpVar; stack.push(tmpVar); instructions.push(new AstVariableDefinition(tmpVar, ast1)); break; case "dup": if (stack.length < 1) { return null; } if (typeof code[i + 1] === "number" && code[i + 2] === "gt" && code[i + 3] === i + 7 && code[i + 4] === "jz" && code[i + 5] === "pop" && code[i + 6] === code[i + 1]) { num1 = stack.pop(); stack.push(buildMinOperation(num1, code[i + 1])); i += 6; break; } ast1 = stack.at(-1); if (ast1.type === "literal" || ast1.type === "var") { stack.push(ast1); break; } tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max); stack[stack.length - 1] = tmpVar; stack.push(tmpVar); instructions.push(new AstVariableDefinition(tmpVar, ast1)); break; case "roll": if (stack.length < 2) { return null; } num2 = stack.pop(); num1 = stack.pop(); if (num2.type !== "literal" || num1.type !== "literal") { return null; } j = num2.number; n = num1.number; if (n <= 0 || !Number.isInteger(n) || !Number.isInteger(j) || stack.length < n) { return null; } j = (j % n + n) % n; if (j === 0) { break; } stack.push(...stack.splice(stack.length - n, n - j)); break; default: return null; } } if (stack.length !== outputSize) { return null; } const result = []; for (const instruction of instructions) { const statementBuilder = new ExpressionBuilderVisitor(); instruction.visit(statementBuilder); result.push(statementBuilder.toString()); } for (let i = 0, ii = stack.length; i < ii; i++) { const expr = stack[i], statementBuilder = new ExpressionBuilderVisitor(); expr.visit(statementBuilder); const min = range[i * 2], max = range[i * 2 + 1]; const out = [statementBuilder.toString()]; if (min > expr.min) { out.unshift("Math.max(", min, ", "); out.push(")"); } if (max < expr.max) { out.unshift("Math.min(", max, ", "); out.push(")"); } out.unshift("dest[destOffset + ", i, "] = "); out.push(";"); result.push(out.join("")); } return result.join("\n"); } } ;// CONCATENATED MODULE: ./src/core/bidi.js const baseTypes = ["BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "S", "B", "S", "WS", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "B", "B", "B", "S", "WS", "ON", "ON", "ET", "ET", "ET", "ON", "ON", "ON", "ON", "ON", "ES", "CS", "ES", "CS", "CS", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "CS", "ON", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "ON", "ON", "ON", "BN", "BN", "BN", "BN", "BN", "BN", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "CS", "ON", "ET", "ET", "ET", "ET", "ON", "ON", "ON", "ON", "L", "ON", "ON", "BN", "ON", "ON", "ET", "ET", "EN", "EN", "ON", "L", "ON", "ON", "ON", "EN", "L", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "L", "L", "L", "L", "L", "L", "L", "L"]; const arabicTypes = ["AN", "AN", "AN", "AN", "AN", "AN", "ON", "ON", "AL", "ET", "ET", "AL", "CS", "AL", "ON", "ON", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "ET", "AN", "AN", "AL", "AL", "AL", "NSM", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN", "ON", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "NSM", "NSM", "ON", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "AL", "AL", "AL", "AL", "AL", "AL"]; function isOdd(i) { return (i & 1) !== 0; } function isEven(i) { return (i & 1) === 0; } function findUnequal(arr, start, value) { let j, jj; for (j = start, jj = arr.length; j < jj; ++j) { if (arr[j] !== value) { return j; } } return j; } function setValues(arr, start, end, value) { for (let j = start; j < end; ++j) { arr[j] = value; } } function reverseValues(arr, start, end) { for (let i = start, j = end - 1; i < j; ++i, --j) { const temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } function createBidiText(str, isLTR, vertical = false) { let dir = "ltr"; if (vertical) { dir = "ttb"; } else if (!isLTR) { dir = "rtl"; } return { str, dir }; } const chars = []; const types = []; function bidi(str, startLevel = -1, vertical = false) { let isLTR = true; const strLength = str.length; if (strLength === 0 || vertical) { return createBidiText(str, isLTR, vertical); } chars.length = strLength; types.length = strLength; let numBidi = 0; let i, ii; for (i = 0; i < strLength; ++i) { chars[i] = str.charAt(i); const charCode = str.charCodeAt(i); let charType = "L"; if (charCode <= 0x00ff) { charType = baseTypes[charCode]; } else if (0x0590 <= charCode && charCode <= 0x05f4) { charType = "R"; } else if (0x0600 <= charCode && charCode <= 0x06ff) { charType = arabicTypes[charCode & 0xff]; if (!charType) { warn("Bidi: invalid Unicode character " + charCode.toString(16)); } } else if (0x0700 <= charCode && charCode <= 0x08ac || 0xfb50 <= charCode && charCode <= 0xfdff || 0xfe70 <= charCode && charCode <= 0xfeff) { charType = "AL"; } if (charType === "R" || charType === "AL" || charType === "AN") { numBidi++; } types[i] = charType; } if (numBidi === 0) { isLTR = true; return createBidiText(str, isLTR); } if (startLevel === -1) { if (numBidi / strLength < 0.3 && strLength > 4) { isLTR = true; startLevel = 0; } else { isLTR = false; startLevel = 1; } } const levels = []; for (i = 0; i < strLength; ++i) { levels[i] = startLevel; } const e = isOdd(startLevel) ? "R" : "L"; const sor = e; const eor = sor; let lastType = sor; for (i = 0; i < strLength; ++i) { if (types[i] === "NSM") { types[i] = lastType; } else { lastType = types[i]; } } lastType = sor; let t; for (i = 0; i < strLength; ++i) { t = types[i]; if (t === "EN") { types[i] = lastType === "AL" ? "AN" : "EN"; } else if (t === "R" || t === "L" || t === "AL") { lastType = t; } } for (i = 0; i < strLength; ++i) { t = types[i]; if (t === "AL") { types[i] = "R"; } } for (i = 1; i < strLength - 1; ++i) { if (types[i] === "ES" && types[i - 1] === "EN" && types[i + 1] === "EN") { types[i] = "EN"; } if (types[i] === "CS" && (types[i - 1] === "EN" || types[i - 1] === "AN") && types[i + 1] === types[i - 1]) { types[i] = types[i - 1]; } } for (i = 0; i < strLength; ++i) { if (types[i] === "EN") { for (let j = i - 1; j >= 0; --j) { if (types[j] !== "ET") { break; } types[j] = "EN"; } for (let j = i + 1; j < strLength; ++j) { if (types[j] !== "ET") { break; } types[j] = "EN"; } } } for (i = 0; i < strLength; ++i) { t = types[i]; if (t === "WS" || t === "ES" || t === "ET" || t === "CS") { types[i] = "ON"; } } lastType = sor; for (i = 0; i < strLength; ++i) { t = types[i]; if (t === "EN") { types[i] = lastType === "L" ? "L" : "EN"; } else if (t === "R" || t === "L") { lastType = t; } } for (i = 0; i < strLength; ++i) { if (types[i] === "ON") { const end = findUnequal(types, i + 1, "ON"); let before = sor; if (i > 0) { before = types[i - 1]; } let after = eor; if (end + 1 < strLength) { after = types[end + 1]; } if (before !== "L") { before = "R"; } if (after !== "L") { after = "R"; } if (before === after) { setValues(types, i, end, before); } i = end - 1; } } for (i = 0; i < strLength; ++i) { if (types[i] === "ON") { types[i] = e; } } for (i = 0; i < strLength; ++i) { t = types[i]; if (isEven(levels[i])) { if (t === "R") { levels[i] += 1; } else if (t === "AN" || t === "EN") { levels[i] += 2; } } else if (t === "L" || t === "AN" || t === "EN") { levels[i] += 1; } } let highestLevel = -1; let lowestOddLevel = 99; let level; for (i = 0, ii = levels.length; i < ii; ++i) { level = levels[i]; if (highestLevel < level) { highestLevel = level; } if (lowestOddLevel > level && isOdd(level)) { lowestOddLevel = level; } } for (level = highestLevel; level >= lowestOddLevel; --level) { let start = -1; for (i = 0, ii = levels.length; i < ii; ++i) { if (levels[i] < level) { if (start >= 0) { reverseValues(chars, start, i); start = -1; } } else if (start < 0) { start = i; } } if (start >= 0) { reverseValues(chars, start, levels.length); } } for (i = 0, ii = chars.length; i < ii; ++i) { const ch = chars[i]; if (ch === "<" || ch === ">") { chars[i] = ""; } } return createBidiText(chars.join(""), isLTR); } ;// CONCATENATED MODULE: ./src/core/font_substitutions.js const NORMAL = { style: "normal", weight: "normal" }; const BOLD = { style: "normal", weight: "bold" }; const ITALIC = { style: "italic", weight: "normal" }; const BOLDITALIC = { style: "italic", weight: "bold" }; const substitutionMap = new Map([["Times-Roman", { local: ["Times New Roman", "Times-Roman", "Times", "Liberation Serif", "Nimbus Roman", "Nimbus Roman L", "Tinos", "Thorndale", "TeX Gyre Termes", "FreeSerif", "Linux Libertine O", "Libertinus Serif", "DejaVu Serif", "Bitstream Vera Serif", "Ubuntu"], style: NORMAL, ultimate: "serif" }], ["Times-Bold", { alias: "Times-Roman", style: BOLD, ultimate: "serif" }], ["Times-Italic", { alias: "Times-Roman", style: ITALIC, ultimate: "serif" }], ["Times-BoldItalic", { alias: "Times-Roman", style: BOLDITALIC, ultimate: "serif" }], ["Helvetica", { local: ["Helvetica", "Helvetica Neue", "Arial", "Arial Nova", "Liberation Sans", "Arimo", "Nimbus Sans", "Nimbus Sans L", "A030", "TeX Gyre Heros", "FreeSans", "DejaVu Sans", "Albany", "Bitstream Vera Sans", "Arial Unicode MS", "Microsoft Sans Serif", "Apple Symbols", "Cantarell"], path: "LiberationSans-Regular.ttf", style: NORMAL, ultimate: "sans-serif" }], ["Helvetica-Bold", { alias: "Helvetica", path: "LiberationSans-Bold.ttf", style: BOLD, ultimate: "sans-serif" }], ["Helvetica-Oblique", { alias: "Helvetica", path: "LiberationSans-Italic.ttf", style: ITALIC, ultimate: "sans-serif" }], ["Helvetica-BoldOblique", { alias: "Helvetica", path: "LiberationSans-BoldItalic.ttf", style: BOLDITALIC, ultimate: "sans-serif" }], ["Courier", { local: ["Courier", "Courier New", "Liberation Mono", "Nimbus Mono", "Nimbus Mono L", "Cousine", "Cumberland", "TeX Gyre Cursor", "FreeMono", "Linux Libertine Mono O", "Libertinus Mono"], style: NORMAL, ultimate: "monospace" }], ["Courier-Bold", { alias: "Courier", style: BOLD, ultimate: "monospace" }], ["Courier-Oblique", { alias: "Courier", style: ITALIC, ultimate: "monospace" }], ["Courier-BoldOblique", { alias: "Courier", style: BOLDITALIC, ultimate: "monospace" }], ["ArialBlack", { local: ["Arial Black"], style: { style: "normal", weight: "900" }, fallback: "Helvetica-Bold" }], ["ArialBlack-Bold", { alias: "ArialBlack" }], ["ArialBlack-Italic", { alias: "ArialBlack", style: { style: "italic", weight: "900" }, fallback: "Helvetica-BoldOblique" }], ["ArialBlack-BoldItalic", { alias: "ArialBlack-Italic" }], ["ArialNarrow", { local: ["Arial Narrow", "Liberation Sans Narrow", "Helvetica Condensed", "Nimbus Sans Narrow", "TeX Gyre Heros Cn"], style: NORMAL, fallback: "Helvetica" }], ["ArialNarrow-Bold", { alias: "ArialNarrow", style: BOLD, fallback: "Helvetica-Bold" }], ["ArialNarrow-Italic", { alias: "ArialNarrow", style: ITALIC, fallback: "Helvetica-Oblique" }], ["ArialNarrow-BoldItalic", { alias: "ArialNarrow", style: BOLDITALIC, fallback: "Helvetica-BoldOblique" }], ["Calibri", { local: ["Calibri", "Carlito"], style: NORMAL, fallback: "Helvetica" }], ["Calibri-Bold", { alias: "Calibri", style: BOLD, fallback: "Helvetica-Bold" }], ["Calibri-Italic", { alias: "Calibri", style: ITALIC, fallback: "Helvetica-Oblique" }], ["Calibri-BoldItalic", { alias: "Calibri", style: BOLDITALIC, fallback: "Helvetica-BoldOblique" }], ["Wingdings", { local: ["Wingdings", "URW Dingbats"], style: NORMAL }], ["Wingdings-Regular", { alias: "Wingdings" }], ["Wingdings-Bold", { alias: "Wingdings" }]]); const fontAliases = new Map([["Arial-Black", "ArialBlack"]]); function getStyleToAppend(style) { switch (style) { case BOLD: return "Bold"; case ITALIC: return "Italic"; case BOLDITALIC: return "Bold Italic"; default: if (style?.weight === "bold") { return "Bold"; } if (style?.style === "italic") { return "Italic"; } } return ""; } function getFamilyName(str) { const keywords = new Set(["thin", "extralight", "ultralight", "demilight", "semilight", "light", "book", "regular", "normal", "medium", "demibold", "semibold", "bold", "extrabold", "ultrabold", "black", "heavy", "extrablack", "ultrablack", "roman", "italic", "oblique", "ultracondensed", "extracondensed", "condensed", "semicondensed", "normal", "semiexpanded", "expanded", "extraexpanded", "ultraexpanded", "bolditalic"]); return str.split(/[- ,+]+/g).filter(tok => !keywords.has(tok.toLowerCase())).join(" "); } function generateFont({ alias, local, path, fallback, style, ultimate }, src, localFontPath, useFallback = true, usePath = true, append = "") { const result = { style: null, ultimate: null }; if (local) { const extra = append ? ` ${append}` : ""; for (const name of local) { src.push(`local(${name}${extra})`); } } if (alias) { const substitution = substitutionMap.get(alias); const aliasAppend = append || getStyleToAppend(style); Object.assign(result, generateFont(substitution, src, localFontPath, useFallback && !fallback, usePath && !path, aliasAppend)); } if (style) { result.style = style; } if (ultimate) { result.ultimate = ultimate; } if (useFallback && fallback) { const fallbackInfo = substitutionMap.get(fallback); const { ultimate: fallbackUltimate } = generateFont(fallbackInfo, src, localFontPath, useFallback, usePath && !path, append); result.ultimate ||= fallbackUltimate; } if (usePath && path && localFontPath) { src.push(`url(${localFontPath}${path})`); } return result; } function getFontSubstitution(systemFontCache, idFactory, localFontPath, baseFontName, standardFontName, type) { if (baseFontName.startsWith("InvalidPDFjsFont_")) { return null; } if ((type === "TrueType" || type === "Type1") && /^[A-Z]{6}\+/.test(baseFontName)) { baseFontName = baseFontName.slice(7); } baseFontName = normalizeFontName(baseFontName); const key = baseFontName; let substitutionInfo = systemFontCache.get(key); if (substitutionInfo) { return substitutionInfo; } let substitution = substitutionMap.get(baseFontName); if (!substitution) { for (const [alias, subst] of fontAliases) { if (baseFontName.startsWith(alias)) { baseFontName = `${subst}${baseFontName.substring(alias.length)}`; substitution = substitutionMap.get(baseFontName); break; } } } let mustAddBaseFont = false; if (!substitution) { substitution = substitutionMap.get(standardFontName); mustAddBaseFont = true; } const loadedName = `${idFactory.getDocId()}_s${idFactory.createFontId()}`; if (!substitution) { if (!validateFontName(baseFontName)) { warn(`Cannot substitute the font because of its name: ${baseFontName}`); systemFontCache.set(key, null); return null; } const bold = /bold/gi.test(baseFontName); const italic = /oblique|italic/gi.test(baseFontName); const style = bold && italic && BOLDITALIC || bold && BOLD || italic && ITALIC || NORMAL; substitutionInfo = { css: `"${getFamilyName(baseFontName)}",${loadedName}`, guessFallback: true, loadedName, baseFontName, src: `local(${baseFontName})`, style }; systemFontCache.set(key, substitutionInfo); return substitutionInfo; } const src = []; if (mustAddBaseFont && validateFontName(baseFontName)) { src.push(`local(${baseFontName})`); } const { style, ultimate } = generateFont(substitution, src, localFontPath); const guessFallback = ultimate === null; const fallback = guessFallback ? "" : `,${ultimate}`; substitutionInfo = { css: `"${getFamilyName(baseFontName)}",${loadedName}${fallback}`, guessFallback, loadedName, baseFontName, src: src.join(","), style }; systemFontCache.set(key, substitutionInfo); return substitutionInfo; } ;// CONCATENATED MODULE: ./src/core/image_resizer.js const MIN_IMAGE_DIM = 2048; const MAX_IMAGE_DIM = 65537; const MAX_ERROR = 128; class ImageResizer { constructor(imgData, isMask) { this._imgData = imgData; this._isMask = isMask; } static needsToBeResized(width, height) { if (width <= this._goodSquareLength && height <= this._goodSquareLength) { return false; } const { MAX_DIM } = this; if (width > MAX_DIM || height > MAX_DIM) { return true; } const area = width * height; if (this._hasMaxArea) { return area > this.MAX_AREA; } if (area < this._goodSquareLength ** 2) { return false; } if (this._areGoodDims(width, height)) { this._goodSquareLength = Math.max(this._goodSquareLength, Math.floor(Math.sqrt(width * height))); return false; } this._goodSquareLength = this._guessMax(this._goodSquareLength, MAX_DIM, MAX_ERROR, 0); const maxArea = this.MAX_AREA = this._goodSquareLength ** 2; return area > maxArea; } static get MAX_DIM() { return shadow(this, "MAX_DIM", this._guessMax(MIN_IMAGE_DIM, MAX_IMAGE_DIM, 0, 1)); } static get MAX_AREA() { this._hasMaxArea = true; return shadow(this, "MAX_AREA", this._guessMax(ImageResizer._goodSquareLength, this.MAX_DIM, MAX_ERROR, 0) ** 2); } static set MAX_AREA(area) { if (area >= 0) { this._hasMaxArea = true; shadow(this, "MAX_AREA", area); } } static setMaxArea(area) { if (!this._hasMaxArea) { this.MAX_AREA = area >> 2; } } static _areGoodDims(width, height) { try { const canvas = new OffscreenCanvas(width, height); const ctx = canvas.getContext("2d"); ctx.fillRect(0, 0, 1, 1); const opacity = ctx.getImageData(0, 0, 1, 1).data[3]; canvas.width = canvas.height = 1; return opacity !== 0; } catch { return false; } } static _guessMax(start, end, tolerance, defaultHeight) { while (start + tolerance + 1 < end) { const middle = Math.floor((start + end) / 2); const height = defaultHeight || middle; if (this._areGoodDims(middle, height)) { start = middle; } else { end = middle; } } return start; } static async createImage(imgData, isMask = false) { return new ImageResizer(imgData, isMask)._createImage(); } async _createImage() { const data = this._encodeBMP(); const blob = new Blob([data.buffer], { type: "image/bmp" }); const bitmapPromise = createImageBitmap(blob); const { MAX_AREA, MAX_DIM } = ImageResizer; const { _imgData: imgData } = this; const { width, height } = imgData; const minFactor = Math.max(width / MAX_DIM, height / MAX_DIM, Math.sqrt(width * height / MAX_AREA)); const firstFactor = Math.max(minFactor, 2); const factor = Math.round(10 * (minFactor + 1.25)) / 10 / firstFactor; const N = Math.floor(Math.log2(factor)); const steps = new Array(N + 2).fill(2); steps[0] = firstFactor; steps.splice(-1, 1, factor / (1 << N)); let newWidth = width; let newHeight = height; let bitmap = await bitmapPromise; for (const step of steps) { const prevWidth = newWidth; const prevHeight = newHeight; newWidth = Math.floor(newWidth / step) - 1; newHeight = Math.floor(newHeight / step) - 1; const canvas = new OffscreenCanvas(newWidth, newHeight); const ctx = canvas.getContext("2d"); ctx.drawImage(bitmap, 0, 0, prevWidth, prevHeight, 0, 0, newWidth, newHeight); bitmap = canvas.transferToImageBitmap(); } imgData.data = null; imgData.bitmap = bitmap; imgData.width = newWidth; imgData.height = newHeight; return imgData; } _encodeBMP() { const { width, height, kind } = this._imgData; let data = this._imgData.data; let bitPerPixel; let colorTable = new Uint8Array(0); let maskTable = colorTable; let compression = 0; switch (kind) { case ImageKind.GRAYSCALE_1BPP: { bitPerPixel = 1; colorTable = new Uint8Array(this._isMask ? [255, 255, 255, 255, 0, 0, 0, 0] : [0, 0, 0, 0, 255, 255, 255, 255]); const rowLen = width + 7 >> 3; const rowSize = rowLen + 3 & -4; if (rowLen !== rowSize) { const newData = new Uint8Array(rowSize * height); let k = 0; for (let i = 0, ii = height * rowLen; i < ii; i += rowLen, k += rowSize) { newData.set(data.subarray(i, i + rowLen), k); } data = newData; } break; } case ImageKind.RGB_24BPP: { bitPerPixel = 24; if (width & 3) { const rowLen = 3 * width; const rowSize = rowLen + 3 & -4; const extraLen = rowSize - rowLen; const newData = new Uint8Array(rowSize * height); let k = 0; for (let i = 0, ii = height * rowLen; i < ii; i += rowLen) { const row = data.subarray(i, i + rowLen); for (let j = 0; j < rowLen; j += 3) { newData[k++] = row[j + 2]; newData[k++] = row[j + 1]; newData[k++] = row[j]; } k += extraLen; } data = newData; } else { for (let i = 0, ii = data.length; i < ii; i += 3) { const tmp = data[i]; data[i] = data[i + 2]; data[i + 2] = tmp; } } break; } case ImageKind.RGBA_32BPP: bitPerPixel = 32; compression = 3; maskTable = new Uint8Array(4 + 4 + 4 + 4 + 52); const view = new DataView(maskTable.buffer); if (FeatureTest.isLittleEndian) { view.setUint32(0, 0x000000ff, true); view.setUint32(4, 0x0000ff00, true); view.setUint32(8, 0x00ff0000, true); view.setUint32(12, 0xff000000, true); } else { view.setUint32(0, 0xff000000, true); view.setUint32(4, 0x00ff0000, true); view.setUint32(8, 0x0000ff00, true); view.setUint32(12, 0x000000ff, true); } break; default: throw new Error("invalid format"); } let i = 0; const headerLength = 40 + maskTable.length; const fileLength = 14 + headerLength + colorTable.length + data.length; const bmpData = new Uint8Array(fileLength); const view = new DataView(bmpData.buffer); view.setUint16(i, 0x4d42, true); i += 2; view.setUint32(i, fileLength, true); i += 4; view.setUint32(i, 0, true); i += 4; view.setUint32(i, 14 + headerLength + colorTable.length, true); i += 4; view.setUint32(i, headerLength, true); i += 4; view.setInt32(i, width, true); i += 4; view.setInt32(i, -height, true); i += 4; view.setUint16(i, 1, true); i += 2; view.setUint16(i, bitPerPixel, true); i += 2; view.setUint32(i, compression, true); i += 4; view.setUint32(i, 0, true); i += 4; view.setInt32(i, 0, true); i += 4; view.setInt32(i, 0, true); i += 4; view.setUint32(i, colorTable.length / 4, true); i += 4; view.setUint32(i, 0, true); i += 4; bmpData.set(maskTable, i); i += maskTable.length; bmpData.set(colorTable, i); i += colorTable.length; bmpData.set(data, i); return bmpData; } } ImageResizer._goodSquareLength = MIN_IMAGE_DIM; ;// CONCATENATED MODULE: ./src/shared/murmurhash3.js const SEED = 0xc3d2e1f0; const MASK_HIGH = 0xffff0000; const MASK_LOW = 0xffff; class MurmurHash3_64 { constructor(seed) { this.h1 = seed ? seed & 0xffffffff : SEED; this.h2 = seed ? seed & 0xffffffff : SEED; } update(input) { let data, length; if (typeof input === "string") { data = new Uint8Array(input.length * 2); length = 0; for (let i = 0, ii = input.length; i < ii; i++) { const code = input.charCodeAt(i); if (code <= 0xff) { data[length++] = code; } else { data[length++] = code >>> 8; data[length++] = code & 0xff; } } } else if (ArrayBuffer.isView(input)) { data = input.slice(); length = data.byteLength; } else { throw new Error("Invalid data format, must be a string or TypedArray."); } const blockCounts = length >> 2; const tailLength = length - blockCounts * 4; const dataUint32 = new Uint32Array(data.buffer, 0, blockCounts); let k1 = 0, k2 = 0; let h1 = this.h1, h2 = this.h2; const C1 = 0xcc9e2d51, C2 = 0x1b873593; const C1_LOW = C1 & MASK_LOW, C2_LOW = C2 & MASK_LOW; for (let i = 0; i < blockCounts; i++) { if (i & 1) { k1 = dataUint32[i]; k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW; k1 = k1 << 15 | k1 >>> 17; k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW; h1 ^= k1; h1 = h1 << 13 | h1 >>> 19; h1 = h1 * 5 + 0xe6546b64; } else { k2 = dataUint32[i]; k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW; k2 = k2 << 15 | k2 >>> 17; k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW; h2 ^= k2; h2 = h2 << 13 | h2 >>> 19; h2 = h2 * 5 + 0xe6546b64; } } k1 = 0; switch (tailLength) { case 3: k1 ^= data[blockCounts * 4 + 2] << 16; case 2: k1 ^= data[blockCounts * 4 + 1] << 8; case 1: k1 ^= data[blockCounts * 4]; k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW; k1 = k1 << 15 | k1 >>> 17; k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW; if (blockCounts & 1) { h1 ^= k1; } else { h2 ^= k1; } } this.h1 = h1; this.h2 = h2; } hexdigest() { let h1 = this.h1, h2 = this.h2; h1 ^= h2 >>> 1; h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW; h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16; h1 ^= h2 >>> 1; h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW; h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16; h1 ^= h2 >>> 1; return (h1 >>> 0).toString(16).padStart(8, "0") + (h2 >>> 0).toString(16).padStart(8, "0"); } } ;// CONCATENATED MODULE: ./src/core/operator_list.js function addState(parentState, pattern, checkFn, iterateFn, processFn) { let state = parentState; for (let i = 0, ii = pattern.length - 1; i < ii; i++) { const item = pattern[i]; state = state[item] ||= []; } state[pattern.at(-1)] = { checkFn, iterateFn, processFn }; } const InitialState = []; addState(InitialState, [OPS.save, OPS.transform, OPS.paintInlineImageXObject, OPS.restore], null, function iterateInlineImageGroup(context, i) { const fnArray = context.fnArray; const iFirstSave = context.iCurr - 3; const pos = (i - iFirstSave) % 4; switch (pos) { case 0: return fnArray[i] === OPS.save; case 1: return fnArray[i] === OPS.transform; case 2: return fnArray[i] === OPS.paintInlineImageXObject; case 3: return fnArray[i] === OPS.restore; } throw new Error(`iterateInlineImageGroup - invalid pos: ${pos}`); }, function foundInlineImageGroup(context, i) { const MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10; const MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200; const MAX_WIDTH = 1000; const IMAGE_PADDING = 1; const fnArray = context.fnArray, argsArray = context.argsArray; const curr = context.iCurr; const iFirstSave = curr - 3; const iFirstTransform = curr - 2; const iFirstPIIXO = curr - 1; const count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_INLINE_IMAGES_BLOCK); if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) { return i - (i - iFirstSave) % 4; } let maxX = 0; const map = []; let maxLineHeight = 0; let currentX = IMAGE_PADDING, currentY = IMAGE_PADDING; for (let q = 0; q < count; q++) { const transform = argsArray[iFirstTransform + (q << 2)]; const img = argsArray[iFirstPIIXO + (q << 2)][0]; if (currentX + img.width > MAX_WIDTH) { maxX = Math.max(maxX, currentX); currentY += maxLineHeight + 2 * IMAGE_PADDING; currentX = 0; maxLineHeight = 0; } map.push({ transform, x: currentX, y: currentY, w: img.width, h: img.height }); currentX += img.width + 2 * IMAGE_PADDING; maxLineHeight = Math.max(maxLineHeight, img.height); } const imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING; const imgHeight = currentY + maxLineHeight + IMAGE_PADDING; const imgData = new Uint8Array(imgWidth * imgHeight * 4); const imgRowSize = imgWidth << 2; for (let q = 0; q < count; q++) { const data = argsArray[iFirstPIIXO + (q << 2)][0].data; const rowSize = map[q].w << 2; let dataOffset = 0; let offset = map[q].x + map[q].y * imgWidth << 2; imgData.set(data.subarray(0, rowSize), offset - imgRowSize); for (let k = 0, kk = map[q].h; k < kk; k++) { imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset); dataOffset += rowSize; offset += imgRowSize; } imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset); while (offset >= 0) { data[offset - 4] = data[offset]; data[offset - 3] = data[offset + 1]; data[offset - 2] = data[offset + 2]; data[offset - 1] = data[offset + 3]; data[offset + rowSize] = data[offset + rowSize - 4]; data[offset + rowSize + 1] = data[offset + rowSize - 3]; data[offset + rowSize + 2] = data[offset + rowSize - 2]; data[offset + rowSize + 3] = data[offset + rowSize - 1]; offset -= imgRowSize; } } const img = { width: imgWidth, height: imgHeight }; if (context.isOffscreenCanvasSupported) { const canvas = new OffscreenCanvas(imgWidth, imgHeight); const ctx = canvas.getContext("2d"); ctx.putImageData(new ImageData(new Uint8ClampedArray(imgData.buffer), imgWidth, imgHeight), 0, 0); img.bitmap = canvas.transferToImageBitmap(); img.data = null; } else { img.kind = ImageKind.RGBA_32BPP; img.data = imgData; } fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup); argsArray.splice(iFirstSave, count * 4, [img, map]); return iFirstSave + 1; }); addState(InitialState, [OPS.save, OPS.transform, OPS.paintImageMaskXObject, OPS.restore], null, function iterateImageMaskGroup(context, i) { const fnArray = context.fnArray; const iFirstSave = context.iCurr - 3; const pos = (i - iFirstSave) % 4; switch (pos) { case 0: return fnArray[i] === OPS.save; case 1: return fnArray[i] === OPS.transform; case 2: return fnArray[i] === OPS.paintImageMaskXObject; case 3: return fnArray[i] === OPS.restore; } throw new Error(`iterateImageMaskGroup - invalid pos: ${pos}`); }, function foundImageMaskGroup(context, i) { const MIN_IMAGES_IN_MASKS_BLOCK = 10; const MAX_IMAGES_IN_MASKS_BLOCK = 100; const MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000; const fnArray = context.fnArray, argsArray = context.argsArray; const curr = context.iCurr; const iFirstSave = curr - 3; const iFirstTransform = curr - 2; const iFirstPIMXO = curr - 1; let count = Math.floor((i - iFirstSave) / 4); if (count < MIN_IMAGES_IN_MASKS_BLOCK) { return i - (i - iFirstSave) % 4; } let isSameImage = false; let iTransform, transformArgs; const firstPIMXOArg0 = argsArray[iFirstPIMXO][0]; const firstTransformArg0 = argsArray[iFirstTransform][0], firstTransformArg1 = argsArray[iFirstTransform][1], firstTransformArg2 = argsArray[iFirstTransform][2], firstTransformArg3 = argsArray[iFirstTransform][3]; if (firstTransformArg1 === firstTransformArg2) { isSameImage = true; iTransform = iFirstTransform + 4; let iPIMXO = iFirstPIMXO + 4; for (let q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) { transformArgs = argsArray[iTransform]; if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== firstTransformArg1 || transformArgs[2] !== firstTransformArg2 || transformArgs[3] !== firstTransformArg3) { if (q < MIN_IMAGES_IN_MASKS_BLOCK) { isSameImage = false; } else { count = q; } break; } } } if (isSameImage) { count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK); const positions = new Float32Array(count * 2); iTransform = iFirstTransform; for (let q = 0; q < count; q++, iTransform += 4) { transformArgs = argsArray[iTransform]; positions[q << 1] = transformArgs[4]; positions[(q << 1) + 1] = transformArgs[5]; } fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat); argsArray.splice(iFirstSave, count * 4, [firstPIMXOArg0, firstTransformArg0, firstTransformArg1, firstTransformArg2, firstTransformArg3, positions]); } else { count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK); const images = []; for (let q = 0; q < count; q++) { transformArgs = argsArray[iFirstTransform + (q << 2)]; const maskParams = argsArray[iFirstPIMXO + (q << 2)][0]; images.push({ data: maskParams.data, width: maskParams.width, height: maskParams.height, interpolate: maskParams.interpolate, count: maskParams.count, transform: transformArgs }); } fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup); argsArray.splice(iFirstSave, count * 4, [images]); } return iFirstSave + 1; }); addState(InitialState, [OPS.save, OPS.transform, OPS.paintImageXObject, OPS.restore], function (context) { const argsArray = context.argsArray; const iFirstTransform = context.iCurr - 2; return argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0; }, function iterateImageGroup(context, i) { const fnArray = context.fnArray, argsArray = context.argsArray; const iFirstSave = context.iCurr - 3; const pos = (i - iFirstSave) % 4; switch (pos) { case 0: return fnArray[i] === OPS.save; case 1: if (fnArray[i] !== OPS.transform) { return false; } const iFirstTransform = context.iCurr - 2; const firstTransformArg0 = argsArray[iFirstTransform][0]; const firstTransformArg3 = argsArray[iFirstTransform][3]; if (argsArray[i][0] !== firstTransformArg0 || argsArray[i][1] !== 0 || argsArray[i][2] !== 0 || argsArray[i][3] !== firstTransformArg3) { return false; } return true; case 2: if (fnArray[i] !== OPS.paintImageXObject) { return false; } const iFirstPIXO = context.iCurr - 1; const firstPIXOArg0 = argsArray[iFirstPIXO][0]; if (argsArray[i][0] !== firstPIXOArg0) { return false; } return true; case 3: return fnArray[i] === OPS.restore; } throw new Error(`iterateImageGroup - invalid pos: ${pos}`); }, function (context, i) { const MIN_IMAGES_IN_BLOCK = 3; const MAX_IMAGES_IN_BLOCK = 1000; const fnArray = context.fnArray, argsArray = context.argsArray; const curr = context.iCurr; const iFirstSave = curr - 3; const iFirstTransform = curr - 2; const iFirstPIXO = curr - 1; const firstPIXOArg0 = argsArray[iFirstPIXO][0]; const firstTransformArg0 = argsArray[iFirstTransform][0]; const firstTransformArg3 = argsArray[iFirstTransform][3]; const count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_BLOCK); if (count < MIN_IMAGES_IN_BLOCK) { return i - (i - iFirstSave) % 4; } const positions = new Float32Array(count * 2); let iTransform = iFirstTransform; for (let q = 0; q < count; q++, iTransform += 4) { const transformArgs = argsArray[iTransform]; positions[q << 1] = transformArgs[4]; positions[(q << 1) + 1] = transformArgs[5]; } const args = [firstPIXOArg0, firstTransformArg0, firstTransformArg3, positions]; fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat); argsArray.splice(iFirstSave, count * 4, args); return iFirstSave + 1; }); addState(InitialState, [OPS.beginText, OPS.setFont, OPS.setTextMatrix, OPS.showText, OPS.endText], null, function iterateShowTextGroup(context, i) { const fnArray = context.fnArray, argsArray = context.argsArray; const iFirstSave = context.iCurr - 4; const pos = (i - iFirstSave) % 5; switch (pos) { case 0: return fnArray[i] === OPS.beginText; case 1: return fnArray[i] === OPS.setFont; case 2: return fnArray[i] === OPS.setTextMatrix; case 3: if (fnArray[i] !== OPS.showText) { return false; } const iFirstSetFont = context.iCurr - 3; const firstSetFontArg0 = argsArray[iFirstSetFont][0]; const firstSetFontArg1 = argsArray[iFirstSetFont][1]; if (argsArray[i][0] !== firstSetFontArg0 || argsArray[i][1] !== firstSetFontArg1) { return false; } return true; case 4: return fnArray[i] === OPS.endText; } throw new Error(`iterateShowTextGroup - invalid pos: ${pos}`); }, function (context, i) { const MIN_CHARS_IN_BLOCK = 3; const MAX_CHARS_IN_BLOCK = 1000; const fnArray = context.fnArray, argsArray = context.argsArray; const curr = context.iCurr; const iFirstBeginText = curr - 4; const iFirstSetFont = curr - 3; const iFirstSetTextMatrix = curr - 2; const iFirstShowText = curr - 1; const iFirstEndText = curr; const firstSetFontArg0 = argsArray[iFirstSetFont][0]; const firstSetFontArg1 = argsArray[iFirstSetFont][1]; let count = Math.min(Math.floor((i - iFirstBeginText) / 5), MAX_CHARS_IN_BLOCK); if (count < MIN_CHARS_IN_BLOCK) { return i - (i - iFirstBeginText) % 5; } let iFirst = iFirstBeginText; if (iFirstBeginText >= 4 && fnArray[iFirstBeginText - 4] === fnArray[iFirstSetFont] && fnArray[iFirstBeginText - 3] === fnArray[iFirstSetTextMatrix] && fnArray[iFirstBeginText - 2] === fnArray[iFirstShowText] && fnArray[iFirstBeginText - 1] === fnArray[iFirstEndText] && argsArray[iFirstBeginText - 4][0] === firstSetFontArg0 && argsArray[iFirstBeginText - 4][1] === firstSetFontArg1) { count++; iFirst -= 5; } let iEndText = iFirst + 4; for (let q = 1; q < count; q++) { fnArray.splice(iEndText, 3); argsArray.splice(iEndText, 3); iEndText += 2; } return iEndText + 1; }); class NullOptimizer { constructor(queue) { this.queue = queue; } _optimize() {} push(fn, args) { this.queue.fnArray.push(fn); this.queue.argsArray.push(args); this._optimize(); } flush() {} reset() {} } class QueueOptimizer extends NullOptimizer { constructor(queue) { super(queue); this.state = null; this.context = { iCurr: 0, fnArray: queue.fnArray, argsArray: queue.argsArray, isOffscreenCanvasSupported: false }; this.match = null; this.lastProcessed = 0; } set isOffscreenCanvasSupported(value) { this.context.isOffscreenCanvasSupported = value; } _optimize() { const fnArray = this.queue.fnArray; let i = this.lastProcessed, ii = fnArray.length; let state = this.state; let match = this.match; if (!state && !match && i + 1 === ii && !InitialState[fnArray[i]]) { this.lastProcessed = ii; return; } const context = this.context; while (i < ii) { if (match) { const iterate = (0, match.iterateFn)(context, i); if (iterate) { i++; continue; } i = (0, match.processFn)(context, i + 1); ii = fnArray.length; match = null; state = null; if (i >= ii) { break; } } state = (state || InitialState)[fnArray[i]]; if (!state || Array.isArray(state)) { i++; continue; } context.iCurr = i; i++; if (state.checkFn && !(0, state.checkFn)(context)) { state = null; continue; } match = state; state = null; } this.state = state; this.match = match; this.lastProcessed = i; } flush() { while (this.match) { const length = this.queue.fnArray.length; this.lastProcessed = (0, this.match.processFn)(this.context, length); this.match = null; this.state = null; this._optimize(); } } reset() { this.state = null; this.match = null; this.lastProcessed = 0; } } class OperatorList { static CHUNK_SIZE = 1000; static CHUNK_SIZE_ABOUT = this.CHUNK_SIZE - 5; constructor(intent = 0, streamSink) { this._streamSink = streamSink; this.fnArray = []; this.argsArray = []; this.optimizer = streamSink && !(intent & RenderingIntentFlag.OPLIST) ? new QueueOptimizer(this) : new NullOptimizer(this); this.dependencies = new Set(); this._totalLength = 0; this.weight = 0; this._resolved = streamSink ? null : Promise.resolve(); } set isOffscreenCanvasSupported(value) { this.optimizer.isOffscreenCanvasSupported = value; } get length() { return this.argsArray.length; } get ready() { return this._resolved || this._streamSink.ready; } get totalLength() { return this._totalLength + this.length; } addOp(fn, args) { this.optimizer.push(fn, args); this.weight++; if (this._streamSink) { if (this.weight >= OperatorList.CHUNK_SIZE) { this.flush(); } else if (this.weight >= OperatorList.CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) { this.flush(); } } } addImageOps(fn, args, optionalContent) { if (optionalContent !== undefined) { this.addOp(OPS.beginMarkedContentProps, ["OC", optionalContent]); } this.addOp(fn, args); if (optionalContent !== undefined) { this.addOp(OPS.endMarkedContent, []); } } addDependency(dependency) { if (this.dependencies.has(dependency)) { return; } this.dependencies.add(dependency); this.addOp(OPS.dependency, [dependency]); } addDependencies(dependencies) { for (const dependency of dependencies) { this.addDependency(dependency); } } addOpList(opList) { if (!(opList instanceof OperatorList)) { warn('addOpList - ignoring invalid "opList" parameter.'); return; } for (const dependency of opList.dependencies) { this.dependencies.add(dependency); } for (let i = 0, ii = opList.length; i < ii; i++) { this.addOp(opList.fnArray[i], opList.argsArray[i]); } } getIR() { return { fnArray: this.fnArray, argsArray: this.argsArray, length: this.length }; } get _transfers() { const transfers = []; const { fnArray, argsArray, length } = this; for (let i = 0; i < length; i++) { switch (fnArray[i]) { case OPS.paintInlineImageXObject: case OPS.paintInlineImageXObjectGroup: case OPS.paintImageMaskXObject: const arg = argsArray[i][0]; if (!arg.cached && arg.data?.buffer instanceof ArrayBuffer) { transfers.push(arg.data.buffer); } break; } } return transfers; } flush(lastChunk = false, separateAnnots = null) { this.optimizer.flush(); const length = this.length; this._totalLength += length; this._streamSink.enqueue({ fnArray: this.fnArray, argsArray: this.argsArray, lastChunk, separateAnnots, length }, 1, this._transfers); this.dependencies.clear(); this.fnArray.length = 0; this.argsArray.length = 0; this.weight = 0; this.optimizer.reset(); } } ;// CONCATENATED MODULE: ./src/core/image.js function decodeAndClamp(value, addend, coefficient, max) { value = addend + value * coefficient; if (value < 0) { value = 0; } else if (value > max) { value = max; } return value; } function resizeImageMask(src, bpc, w1, h1, w2, h2) { const length = w2 * h2; let dest; if (bpc <= 8) { dest = new Uint8Array(length); } else if (bpc <= 16) { dest = new Uint16Array(length); } else { dest = new Uint32Array(length); } const xRatio = w1 / w2; const yRatio = h1 / h2; let i, j, py, newIndex = 0, oldIndex; const xScaled = new Uint16Array(w2); const w1Scanline = w1; for (i = 0; i < w2; i++) { xScaled[i] = Math.floor(i * xRatio); } for (i = 0; i < h2; i++) { py = Math.floor(i * yRatio) * w1Scanline; for (j = 0; j < w2; j++) { oldIndex = py + xScaled[j]; dest[newIndex++] = src[oldIndex]; } } return dest; } class PDFImage { constructor({ xref, res, image, isInline = false, smask = null, mask = null, isMask = false, pdfFunctionFactory, localColorSpaceCache }) { this.image = image; let jpxDecode = false; const dict = image.dict; const filter = dict.get("F", "Filter"); let filterName; if (filter instanceof Name) { filterName = filter.name; } else if (Array.isArray(filter)) { const filterZero = xref.fetchIfRef(filter[0]); if (filterZero instanceof Name) { filterName = filterZero.name; } } switch (filterName) { case "JPXDecode": ({ width: image.width, height: image.height, componentsCount: image.numComps, bitsPerComponent: image.bitsPerComponent } = JpxImage.parseImageProperties(image.stream)); image.stream.reset(); jpxDecode = true; break; case "JBIG2Decode": image.bitsPerComponent = 1; image.numComps = 1; break; } let width = dict.get("W", "Width"); let height = dict.get("H", "Height"); if (Number.isInteger(image.width) && image.width > 0 && Number.isInteger(image.height) && image.height > 0 && (image.width !== width || image.height !== height)) { warn("PDFImage - using the Width/Height of the image data, " + "rather than the image dictionary."); width = image.width; height = image.height; } if (width < 1 || height < 1) { throw new FormatError(`Invalid image width: ${width} or height: ${height}`); } this.width = width; this.height = height; this.interpolate = dict.get("I", "Interpolate"); this.imageMask = dict.get("IM", "ImageMask") || false; this.matte = dict.get("Matte") || false; let bitsPerComponent = image.bitsPerComponent; if (!bitsPerComponent) { bitsPerComponent = dict.get("BPC", "BitsPerComponent"); if (!bitsPerComponent) { if (this.imageMask) { bitsPerComponent = 1; } else { throw new FormatError(`Bits per component missing in image: ${this.imageMask}`); } } } this.bpc = bitsPerComponent; if (!this.imageMask) { let colorSpace = dict.getRaw("CS") || dict.getRaw("ColorSpace"); if (!colorSpace) { info("JPX images (which do not require color spaces)"); switch (image.numComps) { case 1: colorSpace = Name.get("DeviceGray"); break; case 3: colorSpace = Name.get("DeviceRGB"); break; case 4: colorSpace = Name.get("DeviceCMYK"); break; default: throw new Error(`JPX images with ${image.numComps} color components not supported.`); } } this.colorSpace = ColorSpace.parse({ cs: colorSpace, xref, resources: isInline ? res : null, pdfFunctionFactory, localColorSpaceCache }); this.numComps = this.colorSpace.numComps; this.ignoreColorSpace = jpxDecode && this.colorSpace.name === "Indexed"; } this.decode = dict.getArray("D", "Decode"); this.needsDecode = false; if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode, bitsPerComponent) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) { this.needsDecode = true; const max = (1 << bitsPerComponent) - 1; this.decodeCoefficients = []; this.decodeAddends = []; const isIndexed = this.colorSpace?.name === "Indexed"; for (let i = 0, j = 0; i < this.decode.length; i += 2, ++j) { const dmin = this.decode[i]; const dmax = this.decode[i + 1]; this.decodeCoefficients[j] = isIndexed ? (dmax - dmin) / max : dmax - dmin; this.decodeAddends[j] = isIndexed ? dmin : max * dmin; } } if (smask) { this.smask = new PDFImage({ xref, res, image: smask, isInline, pdfFunctionFactory, localColorSpaceCache }); } else if (mask) { if (mask instanceof BaseStream) { const maskDict = mask.dict, imageMask = maskDict.get("IM", "ImageMask"); if (!imageMask) { warn("Ignoring /Mask in image without /ImageMask."); } else { this.mask = new PDFImage({ xref, res, image: mask, isInline, isMask: true, pdfFunctionFactory, localColorSpaceCache }); } } else { this.mask = mask; } } } static async buildImage({ xref, res, image, isInline = false, pdfFunctionFactory, localColorSpaceCache }) { const imageData = image; let smaskData = null; let maskData = null; const smask = image.dict.get("SMask"); const mask = image.dict.get("Mask"); if (smask) { if (smask instanceof BaseStream) { smaskData = smask; } else { warn("Unsupported /SMask format."); } } else if (mask) { if (mask instanceof BaseStream || Array.isArray(mask)) { maskData = mask; } else { warn("Unsupported /Mask format."); } } return new PDFImage({ xref, res, image: imageData, isInline, smask: smaskData, mask: maskData, pdfFunctionFactory, localColorSpaceCache }); } static createRawMask({ imgArray, width, height, imageIsFromDecodeStream, inverseDecode, interpolate }) { const computedLength = (width + 7 >> 3) * height; const actualLength = imgArray.byteLength; const haveFullData = computedLength === actualLength; let data, i; if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) { data = imgArray; } else if (!inverseDecode) { data = new Uint8Array(imgArray); } else { data = new Uint8Array(computedLength); data.set(imgArray); data.fill(0xff, actualLength); } if (inverseDecode) { for (i = 0; i < actualLength; i++) { data[i] ^= 0xff; } } return { data, width, height, interpolate }; } static async createMask({ imgArray, width, height, imageIsFromDecodeStream, inverseDecode, interpolate, isOffscreenCanvasSupported = false }) { const isSingleOpaquePixel = width === 1 && height === 1 && inverseDecode === (imgArray.length === 0 || !!(imgArray[0] & 128)); if (isSingleOpaquePixel) { return { isSingleOpaquePixel }; } if (isOffscreenCanvasSupported) { if (ImageResizer.needsToBeResized(width, height)) { const data = new Uint8ClampedArray(width * height * 4); convertBlackAndWhiteToRGBA({ src: imgArray, dest: data, width, height, nonBlackColor: 0, inverseDecode }); return ImageResizer.createImage({ kind: ImageKind.RGBA_32BPP, data, width, height, interpolate }); } const canvas = new OffscreenCanvas(width, height); const ctx = canvas.getContext("2d"); const imgData = ctx.createImageData(width, height); convertBlackAndWhiteToRGBA({ src: imgArray, dest: imgData.data, width, height, nonBlackColor: 0, inverseDecode }); ctx.putImageData(imgData, 0, 0); const bitmap = canvas.transferToImageBitmap(); return { data: null, width, height, interpolate, bitmap }; } return this.createRawMask({ imgArray, width, height, inverseDecode, imageIsFromDecodeStream, interpolate }); } get drawWidth() { return Math.max(this.width, this.smask?.width || 0, this.mask?.width || 0); } get drawHeight() { return Math.max(this.height, this.smask?.height || 0, this.mask?.height || 0); } decodeBuffer(buffer) { const bpc = this.bpc; const numComps = this.numComps; const decodeAddends = this.decodeAddends; const decodeCoefficients = this.decodeCoefficients; const max = (1 << bpc) - 1; let i, ii; if (bpc === 1) { for (i = 0, ii = buffer.length; i < ii; i++) { buffer[i] = +!buffer[i]; } return; } let index = 0; for (i = 0, ii = this.width * this.height; i < ii; i++) { for (let j = 0; j < numComps; j++) { buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max); index++; } } } getComponents(buffer) { const bpc = this.bpc; if (bpc === 8) { return buffer; } const width = this.width; const height = this.height; const numComps = this.numComps; const length = width * height * numComps; let bufferPos = 0; let output; if (bpc <= 8) { output = new Uint8Array(length); } else if (bpc <= 16) { output = new Uint16Array(length); } else { output = new Uint32Array(length); } const rowComps = width * numComps; const max = (1 << bpc) - 1; let i = 0, ii, buf; if (bpc === 1) { let mask, loop1End, loop2End; for (let j = 0; j < height; j++) { loop1End = i + (rowComps & ~7); loop2End = i + rowComps; while (i < loop1End) { buf = buffer[bufferPos++]; output[i] = buf >> 7 & 1; output[i + 1] = buf >> 6 & 1; output[i + 2] = buf >> 5 & 1; output[i + 3] = buf >> 4 & 1; output[i + 4] = buf >> 3 & 1; output[i + 5] = buf >> 2 & 1; output[i + 6] = buf >> 1 & 1; output[i + 7] = buf & 1; i += 8; } if (i < loop2End) { buf = buffer[bufferPos++]; mask = 128; while (i < loop2End) { output[i++] = +!!(buf & mask); mask >>= 1; } } } } else { let bits = 0; buf = 0; for (i = 0, ii = length; i < ii; ++i) { if (i % rowComps === 0) { buf = 0; bits = 0; } while (bits < bpc) { buf = buf << 8 | buffer[bufferPos++]; bits += 8; } const remainingBits = bits - bpc; let value = buf >> remainingBits; if (value < 0) { value = 0; } else if (value > max) { value = max; } output[i] = value; buf &= (1 << remainingBits) - 1; bits = remainingBits; } } return output; } fillOpacity(rgbaBuf, width, height, actualHeight, image) { const smask = this.smask; const mask = this.mask; let alphaBuf, sw, sh, i, ii, j; if (smask) { sw = smask.width; sh = smask.height; alphaBuf = new Uint8ClampedArray(sw * sh); smask.fillGrayBuffer(alphaBuf); if (sw !== width || sh !== height) { alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height); } } else if (mask) { if (mask instanceof PDFImage) { sw = mask.width; sh = mask.height; alphaBuf = new Uint8ClampedArray(sw * sh); mask.numComps = 1; mask.fillGrayBuffer(alphaBuf); for (i = 0, ii = sw * sh; i < ii; ++i) { alphaBuf[i] = 255 - alphaBuf[i]; } if (sw !== width || sh !== height) { alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height); } } else if (Array.isArray(mask)) { alphaBuf = new Uint8ClampedArray(width * height); const numComps = this.numComps; for (i = 0, ii = width * height; i < ii; ++i) { let opacity = 0; const imageOffset = i * numComps; for (j = 0; j < numComps; ++j) { const color = image[imageOffset + j]; const maskOffset = j * 2; if (color < mask[maskOffset] || color > mask[maskOffset + 1]) { opacity = 255; break; } } alphaBuf[i] = opacity; } } else { throw new FormatError("Unknown mask format."); } } if (alphaBuf) { for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) { rgbaBuf[j] = alphaBuf[i]; } } else { for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) { rgbaBuf[j] = 255; } } } undoPreblend(buffer, width, height) { const matte = this.smask?.matte; if (!matte) { return; } const matteRgb = this.colorSpace.getRgb(matte, 0); const matteR = matteRgb[0]; const matteG = matteRgb[1]; const matteB = matteRgb[2]; const length = width * height * 4; for (let i = 0; i < length; i += 4) { const alpha = buffer[i + 3]; if (alpha === 0) { buffer[i] = 255; buffer[i + 1] = 255; buffer[i + 2] = 255; continue; } const k = 255 / alpha; buffer[i] = (buffer[i] - matteR) * k + matteR; buffer[i + 1] = (buffer[i + 1] - matteG) * k + matteG; buffer[i + 2] = (buffer[i + 2] - matteB) * k + matteB; } } async createImageData(forceRGBA = false, isOffscreenCanvasSupported = false) { const drawWidth = this.drawWidth; const drawHeight = this.drawHeight; const imgData = { width: drawWidth, height: drawHeight, interpolate: this.interpolate, kind: 0, data: null }; const numComps = this.numComps; const originalWidth = this.width; const originalHeight = this.height; const bpc = this.bpc; const rowBytes = originalWidth * numComps * bpc + 7 >> 3; const mustBeResized = isOffscreenCanvasSupported && ImageResizer.needsToBeResized(drawWidth, drawHeight); if (!forceRGBA) { let kind; if (this.colorSpace.name === "DeviceGray" && bpc === 1) { kind = ImageKind.GRAYSCALE_1BPP; } else if (this.colorSpace.name === "DeviceRGB" && bpc === 8 && !this.needsDecode) { kind = ImageKind.RGB_24BPP; } if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) { const data = this.getImageBytes(originalHeight * rowBytes, {}); if (isOffscreenCanvasSupported) { if (mustBeResized) { return ImageResizer.createImage({ data, kind, width: drawWidth, height: drawHeight, interpolate: this.interpolate }, this.needsDecode); } return this.createBitmap(kind, originalWidth, originalHeight, data); } imgData.kind = kind; imgData.data = data; if (this.needsDecode) { assert(kind === ImageKind.GRAYSCALE_1BPP, "PDFImage.createImageData: The image must be grayscale."); const buffer = imgData.data; for (let i = 0, ii = buffer.length; i < ii; i++) { buffer[i] ^= 0xff; } } return imgData; } if (this.image instanceof JpegStream && !this.smask && !this.mask && !this.needsDecode) { let imageLength = originalHeight * rowBytes; if (isOffscreenCanvasSupported && !mustBeResized) { let isHandled = false; switch (this.colorSpace.name) { case "DeviceGray": imageLength *= 4; isHandled = true; break; case "DeviceRGB": imageLength = imageLength / 3 * 4; isHandled = true; break; case "DeviceCMYK": isHandled = true; break; } if (isHandled) { const rgba = this.getImageBytes(imageLength, { drawWidth, drawHeight, forceRGBA: true }); return this.createBitmap(ImageKind.RGBA_32BPP, drawWidth, drawHeight, rgba); } } else { switch (this.colorSpace.name) { case "DeviceGray": imageLength *= 3; case "DeviceRGB": case "DeviceCMYK": imgData.kind = ImageKind.RGB_24BPP; imgData.data = this.getImageBytes(imageLength, { drawWidth, drawHeight, forceRGB: true }); if (mustBeResized) { return ImageResizer.createImage(imgData); } return imgData; } } } } const imgArray = this.getImageBytes(originalHeight * rowBytes, { internal: true }); const actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight; const comps = this.getComponents(imgArray); let alpha01, maybeUndoPreblend; let canvas, ctx, canvasImgData, data; if (isOffscreenCanvasSupported && !mustBeResized) { canvas = new OffscreenCanvas(drawWidth, drawHeight); ctx = canvas.getContext("2d"); canvasImgData = ctx.createImageData(drawWidth, drawHeight); data = canvasImgData.data; } imgData.kind = ImageKind.RGBA_32BPP; if (!forceRGBA && !this.smask && !this.mask) { if (!isOffscreenCanvasSupported || mustBeResized) { imgData.kind = ImageKind.RGB_24BPP; data = new Uint8ClampedArray(drawWidth * drawHeight * 3); alpha01 = 0; } else { const arr = new Uint32Array(data.buffer); arr.fill(FeatureTest.isLittleEndian ? 0xff000000 : 0x000000ff); alpha01 = 1; } maybeUndoPreblend = false; } else { if (!isOffscreenCanvasSupported || mustBeResized) { data = new Uint8ClampedArray(drawWidth * drawHeight * 4); } alpha01 = 1; maybeUndoPreblend = true; this.fillOpacity(data, drawWidth, drawHeight, actualHeight, comps); } if (this.needsDecode) { this.decodeBuffer(comps); } this.colorSpace.fillRgb(data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01); if (maybeUndoPreblend) { this.undoPreblend(data, drawWidth, actualHeight); } if (isOffscreenCanvasSupported && !mustBeResized) { ctx.putImageData(canvasImgData, 0, 0); const bitmap = canvas.transferToImageBitmap(); return { data: null, width: drawWidth, height: drawHeight, bitmap, interpolate: this.interpolate }; } imgData.data = data; if (mustBeResized) { return ImageResizer.createImage(imgData); } return imgData; } fillGrayBuffer(buffer) { const numComps = this.numComps; if (numComps !== 1) { throw new FormatError(`Reading gray scale from a color image: ${numComps}`); } const width = this.width; const height = this.height; const bpc = this.bpc; const rowBytes = width * numComps * bpc + 7 >> 3; const imgArray = this.getImageBytes(height * rowBytes, { internal: true }); const comps = this.getComponents(imgArray); let i, length; if (bpc === 1) { length = width * height; if (this.needsDecode) { for (i = 0; i < length; ++i) { buffer[i] = comps[i] - 1 & 255; } } else { for (i = 0; i < length; ++i) { buffer[i] = -comps[i] & 255; } } return; } if (this.needsDecode) { this.decodeBuffer(comps); } length = width * height; const scale = 255 / ((1 << bpc) - 1); for (i = 0; i < length; ++i) { buffer[i] = scale * comps[i]; } } createBitmap(kind, width, height, src) { const canvas = new OffscreenCanvas(width, height); const ctx = canvas.getContext("2d"); let imgData; if (kind === ImageKind.RGBA_32BPP) { imgData = new ImageData(src, width, height); } else { imgData = ctx.createImageData(width, height); convertToRGBA({ kind, src, dest: new Uint32Array(imgData.data.buffer), width, height, inverseDecode: this.needsDecode }); } ctx.putImageData(imgData, 0, 0); const bitmap = canvas.transferToImageBitmap(); return { data: null, width, height, bitmap, interpolate: this.interpolate }; } getImageBytes(length, { drawWidth, drawHeight, forceRGBA = false, forceRGB = false, internal = false }) { this.image.reset(); this.image.drawWidth = drawWidth || this.width; this.image.drawHeight = drawHeight || this.height; this.image.forceRGBA = !!forceRGBA; this.image.forceRGB = !!forceRGB; const imageBytes = this.image.getBytes(length, this.ignoreColorSpace); if (internal || this.image instanceof DecodeStream) { return imageBytes; } assert(imageBytes instanceof Uint8Array, 'PDFImage.getImageBytes: Unsupported "imageBytes" type.'); return new Uint8Array(imageBytes); } } ;// CONCATENATED MODULE: ./src/core/evaluator.js const DefaultPartialEvaluatorOptions = Object.freeze({ maxImageSize: -1, disableFontFace: false, ignoreErrors: false, isEvalSupported: true, isOffscreenCanvasSupported: false, canvasMaxAreaInBytes: -1, fontExtraProperties: false, useSystemFonts: true, cMapUrl: null, standardFontDataUrl: null }); const PatternType = { TILING: 1, SHADING: 2 }; const TEXT_CHUNK_BATCH_SIZE = 10; const deferred = Promise.resolve(); function normalizeBlendMode(value, parsingArray = false) { if (Array.isArray(value)) { for (const val of value) { const maybeBM = normalizeBlendMode(val, true); if (maybeBM) { return maybeBM; } } warn(`Unsupported blend mode Array: ${value}`); return "source-over"; } if (!(value instanceof Name)) { if (parsingArray) { return null; } return "source-over"; } switch (value.name) { case "Normal": case "Compatible": return "source-over"; case "Multiply": return "multiply"; case "Screen": return "screen"; case "Overlay": return "overlay"; case "Darken": return "darken"; case "Lighten": return "lighten"; case "ColorDodge": return "color-dodge"; case "ColorBurn": return "color-burn"; case "HardLight": return "hard-light"; case "SoftLight": return "soft-light"; case "Difference": return "difference"; case "Exclusion": return "exclusion"; case "Hue": return "hue"; case "Saturation": return "saturation"; case "Color": return "color"; case "Luminosity": return "luminosity"; } if (parsingArray) { return null; } warn(`Unsupported blend mode: ${value.name}`); return "source-over"; } function incrementCachedImageMaskCount(data) { if (data.fn === OPS.paintImageMaskXObject && data.args[0]?.count > 0) { data.args[0].count++; } } class TimeSlotManager { static TIME_SLOT_DURATION_MS = 20; static CHECK_TIME_EVERY = 100; constructor() { this.reset(); } check() { if (++this.checked < TimeSlotManager.CHECK_TIME_EVERY) { return false; } this.checked = 0; return this.endTime <= Date.now(); } reset() { this.endTime = Date.now() + TimeSlotManager.TIME_SLOT_DURATION_MS; this.checked = 0; } } class PartialEvaluator { constructor({ xref, handler, pageIndex, idFactory, fontCache, builtInCMapCache, standardFontDataCache, globalImageCache, systemFontCache, options = null }) { this.xref = xref; this.handler = handler; this.pageIndex = pageIndex; this.idFactory = idFactory; this.fontCache = fontCache; this.builtInCMapCache = builtInCMapCache; this.standardFontDataCache = standardFontDataCache; this.globalImageCache = globalImageCache; this.systemFontCache = systemFontCache; this.options = options || DefaultPartialEvaluatorOptions; this.type3FontRefs = null; this._regionalImageCache = new RegionalImageCache(); this._fetchBuiltInCMapBound = this.fetchBuiltInCMap.bind(this); ImageResizer.setMaxArea(this.options.canvasMaxAreaInBytes); } get _pdfFunctionFactory() { const pdfFunctionFactory = new PDFFunctionFactory({ xref: this.xref, isEvalSupported: this.options.isEvalSupported }); return shadow(this, "_pdfFunctionFactory", pdfFunctionFactory); } get parsingType3Font() { return !!this.type3FontRefs; } clone(newOptions = null) { const newEvaluator = Object.create(this); newEvaluator.options = Object.assign(Object.create(null), this.options, newOptions); return newEvaluator; } hasBlendModes(resources, nonBlendModesSet) { if (!(resources instanceof Dict)) { return false; } if (resources.objId && nonBlendModesSet.has(resources.objId)) { return false; } const processed = new RefSet(nonBlendModesSet); if (resources.objId) { processed.put(resources.objId); } const nodes = [resources], xref = this.xref; while (nodes.length) { const node = nodes.shift(); const graphicStates = node.get("ExtGState"); if (graphicStates instanceof Dict) { for (let graphicState of graphicStates.getRawValues()) { if (graphicState instanceof Ref) { if (processed.has(graphicState)) { continue; } try { graphicState = xref.fetch(graphicState); } catch (ex) { processed.put(graphicState); info(`hasBlendModes - ignoring ExtGState: "${ex}".`); continue; } } if (!(graphicState instanceof Dict)) { continue; } if (graphicState.objId) { processed.put(graphicState.objId); } const bm = graphicState.get("BM"); if (bm instanceof Name) { if (bm.name !== "Normal") { return true; } continue; } if (bm !== undefined && Array.isArray(bm)) { for (const element of bm) { if (element instanceof Name && element.name !== "Normal") { return true; } } } } } const xObjects = node.get("XObject"); if (!(xObjects instanceof Dict)) { continue; } for (let xObject of xObjects.getRawValues()) { if (xObject instanceof Ref) { if (processed.has(xObject)) { continue; } try { xObject = xref.fetch(xObject); } catch (ex) { processed.put(xObject); info(`hasBlendModes - ignoring XObject: "${ex}".`); continue; } } if (!(xObject instanceof BaseStream)) { continue; } if (xObject.dict.objId) { processed.put(xObject.dict.objId); } const xResources = xObject.dict.get("Resources"); if (!(xResources instanceof Dict)) { continue; } if (xResources.objId && processed.has(xResources.objId)) { continue; } nodes.push(xResources); if (xResources.objId) { processed.put(xResources.objId); } } } for (const ref of processed) { nonBlendModesSet.put(ref); } return false; } async fetchBuiltInCMap(name) { const cachedData = this.builtInCMapCache.get(name); if (cachedData) { return cachedData; } let data; if (this.options.cMapUrl !== null) { const url = `${this.options.cMapUrl}${name}.bcmap`; const response = await fetch(url); if (!response.ok) { throw new Error(`fetchBuiltInCMap: failed to fetch file "${url}" with "${response.statusText}".`); } data = { cMapData: new Uint8Array(await response.arrayBuffer()), compressionType: CMapCompressionType.BINARY }; } else { data = await this.handler.sendWithPromise("FetchBuiltInCMap", { name }); } if (data.compressionType !== CMapCompressionType.NONE) { this.builtInCMapCache.set(name, data); } return data; } async fetchStandardFontData(name) { const cachedData = this.standardFontDataCache.get(name); if (cachedData) { return new Stream(cachedData); } if (this.options.useSystemFonts && name !== "Symbol" && name !== "ZapfDingbats") { return null; } const standardFontNameToFileName = getFontNameToFileMap(), filename = standardFontNameToFileName[name]; let data; if (this.options.standardFontDataUrl !== null) { const url = `${this.options.standardFontDataUrl}${filename}`; const response = await fetch(url); if (!response.ok) { warn(`fetchStandardFontData: failed to fetch file "${url}" with "${response.statusText}".`); } else { data = new Uint8Array(await response.arrayBuffer()); } } else { try { data = await this.handler.sendWithPromise("FetchStandardFontData", { filename }); } catch (e) { warn(`fetchStandardFontData: failed to fetch file "${filename}" with "${e}".`); } } if (!data) { return null; } this.standardFontDataCache.set(name, data); return new Stream(data); } async buildFormXObject(resources, xobj, smask, operatorList, task, initialState, localColorSpaceCache) { const dict = xobj.dict; const matrix = lookupMatrix(dict.getArray("Matrix"), null); const bbox = lookupNormalRect(dict.getArray("BBox"), null); let optionalContent, groupOptions; if (dict.has("OC")) { optionalContent = await this.parseMarkedContentProps(dict.get("OC"), resources); } if (optionalContent !== undefined) { operatorList.addOp(OPS.beginMarkedContentProps, ["OC", optionalContent]); } const group = dict.get("Group"); if (group) { groupOptions = { matrix, bbox, smask, isolated: false, knockout: false }; const groupSubtype = group.get("S"); let colorSpace = null; if (isName(groupSubtype, "Transparency")) { groupOptions.isolated = group.get("I") || false; groupOptions.knockout = group.get("K") || false; if (group.has("CS")) { const cs = group.getRaw("CS"); const cachedColorSpace = ColorSpace.getCached(cs, this.xref, localColorSpaceCache); if (cachedColorSpace) { colorSpace = cachedColorSpace; } else { colorSpace = await this.parseColorSpace({ cs, resources, localColorSpaceCache }); } } } if (smask?.backdrop) { colorSpace ||= ColorSpace.singletons.rgb; smask.backdrop = colorSpace.getRgb(smask.backdrop, 0); } operatorList.addOp(OPS.beginGroup, [groupOptions]); } const args = group ? [matrix, null] : [matrix, bbox]; operatorList.addOp(OPS.paintFormXObjectBegin, args); await this.getOperatorList({ stream: xobj, task, resources: dict.get("Resources") || resources, operatorList, initialState }); operatorList.addOp(OPS.paintFormXObjectEnd, []); if (group) { operatorList.addOp(OPS.endGroup, [groupOptions]); } if (optionalContent !== undefined) { operatorList.addOp(OPS.endMarkedContent, []); } } _sendImgData(objId, imgData, cacheGlobally = false) { const transfers = imgData ? [imgData.bitmap || imgData.data.buffer] : null; if (this.parsingType3Font || cacheGlobally) { return this.handler.send("commonobj", [objId, "Image", imgData], transfers); } return this.handler.send("obj", [objId, this.pageIndex, "Image", imgData], transfers); } async buildPaintImageXObject({ resources, image, isInline = false, operatorList, cacheKey, localImageCache, localColorSpaceCache }) { const dict = image.dict; const imageRef = dict.objId; const w = dict.get("W", "Width"); const h = dict.get("H", "Height"); if (!(w && typeof w === "number") || !(h && typeof h === "number")) { warn("Image dimensions are missing, or not numbers."); return; } const maxImageSize = this.options.maxImageSize; if (maxImageSize !== -1 && w * h > maxImageSize) { const msg = "Image exceeded maximum allowed size and was removed."; if (this.options.ignoreErrors) { warn(msg); return; } throw new Error(msg); } let optionalContent; if (dict.has("OC")) { optionalContent = await this.parseMarkedContentProps(dict.get("OC"), resources); } const imageMask = dict.get("IM", "ImageMask") || false; let imgData, args; if (imageMask) { const interpolate = dict.get("I", "Interpolate"); const bitStrideLength = w + 7 >> 3; const imgArray = image.getBytes(bitStrideLength * h); const decode = dict.getArray("D", "Decode"); if (this.parsingType3Font) { imgData = PDFImage.createRawMask({ imgArray, width: w, height: h, imageIsFromDecodeStream: image instanceof DecodeStream, inverseDecode: decode?.[0] > 0, interpolate }); imgData.cached = !!cacheKey; args = [imgData]; operatorList.addImageOps(OPS.paintImageMaskXObject, args, optionalContent); if (cacheKey) { const cacheData = { fn: OPS.paintImageMaskXObject, args, optionalContent }; localImageCache.set(cacheKey, imageRef, cacheData); if (imageRef) { this._regionalImageCache.set(null, imageRef, cacheData); } } return; } imgData = await PDFImage.createMask({ imgArray, width: w, height: h, imageIsFromDecodeStream: image instanceof DecodeStream, inverseDecode: decode?.[0] > 0, interpolate, isOffscreenCanvasSupported: this.options.isOffscreenCanvasSupported }); if (imgData.isSingleOpaquePixel) { operatorList.addImageOps(OPS.paintSolidColorImageMask, [], optionalContent); if (cacheKey) { const cacheData = { fn: OPS.paintSolidColorImageMask, args: [], optionalContent }; localImageCache.set(cacheKey, imageRef, cacheData); if (imageRef) { this._regionalImageCache.set(null, imageRef, cacheData); } } return; } const objId = `mask_${this.idFactory.createObjId()}`; operatorList.addDependency(objId); imgData.dataLen = imgData.bitmap ? imgData.width * imgData.height * 4 : imgData.data.length; this._sendImgData(objId, imgData); args = [{ data: objId, width: imgData.width, height: imgData.height, interpolate: imgData.interpolate, count: 1 }]; operatorList.addImageOps(OPS.paintImageMaskXObject, args, optionalContent); if (cacheKey) { const cacheData = { fn: OPS.paintImageMaskXObject, args, optionalContent }; localImageCache.set(cacheKey, imageRef, cacheData); if (imageRef) { this._regionalImageCache.set(null, imageRef, cacheData); } } return; } const SMALL_IMAGE_DIMENSIONS = 200; if (isInline && w + h < SMALL_IMAGE_DIMENSIONS && !dict.has("SMask") && !dict.has("Mask")) { try { const imageObj = new PDFImage({ xref: this.xref, res: resources, image, isInline, pdfFunctionFactory: this._pdfFunctionFactory, localColorSpaceCache }); imgData = await imageObj.createImageData(true, false); operatorList.isOffscreenCanvasSupported = this.options.isOffscreenCanvasSupported; operatorList.addImageOps(OPS.paintInlineImageXObject, [imgData], optionalContent); } catch (reason) { const msg = `Unable to decode inline image: "${reason}".`; if (!this.options.ignoreErrors) { throw new Error(msg); } warn(msg); } return; } let objId = `img_${this.idFactory.createObjId()}`, cacheGlobally = false; if (this.parsingType3Font) { objId = `${this.idFactory.getDocId()}_type3_${objId}`; } else if (cacheKey && imageRef) { cacheGlobally = this.globalImageCache.shouldCache(imageRef, this.pageIndex); if (cacheGlobally) { assert(!isInline, "Cannot cache an inline image globally."); objId = `${this.idFactory.getDocId()}_${objId}`; } } operatorList.addDependency(objId); args = [objId, w, h]; operatorList.addImageOps(OPS.paintImageXObject, args, optionalContent); if (cacheGlobally) { if (this.globalImageCache.hasDecodeFailed(imageRef)) { this.globalImageCache.setData(imageRef, { objId, fn: OPS.paintImageXObject, args, optionalContent, byteSize: 0 }); this._sendImgData(objId, null, cacheGlobally); return; } if (w * h > 250000 || dict.has("SMask") || dict.has("Mask")) { const localLength = await this.handler.sendWithPromise("commonobj", [objId, "CopyLocalImage", { imageRef }]); if (localLength) { this.globalImageCache.setData(imageRef, { objId, fn: OPS.paintImageXObject, args, optionalContent, byteSize: 0 }); this.globalImageCache.addByteSize(imageRef, localLength); return; } } } PDFImage.buildImage({ xref: this.xref, res: resources, image, isInline, pdfFunctionFactory: this._pdfFunctionFactory, localColorSpaceCache }).then(async imageObj => { imgData = await imageObj.createImageData(false, this.options.isOffscreenCanvasSupported); imgData.dataLen = imgData.bitmap ? imgData.width * imgData.height * 4 : imgData.data.length; imgData.ref = imageRef; if (cacheGlobally) { this.globalImageCache.addByteSize(imageRef, imgData.dataLen); } return this._sendImgData(objId, imgData, cacheGlobally); }).catch(reason => { warn(`Unable to decode image "${objId}": "${reason}".`); if (imageRef) { this.globalImageCache.addDecodeFailed(imageRef); } return this._sendImgData(objId, null, cacheGlobally); }); if (cacheKey) { const cacheData = { fn: OPS.paintImageXObject, args, optionalContent }; localImageCache.set(cacheKey, imageRef, cacheData); if (imageRef) { this._regionalImageCache.set(null, imageRef, cacheData); if (cacheGlobally) { this.globalImageCache.setData(imageRef, { objId, fn: OPS.paintImageXObject, args, optionalContent, byteSize: 0 }); } } } } handleSMask(smask, resources, operatorList, task, stateManager, localColorSpaceCache) { const smaskContent = smask.get("G"); const smaskOptions = { subtype: smask.get("S").name, backdrop: smask.get("BC") }; const transferObj = smask.get("TR"); if (isPDFFunction(transferObj)) { const transferFn = this._pdfFunctionFactory.create(transferObj); const transferMap = new Uint8Array(256); const tmp = new Float32Array(1); for (let i = 0; i < 256; i++) { tmp[0] = i / 255; transferFn(tmp, 0, tmp, 0); transferMap[i] = tmp[0] * 255 | 0; } smaskOptions.transferMap = transferMap; } return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone(), localColorSpaceCache); } handleTransferFunction(tr) { let transferArray; if (Array.isArray(tr)) { transferArray = tr; } else if (isPDFFunction(tr)) { transferArray = [tr]; } else { return null; } const transferMaps = []; let numFns = 0, numEffectfulFns = 0; for (const entry of transferArray) { const transferObj = this.xref.fetchIfRef(entry); numFns++; if (isName(transferObj, "Identity")) { transferMaps.push(null); continue; } else if (!isPDFFunction(transferObj)) { return null; } const transferFn = this._pdfFunctionFactory.create(transferObj); const transferMap = new Uint8Array(256), tmp = new Float32Array(1); for (let j = 0; j < 256; j++) { tmp[0] = j / 255; transferFn(tmp, 0, tmp, 0); transferMap[j] = tmp[0] * 255 | 0; } transferMaps.push(transferMap); numEffectfulFns++; } if (!(numFns === 1 || numFns === 4)) { return null; } if (numEffectfulFns === 0) { return null; } return transferMaps; } handleTilingType(fn, color, resources, pattern, patternDict, operatorList, task, localTilingPatternCache) { const tilingOpList = new OperatorList(); const patternResources = Dict.merge({ xref: this.xref, dictArray: [patternDict.get("Resources"), resources] }); return this.getOperatorList({ stream: pattern, task, resources: patternResources, operatorList: tilingOpList }).then(function () { const operatorListIR = tilingOpList.getIR(); const tilingPatternIR = getTilingPatternIR(operatorListIR, patternDict, color); operatorList.addDependencies(tilingOpList.dependencies); operatorList.addOp(fn, tilingPatternIR); if (patternDict.objId) { localTilingPatternCache.set(null, patternDict.objId, { operatorListIR, dict: patternDict }); } }).catch(reason => { if (reason instanceof AbortException) { return; } if (this.options.ignoreErrors) { warn(`handleTilingType - ignoring pattern: "${reason}".`); return; } throw reason; }); } async handleSetFont(resources, fontArgs, fontRef, operatorList, task, state, fallbackFontDict = null, cssFontInfo = null) { const fontName = fontArgs?.[0] instanceof Name ? fontArgs[0].name : null; let translated = await this.loadFont(fontName, fontRef, resources, fallbackFontDict, cssFontInfo); if (translated.font.isType3Font) { try { await translated.loadType3Data(this, resources, task); operatorList.addDependencies(translated.type3Dependencies); } catch (reason) { translated = new TranslatedFont({ loadedName: "g_font_error", font: new ErrorFont(`Type3 font load error: ${reason}`), dict: translated.font, evaluatorOptions: this.options }); } } state.font = translated.font; translated.send(this.handler); return translated.loadedName; } handleText(chars, state) { const font = state.font; const glyphs = font.charsToGlyphs(chars); if (font.data) { const isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG); if (isAddToPathSet || state.fillColorSpace.name === "Pattern" || font.disableFontFace || this.options.disableFontFace) { PartialEvaluator.buildFontPaths(font, glyphs, this.handler, this.options); } } return glyphs; } ensureStateFont(state) { if (state.font) { return; } const reason = new FormatError("Missing setFont (Tf) operator before text rendering operator."); if (this.options.ignoreErrors) { warn(`ensureStateFont: "${reason}".`); return; } throw reason; } async setGState({ resources, gState, operatorList, cacheKey, task, stateManager, localGStateCache, localColorSpaceCache }) { const gStateRef = gState.objId; let isSimpleGState = true; const gStateObj = []; let promise = Promise.resolve(); for (const key of gState.getKeys()) { const value = gState.get(key); switch (key) { case "Type": break; case "LW": case "LC": case "LJ": case "ML": case "D": case "RI": case "FL": case "CA": case "ca": gStateObj.push([key, value]); break; case "Font": isSimpleGState = false; promise = promise.then(() => this.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) { operatorList.addDependency(loadedName); gStateObj.push([key, [loadedName, value[1]]]); })); break; case "BM": gStateObj.push([key, normalizeBlendMode(value)]); break; case "SMask": if (isName(value, "None")) { gStateObj.push([key, false]); break; } if (value instanceof Dict) { isSimpleGState = false; promise = promise.then(() => this.handleSMask(value, resources, operatorList, task, stateManager, localColorSpaceCache)); gStateObj.push([key, true]); } else { warn("Unsupported SMask type"); } break; case "TR": const transferMaps = this.handleTransferFunction(value); gStateObj.push([key, transferMaps]); break; case "OP": case "op": case "OPM": case "BG": case "BG2": case "UCR": case "UCR2": case "TR2": case "HT": case "SM": case "SA": case "AIS": case "TK": info("graphic state operator " + key); break; default: info("Unknown graphic state operator " + key); break; } } await promise; if (gStateObj.length > 0) { operatorList.addOp(OPS.setGState, [gStateObj]); } if (isSimpleGState) { localGStateCache.set(cacheKey, gStateRef, gStateObj); } } loadFont(fontName, font, resources, fallbackFontDict = null, cssFontInfo = null) { const errorFont = async () => { return new TranslatedFont({ loadedName: "g_font_error", font: new ErrorFont(`Font "${fontName}" is not available.`), dict: font, evaluatorOptions: this.options }); }; let fontRef; if (font) { if (font instanceof Ref) { fontRef = font; } } else { const fontRes = resources.get("Font"); if (fontRes) { fontRef = fontRes.getRaw(fontName); } } if (fontRef) { if (this.type3FontRefs?.has(fontRef)) { return errorFont(); } if (this.fontCache.has(fontRef)) { return this.fontCache.get(fontRef); } try { font = this.xref.fetchIfRef(fontRef); } catch (ex) { warn(`loadFont - lookup failed: "${ex}".`); } } if (!(font instanceof Dict)) { if (!this.options.ignoreErrors && !this.parsingType3Font) { warn(`Font "${fontName}" is not available.`); return errorFont(); } warn(`Font "${fontName}" is not available -- attempting to fallback to a default font.`); font = fallbackFontDict || PartialEvaluator.fallbackFontDict; } if (font.cacheKey && this.fontCache.has(font.cacheKey)) { return this.fontCache.get(font.cacheKey); } const { promise, resolve } = Promise.withResolvers(); let preEvaluatedFont; try { preEvaluatedFont = this.preEvaluateFont(font); preEvaluatedFont.cssFontInfo = cssFontInfo; } catch (reason) { warn(`loadFont - preEvaluateFont failed: "${reason}".`); return errorFont(); } const { descriptor, hash } = preEvaluatedFont; const fontRefIsRef = fontRef instanceof Ref; let fontID; if (hash && descriptor instanceof Dict) { const fontAliases = descriptor.fontAliases ||= Object.create(null); if (fontAliases[hash]) { const aliasFontRef = fontAliases[hash].aliasRef; if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) { this.fontCache.putAlias(fontRef, aliasFontRef); return this.fontCache.get(fontRef); } } else { fontAliases[hash] = { fontID: this.idFactory.createFontId() }; } if (fontRefIsRef) { fontAliases[hash].aliasRef = fontRef; } fontID = fontAliases[hash].fontID; } else { fontID = this.idFactory.createFontId(); } assert(fontID?.startsWith("f"), 'The "fontID" must be (correctly) defined.'); if (fontRefIsRef) { this.fontCache.put(fontRef, promise); } else { font.cacheKey = `cacheKey_${fontID}`; this.fontCache.put(font.cacheKey, promise); } font.loadedName = `${this.idFactory.getDocId()}_${fontID}`; this.translateFont(preEvaluatedFont).then(translatedFont => { resolve(new TranslatedFont({ loadedName: font.loadedName, font: translatedFont, dict: font, evaluatorOptions: this.options })); }).catch(reason => { warn(`loadFont - translateFont failed: "${reason}".`); resolve(new TranslatedFont({ loadedName: font.loadedName, font: new ErrorFont(reason instanceof Error ? reason.message : reason), dict: font, evaluatorOptions: this.options })); }); return promise; } buildPath(operatorList, fn, args, parsingText = false) { const lastIndex = operatorList.length - 1; if (!args) { args = []; } if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) { if (parsingText) { warn(`Encountered path operator "${fn}" inside of a text object.`); operatorList.addOp(OPS.save, null); } let minMax; switch (fn) { case OPS.rectangle: const x = args[0] + args[2]; const y = args[1] + args[3]; minMax = [Math.min(args[0], x), Math.min(args[1], y), Math.max(args[0], x), Math.max(args[1], y)]; break; case OPS.moveTo: case OPS.lineTo: minMax = [args[0], args[1], args[0], args[1]]; break; default: minMax = [Infinity, Infinity, -Infinity, -Infinity]; break; } operatorList.addOp(OPS.constructPath, [[fn], args, minMax]); if (parsingText) { operatorList.addOp(OPS.restore, null); } } else { const opArgs = operatorList.argsArray[lastIndex]; opArgs[0].push(fn); opArgs[1].push(...args); const minMax = opArgs[2]; switch (fn) { case OPS.rectangle: const x = args[0] + args[2]; const y = args[1] + args[3]; minMax[0] = Math.min(minMax[0], args[0], x); minMax[1] = Math.min(minMax[1], args[1], y); minMax[2] = Math.max(minMax[2], args[0], x); minMax[3] = Math.max(minMax[3], args[1], y); break; case OPS.moveTo: case OPS.lineTo: minMax[0] = Math.min(minMax[0], args[0]); minMax[1] = Math.min(minMax[1], args[1]); minMax[2] = Math.max(minMax[2], args[0]); minMax[3] = Math.max(minMax[3], args[1]); break; } } } parseColorSpace({ cs, resources, localColorSpaceCache }) { return ColorSpace.parseAsync({ cs, xref: this.xref, resources, pdfFunctionFactory: this._pdfFunctionFactory, localColorSpaceCache }).catch(reason => { if (reason instanceof AbortException) { return null; } if (this.options.ignoreErrors) { warn(`parseColorSpace - ignoring ColorSpace: "${reason}".`); return null; } throw reason; }); } parseShading({ shading, resources, localColorSpaceCache, localShadingPatternCache }) { let id = localShadingPatternCache.get(shading); if (id) { return id; } let patternIR; try { const shadingFill = Pattern.parseShading(shading, this.xref, resources, this._pdfFunctionFactory, localColorSpaceCache); patternIR = shadingFill.getIR(); } catch (reason) { if (reason instanceof AbortException) { return null; } if (this.options.ignoreErrors) { warn(`parseShading - ignoring shading: "${reason}".`); localShadingPatternCache.set(shading, null); return null; } throw reason; } id = `pattern_${this.idFactory.createObjId()}`; if (this.parsingType3Font) { id = `${this.idFactory.getDocId()}_type3_${id}`; } localShadingPatternCache.set(shading, id); if (this.parsingType3Font) { this.handler.send("commonobj", [id, "Pattern", patternIR]); } else { this.handler.send("obj", [id, this.pageIndex, "Pattern", patternIR]); } return id; } handleColorN(operatorList, fn, args, cs, patterns, resources, task, localColorSpaceCache, localTilingPatternCache, localShadingPatternCache) { const patternName = args.pop(); if (patternName instanceof Name) { const rawPattern = patterns.getRaw(patternName.name); const localTilingPattern = rawPattern instanceof Ref && localTilingPatternCache.getByRef(rawPattern); if (localTilingPattern) { try { const color = cs.base ? cs.base.getRgb(args, 0) : null; const tilingPatternIR = getTilingPatternIR(localTilingPattern.operatorListIR, localTilingPattern.dict, color); operatorList.addOp(fn, tilingPatternIR); return undefined; } catch {} } const pattern = this.xref.fetchIfRef(rawPattern); if (pattern) { const dict = pattern instanceof BaseStream ? pattern.dict : pattern; const typeNum = dict.get("PatternType"); if (typeNum === PatternType.TILING) { const color = cs.base ? cs.base.getRgb(args, 0) : null; return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task, localTilingPatternCache); } else if (typeNum === PatternType.SHADING) { const shading = dict.get("Shading"); const objId = this.parseShading({ shading, resources, localColorSpaceCache, localShadingPatternCache }); if (objId) { const matrix = lookupMatrix(dict.getArray("Matrix"), null); operatorList.addOp(fn, ["Shading", objId, matrix]); } return undefined; } throw new FormatError(`Unknown PatternType: ${typeNum}`); } } throw new FormatError(`Unknown PatternName: ${patternName}`); } _parseVisibilityExpression(array, nestingCounter, currentResult) { const MAX_NESTING = 10; if (++nestingCounter > MAX_NESTING) { warn("Visibility expression is too deeply nested"); return; } const length = array.length; const operator = this.xref.fetchIfRef(array[0]); if (length < 2 || !(operator instanceof Name)) { warn("Invalid visibility expression"); return; } switch (operator.name) { case "And": case "Or": case "Not": currentResult.push(operator.name); break; default: warn(`Invalid operator ${operator.name} in visibility expression`); return; } for (let i = 1; i < length; i++) { const raw = array[i]; const object = this.xref.fetchIfRef(raw); if (Array.isArray(object)) { const nestedResult = []; currentResult.push(nestedResult); this._parseVisibilityExpression(object, nestingCounter, nestedResult); } else if (raw instanceof Ref) { currentResult.push(raw.toString()); } } } async parseMarkedContentProps(contentProperties, resources) { let optionalContent; if (contentProperties instanceof Name) { const properties = resources.get("Properties"); optionalContent = properties.get(contentProperties.name); } else if (contentProperties instanceof Dict) { optionalContent = contentProperties; } else { throw new FormatError("Optional content properties malformed."); } const optionalContentType = optionalContent.get("Type")?.name; if (optionalContentType === "OCG") { return { type: optionalContentType, id: optionalContent.objId }; } else if (optionalContentType === "OCMD") { const expression = optionalContent.get("VE"); if (Array.isArray(expression)) { const result = []; this._parseVisibilityExpression(expression, 0, result); if (result.length > 0) { return { type: "OCMD", expression: result }; } } const optionalContentGroups = optionalContent.get("OCGs"); if (Array.isArray(optionalContentGroups) || optionalContentGroups instanceof Dict) { const groupIds = []; if (Array.isArray(optionalContentGroups)) { for (const ocg of optionalContentGroups) { groupIds.push(ocg.toString()); } } else { groupIds.push(optionalContentGroups.objId); } return { type: optionalContentType, ids: groupIds, policy: optionalContent.get("P") instanceof Name ? optionalContent.get("P").name : null, expression: null }; } else if (optionalContentGroups instanceof Ref) { return { type: optionalContentType, id: optionalContentGroups.toString() }; } } return null; } getOperatorList({ stream, task, resources, operatorList, initialState = null, fallbackFontDict = null }) { resources ||= Dict.empty; initialState ||= new EvalState(); if (!operatorList) { throw new Error('getOperatorList: missing "operatorList" parameter'); } const self = this; const xref = this.xref; let parsingText = false; const localImageCache = new LocalImageCache(); const localColorSpaceCache = new LocalColorSpaceCache(); const localGStateCache = new LocalGStateCache(); const localTilingPatternCache = new LocalTilingPatternCache(); const localShadingPatternCache = new Map(); const xobjs = resources.get("XObject") || Dict.empty; const patterns = resources.get("Pattern") || Dict.empty; const stateManager = new StateManager(initialState); const preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager); const timeSlotManager = new TimeSlotManager(); function closePendingRestoreOPS(argument) { for (let i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) { operatorList.addOp(OPS.restore, []); } } return new Promise(function promiseBody(resolve, reject) { const next = function (promise) { Promise.all([promise, operatorList.ready]).then(function () { try { promiseBody(resolve, reject); } catch (ex) { reject(ex); } }, reject); }; task.ensureNotTerminated(); timeSlotManager.reset(); const operation = {}; let stop, i, ii, cs, name, isValidName; while (!(stop = timeSlotManager.check())) { operation.args = null; if (!preprocessor.read(operation)) { break; } let args = operation.args; let fn = operation.fn; switch (fn | 0) { case OPS.paintXObject: isValidName = args[0] instanceof Name; name = args[0].name; if (isValidName) { const localImage = localImageCache.getByName(name); if (localImage) { operatorList.addImageOps(localImage.fn, localImage.args, localImage.optionalContent); incrementCachedImageMaskCount(localImage); args = null; continue; } } next(new Promise(function (resolveXObject, rejectXObject) { if (!isValidName) { throw new FormatError("XObject must be referred to by name."); } let xobj = xobjs.getRaw(name); if (xobj instanceof Ref) { const localImage = localImageCache.getByRef(xobj) || self._regionalImageCache.getByRef(xobj); if (localImage) { operatorList.addImageOps(localImage.fn, localImage.args, localImage.optionalContent); incrementCachedImageMaskCount(localImage); resolveXObject(); return; } const globalImage = self.globalImageCache.getData(xobj, self.pageIndex); if (globalImage) { operatorList.addDependency(globalImage.objId); operatorList.addImageOps(globalImage.fn, globalImage.args, globalImage.optionalContent); resolveXObject(); return; } xobj = xref.fetch(xobj); } if (!(xobj instanceof BaseStream)) { throw new FormatError("XObject should be a stream"); } const type = xobj.dict.get("Subtype"); if (!(type instanceof Name)) { throw new FormatError("XObject should have a Name subtype"); } if (type.name === "Form") { stateManager.save(); self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone(), localColorSpaceCache).then(function () { stateManager.restore(); resolveXObject(); }, rejectXObject); return; } else if (type.name === "Image") { self.buildPaintImageXObject({ resources, image: xobj, operatorList, cacheKey: name, localImageCache, localColorSpaceCache }).then(resolveXObject, rejectXObject); return; } else if (type.name === "PS") { info("Ignored XObject subtype PS"); } else { throw new FormatError(`Unhandled XObject subtype ${type.name}`); } resolveXObject(); }).catch(function (reason) { if (reason instanceof AbortException) { return; } if (self.options.ignoreErrors) { warn(`getOperatorList - ignoring XObject: "${reason}".`); return; } throw reason; })); return; case OPS.setFont: var fontSize = args[1]; next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state, fallbackFontDict).then(function (loadedName) { operatorList.addDependency(loadedName); operatorList.addOp(OPS.setFont, [loadedName, fontSize]); })); return; case OPS.beginText: parsingText = true; break; case OPS.endText: parsingText = false; break; case OPS.endInlineImage: var cacheKey = args[0].cacheKey; if (cacheKey) { const localImage = localImageCache.getByName(cacheKey); if (localImage) { operatorList.addImageOps(localImage.fn, localImage.args, localImage.optionalContent); incrementCachedImageMaskCount(localImage); args = null; continue; } } next(self.buildPaintImageXObject({ resources, image: args[0], isInline: true, operatorList, cacheKey, localImageCache, localColorSpaceCache })); return; case OPS.showText: if (!stateManager.state.font) { self.ensureStateFont(stateManager.state); continue; } args[0] = self.handleText(args[0], stateManager.state); break; case OPS.showSpacedText: if (!stateManager.state.font) { self.ensureStateFont(stateManager.state); continue; } var combinedGlyphs = []; var state = stateManager.state; for (const arrItem of args[0]) { if (typeof arrItem === "string") { combinedGlyphs.push(...self.handleText(arrItem, state)); } else if (typeof arrItem === "number") { combinedGlyphs.push(arrItem); } } args[0] = combinedGlyphs; fn = OPS.showText; break; case OPS.nextLineShowText: if (!stateManager.state.font) { self.ensureStateFont(stateManager.state); continue; } operatorList.addOp(OPS.nextLine); args[0] = self.handleText(args[0], stateManager.state); fn = OPS.showText; break; case OPS.nextLineSetSpacingShowText: if (!stateManager.state.font) { self.ensureStateFont(stateManager.state); continue; } operatorList.addOp(OPS.nextLine); operatorList.addOp(OPS.setWordSpacing, [args.shift()]); operatorList.addOp(OPS.setCharSpacing, [args.shift()]); args[0] = self.handleText(args[0], stateManager.state); fn = OPS.showText; break; case OPS.setTextRenderingMode: stateManager.state.textRenderingMode = args[0]; break; case OPS.setFillColorSpace: { const cachedColorSpace = ColorSpace.getCached(args[0], xref, localColorSpaceCache); if (cachedColorSpace) { stateManager.state.fillColorSpace = cachedColorSpace; continue; } next(self.parseColorSpace({ cs: args[0], resources, localColorSpaceCache }).then(function (colorSpace) { if (colorSpace) { stateManager.state.fillColorSpace = colorSpace; } })); return; } case OPS.setStrokeColorSpace: { const cachedColorSpace = ColorSpace.getCached(args[0], xref, localColorSpaceCache); if (cachedColorSpace) { stateManager.state.strokeColorSpace = cachedColorSpace; continue; } next(self.parseColorSpace({ cs: args[0], resources, localColorSpaceCache }).then(function (colorSpace) { if (colorSpace) { stateManager.state.strokeColorSpace = colorSpace; } })); return; } case OPS.setFillColor: cs = stateManager.state.fillColorSpace; args = cs.getRgb(args, 0); fn = OPS.setFillRGBColor; break; case OPS.setStrokeColor: cs = stateManager.state.strokeColorSpace; args = cs.getRgb(args, 0); fn = OPS.setStrokeRGBColor; break; case OPS.setFillGray: stateManager.state.fillColorSpace = ColorSpace.singletons.gray; args = ColorSpace.singletons.gray.getRgb(args, 0); fn = OPS.setFillRGBColor; break; case OPS.setStrokeGray: stateManager.state.strokeColorSpace = ColorSpace.singletons.gray; args = ColorSpace.singletons.gray.getRgb(args, 0); fn = OPS.setStrokeRGBColor; break; case OPS.setFillCMYKColor: stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk; args = ColorSpace.singletons.cmyk.getRgb(args, 0); fn = OPS.setFillRGBColor; break; case OPS.setStrokeCMYKColor: stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk; args = ColorSpace.singletons.cmyk.getRgb(args, 0); fn = OPS.setStrokeRGBColor; break; case OPS.setFillRGBColor: stateManager.state.fillColorSpace = ColorSpace.singletons.rgb; args = ColorSpace.singletons.rgb.getRgb(args, 0); break; case OPS.setStrokeRGBColor: stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb; args = ColorSpace.singletons.rgb.getRgb(args, 0); break; case OPS.setFillColorN: cs = stateManager.state.fillColorSpace; if (cs.name === "Pattern") { next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, localColorSpaceCache, localTilingPatternCache, localShadingPatternCache)); return; } args = cs.getRgb(args, 0); fn = OPS.setFillRGBColor; break; case OPS.setStrokeColorN: cs = stateManager.state.strokeColorSpace; if (cs.name === "Pattern") { next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, localColorSpaceCache, localTilingPatternCache, localShadingPatternCache)); return; } args = cs.getRgb(args, 0); fn = OPS.setStrokeRGBColor; break; case OPS.shadingFill: var shadingRes = resources.get("Shading"); if (!shadingRes) { throw new FormatError("No shading resource found"); } var shading = shadingRes.get(args[0].name); if (!shading) { throw new FormatError("No shading object found"); } const patternId = self.parseShading({ shading, resources, localColorSpaceCache, localShadingPatternCache }); if (!patternId) { continue; } args = [patternId]; fn = OPS.shadingFill; break; case OPS.setGState: isValidName = args[0] instanceof Name; name = args[0].name; if (isValidName) { const localGStateObj = localGStateCache.getByName(name); if (localGStateObj) { if (localGStateObj.length > 0) { operatorList.addOp(OPS.setGState, [localGStateObj]); } args = null; continue; } } next(new Promise(function (resolveGState, rejectGState) { if (!isValidName) { throw new FormatError("GState must be referred to by name."); } const extGState = resources.get("ExtGState"); if (!(extGState instanceof Dict)) { throw new FormatError("ExtGState should be a dictionary."); } const gState = extGState.get(name); if (!(gState instanceof Dict)) { throw new FormatError("GState should be a dictionary."); } self.setGState({ resources, gState, operatorList, cacheKey: name, task, stateManager, localGStateCache, localColorSpaceCache }).then(resolveGState, rejectGState); }).catch(function (reason) { if (reason instanceof AbortException) { return; } if (self.options.ignoreErrors) { warn(`getOperatorList - ignoring ExtGState: "${reason}".`); return; } throw reason; })); return; case OPS.moveTo: case OPS.lineTo: case OPS.curveTo: case OPS.curveTo2: case OPS.curveTo3: case OPS.closePath: case OPS.rectangle: self.buildPath(operatorList, fn, args, parsingText); continue; case OPS.markPoint: case OPS.markPointProps: case OPS.beginCompat: case OPS.endCompat: continue; case OPS.beginMarkedContentProps: if (!(args[0] instanceof Name)) { warn(`Expected name for beginMarkedContentProps arg0=${args[0]}`); operatorList.addOp(OPS.beginMarkedContentProps, ["OC", null]); continue; } if (args[0].name === "OC") { next(self.parseMarkedContentProps(args[1], resources).then(data => { operatorList.addOp(OPS.beginMarkedContentProps, ["OC", data]); }).catch(reason => { if (reason instanceof AbortException) { return; } if (self.options.ignoreErrors) { warn(`getOperatorList - ignoring beginMarkedContentProps: "${reason}".`); operatorList.addOp(OPS.beginMarkedContentProps, ["OC", null]); return; } throw reason; })); return; } args = [args[0].name, args[1] instanceof Dict ? args[1].get("MCID") : null]; break; case OPS.beginMarkedContent: case OPS.endMarkedContent: default: if (args !== null) { for (i = 0, ii = args.length; i < ii; i++) { if (args[i] instanceof Dict) { break; } } if (i < ii) { warn("getOperatorList - ignoring operator: " + fn); continue; } } } operatorList.addOp(fn, args); } if (stop) { next(deferred); return; } closePendingRestoreOPS(); resolve(); }).catch(reason => { if (reason instanceof AbortException) { return; } if (this.options.ignoreErrors) { warn(`getOperatorList - ignoring errors during "${task.name}" ` + `task: "${reason}".`); closePendingRestoreOPS(); return; } throw reason; }); } getTextContent({ stream, task, resources, stateManager = null, includeMarkedContent = false, sink, seenStyles = new Set(), viewBox, lang = null, markedContentData = null, disableNormalization = false, keepWhiteSpace = false }) { resources ||= Dict.empty; stateManager ||= new StateManager(new TextState()); if (includeMarkedContent) { markedContentData ||= { level: 0 }; } const textContent = { items: [], styles: Object.create(null), lang }; const textContentItem = { initialized: false, str: [], totalWidth: 0, totalHeight: 0, width: 0, height: 0, vertical: false, prevTransform: null, textAdvanceScale: 0, spaceInFlowMin: 0, spaceInFlowMax: 0, trackingSpaceMin: Infinity, negativeSpaceMax: -Infinity, notASpace: -Infinity, transform: null, fontName: null, hasEOL: false }; const twoLastChars = [" ", " "]; let twoLastCharsPos = 0; function saveLastChar(char) { const nextPos = (twoLastCharsPos + 1) % 2; const ret = twoLastChars[twoLastCharsPos] !== " " && twoLastChars[nextPos] === " "; twoLastChars[twoLastCharsPos] = char; twoLastCharsPos = nextPos; return !keepWhiteSpace && ret; } function shouldAddWhitepsace() { return !keepWhiteSpace && twoLastChars[twoLastCharsPos] !== " " && twoLastChars[(twoLastCharsPos + 1) % 2] === " "; } function resetLastChars() { twoLastChars[0] = twoLastChars[1] = " "; twoLastCharsPos = 0; } const TRACKING_SPACE_FACTOR = 0.102; const NOT_A_SPACE_FACTOR = 0.03; const NEGATIVE_SPACE_FACTOR = -0.2; const SPACE_IN_FLOW_MIN_FACTOR = 0.102; const SPACE_IN_FLOW_MAX_FACTOR = 0.6; const VERTICAL_SHIFT_RATIO = 0.25; const self = this; const xref = this.xref; const showSpacedTextBuffer = []; let xobjs = null; const emptyXObjectCache = new LocalImageCache(); const emptyGStateCache = new LocalGStateCache(); const preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager); let textState; function pushWhitespace({ width = 0, height = 0, transform = textContentItem.prevTransform, fontName = textContentItem.fontName }) { textContent.items.push({ str: " ", dir: "ltr", width, height, transform, fontName, hasEOL: false }); } function getCurrentTextTransform() { const font = textState.font; const tsm = [textState.fontSize * textState.textHScale, 0, 0, textState.fontSize, 0, textState.textRise]; if (font.isType3Font && (textState.fontSize <= 1 || font.isCharBBox) && !isArrayEqual(textState.fontMatrix, FONT_IDENTITY_MATRIX)) { const glyphHeight = font.bbox[3] - font.bbox[1]; if (glyphHeight > 0) { tsm[3] *= glyphHeight * textState.fontMatrix[3]; } } return Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm)); } function ensureTextContentItem() { if (textContentItem.initialized) { return textContentItem; } const { font, loadedName } = textState; if (!seenStyles.has(loadedName)) { seenStyles.add(loadedName); textContent.styles[loadedName] = { fontFamily: font.fallbackName, ascent: font.ascent, descent: font.descent, vertical: font.vertical }; if (self.options.fontExtraProperties && font.systemFontInfo) { const style = textContent.styles[loadedName]; style.fontSubstitution = font.systemFontInfo.css; style.fontSubstitutionLoadedName = font.systemFontInfo.loadedName; } } textContentItem.fontName = loadedName; const trm = textContentItem.transform = getCurrentTextTransform(); if (!font.vertical) { textContentItem.width = textContentItem.totalWidth = 0; textContentItem.height = textContentItem.totalHeight = Math.hypot(trm[2], trm[3]); textContentItem.vertical = false; } else { textContentItem.width = textContentItem.totalWidth = Math.hypot(trm[0], trm[1]); textContentItem.height = textContentItem.totalHeight = 0; textContentItem.vertical = true; } const scaleLineX = Math.hypot(textState.textLineMatrix[0], textState.textLineMatrix[1]); const scaleCtmX = Math.hypot(textState.ctm[0], textState.ctm[1]); textContentItem.textAdvanceScale = scaleCtmX * scaleLineX; const { fontSize } = textState; textContentItem.trackingSpaceMin = fontSize * TRACKING_SPACE_FACTOR; textContentItem.notASpace = fontSize * NOT_A_SPACE_FACTOR; textContentItem.negativeSpaceMax = fontSize * NEGATIVE_SPACE_FACTOR; textContentItem.spaceInFlowMin = fontSize * SPACE_IN_FLOW_MIN_FACTOR; textContentItem.spaceInFlowMax = fontSize * SPACE_IN_FLOW_MAX_FACTOR; textContentItem.hasEOL = false; textContentItem.initialized = true; return textContentItem; } function updateAdvanceScale() { if (!textContentItem.initialized) { return; } const scaleLineX = Math.hypot(textState.textLineMatrix[0], textState.textLineMatrix[1]); const scaleCtmX = Math.hypot(textState.ctm[0], textState.ctm[1]); const scaleFactor = scaleCtmX * scaleLineX; if (scaleFactor === textContentItem.textAdvanceScale) { return; } if (!textContentItem.vertical) { textContentItem.totalWidth += textContentItem.width * textContentItem.textAdvanceScale; textContentItem.width = 0; } else { textContentItem.totalHeight += textContentItem.height * textContentItem.textAdvanceScale; textContentItem.height = 0; } textContentItem.textAdvanceScale = scaleFactor; } function runBidiTransform(textChunk) { let text = textChunk.str.join(""); if (!disableNormalization) { text = normalizeUnicode(text); } const bidiResult = bidi(text, -1, textChunk.vertical); return { str: bidiResult.str, dir: bidiResult.dir, width: Math.abs(textChunk.totalWidth), height: Math.abs(textChunk.totalHeight), transform: textChunk.transform, fontName: textChunk.fontName, hasEOL: textChunk.hasEOL }; } async function handleSetFont(fontName, fontRef) { const translated = await self.loadFont(fontName, fontRef, resources); if (translated.font.isType3Font) { try { await translated.loadType3Data(self, resources, task); } catch {} } textState.loadedName = translated.loadedName; textState.font = translated.font; textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX; } function applyInverseRotation(x, y, matrix) { const scale = Math.hypot(matrix[0], matrix[1]); return [(matrix[0] * x + matrix[1] * y) / scale, (matrix[2] * x + matrix[3] * y) / scale]; } function compareWithLastPosition(glyphWidth) { const currentTransform = getCurrentTextTransform(); let posX = currentTransform[4]; let posY = currentTransform[5]; if (textState.font?.vertical) { if (posX < viewBox[0] || posX > viewBox[2] || posY + glyphWidth < viewBox[1] || posY > viewBox[3]) { return false; } } else if (posX + glyphWidth < viewBox[0] || posX > viewBox[2] || posY < viewBox[1] || posY > viewBox[3]) { return false; } if (!textState.font || !textContentItem.prevTransform) { return true; } let lastPosX = textContentItem.prevTransform[4]; let lastPosY = textContentItem.prevTransform[5]; if (lastPosX === posX && lastPosY === posY) { return true; } let rotate = -1; if (currentTransform[0] && currentTransform[1] === 0 && currentTransform[2] === 0) { rotate = currentTransform[0] > 0 ? 0 : 180; } else if (currentTransform[1] && currentTransform[0] === 0 && currentTransform[3] === 0) { rotate = currentTransform[1] > 0 ? 90 : 270; } switch (rotate) { case 0: break; case 90: [posX, posY] = [posY, posX]; [lastPosX, lastPosY] = [lastPosY, lastPosX]; break; case 180: [posX, posY, lastPosX, lastPosY] = [-posX, -posY, -lastPosX, -lastPosY]; break; case 270: [posX, posY] = [-posY, -posX]; [lastPosX, lastPosY] = [-lastPosY, -lastPosX]; break; default: [posX, posY] = applyInverseRotation(posX, posY, currentTransform); [lastPosX, lastPosY] = applyInverseRotation(lastPosX, lastPosY, textContentItem.prevTransform); } if (textState.font.vertical) { const advanceY = (lastPosY - posY) / textContentItem.textAdvanceScale; const advanceX = posX - lastPosX; const textOrientation = Math.sign(textContentItem.height); if (advanceY < textOrientation * textContentItem.negativeSpaceMax) { if (Math.abs(advanceX) > 0.5 * textContentItem.width) { appendEOL(); return true; } resetLastChars(); flushTextContentItem(); return true; } if (Math.abs(advanceX) > textContentItem.width) { appendEOL(); return true; } if (advanceY <= textOrientation * textContentItem.notASpace) { resetLastChars(); } if (advanceY <= textOrientation * textContentItem.trackingSpaceMin) { if (shouldAddWhitepsace()) { resetLastChars(); flushTextContentItem(); pushWhitespace({ height: Math.abs(advanceY) }); } else { textContentItem.height += advanceY; } } else if (!addFakeSpaces(advanceY, textContentItem.prevTransform, textOrientation)) { if (textContentItem.str.length === 0) { resetLastChars(); pushWhitespace({ height: Math.abs(advanceY) }); } else { textContentItem.height += advanceY; } } if (Math.abs(advanceX) > textContentItem.width * VERTICAL_SHIFT_RATIO) { flushTextContentItem(); } return true; } const advanceX = (posX - lastPosX) / textContentItem.textAdvanceScale; const advanceY = posY - lastPosY; const textOrientation = Math.sign(textContentItem.width); if (advanceX < textOrientation * textContentItem.negativeSpaceMax) { if (Math.abs(advanceY) > 0.5 * textContentItem.height) { appendEOL(); return true; } resetLastChars(); flushTextContentItem(); return true; } if (Math.abs(advanceY) > textContentItem.height) { appendEOL(); return true; } if (advanceX <= textOrientation * textContentItem.notASpace) { resetLastChars(); } if (advanceX <= textOrientation * textContentItem.trackingSpaceMin) { if (shouldAddWhitepsace()) { resetLastChars(); flushTextContentItem(); pushWhitespace({ width: Math.abs(advanceX) }); } else { textContentItem.width += advanceX; } } else if (!addFakeSpaces(advanceX, textContentItem.prevTransform, textOrientation)) { if (textContentItem.str.length === 0) { resetLastChars(); pushWhitespace({ width: Math.abs(advanceX) }); } else { textContentItem.width += advanceX; } } if (Math.abs(advanceY) > textContentItem.height * VERTICAL_SHIFT_RATIO) { flushTextContentItem(); } return true; } function buildTextContentItem({ chars, extraSpacing }) { const font = textState.font; if (!chars) { const charSpacing = textState.charSpacing + extraSpacing; if (charSpacing) { if (!font.vertical) { textState.translateTextMatrix(charSpacing * textState.textHScale, 0); } else { textState.translateTextMatrix(0, -charSpacing); } } if (keepWhiteSpace) { compareWithLastPosition(0); } return; } const glyphs = font.charsToGlyphs(chars); const scale = textState.fontMatrix[0] * textState.fontSize; for (let i = 0, ii = glyphs.length; i < ii; i++) { const glyph = glyphs[i]; const { category } = glyph; if (category.isInvisibleFormatMark) { continue; } let charSpacing = textState.charSpacing + (i + 1 === ii ? extraSpacing : 0); let glyphWidth = glyph.width; if (font.vertical) { glyphWidth = glyph.vmetric ? glyph.vmetric[0] : -glyphWidth; } let scaledDim = glyphWidth * scale; if (!keepWhiteSpace && category.isWhitespace) { if (!font.vertical) { charSpacing += scaledDim + textState.wordSpacing; textState.translateTextMatrix(charSpacing * textState.textHScale, 0); } else { charSpacing += -scaledDim + textState.wordSpacing; textState.translateTextMatrix(0, -charSpacing); } saveLastChar(" "); continue; } if (!category.isZeroWidthDiacritic && !compareWithLastPosition(scaledDim)) { if (!font.vertical) { textState.translateTextMatrix(scaledDim * textState.textHScale, 0); } else { textState.translateTextMatrix(0, scaledDim); } continue; } const textChunk = ensureTextContentItem(); if (category.isZeroWidthDiacritic) { scaledDim = 0; } if (!font.vertical) { scaledDim *= textState.textHScale; textState.translateTextMatrix(scaledDim, 0); textChunk.width += scaledDim; } else { textState.translateTextMatrix(0, scaledDim); scaledDim = Math.abs(scaledDim); textChunk.height += scaledDim; } if (scaledDim) { textChunk.prevTransform = getCurrentTextTransform(); } const glyphUnicode = glyph.unicode; if (saveLastChar(glyphUnicode)) { textChunk.str.push(" "); } textChunk.str.push(glyphUnicode); if (charSpacing) { if (!font.vertical) { textState.translateTextMatrix(charSpacing * textState.textHScale, 0); } else { textState.translateTextMatrix(0, -charSpacing); } } } } function appendEOL() { resetLastChars(); if (textContentItem.initialized) { textContentItem.hasEOL = true; flushTextContentItem(); } else { textContent.items.push({ str: "", dir: "ltr", width: 0, height: 0, transform: getCurrentTextTransform(), fontName: textState.loadedName, hasEOL: true }); } } function addFakeSpaces(width, transf, textOrientation) { if (textOrientation * textContentItem.spaceInFlowMin <= width && width <= textOrientation * textContentItem.spaceInFlowMax) { if (textContentItem.initialized) { resetLastChars(); textContentItem.str.push(" "); } return false; } const fontName = textContentItem.fontName; let height = 0; if (textContentItem.vertical) { height = width; width = 0; } flushTextContentItem(); resetLastChars(); pushWhitespace({ width: Math.abs(width), height: Math.abs(height), transform: transf || getCurrentTextTransform(), fontName }); return true; } function flushTextContentItem() { if (!textContentItem.initialized || !textContentItem.str) { return; } if (!textContentItem.vertical) { textContentItem.totalWidth += textContentItem.width * textContentItem.textAdvanceScale; } else { textContentItem.totalHeight += textContentItem.height * textContentItem.textAdvanceScale; } textContent.items.push(runBidiTransform(textContentItem)); textContentItem.initialized = false; textContentItem.str.length = 0; } function enqueueChunk(batch = false) { const length = textContent.items.length; if (length === 0) { return; } if (batch && length < TEXT_CHUNK_BATCH_SIZE) { return; } sink.enqueue(textContent, length); textContent.items = []; textContent.styles = Object.create(null); } const timeSlotManager = new TimeSlotManager(); return new Promise(function promiseBody(resolve, reject) { const next = function (promise) { enqueueChunk(true); Promise.all([promise, sink.ready]).then(function () { try { promiseBody(resolve, reject); } catch (ex) { reject(ex); } }, reject); }; task.ensureNotTerminated(); timeSlotManager.reset(); const operation = {}; let stop, args = []; while (!(stop = timeSlotManager.check())) { args.length = 0; operation.args = args; if (!preprocessor.read(operation)) { break; } const previousState = textState; textState = stateManager.state; const fn = operation.fn; args = operation.args; switch (fn | 0) { case OPS.setFont: var fontNameArg = args[0].name, fontSizeArg = args[1]; if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) { break; } flushTextContentItem(); textState.fontName = fontNameArg; textState.fontSize = fontSizeArg; next(handleSetFont(fontNameArg, null)); return; case OPS.setTextRise: textState.textRise = args[0]; break; case OPS.setHScale: textState.textHScale = args[0] / 100; break; case OPS.setLeading: textState.leading = args[0]; break; case OPS.moveText: textState.translateTextLineMatrix(args[0], args[1]); textState.textMatrix = textState.textLineMatrix.slice(); break; case OPS.setLeadingMoveText: textState.leading = -args[1]; textState.translateTextLineMatrix(args[0], args[1]); textState.textMatrix = textState.textLineMatrix.slice(); break; case OPS.nextLine: textState.carriageReturn(); break; case OPS.setTextMatrix: textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]); textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]); updateAdvanceScale(); break; case OPS.setCharSpacing: textState.charSpacing = args[0]; break; case OPS.setWordSpacing: textState.wordSpacing = args[0]; break; case OPS.beginText: textState.textMatrix = IDENTITY_MATRIX.slice(); textState.textLineMatrix = IDENTITY_MATRIX.slice(); break; case OPS.showSpacedText: if (!stateManager.state.font) { self.ensureStateFont(stateManager.state); continue; } const spaceFactor = (textState.font.vertical ? 1 : -1) * textState.fontSize / 1000; const elements = args[0]; for (let i = 0, ii = elements.length; i < ii; i++) { const item = elements[i]; if (typeof item === "string") { showSpacedTextBuffer.push(item); } else if (typeof item === "number" && item !== 0) { const str = showSpacedTextBuffer.join(""); showSpacedTextBuffer.length = 0; buildTextContentItem({ chars: str, extraSpacing: item * spaceFactor }); } } if (showSpacedTextBuffer.length > 0) { const str = showSpacedTextBuffer.join(""); showSpacedTextBuffer.length = 0; buildTextContentItem({ chars: str, extraSpacing: 0 }); } break; case OPS.showText: if (!stateManager.state.font) { self.ensureStateFont(stateManager.state); continue; } buildTextContentItem({ chars: args[0], extraSpacing: 0 }); break; case OPS.nextLineShowText: if (!stateManager.state.font) { self.ensureStateFont(stateManager.state); continue; } textState.carriageReturn(); buildTextContentItem({ chars: args[0], extraSpacing: 0 }); break; case OPS.nextLineSetSpacingShowText: if (!stateManager.state.font) { self.ensureStateFont(stateManager.state); continue; } textState.wordSpacing = args[0]; textState.charSpacing = args[1]; textState.carriageReturn(); buildTextContentItem({ chars: args[2], extraSpacing: 0 }); break; case OPS.paintXObject: flushTextContentItem(); if (!xobjs) { xobjs = resources.get("XObject") || Dict.empty; } var isValidName = args[0] instanceof Name; var name = args[0].name; if (isValidName && emptyXObjectCache.getByName(name)) { break; } next(new Promise(function (resolveXObject, rejectXObject) { if (!isValidName) { throw new FormatError("XObject must be referred to by name."); } let xobj = xobjs.getRaw(name); if (xobj instanceof Ref) { if (emptyXObjectCache.getByRef(xobj)) { resolveXObject(); return; } const globalImage = self.globalImageCache.getData(xobj, self.pageIndex); if (globalImage) { resolveXObject(); return; } xobj = xref.fetch(xobj); } if (!(xobj instanceof BaseStream)) { throw new FormatError("XObject should be a stream"); } const type = xobj.dict.get("Subtype"); if (!(type instanceof Name)) { throw new FormatError("XObject should have a Name subtype"); } if (type.name !== "Form") { emptyXObjectCache.set(name, xobj.dict.objId, true); resolveXObject(); return; } const currentState = stateManager.state.clone(); const xObjStateManager = new StateManager(currentState); const matrix = lookupMatrix(xobj.dict.getArray("Matrix"), null); if (matrix) { xObjStateManager.transform(matrix); } enqueueChunk(); const sinkWrapper = { enqueueInvoked: false, enqueue(chunk, size) { this.enqueueInvoked = true; sink.enqueue(chunk, size); }, get desiredSize() { return sink.desiredSize; }, get ready() { return sink.ready; } }; self.getTextContent({ stream: xobj, task, resources: xobj.dict.get("Resources") || resources, stateManager: xObjStateManager, includeMarkedContent, sink: sinkWrapper, seenStyles, viewBox, lang, markedContentData, disableNormalization, keepWhiteSpace }).then(function () { if (!sinkWrapper.enqueueInvoked) { emptyXObjectCache.set(name, xobj.dict.objId, true); } resolveXObject(); }, rejectXObject); }).catch(function (reason) { if (reason instanceof AbortException) { return; } if (self.options.ignoreErrors) { warn(`getTextContent - ignoring XObject: "${reason}".`); return; } throw reason; })); return; case OPS.setGState: isValidName = args[0] instanceof Name; name = args[0].name; if (isValidName && emptyGStateCache.getByName(name)) { break; } next(new Promise(function (resolveGState, rejectGState) { if (!isValidName) { throw new FormatError("GState must be referred to by name."); } const extGState = resources.get("ExtGState"); if (!(extGState instanceof Dict)) { throw new FormatError("ExtGState should be a dictionary."); } const gState = extGState.get(name); if (!(gState instanceof Dict)) { throw new FormatError("GState should be a dictionary."); } const gStateFont = gState.get("Font"); if (!gStateFont) { emptyGStateCache.set(name, gState.objId, true); resolveGState(); return; } flushTextContentItem(); textState.fontName = null; textState.fontSize = gStateFont[1]; handleSetFont(null, gStateFont[0]).then(resolveGState, rejectGState); }).catch(function (reason) { if (reason instanceof AbortException) { return; } if (self.options.ignoreErrors) { warn(`getTextContent - ignoring ExtGState: "${reason}".`); return; } throw reason; })); return; case OPS.beginMarkedContent: flushTextContentItem(); if (includeMarkedContent) { markedContentData.level++; textContent.items.push({ type: "beginMarkedContent", tag: args[0] instanceof Name ? args[0].name : null }); } break; case OPS.beginMarkedContentProps: flushTextContentItem(); if (includeMarkedContent) { markedContentData.level++; let mcid = null; if (args[1] instanceof Dict) { mcid = args[1].get("MCID"); } textContent.items.push({ type: "beginMarkedContentProps", id: Number.isInteger(mcid) ? `${self.idFactory.getPageObjId()}_mc${mcid}` : null, tag: args[0] instanceof Name ? args[0].name : null }); } break; case OPS.endMarkedContent: flushTextContentItem(); if (includeMarkedContent) { if (markedContentData.level === 0) { break; } markedContentData.level--; textContent.items.push({ type: "endMarkedContent" }); } break; case OPS.restore: if (previousState && (previousState.font !== textState.font || previousState.fontSize !== textState.fontSize || previousState.fontName !== textState.fontName)) { flushTextContentItem(); } break; } if (textContent.items.length >= sink.desiredSize) { stop = true; break; } } if (stop) { next(deferred); return; } flushTextContentItem(); enqueueChunk(); resolve(); }).catch(reason => { if (reason instanceof AbortException) { return; } if (this.options.ignoreErrors) { warn(`getTextContent - ignoring errors during "${task.name}" ` + `task: "${reason}".`); flushTextContentItem(); enqueueChunk(); return; } throw reason; }); } async extractDataStructures(dict, properties) { const xref = this.xref; let cidToGidBytes; const toUnicodePromise = this.readToUnicode(properties.toUnicode); if (properties.composite) { const cidSystemInfo = dict.get("CIDSystemInfo"); if (cidSystemInfo instanceof Dict) { properties.cidSystemInfo = { registry: stringToPDFString(cidSystemInfo.get("Registry")), ordering: stringToPDFString(cidSystemInfo.get("Ordering")), supplement: cidSystemInfo.get("Supplement") }; } try { const cidToGidMap = dict.get("CIDToGIDMap"); if (cidToGidMap instanceof BaseStream) { cidToGidBytes = cidToGidMap.getBytes(); } } catch (ex) { if (!this.options.ignoreErrors) { throw ex; } warn(`extractDataStructures - ignoring CIDToGIDMap data: "${ex}".`); } } const differences = []; let baseEncodingName = null; let encoding; if (dict.has("Encoding")) { encoding = dict.get("Encoding"); if (encoding instanceof Dict) { baseEncodingName = encoding.get("BaseEncoding"); baseEncodingName = baseEncodingName instanceof Name ? baseEncodingName.name : null; if (encoding.has("Differences")) { const diffEncoding = encoding.get("Differences"); let index = 0; for (const entry of diffEncoding) { const data = xref.fetchIfRef(entry); if (typeof data === "number") { index = data; } else if (data instanceof Name) { differences[index++] = data.name; } else { throw new FormatError(`Invalid entry in 'Differences' array: ${data}`); } } } } else if (encoding instanceof Name) { baseEncodingName = encoding.name; } else { const msg = "Encoding is not a Name nor a Dict"; if (!this.options.ignoreErrors) { throw new FormatError(msg); } warn(msg); } if (baseEncodingName !== "MacRomanEncoding" && baseEncodingName !== "MacExpertEncoding" && baseEncodingName !== "WinAnsiEncoding") { baseEncodingName = null; } } const nonEmbeddedFont = !properties.file || properties.isInternalFont, isSymbolsFontName = getSymbolsFonts()[properties.name]; if (baseEncodingName && nonEmbeddedFont && isSymbolsFontName) { baseEncodingName = null; } if (baseEncodingName) { properties.defaultEncoding = getEncoding(baseEncodingName); } else { const isSymbolicFont = !!(properties.flags & FontFlags.Symbolic); const isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic); encoding = StandardEncoding; if (properties.type === "TrueType" && !isNonsymbolicFont) { encoding = WinAnsiEncoding; } if (isSymbolicFont || isSymbolsFontName) { encoding = MacRomanEncoding; if (nonEmbeddedFont) { if (/Symbol/i.test(properties.name)) { encoding = SymbolSetEncoding; } else if (/Dingbats/i.test(properties.name)) { encoding = ZapfDingbatsEncoding; } else if (/Wingdings/i.test(properties.name)) { encoding = WinAnsiEncoding; } } } properties.defaultEncoding = encoding; } properties.differences = differences; properties.baseEncodingName = baseEncodingName; properties.hasEncoding = !!baseEncodingName || differences.length > 0; properties.dict = dict; properties.toUnicode = await toUnicodePromise; const builtToUnicode = await this.buildToUnicode(properties); properties.toUnicode = builtToUnicode; if (cidToGidBytes) { properties.cidToGidMap = this.readCidToGidMap(cidToGidBytes, builtToUnicode); } return properties; } _simpleFontToUnicode(properties, forceGlyphs = false) { assert(!properties.composite, "Must be a simple font."); const toUnicode = []; const encoding = properties.defaultEncoding.slice(); const baseEncodingName = properties.baseEncodingName; const differences = properties.differences; for (const charcode in differences) { const glyphName = differences[charcode]; if (glyphName === ".notdef") { continue; } encoding[charcode] = glyphName; } const glyphsUnicodeMap = getGlyphsUnicode(); for (const charcode in encoding) { let glyphName = encoding[charcode]; if (glyphName === "") { continue; } let unicode = glyphsUnicodeMap[glyphName]; if (unicode !== undefined) { toUnicode[charcode] = String.fromCharCode(unicode); continue; } let code = 0; switch (glyphName[0]) { case "G": if (glyphName.length === 3) { code = parseInt(glyphName.substring(1), 16); } break; case "g": if (glyphName.length === 5) { code = parseInt(glyphName.substring(1), 16); } break; case "C": case "c": if (glyphName.length >= 3 && glyphName.length <= 4) { const codeStr = glyphName.substring(1); if (forceGlyphs) { code = parseInt(codeStr, 16); break; } code = +codeStr; if (Number.isNaN(code) && Number.isInteger(parseInt(codeStr, 16))) { return this._simpleFontToUnicode(properties, true); } } break; case "u": unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap); if (unicode !== -1) { code = unicode; } break; default: switch (glyphName) { case "f_h": case "f_t": case "T_h": toUnicode[charcode] = glyphName.replaceAll("_", ""); continue; } break; } if (code > 0 && code <= 0x10ffff && Number.isInteger(code)) { if (baseEncodingName && code === +charcode) { const baseEncoding = getEncoding(baseEncodingName); if (baseEncoding && (glyphName = baseEncoding[charcode])) { toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]); continue; } } toUnicode[charcode] = String.fromCodePoint(code); } } return toUnicode; } async buildToUnicode(properties) { properties.hasIncludedToUnicodeMap = properties.toUnicode?.length > 0; if (properties.hasIncludedToUnicodeMap) { if (!properties.composite && properties.hasEncoding) { properties.fallbackToUnicode = this._simpleFontToUnicode(properties); } return properties.toUnicode; } if (!properties.composite) { return new ToUnicodeMap(this._simpleFontToUnicode(properties)); } if (properties.composite && (properties.cMap.builtInCMap && !(properties.cMap instanceof IdentityCMap) || properties.cidSystemInfo?.registry === "Adobe" && (properties.cidSystemInfo.ordering === "GB1" || properties.cidSystemInfo.ordering === "CNS1" || properties.cidSystemInfo.ordering === "Japan1" || properties.cidSystemInfo.ordering === "Korea1"))) { const { registry, ordering } = properties.cidSystemInfo; const ucs2CMapName = Name.get(`${registry}-${ordering}-UCS2`); const ucs2CMap = await CMapFactory.create({ encoding: ucs2CMapName, fetchBuiltInCMap: this._fetchBuiltInCMapBound, useCMap: null }); const toUnicode = [], buf = []; properties.cMap.forEach(function (charcode, cid) { if (cid > 0xffff) { throw new FormatError("Max size of CID is 65,535"); } const ucs2 = ucs2CMap.lookup(cid); if (ucs2) { buf.length = 0; for (let i = 0, ii = ucs2.length; i < ii; i += 2) { buf.push((ucs2.charCodeAt(i) << 8) + ucs2.charCodeAt(i + 1)); } toUnicode[charcode] = String.fromCharCode(...buf); } }); return new ToUnicodeMap(toUnicode); } return new IdentityToUnicodeMap(properties.firstChar, properties.lastChar); } async readToUnicode(cmapObj) { if (!cmapObj) { return null; } if (cmapObj instanceof Name) { const cmap = await CMapFactory.create({ encoding: cmapObj, fetchBuiltInCMap: this._fetchBuiltInCMapBound, useCMap: null }); if (cmap instanceof IdentityCMap) { return new IdentityToUnicodeMap(0, 0xffff); } return new ToUnicodeMap(cmap.getMap()); } if (cmapObj instanceof BaseStream) { try { const cmap = await CMapFactory.create({ encoding: cmapObj, fetchBuiltInCMap: this._fetchBuiltInCMapBound, useCMap: null }); if (cmap instanceof IdentityCMap) { return new IdentityToUnicodeMap(0, 0xffff); } const map = new Array(cmap.length); cmap.forEach(function (charCode, token) { if (typeof token === "number") { map[charCode] = String.fromCodePoint(token); return; } const str = []; for (let k = 0; k < token.length; k += 2) { const w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1); if ((w1 & 0xf800) !== 0xd800) { str.push(w1); continue; } k += 2; const w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1); str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000); } map[charCode] = String.fromCodePoint(...str); }); return new ToUnicodeMap(map); } catch (reason) { if (reason instanceof AbortException) { return null; } if (this.options.ignoreErrors) { warn(`readToUnicode - ignoring ToUnicode data: "${reason}".`); return null; } throw reason; } } return null; } readCidToGidMap(glyphsData, toUnicode) { const result = []; for (let j = 0, jj = glyphsData.length; j < jj; j++) { const glyphID = glyphsData[j++] << 8 | glyphsData[j]; const code = j >> 1; if (glyphID === 0 && !toUnicode.has(code)) { continue; } result[code] = glyphID; } return result; } extractWidths(dict, descriptor, properties) { const xref = this.xref; let glyphsWidths = []; let defaultWidth = 0; const glyphsVMetrics = []; let defaultVMetrics; if (properties.composite) { const dw = dict.get("DW"); defaultWidth = Number.isInteger(dw) ? dw : 1000; const widths = dict.get("W"); if (Array.isArray(widths)) { for (let i = 0, ii = widths.length; i < ii; i++) { let start = xref.fetchIfRef(widths[i++]); if (!Number.isInteger(start)) { break; } const code = xref.fetchIfRef(widths[i]); if (Array.isArray(code)) { for (const c of code) { const width = xref.fetchIfRef(c); if (typeof width === "number") { glyphsWidths[start] = width; } start++; } } else if (Number.isInteger(code)) { const width = xref.fetchIfRef(widths[++i]); if (typeof width !== "number") { continue; } for (let j = start; j <= code; j++) { glyphsWidths[j] = width; } } else { break; } } } if (properties.vertical) { const dw2 = dict.getArray("DW2"); let vmetrics = isNumberArray(dw2, 2) ? dw2 : [880, -1000]; defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]]; vmetrics = dict.get("W2"); if (Array.isArray(vmetrics)) { for (let i = 0, ii = vmetrics.length; i < ii; i++) { let start = xref.fetchIfRef(vmetrics[i++]); if (!Number.isInteger(start)) { break; } const code = xref.fetchIfRef(vmetrics[i]); if (Array.isArray(code)) { for (let j = 0, jj = code.length; j < jj; j++) { const vmetric = [xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j])]; if (isNumberArray(vmetric, null)) { glyphsVMetrics[start] = vmetric; } start++; } } else if (Number.isInteger(code)) { const vmetric = [xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i])]; if (!isNumberArray(vmetric, null)) { continue; } for (let j = start; j <= code; j++) { glyphsVMetrics[j] = vmetric; } } else { break; } } } } } else { const widths = dict.get("Widths"); if (Array.isArray(widths)) { let j = properties.firstChar; for (const w of widths) { const width = xref.fetchIfRef(w); if (typeof width === "number") { glyphsWidths[j] = width; } j++; } const missingWidth = descriptor.get("MissingWidth"); defaultWidth = typeof missingWidth === "number" ? missingWidth : 0; } else { const baseFontName = dict.get("BaseFont"); if (baseFontName instanceof Name) { const metrics = this.getBaseFontMetrics(baseFontName.name); glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties); defaultWidth = metrics.defaultWidth; } } } let isMonospace = true; let firstWidth = defaultWidth; for (const glyph in glyphsWidths) { const glyphWidth = glyphsWidths[glyph]; if (!glyphWidth) { continue; } if (!firstWidth) { firstWidth = glyphWidth; continue; } if (firstWidth !== glyphWidth) { isMonospace = false; break; } } if (isMonospace) { properties.flags |= FontFlags.FixedPitch; } else { properties.flags &= ~FontFlags.FixedPitch; } properties.defaultWidth = defaultWidth; properties.widths = glyphsWidths; properties.defaultVMetrics = defaultVMetrics; properties.vmetrics = glyphsVMetrics; } isSerifFont(baseFontName) { const fontNameWoStyle = baseFontName.split("-", 1)[0]; return fontNameWoStyle in getSerifFonts() || /serif/gi.test(fontNameWoStyle); } getBaseFontMetrics(name) { let defaultWidth = 0; let widths = Object.create(null); let monospace = false; const stdFontMap = getStdFontMap(); let lookupName = stdFontMap[name] || name; const Metrics = getMetrics(); if (!(lookupName in Metrics)) { lookupName = this.isSerifFont(name) ? "Times-Roman" : "Helvetica"; } const glyphWidths = Metrics[lookupName]; if (typeof glyphWidths === "number") { defaultWidth = glyphWidths; monospace = true; } else { widths = glyphWidths(); } return { defaultWidth, monospace, widths }; } buildCharCodeToWidth(widthsByGlyphName, properties) { const widths = Object.create(null); const differences = properties.differences; const encoding = properties.defaultEncoding; for (let charCode = 0; charCode < 256; charCode++) { if (charCode in differences && widthsByGlyphName[differences[charCode]]) { widths[charCode] = widthsByGlyphName[differences[charCode]]; continue; } if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) { widths[charCode] = widthsByGlyphName[encoding[charCode]]; continue; } } return widths; } preEvaluateFont(dict) { const baseDict = dict; let type = dict.get("Subtype"); if (!(type instanceof Name)) { throw new FormatError("invalid font Subtype"); } let composite = false; let hash; if (type.name === "Type0") { const df = dict.get("DescendantFonts"); if (!df) { throw new FormatError("Descendant fonts are not specified"); } dict = Array.isArray(df) ? this.xref.fetchIfRef(df[0]) : df; if (!(dict instanceof Dict)) { throw new FormatError("Descendant font is not a dictionary."); } type = dict.get("Subtype"); if (!(type instanceof Name)) { throw new FormatError("invalid font Subtype"); } composite = true; } let firstChar = dict.get("FirstChar"); if (!Number.isInteger(firstChar)) { firstChar = 0; } let lastChar = dict.get("LastChar"); if (!Number.isInteger(lastChar)) { lastChar = composite ? 0xffff : 0xff; } const descriptor = dict.get("FontDescriptor"); const toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode"); if (descriptor) { hash = new MurmurHash3_64(); const encoding = baseDict.getRaw("Encoding"); if (encoding instanceof Name) { hash.update(encoding.name); } else if (encoding instanceof Ref) { hash.update(encoding.toString()); } else if (encoding instanceof Dict) { for (const entry of encoding.getRawValues()) { if (entry instanceof Name) { hash.update(entry.name); } else if (entry instanceof Ref) { hash.update(entry.toString()); } else if (Array.isArray(entry)) { const diffLength = entry.length, diffBuf = new Array(diffLength); for (let j = 0; j < diffLength; j++) { const diffEntry = entry[j]; if (diffEntry instanceof Name) { diffBuf[j] = diffEntry.name; } else if (typeof diffEntry === "number" || diffEntry instanceof Ref) { diffBuf[j] = diffEntry.toString(); } } hash.update(diffBuf.join()); } } } hash.update(`${firstChar}-${lastChar}`); if (toUnicode instanceof BaseStream) { const stream = toUnicode.str || toUnicode; const uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start); hash.update(uint8array); } else if (toUnicode instanceof Name) { hash.update(toUnicode.name); } const widths = dict.get("Widths") || baseDict.get("Widths"); if (Array.isArray(widths)) { const widthsBuf = []; for (const entry of widths) { if (typeof entry === "number" || entry instanceof Ref) { widthsBuf.push(entry.toString()); } } hash.update(widthsBuf.join()); } if (composite) { hash.update("compositeFont"); const compositeWidths = dict.get("W") || baseDict.get("W"); if (Array.isArray(compositeWidths)) { const widthsBuf = []; for (const entry of compositeWidths) { if (typeof entry === "number" || entry instanceof Ref) { widthsBuf.push(entry.toString()); } else if (Array.isArray(entry)) { const subWidthsBuf = []; for (const element of entry) { if (typeof element === "number" || element instanceof Ref) { subWidthsBuf.push(element.toString()); } } widthsBuf.push(`[${subWidthsBuf.join()}]`); } } hash.update(widthsBuf.join()); } const cidToGidMap = dict.getRaw("CIDToGIDMap") || baseDict.getRaw("CIDToGIDMap"); if (cidToGidMap instanceof Name) { hash.update(cidToGidMap.name); } else if (cidToGidMap instanceof Ref) { hash.update(cidToGidMap.toString()); } else if (cidToGidMap instanceof BaseStream) { hash.update(cidToGidMap.peekBytes()); } } } return { descriptor, dict, baseDict, composite, type: type.name, firstChar, lastChar, toUnicode, hash: hash ? hash.hexdigest() : "" }; } async translateFont({ descriptor, dict, baseDict, composite, type, firstChar, lastChar, toUnicode, cssFontInfo }) { const isType3Font = type === "Type3"; if (!descriptor) { if (isType3Font) { const bbox = lookupNormalRect(dict.getArray("FontBBox"), [0, 0, 0, 0]); descriptor = new Dict(null); descriptor.set("FontName", Name.get(type)); descriptor.set("FontBBox", bbox); } else { let baseFontName = dict.get("BaseFont"); if (!(baseFontName instanceof Name)) { throw new FormatError("Base font is not specified"); } baseFontName = baseFontName.name.replaceAll(/[,_]/g, "-"); const metrics = this.getBaseFontMetrics(baseFontName); const fontNameWoStyle = baseFontName.split("-", 1)[0]; const flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic); const properties = { type, name: baseFontName, loadedName: baseDict.loadedName, systemFontInfo: null, widths: metrics.widths, defaultWidth: metrics.defaultWidth, isSimulatedFlags: true, flags, firstChar, lastChar, toUnicode, xHeight: 0, capHeight: 0, italicAngle: 0, isType3Font }; const widths = dict.get("Widths"); const standardFontName = getStandardFontName(baseFontName); let file = null; if (standardFontName) { file = await this.fetchStandardFontData(standardFontName); properties.isInternalFont = !!file; } if (!properties.isInternalFont && this.options.useSystemFonts) { properties.systemFontInfo = getFontSubstitution(this.systemFontCache, this.idFactory, this.options.standardFontDataUrl, baseFontName, standardFontName, type); } const newProperties = await this.extractDataStructures(dict, properties); if (Array.isArray(widths)) { const glyphWidths = []; let j = firstChar; for (const w of widths) { const width = this.xref.fetchIfRef(w); if (typeof width === "number") { glyphWidths[j] = width; } j++; } newProperties.widths = glyphWidths; } else { newProperties.widths = this.buildCharCodeToWidth(metrics.widths, newProperties); } return new Font(baseFontName, file, newProperties); } } let fontName = descriptor.get("FontName"); let baseFont = dict.get("BaseFont"); if (typeof fontName === "string") { fontName = Name.get(fontName); } if (typeof baseFont === "string") { baseFont = Name.get(baseFont); } const fontNameStr = fontName?.name; const baseFontStr = baseFont?.name; if (!isType3Font && fontNameStr !== baseFontStr) { info(`The FontDescriptor's FontName is "${fontNameStr}" but ` + `should be the same as the Font's BaseFont "${baseFontStr}".`); if (fontNameStr && baseFontStr && (baseFontStr.startsWith(fontNameStr) || !isKnownFontName(fontNameStr) && isKnownFontName(baseFontStr))) { fontName = null; } } fontName ||= baseFont; if (!(fontName instanceof Name)) { throw new FormatError("invalid font name"); } let fontFile, subtype, length1, length2, length3; try { fontFile = descriptor.get("FontFile", "FontFile2", "FontFile3"); } catch (ex) { if (!this.options.ignoreErrors) { throw ex; } warn(`translateFont - fetching "${fontName.name}" font file: "${ex}".`); fontFile = new NullStream(); } let isInternalFont = false; let glyphScaleFactors = null; let systemFontInfo = null; if (fontFile) { if (fontFile.dict) { const subtypeEntry = fontFile.dict.get("Subtype"); if (subtypeEntry instanceof Name) { subtype = subtypeEntry.name; } length1 = fontFile.dict.get("Length1"); length2 = fontFile.dict.get("Length2"); length3 = fontFile.dict.get("Length3"); } } else if (cssFontInfo) { const standardFontName = getXfaFontName(fontName.name); if (standardFontName) { cssFontInfo.fontFamily = `${cssFontInfo.fontFamily}-PdfJS-XFA`; cssFontInfo.metrics = standardFontName.metrics || null; glyphScaleFactors = standardFontName.factors || null; fontFile = await this.fetchStandardFontData(standardFontName.name); isInternalFont = !!fontFile; baseDict = dict = getXfaFontDict(fontName.name); composite = true; } } else if (!isType3Font) { const standardFontName = getStandardFontName(fontName.name); if (standardFontName) { fontFile = await this.fetchStandardFontData(standardFontName); isInternalFont = !!fontFile; } if (!isInternalFont && this.options.useSystemFonts) { systemFontInfo = getFontSubstitution(this.systemFontCache, this.idFactory, this.options.standardFontDataUrl, fontName.name, standardFontName, type); } } const fontMatrix = lookupMatrix(dict.getArray("FontMatrix"), FONT_IDENTITY_MATRIX); const bbox = lookupNormalRect(descriptor.getArray("FontBBox") || dict.getArray("FontBBox"), undefined); let ascent = descriptor.get("Ascent"); if (typeof ascent !== "number") { ascent = undefined; } let descent = descriptor.get("Descent"); if (typeof descent !== "number") { descent = undefined; } let xHeight = descriptor.get("XHeight"); if (typeof xHeight !== "number") { xHeight = 0; } let capHeight = descriptor.get("CapHeight"); if (typeof capHeight !== "number") { capHeight = 0; } let flags = descriptor.get("Flags"); if (!Number.isInteger(flags)) { flags = 0; } let italicAngle = descriptor.get("ItalicAngle"); if (typeof italicAngle !== "number") { italicAngle = 0; } const properties = { type, name: fontName.name, subtype, file: fontFile, length1, length2, length3, isInternalFont, loadedName: baseDict.loadedName, composite, fixedPitch: false, fontMatrix, firstChar, lastChar, toUnicode, bbox, ascent, descent, xHeight, capHeight, flags, italicAngle, isType3Font, cssFontInfo, scaleFactors: glyphScaleFactors, systemFontInfo }; if (composite) { const cidEncoding = baseDict.get("Encoding"); if (cidEncoding instanceof Name) { properties.cidEncoding = cidEncoding.name; } const cMap = await CMapFactory.create({ encoding: cidEncoding, fetchBuiltInCMap: this._fetchBuiltInCMapBound, useCMap: null }); properties.cMap = cMap; properties.vertical = properties.cMap.vertical; } const newProperties = await this.extractDataStructures(dict, properties); this.extractWidths(dict, descriptor, newProperties); return new Font(fontName.name, fontFile, newProperties); } static buildFontPaths(font, glyphs, handler, evaluatorOptions) { function buildPath(fontChar) { const glyphName = `${font.loadedName}_path_${fontChar}`; try { if (font.renderer.hasBuiltPath(fontChar)) { return; } handler.send("commonobj", [glyphName, "FontPath", font.renderer.getPathJs(fontChar)]); } catch (reason) { if (evaluatorOptions.ignoreErrors) { warn(`buildFontPaths - ignoring ${glyphName} glyph: "${reason}".`); return; } throw reason; } } for (const glyph of glyphs) { buildPath(glyph.fontChar); const accent = glyph.accent; if (accent?.fontChar) { buildPath(accent.fontChar); } } } static get fallbackFontDict() { const dict = new Dict(); dict.set("BaseFont", Name.get("Helvetica")); dict.set("Type", Name.get("FallbackType")); dict.set("Subtype", Name.get("FallbackType")); dict.set("Encoding", Name.get("WinAnsiEncoding")); return shadow(this, "fallbackFontDict", dict); } } class TranslatedFont { constructor({ loadedName, font, dict, evaluatorOptions }) { this.loadedName = loadedName; this.font = font; this.dict = dict; this._evaluatorOptions = evaluatorOptions || DefaultPartialEvaluatorOptions; this.type3Loaded = null; this.type3Dependencies = font.isType3Font ? new Set() : null; this.sent = false; } send(handler) { if (this.sent) { return; } this.sent = true; handler.send("commonobj", [this.loadedName, "Font", this.font.exportData(this._evaluatorOptions.fontExtraProperties)]); } fallback(handler) { if (!this.font.data) { return; } this.font.disableFontFace = true; PartialEvaluator.buildFontPaths(this.font, this.font.glyphCacheValues, handler, this._evaluatorOptions); } loadType3Data(evaluator, resources, task) { if (this.type3Loaded) { return this.type3Loaded; } if (!this.font.isType3Font) { throw new Error("Must be a Type3 font."); } const type3Evaluator = evaluator.clone({ ignoreErrors: false }); const type3FontRefs = new RefSet(evaluator.type3FontRefs); if (this.dict.objId && !type3FontRefs.has(this.dict.objId)) { type3FontRefs.put(this.dict.objId); } type3Evaluator.type3FontRefs = type3FontRefs; const translatedFont = this.font, type3Dependencies = this.type3Dependencies; let loadCharProcsPromise = Promise.resolve(); const charProcs = this.dict.get("CharProcs"); const fontResources = this.dict.get("Resources") || resources; const charProcOperatorList = Object.create(null); const fontBBox = Util.normalizeRect(translatedFont.bbox || [0, 0, 0, 0]), width = fontBBox[2] - fontBBox[0], height = fontBBox[3] - fontBBox[1]; const fontBBoxSize = Math.hypot(width, height); for (const key of charProcs.getKeys()) { loadCharProcsPromise = loadCharProcsPromise.then(() => { const glyphStream = charProcs.get(key); const operatorList = new OperatorList(); return type3Evaluator.getOperatorList({ stream: glyphStream, task, resources: fontResources, operatorList }).then(() => { if (operatorList.fnArray[0] === OPS.setCharWidthAndBounds) { this._removeType3ColorOperators(operatorList, fontBBoxSize); } charProcOperatorList[key] = operatorList.getIR(); for (const dependency of operatorList.dependencies) { type3Dependencies.add(dependency); } }).catch(function (reason) { warn(`Type3 font resource "${key}" is not available.`); const dummyOperatorList = new OperatorList(); charProcOperatorList[key] = dummyOperatorList.getIR(); }); }); } this.type3Loaded = loadCharProcsPromise.then(() => { translatedFont.charProcOperatorList = charProcOperatorList; if (this._bbox) { translatedFont.isCharBBox = true; translatedFont.bbox = this._bbox; } }); return this.type3Loaded; } _removeType3ColorOperators(operatorList, fontBBoxSize = NaN) { const charBBox = Util.normalizeRect(operatorList.argsArray[0].slice(2)), width = charBBox[2] - charBBox[0], height = charBBox[3] - charBBox[1]; const charBBoxSize = Math.hypot(width, height); if (width === 0 || height === 0) { operatorList.fnArray.splice(0, 1); operatorList.argsArray.splice(0, 1); } else if (fontBBoxSize === 0 || Math.round(charBBoxSize / fontBBoxSize) >= 10) { if (!this._bbox) { this._bbox = [Infinity, Infinity, -Infinity, -Infinity]; } this._bbox[0] = Math.min(this._bbox[0], charBBox[0]); this._bbox[1] = Math.min(this._bbox[1], charBBox[1]); this._bbox[2] = Math.max(this._bbox[2], charBBox[2]); this._bbox[3] = Math.max(this._bbox[3], charBBox[3]); } let i = 0, ii = operatorList.length; while (i < ii) { switch (operatorList.fnArray[i]) { case OPS.setCharWidthAndBounds: break; case OPS.setStrokeColorSpace: case OPS.setFillColorSpace: case OPS.setStrokeColor: case OPS.setStrokeColorN: case OPS.setFillColor: case OPS.setFillColorN: case OPS.setStrokeGray: case OPS.setFillGray: case OPS.setStrokeRGBColor: case OPS.setFillRGBColor: case OPS.setStrokeCMYKColor: case OPS.setFillCMYKColor: case OPS.shadingFill: case OPS.setRenderingIntent: operatorList.fnArray.splice(i, 1); operatorList.argsArray.splice(i, 1); ii--; continue; case OPS.setGState: const [gStateObj] = operatorList.argsArray[i]; let j = 0, jj = gStateObj.length; while (j < jj) { const [gStateKey] = gStateObj[j]; switch (gStateKey) { case "TR": case "TR2": case "HT": case "BG": case "BG2": case "UCR": case "UCR2": gStateObj.splice(j, 1); jj--; continue; } j++; } break; } i++; } } } class StateManager { constructor(initialState = new EvalState()) { this.state = initialState; this.stateStack = []; } save() { const old = this.state; this.stateStack.push(this.state); this.state = old.clone(); } restore() { const prev = this.stateStack.pop(); if (prev) { this.state = prev; } } transform(args) { this.state.ctm = Util.transform(this.state.ctm, args); } } class TextState { constructor() { this.ctm = new Float32Array(IDENTITY_MATRIX); this.fontName = null; this.fontSize = 0; this.loadedName = null; this.font = null; this.fontMatrix = FONT_IDENTITY_MATRIX; this.textMatrix = IDENTITY_MATRIX.slice(); this.textLineMatrix = IDENTITY_MATRIX.slice(); this.charSpacing = 0; this.wordSpacing = 0; this.leading = 0; this.textHScale = 1; this.textRise = 0; } setTextMatrix(a, b, c, d, e, f) { const m = this.textMatrix; m[0] = a; m[1] = b; m[2] = c; m[3] = d; m[4] = e; m[5] = f; } setTextLineMatrix(a, b, c, d, e, f) { const m = this.textLineMatrix; m[0] = a; m[1] = b; m[2] = c; m[3] = d; m[4] = e; m[5] = f; } translateTextMatrix(x, y) { const m = this.textMatrix; m[4] = m[0] * x + m[2] * y + m[4]; m[5] = m[1] * x + m[3] * y + m[5]; } translateTextLineMatrix(x, y) { const m = this.textLineMatrix; m[4] = m[0] * x + m[2] * y + m[4]; m[5] = m[1] * x + m[3] * y + m[5]; } carriageReturn() { this.translateTextLineMatrix(0, -this.leading); this.textMatrix = this.textLineMatrix.slice(); } clone() { const clone = Object.create(this); clone.textMatrix = this.textMatrix.slice(); clone.textLineMatrix = this.textLineMatrix.slice(); clone.fontMatrix = this.fontMatrix.slice(); return clone; } } class EvalState { constructor() { this.ctm = new Float32Array(IDENTITY_MATRIX); this.font = null; this.textRenderingMode = TextRenderingMode.FILL; this.fillColorSpace = ColorSpace.singletons.gray; this.strokeColorSpace = ColorSpace.singletons.gray; } clone() { return Object.create(this); } } class EvaluatorPreprocessor { static get opMap() { return shadow(this, "opMap", Object.assign(Object.create(null), { w: { id: OPS.setLineWidth, numArgs: 1, variableArgs: false }, J: { id: OPS.setLineCap, numArgs: 1, variableArgs: false }, j: { id: OPS.setLineJoin, numArgs: 1, variableArgs: false }, M: { id: OPS.setMiterLimit, numArgs: 1, variableArgs: false }, d: { id: OPS.setDash, numArgs: 2, variableArgs: false }, ri: { id: OPS.setRenderingIntent, numArgs: 1, variableArgs: false }, i: { id: OPS.setFlatness, numArgs: 1, variableArgs: false }, gs: { id: OPS.setGState, numArgs: 1, variableArgs: false }, q: { id: OPS.save, numArgs: 0, variableArgs: false }, Q: { id: OPS.restore, numArgs: 0, variableArgs: false }, cm: { id: OPS.transform, numArgs: 6, variableArgs: false }, m: { id: OPS.moveTo, numArgs: 2, variableArgs: false }, l: { id: OPS.lineTo, numArgs: 2, variableArgs: false }, c: { id: OPS.curveTo, numArgs: 6, variableArgs: false }, v: { id: OPS.curveTo2, numArgs: 4, variableArgs: false }, y: { id: OPS.curveTo3, numArgs: 4, variableArgs: false }, h: { id: OPS.closePath, numArgs: 0, variableArgs: false }, re: { id: OPS.rectangle, numArgs: 4, variableArgs: false }, S: { id: OPS.stroke, numArgs: 0, variableArgs: false }, s: { id: OPS.closeStroke, numArgs: 0, variableArgs: false }, f: { id: OPS.fill, numArgs: 0, variableArgs: false }, F: { id: OPS.fill, numArgs: 0, variableArgs: false }, "f*": { id: OPS.eoFill, numArgs: 0, variableArgs: false }, B: { id: OPS.fillStroke, numArgs: 0, variableArgs: false }, "B*": { id: OPS.eoFillStroke, numArgs: 0, variableArgs: false }, b: { id: OPS.closeFillStroke, numArgs: 0, variableArgs: false }, "b*": { id: OPS.closeEOFillStroke, numArgs: 0, variableArgs: false }, n: { id: OPS.endPath, numArgs: 0, variableArgs: false }, W: { id: OPS.clip, numArgs: 0, variableArgs: false }, "W*": { id: OPS.eoClip, numArgs: 0, variableArgs: false }, BT: { id: OPS.beginText, numArgs: 0, variableArgs: false }, ET: { id: OPS.endText, numArgs: 0, variableArgs: false }, Tc: { id: OPS.setCharSpacing, numArgs: 1, variableArgs: false }, Tw: { id: OPS.setWordSpacing, numArgs: 1, variableArgs: false }, Tz: { id: OPS.setHScale, numArgs: 1, variableArgs: false }, TL: { id: OPS.setLeading, numArgs: 1, variableArgs: false }, Tf: { id: OPS.setFont, numArgs: 2, variableArgs: false }, Tr: { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false }, Ts: { id: OPS.setTextRise, numArgs: 1, variableArgs: false }, Td: { id: OPS.moveText, numArgs: 2, variableArgs: false }, TD: { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false }, Tm: { id: OPS.setTextMatrix, numArgs: 6, variableArgs: false }, "T*": { id: OPS.nextLine, numArgs: 0, variableArgs: false }, Tj: { id: OPS.showText, numArgs: 1, variableArgs: false }, TJ: { id: OPS.showSpacedText, numArgs: 1, variableArgs: false }, "'": { id: OPS.nextLineShowText, numArgs: 1, variableArgs: false }, '"': { id: OPS.nextLineSetSpacingShowText, numArgs: 3, variableArgs: false }, d0: { id: OPS.setCharWidth, numArgs: 2, variableArgs: false }, d1: { id: OPS.setCharWidthAndBounds, numArgs: 6, variableArgs: false }, CS: { id: OPS.setStrokeColorSpace, numArgs: 1, variableArgs: false }, cs: { id: OPS.setFillColorSpace, numArgs: 1, variableArgs: false }, SC: { id: OPS.setStrokeColor, numArgs: 4, variableArgs: true }, SCN: { id: OPS.setStrokeColorN, numArgs: 33, variableArgs: true }, sc: { id: OPS.setFillColor, numArgs: 4, variableArgs: true }, scn: { id: OPS.setFillColorN, numArgs: 33, variableArgs: true }, G: { id: OPS.setStrokeGray, numArgs: 1, variableArgs: false }, g: { id: OPS.setFillGray, numArgs: 1, variableArgs: false }, RG: { id: OPS.setStrokeRGBColor, numArgs: 3, variableArgs: false }, rg: { id: OPS.setFillRGBColor, numArgs: 3, variableArgs: false }, K: { id: OPS.setStrokeCMYKColor, numArgs: 4, variableArgs: false }, k: { id: OPS.setFillCMYKColor, numArgs: 4, variableArgs: false }, sh: { id: OPS.shadingFill, numArgs: 1, variableArgs: false }, BI: { id: OPS.beginInlineImage, numArgs: 0, variableArgs: false }, ID: { id: OPS.beginImageData, numArgs: 0, variableArgs: false }, EI: { id: OPS.endInlineImage, numArgs: 1, variableArgs: false }, Do: { id: OPS.paintXObject, numArgs: 1, variableArgs: false }, MP: { id: OPS.markPoint, numArgs: 1, variableArgs: false }, DP: { id: OPS.markPointProps, numArgs: 2, variableArgs: false }, BMC: { id: OPS.beginMarkedContent, numArgs: 1, variableArgs: false }, BDC: { id: OPS.beginMarkedContentProps, numArgs: 2, variableArgs: false }, EMC: { id: OPS.endMarkedContent, numArgs: 0, variableArgs: false }, BX: { id: OPS.beginCompat, numArgs: 0, variableArgs: false }, EX: { id: OPS.endCompat, numArgs: 0, variableArgs: false }, BM: null, BD: null, true: null, fa: null, fal: null, fals: null, false: null, nu: null, nul: null, null: null })); } static MAX_INVALID_PATH_OPS = 10; constructor(stream, xref, stateManager = new StateManager()) { this.parser = new Parser({ lexer: new Lexer(stream, EvaluatorPreprocessor.opMap), xref }); this.stateManager = stateManager; this.nonProcessedArgs = []; this._isPathOp = false; this._numInvalidPathOPS = 0; } get savedStatesDepth() { return this.stateManager.stateStack.length; } read(operation) { let args = operation.args; while (true) { const obj = this.parser.getObj(); if (obj instanceof Cmd) { const cmd = obj.cmd; const opSpec = EvaluatorPreprocessor.opMap[cmd]; if (!opSpec) { warn(`Unknown command "${cmd}".`); continue; } const fn = opSpec.id; const numArgs = opSpec.numArgs; let argsLength = args !== null ? args.length : 0; if (!this._isPathOp) { this._numInvalidPathOPS = 0; } this._isPathOp = fn >= OPS.moveTo && fn <= OPS.endPath; if (!opSpec.variableArgs) { if (argsLength !== numArgs) { const nonProcessedArgs = this.nonProcessedArgs; while (argsLength > numArgs) { nonProcessedArgs.push(args.shift()); argsLength--; } while (argsLength < numArgs && nonProcessedArgs.length !== 0) { if (args === null) { args = []; } args.unshift(nonProcessedArgs.pop()); argsLength++; } } if (argsLength < numArgs) { const partialMsg = `command ${cmd}: expected ${numArgs} args, ` + `but received ${argsLength} args.`; if (this._isPathOp && ++this._numInvalidPathOPS > EvaluatorPreprocessor.MAX_INVALID_PATH_OPS) { throw new FormatError(`Invalid ${partialMsg}`); } warn(`Skipping ${partialMsg}`); if (args !== null) { args.length = 0; } continue; } } else if (argsLength > numArgs) { info(`Command ${cmd}: expected [0, ${numArgs}] args, ` + `but received ${argsLength} args.`); } this.preprocessCommand(fn, args); operation.fn = fn; operation.args = args; return true; } if (obj === EOF) { return false; } if (obj !== null) { if (args === null) { args = []; } args.push(obj); if (args.length > 33) { throw new FormatError("Too many arguments"); } } } } preprocessCommand(fn, args) { switch (fn | 0) { case OPS.save: this.stateManager.save(); break; case OPS.restore: this.stateManager.restore(); break; case OPS.transform: this.stateManager.transform(args); break; } } } ;// CONCATENATED MODULE: ./src/core/default_appearance.js class DefaultAppearanceEvaluator extends EvaluatorPreprocessor { constructor(str) { super(new StringStream(str)); } parse() { const operation = { fn: 0, args: [] }; const result = { fontSize: 0, fontName: "", fontColor: new Uint8ClampedArray(3) }; try { while (true) { operation.args.length = 0; if (!this.read(operation)) { break; } if (this.savedStatesDepth !== 0) { continue; } const { fn, args } = operation; switch (fn | 0) { case OPS.setFont: const [fontName, fontSize] = args; if (fontName instanceof Name) { result.fontName = fontName.name; } if (typeof fontSize === "number" && fontSize > 0) { result.fontSize = fontSize; } break; case OPS.setFillRGBColor: ColorSpace.singletons.rgb.getRgbItem(args, 0, result.fontColor, 0); break; case OPS.setFillGray: ColorSpace.singletons.gray.getRgbItem(args, 0, result.fontColor, 0); break; case OPS.setFillCMYKColor: ColorSpace.singletons.cmyk.getRgbItem(args, 0, result.fontColor, 0); break; } } } catch (reason) { warn(`parseDefaultAppearance - ignoring errors: "${reason}".`); } return result; } } function parseDefaultAppearance(str) { return new DefaultAppearanceEvaluator(str).parse(); } class AppearanceStreamEvaluator extends EvaluatorPreprocessor { constructor(stream, evaluatorOptions, xref) { super(stream); this.stream = stream; this.evaluatorOptions = evaluatorOptions; this.xref = xref; this.resources = stream.dict?.get("Resources"); } parse() { const operation = { fn: 0, args: [] }; let result = { scaleFactor: 1, fontSize: 0, fontName: "", fontColor: new Uint8ClampedArray(3), fillColorSpace: ColorSpace.singletons.gray }; let breakLoop = false; const stack = []; try { while (true) { operation.args.length = 0; if (breakLoop || !this.read(operation)) { break; } const { fn, args } = operation; switch (fn | 0) { case OPS.save: stack.push({ scaleFactor: result.scaleFactor, fontSize: result.fontSize, fontName: result.fontName, fontColor: result.fontColor.slice(), fillColorSpace: result.fillColorSpace }); break; case OPS.restore: result = stack.pop() || result; break; case OPS.setTextMatrix: result.scaleFactor *= Math.hypot(args[0], args[1]); break; case OPS.setFont: const [fontName, fontSize] = args; if (fontName instanceof Name) { result.fontName = fontName.name; } if (typeof fontSize === "number" && fontSize > 0) { result.fontSize = fontSize * result.scaleFactor; } break; case OPS.setFillColorSpace: result.fillColorSpace = ColorSpace.parse({ cs: args[0], xref: this.xref, resources: this.resources, pdfFunctionFactory: this._pdfFunctionFactory, localColorSpaceCache: this._localColorSpaceCache }); break; case OPS.setFillColor: const cs = result.fillColorSpace; cs.getRgbItem(args, 0, result.fontColor, 0); break; case OPS.setFillRGBColor: ColorSpace.singletons.rgb.getRgbItem(args, 0, result.fontColor, 0); break; case OPS.setFillGray: ColorSpace.singletons.gray.getRgbItem(args, 0, result.fontColor, 0); break; case OPS.setFillCMYKColor: ColorSpace.singletons.cmyk.getRgbItem(args, 0, result.fontColor, 0); break; case OPS.showText: case OPS.showSpacedText: case OPS.nextLineShowText: case OPS.nextLineSetSpacingShowText: breakLoop = true; break; } } } catch (reason) { warn(`parseAppearanceStream - ignoring errors: "${reason}".`); } this.stream.reset(); delete result.scaleFactor; delete result.fillColorSpace; return result; } get _localColorSpaceCache() { return shadow(this, "_localColorSpaceCache", new LocalColorSpaceCache()); } get _pdfFunctionFactory() { const pdfFunctionFactory = new PDFFunctionFactory({ xref: this.xref, isEvalSupported: this.evaluatorOptions.isEvalSupported }); return shadow(this, "_pdfFunctionFactory", pdfFunctionFactory); } } function parseAppearanceStream(stream, evaluatorOptions, xref) { return new AppearanceStreamEvaluator(stream, evaluatorOptions, xref).parse(); } function getPdfColor(color, isFill) { if (color[0] === color[1] && color[1] === color[2]) { const gray = color[0] / 255; return `${numberToString(gray)} ${isFill ? "g" : "G"}`; } return Array.from(color, c => numberToString(c / 255)).join(" ") + ` ${isFill ? "rg" : "RG"}`; } function createDefaultAppearance({ fontSize, fontName, fontColor }) { return `/${escapePDFName(fontName)} ${fontSize} Tf ${getPdfColor(fontColor, true)}`; } class FakeUnicodeFont { constructor(xref, fontFamily) { this.xref = xref; this.widths = null; this.firstChar = Infinity; this.lastChar = -Infinity; this.fontFamily = fontFamily; const canvas = new OffscreenCanvas(1, 1); this.ctxMeasure = canvas.getContext("2d"); if (!FakeUnicodeFont._fontNameId) { FakeUnicodeFont._fontNameId = 1; } this.fontName = Name.get(`InvalidPDFjsFont_${fontFamily}_${FakeUnicodeFont._fontNameId++}`); } get fontDescriptorRef() { if (!FakeUnicodeFont._fontDescriptorRef) { const fontDescriptor = new Dict(this.xref); fontDescriptor.set("Type", Name.get("FontDescriptor")); fontDescriptor.set("FontName", this.fontName); fontDescriptor.set("FontFamily", "MyriadPro Regular"); fontDescriptor.set("FontBBox", [0, 0, 0, 0]); fontDescriptor.set("FontStretch", Name.get("Normal")); fontDescriptor.set("FontWeight", 400); fontDescriptor.set("ItalicAngle", 0); FakeUnicodeFont._fontDescriptorRef = this.xref.getNewPersistentRef(fontDescriptor); } return FakeUnicodeFont._fontDescriptorRef; } get descendantFontRef() { const descendantFont = new Dict(this.xref); descendantFont.set("BaseFont", this.fontName); descendantFont.set("Type", Name.get("Font")); descendantFont.set("Subtype", Name.get("CIDFontType0")); descendantFont.set("CIDToGIDMap", Name.get("Identity")); descendantFont.set("FirstChar", this.firstChar); descendantFont.set("LastChar", this.lastChar); descendantFont.set("FontDescriptor", this.fontDescriptorRef); descendantFont.set("DW", 1000); const widths = []; const chars = [...this.widths.entries()].sort(); let currentChar = null; let currentWidths = null; for (const [char, width] of chars) { if (!currentChar) { currentChar = char; currentWidths = [width]; continue; } if (char === currentChar + currentWidths.length) { currentWidths.push(width); } else { widths.push(currentChar, currentWidths); currentChar = char; currentWidths = [width]; } } if (currentChar) { widths.push(currentChar, currentWidths); } descendantFont.set("W", widths); const cidSystemInfo = new Dict(this.xref); cidSystemInfo.set("Ordering", "Identity"); cidSystemInfo.set("Registry", "Adobe"); cidSystemInfo.set("Supplement", 0); descendantFont.set("CIDSystemInfo", cidSystemInfo); return this.xref.getNewPersistentRef(descendantFont); } get baseFontRef() { const baseFont = new Dict(this.xref); baseFont.set("BaseFont", this.fontName); baseFont.set("Type", Name.get("Font")); baseFont.set("Subtype", Name.get("Type0")); baseFont.set("Encoding", Name.get("Identity-H")); baseFont.set("DescendantFonts", [this.descendantFontRef]); baseFont.set("ToUnicode", Name.get("Identity-H")); return this.xref.getNewPersistentRef(baseFont); } get resources() { const resources = new Dict(this.xref); const font = new Dict(this.xref); font.set(this.fontName.name, this.baseFontRef); resources.set("Font", font); return resources; } _createContext() { this.widths = new Map(); this.ctxMeasure.font = `1000px ${this.fontFamily}`; return this.ctxMeasure; } createFontResources(text) { const ctx = this._createContext(); for (const line of text.split(/\r\n?|\n/)) { for (const char of line.split("")) { const code = char.charCodeAt(0); if (this.widths.has(code)) { continue; } const metrics = ctx.measureText(char); const width = Math.ceil(metrics.width); this.widths.set(code, width); this.firstChar = Math.min(code, this.firstChar); this.lastChar = Math.max(code, this.lastChar); } } return this.resources; } static getFirstPositionInfo(rect, rotation, fontSize) { const [x1, y1, x2, y2] = rect; let w = x2 - x1; let h = y2 - y1; if (rotation % 180 !== 0) { [w, h] = [h, w]; } const lineHeight = LINE_FACTOR * fontSize; const lineDescent = LINE_DESCENT_FACTOR * fontSize; return { coords: [0, h + lineDescent - lineHeight], bbox: [0, 0, w, h], matrix: rotation !== 0 ? getRotationMatrix(rotation, h, lineHeight) : undefined }; } createAppearance(text, rect, rotation, fontSize, bgColor, strokeAlpha) { const ctx = this._createContext(); const lines = []; let maxWidth = -Infinity; for (const line of text.split(/\r\n?|\n/)) { lines.push(line); const lineWidth = ctx.measureText(line).width; maxWidth = Math.max(maxWidth, lineWidth); for (const code of codePointIter(line)) { const char = String.fromCodePoint(code); let width = this.widths.get(code); if (width === undefined) { const metrics = ctx.measureText(char); width = Math.ceil(metrics.width); this.widths.set(code, width); this.firstChar = Math.min(code, this.firstChar); this.lastChar = Math.max(code, this.lastChar); } } } maxWidth *= fontSize / 1000; const [x1, y1, x2, y2] = rect; let w = x2 - x1; let h = y2 - y1; if (rotation % 180 !== 0) { [w, h] = [h, w]; } let hscale = 1; if (maxWidth > w) { hscale = w / maxWidth; } let vscale = 1; const lineHeight = LINE_FACTOR * fontSize; const lineDescent = LINE_DESCENT_FACTOR * fontSize; const maxHeight = lineHeight * lines.length; if (maxHeight > h) { vscale = h / maxHeight; } const fscale = Math.min(hscale, vscale); const newFontSize = fontSize * fscale; const buffer = ["q", `0 0 ${numberToString(w)} ${numberToString(h)} re W n`, `BT`, `1 0 0 1 0 ${numberToString(h + lineDescent)} Tm 0 Tc ${getPdfColor(bgColor, true)}`, `/${this.fontName.name} ${numberToString(newFontSize)} Tf`]; const { resources } = this; strokeAlpha = typeof strokeAlpha === "number" && strokeAlpha >= 0 && strokeAlpha <= 1 ? strokeAlpha : 1; if (strokeAlpha !== 1) { buffer.push("/R0 gs"); const extGState = new Dict(this.xref); const r0 = new Dict(this.xref); r0.set("ca", strokeAlpha); r0.set("CA", strokeAlpha); r0.set("Type", Name.get("ExtGState")); extGState.set("R0", r0); resources.set("ExtGState", extGState); } const vShift = numberToString(lineHeight); for (const line of lines) { buffer.push(`0 -${vShift} Td <${stringToUTF16HexString(line)}> Tj`); } buffer.push("ET", "Q"); const appearance = buffer.join("\n"); const appearanceStreamDict = new Dict(this.xref); appearanceStreamDict.set("Subtype", Name.get("Form")); appearanceStreamDict.set("Type", Name.get("XObject")); appearanceStreamDict.set("BBox", [0, 0, w, h]); appearanceStreamDict.set("Length", appearance.length); appearanceStreamDict.set("Resources", resources); if (rotation) { const matrix = getRotationMatrix(rotation, w, h); appearanceStreamDict.set("Matrix", matrix); } const ap = new StringStream(appearance); ap.dict = appearanceStreamDict; return ap; } } ;// CONCATENATED MODULE: ./src/core/name_number_tree.js class NameOrNumberTree { constructor(root, xref, type) { if (this.constructor === NameOrNumberTree) { unreachable("Cannot initialize NameOrNumberTree."); } this.root = root; this.xref = xref; this._type = type; } getAll() { const map = new Map(); if (!this.root) { return map; } const xref = this.xref; const processed = new RefSet(); processed.put(this.root); const queue = [this.root]; while (queue.length > 0) { const obj = xref.fetchIfRef(queue.shift()); if (!(obj instanceof Dict)) { continue; } if (obj.has("Kids")) { const kids = obj.get("Kids"); if (!Array.isArray(kids)) { continue; } for (const kid of kids) { if (processed.has(kid)) { throw new FormatError(`Duplicate entry in "${this._type}" tree.`); } queue.push(kid); processed.put(kid); } continue; } const entries = obj.get(this._type); if (!Array.isArray(entries)) { continue; } for (let i = 0, ii = entries.length; i < ii; i += 2) { map.set(xref.fetchIfRef(entries[i]), xref.fetchIfRef(entries[i + 1])); } } return map; } get(key) { if (!this.root) { return null; } const xref = this.xref; let kidsOrEntries = xref.fetchIfRef(this.root); let loopCount = 0; const MAX_LEVELS = 10; while (kidsOrEntries.has("Kids")) { if (++loopCount > MAX_LEVELS) { warn(`Search depth limit reached for "${this._type}" tree.`); return null; } const kids = kidsOrEntries.get("Kids"); if (!Array.isArray(kids)) { return null; } let l = 0, r = kids.length - 1; while (l <= r) { const m = l + r >> 1; const kid = xref.fetchIfRef(kids[m]); const limits = kid.get("Limits"); if (key < xref.fetchIfRef(limits[0])) { r = m - 1; } else if (key > xref.fetchIfRef(limits[1])) { l = m + 1; } else { kidsOrEntries = kid; break; } } if (l > r) { return null; } } const entries = kidsOrEntries.get(this._type); if (Array.isArray(entries)) { let l = 0, r = entries.length - 2; while (l <= r) { const tmp = l + r >> 1, m = tmp + (tmp & 1); const currentKey = xref.fetchIfRef(entries[m]); if (key < currentKey) { r = m - 2; } else if (key > currentKey) { l = m + 2; } else { return xref.fetchIfRef(entries[m + 1]); } } } return null; } } class NameTree extends NameOrNumberTree { constructor(root, xref) { super(root, xref, "Names"); } } class NumberTree extends NameOrNumberTree { constructor(root, xref) { super(root, xref, "Nums"); } } ;// CONCATENATED MODULE: ./src/core/cleanup_helper.js function clearGlobalCaches() { clearPatternCaches(); clearPrimitiveCaches(); clearUnicodeCaches(); JpxImage.cleanup(); } ;// CONCATENATED MODULE: ./src/core/file_spec.js function pickPlatformItem(dict) { if (!(dict instanceof Dict)) { return null; } if (dict.has("UF")) { return dict.get("UF"); } else if (dict.has("F")) { return dict.get("F"); } else if (dict.has("Unix")) { return dict.get("Unix"); } else if (dict.has("Mac")) { return dict.get("Mac"); } else if (dict.has("DOS")) { return dict.get("DOS"); } return null; } function stripPath(str) { return str.substring(str.lastIndexOf("/") + 1); } class FileSpec { #contentAvailable = false; constructor(root, xref, skipContent = false) { if (!(root instanceof Dict)) { return; } this.xref = xref; this.root = root; if (root.has("FS")) { this.fs = root.get("FS"); } if (root.has("RF")) { warn("Related file specifications are not supported"); } if (!skipContent) { if (root.has("EF")) { this.#contentAvailable = true; } else { warn("Non-embedded file specifications are not supported"); } } } get filename() { let filename = ""; const item = pickPlatformItem(this.root); if (item && typeof item === "string") { filename = stringToPDFString(item).replaceAll("\\\\", "\\").replaceAll("\\/", "/").replaceAll("\\", "/"); } return shadow(this, "filename", filename || "unnamed"); } get content() { if (!this.#contentAvailable) { return null; } this._contentRef ||= pickPlatformItem(this.root?.get("EF")); let content = null; if (this._contentRef) { const fileObj = this.xref.fetchIfRef(this._contentRef); if (fileObj instanceof BaseStream) { content = fileObj.getBytes(); } else { warn("Embedded file specification points to non-existing/invalid content"); } } else { warn("Embedded file specification does not have any content"); } return content; } get description() { let description = ""; const desc = this.root?.get("Desc"); if (desc && typeof desc === "string") { description = stringToPDFString(desc); } return shadow(this, "description", description); } get serializable() { return { rawFilename: this.filename, filename: stripPath(this.filename), content: this.content, description: this.description }; } } ;// CONCATENATED MODULE: ./src/core/xml_parser.js const XMLParserErrorCode = { NoError: 0, EndOfDocument: -1, UnterminatedCdat: -2, UnterminatedXmlDeclaration: -3, UnterminatedDoctypeDeclaration: -4, UnterminatedComment: -5, MalformedElement: -6, OutOfMemory: -7, UnterminatedAttributeValue: -8, UnterminatedElement: -9, ElementNeverBegun: -10 }; function isWhitespace(s, index) { const ch = s[index]; return ch === " " || ch === "\n" || ch === "\r" || ch === "\t"; } function isWhitespaceString(s) { for (let i = 0, ii = s.length; i < ii; i++) { if (!isWhitespace(s, i)) { return false; } } return true; } class XMLParserBase { _resolveEntities(s) { return s.replaceAll(/&([^;]+);/g, (all, entity) => { if (entity.substring(0, 2) === "#x") { return String.fromCodePoint(parseInt(entity.substring(2), 16)); } else if (entity.substring(0, 1) === "#") { return String.fromCodePoint(parseInt(entity.substring(1), 10)); } switch (entity) { case "lt": return "<"; case "gt": return ">"; case "amp": return "&"; case "quot": return '"'; case "apos": return "'"; } return this.onResolveEntity(entity); }); } _parseContent(s, start) { const attributes = []; let pos = start; function skipWs() { while (pos < s.length && isWhitespace(s, pos)) { ++pos; } } while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== ">" && s[pos] !== "/") { ++pos; } const name = s.substring(start, pos); skipWs(); while (pos < s.length && s[pos] !== ">" && s[pos] !== "/" && s[pos] !== "?") { skipWs(); let attrName = "", attrValue = ""; while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== "=") { attrName += s[pos]; ++pos; } skipWs(); if (s[pos] !== "=") { return null; } ++pos; skipWs(); const attrEndChar = s[pos]; if (attrEndChar !== '"' && attrEndChar !== "'") { return null; } const attrEndIndex = s.indexOf(attrEndChar, ++pos); if (attrEndIndex < 0) { return null; } attrValue = s.substring(pos, attrEndIndex); attributes.push({ name: attrName, value: this._resolveEntities(attrValue) }); pos = attrEndIndex + 1; skipWs(); } return { name, attributes, parsed: pos - start }; } _parseProcessingInstruction(s, start) { let pos = start; function skipWs() { while (pos < s.length && isWhitespace(s, pos)) { ++pos; } } while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== ">" && s[pos] !== "?" && s[pos] !== "/") { ++pos; } const name = s.substring(start, pos); skipWs(); const attrStart = pos; while (pos < s.length && (s[pos] !== "?" || s[pos + 1] !== ">")) { ++pos; } const value = s.substring(attrStart, pos); return { name, value, parsed: pos - start }; } parseXml(s) { let i = 0; while (i < s.length) { const ch = s[i]; let j = i; if (ch === "<") { ++j; const ch2 = s[j]; let q; switch (ch2) { case "/": ++j; q = s.indexOf(">", j); if (q < 0) { this.onError(XMLParserErrorCode.UnterminatedElement); return; } this.onEndElement(s.substring(j, q)); j = q + 1; break; case "?": ++j; const pi = this._parseProcessingInstruction(s, j); if (s.substring(j + pi.parsed, j + pi.parsed + 2) !== "?>") { this.onError(XMLParserErrorCode.UnterminatedXmlDeclaration); return; } this.onPi(pi.name, pi.value); j += pi.parsed + 2; break; case "!": if (s.substring(j + 1, j + 3) === "--") { q = s.indexOf("-->", j + 3); if (q < 0) { this.onError(XMLParserErrorCode.UnterminatedComment); return; } this.onComment(s.substring(j + 3, q)); j = q + 3; } else if (s.substring(j + 1, j + 8) === "[CDATA[") { q = s.indexOf("]]>", j + 8); if (q < 0) { this.onError(XMLParserErrorCode.UnterminatedCdat); return; } this.onCdata(s.substring(j + 8, q)); j = q + 3; } else if (s.substring(j + 1, j + 8) === "DOCTYPE") { const q2 = s.indexOf("[", j + 8); let complexDoctype = false; q = s.indexOf(">", j + 8); if (q < 0) { this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration); return; } if (q2 > 0 && q > q2) { q = s.indexOf("]>", j + 8); if (q < 0) { this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration); return; } complexDoctype = true; } const doctypeContent = s.substring(j + 8, q + (complexDoctype ? 1 : 0)); this.onDoctype(doctypeContent); j = q + (complexDoctype ? 2 : 1); } else { this.onError(XMLParserErrorCode.MalformedElement); return; } break; default: const content = this._parseContent(s, j); if (content === null) { this.onError(XMLParserErrorCode.MalformedElement); return; } let isClosed = false; if (s.substring(j + content.parsed, j + content.parsed + 2) === "/>") { isClosed = true; } else if (s.substring(j + content.parsed, j + content.parsed + 1) !== ">") { this.onError(XMLParserErrorCode.UnterminatedElement); return; } this.onBeginElement(content.name, content.attributes, isClosed); j += content.parsed + (isClosed ? 2 : 1); break; } } else { while (j < s.length && s[j] !== "<") { j++; } const text = s.substring(i, j); this.onText(this._resolveEntities(text)); } i = j; } } onResolveEntity(name) { return `&${name};`; } onPi(name, value) {} onComment(text) {} onCdata(text) {} onDoctype(doctypeContent) {} onText(text) {} onBeginElement(name, attributes, isEmpty) {} onEndElement(name) {} onError(code) {} } class SimpleDOMNode { constructor(nodeName, nodeValue) { this.nodeName = nodeName; this.nodeValue = nodeValue; Object.defineProperty(this, "parentNode", { value: null, writable: true }); } get firstChild() { return this.childNodes?.[0]; } get nextSibling() { const childNodes = this.parentNode.childNodes; if (!childNodes) { return undefined; } const index = childNodes.indexOf(this); if (index === -1) { return undefined; } return childNodes[index + 1]; } get textContent() { if (!this.childNodes) { return this.nodeValue || ""; } return this.childNodes.map(function (child) { return child.textContent; }).join(""); } get children() { return this.childNodes || []; } hasChildNodes() { return this.childNodes?.length > 0; } searchNode(paths, pos) { if (pos >= paths.length) { return this; } const component = paths[pos]; if (component.name.startsWith("#") && pos < paths.length - 1) { return this.searchNode(paths, pos + 1); } const stack = []; let node = this; while (true) { if (component.name === node.nodeName) { if (component.pos === 0) { const res = node.searchNode(paths, pos + 1); if (res !== null) { return res; } } else if (stack.length === 0) { return null; } else { const [parent] = stack.pop(); let siblingPos = 0; for (const child of parent.childNodes) { if (component.name === child.nodeName) { if (siblingPos === component.pos) { return child.searchNode(paths, pos + 1); } siblingPos++; } } return node.searchNode(paths, pos + 1); } } if (node.childNodes?.length > 0) { stack.push([node, 0]); node = node.childNodes[0]; } else if (stack.length === 0) { return null; } else { while (stack.length !== 0) { const [parent, currentPos] = stack.pop(); const newPos = currentPos + 1; if (newPos < parent.childNodes.length) { stack.push([parent, newPos]); node = parent.childNodes[newPos]; break; } } if (stack.length === 0) { return null; } } } } dump(buffer) { if (this.nodeName === "#text") { buffer.push(encodeToXmlString(this.nodeValue)); return; } buffer.push(`<${this.nodeName}`); if (this.attributes) { for (const attribute of this.attributes) { buffer.push(` ${attribute.name}="${encodeToXmlString(attribute.value)}"`); } } if (this.hasChildNodes()) { buffer.push(">"); for (const child of this.childNodes) { child.dump(buffer); } buffer.push(`</${this.nodeName}>`); } else if (this.nodeValue) { buffer.push(`>${encodeToXmlString(this.nodeValue)}</${this.nodeName}>`); } else { buffer.push("/>"); } } } class SimpleXMLParser extends XMLParserBase { constructor({ hasAttributes = false, lowerCaseName = false }) { super(); this._currentFragment = null; this._stack = null; this._errorCode = XMLParserErrorCode.NoError; this._hasAttributes = hasAttributes; this._lowerCaseName = lowerCaseName; } parseFromString(data) { this._currentFragment = []; this._stack = []; this._errorCode = XMLParserErrorCode.NoError; this.parseXml(data); if (this._errorCode !== XMLParserErrorCode.NoError) { return undefined; } const [documentElement] = this._currentFragment; if (!documentElement) { return undefined; } return { documentElement }; } onText(text) { if (isWhitespaceString(text)) { return; } const node = new SimpleDOMNode("#text", text); this._currentFragment.push(node); } onCdata(text) { const node = new SimpleDOMNode("#text", text); this._currentFragment.push(node); } onBeginElement(name, attributes, isEmpty) { if (this._lowerCaseName) { name = name.toLowerCase(); } const node = new SimpleDOMNode(name); node.childNodes = []; if (this._hasAttributes) { node.attributes = attributes; } this._currentFragment.push(node); if (isEmpty) { return; } this._stack.push(this._currentFragment); this._currentFragment = node.childNodes; } onEndElement(name) { this._currentFragment = this._stack.pop() || []; const lastElement = this._currentFragment.at(-1); if (!lastElement) { return null; } for (const childNode of lastElement.childNodes) { childNode.parentNode = lastElement; } return lastElement; } onError(code) { this._errorCode = code; } } ;// CONCATENATED MODULE: ./src/core/metadata_parser.js class MetadataParser { constructor(data) { data = this._repair(data); const parser = new SimpleXMLParser({ lowerCaseName: true }); const xmlDocument = parser.parseFromString(data); this._metadataMap = new Map(); this._data = data; if (xmlDocument) { this._parse(xmlDocument); } } _repair(data) { return data.replace(/^[^<]+/, "").replaceAll(/>\\376\\377([^<]+)/g, function (all, codes) { const bytes = codes.replaceAll(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) { return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1); }).replaceAll(/&(amp|apos|gt|lt|quot);/g, function (str, name) { switch (name) { case "amp": return "&"; case "apos": return "'"; case "gt": return ">"; case "lt": return "<"; case "quot": return '"'; } throw new Error(`_repair: ${name} isn't defined.`); }); const charBuf = [">"]; for (let i = 0, ii = bytes.length; i < ii; i += 2) { const code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1); if (code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38) { charBuf.push(String.fromCharCode(code)); } else { charBuf.push("&#x" + (0x10000 + code).toString(16).substring(1) + ";"); } } return charBuf.join(""); }); } _getSequence(entry) { const name = entry.nodeName; if (name !== "rdf:bag" && name !== "rdf:seq" && name !== "rdf:alt") { return null; } return entry.childNodes.filter(node => node.nodeName === "rdf:li"); } _parseArray(entry) { if (!entry.hasChildNodes()) { return; } const [seqNode] = entry.childNodes; const sequence = this._getSequence(seqNode) || []; this._metadataMap.set(entry.nodeName, sequence.map(node => node.textContent.trim())); } _parse(xmlDocument) { let rdf = xmlDocument.documentElement; if (rdf.nodeName !== "rdf:rdf") { rdf = rdf.firstChild; while (rdf && rdf.nodeName !== "rdf:rdf") { rdf = rdf.nextSibling; } } if (!rdf || rdf.nodeName !== "rdf:rdf" || !rdf.hasChildNodes()) { return; } for (const desc of rdf.childNodes) { if (desc.nodeName !== "rdf:description") { continue; } for (const entry of desc.childNodes) { const name = entry.nodeName; switch (name) { case "#text": continue; case "dc:creator": case "dc:subject": this._parseArray(entry); continue; } this._metadataMap.set(name, entry.textContent.trim()); } } } get serializable() { return { parsedData: this._metadataMap, rawData: this._data }; } } ;// CONCATENATED MODULE: ./src/core/decrypt_stream.js const chunkSize = 512; class DecryptStream extends DecodeStream { constructor(str, maybeLength, decrypt) { super(maybeLength); this.str = str; this.dict = str.dict; this.decrypt = decrypt; this.nextChunk = null; this.initialized = false; } readBlock() { let chunk; if (this.initialized) { chunk = this.nextChunk; } else { chunk = this.str.getBytes(chunkSize); this.initialized = true; } if (!chunk || chunk.length === 0) { this.eof = true; return; } this.nextChunk = this.str.getBytes(chunkSize); const hasMoreData = this.nextChunk?.length > 0; const decrypt = this.decrypt; chunk = decrypt(chunk, !hasMoreData); const bufferLength = this.bufferLength, newLength = bufferLength + chunk.length, buffer = this.ensureBuffer(newLength); buffer.set(chunk, bufferLength); this.bufferLength = newLength; } } ;// CONCATENATED MODULE: ./src/core/crypto.js class ARCFourCipher { constructor(key) { this.a = 0; this.b = 0; const s = new Uint8Array(256); const keyLength = key.length; for (let i = 0; i < 256; ++i) { s[i] = i; } for (let i = 0, j = 0; i < 256; ++i) { const tmp = s[i]; j = j + tmp + key[i % keyLength] & 0xff; s[i] = s[j]; s[j] = tmp; } this.s = s; } encryptBlock(data) { let a = this.a, b = this.b; const s = this.s; const n = data.length; const output = new Uint8Array(n); for (let i = 0; i < n; ++i) { a = a + 1 & 0xff; const tmp = s[a]; b = b + tmp & 0xff; const tmp2 = s[b]; s[a] = tmp2; s[b] = tmp; output[i] = data[i] ^ s[tmp + tmp2 & 0xff]; } this.a = a; this.b = b; return output; } decryptBlock(data) { return this.encryptBlock(data); } encrypt(data) { return this.encryptBlock(data); } } const calculateMD5 = function calculateMD5Closure() { const r = new Uint8Array([7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21]); const k = new Int32Array([-680876936, -389564586, 606105819, -1044525330, -176418897, 1200080426, -1473231341, -45705983, 1770035416, -1958414417, -42063, -1990404162, 1804603682, -40341101, -1502002290, 1236535329, -165796510, -1069501632, 643717713, -373897302, -701558691, 38016083, -660478335, -405537848, 568446438, -1019803690, -187363961, 1163531501, -1444681467, -51403784, 1735328473, -1926607734, -378558, -2022574463, 1839030562, -35309556, -1530992060, 1272893353, -155497632, -1094730640, 681279174, -358537222, -722521979, 76029189, -640364487, -421815835, 530742520, -995338651, -198630844, 1126891415, -1416354905, -57434055, 1700485571, -1894986606, -1051523, -2054922799, 1873313359, -30611744, -1560198380, 1309151649, -145523070, -1120210379, 718787259, -343485551]); function hash(data, offset, length) { let h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878; const paddedLength = length + 72 & ~63; const padded = new Uint8Array(paddedLength); let i, j; for (i = 0; i < length; ++i) { padded[i] = data[offset++]; } padded[i++] = 0x80; const n = paddedLength - 8; while (i < n) { padded[i++] = 0; } padded[i++] = length << 3 & 0xff; padded[i++] = length >> 5 & 0xff; padded[i++] = length >> 13 & 0xff; padded[i++] = length >> 21 & 0xff; padded[i++] = length >>> 29 & 0xff; padded[i++] = 0; padded[i++] = 0; padded[i++] = 0; const w = new Int32Array(16); for (i = 0; i < paddedLength;) { for (j = 0; j < 16; ++j, i += 4) { w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24; } let a = h0, b = h1, c = h2, d = h3, f, g; for (j = 0; j < 64; ++j) { if (j < 16) { f = b & c | ~b & d; g = j; } else if (j < 32) { f = d & b | ~d & c; g = 5 * j + 1 & 15; } else if (j < 48) { f = b ^ c ^ d; g = 3 * j + 5 & 15; } else { f = c ^ (b | ~d); g = 7 * j & 15; } const tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j]; d = c; c = b; b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0; a = tmp; } h0 = h0 + a | 0; h1 = h1 + b | 0; h2 = h2 + c | 0; h3 = h3 + d | 0; } return new Uint8Array([h0 & 0xFF, h0 >> 8 & 0xFF, h0 >> 16 & 0xFF, h0 >>> 24 & 0xFF, h1 & 0xFF, h1 >> 8 & 0xFF, h1 >> 16 & 0xFF, h1 >>> 24 & 0xFF, h2 & 0xFF, h2 >> 8 & 0xFF, h2 >> 16 & 0xFF, h2 >>> 24 & 0xFF, h3 & 0xFF, h3 >> 8 & 0xFF, h3 >> 16 & 0xFF, h3 >>> 24 & 0xFF]); } return hash; }(); class Word64 { constructor(highInteger, lowInteger) { this.high = highInteger | 0; this.low = lowInteger | 0; } and(word) { this.high &= word.high; this.low &= word.low; } xor(word) { this.high ^= word.high; this.low ^= word.low; } or(word) { this.high |= word.high; this.low |= word.low; } shiftRight(places) { if (places >= 32) { this.low = this.high >>> places - 32 | 0; this.high = 0; } else { this.low = this.low >>> places | this.high << 32 - places; this.high = this.high >>> places | 0; } } shiftLeft(places) { if (places >= 32) { this.high = this.low << places - 32; this.low = 0; } else { this.high = this.high << places | this.low >>> 32 - places; this.low <<= places; } } rotateRight(places) { let low, high; if (places & 32) { high = this.low; low = this.high; } else { low = this.low; high = this.high; } places &= 31; this.low = low >>> places | high << 32 - places; this.high = high >>> places | low << 32 - places; } not() { this.high = ~this.high; this.low = ~this.low; } add(word) { const lowAdd = (this.low >>> 0) + (word.low >>> 0); let highAdd = (this.high >>> 0) + (word.high >>> 0); if (lowAdd > 0xffffffff) { highAdd += 1; } this.low = lowAdd | 0; this.high = highAdd | 0; } copyTo(bytes, offset) { bytes[offset] = this.high >>> 24 & 0xff; bytes[offset + 1] = this.high >> 16 & 0xff; bytes[offset + 2] = this.high >> 8 & 0xff; bytes[offset + 3] = this.high & 0xff; bytes[offset + 4] = this.low >>> 24 & 0xff; bytes[offset + 5] = this.low >> 16 & 0xff; bytes[offset + 6] = this.low >> 8 & 0xff; bytes[offset + 7] = this.low & 0xff; } assign(word) { this.high = word.high; this.low = word.low; } } const calculateSHA256 = function calculateSHA256Closure() { function rotr(x, n) { return x >>> n | x << 32 - n; } function ch(x, y, z) { return x & y ^ ~x & z; } function maj(x, y, z) { return x & y ^ x & z ^ y & z; } function sigma(x) { return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22); } function sigmaPrime(x) { return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25); } function littleSigma(x) { return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3; } function littleSigmaPrime(x) { return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10; } const k = [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2]; function hash(data, offset, length) { let h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19; const paddedLength = Math.ceil((length + 9) / 64) * 64; const padded = new Uint8Array(paddedLength); let i, j; for (i = 0; i < length; ++i) { padded[i] = data[offset++]; } padded[i++] = 0x80; const n = paddedLength - 8; while (i < n) { padded[i++] = 0; } padded[i++] = 0; padded[i++] = 0; padded[i++] = 0; padded[i++] = length >>> 29 & 0xff; padded[i++] = length >> 21 & 0xff; padded[i++] = length >> 13 & 0xff; padded[i++] = length >> 5 & 0xff; padded[i++] = length << 3 & 0xff; const w = new Uint32Array(64); for (i = 0; i < paddedLength;) { for (j = 0; j < 16; ++j) { w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3]; i += 4; } for (j = 16; j < 64; ++j) { w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0; } let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2; for (j = 0; j < 64; ++j) { t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j]; t2 = sigma(a) + maj(a, b, c); h = g; g = f; f = e; e = d + t1 | 0; d = c; c = b; b = a; a = t1 + t2 | 0; } h0 = h0 + a | 0; h1 = h1 + b | 0; h2 = h2 + c | 0; h3 = h3 + d | 0; h4 = h4 + e | 0; h5 = h5 + f | 0; h6 = h6 + g | 0; h7 = h7 + h | 0; } return new Uint8Array([h0 >> 24 & 0xFF, h0 >> 16 & 0xFF, h0 >> 8 & 0xFF, h0 & 0xFF, h1 >> 24 & 0xFF, h1 >> 16 & 0xFF, h1 >> 8 & 0xFF, h1 & 0xFF, h2 >> 24 & 0xFF, h2 >> 16 & 0xFF, h2 >> 8 & 0xFF, h2 & 0xFF, h3 >> 24 & 0xFF, h3 >> 16 & 0xFF, h3 >> 8 & 0xFF, h3 & 0xFF, h4 >> 24 & 0xFF, h4 >> 16 & 0xFF, h4 >> 8 & 0xFF, h4 & 0xFF, h5 >> 24 & 0xFF, h5 >> 16 & 0xFF, h5 >> 8 & 0xFF, h5 & 0xFF, h6 >> 24 & 0xFF, h6 >> 16 & 0xFF, h6 >> 8 & 0xFF, h6 & 0xFF, h7 >> 24 & 0xFF, h7 >> 16 & 0xFF, h7 >> 8 & 0xFF, h7 & 0xFF]); } return hash; }(); const calculateSHA512 = function calculateSHA512Closure() { function ch(result, x, y, z, tmp) { result.assign(x); result.and(y); tmp.assign(x); tmp.not(); tmp.and(z); result.xor(tmp); } function maj(result, x, y, z, tmp) { result.assign(x); result.and(y); tmp.assign(x); tmp.and(z); result.xor(tmp); tmp.assign(y); tmp.and(z); result.xor(tmp); } function sigma(result, x, tmp) { result.assign(x); result.rotateRight(28); tmp.assign(x); tmp.rotateRight(34); result.xor(tmp); tmp.assign(x); tmp.rotateRight(39); result.xor(tmp); } function sigmaPrime(result, x, tmp) { result.assign(x); result.rotateRight(14); tmp.assign(x); tmp.rotateRight(18); result.xor(tmp); tmp.assign(x); tmp.rotateRight(41); result.xor(tmp); } function littleSigma(result, x, tmp) { result.assign(x); result.rotateRight(1); tmp.assign(x); tmp.rotateRight(8); result.xor(tmp); tmp.assign(x); tmp.shiftRight(7); result.xor(tmp); } function littleSigmaPrime(result, x, tmp) { result.assign(x); result.rotateRight(19); tmp.assign(x); tmp.rotateRight(61); result.xor(tmp); tmp.assign(x); tmp.shiftRight(6); result.xor(tmp); } const k = [new Word64(0x428a2f98, 0xd728ae22), new Word64(0x71374491, 0x23ef65cd), new Word64(0xb5c0fbcf, 0xec4d3b2f), new Word64(0xe9b5dba5, 0x8189dbbc), new Word64(0x3956c25b, 0xf348b538), new Word64(0x59f111f1, 0xb605d019), new Word64(0x923f82a4, 0xaf194f9b), new Word64(0xab1c5ed5, 0xda6d8118), new Word64(0xd807aa98, 0xa3030242), new Word64(0x12835b01, 0x45706fbe), new Word64(0x243185be, 0x4ee4b28c), new Word64(0x550c7dc3, 0xd5ffb4e2), new Word64(0x72be5d74, 0xf27b896f), new Word64(0x80deb1fe, 0x3b1696b1), new Word64(0x9bdc06a7, 0x25c71235), new Word64(0xc19bf174, 0xcf692694), new Word64(0xe49b69c1, 0x9ef14ad2), new Word64(0xefbe4786, 0x384f25e3), new Word64(0x0fc19dc6, 0x8b8cd5b5), new Word64(0x240ca1cc, 0x77ac9c65), new Word64(0x2de92c6f, 0x592b0275), new Word64(0x4a7484aa, 0x6ea6e483), new Word64(0x5cb0a9dc, 0xbd41fbd4), new Word64(0x76f988da, 0x831153b5), new Word64(0x983e5152, 0xee66dfab), new Word64(0xa831c66d, 0x2db43210), new Word64(0xb00327c8, 0x98fb213f), new Word64(0xbf597fc7, 0xbeef0ee4), new Word64(0xc6e00bf3, 0x3da88fc2), new Word64(0xd5a79147, 0x930aa725), new Word64(0x06ca6351, 0xe003826f), new Word64(0x14292967, 0x0a0e6e70), new Word64(0x27b70a85, 0x46d22ffc), new Word64(0x2e1b2138, 0x5c26c926), new Word64(0x4d2c6dfc, 0x5ac42aed), new Word64(0x53380d13, 0x9d95b3df), new Word64(0x650a7354, 0x8baf63de), new Word64(0x766a0abb, 0x3c77b2a8), new Word64(0x81c2c92e, 0x47edaee6), new Word64(0x92722c85, 0x1482353b), new Word64(0xa2bfe8a1, 0x4cf10364), new Word64(0xa81a664b, 0xbc423001), new Word64(0xc24b8b70, 0xd0f89791), new Word64(0xc76c51a3, 0x0654be30), new Word64(0xd192e819, 0xd6ef5218), new Word64(0xd6990624, 0x5565a910), new Word64(0xf40e3585, 0x5771202a), new Word64(0x106aa070, 0x32bbd1b8), new Word64(0x19a4c116, 0xb8d2d0c8), new Word64(0x1e376c08, 0x5141ab53), new Word64(0x2748774c, 0xdf8eeb99), new Word64(0x34b0bcb5, 0xe19b48a8), new Word64(0x391c0cb3, 0xc5c95a63), new Word64(0x4ed8aa4a, 0xe3418acb), new Word64(0x5b9cca4f, 0x7763e373), new Word64(0x682e6ff3, 0xd6b2b8a3), new Word64(0x748f82ee, 0x5defb2fc), new Word64(0x78a5636f, 0x43172f60), new Word64(0x84c87814, 0xa1f0ab72), new Word64(0x8cc70208, 0x1a6439ec), new Word64(0x90befffa, 0x23631e28), new Word64(0xa4506ceb, 0xde82bde9), new Word64(0xbef9a3f7, 0xb2c67915), new Word64(0xc67178f2, 0xe372532b), new Word64(0xca273ece, 0xea26619c), new Word64(0xd186b8c7, 0x21c0c207), new Word64(0xeada7dd6, 0xcde0eb1e), new Word64(0xf57d4f7f, 0xee6ed178), new Word64(0x06f067aa, 0x72176fba), new Word64(0x0a637dc5, 0xa2c898a6), new Word64(0x113f9804, 0xbef90dae), new Word64(0x1b710b35, 0x131c471b), new Word64(0x28db77f5, 0x23047d84), new Word64(0x32caab7b, 0x40c72493), new Word64(0x3c9ebe0a, 0x15c9bebc), new Word64(0x431d67c4, 0x9c100d4c), new Word64(0x4cc5d4be, 0xcb3e42b6), new Word64(0x597f299c, 0xfc657e2a), new Word64(0x5fcb6fab, 0x3ad6faec), new Word64(0x6c44198c, 0x4a475817)]; function hash(data, offset, length, mode384 = false) { let h0, h1, h2, h3, h4, h5, h6, h7; if (!mode384) { h0 = new Word64(0x6a09e667, 0xf3bcc908); h1 = new Word64(0xbb67ae85, 0x84caa73b); h2 = new Word64(0x3c6ef372, 0xfe94f82b); h3 = new Word64(0xa54ff53a, 0x5f1d36f1); h4 = new Word64(0x510e527f, 0xade682d1); h5 = new Word64(0x9b05688c, 0x2b3e6c1f); h6 = new Word64(0x1f83d9ab, 0xfb41bd6b); h7 = new Word64(0x5be0cd19, 0x137e2179); } else { h0 = new Word64(0xcbbb9d5d, 0xc1059ed8); h1 = new Word64(0x629a292a, 0x367cd507); h2 = new Word64(0x9159015a, 0x3070dd17); h3 = new Word64(0x152fecd8, 0xf70e5939); h4 = new Word64(0x67332667, 0xffc00b31); h5 = new Word64(0x8eb44a87, 0x68581511); h6 = new Word64(0xdb0c2e0d, 0x64f98fa7); h7 = new Word64(0x47b5481d, 0xbefa4fa4); } const paddedLength = Math.ceil((length + 17) / 128) * 128; const padded = new Uint8Array(paddedLength); let i, j; for (i = 0; i < length; ++i) { padded[i] = data[offset++]; } padded[i++] = 0x80; const n = paddedLength - 16; while (i < n) { padded[i++] = 0; } padded[i++] = 0; padded[i++] = 0; padded[i++] = 0; padded[i++] = 0; padded[i++] = 0; padded[i++] = 0; padded[i++] = 0; padded[i++] = 0; padded[i++] = 0; padded[i++] = 0; padded[i++] = 0; padded[i++] = length >>> 29 & 0xff; padded[i++] = length >> 21 & 0xff; padded[i++] = length >> 13 & 0xff; padded[i++] = length >> 5 & 0xff; padded[i++] = length << 3 & 0xff; const w = new Array(80); for (i = 0; i < 80; i++) { w[i] = new Word64(0, 0); } let a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0); let d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0); let g = new Word64(0, 0), h = new Word64(0, 0); const t1 = new Word64(0, 0), t2 = new Word64(0, 0); const tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0); let tmp3; for (i = 0; i < paddedLength;) { for (j = 0; j < 16; ++j) { w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3]; w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7]; i += 8; } for (j = 16; j < 80; ++j) { tmp3 = w[j]; littleSigmaPrime(tmp3, w[j - 2], tmp2); tmp3.add(w[j - 7]); littleSigma(tmp1, w[j - 15], tmp2); tmp3.add(tmp1); tmp3.add(w[j - 16]); } a.assign(h0); b.assign(h1); c.assign(h2); d.assign(h3); e.assign(h4); f.assign(h5); g.assign(h6); h.assign(h7); for (j = 0; j < 80; ++j) { t1.assign(h); sigmaPrime(tmp1, e, tmp2); t1.add(tmp1); ch(tmp1, e, f, g, tmp2); t1.add(tmp1); t1.add(k[j]); t1.add(w[j]); sigma(t2, a, tmp2); maj(tmp1, a, b, c, tmp2); t2.add(tmp1); tmp3 = h; h = g; g = f; f = e; d.add(t1);
•
Search:
•
Replace:
1
2
3
4
5
6
7
Function
Edit by line
Download
Information
Rename
Copy
Move
Delete
Chmod
List