Team Ai
Datasetpublic

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.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3.1kdownloads
pdf.image_decoders.mjs7687 linesDownload Raw Back to image_decoders
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 = (/* unused pure expression or super */ null && ([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 util_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 util_warn(msg) {326  if (verbosity >= VerbosityLevel.WARNINGS) {327    console.log(`Warning: ${msg}`);328  }329}330function unreachable(msg) {331  throw new Error(msg);332}333function util_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 util_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 util_hexNumbers = Array.from(Array(256).keys(), n => n.toString(16).padStart(2, "0"));512class util_Util {513  static makeHexColor(r, g, b) {514    return `#${util_hexNumbers[r]}${util_hexNumbers[g]}${util_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 util_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        util_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 => util_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/core/primitives.js890 891const CIRCULAR_REF = Symbol("CIRCULAR_REF");892const EOF = Symbol("EOF");893let CmdCache = Object.create(null);894let NameCache = Object.create(null);895let RefCache = Object.create(null);896function clearPrimitiveCaches() {897  CmdCache = Object.create(null);898  NameCache = Object.create(null);899  RefCache = Object.create(null);900}901class Name {902  constructor(name) {903    this.name = name;904  }905  static get(name) {906    return NameCache[name] ||= new Name(name);907  }908}909class Cmd {910  constructor(cmd) {911    this.cmd = cmd;912  }913  static get(cmd) {914    return CmdCache[cmd] ||= new Cmd(cmd);915  }916}917const nonSerializable = function nonSerializableClosure() {918  return nonSerializable;919};920class primitives_Dict {921  constructor(xref = null) {922    this._map = new Map();923    this.xref = xref;924    this.objId = null;925    this.suppressEncryption = false;926    this.__nonSerializable__ = nonSerializable;927  }928  assignXref(newXref) {929    this.xref = newXref;930  }931  get size() {932    return this._map.size;933  }934  get(key1, key2, key3) {935    let value = this._map.get(key1);936    if (value === undefined && key2 !== undefined) {937      value = this._map.get(key2);938      if (value === undefined && key3 !== undefined) {939        value = this._map.get(key3);940      }941    }942    if (value instanceof primitives_Ref && this.xref) {943      return this.xref.fetch(value, this.suppressEncryption);944    }945    return value;946  }947  async getAsync(key1, key2, key3) {948    let value = this._map.get(key1);949    if (value === undefined && key2 !== undefined) {950      value = this._map.get(key2);951      if (value === undefined && key3 !== undefined) {952        value = this._map.get(key3);953      }954    }955    if (value instanceof primitives_Ref && this.xref) {956      return this.xref.fetchAsync(value, this.suppressEncryption);957    }958    return value;959  }960  getArray(key1, key2, key3) {961    let value = this._map.get(key1);962    if (value === undefined && key2 !== undefined) {963      value = this._map.get(key2);964      if (value === undefined && key3 !== undefined) {965        value = this._map.get(key3);966      }967    }968    if (value instanceof primitives_Ref && this.xref) {969      value = this.xref.fetch(value, this.suppressEncryption);970    }971    if (Array.isArray(value)) {972      value = value.slice();973      for (let i = 0, ii = value.length; i < ii; i++) {974        if (value[i] instanceof primitives_Ref && this.xref) {975          value[i] = this.xref.fetch(value[i], this.suppressEncryption);976        }977      }978    }979    return value;980  }981  getRaw(key) {982    return this._map.get(key);983  }984  getKeys() {985    return [...this._map.keys()];986  }987  getRawValues() {988    return [...this._map.values()];989  }990  set(key, value) {991    this._map.set(key, value);992  }993  setIfNotExists(key, value) {994    if (!this.has(key)) {995      this.set(key, value);996    }997  }998  setIfNumber(key, value) {999    if (typeof value === "number") {1000      this.set(key, value);1001    }1002  }1003  setIfArray(key, value) {1004    if (Array.isArray(value) || ArrayBuffer.isView(value)) {1005      this.set(key, value);1006    }1007  }1008  setIfDefined(key, value) {1009    if (value !== undefined && value !== null) {1010      this.set(key, value);1011    }1012  }1013  setIfName(key, value) {1014    if (typeof value === "string") {1015      this.set(key, Name.get(value));1016    } else if (value instanceof Name) {1017      this.set(key, value);1018    }1019  }1020  has(key) {1021    return this._map.has(key);1022  }1023  *[Symbol.iterator]() {1024    for (const [key, value] of this._map) {1025      yield [key, value instanceof primitives_Ref && this.xref ? this.xref.fetch(value, this.suppressEncryption) : value];1026    }1027  }1028  static get empty() {1029    const emptyDict = new primitives_Dict(null);1030    emptyDict.set = (key, value) => {1031      unreachable("Should not call `set` on the empty dictionary.");1032    };1033    return shadow(this, "empty", emptyDict);1034  }1035  static merge({1036    xref,1037    dictArray,1038    mergeSubDicts = false1039  }) {1040    const mergedDict = new primitives_Dict(xref),1041      properties = new Map();1042    for (const dict of dictArray) {1043      if (!(dict instanceof primitives_Dict)) {1044        continue;1045      }1046      for (const [key, value] of dict._map) {1047        let property = properties.get(key);1048        if (property === undefined) {1049          property = [];1050          properties.set(key, property);1051        } else if (!mergeSubDicts || !(value instanceof primitives_Dict)) {1052          continue;1053        }1054        property.push(value);1055      }1056    }1057    for (const [name, values] of properties) {1058      if (values.length === 1 || !(values[0] instanceof primitives_Dict)) {1059        mergedDict._map.set(name, values[0]);1060        continue;1061      }1062      const subDict = new primitives_Dict(xref);1063      for (const dict of values) {1064        for (const [key, value] of dict._map) {1065          if (!subDict._map.has(key)) {1066            subDict._map.set(key, value);1067          }1068        }1069      }1070      if (subDict.size > 0) {1071        mergedDict._map.set(name, subDict);1072      }1073    }1074    properties.clear();1075    return mergedDict.size > 0 ? mergedDict : primitives_Dict.empty;1076  }1077  clone() {1078    const dict = new primitives_Dict(this.xref);1079    for (const key of this.getKeys()) {1080      dict.set(key, this.getRaw(key));1081    }1082    return dict;1083  }1084  delete(key) {1085    delete this._map[key];1086  }1087}1088class primitives_Ref {1089  constructor(num, gen) {1090    this.num = num;1091    this.gen = gen;1092  }1093  toString() {1094    if (this.gen === 0) {1095      return `${this.num}R`;1096    }1097    return `${this.num}R${this.gen}`;1098  }1099  static fromString(str) {1100    const ref = RefCache[str];1101    if (ref) {1102      return ref;1103    }1104    const m = /^(\d+)R(\d*)$/.exec(str);1105    if (!m || m[1] === "0") {1106      return null;1107    }1108    return RefCache[str] = new primitives_Ref(parseInt(m[1]), !m[2] ? 0 : parseInt(m[2]));1109  }1110  static get(num, gen) {1111    const key = gen === 0 ? `${num}R` : `${num}R${gen}`;1112    return RefCache[key] ||= new primitives_Ref(num, gen);1113  }1114}1115class primitives_RefSet {1116  constructor(parent = null) {1117    this._set = new Set(parent?._set);1118  }1119  has(ref) {1120    return this._set.has(ref.toString());1121  }1122  put(ref) {1123    this._set.add(ref.toString());1124  }1125  remove(ref) {1126    this._set.delete(ref.toString());1127  }1128  [Symbol.iterator]() {1129    return this._set.values();1130  }1131  clear() {1132    this._set.clear();1133  }1134}1135class RefSetCache {1136  constructor() {1137    this._map = new Map();1138  }1139  get size() {1140    return this._map.size;1141  }1142  get(ref) {1143    return this._map.get(ref.toString());1144  }1145  has(ref) {1146    return this._map.has(ref.toString());1147  }1148  put(ref, obj) {1149    this._map.set(ref.toString(), obj);1150  }1151  putAlias(ref, aliasRef) {1152    this._map.set(ref.toString(), this.get(aliasRef));1153  }1154  [Symbol.iterator]() {1155    return this._map.values();1156  }1157  clear() {1158    this._map.clear();1159  }1160  *values() {1161    yield* this._map.values();1162  }1163  *items() {1164    for (const [ref, value] of this._map) {1165      yield [primitives_Ref.fromString(ref), value];1166    }1167  }1168}1169function primitives_isName(v, name) {1170  return v instanceof Name && (name === undefined || v.name === name);1171}1172function isCmd(v, cmd) {1173  return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);1174}1175function isDict(v, type) {1176  return v instanceof primitives_Dict && (type === undefined || primitives_isName(v.get("Type"), type));1177}1178function isRefsEqual(v1, v2) {1179  return v1.num === v2.num && v1.gen === v2.gen;1180}1181 1182;// ./src/core/base_stream.js1183 1184class base_stream_BaseStream {1185  get length() {1186    unreachable("Abstract getter `length` accessed");1187  }1188  get isEmpty() {1189    unreachable("Abstract getter `isEmpty` accessed");1190  }1191  get isDataLoaded() {1192    return shadow(this, "isDataLoaded", true);1193  }1194  getByte() {1195    unreachable("Abstract method `getByte` called");1196  }1197  getBytes(length) {1198    unreachable("Abstract method `getBytes` called");1199  }1200  async getImageData(length, decoderOptions) {

Showing the first 1,200 of 7687 lines. Download the file for the rest.

Brunobkr/llama.cpp_AlgMor24_github · Team Ai