Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1/**2 * @licstart The following is the entire license notice for the3 * JavaScript code in this page4 *5 * Copyright 2024 Mozilla Foundation6 *7 * Licensed under the Apache License, Version 2.0 (the "License");8 * you may not use this file except in compliance with the License.9 * You may obtain a copy of the License at10 *11 * http://www.apache.org/licenses/LICENSE-2.012 *13 * Unless required by applicable law or agreed to in writing, software14 * distributed under the License is distributed on an "AS IS" BASIS,15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.16 * See the License for the specific language governing permissions and17 * limitations under the License.18 *19 * @licend The above is the entire license notice for the20 * JavaScript code in this page21 */22 23/**24 * pdfjsVersion = 5.4.5425 * pdfjsBuild = 295fb3ec426 */27 28;// ./src/shared/util.js29const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");30const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];31const LINE_FACTOR = 1.35;32const LINE_DESCENT_FACTOR = 0.35;33const BASELINE_FACTOR = LINE_DESCENT_FACTOR / LINE_FACTOR;34const RenderingIntentFlag = {35 ANY: 0x01,36 DISPLAY: 0x02,37 PRINT: 0x04,38 SAVE: 0x08,39 ANNOTATIONS_FORMS: 0x10,40 ANNOTATIONS_STORAGE: 0x20,41 ANNOTATIONS_DISABLE: 0x40,42 IS_EDITING: 0x80,43 OPLIST: 0x10044};45const AnnotationMode = {46 DISABLE: 0,47 ENABLE: 1,48 ENABLE_FORMS: 2,49 ENABLE_STORAGE: 350};51const AnnotationEditorPrefix = "pdfjs_internal_editor_";52const AnnotationEditorType = {53 DISABLE: -1,54 NONE: 0,55 FREETEXT: 3,56 HIGHLIGHT: 9,57 STAMP: 13,58 INK: 15,59 SIGNATURE: 101,60 COMMENT: 10261};62const AnnotationEditorParamsType = {63 RESIZE: 1,64 CREATE: 2,65 FREETEXT_SIZE: 11,66 FREETEXT_COLOR: 12,67 FREETEXT_OPACITY: 13,68 INK_COLOR: 21,69 INK_THICKNESS: 22,70 INK_OPACITY: 23,71 HIGHLIGHT_COLOR: 31,72 HIGHLIGHT_THICKNESS: 32,73 HIGHLIGHT_FREE: 33,74 HIGHLIGHT_SHOW_ALL: 34,75 DRAW_STEP: 4176};77const PermissionFlag = {78 PRINT: 0x04,79 MODIFY_CONTENTS: 0x08,80 COPY: 0x10,81 MODIFY_ANNOTATIONS: 0x20,82 FILL_INTERACTIVE_FORMS: 0x100,83 COPY_FOR_ACCESSIBILITY: 0x200,84 ASSEMBLE: 0x400,85 PRINT_HIGH_QUALITY: 0x80086};87const TextRenderingMode = {88 FILL: 0,89 STROKE: 1,90 FILL_STROKE: 2,91 INVISIBLE: 3,92 FILL_ADD_TO_PATH: 4,93 STROKE_ADD_TO_PATH: 5,94 FILL_STROKE_ADD_TO_PATH: 6,95 ADD_TO_PATH: 7,96 FILL_STROKE_MASK: 3,97 ADD_TO_PATH_FLAG: 498};99const util_ImageKind = {100 GRAYSCALE_1BPP: 1,101 RGB_24BPP: 2,102 RGBA_32BPP: 3103};104const AnnotationType = {105 TEXT: 1,106 LINK: 2,107 FREETEXT: 3,108 LINE: 4,109 SQUARE: 5,110 CIRCLE: 6,111 POLYGON: 7,112 POLYLINE: 8,113 HIGHLIGHT: 9,114 UNDERLINE: 10,115 SQUIGGLY: 11,116 STRIKEOUT: 12,117 STAMP: 13,118 CARET: 14,119 INK: 15,120 POPUP: 16,121 FILEATTACHMENT: 17,122 SOUND: 18,123 MOVIE: 19,124 WIDGET: 20,125 SCREEN: 21,126 PRINTERMARK: 22,127 TRAPNET: 23,128 WATERMARK: 24,129 THREED: 25,130 REDACT: 26131};132const AnnotationReplyType = {133 GROUP: "Group",134 REPLY: "R"135};136const AnnotationFlag = {137 INVISIBLE: 0x01,138 HIDDEN: 0x02,139 PRINT: 0x04,140 NOZOOM: 0x08,141 NOROTATE: 0x10,142 NOVIEW: 0x20,143 READONLY: 0x40,144 LOCKED: 0x80,145 TOGGLENOVIEW: 0x100,146 LOCKEDCONTENTS: 0x200147};148const AnnotationFieldFlag = {149 READONLY: 0x0000001,150 REQUIRED: 0x0000002,151 NOEXPORT: 0x0000004,152 MULTILINE: 0x0001000,153 PASSWORD: 0x0002000,154 NOTOGGLETOOFF: 0x0004000,155 RADIO: 0x0008000,156 PUSHBUTTON: 0x0010000,157 COMBO: 0x0020000,158 EDIT: 0x0040000,159 SORT: 0x0080000,160 FILESELECT: 0x0100000,161 MULTISELECT: 0x0200000,162 DONOTSPELLCHECK: 0x0400000,163 DONOTSCROLL: 0x0800000,164 COMB: 0x1000000,165 RICHTEXT: 0x2000000,166 RADIOSINUNISON: 0x2000000,167 COMMITONSELCHANGE: 0x4000000168};169const AnnotationBorderStyleType = {170 SOLID: 1,171 DASHED: 2,172 BEVELED: 3,173 INSET: 4,174 UNDERLINE: 5175};176const AnnotationActionEventType = {177 E: "Mouse Enter",178 X: "Mouse Exit",179 D: "Mouse Down",180 U: "Mouse Up",181 Fo: "Focus",182 Bl: "Blur",183 PO: "PageOpen",184 PC: "PageClose",185 PV: "PageVisible",186 PI: "PageInvisible",187 K: "Keystroke",188 F: "Format",189 V: "Validate",190 C: "Calculate"191};192const DocumentActionEventType = {193 WC: "WillClose",194 WS: "WillSave",195 DS: "DidSave",196 WP: "WillPrint",197 DP: "DidPrint"198};199const PageActionEventType = {200 O: "PageOpen",201 C: "PageClose"202};203const VerbosityLevel = {204 ERRORS: 0,205 WARNINGS: 1,206 INFOS: 5207};208const OPS = {209 dependency: 1,210 setLineWidth: 2,211 setLineCap: 3,212 setLineJoin: 4,213 setMiterLimit: 5,214 setDash: 6,215 setRenderingIntent: 7,216 setFlatness: 8,217 setGState: 9,218 save: 10,219 restore: 11,220 transform: 12,221 moveTo: 13,222 lineTo: 14,223 curveTo: 15,224 curveTo2: 16,225 curveTo3: 17,226 closePath: 18,227 rectangle: 19,228 stroke: 20,229 closeStroke: 21,230 fill: 22,231 eoFill: 23,232 fillStroke: 24,233 eoFillStroke: 25,234 closeFillStroke: 26,235 closeEOFillStroke: 27,236 endPath: 28,237 clip: 29,238 eoClip: 30,239 beginText: 31,240 endText: 32,241 setCharSpacing: 33,242 setWordSpacing: 34,243 setHScale: 35,244 setLeading: 36,245 setFont: 37,246 setTextRenderingMode: 38,247 setTextRise: 39,248 moveText: 40,249 setLeadingMoveText: 41,250 setTextMatrix: 42,251 nextLine: 43,252 showText: 44,253 showSpacedText: 45,254 nextLineShowText: 46,255 nextLineSetSpacingShowText: 47,256 setCharWidth: 48,257 setCharWidthAndBounds: 49,258 setStrokeColorSpace: 50,259 setFillColorSpace: 51,260 setStrokeColor: 52,261 setStrokeColorN: 53,262 setFillColor: 54,263 setFillColorN: 55,264 setStrokeGray: 56,265 setFillGray: 57,266 setStrokeRGBColor: 58,267 setFillRGBColor: 59,268 setStrokeCMYKColor: 60,269 setFillCMYKColor: 61,270 shadingFill: 62,271 beginInlineImage: 63,272 beginImageData: 64,273 endInlineImage: 65,274 paintXObject: 66,275 markPoint: 67,276 markPointProps: 68,277 beginMarkedContent: 69,278 beginMarkedContentProps: 70,279 endMarkedContent: 71,280 beginCompat: 72,281 endCompat: 73,282 paintFormXObjectBegin: 74,283 paintFormXObjectEnd: 75,284 beginGroup: 76,285 endGroup: 77,286 beginAnnotation: 80,287 endAnnotation: 81,288 paintImageMaskXObject: 83,289 paintImageMaskXObjectGroup: 84,290 paintImageXObject: 85,291 paintInlineImageXObject: 86,292 paintInlineImageXObjectGroup: 87,293 paintImageXObjectRepeat: 88,294 paintImageMaskXObjectRepeat: 89,295 paintSolidColorImageMask: 90,296 constructPath: 91,297 setStrokeTransparent: 92,298 setFillTransparent: 93,299 rawFillPath: 94300};301const DrawOPS = {302 moveTo: 0,303 lineTo: 1,304 curveTo: 2,305 closePath: 3306};307const PasswordResponses = {308 NEED_PASSWORD: 1,309 INCORRECT_PASSWORD: 2310};311let verbosity = VerbosityLevel.WARNINGS;312function setVerbosityLevel(level) {313 if (Number.isInteger(level)) {314 verbosity = level;315 }316}317function getVerbosityLevel() {318 return verbosity;319}320function info(msg) {321 if (verbosity >= VerbosityLevel.INFOS) {322 console.log(`Info: ${msg}`);323 }324}325function warn(msg) {326 if (verbosity >= VerbosityLevel.WARNINGS) {327 console.log(`Warning: ${msg}`);328 }329}330function unreachable(msg) {331 throw new Error(msg);332}333function assert(cond, msg) {334 if (!cond) {335 unreachable(msg);336 }337}338function _isValidProtocol(url) {339 switch (url?.protocol) {340 case "http:":341 case "https:":342 case "ftp:":343 case "mailto:":344 case "tel:":345 return true;346 default:347 return false;348 }349}350function createValidAbsoluteUrl(url, baseUrl = null, options = null) {351 if (!url) {352 return null;353 }354 if (options && typeof url === "string") {355 if (options.addDefaultProtocol && url.startsWith("www.")) {356 const dots = url.match(/\./g);357 if (dots?.length >= 2) {358 url = `http://${url}`;359 }360 }361 if (options.tryConvertEncoding) {362 try {363 url = stringToUTF8String(url);364 } catch {}365 }366 }367 const absoluteUrl = baseUrl ? URL.parse(url, baseUrl) : URL.parse(url);368 return _isValidProtocol(absoluteUrl) ? absoluteUrl : null;369}370function updateUrlHash(url, hash, allowRel = false) {371 const res = URL.parse(url);372 if (res) {373 res.hash = hash;374 return res.href;375 }376 if (allowRel && createValidAbsoluteUrl(url, "http://example.com")) {377 return url.split("#", 1)[0] + `${hash ? `#${hash}` : ""}`;378 }379 return "";380}381function shadow(obj, prop, value, nonSerializable = false) {382 Object.defineProperty(obj, prop, {383 value,384 enumerable: !nonSerializable,385 configurable: true,386 writable: false387 });388 return value;389}390const BaseException = function BaseExceptionClosure() {391 function BaseException(message, name) {392 this.message = message;393 this.name = name;394 }395 BaseException.prototype = new Error();396 BaseException.constructor = BaseException;397 return BaseException;398}();399class PasswordException extends BaseException {400 constructor(msg, code) {401 super(msg, "PasswordException");402 this.code = code;403 }404}405class UnknownErrorException extends BaseException {406 constructor(msg, details) {407 super(msg, "UnknownErrorException");408 this.details = details;409 }410}411class InvalidPDFException extends BaseException {412 constructor(msg) {413 super(msg, "InvalidPDFException");414 }415}416class ResponseException extends BaseException {417 constructor(msg, status, missing) {418 super(msg, "ResponseException");419 this.status = status;420 this.missing = missing;421 }422}423class FormatError extends BaseException {424 constructor(msg) {425 super(msg, "FormatError");426 }427}428class AbortException extends BaseException {429 constructor(msg) {430 super(msg, "AbortException");431 }432}433function bytesToString(bytes) {434 if (typeof bytes !== "object" || bytes?.length === undefined) {435 unreachable("Invalid argument for bytesToString");436 }437 const length = bytes.length;438 const MAX_ARGUMENT_COUNT = 8192;439 if (length < MAX_ARGUMENT_COUNT) {440 return String.fromCharCode.apply(null, bytes);441 }442 const strBuf = [];443 for (let i = 0; i < length; i += MAX_ARGUMENT_COUNT) {444 const chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);445 const chunk = bytes.subarray(i, chunkEnd);446 strBuf.push(String.fromCharCode.apply(null, chunk));447 }448 return strBuf.join("");449}450function stringToBytes(str) {451 if (typeof str !== "string") {452 unreachable("Invalid argument for stringToBytes");453 }454 const length = str.length;455 const bytes = new Uint8Array(length);456 for (let i = 0; i < length; ++i) {457 bytes[i] = str.charCodeAt(i) & 0xff;458 }459 return bytes;460}461function string32(value) {462 return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);463}464function objectSize(obj) {465 return Object.keys(obj).length;466}467function isLittleEndian() {468 const buffer8 = new Uint8Array(4);469 buffer8[0] = 1;470 const view32 = new Uint32Array(buffer8.buffer, 0, 1);471 return view32[0] === 1;472}473function isEvalSupported() {474 try {475 new Function("");476 return true;477 } catch {478 return false;479 }480}481class util_FeatureTest {482 static get isLittleEndian() {483 return shadow(this, "isLittleEndian", isLittleEndian());484 }485 static get isEvalSupported() {486 return shadow(this, "isEvalSupported", isEvalSupported());487 }488 static get isOffscreenCanvasSupported() {489 return shadow(this, "isOffscreenCanvasSupported", typeof OffscreenCanvas !== "undefined");490 }491 static get isImageDecoderSupported() {492 return shadow(this, "isImageDecoderSupported", typeof ImageDecoder !== "undefined");493 }494 static get platform() {495 const {496 platform,497 userAgent498 } = navigator;499 return shadow(this, "platform", {500 isAndroid: userAgent.includes("Android"),501 isLinux: platform.includes("Linux"),502 isMac: platform.includes("Mac"),503 isWindows: platform.includes("Win"),504 isFirefox: userAgent.includes("Firefox")505 });506 }507 static get isCSSRoundSupported() {508 return shadow(this, "isCSSRoundSupported", globalThis.CSS?.supports?.("width: round(1.5px, 1px)"));509 }510}511const hexNumbers = Array.from(Array(256).keys(), n => n.toString(16).padStart(2, "0"));512class Util {513 static makeHexColor(r, g, b) {514 return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;515 }516 static scaleMinMax(transform, minMax) {517 let temp;518 if (transform[0]) {519 if (transform[0] < 0) {520 temp = minMax[0];521 minMax[0] = minMax[2];522 minMax[2] = temp;523 }524 minMax[0] *= transform[0];525 minMax[2] *= transform[0];526 if (transform[3] < 0) {527 temp = minMax[1];528 minMax[1] = minMax[3];529 minMax[3] = temp;530 }531 minMax[1] *= transform[3];532 minMax[3] *= transform[3];533 } else {534 temp = minMax[0];535 minMax[0] = minMax[1];536 minMax[1] = temp;537 temp = minMax[2];538 minMax[2] = minMax[3];539 minMax[3] = temp;540 if (transform[1] < 0) {541 temp = minMax[1];542 minMax[1] = minMax[3];543 minMax[3] = temp;544 }545 minMax[1] *= transform[1];546 minMax[3] *= transform[1];547 if (transform[2] < 0) {548 temp = minMax[0];549 minMax[0] = minMax[2];550 minMax[2] = temp;551 }552 minMax[0] *= transform[2];553 minMax[2] *= transform[2];554 }555 minMax[0] += transform[4];556 minMax[1] += transform[5];557 minMax[2] += transform[4];558 minMax[3] += transform[5];559 }560 static transform(m1, m2) {561 return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];562 }563 static applyTransform(p, m, pos = 0) {564 const p0 = p[pos];565 const p1 = p[pos + 1];566 p[pos] = p0 * m[0] + p1 * m[2] + m[4];567 p[pos + 1] = p0 * m[1] + p1 * m[3] + m[5];568 }569 static applyTransformToBezier(p, transform, pos = 0) {570 const m0 = transform[0];571 const m1 = transform[1];572 const m2 = transform[2];573 const m3 = transform[3];574 const m4 = transform[4];575 const m5 = transform[5];576 for (let i = 0; i < 6; i += 2) {577 const pI = p[pos + i];578 const pI1 = p[pos + i + 1];579 p[pos + i] = pI * m0 + pI1 * m2 + m4;580 p[pos + i + 1] = pI * m1 + pI1 * m3 + m5;581 }582 }583 static applyInverseTransform(p, m) {584 const p0 = p[0];585 const p1 = p[1];586 const d = m[0] * m[3] - m[1] * m[2];587 p[0] = (p0 * m[3] - p1 * m[2] + m[2] * m[5] - m[4] * m[3]) / d;588 p[1] = (-p0 * m[1] + p1 * m[0] + m[4] * m[1] - m[5] * m[0]) / d;589 }590 static axialAlignedBoundingBox(rect, transform, output) {591 const m0 = transform[0];592 const m1 = transform[1];593 const m2 = transform[2];594 const m3 = transform[3];595 const m4 = transform[4];596 const m5 = transform[5];597 const r0 = rect[0];598 const r1 = rect[1];599 const r2 = rect[2];600 const r3 = rect[3];601 let a0 = m0 * r0 + m4;602 let a2 = a0;603 let a1 = m0 * r2 + m4;604 let a3 = a1;605 let b0 = m3 * r1 + m5;606 let b2 = b0;607 let b1 = m3 * r3 + m5;608 let b3 = b1;609 if (m1 !== 0 || m2 !== 0) {610 const m1r0 = m1 * r0;611 const m1r2 = m1 * r2;612 const m2r1 = m2 * r1;613 const m2r3 = m2 * r3;614 a0 += m2r1;615 a3 += m2r1;616 a1 += m2r3;617 a2 += m2r3;618 b0 += m1r0;619 b3 += m1r0;620 b1 += m1r2;621 b2 += m1r2;622 }623 output[0] = Math.min(output[0], a0, a1, a2, a3);624 output[1] = Math.min(output[1], b0, b1, b2, b3);625 output[2] = Math.max(output[2], a0, a1, a2, a3);626 output[3] = Math.max(output[3], b0, b1, b2, b3);627 }628 static inverseTransform(m) {629 const d = m[0] * m[3] - m[1] * m[2];630 return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];631 }632 static singularValueDecompose2dScale(matrix, output) {633 const m0 = matrix[0];634 const m1 = matrix[1];635 const m2 = matrix[2];636 const m3 = matrix[3];637 const a = m0 ** 2 + m1 ** 2;638 const b = m0 * m2 + m1 * m3;639 const c = m2 ** 2 + m3 ** 2;640 const first = (a + c) / 2;641 const second = Math.sqrt(first ** 2 - (a * c - b ** 2));642 output[0] = Math.sqrt(first + second || 1);643 output[1] = Math.sqrt(first - second || 1);644 }645 static normalizeRect(rect) {646 const r = rect.slice(0);647 if (rect[0] > rect[2]) {648 r[0] = rect[2];649 r[2] = rect[0];650 }651 if (rect[1] > rect[3]) {652 r[1] = rect[3];653 r[3] = rect[1];654 }655 return r;656 }657 static intersect(rect1, rect2) {658 const xLow = Math.max(Math.min(rect1[0], rect1[2]), Math.min(rect2[0], rect2[2]));659 const xHigh = Math.min(Math.max(rect1[0], rect1[2]), Math.max(rect2[0], rect2[2]));660 if (xLow > xHigh) {661 return null;662 }663 const yLow = Math.max(Math.min(rect1[1], rect1[3]), Math.min(rect2[1], rect2[3]));664 const yHigh = Math.min(Math.max(rect1[1], rect1[3]), Math.max(rect2[1], rect2[3]));665 if (yLow > yHigh) {666 return null;667 }668 return [xLow, yLow, xHigh, yHigh];669 }670 static pointBoundingBox(x, y, minMax) {671 minMax[0] = Math.min(minMax[0], x);672 minMax[1] = Math.min(minMax[1], y);673 minMax[2] = Math.max(minMax[2], x);674 minMax[3] = Math.max(minMax[3], y);675 }676 static rectBoundingBox(x0, y0, x1, y1, minMax) {677 minMax[0] = Math.min(minMax[0], x0, x1);678 minMax[1] = Math.min(minMax[1], y0, y1);679 minMax[2] = Math.max(minMax[2], x0, x1);680 minMax[3] = Math.max(minMax[3], y0, y1);681 }682 static #getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, t, minMax) {683 if (t <= 0 || t >= 1) {684 return;685 }686 const mt = 1 - t;687 const tt = t * t;688 const ttt = tt * t;689 const x = mt * (mt * (mt * x0 + 3 * t * x1) + 3 * tt * x2) + ttt * x3;690 const y = mt * (mt * (mt * y0 + 3 * t * y1) + 3 * tt * y2) + ttt * y3;691 minMax[0] = Math.min(minMax[0], x);692 minMax[1] = Math.min(minMax[1], y);693 minMax[2] = Math.max(minMax[2], x);694 minMax[3] = Math.max(minMax[3], y);695 }696 static #getExtremum(x0, x1, x2, x3, y0, y1, y2, y3, a, b, c, minMax) {697 if (Math.abs(a) < 1e-12) {698 if (Math.abs(b) >= 1e-12) {699 this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, -c / b, minMax);700 }701 return;702 }703 const delta = b ** 2 - 4 * c * a;704 if (delta < 0) {705 return;706 }707 const sqrtDelta = Math.sqrt(delta);708 const a2 = 2 * a;709 this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, (-b + sqrtDelta) / a2, minMax);710 this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, (-b - sqrtDelta) / a2, minMax);711 }712 static bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3, minMax) {713 minMax[0] = Math.min(minMax[0], x0, x3);714 minMax[1] = Math.min(minMax[1], y0, y3);715 minMax[2] = Math.max(minMax[2], x0, x3);716 minMax[3] = Math.max(minMax[3], y0, y3);717 this.#getExtremum(x0, x1, x2, x3, y0, y1, y2, y3, 3 * (-x0 + 3 * (x1 - x2) + x3), 6 * (x0 - 2 * x1 + x2), 3 * (x1 - x0), minMax);718 this.#getExtremum(x0, x1, x2, x3, y0, y1, y2, y3, 3 * (-y0 + 3 * (y1 - y2) + y3), 6 * (y0 - 2 * y1 + y2), 3 * (y1 - y0), minMax);719 }720}721const PDFStringTranslateTable = (/* unused pure expression or super */ null && ([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2d8, 0x2c7, 0x2c6, 0x2d9, 0x2dd, 0x2db, 0x2da, 0x2dc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192, 0x2044, 0x2039, 0x203a, 0x2212, 0x2030, 0x201e, 0x201c, 0x201d, 0x2018, 0x2019, 0x201a, 0x2122, 0xfb01, 0xfb02, 0x141, 0x152, 0x160, 0x178, 0x17d, 0x131, 0x142, 0x153, 0x161, 0x17e, 0, 0x20ac]));722function stringToPDFString(str, keepEscapeSequence = false) {723 if (str[0] >= "\xEF") {724 let encoding;725 if (str[0] === "\xFE" && str[1] === "\xFF") {726 encoding = "utf-16be";727 if (str.length % 2 === 1) {728 str = str.slice(0, -1);729 }730 } else if (str[0] === "\xFF" && str[1] === "\xFE") {731 encoding = "utf-16le";732 if (str.length % 2 === 1) {733 str = str.slice(0, -1);734 }735 } else if (str[0] === "\xEF" && str[1] === "\xBB" && str[2] === "\xBF") {736 encoding = "utf-8";737 }738 if (encoding) {739 try {740 const decoder = new TextDecoder(encoding, {741 fatal: true742 });743 const buffer = stringToBytes(str);744 const decoded = decoder.decode(buffer);745 if (keepEscapeSequence || !decoded.includes("\x1b")) {746 return decoded;747 }748 return decoded.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g, "");749 } catch (ex) {750 warn(`stringToPDFString: "${ex}".`);751 }752 }753 }754 const strBuf = [];755 for (let i = 0, ii = str.length; i < ii; i++) {756 const charCode = str.charCodeAt(i);757 if (!keepEscapeSequence && charCode === 0x1b) {758 while (++i < ii && str.charCodeAt(i) !== 0x1b) {}759 continue;760 }761 const code = PDFStringTranslateTable[charCode];762 strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));763 }764 return strBuf.join("");765}766function stringToUTF8String(str) {767 return decodeURIComponent(escape(str));768}769function utf8StringToString(str) {770 return unescape(encodeURIComponent(str));771}772function isArrayEqual(arr1, arr2) {773 if (arr1.length !== arr2.length) {774 return false;775 }776 for (let i = 0, ii = arr1.length; i < ii; i++) {777 if (arr1[i] !== arr2[i]) {778 return false;779 }780 }781 return true;782}783function getModificationDate(date = new Date()) {784 if (!(date instanceof Date)) {785 date = new Date(date);786 }787 const buffer = [date.getUTCFullYear().toString(), (date.getUTCMonth() + 1).toString().padStart(2, "0"), date.getUTCDate().toString().padStart(2, "0"), date.getUTCHours().toString().padStart(2, "0"), date.getUTCMinutes().toString().padStart(2, "0"), date.getUTCSeconds().toString().padStart(2, "0")];788 return buffer.join("");789}790let NormalizeRegex = null;791let NormalizationMap = null;792function normalizeUnicode(str) {793 if (!NormalizeRegex) {794 NormalizeRegex = /([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu;795 NormalizationMap = new Map([["ſt", "ſt"]]);796 }797 return str.replaceAll(NormalizeRegex, (_, p1, p2) => p1 ? p1.normalize("NFKC") : NormalizationMap.get(p2));798}799function getUuid() {800 if (typeof crypto.randomUUID === "function") {801 return crypto.randomUUID();802 }803 const buf = new Uint8Array(32);804 crypto.getRandomValues(buf);805 return bytesToString(buf);806}807const AnnotationPrefix = "pdfjs_internal_id_";808function _isValidExplicitDest(validRef, validName, dest) {809 if (!Array.isArray(dest) || dest.length < 2) {810 return false;811 }812 const [page, zoom, ...args] = dest;813 if (!validRef(page) && !Number.isInteger(page)) {814 return false;815 }816 if (!validName(zoom)) {817 return false;818 }819 const argsLen = args.length;820 let allowNull = true;821 switch (zoom.name) {822 case "XYZ":823 if (argsLen < 2 || argsLen > 3) {824 return false;825 }826 break;827 case "Fit":828 case "FitB":829 return argsLen === 0;830 case "FitH":831 case "FitBH":832 case "FitV":833 case "FitBV":834 if (argsLen > 1) {835 return false;836 }837 break;838 case "FitR":839 if (argsLen !== 4) {840 return false;841 }842 allowNull = false;843 break;844 default:845 return false;846 }847 for (const arg of args) {848 if (typeof arg === "number" || allowNull && arg === null) {849 continue;850 }851 return false;852 }853 return true;854}855function MathClamp(v, min, max) {856 return Math.min(Math.max(v, min), max);857}858function toHexUtil(arr) {859 if (Uint8Array.prototype.toHex) {860 return arr.toHex();861 }862 return Array.from(arr, num => hexNumbers[num]).join("");863}864function toBase64Util(arr) {865 if (Uint8Array.prototype.toBase64) {866 return arr.toBase64();867 }868 return btoa(bytesToString(arr));869}870function fromBase64Util(str) {871 if (Uint8Array.fromBase64) {872 return Uint8Array.fromBase64(str);873 }874 return stringToBytes(atob(str));875}876if (typeof Promise.try !== "function") {877 Promise.try = function (fn, ...args) {878 return new Promise(resolve => {879 resolve(fn(...args));880 });881 };882}883if (typeof Math.sumPrecise !== "function") {884 Math.sumPrecise = function (numbers) {885 return numbers.reduce((a, b) => a + b, 0);886 };887}888 889;// ./src/display/display_utils.js890 891const SVG_NS = "http://www.w3.org/2000/svg";892class PixelsPerInch {893 static CSS = 96.0;894 static PDF = 72.0;895 static PDF_TO_CSS_UNITS = this.CSS / this.PDF;896}897async function fetchData(url, type = "text") {898 if (isValidFetchUrl(url, document.baseURI)) {899 const response = await fetch(url);900 if (!response.ok) {901 throw new Error(response.statusText);902 }903 switch (type) {904 case "arraybuffer":905 return response.arrayBuffer();906 case "blob":907 return response.blob();908 case "json":909 return response.json();910 }911 return response.text();912 }913 return new Promise((resolve, reject) => {914 const request = new XMLHttpRequest();915 request.open("GET", url, true);916 request.responseType = type;917 request.onreadystatechange = () => {918 if (request.readyState !== XMLHttpRequest.DONE) {919 return;920 }921 if (request.status === 200 || request.status === 0) {922 switch (type) {923 case "arraybuffer":924 case "blob":925 case "json":926 resolve(request.response);927 return;928 }929 resolve(request.responseText);930 return;931 }932 reject(new Error(request.statusText));933 };934 request.send(null);935 });936}937class PageViewport {938 constructor({939 viewBox,940 userUnit,941 scale,942 rotation,943 offsetX = 0,944 offsetY = 0,945 dontFlip = false946 }) {947 this.viewBox = viewBox;948 this.userUnit = userUnit;949 this.scale = scale;950 this.rotation = rotation;951 this.offsetX = offsetX;952 this.offsetY = offsetY;953 scale *= userUnit;954 const centerX = (viewBox[2] + viewBox[0]) / 2;955 const centerY = (viewBox[3] + viewBox[1]) / 2;956 let rotateA, rotateB, rotateC, rotateD;957 rotation %= 360;958 if (rotation < 0) {959 rotation += 360;960 }961 switch (rotation) {962 case 180:963 rotateA = -1;964 rotateB = 0;965 rotateC = 0;966 rotateD = 1;967 break;968 case 90:969 rotateA = 0;970 rotateB = 1;971 rotateC = 1;972 rotateD = 0;973 break;974 case 270:975 rotateA = 0;976 rotateB = -1;977 rotateC = -1;978 rotateD = 0;979 break;980 case 0:981 rotateA = 1;982 rotateB = 0;983 rotateC = 0;984 rotateD = -1;985 break;986 default:987 throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.");988 }989 if (dontFlip) {990 rotateC = -rotateC;991 rotateD = -rotateD;992 }993 let offsetCanvasX, offsetCanvasY;994 let width, height;995 if (rotateA === 0) {996 offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;997 offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;998 width = (viewBox[3] - viewBox[1]) * scale;999 height = (viewBox[2] - viewBox[0]) * scale;1000 } else {1001 offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;1002 offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;1003 width = (viewBox[2] - viewBox[0]) * scale;1004 height = (viewBox[3] - viewBox[1]) * scale;1005 }1006 this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];1007 this.width = width;1008 this.height = height;1009 }1010 get rawDims() {1011 const dims = this.viewBox;1012 return shadow(this, "rawDims", {1013 pageWidth: dims[2] - dims[0],1014 pageHeight: dims[3] - dims[1],1015 pageX: dims[0],1016 pageY: dims[1]1017 });1018 }1019 clone({1020 scale = this.scale,1021 rotation = this.rotation,1022 offsetX = this.offsetX,1023 offsetY = this.offsetY,1024 dontFlip = false1025 } = {}) {1026 return new PageViewport({1027 viewBox: this.viewBox.slice(),1028 userUnit: this.userUnit,1029 scale,1030 rotation,1031 offsetX,1032 offsetY,1033 dontFlip1034 });1035 }1036 convertToViewportPoint(x, y) {1037 const p = [x, y];1038 Util.applyTransform(p, this.transform);1039 return p;1040 }1041 convertToViewportRectangle(rect) {1042 const topLeft = [rect[0], rect[1]];1043 Util.applyTransform(topLeft, this.transform);1044 const bottomRight = [rect[2], rect[3]];1045 Util.applyTransform(bottomRight, this.transform);1046 return [topLeft[0], topLeft[1], bottomRight[0], bottomRight[1]];1047 }1048 convertToPdfPoint(x, y) {1049 const p = [x, y];1050 Util.applyInverseTransform(p, this.transform);1051 return p;1052 }1053}1054class RenderingCancelledException extends BaseException {1055 constructor(msg, extraDelay = 0) {1056 super(msg, "RenderingCancelledException");1057 this.extraDelay = extraDelay;1058 }1059}1060function isDataScheme(url) {1061 const ii = url.length;1062 let i = 0;1063 while (i < ii && url[i].trim() === "") {1064 i++;1065 }1066 return url.substring(i, i + 5).toLowerCase() === "data:";1067}1068function isPdfFile(filename) {1069 return typeof filename === "string" && /\.pdf$/i.test(filename);1070}1071function getFilenameFromUrl(url) {1072 [url] = url.split(/[#?]/, 1);1073 return url.substring(url.lastIndexOf("/") + 1);1074}1075function getPdfFilenameFromUrl(url, defaultFilename = "document.pdf") {1076 if (typeof url !== "string") {1077 return defaultFilename;1078 }1079 if (isDataScheme(url)) {1080 warn('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');1081 return defaultFilename;1082 }1083 const getURL = urlString => {1084 try {1085 return new URL(urlString);1086 } catch {1087 try {1088 return new URL(decodeURIComponent(urlString));1089 } catch {1090 try {1091 return new URL(urlString, "https://foo.bar");1092 } catch {1093 try {1094 return new URL(decodeURIComponent(urlString), "https://foo.bar");1095 } catch {1096 return null;1097 }1098 }1099 }1100 }1101 };1102 const newURL = getURL(url);1103 if (!newURL) {1104 return defaultFilename;1105 }1106 const decode = name => {1107 try {1108 let decoded = decodeURIComponent(name);1109 if (decoded.includes("/")) {1110 decoded = decoded.split("/").at(-1);1111 if (decoded.test(/^\.pdf$/i)) {1112 return decoded;1113 }1114 return name;1115 }1116 return decoded;1117 } catch {1118 return name;1119 }1120 };1121 const pdfRegex = /\.pdf$/i;1122 const filename = newURL.pathname.split("/").at(-1);1123 if (pdfRegex.test(filename)) {1124 return decode(filename);1125 }1126 if (newURL.searchParams.size > 0) {1127 const values = Array.from(newURL.searchParams.values()).reverse();1128 for (const value of values) {1129 if (pdfRegex.test(value)) {1130 return decode(value);1131 }1132 }1133 const keys = Array.from(newURL.searchParams.keys()).reverse();1134 for (const key of keys) {1135 if (pdfRegex.test(key)) {1136 return decode(key);1137 }1138 }1139 }1140 if (newURL.hash) {1141 const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;1142 const hashFilename = reFilename.exec(newURL.hash);1143 if (hashFilename) {1144 return decode(hashFilename[0]);1145 }1146 }1147 return defaultFilename;1148}1149class StatTimer {1150 started = Object.create(null);1151 times = [];1152 time(name) {1153 if (name in this.started) {1154 warn(`Timer is already running for ${name}`);1155 }1156 this.started[name] = Date.now();1157 }1158 timeEnd(name) {1159 if (!(name in this.started)) {1160 warn(`Timer has not been started for ${name}`);1161 }1162 this.times.push({1163 name,1164 start: this.started[name],1165 end: Date.now()1166 });1167 delete this.started[name];1168 }1169 toString() {1170 const outBuf = [];1171 let longest = 0;1172 for (const {1173 name1174 } of this.times) {1175 longest = Math.max(name.length, longest);1176 }1177 for (const {1178 name,1179 start,1180 end1181 } of this.times) {1182 outBuf.push(`${name.padEnd(longest)} ${end - start}ms\n`);1183 }1184 return outBuf.join("");1185 }1186}1187function isValidFetchUrl(url, baseUrl) {1188 const res = baseUrl ? URL.parse(url, baseUrl) : URL.parse(url);1189 return res?.protocol === "http:" || res?.protocol === "https:";1190}1191function noContextMenu(e) {1192 e.preventDefault();1193}1194function stopEvent(e) {1195 e.preventDefault();1196 e.stopPropagation();1197}1198function deprecated(details) {1199 console.log("Deprecated API usage: " + details);1200}