chaite
Version:
core for chatgpt-plugin and karin-plugin-chatgpt
1,161 lines (1,153 loc) • 16.2 MB
JavaScript
'use strict';
var Stream = require('stream');
var http2 = require('http');
var Url = require('url');
var https2 = require('https');
var zlib = require('zlib');
var fs2 = require('fs');
var sysPath2 = require('path');
var crypto5 = require('crypto');
var async_hooks = require('async_hooks');
var fs = require('fs/promises');
var util = require('util');
var EventEmitter2 = require('events');
var os = require('os');
var web = require('stream/web');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var Stream__default = /*#__PURE__*/_interopDefault(Stream);
var http2__default = /*#__PURE__*/_interopDefault(http2);
var Url__default = /*#__PURE__*/_interopDefault(Url);
var https2__default = /*#__PURE__*/_interopDefault(https2);
var zlib__default = /*#__PURE__*/_interopDefault(zlib);
var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
var sysPath2__namespace = /*#__PURE__*/_interopNamespace(sysPath2);
var crypto5__namespace = /*#__PURE__*/_interopNamespace(crypto5);
var fs__default = /*#__PURE__*/_interopDefault(fs);
var util__default = /*#__PURE__*/_interopDefault(util);
var EventEmitter2__default = /*#__PURE__*/_interopDefault(EventEmitter2);
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
get: (a2, b2) => (typeof require !== "undefined" ? require : a2)[b2]
}) : x2)(function(x2) {
if (typeof require !== "undefined") return require.apply(this, arguments);
throw Error('Dynamic require of "' + x2 + '" is not supported');
});
var __glob = (map2) => (path8) => {
var fn = map2[path8];
if (fn) return fn();
throw new Error("Module not found in bundle: " + path8);
};
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb2, mod) => function __require2() {
return mod || (0, cb2[__getOwnPropNames(cb2)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all3) => {
for (var name in all3)
__defProp(target, name, { get: all3[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// node_modules/tsup/assets/cjs_shims.js
var getImportMetaUrl, importMetaUrl;
var init_cjs_shims = __esm({
"node_modules/tsup/assets/cjs_shims.js"() {
getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
}
});
// node_modules/node-ensure/index.js
var require_node_ensure = __commonJS({
"node_modules/node-ensure/index.js"(exports2, module2) {
init_cjs_shims();
function ensure(modules, callback) {
setImmediate(callback);
}
module2.exports = ensure;
}
});
// node_modules/pdf-parse/lib/pdf.js/v1.10.100/build/pdf.worker.js
var require_pdf_worker = __commonJS({
"node_modules/pdf-parse/lib/pdf.js/v1.10.100/build/pdf.worker.js"(exports2, module2) {
init_cjs_shims();
(function webpackUniversalModuleDefinition(root2, factory) {
if (typeof exports2 === "object" && typeof module2 === "object")
module2.exports = factory();
else if (typeof define === "function" && define.amd)
define("pdfjs-dist/build/pdf.worker", [], factory);
else if (typeof exports2 === "object")
exports2["pdfjs-dist/build/pdf.worker"] = factory();
else
root2["pdfjs-dist/build/pdf.worker"] = root2.pdfjsDistBuildPdfWorker = factory();
})(typeof self !== "undefined" ? self : exports2, function() {
return (
/******/
function(modules) {
var installedModules = {};
function __w_pdfjs_require__(moduleId) {
if (installedModules[moduleId]) {
return installedModules[moduleId].exports;
}
var module3 = installedModules[moduleId] = {
/******/
i: moduleId,
/******/
l: false,
/******/
exports: {}
/******/
};
modules[moduleId].call(module3.exports, module3, module3.exports, __w_pdfjs_require__);
module3.l = true;
return module3.exports;
}
__w_pdfjs_require__.m = modules;
__w_pdfjs_require__.c = installedModules;
__w_pdfjs_require__.d = function(exports3, name, getter) {
if (!__w_pdfjs_require__.o(exports3, name)) {
Object.defineProperty(exports3, name, {
/******/
configurable: false,
/******/
enumerable: true,
/******/
get: getter
/******/
});
}
};
__w_pdfjs_require__.n = function(module3) {
var getter = module3 && module3.__esModule ? (
/******/
function getDefault() {
return module3["default"];
}
) : (
/******/
function getModuleExports() {
return module3;
}
);
__w_pdfjs_require__.d(getter, "a", getter);
return getter;
};
__w_pdfjs_require__.o = function(object2, property2) {
return Object.prototype.hasOwnProperty.call(object2, property2);
};
__w_pdfjs_require__.p = "";
return __w_pdfjs_require__(__w_pdfjs_require__.s = 82);
}([
/* 0 */
/***/
function(module3, exports3, __w_pdfjs_require__) {
Object.defineProperty(exports3, "__esModule", {
value: true
});
exports3.unreachable = exports3.warn = exports3.utf8StringToString = exports3.stringToUTF8String = exports3.stringToPDFString = exports3.stringToBytes = exports3.string32 = exports3.shadow = exports3.setVerbosityLevel = exports3.ReadableStream = exports3.removeNullCharacters = exports3.readUint32 = exports3.readUint16 = exports3.readInt8 = exports3.log2 = exports3.loadJpegStream = exports3.isEvalSupported = exports3.isLittleEndian = exports3.createValidAbsoluteUrl = exports3.isSameOrigin = exports3.isNodeJS = exports3.isSpace = exports3.isString = exports3.isNum = exports3.isEmptyObj = exports3.isBool = exports3.isArrayBuffer = exports3.info = exports3.getVerbosityLevel = exports3.getLookupTableFactory = exports3.deprecated = exports3.createObjectURL = exports3.createPromiseCapability = exports3.createBlob = exports3.bytesToString = exports3.assert = exports3.arraysToBytes = exports3.arrayByteLength = exports3.FormatError = exports3.XRefParseException = exports3.Util = exports3.UnknownErrorException = exports3.UnexpectedResponseException = exports3.TextRenderingMode = exports3.StreamType = exports3.StatTimer = exports3.PasswordResponses = exports3.PasswordException = exports3.PageViewport = exports3.NotImplementedException = exports3.NativeImageDecoding = exports3.MissingPDFException = exports3.MissingDataException = exports3.MessageHandler = exports3.InvalidPDFException = exports3.AbortException = exports3.CMapCompressionType = exports3.ImageKind = exports3.FontType = exports3.AnnotationType = exports3.AnnotationFlag = exports3.AnnotationFieldFlag = exports3.AnnotationBorderStyleType = exports3.UNSUPPORTED_FEATURES = exports3.VERBOSITY_LEVELS = exports3.OPS = exports3.IDENTITY_MATRIX = exports3.FONT_IDENTITY_MATRIX = void 0;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj2) {
return typeof obj2;
} : function(obj2) {
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
};
__w_pdfjs_require__(84);
var _streams_polyfill = __w_pdfjs_require__(125);
var FONT_IDENTITY_MATRIX = [1e-3, 0, 0, 1e-3, 0, 0];
var NativeImageDecoding = {
NONE: "none",
DECODE: "decode",
DISPLAY: "display"
};
var TextRenderingMode = {
FILL: 0,
STROKE: 1,
FILL_STROKE: 2,
INVISIBLE: 3,
FILL_ADD_TO_PATH: 4,
STROKE_ADD_TO_PATH: 5,
FILL_STROKE_ADD_TO_PATH: 6,
ADD_TO_PATH: 7,
FILL_STROKE_MASK: 3,
ADD_TO_PATH_FLAG: 4
};
var ImageKind = {
GRAYSCALE_1BPP: 1,
RGB_24BPP: 2,
RGBA_32BPP: 3
};
var AnnotationType = {
TEXT: 1,
LINK: 2,
FREETEXT: 3,
LINE: 4,
SQUARE: 5,
CIRCLE: 6,
POLYGON: 7,
POLYLINE: 8,
HIGHLIGHT: 9,
UNDERLINE: 10,
SQUIGGLY: 11,
STRIKEOUT: 12,
STAMP: 13,
CARET: 14,
INK: 15,
POPUP: 16,
FILEATTACHMENT: 17,
SOUND: 18,
MOVIE: 19,
WIDGET: 20,
SCREEN: 21,
PRINTERMARK: 22,
TRAPNET: 23,
WATERMARK: 24,
THREED: 25,
REDACT: 26
};
var AnnotationFlag = {
INVISIBLE: 1,
HIDDEN: 2,
PRINT: 4,
NOZOOM: 8,
NOROTATE: 16,
NOVIEW: 32,
READONLY: 64,
LOCKED: 128,
TOGGLENOVIEW: 256,
LOCKEDCONTENTS: 512
};
var AnnotationFieldFlag = {
READONLY: 1,
REQUIRED: 2,
NOEXPORT: 4,
MULTILINE: 4096,
PASSWORD: 8192,
NOTOGGLETOOFF: 16384,
RADIO: 32768,
PUSHBUTTON: 65536,
COMBO: 131072,
EDIT: 262144,
SORT: 524288,
FILESELECT: 1048576,
MULTISELECT: 2097152,
DONOTSPELLCHECK: 4194304,
DONOTSCROLL: 8388608,
COMB: 16777216,
RICHTEXT: 33554432,
RADIOSINUNISON: 33554432,
COMMITONSELCHANGE: 67108864
};
var AnnotationBorderStyleType = {
SOLID: 1,
DASHED: 2,
BEVELED: 3,
INSET: 4,
UNDERLINE: 5
};
var StreamType = {
UNKNOWN: 0,
FLATE: 1,
LZW: 2,
DCT: 3,
JPX: 4,
JBIG: 5,
A85: 6,
AHX: 7,
CCF: 8,
RL: 9
};
var FontType = {
UNKNOWN: 0,
TYPE1: 1,
TYPE1C: 2,
CIDFONTTYPE0: 3,
CIDFONTTYPE0C: 4,
TRUETYPE: 5,
CIDFONTTYPE2: 6,
TYPE3: 7,
OPENTYPE: 8,
TYPE0: 9,
MMTYPE1: 10
};
var VERBOSITY_LEVELS = {
errors: 0,
warnings: 1,
infos: 5
};
var CMapCompressionType = {
NONE: 0,
BINARY: 1,
STREAM: 2
};
var OPS = {
dependency: 1,
setLineWidth: 2,
setLineCap: 3,
setLineJoin: 4,
setMiterLimit: 5,
setDash: 6,
setRenderingIntent: 7,
setFlatness: 8,
setGState: 9,
save: 10,
restore: 11,
transform: 12,
moveTo: 13,
lineTo: 14,
curveTo: 15,
curveTo2: 16,
curveTo3: 17,
closePath: 18,
rectangle: 19,
stroke: 20,
closeStroke: 21,
fill: 22,
eoFill: 23,
fillStroke: 24,
eoFillStroke: 25,
closeFillStroke: 26,
closeEOFillStroke: 27,
endPath: 28,
clip: 29,
eoClip: 30,
beginText: 31,
endText: 32,
setCharSpacing: 33,
setWordSpacing: 34,
setHScale: 35,
setLeading: 36,
setFont: 37,
setTextRenderingMode: 38,
setTextRise: 39,
moveText: 40,
setLeadingMoveText: 41,
setTextMatrix: 42,
nextLine: 43,
showText: 44,
showSpacedText: 45,
nextLineShowText: 46,
nextLineSetSpacingShowText: 47,
setCharWidth: 48,
setCharWidthAndBounds: 49,
setStrokeColorSpace: 50,
setFillColorSpace: 51,
setStrokeColor: 52,
setStrokeColorN: 53,
setFillColor: 54,
setFillColorN: 55,
setStrokeGray: 56,
setFillGray: 57,
setStrokeRGBColor: 58,
setFillRGBColor: 59,
setStrokeCMYKColor: 60,
setFillCMYKColor: 61,
shadingFill: 62,
beginInlineImage: 63,
beginImageData: 64,
endInlineImage: 65,
paintXObject: 66,
markPoint: 67,
markPointProps: 68,
beginMarkedContent: 69,
beginMarkedContentProps: 70,
endMarkedContent: 71,
beginCompat: 72,
endCompat: 73,
paintFormXObjectBegin: 74,
paintFormXObjectEnd: 75,
beginGroup: 76,
endGroup: 77,
beginAnnotations: 78,
endAnnotations: 79,
beginAnnotation: 80,
endAnnotation: 81,
paintJpegXObject: 82,
paintImageMaskXObject: 83,
paintImageMaskXObjectGroup: 84,
paintImageXObject: 85,
paintInlineImageXObject: 86,
paintInlineImageXObjectGroup: 87,
paintImageXObjectRepeat: 88,
paintImageMaskXObjectRepeat: 89,
paintSolidColorImageMask: 90,
constructPath: 91
};
var verbosity = VERBOSITY_LEVELS.warnings;
function setVerbosityLevel(level) {
verbosity = level;
}
function getVerbosityLevel() {
return verbosity;
}
function info(msg) {
if (verbosity >= VERBOSITY_LEVELS.infos) {
console.log("Info: " + msg);
}
}
function warn(msg) {
if (verbosity >= VERBOSITY_LEVELS.warnings) {
console.log("Warning: " + msg);
}
}
function deprecated(details) {
console.log("Deprecated API usage: " + details);
}
function unreachable(msg) {
throw new Error(msg);
}
function assert(cond, msg) {
if (!cond) {
unreachable(msg);
}
}
var UNSUPPORTED_FEATURES = {
unknown: "unknown",
forms: "forms",
javaScript: "javaScript",
smask: "smask",
shadingPattern: "shadingPattern",
font: "font"
};
function isSameOrigin(baseUrl, otherUrl) {
try {
var base = new URL(baseUrl);
if (!base.origin || base.origin === "null") {
return false;
}
} catch (e2) {
return false;
}
var other = new URL(otherUrl, base);
return base.origin === other.origin;
}
function isValidProtocol(url2) {
if (!url2) {
return false;
}
switch (url2.protocol) {
case "http:":
case "https:":
case "ftp:":
case "mailto:":
case "tel:":
return true;
default:
return false;
}
}
function createValidAbsoluteUrl(url2, baseUrl) {
if (!url2) {
return null;
}
try {
var absoluteUrl = baseUrl ? new URL(url2, baseUrl) : new URL(url2);
if (isValidProtocol(absoluteUrl)) {
return absoluteUrl;
}
} catch (ex) {
}
return null;
}
function shadow(obj2, prop, value) {
Object.defineProperty(obj2, prop, {
value,
enumerable: true,
configurable: true,
writable: false
});
return value;
}
function getLookupTableFactory(initializer) {
var lookup;
return function() {
if (initializer) {
lookup = /* @__PURE__ */ Object.create(null);
initializer(lookup);
initializer = null;
}
return lookup;
};
}
var PasswordResponses = {
NEED_PASSWORD: 1,
INCORRECT_PASSWORD: 2
};
var PasswordException = function PasswordExceptionClosure() {
function PasswordException2(msg, code) {
this.name = "PasswordException";
this.message = msg;
this.code = code;
}
PasswordException2.prototype = new Error();
PasswordException2.constructor = PasswordException2;
return PasswordException2;
}();
var UnknownErrorException = function UnknownErrorExceptionClosure() {
function UnknownErrorException2(msg, details) {
this.name = "UnknownErrorException";
this.message = msg;
this.details = details;
}
UnknownErrorException2.prototype = new Error();
UnknownErrorException2.constructor = UnknownErrorException2;
return UnknownErrorException2;
}();
var InvalidPDFException = function InvalidPDFExceptionClosure() {
function InvalidPDFException2(msg) {
this.name = "InvalidPDFException";
this.message = msg;
}
InvalidPDFException2.prototype = new Error();
InvalidPDFException2.constructor = InvalidPDFException2;
return InvalidPDFException2;
}();
var MissingPDFException = function MissingPDFExceptionClosure() {
function MissingPDFException2(msg) {
this.name = "MissingPDFException";
this.message = msg;
}
MissingPDFException2.prototype = new Error();
MissingPDFException2.constructor = MissingPDFException2;
return MissingPDFException2;
}();
var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
function UnexpectedResponseException2(msg, status) {
this.name = "UnexpectedResponseException";
this.message = msg;
this.status = status;
}
UnexpectedResponseException2.prototype = new Error();
UnexpectedResponseException2.constructor = UnexpectedResponseException2;
return UnexpectedResponseException2;
}();
var NotImplementedException = function NotImplementedExceptionClosure() {
function NotImplementedException2(msg) {
this.message = msg;
}
NotImplementedException2.prototype = new Error();
NotImplementedException2.prototype.name = "NotImplementedException";
NotImplementedException2.constructor = NotImplementedException2;
return NotImplementedException2;
}();
var MissingDataException = function MissingDataExceptionClosure() {
function MissingDataException2(begin, end) {
this.begin = begin;
this.end = end;
this.message = "Missing data [" + begin + ", " + end + ")";
}
MissingDataException2.prototype = new Error();
MissingDataException2.prototype.name = "MissingDataException";
MissingDataException2.constructor = MissingDataException2;
return MissingDataException2;
}();
var XRefParseException = function XRefParseExceptionClosure() {
function XRefParseException2(msg) {
this.message = msg;
}
XRefParseException2.prototype = new Error();
XRefParseException2.prototype.name = "XRefParseException";
XRefParseException2.constructor = XRefParseException2;
return XRefParseException2;
}();
var FormatError = function FormatErrorClosure() {
function FormatError2(msg) {
this.message = msg;
}
FormatError2.prototype = new Error();
FormatError2.prototype.name = "FormatError";
FormatError2.constructor = FormatError2;
return FormatError2;
}();
var AbortException = function AbortExceptionClosure() {
function AbortException2(msg) {
this.name = "AbortException";
this.message = msg;
}
AbortException2.prototype = new Error();
AbortException2.constructor = AbortException2;
return AbortException2;
}();
var NullCharactersRegExp = /\x00/g;
function removeNullCharacters(str2) {
if (typeof str2 !== "string") {
warn("The argument for removeNullCharacters must be a string.");
return str2;
}
return str2.replace(NullCharactersRegExp, "");
}
function bytesToString(bytes) {
assert(bytes !== null && (typeof bytes === "undefined" ? "undefined" : _typeof(bytes)) === "object" && bytes.length !== void 0, "Invalid argument for bytesToString");
var length = bytes.length;
var MAX_ARGUMENT_COUNT = 8192;
if (length < MAX_ARGUMENT_COUNT) {
return String.fromCharCode.apply(null, bytes);
}
var strBuf = [];
for (var i2 = 0; i2 < length; i2 += MAX_ARGUMENT_COUNT) {
var chunkEnd = Math.min(i2 + MAX_ARGUMENT_COUNT, length);
var chunk2 = bytes.subarray(i2, chunkEnd);
strBuf.push(String.fromCharCode.apply(null, chunk2));
}
return strBuf.join("");
}
function stringToBytes2(str2) {
assert(typeof str2 === "string", "Invalid argument for stringToBytes");
var length = str2.length;
var bytes = new Uint8Array(length);
for (var i2 = 0; i2 < length; ++i2) {
bytes[i2] = str2.charCodeAt(i2) & 255;
}
return bytes;
}
function arrayByteLength(arr) {
if (arr.length !== void 0) {
return arr.length;
}
assert(arr.byteLength !== void 0);
return arr.byteLength;
}
function arraysToBytes(arr) {
if (arr.length === 1 && arr[0] instanceof Uint8Array) {
return arr[0];
}
var resultLength = 0;
var i2, ii = arr.length;
var item, itemLength;
for (i2 = 0; i2 < ii; i2++) {
item = arr[i2];
itemLength = arrayByteLength(item);
resultLength += itemLength;
}
var pos = 0;
var data = new Uint8Array(resultLength);
for (i2 = 0; i2 < ii; i2++) {
item = arr[i2];
if (!(item instanceof Uint8Array)) {
if (typeof item === "string") {
item = stringToBytes2(item);
} else {
item = new Uint8Array(item);
}
}
itemLength = item.byteLength;
data.set(item, pos);
pos += itemLength;
}
return data;
}
function string32(value) {
return String.fromCharCode(value >> 24 & 255, value >> 16 & 255, value >> 8 & 255, value & 255);
}
function log2(x2) {
var n2 = 1, i2 = 0;
while (x2 > n2) {
n2 <<= 1;
i2++;
}
return i2;
}
function readInt8(data, start) {
return data[start] << 24 >> 24;
}
function readUint16(data, offset) {
return data[offset] << 8 | data[offset + 1];
}
function readUint32(data, offset) {
return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
}
function isLittleEndian() {
var buffer8 = new Uint8Array(4);
buffer8[0] = 1;
var view32 = new Uint32Array(buffer8.buffer, 0, 1);
return view32[0] === 1;
}
function isEvalSupported() {
try {
new Function("");
return true;
} catch (e2) {
return false;
}
}
var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
var Util = function UtilClosure() {
function Util2() {
}
var rgbBuf = ["rgb(", 0, ",", 0, ",", 0, ")"];
Util2.makeCssRgb = function Util_makeCssRgb(r2, g2, b2) {
rgbBuf[1] = r2;
rgbBuf[3] = g2;
rgbBuf[5] = b2;
return rgbBuf.join("");
};
Util2.transform = function Util_transform(m1, m2) {
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]];
};
Util2.applyTransform = function Util_applyTransform(p2, m2) {
var xt2 = p2[0] * m2[0] + p2[1] * m2[2] + m2[4];
var yt2 = p2[0] * m2[1] + p2[1] * m2[3] + m2[5];
return [xt2, yt2];
};
Util2.applyInverseTransform = function Util_applyInverseTransform(p2, m2) {
var d2 = m2[0] * m2[3] - m2[1] * m2[2];
var xt2 = (p2[0] * m2[3] - p2[1] * m2[2] + m2[2] * m2[5] - m2[4] * m2[3]) / d2;
var yt2 = (-p2[0] * m2[1] + p2[1] * m2[0] + m2[4] * m2[1] - m2[5] * m2[0]) / d2;
return [xt2, yt2];
};
Util2.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r2, m2) {
var p1 = Util2.applyTransform(r2, m2);
var p2 = Util2.applyTransform(r2.slice(2, 4), m2);
var p3 = Util2.applyTransform([r2[0], r2[3]], m2);
var p4 = Util2.applyTransform([r2[2], r2[1]], m2);
return [Math.min(p1[0], p2[0], p3[0], p4[0]), Math.min(p1[1], p2[1], p3[1], p4[1]), Math.max(p1[0], p2[0], p3[0], p4[0]), Math.max(p1[1], p2[1], p3[1], p4[1])];
};
Util2.inverseTransform = function Util_inverseTransform(m2) {
var d2 = m2[0] * m2[3] - m2[1] * m2[2];
return [m2[3] / d2, -m2[1] / d2, -m2[2] / d2, m2[0] / d2, (m2[2] * m2[5] - m2[4] * m2[3]) / d2, (m2[4] * m2[1] - m2[5] * m2[0]) / d2];
};
Util2.apply3dTransform = function Util_apply3dTransform(m2, v2) {
return [m2[0] * v2[0] + m2[1] * v2[1] + m2[2] * v2[2], m2[3] * v2[0] + m2[4] * v2[1] + m2[5] * v2[2], m2[6] * v2[0] + m2[7] * v2[1] + m2[8] * v2[2]];
};
Util2.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m2) {
var transpose = [m2[0], m2[2], m2[1], m2[3]];
var a2 = m2[0] * transpose[0] + m2[1] * transpose[2];
var b2 = m2[0] * transpose[1] + m2[1] * transpose[3];
var c2 = m2[2] * transpose[0] + m2[3] * transpose[2];
var d2 = m2[2] * transpose[1] + m2[3] * transpose[3];
var first2 = (a2 + d2) / 2;
var second = Math.sqrt((a2 + d2) * (a2 + d2) - 4 * (a2 * d2 - c2 * b2)) / 2;
var sx = first2 + second || 1;
var sy = first2 - second || 1;
return [Math.sqrt(sx), Math.sqrt(sy)];
};
Util2.normalizeRect = function Util_normalizeRect(rect) {
var r2 = rect.slice(0);
if (rect[0] > rect[2]) {
r2[0] = rect[2];
r2[2] = rect[0];
}
if (rect[1] > rect[3]) {
r2[1] = rect[3];
r2[3] = rect[1];
}
return r2;
};
Util2.intersect = function Util_intersect(rect1, rect2) {
function compare(a2, b2) {
return a2 - b2;
}
var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare), orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare), result2 = [];
rect1 = Util2.normalizeRect(rect1);
rect2 = Util2.normalizeRect(rect2);
if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
result2[0] = orderedX[1];
result2[2] = orderedX[2];
} else {
return false;
}
if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
result2[1] = orderedY[1];
result2[3] = orderedY[2];
} else {
return false;
}
return result2;
};
var ROMAN_NUMBER_MAP = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM", "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC", "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"];
Util2.toRoman = function Util_toRoman(number, lowerCase) {
assert(Number.isInteger(number) && number > 0, "The number should be a positive integer.");
var pos, romanBuf = [];
while (number >= 1e3) {
number -= 1e3;
romanBuf.push("M");
}
pos = number / 100 | 0;
number %= 100;
romanBuf.push(ROMAN_NUMBER_MAP[pos]);
pos = number / 10 | 0;
number %= 10;
romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
var romanStr = romanBuf.join("");
return lowerCase ? romanStr.toLowerCase() : romanStr;
};
Util2.appendToArray = function Util_appendToArray(arr1, arr2) {
Array.prototype.push.apply(arr1, arr2);
};
Util2.prependToArray = function Util_prependToArray(arr1, arr2) {
Array.prototype.unshift.apply(arr1, arr2);
};
Util2.extendObj = function extendObj(obj1, obj2) {
for (var key in obj2) {
obj1[key] = obj2[key];
}
};
Util2.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
while (dict && !dict.has(name)) {
dict = dict.get("Parent");
}
if (!dict) {
return null;
}
return getArray ? dict.getArray(name) : dict.get(name);
};
Util2.inherit = function Util_inherit(sub, base, prototype3) {
sub.prototype = Object.create(base.prototype);
sub.prototype.constructor = sub;
for (var prop in prototype3) {
sub.prototype[prop] = prototype3[prop];
}
};
Util2.loadScript = function Util_loadScript(src, callback) {
var script = document.createElement("script");
var loaded = false;
script.setAttribute("src", src);
if (callback) {
script.onload = function() {
if (!loaded) {
callback();
}
loaded = true;
};
}
document.getElementsByTagName("head")[0].appendChild(script);
};
return Util2;
}();
var PageViewport = function PageViewportClosure() {
function PageViewport2(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
this.viewBox = viewBox;
this.scale = scale;
this.rotation = rotation;
this.offsetX = offsetX;
this.offsetY = offsetY;
var centerX = (viewBox[2] + viewBox[0]) / 2;
var centerY = (viewBox[3] + viewBox[1]) / 2;
var rotateA, rotateB, rotateC, rotateD;
rotation = rotation % 360;
rotation = rotation < 0 ? rotation + 360 : rotation;
switch (rotation) {
case 180:
rotateA = -1;
rotateB = 0;
rotateC = 0;
rotateD = 1;
break;
case 90:
rotateA = 0;
rotateB = 1;
rotateC = 1;
rotateD = 0;
break;
case 270:
rotateA = 0;
rotateB = -1;
rotateC = -1;
rotateD = 0;
break;
default:
rotateA = 1;
rotateB = 0;
rotateC = 0;
rotateD = -1;
break;
}
if (dontFlip) {
rotateC = -rotateC;
rotateD = -rotateD;
}
var offsetCanvasX, offsetCanvasY;
var width, height;
if (rotateA === 0) {
offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
width = Math.abs(viewBox[3] - viewBox[1]) * scale;
height = Math.abs(viewBox[2] - viewBox[0]) * scale;
} else {
offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
width = Math.abs(viewBox[2] - viewBox[0]) * scale;
height = Math.abs(viewBox[3] - viewBox[1]) * scale;
}
this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];
this.width = width;
this.height = height;
this.fontScale = scale;
}
PageViewport2.prototype = {
clone: function PageViewPort_clone(args) {
args = args || {};
var scale = "scale" in args ? args.scale : this.scale;
var rotation = "rotation" in args ? args.rotation : this.rotation;
return new PageViewport2(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
},
convertToViewportPoint: function PageViewport_convertToViewportPoint(x2, y2) {
return Util.applyTransform([x2, y2], this.transform);
},
convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
var tl = Util.applyTransform([rect[0], rect[1]], this.transform);
var br2 = Util.applyTransform([rect[2], rect[3]], this.transform);
return [tl[0], tl[1], br2[0], br2[1]];
},
convertToPdfPoint: function PageViewport_convertToPdfPoint(x2, y2) {
return Util.applyInverseTransform([x2, y2], this.transform);
}
};
return PageViewport2;
}();
var PDFStringTranslateTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 728, 711, 710, 729, 733, 731, 730, 732, 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, 8226, 8224, 8225, 8230, 8212, 8211, 402, 8260, 8249, 8250, 8722, 8240, 8222, 8220, 8221, 8216, 8217, 8218, 8482, 64257, 64258, 321, 338, 352, 376, 381, 305, 322, 339, 353, 382, 0, 8364];
function stringToPDFString(str2) {
var i2, n2 = str2.length, strBuf = [];
if (str2[0] === "\xFE" && str2[1] === "\xFF") {
for (i2 = 2; i2 < n2; i2 += 2) {
strBuf.push(String.fromCharCode(str2.charCodeAt(i2) << 8 | str2.charCodeAt(i2 + 1)));
}
} else {
for (i2 = 0; i2 < n2; ++i2) {
var code = PDFStringTranslateTable[str2.charCodeAt(i2)];
strBuf.push(code ? String.fromCharCode(code) : str2.charAt(i2));
}
}
return strBuf.join("");
}
function stringToUTF8String(str2) {
return decodeURIComponent(escape(str2));
}
function utf8StringToString(str2) {
return unescape(encodeURIComponent(str2));
}
function isEmptyObj3(obj2) {
for (var key in obj2) {
return false;
}
return true;
}
function isBool(v2) {
return typeof v2 === "boolean";
}
function isNum(v2) {
return typeof v2 === "number";
}
function isString2(v2) {
return typeof v2 === "string";
}
function isArrayBuffer2(v2) {
return (typeof v2 === "undefined" ? "undefined" : _typeof(v2)) === "object" && v2 !== null && v2.byteLength !== void 0;
}
function isSpace(ch) {
return ch === 32 || ch === 9 || ch === 13 || ch === 10;
}
function isNodeJS() {
return (typeof process === "undefined" ? "undefined" : _typeof(process)) === "object" && process + "" === "[object process]";
}
function createPromiseCapability() {
var capability = {};
capability.promise = new Promise(function(resolve4, reject2) {
capability.resolve = resolve4;
capability.reject = reject2;
});
return capability;
}
var StatTimer = function StatTimerClosure() {
function rpad(str2, pad, length) {
while (str2.length < length) {
str2 += pad;
}
return str2;
}
function StatTimer2() {
this.started = /* @__PURE__ */ Object.create(null);
this.times = [];
this.enabled = true;
}
StatTimer2.prototype = {
time: function StatTimer_time(name) {
if (!this.enabled) {
return;
}
if (name in this.started) {
warn("Timer is already running for " + name);
}
this.started[name] = Date.now();
},
timeEnd: function StatTimer_timeEnd(name) {
if (!this.enabled) {
return;
}
if (!(name in this.started)) {
warn("Timer has not been started for " + name);
}
this.times.push({
"name": name,
"start": this.started[name],
"end": Date.now()
});
delete this.started[name];
},
toString: function StatTimer_toString() {
var i2, ii;
var times2 = this.times;
var out = "";
var longest = 0;
for (i2 = 0, ii = times2.length; i2 < ii; ++i2) {
var name = times2[i2]["name"];
if (name.length > longest) {
longest = name.length;
}
}
for (i2 = 0, ii = times2.length; i2 < ii; ++i2) {
var span = times2[i2];
var duration = span.end - span.start;
out += rpad(span["name"], " ", longest) + " " + duration + "ms\n";
}
return out;
}
};
return StatTimer2;
}();
var createBlob = function createBlob2(data, contentType) {
if (typeof Blob !== "undefined") {
return new Blob([data], { type: contentType });
}
throw new Error('The "Blob" constructor is not supported.');
};
var createObjectURL = /* @__PURE__ */ function createObjectURLClosure() {
var digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
return function createObjectURL2(data, contentType) {
var forceDataSchema = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
if (!forceDataSchema && URL.createObjectURL) {
var blob = createBlob(data, contentType);
return URL.createObjectURL(blob);
}
var buffer = "data:" + contentType + ";base64,";
for (var i2 = 0, ii = data.length; i2 < ii; i2 += 3) {
var b1 = data[i2] & 255;
var b2 = data[i2 + 1] & 255;
var b3 = data[i2 + 2] & 255;
var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
var d3 = i2 + 1 < ii ? (b2 & 15) << 2 | b3 >> 6 : 64;
var d4 = i2 + 2 < ii ? b3 & 63 : 64;
buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
}
return buffer;
};
}();
function resolveCall(fn, args) {
var thisArg = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
if (!fn) {
return Promise.resolve(void 0);
}
return new Promise(function(resolve4, reject2) {
resolve4(fn.apply(thisArg, args));
});
}
function wrapReason(reason) {
if ((typeof reason === "undefined" ? "undefined" : _typeof(reason)) !== "object") {
return reason;
}
switch (reason.name) {
case "AbortException":
return new AbortException(reason.message);
case "MissingPDFException":
return new MissingPDFException(reason.message);
case "UnexpectedResponseException":
return new UnexpectedResponseException(reason.message, reason.status);
default:
return new UnknownErrorException(reason.message, reason.details);
}
}
function makeReasonSerializable(reason) {
if (!(reason instanceof Error) || reason instanceof AbortException || reason instanceof MissingPDFException || reason instanceof UnexpectedResponseException || reason instanceof UnknownErrorException) {
return reason;
}
return new UnknownErrorException(reason.message, reason.toString());
}
function resolveOrReject(capability, success, reason) {
if (success) {
capability.resolve();
} else {
capability.reject(reason);
}
}
function finalize(promise) {
return Promise.resolve(promise).catch(function() {
});
}
function MessageHandler(sourceName, targetName, comObj) {
var _this = this;
this.sourceName = sourceName;
this.targetName = targetName;
this.comObj = comObj;
this.callbackId = 1;
this.streamId = 1;
this.postMessageTransfers = true;
this.streamSinks = /* @__PURE__ */ Object.create(null);
this.streamControllers = /* @__PURE__ */ Object.create(null);
var callbacksCapabilities = this.callbacksCapabilities = /* @__PURE__ */ Object.create(null);
var ah = this.actionHandler = /* @__PURE__ */ Object.create(null);
this._onComObjOnMessage = function(event) {
var data = event.data;
if (data.targetName !== _this.sourceName) {
return;
}
if (data.stream) {
_this._processStreamMessage(data);
} else if (data.isReply) {
var callbackId = data.callbackId;
if (data.callbackId in callbacksCapabilities) {
var callback = callbacksCapabilities[callbackId];
delete callbacksCapabilities[callbackId];
if ("error" in data) {
callback.reject(wrapReason(data.error));
} else {
callback.resolve(data.data);
}
} else {
throw new Error("Cannot resolve callback " + callbackId);
}
} else if (data.action in ah) {
var action = ah[data.action];
if (data.callbackId) {
var _sourceName = _this.sourceName;
var _targetName = data.sourceName;
Promise.resolve().then(function() {
return action[0].call(action[1], data.data);
}).then(function(result2) {
comObj.postMessage({
sourceName: _s