UNPKG

pdf-parse-test

Version:

Pure TypeScript, cross-platform module for extracting text, images, and tabular data from PDFs. Run directly in your browser or in Node!

1 lines 1.78 MB
{"version":3,"file":"index.cjs","sources":["../../src/geometry/Shape.ts","../../src/geometry/Point.ts","../../src/geometry/Line.ts","../../src/geometry/TableData.ts","../../src/geometry/Table.ts","../../src/geometry/LineStore.ts","../../src/geometry/Rectangle.ts","../../src/HeaderResult.ts","../../src/ImageResult.ts","../../node_modules/pdfjs-dist/legacy/build/pdf.mjs","../../src/InfoResult.ts","../../src/ParseParameters.ts","../../src/PathGeometry.ts","../../src/ScreenshotResult.ts","../../src/TableResult.ts","../../src/TextResult.ts","../../src/PDFParse.ts"],"sourcesContent":["export abstract class Shape {\n\tstatic tolerance = 2;\n\tpublic abstract transform(matrix: Array<number>): this;\n\n\tstatic applyTransform(p: Array<number>, m: Array<number>): Array<number> {\n\t\tconst xt = p[0] * m[0] + p[1] * m[2] + m[4];\n\t\tconst yt = p[0] * m[1] + p[1] * m[3] + m[5];\n\t\treturn [xt, yt];\n\t}\n}\n","import { Shape } from './Shape.js';\n\nexport class Point extends Shape {\n\tpublic x: number;\n\tpublic y: number;\n\n\tconstructor(x: number, y: number) {\n\t\tsuper();\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t}\n\n\tpublic equal(point: Point): boolean {\n\t\treturn point.x === this.x && point.y === this.y;\n\t}\n\n\tpublic transform(matrix: Array<number>): this {\n\t\tconst p = Shape.applyTransform([this.x, this.y], matrix);\n\t\tthis.x = p[0];\n\t\tthis.y = p[1];\n\t\treturn this;\n\t}\n}\n","import { Point } from './Point.js';\nimport { Shape } from './Shape.js';\n\nexport enum LineDirection {\n\tNone = 0,\n\tHorizontal = 1,\n\tVertical,\n}\n\nexport class Line extends Shape {\n\tpublic from: Point;\n\tpublic to: Point;\n\tpublic direction: LineDirection = LineDirection.None;\n\tpublic length: number = 0;\n\tpublic intersections: Array<Point> = [];\n\tpublic gaps: Array<Line> = [];\n\n\tconstructor(from: Point, to: Point) {\n\t\tsuper();\n\t\tthis.from = from;\n\t\tthis.to = to;\n\t\tthis.init();\n\t}\n\n\tprivate init(): void {\n\t\tlet from = this.from;\n\t\tlet to = this.to;\n\n\t\tif (Math.abs(from.y - to.y) < Shape.tolerance) {\n\t\t\tthis.direction = LineDirection.Horizontal;\n\t\t\tto.y = from.y;\n\t\t\tif (from.x > to.x) {\n\t\t\t\tconst temp = from;\n\t\t\t\tfrom = to;\n\t\t\t\tto = temp;\n\t\t\t}\n\t\t\tthis.length = to.x - from.x;\n\t\t} else if (Math.abs(from.x - to.x) < Shape.tolerance) {\n\t\t\tthis.direction = LineDirection.Vertical;\n\t\t\tto.x = from.x;\n\t\t\tif (from.y > to.y) {\n\t\t\t\tconst temp = from;\n\t\t\t\tfrom = to;\n\t\t\t\tto = temp;\n\t\t\t}\n\t\t\tthis.length = to.y - from.y;\n\t\t}\n\n\t\tthis.from = from;\n\t\tthis.to = to;\n\t}\n\n\tprivate _valid: boolean | undefined = undefined;\n\n\tget valid(): boolean {\n\t\tif (this._valid === undefined) {\n\t\t\tthis._valid = this.direction !== LineDirection.None && this.length > Shape.tolerance;\n\t\t}\n\t\treturn this._valid;\n\t}\n\n\tget normalized(): Line {\n\t\tif (this.direction === LineDirection.Horizontal) {\n\t\t\treturn new Line(new Point(this.from.x - Shape.tolerance, this.from.y), new Point(this.to.x + Shape.tolerance, this.from.y));\n\t\t} else if (this.direction === LineDirection.Vertical) {\n\t\t\treturn new Line(new Point(this.from.x, this.from.y - Shape.tolerance), new Point(this.from.x, this.to.y + Shape.tolerance));\n\t\t}\n\t\treturn this;\n\t}\n\n\tpublic addGap(line: Line): void {\n\t\tthis.gaps.push(line);\n\t}\n\n\tpublic containsPoint(p: Point): boolean {\n\t\tif (this.direction === LineDirection.Vertical) {\n\t\t\treturn this.from.x === p.x && p.y >= this.from.y && p.y <= this.to.y;\n\t\t} else if (this.direction === LineDirection.Horizontal) {\n\t\t\treturn this.from.y === p.y && p.x >= this.from.x && p.x <= this.to.x;\n\t\t}\n\t\treturn false;\n\t}\n\n\t// // todo implement\n\t// public containsLine(l:Line):boolean{\n\t// if(this.direction === LineDirection.Vertical && l.direction === LineDirection.Vertical){\n\t// return this.from.x === l.from.x\n\t// }\n\t// else if(this.direction === LineDirection.Horizontal && l.direction === LineDirection.Horizontal){\n\t// return this.from.y === l.from.y\n\t// }\n\t// return false\n\t// }\n\n\tpublic addIntersectionPoint(point: Point): void {\n\t\tfor (const intPoint of this.intersections) {\n\t\t\tif (intPoint.equal(point)) return;\n\t\t}\n\t\tthis.intersections.push(point);\n\t}\n\n\tpublic intersection(line: Line): Point | undefined {\n\t\tlet result: Point | undefined;\n\n\t\tif (!this.valid || !line.valid) {\n\t\t\treturn result;\n\t\t}\n\n\t\tconst thisNormalized = this.normalized;\n\t\tconst lineNormalized = line.normalized;\n\n\t\tif (this.direction === LineDirection.Horizontal && line.direction === LineDirection.Vertical) {\n\t\t\tconst x = lineNormalized.from.x;\n\t\t\tconst y = thisNormalized.from.y;\n\t\t\tconst isOk = x > thisNormalized.from.x && x < thisNormalized.to.x && y > lineNormalized.from.y && y < lineNormalized.to.y;\n\n\t\t\tif (isOk) {\n\t\t\t\tconst intPoint = new Point(x, y);\n\t\t\t\tthis.addIntersectionPoint(intPoint);\n\t\t\t\tline.addIntersectionPoint(intPoint);\n\t\t\t\tresult = intPoint;\n\t\t\t}\n\t\t} else if (this.direction === LineDirection.Vertical && line.direction === LineDirection.Horizontal) {\n\t\t\tconst x = thisNormalized.from.x;\n\t\t\tconst y = lineNormalized.from.y;\n\t\t\tconst isOk = x > lineNormalized.from.x && x < lineNormalized.to.x && y > thisNormalized.from.y && y < thisNormalized.to.y;\n\n\t\t\tif (isOk) {\n\t\t\t\tconst intPoint = new Point(x, y);\n\t\t\t\tthis.addIntersectionPoint(intPoint);\n\t\t\t\tline.addIntersectionPoint(intPoint);\n\t\t\t\tresult = intPoint;\n\t\t\t}\n\t\t}\n\n\t\t// if(result){\n\t\t// for (const gapLine of this.gaps) {\n\t\t// if(gapLine.containsPoint(result)) return undefined\n\t\t// }\n\t\t//\n\t\t// for (const gapLine of line.gaps) {\n\t\t// if(gapLine.containsPoint(result)) return undefined\n\t\t// }\n\t\t// }\n\n\t\treturn result;\n\t}\n\n\tpublic transform(matrix: Array<number>): this {\n\t\tconst p1 = this.from.transform(matrix);\n\t\tconst p2 = this.to.transform(matrix);\n\n\t\tconst x = Math.min(p1.x, p2.x);\n\t\tconst y = Math.min(p1.y, p2.y);\n\n\t\tconst width = Math.abs(p1.x - p2.x);\n\t\tconst height = Math.abs(p1.y - p2.y);\n\n\t\tthis.from = new Point(x, y);\n\t\tthis.to = new Point(x + width, y + height);\n\t\tthis.init();\n\t\treturn this;\n\t}\n}\n","import type { Point } from './Point.js';\n\nexport type TableCell = {\n\tminXY: Point;\n\tmaxXY: Point;\n\twidth: number;\n\theight: number;\n\tcolspan?: number;\n\trowspan?: number;\n\ttext: Array<string>;\n};\n\nexport type TableRow = Array<TableCell>;\n\nexport class TableData {\n\tpublic minXY: Point;\n\tpublic maxXY: Point;\n\tpublic rows: Array<TableRow>;\n\tprivate rowPivots: Array<number>;\n\tprivate colPivots: Array<number>;\n\n\tconstructor(minXY: Point, maxXY: Point, rowPivots: Array<number>, colPivots: Array<number>) {\n\t\tthis.minXY = minXY;\n\t\tthis.maxXY = maxXY;\n\t\tthis.rows = [];\n\t\tthis.rowPivots = rowPivots;\n\t\tthis.colPivots = colPivots;\n\t}\n\n\tpublic findCell(x: number, y: number): TableCell | undefined {\n\t\tif (x >= this.minXY.x && y >= this.minXY.y && x <= this.maxXY.x && y <= this.maxXY.y) {\n\t\t\tfor (const row of this.rows) {\n\t\t\t\tfor (const cell of row) {\n\t\t\t\t\tif (cell.minXY.x <= x && cell.minXY.y <= y && cell.maxXY.x >= x && cell.maxXY.y >= y) {\n\t\t\t\t\t\treturn cell;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic get cellCount() {\n\t\treturn this.rows.reduce((acc, row) => acc + row.length, 0);\n\t}\n\n\tpublic get rowCount() {\n\t\treturn this.rows.length;\n\t}\n\n\tpublic check(): boolean {\n\t\t// const cellCounts:Array<number> = []\n\t\t//\n\t\t// for (const row of this.rows) {\n\t\t// let cellNum = 0\n\t\t// for (const cell of row) {\n\t\t// cellNum += cell.colspan || 1\n\t\t// }\n\t\t// cellCounts.push(cellNum)\n\t\t// }\n\t\t//\n\t\t// for (let i = 1; i < cellCounts.length; i++) {\n\t\t// if (cellCounts[i] !== cellCounts[i - 1]) {\n\t\t// return false\n\t\t// }\n\t\t// }\n\n\t\tconst virtualCellCount = (this.colPivots.length - 1) * (this.rowPivots.length - 1);\n\t\tlet allCellCount = 0;\n\n\t\tfor (const row of this.rows) {\n\t\t\tfor (const cell of row) {\n\t\t\t\tconst count = (cell.colspan || 1) * (cell.rowspan || 1);\n\t\t\t\tallCellCount += count;\n\t\t\t}\n\t\t}\n\n\t\tif (virtualCellCount !== allCellCount) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic toArray(): string[][] {\n\t\tconst tableArr: string[][] = [];\n\t\tfor (const row of this.rows) {\n\t\t\tconst rowArr: string[] = [];\n\t\t\tfor (const cell of row) {\n\t\t\t\tlet text = cell.text.join('');\n\t\t\t\ttext = text.replace(/^[\\s]+|[\\s]+$/g, '');\n\t\t\t\ttext = text.trim();\n\t\t\t\trowArr.push(text);\n\t\t\t}\n\t\t\ttableArr.push(rowArr);\n\t\t}\n\t\treturn tableArr;\n\t}\n}\n","import { Line, LineDirection } from './Line.js';\nimport { Point } from './Point.js';\nimport { Shape } from './Shape.js';\nimport { type TableCell, TableData, type TableRow } from './TableData.js';\n\nexport class Table {\n\tpublic hLines: Array<Line> = [];\n\tpublic vLines: Array<Line> = [];\n\n\tconstructor(line: Line) {\n\t\tif (line.direction === LineDirection.Horizontal) {\n\t\t\tthis.hLines.push(line);\n\t\t} else if (line.direction === LineDirection.Vertical) {\n\t\t\tthis.vLines.push(line);\n\t\t}\n\t}\n\n\tpublic get isValid(): boolean {\n\t\treturn this.hLines.length + this.vLines.length > 4;\n\t}\n\n\tpublic get rowPivots(): Array<number> {\n\t\tconst rowSet: Set<number> = new Set();\n\n\t\tfor (const line of this.hLines) {\n\t\t\trowSet.add(line.from.y);\n\t\t}\n\n\t\treturn [...rowSet].sort((a, b) => a - b);\n\t}\n\n\tpublic get colPivots(): Array<number> {\n\t\tconst colSet: Set<number> = new Set();\n\n\t\tfor (const line of this.vLines) {\n\t\t\tcolSet.add(line.from.x);\n\t\t}\n\n\t\treturn [...colSet].sort((a, b) => a - b);\n\t}\n\n\tpublic add(line: Line): boolean {\n\t\tconst hasIntersection = this.intersection(line);\n\n\t\tif (hasIntersection) {\n\t\t\tif (line.direction === LineDirection.Horizontal) {\n\t\t\t\tthis.hLines.push(line);\n\t\t\t\treturn true;\n\t\t\t} else if (line.direction === LineDirection.Vertical) {\n\t\t\t\tthis.vLines.push(line);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprivate intersection(line: Line): boolean {\n\t\tlet flag = false;\n\t\tif (!line.valid) return flag;\n\n\t\tif (line.direction === LineDirection.Horizontal) {\n\t\t\tfor (const vLine of this.vLines) {\n\t\t\t\tconst p = line.intersection(vLine);\n\t\t\t\tif (p) {\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (line.direction === LineDirection.Vertical) {\n\t\t\tfor (const hLine of this.hLines) {\n\t\t\t\tconst p = line.intersection(hLine);\n\t\t\t\tif (p) {\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn flag;\n\t}\n\n\tprivate getSameHorizontal(line: Line): Array<Line> {\n\t\tconst same: Array<Line> = [line];\n\t\tconst other: Array<Line> = [];\n\n\t\twhile (this.hLines.length > 0) {\n\t\t\tconst hLine = this.hLines.shift();\n\t\t\tif (!hLine) continue;\n\n\t\t\tif (hLine.from.y === line.from.y) {\n\t\t\t\tsame.push(hLine);\n\t\t\t} else {\n\t\t\t\tother.push(hLine);\n\t\t\t}\n\t\t}\n\n\t\tthis.hLines = other;\n\t\treturn same;\n\t}\n\n\tprivate getSameVertical(line: Line): Array<Line> {\n\t\tconst same: Array<Line> = [line];\n\t\tconst other: Array<Line> = [];\n\n\t\twhile (this.vLines.length > 0) {\n\t\t\tconst vLine = this.vLines.shift();\n\t\t\tif (!vLine) continue;\n\n\t\t\tif (vLine.from.x === line.from.x) {\n\t\t\t\tsame.push(vLine);\n\t\t\t} else {\n\t\t\t\tother.push(vLine);\n\t\t\t}\n\t\t}\n\n\t\tthis.vLines = other;\n\t\treturn same;\n\t}\n\n\tprivate mergeHorizontalLines(lines: Array<Line>): Line {\n\t\tlines.sort((l1, l2) => l1.from.x - l2.from.x);\n\n\t\tconst minX = lines[0].from.x;\n\t\tconst maxX = lines[lines.length - 1].to.x;\n\n\t\tconst resultLine = new Line(new Point(minX, lines[0].from.y), new Point(maxX, lines[0].from.y));\n\n\t\tfor (let i = 1; i < lines.length; i++) {\n\t\t\tconst prevLine = lines[i - 1];\n\t\t\tconst currLine = lines[i];\n\n\t\t\tif (Math.abs(prevLine.to.x - currLine.from.x) > Shape.tolerance) {\n\t\t\t\tconst gapLine = new Line(new Point(prevLine.to.x, prevLine.from.y), new Point(currLine.from.x, currLine.from.y));\n\t\t\t\tresultLine.addGap(gapLine);\n\t\t\t}\n\t\t}\n\n\t\treturn resultLine;\n\t}\n\n\tprivate mergeVerticalLines(lines: Array<Line>): Line {\n\t\tlines.sort((l1, l2) => l1.from.y - l2.from.y);\n\n\t\tconst minY = lines[0].from.y;\n\t\tconst maxY = lines[lines.length - 1].to.y;\n\n\t\tconst resultLine = new Line(new Point(lines[0].from.x, minY), new Point(lines[0].from.x, maxY));\n\n\t\tfor (let i = 1; i < lines.length; i++) {\n\t\t\tconst prevLine = lines[i - 1];\n\t\t\tconst currLine = lines[i];\n\n\t\t\tif (Math.abs(prevLine.to.y - currLine.from.y) > Shape.tolerance) {\n\t\t\t\tconst gapLine = new Line(new Point(prevLine.to.x, prevLine.to.y), new Point(prevLine.to.x, currLine.from.y));\n\t\t\t\tresultLine.addGap(gapLine);\n\t\t\t}\n\t\t}\n\n\t\treturn resultLine;\n\t}\n\n\tpublic normalize(): void {\n\t\tthis.hLines = this.hLines.filter((l) => l.intersections.length > 1);\n\t\tthis.vLines = this.vLines.filter((l) => l.intersections.length > 1);\n\n\t\tthis.hLines.sort((l1, l2) => l1.from.y - l2.from.y);\n\t\tthis.vLines.sort((l1, l2) => l1.from.x - l2.from.x);\n\n\t\tconst newHLines: Array<Line> = [];\n\n\t\twhile (this.hLines.length > 0) {\n\t\t\tconst line = this.hLines.shift();\n\t\t\tif (!line) continue;\n\n\t\t\tconst lines = this.getSameHorizontal(line);\n\t\t\tconst merged = this.mergeHorizontalLines(lines);\n\t\t\tnewHLines.push(merged);\n\t\t}\n\n\t\tthis.hLines = newHLines;\n\n\t\tconst newVLines: Array<Line> = [];\n\n\t\twhile (this.vLines.length > 0) {\n\t\t\tconst line = this.vLines.shift();\n\t\t\tif (!line) continue;\n\n\t\t\tconst lines = this.getSameVertical(line);\n\t\t\tconst merged = this.mergeVerticalLines(lines);\n\t\t\tnewVLines.push(merged);\n\t\t}\n\n\t\tthis.vLines = newVLines;\n\t}\n\n\tpublic verticalExists(line: Line, y1: number, y2: number): boolean {\n\t\tif (line.direction !== LineDirection.Vertical) {\n\t\t\tthrow new Error('Line is not vertical');\n\t\t}\n\n\t\tif (y1 >= y2) {\n\t\t\tthrow new Error('y1 must be less than y2');\n\t\t}\n\n\t\tif (line.from.y <= y1 && line.to.y >= y2) {\n\t\t\tfor (const gap of line.gaps) {\n\t\t\t\tif (gap.from.y <= y1 && gap.to.y >= y2) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tpublic horizontalExists(line: Line, x1: number, x2: number): boolean {\n\t\tif (line.direction !== LineDirection.Horizontal) {\n\t\t\tthrow new Error('Line is not horizontal');\n\t\t}\n\n\t\tif (x1 >= x2) {\n\t\t\tthrow new Error('x1 must be less than x2');\n\t\t}\n\n\t\tif (line.from.x <= x1 && line.to.x >= x2) {\n\t\t\tfor (const gap of line.gaps) {\n\t\t\t\tif (gap.from.x <= x1 && gap.to.x >= x2) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprivate findBottomLineIndex(h2Index: number, xMiddle: number): number {\n\t\tfor (let i = h2Index; i < this.hLines.length; i++) {\n\t\t\tconst hLine = this.hLines[i];\n\t\t\tif (hLine.from.x <= xMiddle && hLine.to.x >= xMiddle) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}\n\n\tprivate findVerticalLineIndexs(topHLine: Line, yMiddle: number): Array<number> {\n\t\tconst result: Array<number> = [];\n\n\t\tfor (let i = 0; i < this.vLines.length; i++) {\n\t\t\tconst vLine = this.vLines[i];\n\t\t\tif (vLine.from.y <= yMiddle && vLine.to.y >= yMiddle && topHLine.intersection(vLine)) {\n\t\t\t\tresult.push(i);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprivate getRow(h1Index: number, h2Index: number, yMiddle: number): TableRow {\n\t\tconst tableRow: TableRow = [];\n\t\t//const colCount = this.vLines.length -1\n\t\tconst topHLine = this.hLines[h1Index];\n\t\tconst vLineIndexes = this.findVerticalLineIndexs(topHLine, yMiddle);\n\n\t\tfor (let i = 1; i < vLineIndexes.length; i++) {\n\t\t\tconst leftVLine = this.vLines[vLineIndexes[i - 1]];\n\t\t\tconst rightVLine = this.vLines[vLineIndexes[i]];\n\t\t\tconst xMiddle = (leftVLine.from.x + rightVLine.from.x) / 2;\n\t\t\tconst bottomHLineIndex = this.findBottomLineIndex(h2Index, xMiddle);\n\t\t\tconst bottomHLine = this.hLines[bottomHLineIndex];\n\t\t\t// minXY: {x:leftVLine.from.x,y:topHLine.from.y},\n\t\t\t// maxXY: {x:rightVLine.from.x,y:bottomHLine.from.y},\n\t\t\tconst tableCell: TableCell = {\n\t\t\t\tminXY: new Point(leftVLine.from.x, topHLine.from.y),\n\t\t\t\tmaxXY: new Point(rightVLine.from.x, bottomHLine.from.y),\n\t\t\t\twidth: rightVLine.from.x - leftVLine.from.x,\n\t\t\t\theight: bottomHLine.from.y - topHLine.from.y,\n\t\t\t\ttext: [],\n\t\t\t};\n\t\t\tconst colSpan = vLineIndexes[i] - vLineIndexes[i - 1];\n\t\t\tconst rowSpan = bottomHLineIndex - h1Index;\n\n\t\t\tif (colSpan > 1) {\n\t\t\t\ttableCell.colspan = colSpan;\n\t\t\t}\n\t\t\tif (rowSpan > 1) {\n\t\t\t\ttableCell.rowspan = rowSpan;\n\t\t\t}\n\n\t\t\ttableRow.push(tableCell);\n\t\t}\n\n\t\treturn tableRow;\n\t}\n\n\tpublic toData(): TableData {\n\t\tconst rowPivots = this.rowPivots;\n\t\tconst colPivots = this.colPivots;\n\n\t\tconst minXY = new Point(colPivots[0], rowPivots[0]);\n\t\tconst maxXY = new Point(colPivots[colPivots.length - 1], rowPivots[rowPivots.length - 1]);\n\n\t\tconst result: TableData = new TableData(minXY, maxXY, rowPivots, colPivots);\n\n\t\tfor (let h1 = 1; h1 < this.hLines.length; h1++) {\n\t\t\tconst prevHLine = this.hLines[h1 - 1];\n\t\t\tconst currHLine = this.hLines[h1];\n\t\t\tconst YMiddle = (prevHLine.from.y + currHLine.from.y) / 2;\n\t\t\tconst rowData = this.getRow(h1 - 1, h1, YMiddle);\n\t\t\tresult.rows.push(rowData);\n\t\t}\n\n\t\treturn result;\n\t}\n}\n","import { Line, LineDirection } from './Line.js';\nimport { Point } from './Point.js';\nimport type { Rectangle } from './Rectangle.js';\nimport { Shape } from './Shape.js';\nimport { Table } from './Table.js';\nimport type { TableData } from './TableData.js';\n\nexport class LineStore {\n\tpublic hLines: Array<Line> = [];\n\tpublic vLines: Array<Line> = [];\n\n\tpublic add(line: Line): void {\n\t\tif (line.valid) {\n\t\t\tif (line.direction === LineDirection.Horizontal) {\n\t\t\t\tthis.hLines.push(line);\n\t\t\t} else if (line.direction === LineDirection.Vertical) {\n\t\t\t\tthis.vLines.push(line);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic addRectangle(rect: Rectangle): void {\n\t\tfor (const line of rect.getLines()) {\n\t\t\tthis.add(line);\n\t\t}\n\t}\n\n\tpublic getTableData(): Array<TableData> {\n\t\tconst result: Array<TableData> = [];\n\n\t\tconst tables = this.getTables();\n\n\t\tfor (const table of tables) {\n\t\t\tconst data = table.toData();\n\t\t\tif (data) {\n\t\t\t\tresult.push(data);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tpublic getTables(): Array<Table> {\n\t\tconst result: Array<Table> = [];\n\n\t\twhile (this.hLines.length !== 0) {\n\t\t\tconst hLine = this.hLines.shift();\n\t\t\tif (!hLine) continue;\n\n\t\t\tconst filled = this.tryFill(result, hLine);\n\t\t\tif (filled) continue;\n\n\t\t\tconst table = new Table(hLine);\n\t\t\tthis.fillTable(table);\n\t\t\tresult.push(table);\n\t\t}\n\n\t\twhile (this.vLines.length !== 0) {\n\t\t\tconst vLine = this.vLines.shift();\n\t\t\tif (!vLine) continue;\n\n\t\t\tconst filled = this.tryFill(result, vLine);\n\t\t\tif (filled) continue;\n\n\t\t\tconst table = new Table(vLine);\n\t\t\tthis.fillTable(table);\n\t\t\tresult.push(table);\n\t\t}\n\n\t\tconst validTables = result.filter((t) => t.isValid);\n\n\t\tfor (const table of validTables) {\n\t\t\ttable.normalize();\n\t\t}\n\n\t\treturn validTables;\n\t}\n\n\tpublic normalize(): void {\n\t\tthis.normalizeHorizontal();\n\t\tthis.normalizeVertical();\n\t}\n\n\tpublic normalizeHorizontal() {\n\t\tthis.hLines.sort((l1, l2) => l1.from.y - l2.from.y);\n\n\t\tconst newLines: Array<Line> = [];\n\n\t\tlet sameY: Array<Line> = [];\n\t\tfor (const line of this.hLines) {\n\t\t\tif (sameY.length === 0) {\n\t\t\t\tsameY.push(line);\n\t\t\t} else if (Math.abs(sameY[0]?.from.y - line.from.y) < Shape.tolerance) {\n\t\t\t\tsameY.push(line);\n\t\t\t} else {\n\t\t\t\tconst merged = this.margeHorizontalLines(sameY);\n\t\t\t\tnewLines.push(...merged);\n\t\t\t\tsameY = [line];\n\t\t\t}\n\t\t}\n\n\t\tif (sameY.length > 0) {\n\t\t\tconst merged = this.margeHorizontalLines(sameY);\n\t\t\tnewLines.push(...merged);\n\t\t}\n\n\t\tthis.hLines = newLines;\n\t}\n\n\tpublic normalizeVertical() {\n\t\tthis.vLines.sort((l1, l2) => l1.from.x - l2.from.x);\n\n\t\tconst newLines: Array<Line> = [];\n\n\t\tlet sameX: Array<Line> = [];\n\t\tfor (const line of this.vLines) {\n\t\t\tif (sameX.length === 0) {\n\t\t\t\tsameX.push(line);\n\t\t\t} else if (Math.abs(sameX[0]?.from.x - line.from.x) < Shape.tolerance) {\n\t\t\t\tsameX.push(line);\n\t\t\t} else {\n\t\t\t\tconst merged = this.margeVerticalLines(sameX);\n\t\t\t\tnewLines.push(...merged);\n\t\t\t\tsameX = [line];\n\t\t\t}\n\t\t}\n\n\t\tif (sameX.length > 0) {\n\t\t\tconst merged = this.margeVerticalLines(sameX);\n\t\t\tnewLines.push(...merged);\n\t\t}\n\n\t\tthis.vLines = newLines;\n\t}\n\n\tprivate fillTable(table: Table): void {\n\t\tconst newVLines: Array<Line> = [];\n\t\tconst newHLines: Array<Line> = [];\n\n\t\tfor (const vLine of this.vLines) {\n\t\t\tif (!table.add(vLine)) {\n\t\t\t\tnewVLines.push(vLine);\n\t\t\t}\n\t\t}\n\n\t\tfor (const hLine of this.hLines) {\n\t\t\tif (!table.add(hLine)) {\n\t\t\t\tnewHLines.push(hLine);\n\t\t\t}\n\t\t}\n\n\t\tthis.hLines = newHLines;\n\t\tthis.vLines = newVLines;\n\t}\n\n\tprivate tryFill(tables: Array<Table>, line: Line): boolean {\n\t\tfor (const table of tables) {\n\t\t\tif (table.add(line)) {\n\t\t\t\tthis.fillTable(table);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate margeHorizontalLines(sameYLines: Array<Line>): Array<Line> {\n\t\tconst result: Array<Line> = [];\n\t\tsameYLines.sort((l1, l2) => l1.from.x - l2.from.x);\n\n\t\tconst sameY = sameYLines[0]?.from.y;\n\t\tif (sameY === undefined) return result;\n\n\t\tlet minX: number = Number.MAX_SAFE_INTEGER;\n\t\tlet maxX: number = Number.MIN_SAFE_INTEGER;\n\n\t\tfor (const line of sameYLines) {\n\t\t\tif (line.from.x - maxX < Shape.tolerance) {\n\t\t\t\tif (line.from.x < minX) {\n\t\t\t\t\tminX = line.from.x;\n\t\t\t\t}\n\t\t\t\tif (line.to.x > maxX) {\n\t\t\t\t\tmaxX = line.to.x;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (maxX > minX) {\n\t\t\t\t\tresult.push(new Line(new Point(minX, sameY), new Point(maxX, sameY)));\n\t\t\t\t}\n\t\t\t\tminX = line.from.x;\n\t\t\t\tmaxX = line.to.x;\n\t\t\t}\n\t\t}\n\n\t\tconst last = result[result.length - 1];\n\n\t\tif (last) {\n\t\t\tif (last.from.x !== minX && last.to.x !== maxX) {\n\t\t\t\tresult.push(new Line(new Point(minX, sameY), new Point(maxX, sameY)));\n\t\t\t}\n\t\t} else {\n\t\t\tresult.push(new Line(new Point(minX, sameY), new Point(maxX, sameY)));\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprivate margeVerticalLines(sameXLines: Array<Line>): Array<Line> {\n\t\tconst result: Array<Line> = [];\n\t\tsameXLines.sort((l1, l2) => l1.from.y - l2.from.y);\n\n\t\tconst sameX = sameXLines[0]?.from.x;\n\t\tif (sameX === undefined) return result;\n\n\t\tlet minY: number = Number.MAX_SAFE_INTEGER;\n\t\tlet maxY: number = Number.MIN_SAFE_INTEGER;\n\n\t\tfor (const line of sameXLines) {\n\t\t\tif (line.from.y - maxY < Shape.tolerance) {\n\t\t\t\tif (line.from.y < minY) {\n\t\t\t\t\tminY = line.from.y;\n\t\t\t\t}\n\t\t\t\tif (line.to.y > maxY) {\n\t\t\t\t\tmaxY = line.to.y;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (maxY > minY) {\n\t\t\t\t\tresult.push(new Line(new Point(sameX, minY), new Point(sameX, maxY)));\n\t\t\t\t}\n\t\t\t\tminY = line.from.y;\n\t\t\t\tmaxY = line.to.y;\n\t\t\t}\n\t\t}\n\n\t\tconst last = result[result.length - 1];\n\n\t\tif (last) {\n\t\t\tif (last.from.y !== minY && last.to.y !== maxY) {\n\t\t\t\tresult.push(new Line(new Point(sameX, minY), new Point(sameX, maxY)));\n\t\t\t}\n\t\t} else {\n\t\t\tresult.push(new Line(new Point(sameX, minY), new Point(sameX, maxY)));\n\t\t}\n\n\t\treturn result;\n\t}\n}\n","import { Line } from './Line.js';\nimport { Point } from './Point.js';\nimport { Shape } from './Shape.js';\n\nexport class Rectangle extends Shape {\n\tpublic from: Point;\n\tpublic width: number;\n\tpublic height: number;\n\n\tconstructor(from: Point, width: number, height: number) {\n\t\tsuper();\n\t\tthis.from = from;\n\t\tthis.width = width;\n\t\tthis.height = height;\n\t}\n\n\tpublic get to(): Point {\n\t\treturn new Point(this.from.x + this.width, this.from.y + this.height);\n\t}\n\n\tpublic getLines(): Line[] {\n\t\tconst to = this.to;\n\n\t\tconst lines: Array<Line> = [\n\t\t\tnew Line(this.from, new Point(to.x, this.from.y)),\n\t\t\tnew Line(this.from, new Point(this.from.x, to.y)),\n\t\t\tnew Line(new Point(to.x, this.from.y), to),\n\t\t\tnew Line(new Point(this.from.x, to.y), to),\n\t\t];\n\t\treturn lines.filter((l) => l.valid);\n\t}\n\n\tpublic transform(matrix: Array<number>): this {\n\t\tconst p1 = Shape.applyTransform([this.from.x, this.from.y], matrix);\n\t\tconst p2 = Shape.applyTransform([this.from.x + this.width, this.from.y + this.height], matrix);\n\n\t\tconst x = Math.min(p1[0], p2[0]);\n\t\tconst y = Math.min(p1[1], p2[1]);\n\n\t\tconst width = Math.abs(p1[0] - p2[0]);\n\t\tconst height = Math.abs(p1[1] - p2[1]);\n\n\t\tthis.from = new Point(x, y);\n\t\tthis.width = width;\n\t\tthis.height = height;\n\t\treturn this;\n\t}\n}\n","export interface HeaderResult {\n\tok: boolean;\n\tstatus?: number;\n\tsize?: number;\n\tisPdf?: boolean;\n\theaders?: Record<string, string>;\n\terror?: Error;\n}\n\n/**\n * Perform an HTTP HEAD request to retrieve the file size and verify existence;\n * when `check` is true, fetch a small range and inspect the magic number to confirm the URL points to a valid PDF.\n * If the server does not support range requests, `isPdf` will be set to `false`.\n * @param url The URL of the PDF file to check. Can be a string or URL object.\n * @param check When `true`, download a small byte range (first 4 bytes) to validate the file signature by checking for '%PDF' magic bytes. Default: `false`.\n * @returns A Promise that resolves to a HeaderResult object containing the response status, size, headers, and PDF validation result.\n */\nexport async function getHeader(url: string | URL, check: boolean = false): Promise<HeaderResult> {\n\ttry {\n\t\t// Try using global fetch when available (browser / Node 18+)\n\t\t// biome-ignore lint/suspicious/noExplicitAny: <unsupported underline type>\n\t\tconst fetch: typeof globalThis.fetch = (globalThis as any).fetch;\n\n\t\tif (typeof fetch === 'function') {\n\t\t\tconst headResp = await fetch(url, { method: 'HEAD' });\n\t\t\tconst headersObj: Record<string, string> = {};\n\t\t\theadResp.headers.forEach((v: string, k: string) => {\n\t\t\t\theadersObj[k] = v;\n\t\t\t});\n\n\t\t\tconst size = headResp.headers.get('content-length') ? parseInt(headResp.headers.get('content-length') as string, 10) : undefined;\n\n\t\t\tlet isPdf: boolean | undefined;\n\t\t\tif (check) {\n\t\t\t\t// Try range request to fetch initial bytes\n\t\t\t\tconst rangeResp = await fetch(url, { method: 'GET', headers: { Range: 'bytes=0-4' } });\n\t\t\t\tif (rangeResp.ok) {\n\t\t\t\t\tconst buf = new Uint8Array(await rangeResp.arrayBuffer());\n\t\t\t\t\tconst headerStr = Array.from(buf)\n\t\t\t\t\t\t.map((b) => String.fromCharCode(b))\n\t\t\t\t\t\t.join('');\n\t\t\t\t\tisPdf = headerStr.startsWith('%PDF');\n\t\t\t\t} else {\n\t\t\t\t\tisPdf = false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { ok: headResp.ok, status: headResp.status, size, isPdf, headers: headersObj };\n\t\t}\n\n\t\tthrow new Error('Fetch API not available');\n\t} catch (error) {\n\t\treturn { ok: false, status: undefined, size: undefined, isPdf: false, headers: {}, error: new Error(String(error)) };\n\t}\n}\n","import type { ImageKind } from 'pdfjs-dist/legacy/build/pdf.mjs';\n\n/**\n * ImageKindKey\n * - Represents the keys of the ImageKind enum (e.g. \"GRAYSCALE_1BPP\", \"RGB_24BPP\", \"RGBA_32BPP\").\n */\nexport type ImageKindKey = keyof typeof ImageKind;\n\n/**\n * ImageKindValue\n * - Represents the numeric values of the ImageKind enum (e.g. 1, 2, 3).\n */\nexport type ImageKindValue = (typeof ImageKind)[ImageKindKey];\n\nexport class ImageResult {\n\tpages: Array<PageImages> = [];\n\ttotal: number = 0;\n\n\tpublic getPageImage(num: number, name: string): EmbeddedImage | null {\n\t\tfor (const pageData of this.pages) {\n\t\t\tif (pageData.pageNumber === num) {\n\t\t\t\tfor (const img of pageData.images) {\n\t\t\t\t\tif (img.name === name) {\n\t\t\t\t\t\treturn img;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\tconstructor(total: number) {\n\t\tthis.total = total;\n\t}\n}\n\n/**\n * PageImages\n * - Represents all embedded images found on a single PDF page.\n * - pageNumber: 1-based page index.\n * - images: Array of EmbeddedImage objects for this page.\n */\nexport interface PageImages {\n\tpageNumber: number;\n\timages: EmbeddedImage[];\n}\n\n/**\n * EmbeddedImage\n * - Normalized representation of an embedded image extracted from the PDF.\n * - `data`: Raw image bytes (e.g. PNG/JPEG) as Uint8Array. Use this for file writing or binary processing.\n * - `dataUrl`: Optional data URL (e.g. \"data:image/png;base64,...\") for directly embedding in <img> src.\n * Storing both lets consumers choose the most convenient form; consider omitting one to save memory.\n * - `name`: Resource name for the image.\n * - `width` / `height`: Dimensions in pixels.\n * - `kind`: ImageKindValue from indicating the pixel format (e.g. GRAYSCALE_1BPP / RGB_24BPP / RGBA_32BPP).\n */\nexport interface EmbeddedImage {\n\t// Raw binary image data (PNG/JPEG) normalized to Uint8Array.\n\tdata: Uint8Array;\n\n\t// Optional base64 data URL for easy embedding in HTML.\n\tdataUrl: string;\n\n\t// Resource identifier for the image.\n\tname: string;\n\n\t// Image dimensions in pixels.\n\twidth: number;\n\theight: number;\n\n\t// Color format as defined by pdfjs ImageKind numeric values.\n\tkind: ImageKindValue;\n}\n","/**\n * @licstart The following is the entire license notice for the\n * JavaScript code in this page\n *\n * Copyright 2024 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * @licend The above is the entire license notice for the\n * JavaScript code in this page\n */\n\n/**\n * pdfjsVersion = 5.4.296\n * pdfjsBuild = f56dc8601\n */\n/******/ var __webpack_modules__ = ({\n\n/***/ 34:\n/***/ ((module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar isCallable = __webpack_require__(4901);\n\nmodule.exports = function (it) {\n return typeof it == 'object' ? it !== null : isCallable(it);\n};\n\n\n/***/ }),\n\n/***/ 81:\n/***/ ((module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar call = __webpack_require__(9565);\nvar aCallable = __webpack_require__(9306);\nvar anObject = __webpack_require__(8551);\nvar tryToString = __webpack_require__(6823);\nvar getIteratorMethod = __webpack_require__(851);\n\nvar $TypeError = TypeError;\n\nmodule.exports = function (argument, usingIterator) {\n var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator;\n if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument));\n throw new $TypeError(tryToString(argument) + ' is not iterable');\n};\n\n\n/***/ }),\n\n/***/ 116:\n/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar $ = __webpack_require__(6518);\nvar call = __webpack_require__(9565);\nvar iterate = __webpack_require__(2652);\nvar aCallable = __webpack_require__(9306);\nvar anObject = __webpack_require__(8551);\nvar getIteratorDirect = __webpack_require__(1767);\nvar iteratorClose = __webpack_require__(9539);\nvar iteratorHelperWithoutClosingOnEarlyError = __webpack_require__(4549);\n\nvar findWithoutClosingOnEarlyError = iteratorHelperWithoutClosingOnEarlyError('find', TypeError);\n\n// `Iterator.prototype.find` method\n// https://tc39.es/ecma262/#sec-iterator.prototype.find\n$({ target: 'Iterator', proto: true, real: true, forced: findWithoutClosingOnEarlyError }, {\n find: function find(predicate) {\n anObject(this);\n try {\n aCallable(predicate);\n } catch (error) {\n iteratorClose(this, 'throw', error);\n }\n\n if (findWithoutClosingOnEarlyError) return call(findWithoutClosingOnEarlyError, this, predicate);\n\n var record = getIteratorDirect(this);\n var counter = 0;\n return iterate(record, function (value, stop) {\n if (predicate(value, counter++)) return stop(value);\n }, { IS_RECORD: true, INTERRUPTED: true }).result;\n }\n});\n\n\n/***/ }),\n\n/***/ 283:\n/***/ ((module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar uncurryThis = __webpack_require__(9504);\nvar fails = __webpack_require__(9039);\nvar isCallable = __webpack_require__(4901);\nvar hasOwn = __webpack_require__(9297);\nvar DESCRIPTORS = __webpack_require__(3724);\nvar CONFIGURABLE_FUNCTION_NAME = (__webpack_require__(350).CONFIGURABLE);\nvar inspectSource = __webpack_require__(3706);\nvar InternalStateModule = __webpack_require__(1181);\n\nvar enforceInternalState = InternalStateModule.enforce;\nvar getInternalState = InternalStateModule.get;\nvar $String = String;\n// eslint-disable-next-line es/no-object-defineproperty -- safe\nvar defineProperty = Object.defineProperty;\nvar stringSlice = uncurryThis(''.slice);\nvar replace = uncurryThis(''.replace);\nvar join = uncurryThis([].join);\n\nvar CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function () {\n return defineProperty(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;\n});\n\nvar TEMPLATE = String(String).split('String');\n\nvar makeBuiltIn = module.exports = function (value, name, options) {\n if (stringSlice($String(name), 0, 7) === 'Symbol(') {\n name = '[' + replace($String(name), /^Symbol\\(([^)]*)\\).*$/, '$1') + ']';\n }\n if (options && options.getter) name = 'get ' + name;\n if (options && options.setter) name = 'set ' + name;\n if (!hasOwn(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {\n if (DESCRIPTORS) defineProperty(value, 'name', { value: name, configurable: true });\n else value.name = name;\n }\n if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) {\n defineProperty(value, 'length', { value: options.arity });\n }\n try {\n if (options && hasOwn(options, 'constructor') && options.constructor) {\n if (DESCRIPTORS) defineProperty(value, 'prototype', { writable: false });\n // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable\n } else if (value.prototype) value.prototype = undefined;\n } catch (error) { /* empty */ }\n var state = enforceInternalState(value);\n if (!hasOwn(state, 'source')) {\n state.source = join(TEMPLATE, typeof name == 'string' ? name : '');\n } return value;\n};\n\n// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative\n// eslint-disable-next-line no-extend-native -- required\nFunction.prototype.toString = makeBuiltIn(function toString() {\n return isCallable(this) && getInternalState(this).source || inspectSource(this);\n}, 'toString');\n\n\n/***/ }),\n\n/***/ 350:\n/***/ ((module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar DESCRIPTORS = __webpack_require__(3724);\nvar hasOwn = __webpack_require__(9297);\n\nvar FunctionPrototype = Function.prototype;\n// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe\nvar getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;\n\nvar EXISTS = hasOwn(FunctionPrototype, 'name');\n// additional protection from minified / mangled / dropped function names\nvar PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';\nvar CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));\n\nmodule.exports = {\n EXISTS: EXISTS,\n PROPER: PROPER,\n CONFIGURABLE: CONFIGURABLE\n};\n\n\n/***/ }),\n\n/***/ 397:\n/***/ ((module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar getBuiltIn = __webpack_require__(7751);\n\nmodule.exports = getBuiltIn('document', 'documentElement');\n\n\n/***/ }),\n\n/***/ 421:\n/***/ ((module) => {\n\n\nmodule.exports = {};\n\n\n/***/ }),\n\n/***/ 456:\n/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar $ = __webpack_require__(6518);\nvar globalThis = __webpack_require__(4576);\nvar uncurryThis = __webpack_require__(9504);\nvar anUint8Array = __webpack_require__(4154);\nvar notDetached = __webpack_require__(5169);\n\nvar numberToString = uncurryThis(1.1.toString);\n\nvar Uint8Array = globalThis.Uint8Array;\n\nvar INCORRECT_BEHAVIOR_OR_DOESNT_EXISTS = !Uint8Array || !Uint8Array.prototype.toHex || !(function () {\n try {\n var target = new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255]);\n return target.toHex() === 'ffffffffffffffff';\n } catch (error) {\n return false;\n }\n})();\n\n// `Uint8Array.prototype.toHex` method\n// https://github.com/tc39/proposal-arraybuffer-base64\nif (Uint8Array) $({ target: 'Uint8Array', proto: true, forced: INCORRECT_BEHAVIOR_OR_DOESNT_EXISTS }, {\n toHex: function toHex() {\n anUint8Array(this);\n notDetached(this.buffer);\n var result = '';\n for (var i = 0, length = this.length; i < length; i++) {\n var hex = numberToString(this[i], 16);\n result += hex.length === 1 ? '0' + hex : hex;\n }\n return result;\n }\n});\n\n\n/***/ }),\n\n/***/ 507:\n/***/ ((module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar call = __webpack_require__(9565);\n\nmodule.exports = function (record, fn, ITERATOR_INSTEAD_OF_RECORD) {\n var iterator = ITERATOR_INSTEAD_OF_RECORD ? record : record.iterator;\n var next = record.next;\n var step, result;\n while (!(step = call(next, iterator)).done) {\n result = fn(step.value);\n if (result !== undefined) return result;\n }\n};\n\n\n/***/ }),\n\n/***/ 531:\n/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar $ = __webpack_require__(6518);\nvar call = __webpack_require__(9565);\nvar aCallable = __webpack_require__(9306);\nvar anObject = __webpack_require__(8551);\nvar getIteratorDirect = __webpack_require__(1767);\nvar getIteratorFlattenable = __webpack_require__(8646);\nvar createIteratorProxy = __webpack_require__(9462);\nvar iteratorClose = __webpack_require__(9539);\nvar IS_PURE = __webpack_require__(6395);\nvar iteratorHelperThrowsOnInvalidIterator = __webpack_require__(684);\nvar iteratorHelperWithoutClosingOnEarlyError = __webpack_require__(4549);\n\nvar FLAT_MAP_WITHOUT_THROWING_ON_INVALID_ITERATOR = !IS_PURE\n && !iteratorHelperThrowsOnInvalidIterator('flatMap', function () { /* empty */ });\nvar flatMapWithoutClosingOnEarlyError = !IS_PURE && !FLAT_MAP_WITHOUT_THROWING_ON_INVALID_ITERATOR\n && iteratorHelperWithoutClosingOnEarlyError('flatMap', TypeError);\n\nvar FORCED = IS_PURE || FLAT_MAP_WITHOUT_THROWING_ON_INVALID_ITERATOR || flatMapWithoutClosingOnEarlyError;\n\nvar IteratorProxy = createIteratorProxy(function () {\n var iterator = this.iterator;\n var mapper = this.mapper;\n var result, inner;\n\n while (true) {\n if (inner = this.inner) try {\n result = anObject(call(inner.next, inner.iterator));\n if (!result.done) return result.value;\n this.inner = null;\n } catch (error) { iteratorClose(iterator, 'throw', error); }\n\n result = anObject(call(this.next, iterator));\n\n if (this.done = !!result.done) return;\n\n try {\n this.inner = getIteratorFlattenable(mapper(result.value, this.counter++), false);\n } catch (error) { iteratorClose(iterator, 'throw', error); }\n }\n});\n\n// `Iterator.prototype.flatMap` method\n// https://tc39.es/ecma262/#sec-iterator.prototype.flatmap\n$({ target: 'Iterator', proto: true, real: true, forced: FORCED }, {\n flatMap: function flatMap(mapper) {\n anObject(this);\n try {\n aCallable(mapper);\n } catch (error) {\n iteratorClose(this, 'throw', error);\n }\n\n if (flatMapWithoutClosingOnEarlyError) return call(flatMapWithoutClosingOnEarlyError, this, mapper);\n\n return new IteratorProxy(getIteratorDirect(this), {\n mapper: mapper,\n inner: null\n });\n }\n});\n\n\n/***/ }),\n\n/***/ 616:\n/***/ ((module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar fails = __webpack_require__(9039);\n\nmodule.exports = !fails(function () {\n // eslint-disable-next-line es/no-function-prototype-bind -- safe\n var test = (function () { /* empty */ }).bind();\n // eslint-disable-next-line no-prototype-builtins -- safe\n return typeof test != 'function' || test.hasOwnProperty('prototype');\n});\n\n\n/***/ }),\n\n/***/ 655:\n/***/ ((module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar classof = __webpack_require__(6955);\n\nvar $String = String;\n\nmodule.exports = function (argument) {\n if (classof(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string');\n return $String(argument);\n};\n\n\n/***/ }),\n\n/***/ 679:\n/***/ ((module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar isPrototypeOf = __webpack_require__(1625);\n\nvar $TypeError = TypeError;\n\nmodule.exports = function (it, Prototype) {\n if (isPrototypeOf(Prototype, it)) return it;\n throw new $TypeError('Incorrect invocation');\n};\n\n\n/***/ }),\n\n/***/ 684:\n/***/ ((module) => {\n\n\n// Should throw an error on invalid iterator\n// https://issues.chromium.org/issues/336839115\nmodule.exports = function (methodName, argument) {\n // eslint-disable-next-line es/no-iterator -- required for testing\n var method = typeof Iterator == 'function' && Iterator.prototype[methodName];\n if (method) try {\n method.call({ next: null }, argument).next();\n } catch (error) {\n return true;\n }\n};\n\n\n/***/ }),\n\n/***/ 741:\n/***/ ((module) => {\n\n\nvar ceil = Math.ceil;\nvar floor = Math.floor;\n\n// `Math.trunc` method\n// https://tc39.es/ecma262/#sec-math.trunc\n// eslint-disable-next-line es/no-math-trunc -- safe\nmodule.exports = Math.trunc || function trunc(x) {\n var n = +x;\n return (n > 0 ? floor : ceil)(n);\n};\n\n\n/***/ }),\n\n/***/ 757:\n/***/ ((module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar getBuiltIn = __webpack_require__(7751);\nvar isCallable = __webpack_require__(4901);\nvar isPrototypeOf = __webpack_require__(1625);\nvar USE_SYMBOL_AS_UID = __webpack_require__(7040);\n\nvar $Object = Object;\n\nmodule.exports = USE_SYMBOL_AS_UID ? function (it) {\n return typeof it == 'symbol';\n} : function (it) {\n var $Symbol = getBuiltIn('Symbol');\n return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it));\n};\n\n\n/***/ }),\n\n/***/ 851:\n/***/ ((module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar classof = __webpack_require__(6955);\nvar getMethod = __webpack_require__(5966);\nvar isNullOrUndefined = __webpack_require__(4117);\nvar Iterators = __webpack_require__(6269);\nvar wellKnownSymbol = __webpack_require__(8227);\n\nvar ITERATOR = wellKnownSymbol('iterator');\n\nmodule.exports = function (it) {\n if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR)\n || getMethod(it, '@@iterator')\n || Iterators[classof(it)];\n};\n\n\n/***/ }),\n\n/***/ 944:\n/***/ ((module) => {\n\n\nvar $TypeError = TypeError;\n\nmodule.exports = function (options) {\n var alphabet = options && options.alphabet;\n if (alphabet === undefined || alphabet === 'base64' || alphabet === 'base64url') return alphabet || 'base64';\n throw new $TypeError('Incorrect `alphabet` option');\n};\n\n\n/***/ }),\n\n/***/ 1072:\n/***/ ((module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar internalObjectKeys = __webpack_require__(1828);\nvar enumBugKeys = __webpack_require__(8727);\n\n// `Object.keys` method\n// https://tc39.es/ecma262/#sec-object.keys\n// eslint-disable-next-line es/no-object-keys -- safe\nmodule.exports = Object.keys || function keys(O) {\n return internalObjectKeys(O, enumBugKeys);\n};\n\n\n/***/ }),\n\n/***/ 1103:\n/***/ ((module) => {\n\n\nmodule.exports = function (exec) {\n try {\n return { error: false, value: exec() };\n } catch (error) {\n return { error: true, value: error };\n }\n};\n\n\n/***/ }),\n\n/***/ 1108:\n/***/ ((module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar classof = __webpack_require__(6955);\n\nmodule.exports = function (it) {\n var klass = classof(it);\n return klass === 'BigInt64Array' || klass === 'BigUint64Array';\n};\n\n\n/***/ }),\n\n/***/ 1148:\n/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar $ = __webpack_require__(6518);\nvar call = __webpack_require__(9565);\nvar iterate = __webpack_require__(2652);\nvar aCallable = __webpack_require__(9306);\nvar anObject = __webpack_require__(8551);\nvar getIteratorDirect = __webpack_require__(1767);\nvar iteratorClose = __webpack_require__(9539);\nvar iteratorHelperWithoutClosingOnEarlyError = __webpack_require__(4549);\n\nvar everyWithoutClosingOnEarlyError = iteratorHelperWithoutClosingOnEarlyError('every', TypeError);\n\n// `Iterator.prototype.every` method\n// https://tc39.es/ecma262/#sec-iterator.prototype.every\n$({ target: 'Iterator', proto: true, real: true, forced: everyWithoutClosingOnEarlyError }, {\n every: function every(predicate) {\n anObject(this);\n try {\n aCallable(predicate);\n } catch (error) {\n iteratorClose(this, 'throw', error);\n }\n\n if (everyWithoutClosingOnEarlyError) return call(everyWithoutClosingOnEarlyError, this, predicate);\n\n var record = getIteratorDirect(this);\n var counter = 0;\n return !iterate(record, function (value, stop) {\n if (!predicate(value, counter++)) return stop();\n }, { IS_RECORD: true, INTERRUPTED: true }).stopped;\n }\n});\n\n\n/***/ }),\n\n/***/ 1181:\n/***/ ((module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar NATIVE_WEAK_MAP = __webpack_require__(8622);\nvar globalThis = __webpack_require__(4576);\nvar isObject = __webpack_require__(34);\nvar createNonEnumerableProperty = __webpack_require__(6699);\nvar hasOwn = __webpack_require__(9297);\nvar shared = __webpack_require__(7629);\nvar sharedKey = __webpack_require__(6119);\nvar hiddenKeys = __webpack_require__(421);\n\nvar OBJECT_ALREADY_INITIALIZED = 'Object already initialized';\nvar TypeError = globalThis.TypeError;\nvar WeakMap = globalThis.WeakMap;\nvar set, get, has;\n\nvar enforce = function (it) {\n return has(it) ? get(it) : set(it, {});\n};\n\nvar getterFor = function (TYPE) {\n return function (it) {\n var state;\n if (!isObject(it) || (state = get(it)).type !== TYPE) {\n throw new TypeError('Incompatible receiver, ' + TYPE + ' required');\n } return state;\n };\n};\n\nif (NATIVE_WEAK_MAP || shared.state) {\n var store = shared.state || (shared.state = new WeakMap());\n /* eslint-disable no-self-assign -- prototype methods protection */\n store.get = store.get;\n store.has = store.has;\n store.set = store.set;\n /* eslint-enable no-self-assign -- prototype methods protection */\n set = function (it, metadata) {\n if (store.has(it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);\n metadata.facade = it;\n store.set(it, metadata);\n return metadata;\n };\n get = function (it) {\n return store.get(it) || {};\n };\n has = function (it) {\n return store.has(it);\n };\n} else {\n var STATE = sharedKey('state');\n hiddenKeys[STATE] = true;\n set = function (it, metadata) {\n if (hasOwn(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);\n metadata.facade = it;\n createNonEnumerableProperty(it, STATE, metadata);\n return metadata;\n };\n get = function (it) {\n return hasOwn(it, STATE) ? it[STATE] : {};\n };\n has = function (it) {\n return hasOwn(it, STATE);\n };\n}\n\nmodule.exports = {\n set: set,\n get: get,\n has: has,\n enforce: enforce,\n getterFor: getterFor\n};\n\n\n/***/ }),\n\n/***/ 1291:\n/***/ ((module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar trunc = __webpack_require__(741);\n\n// `ToIntegerOrInfinity` abstract operation\n// https://tc39.es/ecma262/#sec-tointegerorinfinity\nmodule.exports = function (argument) {\n var number = +argument;\n // eslint-disable-next-line no-self-compare -- NaN check\n return number !== number || number === 0 ? 0 : trunc(number);\n};\n\n\n/***/ }),\n\n/***/ 1385:\n/***/ ((module, __unused_webpack_exports, __webpack_require__) => {\n\n\nvar iteratorClose = __webpack_require__(9539);\n\nmodule.exports = function (iters, kind, value) {\n for (var i = iters.length - 1; i >= 0; i--) {\n if (iters[i] === undefined) continue;\n try {\n value = iteratorClose(iters[i].iterator, kind, value);\n } catch (error) {\n kind = 'throw';\n value = error;\n }\n }\n if (kind === 'throw') throw value;\n return value;\n};\n\n\n/***/ }),\n\n/***/ 1548:\n/***/ ((module, __unused_w