https://www.revistalopinio.cat/wp-content/plugins/pdfjs-viewer-shortcode/pdfjs/web/viewer.js?v=3.1.1
1/** 2 * @licstart The following is the entire license notice for the 3 * JavaScript code in this page 4 * 5 * Copyright 2024 Mozilla Foundation 6 * 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 at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * 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 and 17 * limitations under the License. 18 * 19 * @licend The above is the entire license notice for the 20 * JavaScript code in this page 21 */ 22 23/** 24 * pdfjsVersion = 5.5.207 25 * pdfjsBuild = 527964698 26 */ 27/******/ var __webpack_modules__ = ({ 28 29/***/ 9306 30(module, __unused_webpack_exports, __webpack_require__) { 31 32 33var isCallable = __webpack_require__(4901); 34var tryToString = __webpack_require__(6823); 35 36var $TypeError = TypeError; 37 38// `Assert: IsCallable(argument) is true` 39module.exports = function (argument) { 40 if (isCallable(argument)) return argument; 41 throw new $TypeError(tryToString(argument) + ' is not a function'); 42}; 43 44 45/***/ }, 46 47/***/ 6194 48(module, __unused_webpack_exports, __webpack_require__) { 49 50 51var has = (__webpack_require__(2248).has); 52 53// Perform ? RequireInternalSlot(M, [[MapData]]) 54module.exports = function (it) { 55 has(it); 56 return it; 57}; 58 59 60/***/ }, 61 62/***/ 3506 63(module, __unused_webpack_exports, __webpack_require__) { 64 65 66var isPossiblePrototype = __webpack_require__(3925); 67 68var $String = String; 69var $TypeError = TypeError; 70 71module.exports = function (argument) { 72 if (isPossiblePrototype(argument)) return argument; 73 throw new $TypeError("Can't set " + $String(argument) + ' as a prototype'); 74}; 75 76 77/***/ }, 78 79/***/ 7080 80(module, __unused_webpack_exports, __webpack_require__) { 81 82 83var has = (__webpack_require__(4402).has); 84 85// Perform ? RequireInternalSlot(M, [[SetData]]) 86module.exports = function (it) { 87 has(it); 88 return it; 89}; 90 91 92/***/ }, 93 94/***/ 3463 95(module) { 96 97 98var $TypeError = TypeError; 99 100module.exports = function (argument) { 101 if (typeof argument == 'string') return argument; 102 throw new $TypeError('Argument is not a string'); 103}; 104 105 106/***/ }, 107 108/***/ 4328 109(module, __unused_webpack_exports, __webpack_require__) { 110 111 112var WeakMapHelpers = __webpack_require__(4995); 113 114var weakmap = new WeakMapHelpers.WeakMap(); 115var set = WeakMapHelpers.set; 116var remove = WeakMapHelpers.remove; 117 118module.exports = function (key) { 119 set(weakmap, key, 1); 120 remove(weakmap, key); 121 return key; 122}; 123 124 125/***/ }, 126 127/***/ 6557 128(module, __unused_webpack_exports, __webpack_require__) { 129 130 131var has = (__webpack_require__(4995).has); 132 133// Perform ? RequireInternalSlot(M, [[WeakMapData]]) 134module.exports = function (it) { 135 has(it); 136 return it; 137}; 138 139 140/***/ }, 141 142/***/ 679 143(module, __unused_webpack_exports, __webpack_require__) { 144 145 146var isPrototypeOf = __webpack_require__(1625); 147 148var $TypeError = TypeError; 149 150module.exports = function (it, Prototype) { 151 if (isPrototypeOf(Prototype, it)) return it; 152 throw new $TypeError('Incorrect invocation'); 153}; 154 155 156/***/ }, 157 158/***/ 8551 159(module, __unused_webpack_exports, __webpack_require__) { 160 161 162var isObject = __webpack_require__(34); 163 164var $String = String; 165var $TypeError = TypeError; 166 167// `Assert: Type(argument) is Object` 168module.exports = function (argument) { 169 if (isObject(argument)) return argument; 170 throw new $TypeError($String(argument) + ' is not an object'); 171}; 172 173 174/***/ }, 175 176/***/ 7811 177(module) { 178 179 180// eslint-disable-next-line es/no-typed-arrays -- safe 181module.exports = typeof ArrayBuffer != 'undefined' && typeof DataView != 'undefined'; 182 183 184/***/ }, 185 186/***/ 7394 187(module, __unused_webpack_exports, __webpack_require__) { 188 189 190var globalThis = __webpack_require__(4576); 191var uncurryThisAccessor = __webpack_require__(6706); 192var classof = __webpack_require__(2195); 193 194var ArrayBuffer = globalThis.ArrayBuffer; 195var TypeError = globalThis.TypeError; 196 197// Includes 198// - Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). 199// - If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 200module.exports = ArrayBuffer && uncurryThisAccessor(ArrayBuffer.prototype, 'byteLength', 'get') || function (O) { 201 if (classof(O) !== 'ArrayBuffer') throw new TypeError('ArrayBuffer expected'); 202 return O.byteLength; 203}; 204 205 206/***/ }, 207 208/***/ 3238 209(module, __unused_webpack_exports, __webpack_require__) { 210 211 212var globalThis = __webpack_require__(4576); 213var NATIVE_ARRAY_BUFFER = __webpack_require__(7811); 214var arrayBufferByteLength = __webpack_require__(7394); 215 216var DataView = globalThis.DataView; 217 218module.exports = function (O) { 219 if (!NATIVE_ARRAY_BUFFER || arrayBufferByteLength(O) !== 0) return false;
vendor: 4,303 bytes, lines 220-335
220 try { 221 // eslint-disable-next-line no-new -- thrower 222 new DataView(O); 223 return false; 224 } catch (error) { 225 return true; 226 } 227}; 228 229 230/***/ }, 231 232/***/ 5169 233(module, __unused_webpack_exports, __webpack_require__) { 234 235 236var isDetached = __webpack_require__(3238); 237 238var $TypeError = TypeError; 239 240module.exports = function (it) { 241 if (isDetached(it)) throw new $TypeError('ArrayBuffer is detached'); 242 return it; 243}; 244 245 246/***/ }, 247 248/***/ 5636 249(module, __unused_webpack_exports, __webpack_require__) { 250 251 252var globalThis = __webpack_require__(4576); 253var uncurryThis = __webpack_require__(9504); 254var uncurryThisAccessor = __webpack_require__(6706); 255var toIndex = __webpack_require__(7696); 256var notDetached = __webpack_require__(5169); 257var arrayBufferByteLength = __webpack_require__(7394); 258var detachTransferable = __webpack_require__(4483); 259var PROPER_STRUCTURED_CLONE_TRANSFER = __webpack_require__(1548); 260 261var structuredClone = globalThis.structuredClone; 262var ArrayBuffer = globalThis.ArrayBuffer; 263var DataView = globalThis.DataView; 264var min = Math.min; 265var ArrayBufferPrototype = ArrayBuffer.prototype; 266var DataViewPrototype = DataView.prototype; 267var slice = uncurryThis(ArrayBufferPrototype.slice); 268var isResizable = uncurryThisAccessor(ArrayBufferPrototype, 'resizable', 'get'); 269var maxByteLength = uncurryThisAccessor(ArrayBufferPrototype, 'maxByteLength', 'get'); 270var getInt8 = uncurryThis(DataViewPrototype.getInt8); 271var setInt8 = uncurryThis(DataViewPrototype.setInt8); 272 273module.exports = (PROPER_STRUCTURED_CLONE_TRANSFER || detachTransferable) && function (arrayBuffer, newLength, preserveResizability) { 274 var byteLength = arrayBufferByteLength(arrayBuffer); 275 var newByteLength = newLength === undefined ? byteLength : toIndex(newLength); 276 var fixedLength = !isResizable || !isResizable(arrayBuffer); 277 var newBuffer; 278 notDetached(arrayBuffer); 279 if (PROPER_STRUCTURED_CLONE_TRANSFER) { 280 arrayBuffer = structuredClone(arrayBuffer, { transfer: [arrayBuffer] }); 281 if (byteLength === newByteLength && (preserveResizability || fixedLength)) return arrayBuffer; 282 } 283 if (byteLength >= newByteLength && (!preserveResizability || fixedLength)) { 284 newBuffer = slice(arrayBuffer, 0, newByteLength); 285 } else { 286 var options = preserveResizability && !fixedLength && maxByteLength ? { maxByteLength: maxByteLength(arrayBuffer) } : undefined; 287 newBuffer = new ArrayBuffer(newByteLength, options); 288 var a = new DataView(arrayBuffer); 289 var b = new DataView(newBuffer); 290 var copyLength = min(newByteLength, byteLength); 291 for (var i = 0; i < copyLength; i++) setInt8(b, i, getInt8(a, i)); 292 } 293 if (!PROPER_STRUCTURED_CLONE_TRANSFER) detachTransferable(arrayBuffer); 294 return newBuffer; 295}; 296 297 298/***/ }, 299 300/***/ 4644 301(module, __unused_webpack_exports, __webpack_require__) { 302 303 304var NATIVE_ARRAY_BUFFER = __webpack_require__(7811); 305var DESCRIPTORS = __webpack_require__(3724); 306var globalThis = __webpack_require__(4576); 307var isCallable = __webpack_require__(4901); 308var isObject = __webpack_require__(34); 309var hasOwn = __webpack_require__(9297); 310var classof = __webpack_require__(6955); 311var tryToString = __webpack_require__(6823); 312var createNonEnumerableProperty = __webpack_require__(6699); 313var defineBuiltIn = __webpack_require__(6840); 314var defineBuiltInAccessor = __webpack_require__(2106); 315var isPrototypeOf = __webpack_require__(1625); 316var getPrototypeOf = __webpack_require__(2787); 317var setPrototypeOf = __webpack_require__(2967); 318var wellKnownSymbol = __webpack_require__(8227); 319var uid = __webpack_require__(3392); 320var InternalStateModule = __webpack_require__(1181); 321 322var enforceInternalState = InternalStateModule.enforce; 323var getInternalState = InternalStateModule.get; 324var Int8Array = globalThis.Int8Array; 325var Int8ArrayPrototype = Int8Array && Int8Array.prototype; 326var Uint8ClampedArray = globalThis.Uint8ClampedArray; 327var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype; 328var TypedArray = Int8Array && getPrototypeOf(Int8Array); 329var TypedArrayPrototype = Int8ArrayPrototype && getPrototypeOf(Int8ArrayPrototype); 330var ObjectPrototype = Object.prototype; 331var TypeError = globalThis.TypeError; 332 333var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 334var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG'); 335var TYPED_ARRAY_CONSTRUCTOR = 'TypedArrayConstructor';
vendor: 6,780 bytes, lines 336-523
336// Fixing native typed arrays in Opera Presto crashes the browser, see #595 337var NATIVE_ARRAY_BUFFER_VIEWS = NATIVE_ARRAY_BUFFER && !!setPrototypeOf && classof(globalThis.opera) !== 'Opera'; 338var TYPED_ARRAY_TAG_REQUIRED = false; 339var NAME, Constructor, Prototype; 340 341var TypedArrayConstructorsList = { 342 Int8Array: 1, 343 Uint8Array: 1, 344 Uint8ClampedArray: 1, 345 Int16Array: 2, 346 Uint16Array: 2, 347 Int32Array: 4, 348 Uint32Array: 4, 349 Float32Array: 4, 350 Float64Array: 8 351}; 352 353var BigIntArrayConstructorsList = { 354 BigInt64Array: 8, 355 BigUint64Array: 8 356}; 357 358var isView = function isView(it) { 359 if (!isObject(it)) return false; 360 var klass = classof(it); 361 return klass === 'DataView' 362 || hasOwn(TypedArrayConstructorsList, klass) 363 || hasOwn(BigIntArrayConstructorsList, klass); 364}; 365 366var getTypedArrayConstructor = function (it) { 367 var proto = getPrototypeOf(it); 368 if (!isObject(proto)) return; 369 var state = getInternalState(proto); 370 return (state && hasOwn(state, TYPED_ARRAY_CONSTRUCTOR)) ? state[TYPED_ARRAY_CONSTRUCTOR] : getTypedArrayConstructor(proto); 371}; 372 373var isTypedArray = function (it) { 374 if (!isObject(it)) return false; 375 var klass = classof(it); 376 return hasOwn(TypedArrayConstructorsList, klass) 377 || hasOwn(BigIntArrayConstructorsList, klass); 378}; 379 380var aTypedArray = function (it) { 381 if (isTypedArray(it)) return it; 382 throw new TypeError('Target is not a typed array'); 383}; 384 385var aTypedArrayConstructor = function (C) { 386 if (isCallable(C) && (!setPrototypeOf || isPrototypeOf(TypedArray, C))) return C; 387 throw new TypeError(tryToString(C) + ' is not a typed array constructor'); 388}; 389 390var exportTypedArrayMethod = function (KEY, property, forced, options) { 391 if (!DESCRIPTORS) return; 392 if (forced) for (var ARRAY in TypedArrayConstructorsList) { 393 var TypedArrayConstructor = globalThis[ARRAY]; 394 if (TypedArrayConstructor && hasOwn(TypedArrayConstructor.prototype, KEY)) try { 395 delete TypedArrayConstructor.prototype[KEY]; 396 } catch (error) { 397 // old WebKit bug - some methods are non-configurable 398 try { 399 TypedArrayConstructor.prototype[KEY] = property; 400 } catch (error2) { /* empty */ } 401 } 402 } 403 if (!TypedArrayPrototype[KEY] || forced) { 404 defineBuiltIn(TypedArrayPrototype, KEY, forced ? property 405 : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property, options); 406 } 407}; 408 409var exportTypedArrayStaticMethod = function (KEY, property, forced) { 410 var ARRAY, TypedArrayConstructor; 411 if (!DESCRIPTORS) return; 412 if (setPrototypeOf) { 413 if (forced) for (ARRAY in TypedArrayConstructorsList) { 414 TypedArrayConstructor = globalThis[ARRAY]; 415 if (TypedArrayConstructor && hasOwn(TypedArrayConstructor, KEY)) try { 416 delete TypedArrayConstructor[KEY]; 417 } catch (error) { /* empty */ } 418 } 419 if (!TypedArray[KEY] || forced) { 420 // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable 421 try { 422 return defineBuiltIn(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property); 423 } catch (error) { /* empty */ } 424 } else return; 425 } 426 for (ARRAY in TypedArrayConstructorsList) { 427 TypedArrayConstructor = globalThis[ARRAY]; 428 if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) { 429 defineBuiltIn(TypedArrayConstructor, KEY, property); 430 } 431 } 432}; 433 434for (NAME in TypedArrayConstructorsList) { 435 Constructor = globalThis[NAME]; 436 Prototype = Constructor && Constructor.prototype; 437 if (Prototype) enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor; 438 else NATIVE_ARRAY_BUFFER_VIEWS = false; 439} 440 441for (NAME in BigIntArrayConstructorsList) { 442 Constructor = globalThis[NAME]; 443 Prototype = Constructor && Constructor.prototype; 444 if (Prototype) enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor; 445} 446 447// WebKit bug - typed arrays constructors prototype is Object.prototype 448if (!NATIVE_ARRAY_BUFFER_VIEWS || !isCallable(TypedArray) || TypedArray === Function.prototype) { 449 // eslint-disable-next-line no-shadow -- safe 450 TypedArray = function TypedArray() { 451 throw new TypeError('Incorrect invocation'); 452 }; 453 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 454 if (globalThis[NAME]) setPrototypeOf(globalThis[NAME], TypedArray); 455 } 456} 457 458if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype) { 459 TypedArrayPrototype = TypedArray.prototype; 460 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 461 if (globalThis[NAME]) setPrototypeOf(globalThis[NAME].prototype, TypedArrayPrototype); 462 } 463} 464 465// WebKit bug - one more object in Uint8ClampedArray prototype chain 466if (NATIVE_ARRAY_BUFFER_VIEWS && getPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) { 467 setPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype); 468} 469 470if (DESCRIPTORS && !hasOwn(TypedArrayPrototype, TO_STRING_TAG)) { 471 TYPED_ARRAY_TAG_REQUIRED = true; 472 defineBuiltInAccessor(TypedArrayPrototype, TO_STRING_TAG, { 473 configurable: true, 474 get: function () { 475 return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined; 476 } 477 }); 478 for (NAME in TypedArrayConstructorsList) if (globalThis[NAME]) { 479 createNonEnumerableProperty(globalThis[NAME], TYPED_ARRAY_TAG, NAME); 480 } 481} 482 483module.exports = { 484 NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS, 485 TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQUIRED && TYPED_ARRAY_TAG, 486 aTypedArray: aTypedArray, 487 aTypedArrayConstructor: aTypedArrayConstructor, 488 exportTypedArrayMethod: exportTypedArrayMethod, 489 exportTypedArrayStaticMethod: exportTypedArrayStaticMethod, 490 getTypedArrayConstructor: getTypedArrayConstructor, 491 isView: isView, 492 isTypedArray: isTypedArray, 493 TypedArray: TypedArray, 494 TypedArrayPrototype: TypedArrayPrototype 495}; 496 497 498/***/ }, 499 500/***/ 9617 501(module, __unused_webpack_exports, __webpack_require__) { 502 503 504var toIndexedObject = __webpack_require__(5397); 505var toAbsoluteIndex = __webpack_require__(5610); 506var lengthOfArrayLike = __webpack_require__(6198); 507 508// `Array.prototype.{ indexOf, includes }` methods implementation 509var createMethod = function (IS_INCLUDES) { 510 return function ($this, el, fromIndex) { 511 var O = toIndexedObject($this); 512 var length = lengthOfArrayLike(O); 513 if (length === 0) return !IS_INCLUDES && -1; 514 var index = toAbsoluteIndex(fromIndex, length); 515 var value; 516 // Array#includes uses SameValueZero equality algorithm 517 // eslint-disable-next-line no-self-compare -- NaN check 518 if (IS_INCLUDES && el !== el) while (length > index) { 519 value = O[index++]; 520 // eslint-disable-next-line no-self-compare -- NaN check 521 if (value !== value) return true; 522 // Array#indexOf ignores holes, Array#includes - not 523 } else for (;length > index; index++) {
vendor: 8,812 bytes, lines 524-872
524 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; 525 } return !IS_INCLUDES && -1; 526 }; 527}; 528 529module.exports = { 530 // `Array.prototype.includes` method 531 // https://tc39.es/ecma262/#sec-array.prototype.includes 532 includes: createMethod(true), 533 // `Array.prototype.indexOf` method 534 // https://tc39.es/ecma262/#sec-array.prototype.indexof 535 indexOf: createMethod(false) 536}; 537 538 539/***/ }, 540 541/***/ 4527 542(module, __unused_webpack_exports, __webpack_require__) { 543 544 545var DESCRIPTORS = __webpack_require__(3724); 546var isArray = __webpack_require__(4376); 547 548var $TypeError = TypeError; 549// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 550var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 551 552// Safari < 13 does not throw an error in this case 553var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !function () { 554 // makes no sense without proper strict mode support 555 if (this !== undefined) return true; 556 try { 557 // eslint-disable-next-line es/no-object-defineproperty -- safe 558 Object.defineProperty([], 'length', { writable: false }).length = 1; 559 } catch (error) { 560 return error instanceof TypeError; 561 } 562}(); 563 564module.exports = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) { 565 if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) { 566 throw new $TypeError('Cannot set read only .length'); 567 } return O.length = length; 568} : function (O, length) { 569 return O.length = length; 570}; 571 572 573/***/ }, 574 575/***/ 7680 576(module, __unused_webpack_exports, __webpack_require__) { 577 578 579var uncurryThis = __webpack_require__(9504); 580 581module.exports = uncurryThis([].slice); 582 583 584/***/ }, 585 586/***/ 6319 587(module, __unused_webpack_exports, __webpack_require__) { 588 589 590var anObject = __webpack_require__(8551); 591var iteratorClose = __webpack_require__(9539); 592 593// call something on iterator step with safe closing on error 594module.exports = function (iterator, fn, value, ENTRIES) { 595 try { 596 return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value); 597 } catch (error) { 598 iteratorClose(iterator, 'throw', error); 599 } 600}; 601 602 603/***/ }, 604 605/***/ 2195 606(module, __unused_webpack_exports, __webpack_require__) { 607 608 609var uncurryThis = __webpack_require__(9504); 610 611var toString = uncurryThis({}.toString); 612var stringSlice = uncurryThis(''.slice); 613 614module.exports = function (it) { 615 return stringSlice(toString(it), 8, -1); 616}; 617 618 619/***/ }, 620 621/***/ 6955 622(module, __unused_webpack_exports, __webpack_require__) { 623 624 625var TO_STRING_TAG_SUPPORT = __webpack_require__(2140); 626var isCallable = __webpack_require__(4901); 627var classofRaw = __webpack_require__(2195); 628var wellKnownSymbol = __webpack_require__(8227); 629 630var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 631var $Object = Object; 632 633// ES3 wrong here 634var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) === 'Arguments'; 635 636// fallback for IE11 Script Access Denied error 637var tryGet = function (it, key) { 638 try { 639 return it[key]; 640 } catch (error) { /* empty */ } 641}; 642 643// getting tag from ES6+ `Object.prototype.toString` 644module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) { 645 var O, tag, result; 646 return it === undefined ? 'Undefined' : it === null ? 'Null' 647 // @@toStringTag case 648 : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag 649 // builtinTag case 650 : CORRECT_ARGUMENTS ? classofRaw(O) 651 // ES3 arguments fallback 652 : (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result; 653}; 654 655 656/***/ }, 657 658/***/ 7740 659(module, __unused_webpack_exports, __webpack_require__) { 660 661 662var hasOwn = __webpack_require__(9297); 663var ownKeys = __webpack_require__(5031); 664var getOwnPropertyDescriptorModule = __webpack_require__(7347); 665var definePropertyModule = __webpack_require__(4913); 666 667module.exports = function (target, source, exceptions) { 668 var keys = ownKeys(source); 669 var defineProperty = definePropertyModule.f; 670 var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f; 671 for (var i = 0; i < keys.length; i++) { 672 var key = keys[i]; 673 if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) { 674 defineProperty(target, key, getOwnPropertyDescriptor(source, key)); 675 } 676 } 677}; 678 679 680/***/ }, 681 682/***/ 2211 683(module, __unused_webpack_exports, __webpack_require__) { 684 685 686var fails = __webpack_require__(9039); 687 688module.exports = !fails(function () { 689 function F() { /* empty */ } 690 F.prototype.constructor = null; 691 // eslint-disable-next-line es/no-object-getprototypeof -- required for testing 692 return Object.getPrototypeOf(new F()) !== F.prototype; 693}); 694 695 696/***/ }, 697 698/***/ 2529 699(module) { 700 701 702// `CreateIterResultObject` abstract operation 703// https://tc39.es/ecma262/#sec-createiterresultobject 704module.exports = function (value, done) { 705 return { value: value, done: done }; 706}; 707 708 709/***/ }, 710 711/***/ 6699 712(module, __unused_webpack_exports, __webpack_require__) { 713 714 715var DESCRIPTORS = __webpack_require__(3724); 716var definePropertyModule = __webpack_require__(4913); 717var createPropertyDescriptor = __webpack_require__(6980); 718 719module.exports = DESCRIPTORS ? function (object, key, value) { 720 return definePropertyModule.f(object, key, createPropertyDescriptor(1, value)); 721} : function (object, key, value) { 722 object[key] = value; 723 return object; 724}; 725 726 727/***/ }, 728 729/***/ 6980 730(module) { 731 732 733module.exports = function (bitmap, value) { 734 return { 735 enumerable: !(bitmap & 1), 736 configurable: !(bitmap & 2), 737 writable: !(bitmap & 4), 738 value: value 739 }; 740}; 741 742 743/***/ }, 744 745/***/ 4659 746(module, __unused_webpack_exports, __webpack_require__) { 747 748 749var DESCRIPTORS = __webpack_require__(3724); 750var definePropertyModule = __webpack_require__(4913); 751var createPropertyDescriptor = __webpack_require__(6980); 752 753module.exports = function (object, key, value) { 754 if (DESCRIPTORS) definePropertyModule.f(object, key, createPropertyDescriptor(0, value)); 755 else object[key] = value; 756}; 757 758 759/***/ }, 760 761/***/ 2106 762(module, __unused_webpack_exports, __webpack_require__) { 763 764 765var makeBuiltIn = __webpack_require__(283); 766var defineProperty = __webpack_require__(4913); 767 768module.exports = function (target, name, descriptor) { 769 if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true }); 770 if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true }); 771 return defineProperty.f(target, name, descriptor); 772}; 773 774 775/***/ }, 776 777/***/ 6840 778(module, __unused_webpack_exports, __webpack_require__) { 779 780 781var isCallable = __webpack_require__(4901); 782var definePropertyModule = __webpack_require__(4913); 783var makeBuiltIn = __webpack_require__(283); 784var defineGlobalProperty = __webpack_require__(9433); 785 786module.exports = function (O, key, value, options) { 787 if (!options) options = {}; 788 var simple = options.enumerable; 789 var name = options.name !== undefined ? options.name : key; 790 if (isCallable(value)) makeBuiltIn(value, name, options); 791 if (options.global) { 792 if (simple) O[key] = value; 793 else defineGlobalProperty(key, value); 794 } else { 795 try { 796 if (!options.unsafe) delete O[key]; 797 else if (O[key]) simple = true; 798 } catch (error) { /* empty */ } 799 if (simple) O[key] = value; 800 else definePropertyModule.f(O, key, { 801 value: value, 802 enumerable: false, 803 configurable: !options.nonConfigurable, 804 writable: !options.nonWritable 805 }); 806 } return O; 807}; 808 809 810/***/ }, 811 812/***/ 6279 813(module, __unused_webpack_exports, __webpack_require__) { 814 815 816var defineBuiltIn = __webpack_require__(6840); 817 818module.exports = function (target, src, options) { 819 for (var key in src) defineBuiltIn(target, key, src[key], options); 820 return target; 821}; 822 823 824/***/ }, 825 826/***/ 9433 827(module, __unused_webpack_exports, __webpack_require__) { 828 829 830var globalThis = __webpack_require__(4576); 831 832// eslint-disable-next-line es/no-object-defineproperty -- safe 833var defineProperty = Object.defineProperty; 834 835module.exports = function (key, value) { 836 try { 837 defineProperty(globalThis, key, { value: value, configurable: true, writable: true }); 838 } catch (error) { 839 globalThis[key] = value; 840 } return value; 841}; 842 843 844/***/ }, 845 846/***/ 3724 847(module, __unused_webpack_exports, __webpack_require__) { 848 849 850var fails = __webpack_require__(9039); 851 852// Detect IE8's incomplete defineProperty implementation 853module.exports = !fails(function () { 854 // eslint-disable-next-line es/no-object-defineproperty -- required for testing 855 return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] !== 7; 856}); 857 858 859/***/ }, 860 861/***/ 4483 862(module, __unused_webpack_exports, __webpack_require__) { 863 864 865var globalThis = __webpack_require__(4576); 866var getBuiltInNodeModule = __webpack_require__(9429); 867var PROPER_STRUCTURED_CLONE_TRANSFER = __webpack_require__(1548); 868 869var structuredClone = globalThis.structuredClone; 870var $ArrayBuffer = globalThis.ArrayBuffer; 871var $MessageChannel = globalThis.MessageChannel; 872var detach = false;
vendor: 4,772 bytes, lines 873-1062
873var WorkerThreads, channel, buffer, $detach; 874 875if (PROPER_STRUCTURED_CLONE_TRANSFER) { 876 detach = function (transferable) { 877 structuredClone(transferable, { transfer: [transferable] }); 878 }; 879} else if ($ArrayBuffer) try { 880 if (!$MessageChannel) { 881 WorkerThreads = getBuiltInNodeModule('worker_threads'); 882 if (WorkerThreads) $MessageChannel = WorkerThreads.MessageChannel; 883 } 884 885 if ($MessageChannel) { 886 channel = new $MessageChannel(); 887 buffer = new $ArrayBuffer(2); 888 889 $detach = function (transferable) { 890 channel.port1.postMessage(null, [transferable]); 891 }; 892 893 if (buffer.byteLength === 2) { 894 $detach(buffer); 895 if (buffer.byteLength === 0) detach = $detach; 896 } 897 } 898} catch (error) { /* empty */ } 899 900module.exports = detach; 901 902 903/***/ }, 904 905/***/ 4055 906(module, __unused_webpack_exports, __webpack_require__) { 907 908 909var globalThis = __webpack_require__(4576); 910var isObject = __webpack_require__(34); 911 912var document = globalThis.document; 913// typeof document.createElement is 'object' in old IE 914var EXISTS = isObject(document) && isObject(document.createElement); 915 916module.exports = function (it) { 917 return EXISTS ? document.createElement(it) : {}; 918}; 919 920 921/***/ }, 922 923/***/ 6837 924(module) { 925 926 927var $TypeError = TypeError; 928var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991 929 930module.exports = function (it) { 931 if (it > MAX_SAFE_INTEGER) throw $TypeError('Maximum allowed index exceeded'); 932 return it; 933}; 934 935 936/***/ }, 937 938/***/ 8727 939(module) { 940 941 942// IE8- don't enum bug keys 943module.exports = [ 944 'constructor', 945 'hasOwnProperty', 946 'isPrototypeOf', 947 'propertyIsEnumerable', 948 'toLocaleString', 949 'toString', 950 'valueOf' 951]; 952 953 954/***/ }, 955 956/***/ 6193 957(module, __unused_webpack_exports, __webpack_require__) { 958 959 960var ENVIRONMENT = __webpack_require__(4215); 961 962module.exports = ENVIRONMENT === 'NODE'; 963 964 965/***/ }, 966 967/***/ 2839 968(module, __unused_webpack_exports, __webpack_require__) { 969 970 971var globalThis = __webpack_require__(4576); 972 973var navigator = globalThis.navigator; 974var userAgent = navigator && navigator.userAgent; 975 976module.exports = userAgent ? String(userAgent) : ''; 977 978 979/***/ }, 980 981/***/ 9519 982(module, __unused_webpack_exports, __webpack_require__) { 983 984 985var globalThis = __webpack_require__(4576); 986var userAgent = __webpack_require__(2839); 987 988var process = globalThis.process; 989var Deno = globalThis.Deno; 990var versions = process && process.versions || Deno && Deno.version; 991var v8 = versions && versions.v8; 992var match, version; 993 994if (v8) { 995 match = v8.split('.'); 996 // in old Chrome, versions of V8 isn't V8 = Chrome / 10 997 // but their correct versions are not interesting for us 998 version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); 999} 1000 1001// BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0` 1002// so check `userAgent` even if `.v8` exists, but 0 1003if (!version && userAgent) { 1004 match = userAgent.match(/Edge\/(\d+)/); 1005 if (!match || match[1] >= 74) { 1006 match = userAgent.match(/Chrome\/(\d+)/); 1007 if (match) version = +match[1]; 1008 } 1009} 1010 1011module.exports = version; 1012 1013 1014/***/ }, 1015 1016/***/ 4215 1017(module, __unused_webpack_exports, __webpack_require__) { 1018 1019 1020/* global Bun, Deno -- detection */ 1021var globalThis = __webpack_require__(4576); 1022var userAgent = __webpack_require__(2839); 1023var classof = __webpack_require__(2195); 1024 1025var userAgentStartsWith = function (string) { 1026 return userAgent.slice(0, string.length) === string; 1027}; 1028 1029module.exports = (function () { 1030 if (userAgentStartsWith('Bun/')) return 'BUN'; 1031 if (userAgentStartsWith('Cloudflare-Workers')) return 'CLOUDFLARE'; 1032 if (userAgentStartsWith('Deno/')) return 'DENO'; 1033 if (userAgentStartsWith('Node.js/')) return 'NODE'; 1034 if (globalThis.Bun && typeof Bun.version == 'string') return 'BUN'; 1035 if (globalThis.Deno && typeof Deno.version == 'object') return 'DENO'; 1036 if (classof(globalThis.process) === 'process') return 'NODE'; 1037 if (globalThis.window && globalThis.document) return 'BROWSER'; 1038 return 'REST'; 1039})(); 1040 1041 1042/***/ }, 1043 1044/***/ 6518 1045(module, __unused_webpack_exports, __webpack_require__) { 1046 1047 1048var globalThis = __webpack_require__(4576); 1049var getOwnPropertyDescriptor = (__webpack_require__(7347).f); 1050var createNonEnumerableProperty = __webpack_require__(6699); 1051var defineBuiltIn = __webpack_require__(6840); 1052var defineGlobalProperty = __webpack_require__(9433); 1053var copyConstructorProperties = __webpack_require__(7740); 1054var isForced = __webpack_require__(2796); 1055 1056/* 1057 options.target - name of the target object 1058 options.global - target is the global object 1059 options.stat - export as static methods of target 1060 options.proto - export as prototype methods of target 1061 options.real - real prototype method for the `pure` version 1062 options.forced - export even if the native feature is available
vendor: 15,939 bytes, lines 1063-1688
1063 options.bind - bind methods to the target, required for the `pure` version 1064 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version 1065 options.unsafe - use the simple assignment of property instead of delete + defineProperty 1066 options.sham - add a flag to not completely full polyfills 1067 options.enumerable - export as enumerable property 1068 options.dontCallGetSet - prevent calling a getter on target 1069 options.name - the .name of the function if it does not match the key 1070*/ 1071module.exports = function (options, source) { 1072 var TARGET = options.target; 1073 var GLOBAL = options.global; 1074 var STATIC = options.stat; 1075 var FORCED, target, key, targetProperty, sourceProperty, descriptor; 1076 if (GLOBAL) { 1077 target = globalThis; 1078 } else if (STATIC) { 1079 target = globalThis[TARGET] || defineGlobalProperty(TARGET, {}); 1080 } else { 1081 target = globalThis[TARGET] && globalThis[TARGET].prototype; 1082 } 1083 if (target) for (key in source) { 1084 sourceProperty = source[key]; 1085 if (options.dontCallGetSet) { 1086 descriptor = getOwnPropertyDescriptor(target, key); 1087 targetProperty = descriptor && descriptor.value; 1088 } else targetProperty = target[key]; 1089 FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); 1090 // contained in target 1091 if (!FORCED && targetProperty !== undefined) { 1092 if (typeof sourceProperty == typeof targetProperty) continue; 1093 copyConstructorProperties(sourceProperty, targetProperty); 1094 } 1095 // add a flag to not completely full polyfills 1096 if (options.sham || (targetProperty && targetProperty.sham)) { 1097 createNonEnumerableProperty(sourceProperty, 'sham', true); 1098 } 1099 defineBuiltIn(target, key, sourceProperty, options); 1100 } 1101}; 1102 1103 1104/***/ }, 1105 1106/***/ 9039 1107(module) { 1108 1109 1110module.exports = function (exec) { 1111 try { 1112 return !!exec(); 1113 } catch (error) { 1114 return true; 1115 } 1116}; 1117 1118 1119/***/ }, 1120 1121/***/ 8745 1122(module, __unused_webpack_exports, __webpack_require__) { 1123 1124 1125var NATIVE_BIND = __webpack_require__(616); 1126 1127var FunctionPrototype = Function.prototype; 1128var apply = FunctionPrototype.apply; 1129var call = FunctionPrototype.call; 1130 1131// eslint-disable-next-line es/no-function-prototype-bind, es/no-reflect -- safe 1132module.exports = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function () { 1133 return call.apply(apply, arguments); 1134}); 1135 1136 1137/***/ }, 1138 1139/***/ 6080 1140(module, __unused_webpack_exports, __webpack_require__) { 1141 1142 1143var uncurryThis = __webpack_require__(7476); 1144var aCallable = __webpack_require__(9306); 1145var NATIVE_BIND = __webpack_require__(616); 1146 1147var bind = uncurryThis(uncurryThis.bind); 1148 1149// optional / simple context binding 1150module.exports = function (fn, that) { 1151 aCallable(fn); 1152 return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function (/* ...args */) { 1153 return fn.apply(that, arguments); 1154 }; 1155}; 1156 1157 1158/***/ }, 1159 1160/***/ 616 1161(module, __unused_webpack_exports, __webpack_require__) { 1162 1163 1164var fails = __webpack_require__(9039); 1165 1166module.exports = !fails(function () { 1167 // eslint-disable-next-line es/no-function-prototype-bind -- safe 1168 var test = (function () { /* empty */ }).bind(); 1169 // eslint-disable-next-line no-prototype-builtins -- safe 1170 return typeof test != 'function' || test.hasOwnProperty('prototype'); 1171}); 1172 1173 1174/***/ }, 1175 1176/***/ 9565 1177(module, __unused_webpack_exports, __webpack_require__) { 1178 1179 1180var NATIVE_BIND = __webpack_require__(616); 1181 1182var call = Function.prototype.call; 1183// eslint-disable-next-line es/no-function-prototype-bind -- safe 1184module.exports = NATIVE_BIND ? call.bind(call) : function () { 1185 return call.apply(call, arguments); 1186}; 1187 1188 1189/***/ }, 1190 1191/***/ 350 1192(module, __unused_webpack_exports, __webpack_require__) { 1193 1194 1195var DESCRIPTORS = __webpack_require__(3724); 1196var hasOwn = __webpack_require__(9297); 1197 1198var FunctionPrototype = Function.prototype; 1199// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 1200var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor; 1201 1202var EXISTS = hasOwn(FunctionPrototype, 'name'); 1203// additional protection from minified / mangled / dropped function names 1204var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something'; 1205var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable)); 1206 1207module.exports = { 1208 EXISTS: EXISTS, 1209 PROPER: PROPER, 1210 CONFIGURABLE: CONFIGURABLE 1211}; 1212 1213 1214/***/ }, 1215 1216/***/ 6706 1217(module, __unused_webpack_exports, __webpack_require__) { 1218 1219 1220var uncurryThis = __webpack_require__(9504); 1221var aCallable = __webpack_require__(9306); 1222 1223module.exports = function (object, key, method) { 1224 try { 1225 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 1226 return uncurryThis(aCallable(Object.getOwnPropertyDescriptor(object, key)[method])); 1227 } catch (error) { /* empty */ } 1228}; 1229 1230 1231/***/ }, 1232 1233/***/ 7476 1234(module, __unused_webpack_exports, __webpack_require__) { 1235 1236 1237var classofRaw = __webpack_require__(2195); 1238var uncurryThis = __webpack_require__(9504); 1239 1240module.exports = function (fn) { 1241 // Nashorn bug: 1242 // https://github.com/zloirock/core-js/issues/1128 1243 // https://github.com/zloirock/core-js/issues/1130 1244 if (classofRaw(fn) === 'Function') return uncurryThis(fn); 1245}; 1246 1247 1248/***/ }, 1249 1250/***/ 9504 1251(module, __unused_webpack_exports, __webpack_require__) { 1252 1253 1254var NATIVE_BIND = __webpack_require__(616); 1255 1256var FunctionPrototype = Function.prototype; 1257var call = FunctionPrototype.call; 1258// eslint-disable-next-line es/no-function-prototype-bind -- safe 1259var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call); 1260 1261module.exports = NATIVE_BIND ? uncurryThisWithBind : function (fn) { 1262 return function () { 1263 return call.apply(fn, arguments); 1264 }; 1265}; 1266 1267 1268/***/ }, 1269 1270/***/ 9429 1271(module, __unused_webpack_exports, __webpack_require__) { 1272 1273 1274var globalThis = __webpack_require__(4576); 1275var IS_NODE = __webpack_require__(6193); 1276 1277module.exports = function (name) { 1278 if (IS_NODE) { 1279 try { 1280 return globalThis.process.getBuiltinModule(name); 1281 } catch (error) { /* empty */ } 1282 try { 1283 // eslint-disable-next-line no-new-func -- safe 1284 return Function('return require("' + name + '")')(); 1285 } catch (error) { /* empty */ } 1286 } 1287}; 1288 1289 1290/***/ }, 1291 1292/***/ 7751 1293(module, __unused_webpack_exports, __webpack_require__) { 1294 1295 1296var globalThis = __webpack_require__(4576); 1297var isCallable = __webpack_require__(4901); 1298 1299var aFunction = function (argument) { 1300 return isCallable(argument) ? argument : undefined; 1301}; 1302 1303module.exports = function (namespace, method) { 1304 return arguments.length < 2 ? aFunction(globalThis[namespace]) : globalThis[namespace] && globalThis[namespace][method]; 1305}; 1306 1307 1308/***/ }, 1309 1310/***/ 1767 1311(module) { 1312 1313 1314// `GetIteratorDirect(obj)` abstract operation 1315// https://tc39.es/ecma262/#sec-getiteratordirect 1316module.exports = function (obj) { 1317 return { 1318 iterator: obj, 1319 next: obj.next, 1320 done: false 1321 }; 1322}; 1323 1324 1325/***/ }, 1326 1327/***/ 851 1328(module, __unused_webpack_exports, __webpack_require__) { 1329 1330 1331var classof = __webpack_require__(6955); 1332var getMethod = __webpack_require__(5966); 1333var isNullOrUndefined = __webpack_require__(4117); 1334var Iterators = __webpack_require__(6269); 1335var wellKnownSymbol = __webpack_require__(8227); 1336 1337var ITERATOR = wellKnownSymbol('iterator'); 1338 1339module.exports = function (it) { 1340 if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR) 1341 || getMethod(it, '@@iterator') 1342 || Iterators[classof(it)]; 1343}; 1344 1345 1346/***/ }, 1347 1348/***/ 81 1349(module, __unused_webpack_exports, __webpack_require__) { 1350 1351 1352var call = __webpack_require__(9565); 1353var aCallable = __webpack_require__(9306); 1354var anObject = __webpack_require__(8551); 1355var tryToString = __webpack_require__(6823); 1356var getIteratorMethod = __webpack_require__(851); 1357 1358var $TypeError = TypeError; 1359 1360module.exports = function (argument, usingIterator) { 1361 var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator; 1362 if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument)); 1363 throw new $TypeError(tryToString(argument) + ' is not iterable'); 1364}; 1365 1366 1367/***/ }, 1368 1369/***/ 5966 1370(module, __unused_webpack_exports, __webpack_require__) { 1371 1372 1373var aCallable = __webpack_require__(9306); 1374var isNullOrUndefined = __webpack_require__(4117); 1375 1376// `GetMethod` abstract operation 1377// https://tc39.es/ecma262/#sec-getmethod 1378module.exports = function (V, P) { 1379 var func = V[P]; 1380 return isNullOrUndefined(func) ? undefined : aCallable(func); 1381}; 1382 1383 1384/***/ }, 1385 1386/***/ 3789 1387(module, __unused_webpack_exports, __webpack_require__) { 1388 1389 1390var aCallable = __webpack_require__(9306); 1391var anObject = __webpack_require__(8551); 1392var call = __webpack_require__(9565); 1393var toIntegerOrInfinity = __webpack_require__(1291); 1394var getIteratorDirect = __webpack_require__(1767); 1395 1396var INVALID_SIZE = 'Invalid size'; 1397var $RangeError = RangeError; 1398var $TypeError = TypeError; 1399var max = Math.max; 1400 1401var SetRecord = function (set, intSize) { 1402 this.set = set; 1403 this.size = max(intSize, 0); 1404 this.has = aCallable(set.has); 1405 this.keys = aCallable(set.keys); 1406}; 1407 1408SetRecord.prototype = { 1409 getIterator: function () { 1410 return getIteratorDirect(anObject(call(this.keys, this.set))); 1411 }, 1412 includes: function (it) { 1413 return call(this.has, this.set, it); 1414 } 1415}; 1416 1417// `GetSetRecord` abstract operation 1418// https://tc39.es/proposal-set-methods/#sec-getsetrecord 1419module.exports = function (obj) { 1420 anObject(obj); 1421 var numSize = +obj.size; 1422 // NOTE: If size is undefined, then numSize will be NaN 1423 // eslint-disable-next-line no-self-compare -- NaN check 1424 if (numSize !== numSize) throw new $TypeError(INVALID_SIZE); 1425 var intSize = toIntegerOrInfinity(numSize); 1426 if (intSize < 0) throw new $RangeError(INVALID_SIZE); 1427 return new SetRecord(obj, intSize); 1428}; 1429 1430 1431/***/ }, 1432 1433/***/ 4576 1434(module) { 1435 1436 1437var check = function (it) { 1438 return it && it.Math === Math && it; 1439}; 1440 1441// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 1442module.exports = 1443 // eslint-disable-next-line es/no-global-this -- safe 1444 check(typeof globalThis == 'object' && globalThis) || 1445 check(typeof window == 'object' && window) || 1446 // eslint-disable-next-line no-restricted-globals -- safe 1447 check(typeof self == 'object' && self) || 1448 check(typeof global == 'object' && global) || 1449 check(typeof this == 'object' && this) || 1450 // eslint-disable-next-line no-new-func -- fallback 1451 (function () { return this; })() || Function('return this')(); 1452 1453 1454/***/ }, 1455 1456/***/ 9297 1457(module, __unused_webpack_exports, __webpack_require__) { 1458 1459 1460var uncurryThis = __webpack_require__(9504); 1461var toObject = __webpack_require__(8981); 1462 1463var hasOwnProperty = uncurryThis({}.hasOwnProperty); 1464 1465// `HasOwnProperty` abstract operation 1466// https://tc39.es/ecma262/#sec-hasownproperty 1467// eslint-disable-next-line es/no-object-hasown -- safe 1468module.exports = Object.hasOwn || function hasOwn(it, key) { 1469 return hasOwnProperty(toObject(it), key); 1470}; 1471 1472 1473/***/ }, 1474 1475/***/ 421 1476(module) { 1477 1478 1479module.exports = {}; 1480 1481 1482/***/ }, 1483 1484/***/ 397 1485(module, __unused_webpack_exports, __webpack_require__) { 1486 1487 1488var getBuiltIn = __webpack_require__(7751); 1489 1490module.exports = getBuiltIn('document', 'documentElement'); 1491 1492 1493/***/ }, 1494 1495/***/ 5917 1496(module, __unused_webpack_exports, __webpack_require__) { 1497 1498 1499var DESCRIPTORS = __webpack_require__(3724); 1500var fails = __webpack_require__(9039); 1501var createElement = __webpack_require__(4055); 1502 1503// Thanks to IE8 for its funny defineProperty 1504module.exports = !DESCRIPTORS && !fails(function () { 1505 // eslint-disable-next-line es/no-object-defineproperty -- required for testing 1506 return Object.defineProperty(createElement('div'), 'a', { 1507 get: function () { return 7; } 1508 }).a !== 7; 1509}); 1510 1511 1512/***/ }, 1513 1514/***/ 7055 1515(module, __unused_webpack_exports, __webpack_require__) { 1516 1517 1518var uncurryThis = __webpack_require__(9504); 1519var fails = __webpack_require__(9039); 1520var classof = __webpack_require__(2195); 1521 1522var $Object = Object; 1523var split = uncurryThis(''.split); 1524 1525// fallback for non-array-like ES3 and non-enumerable old V8 strings 1526module.exports = fails(function () { 1527 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 1528 // eslint-disable-next-line no-prototype-builtins -- safe 1529 return !$Object('z').propertyIsEnumerable(0); 1530}) ? function (it) { 1531 return classof(it) === 'String' ? split(it, '') : $Object(it); 1532} : $Object; 1533 1534 1535/***/ }, 1536 1537/***/ 3706 1538(module, __unused_webpack_exports, __webpack_require__) { 1539 1540 1541var uncurryThis = __webpack_require__(9504); 1542var isCallable = __webpack_require__(4901); 1543var store = __webpack_require__(7629); 1544 1545var functionToString = uncurryThis(Function.toString); 1546 1547// this helper broken in `[email protected]`, so we can't use `shared` helper 1548if (!isCallable(store.inspectSource)) { 1549 store.inspectSource = function (it) { 1550 return functionToString(it); 1551 }; 1552} 1553 1554module.exports = store.inspectSource; 1555 1556 1557/***/ }, 1558 1559/***/ 1181 1560(module, __unused_webpack_exports, __webpack_require__) { 1561 1562 1563var NATIVE_WEAK_MAP = __webpack_require__(8622); 1564var globalThis = __webpack_require__(4576); 1565var isObject = __webpack_require__(34); 1566var createNonEnumerableProperty = __webpack_require__(6699); 1567var hasOwn = __webpack_require__(9297); 1568var shared = __webpack_require__(7629); 1569var sharedKey = __webpack_require__(6119); 1570var hiddenKeys = __webpack_require__(421); 1571 1572var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; 1573var TypeError = globalThis.TypeError; 1574var WeakMap = globalThis.WeakMap; 1575var set, get, has; 1576 1577var enforce = function (it) { 1578 return has(it) ? get(it) : set(it, {}); 1579}; 1580 1581var getterFor = function (TYPE) { 1582 return function (it) { 1583 var state; 1584 if (!isObject(it) || (state = get(it)).type !== TYPE) { 1585 throw new TypeError('Incompatible receiver, ' + TYPE + ' required'); 1586 } return state; 1587 }; 1588}; 1589 1590if (NATIVE_WEAK_MAP || shared.state) { 1591 var store = shared.state || (shared.state = new WeakMap()); 1592 /* eslint-disable no-self-assign -- prototype methods protection */ 1593 store.get = store.get; 1594 store.has = store.has; 1595 store.set = store.set; 1596 /* eslint-enable no-self-assign -- prototype methods protection */ 1597 set = function (it, metadata) { 1598 if (store.has(it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED); 1599 metadata.facade = it; 1600 store.set(it, metadata); 1601 return metadata; 1602 }; 1603 get = function (it) { 1604 return store.get(it) || {}; 1605 }; 1606 has = function (it) { 1607 return store.has(it); 1608 }; 1609} else { 1610 var STATE = sharedKey('state'); 1611 hiddenKeys[STATE] = true; 1612 set = function (it, metadata) { 1613 if (hasOwn(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED); 1614 metadata.facade = it; 1615 createNonEnumerableProperty(it, STATE, metadata); 1616 return metadata; 1617 }; 1618 get = function (it) { 1619 return hasOwn(it, STATE) ? it[STATE] : {}; 1620 }; 1621 has = function (it) { 1622 return hasOwn(it, STATE); 1623 }; 1624} 1625 1626module.exports = { 1627 set: set, 1628 get: get, 1629 has: has, 1630 enforce: enforce, 1631 getterFor: getterFor 1632}; 1633 1634 1635/***/ }, 1636 1637/***/ 4209 1638(module, __unused_webpack_exports, __webpack_require__) { 1639 1640 1641var wellKnownSymbol = __webpack_require__(8227); 1642var Iterators = __webpack_require__(6269); 1643 1644var ITERATOR = wellKnownSymbol('iterator'); 1645var ArrayPrototype = Array.prototype; 1646 1647// check on default Array iterator 1648module.exports = function (it) { 1649 return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it); 1650}; 1651 1652 1653/***/ }, 1654 1655/***/ 4376 1656(module, __unused_webpack_exports, __webpack_require__) { 1657 1658 1659var classof = __webpack_require__(2195); 1660 1661// `IsArray` abstract operation 1662// https://tc39.es/ecma262/#sec-isarray 1663// eslint-disable-next-line es/no-array-isarray -- safe 1664module.exports = Array.isArray || function isArray(argument) { 1665 return classof(argument) === 'Array'; 1666}; 1667 1668 1669/***/ }, 1670 1671/***/ 1108 1672(module, __unused_webpack_exports, __webpack_require__) { 1673 1674 1675var classof = __webpack_require__(6955); 1676 1677module.exports = function (it) { 1678 var klass = classof(it); 1679 return klass === 'BigInt64Array' || klass === 'BigUint64Array'; 1680}; 1681 1682 1683/***/ }, 1684 1685/***/ 4901 1686(module) { 1687 1688
vendor: 4,675 bytes, lines 1689-1880
1689// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot 1690var documentAll = typeof document == 'object' && document.all; 1691 1692// `IsCallable` abstract operation 1693// https://tc39.es/ecma262/#sec-iscallable 1694// eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing 1695module.exports = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) { 1696 return typeof argument == 'function' || argument === documentAll; 1697} : function (argument) { 1698 return typeof argument == 'function'; 1699}; 1700 1701 1702/***/ }, 1703 1704/***/ 2796 1705(module, __unused_webpack_exports, __webpack_require__) { 1706 1707 1708var fails = __webpack_require__(9039); 1709var isCallable = __webpack_require__(4901); 1710 1711var replacement = /#|\.prototype\./; 1712 1713var isForced = function (feature, detection) { 1714 var value = data[normalize(feature)]; 1715 return value === POLYFILL ? true 1716 : value === NATIVE ? false 1717 : isCallable(detection) ? fails(detection) 1718 : !!detection; 1719}; 1720 1721var normalize = isForced.normalize = function (string) { 1722 return String(string).replace(replacement, '.').toLowerCase(); 1723}; 1724 1725var data = isForced.data = {}; 1726var NATIVE = isForced.NATIVE = 'N'; 1727var POLYFILL = isForced.POLYFILL = 'P'; 1728 1729module.exports = isForced; 1730 1731 1732/***/ }, 1733 1734/***/ 4117 1735(module) { 1736 1737 1738// we can't use just `it == null` since of `document.all` special case 1739// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec 1740module.exports = function (it) { 1741 return it === null || it === undefined; 1742}; 1743 1744 1745/***/ }, 1746 1747/***/ 34 1748(module, __unused_webpack_exports, __webpack_require__) { 1749 1750 1751var isCallable = __webpack_require__(4901); 1752 1753module.exports = function (it) { 1754 return typeof it == 'object' ? it !== null : isCallable(it); 1755}; 1756 1757 1758/***/ }, 1759 1760/***/ 3925 1761(module, __unused_webpack_exports, __webpack_require__) { 1762 1763 1764var isObject = __webpack_require__(34); 1765 1766module.exports = function (argument) { 1767 return isObject(argument) || argument === null; 1768}; 1769 1770 1771/***/ }, 1772 1773/***/ 6395 1774(module) { 1775 1776 1777module.exports = false; 1778 1779 1780/***/ }, 1781 1782/***/ 5810 1783(module, __unused_webpack_exports, __webpack_require__) { 1784 1785 1786var isObject = __webpack_require__(34); 1787var getInternalState = (__webpack_require__(1181).get); 1788 1789module.exports = function isRawJSON(O) { 1790 if (!isObject(O)) return false; 1791 var state = getInternalState(O); 1792 return !!state && state.type === 'RawJSON'; 1793}; 1794 1795 1796/***/ }, 1797 1798/***/ 757 1799(module, __unused_webpack_exports, __webpack_require__) { 1800 1801 1802var getBuiltIn = __webpack_require__(7751); 1803var isCallable = __webpack_require__(4901); 1804var isPrototypeOf = __webpack_require__(1625); 1805var USE_SYMBOL_AS_UID = __webpack_require__(7040); 1806 1807var $Object = Object; 1808 1809module.exports = USE_SYMBOL_AS_UID ? function (it) { 1810 return typeof it == 'symbol'; 1811} : function (it) { 1812 var $Symbol = getBuiltIn('Symbol'); 1813 return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it)); 1814}; 1815 1816 1817/***/ }, 1818 1819/***/ 507 1820(module, __unused_webpack_exports, __webpack_require__) { 1821 1822 1823var call = __webpack_require__(9565); 1824 1825module.exports = function (record, fn, ITERATOR_INSTEAD_OF_RECORD) { 1826 var iterator = ITERATOR_INSTEAD_OF_RECORD ? record : record.iterator; 1827 var next = record.next; 1828 var step, result; 1829 while (!(step = call(next, iterator)).done) { 1830 result = fn(step.value); 1831 if (result !== undefined) return result; 1832 } 1833}; 1834 1835 1836/***/ }, 1837 1838/***/ 2652 1839(module, __unused_webpack_exports, __webpack_require__) { 1840 1841 1842var bind = __webpack_require__(6080); 1843var call = __webpack_require__(9565); 1844var anObject = __webpack_require__(8551); 1845var tryToString = __webpack_require__(6823); 1846var isArrayIteratorMethod = __webpack_require__(4209); 1847var lengthOfArrayLike = __webpack_require__(6198); 1848var isPrototypeOf = __webpack_require__(1625); 1849var getIterator = __webpack_require__(81); 1850var getIteratorMethod = __webpack_require__(851); 1851var iteratorClose = __webpack_require__(9539); 1852 1853var $TypeError = TypeError; 1854 1855var Result = function (stopped, result) { 1856 this.stopped = stopped; 1857 this.result = result; 1858}; 1859 1860var ResultPrototype = Result.prototype; 1861 1862module.exports = function (iterable, unboundFunction, options) { 1863 var that = options && options.that; 1864 var AS_ENTRIES = !!(options && options.AS_ENTRIES); 1865 var IS_RECORD = !!(options && options.IS_RECORD); 1866 var IS_ITERATOR = !!(options && options.IS_ITERATOR); 1867 var INTERRUPTED = !!(options && options.INTERRUPTED); 1868 var fn = bind(unboundFunction, that); 1869 var iterator, iterFn, index, length, result, next, step; 1870 1871 var stop = function (condition) { 1872 if (iterator) iteratorClose(iterator, 'normal'); 1873 return new Result(true, condition); 1874 }; 1875 1876 var callFn = function (value) { 1877 if (AS_ENTRIES) { 1878 anObject(value); 1879 return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]); 1880 }
vendor: 3,725 bytes, lines 1880-2001
1880 return INTERRUPTED ? fn(value, stop) : fn(value); 1881 }; 1882 1883 if (IS_RECORD) { 1884 iterator = iterable.iterator; 1885 } else if (IS_ITERATOR) { 1886 iterator = iterable; 1887 } else { 1888 iterFn = getIteratorMethod(iterable); 1889 if (!iterFn) throw new $TypeError(tryToString(iterable) + ' is not iterable'); 1890 // optimisation for array iterators 1891 if (isArrayIteratorMethod(iterFn)) { 1892 for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) { 1893 result = callFn(iterable[index]); 1894 if (result && isPrototypeOf(ResultPrototype, result)) return result; 1895 } return new Result(false); 1896 } 1897 iterator = getIterator(iterable, iterFn); 1898 } 1899 1900 next = IS_RECORD ? iterable.next : iterator.next; 1901 while (!(step = call(next, iterator)).done) { 1902 try { 1903 result = callFn(step.value); 1904 } catch (error) { 1905 iteratorClose(iterator, 'throw', error); 1906 } 1907 if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result; 1908 } return new Result(false); 1909}; 1910 1911 1912/***/ }, 1913 1914/***/ 1385 1915(module, __unused_webpack_exports, __webpack_require__) { 1916 1917 1918var iteratorClose = __webpack_require__(9539); 1919 1920module.exports = function (iters, kind, value) { 1921 for (var i = iters.length - 1; i >= 0; i--) { 1922 if (iters[i] === undefined) continue; 1923 try { 1924 value = iteratorClose(iters[i].iterator, kind, value); 1925 } catch (error) { 1926 kind = 'throw'; 1927 value = error; 1928 } 1929 } 1930 if (kind === 'throw') throw value; 1931 return value; 1932}; 1933 1934 1935/***/ }, 1936 1937/***/ 9539 1938(module, __unused_webpack_exports, __webpack_require__) { 1939 1940 1941var call = __webpack_require__(9565); 1942var anObject = __webpack_require__(8551); 1943var getMethod = __webpack_require__(5966); 1944 1945module.exports = function (iterator, kind, value) { 1946 var innerResult, innerError; 1947 anObject(iterator); 1948 try { 1949 innerResult = getMethod(iterator, 'return'); 1950 if (!innerResult) { 1951 if (kind === 'throw') throw value; 1952 return value; 1953 } 1954 innerResult = call(innerResult, iterator); 1955 } catch (error) { 1956 innerError = true; 1957 innerResult = error; 1958 } 1959 if (kind === 'throw') throw value; 1960 if (innerError) throw innerResult; 1961 anObject(innerResult); 1962 return value; 1963}; 1964 1965 1966/***/ }, 1967 1968/***/ 9462 1969(module, __unused_webpack_exports, __webpack_require__) { 1970 1971 1972var call = __webpack_require__(9565); 1973var create = __webpack_require__(2360); 1974var createNonEnumerableProperty = __webpack_require__(6699); 1975var defineBuiltIns = __webpack_require__(6279); 1976var wellKnownSymbol = __webpack_require__(8227); 1977var InternalStateModule = __webpack_require__(1181); 1978var getMethod = __webpack_require__(5966); 1979var IteratorPrototype = (__webpack_require__(7657).IteratorPrototype); 1980var createIterResultObject = __webpack_require__(2529); 1981var iteratorClose = __webpack_require__(9539); 1982var iteratorCloseAll = __webpack_require__(1385); 1983 1984var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 1985var ITERATOR_HELPER = 'IteratorHelper'; 1986var WRAP_FOR_VALID_ITERATOR = 'WrapForValidIterator'; 1987var NORMAL = 'normal'; 1988var THROW = 'throw'; 1989var setInternalState = InternalStateModule.set; 1990 1991var createIteratorProxyPrototype = function (IS_ITERATOR) { 1992 var getInternalState = InternalStateModule.getterFor(IS_ITERATOR ? WRAP_FOR_VALID_ITERATOR : ITERATOR_HELPER); 1993 1994 return defineBuiltIns(create(IteratorPrototype), { 1995 next: function next() { 1996 var state = getInternalState(this); 1997 // for simplification: 1998 // for `%WrapForValidIteratorPrototype%.next` or with `state.returnHandlerResult` our `nextHandler` returns `IterResultObject` 1999 // for `%IteratorHelperPrototype%.next` - just a value 2000 if (IS_ITERATOR) return state.nextHandler(); 2001 if (state.done) return createIterResultObject(undefined, true);
vendor: 4,981 bytes, lines 2002-2178
2002 try { 2003 var result = state.nextHandler(); 2004 return state.returnHandlerResult ? result : createIterResultObject(result, state.done); 2005 } catch (error) { 2006 state.done = true; 2007 throw error; 2008 } 2009 }, 2010 'return': function () { 2011 var state = getInternalState(this); 2012 var iterator = state.iterator; 2013 state.done = true; 2014 if (IS_ITERATOR) { 2015 var returnMethod = getMethod(iterator, 'return'); 2016 return returnMethod ? call(returnMethod, iterator) : createIterResultObject(undefined, true); 2017 } 2018 if (state.inner) try { 2019 iteratorClose(state.inner.iterator, NORMAL); 2020 } catch (error) { 2021 return iteratorClose(iterator, THROW, error); 2022 } 2023 if (state.openIters) try { 2024 iteratorCloseAll(state.openIters, NORMAL); 2025 } catch (error) { 2026 return iteratorClose(iterator, THROW, error); 2027 } 2028 if (iterator) iteratorClose(iterator, NORMAL); 2029 return createIterResultObject(undefined, true); 2030 } 2031 }); 2032}; 2033 2034var WrapForValidIteratorPrototype = createIteratorProxyPrototype(true); 2035var IteratorHelperPrototype = createIteratorProxyPrototype(false); 2036 2037createNonEnumerableProperty(IteratorHelperPrototype, TO_STRING_TAG, 'Iterator Helper'); 2038 2039module.exports = function (nextHandler, IS_ITERATOR, RETURN_HANDLER_RESULT) { 2040 var IteratorProxy = function Iterator(record, state) { 2041 if (state) { 2042 state.iterator = record.iterator; 2043 state.next = record.next; 2044 } else state = record; 2045 state.type = IS_ITERATOR ? WRAP_FOR_VALID_ITERATOR : ITERATOR_HELPER; 2046 state.returnHandlerResult = !!RETURN_HANDLER_RESULT; 2047 state.nextHandler = nextHandler; 2048 state.counter = 0; 2049 state.done = false; 2050 setInternalState(this, state); 2051 }; 2052 2053 IteratorProxy.prototype = IS_ITERATOR ? WrapForValidIteratorPrototype : IteratorHelperPrototype; 2054 2055 return IteratorProxy; 2056}; 2057 2058 2059/***/ }, 2060 2061/***/ 684 2062(module) { 2063 2064 2065// Should throw an error on invalid iterator 2066// https://issues.chromium.org/issues/336839115 2067module.exports = function (methodName, argument) { 2068 // eslint-disable-next-line es/no-iterator -- required for testing 2069 var method = typeof Iterator == 'function' && Iterator.prototype[methodName]; 2070 if (method) try { 2071 method.call({ next: null }, argument).next(); 2072 } catch (error) { 2073 return true; 2074 } 2075}; 2076 2077 2078/***/ }, 2079 2080/***/ 4549 2081(module, __unused_webpack_exports, __webpack_require__) { 2082 2083 2084var globalThis = __webpack_require__(4576); 2085 2086// https://github.com/tc39/ecma262/pull/3467 2087module.exports = function (METHOD_NAME, ExpectedError) { 2088 var Iterator = globalThis.Iterator; 2089 var IteratorPrototype = Iterator && Iterator.prototype; 2090 var method = IteratorPrototype && IteratorPrototype[METHOD_NAME]; 2091 2092 var CLOSED = false; 2093 2094 if (method) try { 2095 method.call({ 2096 next: function () { return { done: true }; }, 2097 'return': function () { CLOSED = true; } 2098 }, -1); 2099 } catch (error) { 2100 // https://bugs.webkit.org/show_bug.cgi?id=291195 2101 if (!(error instanceof ExpectedError)) CLOSED = false; 2102 } 2103 2104 if (!CLOSED) return method; 2105}; 2106 2107 2108/***/ }, 2109 2110/***/ 7657 2111(module, __unused_webpack_exports, __webpack_require__) { 2112 2113 2114var fails = __webpack_require__(9039); 2115var isCallable = __webpack_require__(4901); 2116var isObject = __webpack_require__(34); 2117var create = __webpack_require__(2360); 2118var getPrototypeOf = __webpack_require__(2787); 2119var defineBuiltIn = __webpack_require__(6840); 2120var wellKnownSymbol = __webpack_require__(8227); 2121var IS_PURE = __webpack_require__(6395); 2122 2123var ITERATOR = wellKnownSymbol('iterator'); 2124var BUGGY_SAFARI_ITERATORS = false; 2125 2126// `%IteratorPrototype%` object 2127// https://tc39.es/ecma262/#sec-%iteratorprototype%-object 2128var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator; 2129 2130/* eslint-disable es/no-array-prototype-keys -- safe */ 2131if ([].keys) { 2132 arrayIterator = [].keys(); 2133 // Safari 8 has buggy iterators w/o `next` 2134 if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true; 2135 else { 2136 PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator)); 2137 if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype; 2138 } 2139} 2140 2141var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype) || fails(function () { 2142 var test = {}; 2143 // FF44- legacy iterators case 2144 return IteratorPrototype[ITERATOR].call(test) !== test; 2145}); 2146 2147if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {}; 2148else if (IS_PURE) IteratorPrototype = create(IteratorPrototype); 2149 2150// `%IteratorPrototype%[@@iterator]()` method 2151// https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator 2152if (!isCallable(IteratorPrototype[ITERATOR])) { 2153 defineBuiltIn(IteratorPrototype, ITERATOR, function () { 2154 return this; 2155 }); 2156} 2157 2158module.exports = { 2159 IteratorPrototype: IteratorPrototype, 2160 BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS 2161}; 2162 2163 2164/***/ }, 2165 2166/***/ 6269 2167(module) { 2168 2169 2170module.exports = {}; 2171 2172 2173/***/ }, 2174 2175/***/ 6198 2176(module, __unused_webpack_exports, __webpack_require__) { 2177 2178
vendor: 4,727 bytes, lines 2179-2332
2179var toLength = __webpack_require__(8014); 2180 2181// `LengthOfArrayLike` abstract operation 2182// https://tc39.es/ecma262/#sec-lengthofarraylike 2183module.exports = function (obj) { 2184 return toLength(obj.length); 2185}; 2186 2187 2188/***/ }, 2189 2190/***/ 283 2191(module, __unused_webpack_exports, __webpack_require__) { 2192 2193 2194var uncurryThis = __webpack_require__(9504); 2195var fails = __webpack_require__(9039); 2196var isCallable = __webpack_require__(4901); 2197var hasOwn = __webpack_require__(9297); 2198var DESCRIPTORS = __webpack_require__(3724); 2199var CONFIGURABLE_FUNCTION_NAME = (__webpack_require__(350).CONFIGURABLE); 2200var inspectSource = __webpack_require__(3706); 2201var InternalStateModule = __webpack_require__(1181); 2202 2203var enforceInternalState = InternalStateModule.enforce; 2204var getInternalState = InternalStateModule.get; 2205var $String = String; 2206// eslint-disable-next-line es/no-object-defineproperty -- safe 2207var defineProperty = Object.defineProperty; 2208var stringSlice = uncurryThis(''.slice); 2209var replace = uncurryThis(''.replace); 2210var join = uncurryThis([].join); 2211 2212var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function () { 2213 return defineProperty(function () { /* empty */ }, 'length', { value: 8 }).length !== 8; 2214}); 2215 2216var TEMPLATE = String(String).split('String'); 2217 2218var makeBuiltIn = module.exports = function (value, name, options) { 2219 if (stringSlice($String(name), 0, 7) === 'Symbol(') { 2220 name = '[' + replace($String(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']'; 2221 } 2222 if (options && options.getter) name = 'get ' + name; 2223 if (options && options.setter) name = 'set ' + name; 2224 if (!hasOwn(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) { 2225 if (DESCRIPTORS) defineProperty(value, 'name', { value: name, configurable: true }); 2226 else value.name = name; 2227 } 2228 if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) { 2229 defineProperty(value, 'length', { value: options.arity }); 2230 } 2231 try { 2232 if (options && hasOwn(options, 'constructor') && options.constructor) { 2233 if (DESCRIPTORS) defineProperty(value, 'prototype', { writable: false }); 2234 // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable 2235 } else if (value.prototype) value.prototype = undefined; 2236 } catch (error) { /* empty */ } 2237 var state = enforceInternalState(value); 2238 if (!hasOwn(state, 'source')) { 2239 state.source = join(TEMPLATE, typeof name == 'string' ? name : ''); 2240 } return value; 2241}; 2242 2243// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative 2244// eslint-disable-next-line no-extend-native -- required 2245Function.prototype.toString = makeBuiltIn(function toString() { 2246 return isCallable(this) && getInternalState(this).source || inspectSource(this); 2247}, 'toString'); 2248 2249 2250/***/ }, 2251 2252/***/ 2248 2253(module, __unused_webpack_exports, __webpack_require__) { 2254 2255 2256var uncurryThis = __webpack_require__(9504); 2257 2258// eslint-disable-next-line es/no-map -- safe 2259var MapPrototype = Map.prototype; 2260 2261module.exports = { 2262 // eslint-disable-next-line es/no-map -- safe 2263 Map: Map, 2264 set: uncurryThis(MapPrototype.set), 2265 get: uncurryThis(MapPrototype.get), 2266 has: uncurryThis(MapPrototype.has), 2267 remove: uncurryThis(MapPrototype['delete']), 2268 proto: MapPrototype 2269}; 2270 2271 2272/***/ }, 2273 2274/***/ 741 2275(module) { 2276 2277 2278var ceil = Math.ceil; 2279var floor = Math.floor; 2280 2281// `Math.trunc` method 2282// https://tc39.es/ecma262/#sec-math.trunc 2283// eslint-disable-next-line es/no-math-trunc -- safe 2284module.exports = Math.trunc || function trunc(x) { 2285 var n = +x; 2286 return (n > 0 ? floor : ceil)(n); 2287}; 2288 2289 2290/***/ }, 2291 2292/***/ 7819 2293(module, __unused_webpack_exports, __webpack_require__) { 2294 2295 2296/* eslint-disable es/no-json -- safe */ 2297var fails = __webpack_require__(9039); 2298 2299module.exports = !fails(function () { 2300 var unsafeInt = '9007199254740993'; 2301 // eslint-disable-next-line es/no-json-rawjson -- feature detection 2302 var raw = JSON.rawJSON(unsafeInt); 2303 // eslint-disable-next-line es/no-json-israwjson -- feature detection 2304 return !JSON.isRawJSON(raw) || JSON.stringify(raw) !== unsafeInt; 2305}); 2306 2307 2308/***/ }, 2309 2310/***/ 6043 2311(module, __unused_webpack_exports, __webpack_require__) { 2312 2313 2314var aCallable = __webpack_require__(9306); 2315 2316var $TypeError = TypeError; 2317 2318var PromiseCapability = function (C) { 2319 var resolve, reject; 2320 this.promise = new C(function ($$resolve, $$reject) { 2321 if (resolve !== undefined || reject !== undefined) throw new $TypeError('Bad Promise constructor'); 2322 resolve = $$resolve; 2323 reject = $$reject; 2324 }); 2325 this.resolve = aCallable(resolve); 2326 this.reject = aCallable(reject); 2327}; 2328 2329// `NewPromiseCapability` abstract operation 2330// https://tc39.es/ecma262/#sec-newpromisecapability 2331module.exports.f = function (C) { 2332 return new PromiseCapability(C
vendor: 11,767 bytes, lines 2332-2710
2332); 2333}; 2334 2335 2336/***/ }, 2337 2338/***/ 2360 2339(module, __unused_webpack_exports, __webpack_require__) { 2340 2341 2342/* global ActiveXObject -- old IE, WSH */ 2343var anObject = __webpack_require__(8551); 2344var definePropertiesModule = __webpack_require__(6801); 2345var enumBugKeys = __webpack_require__(8727); 2346var hiddenKeys = __webpack_require__(421); 2347var html = __webpack_require__(397); 2348var documentCreateElement = __webpack_require__(4055); 2349var sharedKey = __webpack_require__(6119); 2350 2351var GT = '>'; 2352var LT = '<'; 2353var PROTOTYPE = 'prototype'; 2354var SCRIPT = 'script'; 2355var IE_PROTO = sharedKey('IE_PROTO'); 2356 2357var EmptyConstructor = function () { /* empty */ }; 2358 2359var scriptTag = function (content) { 2360 return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; 2361}; 2362 2363// Create object with fake `null` prototype: use ActiveX Object with cleared prototype 2364var NullProtoObjectViaActiveX = function (activeXDocument) { 2365 activeXDocument.write(scriptTag('')); 2366 activeXDocument.close(); 2367 var temp = activeXDocument.parentWindow.Object; 2368 // eslint-disable-next-line no-useless-assignment -- avoid memory leak 2369 activeXDocument = null; 2370 return temp; 2371}; 2372 2373// Create object with fake `null` prototype: use iframe Object with cleared prototype 2374var NullProtoObjectViaIFrame = function () { 2375 // Thrash, waste and sodomy: IE GC bug 2376 var iframe = documentCreateElement('iframe'); 2377 var JS = 'java' + SCRIPT + ':'; 2378 var iframeDocument; 2379 iframe.style.display = 'none'; 2380 html.appendChild(iframe); 2381 // https://github.com/zloirock/core-js/issues/475 2382 iframe.src = String(JS); 2383 iframeDocument = iframe.contentWindow.document; 2384 iframeDocument.open(); 2385 iframeDocument.write(scriptTag('document.F=Object')); 2386 iframeDocument.close(); 2387 return iframeDocument.F; 2388}; 2389 2390// Check for document.domain and active x support 2391// No need to use active x approach when document.domain is not set 2392// see https://github.com/es-shims/es5-shim/issues/150 2393// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 2394// avoid IE GC bug 2395var activeXDocument; 2396var NullProtoObject = function () { 2397 try { 2398 activeXDocument = new ActiveXObject('htmlfile'); 2399 } catch (error) { /* ignore */ } 2400 NullProtoObject = typeof document != 'undefined' 2401 ? document.domain && activeXDocument 2402 ? NullProtoObjectViaActiveX(activeXDocument) // old IE 2403 : NullProtoObjectViaIFrame() 2404 : NullProtoObjectViaActiveX(activeXDocument); // WSH 2405 var length = enumBugKeys.length; 2406 while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; 2407 return NullProtoObject(); 2408}; 2409 2410hiddenKeys[IE_PROTO] = true; 2411 2412// `Object.create` method 2413// https://tc39.es/ecma262/#sec-object.create 2414// eslint-disable-next-line es/no-object-create -- safe 2415module.exports = Object.create || function create(O, Properties) { 2416 var result; 2417 if (O !== null) { 2418 EmptyConstructor[PROTOTYPE] = anObject(O); 2419 result = new EmptyConstructor(); 2420 EmptyConstructor[PROTOTYPE] = null; 2421 // add "__proto__" for Object.getPrototypeOf polyfill 2422 result[IE_PROTO] = O; 2423 } else result = NullProtoObject(); 2424 return Properties === undefined ? result : definePropertiesModule.f(result, Properties); 2425}; 2426 2427 2428/***/ }, 2429 2430/***/ 6801 2431(__unused_webpack_module, exports, __webpack_require__) { 2432 2433 2434var DESCRIPTORS = __webpack_require__(3724); 2435var V8_PROTOTYPE_DEFINE_BUG = __webpack_require__(8686); 2436var definePropertyModule = __webpack_require__(4913); 2437var anObject = __webpack_require__(8551); 2438var toIndexedObject = __webpack_require__(5397); 2439var objectKeys = __webpack_require__(1072); 2440 2441// `Object.defineProperties` method 2442// https://tc39.es/ecma262/#sec-object.defineproperties 2443// eslint-disable-next-line es/no-object-defineproperties -- safe 2444exports.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) { 2445 anObject(O); 2446 var props = toIndexedObject(Properties); 2447 var keys = objectKeys(Properties); 2448 var length = keys.length; 2449 var index = 0; 2450 var key; 2451 while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]); 2452 return O; 2453}; 2454 2455 2456/***/ }, 2457 2458/***/ 4913 2459(__unused_webpack_module, exports, __webpack_require__) { 2460 2461 2462var DESCRIPTORS = __webpack_require__(3724); 2463var IE8_DOM_DEFINE = __webpack_require__(5917); 2464var V8_PROTOTYPE_DEFINE_BUG = __webpack_require__(8686); 2465var anObject = __webpack_require__(8551); 2466var toPropertyKey = __webpack_require__(6969); 2467 2468var $TypeError = TypeError; 2469// eslint-disable-next-line es/no-object-defineproperty -- safe 2470var $defineProperty = Object.defineProperty; 2471// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2472var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 2473var ENUMERABLE = 'enumerable'; 2474var CONFIGURABLE = 'configurable'; 2475var WRITABLE = 'writable'; 2476 2477// `Object.defineProperty` method 2478// https://tc39.es/ecma262/#sec-object.defineproperty 2479exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) { 2480 anObject(O); 2481 P = toPropertyKey(P); 2482 anObject(Attributes); 2483 if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) { 2484 var current = $getOwnPropertyDescriptor(O, P); 2485 if (current && current[WRITABLE]) { 2486 O[P] = Attributes.value; 2487 Attributes = { 2488 configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE], 2489 enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE], 2490 writable: false 2491 }; 2492 } 2493 } return $defineProperty(O, P, Attributes); 2494} : $defineProperty : function defineProperty(O, P, Attributes) { 2495 anObject(O); 2496 P = toPropertyKey(P); 2497 anObject(Attributes); 2498 if (IE8_DOM_DEFINE) try { 2499 return $defineProperty(O, P, Attributes); 2500 } catch (error) { /* empty */ } 2501 if ('get' in Attributes || 'set' in Attributes) throw new $TypeError('Accessors not supported'); 2502 if ('value' in Attributes) O[P] = Attributes.value; 2503 return O; 2504}; 2505 2506 2507/***/ }, 2508 2509/***/ 7347 2510(__unused_webpack_module, exports, __webpack_require__) { 2511 2512 2513var DESCRIPTORS = __webpack_require__(3724); 2514var call = __webpack_require__(9565); 2515var propertyIsEnumerableModule = __webpack_require__(8773); 2516var createPropertyDescriptor = __webpack_require__(6980); 2517var toIndexedObject = __webpack_require__(5397); 2518var toPropertyKey = __webpack_require__(6969); 2519var hasOwn = __webpack_require__(9297); 2520var IE8_DOM_DEFINE = __webpack_require__(5917); 2521 2522// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2523var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 2524 2525// `Object.getOwnPropertyDescriptor` method 2526// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor 2527exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { 2528 O = toIndexedObject(O); 2529 P = toPropertyKey(P); 2530 if (IE8_DOM_DEFINE) try { 2531 return $getOwnPropertyDescriptor(O, P); 2532 } catch (error) { /* empty */ } 2533 if (hasOwn(O, P)) return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]); 2534}; 2535 2536 2537/***/ }, 2538 2539/***/ 8480 2540(__unused_webpack_module, exports, __webpack_require__) { 2541 2542 2543var internalObjectKeys = __webpack_require__(1828); 2544var enumBugKeys = __webpack_require__(8727); 2545 2546var hiddenKeys = enumBugKeys.concat('length', 'prototype'); 2547 2548// `Object.getOwnPropertyNames` method 2549// https://tc39.es/ecma262/#sec-object.getownpropertynames 2550// eslint-disable-next-line es/no-object-getownpropertynames -- safe 2551exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { 2552 return internalObjectKeys(O, hiddenKeys); 2553}; 2554 2555 2556/***/ }, 2557 2558/***/ 3717 2559(__unused_webpack_module, exports) { 2560 2561 2562// eslint-disable-next-line es/no-object-getownpropertysymbols -- safe 2563exports.f = Object.getOwnPropertySymbols; 2564 2565 2566/***/ }, 2567 2568/***/ 2787 2569(module, __unused_webpack_exports, __webpack_require__) { 2570 2571 2572var hasOwn = __webpack_require__(9297); 2573var isCallable = __webpack_require__(4901); 2574var toObject = __webpack_require__(8981); 2575var sharedKey = __webpack_require__(6119); 2576var CORRECT_PROTOTYPE_GETTER = __webpack_require__(2211); 2577 2578var IE_PROTO = sharedKey('IE_PROTO'); 2579var $Object = Object; 2580var ObjectPrototype = $Object.prototype; 2581 2582// `Object.getPrototypeOf` method 2583// https://tc39.es/ecma262/#sec-object.getprototypeof 2584// eslint-disable-next-line es/no-object-getprototypeof -- safe 2585module.exports = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) { 2586 var object = toObject(O); 2587 if (hasOwn(object, IE_PROTO)) return object[IE_PROTO]; 2588 var constructor = object.constructor; 2589 if (isCallable(constructor) && object instanceof constructor) { 2590 return constructor.prototype; 2591 } return object instanceof $Object ? ObjectPrototype : null; 2592}; 2593 2594 2595/***/ }, 2596 2597/***/ 1625 2598(module, __unused_webpack_exports, __webpack_require__) { 2599 2600 2601var uncurryThis = __webpack_require__(9504); 2602 2603module.exports = uncurryThis({}.isPrototypeOf); 2604 2605 2606/***/ }, 2607 2608/***/ 1828 2609(module, __unused_webpack_exports, __webpack_require__) { 2610 2611 2612var uncurryThis = __webpack_require__(9504); 2613var hasOwn = __webpack_require__(9297); 2614var toIndexedObject = __webpack_require__(5397); 2615var indexOf = (__webpack_require__(9617).indexOf); 2616var hiddenKeys = __webpack_require__(421); 2617 2618var push = uncurryThis([].push); 2619 2620module.exports = function (object, names) { 2621 var O = toIndexedObject(object); 2622 var i = 0; 2623 var result = []; 2624 var key; 2625 for (key in O) !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key); 2626 // Don't enum bug & hidden keys 2627 while (names.length > i) if (hasOwn(O, key = names[i++])) { 2628 ~indexOf(result, key) || push(result, key); 2629 } 2630 return result; 2631}; 2632 2633 2634/***/ }, 2635 2636/***/ 1072 2637(module, __unused_webpack_exports, __webpack_require__) { 2638 2639 2640var internalObjectKeys = __webpack_require__(1828); 2641var enumBugKeys = __webpack_require__(8727); 2642 2643// `Object.keys` method 2644// https://tc39.es/ecma262/#sec-object.keys 2645// eslint-disable-next-line es/no-object-keys -- safe 2646module.exports = Object.keys || function keys(O) { 2647 return internalObjectKeys(O, enumBugKeys); 2648}; 2649 2650 2651/***/ }, 2652 2653/***/ 8773 2654(__unused_webpack_module, exports) { 2655 2656 2657var $propertyIsEnumerable = {}.propertyIsEnumerable; 2658// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2659var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 2660 2661// Nashorn ~ JDK8 bug 2662var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1); 2663 2664// `Object.prototype.propertyIsEnumerable` method implementation 2665// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable 2666exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) { 2667 var descriptor = getOwnPropertyDescriptor(this, V); 2668 return !!descriptor && descriptor.enumerable; 2669} : $propertyIsEnumerable; 2670 2671 2672/***/ }, 2673 2674/***/ 2967 2675(module, __unused_webpack_exports, __webpack_require__) { 2676 2677 2678/* eslint-disable no-proto -- safe */ 2679var uncurryThisAccessor = __webpack_require__(6706); 2680var isObject = __webpack_require__(34); 2681var requireObjectCoercible = __webpack_require__(7750); 2682var aPossiblePrototype = __webpack_require__(3506); 2683 2684// `Object.setPrototypeOf` method 2685// https://tc39.es/ecma262/#sec-object.setprototypeof 2686// Works with __proto__ only. Old v8 can't work with null proto objects. 2687// eslint-disable-next-line es/no-object-setprototypeof -- safe 2688module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () { 2689 var CORRECT_SETTER = false; 2690 var test = {}; 2691 var setter; 2692 try { 2693 setter = uncurryThisAccessor(Object.prototype, '__proto__', 'set'); 2694 setter(test, []); 2695 CORRECT_SETTER = test instanceof Array; 2696 } catch (error) { /* empty */ } 2697 return function setPrototypeOf(O, proto) { 2698 requireObjectCoercible(O); 2699 aPossiblePrototype(proto); 2700 if (!isObject(O)) return O; 2701 if (CORRECT_SETTER) setter(O, proto); 2702 else O.__proto__ = proto; 2703 return O; 2704 }; 2705}() : undefined); 2706 2707 2708/***/ }, 2709 2710/***/
27104270 2711(module, __unused_webpack_exports, __webpack_require__) { 2712 2713 2714var call = __webpack_require__(9565); 2715var isCallable = __webpack_require__(4901); 2716var isObject = __webpack_require__(34); 2717 2718var $TypeError = TypeError; 2719 2720// `OrdinaryToPrimitive` abstract operation 2721// https://tc39.es/ecma262/#sec-ordinarytoprimitive 2722module.exports = function (input, pref) { 2723 var fn, val; 2724 if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val; 2725 if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val; 2726 if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val; 2727 throw new $TypeError("Can't convert object to primitive value"); 2728}; 2729 2730 2731/***/ }, 2732 2733/***/ 5031 2734(module, __unused_webpack_exports, __webpack_require__) { 2735 2736 2737var getBuiltIn = __webpack_require__(7751); 2738var uncurryThis = __webpack_require__(9504); 2739var getOwnPropertyNamesModule = __webpack_require__(8480); 2740var getOwnPropertySymbolsModule = __webpack_require__(3717); 2741var anObject = __webpack_require__(8551); 2742
vendor: 5,808 bytes, lines 2743-2967
2743var concat = uncurryThis([].concat); 2744 2745// all object keys, includes non-enumerable and symbols 2746module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { 2747 var keys = getOwnPropertyNamesModule.f(anObject(it)); 2748 var getOwnPropertySymbols = getOwnPropertySymbolsModule.f; 2749 return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys; 2750}; 2751 2752 2753/***/ }, 2754 2755/***/ 8235 2756(module, __unused_webpack_exports, __webpack_require__) { 2757 2758 2759var uncurryThis = __webpack_require__(9504); 2760var hasOwn = __webpack_require__(9297); 2761 2762var $SyntaxError = SyntaxError; 2763var $parseInt = parseInt; 2764var fromCharCode = String.fromCharCode; 2765var at = uncurryThis(''.charAt); 2766var slice = uncurryThis(''.slice); 2767var exec = uncurryThis(/./.exec); 2768 2769var codePoints = { 2770 '\\"': '"', 2771 '\\\\': '\\', 2772 '\\/': '/', 2773 '\\b': '\b', 2774 '\\f': '\f', 2775 '\\n': '\n', 2776 '\\r': '\r', 2777 '\\t': '\t' 2778}; 2779 2780var IS_4_HEX_DIGITS = /^[\da-f]{4}$/i; 2781// eslint-disable-next-line regexp/no-control-character -- safe 2782var IS_C0_CONTROL_CODE = /^[\u0000-\u001F]$/; 2783 2784module.exports = function (source, i) { 2785 var unterminated = true; 2786 var value = ''; 2787 while (i < source.length) { 2788 var chr = at(source, i); 2789 if (chr === '\\') { 2790 var twoChars = slice(source, i, i + 2); 2791 if (hasOwn(codePoints, twoChars)) { 2792 value += codePoints[twoChars]; 2793 i += 2; 2794 } else if (twoChars === '\\u') { 2795 i += 2; 2796 var fourHexDigits = slice(source, i, i + 4); 2797 if (!exec(IS_4_HEX_DIGITS, fourHexDigits)) throw new $SyntaxError('Bad Unicode escape at: ' + i); 2798 value += fromCharCode($parseInt(fourHexDigits, 16)); 2799 i += 4; 2800 } else throw new $SyntaxError('Unknown escape sequence: "' + twoChars + '"'); 2801 } else if (chr === '"') { 2802 unterminated = false; 2803 i++; 2804 break; 2805 } else { 2806 if (exec(IS_C0_CONTROL_CODE, chr)) throw new $SyntaxError('Bad control character in string literal at: ' + i); 2807 value += chr; 2808 i++; 2809 } 2810 } 2811 if (unterminated) throw new $SyntaxError('Unterminated string at: ' + i); 2812 return { value: value, end: i }; 2813}; 2814 2815 2816/***/ }, 2817 2818/***/ 7750 2819(module, __unused_webpack_exports, __webpack_require__) { 2820 2821 2822var isNullOrUndefined = __webpack_require__(4117); 2823 2824var $TypeError = TypeError; 2825 2826// `RequireObjectCoercible` abstract operation 2827// https://tc39.es/ecma262/#sec-requireobjectcoercible 2828module.exports = function (it) { 2829 if (isNullOrUndefined(it)) throw new $TypeError("Can't call method on " + it); 2830 return it; 2831}; 2832 2833 2834/***/ }, 2835 2836/***/ 9286 2837(module, __unused_webpack_exports, __webpack_require__) { 2838 2839 2840var SetHelpers = __webpack_require__(4402); 2841var iterate = __webpack_require__(8469); 2842 2843var Set = SetHelpers.Set; 2844var add = SetHelpers.add; 2845 2846module.exports = function (set) { 2847 var result = new Set(); 2848 iterate(set, function (it) { 2849 add(result, it); 2850 }); 2851 return result; 2852}; 2853 2854 2855/***/ }, 2856 2857/***/ 3440 2858(module, __unused_webpack_exports, __webpack_require__) { 2859 2860 2861var aSet = __webpack_require__(7080); 2862var SetHelpers = __webpack_require__(4402); 2863var clone = __webpack_require__(9286); 2864var size = __webpack_require__(5170); 2865var getSetRecord = __webpack_require__(3789); 2866var iterateSet = __webpack_require__(8469); 2867var iterateSimple = __webpack_require__(507); 2868 2869var has = SetHelpers.has; 2870var remove = SetHelpers.remove; 2871 2872// `Set.prototype.difference` method 2873// https://tc39.es/ecma262/#sec-set.prototype.difference 2874module.exports = function difference(other) { 2875 var O = aSet(this); 2876 var otherRec = getSetRecord(other); 2877 var result = clone(O); 2878 if (size(O) <= otherRec.size) iterateSet(O, function (e) { 2879 if (otherRec.includes(e)) remove(result, e); 2880 }); 2881 else iterateSimple(otherRec.getIterator(), function (e) { 2882 if (has(result, e)) remove(result, e); 2883 }); 2884 return result; 2885}; 2886 2887 2888/***/ }, 2889 2890/***/ 4402 2891(module, __unused_webpack_exports, __webpack_require__) { 2892 2893 2894var uncurryThis = __webpack_require__(9504); 2895 2896// eslint-disable-next-line es/no-set -- safe 2897var SetPrototype = Set.prototype; 2898 2899module.exports = { 2900 // eslint-disable-next-line es/no-set -- safe 2901 Set: Set, 2902 add: uncurryThis(SetPrototype.add), 2903 has: uncurryThis(SetPrototype.has), 2904 remove: uncurryThis(SetPrototype['delete']), 2905 proto: SetPrototype 2906}; 2907 2908 2909/***/ }, 2910 2911/***/ 8750 2912(module, __unused_webpack_exports, __webpack_require__) { 2913 2914 2915var aSet = __webpack_require__(7080); 2916var SetHelpers = __webpack_require__(4402); 2917var size = __webpack_require__(5170); 2918var getSetRecord = __webpack_require__(3789); 2919var iterateSet = __webpack_require__(8469); 2920var iterateSimple = __webpack_require__(507); 2921 2922var Set = SetHelpers.Set; 2923var add = SetHelpers.add; 2924var has = SetHelpers.has; 2925 2926// `Set.prototype.intersection` method 2927// https://tc39.es/ecma262/#sec-set.prototype.intersection 2928module.exports = function intersection(other) { 2929 var O = aSet(this); 2930 var otherRec = getSetRecord(other); 2931 var result = new Set(); 2932 2933 if (size(O) > otherRec.size) { 2934 iterateSimple(otherRec.getIterator(), function (e) { 2935 if (has(O, e)) add(result, e); 2936 }); 2937 } else { 2938 iterateSet(O, function (e) { 2939 if (otherRec.includes(e)) add(result, e); 2940 }); 2941 } 2942 2943 return result; 2944}; 2945 2946 2947/***/ }, 2948 2949/***/ 4449 2950(module, __unused_webpack_exports, __webpack_require__) { 2951 2952 2953var aSet = __webpack_require__(7080); 2954var has = (__webpack_require__(4402).has); 2955var size = __webpack_require__(5170); 2956var getSetRecord = __webpack_require__(3789); 2957var iterateSet = __webpack_require__(8469); 2958var iterateSimple = __webpack_require__(507); 2959var iteratorClose = __webpack_require__(9539); 2960 2961// `Set.prototype.isDisjointFrom` method 2962// https://tc39.es/ecma262/#sec-set.prototype.isdisjointfrom 2963module.exports = function isDisjointFrom(other) { 2964 var O = aSet(this); 2965 var otherRec = getSetRecord(other); 2966 if (size(O) <= otherRec.size) return iterateSet(O, function (e) { 2967 if (otherRec.includes(e)) return false;
vendor: 4,477 bytes, lines 2968-3143
2968 }, true) !== false; 2969 var iterator = otherRec.getIterator(); 2970 return iterateSimple(iterator, function (e) { 2971 if (has(O, e)) return iteratorClose(iterator, 'normal', false); 2972 }) !== false; 2973}; 2974 2975 2976/***/ }, 2977 2978/***/ 3838 2979(module, __unused_webpack_exports, __webpack_require__) { 2980 2981 2982var aSet = __webpack_require__(7080); 2983var size = __webpack_require__(5170); 2984var iterate = __webpack_require__(8469); 2985var getSetRecord = __webpack_require__(3789); 2986 2987// `Set.prototype.isSubsetOf` method 2988// https://tc39.es/ecma262/#sec-set.prototype.issubsetof 2989module.exports = function isSubsetOf(other) { 2990 var O = aSet(this); 2991 var otherRec = getSetRecord(other); 2992 if (size(O) > otherRec.size) return false; 2993 return iterate(O, function (e) { 2994 if (!otherRec.includes(e)) return false; 2995 }, true) !== false; 2996}; 2997 2998 2999/***/ }, 3000 3001/***/ 8527 3002(module, __unused_webpack_exports, __webpack_require__) { 3003 3004 3005var aSet = __webpack_require__(7080); 3006var has = (__webpack_require__(4402).has); 3007var size = __webpack_require__(5170); 3008var getSetRecord = __webpack_require__(3789); 3009var iterateSimple = __webpack_require__(507); 3010var iteratorClose = __webpack_require__(9539); 3011 3012// `Set.prototype.isSupersetOf` method 3013// https://tc39.es/ecma262/#sec-set.prototype.issupersetof 3014module.exports = function isSupersetOf(other) { 3015 var O = aSet(this); 3016 var otherRec = getSetRecord(other); 3017 if (size(O) < otherRec.size) return false; 3018 var iterator = otherRec.getIterator(); 3019 return iterateSimple(iterator, function (e) { 3020 if (!has(O, e)) return iteratorClose(iterator, 'normal', false); 3021 }) !== false; 3022}; 3023 3024 3025/***/ }, 3026 3027/***/ 8469 3028(module, __unused_webpack_exports, __webpack_require__) { 3029 3030 3031var uncurryThis = __webpack_require__(9504); 3032var iterateSimple = __webpack_require__(507); 3033var SetHelpers = __webpack_require__(4402); 3034 3035var Set = SetHelpers.Set; 3036var SetPrototype = SetHelpers.proto; 3037var forEach = uncurryThis(SetPrototype.forEach); 3038var keys = uncurryThis(SetPrototype.keys); 3039var next = keys(new Set()).next; 3040 3041module.exports = function (set, fn, interruptible) { 3042 return interruptible ? iterateSimple({ iterator: keys(set), next: next }, fn) : forEach(set, fn); 3043}; 3044 3045 3046/***/ }, 3047 3048/***/ 4916 3049(module, __unused_webpack_exports, __webpack_require__) { 3050 3051 3052var getBuiltIn = __webpack_require__(7751); 3053 3054var createSetLike = function (size) { 3055 return { 3056 size: size, 3057 has: function () { 3058 return false; 3059 }, 3060 keys: function () { 3061 return { 3062 next: function () { 3063 return { done: true }; 3064 } 3065 }; 3066 } 3067 }; 3068}; 3069 3070var createSetLikeWithInfinitySize = function (size) { 3071 return { 3072 size: size, 3073 has: function () { 3074 return true; 3075 }, 3076 keys: function () { 3077 throw new Error('e'); 3078 } 3079 }; 3080}; 3081 3082module.exports = function (name, callback) { 3083 var Set = getBuiltIn('Set'); 3084 try { 3085 new Set()[name](createSetLike(0)); 3086 try { 3087 // late spec change, early WebKit ~ Safari 17 implementation does not pass it 3088 // https://github.com/tc39/proposal-set-methods/pull/88 3089 // also covered engines with 3090 // https://bugs.webkit.org/show_bug.cgi?id=272679 3091 new Set()[name](createSetLike(-1)); 3092 return false; 3093 } catch (error2) { 3094 if (!callback) return true; 3095 // early V8 implementation bug 3096 // https://issues.chromium.org/issues/351332634 3097 try { 3098 new Set()[name](createSetLikeWithInfinitySize(-Infinity)); 3099 return false; 3100 } catch (error) { 3101 var set = new Set([1, 2]); 3102 return callback(set[name](createSetLikeWithInfinitySize(Infinity))); 3103 } 3104 } 3105 } catch (error) { 3106 return false; 3107 } 3108}; 3109 3110 3111/***/ }, 3112 3113/***/ 9835 3114(module) { 3115 3116 3117// Should get iterator record of a set-like object before cloning this 3118// https://bugs.webkit.org/show_bug.cgi?id=289430 3119module.exports = function (METHOD_NAME) { 3120 try { 3121 // eslint-disable-next-line es/no-set -- needed for test 3122 var baseSet = new Set(); 3123 var setLike = { 3124 size: 0, 3125 has: function () { return true; }, 3126 keys: function () { 3127 // eslint-disable-next-line es/no-object-defineproperty -- needed for test 3128 return Object.defineProperty({}, 'next', { 3129 get: function () { 3130 baseSet.clear(); 3131 baseSet.add(4); 3132 return function () { 3133 return { done: true }; 3134 }; 3135 } 3136 }); 3137 } 3138 }; 3139 var result = baseSet[METHOD_NAME](setLike); 3140 3141 return result.size === 1 && result.values().next().value === 4; 3142 } catch (error) { 3143 return false;
vendor: 5,620 bytes, lines 3144-3350
3144 } 3145}; 3146 3147 3148/***/ }, 3149 3150/***/ 5170 3151(module, __unused_webpack_exports, __webpack_require__) { 3152 3153 3154var uncurryThisAccessor = __webpack_require__(6706); 3155var SetHelpers = __webpack_require__(4402); 3156 3157module.exports = uncurryThisAccessor(SetHelpers.proto, 'size', 'get') || function (set) { 3158 return set.size; 3159}; 3160 3161 3162/***/ }, 3163 3164/***/ 3650 3165(module, __unused_webpack_exports, __webpack_require__) { 3166 3167 3168var aSet = __webpack_require__(7080); 3169var SetHelpers = __webpack_require__(4402); 3170var clone = __webpack_require__(9286); 3171var getSetRecord = __webpack_require__(3789); 3172var iterateSimple = __webpack_require__(507); 3173 3174var add = SetHelpers.add; 3175var has = SetHelpers.has; 3176var remove = SetHelpers.remove; 3177 3178// `Set.prototype.symmetricDifference` method 3179// https://tc39.es/ecma262/#sec-set.prototype.symmetricdifference 3180module.exports = function symmetricDifference(other) { 3181 var O = aSet(this); 3182 var keysIter = getSetRecord(other).getIterator(); 3183 var result = clone(O); 3184 iterateSimple(keysIter, function (e) { 3185 if (has(O, e)) remove(result, e); 3186 else add(result, e); 3187 }); 3188 return result; 3189}; 3190 3191 3192/***/ }, 3193 3194/***/ 4204 3195(module, __unused_webpack_exports, __webpack_require__) { 3196 3197 3198var aSet = __webpack_require__(7080); 3199var add = (__webpack_require__(4402).add); 3200var clone = __webpack_require__(9286); 3201var getSetRecord = __webpack_require__(3789); 3202var iterateSimple = __webpack_require__(507); 3203 3204// `Set.prototype.union` method 3205// https://tc39.es/ecma262/#sec-set.prototype.union 3206module.exports = function union(other) { 3207 var O = aSet(this); 3208 var keysIter = getSetRecord(other).getIterator(); 3209 var result = clone(O); 3210 iterateSimple(keysIter, function (it) { 3211 add(result, it); 3212 }); 3213 return result; 3214}; 3215 3216 3217/***/ }, 3218 3219/***/ 6119 3220(module, __unused_webpack_exports, __webpack_require__) { 3221 3222 3223var shared = __webpack_require__(5745); 3224var uid = __webpack_require__(3392); 3225 3226var keys = shared('keys'); 3227 3228module.exports = function (key) { 3229 return keys[key] || (keys[key] = uid(key)); 3230}; 3231 3232 3233/***/ }, 3234 3235/***/ 7629 3236(module, __unused_webpack_exports, __webpack_require__) { 3237 3238 3239var IS_PURE = __webpack_require__(6395); 3240var globalThis = __webpack_require__(4576); 3241var defineGlobalProperty = __webpack_require__(9433); 3242 3243var SHARED = '__core-js_shared__'; 3244var store = module.exports = globalThis[SHARED] || defineGlobalProperty(SHARED, {}); 3245 3246(store.versions || (store.versions = [])).push({ 3247 version: '3.48.0', 3248 mode: IS_PURE ? 'pure' : 'global', 3249 copyright: '© 2013â2025 Denis Pushkarev (zloirock.ru), 2025â2026 CoreJS Company (core-js.io). All rights reserved.', 3250 license: 'https://github.com/zloirock/core-js/blob/v3.48.0/LICENSE', 3251 source: 'https://github.com/zloirock/core-js' 3252}); 3253 3254 3255/***/ }, 3256 3257/***/ 5745 3258(module, __unused_webpack_exports, __webpack_require__) { 3259 3260 3261var store = __webpack_require__(7629); 3262 3263module.exports = function (key, value) { 3264 return store[key] || (store[key] = value || {}); 3265}; 3266 3267 3268/***/ }, 3269 3270/***/ 533 3271(module, __unused_webpack_exports, __webpack_require__) { 3272 3273 3274var uncurryThis = __webpack_require__(9504); 3275var toLength = __webpack_require__(8014); 3276var toString = __webpack_require__(655); 3277var $repeat = __webpack_require__(2333); 3278var requireObjectCoercible = __webpack_require__(7750); 3279 3280var repeat = uncurryThis($repeat); 3281var stringSlice = uncurryThis(''.slice); 3282var ceil = Math.ceil; 3283 3284// `String.prototype.{ padStart, padEnd }` methods implementation 3285var createMethod = function (IS_END) { 3286 return function ($this, maxLength, fillString) { 3287 var S = toString(requireObjectCoercible($this)); 3288 var intMaxLength = toLength(maxLength); 3289 var stringLength = S.length; 3290 var fillStr = fillString === undefined ? ' ' : toString(fillString); 3291 var fillLen, stringFiller; 3292 if (intMaxLength <= stringLength || fillStr === '') return S; 3293 fillLen = intMaxLength - stringLength; 3294 stringFiller = repeat(fillStr, ceil(fillLen / fillStr.length)); 3295 if (stringFiller.length > fillLen) stringFiller = stringSlice(stringFiller, 0, fillLen); 3296 return IS_END ? S + stringFiller : stringFiller + S; 3297 }; 3298}; 3299 3300module.exports = { 3301 // `String.prototype.padStart` method 3302 // https://tc39.es/ecma262/#sec-string.prototype.padstart 3303 start: createMethod(false), 3304 // `String.prototype.padEnd` method 3305 // https://tc39.es/ecma262/#sec-string.prototype.padend 3306 end: createMethod(true) 3307}; 3308 3309 3310/***/ }, 3311 3312/***/ 2333 3313(module, __unused_webpack_exports, __webpack_require__) { 3314 3315 3316var toIntegerOrInfinity = __webpack_require__(1291); 3317var toString = __webpack_require__(655); 3318var requireObjectCoercible = __webpack_require__(7750); 3319 3320var $RangeError = RangeError; 3321 3322// `String.prototype.repeat` method implementation 3323// https://tc39.es/ecma262/#sec-string.prototype.repeat 3324module.exports = function repeat(count) { 3325 var str = toString(requireObjectCoercible(this)); 3326 var result = ''; 3327 var n = toIntegerOrInfinity(count); 3328 if (n < 0 || n === Infinity) throw new $RangeError('Wrong number of repetitions'); 3329 for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str; 3330 return result; 3331}; 3332 3333 3334/***/ }, 3335 3336/***/ 1548 3337(module, __unused_webpack_exports, __webpack_require__) { 3338 3339 3340var globalThis = __webpack_require__(4576); 3341var fails = __webpack_require__(9039); 3342var V8 = __webpack_require__(9519); 3343var ENVIRONMENT = __webpack_require__(4215); 3344 3345var structuredClone = globalThis.structuredClone; 3346 3347module.exports = !!structuredClone && !fails(function () { 3348 // prevent V8 ArrayBufferDetaching protector cell invalidation and performance degradation 3349 // https://github.com/zloirock/core-js/issues/679 3350 if ((ENVIRONMENT === 'DENO' && V8 > 92) || (ENVIRONMENT === 'NODE' && V8 > 94) || (ENVIRONMENT === 'BROWSER' && V8 > 97)) return false;
vendor: 7,359 bytes, lines 3351-3647
3351 var buffer = new ArrayBuffer(8); 3352 var clone = structuredClone(buffer, { transfer: [buffer] }); 3353 return buffer.byteLength !== 0 || clone.byteLength !== 8; 3354}); 3355 3356 3357/***/ }, 3358 3359/***/ 4495 3360(module, __unused_webpack_exports, __webpack_require__) { 3361 3362 3363/* eslint-disable es/no-symbol -- required for testing */ 3364var V8_VERSION = __webpack_require__(9519); 3365var fails = __webpack_require__(9039); 3366var globalThis = __webpack_require__(4576); 3367 3368var $String = globalThis.String; 3369 3370// eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing 3371module.exports = !!Object.getOwnPropertySymbols && !fails(function () { 3372 var symbol = Symbol('symbol detection'); 3373 // Chrome 38 Symbol has incorrect toString conversion 3374 // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances 3375 // nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will, 3376 // of course, fail. 3377 return !$String(symbol) || !(Object(symbol) instanceof Symbol) || 3378 // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances 3379 !Symbol.sham && V8_VERSION && V8_VERSION < 41; 3380}); 3381 3382 3383/***/ }, 3384 3385/***/ 5610 3386(module, __unused_webpack_exports, __webpack_require__) { 3387 3388 3389var toIntegerOrInfinity = __webpack_require__(1291); 3390 3391var max = Math.max; 3392var min = Math.min; 3393 3394// Helper for a popular repeating case of the spec: 3395// Let integer be ? ToInteger(index). 3396// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). 3397module.exports = function (index, length) { 3398 var integer = toIntegerOrInfinity(index); 3399 return integer < 0 ? max(integer + length, 0) : min(integer, length); 3400}; 3401 3402 3403/***/ }, 3404 3405/***/ 5854 3406(module, __unused_webpack_exports, __webpack_require__) { 3407 3408 3409var toPrimitive = __webpack_require__(2777); 3410 3411var $TypeError = TypeError; 3412 3413// `ToBigInt` abstract operation 3414// https://tc39.es/ecma262/#sec-tobigint 3415module.exports = function (argument) { 3416 var prim = toPrimitive(argument, 'number'); 3417 if (typeof prim == 'number') throw new $TypeError("Can't convert number to bigint"); 3418 // eslint-disable-next-line es/no-bigint -- safe 3419 return BigInt(prim); 3420}; 3421 3422 3423/***/ }, 3424 3425/***/ 7696 3426(module, __unused_webpack_exports, __webpack_require__) { 3427 3428 3429var toIntegerOrInfinity = __webpack_require__(1291); 3430var toLength = __webpack_require__(8014); 3431 3432var $RangeError = RangeError; 3433 3434// `ToIndex` abstract operation 3435// https://tc39.es/ecma262/#sec-toindex 3436module.exports = function (it) { 3437 if (it === undefined) return 0; 3438 var number = toIntegerOrInfinity(it); 3439 var length = toLength(number); 3440 if (number !== length) throw new $RangeError('Wrong length or index'); 3441 return length; 3442}; 3443 3444 3445/***/ }, 3446 3447/***/ 5397 3448(module, __unused_webpack_exports, __webpack_require__) { 3449 3450 3451// toObject with fallback for non-array-like ES3 strings 3452var IndexedObject = __webpack_require__(7055); 3453var requireObjectCoercible = __webpack_require__(7750); 3454 3455module.exports = function (it) { 3456 return IndexedObject(requireObjectCoercible(it)); 3457}; 3458 3459 3460/***/ }, 3461 3462/***/ 1291 3463(module, __unused_webpack_exports, __webpack_require__) { 3464 3465 3466var trunc = __webpack_require__(741); 3467 3468// `ToIntegerOrInfinity` abstract operation 3469// https://tc39.es/ecma262/#sec-tointegerorinfinity 3470module.exports = function (argument) { 3471 var number = +argument; 3472 // eslint-disable-next-line no-self-compare -- NaN check 3473 return number !== number || number === 0 ? 0 : trunc(number); 3474}; 3475 3476 3477/***/ }, 3478 3479/***/ 8014 3480(module, __unused_webpack_exports, __webpack_require__) { 3481 3482 3483var toIntegerOrInfinity = __webpack_require__(1291); 3484 3485var min = Math.min; 3486 3487// `ToLength` abstract operation 3488// https://tc39.es/ecma262/#sec-tolength 3489module.exports = function (argument) { 3490 var len = toIntegerOrInfinity(argument); 3491 return len > 0 ? min(len, 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 3492}; 3493 3494 3495/***/ }, 3496 3497/***/ 8981 3498(module, __unused_webpack_exports, __webpack_require__) { 3499 3500 3501var requireObjectCoercible = __webpack_require__(7750); 3502 3503var $Object = Object; 3504 3505// `ToObject` abstract operation 3506// https://tc39.es/ecma262/#sec-toobject 3507module.exports = function (argument) { 3508 return $Object(requireObjectCoercible(argument)); 3509}; 3510 3511 3512/***/ }, 3513 3514/***/ 2777 3515(module, __unused_webpack_exports, __webpack_require__) { 3516 3517 3518var call = __webpack_require__(9565); 3519var isObject = __webpack_require__(34); 3520var isSymbol = __webpack_require__(757); 3521var getMethod = __webpack_require__(5966); 3522var ordinaryToPrimitive = __webpack_require__(4270); 3523var wellKnownSymbol = __webpack_require__(8227); 3524 3525var $TypeError = TypeError; 3526var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); 3527 3528// `ToPrimitive` abstract operation 3529// https://tc39.es/ecma262/#sec-toprimitive 3530module.exports = function (input, pref) { 3531 if (!isObject(input) || isSymbol(input)) return input; 3532 var exoticToPrim = getMethod(input, TO_PRIMITIVE); 3533 var result; 3534 if (exoticToPrim) { 3535 if (pref === undefined) pref = 'default'; 3536 result = call(exoticToPrim, input, pref); 3537 if (!isObject(result) || isSymbol(result)) return result; 3538 throw new $TypeError("Can't convert object to primitive value"); 3539 } 3540 if (pref === undefined) pref = 'number'; 3541 return ordinaryToPrimitive(input, pref); 3542}; 3543 3544 3545/***/ }, 3546 3547/***/ 6969 3548(module, __unused_webpack_exports, __webpack_require__) { 3549 3550 3551var toPrimitive = __webpack_require__(2777); 3552var isSymbol = __webpack_require__(757); 3553 3554// `ToPropertyKey` abstract operation 3555// https://tc39.es/ecma262/#sec-topropertykey 3556module.exports = function (argument) { 3557 var key = toPrimitive(argument, 'string'); 3558 return isSymbol(key) ? key : key + ''; 3559}; 3560 3561 3562/***/ }, 3563 3564/***/ 2140 3565(module, __unused_webpack_exports, __webpack_require__) { 3566 3567 3568var wellKnownSymbol = __webpack_require__(8227); 3569 3570var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 3571var test = {}; 3572// eslint-disable-next-line unicorn/no-immediate-mutation -- ES3 syntax limitation 3573test[TO_STRING_TAG] = 'z'; 3574 3575module.exports = String(test) === '[object z]'; 3576 3577 3578/***/ }, 3579 3580/***/ 655 3581(module, __unused_webpack_exports, __webpack_require__) { 3582 3583 3584var classof = __webpack_require__(6955); 3585 3586var $String = String; 3587 3588module.exports = function (argument) { 3589 if (classof(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string'); 3590 return $String(argument); 3591}; 3592 3593 3594/***/ }, 3595 3596/***/ 6823 3597(module) { 3598 3599 3600var $String = String; 3601 3602module.exports = function (argument) { 3603 try { 3604 return $String(argument); 3605 } catch (error) { 3606 return 'Object'; 3607 } 3608}; 3609 3610 3611/***/ }, 3612 3613/***/ 3392 3614(module, __unused_webpack_exports, __webpack_require__) { 3615 3616 3617var uncurryThis = __webpack_require__(9504); 3618 3619var id = 0; 3620var postfix = Math.random(); 3621var toString = uncurryThis(1.1.toString); 3622 3623module.exports = function (key) { 3624 return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36); 3625}; 3626 3627 3628/***/ }, 3629 3630/***/ 7416 3631(module, __unused_webpack_exports, __webpack_require__) { 3632 3633 3634var fails = __webpack_require__(9039); 3635var wellKnownSymbol = __webpack_require__(8227); 3636var DESCRIPTORS = __webpack_require__(3724); 3637var IS_PURE = __webpack_require__(6395); 3638 3639var ITERATOR = wellKnownSymbol('iterator'); 3640 3641module.exports = !fails(function () { 3642 // eslint-disable-next-line unicorn/relative-url-style -- required for testing 3643 var url = new URL('b?a=1&b=2&c=3', 'https://a'); 3644 var params = url.searchParams; 3645 var params2 = new URLSearchParams('a=1&a=2&b=3'); 3646 var result = ''; 3647 url.pathname = 'c%20d';
vendor: 4,710 bytes, lines 3648-3829
3648 params.forEach(function (value, key) { 3649 params['delete']('b'); 3650 result += key + value; 3651 }); 3652 params2['delete']('a', 2); 3653 // `undefined` case is a Chromium 117 bug 3654 // https://bugs.chromium.org/p/v8/issues/detail?id=14222 3655 params2['delete']('b', undefined); 3656 return (IS_PURE && (!url.toJSON || !params2.has('a', 1) || params2.has('a', 2) || !params2.has('a', undefined) || params2.has('b'))) 3657 || (!params.size && (IS_PURE || !DESCRIPTORS)) 3658 || !params.sort 3659 || url.href !== 'https://a/c%20d?a=1&c=3' 3660 || params.get('c') !== '3' 3661 || String(new URLSearchParams('?a=1')) !== 'a=1' 3662 || !params[ITERATOR] 3663 // throws in Edge 3664 || new URL('https://a@b').username !== 'a' 3665 || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b' 3666 // not punycoded in Edge 3667 || new URL('https://ÑеÑÑ').host !== 'xn--e1aybc' 3668 // not escaped in Chrome 62- 3669 || new URL('https://a#б').hash !== '#%D0%B1' 3670 // fails in Chrome 66- 3671 || result !== 'a1c3' 3672 // throws in Safari 3673 || new URL('https://x', undefined).host !== 'x'; 3674}); 3675 3676 3677/***/ }, 3678 3679/***/ 7040 3680(module, __unused_webpack_exports, __webpack_require__) { 3681 3682 3683/* eslint-disable es/no-symbol -- required for testing */ 3684var NATIVE_SYMBOL = __webpack_require__(4495); 3685 3686module.exports = NATIVE_SYMBOL && 3687 !Symbol.sham && 3688 typeof Symbol.iterator == 'symbol'; 3689 3690 3691/***/ }, 3692 3693/***/ 8686 3694(module, __unused_webpack_exports, __webpack_require__) { 3695 3696 3697var DESCRIPTORS = __webpack_require__(3724); 3698var fails = __webpack_require__(9039); 3699 3700// V8 ~ Chrome 36- 3701// https://bugs.chromium.org/p/v8/issues/detail?id=3334 3702module.exports = DESCRIPTORS && fails(function () { 3703 // eslint-disable-next-line es/no-object-defineproperty -- required for testing 3704 return Object.defineProperty(function () { /* empty */ }, 'prototype', { 3705 value: 42, 3706 writable: false 3707 }).prototype !== 42; 3708}); 3709 3710 3711/***/ }, 3712 3713/***/ 2812 3714(module) { 3715 3716 3717var $TypeError = TypeError; 3718 3719module.exports = function (passed, required) { 3720 if (passed < required) throw new $TypeError('Not enough arguments'); 3721 return passed; 3722}; 3723 3724 3725/***/ }, 3726 3727/***/ 8622 3728(module, __unused_webpack_exports, __webpack_require__) { 3729 3730 3731var globalThis = __webpack_require__(4576); 3732var isCallable = __webpack_require__(4901); 3733 3734var WeakMap = globalThis.WeakMap; 3735 3736module.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap)); 3737 3738 3739/***/ }, 3740 3741/***/ 4995 3742(module, __unused_webpack_exports, __webpack_require__) { 3743 3744 3745var uncurryThis = __webpack_require__(9504); 3746 3747// eslint-disable-next-line es/no-weak-map -- safe 3748var WeakMapPrototype = WeakMap.prototype; 3749 3750module.exports = { 3751 // eslint-disable-next-line es/no-weak-map -- safe 3752 WeakMap: WeakMap, 3753 set: uncurryThis(WeakMapPrototype.set), 3754 get: uncurryThis(WeakMapPrototype.get), 3755 has: uncurryThis(WeakMapPrototype.has), 3756 remove: uncurryThis(WeakMapPrototype['delete']) 3757}; 3758 3759 3760/***/ }, 3761 3762/***/ 8227 3763(module, __unused_webpack_exports, __webpack_require__) { 3764 3765 3766var globalThis = __webpack_require__(4576); 3767var shared = __webpack_require__(5745); 3768var hasOwn = __webpack_require__(9297); 3769var uid = __webpack_require__(3392); 3770var NATIVE_SYMBOL = __webpack_require__(4495); 3771var USE_SYMBOL_AS_UID = __webpack_require__(7040); 3772 3773var Symbol = globalThis.Symbol; 3774var WellKnownSymbolsStore = shared('wks'); 3775var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol['for'] || Symbol : Symbol && Symbol.withoutSetter || uid; 3776 3777module.exports = function (name) { 3778 if (!hasOwn(WellKnownSymbolsStore, name)) { 3779 WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn(Symbol, name) 3780 ? Symbol[name] 3781 : createWellKnownSymbol('Symbol.' + name); 3782 } return WellKnownSymbolsStore[name]; 3783}; 3784 3785 3786/***/ }, 3787 3788/***/ 7452 3789(module) { 3790 3791 3792// a string of all valid unicode whitespaces 3793module.exports = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' + 3794 '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; 3795 3796 3797/***/ }, 3798 3799/***/ 6573 3800(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 3801 3802 3803var DESCRIPTORS = __webpack_require__(3724); 3804var defineBuiltInAccessor = __webpack_require__(2106); 3805var isDetached = __webpack_require__(3238); 3806 3807var ArrayBufferPrototype = ArrayBuffer.prototype; 3808 3809// `ArrayBuffer.prototype.detached` getter 3810// https://tc39.es/ecma262/#sec-get-arraybuffer.prototype.detached 3811if (DESCRIPTORS && !('detached' in ArrayBufferPrototype)) { 3812 defineBuiltInAccessor(ArrayBufferPrototype, 'detached', { 3813 configurable: true, 3814 get: function detached() { 3815 return isDetached(this); 3816 } 3817 }); 3818} 3819 3820 3821/***/ }, 3822 3823/***/ 7936 3824(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 3825 3826 3827var $ = __webpack_require__(6518); 3828var $transfer = __webpack_require__(5636); 3829
vendor: 5,834 bytes, lines 3830-4009
3830// `ArrayBuffer.prototype.transferToFixedLength` method 3831// https://tc39.es/ecma262/#sec-arraybuffer.prototype.transfertofixedlength 3832if ($transfer) $({ target: 'ArrayBuffer', proto: true }, { 3833 transferToFixedLength: function transferToFixedLength() { 3834 return $transfer(this, arguments.length ? arguments[0] : undefined, false); 3835 } 3836}); 3837 3838 3839/***/ }, 3840 3841/***/ 8100 3842(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 3843 3844 3845var $ = __webpack_require__(6518); 3846var $transfer = __webpack_require__(5636); 3847 3848// `ArrayBuffer.prototype.transfer` method 3849// https://tc39.es/ecma262/#sec-arraybuffer.prototype.transfer 3850if ($transfer) $({ target: 'ArrayBuffer', proto: true }, { 3851 transfer: function transfer() { 3852 return $transfer(this, arguments.length ? arguments[0] : undefined, true); 3853 } 3854}); 3855 3856 3857/***/ }, 3858 3859/***/ 4114 3860(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 3861 3862 3863var $ = __webpack_require__(6518); 3864var toObject = __webpack_require__(8981); 3865var lengthOfArrayLike = __webpack_require__(6198); 3866var setArrayLength = __webpack_require__(4527); 3867var doesNotExceedSafeInteger = __webpack_require__(6837); 3868var fails = __webpack_require__(9039); 3869 3870var INCORRECT_TO_LENGTH = fails(function () { 3871 return [].push.call({ length: 0x100000000 }, 1) !== 4294967297; 3872}); 3873 3874// V8 <= 121 and Safari <= 15.4; FF < 23 throws InternalError 3875// https://bugs.chromium.org/p/v8/issues/detail?id=12681 3876var properErrorOnNonWritableLength = function () { 3877 try { 3878 // eslint-disable-next-line es/no-object-defineproperty -- safe 3879 Object.defineProperty([], 'length', { writable: false }).push(); 3880 } catch (error) { 3881 return error instanceof TypeError; 3882 } 3883}; 3884 3885var FORCED = INCORRECT_TO_LENGTH || !properErrorOnNonWritableLength(); 3886 3887// `Array.prototype.push` method 3888// https://tc39.es/ecma262/#sec-array.prototype.push 3889$({ target: 'Array', proto: true, arity: 1, forced: FORCED }, { 3890 // eslint-disable-next-line no-unused-vars -- required for `.length` 3891 push: function push(item) { 3892 var O = toObject(this); 3893 var len = lengthOfArrayLike(O); 3894 var argCount = arguments.length; 3895 doesNotExceedSafeInteger(len + argCount); 3896 for (var i = 0; i < argCount; i++) { 3897 O[len] = arguments[i]; 3898 len++; 3899 } 3900 setArrayLength(O, len); 3901 return len; 3902 } 3903}); 3904 3905 3906/***/ }, 3907 3908/***/ 8111 3909(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 3910 3911 3912var $ = __webpack_require__(6518); 3913var globalThis = __webpack_require__(4576); 3914var anInstance = __webpack_require__(679); 3915var anObject = __webpack_require__(8551); 3916var isCallable = __webpack_require__(4901); 3917var getPrototypeOf = __webpack_require__(2787); 3918var defineBuiltInAccessor = __webpack_require__(2106); 3919var createProperty = __webpack_require__(4659); 3920var fails = __webpack_require__(9039); 3921var hasOwn = __webpack_require__(9297); 3922var wellKnownSymbol = __webpack_require__(8227); 3923var IteratorPrototype = (__webpack_require__(7657).IteratorPrototype); 3924var DESCRIPTORS = __webpack_require__(3724); 3925var IS_PURE = __webpack_require__(6395); 3926 3927var CONSTRUCTOR = 'constructor'; 3928var ITERATOR = 'Iterator'; 3929var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 3930 3931var $TypeError = TypeError; 3932var NativeIterator = globalThis[ITERATOR]; 3933 3934// FF56- have non-standard global helper `Iterator` 3935var FORCED = IS_PURE 3936 || !isCallable(NativeIterator) 3937 || NativeIterator.prototype !== IteratorPrototype 3938 // FF44- non-standard `Iterator` passes previous tests 3939 || !fails(function () { NativeIterator({}); }); 3940 3941var IteratorConstructor = function Iterator() { 3942 anInstance(this, IteratorPrototype); 3943 if (getPrototypeOf(this) === IteratorPrototype) throw new $TypeError('Abstract class Iterator not directly constructable'); 3944}; 3945 3946var defineIteratorPrototypeAccessor = function (key, value) { 3947 if (DESCRIPTORS) { 3948 defineBuiltInAccessor(IteratorPrototype, key, { 3949 configurable: true, 3950 get: function () { 3951 return value; 3952 }, 3953 set: function (replacement) { 3954 anObject(this); 3955 if (this === IteratorPrototype) throw new $TypeError("You can't redefine this property"); 3956 if (hasOwn(this, key)) this[key] = replacement; 3957 else createProperty(this, key, replacement); 3958 } 3959 }); 3960 } else IteratorPrototype[key] = value; 3961}; 3962 3963if (!hasOwn(IteratorPrototype, TO_STRING_TAG)) defineIteratorPrototypeAccessor(TO_STRING_TAG, ITERATOR); 3964 3965if (FORCED || !hasOwn(IteratorPrototype, CONSTRUCTOR) || IteratorPrototype[CONSTRUCTOR] === Object) { 3966 defineIteratorPrototypeAccessor(CONSTRUCTOR, IteratorConstructor); 3967} 3968 3969IteratorConstructor.prototype = IteratorPrototype; 3970 3971// `Iterator` constructor 3972// https://tc39.es/ecma262/#sec-iterator 3973$({ global: true, constructor: true, forced: FORCED }, { 3974 Iterator: IteratorConstructor 3975}); 3976 3977 3978/***/ }, 3979 3980/***/ 1148 3981(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 3982 3983 3984var $ = __webpack_require__(6518); 3985var call = __webpack_require__(9565); 3986var iterate = __webpack_require__(2652); 3987var aCallable = __webpack_require__(9306); 3988var anObject = __webpack_require__(8551); 3989var getIteratorDirect = __webpack_require__(1767); 3990var iteratorClose = __webpack_require__(9539); 3991var iteratorHelperWithoutClosingOnEarlyError = __webpack_require__(4549); 3992 3993var everyWithoutClosingOnEarlyError = iteratorHelperWithoutClosingOnEarlyError('every', TypeError); 3994 3995// `Iterator.prototype.every` method 3996// https://tc39.es/ecma262/#sec-iterator.prototype.every 3997$({ target: 'Iterator', proto: true, real: true, forced: everyWithoutClosingOnEarlyError }, { 3998 every: function every(predicate) { 3999 anObject(this); 4000 try { 4001 aCallable(predicate); 4002 } catch (error) { 4003 iteratorClose(this, 'throw', error); 4004 } 4005 4006 if (everyWithoutClosingOnEarlyError) return call(everyWithoutClosingOnEarlyError, this, predicate); 4007 4008 var record = getIteratorDirect(this); 4009 var counter = 0;
vendor: 9,376 bytes, lines 4010-4290
4010 return !iterate(record, function (value, stop) { 4011 if (!predicate(value, counter++)) return stop(); 4012 }, { IS_RECORD: true, INTERRUPTED: true }).stopped; 4013 } 4014}); 4015 4016 4017/***/ }, 4018 4019/***/ 2489 4020(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4021 4022 4023var $ = __webpack_require__(6518); 4024var call = __webpack_require__(9565); 4025var aCallable = __webpack_require__(9306); 4026var anObject = __webpack_require__(8551); 4027var getIteratorDirect = __webpack_require__(1767); 4028var createIteratorProxy = __webpack_require__(9462); 4029var callWithSafeIterationClosing = __webpack_require__(6319); 4030var IS_PURE = __webpack_require__(6395); 4031var iteratorClose = __webpack_require__(9539); 4032var iteratorHelperThrowsOnInvalidIterator = __webpack_require__(684); 4033var iteratorHelperWithoutClosingOnEarlyError = __webpack_require__(4549); 4034 4035var FILTER_WITHOUT_THROWING_ON_INVALID_ITERATOR = !IS_PURE && !iteratorHelperThrowsOnInvalidIterator('filter', function () { /* empty */ }); 4036var filterWithoutClosingOnEarlyError = !IS_PURE && !FILTER_WITHOUT_THROWING_ON_INVALID_ITERATOR 4037 && iteratorHelperWithoutClosingOnEarlyError('filter', TypeError); 4038 4039var FORCED = IS_PURE || FILTER_WITHOUT_THROWING_ON_INVALID_ITERATOR || filterWithoutClosingOnEarlyError; 4040 4041var IteratorProxy = createIteratorProxy(function () { 4042 var iterator = this.iterator; 4043 var predicate = this.predicate; 4044 var next = this.next; 4045 var result, done, value; 4046 while (true) { 4047 result = anObject(call(next, iterator)); 4048 done = this.done = !!result.done; 4049 if (done) return; 4050 value = result.value; 4051 if (callWithSafeIterationClosing(iterator, predicate, [value, this.counter++], true)) return value; 4052 } 4053}); 4054 4055// `Iterator.prototype.filter` method 4056// https://tc39.es/ecma262/#sec-iterator.prototype.filter 4057$({ target: 'Iterator', proto: true, real: true, forced: FORCED }, { 4058 filter: function filter(predicate) { 4059 anObject(this); 4060 try { 4061 aCallable(predicate); 4062 } catch (error) { 4063 iteratorClose(this, 'throw', error); 4064 } 4065 4066 if (filterWithoutClosingOnEarlyError) return call(filterWithoutClosingOnEarlyError, this, predicate); 4067 4068 return new IteratorProxy(getIteratorDirect(this), { 4069 predicate: predicate 4070 }); 4071 } 4072}); 4073 4074 4075/***/ }, 4076 4077/***/ 116 4078(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4079 4080 4081var $ = __webpack_require__(6518); 4082var call = __webpack_require__(9565); 4083var iterate = __webpack_require__(2652); 4084var aCallable = __webpack_require__(9306); 4085var anObject = __webpack_require__(8551); 4086var getIteratorDirect = __webpack_require__(1767); 4087var iteratorClose = __webpack_require__(9539); 4088var iteratorHelperWithoutClosingOnEarlyError = __webpack_require__(4549); 4089 4090var findWithoutClosingOnEarlyError = iteratorHelperWithoutClosingOnEarlyError('find', TypeError); 4091 4092// `Iterator.prototype.find` method 4093// https://tc39.es/ecma262/#sec-iterator.prototype.find 4094$({ target: 'Iterator', proto: true, real: true, forced: findWithoutClosingOnEarlyError }, { 4095 find: function find(predicate) { 4096 anObject(this); 4097 try { 4098 aCallable(predicate); 4099 } catch (error) { 4100 iteratorClose(this, 'throw', error); 4101 } 4102 4103 if (findWithoutClosingOnEarlyError) return call(findWithoutClosingOnEarlyError, this, predicate); 4104 4105 var record = getIteratorDirect(this); 4106 var counter = 0; 4107 return iterate(record, function (value, stop) { 4108 if (predicate(value, counter++)) return stop(value); 4109 }, { IS_RECORD: true, INTERRUPTED: true }).result; 4110 } 4111}); 4112 4113 4114/***/ }, 4115 4116/***/ 7588 4117(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4118 4119 4120var $ = __webpack_require__(6518); 4121var call = __webpack_require__(9565); 4122var iterate = __webpack_require__(2652); 4123var aCallable = __webpack_require__(9306); 4124var anObject = __webpack_require__(8551); 4125var getIteratorDirect = __webpack_require__(1767); 4126var iteratorClose = __webpack_require__(9539); 4127var iteratorHelperWithoutClosingOnEarlyError = __webpack_require__(4549); 4128 4129var forEachWithoutClosingOnEarlyError = iteratorHelperWithoutClosingOnEarlyError('forEach', TypeError); 4130 4131// `Iterator.prototype.forEach` method 4132// https://tc39.es/ecma262/#sec-iterator.prototype.foreach 4133$({ target: 'Iterator', proto: true, real: true, forced: forEachWithoutClosingOnEarlyError }, { 4134 forEach: function forEach(fn) { 4135 anObject(this); 4136 try { 4137 aCallable(fn); 4138 } catch (error) { 4139 iteratorClose(this, 'throw', error); 4140 } 4141 4142 if (forEachWithoutClosingOnEarlyError) return call(forEachWithoutClosingOnEarlyError, this, fn); 4143 4144 var record = getIteratorDirect(this); 4145 var counter = 0; 4146 iterate(record, function (value) { 4147 fn(value, counter++); 4148 }, { IS_RECORD: true }); 4149 } 4150}); 4151 4152 4153/***/ }, 4154 4155/***/ 1701 4156(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4157 4158 4159var $ = __webpack_require__(6518); 4160var call = __webpack_require__(9565); 4161var aCallable = __webpack_require__(9306); 4162var anObject = __webpack_require__(8551); 4163var getIteratorDirect = __webpack_require__(1767); 4164var createIteratorProxy = __webpack_require__(9462); 4165var callWithSafeIterationClosing = __webpack_require__(6319); 4166var iteratorClose = __webpack_require__(9539); 4167var iteratorHelperThrowsOnInvalidIterator = __webpack_require__(684); 4168var iteratorHelperWithoutClosingOnEarlyError = __webpack_require__(4549); 4169var IS_PURE = __webpack_require__(6395); 4170 4171var MAP_WITHOUT_THROWING_ON_INVALID_ITERATOR = !IS_PURE && !iteratorHelperThrowsOnInvalidIterator('map', function () { /* empty */ }); 4172var mapWithoutClosingOnEarlyError = !IS_PURE && !MAP_WITHOUT_THROWING_ON_INVALID_ITERATOR 4173 && iteratorHelperWithoutClosingOnEarlyError('map', TypeError); 4174 4175var FORCED = IS_PURE || MAP_WITHOUT_THROWING_ON_INVALID_ITERATOR || mapWithoutClosingOnEarlyError; 4176 4177var IteratorProxy = createIteratorProxy(function () { 4178 var iterator = this.iterator; 4179 var result = anObject(call(this.next, iterator)); 4180 var done = this.done = !!result.done; 4181 if (!done) return callWithSafeIterationClosing(iterator, this.mapper, [result.value, this.counter++], true); 4182}); 4183 4184// `Iterator.prototype.map` method 4185// https://tc39.es/ecma262/#sec-iterator.prototype.map 4186$({ target: 'Iterator', proto: true, real: true, forced: FORCED }, { 4187 map: function map(mapper) { 4188 anObject(this); 4189 try { 4190 aCallable(mapper); 4191 } catch (error) { 4192 iteratorClose(this, 'throw', error); 4193 } 4194 4195 if (mapWithoutClosingOnEarlyError) return call(mapWithoutClosingOnEarlyError, this, mapper); 4196 4197 return new IteratorProxy(getIteratorDirect(this), { 4198 mapper: mapper 4199 }); 4200 } 4201}); 4202 4203 4204/***/ }, 4205 4206/***/ 3579 4207(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4208 4209 4210var $ = __webpack_require__(6518); 4211var call = __webpack_require__(9565); 4212var iterate = __webpack_require__(2652); 4213var aCallable = __webpack_require__(9306); 4214var anObject = __webpack_require__(8551); 4215var getIteratorDirect = __webpack_require__(1767); 4216var iteratorClose = __webpack_require__(9539); 4217var iteratorHelperWithoutClosingOnEarlyError = __webpack_require__(4549); 4218 4219var someWithoutClosingOnEarlyError = iteratorHelperWithoutClosingOnEarlyError('some', TypeError); 4220 4221// `Iterator.prototype.some` method 4222// https://tc39.es/ecma262/#sec-iterator.prototype.some 4223$({ target: 'Iterator', proto: true, real: true, forced: someWithoutClosingOnEarlyError }, { 4224 some: function some(predicate) { 4225 anObject(this); 4226 try { 4227 aCallable(predicate); 4228 } catch (error) { 4229 iteratorClose(this, 'throw', error); 4230 } 4231 4232 if (someWithoutClosingOnEarlyError) return call(someWithoutClosingOnEarlyError, this, predicate); 4233 4234 var record = getIteratorDirect(this); 4235 var counter = 0; 4236 return iterate(record, function (value, stop) { 4237 if (predicate(value, counter++)) return stop(); 4238 }, { IS_RECORD: true, INTERRUPTED: true }).stopped; 4239 } 4240}); 4241 4242 4243/***/ }, 4244 4245/***/ 9112 4246(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4247 4248 4249var $ = __webpack_require__(6518); 4250var DESCRIPTORS = __webpack_require__(3724); 4251var globalThis = __webpack_require__(4576); 4252var getBuiltIn = __webpack_require__(7751); 4253var uncurryThis = __webpack_require__(9504); 4254var call = __webpack_require__(9565); 4255var isCallable = __webpack_require__(4901); 4256var isObject = __webpack_require__(34); 4257var isArray = __webpack_require__(4376); 4258var hasOwn = __webpack_require__(9297); 4259var toString = __webpack_require__(655); 4260var lengthOfArrayLike = __webpack_require__(6198); 4261var createProperty = __webpack_require__(4659); 4262var fails = __webpack_require__(9039); 4263var parseJSONString = __webpack_require__(8235); 4264var NATIVE_SYMBOL = __webpack_require__(4495); 4265 4266var JSON = globalThis.JSON; 4267var Number = globalThis.Number; 4268var SyntaxError = globalThis.SyntaxError; 4269var nativeParse = JSON && JSON.parse; 4270var enumerableOwnProperties = getBuiltIn('Object', 'keys'); 4271// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 4272var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 4273var at = uncurryThis(''.charAt); 4274var slice = uncurryThis(''.slice); 4275var exec = uncurryThis(/./.exec); 4276var push = uncurryThis([].push); 4277 4278var IS_DIGIT = /^\d$/; 4279var IS_NON_ZERO_DIGIT = /^[1-9]$/; 4280var IS_NUMBER_START = /^[\d-]$/; 4281var IS_WHITESPACE = /^[\t\n\r ]$/; 4282 4283var PRIMITIVE = 0; 4284var OBJECT = 1; 4285 4286var $parse = function (source, reviver) { 4287 source = toString(source); 4288 var context = new Context(source, 0, ''); 4289 var root = context.parse(); 4290 var value = root.value;
vendor: 7,710 bytes, lines 4291-4528
4291 var endIndex = context.skip(IS_WHITESPACE, root.end); 4292 if (endIndex < source.length) { 4293 throw new SyntaxError('Unexpected extra character: "' + at(source, endIndex) + '" after the parsed data at: ' + endIndex); 4294 } 4295 return isCallable(reviver) ? internalize({ '': value }, '', reviver, root) : value; 4296}; 4297 4298var internalize = function (holder, name, reviver, node) { 4299 var val = holder[name]; 4300 var unmodified = node && val === node.value; 4301 var context = unmodified && typeof node.source == 'string' ? { source: node.source } : {}; 4302 var elementRecordsLen, keys, len, i, P; 4303 if (isObject(val)) { 4304 var nodeIsArray = isArray(val); 4305 var nodes = unmodified ? node.nodes : nodeIsArray ? [] : {}; 4306 if (nodeIsArray) { 4307 elementRecordsLen = nodes.length; 4308 len = lengthOfArrayLike(val); 4309 for (i = 0; i < len; i++) { 4310 internalizeProperty(val, i, internalize(val, '' + i, reviver, i < elementRecordsLen ? nodes[i] : undefined)); 4311 } 4312 } else { 4313 keys = enumerableOwnProperties(val); 4314 len = lengthOfArrayLike(keys); 4315 for (i = 0; i < len; i++) { 4316 P = keys[i]; 4317 internalizeProperty(val, P, internalize(val, P, reviver, hasOwn(nodes, P) ? nodes[P] : undefined)); 4318 } 4319 } 4320 } 4321 return call(reviver, holder, name, val, context); 4322}; 4323 4324var internalizeProperty = function (object, key, value) { 4325 if (DESCRIPTORS) { 4326 var descriptor = getOwnPropertyDescriptor(object, key); 4327 if (descriptor && !descriptor.configurable) return; 4328 } 4329 if (value === undefined) delete object[key]; 4330 else createProperty(object, key, value); 4331}; 4332 4333var Node = function (value, end, source, nodes) { 4334 this.value = value; 4335 this.end = end; 4336 this.source = source; 4337 this.nodes = nodes; 4338}; 4339 4340var Context = function (source, index) { 4341 this.source = source; 4342 this.index = index; 4343}; 4344 4345// https://www.json.org/json-en.html 4346Context.prototype = { 4347 fork: function (nextIndex) { 4348 return new Context(this.source, nextIndex); 4349 }, 4350 parse: function () { 4351 var source = this.source; 4352 var i = this.skip(IS_WHITESPACE, this.index); 4353 var fork = this.fork(i); 4354 var chr = at(source, i); 4355 if (exec(IS_NUMBER_START, chr)) return fork.number(); 4356 switch (chr) { 4357 case '{': 4358 return fork.object(); 4359 case '[': 4360 return fork.array(); 4361 case '"': 4362 return fork.string(); 4363 case 't': 4364 return fork.keyword(true); 4365 case 'f': 4366 return fork.keyword(false); 4367 case 'n': 4368 return fork.keyword(null); 4369 } throw new SyntaxError('Unexpected character: "' + chr + '" at: ' + i); 4370 }, 4371 node: function (type, value, start, end, nodes) { 4372 return new Node(value, end, type ? null : slice(this.source, start, end), nodes); 4373 }, 4374 object: function () { 4375 var source = this.source; 4376 var i = this.index + 1; 4377 var expectKeypair = false; 4378 var object = {}; 4379 var nodes = {}; 4380 while (i < source.length) { 4381 i = this.until(['"', '}'], i); 4382 if (at(source, i) === '}' && !expectKeypair) { 4383 i++; 4384 break; 4385 } 4386 // Parsing the key 4387 var result = this.fork(i).string(); 4388 var key = result.value; 4389 i = result.end; 4390 i = this.until([':'], i) + 1; 4391 // Parsing value 4392 i = this.skip(IS_WHITESPACE, i); 4393 result = this.fork(i).parse(); 4394 createProperty(nodes, key, result); 4395 createProperty(object, key, result.value); 4396 i = this.until([',', '}'], result.end); 4397 var chr = at(source, i); 4398 if (chr === ',') { 4399 expectKeypair = true; 4400 i++; 4401 } else if (chr === '}') { 4402 i++; 4403 break; 4404 } 4405 } 4406 return this.node(OBJECT, object, this.index, i, nodes); 4407 }, 4408 array: function () { 4409 var source = this.source; 4410 var i = this.index + 1; 4411 var expectElement = false; 4412 var array = []; 4413 var nodes = []; 4414 while (i < source.length) { 4415 i = this.skip(IS_WHITESPACE, i); 4416 if (at(source, i) === ']' && !expectElement) { 4417 i++; 4418 break; 4419 } 4420 var result = this.fork(i).parse(); 4421 push(nodes, result); 4422 push(array, result.value); 4423 i = this.until([',', ']'], result.end); 4424 if (at(source, i) === ',') { 4425 expectElement = true; 4426 i++; 4427 } else if (at(source, i) === ']') { 4428 i++; 4429 break; 4430 } 4431 } 4432 return this.node(OBJECT, array, this.index, i, nodes); 4433 }, 4434 string: function () { 4435 var index = this.index; 4436 var parsed = parseJSONString(this.source, this.index + 1); 4437 return this.node(PRIMITIVE, parsed.value, index, parsed.end); 4438 }, 4439 number: function () { 4440 var source = this.source; 4441 var startIndex = this.index; 4442 var i = startIndex; 4443 if (at(source, i) === '-') i++; 4444 if (at(source, i) === '0') i++; 4445 else if (exec(IS_NON_ZERO_DIGIT, at(source, i))) i = this.skip(IS_DIGIT, i + 1); 4446 else throw new SyntaxError('Failed to parse number at: ' + i); 4447 if (at(source, i) === '.') i = this.skip(IS_DIGIT, i + 1); 4448 if (at(source, i) === 'e' || at(source, i) === 'E') { 4449 i++; 4450 if (at(source, i) === '+' || at(source, i) === '-') i++; 4451 var exponentStartIndex = i; 4452 i = this.skip(IS_DIGIT, i); 4453 if (exponentStartIndex === i) throw new SyntaxError("Failed to parse number's exponent value at: " + i); 4454 } 4455 return this.node(PRIMITIVE, Number(slice(source, startIndex, i)), startIndex, i); 4456 }, 4457 keyword: function (value) { 4458 var keyword = '' + value; 4459 var index = this.index; 4460 var endIndex = index + keyword.length; 4461 if (slice(this.source, index, endIndex) !== keyword) throw new SyntaxError('Failed to parse value at: ' + index); 4462 return this.node(PRIMITIVE, value, index, endIndex); 4463 }, 4464 skip: function (regex, i) { 4465 var source = this.source; 4466 for (; i < source.length; i++) if (!exec(regex, at(source, i))) break; 4467 return i; 4468 }, 4469 until: function (array, i) { 4470 i = this.skip(IS_WHITESPACE, i); 4471 var chr = at(this.source, i); 4472 for (var j = 0; j < array.length; j++) if (array[j] === chr) return i; 4473 throw new SyntaxError('Unexpected character: "' + chr + '" at: ' + i); 4474 } 4475}; 4476 4477var NO_SOURCE_SUPPORT = fails(function () { 4478 var unsafeInt = '9007199254740993'; 4479 var source; 4480 nativeParse(unsafeInt, function (key, value, context) { 4481 source = context.source; 4482 }); 4483 return source !== unsafeInt; 4484}); 4485 4486var PROPER_BASE_PARSE = NATIVE_SYMBOL && !fails(function () { 4487 // Safari 9 bug 4488 return 1 / nativeParse('-0 \t') !== -Infinity; 4489}); 4490 4491// `JSON.parse` method 4492// https://tc39.es/ecma262/#sec-json.parse 4493// https://github.com/tc39/proposal-json-parse-with-source 4494$({ target: 'JSON', stat: true, forced: NO_SOURCE_SUPPORT }, { 4495 parse: function parse(text, reviver) { 4496 return PROPER_BASE_PARSE && !isCallable(reviver) ? nativeParse(text) : $parse(text, reviver); 4497 } 4498}); 4499 4500 4501/***/ }, 4502 4503/***/ 3110 4504(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4505 4506 4507var $ = __webpack_require__(6518); 4508var getBuiltIn = __webpack_require__(7751); 4509var apply = __webpack_require__(8745); 4510var call = __webpack_require__(9565); 4511var uncurryThis = __webpack_require__(9504); 4512var fails = __webpack_require__(9039); 4513var isArray = __webpack_require__(4376); 4514var isCallable = __webpack_require__(4901); 4515var isRawJSON = __webpack_require__(5810); 4516var isSymbol = __webpack_require__(757); 4517var classof = __webpack_require__(2195); 4518var toString = __webpack_require__(655); 4519var arraySlice = __webpack_require__(7680); 4520var parseJSONString = __webpack_require__(8235); 4521var uid = __webpack_require__(3392); 4522var NATIVE_SYMBOL = __webpack_require__(4495); 4523var NATIVE_RAW_JSON = __webpack_require__(7819); 4524 4525var $String = String; 4526var $stringify = getBuiltIn('JSON', 'stringify'); 4527var exec = uncurryThis(/./.exec); 4528var charAt = uncurryThis(''.charAt);
vendor: 5,886 bytes, lines 4529-4709
4529var charCodeAt = uncurryThis(''.charCodeAt); 4530var replace = uncurryThis(''.replace); 4531var slice = uncurryThis(''.slice); 4532var push = uncurryThis([].push); 4533var numberToString = uncurryThis(1.1.toString); 4534 4535var surrogates = /[\uD800-\uDFFF]/g; 4536var lowSurrogates = /^[\uD800-\uDBFF]$/; 4537var hiSurrogates = /^[\uDC00-\uDFFF]$/; 4538 4539var MARK = uid(); 4540var MARK_LENGTH = MARK.length; 4541 4542var WRONG_SYMBOLS_CONVERSION = !NATIVE_SYMBOL || fails(function () { 4543 var symbol = getBuiltIn('Symbol')('stringify detection'); 4544 // MS Edge converts symbol values to JSON as {} 4545 return $stringify([symbol]) !== '[null]' 4546 // WebKit converts symbol values to JSON as null 4547 || $stringify({ a: symbol }) !== '{}' 4548 // V8 throws on boxed symbols 4549 || $stringify(Object(symbol)) !== '{}'; 4550}); 4551 4552// https://github.com/tc39/proposal-well-formed-stringify 4553var ILL_FORMED_UNICODE = fails(function () { 4554 return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"' 4555 || $stringify('\uDEAD') !== '"\\udead"'; 4556}); 4557 4558var stringifyWithProperSymbolsConversion = WRONG_SYMBOLS_CONVERSION ? function (it, replacer) { 4559 var args = arraySlice(arguments); 4560 var $replacer = getReplacerFunction(replacer); 4561 if (!isCallable($replacer) && (it === undefined || isSymbol(it))) return; // IE8 returns string on undefined 4562 args[1] = function (key, value) { 4563 // some old implementations (like WebKit) could pass numbers as keys 4564 if (isCallable($replacer)) value = call($replacer, this, $String(key), value); 4565 if (!isSymbol(value)) return value; 4566 }; 4567 return apply($stringify, null, args); 4568} : $stringify; 4569 4570var fixIllFormedJSON = function (match, offset, string) { 4571 var prev = charAt(string, offset - 1); 4572 var next = charAt(string, offset + 1); 4573 if ((exec(lowSurrogates, match) && !exec(hiSurrogates, next)) || (exec(hiSurrogates, match) && !exec(lowSurrogates, prev))) { 4574 return '\\u' + numberToString(charCodeAt(match, 0), 16); 4575 } return match; 4576}; 4577 4578var getReplacerFunction = function (replacer) { 4579 if (isCallable(replacer)) return replacer; 4580 if (!isArray(replacer)) return; 4581 var rawLength = replacer.length; 4582 var keys = []; 4583 for (var i = 0; i < rawLength; i++) { 4584 var element = replacer[i]; 4585 if (typeof element == 'string') push(keys, element); 4586 else if (typeof element == 'number' || classof(element) === 'Number' || classof(element) === 'String') push(keys, toString(element)); 4587 } 4588 var keysLength = keys.length; 4589 var root = true; 4590 return function (key, value) { 4591 if (root) { 4592 root = false; 4593 return value; 4594 } 4595 if (isArray(this)) return value; 4596 for (var j = 0; j < keysLength; j++) if (keys[j] === key) return value; 4597 }; 4598}; 4599 4600// `JSON.stringify` method 4601// https://tc39.es/ecma262/#sec-json.stringify 4602// https://github.com/tc39/proposal-json-parse-with-source 4603if ($stringify) $({ target: 'JSON', stat: true, arity: 3, forced: WRONG_SYMBOLS_CONVERSION || ILL_FORMED_UNICODE || !NATIVE_RAW_JSON }, { 4604 stringify: function stringify(text, replacer, space) { 4605 var replacerFunction = getReplacerFunction(replacer); 4606 var rawStrings = []; 4607 4608 var json = stringifyWithProperSymbolsConversion(text, function (key, value) { 4609 // some old implementations (like WebKit) could pass numbers as keys 4610 var v = isCallable(replacerFunction) ? call(replacerFunction, this, $String(key), value) : value; 4611 return !NATIVE_RAW_JSON && isRawJSON(v) ? MARK + (push(rawStrings, v.rawJSON) - 1) : v; 4612 }, space); 4613 4614 if (typeof json != 'string') return json; 4615 4616 if (ILL_FORMED_UNICODE) json = replace(json, surrogates, fixIllFormedJSON); 4617 4618 if (NATIVE_RAW_JSON) return json; 4619 4620 var result = ''; 4621 var length = json.length; 4622 4623 for (var i = 0; i < length; i++) { 4624 var chr = charAt(json, i); 4625 if (chr === '"') { 4626 var end = parseJSONString(json, ++i).end - 1; 4627 var string = slice(json, i, end); 4628 result += slice(string, 0, MARK_LENGTH) === MARK 4629 ? rawStrings[slice(string, MARK_LENGTH)] 4630 : '"' + string + '"'; 4631 i = end; 4632 } else result += chr; 4633 } 4634 4635 return result; 4636 } 4637}); 4638 4639 4640/***/ }, 4641 4642/***/ 2731 4643(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4644 4645 4646var $ = __webpack_require__(6518); 4647var aCallable = __webpack_require__(9306); 4648var aMap = __webpack_require__(6194); 4649var MapHelpers = __webpack_require__(2248); 4650var IS_PURE = __webpack_require__(6395); 4651 4652var get = MapHelpers.get; 4653var has = MapHelpers.has; 4654var set = MapHelpers.set; 4655 4656// `Map.prototype.getOrInsertComputed` method 4657// https://github.com/tc39/proposal-upsert 4658$({ target: 'Map', proto: true, real: true, forced: IS_PURE }, { 4659 getOrInsertComputed: function getOrInsertComputed(key, callbackfn) { 4660 aMap(this); 4661 aCallable(callbackfn); 4662 if (has(this, key)) return get(this, key); 4663 // CanonicalizeKeyedCollectionKey 4664 if (key === 0 && 1 / key === -Infinity) key = 0; 4665 var value = callbackfn(key); 4666 set(this, key, value); 4667 return value; 4668 } 4669}); 4670 4671 4672/***/ }, 4673 4674/***/ 5367 4675(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4676 4677 4678var $ = __webpack_require__(6518); 4679var aMap = __webpack_require__(6194); 4680var MapHelpers = __webpack_require__(2248); 4681var IS_PURE = __webpack_require__(6395); 4682 4683var get = MapHelpers.get; 4684var has = MapHelpers.has; 4685var set = MapHelpers.set; 4686 4687// `Map.prototype.getOrInsert` method 4688// https://github.com/tc39/proposal-upsert 4689$({ target: 'Map', proto: true, real: true, forced: IS_PURE }, { 4690 getOrInsert: function getOrInsert(key, value) { 4691 if (has(aMap(this), key)) return get(this, key); 4692 set(this, key, value); 4693 return value; 4694 } 4695}); 4696 4697 4698/***/ }, 4699 4700/***/ 4628 4701(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4702 4703 4704var $ = __webpack_require__(6518); 4705var newPromiseCapabilityModule = __webpack_require__(6043); 4706 4707// `Promise.withResolvers` method 4708// https://tc39.es/ecma262/#sec-promise.withResolvers 4709$({ target: 'Promise', stat: true }, {
vendor: 8,245 bytes, lines 4710-4990
4710 withResolvers: function withResolvers() { 4711 var promiseCapability = newPromiseCapabilityModule.f(this); 4712 return { 4713 promise: promiseCapability.promise, 4714 resolve: promiseCapability.resolve, 4715 reject: promiseCapability.reject 4716 }; 4717 } 4718}); 4719 4720 4721/***/ }, 4722 4723/***/ 6069 4724(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4725 4726 4727var $ = __webpack_require__(6518); 4728var uncurryThis = __webpack_require__(9504); 4729var aString = __webpack_require__(3463); 4730var hasOwn = __webpack_require__(9297); 4731var padStart = (__webpack_require__(533).start); 4732var WHITESPACES = __webpack_require__(7452); 4733 4734var $Array = Array; 4735var $escape = RegExp.escape; 4736var charAt = uncurryThis(''.charAt); 4737var charCodeAt = uncurryThis(''.charCodeAt); 4738var numberToString = uncurryThis(1.1.toString); 4739var join = uncurryThis([].join); 4740var FIRST_DIGIT_OR_ASCII = /^[0-9a-z]/i; 4741var SYNTAX_SOLIDUS = /^[$()*+./?[\\\]^{|}]/; 4742var OTHER_PUNCTUATORS_AND_WHITESPACES = RegExp('^[!"#%&\',\\-:;<=>@`~' + WHITESPACES + ']'); 4743var exec = uncurryThis(FIRST_DIGIT_OR_ASCII.exec); 4744 4745var ControlEscape = { 4746 '\u0009': 't', 4747 '\u000A': 'n', 4748 '\u000B': 'v', 4749 '\u000C': 'f', 4750 '\u000D': 'r' 4751}; 4752 4753var escapeChar = function (chr) { 4754 var hex = numberToString(charCodeAt(chr, 0), 16); 4755 return hex.length < 3 ? '\\x' + padStart(hex, 2, '0') : '\\u' + padStart(hex, 4, '0'); 4756}; 4757 4758// Avoiding the use of polyfills of the previous iteration of this proposal 4759var FORCED = !$escape || $escape('ab') !== '\\x61b'; 4760 4761// `RegExp.escape` method 4762// https://tc39.es/ecma262/#sec-regexp.escape 4763$({ target: 'RegExp', stat: true, forced: FORCED }, { 4764 escape: function escape(S) { 4765 aString(S); 4766 var length = S.length; 4767 var result = $Array(length); 4768 4769 for (var i = 0; i < length; i++) { 4770 var chr = charAt(S, i); 4771 if (i === 0 && exec(FIRST_DIGIT_OR_ASCII, chr)) { 4772 result[i] = escapeChar(chr); 4773 } else if (hasOwn(ControlEscape, chr)) { 4774 result[i] = '\\' + ControlEscape[chr]; 4775 } else if (exec(SYNTAX_SOLIDUS, chr)) { 4776 result[i] = '\\' + chr; 4777 } else if (exec(OTHER_PUNCTUATORS_AND_WHITESPACES, chr)) { 4778 result[i] = escapeChar(chr); 4779 } else { 4780 var charCode = charCodeAt(chr, 0); 4781 // single UTF-16 code unit 4782 if ((charCode & 0xF800) !== 0xD800) result[i] = chr; 4783 // unpaired surrogate 4784 else if (charCode >= 0xDC00 || i + 1 >= length || (charCodeAt(S, i + 1) & 0xFC00) !== 0xDC00) result[i] = escapeChar(chr); 4785 // surrogate pair 4786 else { 4787 result[i] = chr; 4788 result[++i] = charAt(S, i); 4789 } 4790 } 4791 } 4792 4793 return join(result, ''); 4794 } 4795}); 4796 4797 4798/***/ }, 4799 4800/***/ 7642 4801(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4802 4803 4804var $ = __webpack_require__(6518); 4805var difference = __webpack_require__(3440); 4806var fails = __webpack_require__(9039); 4807var setMethodAcceptSetLike = __webpack_require__(4916); 4808 4809var SET_LIKE_INCORRECT_BEHAVIOR = !setMethodAcceptSetLike('difference', function (result) { 4810 return result.size === 0; 4811}); 4812 4813var FORCED = SET_LIKE_INCORRECT_BEHAVIOR || fails(function () { 4814 // https://bugs.webkit.org/show_bug.cgi?id=288595 4815 var setLike = { 4816 size: 1, 4817 has: function () { return true; }, 4818 keys: function () { 4819 var index = 0; 4820 return { 4821 next: function () { 4822 var done = index++ > 1; 4823 if (baseSet.has(1)) baseSet.clear(); 4824 return { done: done, value: 2 }; 4825 } 4826 }; 4827 } 4828 }; 4829 // eslint-disable-next-line es/no-set -- testing 4830 var baseSet = new Set([1, 2, 3, 4]); 4831 // eslint-disable-next-line es/no-set-prototype-difference -- testing 4832 return baseSet.difference(setLike).size !== 3; 4833}); 4834 4835// `Set.prototype.difference` method 4836// https://tc39.es/ecma262/#sec-set.prototype.difference 4837$({ target: 'Set', proto: true, real: true, forced: FORCED }, { 4838 difference: difference 4839}); 4840 4841 4842/***/ }, 4843 4844/***/ 8004 4845(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4846 4847 4848var $ = __webpack_require__(6518); 4849var fails = __webpack_require__(9039); 4850var intersection = __webpack_require__(8750); 4851var setMethodAcceptSetLike = __webpack_require__(4916); 4852 4853var INCORRECT = !setMethodAcceptSetLike('intersection', function (result) { 4854 return result.size === 2 && result.has(1) && result.has(2); 4855}) || fails(function () { 4856 // eslint-disable-next-line es/no-array-from, es/no-set, es/no-set-prototype-intersection -- testing 4857 return String(Array.from(new Set([1, 2, 3]).intersection(new Set([3, 2])))) !== '3,2'; 4858}); 4859 4860// `Set.prototype.intersection` method 4861// https://tc39.es/ecma262/#sec-set.prototype.intersection 4862$({ target: 'Set', proto: true, real: true, forced: INCORRECT }, { 4863 intersection: intersection 4864}); 4865 4866 4867/***/ }, 4868 4869/***/ 3853 4870(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4871 4872 4873var $ = __webpack_require__(6518); 4874var isDisjointFrom = __webpack_require__(4449); 4875var setMethodAcceptSetLike = __webpack_require__(4916); 4876 4877var INCORRECT = !setMethodAcceptSetLike('isDisjointFrom', function (result) { 4878 return !result; 4879}); 4880 4881// `Set.prototype.isDisjointFrom` method 4882// https://tc39.es/ecma262/#sec-set.prototype.isdisjointfrom 4883$({ target: 'Set', proto: true, real: true, forced: INCORRECT }, { 4884 isDisjointFrom: isDisjointFrom 4885}); 4886 4887 4888/***/ }, 4889 4890/***/ 5876 4891(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4892 4893 4894var $ = __webpack_require__(6518); 4895var isSubsetOf = __webpack_require__(3838); 4896var setMethodAcceptSetLike = __webpack_require__(4916); 4897 4898var INCORRECT = !setMethodAcceptSetLike('isSubsetOf', function (result) { 4899 return result; 4900}); 4901 4902// `Set.prototype.isSubsetOf` method 4903// https://tc39.es/ecma262/#sec-set.prototype.issubsetof 4904$({ target: 'Set', proto: true, real: true, forced: INCORRECT }, { 4905 isSubsetOf: isSubsetOf 4906}); 4907 4908 4909/***/ }, 4910 4911/***/ 2475 4912(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4913 4914 4915var $ = __webpack_require__(6518); 4916var isSupersetOf = __webpack_require__(8527); 4917var setMethodAcceptSetLike = __webpack_require__(4916); 4918 4919var INCORRECT = !setMethodAcceptSetLike('isSupersetOf', function (result) { 4920 return !result; 4921}); 4922 4923// `Set.prototype.isSupersetOf` method 4924// https://tc39.es/ecma262/#sec-set.prototype.issupersetof 4925$({ target: 'Set', proto: true, real: true, forced: INCORRECT }, { 4926 isSupersetOf: isSupersetOf 4927}); 4928 4929 4930/***/ }, 4931 4932/***/ 5024 4933(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4934 4935 4936var $ = __webpack_require__(6518); 4937var symmetricDifference = __webpack_require__(3650); 4938var setMethodGetKeysBeforeCloning = __webpack_require__(9835); 4939var setMethodAcceptSetLike = __webpack_require__(4916); 4940 4941var FORCED = !setMethodAcceptSetLike('symmetricDifference') || !setMethodGetKeysBeforeCloning('symmetricDifference'); 4942 4943// `Set.prototype.symmetricDifference` method 4944// https://tc39.es/ecma262/#sec-set.prototype.symmetricdifference 4945$({ target: 'Set', proto: true, real: true, forced: FORCED }, { 4946 symmetricDifference: symmetricDifference 4947}); 4948 4949 4950/***/ }, 4951 4952/***/ 1698 4953(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4954 4955 4956var $ = __webpack_require__(6518); 4957var union = __webpack_require__(4204); 4958var setMethodGetKeysBeforeCloning = __webpack_require__(9835); 4959var setMethodAcceptSetLike = __webpack_require__(4916); 4960 4961var FORCED = !setMethodAcceptSetLike('union') || !setMethodGetKeysBeforeCloning('union'); 4962 4963// `Set.prototype.union` method 4964// https://tc39.es/ecma262/#sec-set.prototype.union 4965$({ target: 'Set', proto: true, real: true, forced: FORCED }, { 4966 union: union 4967}); 4968 4969 4970/***/ }, 4971 4972/***/ 9577 4973(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 4974 4975 4976var ArrayBufferViewCore = __webpack_require__(4644); 4977var isBigIntArray = __webpack_require__(1108); 4978var lengthOfArrayLike = __webpack_require__(6198); 4979var toIntegerOrInfinity = __webpack_require__(1291); 4980var toBigInt = __webpack_require__(5854); 4981 4982var aTypedArray = ArrayBufferViewCore.aTypedArray; 4983var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor; 4984var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; 4985 4986var $RangeError = RangeError; 4987 4988var PROPER_ORDER = function () { 4989 try { 4990 // eslint-disable-next-line no-throw-literal, es/no-typed-arrays, es/no-array-prototype-with -- required for testing
vendor: 4,425 bytes, lines 4991-5123
4991 new Int8Array(1)['with'](2, { valueOf: function () { throw 8; } }); 4992 } catch (error) { 4993 // some early implementations, like WebKit, does not follow the final semantic 4994 // https://github.com/tc39/proposal-change-array-by-copy/pull/86 4995 return error === 8; 4996 } 4997}(); 4998 4999// Bug in WebKit. It should truncate a negative fractional index to zero, but instead throws an error 5000var THROW_ON_NEGATIVE_FRACTIONAL_INDEX = PROPER_ORDER && function () { 5001 try { 5002 // eslint-disable-next-line es/no-typed-arrays, es/no-array-prototype-with -- required for testing 5003 new Int8Array(1)['with'](-0.5, 1); 5004 } catch (error) { 5005 return true; 5006 } 5007}(); 5008 5009// `%TypedArray%.prototype.with` method 5010// https://tc39.es/ecma262/#sec-%typedarray%.prototype.with 5011exportTypedArrayMethod('with', { 'with': function (index, value) { 5012 var O = aTypedArray(this); 5013 var len = lengthOfArrayLike(O); 5014 var relativeIndex = toIntegerOrInfinity(index); 5015 var actualIndex = relativeIndex < 0 ? len + relativeIndex : relativeIndex; 5016 var numericValue = isBigIntArray(O) ? toBigInt(value) : +value; 5017 if (actualIndex >= len || actualIndex < 0) throw new $RangeError('Incorrect index'); 5018 var A = new (getTypedArrayConstructor(O))(len); 5019 var k = 0; 5020 for (; k < len; k++) A[k] = k === actualIndex ? numericValue : O[k]; 5021 return A; 5022} }['with'], !PROPER_ORDER || THROW_ON_NEGATIVE_FRACTIONAL_INDEX); 5023 5024 5025/***/ }, 5026 5027/***/ 9452 5028(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 5029 5030 5031var $ = __webpack_require__(6518); 5032var aCallable = __webpack_require__(9306); 5033var aWeakMap = __webpack_require__(6557); 5034var aWeakKey = __webpack_require__(4328); 5035var WeakMapHelpers = __webpack_require__(4995); 5036var IS_PURE = __webpack_require__(6395); 5037 5038var get = WeakMapHelpers.get; 5039var has = WeakMapHelpers.has; 5040var set = WeakMapHelpers.set; 5041 5042var FORCED = IS_PURE || !function () { 5043 try { 5044 // eslint-disable-next-line es/no-weak-map, no-throw-literal -- testing 5045 if (WeakMap.prototype.getOrInsertComputed) new WeakMap().getOrInsertComputed(1, function () { throw 1; }); 5046 } catch (error) { 5047 // FF144 Nightly - Beta 3 bug 5048 // https://bugzilla.mozilla.org/show_bug.cgi?id=1988369 5049 return error instanceof TypeError; 5050 } 5051}(); 5052 5053// `WeakMap.prototype.getOrInsertComputed` method 5054// https://github.com/tc39/proposal-upsert 5055$({ target: 'WeakMap', proto: true, real: true, forced: FORCED }, { 5056 getOrInsertComputed: function getOrInsertComputed(key, callbackfn) { 5057 aWeakMap(this); 5058 aWeakKey(key); 5059 aCallable(callbackfn); 5060 if (has(this, key)) return get(this, key); 5061 var value = callbackfn(key); 5062 set(this, key, value); 5063 return value; 5064 } 5065}); 5066 5067 5068/***/ }, 5069 5070/***/ 8454 5071(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 5072 5073 5074var $ = __webpack_require__(6518); 5075var aWeakMap = __webpack_require__(6557); 5076var WeakMapHelpers = __webpack_require__(4995); 5077var IS_PURE = __webpack_require__(6395); 5078 5079var get = WeakMapHelpers.get; 5080var has = WeakMapHelpers.has; 5081var set = WeakMapHelpers.set; 5082 5083// `WeakMap.prototype.getOrInsert` method 5084// https://github.com/tc39/proposal-upsert 5085$({ target: 'WeakMap', proto: true, real: true, forced: IS_PURE }, { 5086 getOrInsert: function getOrInsert(key, value) { 5087 if (has(aWeakMap(this), key)) return get(this, key); 5088 set(this, key, value); 5089 return value; 5090 } 5091}); 5092 5093 5094/***/ }, 5095 5096/***/ 4603 5097(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 5098 5099 5100var defineBuiltIn = __webpack_require__(6840); 5101var uncurryThis = __webpack_require__(9504); 5102var toString = __webpack_require__(655); 5103var validateArgumentsLength = __webpack_require__(2812); 5104 5105var $URLSearchParams = URLSearchParams; 5106var URLSearchParamsPrototype = $URLSearchParams.prototype; 5107var append = uncurryThis(URLSearchParamsPrototype.append); 5108var $delete = uncurryThis(URLSearchParamsPrototype['delete']); 5109var forEach = uncurryThis(URLSearchParamsPrototype.forEach); 5110var push = uncurryThis([].push); 5111var params = new $URLSearchParams('a=1&a=2&b=3'); 5112 5113params['delete']('a', 1); 5114// `undefined` case is a Chromium 117 bug 5115// https://bugs.chromium.org/p/v8/issues/detail?id=14222 5116params['delete']('b', undefined); 5117 5118if (params + '' !== 'a=2') { 5119 defineBuiltIn(URLSearchParamsPrototype, 'delete', function (name /* , value */) { 5120 var length = arguments.length; 5121 var $value = length < 2 ? undefined : arguments[1]; 5122 if (length && $value === undefined) return $delete(this, name); 5123 var entries = [];
vendor: 8,681 bytes, lines 5124-5415
5124 forEach(this, function (v, k) { // also validates `this` 5125 push(entries, { key: k, value: v }); 5126 }); 5127 validateArgumentsLength(length, 1); 5128 var key = toString(name); 5129 var value = toString($value); 5130 var index = 0; 5131 var dindex = 0; 5132 var found = false; 5133 var entriesLength = entries.length; 5134 var entry; 5135 while (index < entriesLength) { 5136 entry = entries[index++]; 5137 if (found || entry.key === key) { 5138 found = true; 5139 $delete(this, entry.key); 5140 } else dindex++; 5141 } 5142 while (dindex < entriesLength) { 5143 entry = entries[dindex++]; 5144 if (!(entry.key === key && entry.value === value)) append(this, entry.key, entry.value); 5145 } 5146 }, { enumerable: true, unsafe: true }); 5147} 5148 5149 5150/***/ }, 5151 5152/***/ 7566 5153(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 5154 5155 5156var defineBuiltIn = __webpack_require__(6840); 5157var uncurryThis = __webpack_require__(9504); 5158var toString = __webpack_require__(655); 5159var validateArgumentsLength = __webpack_require__(2812); 5160 5161var $URLSearchParams = URLSearchParams; 5162var URLSearchParamsPrototype = $URLSearchParams.prototype; 5163var getAll = uncurryThis(URLSearchParamsPrototype.getAll); 5164var $has = uncurryThis(URLSearchParamsPrototype.has); 5165var params = new $URLSearchParams('a=1'); 5166 5167// `undefined` case is a Chromium 117 bug 5168// https://bugs.chromium.org/p/v8/issues/detail?id=14222 5169if (params.has('a', 2) || !params.has('a', undefined)) { 5170 defineBuiltIn(URLSearchParamsPrototype, 'has', function has(name /* , value */) { 5171 var length = arguments.length; 5172 var $value = length < 2 ? undefined : arguments[1]; 5173 if (length && $value === undefined) return $has(this, name); 5174 var values = getAll(this, name); // also validates `this` 5175 validateArgumentsLength(length, 1); 5176 var value = toString($value); 5177 var index = 0; 5178 while (index < values.length) { 5179 if (values[index++] === value) return true; 5180 } return false; 5181 }, { enumerable: true, unsafe: true }); 5182} 5183 5184 5185/***/ }, 5186 5187/***/ 8721 5188(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 5189 5190 5191var DESCRIPTORS = __webpack_require__(3724); 5192var uncurryThis = __webpack_require__(9504); 5193var defineBuiltInAccessor = __webpack_require__(2106); 5194 5195var URLSearchParamsPrototype = URLSearchParams.prototype; 5196var forEach = uncurryThis(URLSearchParamsPrototype.forEach); 5197 5198// `URLSearchParams.prototype.size` getter 5199// https://github.com/whatwg/url/pull/734 5200if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) { 5201 defineBuiltInAccessor(URLSearchParamsPrototype, 'size', { 5202 get: function size() { 5203 var count = 0; 5204 forEach(this, function () { count++; }); 5205 return count; 5206 }, 5207 configurable: true, 5208 enumerable: true 5209 }); 5210} 5211 5212 5213/***/ }, 5214 5215/***/ 5781 5216(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { 5217 5218 5219var $ = __webpack_require__(6518); 5220var getBuiltIn = __webpack_require__(7751); 5221var validateArgumentsLength = __webpack_require__(2812); 5222var toString = __webpack_require__(655); 5223var USE_NATIVE_URL = __webpack_require__(7416); 5224 5225var URL = getBuiltIn('URL'); 5226 5227// `URL.parse` method 5228// https://url.spec.whatwg.org/#dom-url-canparse 5229$({ target: 'URL', stat: true, forced: !USE_NATIVE_URL }, { 5230 parse: function parse(url) { 5231 var length = validateArgumentsLength(arguments.length, 1); 5232 var urlString = toString(url); 5233 var base = length < 2 || arguments[1] === undefined ? undefined : toString(arguments[1]); 5234 try { 5235 return new URL(urlString, base); 5236 } catch (error) { 5237 return null; 5238 } 5239 } 5240}); 5241 5242 5243/***/ } 5244 5245/******/ }); 5246/************************************************************************/ 5247/******/ // The module cache 5248/******/ var __webpack_module_cache__ = {}; 5249/******/ 5250/******/ // The require function 5251/******/ function __webpack_require__(moduleId) { 5252/******/ // Check if module is in cache 5253/******/ var cachedModule = __webpack_module_cache__[moduleId]; 5254/******/ if (cachedModule !== undefined) { 5255/******/ return cachedModule.exports; 5256/******/ } 5257/******/ // Create a new module (and put it into the cache) 5258/******/ var module = __webpack_module_cache__[moduleId] = { 5259/******/ // no module.id needed 5260/******/ // no module.loaded needed 5261/******/ exports: {} 5262/******/ }; 5263/******/ 5264/******/ // Execute the module function 5265/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); 5266/******/ 5267/******/ // Return the exports of the module 5268/******/ return module.exports; 5269/******/ } 5270/******/ 5271/************************************************************************/ 5272/******/ /* webpack/runtime/define property getters */ 5273/******/ (() => { 5274/******/ // define getter functions for harmony exports 5275/******/ __webpack_require__.d = (exports, definition) => { 5276/******/ for(var key in definition) { 5277/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 5278/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 5279/******/ } 5280/******/ } 5281/******/ }; 5282/******/ })(); 5283/******/ 5284/******/ /* webpack/runtime/hasOwnProperty shorthand */ 5285/******/ (() => { 5286/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 5287/******/ })(); 5288/******/ 5289/************************************************************************/ 5290var __webpack_exports__ = {}; 5291 5292// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.push.js 5293var es_array_push = __webpack_require__(4114); 5294// EXTERNAL MODULE: ./node_modules/core-js/modules/es.map.get-or-insert.js 5295var es_map_get_or_insert = __webpack_require__(5367); 5296// EXTERNAL MODULE: ./node_modules/core-js/modules/es.map.get-or-insert-computed.js 5297var es_map_get_or_insert_computed = __webpack_require__(2731); 5298// EXTERNAL MODULE: ./node_modules/core-js/modules/es.set.difference.v2.js 5299var es_set_difference_v2 = __webpack_require__(7642); 5300// EXTERNAL MODULE: ./node_modules/core-js/modules/es.set.intersection.v2.js 5301var es_set_intersection_v2 = __webpack_require__(8004); 5302// EXTERNAL MODULE: ./node_modules/core-js/modules/es.set.is-disjoint-from.v2.js 5303var es_set_is_disjoint_from_v2 = __webpack_require__(3853); 5304// EXTERNAL MODULE: ./node_modules/core-js/modules/es.set.is-subset-of.v2.js 5305var es_set_is_subset_of_v2 = __webpack_require__(5876); 5306// EXTERNAL MODULE: ./node_modules/core-js/modules/es.set.is-superset-of.v2.js 5307var es_set_is_superset_of_v2 = __webpack_require__(2475); 5308// EXTERNAL MODULE: ./node_modules/core-js/modules/es.set.symmetric-difference.v2.js 5309var es_set_symmetric_difference_v2 = __webpack_require__(5024); 5310// EXTERNAL MODULE: ./node_modules/core-js/modules/es.set.union.v2.js 5311var es_set_union_v2 = __webpack_require__(1698); 5312// EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.delete.js 5313var web_url_search_params_delete = __webpack_require__(4603); 5314// EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.has.js 5315var web_url_search_params_has = __webpack_require__(7566); 5316// EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.size.js 5317var web_url_search_params_size = __webpack_require__(8721); 5318;// ./web/pdfjs.js 5319const { 5320 AbortException, 5321 AnnotationEditorLayer, 5322 AnnotationEditorParamsType, 5323 AnnotationEditorType, 5324 AnnotationEditorUIManager, 5325 AnnotationLayer, 5326 AnnotationMode, 5327 AnnotationType, 5328 applyOpacity, 5329 build, 5330 ColorPicker, 5331 createValidAbsoluteUrl, 5332 CSSConstants, 5333 DOMSVGFactory, 5334 DrawLayer, 5335 FeatureTest, 5336 fetchData, 5337 findContrastColor, 5338 getDocument, 5339 getFilenameFromUrl, 5340 getPdfFilenameFromUrl, 5341 getRGB, 5342 getUuid, 5343 getXfaPageViewport, 5344 GlobalWorkerOptions, 5345 ImageKind, 5346 InvalidPDFException, 5347 isDataScheme, 5348 isPdfFile, 5349 isValidExplicitDest, 5350 makeArr, 5351 makeMap, 5352 makeObj, 5353 MathClamp, 5354 noContextMenu, 5355 normalizeUnicode, 5356 OPS, 5357 OutputScale, 5358 PasswordResponses, 5359 PDFDataRangeTransport, 5360 PDFDateString, 5361 PDFWorker, 5362 PermissionFlag, 5363 PixelsPerInch, 5364 RenderingCancelledException, 5365 renderRichText, 5366 ResponseException, 5367 setLayerDimensions, 5368 shadow, 5369 SignatureExtractor, 5370 stopEvent, 5371 SupportedImageMimeTypes, 5372 TextLayer, 5373 TouchManager, 5374 updateUrlHash, 5375 Util, 5376 VerbosityLevel, 5377 version, 5378 XfaLayer 5379} = globalThis.pdfjsLib; 5380 5381;// ./web/ui_utils.js 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396const DEFAULT_SCALE_VALUE = "auto"; 5397const DEFAULT_SCALE = 1.0; 5398const DEFAULT_SCALE_DELTA = 1.1; 5399const MIN_SCALE = 0.1; 5400const MAX_SCALE = 10.0; 5401const UNKNOWN_SCALE = 0; 5402const MAX_AUTO_SCALE = 1.25; 5403const SCROLLBAR_PADDING = 40; 5404const VERTICAL_PADDING = 5; 5405const PresentationModeState = { 5406 UNKNOWN: 0, 5407 NORMAL: 1, 5408 CHANGING: 2, 5409 FULLSCREEN: 3 5410}; 5411const SidebarView = { 5412 UNKNOWN: -1, 5413 NONE: 0, 5414 THUMBS: 1, 5415 OUTLINE: 2,
5416 ATTACHMENTS: 3, 5417 LAYERS: 4 5418}; 5419const TextLayerMode = { 5420 DISABLE: 0, 5421 ENABLE: 1, 5422 ENABLE_PERMISSIONS: 2 5423}; 5424const ScrollMode = { 5425 UNKNOWN: -1, 5426 VERTICAL: 0, 5427 HORIZONTAL: 1, 5428 WRAPPED: 2, 5429 PAGE: 3 5430}; 5431const SpreadMode = { 5432 UNKNOWN: -1, 5433 NONE: 0, 5434 ODD: 1, 5435 EVEN: 2 5436}; 5437const CursorTool = { 5438 SELECT: 0, 5439 HAND: 1, 5440 ZOOM: 2 5441}; 5442const AutoPrintRegExp = /\bprint\s*\(/; 5443function scrollIntoView(element, spot, scrollMatches = false) { 5444 let parent = element.offsetParent; 5445 if (!parent) { 5446 console.error("offsetParent is not set -- cannot scroll"); 5447 return; 5448 } 5449 let offsetY = element.offsetTop + element.clientTop; 5450 let offsetX = element.offsetLeft + element.clientLeft; 5451 while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || scrollMatches && (parent.classList.contains("markedContent") || getComputedStyle(parent).overflow === "hidden")) { 5452 offsetY += parent.offsetTop; 5453 offsetX += parent.offsetLeft; 5454 parent = parent.offsetParent; 5455 if (!parent) { 5456 return; 5457 } 5458 } 5459 if (spot) { 5460 if (spot.top !== undefined) { 5461 offsetY += spot.top; 5462 } 5463 if (spot.left !== undefined) { 5464 if (scrollMatches) { 5465 const elementWidth = element.getBoundingClientRect().width; 5466 const padding = MathClamp((parent.clientWidth - elementWidth) / 2, 20, 400); 5467 offsetX += spot.left - padding; 5468 } else { 5469 offsetX += spot.left; 5470 } 5471 parent.scrollLeft = offsetX; 5472 } 5473 } 5474 parent.scrollTop = offsetY; 5475} 5476function watchScroll(viewAreaElement, callback, abortSignal = undefined) { 5477 const debounceScroll = function (evt) { 5478 if (rAF) { 5479 return; 5480 } 5481 rAF = window.requestAnimationFrame(function viewAreaElementScrolled() { 5482 rAF = null; 5483 const currentX = viewAreaElement.scrollLeft; 5484 const lastX = state.lastX; 5485 if (currentX !== lastX) { 5486 state.right = currentX > lastX; 5487 } 5488 state.lastX = currentX; 5489 const currentY = viewAreaElement.scrollTop; 5490 const lastY = state.lastY; 5491 if (currentY !== lastY) { 5492 state.down = currentY > lastY; 5493 } 5494 state.lastY = currentY; 5495 callback(state); 5496 }); 5497 }; 5498 const state = { 5499 right: true, 5500 down: true, 5501 lastX: viewAreaElement.scrollLeft, 5502 lastY: viewAreaElement.scrollTop, 5503 _eventHandler: debounceScroll 5504 }; 5505 let rAF = null; 5506 viewAreaElement.addEventListener("scroll", debounceScroll, { 5507 useCapture: true, 5508 signal: abortSignal 5509 }); 5510 abortSignal?.addEventListener("abort", () => window.cancelAnimationFrame(rAF), { 5511 once: true 5512 }); 5513 return state; 5514} 5515function parseQueryString(query) { 5516 const params = new Map(); 5517 for (const [key, value] of new URLSearchParams(query)) { 5518 params.set(key.toLowerCase(), value); 5519 } 5520 return params; 5521} 5522const InvisibleCharsRegExp = /[\x00-\x1F]/g; 5523function removeNullCharacters(str, replaceInvisible = false) { 5524 if (!InvisibleCharsRegExp.test(str)) { 5525 return str; 5526 } 5527 if (replaceInvisible) { 5528 return str.replaceAll(InvisibleCharsRegExp, m => m === "\x00" ? "" : " "); 5529 } 5530 return str.replaceAll("\x00", ""); 5531} 5532function binarySearchFirstItem(items, condition, start = 0) { 5533 let minIndex = start; 5534 let maxIndex = items.length - 1; 5535 if (maxIndex < 0 || !condition(items[maxIndex])) { 5536 return items.length; 5537 } 5538 if (condition(items[minIndex])) { 5539 return minIndex; 5540 } 5541 while (minIndex < maxIndex) { 5542 const currentIndex = minIndex + maxIndex >> 1; 5543 const currentItem = items[currentIndex]; 5544 if (condition(currentItem)) { 5545 maxIndex = currentIndex; 5546 } else { 5547 minIndex = currentIndex + 1; 5548 } 5549 } 5550 return minIndex; 5551} 5552function approximateFraction(x) { 5553 if (Math.floor(x) === x) { 5554 return [x, 1]; 5555 } 5556 const xinv = 1 / x; 5557 const limit = 8; 5558 if (xinv > limit) { 5559 return [1, limit]; 5560 } else if (Math.floor(xinv) === xinv) { 5561 return [1, xinv]; 5562 } 5563 const x_ = x > 1 ? xinv : x; 5564 let a = 0, 5565 b = 1, 5566 c = 1, 5567 d = 1; 5568 while (true) { 5569 const p = a + c, 5570 q = b + d; 5571 if (q > limit) { 5572 break; 5573 } 5574 if (x_ <= p / q) { 5575 c = p; 5576 d = q; 5577 } else { 5578 a = p; 5579 b = q; 5580 } 5581 } 5582 let result; 5583 if (x_ - a / b < c / d - x_) { 5584 result = x_ === x ? [a, b] : [b, a]; 5585 } else { 5586 result = x_ === x ? [c, d] : [d, c]; 5587 } 5588 return result; 5589} 5590function floorToDivide(x, div) { 5591 return x - x % div; 5592} 5593function getPageSizeInches({ 5594 view, 5595 userUnit, 5596 rotate 5597}) { 5598 const [x1, y1, x2, y2] = view; 5599 const changeOrientation = rotate % 180 !== 0; 5600 const width = (x2 - x1) / 72 * userUnit; 5601 const height = (y2 - y1) / 72 * userUnit; 5602 return { 5603 width: changeOrientation ? height : width, 5604 height: changeOrientation ? width : height 5605 }; 5606} 5607function backtrackBeforeAllVisibleElements(index, views, top) { 5608 if (index < 2) { 5609 return index; 5610 } 5611 let elt = views[index].div; 5612 let pageTop = elt.offsetTop + elt.clientTop; 5613 if (pageTop >= top) { 5614 elt = views[index - 1].div; 5615 pageTop = elt.offsetTop + elt.clientTop; 5616 } 5617 for (let i = index - 2; i >= 0; --i) { 5618 elt = views[i].div; 5619 if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) { 5620 break; 5621 } 5622 index = i; 5623 } 5624 return index; 5625} 5626function getVisibleElements({ 5627 scrollEl, 5628 views, 5629 sortByVisibility = false, 5630 horizontal = false, 5631 rtl = false 5632}) { 5633 const top = scrollEl.scrollTop, 5634 bottom = top + scrollEl.clientHeight; 5635 const left = scrollEl.scrollLeft, 5636 right = left + scrollEl.clientWidth; 5637 function isElementBottomAfterViewTop(view) { 5638 const element = view.div; 5639 const elementBottom = element.offsetTop + element.clientTop + element.clientHeight; 5640 return elementBottom > top; 5641 } 5642 function isElementNextAfterViewHorizontally(view) { 5643 const element = view.div; 5644 const elementLeft = element.offsetLeft + element.clientLeft; 5645 const elementRight = elementLeft + element.clientWidth; 5646 return rtl ? elementLeft < right : elementRight > left; 5647 } 5648 const visible = [], 5649 ids = new Set(), 5650 numViews = views.length;
5651 let firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop); 5652 if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) { 5653 firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top); 5654 } 5655 let lastEdge = horizontal ? right : -1; 5656 for (let i = firstVisibleElementInd; i < numViews; i++) { 5657 const view = views[i], 5658 element = view.div; 5659 const currentWidth = element.offsetLeft + element.clientLeft; 5660 const currentHeight = element.offsetTop + element.clientTop; 5661 const viewWidth = element.clientWidth, 5662 viewHeight = element.clientHeight; 5663 const viewRight = currentWidth + viewWidth; 5664 const viewBottom = currentHeight + viewHeight; 5665 if (lastEdge === -1) { 5666 if (viewBottom >= bottom) { 5667 lastEdge = viewBottom; 5668 } 5669 } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) { 5670 break; 5671 } 5672 if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) { 5673 continue; 5674 } 5675 const minY = Math.max(0, top - currentHeight); 5676 const minX = Math.max(0, left - currentWidth); 5677 const hiddenHeight = minY + Math.max(0, viewBottom - bottom); 5678 const hiddenWidth = minX + Math.max(0, viewRight - right); 5679 const fractionHeight = (viewHeight - hiddenHeight) / viewHeight, 5680 fractionWidth = (viewWidth - hiddenWidth) / viewWidth; 5681 const percent = fractionHeight * fractionWidth * 100 | 0; 5682 visible.push({ 5683 id: view.id, 5684 x: currentWidth, 5685 y: currentHeight, 5686 visibleArea: percent === 100 ? null : { 5687 minX, 5688 minY, 5689 maxX: Math.min(viewRight, right) - currentWidth, 5690 maxY: Math.min(viewBottom, bottom) - currentHeight 5691 }, 5692 view, 5693 percent, 5694 widthPercent: fractionWidth * 100 | 0 5695 }); 5696 ids.add(view.id); 5697 } 5698 const first = visible[0], 5699 last = visible.at(-1); 5700 if (sortByVisibility) { 5701 visible.sort(function (a, b) { 5702 const pc = a.percent - b.percent; 5703 if (Math.abs(pc) > 0.001) { 5704 return -pc; 5705 } 5706 return a.id - b.id; 5707 }); 5708 } 5709 return { 5710 first, 5711 last, 5712 views: visible, 5713 ids 5714 }; 5715} 5716function normalizeWheelEventDirection(evt) { 5717 let delta = Math.hypot(evt.deltaX, evt.deltaY); 5718 const angle = Math.atan2(evt.deltaY, evt.deltaX); 5719 if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) { 5720 delta = -delta; 5721 } 5722 return delta; 5723} 5724function normalizeWheelEventDelta(evt) { 5725 const deltaMode = evt.deltaMode; 5726 let delta = normalizeWheelEventDirection(evt); 5727 const MOUSE_PIXELS_PER_LINE = 30; 5728 const MOUSE_LINES_PER_PAGE = 30; 5729 if (deltaMode === WheelEvent.DOM_DELTA_PIXEL) { 5730 delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE; 5731 } else if (deltaMode === WheelEvent.DOM_DELTA_LINE) { 5732 delta /= MOUSE_LINES_PER_PAGE; 5733 } 5734 return delta; 5735} 5736function isValidRotation(angle) { 5737 return Number.isInteger(angle) && angle % 90 === 0; 5738} 5739function isValidScrollMode(mode) { 5740 return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN; 5741} 5742function isValidSpreadMode(mode) { 5743 return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN; 5744} 5745function isPortraitOrientation(size) { 5746 return size.width <= size.height; 5747} 5748const animationStarted = new Promise(function (resolve) { 5749 window.requestAnimationFrame(resolve); 5750}); 5751const docStyle = document.documentElement.style; 5752class ProgressBar { 5753 #classList = null; 5754 #disableAutoFetchTimeout = null; 5755 #percent = 0; 5756 #style = null; 5757 #visible = true; 5758 constructor(bar) { 5759 this.#classList = bar.classList; 5760 this.#style = bar.style; 5761 } 5762 get percent() { 5763 return this.#percent; 5764 } 5765 set percent(val) { 5766 this.#percent = val; 5767 if (isNaN(val)) { 5768 this.#classList.add("indeterminate"); 5769 return; 5770 } 5771 this.#classList.remove("indeterminate"); 5772 this.#style.setProperty("--progressBar-percent", `${this.#percent}%`); 5773 } 5774 setWidth(viewer) { 5775 if (!viewer) { 5776 return; 5777 } 5778 const container = viewer.parentNode; 5779 const scrollbarWidth = container.offsetWidth - viewer.offsetWidth; 5780 if (scrollbarWidth > 0) { 5781 this.#style.setProperty("--progressBar-end-offset", `${scrollbarWidth}px`); 5782 } 5783 } 5784 setDisableAutoFetch(delay = 5000) { 5785 if (this.#percent === 100 || isNaN(this.#percent)) { 5786 return; 5787 } 5788 if (this.#disableAutoFetchTimeout) { 5789 clearTimeout(this.#disableAutoFetchTimeout); 5790 } 5791 this.show(); 5792 this.#disableAutoFetchTimeout = setTimeout(() => { 5793 this.#disableAutoFetchTimeout = null; 5794 this.hide(); 5795 }, delay); 5796 } 5797 hide() { 5798 if (!this.#visible) { 5799 return; 5800 } 5801 this.#visible = false;
5802 this.#classList.add("hidden"); 5803 } 5804 show() { 5805 if (this.#visible) { 5806 return; 5807 } 5808 this.#visible = true; 5809 this.#classList.remove("hidden"); 5810 } 5811} 5812function getActiveOrFocusedElement() { 5813 let curRoot = document; 5814 let curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus"); 5815 while (curActiveOrFocused?.shadowRoot) { 5816 curRoot = curActiveOrFocused.shadowRoot; 5817 curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus"); 5818 } 5819 return curActiveOrFocused; 5820} 5821function apiPageLayoutToViewerModes(layout) { 5822 let scrollMode = ScrollMode.VERTICAL, 5823 spreadMode = SpreadMode.NONE; 5824 switch (layout) { 5825 case "SinglePage": 5826 scrollMode = ScrollMode.PAGE; 5827 break; 5828 case "OneColumn": 5829 break; 5830 case "TwoPageLeft": 5831 scrollMode = ScrollMode.PAGE; 5832 case "TwoColumnLeft": 5833 spreadMode = SpreadMode.ODD; 5834 break; 5835 case "TwoPageRight": 5836 scrollMode = ScrollMode.PAGE; 5837 case "TwoColumnRight": 5838 spreadMode = SpreadMode.EVEN; 5839 break; 5840 } 5841 return { 5842 scrollMode, 5843 spreadMode 5844 }; 5845} 5846function apiPageModeToSidebarView(mode) { 5847 switch (mode) { 5848 case "UseNone": 5849 return SidebarView.NONE; 5850 case "UseThumbs": 5851 return SidebarView.THUMBS; 5852 case "UseOutlines": 5853 return SidebarView.OUTLINE; 5854 case "UseAttachments": 5855 return SidebarView.ATTACHMENTS; 5856 case "UseOC": 5857 return SidebarView.LAYERS; 5858 } 5859 return SidebarView.NONE; 5860} 5861function toggleCheckedBtn(button, toggle, view = null) { 5862 button.classList.toggle("toggled", toggle); 5863 button.setAttribute("aria-checked", toggle); 5864 view?.classList.toggle("hidden", !toggle); 5865} 5866function toggleSelectedBtn(button, toggle, view = null) { 5867 button.classList.toggle("selected", toggle); 5868 button.setAttribute("aria-selected", toggle); 5869 view?.classList.toggle("hidden", !toggle); 5870} 5871function toggleExpandedBtn(button, toggle, view = null) { 5872 button.classList.toggle("toggled", toggle); 5873 button.setAttribute("aria-expanded", toggle); 5874 view?.classList.toggle("hidden", !toggle); 5875} 5876const calcRound = function () { 5877 const e = document.createElement("div"); 5878 e.style.width = "round(down, calc(1.6666666666666665 * 792px), 1px)"; 5879 return e.style.width === "calc(1320px)" ? Math.fround : x => x; 5880}(); 5881 5882;// ./web/app_options.js 5883 5884 5885{ 5886 var compatParams = new Map(); 5887 const { 5888 maxTouchPoints, 5889 platform, 5890 userAgent 5891 } = navigator; 5892 const isAndroid = /Android/.test(userAgent); 5893 const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1; 5894 if (isIOS || isAndroid) { 5895 compatParams.set("maxCanvasPixels", 5242880); 5896 } 5897 if (isAndroid) { 5898 compatParams.set("useSystemFonts", false); 5899 } 5900} 5901const OptionKind = { 5902 BROWSER: 0x01, 5903 VIEWER: 0x02, 5904 API: 0x04, 5905 WORKER: 0x08, 5906 EVENT_DISPATCH: 0x10, 5907 PREFERENCE: 0x80 5908}; 5909const Type = { 5910 BOOLEAN: 0x01, 5911 NUMBER: 0x02, 5912 OBJECT: 0x04, 5913 STRING: 0x08, 5914 UNDEFINED: 0x10 5915}; 5916const defaultOptions = { 5917 allowedGlobalEvents: { 5918 value: null, 5919 kind: OptionKind.BROWSER 5920 }, 5921 canvasMaxAreaInBytes: { 5922 value: -1, 5923 kind: OptionKind.BROWSER + OptionKind.API 5924 }, 5925 isInAutomation: { 5926 value: false, 5927 kind: OptionKind.BROWSER 5928 }, 5929 localeProperties: { 5930 value: { 5931 lang: navigator.language || "en-US" 5932 }, 5933 kind: OptionKind.BROWSER 5934 }, 5935 maxCanvasDim: { 5936 value: 32767, 5937 kind: OptionKind.BROWSER + OptionKind.VIEWER 5938 }, 5939 nimbusDataStr: { 5940 value: "", 5941 kind: OptionKind.BROWSER 5942 }, 5943 supportsCaretBrowsingMode: { 5944 value: false, 5945 kind: OptionKind.BROWSER 5946 }, 5947 supportsDocumentFonts: { 5948 value: true, 5949 kind: OptionKind.BROWSER 5950 }, 5951 supportsIntegratedFind: { 5952 value: false, 5953 kind: OptionKind.BROWSER 5954 }, 5955 supportsMouseWheelZoomCtrlKey: { 5956 value: true, 5957 kind: OptionKind.BROWSER 5958 }, 5959 supportsMouseWheelZoomMetaKey: { 5960 value: true, 5961 kind: OptionKind.BROWSER 5962 }, 5963 supportsPinchToZoom: { 5964 value: true, 5965 kind: OptionKind.BROWSER 5966 }, 5967 supportsPrinting: { 5968 value: true, 5969 kind: OptionKind.BROWSER 5970 }, 5971 toolbarDensity: { 5972 value: 0, 5973 kind: OptionKind.BROWSER + OptionKind.EVENT_DISPATCH 5974 }, 5975 altTextLearnMoreUrl: { 5976 value: "",
5977 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5978 }, 5979 annotationEditorMode: { 5980 value: 0, 5981 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5982 }, 5983 annotationMode: { 5984 value: 2, 5985 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5986 }, 5987 capCanvasAreaFactor: { 5988 value: 200, 5989 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5990 }, 5991 commentLearnMoreUrl: { 5992 value: "", 5993 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5994 }, 5995 cursorToolOnLoad: { 5996 value: 0, 5997 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5998 }, 5999 debuggerSrc: { 6000 value: "./debugger.js", 6001 kind: OptionKind.VIEWER 6002 }, 6003 defaultZoomDelay: { 6004 value: 400, 6005 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6006 }, 6007 defaultZoomValue: { 6008 value: "", 6009 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6010 }, 6011 disableHistory: { 6012 value: false, 6013 kind: OptionKind.VIEWER 6014 }, 6015 disablePageLabels: { 6016 value: false, 6017 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6018 }, 6019 enableAltText: { 6020 value: false, 6021 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6022 }, 6023 enableAltTextModelDownload: { 6024 value: true, 6025 kind: OptionKind.VIEWER + OptionKind.PREFERENCE + OptionKind.EVENT_DISPATCH 6026 }, 6027 enableAutoLinking: { 6028 value: true, 6029 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6030 }, 6031 enableComment: { 6032 value: false, 6033 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6034 }, 6035 enableDetailCanvas: { 6036 value: true, 6037 kind: OptionKind.VIEWER 6038 }, 6039 enableGuessAltText: { 6040 value: true, 6041 kind: OptionKind.VIEWER + OptionKind.PREFERENCE + OptionKind.EVENT_DISPATCH 6042 }, 6043 enableHighlightFloatingButton: { 6044 value: false, 6045 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6046 }, 6047 enableNewAltTextWhenAddingImage: { 6048 value: true, 6049 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6050 }, 6051 enableOptimizedPartialRendering: { 6052 value: false, 6053 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6054 }, 6055 enablePermissions: { 6056 value: false, 6057 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6058 }, 6059 enablePrintAutoRotate: { 6060 value: true, 6061 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6062 }, 6063 enableScripting: { 6064 value: true, 6065 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6066 }, 6067 enableSignatureEditor: { 6068 value: false, 6069 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6070 }, 6071 enableSplitMerge: { 6072 value: false, 6073 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6074 }, 6075 enableUpdatedAddImage: { 6076 value: false, 6077 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6078 }, 6079 externalLinkRel: { 6080 value: "noopener noreferrer nofollow", 6081 kind: OptionKind.VIEWER 6082 }, 6083 externalLinkTarget: { 6084 value: 0, 6085 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6086 }, 6087 highlightEditorColors: { 6088 value: "yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F," + "yellow_HCM=#FFFFCC,green_HCM=#53FFBC,blue_HCM=#80EBFF,pink_HCM=#F6B8FF,red_HCM=#C50043", 6089 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6090 }, 6091 historyUpdateUrl: { 6092 value: false, 6093 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6094 }, 6095 ignoreDestinationZoom: { 6096 value: false, 6097 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6098 }, 6099 imageResourcesPath: { 6100 value: "./images/", 6101 kind: OptionKind.VIEWER 6102 }, 6103 maxCanvasPixels: { 6104 value: 2 ** 25, 6105 kind: OptionKind.VIEWER 6106 }, 6107 minDurationToUpdateCanvas: { 6108 value: 500, 6109 kind: OptionKind.VIEWER 6110 }, 6111 forcePageColors: { 6112 value: false, 6113 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6114 }, 6115 pageColorsBackground: { 6116 value: "Canvas", 6117 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6118 }, 6119 pageColorsForeground: { 6120 value: "CanvasText", 6121 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6122 }, 6123 pdfBugEnabled: { 6124 value: false, 6125 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6126 }, 6127 printResolution: { 6128 value: 150, 6129 kind: OptionKind.VIEWER 6130 }, 6131 sidebarViewOnLoad: { 6132 value: -1, 6133 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6134 }, 6135 scrollModeOnLoad: { 6136 value: -1, 6137 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6138 }, 6139 spreadModeOnLoad: { 6140 value: -1, 6141 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6142 }, 6143 textLayerMode: { 6144 value: 1, 6145 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6146 }, 6147 viewerCssTheme: { 6148 value: 0, 6149 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6150 }, 6151 viewOnLoad: { 6152 value: 0, 6153 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 6154 }, 6155 cMapPacked: { 6156 value: true, 6157 kind: OptionKind.API 6158 }, 6159 cMapUrl: { 6160 value: "../web/cmaps/", 6161 kind: OptionKind.API 6162 }, 6163 disableAutoFetch: { 6164 value: false, 6165 kind: OptionKind.API + OptionKind.PREFERENCE 6166 }, 6167 disableFontFace: { 6168 value: false, 6169 kind: OptionKind.API + OptionKind.PREFERENCE 6170 }, 6171 disableRange: { 6172 value: false, 6173 kind: OptionKind.API + OptionKind.PREFERENCE 6174 }, 6175 disableStream: { 6176 value: false, 6177 kind: OptionKind.API + OptionKind.PREFERENCE 6178 }, 6179 docBaseUrl: { 6180 value: "",
6181 kind: OptionKind.API 6182 }, 6183 enableHWA: { 6184 value: true, 6185 kind: OptionKind.API + OptionKind.VIEWER + OptionKind.PREFERENCE 6186 }, 6187 enableXfa: { 6188 value: true, 6189 kind: OptionKind.API + OptionKind.PREFERENCE 6190 }, 6191 fontExtraProperties: { 6192 value: false, 6193 kind: OptionKind.API 6194 }, 6195 iccUrl: { 6196 value: "../web/iccs/", 6197 kind: OptionKind.API 6198 }, 6199 isEvalSupported: { 6200 value: true, 6201 kind: OptionKind.API 6202 }, 6203 isOffscreenCanvasSupported: { 6204 value: true, 6205 kind: OptionKind.API 6206 }, 6207 maxImageSize: { 6208 value: -1, 6209 kind: OptionKind.API 6210 }, 6211 pdfBug: { 6212 value: false, 6213 kind: OptionKind.API 6214 }, 6215 standardFontDataUrl: { 6216 value: "../web/standard_fonts/", 6217 kind: OptionKind.API 6218 }, 6219 useSystemFonts: { 6220 value: undefined, 6221 kind: OptionKind.API, 6222 type: Type.BOOLEAN + Type.UNDEFINED 6223 }, 6224 verbosity: { 6225 value: 1, 6226 kind: OptionKind.API 6227 }, 6228 wasmUrl: { 6229 value: "../web/wasm/", 6230 kind: OptionKind.API 6231 }, 6232 workerPort: { 6233 value: null, 6234 kind: OptionKind.WORKER 6235 }, 6236 workerSrc: { 6237 value: "../build/pdf.worker.js", 6238 kind: OptionKind.WORKER 6239 } 6240}; 6241{ 6242 defaultOptions.defaultUrl = { 6243 value: "compressed.tracemonkey-pldi-09.pdf", 6244 kind: OptionKind.VIEWER 6245 }; 6246 defaultOptions.sandboxBundleSrc = { 6247 value: "../build/pdf.sandbox.js", 6248 kind: OptionKind.VIEWER 6249 }; 6250 defaultOptions.enableFakeMLManager = { 6251 value: true, 6252 kind: OptionKind.VIEWER 6253 }; 6254} 6255{ 6256 defaultOptions.disablePreferences = { 6257 value: false, 6258 kind: OptionKind.VIEWER 6259 }; 6260} 6261class AppOptions { 6262 static eventBus; 6263 static #opts = new Map(); 6264 static { 6265 for (const name in defaultOptions) { 6266 this.#opts.set(name, defaultOptions[name].value); 6267 } 6268 for (const [name, value] of compatParams) { 6269 this.#opts.set(name, value); 6270 } 6271 this._hasInvokedSet = false; 6272 this._checkDisablePreferences = () => { 6273 if (this.get("disablePreferences")) { 6274 return true; 6275 } 6276 if (this._hasInvokedSet) { 6277 console.warn("The Preferences may override manually set AppOptions; " + 'please use the "disablePreferences"-option to prevent that.'); 6278 } 6279 return false; 6280 }; 6281 } 6282 static get(name) { 6283 return this.#opts.get(name); 6284 } 6285 static getAll(kind = null, defaultOnly = false) { 6286 const options = Object.create(null); 6287 for (const name in defaultOptions) { 6288 const defaultOpt = defaultOptions[name]; 6289 if (kind && !(kind & defaultOpt.kind)) { 6290 continue; 6291 } 6292 options[name] = !defaultOnly ? this.#opts.get(name) : defaultOpt.value; 6293 } 6294 return options; 6295 } 6296 static set(name, value) { 6297 this.setAll({ 6298 [name]: value 6299 }); 6300 } 6301 static setAll(options, prefs = false) { 6302 this._hasInvokedSet ||= true; 6303 let events; 6304 for (const name in options) { 6305 const defaultOpt = defaultOptions[name], 6306 userOpt = options[name]; 6307 if (!defaultOpt || !(typeof userOpt === typeof defaultOpt.value || Type[(typeof userOpt).toUpperCase()] & defaultOpt.type)) { 6308 continue; 6309 } 6310 const { 6311 kind 6312 } = defaultOpt; 6313 if (prefs && !(kind & OptionKind.BROWSER || kind & OptionKind.PREFERENCE)) { 6314 continue; 6315 } 6316 if (this.eventBus && kind & OptionKind.EVENT_DISPATCH) { 6317 (events ||= new Map()).set(name, userOpt); 6318 } 6319 this.#opts.set(name, userOpt); 6320 } 6321 if (events) { 6322 for (const [name, value] of events) { 6323 this.eventBus.dispatch(name.toLowerCase(), { 6324 source: this, 6325 value 6326 }); 6327 } 6328 } 6329 } 6330} 6331 6332// EXTERNAL MODULE: ./node_modules/core-js/modules/es.json.parse.js 6333var es_json_parse = __webpack_require__(9112); 6334// EXTERNAL MODULE: ./node_modules/core-js/modules/es.json.stringify.js 6335var es_json_stringify = __webpack_require__(3110); 6336;// ./web/pdf_link_service.js 6337 6338 6339 6340 6341 6342const DEFAULT_LINK_REL = "noopener noreferrer nofollow"; 6343const LinkTarget = { 6344 NONE: 0, 6345 SELF: 1, 6346 BLANK: 2, 6347 PARENT: 3, 6348 TOP: 4 6349}; 6350class PDFLinkService { 6351 externalLinkEnabled = true; 6352 constructor({ 6353 eventBus, 6354 externalLinkTarget = null, 6355 externalLinkRel = null, 6356 ignoreDestinationZoom = false 6357 }
6357 = {}) { 6358 this.eventBus = eventBus; 6359 this.externalLinkTarget = externalLinkTarget; 6360 this.externalLinkRel = externalLinkRel; 6361 this._ignoreDestinationZoom = ignoreDestinationZoom; 6362 this.baseUrl = null; 6363 this.pdfDocument = null; 6364 this.pdfViewer = null; 6365 this.pdfHistory = null; 6366 } 6367 setDocument(pdfDocument, baseUrl = null) { 6368 this.baseUrl = baseUrl; 6369 this.pdfDocument = pdfDocument; 6370 } 6371 setViewer(pdfViewer) { 6372 this.pdfViewer = pdfViewer; 6373 } 6374 setHistory(pdfHistory) { 6375 this.pdfHistory = pdfHistory; 6376 } 6377 get pagesCount() { 6378 return this.pdfDocument?.pagesMapper.pagesNumber || 0; 6379 } 6380 get page() { 6381 return this.pdfDocument ? this.pdfViewer.currentPageNumber : 1; 6382 } 6383 set page(value) { 6384 if (this.pdfDocument) { 6385 this.pdfViewer.currentPageNumber = value; 6386 } 6387 } 6388 get rotation() { 6389 return this.pdfDocument ? this.pdfViewer.pagesRotation : 0; 6390 } 6391 set rotation(value) { 6392 if (this.pdfDocument) { 6393 this.pdfViewer.pagesRotation = value; 6394 } 6395 } 6396 get isInPresentationMode() { 6397 return this.pdfDocument ? this.pdfViewer.isInPresentationMode : false; 6398 } 6399 async goToDestination(dest) { 6400 if (!this.pdfDocument) { 6401 return; 6402 } 6403 let namedDest, explicitDest, pageNumber; 6404 if (typeof dest === "string") { 6405 namedDest = dest; 6406 explicitDest = await this.pdfDocument.getDestination(dest); 6407 } else { 6408 namedDest = null; 6409 explicitDest = await dest; 6410 } 6411 if (!Array.isArray(explicitDest)) { 6412 console.error(`goToDestination: "${explicitDest}" is not a valid destination array, for dest="${dest}".`); 6413 return; 6414 } 6415 const [destRef] = explicitDest; 6416 if (destRef && typeof destRef === "object") { 6417 pageNumber = this.pdfDocument.cachedPageNumber(destRef); 6418 if (!pageNumber) { 6419 try { 6420 pageNumber = (await this.pdfDocument.getPageIndex(destRef)) + 1; 6421 } catch { 6422 console.error(`goToDestination: "${destRef}" is not a valid page reference, for dest="${dest}".`); 6423 return; 6424 } 6425 } 6426 } else if (Number.isInteger(destRef)) { 6427 pageNumber = destRef + 1; 6428 } 6429 if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) { 6430 console.error(`goToDestination: "${pageNumber}" is not a valid page number, for dest="${dest}".`); 6431 return; 6432 } 6433 if (this.pdfHistory) { 6434 this.pdfHistory.pushCurrentPosition(); 6435 this.pdfHistory.push({ 6436 namedDest, 6437 explicitDest, 6438 pageNumber 6439 }); 6440 } 6441 this.pdfViewer.scrollPageIntoView({ 6442 pageNumber, 6443 destArray: explicitDest, 6444 ignoreDestinationZoom: this._ignoreDestinationZoom 6445 }); 6446 const ac = new AbortController(); 6447 this.eventBus._on("textlayerrendered", evt => { 6448 if (evt.pageNumber === pageNumber) { 6449 evt.source.textLayer.div.focus(); 6450 ac.abort(); 6451 } 6452 }, { 6453 signal: ac.signal 6454 }); 6455 } 6456 goToPage(val) { 6457 if (!this.pdfDocument) { 6458 return; 6459 } 6460 const pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0; 6461 if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) { 6462 console.error(`PDFLinkService.goToPage: "${val}" is not a valid page.`); 6463 return; 6464 } 6465 if (this.pdfHistory) { 6466 this.pdfHistory.pushCurrentPosition(); 6467 this.pdfHistory.pushPage(pageNumber); 6468 } 6469 this.pdfViewer.scrollPageIntoView({ 6470 pageNumber 6471 }); 6472 } 6473 goToXY(pageNumber, x, y, options = {}) { 6474 this.pdfViewer.scrollPageIntoView({ 6475 pageNumber, 6476 destArray: [null, { 6477 name: "XYZ" 6478 }, x, y], 6479 ignoreDestinationZoom: true, 6480 ...options 6481 }); 6482 } 6483 addLinkAttributes(link, url, newWindow = false) { 6484 if (!url || typeof url !== "string") { 6485 throw new Error('A valid "url" parameter must provided.'); 6486 } 6487 const target = newWindow ? LinkTarget.BLANK : this.externalLinkTarget, 6488 rel = this.externalLinkRel; 6489 if (this.externalLinkEnabled) { 6490 link.href = link.title = url; 6491 } else { 6492 link.href = ""; 6493 link.title = `Disabled: ${url}`; 6494 link.onclick = () => false;
6495 } 6496 let targetStr = ""; 6497 switch (target) { 6498 case LinkTarget.NONE: 6499 break; 6500 case LinkTarget.SELF: 6501 targetStr = "_self"; 6502 break; 6503 case LinkTarget.BLANK: 6504 targetStr = "_blank"; 6505 break; 6506 case LinkTarget.PARENT: 6507 targetStr = "_parent"; 6508 break; 6509 case LinkTarget.TOP: 6510 targetStr = "_top"; 6511 break; 6512 } 6513 link.target = targetStr; 6514 link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL; 6515 } 6516 getDestinationHash(dest) { 6517 if (typeof dest === "string") { 6518 if (dest.length > 0) { 6519 return this.getAnchorUrl("#" + escape(dest)); 6520 } 6521 } else if (Array.isArray(dest)) { 6522 const str = JSON.stringify(dest); 6523 if (str.length > 0) { 6524 return this.getAnchorUrl("#" + escape(str)); 6525 } 6526 } 6527 return this.getAnchorUrl(""); 6528 } 6529 getAnchorUrl(anchor) { 6530 return this.baseUrl ? this.baseUrl + anchor : anchor; 6531 } 6532 setHash(hash) { 6533 if (!this.pdfDocument) { 6534 return; 6535 } 6536 let pageNumber, dest; 6537 if (hash.includes("=")) { 6538 const params = parseQueryString(hash); 6539 if (params.has("search")) { 6540 const query = params.get("search").replaceAll('"', ""), 6541 phrase = params.get("phrase") === "true"; 6542 this.eventBus.dispatch("findfromurlhash", { 6543 source: this, 6544 query: phrase ? query : query.match(/\S+/g) 6545 }); 6546 } 6547 if (params.has("page")) { 6548 pageNumber = params.get("page") | 0 || 1; 6549 } 6550 if (params.has("zoom")) { 6551 const zoomArgs = params.get("zoom").split(","); 6552 const zoomArg = zoomArgs[0]; 6553 const zoomArgNumber = parseFloat(zoomArg); 6554 if (!zoomArg.includes("Fit")) { 6555 dest = [null, { 6556 name: "XYZ" 6557 }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg]; 6558 } else if (zoomArg === "Fit" || zoomArg === "FitB") { 6559 dest = [null, { 6560 name: zoomArg 6561 }]; 6562 } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") { 6563 dest = [null, { 6564 name: zoomArg 6565 }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null]; 6566 } else if (zoomArg === "FitR") { 6567 if (zoomArgs.length !== 5) { 6568 console.error('PDFLinkService.setHash: Not enough parameters for "FitR".'); 6569 } else { 6570 dest = [null, { 6571 name: zoomArg 6572 }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0]; 6573 } 6574 } else { 6575 console.error(`PDFLinkService.setHash: "${zoomArg}" is not a valid zoom value.`); 6576 } 6577 } 6578 if (dest) { 6579 this.pdfViewer.scrollPageIntoView({ 6580 pageNumber: pageNumber || this.page, 6581 destArray: dest, 6582 allowNegativeOffset: true 6583 }); 6584 } else if (pageNumber) { 6585 this.page = pageNumber; 6586 } 6587 if (params.has("pagemode")) { 6588 this.eventBus.dispatch("pagemode", { 6589 source: this, 6590 mode: params.get("pagemode") 6591 }); 6592 } 6593 if (params.has("nameddest")) { 6594 this.goToDestination(params.get("nameddest")); 6595 } 6596 return; 6597 } 6598 dest = unescape(hash); 6599 try { 6600 dest = JSON.parse(dest); 6601 if (!Array.isArray(dest)) { 6602 dest = dest.toString(); 6603 } 6604 } catch {} 6605 if (typeof dest === "string" || isValidExplicitDest(dest)) { 6606 this.goToDestination(dest); 6607 return; 6608 } 6609 console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not a valid destination.`); 6610 } 6611 executeNamedAction(action) { 6612 if (!this.pdfDocument) { 6613 return; 6614 } 6615 switch (action) { 6616 case "GoBack": 6617 this.pdfHistory?.back(); 6618 break; 6619 case "GoForward": 6620 this.pdfHistory?.forward(); 6621 break; 6622 case "NextPage": 6623 this.pdfViewer.nextPage(); 6624 break; 6625 case "PrevPage": 6626 this.pdfViewer.previousPage(); 6627 break; 6628 case "LastPage": 6629 this.page = this.pagesCount; 6630 break; 6631 case "FirstPage": 6632 this.page = 1; 6633 break; 6634 default: 6635 break; 6636 } 6637 this.eventBus.dispatch("namedaction", { 6638 source: this, 6639 action 6640 }); 6641 } 6642 async executeSetOCGState(action) { 6643 if (!this.pdfDocument) { 6644 return; 6645 } 6646 const pdfDocument = this.pdfDocument, 6647 optionalContentConfig = await this.pdfViewer.optionalContentConfigPromise; 6648 if (pdfDocument !== this.pdfDocument) { 6649 return; 6650 } 6651 optionalContentConfig.setOCGState(action); 6652 this.pdfViewer.optionalContentConfigPromise = Promise.resolve(optionalContentConfig); 6653 } 6654} 6655class SimpleLinkService extends PDFLinkService { 6656 setDocument(pdfDocument, baseUrl = null) {} 6657} 6658 6659// EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.constructor.js 6660var es_iterator_constructor = __webpack_require__(8111); 6661// EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.some.js 6662var es_iterator_some = __webpack_require__(3579); 6663// EXTERNAL MODULE: ./node_modules/core-js/modules/es.promise.with-resolvers.js 6664var es_promise_with_resolvers = __webpack_require__(4628); 6665// EXTERNAL MODULE: ./node_modules/core-js/modules/web.url.parse.js 6666var web_url_parse = __webpack_require__(5781); 6667;// ./web/event_utils.js 6668 6669 6670const WaitOnType = { 6671 EVENT: "event", 6672 TIMEOUT: "timeout" 6673}; 6674async function waitOnEventOrTimeout({ 6675 target, 6676 name, 6677 delay = 0 6678}) { 6679 if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
6680 throw new Error("waitOnEventOrTimeout - invalid parameters."); 6681 } 6682 const { 6683 promise, 6684 resolve 6685 } = Promise.withResolvers(); 6686 const ac = new AbortController(); 6687 function handler(type) { 6688 ac.abort(); 6689 clearTimeout(timeout); 6690 resolve(type); 6691 } 6692 const evtMethod = target instanceof EventBus ? "_on" : "addEventListener"; 6693 target[evtMethod](name, handler.bind(null, WaitOnType.EVENT), { 6694 signal: ac.signal 6695 }); 6696 const timeout = setTimeout(handler.bind(null, WaitOnType.TIMEOUT), delay); 6697 return promise; 6698} 6699class EventBus { 6700 #listeners = Object.create(null); 6701 on(eventName, listener, options = null) { 6702 this._on(eventName, listener, { 6703 external: true, 6704 once: options?.once, 6705 signal: options?.signal 6706 }); 6707 } 6708 off(eventName, listener, options = null) { 6709 this._off(eventName, listener); 6710 } 6711 dispatch(eventName, data) { 6712 const eventListeners = this.#listeners[eventName]; 6713 if (!eventListeners || eventListeners.length === 0) { 6714 return; 6715 } 6716 let externalListeners; 6717 for (const { 6718 listener, 6719 external, 6720 once 6721 } of eventListeners.slice(0)) { 6722 if (once) { 6723 this._off(eventName, listener); 6724 } 6725 if (external) { 6726 (externalListeners ||= []).push(listener); 6727 continue; 6728 } 6729 listener(data); 6730 } 6731 if (externalListeners) { 6732 for (const listener of externalListeners) { 6733 listener(data); 6734 } 6735 externalListeners = null; 6736 } 6737 } 6738 _on(eventName, listener, options = null) { 6739 let rmAbort = null; 6740 if (options?.signal instanceof AbortSignal) { 6741 const { 6742 signal 6743 } = options; 6744 if (signal.aborted) { 6745 console.error("Cannot use an `aborted` signal."); 6746 return; 6747 } 6748 const onAbort = () => this._off(eventName, listener); 6749 rmAbort = () => signal.removeEventListener("abort", onAbort); 6750 signal.addEventListener("abort", onAbort); 6751 } 6752 const eventListeners = this.#listeners[eventName] ||= []; 6753 eventListeners.push({ 6754 listener, 6755 external: options?.external === true, 6756 once: options?.once === true, 6757 rmAbort 6758 }); 6759 } 6760 _off(eventName, listener, options = null) { 6761 const eventListeners = this.#listeners[eventName]; 6762 if (!eventListeners) { 6763 return; 6764 } 6765 for (let i = 0, ii = eventListeners.length; i < ii; i++) { 6766 const evt = eventListeners[i]; 6767 if (evt.listener === listener) { 6768 evt.rmAbort?.(); 6769 eventListeners.splice(i, 1); 6770 return; 6771 } 6772 } 6773 } 6774} 6775class FirefoxEventBus extends EventBus { 6776 #externalServices; 6777 #globalEventNames; 6778 #isInAutomation; 6779 constructor(globalEventNames, externalServices, isInAutomation) { 6780 super(); 6781 this.#globalEventNames = globalEventNames; 6782 this.#externalServices = externalServices; 6783 this.#isInAutomation = isInAutomation; 6784 } 6785 dispatch(eventName, data) { 6786 throw new Error("Not implemented: FirefoxEventBus.dispatch"); 6787 } 6788} 6789 6790;// ./web/external_services.js 6791class BaseExternalServices { 6792 updateFindControlState(data) {} 6793 updateFindMatchesCount(data) {} 6794 initPassiveLoading() {} 6795 reportTelemetry(data) {} 6796 reportText(data) {} 6797 async createL10n() { 6798 throw new Error("Not implemented: createL10n"); 6799 } 6800 createScripting() { 6801 throw new Error("Not implemented: createScripting"); 6802 } 6803 createSignatureStorage() { 6804 throw new Error("Not implemented: createSignatureStorage"); 6805 } 6806 updateEditorStates(data) { 6807 throw new Error("Not implemented: updateEditorStates"); 6808 } 6809 dispatchGlobalEvent(_event) {} 6810} 6811 6812;// ./web/preferences.js 6813 6814class BasePreferences { 6815 #defaults = Object.freeze(AppOptions.getAll(OptionKind.PREFERENCE, true)); 6816 #initializedPromise = null; 6817 constructor() { 6818 this.#initializedPromise = this._readFromStorage(this.#defaults).then(({ 6819 browserPrefs, 6820 prefs 6821 }) => { 6822 if (AppOptions._checkDisablePreferences()) { 6823 return; 6824 } 6825 AppOptions.setAll({ 6826 ...browserPrefs, 6827 ...prefs 6828 }, true); 6829 }); 6830 } 6831 async _writeToStorage(prefObj) { 6832 throw new Error("Not implemented: _writeToStorage"); 6833 } 6834 async _readFromStorage(prefObj) { 6835 throw new Error("Not implemented: _readFromStorage"); 6836 } 6837 async reset() { 6838 await this.#initializedPromise; 6839 AppOptions.setAll(this.#defaults, true); 6840 await this._writeToStorage(this.#defaults); 6841 } 6842 async set(name, value) { 6843 await this.#initializedPromise; 6844 AppOptions.setAll({
vendor: 20,922 bytes, lines 6845-7595
6845 [name]: value 6846 }, true); 6847 await this._writeToStorage(AppOptions.getAll(OptionKind.PREFERENCE)); 6848 } 6849 async get(name) { 6850 await this.#initializedPromise; 6851 return AppOptions.get(name); 6852 } 6853 get defaults() { 6854 return this.#defaults; 6855 } 6856 get initializedPromise() { 6857 return this.#initializedPromise; 6858 } 6859} 6860 6861;// ./node_modules/@fluent/bundle/esm/types.js 6862class FluentType { 6863 constructor(value) { 6864 this.value = value; 6865 } 6866 valueOf() { 6867 return this.value; 6868 } 6869} 6870class FluentNone extends FluentType { 6871 constructor(value = "???") { 6872 super(value); 6873 } 6874 toString(scope) { 6875 return `{${this.value}}`; 6876 } 6877} 6878class FluentNumber extends FluentType { 6879 constructor(value, opts = {}) { 6880 super(value); 6881 this.opts = opts; 6882 } 6883 toString(scope) { 6884 if (scope) { 6885 try { 6886 const nf = scope.memoizeIntlObject(Intl.NumberFormat, this.opts); 6887 return nf.format(this.value); 6888 } catch (err) { 6889 scope.reportError(err); 6890 } 6891 } 6892 return this.value.toString(10); 6893 } 6894} 6895class FluentDateTime extends FluentType { 6896 static supportsValue(value) { 6897 if (typeof value === "number") return true; 6898 if (value instanceof Date) return true; 6899 if (value instanceof FluentType) return FluentDateTime.supportsValue(value.valueOf()); 6900 if ("Temporal" in globalThis) { 6901 const _Temporal = globalThis.Temporal; 6902 if (value instanceof _Temporal.Instant || value instanceof _Temporal.PlainDateTime || value instanceof _Temporal.PlainDate || value instanceof _Temporal.PlainMonthDay || value instanceof _Temporal.PlainTime || value instanceof _Temporal.PlainYearMonth) { 6903 return true; 6904 } 6905 } 6906 return false; 6907 } 6908 constructor(value, opts = {}) { 6909 if (value instanceof FluentDateTime) { 6910 opts = { 6911 ...value.opts, 6912 ...opts 6913 }; 6914 value = value.value; 6915 } else if (value instanceof FluentType) { 6916 value = value.valueOf(); 6917 } 6918 if (typeof value === "object" && "calendarId" in value && opts.calendar === undefined) { 6919 opts = { 6920 ...opts, 6921 calendar: value.calendarId 6922 }; 6923 } 6924 super(value); 6925 this.opts = opts; 6926 } 6927 [Symbol.toPrimitive](hint) { 6928 return hint === "string" ? this.toString() : this.toNumber(); 6929 } 6930 toNumber() { 6931 const value = this.value; 6932 if (typeof value === "number") return value; 6933 if (value instanceof Date) return value.getTime(); 6934 if ("epochMilliseconds" in value) { 6935 return value.epochMilliseconds; 6936 } 6937 if ("toZonedDateTime" in value) { 6938 return value.toZonedDateTime("UTC").epochMilliseconds; 6939 } 6940 throw new TypeError("Unwrapping a non-number value as a number"); 6941 } 6942 toString(scope) { 6943 if (scope) { 6944 try { 6945 const dtf = scope.memoizeIntlObject(Intl.DateTimeFormat, this.opts); 6946 return dtf.format(this.value); 6947 } catch (err) { 6948 scope.reportError(err); 6949 } 6950 } 6951 if (typeof this.value === "number" || this.value instanceof Date) { 6952 return new Date(this.value).toISOString(); 6953 } 6954 return this.value.toString(); 6955 } 6956} 6957;// ./node_modules/@fluent/bundle/esm/resolver.js 6958 6959 6960const MAX_PLACEABLES = 100; 6961const FSI = "\u2068"; 6962const PDI = "\u2069"; 6963function match(scope, selector, key) { 6964 if (key === selector) { 6965 return true; 6966 } 6967 if (key instanceof FluentNumber && selector instanceof FluentNumber && key.value === selector.value) { 6968 return true; 6969 } 6970 if (selector instanceof FluentNumber && typeof key === "string") { 6971 let category = scope.memoizeIntlObject(Intl.PluralRules, selector.opts).select(selector.value); 6972 if (key === category) { 6973 return true; 6974 } 6975 } 6976 return false; 6977} 6978function getDefault(scope, variants, star) { 6979 if (variants[star]) { 6980 return resolvePattern(scope, variants[star].value); 6981 } 6982 scope.reportError(new RangeError("No default")); 6983 return new FluentNone(); 6984} 6985function getArguments(scope, args) { 6986 const positional = []; 6987 const named = Object.create(null); 6988 for (const arg of args) { 6989 if (arg.type === "narg") { 6990 named[arg.name] = resolveExpression(scope, arg.value); 6991 } else { 6992 positional.push(resolveExpression(scope, arg)); 6993 } 6994 } 6995 return { 6996 positional, 6997 named 6998 }; 6999} 7000function resolveExpression(scope, expr) { 7001 switch (expr.type) { 7002 case "str": 7003 return expr.value; 7004 case "num": 7005 return new FluentNumber(expr.value, { 7006 minimumFractionDigits: expr.precision 7007 }); 7008 case "var": 7009 return resolveVariableReference(scope, expr); 7010 case "mesg": 7011 return resolveMessageReference(scope, expr); 7012 case "term": 7013 return resolveTermReference(scope, expr); 7014 case "func": 7015 return resolveFunctionReference(scope, expr); 7016 case "select": 7017 return resolveSelectExpression(scope, expr); 7018 default: 7019 return new FluentNone(); 7020 } 7021} 7022function resolveVariableReference(scope, { 7023 name 7024}) { 7025 let arg; 7026 if (scope.params) { 7027 if (Object.prototype.hasOwnProperty.call(scope.params, name)) { 7028 arg = scope.params[name]; 7029 } else { 7030 return new FluentNone(`$${name}`); 7031 } 7032 } else if (scope.args && Object.prototype.hasOwnProperty.call(scope.args, name)) { 7033 arg = scope.args[name]; 7034 } else { 7035 scope.reportError(new ReferenceError(`Unknown variable: $${name}`)); 7036 return new FluentNone(`$${name}`); 7037 } 7038 if (arg instanceof FluentType) { 7039 return arg; 7040 } 7041 switch (typeof arg) { 7042 case "string": 7043 return arg; 7044 case "number": 7045 return new FluentNumber(arg); 7046 case "object": 7047 if (FluentDateTime.supportsValue(arg)) { 7048 return new FluentDateTime(arg); 7049 } 7050 default: 7051 scope.reportError(new TypeError(`Variable type not supported: $${name}, ${typeof arg}`)); 7052 return new FluentNone(`$${name}`); 7053 } 7054} 7055function resolveMessageReference(scope, { 7056 name, 7057 attr 7058}) { 7059 const message = scope.bundle._messages.get(name); 7060 if (!message) { 7061 scope.reportError(new ReferenceError(`Unknown message: ${name}`)); 7062 return new FluentNone(name); 7063 } 7064 if (attr) { 7065 const attribute = message.attributes[attr]; 7066 if (attribute) { 7067 return resolvePattern(scope, attribute); 7068 } 7069 scope.reportError(new ReferenceError(`Unknown attribute: ${attr}`)); 7070 return new FluentNone(`${name}.${attr}`); 7071 } 7072 if (message.value) { 7073 return resolvePattern(scope, message.value); 7074 } 7075 scope.reportError(new ReferenceError(`No value: ${name}`)); 7076 return new FluentNone(name); 7077} 7078function resolveTermReference(scope, { 7079 name, 7080 attr, 7081 args 7082}) { 7083 const id = `-${name}`; 7084 const term = scope.bundle._terms.get(id); 7085 if (!term) { 7086 scope.reportError(new ReferenceError(`Unknown term: ${id}`)); 7087 return new FluentNone(id); 7088 } 7089 if (attr) { 7090 const attribute = term.attributes[attr]; 7091 if (attribute) { 7092 scope.params = getArguments(scope, args).named; 7093 const resolved = resolvePattern(scope, attribute); 7094 scope.params = null; 7095 return resolved; 7096 } 7097 scope.reportError(new ReferenceError(`Unknown attribute: ${attr}`)); 7098 return new FluentNone(`${id}.${attr}`); 7099 } 7100 scope.params = getArguments(scope, args).named; 7101 const resolved = resolvePattern(scope, term.value); 7102 scope.params = null; 7103 return resolved; 7104} 7105function resolveFunctionReference(scope, { 7106 name, 7107 args 7108}) { 7109 let func = scope.bundle._functions[name]; 7110 if (!func) { 7111 scope.reportError(new ReferenceError(`Unknown function: ${name}()`)); 7112 return new FluentNone(`${name}()`); 7113 } 7114 if (typeof func !== "function") { 7115 scope.reportError(new TypeError(`Function ${name}() is not callable`)); 7116 return new FluentNone(`${name}()`); 7117 } 7118 try { 7119 let resolved = getArguments(scope, args); 7120 return func(resolved.positional, resolved.named); 7121 } catch (err) { 7122 scope.reportError(err); 7123 return new FluentNone(`${name}()`); 7124 } 7125} 7126function resolveSelectExpression(scope, { 7127 selector, 7128 variants, 7129 star 7130}) { 7131 let sel = resolveExpression(scope, selector); 7132 if (sel instanceof FluentNone) { 7133 return getDefault(scope, variants, star); 7134 } 7135 for (const variant of variants) { 7136 const key = resolveExpression(scope, variant.key); 7137 if (match(scope, sel, key)) { 7138 return resolvePattern(scope, variant.value); 7139 } 7140 } 7141 return getDefault(scope, variants, star); 7142} 7143function resolveComplexPattern(scope, ptn) { 7144 if (scope.dirty.has(ptn)) { 7145 scope.reportError(new RangeError("Cyclic reference")); 7146 return new FluentNone(); 7147 } 7148 scope.dirty.add(ptn); 7149 const result = []; 7150 const useIsolating = scope.bundle._useIsolating && ptn.length > 1; 7151 for (const elem of ptn) { 7152 if (typeof elem === "string") { 7153 result.push(scope.bundle._transform(elem)); 7154 continue; 7155 } 7156 scope.placeables++; 7157 if (scope.placeables > MAX_PLACEABLES) { 7158 scope.dirty.delete(ptn); 7159 throw new RangeError(`Too many placeables expanded: ${scope.placeables}, ` + `max allowed is ${MAX_PLACEABLES}`); 7160 } 7161 if (useIsolating) { 7162 result.push(FSI); 7163 } 7164 result.push(resolveExpression(scope, elem).toString(scope)); 7165 if (useIsolating) { 7166 result.push(PDI); 7167 } 7168 } 7169 scope.dirty.delete(ptn); 7170 return result.join(""); 7171} 7172function resolvePattern(scope, value) { 7173 if (typeof value === "string") { 7174 return scope.bundle._transform(value); 7175 } 7176 return resolveComplexPattern(scope, value); 7177} 7178;// ./node_modules/@fluent/bundle/esm/scope.js 7179 7180 7181class Scope { 7182 constructor(bundle, errors, args) { 7183 this.dirty = new WeakSet(); 7184 this.params = null; 7185 this.placeables = 0; 7186 this.bundle = bundle; 7187 this.errors = errors; 7188 this.args = args; 7189 } 7190 reportError(error) { 7191 if (!this.errors || !(error instanceof Error)) { 7192 throw error; 7193 } 7194 this.errors.push(error); 7195 } 7196 memoizeIntlObject(ctor, opts) { 7197 let cache = this.bundle._intls.get(ctor); 7198 if (!cache) { 7199 cache = {}; 7200 this.bundle._intls.set(ctor, cache); 7201 } 7202 let id = JSON.stringify(opts); 7203 if (!cache[id]) { 7204 cache[id] = new ctor(this.bundle.locales, opts); 7205 } 7206 return cache[id]; 7207 } 7208} 7209;// ./node_modules/@fluent/bundle/esm/builtins.js 7210 7211function values(opts, allowed) { 7212 const unwrapped = Object.create(null); 7213 for (const [name, opt] of Object.entries(opts)) { 7214 if (allowed.includes(name)) { 7215 unwrapped[name] = opt.valueOf(); 7216 } 7217 } 7218 return unwrapped; 7219} 7220const NUMBER_ALLOWED = ["unitDisplay", "currencyDisplay", "useGrouping", "minimumIntegerDigits", "minimumFractionDigits", "maximumFractionDigits", "minimumSignificantDigits", "maximumSignificantDigits"]; 7221function NUMBER(args, opts) { 7222 let arg = args[0]; 7223 if (arg instanceof FluentNone) { 7224 return new FluentNone(`NUMBER(${arg.valueOf()})`); 7225 } 7226 if (arg instanceof FluentNumber) { 7227 return new FluentNumber(arg.valueOf(), { 7228 ...arg.opts, 7229 ...values(opts, NUMBER_ALLOWED) 7230 }); 7231 } 7232 if (arg instanceof FluentDateTime) { 7233 return new FluentNumber(arg.toNumber(), { 7234 ...values(opts, NUMBER_ALLOWED) 7235 }); 7236 } 7237 throw new TypeError("Invalid argument to NUMBER"); 7238} 7239const DATETIME_ALLOWED = ["dateStyle", "timeStyle", "fractionalSecondDigits", "dayPeriod", "hour12", "weekday", "era", "year", "month", "day", "hour", "minute", "second", "timeZoneName"]; 7240function DATETIME(args, opts) { 7241 let arg = args[0]; 7242 if (arg instanceof FluentNone) { 7243 return new FluentNone(`DATETIME(${arg.valueOf()})`); 7244 } 7245 if (arg instanceof FluentDateTime || arg instanceof FluentNumber) { 7246 return new FluentDateTime(arg, values(opts, DATETIME_ALLOWED)); 7247 } 7248 throw new TypeError("Invalid argument to DATETIME"); 7249} 7250;// ./node_modules/@fluent/bundle/esm/memoizer.js 7251 7252 7253const cache = new Map(); 7254function getMemoizerForLocale(locales) { 7255 const stringLocale = Array.isArray(locales) ? locales.join(" ") : locales; 7256 let memoizer = cache.get(stringLocale); 7257 if (memoizer === undefined) { 7258 memoizer = new Map(); 7259 cache.set(stringLocale, memoizer); 7260 } 7261 return memoizer; 7262} 7263;// ./node_modules/@fluent/bundle/esm/bundle.js 7264 7265 7266 7267 7268 7269 7270 7271 7272class FluentBundle { 7273 constructor(locales, { 7274 functions, 7275 useIsolating = true, 7276 transform = v => v 7277 } = {}) { 7278 this._terms = new Map(); 7279 this._messages = new Map(); 7280 this.locales = Array.isArray(locales) ? locales : [locales]; 7281 this._functions = { 7282 NUMBER: NUMBER, 7283 DATETIME: DATETIME, 7284 ...functions 7285 }; 7286 this._useIsolating = useIsolating; 7287 this._transform = transform; 7288 this._intls = getMemoizerForLocale(locales); 7289 } 7290 hasMessage(id) { 7291 return this._messages.has(id); 7292 } 7293 getMessage(id) { 7294 return this._messages.get(id); 7295 } 7296 addResource(res, { 7297 allowOverrides = false 7298 } = {}) { 7299 const errors = []; 7300 for (let i = 0; i < res.body.length; i++) { 7301 let entry = res.body[i]; 7302 if (entry.id.startsWith("-")) { 7303 if (allowOverrides === false && this._terms.has(entry.id)) { 7304 errors.push(new Error(`Attempt to override an existing term: "${entry.id}"`)); 7305 continue; 7306 } 7307 this._terms.set(entry.id, entry); 7308 } else { 7309 if (allowOverrides === false && this._messages.has(entry.id)) { 7310 errors.push(new Error(`Attempt to override an existing message: "${entry.id}"`)); 7311 continue; 7312 } 7313 this._messages.set(entry.id, entry); 7314 } 7315 } 7316 return errors; 7317 } 7318 formatPattern(pattern, args = null, errors = null) { 7319 if (typeof pattern === "string") { 7320 return this._transform(pattern); 7321 } 7322 let scope = new Scope(this, errors, args); 7323 try { 7324 let value = resolveComplexPattern(scope, pattern); 7325 return value.toString(scope); 7326 } catch (err) { 7327 if (scope.errors && err instanceof Error) { 7328 scope.errors.push(err); 7329 return new FluentNone().toString(scope); 7330 } 7331 throw err; 7332 } 7333 } 7334} 7335;// ./node_modules/@fluent/bundle/esm/resource.js 7336 7337const RE_MESSAGE_START = /^(-?[a-zA-Z][\w-]*) *= */gm; 7338const RE_ATTRIBUTE_START = /\.([a-zA-Z][\w-]*) *= */y; 7339const RE_VARIANT_START = /\*?\[/y; 7340const RE_NUMBER_LITERAL = /(-?[0-9]+(?:\.([0-9]+))?)/y; 7341const RE_IDENTIFIER = /([a-zA-Z][\w-]*)/y; 7342const RE_REFERENCE = /([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y; 7343const RE_FUNCTION_NAME = /^[A-Z][A-Z0-9_-]*$/; 7344const RE_TEXT_RUN = /([^{}\n\r]+)/y; 7345const RE_STRING_RUN = /([^\\"\n\r]*)/y; 7346const RE_STRING_ESCAPE = /\\([\\"])/y; 7347const RE_UNICODE_ESCAPE = /\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y; 7348const RE_LEADING_NEWLINES = /^\n+/; 7349const RE_TRAILING_SPACES = / +$/; 7350const RE_BLANK_LINES = / *\r?\n/g; 7351const RE_INDENT = /( *)$/; 7352const TOKEN_BRACE_OPEN = /{\s*/y; 7353const TOKEN_BRACE_CLOSE = /\s*}/y; 7354const TOKEN_BRACKET_OPEN = /\[\s*/y; 7355const TOKEN_BRACKET_CLOSE = /\s*] */y; 7356const TOKEN_PAREN_OPEN = /\s*\(\s*/y; 7357const TOKEN_ARROW = /\s*->\s*/y; 7358const TOKEN_COLON = /\s*:\s*/y; 7359const TOKEN_COMMA = /\s*,?\s*/y; 7360const TOKEN_BLANK = /\s+/y; 7361class FluentResource { 7362 constructor(source) { 7363 this.body = []; 7364 RE_MESSAGE_START.lastIndex = 0; 7365 let cursor = 0; 7366 while (true) { 7367 let next = RE_MESSAGE_START.exec(source); 7368 if (next === null) { 7369 break; 7370 } 7371 cursor = RE_MESSAGE_START.lastIndex; 7372 try { 7373 this.body.push(parseMessage(next[1])); 7374 } catch (err) { 7375 if (err instanceof SyntaxError) { 7376 continue; 7377 } 7378 throw err; 7379 } 7380 } 7381 function test(re) { 7382 re.lastIndex = cursor; 7383 return re.test(source); 7384 } 7385 function consumeChar(char, errorClass) { 7386 if (source[cursor] === char) { 7387 cursor++; 7388 return true; 7389 } 7390 if (errorClass) { 7391 throw new errorClass(`Expected ${char}`); 7392 } 7393 return false; 7394 } 7395 function consumeToken(re, errorClass) { 7396 if (test(re)) { 7397 cursor = re.lastIndex; 7398 return true; 7399 } 7400 if (errorClass) { 7401 throw new errorClass(`Expected ${re.toString()}`); 7402 } 7403 return false; 7404 } 7405 function match(re) { 7406 re.lastIndex = cursor; 7407 let result = re.exec(source); 7408 if (result === null) { 7409 throw new SyntaxError(`Expected ${re.toString()}`); 7410 } 7411 cursor = re.lastIndex; 7412 return result; 7413 } 7414 function match1(re) { 7415 return match(re)[1]; 7416 } 7417 function parseMessage(id) { 7418 let value = parsePattern(); 7419 let attributes = parseAttributes(); 7420 if (value === null && Object.keys(attributes).length === 0) { 7421 throw new SyntaxError("Expected message value or attributes"); 7422 } 7423 return { 7424 id, 7425 value, 7426 attributes 7427 }; 7428 } 7429 function parseAttributes() { 7430 let attrs = Object.create(null); 7431 while (test(RE_ATTRIBUTE_START)) { 7432 let name = match1(RE_ATTRIBUTE_START); 7433 let value = parsePattern(); 7434 if (value === null) { 7435 throw new SyntaxError("Expected attribute value"); 7436 } 7437 attrs[name] = value; 7438 } 7439 return attrs; 7440 } 7441 function parsePattern() { 7442 let first; 7443 if (test(RE_TEXT_RUN)) { 7444 first = match1(RE_TEXT_RUN); 7445 } 7446 if (source[cursor] === "{" || source[cursor] === "}") { 7447 return parsePatternElements(first ? [first] : [], Infinity); 7448 } 7449 let indent = parseIndent(); 7450 if (indent) { 7451 if (first) { 7452 return parsePatternElements([first, indent], indent.length); 7453 } 7454 indent.value = trim(indent.value, RE_LEADING_NEWLINES); 7455 return parsePatternElements([indent], indent.length); 7456 } 7457 if (first) { 7458 return trim(first, RE_TRAILING_SPACES); 7459 } 7460 return null; 7461 } 7462 function parsePatternElements(elements = [], commonIndent) { 7463 while (true) { 7464 if (test(RE_TEXT_RUN)) { 7465 elements.push(match1(RE_TEXT_RUN)); 7466 continue; 7467 } 7468 if (source[cursor] === "{") { 7469 elements.push(parsePlaceable()); 7470 continue; 7471 } 7472 if (source[cursor] === "}") { 7473 throw new SyntaxError("Unbalanced closing brace"); 7474 } 7475 let indent = parseIndent(); 7476 if (indent) { 7477 elements.push(indent); 7478 commonIndent = Math.min(commonIndent, indent.length); 7479 continue; 7480 } 7481 break; 7482 } 7483 let lastIndex = elements.length - 1; 7484 let lastElement = elements[lastIndex]; 7485 if (typeof lastElement === "string") { 7486 elements[lastIndex] = trim(lastElement, RE_TRAILING_SPACES); 7487 } 7488 let baked = []; 7489 for (let element of elements) { 7490 if (element instanceof Indent) { 7491 element = element.value.slice(0, element.value.length - commonIndent); 7492 } 7493 if (element) { 7494 baked.push(element); 7495 } 7496 } 7497 return baked; 7498 } 7499 function parsePlaceable() { 7500 consumeToken(TOKEN_BRACE_OPEN, SyntaxError); 7501 let selector = parseInlineExpression(); 7502 if (consumeToken(TOKEN_BRACE_CLOSE)) { 7503 return selector; 7504 } 7505 if (consumeToken(TOKEN_ARROW)) { 7506 let variants = parseVariants(); 7507 consumeToken(TOKEN_BRACE_CLOSE, SyntaxError); 7508 return { 7509 type: "select", 7510 selector, 7511 ...variants 7512 }; 7513 } 7514 throw new SyntaxError("Unclosed placeable"); 7515 } 7516 function parseInlineExpression() { 7517 if (source[cursor] === "{") { 7518 return parsePlaceable(); 7519 } 7520 if (test(RE_REFERENCE)) { 7521 let [, sigil, name, attr = null] = match(RE_REFERENCE); 7522 if (sigil === "$") { 7523 return { 7524 type: "var", 7525 name 7526 }; 7527 } 7528 if (consumeToken(TOKEN_PAREN_OPEN)) { 7529 let args = parseArguments(); 7530 if (sigil === "-") { 7531 return { 7532 type: "term", 7533 name, 7534 attr, 7535 args 7536 }; 7537 } 7538 if (RE_FUNCTION_NAME.test(name)) { 7539 return { 7540 type: "func", 7541 name, 7542 args 7543 }; 7544 } 7545 throw new SyntaxError("Function names must be all upper-case"); 7546 } 7547 if (sigil === "-") { 7548 return { 7549 type: "term", 7550 name, 7551 attr, 7552 args: [] 7553 }; 7554 } 7555 return { 7556 type: "mesg", 7557 name, 7558 attr 7559 }; 7560 } 7561 return parseLiteral(); 7562 } 7563 function parseArguments() { 7564 let args = []; 7565 while (true) { 7566 switch (source[cursor]) { 7567 case ")": 7568 cursor++; 7569 return args; 7570 case undefined: 7571 throw new SyntaxError("Unclosed argument list"); 7572 } 7573 args.push(parseArgument()); 7574 consumeToken(TOKEN_COMMA); 7575 } 7576 } 7577 function parseArgument() { 7578 let expr = parseInlineExpression(); 7579 if (expr.type !== "mesg") { 7580 return expr; 7581 } 7582 if (consumeToken(TOKEN_COLON)) { 7583 return { 7584 type: "narg", 7585 name: expr.name, 7586 value: parseLiteral() 7587 }; 7588 } 7589 return expr; 7590 } 7591 function parseVariants() { 7592 let variants = []; 7593 let count = 0; 7594 let star; 7595 while (test(RE_VARIANT_START)) {
7596 if (consumeChar("*")) { 7597 star = count; 7598 } 7599 let key = parseVariantKey(); 7600 let value = parsePattern(); 7601 if (value === null) { 7602 throw new SyntaxError("Expected variant value"); 7603 } 7604 variants[count++] = { 7605 key, 7606 value 7607 }; 7608 } 7609 if (count === 0) { 7610 return null; 7611 } 7612 if (star === undefined) { 7613 throw new SyntaxError("Expected default variant"); 7614 } 7615 return { 7616 variants, 7617 star 7618 }; 7619 } 7620 function parseVariantKey() { 7621 consumeToken(TOKEN_BRACKET_OPEN, SyntaxError); 7622 let key; 7623 if (test(RE_NUMBER_LITERAL)) { 7624 key = parseNumberLiteral(); 7625 } else { 7626 key = { 7627 type: "str", 7628 value: match1(RE_IDENTIFIER) 7629 }; 7630 } 7631 consumeToken(TOKEN_BRACKET_CLOSE, SyntaxError); 7632 return key; 7633 } 7634 function parseLiteral() { 7635 if (test(RE_NUMBER_LITERAL)) { 7636 return parseNumberLiteral(); 7637 } 7638 if (source[cursor] === '"') { 7639 return parseStringLiteral(); 7640 } 7641 throw new SyntaxError("Invalid expression"); 7642 } 7643 function parseNumberLiteral() { 7644 let [, value, fraction = ""] = match(RE_NUMBER_LITERAL); 7645 let precision = fraction.length; 7646 return { 7647 type: "num", 7648 value: parseFloat(value), 7649 precision 7650 }; 7651 } 7652 function parseStringLiteral() { 7653 consumeChar('"', SyntaxError); 7654 let value = ""; 7655 while (true) { 7656 value += match1(RE_STRING_RUN); 7657 if (source[cursor] === "\\") { 7658 value += parseEscapeSequence(); 7659 continue; 7660 } 7661 if (consumeChar('"')) { 7662 return { 7663 type: "str", 7664 value 7665 }; 7666 } 7667 throw new SyntaxError("Unclosed string literal"); 7668 } 7669 } 7670 function parseEscapeSequence() { 7671 if (test(RE_STRING_ESCAPE)) { 7672 return match1(RE_STRING_ESCAPE); 7673 } 7674 if (test(RE_UNICODE_ESCAPE)) { 7675 let [, codepoint4, codepoint6] = match(RE_UNICODE_ESCAPE); 7676 let codepoint = parseInt(codepoint4 || codepoint6, 16); 7677 return codepoint <= 0xd7ff || 0xe000 <= codepoint ? String.fromCodePoint(codepoint) : "�"; 7678 } 7679 throw new SyntaxError("Unknown escape sequence"); 7680 } 7681 function parseIndent() { 7682 let start = cursor; 7683 consumeToken(TOKEN_BLANK); 7684 switch (source[cursor]) { 7685 case ".": 7686 case "[": 7687 case "*": 7688 case "}": 7689 case undefined: 7690 return false; 7691 case "{": 7692 return makeIndent(source.slice(start, cursor)); 7693 } 7694 if (source[cursor - 1] === " ") { 7695 return makeIndent(source.slice(start, cursor)); 7696 } 7697 return false; 7698 } 7699 function trim(text, re) { 7700 return text.replace(re, ""); 7701 } 7702 function makeIndent(blank) { 7703 let value = blank.replace(RE_BLANK_LINES, "\n"); 7704 let length = RE_INDENT.exec(blank)[1].length; 7705 return new Indent(value, length); 7706 } 7707 } 7708} 7709class Indent { 7710 constructor(value, length) { 7711 this.value = value; 7712 this.length = length; 7713 } 7714} 7715;// ./node_modules/@fluent/bundle/esm/index.js 7716 7717 7718 7719// EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.map.js 7720var es_iterator_map = __webpack_require__(1701); 7721;// ./node_modules/@fluent/dom/esm/overlay.js 7722 7723 7724const reOverlay = /<|&#?\w+;/; 7725const TEXT_LEVEL_ELEMENTS = { 7726 "http://www.w3.org/1999/xhtml": ["em", "strong", "small", "s", "cite", "q", "dfn", "abbr", "data", "time", "code", "var", "samp", "kbd", "sub", "sup", "i", "b", "u", "mark", "bdi", "bdo", "span", "br", "wbr"] 7727}; 7728const LOCALIZABLE_ATTRIBUTES = { 7729 "http://www.w3.org/1999/xhtml": { 7730 global: ["title", "aria-description", "aria-label", "aria-valuetext"], 7731 a: ["download"], 7732 area: ["download", "alt"], 7733 input: ["alt", "placeholder"], 7734 menuitem: ["label"], 7735 menu: ["label"], 7736 optgroup: ["label"], 7737 option: ["label"], 7738 track: ["label"], 7739 img: ["alt"], 7740 textarea: ["placeholder"], 7741 th: ["abbr"] 7742 }, 7743 "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul": { 7744 global: ["accesskey", "aria-label", "aria-valuetext", "label", "title", "tooltiptext"], 7745 description: ["value"], 7746 key: ["key", "keycode"], 7747 label: ["value"], 7748 textbox: ["placeholder", "value"] 7749 } 7750}; 7751function translateElement(element, translation) { 7752 const { 7753 value 7754 } = translation; 7755 if (typeof value === "string") { 7756 if (element.localName === "title" && element.namespaceURI === "http://www.w3.org/1999/xhtml") { 7757 element.textContent = value; 7758 } else if (!reOverlay.test(value)) { 7759 element.textContent = value; 7760 } else { 7761 const templateElement = element.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml", "template"); 7762 templateElement.innerHTML = value; 7763 overlayChildNodes(templateElement.content, element); 7764 } 7765 } 7766 overlayAttributes(translation, element); 7767} 7768function overlayChildNodes(fromFragment, toElement) { 7769 for (const childNode of fromFragment.childNodes) { 7770 if (childNode.nodeType === childNode.TEXT_NODE) { 7771 continue; 7772 } 7773 if (childNode.hasAttribute("data-l10n-name")) { 7774 const sanitized = getNodeForNamedElement(toElement, childNode); 7775 fromFragment.replaceChild(sanitized, childNode); 7776 continue; 7777 } 7778 if (isElementAllowed(childNode)) { 7779 const sanitized = createSanitizedElement(childNode); 7780 fromFragment.replaceChild(sanitized, childNode); 7781 continue; 7782 } 7783 console.warn(`An element of forbidden type "${childNode.localName}" was found in ` + "the translation. Only safe text-level elements and elements with " + "data-l10n-name are allowed."); 7784 fromFragment.replaceChild(createTextNodeFromTextContent(childNode), childNode); 7785 } 7786 toElement.textContent = ""; 7787 toElement.appendChild(fromFragment); 7788} 7789function hasAttribute(attributes, name) { 7790 if (!attributes) { 7791 return false;
7792 } 7793 for (let attr of attributes) { 7794 if (attr.name === name) { 7795 return true; 7796 } 7797 } 7798 return false; 7799} 7800function overlayAttributes(fromElement, toElement) { 7801 const explicitlyAllowed = toElement.hasAttribute("data-l10n-attrs") ? toElement.getAttribute("data-l10n-attrs").split(",").map(i => i.trim()) : null; 7802 for (const attr of Array.from(toElement.attributes)) { 7803 if (isAttrNameLocalizable(attr.name, toElement, explicitlyAllowed) && !hasAttribute(fromElement.attributes, attr.name)) { 7804 toElement.removeAttribute(attr.name); 7805 } 7806 } 7807 if (!fromElement.attributes) { 7808 return; 7809 } 7810 for (const attr of Array.from(fromElement.attributes)) { 7811 if (isAttrNameLocalizable(attr.name, toElement, explicitlyAllowed) && toElement.getAttribute(attr.name) !== attr.value) { 7812 toElement.setAttribute(attr.name, attr.value); 7813 } 7814 } 7815} 7816function getNodeForNamedElement(sourceElement, translatedChild) { 7817 const childName = translatedChild.getAttribute("data-l10n-name"); 7818 const sourceChild = sourceElement.querySelector(`[data-l10n-name="${childName}"]`); 7819 if (!sourceChild) { 7820 console.warn(`An element named "${childName}" wasn't found in the source.`); 7821 return createTextNodeFromTextContent(translatedChild); 7822 } 7823 if (sourceChild.localName !== translatedChild.localName) { 7824 console.warn(`An element named "${childName}" was found in the translation ` + `but its type ${translatedChild.localName} didn't match the ` + `element found in the source (${sourceChild.localName}).`); 7825 return createTextNodeFromTextContent(translatedChild); 7826 } 7827 sourceElement.removeChild(sourceChild); 7828 const clone = sourceChild.cloneNode(false); 7829 return shallowPopulateUsing(translatedChild, clone); 7830} 7831function createSanitizedElement(element) { 7832 const clone = element.ownerDocument.createElement(element.localName); 7833 return shallowPopulateUsing(element, clone); 7834} 7835function createTextNodeFromTextContent(element) { 7836 return element.ownerDocument.createTextNode(element.textContent); 7837} 7838function isElementAllowed(element) { 7839 const allowed = TEXT_LEVEL_ELEMENTS[element.namespaceURI]; 7840 return allowed && allowed.includes(element.localName); 7841} 7842function isAttrNameLocalizable(name, element, explicitlyAllowed = null) { 7843 if (explicitlyAllowed && explicitlyAllowed.includes(name)) { 7844 return true; 7845 } 7846 const allowed = LOCALIZABLE_ATTRIBUTES[element.namespaceURI]; 7847 if (!allowed) { 7848 return false; 7849 } 7850 const attrName = name.toLowerCase(); 7851 const elemName = element.localName; 7852 if (allowed.global.includes(attrName)) { 7853 return true; 7854 } 7855 if (!allowed[elemName]) { 7856 return false; 7857 } 7858 if (allowed[elemName].includes(attrName)) { 7859 return true; 7860 } 7861 if (element.namespaceURI === "http://www.w3.org/1999/xhtml" && elemName === "input" && attrName === "value") { 7862 const type = element.type.toLowerCase(); 7863 if (type === "submit" || type === "button" || type === "reset") { 7864 return true; 7865 } 7866 } 7867 return false; 7868} 7869function shallowPopulateUsing(fromElement, toElement) { 7870 toElement.textContent = fromElement.textContent; 7871 overlayAttributes(fromElement, toElement); 7872 return toElement; 7873} 7874// EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.filter.js 7875var es_iterator_filter = __webpack_require__(2489); 7876// EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.for-each.js 7877var es_iterator_for_each = __webpack_require__(7588); 7878;// ./node_modules/cached-iterable/src/cached_iterable.mjs 7879class CachedIterable extends Array { 7880 static from(iterable) { 7881 if (iterable instanceof this) { 7882 return iterable; 7883 } 7884 return new this(iterable); 7885 } 7886} 7887;// ./node_modules/cached-iterable/src/cached_sync_iterable.mjs 7888 7889 7890class CachedSyncIterable extends CachedIterable { 7891 constructor(iterable) { 7892 super(); 7893 if (Symbol.iterator in Object(iterable)) { 7894 this.iterator = iterable[Symbol.iterator](); 7895 } else { 7896 throw new TypeError("Argument must implement the iteration protocol."); 7897 } 7898 } 7899 [Symbol.iterator]() { 7900 const cached = this; 7901 let cur = 0; 7902 return { 7903 next() { 7904 if (cached.length <= cur) { 7905 cached.push(cached.iterator.next()); 7906 } 7907 return cached[cur++]; 7908 } 7909 }; 7910 } 7911 touchNext(count = 1) { 7912 let idx = 0; 7913 while (idx++ < count) { 7914 const last = this[this.length - 1]; 7915 if (last && last.done) { 7916 break; 7917 } 7918 this.push(this.iterator.next()); 7919 } 7920 return this[this.length - 1]; 7921 } 7922} 7923;// ./node_modules/cached-iterable/src/cached_async_iterable.mjs 7924 7925 7926class CachedAsyncIterable extends CachedIterable { 7927 constructor(iterable) { 7928 super(); 7929 if (Symbol.asyncIterator in Object(iterable)) { 7930 this.iterator = iterable[Symbol.asyncIterator](); 7931 } else if (Symbol.iterator in Object(iterable)) { 7932 this.iterator = iterable[Symbol.iterator](); 7933 } else { 7934 throw new TypeError("Argument must implement the iteration protocol."); 7935 } 7936 }
7937 [Symbol.asyncIterator]() { 7938 const cached = this; 7939 let cur = 0; 7940 return { 7941 async next() { 7942 if (cached.length <= cur) { 7943 cached.push(cached.iterator.next()); 7944 } 7945 return cached[cur++]; 7946 } 7947 }; 7948 } 7949 async touchNext(count = 1) { 7950 let idx = 0; 7951 while (idx++ < count) { 7952 const last = this[this.length - 1]; 7953 if (last && (await last).done) { 7954 break; 7955 } 7956 this.push(this.iterator.next()); 7957 } 7958 return this[this.length - 1]; 7959 } 7960} 7961;// ./node_modules/cached-iterable/src/index.mjs 7962 7963 7964;// ./node_modules/@fluent/dom/esm/localization.js 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978class Localization { 7979 constructor(resourceIds = [], generateBundles) { 7980 this.resourceIds = resourceIds; 7981 this.generateBundles = generateBundles; 7982 this.onChange(true); 7983 } 7984 addResourceIds(resourceIds, eager = false) { 7985 this.resourceIds.push(...resourceIds); 7986 this.onChange(eager); 7987 return this.resourceIds.length; 7988 } 7989 removeResourceIds(resourceIds) { 7990 this.resourceIds = this.resourceIds.filter(r => !resourceIds.includes(r)); 7991 this.onChange(); 7992 return this.resourceIds.length; 7993 } 7994 async formatWithFallback(keys, method) { 7995 const translations = []; 7996 let hasAtLeastOneBundle = false; 7997 for await (const bundle of this.bundles) { 7998 hasAtLeastOneBundle = true; 7999 const missingIds = keysFromBundle(method, bundle, keys, translations); 8000 if (missingIds.size === 0) { 8001 break; 8002 } 8003 if (typeof console !== "undefined") { 8004 const locale = bundle.locales[0]; 8005 const ids = Array.from(missingIds).join(", "); 8006 console.warn(`[fluent] Missing translations in ${locale}: ${ids}`); 8007 } 8008 } 8009 if (!hasAtLeastOneBundle && typeof console !== "undefined") { 8010 console.warn(`[fluent] Request for keys failed because no resource bundles got generated. 8011 keys: ${JSON.stringify(keys)}. 8012 resourceIds: ${JSON.stringify(this.resourceIds)}.`); 8013 } 8014 return translations; 8015 } 8016 formatMessages(keys) { 8017 return this.formatWithFallback(keys, messageFromBundle); 8018 } 8019 formatValues(keys) { 8020 return this.formatWithFallback(keys, valueFromBundle); 8021 } 8022 async formatValue(id, args) { 8023 const [val] = await this.formatValues([{ 8024 id, 8025 args 8026 }]); 8027 return val; 8028 } 8029 handleEvent() { 8030 this.onChange(); 8031 } 8032 onChange(eager = false) { 8033 this.bundles = CachedAsyncIterable.from(this.generateBundles(this.resourceIds)); 8034 if (eager) { 8035 this.bundles.touchNext(2); 8036 } 8037 } 8038} 8039function valueFromBundle(bundle, errors, message, args) { 8040 if (message.value) { 8041 return bundle.formatPattern(message.value, args, errors); 8042 } 8043 return null; 8044} 8045function messageFromBundle(bundle, errors, message, args) { 8046 const formatted = { 8047 value: null, 8048 attributes: null 8049 }; 8050 if (message.value) { 8051 formatted.value = bundle.formatPattern(message.value, args, errors); 8052 } 8053 let attrNames = Object.keys(message.attributes); 8054 if (attrNames.length > 0) { 8055 formatted.attributes = new Array(attrNames.length); 8056 for (let [i, name] of attrNames.entries()) { 8057 let value = bundle.formatPattern(message.attributes[name], args, errors); 8058 formatted.attributes[i] = { 8059 name, 8060 value 8061 }; 8062 } 8063 } 8064 return formatted; 8065} 8066function keysFromBundle(method, bundle, keys, translations) { 8067 const messageErrors = []; 8068 const missingIds = new Set(); 8069 keys.forEach(({ 8070 id, 8071 args 8072 }, i) => { 8073 if (translations[i] !== undefined) { 8074 return; 8075 } 8076 let message = bundle.getMessage(id); 8077 if (message) { 8078 messageErrors.length = 0; 8079 translations[i] = method(bundle, messageErrors, message, args); 8080 if (messageErrors.length > 0 && typeof console !== "undefined") { 8081 const locale = bundle.locales[0]; 8082 const errors = messageErrors.join(", "); 8083 console.warn(`[fluent][resolver] errors in ${locale}/${id}: ${errors}.`); 8084 } 8085 } else { 8086 missingIds.add(id); 8087 } 8088 }); 8089 return missingIds; 8090} 8091;// ./node_modules/@fluent/dom/esm/dom_localization.js 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106const L10NID_ATTR_NAME = "data-l10n-id"; 8107const L10NARGS_ATTR_NAME = "data-l10n-args"; 8108const L10N_ELEMENT_QUERY = `[${L10NID_ATTR_NAME}]`; 8109class DOMLocalization extends Localization { 8110 constructor(resourceIds, generateBundles) { 8111 super(resourceIds, generateBundles); 8112 this.roots = new Set(); 8113 this.pendingrAF = null; 8114 this.pendingElements = new Set(); 8115 this.windowElement = null; 8116 this.mutationObserver = null; 8117 this.observerConfig = { 8118 attributes: true, 8119 characterData: false, 8120 childList: true, 8121 subtree: true, 8122 attributeFilter: [L10NID_ATTR_NAME, L10NARGS_ATTR_NAME] 8123 }; 8124 } 8125 onChange(eager = false) { 8126 super.onChange(eager); 8127 if (this.roots) { 8128 this.translateRoots(); 8129 } 8130 } 8131 setAttributes(element, id, args) { 8132 element.setAttribute(L10NID_ATTR_NAME, id); 8133 if (args) { 8134 element.setAttribute(L10NARGS_ATTR_NAME, JSON.stringify(args)); 8135 } else { 8136 element.removeAttribute(L10NARGS_ATTR_NAME); 8137 } 8138 return element; 8139 } 8140 getAttributes(element) { 8141 return { 8142 id: element.getAttribute(L10NID_ATTR_NAME), 8143 args: JSON.parse(element.getAttribute(L10NARGS_ATTR_NAME) || null) 8144 }; 8145 } 8146 connectRoot(newRoot) { 8147 for (const root of this.roots) { 8148 if (root === newRoot || root.contains(newRoot) || newRoot.contains(root)) { 8149 throw new Error("Cannot add a root that overlaps with existing root."); 8150 } 8151 } 8152 if (this.windowElement) { 8153 if (this.windowElement !== newRoot.ownerDocument.defaultView) { 8154 throw new Error(`Cannot connect a root: 8155 DOMLocalization already has a root from a different window.`); 8156 } 8157 } else { 8158 this.windowElement = newRoot.ownerDocument.defaultView; 8159 this.mutationObserver = new this.windowElement.MutationObserver(mutations => this.translateMutations(mutations)); 8160 } 8161 this.roots.add(newRoot); 8162 this.mutationObserver.observe(newRoot, this.observerConfig); 8163 } 8164 disconnectRoot(root) { 8165 this.roots.delete(root); 8166 this.pauseObserving(); 8167 if (this.roots.size === 0) { 8168 this.mutationObserver = null; 8169 if (this.windowElement && this.pendingrAF) { 8170 this.windowElement.cancelAnimationFrame(this.pendingrAF); 8171 } 8172 this.windowElement = null; 8173 this.pendingrAF = null; 8174 this.pendingElements.clear(); 8175 return true; 8176 } 8177 this.resumeObserving(); 8178 return false;
8179 } 8180 translateRoots() { 8181 const roots = Array.from(this.roots); 8182 return Promise.all(roots.map(root => this.translateFragment(root))); 8183 } 8184 pauseObserving() { 8185 if (!this.mutationObserver) { 8186 return; 8187 } 8188 this.translateMutations(this.mutationObserver.takeRecords()); 8189 this.mutationObserver.disconnect(); 8190 } 8191 resumeObserving() { 8192 if (!this.mutationObserver) { 8193 return; 8194 } 8195 for (const root of this.roots) { 8196 this.mutationObserver.observe(root, this.observerConfig); 8197 } 8198 } 8199 translateMutations(mutations) { 8200 for (const mutation of mutations) { 8201 switch (mutation.type) { 8202 case "attributes": 8203 if (mutation.target.hasAttribute("data-l10n-id")) { 8204 this.pendingElements.add(mutation.target); 8205 } 8206 break; 8207 case "childList": 8208 for (const addedNode of mutation.addedNodes) { 8209 if (addedNode.nodeType === addedNode.ELEMENT_NODE) { 8210 if (addedNode.childElementCount) { 8211 for (const element of this.getTranslatables(addedNode)) { 8212 this.pendingElements.add(element); 8213 } 8214 } else if (addedNode.hasAttribute(L10NID_ATTR_NAME)) { 8215 this.pendingElements.add(addedNode); 8216 } 8217 } 8218 } 8219 break; 8220 } 8221 } 8222 if (this.pendingElements.size > 0) { 8223 if (this.pendingrAF === null) { 8224 this.pendingrAF = this.windowElement.requestAnimationFrame(() => { 8225 this.translateElements(Array.from(this.pendingElements)); 8226 this.pendingElements.clear(); 8227 this.pendingrAF = null; 8228 }); 8229 } 8230 } 8231 } 8232 translateFragment(frag) { 8233 return this.translateElements(this.getTranslatables(frag)); 8234 } 8235 async translateElements(elements) { 8236 if (!elements.length) { 8237 return undefined; 8238 } 8239 const keys = elements.map(this.getKeysForElement); 8240 const translations = await this.formatMessages(keys); 8241 return this.applyTranslations(elements, translations); 8242 } 8243 applyTranslations(elements, translations) { 8244 this.pauseObserving(); 8245 for (let i = 0; i < elements.length; i++) { 8246 if (translations[i] !== undefined) { 8247 translateElement(elements[i], translations[i]); 8248 } 8249 } 8250 this.resumeObserving(); 8251 } 8252 getTranslatables(element) { 8253 const nodes = Array.from(element.querySelectorAll(L10N_ELEMENT_QUERY)); 8254 if (typeof element.hasAttribute === "function" && element.hasAttribute(L10NID_ATTR_NAME)) { 8255 nodes.push(element); 8256 } 8257 return nodes; 8258 } 8259 getKeysForElement(element) { 8260 return { 8261 id: element.getAttribute(L10NID_ATTR_NAME), 8262 args: JSON.parse(element.getAttribute(L10NARGS_ATTR_NAME) || null) 8263 }; 8264 } 8265} 8266;// ./node_modules/@fluent/dom/esm/index.js 8267 8268 8269;// ./web/l10n.js 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279class L10n { 8280 #dir; 8281 #elements; 8282 #lang; 8283 #l10n; 8284 constructor({ 8285 lang, 8286 isRTL 8287 }, l10n = null) { 8288 this.#lang = L10n.#fixupLangCode(lang); 8289 this.#l10n = l10n; 8290 this.#dir = isRTL ?? L10n.#isRTL(this.#lang) ? "rtl" : "ltr"; 8291 } 8292 _setL10n(l10n) { 8293 this.#l10n = l10n; 8294 } 8295 getLanguage() { 8296 return this.#lang; 8297 } 8298 getDirection() { 8299 return this.#dir; 8300 } 8301 async get(ids, args = null, fallback) { 8302 if (Array.isArray(ids)) { 8303 ids = ids.map(id => ({ 8304 id 8305 })); 8306 const messages = await this.#l10n.formatMessages(ids); 8307 return messages.map(message => message.value); 8308 } 8309 const messages = await this.#l10n.formatMessages([{ 8310 id: ids, 8311 args 8312 }]); 8313 return messages[0]?.value || fallback; 8314 } 8315 async translate(element) { 8316 (this.#elements ||= new Set()).add(element); 8317 try { 8318 this.#l10n.connectRoot(element); 8319 await this.#l10n.translateRoots(); 8320 } catch {} 8321 } 8322 async translateOnce(element) { 8323 try { 8324 await this.#l10n.translateElements([element]); 8325 } catch (ex) { 8326 console.error("translateOnce:", ex); 8327 } 8328 } 8329 async destroy() { 8330 if (this.#elements) { 8331 for (const element of this.#elements) { 8332 this.#l10n.disconnectRoot(element); 8333 } 8334 this.#elements.clear(); 8335 this.#elements = null; 8336 } 8337 this.#l10n.pauseObserving(); 8338 } 8339 pause() { 8340 this.#l10n.pauseObserving(); 8341 } 8342 resume() { 8343 this.#l10n.resumeObserving(); 8344 } 8345 static #fixupLangCode(langCode) { 8346 langCode = langCode?.toLowerCase() || "en-us"; 8347 const PARTIAL_LANG_CODES = { 8348 en: "en-us", 8349 es: "es-es", 8350 fy: "fy-nl", 8351 ga: "ga-ie", 8352 gu: "gu-in", 8353 hi: "hi-in", 8354 hy: "hy-am", 8355 nb: "nb-no", 8356 ne: "ne-np", 8357 nn: "nn-no", 8358 pa: "pa-in", 8359 pt: "pt-pt", 8360 sv: "sv-se", 8361 zh: "zh-cn" 8362 }; 8363 return PARTIAL_LANG_CODES[langCode] || langCode;
8364 } 8365 static #isRTL(lang) { 8366 const shortCode = lang.split("-", 1)[0]; 8367 return ["ar", "he", "fa", "ps", "ur"].includes(shortCode); 8368 } 8369} 8370const GenericL10n = null; 8371 8372;// ./web/genericl10n.js 8373 8374 8375 8376 8377 8378 8379 8380 8381function PLATFORM() { 8382 const { 8383 isAndroid, 8384 isLinux, 8385 isMac, 8386 isWindows 8387 } = FeatureTest.platform; 8388 if (isLinux) { 8389 return "linux"; 8390 } 8391 if (isWindows) { 8392 return "windows"; 8393 } 8394 if (isMac) { 8395 return "macos"; 8396 } 8397 if (isAndroid) { 8398 return "android"; 8399 } 8400 return "other"; 8401} 8402function createBundle(lang, text) { 8403 const resource = new FluentResource(text); 8404 const bundle = new FluentBundle(lang, { 8405 functions: { 8406 PLATFORM 8407 } 8408 }); 8409 const errors = bundle.addResource(resource); 8410 if (errors.length) { 8411 console.error("L10n errors", errors); 8412 } 8413 return bundle; 8414} 8415class genericl10n_GenericL10n extends L10n { 8416 constructor(lang) { 8417 super({ 8418 lang 8419 }); 8420 const generateBundles = !lang ? genericl10n_GenericL10n.#generateBundlesFallback.bind(genericl10n_GenericL10n, this.getLanguage()) : genericl10n_GenericL10n.#generateBundles.bind(genericl10n_GenericL10n, "en-us", this.getLanguage()); 8421 this._setL10n(new DOMLocalization([], generateBundles)); 8422 } 8423 static async *#generateBundles(defaultLang, baseLang) { 8424 const { 8425 baseURL, 8426 paths 8427 } = await this.#getPaths(); 8428 const langs = [baseLang]; 8429 if (defaultLang !== baseLang) { 8430 const shortLang = baseLang.split("-", 1)[0]; 8431 if (shortLang !== baseLang) { 8432 langs.push(shortLang); 8433 } 8434 langs.push(defaultLang); 8435 } 8436 const bundles = langs.map(lang => [lang, this.#createBundle(lang, baseURL, paths)]); 8437 for (const [lang, bundlePromise] of bundles) { 8438 const bundle = await bundlePromise; 8439 if (bundle) { 8440 yield bundle; 8441 } else if (lang === "en-us") { 8442 yield this.#createBundleFallback(lang); 8443 } 8444 } 8445 } 8446 static async #createBundle(lang, baseURL, paths) { 8447 const path = paths[lang]; 8448 if (!path) { 8449 return null; 8450 } 8451 const url = new URL(path, baseURL); 8452 const text = await fetchData(url, "text"); 8453 return createBundle(lang, text); 8454 } 8455 static async #getPaths() { 8456 try { 8457 const { 8458 href 8459 } = document.querySelector(`link[type="application/l10n"]`); 8460 const paths = await fetchData(href, "json"); 8461 return { 8462 baseURL: href.substring(0, href.lastIndexOf("/") + 1) || "./", 8463 paths 8464 }; 8465 } catch {} 8466 return { 8467 baseURL: "./", 8468 paths: Object.create(null) 8469 }; 8470 } 8471 static async *#generateBundlesFallback(lang) { 8472 yield this.#createBundleFallback(lang); 8473 } 8474 static async #createBundleFallback(lang) { 8475 const text = "pdfjs-previous-button =\n .title = Previous Page\npdfjs-previous-button-label = Previous\npdfjs-next-button =\n .title = Next Page\npdfjs-next-button-label = Next\npdfjs-page-input =\n .title = Page\npdfjs-of-pages = of { $pagesCount }\npdfjs-page-of-pages = ({ $pageNumber } of { $pagesCount })\npdfjs-zoom-out-button =\n .title = Zoom Out\npdfjs-zoom-out-button-label = Zoom Out\npdfjs-zoom-in-button =\n .title = Zoom In\npdfjs-zoom-in-button-label = Zoom In\npdfjs-zoom-select =\n .title = Zoom\npdfjs-presentation-mode-button =\n .title = Switch to Presentation Mode\npdfjs-presentation-mode-button-label = Presentation Mode\npdfjs-open-file-button =\n .title = Open File\npdfjs-open-file-button-label = Open\npdfjs-print-button =\n .title = Print\npdfjs-print-button-label = Print\npdfjs-save-button =\n .title = Save\npdfjs-save-button-label = Save\npdfjs-download-button =\n .title = Download\npdfjs-download-button-label = Download\npdfjs-bookmark-button =\n .title = Current Page (View URL from Current Page)\npdfjs-bookmark-button-label = Current Page\npdfjs-tools-button =\n .title = Tools\npdfjs-tools-button-label = Tools\npdfjs-first-page-button =\n .title = Go to First Page\npdfjs-first-page-button-label = Go to First Page\npdfjs-last-page-button =\n .title = Go to Last Page\npdfjs-last-page-button-label = Go to Last Page\npdfjs-page-rotate-cw-button =\n .title = Rotate Clockwise\npdfjs-page-rotate-cw-button-label = Rotate Clockwise\npdfjs-page-rotate-ccw-button =\n .title = Rotate Counterclockwise\npdfjs-page-rotate-ccw-button-label = Rotate Counterclockwise\npdfjs-cursor-text-select-tool-button =\n .title = Enable Text Selection Tool\npdfjs-cursor-text-select-tool-button-label = Text Selection Tool\npdfjs-cursor-hand-tool-button =\n .title = Enable Hand Tool\npdfjs-cursor-hand-tool-button-label = Hand Tool\npdfjs-scroll-page-button =\n .title = Use Page Scrolling\npdfjs-scroll-page-button-label = Page Scrolling\npdfjs-scroll-vertical-button =\n .title = Use Vertical Scrolling\npdfjs-scroll-vertical-button-label = Vertical Scrolling\npdfjs-scroll-horizontal-button =\n .title = Use Horizontal Scrolling\npdfjs-scroll-horizontal-button-label = Horizontal Scrolling\npdfjs-scroll-wrapped-button =\n .title = Use Wrapped Scrolling\npdfjs-scroll-wrapped-button-label = Wrapped Scrolling\npdfjs-spread-none-button =\n .title = Do not join page spreads\npdfjs-spread-none-button-label = No Spreads\npdfjs-spread-odd-button =\n .title = Join page spreads starting with odd-numbered pages\npdfjs-spread-odd-button-label = Odd Spreads\npdfjs-spread-even-button =\n .title = Join page spreads starting with even-numbered pages\npdfjs-spread-even-button-label = Even Spreads\npdfjs-document-properties-button =\n .title = Document Properties\u2026\npdfjs-document-properties-button-label = Document Properties\u2026\npdfjs-document-properties-file-name = File name:\npdfjs-document-properties-file-size = File size:\npdfjs-document-properties-size-kb = { NUMBER($kb, maximumSignificantDigits: 3) } KB ({ $b } bytes)\npdfjs-document-properties-size-mb = { NUMBER($mb, maximumSignificantDigits: 3) } MB ({ $b } bytes)\npdfjs-document-properties-title = Title:\npdfjs-document-properties-author = Author:\npdfjs-document-properties-subject = Subject:\npdfjs-document-properties-keywords = Keywords:\npdfjs-document-properties-creation-date = Creation Date:\npdfjs-document-properties-modification-date = Modification Date:\npdfjs-document-properties-date-time-string = { DATETIME($dateObj, dateStyle: \"short\", timeStyle: \"medium\") }\npdfjs-document-properties-creator = Creator:\npdfjs-document-properties-producer = PDF Producer:\npdfjs-document-properties-version = PDF Version:\npdfjs-document-properties-page-count = Page Count:\npdfjs-document-properties-page-size = Page Size:\npdfjs-document-properties-page-size-unit-inches = in\npdfjs-document-properties-page-size-unit-millimeters = mm\npdfjs-document-properties-page-size-orientation-portrait = portrait\npdfjs-document-properties-page-size-orientation-landscape = landscape\npdfjs-document-properties-page-size-name-a-three = A3\npdfjs-document-properties-page-size-name-a-four = A4\npdfjs-document-properties-page-size-name-letter = Letter\npdfjs-document-properties-page-size-name-legal = Legal\npdfjs-document-properties-page-size-dimension-string = { $width } \xD7 { $height } { $unit } ({ $orientation })\npdfjs-document-properties-page-size-dimension-name-string = { $width } \xD7 { $height } { $unit } ({ $name }, { $orientation })\npdfjs-document-properties-linearized = Fast Web View:\npdfjs-document-properties-linearized-yes = Yes\npdfjs-document-properties-linearized-no = No\npdfjs-document-properties-close-button = Close\npdfjs-print-progress-message = Preparing document for printing\u2026\npdfjs-print-progress-percent = { $progress }%\npdfjs-print-progress-close-button = Cancel\npdfjs-printing-not-supported = Warning: Printing is not fully supported by this browser.\npdfjs-printing-not-ready = Warning: The PDF is not fully loaded for printing.\npdfjs-current-outline-item-button =\n .title = Find Current Outline Item\npdfjs-current-outline-item-button-label = Current Outline Item\npdfjs-findbar-button =\n .title = Find in Document\npdfjs-findbar-button-label = Find\npdfjs-additional-layers = Additional Layers\npdfjs-thumb-page-title1 =\n .title = Page { $page } of { $total }\npdfjs-thumb-page-canvas =\n .aria-label = Thumbnail of Page { $page }\npdfjs-thumb-page-checkbox1 =\n .title = Select page { $page }\npdfjs-find-input =\n .title = Find\n .placeholder = Find in document\u2026\npdfjs-find-previous-button =\n .title = Find the previous occurrence of the phrase\npdfjs-find-previous-button-label = Previous\npdfjs-find-next-button =\n .title = Find the next occurrence of the phrase\npdfjs-find-next-button-label = Next\npdfjs-find-highlight-checkbox = Highlight All\npdfjs-find-match-case-checkbox-label = Match Case\npdfjs-find-match-diacritics-checkbox-label = Match Diacritics\npdfjs-find-entire-word-checkbox-label = Whole Words\npdfjs-find-reached-top = Reached top of document, continued from bottom\npdfjs-find-reached-bottom = Reached end of document, continued from top\npdfjs-find-match-count =\n { $total ->\n [one] { $current } of { $total } match\n *[other] { $current } of { $total } matches\n }\npdfjs-find-match-count-limit =\n { $limit ->\n [one] More than { $limit } match\n *[other] More than { $limit } matches\n }\npdfjs-find-not-found = Phrase not found\npdfjs-page-scale-width = Page Width\npdfjs-page-scale-fit = Page Fit\npdfjs-page-scale-auto = Automatic Zoom\npdfjs-page-scale-actual = Actual Size\npdfjs-page-scale-percent = { $scale }%\npdfjs-page-landmark =\n .aria-label = Page { $page }\npdfjs-loading-error = An error occurred while loading the PDF.\npdfjs-invalid-file-error = Invalid or corrupted PDF file.\npdfjs-missing-file-error = Missing PDF file.\npdfjs-unexpected-response-error = Unexpected server response.\npdfjs-rendering-error = An error occurred while rendering the page.\npdfjs-annotation-date-time-string = { DATETIME($dateObj, dateStyle: \"short\", timeStyle: \"medium\") }\npdfjs-text-annotation-type =\n .alt = [{ $type } Annotation]\npdfjs-password-label = Enter the password to open this PDF file.\npdfjs-password-invalid = Invalid password. Please try again.\npdfjs-password-ok-button = OK\npdfjs-password-cancel-button = Cancel\npdfjs-web-fonts-disabled = Web fonts are disabled: unable to use embedded PDF fonts.\npdfjs-editor-free-text-button =\n .title = Text\npdfjs-editor-color-picker-free-text-input =\n .title = Change text color\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n .title = Draw\npdfjs-editor-color-picker-ink-input =\n .title = Change drawing color\npdfjs-editor-ink-button-label = Draw\npdfjs-editor-stamp-button =\n .title = Add or edit images\npdfjs-editor-stamp-button-label = Add or edit images\npdfjs-editor-highlight-button =\n .title = Highlight\npdfjs-editor-highlight-button-label = Highlight\npdfjs-highlight-floating-button1 =\n .title = Highlight\n .aria-label = Highlight\npdfjs-highlight-floating-button-label = Highlight\npdfjs-comment-floating-button =\n .title = Comment\n .aria-label = Comment\npdfjs-comment-floating-button-label = Comment\npdfjs-editor-comment-button =\n .title = Comment\n .aria-label = Comment\npdfjs-editor-comment-button-label = Comment\npdfjs-editor-signature-button =\n .title = Add signature\npdfjs-editor-signature-button-label = Add signature\npdfjs-editor-highlight-editor =\n .aria-label = Highlight editor\npdfjs-editor-ink-editor =\n .aria-label = Drawing editor\npdfjs-editor-signature-editor1 =\n .aria-description = Signature editor: { $description }\npdfjs-editor-stamp-editor =\n .aria-label = Image editor\npdfjs-editor-remove-ink-button =\n .title = Remove drawing\npdfjs-editor-remove-freetext-button =\n .title = Remove text\npdfjs-editor-remove-stamp-button =\n .title = Remove image\npdfjs-editor-remove-highlight-button =\n .title = Remove highlight\npdfjs-editor-remove-signature-button =\n .title = Remove signature\npdfjs-editor-free-text-color-input = Color\npdfjs-editor-free-text-size-input = Size\npdfjs-editor-ink-color-input = Color\npdfjs-editor-ink-thickness-input = Thickness\npdfjs-editor-ink-opacity-input = Opacity\npdfjs-editor-stamp-add-image-button =\n .title = Add image\npdfjs-editor-stamp-add-image-button-label = Add image\npdfjs-editor-free-highlight-thickness-input = Thickness\npdfjs-editor-free-highlight-thickness-title =\n .title = Change thickness when highlighting items other than text\npdfjs-editor-add-signature-container =\n .aria-label = Signature controls and saved signatures\npdfjs-editor-signature-add-signature-button =\n .title = Add new signature\npdfjs-editor-signature-add-signature-button-label = Add new signature\npdfjs-editor-add-saved-signature-button =\n .title = Saved signature: { $description }\npdfjs-free-text2 =\n .aria-label = Text Editor\n .default-content = Start t
8475yping\u2026\npdfjs-editor-comments-sidebar-title =\n { $count ->\n [one] Comment\n *[other] Comments\n }\npdfjs-editor-comments-sidebar-close-button =\n .title = Close the sidebar\n .aria-label = Close the sidebar\npdfjs-editor-comments-sidebar-close-button-label = Close the sidebar\npdfjs-editor-comments-sidebar-no-comments1 = See something noteworthy? Highlight it and leave a comment.\npdfjs-editor-comments-sidebar-no-comments-link = Learn more\npdfjs-editor-alt-text-button =\n .aria-label = Alt text\npdfjs-editor-alt-text-button-label = Alt text\npdfjs-editor-alt-text-edit-button =\n .aria-label = Edit alt text\npdfjs-editor-alt-text-dialog-label = Choose an option\npdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people can\u2019t see the image or when it doesn\u2019t load.\npdfjs-editor-alt-text-add-description-label = Add a description\npdfjs-editor-alt-text-add-description-description = Aim for 1-2 sentences that describe the subject, setting, or actions.\npdfjs-editor-alt-text-mark-decorative-label = Mark as decorative\npdfjs-editor-alt-text-mark-decorative-description = This is used for ornamental images, like borders or watermarks.\npdfjs-editor-alt-text-cancel-button = Cancel\npdfjs-editor-alt-text-save-button = Save\npdfjs-editor-alt-text-decorative-tooltip = Marked as decorative\npdfjs-editor-alt-text-textarea =\n .placeholder = For example, \u201CA young man sits down at a table to eat a meal\u201D\npdfjs-editor-resizer-top-left =\n .aria-label = Top left corner \u2014 resize\npdfjs-editor-resizer-top-middle =\n .aria-label = Top middle \u2014 resize\npdfjs-editor-resizer-top-right =\n .aria-label = Top right corner \u2014 resize\npdfjs-editor-resizer-middle-right =\n .aria-label = Middle right \u2014 resize\npdfjs-editor-resizer-bottom-right =\n .aria-label = Bottom right corner \u2014 resize\npdfjs-editor-resizer-bottom-middle =\n .aria-label = Bottom middle \u2014 resize\npdfjs-editor-resizer-bottom-left =\n .aria-label = Bottom left corner \u2014 resize\npdfjs-editor-resizer-middle-left =\n .aria-label = Middle left \u2014 resize\npdfjs-editor-highlight-colorpicker-label = Highlight color\npdfjs-editor-colorpicker-button =\n .title = Change color\npdfjs-editor-colorpicker-dropdown =\n .aria-label = Color choices\npdfjs-editor-colorpicker-yellow =\n .title = Yellow\npdfjs-editor-colorpicker-green =\n .title = Green\npdfjs-editor-colorpicker-blue =\n .title = Blue\npdfjs-editor-colorpicker-pink =\n .title = Pink\npdfjs-editor-colorpicker-red =\n .title = Red\npdfjs-editor-highlight-show-all-button-label = Show all\npdfjs-editor-highlight-show-all-button =\n .title = Show all\npdfjs-editor-new-alt-text-dialog-edit-label = Edit alt text (image description)\npdfjs-editor-new-alt-text-dialog-add-label = Add alt text (image description)\npdfjs-editor-new-alt-text-textarea =\n .placeholder = Write your description here\u2026\npdfjs-editor-new-alt-text-description = Short description for people who can\u2019t see the image or when the image doesn\u2019t load.\npdfjs-editor-new-alt-text-disclaimer1 = This alt text was created automatically and may be inaccurate.\npdfjs-editor-new-alt-text-disclaimer-learn-more-url = Learn more\npdfjs-editor-new-alt-text-create-automatically-button-label = Create alt text automatically\npdfjs-editor-new-alt-text-not-now-button = Not now\npdfjs-editor-new-alt-text-error-title = Couldn\u2019t create alt text automatically\npdfjs-editor-new-alt-text-error-description = Please write your own alt text or try again later.\npdfjs-editor-new-alt-text-error-close-button = Close\npdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\n .aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\npdfjs-editor-new-alt-text-added-button =\n .aria-label = Alt text added\npdfjs-editor-new-alt-text-added-button-label = Alt text added\npdfjs-editor-new-alt-text-missing-button =\n .aria-label = Missing alt text\npdfjs-editor-new-alt-text-missing-button-label = Missing alt text\npdfjs-editor-new-alt-text-to-review-button =\n .aria-label = Review alt text\npdfjs-editor-new-alt-text-to-review-button-label = Review alt text\npdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer = Created automatically: { $generatedAltText }\npdfjs-image-alt-text-settings-button =\n .title = Image alt text settings\npdfjs-image-alt-text-settings-button-label = Image alt text settings\npdfjs-editor-alt-text-settings-dialog-label = Image alt text settings\npdfjs-editor-alt-text-settings-automatic-title = Automatic alt text\npdfjs-editor-alt-text-settings-create-model-button-label = Create alt text automatically\npdfjs-editor-alt-text-settings-create-model-description = Suggests descriptions to help people who can\u2019t see the image or when the image doesn\u2019t load.\npdfjs-editor-alt-text-settings-editor-title = Alt text editor\npdfjs-editor-alt-text-settings-show-dialog-button-label = Show alt text editor right away when adding an image\npdfjs-editor-alt-text-settings-show-dialog-description = Helps you make sure all your images have alt text.\npdfjs-editor-alt-text-settings-close-button = Close\npdfjs-editor-highlight-added-alert = Highlight added\npdfjs-editor-freetext-added-alert = Text added\npdfjs-editor-ink-added-alert = Drawing added\npdfjs-editor-stamp-added-alert = Image added\npdfjs-editor-signature-added-alert = Signature added\npdfjs-editor-undo-bar-message-highlight = Highlight removed\npdfjs-editor-undo-bar-message-freetext = Text removed\npdfjs-editor-undo-bar-message-ink = Drawing removed\npdfjs-editor-undo-bar-message-stamp = Image removed\npdfjs-editor-undo-bar-message-signature = Signature removed\npdfjs-editor-undo-bar-message-comment = Comment removed\npdfjs-editor-undo-bar-message-multiple =\n { $count ->\n [one] { $count } annotation removed\n *[other] { $count } annotations removed\n }\npdfjs-editor-undo-bar-undo-button =\n .title = Undo\npdfjs-editor-undo-bar-undo-button-label = Undo\npdfjs-editor-undo-bar-close-button =\n .title = Close\npdfjs-editor-undo-bar-close-button-label = Close\npdfjs-editor-add-signature-dialog-label = This modal allows the user to create a signature to add to a PDF document. The user can edit the name (which also serves as the alt text), and optionally save the signature for repeated use.\npdfjs-editor-add-signature-dialog-title = Add a signature\npdfjs-editor-add-signature-type-button = Type\n .title = Type\npdfjs-editor-add-signature-draw-button = Draw\n .title = Draw\npdfjs-editor-add-signature-image-button = Image\n .title = Image\npdfjs-editor-add-signature-type-input =\n .aria-label = Type your signature\n .placeholder = Type your signature\npdfjs-editor-add-signature-draw-placeholder = Draw your signature\npdfjs-editor-add-signature-draw-thickness-range-label = Thickness\npdfjs-editor-add-signature-draw-thickness-range =\n .title = Drawing thickness: { $thickness }\npdfjs-editor-add-signature-image-placeholder = Drag a file here to upload\npdfjs-editor-add-signature-image-browse-link =\n { PLATFORM() ->\n [macos] Or choose image files\n *[other] Or browse image files\n }\npdfjs-editor-add-signature-description-label = Description (alt text)\npdfjs-editor-add-signature-description-input =\n .title = Description (alt text)\npdfjs-editor-add-signature-description-default-when-drawing = Signature\npdfjs-editor-add-signature-clear-button-label = Clear signature\npdfjs-editor-add-signature-clear-button =\n .title = Clear signature\npdfjs-editor-add-signature-save-checkbox = Save signature\npdfjs-editor-add-signature-save-warning-message = You\u2019ve reached the limit of 5 saved signatures. Remove one to save more.\npdfjs-editor-add-signature-image-upload-error-title = Couldn\u2019t upload image\npdfjs-editor-add-signature-image-upload-error-description = Check your network connection or try another image.\npdfjs-editor-add-signature-image-no-data-error-title = Can\u2019t convert this image into a signature\npdfjs-editor-add-signature-image-no-data-error-description = Please try uploading a different image.\npdfjs-editor-add-signature-error-close-button = Close\npdfjs-editor-add-signature-cancel-button = Cancel\npdfjs-editor-add-signature-add-button = Add\npdfjs-editor-delete-signature-button1 =\n .title = Remove saved signature\npdfjs-editor-delete-signature-button-label1 = Remove saved signature\npdfjs-editor-add-signature-edit-button-label = Edit description\npdfjs-editor-edit-signature-dialog-title = Edit description\npdfjs-editor-edit-signature-update-button = Update\npdfjs-show-comment-button =\n .title = Show comment\npdfjs-editor-edit-comment-popup-button-label = Edit comment\npdfjs-editor-edit-comment-popup-button =\n .title = Edit comment\npdfjs-editor-delete-comment-popup-button-label = Remove c
8475omment\npdfjs-editor-delete-comment-popup-button =\n .title = Remove comment\npdfjs-editor-edit-comment-dialog-title-when-editing = Edit comment\npdfjs-editor-edit-comment-dialog-save-button-when-editing = Update\npdfjs-editor-edit-comment-dialog-title-when-adding = Add comment\npdfjs-editor-edit-comment-dialog-save-button-when-adding = Add\npdfjs-editor-edit-comment-dialog-text-input =\n .placeholder = Start typing\u2026\npdfjs-editor-edit-comment-dialog-cancel-button = Cancel\npdfjs-editor-add-comment-button =\n .title = Add comment\npdfjs-toggle-views-manager-button1 =\n .title = Manage pages\npdfjs-toggle-views-manager-notification-button =\n .title = Toggle Sidebar (document contains thumbnails/outline/attachments/layers)\npdfjs-toggle-views-manager-button1-label = Manage pages\npdfjs-views-manager-sidebar =\n .aria-label = Sidebar\npdfjs-views-manager-sidebar-resizer =\n .aria-label = Sidebar resizer\npdfjs-views-manager-view-selector-button =\n .title = Views\npdfjs-views-manager-view-selector-button-label = Views\npdfjs-views-manager-pages-title = Pages\npdfjs-views-manager-outlines-title = Document outline\npdfjs-views-manager-attachments-title = Attachments\npdfjs-views-manager-layers-title = Layers\npdfjs-views-manager-pages-option-label = Pages\npdfjs-views-manager-outlines-option-label = Document outline\npdfjs-views-manager-attachments-option-label = Attachments\npdfjs-views-manager-layers-option-label = Layers\npdfjs-views-manager-add-file-button =\n .title = Add f
8475ile\npdfjs-views-manager-add-file-button-label = Add file\npdfjs-views-manager-pages-status-action-label =\n { $count ->\n [one] { $count } selected\n *[other] { $count } selected\n }\npdfjs-views-manager-pages-status-none-action-label = Select pages\npdfjs-views-manager-pages-status-action-button-label = Manage\npdfjs-views-manager-pages-status-copy-button-label = Copy\npdfjs-views-manager-pages-status-cut-button-label = Cut\npdfjs-views-manager-pages-status-delete-button-label = Delete\npdfjs-views-manager-pages-status-save-as-button-label = Save as\u2026\npdfjs-views-manager-status-undo-cut-label =\n { $count ->\n [one] 1 page cut\n *[other] { $count } pages cut\n }\npdfjs-views-manager-pages-status-undo-copy-label =\n { $count ->\n [one] 1 page copied\n *[other] { $count } pages copied\n }\npdfjs-views-manager-pages-status-undo-delete-label =\n { $count ->\n [one] 1 page deleted\n *[other] { $count } pages deleted\n }\npdfjs-views-manager-pages-status-waiting-ready-label = Getting your file ready\u2026\npdfjs-views-manager-pages-status-waiting-uploading-label = Uploading file\u2026\npdfjs-views-manager-status-warning-cut-label = Couldn\u2019t cut. Refresh page and try again.\npdfjs-views-manager-status-warning-copy-label = Couldn\u2019t copy. Refresh page and try again.\npdfjs-views-manager-status-warning-delete-label = Couldn\u2019t delete. Refresh page and try again.\npdfjs-views-manager-status-warning-save-label = Couldn\u2019t save. Refresh page and try again.\npdfjs-views-manager-status-undo-button-label = Undo\npdfjs-views-manager-status-close-button =\n .title = Close\npdfjs-views-manager-status-close-button-label = Close\npdfjs-views-manager-paste-button-label = Paste"; 8476 return createBundle(lang, text); 8477 } 8478} 8479 8480;// ./web/generic_scripting.js 8481/* unused harmony import specifier */ var generic_scripting_getPdfFilenameFromUrl; 8482 8483async function docProperties(pdfDocument) { 8484 const url = "", 8485 baseUrl = ""; 8486 const { 8487 info, 8488 metadata, 8489 contentDispositionFilename, 8490 contentLength 8491 } = await pdfDocument.getMetadata(); 8492 return { 8493 ...info, 8494 baseURL: baseUrl, 8495 filesize: contentLength || (await pdfDocument.getDownloadInfo()).length, 8496 filename: contentDispositionFilename || generic_scripting_getPdfFilenameFromUrl(url), 8497 metadata: metadata?.getRaw(), 8498 authors: metadata?.get("dc:creator"), 8499 numPages: pdfDocument.numPages, 8500 URL: url 8501 }; 8502} 8503class GenericScripting { 8504 constructor(sandboxBundleSrc) { 8505 this._ready = new Promise((resolve, reject) => { 8506 const sandbox = import( 8507 /*webpackIgnore: true*/ 8508 /*@vite-ignore*/ 8509 sandboxBundleSrc); 8510 sandbox.then(pdfjsSandbox => { 8511 resolve(pdfjsSandbox.QuickJSSandbox()); 8512 }).catch(reject); 8513 }); 8514 } 8515 async createSandbox(data) { 8516 const sandbox = await this._ready; 8517 sandbox.create(data); 8518 } 8519 async dispatchEventInSandbox(event) { 8520 const sandbox = await this._ready; 8521 setTimeout(() => sandbox.dispatchEvent(event), 0); 8522 } 8523 async destroySandbox() { 8524 const sandbox = await this._ready; 8525 sandbox.nukeSandbox(); 8526 } 8527} 8528 8529;// ./web/generic_signature_storage.js 8530 8531 8532 8533 8534 8535const KEY_STORAGE = "pdfjs.signature"; 8536class SignatureStorage { 8537 #eventBus; 8538 #signatures = null; 8539 #signal = null; 8540 constructor(eventBus, signal) { 8541 this.#eventBus = eventBus; 8542 this.#signal = signal; 8543 } 8544 #save() { 8545 localStorage.setItem(KEY_STORAGE, JSON.stringify(Object.fromEntries(this.#signatures))); 8546 } 8547 async getAll() { 8548 if (this.#signal) { 8549 window.addEventListener("storage", ({ 8550 key 8551 }) => { 8552 if (key === KEY_STORAGE) { 8553 this.#signatures = null; 8554 this.#eventBus?.dispatch("storedsignatureschanged", { 8555 source: this 8556 }); 8557 } 8558 }, { 8559 signal: this.#signal 8560 }); 8561 this.#signal = null; 8562 } 8563 if (!this.#signatures) { 8564 this.#signatures = new Map(); 8565 const data = localStorage.getItem(KEY_STORAGE); 8566 if (data) { 8567 for (const [key, value] of Object.entries(JSON.parse(data))) { 8568 this.#signatures.set(key, value); 8569 } 8570 } 8571 } 8572 return this.#signatures; 8573 }
8574 async isFull() { 8575 return (await this.size()) === 5; 8576 } 8577 async size() { 8578 return (await this.getAll()).size; 8579 } 8580 async create(data) { 8581 if (await this.isFull()) { 8582 return null; 8583 } 8584 const uuid = getUuid(); 8585 this.#signatures.set(uuid, data); 8586 this.#save(); 8587 return uuid; 8588 } 8589 async delete(uuid) { 8590 const signatures = await this.getAll(); 8591 if (!signatures.has(uuid)) { 8592 return false; 8593 } 8594 signatures.delete(uuid); 8595 this.#save(); 8596 return true; 8597 } 8598} 8599 8600;// ./web/genericcom.js 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610function initCom(app) {} 8611class Preferences extends BasePreferences { 8612 async _writeToStorage(prefObj) { 8613 localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj)); 8614 } 8615 async _readFromStorage(prefObj) { 8616 return { 8617 prefs: JSON.parse(localStorage.getItem("pdfjs.preferences")) 8618 }; 8619 } 8620} 8621class ExternalServices extends BaseExternalServices { 8622 async createL10n() { 8623 return new genericl10n_GenericL10n(AppOptions.get("localeProperties")?.lang); 8624 } 8625 createScripting() { 8626 return new GenericScripting(AppOptions.get("sandboxBundleSrc")); 8627 } 8628 createSignatureStorage(eventBus, signal) { 8629 return new SignatureStorage(eventBus, signal); 8630 } 8631} 8632class MLManager { 8633 async isEnabledFor(_name) { 8634 return false; 8635 } 8636 async deleteModel(_service) { 8637 return null; 8638 } 8639 isReady(_name) { 8640 return false; 8641 } 8642 guess(_data) {} 8643 toggleService(_name, _enabled) {} 8644} 8645 8646;// ./web/new_alt_text_manager.js 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658class NewAltTextManager { 8659 #boundCancel = this.#cancel.bind(this); 8660 #createAutomaticallyButton; 8661 #currentEditor = null; 8662 #cancelButton; 8663 #descriptionContainer; 8664 #dialog; 8665 #disclaimer; 8666 #downloadModel; 8667 #downloadModelDescription; 8668 #eventBus; 8669 #firstTime = false; 8670 #guessedAltText; 8671 #hasAI = null; 8672 #isEditing = null; 8673 #imagePreview; 8674 #imageData; 8675 #isAILoading = false; 8676 #wasAILoading = false; 8677 #learnMore; 8678 #notNowButton; 8679 #overlayManager; 8680 #textarea; 8681 #title; 8682 #uiManager; 8683 #previousAltText = null; 8684 constructor({ 8685 descriptionContainer, 8686 dialog, 8687 imagePreview, 8688 cancelButton, 8689 disclaimer, 8690 notNowButton, 8691 saveButton, 8692 textarea, 8693 learnMore, 8694 errorCloseButton, 8695 createAutomaticallyButton, 8696 downloadModel, 8697 downloadModelDescription, 8698 title 8699 }, overlayManager, eventBus) { 8700 this.#cancelButton = cancelButton; 8701 this.#createAutomaticallyButton = createAutomaticallyButton; 8702 this.#descriptionContainer = descriptionContainer; 8703 this.#dialog = dialog; 8704 this.#disclaimer = disclaimer; 8705 this.#notNowButton = notNowButton; 8706 this.#imagePreview = imagePreview; 8707 this.#textarea = textarea; 8708 this.#learnMore = learnMore; 8709 this.#title = title; 8710 this.#downloadModel = downloadModel; 8711 this.#downloadModelDescription = downloadModelDescription; 8712 this.#overlayManager = overlayManager; 8713 this.#eventBus = eventBus; 8714 dialog.addEventListener("close", this.#close.bind(this)); 8715 dialog.addEventListener("contextmenu", event => { 8716 if (event.target !== this.#textarea) { 8717 event.preventDefault(); 8718 } 8719 }); 8720 cancelButton.addEventListener("click", this.#boundCancel); 8721 notNowButton.addEventListener("click", this.#boundCancel); 8722 saveButton.addEventListener("click", this.#save.bind(this)); 8723 errorCloseButton.addEventListener("click", () => { 8724 this.#toggleError(false); 8725 }); 8726 createAutomaticallyButton.addEventListener("click", async () => { 8727 const checked = createAutomaticallyButton.getAttribute("aria-pressed") !== "true"; 8728 this.#currentEditor._reportTelemetry({ 8729 action: "pdfjs.image.alt_text.ai_generation_check", 8730 data: { 8731 status: checked 8732 } 8733 }); 8734 if (this.#uiManager) { 8735 const isAltTextEnabled = await this.#uiManager.mlManager.isEnabledFor("altText"); 8736 this.#createAutomaticallyButton.disabled = true; 8737 if (checked && !isAltTextEnabled) { 8738 this.#textarea.value = ""; 8739 this.#setProgress(); 8740 this.#uiManager.setPreference("enableGuessAltText", true); 8741 await this.#uiManager.mlManager.downloadModel("altText"); 8742 this.#setPref("enableAltTextModelDownload", true); 8743 } else if (!checked && isAltTextEnabled) { 8744 this.#uiManager.setPreference("enableGuessAltText", false); 8745 await this.#uiManager.mlManager.deleteModel("altText"); 8746 this.#setPref("enableAltTextModelDownload", false); 8747 } 8748 this.#createAutomaticallyButton.disabled = false;
8749 await this.#uiManager.mlManager.toggleService("altText", checked); 8750 } 8751 this.#toggleGuessAltText(checked, false); 8752 }); 8753 textarea.addEventListener("focus", () => { 8754 this.#wasAILoading = this.#isAILoading; 8755 this.#toggleLoading(false); 8756 this.#toggleTitleAndDisclaimer(); 8757 }); 8758 textarea.addEventListener("blur", () => { 8759 if (!textarea.value) { 8760 this.#toggleLoading(this.#wasAILoading); 8761 } 8762 this.#toggleTitleAndDisclaimer(); 8763 }); 8764 textarea.addEventListener("input", () => { 8765 this.#toggleTitleAndDisclaimer(); 8766 }); 8767 textarea.addEventListener("keydown", e => { 8768 if ((e.ctrlKey || e.metaKey) && e.key === "Enter" && !saveButton.disabled) { 8769 this.#save(); 8770 } 8771 }); 8772 eventBus._on("enableguessalttext", ({ 8773 value 8774 }) => { 8775 this.#toggleGuessAltText(value, false); 8776 }); 8777 this.#overlayManager.register(dialog); 8778 this.#learnMore.addEventListener("click", () => { 8779 this.#currentEditor._reportTelemetry({ 8780 action: "pdfjs.image.alt_text.info", 8781 data: { 8782 topic: "alt_text" 8783 } 8784 }); 8785 }); 8786 } 8787 #setPref(name, value) { 8788 this.#eventBus.dispatch("setpreference", { 8789 source: this, 8790 name, 8791 value 8792 }); 8793 } 8794 #toggleLoading(value) { 8795 if (!this.#uiManager || this.#isAILoading === value) { 8796 return; 8797 } 8798 this.#isAILoading = value; 8799 this.#descriptionContainer.classList.toggle("loading", value); 8800 } 8801 #toggleError(value) { 8802 if (!this.#uiManager) { 8803 return; 8804 } 8805 this.#dialog.classList.toggle("error", value); 8806 } 8807 async #toggleGuessAltText(value, isInitial) { 8808 if (!this.#uiManager) { 8809 return; 8810 } 8811 this.#dialog.classList.toggle("aiDisabled", !value); 8812 this.#createAutomaticallyButton.setAttribute("aria-pressed", value); 8813 if (value) { 8814 const { 8815 altTextLearnMoreUrl 8816 } = this.#uiManager.mlManager; 8817 if (altTextLearnMoreUrl) { 8818 this.#learnMore.href = altTextLearnMoreUrl; 8819 } 8820 this.#mlGuessAltText(isInitial); 8821 } else { 8822 this.#toggleLoading(false); 8823 this.#isAILoading = false; 8824 this.#toggleTitleAndDisclaimer(); 8825 } 8826 } 8827 #toggleNotNow() { 8828 this.#notNowButton.classList.toggle("hidden", !this.#firstTime); 8829 this.#cancelButton.classList.toggle("hidden", this.#firstTime); 8830 } 8831 #toggleAI(value) { 8832 if (!this.#uiManager || this.#hasAI === value) { 8833 return; 8834 } 8835 this.#hasAI = value; 8836 this.#dialog.classList.toggle("noAi", !value); 8837 this.#toggleTitleAndDisclaimer(); 8838 } 8839 #toggleTitleAndDisclaimer() { 8840 const visible = this.#isAILoading || this.#guessedAltText && this.#guessedAltText === this.#textarea.value; 8841 this.#disclaimer.hidden = !visible; 8842 const isEditing = this.#isAILoading || !!this.#textarea.value; 8843 if (this.#isEditing === isEditing) { 8844 return; 8845 } 8846 this.#isEditing = isEditing; 8847 this.#title.setAttribute("data-l10n-id", isEditing ? "pdfjs-editor-new-alt-text-dialog-edit-label" : "pdfjs-editor-new-alt-text-dialog-add-label"); 8848 } 8849 async #mlGuessAltText(isInitial) { 8850 if (this.#isAILoading) { 8851 return; 8852 } 8853 if (this.#textarea.value) { 8854 return; 8855 } 8856 if (isInitial && this.#previousAltText !== null) { 8857 return; 8858 } 8859 this.#guessedAltText = this.#currentEditor.guessedAltText; 8860 if (this.#previousAltText === null && this.#guessedAltText) { 8861 this.#addAltText(this.#guessedAltText); 8862 return; 8863 } 8864 this.#toggleLoading(true); 8865 this.#toggleTitleAndDisclaimer(); 8866 let hasError = false; 8867 try { 8868 const altText = await this.#currentEditor.mlGuessAltText(this.#imageData, false); 8869 if (altText) { 8870 this.#guessedAltText = altText; 8871 this.#wasAILoading = this.#isAILoading; 8872 if (this.#isAILoading) { 8873 this.#addAltText(altText); 8874 } 8875 } 8876 } catch (e) { 8877 console.error(e); 8878 hasError = true; 8879 } 8880 this.#toggleLoading(false); 8881 this.#toggleTitleAndDisclaimer(); 8882 if (hasError && this.#uiManager) { 8883 this.#toggleError(true); 8884 } 8885 } 8886 #addAltText(altText) { 8887 if (!this.#uiManager || this.#textarea.value) { 8888 return; 8889 } 8890 this.#textarea.value = altText; 8891 this.#toggleTitleAndDisclaimer(); 8892 } 8893 #setProgress() { 8894 this.#downloadModel.classList.toggle("hidden", false); 8895 const callback = async ({ 8896 detail: { 8897 finished, 8898 total, 8899 totalLoaded 8900 } 8901 }) => { 8902 const ONE_MEGA_BYTES = 1e6; 8903 totalLoaded = Math.min(0.99 * total, totalLoaded); 8904 const totalSize = this.#downloadModelDescription.ariaValueMax = Math.round(total / ONE_MEGA_BYTES); 8905 const downloadedSize = this.#downloadModelDescription.ariaValueNow = Math.round(totalLoaded / ONE_MEGA_BYTES); 8906 this.#downloadModelDescription.setAttribute("data-l10n-args", JSON.stringify({ 8907 totalSize, 8908 downloadedSize 8909 })); 8910 if (!finished) { 8911 return; 8912 } 8913 this.#eventBus._off("loadaiengineprogress", callback); 8914 this.#downloadModel.classList.toggle("hidden", true); 8915 this.#toggleAI(true); 8916 if (!this.#uiManager) { 8917 return; 8918 } 8919 const { 8920 mlManager 8921 } = this.#uiManager; 8922 mlManager.toggleService("altText", true); 8923 this.#toggleGuessAltText(await mlManager.isEnabledFor("altText"), true); 8924 }; 8925 this.#eventBus._on("loadaiengineprogress", callback); 8926 } 8927 async editAltText(uiManager, editor, firstTime) { 8928 if (this.#currentEditor || !editor) { 8929 return; 8930 } 8931 if (firstTime && editor.hasAltTextData()) { 8932 editor.altTextFinish(); 8933 return; 8934 } 8935 this.#firstTime = firstTime; 8936 const { 8937 mlManager 8938 } = uiManager; 8939 const hasAI = !!mlManager; 8940 this.#toggleTitleAndDisclaimer(); 8941 if (mlManager && !mlManager.isReady("altText")) { 8942 if (mlManager.hasProgress) { 8943 this.#setProgress(); 8944 } else { 8945 this.#createAutomaticallyButton.setAttribute("aria-pressed", false); 8946 } 8947 } else { 8948 this.#downloadModel.classList.toggle("hidden", true); 8949 } 8950 const isAltTextEnabledPromise = mlManager?.isEnabledFor("altText"); 8951 this.#currentEditor = editor; 8952 this.#uiManager = uiManager; 8953 this.#uiManager.removeEditListeners(); 8954 ({ 8955 altText: this.#previousAltText 8956 } = editor.altTextData); 8957 this.#textarea.value = this.#previousAltText ?? ""; 8958 const AI_MAX_IMAGE_DIMENSION = 224; 8959 const MAX_PREVIEW_DIMENSION = 180;
8960 let canvas, width, height; 8961 if (mlManager) { 8962 ({ 8963 canvas, 8964 width, 8965 height, 8966 imageData: this.#imageData 8967 } = editor.copyCanvas(AI_MAX_IMAGE_DIMENSION, MAX_PREVIEW_DIMENSION, true)); 8968 if (hasAI) { 8969 this.#toggleGuessAltText(await isAltTextEnabledPromise, true); 8970 } 8971 } else { 8972 ({ 8973 canvas, 8974 width, 8975 height 8976 } = editor.copyCanvas(AI_MAX_IMAGE_DIMENSION, MAX_PREVIEW_DIMENSION, false)); 8977 } 8978 canvas.setAttribute("role", "presentation"); 8979 const { 8980 style 8981 } = canvas; 8982 style.width = `${width}px`; 8983 style.height = `${height}px`; 8984 this.#imagePreview.append(canvas); 8985 this.#toggleNotNow(); 8986 this.#toggleAI(hasAI); 8987 this.#toggleError(false); 8988 try { 8989 await this.#overlayManager.open(this.#dialog); 8990 } catch (ex) { 8991 this.#close(); 8992 throw ex; 8993 } 8994 } 8995 #cancel() { 8996 this.#currentEditor.altTextData = { 8997 cancel: true 8998 }; 8999 const altText = this.#textarea.value.trim(); 9000 this.#currentEditor._reportTelemetry({ 9001 action: "pdfjs.image.alt_text.dismiss", 9002 data: { 9003 alt_text_type: altText ? "present" : "empty", 9004 flow: this.#firstTime ? "image_add" : "alt_text_edit" 9005 } 9006 }); 9007 this.#currentEditor._reportTelemetry({ 9008 action: "pdfjs.image.image_added", 9009 data: { 9010 alt_text_modal: true, 9011 alt_text_type: "skipped" 9012 } 9013 }); 9014 this.#finish(); 9015 } 9016 #finish() { 9017 this.#overlayManager.closeIfActive(this.#dialog); 9018 } 9019 #close() { 9020 const canvas = this.#imagePreview.firstElementChild; 9021 canvas.remove(); 9022 canvas.width = canvas.height = 0; 9023 this.#imageData = null; 9024 this.#toggleLoading(false); 9025 this.#uiManager?.addEditListeners(); 9026 this.#currentEditor.altTextFinish(); 9027 this.#uiManager?.setSelected(this.#currentEditor); 9028 this.#currentEditor = null; 9029 this.#uiManager = null; 9030 } 9031 #extractWords(text) { 9032 return new Set(text.toLowerCase().split(/[^\p{L}\p{N}]+/gu).filter(x => !!x)); 9033 } 9034 #save() { 9035 const altText = this.#textarea.value.trim(); 9036 this.#currentEditor.altTextData = { 9037 altText, 9038 decorative: false 9039 }; 9040 this.#currentEditor.altTextData.guessedAltText = this.#guessedAltText; 9041 if (this.#guessedAltText && this.#guessedAltText !== altText) { 9042 const guessedWords = this.#extractWords(this.#guessedAltText); 9043 const words = this.#extractWords(altText); 9044 this.#currentEditor._reportTelemetry({ 9045 action: "pdfjs.image.alt_text.user_edit", 9046 data: { 9047 total_words: guessedWords.size, 9048 words_removed: guessedWords.difference(words).size, 9049 words_added: words.difference(guessedWords).size 9050 } 9051 }); 9052 } 9053 this.#currentEditor._reportTelemetry({ 9054 action: "pdfjs.image.image_added", 9055 data: { 9056 alt_text_modal: true, 9057 alt_text_type: altText ? "present" : "empty" 9058 } 9059 }); 9060 this.#currentEditor._reportTelemetry({ 9061 action: "pdfjs.image.alt_text.save", 9062 data: { 9063 alt_text_type: altText ? "present" : "empty", 9064 flow: this.#firstTime ? "image_add" : "alt_text_edit" 9065 } 9066 }); 9067 this.#finish(); 9068 } 9069 destroy() { 9070 this.#uiManager = null; 9071 this.#finish(); 9072 } 9073} 9074class ImageAltTextSettings { 9075 #createModelButton; 9076 #dialog; 9077 #eventBus; 9078 #mlManager; 9079 #overlayManager; 9080 #showAltTextDialogButton; 9081 constructor({ 9082 dialog, 9083 createModelButton, 9084 learnMore, 9085 closeButton, 9086 showAltTextDialogButton 9087 }, overlayManager, eventBus, mlManager) { 9088 this.#dialog = dialog; 9089 this.#createModelButton = createModelButton; 9090 this.#showAltTextDialogButton = showAltTextDialogButton; 9091 this.#overlayManager = overlayManager; 9092 this.#eventBus = eventBus; 9093 this.#mlManager = mlManager; 9094 const { 9095 altTextLearnMoreUrl 9096 } = mlManager; 9097 if (altTextLearnMoreUrl) { 9098 learnMore.href = altTextLearnMoreUrl; 9099 } 9100 dialog.addEventListener("contextmenu", noContextMenu); 9101 createModelButton.addEventListener("click", async e => { 9102 const checked = this.#togglePref("enableGuessAltText", e); 9103 await (checked ? this.#download(true) : this.#delete(true)); 9104 await mlManager.toggleService("altText", checked); 9105 this.#reportTelemetry({ 9106 type: "stamp", 9107 action: "pdfjs.image.alt_text.settings_ai_generation_check", 9108 data: { 9109 status: checked 9110 } 9111 }); 9112 }); 9113 showAltTextDialogButton.addEventListener("click", e => { 9114 const checked = this.#togglePref("enableNewAltTextWhenAddingImage", e); 9115 this.#reportTelemetry({ 9116 type: "stamp", 9117 action: "pdfjs.image.alt_text.settings_edit_alt_text_check", 9118 data: { 9119 status: checked 9120 } 9121 }); 9122 }); 9123 closeButton.addEventListener("click", this.#finish.bind(this)); 9124 learnMore.addEventListener("click", () => { 9125 this.#reportTelemetry({ 9126 type: "stamp", 9127 action: "pdfjs.image.alt_text.info", 9128 data: { 9129 topic: "ai_generation" 9130 } 9131 }); 9132 }); 9133 eventBus._on("enablealttextmodeldownload", ({ 9134 value 9135 }) => { 9136 if (value) { 9137 this.#download(false); 9138 } else { 9139 this.#delete(false); 9140 } 9141 }); 9142 this.#overlayManager.register(dialog); 9143 } 9144 #reportTelemetry(data) { 9145 this.#eventBus.dispatch("reporttelemetry", { 9146 source: this, 9147 details: { 9148 type: "editing", 9149 data 9150 } 9151 }); 9152 } 9153 async #download(isFromUI = false) { 9154 if (isFromUI) { 9155 await this.#mlManager.downloadModel("altText"); 9156 this.#setPref("enableGuessAltText", true); 9157 this.#mlManager.toggleService("altText", true); 9158 this.#setPref("enableAltTextModelDownload", true); 9159 } 9160 } 9161 async #delete(isFromUI = false) { 9162 if (isFromUI) { 9163 await this.#mlManager.deleteModel("altText"); 9164 this.#setPref("enableGuessAltText", false); 9165 this.#setPref("enableAltTextModelDownload", false); 9166 } 9167 this.#createModelButton.setAttribute("aria-pressed", false); 9168 } 9169 async open({ 9170 enableGuessAltText, 9171 enableNewAltTextWhenAddingImage 9172 }) { 9173 const { 9174 enableAltTextModelDownload 9175 } = this.#mlManager; 9176 this.#createModelButton.setAttribute("aria-pressed", enableAltTextModelDownload && enableGuessAltText); 9177 this.#showAltTextDialogButton.setAttribute("aria-pressed", enableNewAltTextWhenAddingImage); 9178 await this.#overlayManager.open(this.#dialog); 9179 this.#reportTelemetry({ 9180 type: "stamp", 9181 action: "pdfjs.image.alt_text.settings_displayed" 9182 }); 9183 } 9184 #togglePref(name, { 9185 target 9186 }) { 9187 const checked = target.getAttribute("aria-pressed") !== "true"; 9188 this.#setPref(name, checked); 9189 target.setAttribute("aria-pressed", checked); 9190 return checked; 9191 } 9192 #setPref(name, value) { 9193 this.#eventBus.dispatch("setpreference", { 9194 source: this, 9195 name, 9196 value 9197 }); 9198 } 9199 #finish() { 9200 this.#overlayManager.closeIfActive(this.#dialog); 9201 } 9202} 9203 9204;// ./web/alt_text_manager.js 9205 9206class AltTextManager { 9207 #clickAC = null; 9208 #currentEditor = null; 9209 #cancelButton; 9210 #dialog; 9211 #eventBus; 9212 #hasUsedPointer = false;
9213 #optionDescription; 9214 #optionDecorative; 9215 #overlayManager; 9216 #saveButton; 9217 #textarea; 9218 #uiManager; 9219 #previousAltText = null; 9220 #resizeAC = null; 9221 #svgElement = null; 9222 #rectElement = null; 9223 #container; 9224 #telemetryData = null; 9225 constructor({ 9226 dialog, 9227 optionDescription, 9228 optionDecorative, 9229 textarea, 9230 cancelButton, 9231 saveButton 9232 }, container, overlayManager, eventBus) { 9233 this.#dialog = dialog; 9234 this.#optionDescription = optionDescription; 9235 this.#optionDecorative = optionDecorative; 9236 this.#textarea = textarea; 9237 this.#cancelButton = cancelButton; 9238 this.#saveButton = saveButton; 9239 this.#overlayManager = overlayManager; 9240 this.#eventBus = eventBus; 9241 this.#container = container; 9242 const onUpdateUIState = this.#updateUIState.bind(this); 9243 dialog.addEventListener("close", this.#close.bind(this)); 9244 dialog.addEventListener("contextmenu", event => { 9245 if (event.target !== this.#textarea) { 9246 event.preventDefault(); 9247 } 9248 }); 9249 cancelButton.addEventListener("click", this.#finish.bind(this)); 9250 saveButton.addEventListener("click", this.#save.bind(this)); 9251 optionDescription.addEventListener("change", onUpdateUIState); 9252 optionDecorative.addEventListener("change", onUpdateUIState); 9253 textarea.addEventListener("keydown", e => { 9254 if ((e.ctrlKey || e.metaKey) && e.key === "Enter" && !saveButton.disabled) { 9255 this.#save(); 9256 } 9257 }); 9258 this.#overlayManager.register(dialog); 9259 } 9260 #createSVGElement() { 9261 if (this.#svgElement) { 9262 return; 9263 } 9264 const svgFactory = new DOMSVGFactory(); 9265 const svg = this.#svgElement = svgFactory.createElement("svg"); 9266 svg.setAttribute("width", "0"); 9267 svg.setAttribute("height", "0"); 9268 const defs = svgFactory.createElement("defs"); 9269 svg.append(defs); 9270 const mask = svgFactory.createElement("mask"); 9271 defs.append(mask); 9272 mask.setAttribute("id", "alttext-manager-mask"); 9273 mask.setAttribute("maskContentUnits", "objectBoundingBox"); 9274 let rect = svgFactory.createElement("rect"); 9275 mask.append(rect); 9276 rect.setAttribute("fill", "white"); 9277 rect.setAttribute("width", "1"); 9278 rect.setAttribute("height", "1"); 9279 rect.setAttribute("x", "0"); 9280 rect.setAttribute("y", "0"); 9281 rect = this.#rectElement = svgFactory.createElement("rect"); 9282 mask.append(rect); 9283 rect.setAttribute("fill", "black"); 9284 this.#dialog.append(svg); 9285 } 9286 async editAltText(uiManager, editor) { 9287 if (this.#currentEditor || !editor) { 9288 return; 9289 } 9290 this.#createSVGElement(); 9291 this.#hasUsedPointer = false; 9292 this.#clickAC = new AbortController(); 9293 const clickOpts = { 9294 signal: this.#clickAC.signal 9295 }, 9296 onClick = this.#onClick.bind(this); 9297 for (const element of [this.#optionDescription, this.#optionDecorative, this.#textarea, this.#saveButton, this.#cancelButton]) { 9298 element.addEventListener("click", onClick, clickOpts); 9299 } 9300 const { 9301 altText, 9302 decorative 9303 } = editor.altTextData; 9304 if (decorative === true) { 9305 this.#optionDecorative.checked = true; 9306 this.#optionDescription.checked = false; 9307 } else { 9308 this.#optionDecorative.checked = false; 9309 this.#optionDescription.checked = true; 9310 } 9311 this.#previousAltText = this.#textarea.value = altText?.trim() || ""; 9312 this.#updateUIState(); 9313 this.#currentEditor = editor; 9314 this.#uiManager = uiManager; 9315 this.#uiManager.removeEditListeners(); 9316 this.#resizeAC = new AbortController(); 9317 this.#eventBus._on("resize", this.#setPosition.bind(this), { 9318 signal: this.#resizeAC.signal 9319 }); 9320 try { 9321 await this.#overlayManager.open(this.#dialog); 9322 this.#setPosition(); 9323 } catch (ex) { 9324 this.#close(); 9325 throw ex; 9326 } 9327 } 9328 #setPosition() { 9329 if (!this.#currentEditor) { 9330 return; 9331 } 9332 const dialog = this.#dialog; 9333 const { 9334 style 9335 } = dialog; 9336 const { 9337 x: containerX, 9338 y: containerY, 9339 width: containerW, 9340 height: containerH 9341 } = this.#container.getBoundingClientRect(); 9342 const { 9343 innerWidth: windowW, 9344 innerHeight: windowH 9345 } = window; 9346 const { 9347 width: dialogW, 9348 height: dialogH 9349 } = dialog.getBoundingClientRect(); 9350 const { 9351 x, 9352 y, 9353 width, 9354 height 9355 } = this.#currentEditor.getClientDimensions(); 9356 const MARGIN = 10; 9357 const isLTR = this.#uiManager.direction === "ltr"; 9358 const xs = Math.max(x, containerX); 9359 const xe = Math.min(x + width, containerX + containerW); 9360 const ys = Math.max(y, containerY);
9361 const ye = Math.min(y + height, containerY + containerH); 9362 this.#rectElement.setAttribute("width", `${(xe - xs) / windowW}`); 9363 this.#rectElement.setAttribute("height", `${(ye - ys) / windowH}`); 9364 this.#rectElement.setAttribute("x", `${xs / windowW}`); 9365 this.#rectElement.setAttribute("y", `${ys / windowH}`); 9366 let left = null; 9367 let top = Math.max(y, 0); 9368 top += Math.min(windowH - (top + dialogH), 0); 9369 if (isLTR) { 9370 if (x + width + MARGIN + dialogW < windowW) { 9371 left = x + width + MARGIN; 9372 } else if (x > dialogW + MARGIN) { 9373 left = x - dialogW - MARGIN; 9374 } 9375 } else if (x > dialogW + MARGIN) { 9376 left = x - dialogW - MARGIN; 9377 } else if (x + width + MARGIN + dialogW < windowW) { 9378 left = x + width + MARGIN; 9379 } 9380 if (left === null) { 9381 top = null; 9382 left = Math.max(x, 0); 9383 left += Math.min(windowW - (left + dialogW), 0); 9384 if (y > dialogH + MARGIN) { 9385 top = y - dialogH - MARGIN; 9386 } else if (y + height + MARGIN + dialogH < windowH) { 9387 top = y + height + MARGIN; 9388 } 9389 } 9390 if (top !== null) { 9391 dialog.classList.add("positioned"); 9392 if (isLTR) { 9393 style.left = `${left}px`; 9394 } else { 9395 style.right = `${windowW - left - dialogW}px`; 9396 } 9397 style.top = `${top}px`; 9398 } else { 9399 dialog.classList.remove("positioned"); 9400 style.left = ""; 9401 style.top = ""; 9402 } 9403 } 9404 #finish() { 9405 this.#overlayManager.closeIfActive(this.#dialog); 9406 } 9407 #close() { 9408 this.#currentEditor._reportTelemetry(this.#telemetryData || { 9409 action: "alt_text_cancel", 9410 alt_text_keyboard: !this.#hasUsedPointer 9411 }); 9412 this.#telemetryData = null; 9413 this.#removeOnClickListeners(); 9414 this.#uiManager?.addEditListeners(); 9415 this.#resizeAC?.abort(); 9416 this.#resizeAC = null; 9417 this.#currentEditor.altTextFinish(); 9418 this.#currentEditor = null; 9419 this.#uiManager = null; 9420 } 9421 #updateUIState() { 9422 this.#textarea.disabled = this.#optionDecorative.checked; 9423 } 9424 #save() { 9425 const altText = this.#textarea.value.trim(); 9426 const decorative = this.#optionDecorative.checked; 9427 this.#currentEditor.altTextData = { 9428 altText, 9429 decorative 9430 }; 9431 this.#telemetryData = { 9432 action: "alt_text_save", 9433 alt_text_description: !!altText, 9434 alt_text_edit: !!this.#previousAltText && this.#previousAltText !== altText, 9435 alt_text_decorative: decorative, 9436 alt_text_keyboard: !this.#hasUsedPointer 9437 }; 9438 this.#finish(); 9439 } 9440 #onClick(evt) { 9441 if (evt.detail === 0) { 9442 return; 9443 } 9444 this.#hasUsedPointer = true; 9445 this.#removeOnClickListeners(); 9446 } 9447 #removeOnClickListeners() { 9448 this.#clickAC?.abort(); 9449 this.#clickAC = null; 9450 } 9451 destroy() { 9452 this.#uiManager = null; 9453 this.#finish(); 9454 this.#svgElement?.remove(); 9455 this.#svgElement = this.#rectElement = null; 9456 } 9457} 9458 9459;// ./web/annotation_editor_params.js 9460 9461class AnnotationEditorParams { 9462 constructor(options, eventBus) { 9463 this.eventBus = eventBus; 9464 this.#bindListeners(options); 9465 } 9466 #bindListeners({ 9467 editorFreeTextFontSize, 9468 editorFreeTextColor, 9469 editorInkColor, 9470 editorInkThickness, 9471 editorInkOpacity, 9472 editorStampAddImage, 9473 editorFreeHighlightThickness, 9474 editorHighlightShowAll, 9475 editorSignatureAddSignature 9476 }) { 9477 const { 9478 eventBus 9479 } = this; 9480 const dispatchEvent = (typeStr, value) => { 9481 eventBus.dispatch("switchannotationeditorparams", { 9482 source: this, 9483 type: AnnotationEditorParamsType[typeStr], 9484 value 9485 }); 9486 }; 9487 editorFreeTextFontSize.addEventListener("input", function () { 9488 dispatchEvent("FREETEXT_SIZE", this.valueAsNumber); 9489 }); 9490 editorFreeTextColor.addEventListener("input", function () { 9491 dispatchEvent("FREETEXT_COLOR", this.value); 9492 }); 9493 editorInkColor.addEventListener("input", function () { 9494 dispatchEvent("INK_COLOR", this.value); 9495 }); 9496 editorInkThickness.addEventListener("input", function () { 9497 dispatchEvent("INK_THICKNESS", this.valueAsNumber); 9498 }); 9499 editorInkOpacity.addEventListener("input", function () { 9500 dispatchEvent("INK_OPACITY", this.valueAsNumber); 9501 }); 9502 editorStampAddImage.addEventListener("click", () => { 9503 eventBus.dispatch("reporttelemetry", { 9504 source: this, 9505 details: { 9506 type: "editing", 9507 data: { 9508 action: "pdfjs.image.add_image_click" 9509 } 9510 } 9511 }); 9512 dispatchEvent("CREATE"); 9513 }); 9514 editorFreeHighlightThickness.addEventListener("input", function () { 9515 dispatchEvent("HIGHLIGHT_THICKNESS", this.valueAsNumber); 9516 }); 9517 editorHighlightShowAll.addEventListener("click", function () { 9518 const checked = this.getAttribute("aria-pressed") === "true"; 9519 this.setAttribute("aria-pressed", !checked); 9520 dispatchEvent("HIGHLIGHT_SHOW_ALL", !checked); 9521 }); 9522 editorSignatureAddSignature.addEventListener("click", () => { 9523 dispatchEvent("CREATE"); 9524 }); 9525 eventBus._on("annotationeditorparamschanged", evt => { 9526 for (const [type, value] of evt.details) { 9527 switch (type) {
9528 case AnnotationEditorParamsType.FREETEXT_SIZE: 9529 editorFreeTextFontSize.value = value; 9530 break; 9531 case AnnotationEditorParamsType.FREETEXT_COLOR: 9532 editorFreeTextColor.value = value; 9533 break; 9534 case AnnotationEditorParamsType.INK_COLOR: 9535 editorInkColor.value = value; 9536 break; 9537 case AnnotationEditorParamsType.INK_THICKNESS: 9538 editorInkThickness.value = value; 9539 break; 9540 case AnnotationEditorParamsType.INK_OPACITY: 9541 editorInkOpacity.value = value; 9542 break; 9543 case AnnotationEditorParamsType.HIGHLIGHT_COLOR: 9544 eventBus.dispatch("mainhighlightcolorpickerupdatecolor", { 9545 source: this, 9546 value 9547 }); 9548 break; 9549 case AnnotationEditorParamsType.HIGHLIGHT_THICKNESS: 9550 editorFreeHighlightThickness.value = value; 9551 break; 9552 case AnnotationEditorParamsType.HIGHLIGHT_FREE: 9553 editorFreeHighlightThickness.disabled = !value; 9554 break; 9555 case AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL: 9556 editorHighlightShowAll.setAttribute("aria-pressed", value); 9557 break; 9558 } 9559 } 9560 }); 9561 } 9562} 9563 9564;// ./web/caret_browsing.js 9565 9566const PRECISION = 1e-1; 9567class CaretBrowsingMode { 9568 #mainContainer; 9569 #toolBarHeight = 0; 9570 #viewerContainer; 9571 constructor(abortSignal, mainContainer, viewerContainer, toolbarContainer) { 9572 this.#mainContainer = mainContainer; 9573 this.#viewerContainer = viewerContainer; 9574 if (!toolbarContainer) { 9575 return; 9576 } 9577 this.#toolBarHeight = toolbarContainer.getBoundingClientRect().height; 9578 const toolbarObserver = new ResizeObserver(entries => { 9579 for (const entry of entries) { 9580 if (entry.target === toolbarContainer) { 9581 this.#toolBarHeight = Math.floor(entry.borderBoxSize[0].blockSize); 9582 break; 9583 } 9584 } 9585 }); 9586 toolbarObserver.observe(toolbarContainer); 9587 abortSignal.addEventListener("abort", () => toolbarObserver.disconnect(), { 9588 once: true 9589 }); 9590 } 9591 #isOnSameLine(rect1, rect2) { 9592 const top1 = rect1.y; 9593 const bot1 = rect1.bottom; 9594 const mid1 = rect1.y + rect1.height / 2; 9595 const top2 = rect2.y; 9596 const bot2 = rect2.bottom; 9597 const mid2 = rect2.y + rect2.height / 2; 9598 return top1 <= mid2 && mid2 <= bot1 || top2 <= mid1 && mid1 <= bot2; 9599 } 9600 #isUnderOver(rect, x, y, isUp) { 9601 const midY = rect.y + rect.height / 2; 9602 return (isUp ? y >= midY : y <= midY) && rect.x - PRECISION <= x && x <= rect.right + PRECISION; 9603 } 9604 #isVisible(rect) { 9605 return rect.top >= this.#toolBarHeight && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth); 9606 } 9607 #getCaretPosition(selection, isUp) { 9608 const { 9609 focusNode, 9610 focusOffset 9611 } = selection; 9612 const range = document.createRange(); 9613 range.setStart(focusNode, focusOffset); 9614 range.setEnd(focusNode, focusOffset); 9615 const rect = range.getBoundingClientRect(); 9616 return [rect.x, isUp ? rect.top : rect.bottom]; 9617 } 9618 static #caretPositionFromPoint(x, y) { 9619 if (!document.caretPositionFromPoint) { 9620 const { 9621 startContainer: offsetNode, 9622 startOffset: offset 9623 } = document.caretRangeFromPoint(x, y); 9624 return { 9625 offsetNode, 9626 offset 9627 }; 9628 } 9629 return document.caretPositionFromPoint(x, y); 9630 } 9631 #setCaretPositionHelper(selection, caretX, select, element, rect) { 9632 rect ||= element.getBoundingClientRect(); 9633 if (caretX <= rect.x + PRECISION) { 9634 if (select) { 9635 selection.extend(element.firstChild, 0); 9636 } else { 9637 selection.setPosition(element.firstChild, 0); 9638 } 9639 return; 9640 } 9641 if (rect.right - PRECISION <= caretX) { 9642 const { 9643 lastChild 9644 } = element; 9645 if (select) { 9646 selection.extend(lastChild, lastChild.length); 9647 } else { 9648 selection.setPosition(lastChild, lastChild.length); 9649 } 9650 return; 9651 } 9652 const midY = rect.y + rect.height / 2;
9653 let caretPosition = CaretBrowsingMode.#caretPositionFromPoint(caretX, midY); 9654 let parentElement = caretPosition.offsetNode?.parentElement; 9655 if (parentElement && parentElement !== element) { 9656 const elementsAtPoint = document.elementsFromPoint(caretX, midY); 9657 const savedVisibilities = []; 9658 for (const el of elementsAtPoint) { 9659 if (el === element) { 9660 break; 9661 } 9662 const { 9663 style 9664 } = el; 9665 savedVisibilities.push([el, style.visibility]); 9666 style.visibility = "hidden"; 9667 } 9668 caretPosition = CaretBrowsingMode.#caretPositionFromPoint(caretX, midY); 9669 parentElement = caretPosition.offsetNode?.parentElement; 9670 for (const [el, visibility] of savedVisibilities) { 9671 el.style.visibility = visibility; 9672 } 9673 } 9674 if (parentElement !== element) { 9675 if (select) { 9676 selection.extend(element.firstChild, 0); 9677 } else { 9678 selection.setPosition(element.firstChild, 0); 9679 } 9680 return; 9681 } 9682 if (select) { 9683 selection.extend(caretPosition.offsetNode, caretPosition.offset); 9684 } else { 9685 selection.setPosition(caretPosition.offsetNode, caretPosition.offset); 9686 } 9687 } 9688 #setCaretPosition(select, selection, newLineElement, newLineElementRect, caretX) { 9689 if (this.#isVisible(newLineElementRect)) { 9690 this.#setCaretPositionHelper(selection, caretX, select, newLineElement, newLineElementRect); 9691 return; 9692 } 9693 this.#mainContainer.addEventListener("scrollend", this.#setCaretPositionHelper.bind(this, selection, caretX, select, newLineElement, null), { 9694 once: true 9695 }); 9696 newLineElement.scrollIntoView(); 9697 } 9698 #getNodeOnNextPage(textLayer, isUp) { 9699 while (true) { 9700 const page = textLayer.closest(".page"); 9701 const pageNumber = parseInt(page.getAttribute("data-page-number")); 9702 const nextPage = isUp ? pageNumber - 1 : pageNumber + 1; 9703 textLayer = this.#viewerContainer.querySelector(`.page[data-page-number="${nextPage}"] .textLayer`); 9704 if (!textLayer) { 9705 return null; 9706 } 9707 const walker = document.createTreeWalker(textLayer, NodeFilter.SHOW_TEXT); 9708 const node = isUp ? walker.lastChild() : walker.firstChild(); 9709 if (node) { 9710 return node; 9711 } 9712 } 9713 } 9714 moveCaret(isUp, select) { 9715 const selection = document.getSelection(); 9716 if (selection.rangeCount === 0) { 9717 return; 9718 } 9719 const { 9720 focusNode 9721 } = selection; 9722 const focusElement = focusNode.nodeType !== Node.ELEMENT_NODE ? focusNode.parentElement : focusNode; 9723 const root = focusElement.closest(".textLayer"); 9724 if (!root) { 9725 return; 9726 } 9727 const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT); 9728 walker.currentNode = focusNode; 9729 const focusRect = focusElement.getBoundingClientRect(); 9730 let newLineElement = null; 9731 const nodeIterator = (isUp ? walker.previousSibling : walker.nextSibling).bind(walker); 9732 while (nodeIterator()) { 9733 const element = walker.currentNode.parentElement; 9734 if (!this.#isOnSameLine(focusRect, element.getBoundingClientRect())) { 9735 newLineElement = element; 9736 break; 9737 } 9738 } 9739 if (!newLineElement) { 9740 const node = this.#getNodeOnNextPage(root, isUp); 9741 if (!node) { 9742 return; 9743 } 9744 if (select) { 9745 const lastNode = (isUp ? walker.firstChild() : walker.lastChild()) || focusNode; 9746 selection.extend(lastNode, isUp ? 0 : lastNode.length); 9747 const range = document.createRange(); 9748 range.setStart(node, isUp ? node.length : 0); 9749 range.setEnd(node, isUp ? node.length : 0); 9750 selection.addRange(range); 9751 return; 9752 } 9753 const [caretX] = this.#getCaretPosition(selection, isUp); 9754 const { 9755 parentElement 9756 } = node; 9757 this.#setCaretPosition(select, selection, parentElement, parentElement.getBoundingClientRect(), caretX); 9758 return; 9759 } 9760 const [caretX, caretY] = this.#getCaretPosition(selection, isUp); 9761 const newLineElementRect = newLineElement.getBoundingClientRect(); 9762 if (this.#isUnderOver(newLineElementRect, caretX, caretY, isUp)) { 9763 this.#setCaretPosition(select, selection, newLineElement, newLineElementRect, caretX); 9764 return; 9765 } 9766 while (nodeIterator()) { 9767 const element = walker.currentNode.parentElement; 9768 const elementRect = element.getBoundingClientRect(); 9769 if (!this.#isOnSameLine(newLineElementRect, elementRect)) { 9770 break; 9771 } 9772 if (this.#isUnderOver(elementRect, caretX, caretY, isUp)) { 9773 this.#setCaretPosition(select, selection, element, elementRect, caretX); 9774 return; 9775 } 9776 } 9777 this.#setCaretPosition(select, selection, newLineElement, newLineElementRect, caretX); 9778 } 9779} 9780 9781// EXTERNAL MODULE: ./node_modules/core-js/modules/es.weak-map.get-or-insert.js 9782var es_weak_map_get_or_insert = __webpack_require__(8454); 9783// EXTERNAL MODULE: ./node_modules/core-js/modules/es.weak-map.get-or-insert-computed.js 9784var es_weak_map_get_or_insert_computed = __webpack_require__(9452); 9785;// ./web/sidebar.js 9786 9787const RESIZE_TIMEOUT = 400; 9788class Sidebar { 9789 #initialWidth = 0; 9790 #width = 0; 9791 #coefficient; 9792 #resizeTimeout = null; 9793 #resizer; 9794 #isResizerOnTheLeft; 9795 #isKeyboardResizing = false;
9796 #resizeObserver; 9797 #prevX = 0; 9798 constructor({ 9799 sidebar, 9800 resizer, 9801 toggleButton 9802 }, ltr, isResizerOnTheLeft) { 9803 this._sidebar = sidebar; 9804 this.#coefficient = ltr === isResizerOnTheLeft ? -1 : 1; 9805 this.#resizer = resizer; 9806 this.#isResizerOnTheLeft = isResizerOnTheLeft; 9807 const style = window.getComputedStyle(sidebar); 9808 this.#initialWidth = this.#width = parseFloat(style.getPropertyValue("--sidebar-width")); 9809 resizer.ariaValueMin = parseFloat(style.getPropertyValue("--sidebar-min-width")) || 0; 9810 resizer.ariaValueMax = parseFloat(style.getPropertyValue("--sidebar-max-width")) || Infinity; 9811 resizer.ariaValueNow = this.#width; 9812 this.#makeSidebarResizable(); 9813 toggleButton.addEventListener("click", this.toggle.bind(this)); 9814 this._isOpen = false; 9815 sidebar.hidden = true; 9816 this.#resizeObserver = new ResizeObserver(([{ 9817 borderBoxSize: [{ 9818 inlineSize 9819 }] 9820 }]) => { 9821 if (!isNaN(this.#prevX)) { 9822 this.#prevX += this.#coefficient * (inlineSize - this.#width); 9823 } 9824 this.#setWidth(inlineSize); 9825 }); 9826 this.#resizeObserver.observe(sidebar); 9827 } 9828 #makeSidebarResizable() { 9829 const sidebarStyle = this._sidebar.style; 9830 let pointerMoveAC; 9831 const cancelResize = () => { 9832 this.#resizeTimeout = null; 9833 this._sidebar.classList.remove("resizing"); 9834 pointerMoveAC?.abort(); 9835 pointerMoveAC = null; 9836 this.#isKeyboardResizing = false; 9837 this.onStopResizing(); 9838 this.#prevX = NaN; 9839 }; 9840 this.#resizer.addEventListener("pointerdown", e => { 9841 if (pointerMoveAC) { 9842 cancelResize(); 9843 return; 9844 } 9845 this.onStartResizing(); 9846 const { 9847 clientX 9848 } = e; 9849 stopEvent(e); 9850 this.#prevX = clientX; 9851 pointerMoveAC = new AbortController(); 9852 const { 9853 signal 9854 } = pointerMoveAC; 9855 const sidebar = this._sidebar; 9856 sidebar.classList.add("resizing"); 9857 const parentStyle = sidebar.parentElement.style; 9858 parentStyle.minWidth = 0; 9859 window.addEventListener("contextmenu", noContextMenu, { 9860 signal 9861 }); 9862 window.addEventListener("pointermove", ev => { 9863 if (!pointerMoveAC || Math.abs(ev.clientX - this.#prevX) < 1) { 9864 return; 9865 } 9866 stopEvent(ev); 9867 sidebarStyle.width = `${Math.round(this.#width + this.#coefficient * (ev.clientX - this.#prevX))}px`; 9868 }, { 9869 signal, 9870 capture: true 9871 }); 9872 window.addEventListener("blur", cancelResize, { 9873 signal 9874 }); 9875 window.addEventListener("pointerup", ev => { 9876 if (pointerMoveAC) { 9877 cancelResize(); 9878 stopEvent(ev); 9879 } 9880 }, { 9881 signal 9882 }); 9883 }); 9884 this.#resizer.addEventListener("keydown", e => { 9885 const { 9886 key 9887 } = e; 9888 const isArrowLeft = key === "ArrowLeft"; 9889 if (isArrowLeft || key === "ArrowRight") { 9890 if (!this.#isKeyboardResizing) { 9891 this._sidebar.classList.add("resizing"); 9892 this.#isKeyboardResizing = true; 9893 this.onStartResizing(); 9894 } 9895 const base = e.ctrlKey || e.metaKey ? 10 : 1; 9896 const dx = base * (isArrowLeft ? -1 : 1); 9897 clearTimeout(this.#resizeTimeout); 9898 this.#resizeTimeout = setTimeout(cancelResize, RESIZE_TIMEOUT); 9899 sidebarStyle.width = `${Math.round(this.#width + this.#coefficient * dx)}px`; 9900 stopEvent(e); 9901 } 9902 }); 9903 } 9904 #setWidth(newWidth) { 9905 this.#width = newWidth; 9906 this.#resizer.ariaValueNow = Math.round(newWidth); 9907 if (this.#isResizerOnTheLeft) { 9908 this._sidebar.parentElement.style.insetInlineStart = `${(this.#initialWidth - newWidth).toFixed(3)}px`; 9909 } 9910 this.onResizing(newWidth); 9911 } 9912 get width() { 9913 return this.#width; 9914 } 9915 set width(newWidth) { 9916 this._sidebar.style.width = `${newWidth}px`; 9917 } 9918 onStartResizing() {} 9919 onStopResizing() {} 9920 onResizing(_newWidth) {} 9921 toggle(visibility = !this._isOpen) { 9922 this._sidebar.hidden = !(this._isOpen = visibility); 9923 } 9924 destroy() { 9925 this.#resizeObserver?.disconnect(); 9926 this.#resizeObserver = null; 9927 } 9928} 9929 9930;// ./web/comment_manager.js 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947class CommentManager { 9948 #dialog; 9949 #popup; 9950 #sidebar; 9951 static #hasForcedColors = null; 9952 constructor(commentDialog, sidebar, eventBus, linkService, overlayManager, ltr, hasForcedColors) { 9953 const dateFormat = new Intl.DateTimeFormat(undefined, { 9954 dateStyle: "long" 9955 }); 9956 this.dialogElement = commentDialog.dialog; 9957 this.#dialog = new CommentDialog(commentDialog, overlayManager, eventBus, ltr); 9958 this.#popup = new CommentPopup(eventBus, dateFormat, ltr, this.dialogElement); 9959 this.#sidebar = new CommentSidebar(sidebar, eventBus, linkService, this.#popup, dateFormat, ltr); 9960 this.#popup.sidebar = this.#sidebar; 9961 CommentManager.#hasForcedColors = hasForcedColors; 9962 } 9963 setSidebarUiManager(uiManager) { 9964 this.#sidebar.setUIManager(uiManager); 9965 } 9966 showSidebar(annotations) { 9967 this.#sidebar.show(annotations); 9968 } 9969 hideSidebar() { 9970 this.#sidebar.hide(); 9971 } 9972 removeComments(ids) { 9973 this.#sidebar.removeComments(ids); 9974 } 9975 selectComment(id) { 9976 this.#sidebar.selectComment(null, id); 9977 } 9978 addComment(annotation) { 9979 this.#sidebar.addComment(annotation); 9980 } 9981 updateComment(annotation) { 9982 this.#sidebar.updateComment(annotation); 9983 } 9984 toggleCommentPopup(editor, isSelected, visibility, isEditable) { 9985 if (isSelected) { 9986 this.selectComment(editor.uid); 9987 } 9988 this.#popup.toggle(editor, isSelected, visibility, isEditable); 9989 } 9990 destroyPopup() { 9991 this.#popup.destroy(); 9992 } 9993 updatePopupColor(editor) { 9994 this.#popup.updateColor(editor); 9995 } 9996 showDialog(uiManager, editor, posX, posY, options) { 9997 return this.#dialog.open(uiManager, editor, posX, posY, options); 9998 } 9999 makeCommentColor(color, opacity) { 10000 return CommentManager._makeCommentColor(color, opacity); 10001 } 10002 static _makeCommentColor(color, opacity) { 10003 return this.#hasForcedColors ? null : findContrastColor(applyOpacity(...color, opacity ?? 1), CSSConstants.commentForegroundColor); 10004 } 10005 destroy() { 10006 this.#dialog.destroy(); 10007 this.#sidebar.hide(); 10008 this.#popup.destroy(); 10009 } 10010} 10011class CommentSidebar extends Sidebar { 10012 #annotations = null; 10013 #eventBus; 10014 #boundCommentClick = this.#commentClick.bind(this); 10015 #boundCommentKeydown = this.#commentKeydown.bind(this); 10016 #closeButton; 10017 #commentsList; 10018 #commentCount; 10019 #dateFormat; 10020 #sidebarTitle; 10021 #learnMoreUrl; 10022 #linkService; 10023 #popup; 10024 #elementsToAnnotations = null; 10025 #idsToElements = null; 10026 #uiManager = null; 10027 constructor({ 10028 learnMoreUrl, 10029 sidebar, 10030 sidebarResizer, 10031 commentsList, 10032 commentCount, 10033 sidebarTitle, 10034 closeButton, 10035 commentToolbarButton 10036 }, eventBus, linkService, popup, dateFormat, ltr) { 10037 super({ 10038 sidebar, 10039 resizer: sidebarResizer, 10040 toggleButton: commentToolbarButton 10041 }, ltr, true); 10042 this.#sidebarTitle = sidebarTitle; 10043 this.#commentsList = commentsList; 10044 this.#commentCount = commentCount; 10045 this.#learnMoreUrl = learnMoreUrl; 10046 this.#linkService = linkService; 10047 this.#closeButton = closeButton; 10048 this.#popup = popup; 10049 this.#dateFormat = dateFormat; 10050 this.#eventBus = eventBus; 10051 closeButton.addEventListener("click", () => { 10052 eventBus.dispatch("switchannotationeditormode", { 10053 source: this, 10054 mode: AnnotationEditorType.NONE 10055 }); 10056 });
10057 const keyDownCallback = e => { 10058 if (e.key === "ArrowDown" || e.key === "Home" || e.key === "F6") { 10059 this.#commentsList.firstElementChild.focus(); 10060 stopEvent(e); 10061 } else if (e.key === "ArrowUp" || e.key === "End") { 10062 this.#commentsList.lastElementChild.focus(); 10063 stopEvent(e); 10064 } 10065 }; 10066 commentToolbarButton.addEventListener("keydown", keyDownCallback); 10067 sidebar.addEventListener("keydown", keyDownCallback); 10068 } 10069 setUIManager(uiManager) { 10070 this.#uiManager = uiManager; 10071 } 10072 show(annotations) { 10073 this.#elementsToAnnotations = new WeakMap(); 10074 this.#idsToElements = new Map(); 10075 this.#annotations = annotations; 10076 annotations.sort(this.#sortComments.bind(this)); 10077 if (annotations.length !== 0) { 10078 const fragment = document.createDocumentFragment(); 10079 for (const annotation of annotations) { 10080 fragment.append(this.#createCommentElement(annotation)); 10081 } 10082 this.#setCommentsCount(fragment); 10083 this.#commentsList.append(fragment); 10084 } else { 10085 this.#setCommentsCount(); 10086 } 10087 this._sidebar.hidden = false; 10088 this.#eventBus.dispatch("reporttelemetry", { 10089 source: this, 10090 details: { 10091 type: "commentSidebar", 10092 data: { 10093 numberOfAnnotations: annotations.length 10094 } 10095 } 10096 }); 10097 } 10098 hide() { 10099 this._sidebar.hidden = true; 10100 this.#commentsList.replaceChildren(); 10101 this.#elementsToAnnotations = null; 10102 this.#idsToElements = null; 10103 this.#annotations = null; 10104 } 10105 removeComments(ids) { 10106 if (ids.length === 0 || !this.#idsToElements) { 10107 return; 10108 } 10109 if (new Set(this.#idsToElements.keys()).difference(new Set(ids)).size === 0) { 10110 this.#removeAll(); 10111 return; 10112 } 10113 for (const id of ids) { 10114 this.#removeComment(id); 10115 } 10116 } 10117 focusComment(id) { 10118 const element = this.#idsToElements.get(id); 10119 if (!element) { 10120 return; 10121 } 10122 this._sidebar.scrollTop = element.offsetTop - this._sidebar.offsetTop; 10123 for (const el of this.#commentsList.children) { 10124 el.classList.toggle("selected", el === element); 10125 } 10126 } 10127 updateComment(annotation) { 10128 if (!this.#idsToElements) { 10129 return; 10130 } 10131 const { 10132 id, 10133 creationDate, 10134 modificationDate, 10135 richText, 10136 contentsObj, 10137 popupRef 10138 } = annotation; 10139 if (!popupRef || !richText && !contentsObj?.str) { 10140 this.#removeComment(id); 10141 } 10142 const element = this.#idsToElements.get(id); 10143 if (!element) { 10144 return; 10145 } 10146 const prevAnnotation = this.#elementsToAnnotations.get(element); 10147 let index = binarySearchFirstItem(this.#annotations, a => this.#sortComments(a, prevAnnotation) >= 0); 10148 if (index >= this.#annotations.length) { 10149 return; 10150 } 10151 this.#setDate(element.firstElementChild, modificationDate || creationDate); 10152 this.#setText(element.lastElementChild, richText, contentsObj); 10153 this.#annotations.splice(index, 1); 10154 index = binarySearchFirstItem(this.#annotations, a => this.#sortComments(a, annotation) >= 0); 10155 this.#annotations.splice(index, 0, annotation); 10156 if (index >= this.#commentsList.children.length) { 10157 this.#commentsList.append(element); 10158 } else { 10159 this.#commentsList.insertBefore(element, this.#commentsList.children[index]); 10160 } 10161 } 10162 #removeComment(id) { 10163 const element = this.#idsToElements?.get(id); 10164 if (!element) { 10165 return; 10166 } 10167 const annotation = this.#elementsToAnnotations.get(element); 10168 const index = binarySearchFirstItem(this.#annotations, a => this.#sortComments(a, annotation) >= 0); 10169 if (index >= this.#annotations.length) { 10170 return; 10171 } 10172 this.#annotations.splice(index, 1); 10173 element.remove(); 10174 this.#idsToElements.delete(id); 10175 this.#setCommentsCount(); 10176 } 10177 #removeAll() { 10178 this.#commentsList.replaceChildren(); 10179 this.#elementsToAnnotations = new WeakMap(); 10180 this.#idsToElements.clear(); 10181 this.#annotations.length = 0; 10182 this.#setCommentsCount(); 10183 } 10184 selectComment(element, id = null) { 10185 if (!this.#idsToElements) { 10186 return; 10187 } 10188 const hasNoElement = !element; 10189 element ||= this.#idsToElements.get(id); 10190 for (const el of this.#commentsList.children) { 10191 el.classList.toggle("selected", el === element); 10192 } 10193 if (hasNoElement) { 10194 element?.scrollIntoView({ 10195 behavior: "instant", 10196 block: "center" 10197 }); 10198 } 10199 } 10200 addComment(annotation) { 10201 if (this.#idsToElements?.has(annotation.id)) { 10202 return; 10203 } 10204 const { 10205 popupRef, 10206 contentsObj 10207 } = annotation; 10208 if (!popupRef || !contentsObj?.str) { 10209 return; 10210 } 10211 const commentItem = this.#createCommentElement(annotation); 10212 if (this.#annotations.length === 0) { 10213 this.#commentsList.replaceChildren(commentItem); 10214 this.#annotations.push(annotation); 10215 this.#setCommentsCount(); 10216 return; 10217 } 10218 const index = binarySearchFirstItem(this.#annotations, a => this.#sortComments(a, annotation) >= 0); 10219 this.#annotations.splice(index, 0, annotation); 10220 if (index >= this.#commentsList.children.length) { 10221 this.#commentsList.append(commentItem); 10222 } else { 10223 this.#commentsList.insertBefore(commentItem, this.#commentsList.children[index]); 10224 } 10225 this.#setCommentsCount(); 10226 } 10227 #setCommentsCount(container = this.#commentsList) { 10228 const count = this.#idsToElements.size; 10229 this.#sidebarTitle.setAttribute("data-l10n-args", JSON.stringify({ 10230 count 10231 })); 10232 this.#commentCount.textContent = count; 10233 if (count === 0) { 10234 container.append(this.#createZeroCommentElement()); 10235 } 10236 } 10237 #createZeroCommentElement() { 10238 const commentItem = document.createElement("li"); 10239 commentItem.classList.add("sidebarComment", "noComments"); 10240 const textDiv = document.createElement("div"); 10241 textDiv.className = "sidebarCommentText"; 10242 textDiv.setAttribute("data-l10n-id", "pdfjs-editor-comments-sidebar-no-comments1"); 10243 commentItem.append(textDiv); 10244 if (this.#learnMoreUrl) { 10245 const a = document.createElement("a"); 10246 a.setAttribute("data-l10n-id", "pdfjs-editor-comments-sidebar-no-comments-link"); 10247 a.href = this.#learnMoreUrl; 10248 a.target = "_blank"; 10249 a.rel = "noopener noreferrer"; 10250 commentItem.append(a); 10251 } 10252 return commentItem; 10253 } 10254 #setDate(element, date) { 10255 date = PDFDateString.toDateObject(date); 10256 element.dateTime = date.toISOString(); 10257 element.textContent = this.#dateFormat.format(date); 10258 } 10259 #setText(element, richText, contentsObj) { 10260 element.replaceChildren(); 10261 const html = richText?.str && (!contentsObj?.str || richText.str === contentsObj.str) ? richText.html : contentsObj?.str; 10262 renderRichText({ 10263 html, 10264 dir: contentsObj?.dir || "auto", 10265 className: "richText" 10266 }, element); 10267 } 10268 #createCommentElement(annotation) { 10269 const { 10270 id, 10271 creationDate, 10272 modificationDate, 10273 richText, 10274 contentsObj, 10275 color, 10276 opacity 10277 } = annotation; 10278 const commentItem = document.createElement("li"); 10279 commentItem.role = "button"; 10280 commentItem.className = "sidebarComment"; 10281 commentItem.tabIndex = -1; 10282 commentItem.style.backgroundColor = color && CommentManager._makeCommentColor(color, opacity) || ""; 10283 const dateDiv = document.createElement("time"); 10284 this.#setDate(dateDiv, modificationDate || creationDate); 10285 const textDiv = document.createElement("div"); 10286 textDiv.className = "sidebarCommentText"; 10287 this.#setText(textDiv, richText, contentsObj); 10288 commentItem.append(dateDiv, textDiv); 10289 commentItem.addEventListener("click", this.#boundCommentClick); 10290 commentItem.addEventListener("keydown", this.#boundCommentKeydown); 10291 this.#elementsToAnnotations.set(commentItem, annotation); 10292 this.#idsToElements.set(id, commentItem); 10293 return commentItem; 10294 } 10295 async #commentClick({ 10296 currentTarget 10297 }) { 10298 if (currentTarget.classList.contains("selected")) { 10299 currentTarget.classList.remove("selected"); 10300 this.#popup._hide(); 10301 return; 10302 } 10303 const annotation = this.#elementsToAnnotations.get(currentTarget); 10304 if (!annotation) { 10305 return; 10306 } 10307 this.#popup._hide(); 10308 const { 10309 id, 10310 pageIndex, 10311 rect 10312 } = annotation; 10313 const pageNumber = pageIndex + 1; 10314 const pageVisiblePromise = this.#uiManager?.waitForEditorsRendered(pageNumber); 10315 this.#linkService?.goToXY(pageNumber, rect[0], rect[3], { 10316 center: "both" 10317 }); 10318 this.selectComment(currentTarget); 10319 await pageVisiblePromise; 10320 this.#uiManager?.selectComment(pageIndex, id); 10321 } 10322 #commentKeydown(e) { 10323 const { 10324 key, 10325 currentTarget 10326 } = e; 10327 switch (key) { 10328 case "ArrowDown": 10329 (currentTarget.nextElementSibling || this.#commentsList.firstElementChild).focus(); 10330 stopEvent(e); 10331 break; 10332 case "ArrowUp": 10333 (currentTarget.previousElementSibling || this.#commentsList.lastElementChild).focus(); 10334 stopEvent(e); 10335 break; 10336 case "Home": 10337 this.#commentsList.firstElementChild.focus(); 10338 stopEvent(e); 10339 break; 10340 case "End": 10341 this.#commentsList.lastElementChild.focus(); 10342 stopEvent(e); 10343 break; 10344 case "Enter": 10345 case " ": 10346 this.#commentClick(e); 10347 stopEvent(e); 10348 break; 10349 case "ShiftTab": 10350 this.#closeButton.focus(); 10351 stopEvent(e); 10352 break; 10353 } 10354 } 10355 #sortComments(a, b) { 10356 const dateA = PDFDateString.toDateObject(a.modificationDate || a.creationDate);
10357 const dateB = PDFDateString.toDateObject(b.modificationDate || b.creationDate); 10358 if (dateA !== dateB) { 10359 if (dateA !== null && dateB !== null) { 10360 return dateB - dateA; 10361 } 10362 return dateA !== null ? -1 : 1; 10363 } 10364 if (a.pageIndex !== b.pageIndex) { 10365 return a.pageIndex - b.pageIndex; 10366 } 10367 if (a.rect[3] !== b.rect[3]) { 10368 return b.rect[3] - a.rect[3]; 10369 } 10370 if (a.rect[0] !== b.rect[0]) { 10371 return a.rect[0] - b.rect[0]; 10372 } 10373 if (a.rect[1] !== b.rect[1]) { 10374 return b.rect[1] - a.rect[1]; 10375 } 10376 if (a.rect[2] !== b.rect[2]) { 10377 return a.rect[2] - b.rect[2]; 10378 } 10379 return a.id.localeCompare(b.id); 10380 } 10381} 10382class CommentDialog { 10383 #dialog; 10384 #editor; 10385 #overlayManager; 10386 #previousText = ""; 10387 #commentText = ""; 10388 #textInput; 10389 #title; 10390 #saveButton; 10391 #uiManager; 10392 #prevDragX = 0; 10393 #prevDragY = 0; 10394 #dialogX = 0; 10395 #dialogY = 0; 10396 #isLTR; 10397 #eventBus; 10398 constructor({ 10399 dialog, 10400 toolbar, 10401 title, 10402 textInput, 10403 cancelButton, 10404 saveButton 10405 }, overlayManager, eventBus, ltr) { 10406 this.#dialog = dialog; 10407 this.#textInput = textInput; 10408 this.#overlayManager = overlayManager; 10409 this.#eventBus = eventBus; 10410 this.#saveButton = saveButton; 10411 this.#title = title; 10412 this.#isLTR = ltr; 10413 const finishBound = this.#finish.bind(this); 10414 dialog.addEventListener("close", finishBound); 10415 dialog.addEventListener("contextmenu", e => { 10416 if (e.target !== this.#textInput) { 10417 e.preventDefault(); 10418 } 10419 }); 10420 cancelButton.addEventListener("click", finishBound); 10421 saveButton.addEventListener("click", this.#save.bind(this)); 10422 textInput.addEventListener("input", () => { 10423 saveButton.disabled = textInput.value === this.#previousText; 10424 }); 10425 textInput.addEventListener("keydown", e => { 10426 if ((e.ctrlKey || e.metaKey) && e.key === "Enter" && !saveButton.disabled) { 10427 this.#save(); 10428 } 10429 }); 10430 let pointerMoveAC; 10431 const cancelDrag = () => { 10432 dialog.classList.remove("dragging"); 10433 pointerMoveAC?.abort(); 10434 pointerMoveAC = null; 10435 }; 10436 toolbar.addEventListener("pointerdown", e => { 10437 if (pointerMoveAC) { 10438 cancelDrag(); 10439 return; 10440 } 10441 const { 10442 clientX, 10443 clientY 10444 } = e; 10445 stopEvent(e); 10446 this.#prevDragX = clientX; 10447 this.#prevDragY = clientY; 10448 pointerMoveAC = new AbortController(); 10449 const { 10450 signal 10451 } = pointerMoveAC; 10452 const { 10453 innerHeight, 10454 innerWidth 10455 } = window; 10456 dialog.classList.add("dragging"); 10457 window.addEventListener("pointermove", ev => { 10458 if (!pointerMoveAC) { 10459 return; 10460 } 10461 const { 10462 clientX: x, 10463 clientY: y 10464 } = ev; 10465 this.#setPosition(this.#dialogX + (x - this.#prevDragX) / innerWidth, this.#dialogY + (y - this.#prevDragY) / innerHeight); 10466 this.#prevDragX = x; 10467 this.#prevDragY = y; 10468 stopEvent(ev); 10469 }, { 10470 signal 10471 }); 10472 window.addEventListener("blur", cancelDrag, { 10473 signal 10474 }); 10475 window.addEventListener("pointerup", ev => { 10476 if (pointerMoveAC) { 10477 cancelDrag(); 10478 stopEvent(ev); 10479 } 10480 }, { 10481 signal 10482 }); 10483 }); 10484 overlayManager.register(dialog); 10485 } 10486 async open(uiManager, editor, posX, posY, options) { 10487 if (editor) { 10488 this.#uiManager = uiManager; 10489 this.#editor = editor; 10490 } 10491 const { 10492 contentsObj: { 10493 str 10494 }, 10495 color, 10496 opacity 10497 } = editor.getData(); 10498 const { 10499 style: dialogStyle 10500 } = this.#dialog; 10501 if (color) { 10502 dialogStyle.backgroundColor = CommentManager._makeCommentColor(color, opacity); 10503 dialogStyle.borderColor = Util.makeHexColor(...color); 10504 } else { 10505 dialogStyle.backgroundColor = dialogStyle.borderColor = ""; 10506 } 10507 this.#commentText = str || ""; 10508 const textInput = this.#textInput; 10509 textInput.value = this.#previousText = this.#commentText; 10510 if (str) { 10511 this.#title.setAttribute("data-l10n-id", "pdfjs-editor-edit-comment-dialog-title-when-editing"); 10512 this.#saveButton.setAttribute("data-l10n-id", "pdfjs-editor-edit-comment-dialog-save-button-when-editing"); 10513 } else { 10514 this.#title.setAttribute("data-l10n-id", "pdfjs-editor-edit-comment-dialog-title-when-adding"); 10515 this.#saveButton.setAttribute("data-l10n-id", "pdfjs-editor-edit-comment-dialog-save-button-when-adding"); 10516 } 10517 if (options?.height) { 10518 textInput.style.height = `${options.height}px`; 10519 } 10520 this.#uiManager?.removeEditListeners(); 10521 this.#saveButton.disabled = true; 10522 const parentDimensions = options?.parentDimensions; 10523 const { 10524 innerHeight, 10525 innerWidth 10526 } = window; 10527 if (editor.hasDefaultPopupPosition()) { 10528 const { 10529 dialogWidth, 10530 dialogHeight 10531 } = this._dialogDimensions; 10532 if (parentDimensions) { 10533 if (this.#isLTR && posX + dialogWidth > Math.min(parentDimensions.x + parentDimensions.width, innerWidth)) { 10534 const buttonWidth = this.#editor.commentButtonWidth; 10535 posX -= dialogWidth - buttonWidth * parentDimensions.width; 10536 } else if (!this.#isLTR) { 10537 const buttonWidth = this.#editor.commentButtonWidth * parentDimensions.width; 10538 if (posX - dialogWidth < Math.max(0, parentDimensions.x)) { 10539 posX = Math.max(0, posX); 10540 } else { 10541 posX -= dialogWidth - buttonWidth; 10542 } 10543 } 10544 } 10545 const height = Math.max(dialogHeight, options?.height || 0
10545); 10546 if (posY + height > innerHeight) { 10547 posY = innerHeight - height; 10548 } 10549 if (posY < 0) { 10550 posY = 0; 10551 } 10552 } 10553 posX = MathClamp(posX / innerWidth, 0, 1); 10554 posY = MathClamp(posY / innerHeight, 0, 1); 10555 this.#setPosition(posX, posY); 10556 await this.#overlayManager.open(this.#dialog); 10557 textInput.focus(); 10558 } 10559 async #save() { 10560 this.#editor.comment = this.#textInput.value; 10561 this.#finish(); 10562 } 10563 get _dialogDimensions() { 10564 const dialog = this.#dialog; 10565 const { 10566 style 10567 } = dialog; 10568 style.opacity = "0"; 10569 style.display = "block"; 10570 const { 10571 width, 10572 height 10573 } = dialog.getBoundingClientRect(); 10574 style.opacity = style.display = ""; 10575 return shadow(this, "_dialogDimensions", { 10576 dialogWidth: width, 10577 dialogHeight: height 10578 }); 10579 } 10580 #setPosition(x, y) { 10581 this.#dialogX = x; 10582 this.#dialogY = y; 10583 const { 10584 style 10585 } = this.#dialog; 10586 style.left = `${100 * x}%`; 10587 style.top = `${100 * y}%`; 10588 } 10589 #finish() { 10590 if (!this.#editor) { 10591 return; 10592 } 10593 const edited = this.#textInput.value !== this.#commentText; 10594 this.#eventBus.dispatch("reporttelemetry", { 10595 source: this, 10596 details: { 10597 type: "comment", 10598 data: { 10599 edited 10600 } 10601 } 10602 }); 10603 this.#editor?.focusCommentButton(); 10604 this.#editor = null; 10605 this.#textInput.value = this.#previousText = this.#commentText = ""; 10606 this.#overlayManager.closeIfActive(this.#dialog); 10607 this.#textInput.style.height = ""; 10608 this.#uiManager?.addEditListeners(); 10609 this.#uiManager = null; 10610 } 10611 destroy() { 10612 this.#uiManager = null; 10613 this.#editor = null; 10614 this.#finish(); 10615 } 10616} 10617class CommentPopup { 10618 #buttonsContainer = null; 10619 #eventBus; 10620 #commentDialog; 10621 #dateFormat; 10622 #editor = null; 10623 #isLTR; 10624 #container = null; 10625 #text = null; 10626 #time = null; 10627 #prevDragX = 0; 10628 #prevDragY = 0; 10629 #posX = 0; 10630 #posY = 0; 10631 #previousFocusedElement = null; 10632 #selected = false; 10633 #visible = false; 10634 constructor(eventBus, dateFormat, ltr, commentDialog) { 10635 this.#eventBus = eventBus; 10636 this.#dateFormat = dateFormat; 10637 this.#isLTR = ltr; 10638 this.#commentDialog = commentDialog; 10639 this.sidebar = null; 10640 } 10641 get _popupWidth() { 10642 const container = this.#createPopup(); 10643 const { 10644 style 10645 } = container; 10646 style.opacity = "0"; 10647 style.display = "block"; 10648 document.body.append(container); 10649 const width = container.getBoundingClientRect().width; 10650 container.remove(); 10651 style.opacity = style.display = ""; 10652 return shadow(this, "_popupWidth", width); 10653 } 10654 #createPopup() { 10655 if (this.#container) { 10656 return this.#container; 10657 } 10658 const container = this.#container = document.createElement("div"); 10659 container.className = "commentPopup"; 10660 container.id = "commentPopup"; 10661 container.tabIndex = -1; 10662 container.role = "dialog"; 10663 container.ariaModal = "false"; 10664 container.addEventListener("contextmenu", noContextMenu); 10665 container.addEventListener("keydown", e => { 10666 if (e.key === "Escape") { 10667 this.toggle(this.#editor, true, false); 10668 this.#previousFocusedElement?.focus(); 10669 stopEvent(e); 10670 } 10671 }); 10672 container.addEventListener("click", () => { 10673 container.focus(); 10674 }); 10675 const top = document.createElement("div"); 10676 top.className = "commentPopupTop"; 10677 const time = this.#time = document.createElement("time"); 10678 time.className = "commentPopupTime"; 10679 const buttons = this.#buttonsContainer = document.createElement("div"); 10680 buttons.className = "commentPopupButtons"; 10681 const edit = document.createElement("button"); 10682 edit.classList.add("commentPopupEdit", "toolbarButton"); 10683 edit.tabIndex = 0; 10684 edit.setAttribute("data-l10n-id", "pdfjs-editor-edit-comment-popup-button"); 10685 edit.ariaHasPopup = "dialog"; 10686 edit.ariaControlsElements = [this.#commentDialog]; 10687 const editLabel = document.createElement("span"); 10688 editLabel.setAttribute("data-l10n-id", "pdfjs-editor-edit-comment-popup-button-label"); 10689 edit.append(editLabel); 10690 edit.addEventListener("click", () => { 10691 const editor = this.#editor; 10692 const height = parseFloat(getComputedStyle(this.#text).height); 10693 this.toggle(editor, true, false); 10694 editor.editComment({ 10695 height 10696 }); 10697 }); 10698 edit.addEventListener("contextmenu", noContextMenu); 10699 const del = document.createElement("button"); 10700 del.classList.add("commentPopupDelete", "toolbarButton"); 10701 del.tabIndex = 0; 10702 del.setAttribute("data-l10n-id", "pdfjs-editor-delete-comment-popup-button"); 10703 const delLabel = document.createElement("span"); 10704 delLabel.setAttribute("data-l10n-id", "pdfjs-editor-delete-comment-popup-button-label"); 10705 del.append(delLabel); 10706 del.addEventListener("click", () => { 10707 this.#eventBus.dispatch("reporttelemetry", { 10708 source: this, 10709 details: { 10710 type: "comment", 10711 data: { 10712 deleted: true 10713 } 10714 } 10715 }); 10716 const editor = this.#editor; 10717 const savedData = editor.comment; 10718 this.destroy(); 10719 if (savedData?.text) { 10720 editor._uiManager.deleteComment(editor, savedData); 10721 } else { 10722 editor.comment = null; 10723 } 10724 editor.focus(); 10725 }); 10726 del.addEventListener("contextmenu", noContextMenu); 10727 buttons.append(edit, del); 10728 top.append(time, buttons); 10729 const separator = document.createElement("hr"); 10730 const text = this.#text = document.createElement("div"); 10731 text.className = "commentPopupText"; 10732 container.append(top, separator, text); 10733 let pointerMoveAC; 10734 const cancelDrag = () => { 10735 container.classList.remove("dragging"); 10736 pointerMoveAC?.abort(); 10737 pointerMoveAC = null; 10738 }; 10739 top.addEventListener("pointerdown", e => { 10740 if (pointerMoveAC) { 10741 cancelDrag(); 10742 return; 10743 } 10744 const { 10745 target, 10746 clientX, 10747 clientY 10748 } = e; 10749 if (buttons.contains(target)) { 10750 return; 10751 } 10752 stopEvent(e); 10753 const { 10754 width: parentWidth, 10755 height: parentHeight 10756 } = this.#editor.parentBoundingClientRect; 10757 this.#prevDragX = clientX; 10758 this.#prevDragY = clientY; 10759 pointerMoveAC = new AbortController(); 10760 const { 10761 signal 10762 } = pointerMoveAC; 10763 container.classList.add("dragging"); 10764 window.addEventListener("pointermove", ev => { 10765 if (!pointerMoveAC) { 10766 return; 10767 } 10768 const { 10769 clientX: x, 10770 clientY: y 10771 } = ev; 10772 this.#setPosition(this.#posX + (x - this.#prevDragX) / parentWidth, this.#posY + (y - this.#prevDragY) / parentHeight, false); 10773 this.#prevDragX = x;
10774 this.#prevDragY = y; 10775 stopEvent(ev); 10776 }, { 10777 signal 10778 }); 10779 window.addEventListener("blur", cancelDrag, { 10780 signal 10781 }); 10782 window.addEventListener("pointerup", ev => { 10783 if (pointerMoveAC) { 10784 cancelDrag(); 10785 stopEvent(ev); 10786 } 10787 }, { 10788 signal 10789 }); 10790 }); 10791 return container; 10792 } 10793 updateColor(editor) { 10794 if (this.#editor !== editor || !this.#visible) { 10795 return; 10796 } 10797 const { 10798 color, 10799 opacity 10800 } = editor.getData(); 10801 this.#container.style.backgroundColor = color && CommentManager._makeCommentColor(color, opacity) || ""; 10802 } 10803 _hide(editor) { 10804 const container = this.#createPopup(); 10805 container.classList.toggle("hidden", true); 10806 container.classList.toggle("selected", false); 10807 (editor || this.#editor)?.setCommentButtonStates({ 10808 selected: false, 10809 hasPopup: false 10810 }); 10811 this.#editor = null; 10812 this.#selected = false; 10813 this.#visible = false; 10814 this.#text.replaceChildren(); 10815 this.sidebar.selectComment(null); 10816 } 10817 toggle(editor, isSelected, visibility = undefined, isEditable = true) { 10818 if (!editor) { 10819 this.destroy(); 10820 return; 10821 } 10822 if (isSelected) { 10823 visibility ??= this.#editor === editor ? !this.#selected || !this.#visible : true; 10824 } else { 10825 if (this.#selected) { 10826 return; 10827 } 10828 visibility ??= !this.#visible; 10829 } 10830 if (!visibility) { 10831 this._hide(editor); 10832 return; 10833 } 10834 this.#visible = true; 10835 if (this.#editor !== editor) { 10836 this.#editor?.setCommentButtonStates({ 10837 selected: false, 10838 hasPopup: false 10839 }); 10840 } 10841 const container = this.#createPopup(); 10842 this.#buttonsContainer.classList.toggle("hidden", !isEditable); 10843 container.classList.toggle("hidden", false); 10844 container.classList.toggle("selected", isSelected); 10845 this.#selected = isSelected; 10846 this.#editor = editor; 10847 editor.setCommentButtonStates({ 10848 selected: isSelected, 10849 hasPopup: true 10850 }); 10851 const { 10852 contentsObj, 10853 richText, 10854 creationDate, 10855 modificationDate, 10856 color, 10857 opacity 10858 } = editor.getData(); 10859 container.style.backgroundColor = color && CommentManager._makeCommentColor(color, opacity) || ""; 10860 this.#text.replaceChildren(); 10861 const html = richText?.str && (!contentsObj?.str || richText.str === contentsObj.str) ? richText.html : contentsObj?.str; 10862 if (html) { 10863 renderRichText({ 10864 html, 10865 dir: contentsObj?.dir || "auto", 10866 className: "richText" 10867 }, this.#text); 10868 } 10869 this.#time.textContent = this.#dateFormat.format(PDFDateString.toDateObject(modificationDate || creationDate)); 10870 this.#setPosition(...editor.commentPopupPosition, editor.hasDefaultPopupPosition()); 10871 editor.elementBeforePopup.after(container); 10872 container.addEventListener("focus", ({ 10873 relatedTarget 10874 }) => { 10875 this.#previousFocusedElement = relatedTarget; 10876 }, { 10877 once: true 10878 }); 10879 if (isSelected) { 10880 setTimeout(() => container.focus(), 0); 10881 } 10882 } 10883 #setPosition(x, y, correctPosition) { 10884 if (!correctPosition) { 10885 this.#editor.commentPopupPosition = [x, y]; 10886 } else { 10887 const parentRect = this.#editor.parentBoundingClientRect; 10888 const widthRatio = this._popupWidth / parentRect.width; 10889 if (this.#isLTR && x + widthRatio > 1 || !this.#isLTR && x - widthRatio >= 0) { 10890 const buttonWidth = this.#editor.commentButtonWidth; 10891 x -= widthRatio - buttonWidth; 10892 } 10893 const margin = 0.01; 10894 if (this.#isLTR) { 10895 x = Math.max(x, -parentRect.x / parentRect.width + margin); 10896 } else { 10897 x = Math.min(x, (window.innerWidth - parentRect.x) / parentRect.width - widthRatio - margin); 10898 } 10899 } 10900 this.#posX = x; 10901 this.#posY = y; 10902 const { 10903 style 10904 } = this.#container; 10905 style.left = `${100 * x}%`; 10906 style.top = `${100 * y}%`; 10907 } 10908 destroy() { 10909 this._hide(); 10910 this.#container?.remove(); 10911 this.#container = this.#text = this.#time = null; 10912 this.#prevDragX = this.#prevDragY = Infinity; 10913 this.#posX = this.#posY = 0; 10914 this.#previousFocusedElement = null; 10915 } 10916} 10917 10918;// ./web/base_download_manager.js 10919 10920 10921 10922 10923 10924 10925class BaseDownloadManager { 10926 #openBlobUrls = new WeakMap(); 10927 _triggerDownload(blobUrl, originalUrl, filename, isAttachment = false) { 10928 throw new Error("Not implemented: _triggerDownload"); 10929 } 10930 _getOpenDataUrl(blobUrl, filename, dest = null) { 10931 throw new Error("Not implemented: _getOpenDataUrl"); 10932 } 10933 downloadData(data, filename, contentType) { 10934 const blobUrl = URL.createObjectURL(new Blob([data], { 10935 type: contentType 10936 })); 10937 this._triggerDownload(blobUrl, blobUrl, filename, true); 10938 } 10939 openOrDownloadData(data, filename, dest = null) { 10940 const isPdfData = isPdfFile(filename); 10941 const contentType = isPdfData ? "application/pdf" : ""; 10942 if (isPdfData) { 10943 const blobUrl = this.#openBlobUrls.getOrInsertComputed(data, () => URL.createObjectURL(new Blob([data], { 10944 type: contentType 10945 })));
10946 try { 10947 const viewerUrl = this._getOpenDataUrl(blobUrl, filename, dest); 10948 window.open(viewerUrl); 10949 return true; 10950 } catch (ex) { 10951 console.error("openOrDownloadData:", ex); 10952 URL.revokeObjectURL(blobUrl); 10953 this.#openBlobUrls.delete(data); 10954 } 10955 } 10956 this.downloadData(data, filename, contentType); 10957 return false; 10958 } 10959 download(data, url, filename) { 10960 const blobUrl = data ? URL.createObjectURL(new Blob([data], { 10961 type: "application/pdf" 10962 })) : null; 10963 this._triggerDownload(blobUrl, url, filename); 10964 } 10965} 10966 10967;// ./web/download_manager.js 10968 10969 10970class DownloadManager extends BaseDownloadManager { 10971 _triggerDownload(blobUrl, originalUrl, filename, isAttachment = false) { 10972 if (!blobUrl && !isAttachment) { 10973 if (!createValidAbsoluteUrl(originalUrl, "http://example.com")) { 10974 throw new Error(`_triggerDownload - not a valid URL: ${originalUrl}`); 10975 } 10976 blobUrl = originalUrl + "#pdfjs.action=download"; 10977 } 10978 const a = document.createElement("a"); 10979 a.href = blobUrl; 10980 a.target = "_parent"; 10981 if ("download" in a) { 10982 a.download = filename; 10983 } 10984 (document.body || document.documentElement).append(a); 10985 a.click(); 10986 a.remove(); 10987 } 10988 _getOpenDataUrl(blobUrl, filename, dest = null) { 10989 let url = "?file=" + encodeURIComponent(blobUrl + "#" + filename); 10990 if (dest) { 10991 url += `#${escape(dest)}`; 10992 } 10993 return url; 10994 } 10995} 10996 10997;// ./web/editor_undo_bar.js 10998 10999 11000class EditorUndoBar { 11001 #closeButton = null; 11002 #container; 11003 #eventBus = null; 11004 #focusTimeout = null; 11005 #initController = null; 11006 isOpen = false; 11007 #message; 11008 #showController = null; 11009 #undoButton; 11010 static #l10nMessages = Object.freeze({ 11011 highlight: "pdfjs-editor-undo-bar-message-highlight", 11012 freetext: "pdfjs-editor-undo-bar-message-freetext", 11013 stamp: "pdfjs-editor-undo-bar-message-stamp", 11014 ink: "pdfjs-editor-undo-bar-message-ink", 11015 signature: "pdfjs-editor-undo-bar-message-signature", 11016 comment: "pdfjs-editor-undo-bar-message-comment", 11017 _multiple: "pdfjs-editor-undo-bar-message-multiple" 11018 }); 11019 constructor({ 11020 container, 11021 message, 11022 undoButton, 11023 closeButton 11024 }, eventBus) { 11025 this.#container = container; 11026 this.#message = message; 11027 this.#undoButton = undoButton; 11028 this.#closeButton = closeButton; 11029 this.#eventBus = eventBus; 11030 } 11031 destroy() { 11032 this.#initController?.abort(); 11033 this.#initController = null; 11034 this.hide(); 11035 } 11036 show(undoAction, messageData) { 11037 if (!this.#initController) { 11038 this.#initController = new AbortController(); 11039 const opts = { 11040 signal: this.#initController.signal 11041 }; 11042 const boundHide = this.hide.bind(this); 11043 this.#container.addEventListener("contextmenu", noContextMenu, opts); 11044 this.#closeButton.addEventListener("click", boundHide, opts); 11045 this.#eventBus._on("beforeprint", boundHide, opts); 11046 this.#eventBus._on("download", boundHide, opts); 11047 } 11048 this.hide(); 11049 if (typeof messageData === "string") { 11050 this.#message.setAttribute("data-l10n-id", EditorUndoBar.#l10nMessages[messageData]); 11051 } else { 11052 this.#message.setAttribute("data-l10n-id", EditorUndoBar.#l10nMessages._multiple); 11053 this.#message.setAttribute("data-l10n-args", JSON.stringify({ 11054 count: messageData 11055 })); 11056 } 11057 this.isOpen = true; 11058 this.#container.hidden = false; 11059 this.#showController = new AbortController(); 11060 this.#undoButton.addEventListener("click", () => { 11061 undoAction(); 11062 this.hide(); 11063 }, {
11064 signal: this.#showController.signal 11065 }); 11066 this.#focusTimeout = setTimeout(() => { 11067 this.#container.focus(); 11068 this.#focusTimeout = null; 11069 }, 100); 11070 } 11071 hide() { 11072 if (!this.isOpen) { 11073 return; 11074 } 11075 this.isOpen = false; 11076 this.#container.hidden = true; 11077 this.#showController?.abort(); 11078 this.#showController = null; 11079 if (this.#focusTimeout) { 11080 clearTimeout(this.#focusTimeout); 11081 this.#focusTimeout = null; 11082 } 11083 } 11084} 11085 11086;// ./web/overlay_manager.js 11087 11088 11089class OverlayManager { 11090 #overlays = new WeakMap(); 11091 #active = null; 11092 get active() { 11093 return this.#active; 11094 } 11095 async register(dialog, canForceClose = false) { 11096 if (typeof dialog !== "object") { 11097 throw new Error("Not enough parameters."); 11098 } else if (this.#overlays.has(dialog)) { 11099 throw new Error("The overlay is already registered."); 11100 } 11101 this.#overlays.set(dialog, { 11102 canForceClose 11103 }); 11104 dialog.addEventListener("cancel", ({ 11105 target 11106 }) => { 11107 if (this.#active === target) { 11108 this.#active = null; 11109 } 11110 }); 11111 } 11112 async open(dialog) { 11113 if (!this.#overlays.has(dialog)) { 11114 throw new Error("The overlay does not exist."); 11115 } else if (this.#active) { 11116 if (this.#active === dialog) { 11117 throw new Error("The overlay is already active."); 11118 } else if (this.#overlays.get(dialog).canForceClose) { 11119 await this.close(); 11120 } else { 11121 throw new Error("Another overlay is currently active."); 11122 } 11123 } 11124 this.#active = dialog; 11125 dialog.showModal(); 11126 } 11127 async close(dialog = this.#active) { 11128 if (!this.#overlays.has(dialog)) { 11129 throw new Error("The overlay does not exist."); 11130 } else if (!this.#active) { 11131 throw new Error("The overlay is currently not active."); 11132 } else if (this.#active !== dialog) { 11133 throw new Error("Another overlay is currently active."); 11134 } 11135 dialog.close(); 11136 this.#active = null; 11137 } 11138 async closeIfActive(dialog) { 11139 if (this.#active === dialog) { 11140 await this.close(dialog); 11141 } 11142 } 11143} 11144 11145;// ./web/password_prompt.js 11146 11147 11148class PasswordPrompt { 11149 #activeCapability = null; 11150 #updateCallback = null; 11151 #reason = null; 11152 constructor(options, overlayManager, isViewerEmbedded = false) { 11153 this.dialog = options.dialog; 11154 this.label = options.label; 11155 this.input = options.input; 11156 this.submitButton = options.submitButton; 11157 this.cancelButton = options.cancelButton; 11158 this.overlayManager = overlayManager; 11159 this._isViewerEmbedded = isViewerEmbedded; 11160 this.submitButton.addEventListener("click", this.#verify.bind(this)); 11161 this.cancelButton.addEventListener("click", this.close.bind(this)); 11162 this.input.addEventListener("keydown", e => { 11163 if (e.keyCode === 13) { 11164 this.#verify(); 11165 } 11166 }); 11167 this.overlayManager.register(this.dialog, true); 11168 this.dialog.addEventListener("close", this.#cancel.bind(this)); 11169 } 11170 async open() { 11171 await this.#activeCapability?.promise; 11172 this.#activeCapability = Promise.withResolvers(); 11173 try { 11174 await this.overlayManager.open(this.dialog); 11175 } catch (ex) { 11176 this.#activeCapability.resolve(); 11177 throw ex; 11178 } 11179 const passwordIncorrect = this.#reason === PasswordResponses.INCORRECT_PASSWORD; 11180 if (!this._isViewerEmbedded || passwordIncorrect) { 11181 this.input.focus(); 11182 } 11183 this.label.setAttribute("data-l10n-id", passwordIncorrect ? "pdfjs-password-invalid" : "pdfjs-password-label"); 11184 } 11185 async close() { 11186 this.overlayManager.closeIfActive(this.dialog); 11187 } 11188 #verify() { 11189 const password = this.input.value; 11190 if (password?.length > 0) { 11191 this.#invokeCallback(password); 11192 } 11193 } 11194 #cancel() { 11195 this.#invokeCallback(new Error("PasswordPrompt cancelled.")); 11196 this.#activeCapability.resolve(); 11197 } 11198 #invokeCallback(password) { 11199 if (!this.#updateCallback) { 11200 return; 11201 } 11202 this.close(); 11203 this.input.value = ""; 11204 this.#updateCallback(password); 11205 this.#updateCallback = null; 11206 } 11207 async setUpdateCallback(updateCallback, reason) { 11208 if (this.#activeCapability) { 11209 await this.#activeCapability.promise; 11210 } 11211 this.#updateCallback = updateCallback; 11212 this.#reason = reason; 11213 } 11214} 11215 11216;// ./web/base_tree_viewer.js 11217 11218 11219const TREEITEM_SELECTED_CLASS = "selected"; 11220class BaseTreeViewer { 11221 constructor(options) { 11222 this.container = options.container; 11223 this.eventBus = options.eventBus; 11224 this._l10n = options.l10n; 11225 this.reset(); 11226 } 11227 reset() { 11228 this._pdfDocument = null; 11229 this._lastToggleIsShow = true; 11230 this._currentTreeItem = null; 11231 this.container.replaceChildren(); 11232 this.container.classList.remove("withNesting"); 11233 } 11234 _dispatchEvent(count) { 11235 throw new Error("Not implemented: _dispatchEvent"); 11236 } 11237 _bindLink(element, params) { 11238 throw new Error("Not implemented: _bindLink"); 11239 } 11240 _normalizeTextContent(str) { 11241 return removeNullCharacters(str, true) || "\u2013"; 11242 } 11243 _addToggleButton(div, hidden = false) { 11244 const toggler = document.createElement("div"); 11245 toggler.className = "treeItemToggler"; 11246 if (hidden) { 11247 toggler.classList.add("treeItemsHidden"); 11248 } 11249 div.prepend(toggler); 11250 } 11251 _toggleTreeItem(root, show = false) { 11252 this._l10n.pause(); 11253 this._lastToggleIsShow = show; 11254 for (const toggler of root.querySelectorAll(".treeItemToggler")) { 11255 toggler.classList.toggle("treeItemsHidden", !show); 11256 } 11257 this._l10n.resume(); 11258 } 11259 _toggleAllTreeItems() { 11260 this._toggleTreeItem(this.container, !this._lastToggleIsShow); 11261 } 11262 _finishRendering(fragment, count, hasAnyNesting = false) { 11263 if (hasAnyNesting) { 11264 this.container.classList.add("withNesting"); 11265 this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden"); 11266 this.container.addEventListener("click", e => { 11267 const { 11268 target 11269 } = e; 11270 if (!target.classList.contains("treeItemToggler")) { 11271 return; 11272 } 11273 stopEvent(e); 11274 target.classList.toggle("treeItemsHidden"); 11275 if (e.shiftKey) { 11276 const shouldShowAll = !target.classList.contains("treeItemsHidden"); 11277 this._toggleTreeItem(target.parentNode, shouldShowAll); 11278 } 11279 }); 11280 } 11281 this._l10n.pause(); 11282 this.container.append(fragment); 11283 this._l10n.resume(); 11284 this._dispatchEvent(count); 11285 } 11286 render(params) { 11287 throw new Error("Not implemented: render"); 11288 } 11289 _updateCurrentTreeItem(treeItem = null) { 11290 if (this._currentTreeItem) { 11291 this._currentTreeItem.classList.remove(TREEITEM_SELECTED_CLASS); 11292 this._currentTreeItem = null; 11293 } 11294 if (treeItem) { 11295 treeItem.classList.add(TREEITEM_SELECTED_CLASS); 11296 this._currentTreeItem = treeItem; 11297 } 11298 } 11299 _scrollToCurrentTreeItem(treeItem) { 11300 if (!treeItem) { 11301 return; 11302 } 11303 this._l10n.pause();
11304 let currentNode = treeItem.parentNode; 11305 while (currentNode && currentNode !== this.container) { 11306 if (currentNode.classList.contains("treeItem")) { 11307 const toggler = currentNode.firstElementChild; 11308 toggler?.classList.remove("treeItemsHidden"); 11309 } 11310 currentNode = currentNode.parentNode; 11311 } 11312 this._l10n.resume(); 11313 this._updateCurrentTreeItem(treeItem); 11314 treeItem.scrollIntoView({ 11315 behavior: "instant", 11316 block: "center", 11317 inline: "center", 11318 container: "nearest" 11319 }); 11320 } 11321} 11322 11323;// ./web/pdf_attachment_viewer.js 11324 11325 11326 11327class PDFAttachmentViewer extends BaseTreeViewer { 11328 constructor(options) { 11329 super(options); 11330 this.downloadManager = options.downloadManager; 11331 this.eventBus._on("fileattachmentannotation", this.#appendAttachment.bind(this)); 11332 } 11333 reset(keepRenderedCapability = false) { 11334 super.reset(); 11335 this._attachments = null; 11336 if (!keepRenderedCapability) { 11337 this._renderedCapability = Promise.withResolvers(); 11338 } 11339 this._pendingDispatchEvent = false; 11340 } 11341 async _dispatchEvent(attachmentsCount) { 11342 this._renderedCapability.resolve(); 11343 if (attachmentsCount === 0 && !this._pendingDispatchEvent) { 11344 this._pendingDispatchEvent = true; 11345 await waitOnEventOrTimeout({ 11346 target: this.eventBus, 11347 name: "annotationlayerrendered", 11348 delay: 1000 11349 }); 11350 if (!this._pendingDispatchEvent) { 11351 return; 11352 } 11353 } 11354 this._pendingDispatchEvent = false; 11355 this.eventBus.dispatch("attachmentsloaded", { 11356 source: this, 11357 attachmentsCount 11358 }); 11359 } 11360 _bindLink(element, { 11361 content, 11362 description, 11363 filename 11364 }) { 11365 if (description) { 11366 element.title = description; 11367 } 11368 element.onclick = () => { 11369 this.downloadManager.openOrDownloadData(content, filename); 11370 return false; 11371 }; 11372 } 11373 render({ 11374 attachments, 11375 keepRenderedCapability = false 11376 }) { 11377 if (this._attachments) { 11378 this.reset(keepRenderedCapability); 11379 } 11380 this._attachments = attachments || null; 11381 if (!attachments) { 11382 this._dispatchEvent(0); 11383 return; 11384 } 11385 const fragment = document.createDocumentFragment(); 11386 const ul = document.createElement("ul"); 11387 fragment.append(ul); 11388 let attachmentsCount = 0; 11389 for (const name in attachments) { 11390 const item = attachments[name]; 11391 const li = document.createElement("li"); 11392 ul.append(li); 11393 const element = document.createElement("a"); 11394 li.append(element); 11395 this._bindLink(element, item); 11396 element.textContent = this._normalizeTextContent(item.filename); 11397 attachmentsCount++; 11398 } 11399 this._finishRendering(fragment, attachmentsCount); 11400 } 11401 #appendAttachment(item) { 11402 const renderedPromise = this._renderedCapability.promise; 11403 renderedPromise.then(() => { 11404 if (renderedPromise !== this._renderedCapability.promise) { 11405 return; 11406 } 11407 const attachments = this._attachments || Object.create(null); 11408 for (const name in attachments) { 11409 if (item.filename === name) { 11410 return; 11411 } 11412 } 11413 attachments[item.filename] = item; 11414 this.render({ 11415 attachments, 11416 keepRenderedCapability: true 11417 }); 11418 }); 11419 } 11420} 11421 11422;// ./web/grab_to_pan.js 11423 11424const CSS_CLASS_GRAB = "grab-to-pan-grab"; 11425class GrabToPan { 11426 #activateAC = null; 11427 #mouseDownAC = null; 11428 #scrollAC = null; 11429 constructor({ 11430 element 11431 }) { 11432 this.element = element; 11433 this.document = element.ownerDocument; 11434 const overlay = this.overlay = document.createElement("div"); 11435 overlay.className = "grab-to-pan-grabbing"; 11436 } 11437 activate() { 11438 if (!this.#activateAC) { 11439 this.#activateAC = new AbortController(); 11440 this.element.addEventListener("mousedown", this.#onMouseDown.bind(this), { 11441 capture: true, 11442 signal: this.#activateAC.signal 11443 }); 11444 this.element.classList.add(CSS_CLASS_GRAB); 11445 } 11446 } 11447 deactivate() { 11448 if (this.#activateAC) { 11449 this.#activateAC.abort(); 11450 this.#activateAC = null; 11451 this.#endPan(); 11452 this.element.classList.remove(CSS_CLASS_GRAB); 11453 } 11454 } 11455 toggle() { 11456 if (this.#activateAC) { 11457 this.deactivate(); 11458 } else { 11459 this.activate(); 11460 } 11461 } 11462 ignoreTarget(node) { 11463 return node.matches("a[href], a[href] *, input, textarea, button, button *, select, option"); 11464 } 11465 #onMouseDown(event) { 11466 if (event.button !== 0 || this.ignoreTarget(event.target)) { 11467 return; 11468 } 11469 if (event.originalTarget) {
11470 try { 11471 event.originalTarget.tagName; 11472 } catch { 11473 return; 11474 } 11475 } 11476 this.scrollLeftStart = this.element.scrollLeft; 11477 this.scrollTopStart = this.element.scrollTop; 11478 this.clientXStart = event.clientX; 11479 this.clientYStart = event.clientY; 11480 this.#mouseDownAC = new AbortController(); 11481 const boundEndPan = this.#endPan.bind(this), 11482 mouseOpts = { 11483 capture: true, 11484 signal: this.#mouseDownAC.signal 11485 }; 11486 this.document.addEventListener("mousemove", this.#onMouseMove.bind(this), mouseOpts); 11487 this.document.addEventListener("mouseup", boundEndPan, mouseOpts); 11488 this.#scrollAC = new AbortController(); 11489 this.element.addEventListener("scroll", boundEndPan, { 11490 capture: true, 11491 signal: this.#scrollAC.signal 11492 }); 11493 stopEvent(event); 11494 const focusedElement = document.activeElement; 11495 if (focusedElement && !focusedElement.contains(event.target)) { 11496 focusedElement.blur(); 11497 } 11498 } 11499 #onMouseMove(event) { 11500 this.#scrollAC?.abort(); 11501 this.#scrollAC = null; 11502 if (!(event.buttons & 1)) { 11503 this.#endPan(); 11504 return; 11505 } 11506 const xDiff = event.clientX - this.clientXStart; 11507 const yDiff = event.clientY - this.clientYStart; 11508 this.element.scrollTo({ 11509 top: this.scrollTopStart - yDiff, 11510 left: this.scrollLeftStart - xDiff, 11511 behavior: "instant" 11512 }); 11513 if (!this.overlay.parentNode) { 11514 document.body.append(this.overlay); 11515 } 11516 } 11517 #endPan() { 11518 this.#mouseDownAC?.abort(); 11519 this.#mouseDownAC = null; 11520 this.#scrollAC?.abort(); 11521 this.#scrollAC = null; 11522 this.overlay.remove(); 11523 } 11524} 11525 11526;// ./web/pdf_cursor_tools.js 11527 11528 11529 11530class PDFCursorTools { 11531 #active = CursorTool.SELECT; 11532 #prevActive = null; 11533 constructor({ 11534 container, 11535 eventBus, 11536 cursorToolOnLoad = CursorTool.SELECT 11537 }) { 11538 this.container = container; 11539 this.eventBus = eventBus; 11540 this.#addEventListeners(); 11541 Promise.resolve().then(() => { 11542 this.switchTool(cursorToolOnLoad); 11543 }); 11544 } 11545 get activeTool() { 11546 return this.#active; 11547 } 11548 switchTool(tool) { 11549 if (this.#prevActive !== null) { 11550 return; 11551 } 11552 this.#switchTool(tool); 11553 } 11554 #switchTool(tool, disabled = false) { 11555 if (tool === this.#active) { 11556 if (this.#prevActive !== null) { 11557 this.eventBus.dispatch("cursortoolchanged", { 11558 source: this, 11559 tool, 11560 disabled 11561 }); 11562 } 11563 return; 11564 } 11565 const disableActiveTool = () => { 11566 switch (this.#active) { 11567 case CursorTool.SELECT: 11568 break; 11569 case CursorTool.HAND: 11570 this._handTool.deactivate(); 11571 break; 11572 case CursorTool.ZOOM: 11573 } 11574 }; 11575 switch (tool) { 11576 case CursorTool.SELECT: 11577 disableActiveTool(); 11578 break; 11579 case CursorTool.HAND: 11580 disableActiveTool(); 11581 this._handTool.activate(); 11582 break; 11583 case CursorTool.ZOOM: 11584 default: 11585 console.error(`switchTool: "${tool}" is an unsupported value.`); 11586 return; 11587 } 11588 this.#active = tool; 11589 this.eventBus.dispatch("cursortoolchanged", { 11590 source: this, 11591 tool, 11592 disabled 11593 }); 11594 } 11595 #addEventListeners() { 11596 this.eventBus._on("switchcursortool", evt => { 11597 if (!evt.reset) { 11598 this.switchTool(evt.tool); 11599 } else if (this.#prevActive !== null) { 11600 annotationEditorMode = AnnotationEditorType.NONE; 11601 presentationModeState = PresentationModeState.NORMAL; 11602 enableActive(); 11603 } 11604 }); 11605 let annotationEditorMode = AnnotationEditorType.NONE, 11606 presentationModeState = PresentationModeState.NORMAL; 11607 const disableActive = () => { 11608 this.#prevActive ??= this.#active; 11609 this.#switchTool(CursorTool.SELECT, true); 11610 }; 11611 const enableActive = () => { 11612 if (this.#prevActive !== null && annotationEditorMode === AnnotationEditorType.NONE && presentationModeState === PresentationModeState.NORMAL) { 11613 this.#switchTool(this.#prevActive); 11614 this.#prevActive = null; 11615 } 11616 }; 11617 this.eventBus._on("annotationeditormodechanged", ({ 11618 mode 11619 }) => { 11620 annotationEditorMode = mode; 11621 if (mode === AnnotationEditorType.NONE) { 11622 enableActive(); 11623 } else { 11624 disableActive(); 11625 } 11626 }); 11627 this.eventBus._on("presentationmodechanged", ({ 11628 state 11629 }) => { 11630 presentationModeState = state; 11631 if (state === PresentationModeState.NORMAL) { 11632 enableActive(); 11633 } else if (state === PresentationModeState.FULLSCREEN) { 11634 disableActive(); 11635 } 11636 }); 11637 } 11638 get _handTool() { 11639 return shadow(this, "_handTool", new GrabToPan({ 11640 element: this.container 11641 })); 11642 } 11643} 11644 11645;// ./web/pdf_document_properties.js 11646 11647 11648
11649const NON_METRIC_LOCALES = ["en-us", "en-lr", "my"]; 11650const US_PAGE_NAMES = { 11651 "8.5x11": "pdfjs-document-properties-page-size-name-letter", 11652 "8.5x14": "pdfjs-document-properties-page-size-name-legal" 11653}; 11654const METRIC_PAGE_NAMES = { 11655 "297x420": "pdfjs-document-properties-page-size-name-a-three", 11656 "210x297": "pdfjs-document-properties-page-size-name-a-four" 11657}; 11658function getPageName(size, isPortrait, pageNames) { 11659 const width = isPortrait ? size.width : size.height; 11660 const height = isPortrait ? size.height : size.width; 11661 return pageNames[`${width}x${height}`]; 11662} 11663class PDFDocumentProperties { 11664 #fieldData = null; 11665 constructor({ 11666 dialog, 11667 fields, 11668 closeButton 11669 }, overlayManager, eventBus, l10n, fileNameLookup, titleLookup) { 11670 this.dialog = dialog; 11671 this.fields = fields; 11672 this.overlayManager = overlayManager; 11673 this.l10n = l10n; 11674 this._fileNameLookup = fileNameLookup; 11675 this._titleLookup = titleLookup; 11676 this.#reset(); 11677 closeButton.addEventListener("click", this.close.bind(this)); 11678 this.overlayManager.register(this.dialog); 11679 eventBus._on("pagechanging", evt => { 11680 this._currentPageNumber = evt.pageNumber; 11681 }); 11682 eventBus._on("rotationchanging", evt => { 11683 this._pagesRotation = evt.pagesRotation; 11684 }); 11685 } 11686 async open() { 11687 await Promise.all([this.overlayManager.open(this.dialog), this._dataAvailableCapability.promise]); 11688 const currentPageNumber = this._currentPageNumber; 11689 const pagesRotation = this._pagesRotation; 11690 if (this.#fieldData && currentPageNumber === this.#fieldData._currentPageNumber && pagesRotation === this.#fieldData._pagesRotation) { 11691 this.#updateUI(); 11692 return; 11693 } 11694 const [{ 11695 info, 11696 metadata, 11697 contentLength 11698 }, pdfPage] = await Promise.all([this.pdfDocument.getMetadata(), this.pdfDocument.getPage(currentPageNumber)]); 11699 const [fileName, fileSize, title, creationDate, modificationDate, pageSize, isLinearized] = await Promise.all([this._fileNameLookup(), this.#parseFileSize(contentLength), this._titleLookup(), this.#parseDate(metadata?.get("xmp:createdate"), info.CreationDate), this.#parseDate(metadata?.get("xmp:modifydate"), info.ModDate), this.#parsePageSize(getPageSizeInches(pdfPage), pagesRotation), this.#parseLinearization(info.IsLinearized)]); 11700 this.#fieldData = Object.freeze({ 11701 fileName, 11702 fileSize, 11703 title, 11704 author: metadata?.get("dc:creator")?.join("\n") || info.Author, 11705 subject: metadata?.get("dc:subject")?.join("\n") || info.Subject, 11706 keywords: metadata?.get("pdf:keywords") || info.Keywords, 11707 creationDate, 11708 modificationDate, 11709 creator: metadata?.get("xmp:creatortool") || info.Creator, 11710 producer: metadata?.get("pdf:producer") || info.Producer, 11711 version: info.PDFFormatVersion, 11712 pageCount: this.pdfDocument.numPages, 11713 pageSize, 11714 linearized: isLinearized, 11715 _currentPageNumber: currentPageNumber, 11716 _pagesRotation: pagesRotation 11717 }); 11718 this.#updateUI(); 11719 const { 11720 length 11721 } = await this.pdfDocument.getDownloadInfo(); 11722 if (contentLength === length) { 11723 return; 11724 } 11725 const data = Object.assign(Object.create(null), this.#fieldData); 11726 data.fileSize = await this.#parseFileSize(length); 11727 this.#fieldData = Object.freeze(data); 11728 this.#updateUI(); 11729 } 11730 async close() { 11731 this.overlayManager.close(this.dialog); 11732 } 11733 setDocument(pdfDocument) { 11734 if (this.pdfDocument) { 11735 this.#reset(); 11736 this.#updateUI(); 11737 } 11738 if (!pdfDocument) { 11739 return; 11740 } 11741 this.pdfDocument = pdfDocument; 11742 this._dataAvailableCapability.resolve(); 11743 } 11744 #reset() { 11745 this.pdfDocument = null; 11746 this.#fieldData = null; 11747 this._dataAvailableCapability = Promise.withResolvers(); 11748 this._currentPageNumber = 1; 11749 this._pagesRotation = 0; 11750 } 11751 #updateUI() { 11752 if (this.#fieldData && this.overlayManager.active !== this.dialog) { 11753 return; 11754 } 11755 for (const id in this.fields) { 11756 const content = this.#fieldData?.[id]; 11757 this.fields[id].textContent = content || content === 0 ? content : "-"; 11758 } 11759 } 11760 async #parseFileSize(b = 0) {
11761 const kb = b / 1024, 11762 mb = kb / 1024; 11763 return kb ? this.l10n.get(mb >= 1 ? "pdfjs-document-properties-size-mb" : "pdfjs-document-properties-size-kb", { 11764 mb, 11765 kb, 11766 b 11767 }) : undefined; 11768 } 11769 async #parsePageSize(pageSizeInches, pagesRotation) { 11770 if (!pageSizeInches) { 11771 return undefined; 11772 } 11773 if (pagesRotation % 180 !== 0) { 11774 pageSizeInches = { 11775 width: pageSizeInches.height, 11776 height: pageSizeInches.width 11777 }; 11778 } 11779 const isPortrait = isPortraitOrientation(pageSizeInches), 11780 nonMetric = NON_METRIC_LOCALES.includes(this.l10n.getLanguage()); 11781 let sizeInches = { 11782 width: Math.round(pageSizeInches.width * 100) / 100, 11783 height: Math.round(pageSizeInches.height * 100) / 100 11784 }; 11785 let sizeMillimeters = { 11786 width: Math.round(pageSizeInches.width * 25.4 * 10) / 10, 11787 height: Math.round(pageSizeInches.height * 25.4 * 10) / 10 11788 }; 11789 let nameId = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES); 11790 if (!nameId && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) { 11791 const exactMillimeters = { 11792 width: pageSizeInches.width * 25.4, 11793 height: pageSizeInches.height * 25.4 11794 }; 11795 const intMillimeters = { 11796 width: Math.round(sizeMillimeters.width), 11797 height: Math.round(sizeMillimeters.height) 11798 }; 11799 if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) { 11800 nameId = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES); 11801 if (nameId) { 11802 sizeInches = { 11803 width: Math.round(intMillimeters.width / 25.4 * 100) / 100, 11804 height: Math.round(intMillimeters.height / 25.4 * 100) / 100 11805 }; 11806 sizeMillimeters = intMillimeters; 11807 } 11808 } 11809 } 11810 const [{ 11811 width, 11812 height 11813 }, unit, name, orientation] = await Promise.all([nonMetric ? sizeInches : sizeMillimeters, this.l10n.get(nonMetric ? "pdfjs-document-properties-page-size-unit-inches" : "pdfjs-document-properties-page-size-unit-millimeters"), nameId && this.l10n.get(nameId), this.l10n.get(isPortrait ? "pdfjs-document-properties-page-size-orientation-portrait" : "pdfjs-document-properties-page-size-orientation-landscape")]); 11814 return this.l10n.get(name ? "pdfjs-document-properties-page-size-dimension-name-string" : "pdfjs-document-properties-page-size-dimension-string", { 11815 width, 11816 height, 11817 unit, 11818 name, 11819 orientation 11820 }); 11821 } 11822 async #parseDate(metadataDate, infoDate) { 11823 const dateObj = Date.parse(metadataDate) || PDFDateString.toDateObject(infoDate); 11824 return dateObj ? this.l10n.get("pdfjs-document-properties-date-time-string", { 11825 dateObj: dateObj.valueOf() 11826 }) : undefined; 11827 } 11828 #parseLinearization(isLinearized) { 11829 return this.l10n.get(isLinearized ? "pdfjs-document-properties-linearized-yes" : "pdfjs-document-properties-linearized-no"); 11830 } 11831} 11832 11833// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array-buffer.detached.js 11834var es_array_buffer_detached = __webpack_require__(6573); 11835// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array-buffer.transfer.js 11836var es_array_buffer_transfer = __webpack_require__(8100); 11837// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array-buffer.transfer-to-fixed-length.js 11838var es_array_buffer_transfer_to_fixed_length = __webpack_require__(7936); 11839// EXTERNAL MODULE: ./node_modules/core-js/modules/es.regexp.escape.js 11840var es_regexp_escape = __webpack_require__(6069); 11841// EXTERNAL MODULE: ./node_modules/core-js/modules/es.typed-array.with.js 11842var es_typed_array_with = __webpack_require__(9577); 11843;// ./web/pdf_find_utils.js 11844 11845 11846const CharacterType = { 11847 SPACE: 0, 11848 ALPHA_LETTER: 1, 11849 PUNCT: 2, 11850 HAN_LETTER: 3, 11851 KATAKANA_LETTER: 4, 11852 HIRAGANA_LETTER: 5, 11853 HALFWIDTH_KATAKANA_LETTER: 6, 11854 THAI_LETTER: 7 11855}; 11856function isAlphabeticalScript(charCode) { 11857 return charCode < 0x2e80; 11858} 11859function isAscii(charCode) { 11860 return (charCode & 0xff80) === 0; 11861} 11862function isAsciiAlpha(charCode) { 11863 return charCode >
11863= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a; 11864} 11865function isAsciiDigit(charCode) { 11866 return charCode >= 0x30 && charCode <= 0x39; 11867} 11868function isAsciiSpace(charCode) { 11869 return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a; 11870} 11871function isHan(charCode) { 11872 return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff; 11873} 11874function isKatakana(charCode) { 11875 return charCode >= 0x30a0 && charCode <= 0x30ff; 11876} 11877function isHiragana(charCode) { 11878 return charCode >= 0x3040 && charCode <= 0x309f; 11879} 11880function isHalfwidthKatakana(charCode) { 11881 return charCode >= 0xff60 && charCode <= 0xff9f; 11882} 11883function isThai(charCode) { 11884 return (charCode & 0xff80) === 0x0e00; 11885} 11886function getCharacterType(charCode) { 11887 if (isAlphabeticalScript(charCode)) { 11888 if (isAscii(charCode)) { 11889 if (isAsciiSpace(charCode)) { 11890 return CharacterType.SPACE; 11891 } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) { 11892 return CharacterType.ALPHA_LETTER; 11893 } 11894 return CharacterType.PUNCT; 11895 } else if (isThai(charCode)) { 11896 return CharacterType.THAI_LETTER; 11897 } else if (charCode === 0xa0) { 11898 return CharacterType.SPACE; 11899 } 11900 return CharacterType.ALPHA_LETTER; 11901 } 11902 if (isHan(charCode)) { 11903 return CharacterType.HAN_LETTER; 11904 } else if (isKatakana(charCode)) { 11905 return CharacterType.KATAKANA_LETTER; 11906 } else if (isHiragana(charCode)) { 11907 return CharacterType.HIRAGANA_LETTER; 11908 } else if (isHalfwidthKatakana(charCode)) { 11909 return CharacterType.HALFWIDTH_KATAKANA_LETTER; 11910 } 11911 return CharacterType.ALPHA_LETTER; 11912} 11913let NormalizeWithNFKC; 11914function getNormalizeWithNFKC() { 11915 if (!NormalizeWithNFKC) { 11916 const ranges = []; 11917 const range = []; 11918 const diacriticsRegex = /^\p{M}$/u; 11919 for (let i = 0; i < 65536; i++) { 11920 if (i >= 0xd800 && i <= 0xdfff) { 11921 continue; 11922 } 11923 const c = String.fromCharCode(i); 11924 if (c.normalize("NFKC") !== c && !diacriticsRegex.test(c)) { 11925 if (range.length !== 2) { 11926 range[0] = range[1] = i; 11927 continue; 11928 } 11929 if (range[1] + 1 !== i) { 11930 if (range[0] === range[1]) { 11931 ranges.push(String.fromCharCode(range[0])); 11932 } else { 11933 ranges.push(`${String.fromCharCode(range[0])}-${String.fromCharCode(range[1])}`); 11934 } 11935 range[0] = range[1] = i; 11936 } else { 11937 range[1] = i; 11938 } 11939 } 11940 } 11941 const rangesStr = ranges.join(""); 11942 if (!NormalizeWithNFKC) { 11943 NormalizeWithNFKC = rangesStr; 11944 } else if (rangesStr !== NormalizeWithNFKC) { 11945 for (let i = 1; i < rangesStr.length; i++) { 11946 if (rangesStr[i] !== NormalizeWithNFKC[i]) { 11947 console.log(`Difference at index ${i}: ` + `U+${rangesStr.charCodeAt(i).toString(16).toUpperCase().padStart(4, "0")}` + `!== U+${NormalizeWithNFKC.charCodeAt(i).toString(16).toUpperCase().padStart(4, "0")}`); 11948 break; 11949 } 11950 } 11951 throw new Error("getNormalizeWithNFKC - update the `NormalizeWithNFKC` string."); 11952 } 11953 } 11954 return NormalizeWithNFKC; 11955} 11956 11957;// ./web/pdf_find_controller.js 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981const FindState = { 11982 FOUND: 0, 11983 NOT_FOUND: 1, 11984 WRAPPED: 2, 11985 PENDING: 3 11986}; 11987const FIND_TIMEOUT = 250; 11988const MATCH_SCROLL_OFFSET_TOP = -50; 11989const CHARACTERS_TO_NORMALIZE = { 11990 "\u2010": "-", 11991 "\u2018": "'", 11992 "\u2019": "'", 11993 "\u201A": "'", 11994 "\u201B": "'", 11995 "\u201C": '"', 11996 "\u201D": '"', 11997 "\u201E": '"', 11998 "\u201F": '"', 11999 "\u00BC": "1/4", 12000 "\u00BD": "1/2", 12001 "\u00BE": "3/4" 12002}; 12003const DIACRITICS_EXCEPTION = new Set([0x3099, 0x309a, 0x094d, 0x09cd, 0x0a4d, 0x0acd, 0x0b4d, 0x0bcd, 0x0c4d, 0x0ccd, 0x0d3b, 0x0d3c, 0x0d4d, 0x0dca, 0x0e3a, 0x0eba, 0x0f84, 0x1039, 0x103a, 0x1714, 0x1734, 0x17d2, 0x1a60, 0x1b44, 0x1baa, 0x1bab, 0x1bf2, 0x1bf3, 0x2d7f, 0xa806, 0xa82c, 0xa8c4, 0xa953, 0xa9c0, 0xaaf6, 0xabed, 0x0c56, 0x0f71, 0x0f72, 0x0f7a, 0x0f7b, 0x0f7c, 0x0f7d, 0x0f80, 0x0f74]); 12004let DIACRITICS_EXCEPTION_STR; 12005const DIACRITICS_REG_EXP = /\p{M}+/gu; 12006const SPECIAL_CHARS_REG_EXP = /([+^$|])|(\p{P}+)|(\s+)|(\p{M})|(\p{L})/gu; 12007const NOT_DIACRITIC_FROM_END_REG_EXP = /([^\p{M}])\p{M}*$/u; 12008const NOT_DIACRITIC_FROM_START_REG_EXP = /^\p{M}*([^\p{M}])/u; 12009const SYLLABLES_REG_EXP = /[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g; 12010const SYLLABLES_LENGTHS = new Map(); 12011const FIRST_CHAR_SYLLABLES_REG_EXP = "[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]"; 12012const NFKC_CHARS_TO_NORMALIZE = new Map(); 12013let noSyllablesRegExp = null; 12014let withSyllablesRegExp = null; 12015function normalize(text, options = {}) { 12016 const syllablePositions = []; 12017 let m; 12018 while ((m = SYLLABLES_REG_EXP.exec(text)) !== null) { 12019 let { 12020 index 12021 } = m; 12022 for (const char of m[0]) { 12023 let len = SYLLABLES_LENGTHS.get(char); 12024 if (!len) { 12025 len = char.normalize("NFD").length; 12026 SYLLABLES_LENGTHS.set(char, len); 12027 } 12028 syllablePositions.push([len, index++]); 12029 } 12030 } 12031 const hasSyllables = syllablePositions.length > 0; 12032 const ignoreDashEOL = options.ignoreDashEOL ?? false; 12033 let normalizationRegex; 12034 if (!hasSyllables && noSyllablesRegExp) { 12035 normalizationRegex = noSyllablesRegExp; 12036 } else if (hasSyllables && withSyllablesRegExp) { 12037 normalizationRegex = withSyllablesRegExp; 12038 } else { 12039 const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join(""); 12040 const toNormalizeWithNFKC = getNormalizeWithNFKC(); 12041 const CJK = "(?:\\p{Ideographic}|[\u3040-\u30FF])";
12042 const HKDiacritics = "(?:\u3099|\u309A)"; 12043 const BrokenWord = `\\p{Ll}-\\n(?=\\p{Ll})|\\p{Lu}-\\n(?=\\p{L})`; 12044 const regexps = [`[${replace}]`, `[${toNormalizeWithNFKC}]`, `${HKDiacritics}\\n`, "\\p{M}+(?:-\\n)?", `${BrokenWord}`, "\\S-\\n", `${CJK}\\n`, "\\n", hasSyllables ? FIRST_CHAR_SYLLABLES_REG_EXP : "\\u0000"]; 12045 normalizationRegex = new RegExp(regexps.map(r => `(${r})`).join("|"), "gum"); 12046 if (hasSyllables) { 12047 withSyllablesRegExp = normalizationRegex; 12048 } else { 12049 noSyllablesRegExp = normalizationRegex; 12050 } 12051 } 12052 const rawDiacriticsPositions = []; 12053 while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) { 12054 rawDiacriticsPositions.push([m[0].length, m.index]); 12055 } 12056 let normalized = text.normalize("NFD"); 12057 const positions = [0, 0]; 12058 let rawDiacriticsIndex = 0; 12059 let syllableIndex = 0; 12060 let shift = 0; 12061 let shiftOrigin = 0; 12062 let eol = 0; 12063 let hasDiacritics = false; 12064 normalized = normalized.replace(normalizationRegex, (match, p1, p2, p3, p4, p5, p6, p7, p8, p9, i) => { 12065 i -= shiftOrigin; 12066 if (p1) { 12067 const replacement = CHARACTERS_TO_NORMALIZE[p1]; 12068 const jj = replacement.length; 12069 for (let j = 1; j < jj; j++) { 12070 positions.push(i - shift + j, shift - j); 12071 } 12072 shift -= jj - 1; 12073 return replacement; 12074 } 12075 if (p2) { 12076 let replacement = NFKC_CHARS_TO_NORMALIZE.get(p2); 12077 if (!replacement) { 12078 replacement = p2.normalize("NFKC"); 12079 NFKC_CHARS_TO_NORMALIZE.set(p2, replacement); 12080 } 12081 const jj = replacement.length; 12082 for (let j = 1; j < jj; j++) { 12083 positions.push(i - shift + j, shift - j); 12084 } 12085 shift -= jj - 1; 12086 return replacement; 12087 } 12088 if (p3) {
12089 hasDiacritics = true; 12090 if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) { 12091 ++rawDiacriticsIndex; 12092 } else { 12093 positions.push(i - 1 - shift + 1, shift - 1); 12094 shift -= 1; 12095 shiftOrigin += 1; 12096 } 12097 positions.push(i - shift + 1, shift); 12098 shiftOrigin += 1; 12099 eol += 1; 12100 return p3.charAt(0); 12101 } 12102 if (p4) { 12103 const hasTrailingDashEOL = p4.endsWith("\n"); 12104 const len = hasTrailingDashEOL ? p4.length - 2 : p4.length; 12105 hasDiacritics = true; 12106 let jj = len; 12107 if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) { 12108 jj -= rawDiacriticsPositions[rawDiacriticsIndex][0]; 12109 ++rawDiacriticsIndex; 12110 } 12111 for (let j = 1; j <= jj; j++) { 12112 positions.push(i - 1 - shift + j, shift - j); 12113 } 12114 shift -= jj; 12115 shiftOrigin += jj; 12116 if (hasTrailingDashEOL) { 12117 i += len - 1; 12118 positions.push(i - shift + 1, 1 + shift); 12119 shift += 1; 12120 shiftOrigin += 1; 12121 eol += 1; 12122 return p4.slice(0, len); 12123 } 12124 return p4; 12125 } 12126 if (p5) { 12127 if (ignoreDashEOL) { 12128 shiftOrigin += 1; 12129 eol += 1; 12130 return p5.slice(0, -1); 12131 } 12132 const len = p5.length - 2; 12133 positions.push(i - shift + len, 1 + shift); 12134 shift += 1; 12135 shiftOrigin += 1; 12136 eol += 1; 12137 return p5.slice(0, -2); 12138 } 12139 if (p6) { 12140 shiftOrigin += 1; 12141 eol += 1; 12142 return p6.slice(0, -1); 12143 } 12144 if (p7) { 12145 const len = p7.length - 1; 12146 positions.push(i - shift + len, shift); 12147 shiftOrigin += 1; 12148 eol += 1; 12149 return p7.slice(0, -1); 12150 } 12151 if (p8) { 12152 positions.push(i - shift + 1, shift - 1); 12153 shift -= 1; 12154 shiftOrigin += 1; 12155 eol += 1; 12156 return " "; 12157 } 12158 if (i + eol === syllablePositions[syllableIndex]?.[1]) { 12159 const newCharLen = syllablePositions[syllableIndex][0] - 1; 12160 ++syllableIndex; 12161 for (let j = 1; j <= newCharLen; j++) { 12162 positions.push(i - (shift - j), shift - j); 12163 } 12164 shift -= newCharLen; 12165 shiftOrigin += newCharLen; 12166 } 12167 return p9; 12168 }); 12169 positions.push(normalized.length, shift); 12170 const starts = new Uint32Array(positions.length >> 1); 12171 const shifts = new Int32Array(positions.length >> 1); 12172 for (let i = 0, ii = positions.length; i < ii; i += 2) { 12173 starts[i >> 1] = positions[i]; 12174 shifts[i >> 1] = positions[i + 1]; 12175 } 12176 return [normalized, [starts, shifts], hasDiacritics]; 12177} 12178function getOriginalIndex(diffs, pos, len) { 12179 if (!diffs) { 12180 return [pos, len]; 12181 } 12182 const [starts, shifts] = diffs; 12183 const start = pos; 12184 const end = pos + len - 1; 12185 let i = binarySearchFirstItem(starts, x => x >= start); 12186 if (starts[i] > start) { 12187 --i; 12188 } 12189 let j = binarySearchFirstItem(starts, x => x >= end, i); 12190 if (starts[j] > end) { 12191 --j; 12192 } 12193 const oldStart = start + shifts[i]; 12194 const oldEnd = end + shifts[j]; 12195 const oldLen = oldEnd + 1 - oldStart; 12196 return [oldStart, oldLen]; 12197} 12198class PDFFindController { 12199 #state = null; 12200 #updateMatchesCountOnProgress = true; 12201 #visitedPagesCount = 0; 12202 #copiedExtractTextPromises = null; 12203 constructor({ 12204 linkService, 12205 eventBus, 12206 updateMatchesCountOnProgress = true 12207 }) { 12208 this._linkService = linkService; 12209 this._eventBus = eventBus; 12210 this.#updateMatchesCountOnProgress = updateMatchesCountOnProgress; 12211 this.onIsPageVisible = null; 12212 this.#reset(); 12213 eventBus._on("find", this.#onFind.bind(this)); 12214 eventBus._on("findbarclose", this.#onFindBarClose.bind(this)); 12215 eventBus._on("pagesedited", this.#onPagesEdited.bind(this)); 12216 } 12217 get highlightMatches() { 12218 return this._highlightMatches; 12219 } 12220 get pageMatches() { 12221 return this._pageMatches; 12222 } 12223 get pageMatchesLength() { 12224 return this._pageMatchesLength; 12225 } 12226 get selected() { 12227 return this._selected; 12228 } 12229 get state() { 12230 return this.#state; 12231 } 12232 setDocument(pdfDocument) { 12233 if (this._pdfDocument) { 12234 this.#reset(); 12235 } 12236 if (!pdfDocument) { 12237 return; 12238 } 12239 this._pdfDocument = pdfDocument; 12240 this._firstPageCapability.resolve(); 12241 } 12242 #onFind(state) { 12243 if (!state) { 12244 return; 12245 } 12246 const pdfDocument = this._pdfDocument; 12247 const { 12248 type 12249 } = state; 12250 if (this.#state === null || this.#shouldDirtyMatch(state)) { 12251 this._dirtyMatch = true; 12252 } 12253 this.#state = state; 12254 if (type !== "highlightallchange") { 12255 this.#updateUIState(FindState.PENDING); 12256 } 12257 this._firstPageCapability.promise.then(() => { 12258 if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) { 12259 return; 12260 } 12261 this.#extractText(); 12262 const findbarClosed = !this._highlightMatches; 12263 const pendingTimeout = !!this._findTimeout; 12264 if (this._findTimeout) { 12265 clearTimeout(this._findTimeout); 12266 this._findTimeout = null; 12267 } 12268 if (!type) { 12269 this._findTimeout = setTimeout(() => { 12270 this.#nextMatch(); 12271 this._findTimeout = null; 12272 }, FIND_TIMEOUT); 12273 } else if (this._dirtyMatch) { 12274 this.#nextMatch(); 12275 } else if (type === "again") { 12276 this.#nextMatch(); 12277 if (findbarClosed && this.#state.highlightAll) { 12278 this.#updateAllPages(); 12279 } 12280 } else if (type === "highlightallchange") { 12281 if (pendingTimeout) { 12282 this.#nextMatch(); 12283 } else { 12284 this._highlightMatches = true; 12285 } 12286 this.#updateAllPages(); 12287 } else { 12288 this.#nextMatch(); 12289 } 12290 }); 12291 } 12292 scrollMatchIntoView({ 12293 element = null, 12294 selectedLeft = 0, 12295 pageIndex = -1, 12296 matchIndex = -1 12297 }) { 12298 if (!this._scrollMatches || !element) { 12299 return; 12300 } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) { 12301 return; 12302 } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) { 12303 return; 12304 } 12305 this._scrollMatches = false;
12306 const spot = { 12307 top: MATCH_SCROLL_OFFSET_TOP, 12308 left: selectedLeft 12309 }; 12310 scrollIntoView(element, spot, true); 12311 } 12312 #reset() { 12313 this._highlightMatches = false; 12314 this._scrollMatches = false; 12315 this._pdfDocument = null; 12316 this._pageMatches = []; 12317 this._pageMatchesLength = []; 12318 this.#visitedPagesCount = 0; 12319 this.#state = null; 12320 this._selected = { 12321 pageIdx: -1, 12322 matchIdx: -1 12323 }; 12324 this._offset = { 12325 pageIdx: null, 12326 matchIdx: null, 12327 wrapped: false 12328 }; 12329 this._extractTextPromises = []; 12330 this._pageContents = []; 12331 this._pageDiffs = []; 12332 this._hasDiacritics = []; 12333 this._matchesCountTotal = 0; 12334 this._pagesToSearch = null; 12335 this._pendingFindMatches = new Set(); 12336 this._resumePageIdx = null; 12337 this._dirtyMatch = false; 12338 clearTimeout(this._findTimeout); 12339 this._findTimeout = null; 12340 this.#copiedExtractTextPromises = null; 12341 this._firstPageCapability = Promise.withResolvers(); 12342 } 12343 get #query() { 12344 const { 12345 query 12346 } = this.#state; 12347 if (typeof query === "string") { 12348 if (query !== this._rawQuery) { 12349 this._rawQuery = query; 12350 [this._normalizedQuery] = normalize(query); 12351 } 12352 return this._normalizedQuery; 12353 } 12354 return (query || []).filter(q => !!q).map(q => normalize(q)[0]); 12355 } 12356 #shouldDirtyMatch(state) { 12357 const newQuery = state.query, 12358 prevQuery = this.#state.query; 12359 const newType = typeof newQuery, 12360 prevType = typeof prevQuery; 12361 if (newType !== prevType) { 12362 return true; 12363 } 12364 if (newType === "string") { 12365 if (newQuery !== prevQuery) { 12366 return true; 12367 } 12368 } else if (JSON.stringify(newQuery) !== JSON.stringify(prevQuery)) { 12369 return true; 12370 } 12371 switch (state.type) { 12372 case "again": 12373 const pageNumber = this._selected.pageIdx + 1; 12374 const linkService = this._linkService; 12375 return pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !(this.onIsPageVisible?.(pageNumber) ?? true); 12376 case "highlightallchange": 12377 return false; 12378 } 12379 return true; 12380 } 12381 #isEntireWord(content, startIdx, length) { 12382 let match = content.slice(0, startIdx).match(NOT_DIACRITIC_FROM_END_REG_EXP); 12383 if (match) { 12384 const first = content.charCodeAt(startIdx); 12385 const limit = match[1].charCodeAt(0); 12386 if (getCharacterType(first) === getCharacterType(limit)) { 12387 return false; 12388 } 12389 } 12390 match = content.slice(startIdx + length).match(NOT_DIACRITIC_FROM_START_REG_EXP); 12391 if (match) { 12392 const last = content.charCodeAt(startIdx + length - 1); 12393 const limit = match[1].charCodeAt(0); 12394 if (getCharacterType(last) === getCharacterType(limit)) { 12395 return false; 12396 } 12397 } 12398 return true; 12399 } 12400 #convertToRegExpString(query, hasDiacritics) { 12401 const { 12402 matchDiacritics 12403 } = this.#state; 12404 let isUnicode = false; 12405 const addExtraWhitespaces = (original, fixed) => { 12406 if (original === query) { 12407 return fixed; 12408 } 12409 if (query.startsWith(original)) { 12410 return `${fixed}[ ]*`; 12411 } 12412 if (query.endsWith(original)) { 12413 return `[ ]*${fixed}`;
12414 } 12415 return `[ ]*${fixed}[ ]*`; 12416 }; 12417 query = query.replaceAll(SPECIAL_CHARS_REG_EXP, (match, p1, p2, p3, p4, p5) => { 12418 if (p1) { 12419 return addExtraWhitespaces(p1, RegExp.escape(p1)); 12420 } 12421 if (p2) { 12422 return addExtraWhitespaces(p2, RegExp.escape(p2)); 12423 } 12424 if (p3) { 12425 return "[ ]+"; 12426 } 12427 if (matchDiacritics) { 12428 return p4 || p5; 12429 } 12430 if (p4) { 12431 return DIACRITICS_EXCEPTION.has(p4.charCodeAt(0)) ? p4 : ""; 12432 } 12433 if (hasDiacritics) { 12434 isUnicode = true; 12435 return `${p5}\\p{M}*`; 12436 } 12437 return p5; 12438 }); 12439 const trailingSpaces = "[ ]*"; 12440 if (query.endsWith(trailingSpaces)) { 12441 query = query.slice(0, query.length - trailingSpaces.length); 12442 } 12443 if (matchDiacritics) { 12444 if (hasDiacritics) { 12445 DIACRITICS_EXCEPTION_STR ||= String.fromCharCode(...DIACRITICS_EXCEPTION); 12446 isUnicode = true; 12447 query = `${query}(?=[${DIACRITICS_EXCEPTION_STR}]|[^\\p{M}]|$)`; 12448 } 12449 } 12450 return [isUnicode, query]; 12451 } 12452 #calculateMatch(pageIndex) { 12453 if (!this.#state) { 12454 return; 12455 } 12456 const query = this.#query; 12457 if (query.length === 0) { 12458 return; 12459 } 12460 const pageContent = this._pageContents[pageIndex]; 12461 const matcherResult = this.match(query, pageContent, pageIndex); 12462 const matches = this._pageMatches[pageIndex] = []; 12463 const matchesLength = this._pageMatchesLength[pageIndex] = []; 12464 const diffs = this._pageDiffs[pageIndex]; 12465 matcherResult?.forEach(({ 12466 index, 12467 length 12468 }) => { 12469 const [matchPos, matchLen] = getOriginalIndex(diffs, index, length); 12470 if (matchLen) { 12471 matches.push(matchPos); 12472 matchesLength.push(matchLen); 12473 } 12474 }); 12475 if (this.#state.highlightAll) { 12476 this.#updatePage(pageIndex); 12477 } 12478 if (this._resumePageIdx === pageIndex) { 12479 this._resumePageIdx = null; 12480 this.#nextPageMatch(); 12481 } 12482 const pageMatchesCount = matches.length; 12483 this._matchesCountTotal += pageMatchesCount; 12484 if (this.#updateMatchesCountOnProgress) { 12485 if (pageMatchesCount > 0) { 12486 this.#updateUIResultsCount(); 12487 } 12488 } else if (++this.#visitedPagesCount === this._linkService.pagesCount) { 12489 this.#updateUIResultsCount(); 12490 } 12491 } 12492 match(query, pageContent, pageIndex) {
12493 const hasDiacritics = this._hasDiacritics[pageIndex]; 12494 let isUnicode = false; 12495 if (typeof query === "string") { 12496 [isUnicode, query] = this.#convertToRegExpString(query, hasDiacritics); 12497 } else { 12498 query = query.sort().reverse().map(q => { 12499 const [isUnicodePart, queryPart] = this.#convertToRegExpString(q, hasDiacritics); 12500 isUnicode ||= isUnicodePart; 12501 return `(${queryPart})`; 12502 }).join("|"); 12503 } 12504 if (!query) { 12505 return undefined; 12506 } 12507 const { 12508 caseSensitive, 12509 entireWord 12510 } = this.#state; 12511 const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`; 12512 query = new RegExp(query, flags); 12513 const matches = []; 12514 let match; 12515 while ((match = query.exec(pageContent)) !== null) { 12516 if (entireWord && !this.#isEntireWord(pageContent, match.index, match[0].length)) { 12517 continue; 12518 } 12519 matches.push({ 12520 index: match.index, 12521 length: match[0].length 12522 }); 12523 } 12524 return matches; 12525 } 12526 #extractText() { 12527 if (this._extractTextPromises.length > 0) { 12528 return; 12529 } 12530 let deferred = Promise.resolve(); 12531 const textOptions = { 12532 disableNormalization: true 12533 }; 12534 const pdfDoc = this._pdfDocument; 12535 for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) { 12536 const { 12537 promise, 12538 resolve 12539 } = Promise.withResolvers(); 12540 this._extractTextPromises[i] = promise; 12541 deferred = deferred.then(async () => { 12542 if (pdfDoc !== this._pdfDocument) { 12543 resolve(); 12544 return; 12545 } 12546 await pdfDoc.getPage(i + 1).then(pdfPage => pdfPage.getTextContent(textOptions)).then(textContent => { 12547 const strBuf = []; 12548 for (const textItem of textContent.items) { 12549 strBuf.push(textItem.str); 12550 if (textItem.hasEOL) { 12551 strBuf.push("\n"); 12552 } 12553 } 12554 [this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] = normalize(strBuf.join("")); 12555 resolve(); 12556 }, reason => { 12557 console.error(`Unable to get text content for page ${i + 1}`, reason); 12558 this._pageContents[i] = ""; 12559 this._pageDiffs[i] = null; 12560 this._hasDiacritics[i] = false; 12561 resolve(); 12562 }); 12563 }); 12564 } 12565 } 12566 #updatePage(index) { 12567 if (this._scrollMatches && this._selected.pageIdx === index) { 12568 this._linkService.page = index + 1; 12569 } 12570 this._eventBus.dispatch("updatetextlayermatches", { 12571 source: this, 12572 pageIndex: index 12573 }); 12574 } 12575 #updateAllPages() { 12576 this._eventBus.dispatch("updatetextlayermatches", { 12577 source: this, 12578 pageIndex: -1 12579 }); 12580 } 12581 #nextMatch() { 12582 const previous = this.#state.findPrevious; 12583 const currentPageIndex = this._linkService.page - 1; 12584 const numPages = this._linkService.pagesCount; 12585 this._highlightMatches = true; 12586 if (this._dirtyMatch) { 12587 this._dirtyMatch = false; 12588 this._selected.pageIdx = this._selected.matchIdx = -1; 12589 this._offset.pageIdx = currentPageIndex; 12590 this._offset.matchIdx = null; 12591 this._offset.wrapped = false; 12592 this._resumePageIdx = null; 12593 this._pageMatches.length = 0; 12594 this._pageMatchesLength.length = 0; 12595 this.#visitedPagesCount = 0; 12596 this._matchesCountTotal = 0; 12597 this.#updateAllPages(); 12598 for (let i = 0; i < numPages; i++) { 12599 if (this._pendingFindMatches.has(i)) { 12600 continue; 12601 } 12602 this._pendingFindMatches.add(i); 12603 this._extractTextPromises[i].then(() => { 12604 this._pendingFindMatches.delete(i); 12605 this.#calculateMatch(i); 12606 }); 12607 } 12608 } 12609 const query = this.#query; 12610 if (query.length === 0) { 12611 this.#updateUIState(FindState.FOUND); 12612 return; 12613 } 12614 if (this._resumePageIdx) { 12615 return; 12616 } 12617 const offset = this._offset; 12618 this._pagesToSearch = numPages; 12619 if (offset.matchIdx !== null) { 12620 const numPageMatches = this._pageMatches[offset.pageIdx].length; 12621 if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchI
12621dx > 0) { 12622 offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1; 12623 this.#updateMatch(true); 12624 return; 12625 } 12626 this.#advanceOffsetPage(previous); 12627 } 12628 this.#nextPageMatch(); 12629 } 12630 #matchesReady(matches) { 12631 const offset = this._offset; 12632 const numMatches = matches.length; 12633 const previous = this.#state.findPrevious; 12634 if (numMatches) { 12635 offset.matchIdx = previous ? numMatches - 1 : 0; 12636 this.#updateMatch(true); 12637 return true; 12638 } 12639 this.#advanceOffsetPage(previous); 12640 if (offset.wrapped) { 12641 offset.matchIdx = null; 12642 if (this._pagesToSearch < 0) { 12643 this.#updateMatch(false); 12644 return true; 12645 } 12646 } 12647 return false; 12648 } 12649 #nextPageMatch() { 12650 if (this._resumePageIdx !== null) { 12651 console.error("There can only be one pending page."); 12652 } 12653 let matches = null; 12654 do { 12655 const pageIdx = this._offset.pageIdx; 12656 matches = this._pageMatches[pageIdx]; 12657 if (!matches) { 12658 this._resumePageIdx = pageIdx; 12659 break; 12660 } 12661 } while (!this.#matchesReady(matches)); 12662 } 12663 #advanceOffsetPage(previous) { 12664 const offset = this._offset; 12665 const numPages = this._linkService.pagesCount; 12666 offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1; 12667 offset.matchIdx = null; 12668 this._pagesToSearch--; 12669 if (offset.pageIdx >= numPages || offset.pageIdx < 0) { 12670 offset.pageIdx = previous ? numPages - 1 : 0; 12671 offset.wrapped = true; 12672 } 12673 } 12674 #updateMatch(found = false) { 12675 let state = FindState.NOT_FOUND; 12676 const wrapped = this._offset.wrapped; 12677 this._offset.wrapped = false; 12678 if (found) { 12679 const previousPage = this._selected.pageIdx; 12680 this._selected.pageIdx = this._offset.pageIdx; 12681 this._selected.matchIdx = this._offset.matchIdx; 12682 state = wrapped ? FindState.WRAPPED : FindState.FOUND; 12683 if (previousPage !== -1 && previousPage !== this._selected.pageIdx) { 12684 this.#updatePage(previousPage); 12685 } 12686 } 12687 this.#updateUIState(state, this.#state.findPrevious); 12688 if (this._selected.pageIdx !== -1) { 12689 this._scrollMatches = true; 12690 this.#updatePage(this._selected.pageIdx); 12691 } 12692 } 12693 #onPagesEdited({ 12694 pagesMapper, 12695 type, 12696 pageNumbers 12697 }) { 12698 if (this._extractTextPromises.length === 0) { 12699 return; 12700 } 12701 if (type === "copy") { 12702 this.#copiedExtractTextPromises = new Map(); 12703 for (const pageNum of pageNumbers) { 12704 this.#copiedExtractTextPromises.set(pageNum, this._extractTextPromises[pageNum - 1]); 12705 } 12706 return; 12707 } 12708 this.#onFindBarClose(); 12709 this._dirtyMatch = true; 12710 const prevTextPromises = this._extractTextPromises; 12711 const extractTextPromises = this._extractTextPromises.length = []; 12712 for (let i = 1, ii = pagesMapper.length; i <= ii; i++) { 12713 const prevPageNumber = pagesMapper.getPrevPageNumber(i); 12714 if (prevPageNumber < 0) { 12715 extractTextPromises.push(this.#copiedExtractTextPromises?.get(-prevPageNumber) || Promise.resolve()); 12716 continue; 12717 } 12718 extractTextPromises.push(prevTextPromises[prevPageNumber - 1] || Promise.resolve()); 12719 } 12720 } 12721 #onFindBarClose(evt) { 12722 const pdfDocument = this._pdfDocument; 12723 this._firstPageCapability.promise.then(() => { 12724 if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) { 12725 return; 12726 } 12727 if (this._findTimeout) { 12728 clearTimeout(this._findTimeout); 12729 this._findTimeout = null; 12730 } 12731 if (this._resumePageIdx) { 12732 this._resumePageIdx = null; 12733 this._dirtyMatch = true; 12734 } 12735 this.#updateUIState(FindState.FOUND); 12736 this._highlightMatches = false; 12737 this.#updateAllPages(); 12738 }); 12739 } 12740 #requestMatchesCount() { 12741 const { 12742 pageIdx, 12743 matchIdx 12744 } = this._selected; 12745 let current = 0, 12746 total = this._matchesCountTotal; 12747 if (matchIdx !== -1) { 12748 for (let i = 0; i < pageIdx; i++) { 12749 current += this._pageMatches[i]?.length || 0; 12750 } 12751 current += matchIdx + 1; 12752 } 12753 if (current < 1 || current > total) { 12754 current = total = 0; 12755 } 12756 return { 12757 current, 12758 total 12759 }; 12760 } 12761 #updateUIResultsCount() { 12762 this._eventBus.dispatch("updatefindmatchescount", { 12763 source: this, 12764 matchesCount: this.#requestMatchesCount() 12765 }); 12766 } 12767 #updateUIState(state, previous = false) { 12768 if (!this.#updateMatchesCountOnProgress && (this.#visitedPagesCount !== this._linkService.pagesCount || state === FindState.PENDING)) { 12769 return; 12770 }
12771 this._eventBus.dispatch("updatefindcontrolstate", { 12772 source: this, 12773 state, 12774 previous, 12775 entireWord: this.#state?.entireWord ?? null, 12776 matchesCount: this.#requestMatchesCount(), 12777 rawQuery: this.#state?.query ?? null 12778 }); 12779 } 12780} 12781 12782;// ./web/pdf_find_bar.js 12783 12784 12785 12786 12787 12788const MATCHES_COUNT_LIMIT = 1000; 12789class PDFFindBar { 12790 #mainContainer; 12791 #resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this)); 12792 opened = false; 12793 constructor(options, mainContainer, eventBus) { 12794 this.bar = options.bar; 12795 this.toggleButton = options.toggleButton; 12796 this.findField = options.findField; 12797 this.highlightAll = options.highlightAllCheckbox; 12798 this.caseSensitive = options.caseSensitiveCheckbox; 12799 this.matchDiacritics = options.matchDiacriticsCheckbox; 12800 this.entireWord = options.entireWordCheckbox; 12801 this.findMsg = options.findMsg; 12802 this.findResultsCount = options.findResultsCount; 12803 this.findPreviousButton = options.findPreviousButton; 12804 this.findNextButton = options.findNextButton; 12805 this.eventBus = eventBus; 12806 this.#mainContainer = mainContainer; 12807 const checkedInputs = new Map([[this.highlightAll, "highlightallchange"], [this.caseSensitive, "casesensitivitychange"], [this.entireWord, "entirewordchange"], [this.matchDiacritics, "diacriticmatchingchange"]]); 12808 this.toggleButton.addEventListener("click", () => { 12809 this.toggle(); 12810 }); 12811 this.findField.addEventListener("input", () => { 12812 this.dispatchEvent(""); 12813 }); 12814 this.bar.addEventListener("keydown", ({ 12815 keyCode, 12816 shiftKey, 12817 target 12818 }) => { 12819 switch (keyCode) { 12820 case 13: 12821 if (target === this.findField) { 12822 this.dispatchEvent("again", shiftKey); 12823 } else if (checkedInputs.has(target)) { 12824 target.checked = !target.checked; 12825 this.dispatchEvent(checkedInputs.get(target)); 12826 } 12827 break; 12828 case 27: 12829 this.close(); 12830 break; 12831 } 12832 }); 12833 this.findPreviousButton.addEventListener("click", () => { 12834 this.dispatchEvent("again", true); 12835 }); 12836 this.findNextButton.addEventListener("click", () => { 12837 this.dispatchEvent("again", false); 12838 }); 12839 for (const [elem, evtName] of checkedInputs) { 12840 elem.addEventListener("click", () => { 12841 this.dispatchEvent(evtName); 12842 }); 12843 } 12844 } 12845 reset() { 12846 this.updateUIState(); 12847 } 12848 dispatchEvent(type, findPrev = false) { 12849 this.eventBus.dispatch("find", { 12850 source: this, 12851 type, 12852 query: this.findField.value, 12853 caseSensitive: this.caseSensitive.checked, 12854 entireWord: this.entireWord.checked, 12855 highlightAll: this.highlightAll.checked, 12856 findPrevious: findPrev, 12857 matchDiacritics: this.matchDiacritics.checked 12858 }); 12859 } 12860 updateUIState(state, previous, matchesCount) { 12861 const { 12862 findField, 12863 findMsg 12864 } = this; 12865 let findMsgId = "", 12866 status = ""; 12867 switch (state) { 12868 case FindState.FOUND: 12869 break; 12870 case FindState.PENDING: 12871 status = "pending"; 12872 break; 12873 case FindState.NOT_FOUND: 12874 findMsgId = "pdfjs-find-not-found"; 12875 status = "notFound"; 12876 break; 12877 case FindState.WRAPPED: 12878 findMsgId = previous ? "pdfjs-find-reached-top" : "pdfjs-find-reached-bottom"; 12879 break; 12880 } 12881 findField.setAttribute("data-status", status); 12882 findField.setAttribute("aria-invalid", state === FindState.NOT_FOUND); 12883 findMsg.setAttribute("data-status", status); 12884 if (findMsgId) { 12885 findMsg.setAttribute("data-l10n-id", findMsgId); 12886 } else { 12887 findMsg.removeAttribute("data-l10n-id"); 12888 findMsg.textContent = ""; 12889 } 12890 this.updateResultsCount(matchesCount); 12891 } 12892 updateResultsCount({ 12893 current = 0, 12894 total = 0 12895 } = {}) { 12896 const { 12897 findResultsCount 12898 } = this; 12899 if (total > 0) { 12900 const limit = MATCHES_COUNT_LIMIT; 12901 findResultsCount.setAttribute("data-l10n-id", total > limit ? "pdfjs-find-match-count-limit" : "pdfjs-find-match-count"); 12902 findResultsCount.setAttribute("data-l10n-args", JSON.stringify({ 12903 limit, 12904 current, 12905 total 12906 })); 12907 } else { 12908 findResultsCount.removeAttribute("data-l10n-id"); 12909 findResultsCount.textContent = ""; 12910 } 12911 } 12912 open() { 12913 if (!this.opened) { 12914 this.#resizeObserver.observe(this.#mainContainer); 12915 this.#resizeObserver.observe(this.bar); 12916 this.opened = true; 12917 toggleExpandedBtn(this.toggleButton, true, this.bar); 12918 } 12919 this.findField.select(); 12920 this.findField.focus(); 12921 } 12922 close() { 12923 if (!this.opened) { 12924 return; 12925 } 12926 this.#resizeObserver.disconnect(); 12927 this.opened = false;
12928 toggleExpandedBtn(this.toggleButton, false, this.bar); 12929 this.eventBus.dispatch("findbarclose", { 12930 source: this 12931 }); 12932 } 12933 toggle() { 12934 if (this.opened) { 12935 this.close(); 12936 } else { 12937 this.open(); 12938 } 12939 } 12940 #resizeObserverCallback() { 12941 const { 12942 bar 12943 } = this; 12944 bar.classList.remove("wrapContainers"); 12945 const findbarHeight = bar.clientHeight; 12946 const inputContainerHeight = bar.firstElementChild.clientHeight; 12947 if (findbarHeight > inputContainerHeight) { 12948 bar.classList.add("wrapContainers"); 12949 } 12950 } 12951} 12952 12953;// ./web/pdf_history.js 12954 12955 12956 12957 12958const HASH_CHANGE_TIMEOUT = 1000; 12959const POSITION_UPDATED_THRESHOLD = 50; 12960const UPDATE_VIEWAREA_TIMEOUT = 1000; 12961function getCurrentHash() { 12962 return document.location.hash; 12963} 12964class PDFHistory { 12965 #eventAbortController = null; 12966 constructor({ 12967 linkService, 12968 eventBus 12969 }) { 12970 this.linkService = linkService; 12971 this.eventBus = eventBus; 12972 this._initialized = false; 12973 this._fingerprint = ""; 12974 this.reset(); 12975 this.eventBus._on("pagesinit", () => { 12976 this._isPagesLoaded = false; 12977 this.eventBus._on("pagesloaded", evt => { 12978 this._isPagesLoaded = !!evt.pagesCount; 12979 }, { 12980 once: true 12981 }); 12982 }); 12983 } 12984 initialize({ 12985 fingerprint, 12986 resetHistory = false, 12987 updateUrl = false 12988 }) { 12989 if (!fingerprint || typeof fingerprint !== "string") { 12990 console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.'); 12991 return; 12992 } 12993 if (this._initialized) { 12994 this.reset(); 12995 } 12996 const reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint; 12997 this._fingerprint = fingerprint; 12998 this._updateUrl = updateUrl === true; 12999 this._initialized = true; 13000 this.#bindEvents(); 13001 const state = window.history.state; 13002 this._popStateInProgress = false; 13003 this._blockHashChange = 0; 13004 this._currentHash = getCurrentHash(); 13005 this._numPositionUpdates = 0; 13006 this._uid = this._maxUid = 0; 13007 this._destination = null; 13008 this._position = null; 13009 if (!this.#isValidState(state, true) || resetHistory) { 13010 const { 13011 hash, 13012 page, 13013 rotation 13014 } = this.#parseCurrentHash(true); 13015 if (!hash || reInitialized || resetHistory) { 13016 this.#pushOrReplaceState(null, true); 13017 return; 13018 } 13019 this.#pushOrReplaceState({ 13020 hash, 13021 page, 13022 rotation 13023 }, true); 13024 return; 13025 } 13026 const destination = state.destination; 13027 this.#updateInternalState(destination, state.uid, true); 13028 if (destination.rotation !== undefined) { 13029 this._initialRotation = destination.rotation; 13030 } 13031 if (destination.dest) { 13032 this._initialBookmark = JSON.stringify(destination.dest); 13033 this._destination.page = null; 13034 } else if (destination.hash) { 13035 this._initialBookmark = destination.hash; 13036 } else if (destination.page) { 13037 this._initialBookmark = `page=${destination.page}`; 13038 } 13039 } 13040 reset() { 13041 if (this._initialized) { 13042 this.#pageHide(); 13043 this._initialized = false; 13044 this.#unbindEvents(); 13045 } 13046 if (this._updateViewareaTimeout) { 13047 clearTimeout(this._updateViewareaTimeout); 13048 this._updateViewareaTimeout = null; 13049 } 13050 this._initialBookmark = null; 13051 this._initialRotation = null; 13052 } 13053 push({ 13054 namedDest = null, 13055 explicitDest, 13056 pageNumber 13057 }) { 13058 if (!this._initialized) { 13059 return; 13060 } 13061 if (namedDest && typeof namedDest !== "string") { 13062 console.error("PDFHistory.push: " + `"${namedDest}" is not a valid namedDest parameter.`); 13063 return; 13064 } else if (!Array.isArray(explicitDest)) { 13065 console.error("PDFHistory.push: " + `"${explicitDest}" is not a valid explicitDest parameter.`); 13066 return; 13067 } else if (!this.#isValidPage(pageNumber)) { 13068 if (pageNumber !== null || this._destination) { 13069 console.error("PDFHistory.push: " + `"${pageNumber}" is not a valid pageNumber parameter.`); 13070 return; 13071 } 13072 } 13073 const hash = namedDest || JSON.stringify(explicitDest); 13074 if (!hash) { 13075 return; 13076 } 13077 let forceReplace = false;
13078 if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) { 13079 if (this._destination.page) { 13080 return; 13081 } 13082 forceReplace = true; 13083 } 13084 if (this._popStateInProgress && !forceReplace) { 13085 return; 13086 } 13087 this.#pushOrReplaceState({ 13088 dest: explicitDest, 13089 hash, 13090 page: pageNumber, 13091 rotation: this.linkService.rotation 13092 }, forceReplace); 13093 if (!this._popStateInProgress) { 13094 this._popStateInProgress = true; 13095 Promise.resolve().then(() => { 13096 this._popStateInProgress = false; 13097 }); 13098 } 13099 } 13100 pushPage(pageNumber) { 13101 if (!this._initialized) { 13102 return; 13103 } 13104 if (!this.#isValidPage(pageNumber)) { 13105 console.error(`PDFHistory.pushPage: "${pageNumber}" is not a valid page number.`); 13106 return; 13107 } 13108 if (this._destination?.page === pageNumber) { 13109 return; 13110 } 13111 if (this._popStateInProgress) { 13112 return; 13113 } 13114 this.#pushOrReplaceState({ 13115 dest: null, 13116 hash: `page=${pageNumber}`, 13117 page: pageNumber, 13118 rotation: this.linkService.rotation 13119 }); 13120 if (!this._popStateInProgress) { 13121 this._popStateInProgress = true; 13122 Promise.resolve().then(() => { 13123 this._popStateInProgress = false; 13124 }); 13125 } 13126 } 13127 pushCurrentPosition() { 13128 if (!this._initialized || this._popStateInProgress) { 13129 return; 13130 } 13131 this.#tryPushCurrentPosition(); 13132 } 13133 back() { 13134 if (!this._initialized || this._popStateInProgress) { 13135 return; 13136 } 13137 const state = window.history.state; 13138 if (this.#isValidState(state) && state.uid > 0) { 13139 window.history.back(); 13140 } 13141 } 13142 forward() { 13143 if (!this._initialized || this._popStateInProgress) { 13144 return; 13145 } 13146 const state = window.history.state; 13147 if (this.#isValidState(state) && state.uid < this._maxUid) { 13148 window.history.forward(); 13149 } 13150 } 13151 get popStateInProgress() { 13152 return this._initialized && (this._popStateInProgress || this._blockHashChange > 0); 13153 } 13154 get initialBookmark() { 13155 return this._initialized ? this._initialBookmark : null; 13156 } 13157 get initialRotation() { 13158 return this._initialized ? this._initialRotation : null; 13159 } 13160 #pushOrReplaceState(destination, forceReplace = false) { 13161 const shouldReplace = forceReplace || !this._destination; 13162 const newState = { 13163 fingerprint: this._fingerprint, 13164 uid: shouldReplace ? this._uid : this._uid + 1, 13165 destination 13166 }; 13167 this.#updateInternalState(destination, newState.uid); 13168 let newUrl; 13169 if (this._updateUrl && destination?.hash) { 13170 const { 13171 href, 13172 protocol 13173 } = document.location; 13174 if (protocol !== "file:") { 13175 newUrl = updateUrlHash(href, destination.hash); 13176 } 13177 } 13178 if (shouldReplace) { 13179 window.history.replaceState(newState, "", newUrl); 13180 } else { 13181 window.history.pushState(newState, "", newUrl); 13182 } 13183 } 13184 #tryPushCurrentPosition(temporary = false) { 13185 if (!this._position) { 13186 return; 13187 } 13188 let position = this._position; 13189 if (temporary) { 13190 position = Object.assign(Object.create(null), this._position); 13191 position.temporary = true; 13192 } 13193 if (!this._destination) { 13194 this.#pushOrReplaceState(position); 13195 return; 13196 } 13197 if (this._destination.temporary) { 13198 this.#pushOrReplaceState(position, true); 13199 return; 13200 } 13201 if (this._destination.hash === position.hash) { 13202 return; 13203 } 13204 if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) { 13205 return; 13206 } 13207 let forceReplace = false; 13208 if (this._destination.page >= position.first && this._destination.page <= position.page) { 13209 if (this._destination.dest !== undefined || !this._destination.first) { 13210 return; 13211 } 13212 forceReplace = true; 13213 } 13214 this.#pushOrReplaceState(position, forceReplace); 13215 } 13216 #isValidPage(val) { 13217 return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount; 13218 } 13219 #isValidState(state, checkReload = false) { 13220 if (!state) { 13221 return false;
13222 } 13223 if (state.fingerprint !== this._fingerprint) { 13224 if (checkReload) { 13225 if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) { 13226 return false; 13227 } 13228 const [perfEntry] = performance.getEntriesByType("navigation"); 13229 if (perfEntry?.type !== "reload") { 13230 return false; 13231 } 13232 } else { 13233 return false; 13234 } 13235 } 13236 if (!Number.isInteger(state.uid) || state.uid < 0) { 13237 return false; 13238 } 13239 if (state.destination === null || typeof state.destination !== "object") { 13240 return false; 13241 } 13242 return true; 13243 } 13244 #updateInternalState(destination, uid, removeTemporary = false) { 13245 if (this._updateViewareaTimeout) { 13246 clearTimeout(this._updateViewareaTimeout); 13247 this._updateViewareaTimeout = null; 13248 } 13249 if (removeTemporary && destination?.temporary) { 13250 delete destination.temporary; 13251 } 13252 this._destination = destination; 13253 this._uid = uid; 13254 this._maxUid = Math.max(this._maxUid, uid); 13255 this._numPositionUpdates = 0; 13256 } 13257 #parseCurrentHash(checkNameddest = false) { 13258 const hash = unescape(getCurrentHash()).substring(1); 13259 const params = parseQueryString(hash); 13260 const nameddest = params.get("nameddest") || ""; 13261 let page = params.get("page") | 0; 13262 if (!this.#isValidPage(page) || checkNameddest && nameddest.length > 0) { 13263 page = null; 13264 } 13265 return { 13266 hash, 13267 page, 13268 rotation: this.linkService.rotation 13269 }; 13270 } 13271 #updateViewarea({ 13272 location 13273 }) { 13274 if (this._updateViewareaTimeout) { 13275 clearTimeout(this._updateViewareaTimeout); 13276 this._updateViewareaTimeout = null; 13277 } 13278 this._position = { 13279 hash: location.pdfOpenParams.substring(1), 13280 page: this.linkService.page, 13281 first: location.pageNumber, 13282 rotation: location.rotation 13283 }; 13284 if (this._popStateInProgress) { 13285 return; 13286 } 13287 if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) { 13288 this._numPositionUpdates++; 13289 } 13290 if (UPDATE_VIEWAREA_TIMEOUT > 0) { 13291 this._updateViewareaTimeout = setTimeout(() => { 13292 if (!this._popStateInProgress) { 13293 this.#tryPushCurrentPosition(true); 13294 } 13295 this._updateViewareaTimeout = null; 13296 }, UPDATE_VIEWAREA_TIMEOUT); 13297 } 13298 } 13299 #popState({ 13300 state 13301 }) { 13302 const newHash = getCurrentHash(), 13303 hashChanged = this._currentHash !== newHash; 13304 this._currentHash = newHash; 13305 if (!state) { 13306 this._uid++; 13307 const { 13308 hash, 13309 page, 13310 rotation 13311 } = this.#parseCurrentHash(); 13312 this.#pushOrReplaceState({ 13313 hash, 13314 page, 13315 rotation 13316 }, true); 13317 return; 13318 } 13319 if (!this.#isValidState(state)) { 13320 return; 13321 } 13322 this._popStateInProgress = true; 13323 if (hashChanged) { 13324 this._blockHashChange++; 13325 waitOnEventOrTimeout({ 13326 target: window, 13327 name: "hashchange", 13328 delay: HASH_CHANGE_TIMEOUT 13329 }).then(() => { 13330 this._blockHashChange--; 13331 }); 13332 } 13333 const destination = state.destination; 13334 this.#updateInternalState(destination, state.uid, true); 13335 if (isValidRotation(destination.rotation)) { 13336 this.linkService.rotation = destination.rotation; 13337 } 13338 if (destination.dest) { 13339 this.linkService.goToDestination(destination.dest); 13340 } else if (destination.hash) { 13341 this.linkService.setHash(destination.hash); 13342 } else if (destination.page) { 13343 this.linkService.page = destination.page; 13344 } 13345 Promise.resolve().then(() => { 13346 this._popStateInProgress = false; 13347 }); 13348 } 13349 #pageHide() { 13350 if (!this._destination || this._destination.temporary) { 13351 this.#tryPushCurrentPosition(); 13352 } 13353 } 13354 #bindEvents() { 13355 if (this.#eventAbortController) { 13356 return; 13357 } 13358 this.#eventAbortController = new AbortController(); 13359 const { 13360 signal 13361 } = this.#eventAbortController; 13362 this.eventBus._on("updateviewarea", this.#updateViewarea.bind(this), { 13363 signal 13364 }); 13365 window.addEventListener("popstate", this.#popState.bind(this), { 13366 signal 13367 }); 13368 window.addEventListener("pagehide", this.#pageHide.bind(this), { 13369 signal 13370 }); 13371 } 13372 #unbindEvents() { 13373 this.#eventAbortController?.abort(); 13374 this.#eventAbortController = null; 13375 } 13376} 13377function isDestHashesEqual(destHash, pushHash) { 13378 if (typeof destHash !== "string" || typeof pushHash !== "string") { 13379 return false;
13380 } 13381 if (destHash === pushHash) { 13382 return true; 13383 } 13384 const nameddest = parseQueryString(destHash).get("nameddest"); 13385 if (nameddest === pushHash) { 13386 return true; 13387 } 13388 return false; 13389} 13390function isDestArraysEqual(firstDest, secondDest) { 13391 function isEntryEqual(first, second) { 13392 if (typeof first !== typeof second) { 13393 return false; 13394 } 13395 if (Array.isArray(first) || Array.isArray(second)) { 13396 return false; 13397 } 13398 if (first !== null && typeof first === "object" && second !== null) { 13399 if (Object.keys(first).length !== Object.keys(second).length) { 13400 return false; 13401 } 13402 for (const key in first) { 13403 if (!isEntryEqual(first[key], second[key])) { 13404 return false; 13405 } 13406 } 13407 return true; 13408 } 13409 return first === second || Number.isNaN(first) && Number.isNaN(second); 13410 } 13411 if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) { 13412 return false; 13413 } 13414 if (firstDest.length !== secondDest.length) { 13415 return false; 13416 } 13417 for (let i = 0, ii = firstDest.length; i < ii; i++) { 13418 if (!isEntryEqual(firstDest[i], secondDest[i])) { 13419 return false; 13420 } 13421 } 13422 return true; 13423} 13424 13425;// ./web/pdf_layer_viewer.js 13426 13427 13428 13429 13430class PDFLayerViewer extends BaseTreeViewer { 13431 constructor(options) { 13432 super(options); 13433 this.eventBus._on("optionalcontentconfigchanged", evt => { 13434 this.#updateLayers(evt.promise); 13435 }); 13436 this.eventBus._on("resetlayers", () => { 13437 this.#updateLayers(); 13438 }); 13439 this.eventBus._on("togglelayerstree", this._toggleAllTreeItems.bind(this)); 13440 } 13441 reset() { 13442 super.reset(); 13443 this._optionalContentConfig = null; 13444 this._optionalContentVisibility?.clear(); 13445 this._optionalContentVisibility = null; 13446 } 13447 _dispatchEvent(layersCount) { 13448 this.eventBus.dispatch("layersloaded", { 13449 source: this, 13450 layersCount 13451 }); 13452 } 13453 _bindLink(element, { 13454 groupId, 13455 input 13456 }) { 13457 const setVisibility = () => { 13458 const visible = input.checked; 13459 this._optionalContentConfig.setVisibility(groupId, visible); 13460 const cached = this._optionalContentVisibility.get(groupId); 13461 if (cached) { 13462 cached.visible = visible; 13463 } 13464 this.eventBus.dispatch("optionalcontentconfig", { 13465 source: this, 13466 promise: Promise.resolve(this._optionalContentConfig) 13467 }); 13468 }; 13469 element.onclick = evt => { 13470 if (evt.target === input) { 13471 setVisibility(); 13472 return true; 13473 } else if (evt.target !== element) { 13474 return true; 13475 } 13476 input.checked = !input.checked; 13477 setVisibility(); 13478 return false; 13479 }; 13480 } 13481 _setNestedName(element, { 13482 name = null 13483 }) { 13484 if (typeof name === "string") { 13485 element.textContent = this._normalizeTextContent(name); 13486 return; 13487 } 13488 element.setAttribute("data-l10n-id", "pdfjs-additional-layers"); 13489 element.style.fontStyle = "italic"; 13490 this._l10n.translateOnce(element); 13491 } 13492 _addToggleButton(div, { 13493 name = null 13494 }) { 13495 super._addToggleButton(div, name === null); 13496 } 13497 _toggleAllTreeItems() { 13498 if (!this._optionalContentConfig) { 13499 return; 13500 } 13501 super._toggleAllTreeItems(); 13502 } 13503 render({ 13504 optionalContentConfig, 13505 pdfDocument 13506 }) { 13507 if (this._optionalContentConfig) { 13508 this.reset(); 13509 } 13510 this._optionalContentConfig = optionalContentConfig || null; 13511 this._pdfDocument = pdfDocument || null; 13512 const groups = optionalContentConfig?.getOrder(); 13513 if (!groups) { 13514 this._dispatchEvent(0); 13515 return; 13516 } 13517 this._optionalContentVisibility = new Map(); 13518 const fragment = document.createDocumentFragment(), 13519 queue = [{ 13520 parent: fragment, 13521 groups 13522 }]; 13523 let layersCount = 0, 13524 hasAnyNesting = false; 13525 while (queue.length > 0) { 13526 const levelData = queue.shift(); 13527 for (const groupId of levelData.groups) { 13528 const div = document.createElement("div"); 13529 div.className = "treeItem"; 13530 const element = document.createElement("a"); 13531 div.append(element); 13532 if (typeof groupId === "object") { 13533 hasAnyNesting = true; 13534 this._addToggleButton(div, groupId); 13535 this._setNestedName(element, groupId); 13536 const itemsDiv = document.createElement("div"); 13537 itemsDiv.className = "treeItems"; 13538 div.append(itemsDiv); 13539 queue.push({ 13540 parent: itemsDiv, 13541 groups: groupId.order 13542 }); 13543 } else { 13544 const group = optionalContentConfig.getGroup(groupId); 13545 const label = document.createElement("label"); 13546 const input = document.createElement("input"); 13547 label.append(input, document.createTextNode(this._normalizeTextContent(group.name))); 13548 this._bindLink(element, { 13549 groupId, 13550 input 13551 }); 13552 input.type = "checkbox"; 13553 input.checked = group.visible; 13554 this._optionalContentVisibility.set(groupId, { 13555 input, 13556 visible: input.checked 13557 }); 13558 element.append(label); 13559 layersCount++; 13560 } 13561 levelData.parent.append(div); 13562 } 13563 } 13564 this._finishRendering(fragment, layersCount, hasAnyNesting); 13565 } 13566 async #updateLayers(promise = null) { 13567 if (!this._optionalContentConfig) { 13568 return; 13569 } 13570 const pdfDocument = this._pdfDocument; 13571 const optionalContentConfig = await (promise || pdfDocument.getOptionalContentConfig({ 13572 intent: "display" 13573 })); 13574 if (pdfDocument !== this._pdfDocument) { 13575 return; 13576 } 13577 if (promise) { 13578 for (const [groupId, cached] of this._optionalContentVisibility) { 13579 const group = optionalContentConfig.getGroup(groupId); 13580 if (group && cached.visible !== group.visible) {
13581 cached.input.checked = cached.visible = !cached.visible; 13582 } 13583 } 13584 return; 13585 } 13586 this.eventBus.dispatch("optionalcontentconfig", { 13587 source: this, 13588 promise: Promise.resolve(optionalContentConfig) 13589 }); 13590 this.render({ 13591 optionalContentConfig, 13592 pdfDocument: this._pdfDocument 13593 }); 13594 } 13595} 13596 13597;// ./web/pdf_outline_viewer.js 13598 13599 13600 13601 13602 13603 13604class PDFOutlineViewer extends BaseTreeViewer { 13605 constructor(options) { 13606 super(options); 13607 this.linkService = options.linkService; 13608 this.downloadManager = options.downloadManager; 13609 this.eventBus._on("toggleoutlinetree", this._toggleAllTreeItems.bind(this)); 13610 this.eventBus._on("currentoutlineitem", this._currentOutlineItem.bind(this)); 13611 this.eventBus._on("pagechanging", evt => { 13612 this._currentPageNumber = evt.pageNumber; 13613 }); 13614 this.eventBus._on("pagesloaded", evt => { 13615 this._isPagesLoaded = !!evt.pagesCount; 13616 this._currentOutlineItemCapability?.resolve(this._isPagesLoaded); 13617 }); 13618 this.eventBus._on("sidebarviewchanged", evt => { 13619 this._sidebarView = evt.view; 13620 }); 13621 } 13622 reset() { 13623 super.reset(); 13624 this._outline = null; 13625 this._pageNumberToDestHashCapability = null; 13626 this._currentPageNumber = 1; 13627 this._isPagesLoaded = null; 13628 this._currentOutlineItemCapability?.resolve(false); 13629 this._currentOutlineItemCapability = null; 13630 } 13631 _dispatchEvent(outlineCount) { 13632 this._currentOutlineItemCapability = Promise.withResolvers(); 13633 if (outlineCount === 0 || this._pdfDocument?.loadingParams.disableAutoFetch) { 13634 this._currentOutlineItemCapability.resolve(false); 13635 } else if (this._isPagesLoaded !== null) { 13636 this._currentOutlineItemCapability.resolve(this._isPagesLoaded); 13637 } 13638 this.eventBus.dispatch("outlineloaded", { 13639 source: this, 13640 outlineCount, 13641 currentOutlineItemPromise: this._currentOutlineItemCapability.promise 13642 }); 13643 } 13644 _bindLink(element, { 13645 url, 13646 newWindow, 13647 action, 13648 attachment, 13649 dest, 13650 setOCGState 13651 }) { 13652 const { 13653 linkService 13654 } = this; 13655 if (url) { 13656 linkService.addLinkAttributes(element, url, newWindow); 13657 return; 13658 } 13659 if (action) { 13660 element.href = linkService.getAnchorUrl(""); 13661 element.onclick = () => { 13662 linkService.executeNamedAction(action); 13663 return false; 13664 }; 13665 return; 13666 } 13667 if (attachment) { 13668 element.href = linkService.getAnchorUrl(""); 13669 element.onclick = () => { 13670 this.downloadManager.openOrDownloadData(attachment.content, attachment.filename); 13671 return false; 13672 }; 13673 return; 13674 } 13675 if (setOCGState) { 13676 element.href = linkService.getAnchorUrl(""); 13677 element.onclick = () => { 13678 linkService.executeSetOCGState(setOCGState); 13679 return false; 13680 }; 13681 return; 13682 } 13683 element.href = linkService.getDestinationHash(dest); 13684 element.onclick = evt => { 13685 this._updateCurrentTreeItem(evt.target.parentNode); 13686 if (dest) { 13687 linkService.goToDestination(dest); 13688 } 13689 return false; 13690 }; 13691 } 13692 _setStyles(element, { 13693 bold, 13694 italic 13695 }) { 13696 if (bold) { 13697 element.style.fontWeight = "bold"; 13698 } 13699 if (italic) { 13700 element.style.fontStyle = "italic"; 13701 } 13702 } 13703 _addToggleButton(div, { 13704 count, 13705 items 13706 }) { 13707 let hidden = false; 13708 if (count < 0) { 13709 let totalCount = items.length; 13710 if (totalCount > 0) { 13711 const queue = [...items]; 13712 while (queue.length > 0) { 13713 const { 13714 count: nestedCount, 13715 items: nestedItems 13716 } = queue.shift(); 13717 if (nestedCount > 0 && nestedItems.length > 0) { 13718 totalCount += nestedItems.length; 13719 queue.push(...nestedItems); 13720 } 13721 } 13722 } 13723 if (Math.abs(count) === totalCount) { 13724 hidden = true; 13725 } 13726 } 13727 super._addToggleButton(div, hidden); 13728 } 13729 _toggleAllTreeItems() { 13730 if (!this._outline) { 13731 return; 13732 } 13733 super._toggleAllTreeItems(); 13734 } 13735 render({ 13736 outline, 13737 pdfDocument 13738 }) { 13739 if (this._outline) { 13740 this.reset(); 13741 } 13742 this._outline = outline || null; 13743 this._pdfDocument = pdfDocument || null; 13744 if (!outline) { 13745 this._dispatchEvent(0); 13746 return; 13747 } 13748 const fragment = document.createDocumentFragment(); 13749 const queue = [{ 13750 parent: fragment, 13751 items: outline 13752 }]; 13753 let outlineCount = 0, 13754 hasAnyNesting = false;
13755 while (queue.length > 0) { 13756 const levelData = queue.shift(); 13757 for (const item of levelData.items) { 13758 const div = document.createElement("div"); 13759 div.className = "treeItem"; 13760 const element = document.createElement("a"); 13761 this._bindLink(element, item); 13762 this._setStyles(element, item); 13763 element.textContent = this._normalizeTextContent(item.title); 13764 div.append(element); 13765 if (item.items.length > 0) { 13766 hasAnyNesting = true; 13767 this._addToggleButton(div, item); 13768 const itemsDiv = document.createElement("div"); 13769 itemsDiv.className = "treeItems"; 13770 div.append(itemsDiv); 13771 queue.push({ 13772 parent: itemsDiv, 13773 items: item.items 13774 }); 13775 } 13776 levelData.parent.append(div); 13777 outlineCount++; 13778 } 13779 } 13780 this._finishRendering(fragment, outlineCount, hasAnyNesting); 13781 } 13782 async _currentOutlineItem() { 13783 if (!this._isPagesLoaded) { 13784 throw new Error("_currentOutlineItem: All pages have not been loaded."); 13785 } 13786 if (!this._outline || !this._pdfDocument) { 13787 return; 13788 } 13789 const pageNumberToDestHash = await this._getPageNumberToDestHash(this._pdfDocument); 13790 if (!pageNumberToDestHash) { 13791 return; 13792 } 13793 this._updateCurrentTreeItem(null); 13794 if (this._sidebarView !== SidebarView.OUTLINE) { 13795 return; 13796 } 13797 for (let i = this._currentPageNumber; i > 0; i--) { 13798 const destHash = pageNumberToDestHash.get(i); 13799 if (!destHash) { 13800 continue; 13801 } 13802 const linkElement = this.container.querySelector(`a[href="${destHash}"]`); 13803 if (!linkElement) { 13804 continue; 13805 } 13806 this._scrollToCurrentTreeItem(linkElement.parentNode); 13807 break; 13808 } 13809 } 13810 async _getPageNumberToDestHash(pdfDocument) { 13811 if (this._pageNumberToDestHashCapability) { 13812 return this._pageNumberToDestHashCapability.promise; 13813 } 13814 this._pageNumberToDestHashCapability = Promise.withResolvers(); 13815 const pageNumberToDestHash = new Map(), 13816 pageNumberNesting = new Map(); 13817 const queue = [{ 13818 nesting: 0, 13819 items: this._outline 13820 }]; 13821 while (queue.length > 0) { 13822 const levelData = queue.shift(), 13823 currentNesting = levelData.nesting; 13824 for (const { 13825 dest, 13826 items 13827 } of levelData.items) { 13828 let explicitDest, pageNumber; 13829 if (typeof dest === "string") { 13830 explicitDest = await pdfDocument.getDestination(dest); 13831 if (pdfDocument !== this._pdfDocument) { 13832 return null; 13833 } 13834 } else { 13835 explicitDest = dest; 13836 } 13837 if (Array.isArray(explicitDest)) { 13838 const [destRef] = explicitDest; 13839 if (destRef && typeof destRef === "object") { 13840 pageNumber = pdfDocument.cachedPageNumber(destRef); 13841 } else if (Number.isInteger(destRef)) { 13842 pageNumber = destRef + 1; 13843 } 13844 if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(pageNumber) || currentNesting > pageNumberNesting.get(pageNumber))) { 13845 const destHash = this.linkService.getDestinationHash(dest); 13846 pageNumberToDestHash.set(pageNumber, destHash); 13847 pageNumberNesting.set(pageNumber, currentNesting); 13848 } 13849 } 13850 if (items.length > 0) { 13851 queue.push({ 13852 nesting: currentNesting + 1, 13853 items 13854 }); 13855 } 13856 } 13857 } 13858 this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ? pageNumberToDestHash : null); 13859 return this._pageNumberToDestHashCapability.promise; 13860 } 13861} 13862 13863;// ./web/pdf_presentation_mode.js 13864 13865 13866const DELAY_BEFORE_HIDING_CONTROLS = 3000; 13867const ACTIVE_SELECTOR = "pdfPresentationMode"; 13868const CONTROLS_SELECTOR = "pdfPresentationModeControls"; 13869const MOUSE_SCROLL_COOLDOWN_TIME = 50; 13870const PAGE_SWITCH_THRESHOLD = 0.1; 13871const SWIPE_MIN_DISTANCE_THRESHOLD = 50; 13872const SWIPE_ANGLE_THRESHOLD = Math.PI / 6; 13873class PDFPresentationMode { 13874 #state = PresentationModeState.UNKNOWN; 13875 #args = null; 13876 #fullscreenChangeAbortController = null; 13877 #windowAbortController = null; 13878 constructor({ 13879 container, 13880 pdfViewer, 13881 eventBus 13882 }) { 13883 this.container = container; 13884 this.pdfViewer = pdfViewer; 13885 this.eventBus = eventBus; 13886 this.contextMenuOpen = false;
13887 this.mouseScrollTimeStamp = 0; 13888 this.mouseScrollDelta = 0; 13889 this.touchSwipeState = null; 13890 } 13891 async request() { 13892 const { 13893 container, 13894 pdfViewer 13895 } = this; 13896 if (this.active || !pdfViewer.pagesCount || !container.requestFullscreen) { 13897 return false; 13898 } 13899 this.#addFullscreenChangeListeners(); 13900 this.#notifyStateChange(PresentationModeState.CHANGING); 13901 const promise = container.requestFullscreen(); 13902 this.#args = { 13903 pageNumber: pdfViewer.currentPageNumber, 13904 scaleValue: pdfViewer.currentScaleValue, 13905 scrollMode: pdfViewer.scrollMode, 13906 spreadMode: null, 13907 annotationEditorMode: null 13908 }; 13909 if (pdfViewer.spreadMode !== SpreadMode.NONE && !(pdfViewer.pageViewsReady && pdfViewer.hasEqualPageSizes)) { 13910 console.warn("Ignoring Spread modes when entering PresentationMode, " + "since the document may contain varying page sizes."); 13911 this.#args.spreadMode = pdfViewer.spreadMode; 13912 } 13913 if (pdfViewer.annotationEditorMode !== AnnotationEditorType.DISABLE) { 13914 this.#args.annotationEditorMode = pdfViewer.annotationEditorMode; 13915 } 13916 try { 13917 await promise;
13918 pdfViewer.focus(); 13919 return true; 13920 } catch { 13921 this.#removeFullscreenChangeListeners(); 13922 this.#notifyStateChange(PresentationModeState.NORMAL); 13923 } 13924 return false; 13925 } 13926 get active() { 13927 return this.#state === PresentationModeState.CHANGING || this.#state === PresentationModeState.FULLSCREEN; 13928 } 13929 #mouseWheel(evt) { 13930 if (!this.active) { 13931 return; 13932 } 13933 evt.preventDefault(); 13934 const delta = normalizeWheelEventDelta(evt); 13935 const currentTime = Date.now(); 13936 const storedTime = this.mouseScrollTimeStamp; 13937 if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) { 13938 return; 13939 } 13940 if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) { 13941 this.#resetMouseScrollState(); 13942 } 13943 this.mouseScrollDelta += delta; 13944 if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) { 13945 const totalDelta = this.mouseScrollDelta; 13946 this.#resetMouseScrollState(); 13947 const success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage(); 13948 if (success) { 13949 this.mouseScrollTimeStamp = currentTime; 13950 } 13951 } 13952 } 13953 #notifyStateChange(state) { 13954 this.#state = state; 13955 this.eventBus.dispatch("presentationmodechanged", { 13956 source: this, 13957 state 13958 }); 13959 } 13960 #enter() { 13961 this.#notifyStateChange(PresentationModeState.FULLSCREEN); 13962 this.container.classList.add(ACTIVE_SELECTOR); 13963 setTimeout(() => { 13964 this.pdfViewer.scrollMode = ScrollMode.PAGE; 13965 if (this.#args.spreadMode !== null) { 13966 this.pdfViewer.spreadMode = SpreadMode.NONE; 13967 } 13968 this.pdfViewer.currentPageNumber = this.#args.pageNumber; 13969 this.pdfViewer.currentScaleValue = "page-fit"; 13970 if (this.#args.annotationEditorMode !== null) { 13971 this.pdfViewer.annotationEditorMode = { 13972 mode: AnnotationEditorType.NONE 13973 }; 13974 } 13975 }, 0); 13976 this.#addWindowListeners(); 13977 this.#showControls(); 13978 this.contextMenuOpen = false; 13979 document.getSelection().empty(); 13980 } 13981 #exit() { 13982 const pageNumber = this.pdfViewer.currentPageNumber; 13983 this.container.classList.remove(ACTIVE_SELECTOR); 13984 setTimeout(() => { 13985 this.#removeFullscreenChangeListeners(); 13986 this.#notifyStateChange(PresentationModeState.NORMAL); 13987 this.pdfViewer.scrollMode = this.#args.scrollMode; 13988 if (this.#args.spreadMode !== null) { 13989 this.pdfViewer.spreadMode = this.#args.spreadMode; 13990 } 13991 this.pdfViewer.currentScaleValue = this.#args.scaleValue; 13992 this.pdfViewer.currentPageNumber = pageNumber; 13993 if (this.#args.annotationEditorMode !== null) { 13994 this.pdfViewer.annotationEditorMode = { 13995 mode: this.#args.annotationEditorMode 13996 }; 13997 } 13998 this.#args = null; 13999 }, 0); 14000 this.#removeWindowListeners(); 14001 this.#hideControls(); 14002 this.#resetMouseScrollState(); 14003 this.contextMenuOpen = false; 14004 } 14005 #mouseDown(evt) { 14006 if (this.contextMenuOpen) { 14007 this.contextMenuOpen = false; 14008 evt.preventDefault(); 14009 return; 14010 } 14011 if (evt.button !== 0) { 14012 return; 14013 } 14014 if (evt.target.href && evt.target.parentNode?.hasAttribute("data-internal-link")) { 14015 return; 14016 } 14017 evt.preventDefault(); 14018 if (evt.shiftKey) { 14019 this.pdfViewer.previousPage(); 14020 } else { 14021 this.pdfViewer.nextPage(); 14022 } 14023 } 14024 #contextMenu() { 14025 this.contextMenuOpen = true; 14026 } 14027 #showControls() { 14028 if (this.controlsTimeout) { 14029 clearTimeout(this.controlsTimeout); 14030 } else { 14031 this.container.classList.add(CONTROLS_SELECTOR); 14032 } 14033 this.controlsTimeout = setTimeout(() => { 14034 this.container.classList.remove(CONTROLS_SELECTOR); 14035 delete this.controlsTimeout; 14036 }, DELAY_BEFORE_HIDING_CONTROLS); 14037 } 14038 #hideControls() { 14039 if (!this.controlsTimeout) { 14040 return; 14041 } 14042 clearTimeout(this.controlsTimeout); 14043 this.container.classList.remove(CONTROLS_SELECTOR); 14044 delete this.controlsTimeout; 14045 } 14046 #resetMouseScrollState() { 14047 this.mouseScrollTimeStamp = 0; 14048 this.mouseScrollDelta = 0; 14049 } 14050 #touchSwipe(evt) { 14051 if (!this.active) { 14052 return; 14053 } 14054 if (evt.touches.length > 1) { 14055 this.touchSwipeState = null; 14056 return; 14057 } 14058 switch (evt.type) { 14059 case "touchstart": 14060 this.touchSwipeState = { 14061 startX: evt.touches[0].pageX, 14062 startY: evt.touches[0].pageY, 14063 endX: evt.touches[0].pageX, 14064 endY: evt.touches[0].pageY 14065 }; 14066 break; 14067 case "touchmove": 14068 if (this.touchSwipeState === null) { 14069 return; 14070 } 14071 this.touchSwipeState.endX = evt.touches[0].pageX; 14072 this.touchSwipeState.endY = evt.touches[0].pageY; 14073 evt.preventDefault(); 14074 break; 14075 case "touchend": 14076 if (this.touchSwipeState === null) { 14077 return; 14078 } 14079 let delta = 0; 14080 const dx = this.touchSwipeState.endX - this.touchSwipeState.startX; 14081 const dy = this.touchSwipeState.endY - this.touchSwipeState.startY; 14082 const absAngle = Math.abs(Math.atan2(dy, dx)); 14083 if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) { 14084 delta = dx; 14085 } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) { 14086 delta = dy; 14087 } 14088 if (delta > 0) { 14089 this.pdfViewer.previousPage(); 14090 } else if (delta < 0) { 14091 this.pdfViewer.nextPage(); 14092 } 14093 break; 14094 } 14095 } 14096 #addWindowListeners() { 14097 if (this.#windowAbortController) { 14098 return; 14099 } 14100 this.#windowAbortController = new AbortController(); 14101 const { 14102 signal 14103 } = this.#windowAbortController; 14104 const touchSwipeBind = this.#touchSwipe.bind(this); 14105 window.addEventListener("mousemove", this.#showControls.bind(this), { 14106 signal 14107 }); 14108 window.addEventListener("mousedown", this.#mouseDown.bind(this), { 14109 signal 14110 }); 14111 window.addEventListener("wheel", this.#mouseWheel.bind(this), { 14112 passive: false, 14113 signal 14114 }); 14115 window.addEventListener("keydown", this.#resetMouseScrollState.bind(this), { 14116 signal 14117 }); 14118 window.addEventListener("contextmenu", this.#contextMenu.bind(this), { 14119 signal 14120 }); 14121 window.addEventListener("touchstart", touchSwipeBind, { 14122 signal 14123 }); 14124 window.addEventListener("touchmove", touchSwipeBind, { 14125 signal 14126 }); 14127 window.addEventListener("touchend", touchSwipeBind, { 14128 signal 14129 }); 14130 } 14131 #removeWindowListeners() { 14132 this.#windowAbortController?.abort(); 14133 this.#windowAbortController = null; 14134 } 14135 #addFullscreenChangeListeners() { 14136 if (this.#fullscreenChangeAbortController) { 14137 return; 14138 } 14139 this.#fullscreenChangeAbortController = new AbortController(); 14140 window.addEventListener("fullscreenchange", () => { 14141 if (document.fullscreenElement) { 14142 this.#enter(); 14143 } else { 14144 this.#exit(); 14145 } 14146 }, {
14147 signal: this.#fullscreenChangeAbortController.signal 14148 }); 14149 } 14150 #removeFullscreenChangeListeners() { 14151 this.#fullscreenChangeAbortController?.abort(); 14152 this.#fullscreenChangeAbortController = null; 14153 } 14154} 14155 14156// EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.every.js 14157var es_iterator_every = __webpack_require__(1148); 14158;// ./web/xfa_layer_builder.js 14159 14160class XfaLayerBuilder { 14161 constructor({ 14162 pdfPage, 14163 annotationStorage = null, 14164 linkService, 14165 xfaHtml = null 14166 }) { 14167 this.pdfPage = pdfPage; 14168 this.annotationStorage = annotationStorage; 14169 this.linkService = linkService; 14170 this.xfaHtml = xfaHtml; 14171 this.div = null; 14172 this._cancelled = false; 14173 } 14174 async render({ 14175 viewport, 14176 intent = "display" 14177 }) { 14178 if (intent === "print") { 14179 const parameters = { 14180 viewport: viewport.clone({ 14181 dontFlip: true 14182 }), 14183 div: this.div, 14184 xfaHtml: this.xfaHtml, 14185 annotationStorage: this.annotationStorage, 14186 linkService: this.linkService, 14187 intent 14188 }; 14189 this.div = document.createElement("div"); 14190 parameters.div = this.div; 14191 return XfaLayer.render(parameters); 14192 } 14193 const xfaHtml = await this.pdfPage.getXfa(); 14194 if (this._cancelled || !xfaHtml) { 14195 return { 14196 textDivs: [] 14197 }; 14198 } 14199 const parameters = { 14200 viewport: viewport.clone({ 14201 dontFlip: true 14202 }), 14203 div: this.div, 14204 xfaHtml, 14205 annotationStorage: this.annotationStorage, 14206 linkService: this.linkService, 14207 intent 14208 }; 14209 if (this.div) { 14210 return XfaLayer.update(parameters); 14211 } 14212 this.div = document.createElement("div"); 14213 parameters.div = this.div; 14214 return XfaLayer.render(parameters); 14215 } 14216 cancel() { 14217 this._cancelled = true; 14218 } 14219 hide() { 14220 if (!this.div) { 14221 return; 14222 } 14223 this.div.hidden = true; 14224 } 14225} 14226 14227;// ./web/print_utils.js 14228 14229 14230 14231class BasePrintServiceFactory { 14232 static initGlobals(app) {} 14233 static get supportsPrinting() { 14234 throw new Error("Not implemented: supportsPrinting"); 14235 } 14236 static createPrintService(params) { 14237 throw new Error("Not implemented: createPrintService"); 14238 } 14239} 14240function getXfaHtmlForPrinting(printContainer, pdfDocument) { 14241 const xfaHtml = pdfDocument.allXfaHtml; 14242 const linkService = new SimpleLinkService(); 14243 const scale = Math.round(PixelsPerInch.PDF_TO_CSS_UNITS * 100) / 100; 14244 for (const xfaPage of xfaHtml.children) { 14245 const page = document.createElement("div"); 14246 page.className = "xfaPrintedPage"; 14247 printContainer.append(page); 14248 const builder = new XfaLayerBuilder({ 14249 pdfPage: null, 14250 annotationStorage: pdfDocument.annotationStorage, 14251 linkService, 14252 xfaHtml: xfaPage 14253 }); 14254 const viewport = getXfaPageViewport(xfaPage, { 14255 scale 14256 }); 14257 builder.render({ 14258 viewport, 14259 intent: "print" 14260 }); 14261 page.append(builder.div); 14262 } 14263} 14264 14265;// ./web/pdf_print_service.js 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275let activeService = null; 14276let dialog = null; 14277let overlayManager = null; 14278let viewerApp = { 14279 initialized: false 14280}; 14281function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise) { 14282 const scratchCanvas = activeService.scratchCanvas; 14283 const PRINT_UNITS = printResolution / PixelsPerInch.PDF; 14284 scratchCanvas.width = Math.floor(size.width * PRINT_UNITS); 14285 scratchCanvas.height = Math.floor(size.height * PRINT_UNITS); 14286 const ctx = scratchCanvas.getContext("2d"); 14287 ctx.save(); 14288 ctx.fillStyle = "rgb(255, 255, 255)"; 14289 ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height); 14290 ctx.restore(); 14291 return Promise.all([pdfDocument.getPage(pageNumber), printAnnotationStoragePromise]).then(function ([pdfPage, printAnnotationStorage]) { 14292 const renderContext = { 14293 canvas: scratchCanvas, 14294 transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0], 14295 viewport: pdfPage.getViewport({ 14296 scale: 1, 14297 rotation: size.rotation 14298 }), 14299 intent: "print", 14300 annotationMode: AnnotationMode.ENABLE_STORAGE, 14301 optionalContentConfigPromise, 14302 printAnnotationStorage 14303 }; 14304 const renderTask = pdfPage.render(renderContext); 14305 return renderTask.promise.catch(reason => { 14306 if (!(reason instanceof RenderingCancelledException)) { 14307 console.error(reason); 14308 } 14309 throw reason; 14310 }); 14311 }); 14312} 14313class PDFPrintService { 14314 constructor({ 14315 pdfDocument, 14316 pagesOverview, 14317 printContainer, 14318 printResolution, 14319 printAnnotationStoragePromise = null 14320 }) { 14321 this.pdfDocument = pdfDocument; 14322 this.pagesOverview = pagesOverview; 14323 this.printContainer = printContainer; 14324 this._printResolution = printResolution || 150; 14325 this._optionalContentConfigPromise = pdfDocument.getOptionalContentConfig({ 14326 intent: "print" 14327 }); 14328 this._printAnnotationStoragePromise = printAnnotationStoragePromise || Promise.resolve(); 14329 this.currentPage = -1; 14330 this.scratchCanvas = document.createElement("canvas"); 14331 } 14332 layout() { 14333 this.throwIfInactive(); 14334 const body = document.querySelector("body"); 14335 body.setAttribute("data-pdfjsprinting", true); 14336 const { 14337 width, 14338 height 14339 } = this.pagesOverview[0]; 14340 const hasEqualPageSizes = this.pagesOverview.every(size => size.width === width && size.height === height); 14341 if (!hasEqualPageSizes) { 14342 console.warn("Not all pages have the same size. The printed result may be incorrect!"); 14343 } 14344 this.pageStyleSheet = document.createElement("style"); 14345 this.pageStyleSheet.textContent = `@page { size: ${width}pt ${height}pt;}`; 14346 body.append(this.pageStyleSheet); 14347 } 14348 destroy() { 14349 if (activeService !== this) { 14350 return; 14351 } 14352 this.printContainer.textContent = ""; 14353 const body = document.querySelector("body"); 14354 body.removeAttribute("data-pdfjsprinting"); 14355 if (this.pageStyleSheet) { 14356 this.pageStyleSheet.remove(); 14357 this.pageStyleSheet = null; 14358 } 14359 this.scratchCanvas.width = this.scratchCanvas.height = 0; 14360 this.scratchCanvas = null; 14361 activeService = null; 14362 ensureOverlay().then(function () { 14363 overlayManager.closeIfActive(dialog); 14364 }); 14365 } 14366 renderPages() { 14367 if (this.pdfDocument.isPureXfa) { 14368 getXfaHtmlForPrinting(this.printContainer, this.pdfDocument); 14369 return Promise.resolve(); 14370 } 14371 const pageCount = this.pagesOverview.length; 14372 const renderNextPage = (resolve, reject) => { 14373 this.throwIfInactive(); 14374 if (++this.currentPage >= pageCount) { 14375 renderProgress(pageCount, pageCount); 14376 resolve(); 14377 return; 14378 } 14379 const index = this.currentPage; 14380 renderProgress(index, pageCount); 14381 renderPage(this, this.pdfDocument, index + 1, this.pagesOverview[index], this._printResolution, this._optionalContentConfigPromise, this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then(function () { 14382 renderNextPage(resolve, reject); 14383 }, reject); 14384 }; 14385 return new Promise(renderNextPage); 14386 } 14387 useRenderedPage() { 14388 this.throwIfInactive(); 14389 const img = document.createElement("img"); 14390 this.scratchCanvas.toBlob(blob => { 14391 img.src = URL.createObjectURL(blob); 14392 }); 14393 const wrapper = document.createElement("div"); 14394 wrapper.className = "printedPage"; 14395 wrapper.append(img); 14396 this.printContainer.append(wrapper); 14397 const { 14398 promise, 14399 resolve, 14400 reject 14401 } = Promise.withResolvers(); 14402 img.onload = resolve; 14403 img.onerror = reject; 14404 promise.catch(() => {}).then(() => { 14405 URL.revokeObjectURL(img.src); 14406 }); 14407 return promise; 14408 } 14409 performPrint() { 14410 this.throwIfInactive(); 14411 return new Promise(resolve => { 14412 setTimeout(() => { 14413 if (!this.active) { 14414 resolve(); 14415 return; 14416 } 14417 print.call(window); 14418 setTimeout(resolve, 20); 14419 }, 0); 14420 }); 14421 } 14422 get active() { 14423 return this === activeService; 14424 } 14425 throwIfInactive() { 14426 if (!this.active) { 14427 throw new Error("This print request was cancelled or completed."); 14428 } 14429 } 14430} 14431const print = window.print; 14432window.print = function () { 14433 if (activeService) { 14434 console.warn("Ignored window.print() because of a pending print job."); 14435 return; 14436 } 14437 ensureOverlay().then(function () { 14438 if (activeService) { 14439 overlayManager.open(dialog); 14440 } 14441 }); 14442 try { 14443 dispatchEvent("beforeprint"); 14444 } finally { 14445 if (!activeService) { 14446 console.error("Expected print service to be initialized."); 14447 ensureOverlay().then(function () { 14448 overlayManager.closeIfActive(dialog); 14449 }); 14450 } else { 14451 const activeServiceOnEntry = activeService; 14452 activeService.renderPages().then(() => activeServiceOnEntry.performPrint()).catch(() => {}).then(() => { 14453 if (activeServiceOnEntry.active) { 14454 abort(); 14455 } 14456 }); 14457 } 14458 } 14459}; 14460function dispatchEvent(eventType) { 14461 const event = new CustomEvent(eventType, { 14462 bubbles: false, 14463 cancelable: false, 14464 detail: "custom" 14465 }); 14466 window.dispatchEvent(event); 14467} 14468function abort() { 14469 if (activeService) { 14470 activeService.destroy(); 14471 dispatchEvent("afterprint"); 14472 } 14473} 14474function renderProgress(index, total) { 14475 dialog ||= document.getElementById("printServiceDialog"); 14476 const progress = Math.round(100 * index / total); 14477 const progressBar = dialog.querySelector("progress"); 14478 const progressPerc = dialog.querySelector(".relative-progress"); 14479 progressBar.value = progress; 14480 progressPerc.setAttribute("data-l10n-args", JSON.stringify({ 14481 progress 14482 })); 14483} 14484window.addEventListener("keydown", function (event) { 14485 if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) { 14486 window.print(); 14487 event.preventDefault(); 14488 event.stopImmediatePropagation(); 14489 } 14490}, true); 14491if ("onbeforeprint" in window) { 14492 const stopPropagationIfNeeded = function (event) { 14493 if (event.detail !== "custom") { 14494 event.stopImmediatePropagation(); 14495 } 14496 }; 14497 window.addEventListener("beforeprint", stopPropagationIfNeeded); 14498 window.addEventListener("afterprint", stopPropagationIfNeeded); 14499} 14500let overlayPromise; 14501function ensureOverlay() { 14502 if (!overlayPromise) { 14503 overlayManager = viewerApp.overlayManager; 14504 if (!overlayManager) { 14505 throw new Error("The overlay manager has not yet been initialized."); 14506 } 14507 dialog ||= document.getElementById("printServiceDialog"); 14508 overlayPromise = overlayManager.register(dialog, true); 14509 document.getElementById("printCancel").onclick = abort; 14510 dialog.addEventListener("close", abort); 14511 } 14512 return overlayPromise; 14513} 14514class PDFPrintServiceFactory extends BasePrintServiceFactory { 14515 static initGlobals(app) { 14516 viewerApp = app; 14517 } 14518 static get supportsPrinting() { 14519 return shadow(this, "supportsPrinting", true); 14520 } 14521 static createPrintService(params) { 14522 if (activeService) { 14523 throw new Error("The print service is created and active."); 14524 } 14525 return activeService = new PDFPrintService(params); 14526 } 14527} 14528 14529;// ./web/renderable_view.js 14530const RenderingStates = { 14531 INITIAL: 0, 14532 RUNNING: 1, 14533 PAUSED: 2, 14534 FINISHED: 3 14535}; 14536class RenderableView { 14537 renderingId = ""; 14538 renderTask = null; 14539 resume = null; 14540 get renderingState() { 14541 throw new Error("Abstract getter `renderingState` accessed"); 14542 } 14543 set renderingState(state) { 14544 throw new Error("Abstract setter `renderingState` accessed"); 14545 } 14546 async draw() { 14547 throw new Error("Not implemented: draw"); 14548 } 14549} 14550 14551;// ./web/pdf_rendering_queue.js 14552 14553 14554const CLEANUP_TIMEOUT = 30000; 14555class PDFRenderingQueue { 14556 #highestPriorityPage = null; 14557 #idleTimeout = null;
14558 #pdfThumbnailViewer = null; 14559 #pdfViewer = null; 14560 isThumbnailViewEnabled = false; 14561 onIdle = null; 14562 printing = false; 14563 constructor() { 14564 Object.defineProperty(this, "hasViewer", { 14565 value: () => !!this.#pdfViewer 14566 }); 14567 } 14568 setViewer(pdfViewer) { 14569 this.#pdfViewer = pdfViewer; 14570 } 14571 setThumbnailViewer(pdfThumbnailViewer) { 14572 this.#pdfThumbnailViewer = pdfThumbnailViewer; 14573 } 14574 isHighestPriority(view) { 14575 return this.#highestPriorityPage === view.renderingId; 14576 } 14577 renderHighestPriority(currentlyVisiblePages) { 14578 if (this.#idleTimeout) { 14579 clearTimeout(this.#idleTimeout); 14580 this.#idleTimeout = null; 14581 } 14582 if (this.#pdfViewer.forceRendering(currentlyVisiblePages)) { 14583 return; 14584 } 14585 if (this.isThumbnailViewEnabled && this.#pdfThumbnailViewer?.forceRendering()) { 14586 return; 14587 } 14588 if (this.printing) { 14589 return; 14590 } 14591 if (this.onIdle) { 14592 this.#idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT); 14593 } 14594 } 14595 getHighestPriority(visible, views, scrolledDown, preRenderExtra = false, ignoreDetailViews = false) { 14596 const visibleViews = visible.views, 14597 numVisible = visibleViews.length; 14598 if (numVisible === 0) { 14599 return null; 14600 } 14601 for (let i = 0; i < numVisible; i++) { 14602 const view = visibleViews[i].view; 14603 if (!this.isViewFinished(view)) { 14604 return view; 14605 } 14606 } 14607 if (!ignoreDetailViews) { 14608 for (let i = 0; i < numVisible; i++) { 14609 const { 14610 detailView 14611 } = visibleViews[i].view; 14612 if (detailView && !this.isViewFinished(detailView)) { 14613 return detailView; 14614 } 14615 } 14616 } 14617 const firstId = visible.first.id, 14618 lastId = visible.last.id; 14619 if (lastId - firstId + 1 > numVisible) { 14620 const visibleIds = visible.ids; 14621 for (let i = 1, ii = lastId - firstId; i < ii; i++) { 14622 const holeId = scrolledDown ? firstId + i : lastId - i; 14623 if (visibleIds.has(holeId)) { 14624 continue; 14625 } 14626 const holeView = views[holeId - 1]; 14627 if (!this.isViewFinished(holeView)) { 14628 return holeView; 14629 } 14630 } 14631 } 14632 let preRenderIndex = scrolledDown ? lastId : firstId - 2; 14633 let preRenderView = views[preRenderIndex]; 14634 if (preRenderView && !this.isViewFinished(preRenderView)) { 14635 return preRenderView; 14636 } 14637 if (preRenderExtra) { 14638 preRenderIndex += scrolledDown ? 1 : -1; 14639 preRenderView = views[preRenderIndex]; 14640 if (preRenderView && !this.isViewFinished(preRenderView)) { 14641 return preRenderView; 14642 } 14643 } 14644 return null; 14645 } 14646 isViewFinished(view) { 14647 return view.renderingState === RenderingStates.FINISHED; 14648 } 14649 renderView(view) { 14650 switch (view.renderingState) { 14651 case RenderingStates.FINISHED: 14652 return false; 14653 case RenderingStates.PAUSED: 14654 this.#highestPriorityPage = view.renderingId; 14655 view.resume(); 14656 break; 14657 case RenderingStates.RUNNING: 14658 this.#highestPriorityPage = view.renderingId; 14659 break; 14660 case RenderingStates.INITIAL: 14661 this.#highestPriorityPage = view.renderingId; 14662 view.draw().finally(() => { 14663 this.renderHighestPriority(); 14664 }).catch(reason => { 14665 if (reason instanceof RenderingCancelledException) { 14666 return; 14667 } 14668 console.error("renderView:", reason); 14669 }); 14670 break; 14671 } 14672 return true; 14673 } 14674} 14675 14676;// ./web/pdf_scripting_manager.js 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690class PDFScriptingManager { 14691 #closeCapability = null; 14692 #destroyCapability = null; 14693 #docProperties = null; 14694 #eventAbortController = null; 14695 #eventBus = null; 14696 #externalServices = null; 14697 #pdfDocument = null; 14698 #pdfViewer = null; 14699 #ready = false; 14700 #scripting = null; 14701 #willPrintCapability = null; 14702 constructor({ 14703 eventBus, 14704 externalServices = null, 14705 docProperties = null 14706 }) { 14707 this.#eventBus = eventBus; 14708 this.#externalServices = externalServices; 14709 this.#docProperties = docProperties; 14710 } 14711 setViewer(pdfViewer) { 14712 this.#pdfViewer = pdfViewer; 14713 } 14714 async setDocument(pdfDocument) { 14715 if (this.#pdfDocument) { 14716 await this.#destroyScripting(); 14717 } 14718 this.#pdfDocument = pdfDocument; 14719 if (!pdfDocument) { 14720 return; 14721 } 14722 const [objects, calculationOrder, docActions] = await Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]); 14723 if (!objects && !docActions) { 14724 await this.#destroyScripting(); 14725 return; 14726 } 14727 if (pdfDocument !== this.#pdfDocument) { 14728 return; 14729 } 14730 try { 14731 this.#scripting = this.#initScripting(); 14732 } catch (error) { 14733 console.error("setDocument:", error); 14734 await this.#destroyScripting(); 14735 return; 14736 } 14737 const eventBus = this.#eventBus; 14738 this.#eventAbortController = new AbortController(); 14739 const { 14740 signal 14741 } = this.#eventAbortController; 14742 eventBus._on("updatefromsandbox", event => { 14743 if (event?.source === window) { 14744 this.#updateFromSandbox(event.detail); 14745 } 14746 }, {
14747 signal 14748 }); 14749 eventBus._on("dispatcheventinsandbox", event => { 14750 this.#scripting?.dispatchEventInSandbox(event.detail); 14751 }, { 14752 signal 14753 }); 14754 eventBus._on("pagechanging", ({ 14755 pageNumber, 14756 previous 14757 }) => { 14758 if (pageNumber === previous) { 14759 return; 14760 } 14761 this.#dispatchPageClose(previous); 14762 this.#dispatchPageOpen(pageNumber); 14763 }, { 14764 signal 14765 }); 14766 eventBus._on("pagerendered", ({ 14767 pageNumber 14768 }) => { 14769 if (!this._pageOpenPending.has(pageNumber)) { 14770 return; 14771 } 14772 if (pageNumber !== this.#pdfViewer.currentPageNumber) { 14773 return; 14774 } 14775 this.#dispatchPageOpen(pageNumber); 14776 }, { 14777 signal 14778 }); 14779 eventBus._on("pagesdestroy", async () => { 14780 await this.#dispatchPageClose(this.#pdfViewer.currentPageNumber); 14781 await this.#scripting?.dispatchEventInSandbox({ 14782 id: "doc", 14783 name: "WillClose" 14784 }); 14785 this.#closeCapability?.resolve(); 14786 }, { 14787 signal 14788 }); 14789 try { 14790 const docProperties = await this.#docProperties(pdfDocument); 14791 if (pdfDocument !== this.#pdfDocument) { 14792 return; 14793 } 14794 await this.#scripting.createSandbox({ 14795 objects, 14796 calculationOrder, 14797 appInfo: { 14798 platform: navigator.platform, 14799 language: navigator.language 14800 }, 14801 docInfo: { 14802 ...docProperties, 14803 actions: docActions 14804 } 14805 }); 14806 eventBus.dispatch("sandboxcreated", { 14807 source: this 14808 }); 14809 } catch (error) { 14810 console.error("setDocument:", error); 14811 await this.#destroyScripting(); 14812 return; 14813 } 14814 await this.#scripting?.dispatchEventInSandbox({ 14815 id: "doc", 14816 name: "Open" 14817 }); 14818 await this.#dispatchPageOpen(this.#pdfViewer.currentPageNumber, true); 14819 Promise.resolve().then(() => { 14820 if (pdfDocument === this.#pdfDocument) { 14821 this.#ready = true; 14822 } 14823 }); 14824 } 14825 async dispatchWillSave() { 14826 return this.#scripting?.dispatchEventInSandbox({ 14827 id: "doc", 14828 name: "WillSave" 14829 }); 14830 } 14831 async dispatchDidSave() { 14832 return this.#scripting?.dispatchEventInSandbox({ 14833 id: "doc", 14834 name: "DidSave" 14835 }); 14836 } 14837 async dispatchWillPrint() { 14838 if (!this.#scripting) { 14839 return; 14840 } 14841 await this.#willPrintCapability?.promise; 14842 this.#willPrintCapability = Promise.withResolvers(); 14843 try { 14844 await this.#scripting.dispatchEventInSandbox({ 14845 id: "doc", 14846 name: "WillPrint" 14847 }); 14848 } catch (ex) { 14849 this.#willPrintCapability.resolve(); 14850 this.#willPrintCapability = null; 14851 throw ex; 14852 } 14853 await this.#willPrintCapability.promise; 14854 } 14855 async dispatchDidPrint() { 14856 return this.#scripting?.dispatchEventInSandbox({ 14857 id: "doc", 14858 name: "DidPrint" 14859 }); 14860 } 14861 get destroyPromise() { 14862 return this.#destroyCapability?.promise || null; 14863 } 14864 get ready() { 14865 return this.#ready; 14866 } 14867 get _pageOpenPending() { 14868 return shadow(this, "_pageOpenPending", new Set()); 14869 } 14870 get _visitedPages() { 14871 return shadow(this, "_visitedPages", new Map()); 14872 } 14873 async #updateFromSandbox(detail) { 14874 const pdfViewer = this.#pdfViewer; 14875 const isInPresentationMode = pdfViewer.isInPresentationMode || pdfViewer.isChangingPresentationMode; 14876 const { 14877 id, 14878 siblings, 14879 command, 14880 value 14881 } = detail; 14882 if (!id) { 14883 switch (command) { 14884 case "clear": 14885 console.clear(); 14886 break; 14887 case "error": 14888 console.error(value); 14889 break; 14890 case "layout": 14891 if (!isInPresentationMode) { 14892 const modes = apiPageLayoutToViewerModes(value); 14893 pdfViewer.spreadMode = modes.spreadMode; 14894 } 14895 break; 14896 case "page-num": 14897 pdfViewer.currentPageNumber = value + 1; 14898 break; 14899 case "print": 14900 await pdfViewer.pagesPromise; 14901 this.#eventBus.dispatch("print", { 14902 source: this 14903 }); 14904 break; 14905 case "println": 14906 console.log(value); 14907 break; 14908 case "zoom": 14909 if (!isInPresentationMode) { 14910 pdfViewer.currentScaleValue = value; 14911 } 14912 break; 14913 case "SaveAs": 14914 this.#eventBus.dispatch("download", { 14915 source: this 14916 }); 14917 break; 14918 case "FirstPage": 14919 pdfViewer.currentPageNumber = 1; 14920 break; 14921 case "LastPage": 14922 pdfViewer.currentPageNumber = pdfViewer.pagesCount; 14923 break; 14924 case "NextPage": 14925 pdfViewer.nextPage(); 14926 break; 14927 case "PrevPage": 14928 pdfViewer.previousPage(); 14929 break; 14930 case "ZoomViewIn": 14931 if (!isInPresentationMode) { 14932 pdfViewer.increaseScale(); 14933 } 14934 break; 14935 case "ZoomViewOut": 14936 if (!isInPresentationMode) { 14937 pdfViewer.decreaseScale(); 14938 } 14939 break; 14940 case "WillPrintFinished": 14941 this.#willPrintCapability?.resolve(); 14942 this.#willPrintCapability = null; 14943 break; 14944 } 14945 return; 14946 } 14947 if (isInPresentationMode && detail.focus) { 14948 return; 14949 } 14950 delete detail.id; 14951 delete detail.siblings; 14952 const ids = siblings ? [id, ...siblings] : [id]; 14953 for (const elementId of ids) { 14954 const element = document.querySelector(`[data-element-id="${elementId}"]`); 14955 if (element) { 14956 element.dispatchEvent(new CustomEvent("updatefromsandbox", { 14957 detail 14958 })); 14959 } else { 14960 this.#pdfDocument?.annotationStorage.setValue(elementId, detail); 14961 } 14962 } 14963 }
14964 async #dispatchPageOpen(pageNumber, initialize = false) { 14965 const pdfDocument = this.#pdfDocument, 14966 visitedPages = this._visitedPages; 14967 if (initialize) { 14968 this.#closeCapability = Promise.withResolvers(); 14969 } 14970 if (!this.#closeCapability) { 14971 return; 14972 } 14973 const pageView = this.#pdfViewer.getPageView(pageNumber - 1); 14974 if (pageView?.renderingState !== RenderingStates.FINISHED) { 14975 this._pageOpenPending.add(pageNumber); 14976 return; 14977 } 14978 this._pageOpenPending.delete(pageNumber); 14979 const actionsPromise = (async () => { 14980 const actions = await (!visitedPages.has(pageNumber) ? pageView.pdfPage?.getJSActions() : null); 14981 if (pdfDocument !== this.#pdfDocument) { 14982 return; 14983 } 14984 await this.#scripting?.dispatchEventInSandbox({ 14985 id: "page", 14986 name: "PageOpen", 14987 pageNumber, 14988 actions 14989 }); 14990 })(); 14991 visitedPages.set(pageNumber, actionsPromise); 14992 } 14993 async #dispatchPageClose(pageNumber) { 14994 const pdfDocument = this.#pdfDocument, 14995 visitedPages = this._visitedPages; 14996 if (!this.#closeCapability) { 14997 return; 14998 } 14999 if (this._pageOpenPending.has(pageNumber)) { 15000 return; 15001 } 15002 const actionsPromise = visitedPages.get(pageNumber); 15003 if (!actionsPromise) { 15004 return; 15005 } 15006 visitedPages.set(pageNumber, null); 15007 await actionsPromise; 15008 if (pdfDocument !== this.#pdfDocument) { 15009 return; 15010 } 15011 await this.#scripting?.dispatchEventInSandbox({ 15012 id: "page", 15013 name: "PageClose", 15014 pageNumber 15015 }); 15016 } 15017 #initScripting() { 15018 this.#destroyCapability = Promise.withResolvers(); 15019 if (this.#scripting) { 15020 throw new Error("#initScripting: Scripting already exists."); 15021 } 15022 return this.#externalServices.createScripting(); 15023 } 15024 async #destroyScripting() { 15025 if (!this.#scripting) { 15026 this.#pdfDocument = null; 15027 this.#destroyCapability?.resolve(); 15028 return; 15029 } 15030 if (this.#closeCapability) { 15031 await Promise.race([this.#closeCapability.promise, new Promise(resolve => { 15032 setTimeout(resolve, 1000); 15033 })]).catch(() => {}); 15034 this.#closeCapability = null; 15035 } 15036 this.#pdfDocument = null; 15037 try { 15038 await this.#scripting.destroySandbox(); 15039 } catch {} 15040 this.#willPrintCapability?.reject(new Error("Scripting destroyed.")); 15041 this.#willPrintCapability = null; 15042 this.#eventAbortController?.abort(); 15043 this.#eventAbortController = null; 15044 this._pageOpenPending.clear(); 15045 this._visitedPages.clear(); 15046 this.#scripting = null; 15047 this.#ready = false; 15048 this.#destroyCapability?.resolve(); 15049 } 15050} 15051 15052;// ./web/pdf_text_extractor.js 15053 15054 15055 15056 15057 15058 15059 15060class PdfTextExtractor { 15061 #pdfViewer; 15062 #externalServices; 15063 #textPromise; 15064 #pendingRequests = new Set(); 15065 constructor(externalServices) { 15066 this.#externalServices = externalServices; 15067 window.addEventListener("requestTextContent", ({ 15068 detail 15069 }) => { 15070 this.extractTextContent(detail.requestId); 15071 }); 15072 } 15073 setViewer(pdfViewer) { 15074 this.#pdfViewer = pdfViewer; 15075 if (this.#pdfViewer && this.#pendingRequests.size) { 15076 for (const pendingRequest of this.#pendingRequests) { 15077 this.extractTextContent(pendingRequest); 15078 } 15079 this.#pendingRequests.clear(); 15080 } 15081 } 15082 async extractTextContent(requestId) { 15083 if (!this.#pdfViewer) { 15084 this.#pendingRequests.add(requestId); 15085 return; 15086 } 15087 if (!this.#textPromise) { 15088 const textPromise = this.#textPromise = this.#pdfViewer.getAllText(); 15089 textPromise.then(() => { 15090 setTimeout(() => { 15091 if (this.#textPromise === textPromise) { 15092 this.#textPromise = null; 15093 } 15094 }, 5000); 15095 }); 15096 } 15097 this.#externalServices.reportText({ 15098 text: await this.#textPromise, 15099 requestId 15100 }); 15101 } 15102} 15103 15104// EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.find.js 15105var es_iterator_find = __webpack_require__(116); 15106;// ./web/menu.js 15107 15108 15109 15110 15111class Menu { 15112 #triggeringButton; 15113 #menu; 15114 #menuItems; 15115 #openMenuAC = null; 15116 #menuAC = new AbortController(); 15117 #lastIndex = -1; 15118 #onFocusOutBound = this.#onFocusOut.bind(this); 15119 constructor(menuContainer, triggeringButton, menuItems) { 15120 this.#menu = menuContainer; 15121 this.#triggeringButton = triggeringButton; 15122 if (Array.isArray(menuItems)) { 15123 this.#menuItems = menuItems; 15124 } else { 15125 this.#menuItems = []; 15126 for (const button of this.#menu.querySelectorAll("button")) { 15127 this.#menuItems.push(button); 15128 } 15129 } 15130 this.#setUpMenu(); 15131 } 15132 #closeMenu() { 15133 if (!this.#openMenuAC) { 15134 return; 15135 } 15136 const menu = this.#menu; 15137 this.#triggeringButton.ariaExpanded = "false"; 15138 this.#openMenuAC.abort(); 15139 this.#openMenuAC = null; 15140 if (menu.contains(document.activeElement)) { 15141 setTimeout(() => { 15142 if (!menu.contains(document.activeElement)) { 15143 this.#triggeringButton.focus(); 15144 } 15145 }, 0); 15146 } 15147 this.#lastIndex = -1; 15148 } 15149 #openMenu() { 15150 if (this.#openMenuAC) { 15151 return; 15152 } 15153 const menu = this.#menu; 15154 this.#triggeringButton.ariaExpanded = "true"; 15155 this.#openMenuAC = new AbortController(); 15156 const signal = AbortSignal.any([this.#menuAC.signal, this.#openMenuAC.signal]); 15157 window.addEventListener("pointerdown", ({ 15158 target 15159 }) => { 15160 if (!this.#triggeringButton.contains(target) && !menu.contains(target)) { 15161 this.#closeMenu(); 15162 } 15163 }, {
15164 signal 15165 }); 15166 const closeMenu = this.#closeMenu.bind(this); 15167 window.addEventListener("blur", closeMenu, { 15168 signal 15169 }); 15170 menu.addEventListener("focusout", this.#onFocusOutBound, { 15171 signal 15172 }); 15173 } 15174 #onFocusOut({ 15175 relatedTarget 15176 }) { 15177 if (!this.#triggeringButton.contains(relatedTarget) && !this.#menu.contains(relatedTarget)) { 15178 this.#closeMenu(); 15179 } 15180 } 15181 #setUpMenu() { 15182 this.#triggeringButton.addEventListener("click", e => { 15183 if (this.#openMenuAC) { 15184 this.#closeMenu(); 15185 return; 15186 } 15187 this.#openMenu(); 15188 }); 15189 this.#triggeringButton.addEventListener("focusout", this.#onFocusOutBound); 15190 const { 15191 signal 15192 } = this.#menuAC; 15193 this.#menu.addEventListener("keydown", e => { 15194 switch (e.key) { 15195 case "Escape": 15196 this.#closeMenu(); 15197 stopEvent(e); 15198 break; 15199 case "ArrowDown": 15200 this.#goToNextItem(e.target, true); 15201 stopEvent(e); 15202 break; 15203 case "ArrowUp": 15204 this.#goToNextItem(e.target, false); 15205 stopEvent(e); 15206 break; 15207 case "Home": 15208 this.#menuItems.find(item => !item.disabled && !item.classList.contains("hidden"))?.focus(); 15209 stopEvent(e); 15210 break; 15211 case "End": 15212 this.#menuItems.findLast(item => !item.disabled && !item.classList.contains("hidden"))?.focus(); 15213 stopEvent(e); 15214 break; 15215 default: 15216 const { 15217 key 15218 } = e; 15219 if (!/^\p{L}$/u.test(key)) { 15220 break; 15221 } 15222 const char = key.toLocaleLowerCase(); 15223 this.#goToNextItem(e.target, true, item => item.textContent.trim().toLowerCase().startsWith(char)); 15224 stopEvent(e); 15225 break; 15226 } 15227 }, { 15228 signal, 15229 capture: true 15230 }); 15231 this.#menu.addEventListener("contextmenu", noContextMenu, { 15232 signal 15233 }); 15234 this.#menu.addEventListener("click", this.#closeMenu.bind(this), { 15235 signal, 15236 capture: true 15237 }); 15238 this.#triggeringButton.addEventListener("keydown", e => { 15239 switch (e.key) { 15240 case " ": 15241 case "Enter": 15242 case "ArrowDown": 15243 case "Home": 15244 stopEvent(e); 15245 if (!this.#openMenuAC) { 15246 this.#openMenu(); 15247 } 15248 this.#menuItems.find(item => !item.disabled && !item.classList.contains("hidden"))?.focus(); 15249 break; 15250 case "ArrowUp": 15251 case "End": 15252 stopEvent(e); 15253 if (!this.#openMenuAC) { 15254 this.#openMenu(); 15255 } 15256 this.#menuItems.findLast(item => !item.disabled && !item.classList.contains("hidden"))?.focus(); 15257 break; 15258 case "Escape": 15259 this.#closeMenu(); 15260 stopEvent(e); 15261 break; 15262 } 15263 }, { 15264 signal 15265 }); 15266 } 15267 #goToNextItem(element, forward, check = () => true) { 15268 const index = this.#lastIndex === -1 ? this.#menuItems.indexOf(element) : this.#lastIndex; 15269 const len = this.#menuItems.length; 15270 const increment = forward ? 1 : len - 1; 15271 for (let i = (index + increment) % len; i !== index; i = (i + increment) % len) { 15272 const menuItem = this.#menuItems[i]; 15273 if (!menuItem.disabled && !menuItem.classList.contains("hidden") && check(menuItem)) { 15274 menuItem.focus(); 15275 this.#lastIndex = i; 15276 break; 15277 } 15278 } 15279 } 15280 destroy() { 15281 this.#closeMenu(); 15282 this.#menuAC?.abort(); 15283 this.#menuAC = null; 15284 } 15285} 15286 15287;// ./web/pdf_thumbnail_view.js 15288 15289 15290 15291 15292 15293 15294 15295 15296const DRAW_UPSCALE_FACTOR = 2; 15297const MAX_NUM_SCALING_STEPS = 3; 15298const THUMBNAIL_WIDTH = 126; 15299class TempImageFactory { 15300 static getCanvas(width, height) { 15301 let tempCanvas; 15302 if (FeatureTest.isOffscreenCanvasSupported) { 15303 tempCanvas = new OffscreenCanvas(width, height); 15304 } else { 15305 tempCanvas = document.createElement("canvas"); 15306 tempCanvas.width = width; 15307 tempCanvas.height = height; 15308 } 15309 const ctx = tempCanvas.getContext("2d", { 15310 alpha: false 15311 }); 15312 ctx.save(); 15313 ctx.fillStyle = "rgb(255, 255, 255)"; 15314 ctx.fillRect(0, 0, width, height);
15315 ctx.restore(); 15316 return [tempCanvas, ctx]; 15317 } 15318} 15319class PDFThumbnailView extends RenderableView { 15320 #renderingState = RenderingStates.INITIAL; 15321 constructor({ 15322 container, 15323 eventBus, 15324 id, 15325 defaultViewport, 15326 optionalContentConfigPromise, 15327 linkService, 15328 renderingQueue, 15329 maxCanvasPixels, 15330 maxCanvasDim, 15331 pageColors, 15332 enableSplitMerge = false 15333 }) { 15334 super(); 15335 this.id = id; 15336 this.renderingId = `thumbnail${id}`; 15337 this.pageLabel = null; 15338 this.pdfPage = null; 15339 this.rotation = 0; 15340 this.viewport = defaultViewport; 15341 this.pdfPageRotate = defaultViewport.rotation; 15342 this._optionalContentConfigPromise = optionalContentConfigPromise || null; 15343 this.maxCanvasPixels = maxCanvasPixels ?? AppOptions.get("maxCanvasPixels"); 15344 this.maxCanvasDim = maxCanvasDim || AppOptions.get("maxCanvasDim"); 15345 this.pageColors = pageColors || null; 15346 this.eventBus = eventBus; 15347 this.linkService = linkService; 15348 this.renderingQueue = renderingQueue; 15349 this.placeholder = null; 15350 const thumbnailContainer = this.div = document.createElement("div"); 15351 thumbnailContainer.className = "thumbnail"; 15352 thumbnailContainer.setAttribute("page-number", id); 15353 const imageContainer = this.imageContainer = document.createElement("div"); 15354 thumbnailContainer.append(imageContainer); 15355 imageContainer.classList.add("thumbnailImageContainer", "missingThumbnailImage"); 15356 imageContainer.role = "button"; 15357 imageContainer.tabIndex = -1; 15358 imageContainer.draggable = false; 15359 imageContainer.setAttribute("page-number", id); 15360 imageContainer.setAttribute("data-l10n-id", "pdfjs-thumb-page-title1"); 15361 imageContainer.setAttribute("data-l10n-args", this.#getPageL10nArgs(true)); 15362 const image = this.image = document.createElement("img"); 15363 imageContainer.append(image); 15364 if (enableSplitMerge) { 15365 const checkbox = this.checkbox = document.createElement("input"); 15366 checkbox.type = "checkbox"; 15367 checkbox.tabIndex = -1; 15368 checkbox.setAttribute("data-l10n-id", "pdfjs-thumb-page-checkbox1"); 15369 checkbox.setAttribute("data-l10n-args", this.#getPageL10nArgs()); 15370 thumbnailContainer.append(checkbox); 15371 this.pasteButton = null; 15372 } 15373 this.#updateDims(); 15374 container.append(thumbnailContainer); 15375 } 15376 clone(container, id) { 15377 const thumbnailView = new PDFThumbnailView({ 15378 container, 15379 id, 15380 eventBus: this.eventBus, 15381 defaultViewport: this.viewport, 15382 optionalContentConfigPromise: this._optionalContentConfigPromise, 15383 linkService: this.linkService, 15384 renderingQueue: this.renderingQueue, 15385 maxCanvasPixels: this.maxCanvasPixels, 15386 maxCanvasDim: this.maxCanvasDim, 15387 pageColors: this.pageColors, 15388 enableSplitMerge: !!this.checkbox 15389 }); 15390 thumbnailView.setPdfPage(this.pdfPage); 15391 const { 15392 imageContainer 15393 } = this; 15394 if (!imageContainer.classList.contains("missingThumbnailImage")) { 15395 thumbnailView.image.replaceWith(this.image.cloneNode(true)); 15396 thumbnailView.imageContainer.classList.remove("missingThumbnailImage"); 15397 } 15398 return thumbnailView; 15399 } 15400 addPasteButton(pasteCallback) { 15401 if (this.pasteButton) { 15402 return; 15403 } 15404 const pasteButton = this.pasteButton = document.createElement("button"); 15405 pasteButton.classList.add("thumbnailPasteButton", "viewsManagerButton"); 15406 pasteButton.tabIndex = 0; 15407 const span = document.createElement("span"); 15408 span.setAttribute("data-l10n-id", "pdfjs-views-manager-paste-button-label"); 15409 pasteButton.append(span); 15410 pasteButton.addEventListener("click", () => { 15411 pasteCallback(this.id); 15412 }); 15413 this.imageContainer.after(pasteButton); 15414 } 15415 toggleSelected(isSelected) { 15416 if (this.checkbox) { 15417 this.checkbox.checked = isSelected; 15418 } 15419 } 15420 updateId(newId) { 15421 this.id = newId; 15422 this.renderingId = `thumbnail${newId}`; 15423 this.div.setAttribute("page-number", newId); 15424 this.imageContainer.setAttribute("page-number", newId); 15425 this.setPageLabel(this.pageLabel); 15426 } 15427 #updateDims() { 15428 const { 15429 width, 15430 height 15431 } = this.viewport; 15432 const ratio = width / height; 15433 const canvasWidth = this.canvasWidth = THUMBNAIL_WIDTH; 15434 const canvasHeight = this.canvasHeight = canvasWidth / ratio | 0; 15435 this.scale = canvasWidth / width; 15436 this.imageContainer.style.height = `${canvasHeight}px`; 15437 } 15438 get renderingState() { 15439 return this.#renderingState; 15440 } 15441 set renderingState(state) { 15442 this.#renderingState = state; 15443 } 15444 setPdfPage(pdfPage) { 15445 this.pdfPage = pdfPage; 15446 this.pdfPageRotate = pdfPage.rotate; 15447 const totalRotation = (this.rotation + this.pdfPageRotate) % 360; 15448 this.viewport = pdfPage.getViewport({ 15449 scale: 1, 15450 rotation: totalRotation 15451 }); 15452 this.reset(); 15453 } 15454 reset() { 15455 this.cancelRendering(); 15456 this.renderingState = RenderingStates.INITIAL; 15457 this.#updateDims(); 15458 const { 15459 image, 15460 imageContainer 15461 } = this; 15462 const url = image.src; 15463 if (url) { 15464 URL.revokeObjectURL(url); 15465 image.src = ""; 15466 imageContainer.removeAttribute("data-l10n-id"); 15467 imageContainer.removeAttribute("data-l10n-args"); 15468 imageContainer.classList.add("missingThumbnailImage"); 15469 } 15470 } 15471 destroy() { 15472 this.reset(); 15473 this.toggleCurrent(false); 15474 this.div.remove(); 15475 } 15476 update({ 15477 rotation = null 15478 }) { 15479 if (typeof rotation === "number") { 15480 this.rotation = rotation; 15481 } 15482 const totalRotation = (this.rotation + this.pdfPageRotate) % 360; 15483 this.viewport = this.viewport.clone({ 15484 scale: 1, 15485 rotation: totalRotation 15486 }); 15487 this.reset(); 15488 } 15489 toggleCurrent(isCurrent) { 15490 const { 15491 imageContainer 15492 } = this; 15493 if (isCurrent) { 15494 imageContainer.ariaCurrent = "page"; 15495 imageContainer.tabIndex = 0; 15496 if (this.checkbox) { 15497 this.checkbox.tabIndex = 0; 15498 } 15499 } else { 15500 imageContainer.ariaCurrent = false;
15501 imageContainer.tabIndex = -1; 15502 if (this.checkbox) { 15503 this.checkbox.tabIndex = -1; 15504 } 15505 } 15506 } 15507 cancelRendering() { 15508 if (this.renderTask) { 15509 this.renderTask.cancel(); 15510 this.renderTask = null; 15511 } 15512 this.resume = null; 15513 } 15514 #getPageDrawContext(upscaleFactor = 1) { 15515 const outputScale = new OutputScale(); 15516 const width = upscaleFactor * this.canvasWidth, 15517 height = upscaleFactor * this.canvasHeight; 15518 outputScale.limitCanvas(width, height, this.maxCanvasPixels, this.maxCanvasDim); 15519 const canvas = document.createElement("canvas"); 15520 canvas.width = width * outputScale.sx | 0; 15521 canvas.height = height * outputScale.sy | 0; 15522 const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null; 15523 return { 15524 canvas, 15525 transform 15526 }; 15527 } 15528 async #convertCanvasToImage(canvas) { 15529 if (this.renderingState !== RenderingStates.FINISHED) { 15530 throw new Error("#convertCanvasToImage: Rendering has not finished."); 15531 } 15532 const reducedCanvas = this.#reduceImage(canvas); 15533 const { 15534 imageContainer, 15535 image 15536 } = this; 15537 const { 15538 promise, 15539 resolve 15540 } = Promise.withResolvers(); 15541 reducedCanvas.toBlob(resolve); 15542 const blob = await promise; 15543 image.src = URL.createObjectURL(blob); 15544 image.setAttribute("data-l10n-id", "pdfjs-thumb-page-canvas"); 15545 image.setAttribute("data-l10n-args", this.#getPageL10nArgs()); 15546 imageContainer.classList.remove("missingThumbnailImage"); 15547 if (!FeatureTest.isOffscreenCanvasSupported) { 15548 reducedCanvas.width = reducedCanvas.height = 0; 15549 } 15550 } 15551 async draw() { 15552 if (this.renderingState !== RenderingStates.INITIAL) { 15553 console.error("Must be in new state before drawing"); 15554 return; 15555 } 15556 const { 15557 pageColors, 15558 pdfPage 15559 } = this; 15560 if (!pdfPage) { 15561 this.renderingState = RenderingStates.FINISHED; 15562 throw new Error("pdfPage is not loaded"); 15563 } 15564 this.renderingState = RenderingStates.RUNNING; 15565 const { 15566 canvas, 15567 transform 15568 } = this.#getPageDrawContext(DRAW_UPSCALE_FACTOR); 15569 const drawViewport = this.viewport.clone({ 15570 scale: DRAW_UPSCALE_FACTOR * this.scale 15571 }); 15572 const renderContinueCallback = cont => { 15573 if (!this.renderingQueue.isHighestPriority(this)) { 15574 this.renderingState = RenderingStates.PAUSED; 15575 this.resume = () => { 15576 this.renderingState = RenderingStates.RUNNING; 15577 cont(); 15578 }; 15579 return; 15580 } 15581 cont(); 15582 }; 15583 const renderContext = { 15584 canvas, 15585 transform, 15586 viewport: drawViewport, 15587 optionalContentConfigPromise: this._optionalContentConfigPromise, 15588 pageColors 15589 }; 15590 const renderTask = this.renderTask = pdfPage.render(renderContext); 15591 renderTask.onContinue = renderContinueCallback; 15592 let error = null; 15593 try { 15594 await renderTask.promise; 15595 } catch (e) { 15596 if (e instanceof RenderingCancelledException) { 15597 return; 15598 } 15599 error = e; 15600 } finally { 15601 if (renderTask === this.renderTask) { 15602 this.renderTask = null; 15603 } 15604 } 15605 this.renderingState = RenderingStates.FINISHED; 15606 await this.#convertCanvasToImage(canvas); 15607 this.eventBus.dispatch("thumbnailrendered", { 15608 source: this, 15609 pageNumber: this.id, 15610 pdfPage 15611 }); 15612 if (error) { 15613 throw error; 15614 } 15615 } 15616 setImage(pageView) { 15617 if (this.renderingState !== RenderingStates.INITIAL) { 15618 return; 15619 } 15620 const { 15621 thumbnailCanvas: canvas, 15622 pdfPage, 15623 scale 15624 } = pageView; 15625 if (!canvas) { 15626 return; 15627 } 15628 if (!this.pdfPage) { 15629 this.setPdfPage(pdfPage); 15630 } 15631 if (scale < this.scale) { 15632 return; 15633 } 15634 this.renderingState = RenderingStates.FINISHED; 15635 this.#convertCanvasToImage(canvas); 15636 } 15637 #getReducedImageDims(canvas) { 15638 const width = canvas.width << MAX_NUM_SCALING_STEPS, 15639 height = canvas.height << MAX_NUM_SCALING_STEPS; 15640 const outputScale = new OutputScale(); 15641 outputScale.sx = outputScale.sy = 1; 15642 outputScale.limitCanvas(width, height, this.maxCanvasPixels, this.maxCanvasDim); 15643 return [width * outputScale.sx | 0, height * outputScale.sy | 0]; 15644 } 15645 #reduceImage(img) { 15646 const { 15647 canvas 15648 } = this.#getPageDrawContext(1); 15649 const ctx = canvas.getContext("2d", { 15650 alpha: false, 15651 willReadFrequently: false 15652 }); 15653 if (img.width <= 2 * canvas.width) { 15654 ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height); 15655 return canvas; 15656 } 15657 let [reducedWidth, reducedHeight] = this.#getReducedImageDims(canvas); 15658 const [reducedImage, reducedImageCtx] = TempImageFactory.getCanvas(reducedWidth, reducedHeight); 15659 while (reducedWidth > img.width || reducedHeight > img.height) { 15660 reducedWidth >>= 1; 15661 reducedHeight >>= 1; 15662 } 15663 reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight); 15664 while (reducedWidth > 2 * canvas.width) { 15665 reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1); 15666 reducedWidth >>= 1; 15667 reducedHeight >>= 1; 15668 } 15669 ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height); 15670 return canvas; 15671 } 15672 #getPageL10nArgs(hasTotal = false) { 15673 return JSON.stringify({ 15674 page: this.pageLabel ?? this.id, 15675 total: hasTotal ? this.linkService.pagesCount : undefined 15676 }); 15677 } 15678 setPageLabel(label) { 15679 this.pageLabel = typeof label === "string" ? label : null; 15680 this.imageContainer.setAttribute("data-l10n-args", this.#getPageL10nArgs(true)); 15681 this.image.setAttribute("data-l10n-args", this.#getPageL10nArgs()); 15682 this.checkbox?.setAttribute("data-l10n-args", this.#getPageL10nArgs()); 15683 } 15684} 15685 15686;// ./web/pdf_thumbnail_viewer.js 15687 15688 15689 15690 15691 15692 15693 15694 15695 15696 15697 15698 15699 15700 15701 15702 15703 15704 15705 15706const SCROLL_OPTIONS = { 15707 behavior: "instant", 15708 block: "nearest", 15709 inline: "nearest", 15710 container: "nearest" 15711}; 15712const DRAG_THRESHOLD_IN_PIXELS = 5; 15713const PIXELS_TO_SCROLL_WHEN_DRAGGING = 20; 15714const SPACE_FOR_DRAG_MARKER_WHEN_NO_NEXT_ELEMENT = 15; 15715class PDFThumbnailViewer { 15716 static #draggingScaleFactor = 0; 15717 #enableSplitMerge = false;
15718 #dragAC = null; 15719 #draggedContainer = null; 15720 #thumbnailsPositions = null; 15721 #lastDraggedOverIndex = NaN; 15722 #selectedPages = null; 15723 #draggedImageX = 0; 15724 #draggedImageY = 0; 15725 #draggedImageWidth = 0; 15726 #draggedImageHeight = 0; 15727 #draggedImageOffsetX = 0; 15728 #draggedImageOffsetY = 0; 15729 #dragMarker = null; 15730 #pageNumberToRemove = NaN; 15731 #currentScrollBottom = 0; 15732 #currentScrollTop = 0; 15733 #pagesMapper = null; 15734 #manageSaveAsButton = null; 15735 #manageDeleteButton = null; 15736 #manageCopyButton = null; 15737 #manageCutButton = null; 15738 #copiedThumbnails = null; 15739 #copiedPageNumbers = null; 15740 #isCut = false; 15741 #isOneColumnView = false; 15742 #scrollableContainerWidth = 0; 15743 #scrollableContainerHeight = 0; 15744 constructor({ 15745 container, 15746 eventBus, 15747 linkService, 15748 renderingQueue, 15749 maxCanvasPixels, 15750 maxCanvasDim, 15751 pageColors, 15752 abortSignal, 15753 enableHWA, 15754 enableSplitMerge, 15755 manageMenu, 15756 addFileButton 15757 }) { 15758 this.scrollableContainer = container.parentElement; 15759 this.container = container; 15760 this.eventBus = eventBus; 15761 this.linkService = linkService; 15762 this.renderingQueue = renderingQueue; 15763 this.maxCanvasPixels = maxCanvasPixels; 15764 this.maxCanvasDim = maxCanvasDim; 15765 this.pageColors = pageColors || null; 15766 this.enableHWA = enableHWA || false; 15767 this.#enableSplitMerge = enableSplitMerge || false; 15768 if (this.#enableSplitMerge && manageMenu) { 15769 const { 15770 button, 15771 menu, 15772 copy, 15773 cut, 15774 delete: del, 15775 saveAs 15776 } = manageMenu; 15777 this.eventBus.on("pagesloaded", () => { 15778 button.disabled = false; 15779 }, { 15780 once: true 15781 }); 15782 this._manageMenu = new Menu(menu, button, [copy, cut, del, saveAs]); 15783 this.#manageSaveAsButton = saveAs; 15784 saveAs.addEventListener("click", () => { 15785 this.eventBus.dispatch("savepageseditedpdf", { 15786 source: this, 15787 data: this.#pagesMapper.getPageMappingForSaving() 15788 }); 15789 }); 15790 this.#manageDeleteButton = del; 15791 del.addEventListener("click", this.#deletePages.bind(this)); 15792 this.#manageCopyButton = copy; 15793 copy.addEventListener("click", this.#copyPages.bind(this)); 15794 this.#manageCutButton = cut; 15795 cut.addEventListener("click", this.#cutPages.bind(this)); 15796 this.#toggleMenuEntries(false); 15797 button.disabled = true; 15798 } else { 15799 manageMenu.button.hidden = true; 15800 } 15801 this.scroll = watchScroll(this.scrollableContainer, this.#scrollUpdated.bind(this), abortSignal); 15802 this.#resetView(); 15803 this.#addEventListeners(); 15804 } 15805 #scrollUpdated() { 15806 this.renderingQueue.renderHighestPriority(); 15807 } 15808 getThumbnail(index) { 15809 return this._thumbnails[index]; 15810 } 15811 #getVisibleThumbs() { 15812 return getVisibleElements({ 15813 scrollEl: this.scrollableContainer, 15814 views: this._thumbnails 15815 }); 15816 } 15817 scrollThumbnailIntoView(pageNumber) { 15818 if (!this.pdfDocument) { 15819 return; 15820 } 15821 const thumbnailView = this._thumbnails[pageNumber - 1]; 15822 if (!thumbnailView) { 15823 console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.'); 15824 return; 15825 } 15826 if (pageNumber !== this._currentPageNumber) { 15827 const prevThumbnailView = this._thumbnails[this._currentPageNumber - 1]; 15828 prevThumbnailView?.toggleCurrent(false); 15829 thumbnailView.toggleCurrent(true); 15830 this._currentPageNumber = pageNumber; 15831 } 15832 const { 15833 first, 15834 last, 15835 views 15836 } = this.#getVisibleThumbs(); 15837 if (views.length > 0) { 15838 let shouldScroll = false; 15839 if (pageNumber <= first.id || pageNumber >= last.id) { 15840 shouldScroll = true; 15841 } else { 15842 for (const { 15843 id, 15844 percent 15845 } of views) { 15846 if (id !== pageNumber) { 15847 continue; 15848 } 15849 shouldScroll = percent < 100; 15850 break; 15851 } 15852 } 15853 if (shouldScroll) { 15854 thumbnailView.div.scrollIntoView(SCROLL_OPTIONS); 15855 } 15856 } 15857 this._currentPageNumber = pageNumber; 15858 } 15859 get pagesRotation() { 15860 return this._pagesRotation; 15861 } 15862 set pagesRotation(rotation) { 15863 if (!isValidRotation(rotation)) { 15864 throw new Error("Invalid thumbnails rotation angle."); 15865 } 15866 if (!this.pdfDocument) { 15867 return; 15868 } 15869 if (this._pagesRotation === rotation) { 15870 return; 15871 } 15872 this._pagesRotation = rotation; 15873 const updateArgs = { 15874 rotation 15875 }; 15876 for (const thumbnail of this._thumbnails) { 15877 thumbnail.update(updateArgs); 15878 } 15879 } 15880 cleanup() { 15881 for (const thumbnail of this._thumbnails) { 15882 if (thumbnail.renderingState !== RenderingStates.FINISHED) { 15883 thumbnail.reset(); 15884 } 15885 } 15886 } 15887 #resetView() { 15888 this._thumbnails = []; 15889 this._currentPageNumber = 1; 15890 this._pageLabels = null; 15891 this._pagesRotation = 0; 15892 this.container.textContent = ""; 15893 } 15894 setDocument(pdfDocument) { 15895 if (this.pdfDocument) { 15896 this.#cancelRendering(); 15897 this.#resetView(); 15898 } 15899 this.pdfDocument = pdfDocument; 15900 if (!pdfDocument) { 15901 return; 15902 } 15903 this.#pagesMapper = pdfDocument.pagesMapper; 15904 const firstPagePromise = pdfDocument.getPage(1); 15905 const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig({ 15906 intent: "display" 15907 }); 15908 firstPagePromise.then(firstPdfPage => { 15909 const pagesCount = pdfDocument.numPages; 15910 const viewport = firstPdfPage.getViewport({ 15911 scale: 1 15912 }); 15913 const fragment = document.createDocumentFragment(); 15914 for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) { 15915 const thumbnail = new PDFThumbnailView({ 15916 container: fragment, 15917 eventBus: this.eventBus, 15918 id: pageNum, 15919 defaultViewport: viewport.clone(), 15920 optionalContentConfigPromise, 15921 linkService: this.linkService, 15922 renderingQueue: this.renderingQueue, 15923 maxCanvasPixels: this.maxCanvasPixels, 15924 maxCanvasDim: this.maxCanvasDim, 15925 pageColors: this.pageColors, 15926 enableHWA: this.enableHWA, 15927 enableSplitMerge: this.#enableSplitMerge 15928 }); 15929 this._thumbnails.push(thumbnail); 15930 }
15931 this._thumbnails[0]?.setPdfPage(firstPdfPage); 15932 const thumbnailView = this._thumbnails[this._currentPageNumber - 1]; 15933 thumbnailView.toggleCurrent(true); 15934 this.container.append(fragment); 15935 }).catch(reason => { 15936 console.error("Unable to initialize thumbnail viewer", reason); 15937 }); 15938 } 15939 #cancelRendering() { 15940 for (const thumbnail of this._thumbnails) { 15941 thumbnail.cancelRendering(); 15942 } 15943 } 15944 setPageLabels(labels) { 15945 if (!this.pdfDocument) { 15946 return; 15947 } 15948 if (!labels) { 15949 this._pageLabels = null; 15950 } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) { 15951 this._pageLabels = null; 15952 console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels."); 15953 } else { 15954 this._pageLabels = labels; 15955 } 15956 for (let i = 0, ii = this._thumbnails.length; i < ii; i++) { 15957 this._thumbnails[i].setPageLabel(this._pageLabels?.[i] ?? null); 15958 } 15959 } 15960 async #ensurePdfPageLoaded(thumbView) { 15961 if (thumbView.pdfPage) { 15962 return thumbView.pdfPage; 15963 } 15964 try { 15965 const pdfPage = await this.pdfDocument.getPage(thumbView.id); 15966 if (!thumbView.pdfPage) { 15967 thumbView.setPdfPage(pdfPage); 15968 } 15969 return pdfPage; 15970 } catch (reason) { 15971 console.error("Unable to get page for thumb view", reason); 15972 return null; 15973 } 15974 } 15975 #getScrollAhead(visible) { 15976 if (visible.first?.id === 1) { 15977 return true; 15978 } else if (visible.last?.id === this._thumbnails.length) { 15979 return false; 15980 } 15981 return this.scroll.down; 15982 } 15983 forceRendering() { 15984 const visibleThumbs = this.#getVisibleThumbs(); 15985 const scrollAhead = this.#getScrollAhead(visibleThumbs); 15986 const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, scrollAhead, false, true); 15987 if (thumbView) { 15988 this.#ensurePdfPageLoaded(thumbView).then(() => { 15989 this.renderingQueue.renderView(thumbView); 15990 }); 15991 return true; 15992 } 15993 return false; 15994 } 15995 static #getScaleFactor(image) { 15996 return PDFThumbnailViewer.#draggingScaleFactor ||= parseFloat(getComputedStyle(image).getPropertyValue("--thumbnail-dragging-scale")); 15997 } 15998 #updateThumbnails(currentPageNumber) { 15999 let newCurrentPageNumber = 0; 16000 const pagesMapper = this.#pagesMapper; 16001 this.container.replaceChildren(); 16002 const prevThumbnails = this._thumbnails; 16003 const newThumbnails = this._thumbnails = []; 16004 const fragment = document.createDocumentFragment(); 16005 const isCut = this.#isCut; 16006 const oldThumbnails = new Set(prevThumbnails); 16007 for (let i = 1, ii = pagesMapper.pagesNumber; i <= ii; i++) { 16008 const prevPageNumber = pagesMapper.getPrevPageNumber(i); 16009 if (prevPageNumber < 0) { 16010 let thumbnail = this.#copiedThumbnails.get(-prevPageNumber); 16011 oldThumbnails.delete(thumbnail); 16012 thumbnail.checkbox.checked = false; 16013 if (isCut) { 16014 thumbnail.updateId(i); 16015 fragment.append(thumbnail.div); 16016 } else { 16017 thumbnail = thumbnail.clone(fragment, i); 16018 } 16019 newThumbnails.push(thumbnail); 16020 continue; 16021 } 16022 if (prevPageNumber === currentPageNumber) { 16023 newCurrentPageNumber = i; 16024 } 16025 const newThumbnail = prevThumbnails[prevPageNumber - 1]; 16026 newThumbnails.push(newThumbnail); 16027 newThumbnail.updateId(i); 16028 oldThumbnails.delete(newThumbnail); 16029 newThumbnail.checkbox.checked = false; 16030 fragment.append(newThumbnail.div); 16031 } 16032 this.container.append(fragment); 16033 for (const oldThumbnail of oldThumbnails) { 16034 oldThumbnail.destroy(); 16035 } 16036 return newCurrentPageNumber; 16037 } 16038 #onStartDragging(draggedThumbnail) { 16039 this.#currentScrollTop = this.scrollableContainer.scrollTop; 16040 this.#currentScrollBottom = this.#currentScrollTop + this.scrollableContainer.clientHeight; 16041 this.#dragAC = new AbortController(); 16042 this.container.classList.add("isDragging"); 16043 const startPageNumber = parseInt(draggedThumbnail.getAttribute("page-number"), 10); 16044 this.#lastDraggedOverIndex = startPageNumber - 1; 16045 if (!this.#selectedPages?.has(startPageNumber)) { 16046 this.#pageNumberToRemove = startPageNumber; 16047 this.#selectPage(startPageNumber, true); 16048 } 16049 for (const selected of this.#selectedPages) { 16050 const thumbnail = this._thumbnails[selected - 1]; 16051 const placeholder = thumbnail.placeholder = document.createElement("div"); 16052 placeholder.classList.add("thumbnailImageContainer", "placeholder"); 16053 const { 16054 div, 16055 imageContainer 16056 } = thumbnail; 16057 div.classList.add("isDragging"); 16058 placeholder.style.height = getComputedStyle(imageContainer).height; 16059 imageContainer.after(placeholder); 16060 if (selected !== startPageNumber) { 16061 imageContainer.classList.add("hidden"); 16062 continue; 16063 } 16064 if (this.#selectedPages.size === 1) { 16065 imageContainer.classList.add("draggingThumbnail"); 16066 this.#draggedContainer = imageContainer; 16067 continue; 16068 } 16069 const draggedContainer = this.#draggedContainer = document.createElement("div"); 16070 draggedContainer.classList.add("draggingThumbnail", "thumbnailImageContainer", "multiple"); 16071 draggedContainer.style.height = getComputedStyle(imageContainer).height; 16072 imageContainer.replaceWith(draggedContainer); 16073 imageContainer.classList.remove("thumbnailImageContainer"); 16074 draggedContainer.append(imageContainer); 16075 draggedContainer.setAttribute("data-multiple-count", this.#selectedPages.size); 16076 } 16077 } 16078 #onStopDragging(isDropping = false) { 16079 const draggedContainer = this.#draggedContainer; 16080 this.#draggedContainer = null; 16081 const lastDraggedOverIndex = this.#lastDraggedOverIndex; 16082 this.#lastDraggedOverIndex = NaN; 16083 this.#dragMarker?.remove(); 16084 this.#dragMarker = null; 16085 this.#dragAC.abort(); 16086 this.#dragAC = null; 16087 this.container.classList.remove("isDragging"); 16088 for (const selected of this.#selectedPages) { 16089 const thumbnail = this._thumbnails[selected - 1]; 16090 const { 16091 div, 16092 placeholder, 16093 imageContainer 16094 } = thumbnail; 16095 placeholder.remove(); 16096 imageContainer.classList.remove("draggingThumbnail", "hidden"); 16097 div.classList.remove("isDragging"); 16098 } 16099 if (draggedContainer.classList.contains("multiple")) { 16100 const originalImageContainer = draggedContainer.firstElementChild; 16101 draggedContainer.replaceWith(originalImageContainer); 16102 originalImageContainer.classList.add("thumbnailImageContainer"); 16103 } else { 16104 draggedContainer.style.translate = ""; 16105 } 16106 const selectedPages = this.#selectedPages; 16107 if (!isNaN(lastDraggedOverIndex) && isDropping && !(selectedPages.size === 1 && (selectedPages.has(lastDraggedOverIndex + 1) || selectedPages.has(lastDraggedOverIndex + 2)))) { 16108 this._thumbnails[this._currentPageNumber - 1]?.toggleCurrent(false); 16109 this._currentPageNumber = -1; 16110 const newIndex = lastDraggedOverIndex + 1; 16111 const pagesToMove = Array.from(selectedPages).sort((a, b) => a - b); 16112 const pagesMapper = this.#pagesMapper; 16113 let currentPageNumber = isNaN(this.#pageNumberToRemove) ? pagesToMove[0] : this.#pageNumberToRemove; 16114 pagesMapper.movePages(selectedPages, pagesToMove, newIndex); 16115 currentPageNumber = this.#updateThumbnails(currentPageNumber);
16116 this.#computeThumbnailsPosition(); 16117 selectedPages.clear(); 16118 this.#pageNumberToRemove = NaN; 16119 this.#updateMenuEntries(); 16120 this.eventBus.dispatch("pagesedited", { 16121 source: this, 16122 pagesMapper, 16123 type: "move" 16124 }); 16125 setTimeout(() => { 16126 this.forceRendering(); 16127 this.linkService.goToPage(currentPageNumber); 16128 }, 0); 16129 } 16130 if (!isNaN(this.#pageNumberToRemove)) { 16131 this.#selectPage(this.#pageNumberToRemove, false); 16132 this.#pageNumberToRemove = NaN; 16133 } 16134 } 16135 #clearSelection() { 16136 for (const pageNumber of this.#selectedPages) { 16137 this._thumbnails[pageNumber - 1].toggleSelected(false); 16138 } 16139 this.#selectedPages.clear(); 16140 } 16141 #copyPages(clearSelection = true) { 16142 const pageNumbersToCopy = this.#copiedPageNumbers = Uint32Array.from(this.#selectedPages).sort((a, b) => a - b); 16143 const pagesMapper = this.#pagesMapper; 16144 pagesMapper.copyPages(pageNumbersToCopy); 16145 this.#copiedThumbnails ||= new Map(); 16146 for (const pageNumber of pageNumbersToCopy) { 16147 this.#copiedThumbnails.set(pageNumber, this._thumbnails[pageNumber - 1]); 16148 } 16149 this.eventBus.dispatch("pagesedited", { 16150 source: this, 16151 pagesMapper, 16152 pageNumbers: pageNumbersToCopy, 16153 type: "copy" 16154 }); 16155 if (clearSelection) { 16156 this.#clearSelection(); 16157 } 16158 for (const thumbnail of this._thumbnails) { 16159 thumbnail.addPasteButton(this.#pastePages.bind(this)); 16160 } 16161 this.container.classList.add("pasteMode"); 16162 this.#toggleMenuEntries(false); 16163 } 16164 #cutPages() { 16165 this.#isCut = true; 16166 this.#copyPages(false); 16167 this.#deletePages("cut"); 16168 } 16169 #pastePages(index) { 16170 this.container.classList.remove("pasteMode"); 16171 this.#toggleMenuEntries(true); 16172 const pagesMapper = this.#pagesMapper; 16173 let currentPageNumber = this.#copiedPageNumbers.includes(this._currentPageNumber) ? 0 : this._currentPageNumber; 16174 pagesMapper.pastePages(index); 16175 currentPageNumber = this.#updateThumbnails(currentPageNumber); 16176 this.eventBus.dispatch("pagesedited", { 16177 source: this, 16178 pagesMapper, 16179 hasBeenCut: this.#isCut, 16180 type: "paste" 16181 }); 16182 this.#copiedThumbnails = null; 16183 this.#isCut = false; 16184 this.#updateMenuEntries(); 16185 setTimeout(() => { 16186 this.forceRendering(); 16187 this.linkService.goToPage(currentPageNumber || 1); 16188 }, 0); 16189 } 16190 #deletePages(type = "delete") { 16191 const selectedPages = this.#selectedPages; 16192 if (selectedPages.size === 0) { 16193 return; 16194 } 16195 const pagesMapper = this.#pagesMapper; 16196 let currentPageNumber = selectedPages.has(this._currentPageNumber) ? 0 : this._currentPageNumber; 16197 const pagesToDelete = Uint32Array.from(selectedPages).sort((a, b) => a - b); 16198 pagesMapper.deletePages(pagesToDelete); 16199 currentPageNumber = this.#updateThumbnails(currentPageNumber); 16200 selectedPages.clear(); 16201 this.#updateMenuEntries(); 16202 this.eventBus.dispatch("pagesedited", { 16203 source: this, 16204 pagesMapper, 16205 pageNumbers: pagesToDelete, 16206 type 16207 }); 16208 setTimeout(() => { 16209 this.forceRendering(); 16210 this.linkService.goToPage(currentPageNumber || 1); 16211 }, 0); 16212 } 16213 #updateMenuEntries() { 16214 this.#manageSaveAsButton.disabled = !this.#pagesMapper.hasBeenAltered(); 16215 this.#manageDeleteButton.disabled = this.#manageCopyButton.disabled = this.#manageCutButton.disabled = !this.#selectedPages?.size; 16216 } 16217 #toggleMenuEntries(enable) { 16218 this.#manageSaveAsButton.disabled = this.#manageDeleteButton.disabled = this.#manageCopyButton.disabled = this.#manageCutButton.disabled = !enable; 16219 } 16220 #moveDraggedContainer(dx, dy) { 16221 if (this.#isOneColumnView) { 16222 dx = 0; 16223 } 16224 if (this.#draggedImageX + dx < 0 || this.#draggedImageX + this.#draggedImageWidth + dx > this.#scrollableContainerWidth) { 16225 dx = 0; 16226 } 16227 if (this.#draggedImageY + dy < 0 || this.#draggedImageY + this.#draggedImageHeight + dy > this.#scrollableContainerHeight) { 16228 dy = 0; 16229 } 16230 this.#draggedImageX += dx; 16231 this.#draggedImageY += dy; 16232 this.#draggedImageOffsetX += dx; 16233 this.#draggedImageOffsetY += dy; 16234 this.#draggedContainer.style.translate = `${this.#draggedImageOffsetX}px ${this.#draggedImageOffsetY}px`; 16235 if (this.#draggedImageY + this.#draggedImageHeight > this.#currentScrollBottom) { 16236 this.scrollableContainer.scrollTop = Math.min(this.scrollableContainer.scrollTop + PIXELS_TO_SCROLL_WHEN_DRAGGING, this.#scrollableContainerHeight); 16237 } else if (this.#draggedImageY < this.#currentScrollTop) { 16238 this.scrollableContainer.scrollTop = Math.max(this.scrollableContainer.scrollTop - PIXELS_TO_SCROLL_WHEN_DRAGGING, 0); 16239 }
16240 const positionData = this.#findClosestThumbnail(this.#draggedImageX + this.#draggedImageWidth / 2, this.#draggedImageY + this.#draggedImageHeight / 2); 16241 if (!positionData) { 16242 return; 16243 } 16244 let dragMarker = this.#dragMarker; 16245 if (!dragMarker) { 16246 dragMarker = this.#dragMarker = document.createElement("div"); 16247 dragMarker.className = "dragMarker"; 16248 this.container.firstChild.before(dragMarker); 16249 } 16250 const [index, space] = positionData; 16251 const dragMarkerStyle = dragMarker.style; 16252 const { 16253 bbox, 16254 x: xPos 16255 } = this.#thumbnailsPositions; 16256 let x, y, width, height; 16257 if (index < 0) { 16258 if (xPos.length === 1) { 16259 y = bbox[1] - SPACE_FOR_DRAG_MARKER_WHEN_NO_NEXT_ELEMENT; 16260 x = bbox[4]; 16261 width = bbox[2]; 16262 } else { 16263 y = bbox[1]; 16264 x = bbox[0] - SPACE_FOR_DRAG_MARKER_WHEN_NO_NEXT_ELEMENT; 16265 height = bbox[3]; 16266 } 16267 } else if (xPos.length === 1) { 16268 y = bbox[index * 4 + 1] + bbox[index * 4 + 3] + space; 16269 x = bbox[index * 4]; 16270 width = bbox[index * 4 + 2]; 16271 } else { 16272 y = bbox[index * 4 + 1]; 16273 x = bbox[index * 4] + bbox[index * 4 + 2] + space; 16274 height = bbox[index * 4 + 3]; 16275 } 16276 dragMarkerStyle.translate = `${x}px ${y}px`; 16277 dragMarkerStyle.width = width ? `${width}px` : ""; 16278 dragMarkerStyle.height = height ? `${height}px` : ""; 16279 } 16280 #computeThumbnailsPosition() { 16281 const positionsX = []; 16282 const positionsY = []; 16283 const positionsLastX = []; 16284 const bbox = new Float32Array(this._thumbnails.length * 4); 16285 let prevX = -Infinity; 16286 let prevY = -Infinity; 16287 let reminder = -1; 16288 let firstRightX; 16289 let lastRightX; 16290 let firstBottomY; 16291 for (let i = 0, ii = this._thumbnails.length; i < ii; i++) { 16292 const { 16293 div 16294 } = this._thumbnails[i]; 16295 const { 16296 offsetTop: y, 16297 offsetLeft: x, 16298 offsetWidth: w, 16299 offsetHeight: h 16300 } = div; 16301 if (w === 0) { 16302 return; 16303 } 16304 bbox[i * 4] = x; 16305 bbox[i * 4 + 1] = y; 16306 bbox[i * 4 + 2] = w; 16307 bbox[i * 4 + 3] = h; 16308 if (x > prevX) { 16309 prevX = x + w / 2; 16310 firstRightX ??= prevX + w; 16311 positionsX.push(prevX); 16312 } 16313 if (reminder > 0 && i >= ii - reminder) { 16314 const cx = x + w / 2; 16315 positionsLastX.push(cx); 16316 lastRightX ??= cx + w; 16317 } 16318 if (y > prevY) { 16319 if (reminder === -1 && positionsX.length > 1) { 16320 reminder = ii % positionsX.length; 16321 } 16322 prevY = y + h / 2; 16323 firstBottomY ??= prevY + h; 16324 positionsY.push(prevY); 16325 } 16326 } 16327 const space = positionsX.length > 1 ? (positionsX[1] - firstRightX) / 2 : (positionsY[1] - firstBottomY) / 2; 16328 this.#thumbnailsPositions = { 16329 x: positionsX, 16330 y: positionsY, 16331 lastX: positionsLastX, 16332 space, 16333 lastSpace: (positionsLastX.at(-1) - lastRightX) / 2, 16334 bbox 16335 }; 16336 this.#isOneColumnView = positionsX.length === 1; 16337 ({ 16338 clientWidth: this.#scrollableContainerWidth, 16339 scrollHeight: this.#scrollableContainerHeight 16340 } = this.scrollableContainer); 16341 } 16342 #addEventListeners() { 16343 this.eventBus.on("resize", ({ 16344 source 16345 }) => { 16346 if (source.thumbnailsView === this.container) { 16347 this.#computeThumbnailsPosition(); 16348 } 16349 }); 16350 this.container.addEventListener("keydown", e => { 16351 const { 16352 target 16353 } = e; 16354 const isCheckbox = target instanceof HTMLInputElement && target.type === "checkbox"; 16355 switch (e.key) { 16356 case "ArrowLeft": 16357 this.#goToNextItem(target, false, true, isCheckbox); 16358 stopEvent(e); 16359 break; 16360 case "ArrowRight": 16361 this.#goToNextItem(target, true, true, isCheckbox); 16362 stopEvent(e); 16363 break; 16364 case "ArrowDown": 16365 this.#goToNextItem(target, true, false, isCheckbox); 16366 stopEvent(e); 16367 break; 16368 case "ArrowUp": 16369 this.#goToNextItem(target, false, false, isCheckbox); 16370 stopEvent(e); 16371 break; 16372 case "Home":
16373 this.#focusThumbnailElement(this._thumbnails[0], isCheckbox); 16374 stopEvent(e); 16375 break; 16376 case "End": 16377 this.#focusThumbnailElement(this._thumbnails.at(-1), isCheckbox); 16378 stopEvent(e); 16379 break; 16380 case "Enter": 16381 case " ": 16382 if (!isCheckbox) { 16383 this.#goToPage(e); 16384 } 16385 break; 16386 case "c": 16387 if (this.#enableSplitMerge && (e.ctrlKey || e.metaKey) && this.#selectedPages?.size) { 16388 this.#copyPages(); 16389 stopEvent(e); 16390 } 16391 break; 16392 case "x": 16393 if (this.#enableSplitMerge && (e.ctrlKey || e.metaKey) && this.#selectedPages?.size) { 16394 this.#cutPages(); 16395 stopEvent(e); 16396 } 16397 break; 16398 case "Delete": 16399 case "Backspace": 16400 if (this.#enableSplitMerge && this.#selectedPages?.size) { 16401 this.#deletePages(); 16402 stopEvent(e); 16403 } 16404 break; 16405 } 16406 }); 16407 this.container.addEventListener("click", e => { 16408 const { 16409 target 16410 } = e; 16411 if (target instanceof HTMLInputElement) { 16412 const pageNumber = parseInt(target.parentElement.getAttribute("page-number"), 10); 16413 this.#selectPage(pageNumber, target.checked); 16414 return; 16415 } 16416 this.#goToPage(e); 16417 }); 16418 this.#addDragListeners(); 16419 } 16420 #selectPage(pageNumber, checked) { 16421 const set = this.#selectedPages ??= new Set(); 16422 if (checked) { 16423 set.add(pageNumber); 16424 } else { 16425 set.delete(pageNumber); 16426 } 16427 this.#updateMenuEntries(); 16428 } 16429 #addDragListeners() { 16430 if (!this.#enableSplitMerge) { 16431 return; 16432 } 16433 this.container.addEventListener("pointerdown", e => { 16434 const { 16435 target: draggedImage, 16436 clientX: clickX, 16437 clientY: clickY, 16438 pointerId: dragPointerId 16439 } = e; 16440 if (e.button !== 0 || this.#pagesMapper.copiedPageNumbers?.length > 0 || !isNaN(this.#lastDraggedOverIndex) || !draggedImage.classList.contains("thumbnailImageContainer")) { 16441 return; 16442 } 16443 const thumbnail = draggedImage.parentElement; 16444 const pointerDownAC = new AbortController(); 16445 const { 16446 signal: pointerDownSignal 16447 } = pointerDownAC; 16448 let prevDragX = clickX; 16449 let prevDragY = clickY; 16450 let prevScrollTop = this.scrollableContainer.scrollTop; 16451 const scaleFactor = PDFThumbnailViewer.#getScaleFactor(draggedImage); 16452 this.#draggedImageOffsetY = ((scaleFactor - 1) * e.layerY + draggedImage.offsetTop) / scaleFactor; 16453 if (this.#isOneColumnView) { 16454 this.#draggedImageOffsetX = draggedImage.offsetLeft + (scaleFactor - 1) * 0.5 * draggedImage.offsetWidth / scaleFactor; 16455 } else { 16456 this.#draggedImageOffsetX = ((scaleFactor - 1) * e.layerX + draggedImage.offsetLeft) / scaleFactor; 16457 } 16458 this.#draggedImageX = thumbnail.offsetLeft + this.#draggedImageOffsetX; 16459 this.#draggedImageY = thumbnail.offsetTop + this.#draggedImageOffsetY; 16460 this.#draggedImageWidth = draggedImage.offsetWidth / scaleFactor; 16461 this.#draggedImageHeight = draggedImage.offsetHeight / scaleFactor; 16462 this.container.addEventListener("pointermove", ev => { 16463 const { 16464 clientX: x, 16465 clientY: y, 16466 pointerId 16467 } = ev; 16468 if (isNaN(this.#lastDraggedOverIndex)) { 16469 if (pointerId !== dragPointerId || Math.abs(x - clickX) <= DRAG_THRESHOLD_IN_PIXELS && Math.abs(y - clickY) <= DRAG_THRESHOLD_IN_PIXELS) { 16470 return; 16471 } 16472 this.#onStartDragging(thumbnail); 16473 const stopDragging = (_e, isDropping = false) => { 16474 this.#onStopDragging(isDropping); 16475 pointerDownAC.abort(); 16476 }; 16477 const { 16478 signal 16479 } = this.#dragAC; 16480 window.addEventListener("touchmove", stopEvent, { 16481 passive: false, 16482 signal 16483 }); 16484 window.addEventListener("contextmenu", noContextMenu, { 16485 signal 16486 }); 16487 this.scrollableContainer.addEventListener("scrollend", () => { 16488 const { 16489 scrollableContainer: { 16490 clientHeight, 16491 scrollTop 16492 } 16493 } = this; 16494 this.#currentScrollTop = scrollTop; 16495 this.#currentScrollBottom = scrollTop + clientHeight; 16496 const dy = scrollTop - prevScrollTop; 16497 prevScrollTop = scrollTop; 16498 this.#moveDraggedContainer(0, dy); 16499 }, { 16500 passive: true, 16501 signal 16502 }); 16503 window.addEventListener("pointerup", upEv => { 16504 if (upEv.pointerId !== dragPointerId) { 16505 return; 16506 } 16507 window.addEventListener("click", stopEvent, { 16508 capture: true, 16509 once: true, 16510 signal 16511 }); 16512 stopEvent(upEv); 16513 stopDragging(upEv, true); 16514 }, { 16515 signal 16516 }); 16517 window.addEventListener("blur", stopDragging, { 16518 signal 16519 }); 16520 window.addEventListener("pointercancel", stopDragging, { 16521 signal 16522 }); 16523 window.addEventListener("wheel", stopEvent, { 16524 passive: false, 16525 signal 16526 }); 16527 window.addEventListener("keydown", kEv => { 16528 if (kEv.key === "Escape" && !isNaN(this.#lastDraggedOverIndex)) { 16529 stopDragging(kEv); 16530 } 16531 }, { 16532 signal 16533 }); 16534 } 16535 const dx = x - prevDragX; 16536 const dy = y - prevDragY; 16537 prevDragX = x;
16538 prevDragY = y; 16539 this.#moveDraggedContainer(dx, dy); 16540 }, { 16541 passive: true, 16542 signal: pointerDownSignal 16543 }); 16544 window.addEventListener("pointerup", ({ 16545 pointerId 16546 }) => { 16547 if (pointerId !== dragPointerId) { 16548 return; 16549 } 16550 pointerDownAC.abort(); 16551 }, { 16552 signal: pointerDownSignal 16553 }); 16554 window.addEventListener("dragstart", stopEvent, { 16555 capture: true, 16556 signal: pointerDownSignal 16557 }); 16558 }); 16559 } 16560 #goToPage(e) { 16561 const { 16562 target 16563 } = e; 16564 if (target.classList.contains("thumbnailImageContainer")) { 16565 const pageNumber = parseInt(target.parentElement.getAttribute("page-number"), 10); 16566 this.linkService.goToPage(pageNumber); 16567 stopEvent(e); 16568 } 16569 } 16570 #focusThumbnailElement(thumbnail, focusCheckbox) { 16571 if (focusCheckbox && thumbnail.checkbox) { 16572 thumbnail.checkbox.focus(); 16573 } else { 16574 thumbnail.imageContainer.focus(); 16575 } 16576 } 16577 #goToNextItem(element, forward, horizontal, navigateCheckboxes = false) { 16578 let currentPageNumber = parseInt(element.parentElement.getAttribute("page-number"), 10); 16579 if (isNaN(currentPageNumber)) { 16580 currentPageNumber = this._currentPageNumber; 16581 } 16582 const increment = forward ? 1 : -1; 16583 let nextThumbnail; 16584 if (horizontal) { 16585 const nextPageNumber = MathClamp(currentPageNumber + increment, 1, this._thumbnails.length + 1); 16586 nextThumbnail = this._thumbnails[nextPageNumber - 1]; 16587 } else { 16588 const currentThumbnail = this._thumbnails[currentPageNumber - 1]; 16589 const { 16590 x: currentX, 16591 y: currentY 16592 } = currentThumbnail.div.getBoundingClientRect(); 16593 let firstWithDifferentY; 16594 for (let i = currentPageNumber - 1 + increment; i >= 0 && i < this._thumbnails.length; i += increment) { 16595 const thumbnail = this._thumbnails[i]; 16596 const { 16597 x, 16598 y 16599 } = thumbnail.div.getBoundingClientRect(); 16600 if (!firstWithDifferentY && y !== currentY) { 16601 firstWithDifferentY = thumbnail; 16602 } 16603 if (x === currentX) { 16604 nextThumbnail = thumbnail; 16605 break; 16606 } 16607 } 16608 if (!nextThumbnail) { 16609 nextThumbnail = firstWithDifferentY; 16610 } 16611 } 16612 if (nextThumbnail) { 16613 this.#focusThumbnailElement(nextThumbnail, navigateCheckboxes); 16614 } 16615 } 16616 #findClosestThumbnail(x, y) { 16617 if (!this.#thumbnailsPositions) { 16618 this.#computeThumbnailsPosition(); 16619 } 16620 const { 16621 x: positionsX, 16622 y: positionsY, 16623 lastX: positionsLastX, 16624 space: spaceBetweenThumbnails, 16625 lastSpace: lastSpaceBetweenThumbnails 16626 } = this.#thumbnailsPositions; 16627 const lastDraggedOverIndex = this.#lastDraggedOverIndex; 16628 let xPos = lastDraggedOverIndex % positionsX.length; 16629 let yPos = Math.floor(lastDraggedOverIndex / positionsX.length); 16630 let xArray = yPos === positionsY.length - 1 ? positionsLastX : positionsX; 16631 if (positionsY[yPos] <= y && y < (positionsY[yPos + 1] ?? Infinity) && xArray[xPos] <= x && x < (xArray[xPos + 1] ?? Infinity)) { 16632 return null; 16633 } 16634 let index; 16635 yPos = binarySearchFirstItem(positionsY, cy => y < cy); 16636 if (this.#isOneColumnView) { 16637 index = yPos - 1; 16638 } else { 16639 if (yPos === positionsY.length) { 16640 yPos = positionsY.length - 1; 16641 } else { 16642 const dist1 = Math.abs(positionsY[yPos - 1] - y); 16643 const dist2 = Math.abs(positionsY[yPos] - y); 16644 yPos = dist1 < dist2 ? yPos - 1 : yPos; 16645 } 16646 xArray = yPos === positionsY.length - 1 && positionsLastX.length > 0 ? positionsLastX : positionsX; 16647 xPos = binarySearchFirstItem(xArray, cx => x < cx) - 1; 16648 if (yPos < 0) { 16649 if (xPos <= 0) { 16650 xPos = -1; 16651 } 16652 yPos = 0; 16653 } 16654 index = MathClamp(yPos * positionsX.length + xPos, -1, this._thumbnails.length - 1); 16655 } 16656 if (index === lastDraggedOverIndex) { 16657 return null; 16658 } 16659 this.#lastDraggedOverIndex = index; 16660 const space = yPos === positionsY.length - 1 && positionsLastX.length > 0 && xPos >= 0 ? lastSpaceBetweenThumbnails : spaceBetweenThumbnails; 16661 return [index, space]; 16662 } 16663} 16664 16665;// ./web/annotation_editor_layer_builder.js 16666 16667 16668class AnnotationEditorLayerBuilder { 16669 #annotationLayer = null; 16670 #drawLayer = null; 16671 #onAppend = null; 16672 #structTreeLayer = null; 16673 #textLayer = null; 16674 #uiManager; 16675 #clonedFrom = null; 16676 constructor(options) { 16677 this.pageIndex = options.pageIndex; 16678 this.accessibilityManager = options.accessibilityManager; 16679 this.l10n = options.l10n; 16680 this.l10n ||= new genericl10n_GenericL10n(); 16681 this.annotationEditorLayer = null; 16682 this.div = null; 16683 this._cancelled = false;
16684 this.#uiManager = options.uiManager; 16685 this.#annotationLayer = options.annotationLayer || null; 16686 this.#textLayer = options.textLayer || null; 16687 this.#drawLayer = options.drawLayer || null; 16688 this.#onAppend = options.onAppend || null; 16689 this.#structTreeLayer = options.structTreeLayer || null; 16690 this.#clonedFrom = options.clonedFrom || null; 16691 } 16692 updatePageIndex(newPageIndex) { 16693 this.pageIndex = newPageIndex; 16694 this.annotationEditorLayer?.updatePageIndex(newPageIndex); 16695 } 16696 async render({ 16697 viewport, 16698 intent = "display" 16699 }) { 16700 if (intent !== "display") { 16701 return; 16702 } 16703 if (this._cancelled) { 16704 return; 16705 } 16706 const clonedViewport = viewport.clone({ 16707 dontFlip: true 16708 }); 16709 if (this.div) { 16710 this.annotationEditorLayer.update({ 16711 viewport: clonedViewport 16712 }); 16713 this.show(); 16714 return; 16715 } 16716 const div = this.div = document.createElement("div"); 16717 div.className = "annotationEditorLayer"; 16718 div.hidden = true; 16719 div.dir = this.#uiManager.direction; 16720 this.#onAppend?.(div); 16721 this.annotationEditorLayer = new AnnotationEditorLayer({ 16722 uiManager: this.#uiManager, 16723 div, 16724 structTreeLayer: this.#structTreeLayer, 16725 accessibilityManager: this.accessibilityManager, 16726 pageIndex: this.pageIndex, 16727 l10n: this.l10n, 16728 viewport: clonedViewport, 16729 annotationLayer: this.#annotationLayer, 16730 textLayer: this.#textLayer, 16731 drawLayer: this.#drawLayer 16732 }); 16733 this.annotationEditorLayer.setClonedFrom(this.#clonedFrom?.annotationEditorLayer); 16734 this.#clonedFrom = null; 16735 const parameters = { 16736 viewport: clonedViewport, 16737 div, 16738 annotations: null, 16739 intent 16740 }; 16741 this.annotationEditorLayer.render(parameters); 16742 this.show(); 16743 } 16744 cancel() { 16745 this._cancelled = true; 16746 if (!this.div) { 16747 return; 16748 } 16749 this.annotationEditorLayer.destroy(); 16750 } 16751 hide() { 16752 if (!this.div) { 16753 return; 16754 } 16755 this.annotationEditorLayer.pause(true); 16756 this.div.hidden = true; 16757 } 16758 show() { 16759 if (!this.div || this.annotationEditorLayer.isInvisible) { 16760 return; 16761 } 16762 this.div.hidden = false; 16763 this.annotationEditorLayer.pause(false); 16764 } 16765} 16766 16767;// ./web/annotation_layer_builder.js 16768 16769 16770 16771 16772 16773class AnnotationLayerBuilder { 16774 #annotations = null; 16775 #commentManager = null; 16776 #externalHide = false;
16777 #onAppend = null; 16778 #eventAbortController = null; 16779 #linksInjected = false; 16780 constructor({ 16781 pdfPage, 16782 linkService, 16783 downloadManager, 16784 annotationStorage = null, 16785 imageResourcesPath = "", 16786 renderForms = true, 16787 enableComment = false, 16788 commentManager = null, 16789 enableScripting = false, 16790 hasJSActionsPromise = null, 16791 fieldObjectsPromise = null, 16792 annotationCanvasMap = null, 16793 accessibilityManager = null, 16794 annotationEditorUIManager = null, 16795 onAppend = null 16796 }) { 16797 this.pdfPage = pdfPage; 16798 this.linkService = linkService; 16799 this.downloadManager = downloadManager; 16800 this.imageResourcesPath = imageResourcesPath; 16801 this.renderForms = renderForms; 16802 this.annotationStorage = annotationStorage; 16803 this.enableComment = enableComment; 16804 this.#commentManager = commentManager; 16805 this.enableScripting = enableScripting; 16806 this._hasJSActionsPromise = hasJSActionsPromise || Promise.resolve(false); 16807 this._fieldObjectsPromise = fieldObjectsPromise || Promise.resolve(null); 16808 this._annotationCanvasMap = annotationCanvasMap; 16809 this._accessibilityManager = accessibilityManager; 16810 this._annotationEditorUIManager = annotationEditorUIManager; 16811 this.#onAppend = onAppend; 16812 this.annotationLayer = null; 16813 this.div = null; 16814 this._cancelled = false; 16815 this._eventBus = linkService.eventBus; 16816 } 16817 async render({ 16818 viewport, 16819 intent = "display", 16820 structTreeLayer = null 16821 }) { 16822 if (this.div) { 16823 if (this._cancelled || !this.annotationLayer) { 16824 return; 16825 } 16826 this.annotationLayer.update({ 16827 viewport: viewport.clone({ 16828 dontFlip: true 16829 }) 16830 }); 16831 return; 16832 } 16833 const [annotations, hasJSActions, fieldObjects] = await Promise.all([this.pdfPage.getAnnotations({ 16834 intent 16835 }), this._hasJSActionsPromise, this._fieldObjectsPromise]); 16836 if (this._cancelled) { 16837 return; 16838 } 16839 const div = this.div = document.createElement("div"); 16840 div.className = "annotationLayer"; 16841 this.#onAppend?.(div); 16842 this.#initAnnotationLayer(viewport, structTreeLayer); 16843 if (annotations.length === 0) { 16844 this.#annotations = annotations; 16845 setLayerDimensions(this.div, viewport); 16846 return; 16847 } 16848 await this.annotationLayer.render({ 16849 annotations, 16850 imageResourcesPath: this.imageResourcesPath, 16851 renderForms: this.renderForms, 16852 downloadManager: this.downloadManager, 16853 enableComment: this.enableComment, 16854 enableScripting: this.enableScripting, 16855 hasJSActions, 16856 fieldObjects 16857 }); 16858 this.#annotations = annotations; 16859 if (this.linkService.isInPresentationMode) { 16860 this.#updatePresentationModeState(PresentationModeState.FULLSCREEN); 16861 } 16862 if (!this.#eventAbortController) { 16863 this.#eventAbortController = new AbortController(); 16864 this._eventBus?._on("presentationmodechanged", evt => { 16865 this.#updatePresentationModeState(evt.state); 16866 }, { 16867 signal: this.#eventAbortController.signal 16868 }); 16869 } 16870 } 16871 #initAnnotationLayer(viewport, structTreeLayer) { 16872 this.annotationLayer = new AnnotationLayer({ 16873 div: this.div, 16874 accessibilityManager: this._accessibilityManager, 16875 annotationCanvasMap: this._annotationCanvasMap, 16876 annotationEditorUIManager: this._annotationEditorUIManager, 16877 annotationStorage: this.annotationStorage, 16878 page: this.pdfPage, 16879 viewport: viewport.clone({ 16880 dontFlip: true 16881 }), 16882 structTreeLayer, 16883 commentManager: this.#commentManager, 16884 linkService: this.linkService 16885 }); 16886 } 16887 cancel() { 16888 this._cancelled = true; 16889 this.#eventAbortController?.abort(); 16890 this.#eventAbortController = null; 16891 } 16892 hide(internal = false) { 16893 this.#externalHide = !internal; 16894 if (!this.div) { 16895 return; 16896 } 16897 this.div.hidden = true; 16898 } 16899 hasEditableAnnotations() { 16900 return !!this.annotationLayer?.hasEditableAnnotations(); 16901 } 16902 async injectLinkAnnotations(inferredLinks) { 16903 if (this.#annotations === null) { 16904 throw new Error("`render` method must be called before `injectLinkAnnotations`."); 16905 } 16906 if (this._cancelled || this.#linksInjected) { 16907 return; 16908 } 16909 this.#linksInjected = true; 16910 const newLinks = this.#annotations.length ? this.#checkInferredLinks(inferredLinks) : inferredLinks; 16911 if (!newLinks.length) { 16912 return; 16913 } 16914 await this.annotationLayer.addLinkAnnotations(newLinks); 16915 if (!this.#externalHide) { 16916 this.div.hidden = false;
16917 } 16918 } 16919 #updatePresentationModeState(state) { 16920 if (!this.div) { 16921 return; 16922 } 16923 let disableFormElements = false; 16924 switch (state) { 16925 case PresentationModeState.FULLSCREEN: 16926 disableFormElements = true; 16927 break; 16928 case PresentationModeState.NORMAL: 16929 break; 16930 default: 16931 return; 16932 } 16933 for (const section of this.div.childNodes) { 16934 if (section.hasAttribute("data-internal-link")) { 16935 continue; 16936 } 16937 section.inert = disableFormElements; 16938 } 16939 } 16940 #checkInferredLinks(inferredLinks) { 16941 function annotationRects(annot) { 16942 if (!annot.quadPoints) { 16943 return [annot.rect]; 16944 } 16945 const rects = []; 16946 for (let i = 2, ii = annot.quadPoints.length; i < ii; i += 8) { 16947 const trX = annot.quadPoints[i]; 16948 const trY = annot.quadPoints[i + 1]; 16949 const blX = annot.quadPoints[i + 2]; 16950 const blY = annot.quadPoints[i + 3]; 16951 rects.push([blX, blY, trX, trY]); 16952 } 16953 return rects; 16954 } 16955 function intersectAnnotations(annot1, annot2) { 16956 const intersections = []; 16957 const annot1Rects = annotationRects(annot1); 16958 const annot2Rects = annotationRects(annot2); 16959 for (const rect1 of annot1Rects) { 16960 for (const rect2 of annot2Rects) { 16961 const intersection = Util.intersect(rect1, rect2); 16962 if (intersection) { 16963 intersections.push(intersection); 16964 } 16965 } 16966 } 16967 return intersections; 16968 } 16969 function areaRects(rects) { 16970 let totalArea = 0; 16971 for (const rect of rects) { 16972 totalArea += Math.abs((rect[2] - rect[0]) * (rect[3] - rect[1])); 16973 } 16974 return totalArea; 16975 } 16976 return inferredLinks.filter(link => { 16977 let linkAreaRects; 16978 for (const annotation of this.#annotations) { 16979 if (annotation.annotationType !== AnnotationType.LINK || !annotation.url) { 16980 continue; 16981 } 16982 const intersections = intersectAnnotations(annotation, link); 16983 if (intersections.length === 0) { 16984 continue; 16985 } 16986 linkAreaRects ??= areaRects(annotationRects(link)); 16987 if (areaRects(intersections) / linkAreaRects > 0.5) { 16988 return false; 16989 } 16990 } 16991 return true; 16992 }); 16993 } 16994} 16995 16996;// ./web/autolinker.js 16997 16998 16999 17000 17001 17002 17003function DOMRectToPDF({ 17004 width, 17005 height, 17006 left, 17007 top 17008}, pdfPageView) { 17009 if (width === 0 || height === 0) { 17010 return null; 17011 } 17012 const pageBox = pdfPageView.textLayer.div.getBoundingClientRect(); 17013 const bottomLeft = pdfPageView.getPagePoint(left - pageBox.left, top - pageBox.top); 17014 const topRight = pdfPageView.getPagePoint(left - pageBox.left + width, top - pageBox.top + height); 17015 return Util.normalizeRect([bottomLeft[0], bottomLeft[1], topRight[0], topRight[1]]); 17016} 17017function calculateLinkPosition(range, pdfPageView) { 17018 const rangeRects = range.getClientRects(); 17019 if (rangeRects.length === 1) { 17020 return { 17021 rect: DOMRectToPDF(rangeRects[0], pdfPageView) 17022 }; 17023 } 17024 const rect = [Infinity, Infinity, -Infinity, -Infinity]; 17025 const quadPoints = []; 17026 let i = 0; 17027 for (const domRect of rangeRects) { 17028 const normalized = DOMRectToPDF(domRect, pdfPageView); 17029 if (normalized === null) { 17030 continue; 17031 } 17032 quadPoints[i] = quadPoints[i + 4] = normalized[0]; 17033 quadPoints[i + 1] = quadPoints[i + 3] = normalized[3]; 17034 quadPoints[i + 2] = quadPoints[i + 6] = normalized[2]; 17035 quadPoints[i + 5] = quadPoints[i + 7] = normalized[1]; 17036 Util.rectBoundingBox(...normalized, rect); 17037 i += 8; 17038 } 17039 return { 17040 quadPoints, 17041 rect 17042 }; 17043} 17044function textPosition(container, offset) { 17045 let currentContainer = container; 17046 do { 17047 if (currentContainer.nodeType === Node.TEXT_NODE) { 17048 const currentLength = currentContainer.textContent.length; 17049 if (offset <= currentLength) { 17050 return [currentContainer, offset]; 17051 } 17052 offset -= currentLength; 17053 } else if (currentContainer.firstChild) { 17054 currentContainer = currentContainer.firstChild; 17055 continue; 17056 } 17057 while (!currentContainer.nextSibling && currentContainer !== container) { 17058 currentContainer = currentContainer.parentNode; 17059 } 17060 if (currentContainer !== container) { 17061 currentContainer = currentContainer.nextSibling; 17062 } 17063 } while (currentContainer !== container); 17064 throw new Error("Offset is bigger than container's contents length."); 17065} 17066function createLinkAnnotation({ 17067 url, 17068 index, 17069 length 17070}, pdfPageView, id) { 17071 const highlighter = pdfPageView._textHighlighter;
17072 const [{ 17073 begin, 17074 end 17075 }] = highlighter._convertMatches([index], [length]); 17076 const range = new Range(); 17077 range.setStart(...textPosition(highlighter.textDivs[begin.divIdx], begin.offset)); 17078 range.setEnd(...textPosition(highlighter.textDivs[end.divIdx], end.offset)); 17079 return { 17080 id: `inferred_link_${id}`, 17081 unsafeUrl: url, 17082 url, 17083 annotationType: AnnotationType.LINK, 17084 rotation: 0, 17085 ...calculateLinkPosition(range, pdfPageView), 17086 borderStyle: null 17087 }; 17088} 17089class Autolinker { 17090 static #index = 0; 17091 static #regex; 17092 static #numericTLDRegex; 17093 static findLinks(text) { 17094 this.#regex ??= /\b(?:https?:\/\/|mailto:|www\.)(?:[\0-\x08\x0E-\x1F\$\+0-9=A-Z\^`-z\|~-\x9F\xA2-\xA6\xA8-\xAA\xAC-\xB5\xB8-\xBA\xBC-\xBE\xC0-\u037D\u037F-\u0386\u0388-\u0559\u0560-\u0588\u058B-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0608\u060B\u060E-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06FF\u070E-\u07F6\u07FA-\u082F\u083F-\u085D\u085F-\u0963\u0966-\u096F\u0971-\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF1-\u0C76\u0C78-\u0C83\u0C85-\u0DF3\u0DF5-\u0E4E\u0E50-\u0E59\u0E5C-\u0F03\u0F13\u0F15-\u0F39\u0F3E-\u0F84\u0F86-\u0FCF\u0FD5-\u0FD8\u0FDB-\u1049\u1050-\u10FA\u10FC-\u135F\u1369-\u13FF\u1401-\u166D\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DB-\u17FF\u180B-\u1943\u1946-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B61-\u1B7C\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FFF\u200B-\u200F\u202A-\u202E\u2044\u2052\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E50\u2E51\u2E5E-\u2FFF\u3004-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303C\u303E-\u309F\u30A1-\u30FA\u30FC-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAADD\uAAE0-\uAAEF\uAAF2-\uABEA\uABEC-\uFD3D\uFD40-\uFE0F\uFE1A-\uFE2F\uFE53\uFE62\uFE64-\uFE67\uFE69\uFE6C-\uFEFE\uFF00\uFF04\uFF0B\uFF10-\uFF19\uFF1C-\uFF1E\uFF21-\uFF3A\uFF3E\uFF40-\uFF5A\uFF5C\uFF5E\uFF66-\u{100FF}\u{10103}-\u{1039E}\u{103A0}-\u{103CF}\u{103D1}-\u{1056E}\u{10570}-\u{10856}\u{10858}-\u{1091E}\u{10920}-\u{1093E}\u{10940}-\u{10A4F}\u{10A59}-\u{10A7E}\u{10A80}-\u{10AEF}\u{10AF7}-\u{10B38}\u{10B40}-\u{10B98}\u{10B9D}-\u{10D6D}\u{10D6F}-\u{10EAC}\u{10EAE}-\u{10ECF}\u{10ED1}-\u{10F54}\u{10F5A}-\u{10F85}\u{10F8A}-\u{11046}\u{1104E}-\u{110BA}\u{110BD}\u{110C2}-\u{1113F}\u{11144}-\u{11173}\u{11176}-\u{111C4}\u{111C9}-\u{111CC}\u{111CE}-\u{111DA}\u{111DC}\u{111E0}-\u{11237}\u{1123E}-\u{112A8}\u{112AA}-\u{113D3}\u{113D6}\u{113D9}-\u{1144A}\u{11450}-\u{11459}\u{1145C}\u{1145E}-\u{114C5}\u{114C7}-\u{115C0}\u{115D8}-\u{11640}\u{11644}-\u{1165F}\u{1166D}-\u{116B8}\u{116BA}-\u{1173B}\u{1173F}-\u{1183A}\u{1183C}-\u{11943}\u{11947}-\u{119E1}\u{119E3}-\u{11A3E}\u{11A47}-\u{11A99}\u{11A9D}\u{11AA3}-\u{11AFF}\u{11B0A}-\u{11BE0}\u{11BE2}-\u{11C40}\u{11C46}-\u{11C6F}\u{11C72}-\u{11EF6}\u{11EF9}-\u{11F42}\u{11F50}-\u{11FFE}\u{12000}-\u{1246F}\u{12475}-\u{12FF0}\u{12FF3}-\u{16A6D}\u{16A70}-\u{16AF4}\u{16AF6}-\u{16B36}\u{16B3C}-\u{16B43}\u{16B45}-\u{16D6C}\u{16D70}-\u{16E96}\u{16E9B}-\u{16FE1}\u{16FE3}-\u{1BC9E}\u{1BCA0}-\u{1DA86}\u{1DA8C}-\u{1E5FE}\u{1E600}-\u{1E95D}\u{1E960}-\u{10FFFF}]|\/|[\0-\x08\x0E-\x1F!-Z\\\^-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uFEFE\uFF00-\u{10FFFF}]+[\0-\x08\x0E-\x1F\$\+0-9=A-Z\^`-z\|~-\x9F\xA2-\xA6\xA8-\xAA\xAC-\xB5\xB8-\xBA\xBC-\xBE\xC0-\u037D\u037F-\u0386\u0388-\u0559\u0560-\u0588\u058B-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0608\u060B\u060E-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06FF\u070E-\u07F6\u07FA-\u082F\u083F-\u085D\u085F-\u0963\u0966-\u096F\u0971-\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF1-\u0C76\u0C78-\u0C83\u0C85-\u0DF3\u0DF5-\u0E4E\u0E50-\u0E59\u0E5C-\u0F03\u0F13\u0F15-\u0F39\u0F3E-\u0F84\u0F86-\u0FCF\u0FD5-\u0FD8\u0FDB-\u1049\u1050-\u10FA\u10FC-\u135F\u1369-\u13FF\u1401-\u166D\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DB-\u17FF\u180B-\u1943\u1946-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B61-\u1B7C\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FFF\u200B-\u200F\u202A-\u202E\u2044\u2052\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E50\u2E51\u2E5E-\u2F
17094FF\u3004-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303C\u303E-\u309F\u30A1-\u30FA\u30FC-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAADD\uAAE0-\uAAEF\uAAF2-\uABEA\uABEC-\uFD3D\uFD40-\uFE0F\uFE1A-\uFE2F\uFE53\uFE62\uFE64-\uFE67\uFE69\uFE6C-\uFEFE\uFF00\uFF04\uFF0B\uFF10-\uFF19\uFF1C-\uFF1E\uFF21-\uFF3A\uFF3E\uFF40-\uFF5A\uFF5C\uFF5E\uFF66-\u{100FF}\u{10103}-\u{1039E}\u{103A0}-\u{103CF}\u{103D1}-\u{1056E}\u{10570}-\u{10856}\u{10858}-\u{1091E}\u{10920}-\u{1093E}\u{10940}-\u{10A4F}\u{10A59}-\u{10A7E}\u{10A80}-\u{10AEF}\u{10AF7}-\u{10B38}\u{10B40}-\u{10B98}\u{10B9D}-\u{10D6D}\u{10D6F}-\u{10EAC}\u{10EAE}-\u{10ECF}\u{10ED1}-\u{10F54}\u{10F5A}-\u{10F85}\u{10F8A}-\u{11046}\u{1104E}-\u{110BA}\u{110BD}\u{110C2}-\u{1113F}\u{11144}-\u{11173}\u{11176}-\u{111C4}\u{111C9}-\u{111CC}\u{111CE}-\u{111DA}\u{111DC}\u{111E0}-\u{11237}\u{1123E}-\u{112A8}\u{112AA}-\u{113D3}\u{113D6}\u{113D9}-\u{1144A}\u{11450}-\u{11459}\u{1145C}\u{1145E}-\u{114C5}\u{114C7}-\u{115C0}\u{115D8}-\u{11640}\u{11644}-\u{1165F}\u{1166D}-\u{116B8}\u{116BA}-\u{1173B}\u{1173F}-\u{1183A}\u{1183C}-\u{11943}\u{11947}-\u{119E1}\u{119E3}-\u{11A3E}\u{11A47}-\u{11A99}\u{11A9D}\u{11AA3}-\u{11AFF}\u{11B0A}-\u{11BE0}\u{11BE2}-\u{11C40}\u{11C46}-\u{11C6F}\u{11C72}-\u{11EF6}\u{11EF9}-\u{11F42}\u{11F50}-\u{11FFE}\u{12000}-\u{1246F}\u{12475}-\u{12FF0}\u{12FF3}-\u{16A6D}\u{16A70}-\u{16AF4}\u{16AF6}-\u{16B36}\u{16B3C}-\u{16B43}\u{16B45}-\u{16D6C}\u{16D70}-\u{16E96}\u{16E9B}-\u{16FE1}\u{16FE3}-\u{1BC9E}\u{1BCA0}-\u{1DA86}\u{1DA8C}-\u{1E5FE}\u{1E600}-\u{1E95D}\u{1E960}-\u{10FFFF}])+|(?=\p{L})[\0-\x08\x0E-\x1F!-'\*-;=\?A-Z\\\^-z\|~-\x9F\xA1-\u0F39\u0F3E-\u167F\u1681-\u169A\u169D-\u1FFF\u200B-\u2019\u201B-\u201D\u201F-\u2027\u202A-\u202E\u2030-\u2044\u2047-\u205E\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2E21\u2E2A-\u2E41\u2E43-\u2E54\u2E5D-\u2FFF\u3001-\u3007\u3012\u3013\u301C\u3020-\uFD3D\uFD40-\uFE16\uFE19-\uFE34\uFE45\uFE46\uFE49-\uFE58\uFE5F-\uFEFE\uFF00-\uFF07\uFF0A-\uFF3A\uFF3C\uFF3E-\uFF5A\uFF5C\uFF5E\uFF61\uFF64-\u{10FFFF}]+@([\0-\x08\x0E-\x1F\$\+\x2D0-9=A-Z\^`-z\|~-\x9F\xA2-\xA6\xA8-\xAA\xAC-\xB5\xB8-\xBA\xBC-\xBE\xC0-\u037D\u037F-\u0386\u0388-\u0559\u0560-\u0588\u058B-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0608\u060B\u060E-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06FF\u070E-\u07F6\u07FA-\u082F\u083F-\u085D\u085F-\u0963\u0966-\u096F\u0971-\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF1-\u0C76\u0C78-\u0C83\u0C85-\u0DF3\u0DF5-\u0E4E\u0E50-\u0E59\u0E5C-\u0F03\u0F13\u0F15-\u0F39\u0F3E-\u0F84\u0F86-\u0FCF\u0FD5-\u0FD8\u0FDB-\u1049\u1050-\u10FA\u10FC-\u135F\u1369-\u13FF\u1401-\u166D\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DB-\u17FF\u180B-\u1943\u1946-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B61-\u1B7C\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FFF\u200B-\u200F\u202A-\u202E\u2044\u2052\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E50\u2E51\u2E5E-\u2FFF\u3004-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303C\u303E-\u309F\u30A1-\u30FA\u30FC-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAADD\uAAE0-\uAAEF\uAAF2-\uABEA\uABEC-\uFD3D\uFD40-\uFE0F\uFE1A-\uFE2F\uFE53\uFE62\uFE64-\uFE67\uFE69\uFE6C-\uFEFE\uFF00\uFF04\uFF0B\uFF10-\uFF19\uFF1C-\uFF1E\uFF21-\uFF3A\uFF3E\uFF40-\uFF5A\uFF5C\uFF5E\uFF66-\u{100FF}\u{10103}-\u{1039E}\u{103A0}-\u{103CF}\u{103D1}-\u{1056E}\u{10570}-\u{10856}\u{10858}-\u{1091E}\u{10920}-\u{1093E}\u{10940}-\u{10A4F}\u{10A59}-\u{10A7E}\u{10A80}-\u{10AEF}\u{10AF7}-\u{10B38}\u{10B40}-\u{10B98}\u{10B9D}-\u{10D6D}\u{10D6F}-\u{10EAC}\u{10EAE}-\u{10ECF}\u{10ED1}-\u{10F54}\u{10F5A}-\u{10F85}\u{10F8A}-\u{11046}\u{1104E}-\u{110BA}\u{110BD}\u{110C2}-\u{1113F}\u{11144}-\u{11173}\u{11176}-\u{111C4}\u{111C9}-\u{111CC}\u{111CE}-\u{111DA}\u{111DC}\u{111E0}-\u{11237}\u{1123E}-\u{112A8}\u{112AA}-\u{113D3}\u{113D6}\u{113D9}-\u{1144A}\u{11450}-\u{11459}\u{1145C}\u{1145E}-\u{114C5}\u{114C7}-\u{115C0}\u{115D8}-\u{11640}\u{11644}-\u{1165F}\u{1166D}-\u{116B8}\u{116BA}-\u{1173B}\u{1173F}-\u{1183A}\u{1183C}-\u{11943}\u{11947}-\u{119E1}\u{119E3}-\u{11A3E}\u{11A47}-\u{11A99}\u{11A9D}
17094\u{11AA3}-\u{11AFF}\u{11B0A}-\u{11BE0}\u{11BE2}-\u{11C40}\u{11C46}-\u{11C6F}\u{11C72}-\u{11EF6}\u{11EF9}-\u{11F42}\u{11F50}-\u{11FFE}\u{12000}-\u{1246F}\u{12475}-\u{12FF0}\u{12FF3}-\u{16A6D}\u{16A70}-\u{16AF4}\u{16AF6}-\u{16B36}\u{16B3C}-\u{16B43}\u{16B45}-\u{16D6C}\u{16D70}-\u{16E96}\u{16E9B}-\u{16FE1}\u{16FE3}-\u{1BC9E}\u{1BCA0}-\u{1DA86}\u{1DA8C}-\u{1E5FE}\u{1E600}-\u{1E95D}\u{1E960}-\u{10FFFF}]+(?:\.[\0-\x08\x0E-\x1F\$\+\x2D0-9=A-Z\^`-z\|~-\x9F\xA2-\xA6\xA8-\xAA\xAC-\xB5\xB8-\xBA\xBC-\xBE\xC0-\u037D\u037F-\u0386\u0388-\u0559\u0560-\u0588\u058B-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0608\u060B\u060E-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06FF\u070E-\u07F6\u07FA-\u082F\u083F-\u085D\u085F-\u0963\u0966-\u096F\u0971-\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF1-\u0C76\u0C78-\u0C83\u0C85-\u0DF3\u0DF5-\u0E4E\u0E50-\u0E59\u0E5C-\u0F03\u0F13\u0F15-\u0F39\u0F3E-\u0F84\u0F86-\u0FCF\u0FD5-\u0FD8\u0FDB-\u1049\u1050-\u10FA\u10FC-\u135F\u1369-\u13FF\u1401-\u166D\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DB-\u17FF\u180B-\u1943\u1946-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B61-\u1B7C\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FFF\u200B-\u200F\u202A-\u202E\u2044\u2052\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E50\u2E51\u2E5E-\u2FFF\u3004-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303C\u303E-\u309F\u30A1-\u30FA\u30FC-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAADD\uAAE0-\uAAEF\uAAF2-\uABEA\uABEC-\uFD3D\uFD40-\uFE0F\uFE1A-\uFE2F\uFE53\uFE62\uFE64-\uFE67\uFE69\uFE6C-\uFEFE\uFF00\uFF04\uFF0B\uFF10-\uFF19\uFF1C-\uFF1E\uFF21-\uFF3A\uFF3E\uFF40-\uFF5A\uFF5C\uFF5E\uFF66-\u{100FF}\u{10103}-\u{1039E}\u{103A0}-\u{103CF}\u{103D1}-\u{1056E}\u{10570}-\u{10856}\u{10858}-\u{1091E}\u{10920}-\u{1093E}\u{10940}-\u{10A4F}\u{10A59}-\u{10A7E}\u{10A80}-\u{10AEF}\u{10AF7}-\u{10B38}\u{10B40}-\u{10B98}\u{10B9D}-\u{10D6D}\u{10D6F}-\u{10EAC}\u{10EAE}-\u{10ECF}\u{10ED1}-\u{10F54}\u{10F5A}-\u{10F85}\u{10F8A}-\u{11046}\u{1104E}-\u{110BA}\u{110BD}\u{110C2}-\u{1113F}\u{11144}-\u{11173}\u{11176}-\u{111C4}\u{111C9}-\u{111CC}\u{111CE}-\u{111DA}\u{111DC}\u{111E0}-\u{11237}\u{1123E}-\u{112A8}\u{112AA}-\u{113D3}\u{113D6}\u{113D9}-\u{1144A}\u{11450}-\u{11459}\u{1145C}\u{1145E}-\u{114C5}\u{114C7}-\u{115C0}\u{115D8}-\u{11640}\u{11644}-\u{1165F}\u{1166D}-\u{116B8}\u{116BA}-\u{1173B}\u{1173F}-\u{1183A}\u{1183C}-\u{11943}\u{11947}-\u{119E1}\u{119E3}-\u{11A3E}\u{11A47}-\u{11A99}\u{11A9D}\u{11AA3}-\u{11AFF}\u{11B0A}-\u{11BE0}\u{11BE2}-\u{11C40}\u{11C46}-\u{11C6F}\u{11C72}-\u{11EF6}\u{11EF9}-\u{11F42}\u{11F50}-\u{11FFE}\u{12000}-\u{1246F}\u{12475}-\u{12FF0}\u{12FF3}-\u{16A6D}\u{16A70}-\u{16AF4}\u{16AF6}-\u{16B36}\u{16B3C}-\u{16B43}\u{16B45}-\u{16D6C}\u{16D70}-\u{16E96}\u{16E9B}-\u{16FE1}\u{16FE3}-\u{1BC9E}\u{1BCA0}-\u{1DA86}\u{1DA8C}-\u{1E5FE}\u{1E600}-\u{1E95D}\u{1E960}-\u{10FFFF}]+)+)/gmu; 17095 const [normalizedText, diffs] = normalize(text, { 17096 ignoreDashEOL: true 17097 }); 17098 const matches = normalizedText.matchAll(this.#regex); 17099 const links = []; 17100 for (const match of matches) { 17101 const [url, emailDomain] = match; 17102 let raw; 17103 if (url.startsWith("www.") || url.startsWith("http://") || url.startsWith("https://")) { 17104 raw = url; 17105 } else if (emailDomain) { 17106 const hostname = URL.parse(`http://${emailDomain}`)?.hostname; 17107 if (!hostname) { 17108 continue; 17109 } 17110 this.#numericTLDRegex ??= /\.\d+$/; 17111 if (this.#numericTLDRegex.test(hostname)) { 17112 continue; 17113 } 17114 } 17115 raw ??= url.startsWith("mailto:") ? url : `mailto:${url}`; 17116 const absoluteURL = createValidAbsoluteUrl(raw, null, { 17117 addDefaultProtocol: true 17118 }); 17119 if (absoluteURL) { 17120 const [index, length] = getOriginalIndex(diffs, match.index, url.length); 17121 links.push({ 17122 url: absoluteURL.href, 17123 index, 17124 length 17125 }); 17126 } 17127 } 17128 return links; 17129 } 17130 static processLinks(pdfPageView) { 17131 return this.findLinks(pdfPageView._textHighlighter.textContentItemsStr.join("\n")).map(link => createLinkAnnotation(link, pdfPageView, this.#index++)); 17132 } 17133} 17134 17135;// ./web/base_pdf_page_view.js 17136 17137 17138class BasePDFPageView extends RenderableView { 17139 #loadingId = null; 17140 #renderError = null; 17141 #renderingState = RenderingStates.INITIAL; 17142 #showCanvas = null; 17143 #startTime = 0; 17144 #tempCanvas = null; 17145 canvas = null; 17146 div = null; 17147 enableOptimizedPartialRendering = false;
17148 eventBus = null; 17149 id = null; 17150 pageColors = null; 17151 recordedBBoxes = null; 17152 renderingQueue = null; 17153 constructor(options) { 17154 super(); 17155 this.eventBus = options.eventBus; 17156 this.id = options.id; 17157 this.pageColors = options.pageColors || null; 17158 this.renderingQueue = options.renderingQueue; 17159 this.enableOptimizedPartialRendering = options.enableOptimizedPartialRendering ?? false; 17160 this.minDurationToUpdateCanvas = options.minDurationToUpdateCanvas ?? 500; 17161 } 17162 get renderingState() { 17163 return this.#renderingState; 17164 } 17165 set renderingState(state) { 17166 if (state === this.#renderingState) { 17167 return; 17168 } 17169 this.#renderingState = state; 17170 if (this.#loadingId) { 17171 clearTimeout(this.#loadingId); 17172 this.#loadingId = null; 17173 } 17174 switch (state) { 17175 case RenderingStates.PAUSED: 17176 this.div.classList.remove("loading"); 17177 this.#startTime = 0; 17178 this.#showCanvas?.(false); 17179 break; 17180 case RenderingStates.RUNNING: 17181 this.div.classList.add("loadingIcon"); 17182 this.#loadingId = setTimeout(() => { 17183 this.div.classList.add("loading"); 17184 this.#loadingId = null; 17185 }, 0); 17186 this.#startTime = Date.now(); 17187 break; 17188 case RenderingStates.INITIAL: 17189 case RenderingStates.FINISHED: 17190 this.div.classList.remove("loadingIcon", "loading"); 17191 this.#startTime = 0; 17192 break; 17193 } 17194 } 17195 _createCanvas(onShow, hideUntilComplete = false) { 17196 const { 17197 pageColors 17198 } = this; 17199 const hasHCM = !!(pageColors?.background && pageColors?.foreground); 17200 const prevCanvas = this.canvas; 17201 const updateOnFirstShow = !prevCanvas && !hasHCM && !hideUntilComplete;
17202 let canvas = this.canvas = document.createElement("canvas"); 17203 this.#showCanvas = isLastShow => { 17204 if (updateOnFirstShow) { 17205 let tempCanvas = this.#tempCanvas; 17206 if (!isLastShow && this.minDurationToUpdateCanvas > 0) { 17207 if (Date.now() - this.#startTime < this.minDurationToUpdateCanvas) { 17208 return; 17209 } 17210 if (!tempCanvas) { 17211 tempCanvas = this.#tempCanvas = canvas; 17212 canvas = this.canvas = canvas.cloneNode(false); 17213 onShow(canvas); 17214 } 17215 } 17216 if (tempCanvas) { 17217 const ctx = canvas.getContext("2d", { 17218 alpha: false 17219 }); 17220 ctx.drawImage(tempCanvas, 0, 0); 17221 if (isLastShow) { 17222 this.#resetTempCanvas(); 17223 } else { 17224 this.#startTime = Date.now(); 17225 } 17226 return; 17227 } 17228 onShow(canvas); 17229 this.#showCanvas = null; 17230 return; 17231 } 17232 if (!isLastShow) { 17233 return; 17234 } 17235 if (prevCanvas) { 17236 prevCanvas.replaceWith(canvas); 17237 prevCanvas.width = prevCanvas.height = 0; 17238 } else { 17239 onShow(canvas); 17240 } 17241 }; 17242 return { 17243 canvas, 17244 prevCanvas 17245 }; 17246 } 17247 #renderContinueCallback = cont => { 17248 this.#showCanvas?.(false); 17249 if (this.renderingQueue && !this.renderingQueue.isHighestPriority(this)) { 17250 this.renderingState = RenderingStates.PAUSED; 17251 this.resume = () => { 17252 this.renderingState = RenderingStates.RUNNING; 17253 cont(); 17254 }; 17255 return; 17256 } 17257 cont(); 17258 }; 17259 _resetCanvas() { 17260 const { 17261 canvas 17262 } = this; 17263 if (!canvas) { 17264 return; 17265 } 17266 canvas.remove(); 17267 canvas.width = canvas.height = 0; 17268 this.canvas = null; 17269 this.#resetTempCanvas(); 17270 } 17271 #resetTempCanvas() { 17272 if (this.#tempCanvas) { 17273 this.#tempCanvas.width = this.#tempCanvas.height = 0; 17274 this.#tempCanvas = null; 17275 } 17276 } 17277 async _drawCanvas(options, onCancel, onFinish) { 17278 const renderTask = this.renderTask = this.pdfPage.render(options); 17279 renderTask.onContinue = this.#renderContinueCallback; 17280 renderTask.onError = error => { 17281 if (error instanceof RenderingCancelledException) { 17282 onCancel(); 17283 this.#renderError = null; 17284 } 17285 }; 17286 let error = null; 17287 try { 17288 await renderTask.promise; 17289 this.#showCanvas?.(true); 17290 } catch (e) { 17291 if (e instanceof RenderingCancelledException) { 17292 return; 17293 } 17294 error = e; 17295 this.#showCanvas?.(true); 17296 } finally { 17297 this.#renderError = error; 17298 if (renderTask === this.renderTask) { 17299 this.renderTask = null; 17300 if (this.enableOptimizedPartialRendering) { 17301 this.recordedBBoxes ??= renderTask.recordedBBoxes; 17302 } 17303 } 17304 } 17305 this.renderingState = RenderingStates.FINISHED; 17306 onFinish(renderTask); 17307 if (error) { 17308 throw error; 17309 } 17310 } 17311 cancelRendering({ 17312 cancelExtraDelay = 0 17313 } = {}) { 17314 if (this.renderTask) { 17315 this.renderTask.cancel(cancelExtraDelay); 17316 this.renderTask = null; 17317 } 17318 this.resume = null; 17319 } 17320 dispatchPageRender() { 17321 this.eventBus.dispatch("pagerender", { 17322 source: this, 17323 pageNumber: this.id 17324 }); 17325 } 17326 dispatchPageRendered(cssTransform, isDetailView) { 17327 this.eventBus.dispatch("pagerendered", { 17328 source: this, 17329 pageNumber: this.id, 17330 cssTransform, 17331 isDetailView, 17332 timestamp: performance.now(), 17333 error: this.#renderError 17334 }); 17335 } 17336} 17337 17338;// ./web/draw_layer_builder.js 17339 17340class DrawLayerBuilder { 17341 #drawLayer = null; 17342 async render({ 17343 intent = "display" 17344 }) { 17345 if (intent !== "display" || this.#drawLayer || this._cancelled) { 17346 return; 17347 } 17348 this.#drawLayer = new DrawLayer(); 17349 } 17350 cancel() { 17351 this._cancelled = true; 17352 if (!this.#drawLayer) { 17353 return; 17354 } 17355 this.#drawLayer.destroy(); 17356 this.#drawLayer = null; 17357 } 17358 setParent(parent) { 17359 this.#drawLayer?.setParent(parent); 17360 } 17361 getDrawLayer() { 17362 return this.#drawLayer; 17363 } 17364} 17365 17366;// ./web/pdf_page_detail_view.js 17367 17368 17369 17370class PDFPageDetailView extends BasePDFPageView { 17371 #detailArea = null; 17372 renderingCancelled = false;
17373 constructor({ 17374 pageView 17375 }) { 17376 super(pageView); 17377 this.pageView = pageView; 17378 this.renderingId = "detail" + this.id; 17379 this.div = pageView.div; 17380 } 17381 setPdfPage(pdfPage) { 17382 this.pageView.setPdfPage(pdfPage); 17383 } 17384 get pdfPage() { 17385 return this.pageView.pdfPage; 17386 } 17387 get renderingState() { 17388 return super.renderingState; 17389 } 17390 set renderingState(state) { 17391 this.renderingCancelled = false; 17392 super.renderingState = state; 17393 } 17394 reset({ 17395 keepCanvas = false 17396 } = {}) { 17397 const renderingCancelled = this.renderingCancelled || this.renderingState === RenderingStates.RUNNING || this.renderingState === RenderingStates.PAUSED; 17398 this.cancelRendering(); 17399 this.renderingState = RenderingStates.INITIAL; 17400 this.renderingCancelled = renderingCancelled; 17401 if (!keepCanvas) { 17402 this._resetCanvas(); 17403 } 17404 } 17405 #shouldRenderDifferentArea(visibleArea) { 17406 if (!this.#detailArea) { 17407 return true; 17408 } 17409 const minDetailX = this.#detailArea.minX; 17410 const minDetailY = this.#detailArea.minY; 17411 const maxDetailX = this.#detailArea.width + minDetailX; 17412 const maxDetailY = this.#detailArea.height + minDetailY; 17413 if (visibleArea.minX < minDetailX || visibleArea.minY < minDetailY || visibleArea.maxX > maxDetailX || visibleArea.maxY > maxDetailY) { 17414 return true; 17415 } 17416 const { 17417 width: maxWidth, 17418 height: maxHeight, 17419 scale 17420 } = this.pageView.viewport; 17421 if (this.#detailArea.scale !== scale) { 17422 return true; 17423 } 17424 const paddingLeftSize = visibleArea.minX - minDetailX; 17425 const paddingRightSize = maxDetailX - visibleArea.maxX; 17426 const paddingTopSize = visibleArea.minY - minDetailY; 17427 const paddingBottomSize = maxDetailY - visibleArea.maxY; 17428 const MOVEMENT_THRESHOLD = 0.5; 17429 const ratio = (1 + MOVEMENT_THRESHOLD) / MOVEMENT_THRESHOLD; 17430 if (minDetailX > 0 && paddingRightSize / paddingLeftSize > ratio || maxDetailX < maxWidth && paddingLeftSize / paddingRightSize > ratio || minDetailY > 0 && paddingBottomSize / paddingTopSize > ratio || maxDetailY < maxHeight && paddingTopSize / paddingBottomSize > ratio) { 17431 return true; 17432 } 17433 return false; 17434 } 17435 update({ 17436 visibleArea = null, 17437 underlyingViewUpdated = false 17438 } = {}) { 17439 if (underlyingViewUpdated) { 17440 this.cancelRendering(); 17441 this.renderingState = RenderingStates.INITIAL; 17442 return; 17443 } 17444 if (!this.#shouldRenderDifferentArea(visibleArea)) { 17445 return; 17446 } 17447 const { 17448 viewport, 17449 maxCanvasPixels, 17450 capCanvasAreaFactor 17451 } = this.pageView; 17452 const visibleWidth = visibleArea.maxX - visibleArea.minX; 17453 const visibleHeight = visibleArea.maxY - visibleArea.minY; 17454 const visiblePixels = visibleWidth * visibleHeight * OutputScale.pixelRatio ** 2; 17455 const maxDetailToVisibleLinearRatio = Math.sqrt(OutputScale.capPixels(maxCanvasPixels, capCanvasAreaFactor) / visiblePixels); 17456 const maxOverflowScale = (maxDetailToVisibleLinearRatio - 1) / 2; 17457 let overflowScale = Math.min(1, maxOverflowScale); 17458 if (overflowScale < 0) { 17459 overflowScale = 0; 17460 } 17461 const overflowWidth = visibleWidth * overflowScale; 17462 const overflowHeight = visibleHeight * overflowScale; 17463 const minX = Math.max(0, visibleArea.minX - overflowWidth); 17464 const maxX = Math.min(viewport.width, visibleArea.maxX + overflowWidth); 17465 const minY = Math.max(0, visibleArea.minY - overflowHeight); 17466 const maxY = Math.min(viewport.height, visibleArea.maxY + overflowHeight); 17467 const width = maxX - minX; 17468 const height = maxY - minY; 17469 this.#detailArea = { 17470 minX, 17471 minY, 17472 width, 17473 height, 17474 scale: viewport.scale 17475 }; 17476 this.reset({ 17477 keepCanvas: true 17478 }); 17479 } 17480 _getRenderingContext(canvas, transform) { 17481 const baseContext = this.pageView._getRenderingContext(canvas, transform, false); 17482 const recordedBBoxes = this.pdfPage.recordedBBoxes; 17483 if (!recordedBBoxes || !this.enableOptimizedPartialRendering) { 17484 return baseContext; 17485 } 17486 const { 17487 viewport: { 17488 width: vWidth, 17489 height: vHeight 17490 } 17491 } = this.pageView; 17492 const { 17493 width: aWidth, 17494 height: aHeight, 17495 minX: aMinX, 17496 minY: aMinY 17497 } = this.#detailArea; 17498 const detailMinX = aMinX / vWidth; 17499 const detailMinY = aMinY / vHeight; 17500 const detailMaxX = (aMinX + aWidth) / vWidth; 17501 const detailMaxY = (aMinY + aHeight) / vHeight; 17502 return { 17503 ...baseContext, 17504 operationsFilter(index) { 17505 if (recordedBBoxes.isEmpty(index)) { 17506 return false;
17507 } 17508 return recordedBBoxes.minX(index) <= detailMaxX && recordedBBoxes.maxX(index) >= detailMinX && recordedBBoxes.minY(index) <= detailMaxY && recordedBBoxes.maxY(index) >= detailMinY; 17509 } 17510 }; 17511 } 17512 async draw() { 17513 if (this.pageView.detailView !== this) { 17514 return undefined; 17515 } 17516 const hideUntilComplete = this.pageView.renderingState === RenderingStates.FINISHED || this.renderingState === RenderingStates.FINISHED; 17517 if (this.renderingState !== RenderingStates.INITIAL) { 17518 console.error("Must be in new state before drawing"); 17519 this.reset(); 17520 } 17521 const { 17522 div, 17523 pdfPage, 17524 viewport 17525 } = this.pageView; 17526 if (!pdfPage) { 17527 this.renderingState = RenderingStates.FINISHED; 17528 throw new Error("pdfPage is not loaded"); 17529 } 17530 this.renderingState = RenderingStates.RUNNING; 17531 const canvasWrapper = this.pageView._ensureCanvasWrapper(); 17532 const { 17533 canvas, 17534 prevCanvas 17535 } = this._createCanvas(newCanvas => { 17536 if (canvasWrapper.firstElementChild?.tagName === "CANVAS") { 17537 canvasWrapper.firstElementChild.after(newCanvas); 17538 } else { 17539 canvasWrapper.prepend(newCanvas); 17540 } 17541 }, hideUntilComplete); 17542 canvas.ariaHidden = true; 17543 if (this.enableOptimizedPartialRendering) { 17544 canvas.className = "detailView"; 17545 } 17546 const { 17547 width, 17548 height 17549 } = viewport; 17550 const area = this.#detailArea; 17551 const { 17552 pixelRatio 17553 } = OutputScale; 17554 const transform = [pixelRatio, 0, 0, pixelRatio, -area.minX * pixelRatio, -area.minY * pixelRatio]; 17555 canvas.width = area.width * pixelRatio; 17556 canvas.height = area.height * pixelRatio; 17557 const { 17558 style 17559 } = canvas; 17560 style.width = `${area.width * 100 / width}%`; 17561 style.height = `${area.height * 100 / height}%`; 17562 style.top = `${area.minY * 100 / height}%`; 17563 style.left = `${area.minX * 100 / width}%`; 17564 const renderingPromise = this._drawCanvas(this._getRenderingContext(canvas, transform), () => { 17565 this.canvas?.remove(); 17566 this.canvas = prevCanvas; 17567 }, () => { 17568 this.dispatchPageRendered(false, true); 17569 }); 17570 div.setAttribute("data-loaded", true); 17571 this.dispatchPageRender(); 17572 return renderingPromise; 17573 } 17574} 17575 17576;// ./web/struct_tree_layer_builder.js 17577 17578 17579 17580 17581 17582 17583 17584 17585 17586 17587 17588 17589 17590const PDF_ROLE_TO_HTML_ROLE = { 17591 Document: null, 17592 DocumentFragment: null, 17593 Part: "group", 17594 Sect: "group", 17595 Div: "group", 17596 Aside: "note", 17597 NonStruct: "none", 17598 P: null, 17599 H: "heading", 17600 Title: null, 17601 FENote: "note", 17602 Sub: "group", 17603 Lbl: null, 17604 Span: null, 17605 Em: null, 17606 Strong: null, 17607 Link: "link", 17608 Annot: "note", 17609 Form: "form", 17610 Ruby: null, 17611 RB: null, 17612 RT: null, 17613 RP: null, 17614 Warichu: null, 17615 WT: null, 17616 WP: null, 17617 L: "list", 17618 LI: "listitem", 17619 LBody: null, 17620 Table: "table", 17621 TR: "row", 17622 TH: "columnheader", 17623 TD: "cell", 17624 THead: "rowgroup", 17625 TBody: "rowgroup", 17626 TFoot: null, 17627 Caption: null, 17628 Figure: "figure", 17629 Formula: null, 17630 Artifact: null 17631}; 17632const MathMLElements = new Set(["math", "merror", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics"]); 17633const MathMLNamespace = "http://www.w3.org/1998/Math/MathML"; 17634class MathMLSanitizer { 17635 static get sanitizer() { 17636 return shadow(this, "sanitizer", FeatureTest.isSanitizerSupported ? new Sanitizer({ 17637 elements: [...MathMLElements].map(name => ({ 17638 name, 17639 namespace: MathMLNamespace 17640 })), 17641 replaceWithChildrenElements: [{ 17642 name: "maction", 17643 namespace: MathMLNamespace 17644 }], 17645 attributes: ["dir", "displaystyle", "mathbackground", "mathcolor", "mathsize", "scriptlevel", "encoding", "display", "linethickness", "intent", "arg", "form", "fence", "separator", "lspace", "rspace", "stretchy", "symmetric", "maxsize", "minsize", "largeop", "movablelimits", "width", "height", "depth", "voffset", "accent", "accentunder", "columnspan", "rowspan"], 17646 comments: false 17647 }) : null); 17648 } 17649} 17650const HEADING_PATTERN = /^H(\d+)$/; 17651class StructTreeLayerBuilder { 17652 #promise; 17653 #treeDom = null; 17654 #treePromise; 17655 #elementAttributes = new Map(); 17656 #rawDims; 17657 #elementsToAddToTextLayer = null; 17658 #elementsToHideInTextLayer = null; 17659 #elementsToStealFromTextLayer = null; 17660 constructor(pdfPage, rawDims) { 17661 this.#promise = pdfPage.getStructTree(); 17662 this.#rawDims = rawDims; 17663 } 17664 async render() { 17665 if (this.#treePromise) { 17666 return this.#treePromise; 17667 } 17668 const { 17669 promise, 17670 resolve, 17671 reject 17672 } = Promise.withResolvers(); 17673 this.#treePromise = promise; 17674 try { 17675 this.#treeDom = this.#walk(await this.#promise); 17676 } catch (ex) { 17677 reject(ex); 17678 } 17679 this.#promise = null; 17680 this.#treeDom?.classList.add("structTree"); 17681 resolve(this.#treeDom); 17682 return promise; 17683 } 17684 async getAriaAttributes(annotationId) { 17685 try { 17686 await this.render(); 17687 return this.#elementAttributes.get(annotationId); 17688 } catch {} 17689 return null; 17690 } 17691 hide() { 17692 if (this.#treeDom && !this.#treeDom.hidden) { 17693 this.#treeDom.hidden = true; 17694 } 17695 } 17696 show() { 17697 if (this.#treeDom?.hidden) { 17698 this.#treeDom.hidden = false;
17699 } 17700 } 17701 #setAttributes(structElement, htmlElement) { 17702 const { 17703 alt, 17704 id, 17705 lang 17706 } = structElement; 17707 if (alt !== undefined) { 17708 let added = false; 17709 const label = removeNullCharacters(alt); 17710 for (const child of structElement.children) { 17711 if (child.type === "annotation") { 17712 this.#elementAttributes.getOrInsertComputed(child.id, makeMap).set("aria-label", label); 17713 added = true; 17714 } 17715 } 17716 if (!added) { 17717 htmlElement.setAttribute("aria-label", label); 17718 } 17719 } 17720 if (id !== undefined) { 17721 htmlElement.setAttribute("aria-owns", id); 17722 } 17723 if (lang !== undefined) { 17724 htmlElement.setAttribute("lang", removeNullCharacters(lang, true)); 17725 } 17726 } 17727 #addImageInTextLayer(node, element) { 17728 const { 17729 alt, 17730 bbox, 17731 children 17732 } = node; 17733 const child = children?.[0]; 17734 if (!this.#rawDims || !alt || !bbox || child?.type !== "content") { 17735 return false; 17736 } 17737 const { 17738 id 17739 } = child; 17740 if (!id) { 17741 return false; 17742 } 17743 element.setAttribute("aria-owns", id); 17744 const img = document.createElement("span"); 17745 (this.#elementsToAddToTextLayer ||= new Map()).set(id, img); 17746 img.setAttribute("role", "img"); 17747 img.setAttribute("aria-label", removeNullCharacters(alt)); 17748 const { 17749 pageHeight, 17750 pageX, 17751 pageY 17752 } = this.#rawDims; 17753 const calc = "calc(var(--total-scale-factor) *"; 17754 const { 17755 style 17756 } = img; 17757 style.width = `${calc}${bbox[2] - bbox[0]}px)`; 17758 style.height = `${calc}${bbox[3] - bbox[1]}px)`; 17759 style.left = `${calc}${bbox[0] - pageX}px)`; 17760 style.top = `${calc}${pageHeight - bbox[3] + pageY}px)`; 17761 return true; 17762 } 17763 updateTextLayer() { 17764 if (this.#elementsToAddToTextLayer) { 17765 for (const [id, img] of this.#elementsToAddToTextLayer) { 17766 document.getElementById(id)?.append(img); 17767 } 17768 this.#elementsToAddToTextLayer.clear(); 17769 this.#elementsToAddToTextLayer = null; 17770 } 17771 if (this.#elementsToHideInTextLayer) { 17772 for (const id of this.#elementsToHideInTextLayer) { 17773 const elem = document.getElementById(id); 17774 if (elem) { 17775 elem.ariaHidden = true; 17776 } 17777 } 17778 this.#elementsToHideInTextLayer.length = 0; 17779 this.#elementsToHideInTextLayer = null; 17780 } 17781 if (this.#elementsToStealFromTextLayer) { 17782 for (let i = 0, ii = this.#elementsToStealFromTextLayer.length; i < ii; i += 2) { 17783 const element = this.#elementsToStealFromTextLayer[i]; 17784 const ids = this.#elementsToStealFromTextLayer[i + 1]; 17785 let textContent = ""; 17786 for (const id of ids) { 17787 const elem = document.getElementById(id); 17788 if (elem) { 17789 textContent += elem.textContent.trim() || ""; 17790 elem.ariaHidden = "true"; 17791 } 17792 } 17793 if (textContent) { 17794 element.textContent = textContent; 17795 } 17796 } 17797 this.#elementsToStealFromTextLayer.length = 0; 17798 this.#elementsToStealFromTextLayer = null; 17799 } 17800 } 17801 #walk(node, parentNodes = []) { 17802 if (!node) { 17803 return null; 17804 } 17805 let element; 17806 if ("role" in node) { 17807 const { 17808 role 17809 } = node; 17810 if (MathMLElements.has(role)) { 17811 element = document.createElementNS(MathMLNamespace, role); 17812 const ids = []; 17813 (this.#elementsToStealFromTextLayer ||= []).push(element, ids); 17814 for (const { 17815 type, 17816 id 17817 } of node.children || []) { 17818 if (type === "content" && id) { 17819 ids.push(id); 17820 } 17821 } 17822 } else { 17823 element = document.createElement("span"); 17824 } 17825 const match = role.match(HEADING_PATTERN); 17826 if (match) { 17827 element.setAttribute("role", "heading"); 17828 element.setAttribute("aria-level", match[1]); 17829 } else if (PDF_ROLE_TO_HTML_ROLE[role]) { 17830 element.setAttribute("role", role === "TH" && parentNodes.at(-1)?.role === "TR" && parentNodes.at(-2)?.role === "TBody" ? "rowheader" : PDF_ROLE_TO_HTML_ROLE[role]); 17831 } 17832 if (role === "Figure" && this.#addImageInTextLayer(node, element)) { 17833 return element; 17834 } 17835 if (role === "Formula") { 17836 if (node.mathML && MathMLSanitizer.sanitizer) { 17837 element.setHTML(node.mathML, { 17838 sanitizer: MathMLSanitizer.sanitizer 17839 }); 17840 for (const { 17841 id 17842 } of node.children || []) { 17843 if (!id) { 17844 continue; 17845 } 17846 (this.#elementsToHideInTextLayer ||= []).push(id); 17847 } 17848 delete node.alt; 17849 } 17850 if (!node.mathML && node.children.length === 1 && node.children[0].role !== "math") { 17851 element = document.createElementNS(MathMLNamespace, "math"); 17852 delete node.alt; 17853 } 17854 } 17855 } 17856 element ||= document.createElement("span"); 17857 this.#setAttributes(node, element); 17858 if (node.children) { 17859 if (node.children.length === 1 && "id" in node.children[0]) { 17860 this.#setAttributes(node.children[0], element); 17861 } else { 17862 parentNodes.push(node); 17863 for (const kid of node.children) { 17864 element.append(this.#walk(kid, parentNodes)); 17865 } 17866 parentNodes.pop(); 17867 } 17868 } 17869 return element; 17870 } 17871} 17872 17873;// ./web/text_accessibility.js 17874 17875 17876 17877 17878 17879class TextAccessibilityManager { 17880 #enabled = false;
17881 #textChildren = null; 17882 #textNodes = new Map(); 17883 #waitingElements = new Map(); 17884 setTextMapping(textDivs) { 17885 this.#textChildren = textDivs; 17886 } 17887 static #compareElementPositions(e1, e2) { 17888 const rect1 = e1.getBoundingClientRect(); 17889 const rect2 = e2.getBoundingClientRect(); 17890 if (rect1.width === 0 && rect1.height === 0) { 17891 return +1; 17892 } 17893 if (rect2.width === 0 && rect2.height === 0) { 17894 return -1; 17895 } 17896 const top1 = rect1.y; 17897 const bot1 = rect1.y + rect1.height; 17898 const mid1 = rect1.y + rect1.height / 2; 17899 const top2 = rect2.y; 17900 const bot2 = rect2.y + rect2.height; 17901 const mid2 = rect2.y + rect2.height / 2; 17902 if (mid1 <= top2 && mid2 >= bot1) { 17903 return -1; 17904 } 17905 if (mid2 <= top1 && mid1 >= bot2) { 17906 return +1; 17907 } 17908 const centerX1 = rect1.x + rect1.width / 2; 17909 const centerX2 = rect2.x + rect2.width / 2; 17910 return centerX1 - centerX2; 17911 } 17912 enable() { 17913 if (this.#enabled) { 17914 throw new Error("TextAccessibilityManager is already enabled."); 17915 } 17916 if (!this.#textChildren) { 17917 throw new Error("Text divs and strings have not been set."); 17918 } 17919 this.#enabled = true; 17920 this.#textChildren = this.#textChildren.slice(); 17921 this.#textChildren.sort(TextAccessibilityManager.#compareElementPositions); 17922 if (this.#textNodes.size > 0) { 17923 const textChildren = this.#textChildren; 17924 for (const [id, nodeIndex] of this.#textNodes) { 17925 const element = document.getElementById(id); 17926 if (!element) { 17927 this.#textNodes.delete(id); 17928 continue; 17929 } 17930 this.#addIdToAriaOwns(id, textChildren[nodeIndex]); 17931 } 17932 } 17933 for (const [element, isRemovable] of this.#waitingElements) { 17934 this.addPointerInTextLayer(element, isRemovable); 17935 } 17936 this.#waitingElements.clear(); 17937 } 17938 disable() { 17939 if (!this.#enabled) { 17940 return; 17941 } 17942 this.#waitingElements.clear(); 17943 this.#textChildren = null; 17944 this.#enabled = false; 17945 } 17946 removePointerInTextLayer(element) { 17947 if (!this.#enabled) { 17948 this.#waitingElements.delete(element); 17949 return; 17950 } 17951 const children = this.#textChildren; 17952 if (!children || children.length === 0) { 17953 return; 17954 } 17955 const { 17956 id 17957 } = element; 17958 const nodeIndex = this.#textNodes.get(id); 17959 if (nodeIndex === undefined) { 17960 return; 17961 } 17962 const node = children[nodeIndex]; 17963 this.#textNodes.delete(id); 17964 let owns = node.getAttribute("aria-owns"); 17965 if (owns?.includes(id)) { 17966 owns = owns.split(" ").filter(x => x !== id).join(" "); 17967 if (owns) { 17968 node.setAttribute("aria-owns", owns); 17969 } else { 17970 node.removeAttribute("aria-owns"); 17971 node.setAttribute("role", "presentation"); 17972 } 17973 } 17974 } 17975 #addIdToAriaOwns(id, node) { 17976 const owns = node.getAttribute("aria-owns"); 17977 if (!owns?.includes(id)) { 17978 node.setAttribute("aria-owns", owns ? `${owns} ${id}` : id); 17979 } 17980 node.removeAttribute("role"); 17981 } 17982 addPointerInTextLayer(element, isRemovable) { 17983 const { 17984 id 17985 } = element; 17986 if (!id) { 17987 return null; 17988 } 17989 if (!this.#enabled) { 17990 this.#waitingElements.set(element, isRemovable); 17991 return null; 17992 } 17993 if (isRemovable) { 17994 this.removePointerInTextLayer(element); 17995 } 17996 const children = this.#textChildren; 17997 if (!children || children.length === 0) { 17998 return null; 17999 } 18000 const index = binarySearchFirstItem(children, node => TextAccessibilityManager.#compareElementPositions(element, node) < 0); 18001 const nodeIndex = Math.max(0, index - 1); 18002 const child = children[nodeIndex]; 18003 this.#addIdToAriaOwns(id, child); 18004 this.#textNodes.set(id, nodeIndex); 18005 const parent = child.parentNode; 18006 return parent?.classList.contains("markedContent") ? parent.id : null; 18007 } 18008 moveElementInDOM(container, element, contentElement, isRemovable) { 18009 const id = this.addPointerInTextLayer(contentElement, isRemovable); 18010 if (!container.hasChildNodes()) { 18011 container.append(element); 18012 return id; 18013 } 18014 const children = Array.from(container.childNodes).filter(node =>
18014 node !== element); 18015 if (children.length === 0) { 18016 return id; 18017 } 18018 const index = binarySearchFirstItem(children, node => TextAccessibilityManager.#compareElementPositions(element, node) < 0); 18019 if (index === 0) { 18020 children[0].before(element); 18021 } else { 18022 children[index - 1].after(element); 18023 } 18024 return id; 18025 } 18026} 18027 18028;// ./web/text_highlighter.js 18029 18030class TextHighlighter { 18031 #eventAbortController = null; 18032 constructor({ 18033 findController, 18034 eventBus, 18035 pageIndex 18036 }) { 18037 this.findController = findController; 18038 this.matches = []; 18039 this.eventBus = eventBus; 18040 this.pageIdx = pageIndex; 18041 this.textDivs = null; 18042 this.textContentItemsStr = null; 18043 this.enabled = false; 18044 } 18045 setTextMapping(divs, texts) { 18046 this.textDivs = divs; 18047 this.textContentItemsStr = texts; 18048 } 18049 enable() { 18050 if (!this.textDivs || !this.textContentItemsStr) { 18051 throw new Error("Text divs and strings have not been set."); 18052 } 18053 if (this.enabled) { 18054 throw new Error("TextHighlighter is already enabled."); 18055 } 18056 this.enabled = true; 18057 if (!this.#eventAbortController) { 18058 this.#eventAbortController = new AbortController(); 18059 this.eventBus._on("updatetextlayermatches", evt => { 18060 if (evt.pageIndex === this.pageIdx || evt.pageIndex === -1) { 18061 this._updateMatches(); 18062 } 18063 }, { 18064 signal: this.#eventAbortController.signal 18065 }); 18066 } 18067 this._updateMatches(); 18068 } 18069 disable() { 18070 if (!this.enabled) { 18071 return; 18072 } 18073 this.enabled = false; 18074 this.#eventAbortController?.abort(); 18075 this.#eventAbortController = null; 18076 this._updateMatches(true); 18077 } 18078 _convertMatches(matches, matchesLength) { 18079 if (!matches) { 18080 return []; 18081 } 18082 const { 18083 textContentItemsStr 18084 } = this; 18085 let i = 0, 18086 iIndex = 0; 18087 const end = textContentItemsStr.length - 1; 18088 const result = []; 18089 for (let m = 0, mm = matches.length; m < mm; m++) { 18090 let matchIdx = matches[m]; 18091 while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) { 18092 iIndex += textContentItemsStr[i].length; 18093 i++; 18094 } 18095 if (i === textContentItemsStr.length) { 18096 console.error("Could not find a matching mapping"); 18097 } 18098 const match = { 18099 begin: { 18100 divIdx: i,
18101 offset: matchIdx - iIndex 18102 } 18103 }; 18104 matchIdx += matchesLength[m]; 18105 while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) { 18106 iIndex += textContentItemsStr[i].length; 18107 i++; 18108 } 18109 match.end = { 18110 divIdx: i, 18111 offset: matchIdx - iIndex 18112 }; 18113 result.push(match); 18114 } 18115 return result; 18116 } 18117 _renderMatches(matches) { 18118 if (matches.length === 0) { 18119 return; 18120 } 18121 const { 18122 findController, 18123 pageIdx 18124 } = this; 18125 const { 18126 textContentItemsStr, 18127 textDivs 18128 } = this; 18129 const isSelectedPage = pageIdx === findController.selected.pageIdx; 18130 const selectedMatchIdx = findController.selected.matchIdx; 18131 const highlightAll = findController.state.highlightAll; 18132 let prevEnd = null; 18133 const infinity = { 18134 divIdx: -1, 18135 offset: undefined 18136 }; 18137 function beginText(begin, className) { 18138 const divIdx = begin.divIdx; 18139 textDivs[divIdx].textContent = ""; 18140 return appendTextToDiv(divIdx, 0, begin.offset, className); 18141 } 18142 function appendTextToDiv(divIdx, fromOffset, toOffset, className) { 18143 let div = textDivs[divIdx]; 18144 if (div.nodeType === Node.TEXT_NODE) { 18145 const span = document.createElement("span"); 18146 div.before(span); 18147 span.append(div); 18148 textDivs[divIdx] = span; 18149 div = span; 18150 } 18151 const content = textContentItemsStr[divIdx].substring(fromOffset, toOffset); 18152 const node = document.createTextNode(content); 18153 if (className) { 18154 const span = document.createElement("span"); 18155 span.className = `${className} appended`; 18156 span.append(node); 18157 div.append(span); 18158 if (className.includes("selected")) { 18159 const { 18160 left 18161 } = span.getClientRects()[0]; 18162 const parentLeft = div.getBoundingClientRect().left; 18163 return left - parentLeft; 18164 } 18165 return 0; 18166 } 18167 div.append(node); 18168 return 0; 18169 } 18170 let i0 = selectedMatchIdx, 18171 i1 = i0 + 1; 18172 if (highlightAll) { 18173 i0 = 0; 18174 i1 = matches.length; 18175 } else if (!isSelectedPage) { 18176 return; 18177 } 18178 let lastDivIdx = -1; 18179 let lastOffset = -1; 18180 for (let i = i0; i < i1; i++) { 18181 const match = matches[i]; 18182 const begin = match.begin; 18183 if (begin.divIdx === lastDivIdx && begin.offset === lastOffset) { 18184 continue; 18185 } 18186 lastDivIdx = begin.divIdx; 18187 lastOffset = begin.offset; 18188 const end = match.end; 18189 const isSelected = isSelectedPage && i === selectedMatchIdx; 18190 const highlightSuffix = isSelected ? " selected" : ""; 18191 let selectedLeft = 0; 18192 if (!prevEnd || begin.divIdx !== prevEnd.divIdx) { 18193 if (prevEnd !== null) { 18194 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset); 18195 } 18196 beginText(begin); 18197 } else { 18198 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset); 18199 } 18200 if (begin.divIdx === end.divIdx) { 18201 selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix); 18202 } else { 18203 selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix); 18204 for (let n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) { 18205 textDivs[n0].className = "highlight middle" + highlightSuffix; 18206 } 18207 beginText(end, "highlight end" + highlightSuffix); 18208 } 18209 prevEnd = end; 18210 if (isSelected) { 18211 findController.scrollMatchIntoView({ 18212 element: textDivs[begin.divIdx], 18213 selectedLeft, 18214 pageIndex: pageIdx, 18215 matchIndex: selectedMatchIdx 18216 }); 18217 } 18218 } 18219 if (prevEnd) { 18220 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset); 18221 } 18222 } 18223 _updateMatches(reset = false) { 18224 if (!this.enabled && !reset) { 18225 return; 18226 } 18227 const { 18228 findController, 18229 matches, 18230 pageIdx 18231 } = this; 18232 const { 18233 textContentItemsStr, 18234 textDivs 18235 } = this; 18236 let clearedUntilDivIdx = -1; 18237 for (const match of matches) { 18238 const begin = Math.max(clearedUntilDivIdx, match.begin.divIdx); 18239 for (let n = begin, end = match.end.divIdx; n <= end; n++) { 18240 const div = textDivs[n]; 18241 div.textContent = textContentItemsStr[n]; 18242 div.className = ""; 18243 } 18244 clearedUntilDivIdx = match.end.divIdx + 1; 18245 } 18246 if (!findController?.highlightMatches || reset) { 18247 return; 18248 } 18249 const pageMatches = findController.pageMatches[pageIdx] || null; 18250 const pageMatchesLength = findController.pageMatchesLength[pageIdx] || null; 18251 this.matches = this._convertMatches(pageMatches, pageMatchesLength); 18252 this._renderMatches(this.matches); 18253 } 18254} 18255 18256;// ./web/text_layer_builder.js 18257 18258 18259 18260 18261 18262 18263 18264 18265 18266 18267 18268 18269 18270class TextLayerBuilder { 18271 #enablePermissions = false;
18272 #onAppend = null; 18273 #renderingDone = false; 18274 #textLayer = null; 18275 static #textLayers = new Map(); 18276 static #selectionChangeAbortController = null; 18277 constructor({ 18278 pdfPage, 18279 highlighter = null, 18280 accessibilityManager = null, 18281 enablePermissions = false, 18282 onAppend = null 18283 }) { 18284 this.pdfPage = pdfPage; 18285 this.highlighter = highlighter; 18286 this.accessibilityManager = accessibilityManager; 18287 this.#enablePermissions = enablePermissions === true; 18288 this.#onAppend = onAppend; 18289 this.div = document.createElement("div"); 18290 this.div.tabIndex = 0; 18291 this.div.className = "textLayer"; 18292 } 18293 async render({ 18294 viewport, 18295 textContentParams = null 18296 }) { 18297 if (this.#renderingDone && this.#textLayer) { 18298 this.#textLayer.update({ 18299 viewport, 18300 onBefore: this.hide.bind(this) 18301 }); 18302 this.show(); 18303 return; 18304 } 18305 this.cancel(); 18306 this.#textLayer = new TextLayer({ 18307 textContentSource: this.pdfPage.streamTextContent(textContentParams || { 18308 includeMarkedContent: true, 18309 disableNormalization: true 18310 }), 18311 container: this.div, 18312 viewport 18313 }); 18314 const { 18315 textDivs, 18316 textContentItemsStr 18317 } = this.#textLayer; 18318 this.highlighter?.setTextMapping(textDivs, textContentItemsStr); 18319 this.accessibilityManager?.setTextMapping(textDivs); 18320 await this.#textLayer.render(); 18321 this.#renderingDone = true; 18322 const endOfContent = document.createElement("div"); 18323 endOfContent.className = "endOfContent"; 18324 this.div.append(endOfContent); 18325 this.#bindMouse(endOfContent); 18326 this.#onAppend?.(this.div); 18327 this.highlighter?.enable(); 18328 this.accessibilityManager?.enable(); 18329 } 18330 hide() { 18331 if (!this.div.hidden && this.#renderingDone) { 18332 this.highlighter?.disable(); 18333 this.div.hidden = true; 18334 } 18335 } 18336 show() { 18337 if (this.div.hidden && this.#renderingDone) { 18338 this.div.hidden = false; 18339 this.highlighter?.enable(); 18340 } 18341 } 18342 cancel() { 18343 this.#textLayer?.cancel(); 18344 this.#textLayer = null; 18345 this.highlighter?.disable(); 18346 this.accessibilityManager?.disable(); 18347 TextLayerBuilder.#removeGlobalSelectionListener(this.div); 18348 } 18349 #bindMouse(end) { 18350 const { 18351 div 18352 } = this; 18353 div.addEventListener("mousedown", () => { 18354 div.classList.add("selecting"); 18355 }); 18356 div.addEventListener("copy", event => { 18357 if (!this.#enablePermissions) { 18358 const selection = document.getSelection(); 18359 event.clipboardData.setData("text/plain", removeNullCharacters(normalizeUnicode(selection.toString()))); 18360 } 18361 stopEvent(event); 18362 }); 18363 TextLayerBuilder.#textLayers.set(div, end); 18364 TextLayerBuilder.#enableGlobalSelectionListener(); 18365 } 18366 static #removeGlobalSelectionListener(textLayerDiv) { 18367 this.#textLayers.delete(textLayerDiv); 18368 if (this.#textLayers.size === 0) { 18369 this.#selectionChangeAbortController?.abort(); 18370 this.#selectionChangeAbortController = null; 18371 } 18372 } 18373 static #enableGlobalSelectionListener() { 18374 if (this.#selectionChangeAbortController) { 18375 return; 18376 } 18377 this.#selectionChangeAbortController = new AbortController(); 18378 const { 18379 signal 18380 } = this.#selectionChangeAbortController; 18381 const reset = (end, textLayer) => { 18382 textLayer.append(end); 18383 end.style.width = ""; 18384 end.style.height = ""; 18385 textLayer.classList.remove("selecting"); 18386 }; 18387 let isPointerDown = false; 18388 document.addEventListener("pointerdown", () => { 18389 isPointerDown = true; 18390 }, { 18391 signal 18392 }); 18393 document.addEventListener("pointerup", () => { 18394 isPointerDown = false; 18395 this.#textLayers.forEach(reset); 18396 }, { 18397 signal 18398 }); 18399 window.addEventListener("blur", () => { 18400 isPointerDown = false; 18401 this.#textLayers.forEach(reset); 18402 }, { 18403 signal 18404 }); 18405 document.addEventListener("keyup", () => { 18406 if (!isPointerDown) { 18407 this.#textLayers.forEach(reset); 18408 } 18409 }, { 18410 signal 18411 }); 18412 var isFirefox, prevRange; 18413 document.addEventListener("selectionchange", () => { 18414 const selection = document.getSelection(); 18415 if (selection.rangeCount === 0) {
18416 this.#textLayers.forEach(reset); 18417 return; 18418 } 18419 const activeTextLayers = new Set(); 18420 for (let i = 0; i < selection.rangeCount; i++) { 18421 const range = selection.getRangeAt(i); 18422 for (const textLayerDiv of this.#textLayers.keys()) { 18423 if (!activeTextLayers.has(textLayerDiv) && range.intersectsNode(textLayerDiv)) { 18424 activeTextLayers.add(textLayerDiv); 18425 } 18426 } 18427 } 18428 for (const [textLayerDiv, endDiv] of this.#textLayers) { 18429 if (activeTextLayers.has(textLayerDiv)) { 18430 textLayerDiv.classList.add("selecting"); 18431 } else { 18432 reset(endDiv, textLayerDiv); 18433 } 18434 } 18435 isFirefox ??= getComputedStyle(this.#textLayers.values().next().value).getPropertyValue("-moz-user-select") === "none"; 18436 if (isFirefox) { 18437 return; 18438 } 18439 const range = selection.getRangeAt(0); 18440 const modifyStart = prevRange && (range.compareBoundaryPoints(Range.END_TO_END, prevRange) === 0 || range.compareBoundaryPoints(Range.START_TO_END, prevRange) === 0); 18441 let anchor = modifyStart ? range.startContainer : range.endContainer; 18442 if (anchor.nodeType === Node.TEXT_NODE) { 18443 anchor = anchor.parentNode; 18444 } 18445 if (anchor.classList?.contains("highlight")) { 18446 anchor = anchor.parentNode; 18447 } 18448 if (!modifyStart && range.endOffset === 0) { 18449 do { 18450 while (!anchor.previousSibling) { 18451 anchor = anchor.parentNode; 18452 } 18453 anchor = anchor.previousSibling; 18454 } while (!anchor.childNodes.length); 18455 } 18456 const parentTextLayer = anchor.parentElement?.closest(".textLayer"); 18457 const endDiv = this.#textLayers.get(parentTextLayer); 18458 if (endDiv) { 18459 endDiv.style.width = parentTextLayer.style.width; 18460 endDiv.style.height = parentTextLayer.style.height; 18461 endDiv.style.userSelect = "text"; 18462 anchor.parentElement.insertBefore(endDiv, modifyStart ? anchor : anchor.nextSibling); 18463 } 18464 prevRange = range.cloneRange(); 18465 }, {
18466 signal 18467 }); 18468 } 18469} 18470 18471;// ./web/pdf_page_view.js 18472 18473 18474 18475 18476 18477 18478 18479 18480 18481 18482 18483 18484 18485 18486 18487 18488 18489 18490 18491 18492 18493const DEFAULT_LAYER_PROPERTIES = null; 18494const LAYERS_ORDER = new Map([["canvasWrapper", 0], ["textLayer", 1], ["annotationLayer", 2], ["annotationEditorLayer", 3], ["xfaLayer", 3]]); 18495class PDFPageView extends BasePDFPageView { 18496 #annotationMode = AnnotationMode.ENABLE_FORMS; 18497 #canvasWrapper = null; 18498 #commentManager = null; 18499 #enableAutoLinking = true; 18500 #hasRestrictedScaling = false; 18501 #isEditing = false; 18502 #layerProperties = null; 18503 #needsRestrictedScaling = false; 18504 #originalViewport = null; 18505 #previousRotation = null; 18506 #scaleRoundX = 1; 18507 #scaleRoundY = 1; 18508 #textLayerMode = TextLayerMode.ENABLE; 18509 #userUnit = 1; 18510 #useThumbnailCanvas = { 18511 directDrawing: true, 18512 initialOptionalContent: true, 18513 regularAnnotations: true 18514 }; 18515 #layers = [null, null, null, null]; 18516 #clonedFrom = null; 18517 constructor(options) { 18518 super(options); 18519 const { 18520 container, 18521 defaultViewport 18522 } = options; 18523 this.renderingId = "page" + this.id; 18524 this.#layerProperties = options.layerProperties || DEFAULT_LAYER_PROPERTIES; 18525 this.pdfPage = null; 18526 this.pageLabel = null; 18527 this.rotation = 0; 18528 this.scale = options.scale || DEFAULT_SCALE; 18529 this.viewport = defaultViewport; 18530 this.pdfPageRotate = defaultViewport.rotation; 18531 this._optionalContentConfigPromise = options.optionalContentConfigPromise || null; 18532 this.#textLayerMode = options.textLayerMode ?? TextLayerMode.ENABLE; 18533 this.#annotationMode = options.annotationMode ?? AnnotationMode.ENABLE_FORMS; 18534 this.imageResourcesPath = options.imageResourcesPath || ""; 18535 this.enableDetailCanvas = options.enableDetailCanvas ?? true; 18536 this.maxCanvasPixels = options.maxCanvasPixels ?? AppOptions.get("maxCanvasPixels"); 18537 this.maxCanvasDim = options.maxCanvasDim || AppOptions.get("maxCanvasDim"); 18538 this.capCanvasAreaFactor = options.capCanvasAreaFactor ?? AppOptions.get("capCanvasAreaFactor"); 18539 this.#enableAutoLinking = options.enableAutoLinking !== false; 18540 this.#commentManager = options.commentManager || null; 18541 this.#clonedFrom = options.clonedFrom || null; 18542 this.l10n = options.l10n; 18543 this.l10n ||= new genericl10n_GenericL10n(); 18544 this._isStandalone = !this.renderingQueue?.hasViewer(); 18545 this._container = container; 18546 this._annotationCanvasMap = null; 18547 this.annotationLayer = null; 18548 this.annotationEditorLayer = null; 18549 this.textLayer = null; 18550 this.xfaLayer = null; 18551 this.structTreeLayer = null; 18552 this.drawLayer = null; 18553 this.detailView = null; 18554 const div = document.createElement("div"); 18555 div.className = "page"; 18556 div.setAttribute("data-page-number", this.id); 18557 div.setAttribute("role", "region"); 18558 div.setAttribute("data-l10n-id", "pdfjs-page-landmark"); 18559 div.setAttribute("data-l10n-args", JSON.stringify({ 18560 page: this.id 18561 })); 18562 this.div = div; 18563 this.#setDimensions(); 18564 container?.append(div); 18565 if (this._isStandalone) { 18566 container?.style.setProperty("--scale-factor", this.scale * PixelsPerInch.PDF_TO_CSS_UNITS); 18567 if (this.pageColors?.background) { 18568 container?.style.setProperty("--page-bg-color", this.pageColors.background); 18569 } 18570 const { 18571 optionalContentConfigPromise 18572 } = options; 18573 if (optionalContentConfigPromise) { 18574 optionalContentConfigPromise.then(optionalContentConfig => { 18575 if (optionalContentConfigPromise !== this._optionalContentConfigPromise) { 18576 return; 18577 } 18578 this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility; 18579 }); 18580 } 18581 if (!options.l10n) { 18582 this.l10n.translate(this.div); 18583 } 18584 } 18585 } 18586 clone(id) { 18587 const clone = new PDFPageView({ 18588 container: null, 18589 eventBus: this.eventBus, 18590 pagesColors: this.pageColors, 18591 renderingQueue: this.renderingQueue, 18592 enableOptimizedPartialRendering: this.enableOptimizedPartialRendering, 18593 minDurationToUpdateCanvas: this.minDurationToUpdateCanvas, 18594 defaultViewport: this.viewport, 18595 id, 18596 layerProperties: this.#layerProperties, 18597 scale: this.scale, 18598 optionalContentConfigPromise: this._optionalContentConfigPromise, 18599 textLayerMode: this.#textLayerMode, 18600 annotationMode: this.#annotationMode, 18601 imageResourcesPath: this.imageResourcesPath, 18602 enableDetailCanvas: this.enableDetailCanvas, 18603 maxCanvasPixels: this.maxCanvasPixels, 18604 maxCanvasDim: this.maxCanvasDim, 18605 capCanvasAreaFactor: this.capCanvasAreaFactor, 18606 enableAutoLinking: this.#enableAutoLinking, 18607 commentManager: this.#commentManager, 18608 l10n: this.l10n, 18609 clonedFrom: this 18610 }); 18611 clone.setPdfPage(this.pdfPage); 18612 return clone; 18613 } 18614 #addLayer(div, name) { 18615 const pos = LAYERS_ORDER.get(name); 18616 const oldDiv = this.#layers[pos]; 18617 this.#layers[pos] = div; 18618 if (oldDiv) { 18619 oldDiv.replaceWith(div); 18620 return; 18621 } 18622 for (let i = pos - 1; i >= 0; i--) { 18623 const layer = this.#layers[i]; 18624 if (layer) { 18625 layer.after(div); 18626 return; 18627 } 18628 } 18629 this.div.prepend(div); 18630 } 18631 #setDimensions() { 18632 const { 18633 div, 18634 viewport 18635 } = this; 18636 if (viewport.userUnit !== this.#userUnit) { 18637 if (viewport.userUnit !== 1) { 18638 div.style.setProperty("--user-unit", viewport.userUnit); 18639 } else { 18640 div.style.removeProperty("--user-unit"); 18641 } 18642 this.#userUnit = viewport.userUnit; 18643 } 18644 if (this.pdfPage) { 18645 if (this.#previousRotation === viewport.rotation) { 18646 return; 18647 } 18648 this.#previousRotation = viewport.rotation; 18649 } 18650 setLayerDimensions(div, viewport, true, false); 18651 } 18652 updatePageNumber(newPageNumber) { 18653 if (this.id === newPageNumber) { 18654 return; 18655 } 18656 this.id = newPageNumber; 18657 this.renderingId = `page${newPageNumber}`; 18658 if (this.pdfPage) { 18659 this.pdfPage.pageNumber = newPageNumber; 18660 } 18661 this.setPageLabel(this.pageLabel); 18662 const { 18663 div 18664 } = this; 18665 div.setAttribute("data-page-number", newPageNumber); 18666 div.setAttribute("data-l10n-args", JSON.stringify({ 18667 page: newPageNumber 18668 })); 18669 this._textHighlighter.pageIdx = newPageNumber - 1; 18670 this.annotationEditorLayer?.updatePageIndex(newPageNumber - 1); 18671 } 18672 setPdfPage(pdfPage) { 18673 if (this._isStandalone && (this.pageColors?.foreground === "CanvasText" || this.pageColors?.background === "Canvas")) { 18674 this._container?.style.setProperty("--hcm-highlight-filter", pdfPage.filterFactory.addHighlightHCMFilter("highlight", "CanvasText", "Canvas", "HighlightText", "Highlight")); 18675 this._container?.style.setProperty("--hcm-highlight-selected-filter", pdfPage.filterFactory.addHighlightHCMFilter("highlight_selected", "CanvasText", "Canvas", "HighlightText", "Highlight")); 18676 } 18677 this.pdfPage = pdfPage; 18678 this.pdfPageRotate = pdfPage.rotate; 18679 const totalRotation = (this.rotation + this.pdfPageRotate) % 360; 18680 this.viewport = pdfPage.getViewport({ 18681 scale: this.scale * PixelsPerInch.PDF_TO_CSS_UNITS, 18682 rotation: totalRotation 18683 }); 18684 this.#setDimensions(); 18685 this.reset(); 18686 } 18687 destroy() { 18688 this.reset(); 18689 this.pdfPage?.cleanup(); 18690 } 18691 deleteMe(isCut) { 18692 if (isCut) { 18693 this.div.remove(); 18694 return; 18695 } 18696 this.destroy(); 18697 this.#layerProperties.annotationEditorUIManager?.deletePage(this.id
18697); 18698 } 18699 hasEditableAnnotations() { 18700 return !!this.annotationLayer?.hasEditableAnnotations(); 18701 } 18702 get _textHighlighter() { 18703 return shadow(this, "_textHighlighter", new TextHighlighter({ 18704 pageIndex: this.id - 1, 18705 eventBus: this.eventBus, 18706 findController: this.#layerProperties.findController 18707 })); 18708 } 18709 #dispatchLayerRendered(name, error) { 18710 this.eventBus.dispatch(name, { 18711 source: this, 18712 pageNumber: this.id, 18713 error 18714 }); 18715 } 18716 async #renderAnnotationLayer() { 18717 let error = null; 18718 try { 18719 await this.annotationLayer.render({ 18720 viewport: this.viewport, 18721 intent: "display", 18722 structTreeLayer: this.structTreeLayer 18723 }); 18724 } catch (ex) { 18725 console.error("#renderAnnotationLayer:", ex); 18726 error = ex; 18727 } finally { 18728 this.#dispatchLayerRendered("annotationlayerrendered", error); 18729 } 18730 } 18731 async #renderAnnotationEditorLayer() { 18732 let error = null; 18733 try { 18734 await this.annotationEditorLayer.render({ 18735 viewport: this.viewport, 18736 intent: "display" 18737 }); 18738 } catch (ex) { 18739 console.error("#renderAnnotationEditorLayer:", ex); 18740 error = ex; 18741 } finally { 18742 this.#dispatchLayerRendered("annotationeditorlayerrendered", error); 18743 } 18744 } 18745 async #renderDrawLayer() { 18746 try { 18747 await this.drawLayer.render({ 18748 intent: "display" 18749 }); 18750 } catch (ex) { 18751 console.error("#renderDrawLayer:", ex); 18752 } 18753 } 18754 async #renderXfaLayer() { 18755 let error = null; 18756 try { 18757 const result = await this.xfaLayer.render({ 18758 viewport: this.viewport, 18759 intent: "display" 18760 }); 18761 if (result?.textDivs && this._textHighlighter) { 18762 this.#buildXfaTextContentItems(result.textDivs); 18763 } 18764 } catch (ex) { 18765 console.error("#renderXfaLayer:", ex); 18766 error = ex; 18767 } finally { 18768 if (this.xfaLayer?.div) { 18769 this.l10n.pause(); 18770 this.#addLayer(this.xfaLayer.div, "xfaLayer"); 18771 this.l10n.resume(); 18772 } 18773 this.#dispatchLayerRendered("xfalayerrendered", error); 18774 } 18775 } 18776 async #renderTextLayer() { 18777 if (!this.textLayer) { 18778 return; 18779 } 18780 let error = null; 18781 try { 18782 await this.textLayer.render({ 18783 viewport: this.viewport 18784 }); 18785 } catch (ex) { 18786 if (ex instanceof AbortException) { 18787 return; 18788 } 18789 console.error("#renderTextLayer:", ex); 18790 error = ex; 18791 } 18792 this.#dispatchLayerRendered("textlayerrendered", error); 18793 this.#renderStructTreeLayer(); 18794 } 18795 async #renderStructTreeLayer() { 18796 if (!this.textLayer) { 18797 return; 18798 } 18799 const treeDom = await this.structTreeLayer?.render(); 18800 if (treeDom) { 18801 this.l10n.pause(); 18802 this.structTreeLayer?.updateTextLayer(); 18803 if (this.canvas && treeDom.parentNode !== this.canvas) { 18804 this.canvas.append(treeDom); 18805 } 18806 this.l10n.resume(); 18807 } 18808 this.structTreeLayer?.show(); 18809 } 18810 async #buildXfaTextContentItems(textDivs) { 18811 const text = await this.pdfPage.getTextContent(); 18812 const items = []; 18813 for (const item of text.items) { 18814 items.push(item.str); 18815 } 18816 this._textHighlighter.setTextMapping(textDivs, items); 18817 this._textHighlighter.enable(); 18818 } 18819 async #injectLinkAnnotations(textLayerPromise) { 18820 let error = null; 18821 try { 18822 await textLayerPromise; 18823 if (!this.annotationLayer) { 18824 return; 18825 } 18826 await this.annotationLayer.injectLinkAnnotations(Autolinker.processLinks(this)); 18827 } catch (ex) { 18828 console.error("#injectLinkAnnotations:", ex); 18829 error = ex; 18830 } 18831 } 18832 _resetCanvas() { 18833 super._resetCanvas(); 18834 this.#originalViewport = null; 18835 } 18836 reset({ 18837 keepAnnotationLayer = false, 18838 keepAnnotationEditorLayer = false, 18839 keepXfaLayer = false, 18840 keepTextLayer = false, 18841 keepCanvasWrapper = false, 18842 preserveDetailViewState = false 18843 } = {}) { 18844 const keepPdfBugGroups = this.pdfPage?._pdfBug ?? false; 18845 this.cancelRendering({ 18846 keepAnnotationLayer, 18847 keepAnnotationEditorLayer, 18848 keepXfaLayer, 18849 keepTextLayer 18850 }); 18851 this.renderingState = RenderingStates.INITIAL; 18852 const div = this.div; 18853 const childNodes = div.childNodes, 18854 annotationLayerNode = keepAnnotationLayer && this.annotationLayer?.div || null, 18855 annotationEditorLayerNode = keepAnnotationEditorLayer && this.annotationEditorLayer?.div || null, 18856 xfaLayerNode = keepXfaLayer && this.xfaLayer?.div || null, 18857 textLayerNode = keepTextLayer && this.textLayer?.div || null, 18858 canvasWrapperNode = keepCanvasWrapper && this.#canvasWrapper || null; 18859 for (let i = childNodes.length - 1; i >= 0; i--) { 18860 const node = childNodes[i]; 18861 switch (node) { 18862 case annotationLayerNode: 18863 case annotationEditorLayerNode: 18864 case xfaLayerNode: 18865 case textLayerNode: 18866 case canvasWrapperNode: 18867 continue; 18868 } 18869 if (keepPdfBugGroups && node.classList.contains("pdfBugGroupsLayer")) { 18870 continue; 18871 } 18872 node.remove(); 18873 const layerIndex = this.#layers.indexOf(node); 18874 if (layerIndex >= 0) { 18875 this.#layers[layerIndex] = null; 18876 } 18877 } 18878 div.removeAttribute("data-loaded"); 18879 if (annotationLayerNode) { 18880 this.annotationLayer.hide(); 18881 } 18882 if (annotationEditorLayerNode) { 18883 this.annotationEditorLayer.hide(); 18884 } 18885 if (xfaLayerNode) { 18886 this.xfaLayer.hide(); 18887 } 18888 if (textLayerNode) { 18889 this.textLayer.hide(); 18890 } 18891 this.structTreeLayer?.hide(); 18892 if (!keepCanvasWrapper && this.#canvasWrapper) { 18893 this.#canvasWrapper = null; 18894 this._resetCanvas(); 18895 }
18896 if (!preserveDetailViewState) { 18897 this.detailView?.reset({ 18898 keepCanvas: keepCanvasWrapper 18899 }); 18900 if (!keepCanvasWrapper) { 18901 this.detailView = null; 18902 } 18903 } 18904 } 18905 toggleEditingMode(isEditing) { 18906 this.#isEditing = isEditing; 18907 if (!this.hasEditableAnnotations()) { 18908 return; 18909 } 18910 this.reset({ 18911 keepAnnotationLayer: true, 18912 keepAnnotationEditorLayer: true, 18913 keepXfaLayer: true, 18914 keepTextLayer: true, 18915 keepCanvasWrapper: true 18916 }); 18917 } 18918 updateVisibleArea(visibleArea) { 18919 if (this.enableDetailCanvas) { 18920 if (this.#needsRestrictedScaling && this.maxCanvasPixels > 0 && visibleArea) { 18921 this.detailView ??= new PDFPageDetailView({ 18922 pageView: this, 18923 enableOptimizedPartialRendering: this.enableOptimizedPartialRendering 18924 }); 18925 this.detailView.update({ 18926 visibleArea 18927 }); 18928 } else if (this.detailView) { 18929 this.detailView.reset(); 18930 this.detailView = null; 18931 } 18932 } 18933 } 18934 update({ 18935 scale = 0, 18936 rotation = null, 18937 optionalContentConfigPromise = null, 18938 drawingDelay = -1 18939 }) { 18940 this.scale = scale || this.scale; 18941 if (typeof rotation === "number") { 18942 this.rotation = rotation; 18943 } 18944 if (optionalContentConfigPromise instanceof Promise) { 18945 this._optionalContentConfigPromise = optionalContentConfigPromise; 18946 optionalContentConfigPromise.then(optionalContentConfig => { 18947 if (optionalContentConfigPromise !== this._optionalContentConfigPromise) { 18948 return; 18949 } 18950 this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility; 18951 }); 18952 } 18953 this.#useThumbnailCanvas.directDrawing = true; 18954 const totalRotation = (this.rotation + this.pdfPageRotate) % 360; 18955 this.viewport = this.viewport.clone({ 18956 scale: this.scale * PixelsPerInch.PDF_TO_CSS_UNITS, 18957 rotation: totalRotation 18958 }); 18959 this.#setDimensions(); 18960 if (this._isStandalone) { 18961 this._container?.style.setProperty("--scale-factor", this.viewport.scale); 18962 } 18963 this.#computeScale(); 18964 if (this.canvas) { 18965 const onlyCssZoom = this.#hasRestrictedScaling && this.#needsRestrictedScaling; 18966 const postponeDrawing = drawingDelay >= 0 && drawingDelay < 1000; 18967 if (postponeDrawing || onlyCssZoom) { 18968 if (postponeDrawing && !onlyCssZoom && this.renderingState !== RenderingStates.FINISHED) { 18969 this.cancelRendering({ 18970 keepAnnotationLayer: true, 18971 keepAnnotationEditorLayer: true, 18972 keepXfaLayer: true, 18973 keepTextLayer: true, 18974 cancelExtraDelay: drawingDelay 18975 }); 18976 this.renderingState = RenderingStates.FINISHED; 18977 this.#useThumbnailCanvas.directDrawing = false; 18978 } 18979 this.cssTransform({ 18980 redrawAnnotationLayer: true, 18981 redrawAnnotationEditorLayer: true, 18982 redrawXfaLayer: true, 18983 redrawTextLayer: !postponeDrawing, 18984 hideTextLayer: postponeDrawing 18985 }); 18986 if (!postponeDrawing) { 18987 this.detailView?.update({ 18988 underlyingViewUpdated: true 18989 }); 18990 this.dispatchPageRendered(true, false); 18991 } 18992 return; 18993 } 18994 } 18995 this.cssTransform({}); 18996 this.reset({ 18997 keepAnnotationLayer: true, 18998 keepAnnotationEditorLayer: true, 18999 keepXfaLayer: true, 19000 keepTextLayer: true, 19001 keepCanvasWrapper: true, 19002 preserveDetailViewState: true 19003 }); 19004 this.detailView?.update({ 19005 underlyingViewUpdated: true 19006 }); 19007 } 19008 #computeScale() { 19009 const { 19010 width, 19011 height 19012 } = this.viewport; 19013 const outputScale = this.outputScale = new OutputScale(); 19014 if (this.maxCanvasPixels === 0) { 19015 const invScale = 1 / this.scale; 19016 outputScale.sx *= invScale; 19017 outputScale.sy *= invScale; 19018 this.#needsRestrictedScaling = true; 19019 } else { 19020 this.#needsRestrictedScaling = outputScale.limitCanvas(width, height, this.maxCanvasPixels, this.maxCanvasDim, this.capCanvasAreaFactor); 19021 if (this.#needsRestrictedScaling && this.enableDetailCanvas) { 19022 const factor = this.enableOptimizedPartialRendering ? 4 : 2; 19023 outputScale.sx /= factor; 19024 outputScale.sy /= factor; 19025 } 19026 } 19027 } 19028 cancelRendering({ 19029 keepAnnotationLayer = false, 19030 keepAnnotationEditorLayer = false, 19031 keepXfaLayer = false, 19032 keepTextLayer = false, 19033 cancelExtraDelay = 0 19034 } = {}) { 19035 super.cancelRendering({ 19036 cancelExtraDelay 19037 }); 19038 if (this.textLayer && (!keepTextLayer || !this.textLayer.div)) { 19039 this.textLayer.cancel(); 19040 this.textLayer = null; 19041 } 19042 if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer.div)) { 19043 this.annotationLayer.cancel(); 19044 this.annotationLayer = null; 19045 this._annotationCanvasMap = null; 19046 } 19047 if (this.structTreeLayer && !this.textLayer) { 19048 this.structTreeLayer = null; 19049 } 19050 if (this.annotationEditorLayer && (!keepAnnotationEditorLayer || !this.annotationEditorLayer.div)) { 19051 if (this.drawLayer) { 19052 this.drawLayer.cancel(); 19053 this.drawLayer = null; 19054 } 19055 this.annotationEditorLayer.cancel(); 19056 this.annotationEditorLayer = null; 19057 } 19058 if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer.div)) { 19059 this.xfaLayer.cancel(); 19060 this.xfaLayer = null; 19061 this._textHighlighter?.disable(); 19062 } 19063 } 19064 cssTransform({ 19065 redrawAnnotationLayer = false, 19066 redrawAnnotationEditorLayer = false, 19067 redrawXfaLayer = false, 19068 redrawTextLayer = false, 19069 hideTextLayer = false 19070 }) { 19071 const { 19072 canvas 19073 } = this; 19074 if (!canvas) { 19075 return; 19076 } 19077 const originalViewport = this.#originalViewport; 19078 if (this.viewport !== originalViewport) { 19079 const relativeRotation = (360 + this.viewport.rotation - originalViewport.rotation) % 360; 19080 if (relativeRotation === 90 || relativeRotation === 270) { 19081 const { 19082 width, 19083 height 19084 } = this.viewport; 19085 const scaleX = height / width; 19086 const scaleY = width / height; 19087 canvas.style.transform = `rotate(${relativeRotation}deg) scale(${scaleX},${scaleY})`; 19088 } else { 19089 canvas.style.transform = relativeRotation === 0 ? "" : `rotate(${relativeRotation}deg)`; 19090 } 19091 } 19092 if (redrawAnnotationLayer && this.annotationLayer) { 19093 this.#renderAnnotationLayer(); 19094 } 19095 if (redrawAnnotationEditorLayer && this.annotationEditorLayer) { 19096 if (this.drawLayer) { 19097 this.#renderDrawLayer(); 19098 } 19099 this.#renderAnnotationEditorLayer(); 19100 } 19101 if (redrawXfaLayer && this.xfaLayer) { 19102 this.#renderXfaLayer(); 19103 } 19104 if (this.textLayer) { 19105 if (hideTextLayer) { 19106 this.textLayer.hide(); 19107 this.structTreeLayer?.hide(); 19108 } else if (redrawTextLayer) { 19109 this.#renderTextLayer(); 19110 } 19111 } 19112 } 19113 get width() { 19114 return this.viewport.width; 19115 } 19116 get height() { 19117 return this.viewport.height; 19118 } 19119 getPagePoint(x, y) { 19120 return this.viewport.convertToPdfPoint(x, y); 19121 } 19122 _ensureCanvasWrapper() {
19123 let canvasWrapper = this.#canvasWrapper; 19124 if (!canvasWrapper) { 19125 canvasWrapper = this.#canvasWrapper = document.createElement("div"); 19126 canvasWrapper.classList.add("canvasWrapper"); 19127 this.#addLayer(canvasWrapper, "canvasWrapper"); 19128 } 19129 return canvasWrapper; 19130 } 19131 _getRenderingContext(canvas, transform, recordOperations) { 19132 return { 19133 canvas, 19134 transform, 19135 viewport: this.viewport, 19136 annotationMode: this.#annotationMode, 19137 optionalContentConfigPromise: this._optionalContentConfigPromise, 19138 annotationCanvasMap: this._annotationCanvasMap, 19139 pageColors: this.pageColors, 19140 isEditing: this.#isEditing, 19141 recordOperations 19142 }; 19143 } 19144 async draw() { 19145 if (this.renderingState !== RenderingStates.INITIAL) { 19146 console.error("Must be in new state before drawing"); 19147 this.reset(); 19148 } 19149 const { 19150 div, 19151 l10n, 19152 pdfPage, 19153 viewport 19154 } = this; 19155 if (!pdfPage) { 19156 this.renderingState = RenderingStates.FINISHED; 19157 throw new Error("pdfPage is not loaded"); 19158 } 19159 this.renderingState = RenderingStates.RUNNING; 19160 const canvasWrapper = this._ensureCanvasWrapper(); 19161 if (!this.textLayer && this.#textLayerMode !== TextLayerMode.DISABLE && !pdfPage.isPureXfa) { 19162 this._accessibilityManager ||= new TextAccessibilityManager(); 19163 this.textLayer = new TextLayerBuilder({ 19164 pdfPage, 19165 highlighter: this._textHighlighter, 19166 accessibilityManager: this._accessibilityManager, 19167 enablePermissions: this.#textLayerMode === TextLayerMode.ENABLE_PERMISSIONS, 19168 onAppend: textLayerDiv => { 19169 this.l10n.pause(); 19170 this.#addLayer(textLayerDiv, "textLayer"); 19171 this.l10n.resume(); 19172 } 19173 }); 19174 } 19175 if (!this.annotationLayer && this.#annotationMode !== AnnotationMode.DISABLE) { 19176 const { 19177 annotationStorage, 19178 annotationEditorUIManager, 19179 downloadManager, 19180 enableComment, 19181 enableScripting, 19182 fieldObjectsPromise, 19183 hasJSActionsPromise, 19184 linkService 19185 } = this.#layerProperties; 19186 this._annotationCanvasMap ||= new Map(); 19187 this.annotationLayer = new AnnotationLayerBuilder({ 19188 pdfPage, 19189 annotationStorage, 19190 imageResourcesPath: this.imageResourcesPath, 19191 renderForms: this.#annotationMode === AnnotationMode.ENABLE_FORMS, 19192 linkService, 19193 downloadManager, 19194 enableComment, 19195 enableScripting, 19196 hasJSActionsPromise, 19197 fieldObjectsPromise, 19198 annotationCanvasMap: this._annotationCanvasMap, 19199 accessibilityManager: this._accessibilityManager, 19200 annotationEditorUIManager, 19201 commentManager: this.#commentManager, 19202 onAppend: annotationLayerDiv => { 19203 this.#addLayer(annotationLayerDiv, "annotationLayer"); 19204 } 19205 }); 19206 } 19207 const { 19208 width, 19209 height 19210 } = viewport; 19211 this.#originalViewport = viewport; 19212 const { 19213 canvas, 19214 prevCanvas 19215 } = this._createCanvas(newCanvas => { 19216 canvasWrapper.prepend(newCanvas); 19217 }); 19218 canvas.setAttribute("role", "presentation"); 19219 if (!this.outputScale) { 19220 this.#computeScale(); 19221 } 19222 const { 19223 outputScale 19224 } = this; 19225 this.#hasRestrictedScaling = this.#needsRestrictedScaling; 19226 const sfx = approximateFraction(outputScale.sx); 19227 const sfy = approximateFraction(outputScale.sy); 19228 const canvasWidth = canvas.width = floorToDivide(calcRound(width * outputScale.sx), sfx[0]); 19229 const canvasHeight = canvas.height = floorToDivide(calcRound(height * outputScale.sy), sfy[0]); 19230 const pageWidth = floorToDivide(calcRound(width), sfx[1]); 19231 const pageHeight = floorToDivide(calcRound(height), sfy[1]); 19232 outputScale.sx = canvasWidth / pageWidth; 19233 outputScale.sy = canvasHeight / pageHeight; 19234 if (this.#scaleRoundX !== sfx[1]) { 19235 div.style.setProperty("--scale-round-x", `${sfx[1]}px`); 19236 this.#scaleRoundX = sfx[1]; 19237 } 19238 if (this.#scaleRoundY !== sfy[1]) { 19239 div.style.setProperty("--scale-round-y", `${sfy[1]}px`); 19240 this.#scaleRoundY = sfy[1]; 19241 } 19242 const recordBBoxes = this.enableOptimizedPartialRendering && this.#hasRestrictedScaling && !this.recordedBBoxes; 19243 const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null; 19244 const resultPromise = this._drawCanvas(this._getRenderingContext(canvas, transform, recordBBoxes), () => { 19245 prevCanvas?.remove(); 19246 this._resetCanvas(); 19247 }, renderTask => { 19248 this.#useThumbnailCanvas.regularAnnotations = !renderTask.separateAnnots; 19249 this.dispatchPageRendered(false, false); 19250 }).then(async () => { 19251 if (this.renderingState !== RenderingStates.FINISHED) { 19252 return; 19253 } 19254 this.structTreeLayer ||= new StructTreeLayerBuilder(pdfPage, viewport.rawDims); 19255 const textLayerPromise = this.#renderTextLayer(); 19256 if (this.annotationLayer) { 19257 await this.#renderAnnotationLayer(); 19258 if (this.#enableAutoLinking && this.annotationLayer && this.textLayer) { 19259 await this.#injectLinkAnnotations(textLayerPromise); 19260 } 19261 } 19262 const { 19263 annotationEditorUIManager 19264 } = this.#layerProperties; 19265 if (!annotationEditorUIManager) { 19266 return; 19267 } 19268 this.drawLayer ||= new DrawLayerBuilder(); 19269 await this.#renderDrawLayer(); 19270 this.drawLayer.setParent(canvasWrapper); 19271 if (this.annotationLayer || this.#annotationMode === AnnotationMode.DISABLE) { 19272 this.annotationEditorLayer ||= new AnnotationEditorLayerBuilder({ 19273 uiManager: annotationEditorUIManager, 19274 pageIndex: this.id - 1, 19275 l10n, 19276 structTreeLayer: this.structTreeLayer, 19277 accessibilityManager: this._accessibilityManager, 19278 annotationLayer: this.annotationLayer?.annotationLayer, 19279 textLayer: this.textLayer, 19280 drawLayer: this.drawLayer.getDrawLayer(), 19281 clonedFrom: this.#clonedFrom?.annotationEditorLayer, 19282 onAppend: annotationEditorLayerDiv => { 19283 this.#addLayer(annotationEditorLayerDiv, "annotationEditorLayer"); 19284 } 19285 }); 19286 this.#clonedFrom = null; 19287 this.#renderAnnotationEditorLayer(); 19288 } 19289 }); 19290 if (pdfPage.isPureXfa) { 19291 if (!this.xfaLayer) { 19292 const { 19293 annotationStorage, 19294 linkService 19295 } = this.#layerProperties; 19296 this.xfaLayer = new XfaLayerBuilder({ 19297 pdfPage, 19298 annotationStorage, 19299 linkService 19300 }); 19301 } 19302 this.#renderXfaLayer(); 19303 } 19304 div.setAttribute("data-loaded", true); 19305 this.dispatchPageRender(); 19306 return resultPromise; 19307 } 19308 setPageLabel(label) { 19309 this.pageLabel = typeof label === "string" ? label : null; 19310 this.div.setAttribute("data-l10n-args", JSON.stringify({ 19311 page: this.pageLabel ?? this.id 19312 })); 19313 if (this.pageLabel !== null) { 19314 this.div.setAttribute("data-page-label", this.pageLabel); 19315 } else { 19316 this.div.removeAttribute("data-page-label"); 19317 } 19318 } 19319 get thumbnailCanvas() { 19320 const { 19321 directDrawing, 19322 initialOptionalContent, 19323 regularAnnotations 19324 } = this.#useThumbnailCanvas; 19325 return directDrawing && initialOptionalContent && regularAnnotations ? this.canvas : null; 19326 } 19327} 19328 19329;// ./web/pdf_viewer.js 19330 19331 19332 19333 19334 19335 19336 19337 19338 19339 19340 19341 19342 19343 19344 19345 19346 19347 19348 19349 19350 19351 19352const DEFAULT_CACHE_SIZE = 10; 19353const PagesCountLimit = { 19354 FORCE_SCROLL_MODE_PAGE: 10000, 19355 FORCE_LAZY_PAGE_INIT: 5000, 19356 PAUSE_EAGER_PAGE_INIT: 250 19357}; 19358function isValidAnnotationEditorMode(mode) { 19359 return Object.values(AnnotationEditorType).includes(mode) && mode !== AnnotationEditorType.DISABLE; 19360} 19361class PDFPageViewBuffer { 19362 #buf = new Set(); 19363 #size = 0; 19364 constructor(size) { 19365 this.#size = size; 19366 } 19367 push(view) { 19368 const buf = this.#buf; 19369 if (buf.has(view)) { 19370 buf.delete(view); 19371 } 19372 buf.add(view); 19373 if (buf.size > this.#size) { 19374 this.#destroyFirstView(); 19375 } 19376 } 19377 resize(newSize, idsToKeep = null) { 19378 this.#size = newSize; 19379 const buf = this.#buf; 19380 if (idsToKeep) { 19381 const ii = buf.size; 19382 let i = 1; 19383 for (const view of buf) { 19384 if (idsToKeep.has(view.id)) { 19385 buf.delete(view); 19386 buf.add(view); 19387 } 19388 if (++i > ii) { 19389 break; 19390 } 19391 } 19392 } 19393 while (buf.size > this.#size) { 19394 this.#destroyFirstView(); 19395 } 19396 } 19397 has(view) { 19398 return this.#buf.has(view); 19399 } 19400 [Symbol.iterator]() { 19401 return this.#buf.keys(); 19402 } 19403 #destroyFirstView() { 19404 const firstView = this.#buf.keys().next().value; 19405 firstView?.destroy(); 19406 this.#buf.delete(firstView); 19407 } 19408} 19409class PDFViewer { 19410 #buffer = null; 19411 #altTextManager = null; 19412 #annotationEditorHighlightColors = null; 19413 #annotationEditorMode = AnnotationEditorType.NONE; 19414 #annotationEditorUIManager = null; 19415 #annotationMode = AnnotationMode.ENABLE_FORMS; 19416 #commentManager = null; 19417 #containerTopLeft = null; 19418 #editorUndoBar = null; 19419 #enableHWA = false;
19420 #enableHighlightFloatingButton = false; 19421 #enablePermissions = false; 19422 #enableUpdatedAddImage = false; 19423 #enableNewAltTextWhenAddingImage = false; 19424 #enableAutoLinking = true; 19425 #eventAbortController = null; 19426 #minDurationToUpdateCanvas = 0; 19427 #mlManager = null; 19428 #printingAllowed = true; 19429 #scrollTimeoutId = null; 19430 #switchAnnotationEditorModeAC = null; 19431 #switchAnnotationEditorModeTimeoutId = null; 19432 #getAllTextInProgress = false; 19433 #hiddenCopyElement = null; 19434 #interruptCopyCondition = false; 19435 #previousContainerHeight = 0; 19436 #resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this)); 19437 #scrollModePageState = null; 19438 #scaleTimeoutId = null; 19439 #signatureManager = null; 19440 #supportsPinchToZoom = true; 19441 #textLayerMode = TextLayerMode.ENABLE; 19442 #viewerAlert = null; 19443 #copiedPageViews = null; 19444 constructor(options) { 19445 const viewerVersion = "5.5.207"; 19446 if (version !== viewerVersion) { 19447 throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`); 19448 } 19449 this.container = options.container; 19450 this.viewer = options.viewer || options.container.firstElementChild; 19451 this.#viewerAlert = options.viewerAlert || null; 19452 if (this.container?.tagName !== "DIV" || this.viewer?.tagName !== "DIV") { 19453 throw new Error("Invalid `container` and/or `viewer` option."); 19454 } 19455 if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") { 19456 throw new Error("The `container` must be absolutely positioned."); 19457 } 19458 this.#resizeObserver.observe(this.container); 19459 this.eventBus = options.eventBus; 19460 this.linkService = options.linkService || new SimpleLinkService(); 19461 this.downloadManager = options.downloadManager || null; 19462 this.findController = options.findController || null; 19463 this.#altTextManager = options.altTextManager || null; 19464 this.#commentManager = options.commentManager || null; 19465 this.#signatureManager = options.signatureManager || null; 19466 this.#editorUndoBar = options.editorUndoBar || null; 19467 if (this.findController) { 19468 this.findController.onIsPageVisible = pageNumber => this._getVisiblePages().ids.has(pageNumber); 19469 } 19470 this._scriptingManager = options.scriptingManager || null; 19471 this.#textLayerMode = options.textLayerMode ?? TextLayerMode.ENABLE; 19472 this.#annotationMode = options.annotationMode ?? AnnotationMode.ENABLE_FORMS; 19473 this.#annotationEditorMode = options.annotationEditorMode ?? AnnotationEditorType.NONE; 19474 this.#annotationEditorHighlightColors = options.annotationEditorHighlightColors || null; 19475 this.#enableHighlightFloatingButton = options.enableHighlightFloatingButton === true; 19476 this.#enableUpdatedAddImage = options.enableUpdatedAddImage === true; 19477 this.#enableNewAltTextWhenAddingImage = options.enableNewAltTextWhenAddingImage === true; 19478 this.imageResourcesPath = options.imageResourcesPath || ""; 19479 this.enablePrintAutoRotate = options.enablePrintAutoRotate || false; 19480 this.removePageBorders = options.removePageBorders || false; 19481 this.maxCanvasPixels = options.maxCanvasPixels; 19482 this.maxCanvasDim = options.maxCanvasDim; 19483 this.capCanvasAreaFactor = options.capCanvasAreaFactor; 19484 this.enableDetailCanvas = options.enableDetailCanvas ?? true; 19485 this.enableOptimizedPartialRendering = options.enableOptimizedPartialRendering ?? false; 19486 this.l10n = options.l10n; 19487 this.l10n ||= new genericl10n_GenericL10n(); 19488 this.#enablePermissions = options.enablePermissions || false; 19489 this.pageColors = options.pageColors || null; 19490 this.#mlManager = options.mlManager || null; 19491 this.#enableHWA = options.enableHWA || false; 19492 this.#supportsPinchToZoom = options.supportsPinchToZoom !== false; 19493 this.#enableAutoLinking = options.enableAutoLinking !== false; 19494 this.#minDurationToUpdateCanvas = options.minDurationToUpdateCanvas ?? 500; 19495 this.defaultRenderingQueue = !options.renderingQueue; 19496 if (this.defaultRenderingQueue) { 19497 this.renderingQueue = new PDFRenderingQueue(); 19498 this.renderingQueue.setViewer(this); 19499 } else { 19500 this.renderingQueue = options.renderingQueue; 19501 } 19502 const { 19503 abortSignal 19504 } = options; 19505 abortSignal?.addEventListener("abort", () => { 19506 this.#resizeObserver.disconnect(); 19507 this.#resizeObserver = null; 19508 }, {
19509 once: true 19510 }); 19511 this.scroll = watchScroll(this.container, this._scrollUpdate.bind(this), abortSignal); 19512 this.presentationModeState = PresentationModeState.UNKNOWN; 19513 this._resetView(); 19514 if (this.removePageBorders) { 19515 this.viewer.classList.add("removePageBorders"); 19516 } 19517 this.#updateContainerHeightCss(); 19518 this.eventBus._on("thumbnailrendered", ({ 19519 pageNumber, 19520 pdfPage 19521 }) => { 19522 const pageView = this._pages[pageNumber - 1]; 19523 if (!this.#buffer.has(pageView)) { 19524 pdfPage?.cleanup(); 19525 } 19526 }); 19527 if (!options.l10n) { 19528 this.l10n.translate(this.container); 19529 } 19530 } 19531 get printingAllowed() { 19532 return this.#printingAllowed; 19533 } 19534 get pagesCount() { 19535 return this._pages.length; 19536 } 19537 getPageView(index) { 19538 return this._pages[index]; 19539 } 19540 getCachedPageViews() { 19541 return new Set(this.#buffer); 19542 } 19543 get pageViewsReady() { 19544 return this._pages.every(pageView => pageView?.pdfPage); 19545 } 19546 get renderForms() { 19547 return this.#annotationMode === AnnotationMode.ENABLE_FORMS; 19548 } 19549 get enableScripting() { 19550 return !!this._scriptingManager; 19551 } 19552 get currentPageNumber() { 19553 return this._currentPageNumber; 19554 } 19555 set currentPageNumber(val) { 19556 if (!Number.isInteger(val)) { 19557 throw new Error("Invalid page number."); 19558 } 19559 if (!this.pdfDocument) { 19560 return; 19561 } 19562 if (!this._setCurrentPageNumber(val, true)) { 19563 console.error(`currentPageNumber: "${val}" is not a valid page.`); 19564 } 19565 } 19566 _setCurrentPageNumber(val, resetCurrentPageView = false) { 19567 if (this._currentPageNumber === val) { 19568 if (resetCurrentPageView) { 19569 this.#resetCurrentPageView(); 19570 } 19571 return true; 19572 } 19573 if (!(0 < val && val <= this.pagesCount)) { 19574 return false; 19575 } 19576 const previous = this._currentPageNumber; 19577 this._currentPageNumber = val; 19578 this.eventBus.dispatch("pagechanging", { 19579 source: this, 19580 pageNumber: val, 19581 pageLabel: this._pageLabels?.[val - 1] ?? null, 19582 previous 19583 }); 19584 if (resetCurrentPageView) { 19585 this.#resetCurrentPageView(); 19586 } 19587 return true; 19588 } 19589 get currentPageLabel() { 19590 return this._pageLabels?.[this._currentPageNumber - 1] ?? null; 19591 } 19592 set currentPageLabel(val) { 19593 if (!this.pdfDocument) { 19594 return; 19595 } 19596 let page = val | 0; 19597 if (this._pageLabels) { 19598 const i = this._pageLabels.indexOf(val); 19599 if (i >= 0) { 19600 page = i + 1; 19601 } 19602 } 19603 if (!this._setCurrentPageNumber(page, true)) { 19604 console.error(`currentPageLabel: "${val}" is not a valid page.`); 19605 } 19606 } 19607 get currentScale() { 19608 return this._currentScale !== UNKNOWN_SCALE ? this._currentScale : DEFAULT_SCALE; 19609 } 19610 set currentScale(val) { 19611 if (isNaN(val)) { 19612 throw new Error("Invalid numeric scale."); 19613 } 19614 if (!this.pdfDocument) { 19615 return; 19616 } 19617 this.#setScale(val, { 19618 noScroll: false 19619 }); 19620 } 19621 get currentScaleValue() { 19622 return this._currentScaleValue; 19623 } 19624 set currentScaleValue(val) { 19625 if (!this.pdfDocument) { 19626 return; 19627 } 19628 this.#setScale(val, { 19629 noScroll: false 19630 }); 19631 } 19632 get pagesRotation() { 19633 return this._pagesRotation; 19634 } 19635 set pagesRotation(rotation) { 19636 if (!isValidRotation(rotation)) { 19637 throw new Error("Invalid pages rotation angle."); 19638 } 19639 if (!this.pdfDocument) { 19640 return; 19641 } 19642 rotation %= 360; 19643 if (rotation < 0) { 19644 rotation += 360; 19645 } 19646 if (this._pagesRotation === rotation) { 19647 return; 19648 } 19649 this._pagesRotation = rotation; 19650 const pageNumber = this._currentPageNumber; 19651 this.refresh(true, { 19652 rotation 19653 }); 19654 if (this._currentScaleValue) { 19655 this.#setScale(this._currentScaleValue, { 19656 noScroll: true 19657 }); 19658 } 19659 this.eventBus.dispatch("rotationchanging", { 19660 source: this, 19661 pagesRotation: rotation, 19662 pageNumber 19663 }); 19664 if (this.defaultRenderingQueue) { 19665 this.update(); 19666 } 19667 } 19668 get firstPagePromise() { 19669 return this.pdfDocument ? this._firstPageCapability.promise : null; 19670 } 19671 get onePageRendered() { 19672 return this.pdfDocument ? this._onePageRenderedCapability.promise : null; 19673 } 19674 get pagesPromise() { 19675 return this.pdfDocument ? this._pagesCapability.promise : null; 19676 } 19677 get _layerProperties() { 19678 const self = this; 19679 return shadow(this, "_layerProperties", { 19680 get annotationEditorUIManager() { 19681 return self.#annotationEditorUIManager; 19682 }, 19683 get annotationStorage() { 19684 return self.pdfDocument?.annotationStorage; 19685 }, 19686 get downloadManager() { 19687 return self.downloadManager; 19688 }, 19689 get enableComment() { 19690 return !!self.#commentManager; 19691 }, 19692 get enableScripting() { 19693 return !!self._scriptingManager; 19694 }, 19695 get fieldObjectsPromise() { 19696 return self.pdfDocument?.getFieldObjects(); 19697 }, 19698 get findController() { 19699 return self.findController; 19700 },
19701 get hasJSActionsPromise() { 19702 return self.pdfDocument?.hasJSActions(); 19703 }, 19704 get linkService() { 19705 return self.linkService; 19706 } 19707 }); 19708 } 19709 #initializePermissions(permissions) { 19710 const params = { 19711 annotationEditorMode: this.#annotationEditorMode, 19712 annotationMode: this.#annotationMode, 19713 textLayerMode: this.#textLayerMode 19714 }; 19715 if (!permissions) { 19716 this.#printingAllowed = true; 19717 this.eventBus.dispatch("printingallowed", { 19718 source: this, 19719 isAllowed: this.#printingAllowed 19720 }); 19721 return params; 19722 } 19723 this.#printingAllowed = permissions.includes(PermissionFlag.PRINT_HIGH_QUALITY) || permissions.includes(PermissionFlag.PRINT); 19724 this.eventBus.dispatch("printingallowed", { 19725 source: this, 19726 isAllowed: this.#printingAllowed 19727 }); 19728 if (!permissions.includes(PermissionFlag.COPY) && this.#textLayerMode === TextLayerMode.ENABLE) { 19729 params.textLayerMode = TextLayerMode.ENABLE_PERMISSIONS; 19730 } 19731 if (!permissions.includes(PermissionFlag.MODIFY_CONTENTS)) { 19732 params.annotationEditorMode = AnnotationEditorType.DISABLE; 19733 } 19734 if (!permissions.includes(PermissionFlag.MODIFY_ANNOTATIONS) && !permissions.includes(PermissionFlag.FILL_INTERACTIVE_FORMS) && this.#annotationMode === AnnotationMode.ENABLE_FORMS) { 19735 params.annotationMode = AnnotationMode.ENABLE; 19736 } 19737 return params; 19738 } 19739 async #onePageRenderedOrForceFetch(signal) { 19740 if (document.visibilityState === "hidden" || !this.container.offsetParent || this._getVisiblePages().views.length === 0) { 19741 return; 19742 } 19743 const hiddenCapability = Promise.withResolvers(), 19744 ac = new AbortController(); 19745 document.addEventListener("visibilitychange", () => { 19746 if (document.visibilityState === "hidden") { 19747 hiddenCapability.resolve(); 19748 } 19749 }, { 19750 signal: AbortSignal.any([signal, ac.signal]) 19751 }); 19752 await Promise.race([this._onePageRenderedCapability.promise, hiddenCapability.promise]); 19753 ac.abort(); 19754 } 19755 async getAllText() { 19756 const texts = []; 19757 const buffer = []; 19758 for (let pageNum = 1, pagesCount = this.pdfDocument.numPages; pageNum <= pagesCount; ++pageNum) { 19759 if (this.#interruptCopyCondition) { 19760 return null; 19761 } 19762 buffer.length = 0; 19763 const page = await this.pdfDocument.getPage(pageNum); 19764 const { 19765 items 19766 } = await page.getTextContent(); 19767 for (const item of items) { 19768 if (item.str) { 19769 buffer.push(item.str); 19770 } 19771 if (item.hasEOL) { 19772 buffer.push("\n"); 19773 } 19774 } 19775 texts.push(removeNullCharacters(buffer.join(""))); 19776 } 19777 return texts.join("\n"); 19778 } 19779 #copyCallback(textLayerMode, event) { 19780 const selection = document.getSelection(); 19781 const { 19782 focusNode, 19783 anchorNode 19784 } = selection; 19785 if (anchorNode && focusNode && selection.containsNode(this.#hiddenCopyElement)) { 19786 if (this.#getAllTextInProgress || textLayerMode === TextLayerMode.ENABLE_PERMISSIONS) { 19787 stopEvent(event); 19788 return; 19789 } 19790 this.#getAllTextInProgress = true; 19791 const { 19792 classList 19793 } = this.viewer; 19794 classList.add("copyAll"); 19795 const ac = new AbortController(); 19796 window.addEventListener("keydown", ev => this.#interruptCopyCondition = ev.key === "Escape", { 19797 signal: ac.signal 19798 }); 19799 this.getAllText().then(async text => { 19800 if (text !== null) { 19801 await navigator.clipboard.writeText(text); 19802 } 19803 }).catch(reason => { 19804 console.warn(`Something goes wrong when extracting the text: ${reason.message}`); 19805 }).finally(() => { 19806 this.#getAllTextInProgress = false; 19807 this.#interruptCopyCondition = false; 19808 ac.abort(); 19809 classList.remove("copyAll"); 19810 }); 19811 stopEvent(event); 19812 } 19813 } 19814 setDocument(pdfDocument) { 19815 if (this.pdfDocument) { 19816 this.eventBus.dispatch("pagesdestroy", { 19817 source: this 19818 }); 19819 this._cancelRendering(); 19820 this._resetView(); 19821 this.findController?.setDocument(null); 19822 this._scriptingManager?.setDocument(null); 19823 this.#annotationEditorUIManager?.destroy(); 19824 this.#annotationEditorUIManager = null; 19825 this.#annotationEditorMode = AnnotationEditorType.NONE; 19826 this.#printingAllowed = true; 19827 } 19828 this.pdfDocument = pdfDocument; 19829 if (!pdfDocument) { 19830 return; 19831 } 19832 const pagesCount = pdfDocument.numPages; 19833 const firstPagePromise = pdfDocument.getPage(1); 19834 const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig({ 19835 intent: "display" 19836 }); 19837 const permissionsPromise = this.#enablePermissions ? pdfDocument.getPermissions() : Promise.resolve(); 19838 const { 19839 eventBus, 19840 pageColors, 19841 viewer 19842 } = this; 19843 this.#eventAbortController = new AbortController(); 19844 const { 19845 signal 19846 } = this.#eventAbortController; 19847 if (pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) { 19848 console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document."); 19849 const mode = this._scrollMode = ScrollMode.PAGE; 19850 eventBus.dispatch("scrollmodechanged", { 19851 source: this, 19852 mode 19853 }); 19854 } 19855 this._pagesCapability.promise.then(() => { 19856 eventBus.dispatch("pagesloaded", { 19857 source: this, 19858 pagesCount 19859 }); 19860 }, () => {}); 19861 const onBeforeDraw = evt => { 19862 const pageView = this._pages[evt.pageNumber - 1]; 19863 if (!pageView) { 19864 return; 19865 } 19866 this.#buffer.push(pageView); 19867 }; 19868 eventBus._on("pagerender", onBeforeDraw, {
19869 signal 19870 }); 19871 const onAfterDraw = evt => { 19872 if (evt.cssTransform || evt.isDetailView) { 19873 return; 19874 } 19875 this._onePageRenderedCapability.resolve({ 19876 timestamp: evt.timestamp 19877 }); 19878 eventBus._off("pagerendered", onAfterDraw); 19879 }; 19880 eventBus._on("pagerendered", onAfterDraw, { 19881 signal 19882 }); 19883 Promise.all([firstPagePromise, permissionsPromise]).then(([firstPdfPage, permissions]) => { 19884 if (pdfDocument !== this.pdfDocument) { 19885 return; 19886 } 19887 this._firstPageCapability.resolve(firstPdfPage); 19888 this._optionalContentConfigPromise = optionalContentConfigPromise; 19889 const { 19890 annotationEditorMode, 19891 annotationMode, 19892 textLayerMode 19893 } = this.#initializePermissions(permissions); 19894 if (textLayerMode !== TextLayerMode.DISABLE) { 19895 const element = this.#hiddenCopyElement = document.createElement("div"); 19896 element.id = "hiddenCopyElement"; 19897 viewer.before(element); 19898 } 19899 if (annotationEditorMode !== AnnotationEditorType.DISABLE) { 19900 const mode = annotationEditorMode; 19901 if (pdfDocument.isPureXfa) { 19902 console.warn("Warning: XFA-editing is not implemented."); 19903 } else if (isValidAnnotationEditorMode(mode)) { 19904 this.#annotationEditorUIManager = new AnnotationEditorUIManager(this.container, viewer, this.#viewerAlert, this.#altTextManager, this.#commentManager, this.#signatureManager, eventBus, pdfDocument, pageColors, this.#annotationEditorHighlightColors, this.#enableHighlightFloatingButton, this.#enableUpdatedAddImage, this.#enableNewAltTextWhenAddingImage, this.#mlManager, this.#editorUndoBar, this.#supportsPinchToZoom); 19905 eventBus.dispatch("annotationeditoruimanager", { 19906 source: this, 19907 uiManager: this.#annotationEditorUIManager 19908 }); 19909 if (mode !== AnnotationEditorType.NONE) { 19910 this.#preloadEditingData(mode); 19911 this.#annotationEditorUIManager.updateMode(mode); 19912 } 19913 } else { 19914 console.error(`Invalid AnnotationEditor mode: ${mode}`); 19915 } 19916 } 19917 const viewerElement = this._scrollMode === ScrollMode.PAGE ? null : viewer; 19918 const scale = this.currentScale; 19919 const viewport = firstPdfPage.getViewport({ 19920 scale: scale * PixelsPerInch.PDF_TO_CSS_UNITS 19921 }); 19922 viewer.style.setProperty("--scale-factor", viewport.scale); 19923 if (pageColors?.background) { 19924 viewer.style.setProperty("--page-bg-color", pageColors.background); 19925 } 19926 if (pageColors?.foreground === "CanvasText" || pageColors?.background === "Canvas") { 19927 viewer.style.setProperty("--hcm-highlight-filter", pdfDocument.filterFactory.addHighlightHCMFilter("highlight", "CanvasText", "Canvas", "HighlightText", "Highlight")); 19928 viewer.style.setProperty("--hcm-highlight-selected-filter", pdfDocument.filterFactory.addHighlightHCMFilter("highlight_selected", "CanvasText", "Canvas", "HighlightText", "ButtonText")); 19929 } 19930 for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) { 19931 const pageView = new PDFPageView({ 19932 container: viewerElement, 19933 eventBus, 19934 id: pageNum, 19935 scale, 19936 defaultViewport: viewport.clone(), 19937 optionalContentConfigPromise, 19938 renderingQueue: this.renderingQueue, 19939 textLayerMode, 19940 annotationMode, 19941 imageResourcesPath: this.imageResourcesPath, 19942 maxCanvasPixels: this.maxCanvasPixels, 19943 maxCanvasDim: this.maxCanvasDim, 19944 capCanvasAreaFactor: this.capCanvasAreaFactor, 19945 enableDetailCanvas: this.enableDetailCanvas, 19946 enableOptimizedPartialRendering: this.enableOptimizedPartialRendering, 19947 pageColors, 19948 l10n: this.l10n, 19949 layerProperties: this._layerProperties, 19950 enableHWA: this.#enableHWA, 19951 enableAutoLinking: this.#enableAutoLinking, 19952 minDurationToUpdateCanvas: this.#minDurationToUpdateCanvas, 19953 commentManager: this.#commentManager 19954 }); 19955 this._pages.push(pageView); 19956 } 19957 this._pages[0]?.setPdfPage(firstPdfPage); 19958 if (this._scrollMode === ScrollMode.PAGE) { 19959 this.#ensurePageViewVisible(); 19960 } else if (this._spreadMode !== SpreadMode.NONE) { 19961 this._updateSpreadMode(); 19962 } 19963 eventBus._on("annotationeditorlayerrendered", evt => { 19964 if (this.#annotationEditorUIManager) { 19965 eventBus.dispatch("annotationeditormodechanged", { 19966 source: this, 19967 mode: this.#annotationEditorMode 19968 }); 19969 } 19970 }, { 19971 once: true, 19972 signal 19973 }); 19974 this.#onePageRenderedOrForceFetch(signal).then(async () => { 19975 if (pdfDocument !== this.pdfDocument) { 19976 return; 19977 } 19978 this.findController?.setDocument(pdfDocument); 19979 this._scriptingManager?.setDocument(pdfDocument); 19980 if (this.#hiddenCopyElement) { 19981 document.addEventListener("copy", this.#copyCallback.bind(this, textLayerMode), {
19982 signal 19983 }); 19984 } 19985 if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > PagesCountLimit.FORCE_LAZY_PAGE_INIT) { 19986 this._pagesCapability.resolve(); 19987 return; 19988 } 19989 let getPagesLeft = pagesCount - 1; 19990 if (getPagesLeft <= 0) { 19991 this._pagesCapability.resolve(); 19992 return; 19993 } 19994 for (let pageNum = 2; pageNum <= pagesCount; ++pageNum) { 19995 const promise = pdfDocument.getPage(pageNum).then(pdfPage => { 19996 const pageView = this._pages[pageNum - 1]; 19997 if (!pageView.pdfPage) { 19998 pageView.setPdfPage(pdfPage); 19999 } 20000 if (--getPagesLeft === 0) { 20001 this._pagesCapability.resolve(); 20002 } 20003 }, reason => { 20004 console.error(`Unable to get page ${pageNum} to initialize viewer`, reason); 20005 if (--getPagesLeft === 0) { 20006 this._pagesCapability.resolve(); 20007 } 20008 }); 20009 if (pageNum % PagesCountLimit.PAUSE_EAGER_PAGE_INIT === 0) { 20010 await promise; 20011 } 20012 } 20013 }); 20014 eventBus.dispatch("pagesinit", { 20015 source: this 20016 }); 20017 pdfDocument.getMetadata().then(({ 20018 info 20019 }) => { 20020 if (pdfDocument !== this.pdfDocument) { 20021 return; 20022 } 20023 if (info.Language) { 20024 viewer.lang = info.Language; 20025 } 20026 }); 20027 if (this.defaultRenderingQueue) { 20028 this.update(); 20029 } 20030 }).catch(reason => { 20031 console.error("Unable to initialize viewer", reason); 20032 this._pagesCapability.reject(reason); 20033 }); 20034 } 20035 onPagesEdited({ 20036 pagesMapper, 20037 type, 20038 hasBeenCut, 20039 pageNumbers 20040 }) { 20041 if (type === "copy") { 20042 this.#copiedPageViews = new Map(); 20043 for (const pageNum of pageNumbers) { 20044 this.#copiedPageViews.set(pageNum, this._pages[pageNum - 1]); 20045 } 20046 return; 20047 } 20048 const isCut = type === "cut"; 20049 if (isCut || type === "delete") { 20050 for (const pageNum of pageNumbers) { 20051 this._pages[pageNum - 1].deleteMe(isCut); 20052 } 20053 } 20054 this._currentPageNumber = 0; 20055 const prevPages = this._pages; 20056 const newPages = this._pages = []; 20057 for (let i = 1, ii = pagesMapper.pagesNumber; i <= ii; i++) { 20058 const prevPageNumber = pagesMapper.getPrevPageNumber(i); 20059 if (prevPageNumber < 0) { 20060 let page = this.#copiedPageViews.get(-prevPageNumber); 20061 if (hasBeenCut) { 20062 page.updatePageNumber(i); 20063 } else { 20064 page = page.clone(i); 20065 } 20066 newPages.push(page); 20067 continue; 20068 } 20069 const page = prevPages[prevPageNumber - 1]; 20070 newPages.push(page); 20071 page.updatePageNumber(i); 20072 } 20073 if (!isCut) { 20074 this.#copiedPageViews = null; 20075 } 20076 const viewerElement = this._scrollMode === ScrollMode.PAGE ? null : this.viewer; 20077 if (viewerElement) { 20078 viewerElement.replaceChildren(); 20079 const fragment = document.createDocumentFragment(); 20080 for (let i = 0, ii = pagesMapper.pagesNumber; i < ii; i++) { 20081 const { 20082 div 20083 } = newPages[i]; 20084 div.setAttribute("data-page-number", i + 1); 20085 fragment.append(div); 20086 } 20087 viewerElement.append(fragment); 20088 } 20089 setTimeout(() => { 20090 this.forceRendering(); 20091 }); 20092 } 20093 setPageLabels(labels) { 20094 if (!this.pdfDocument) { 20095 return; 20096 } 20097 if (!labels) { 20098 this._pageLabels = null; 20099 } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) { 20100 this._pageLabels = null; 20101 console.error(`setPageLabels: Invalid page labels.`); 20102 } else { 20103 this._pageLabels = labels; 20104 } 20105 for (let i = 0, ii = this._pages.length; i < ii; i++) { 20106 this._pages[i].setPageLabel(this._pageLabels?.[i] ?? null); 20107 } 20108 } 20109 _resetView() { 20110 this._pages = []; 20111 this._currentPageNumber = 1; 20112 this._currentScale = UNKNOWN_SCALE; 20113 this._currentScaleValue = null; 20114 this._pageLabels = null; 20115 this.#buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE); 20116 this._location = null; 20117 this._pagesRotation = 0; 20118 this._optionalContentConfigPromise = null; 20119 this._firstPageCapability = Promise.withResolvers(); 20120 this._onePageRenderedCapability = Promise.withResolvers(); 20121 this._pagesCapability = Promise.withResolvers(); 20122 this._scrollMode = ScrollMode.VERTICAL; 20123 this._previousScrollMode = ScrollMode.UNKNOWN; 20124 this._spreadMode = SpreadMode.NONE; 20125 this.#scrollModePageState = { 20126 previousPageNumber: 1, 20127 scrollDown: true, 20128 pages: [] 20129 }; 20130 this.#eventAbortController?.abort(); 20131 this.#eventAbortController = null; 20132 this.viewer.textContent = ""; 20133 this._updateScrollMode(); 20134 this.viewer.removeAttribute("lang"); 20135 this.#hiddenCopyElement?.remove(); 20136 this.#hiddenCopyElement = null; 20137 this.#cleanupTimeouts(); 20138 this.#cleanupSwitchAnnotationEditorMode(); 20139 } 20140 #ensurePageViewVisible() { 20141 if (this._scrollMode !== ScrollMode.PAGE) { 20142 throw new Error("#ensurePageViewVisible: Invalid scrollMode value."); 20143 } 20144 const pageNumber = this._currentPageNumber, 20145 state = this.#scrollModePageState, 20146 viewer = this.viewer; 20147 viewer.textContent = ""; 20148 state.pages.length = 0; 20149 if (this._spreadMode === SpreadMode.NONE && !this.isInPresentationMode) { 20150 const pageView = this._pages[pageNumber - 1]; 20151 viewer.append(pageView.div); 20152 state.pages.push(pageView); 20153 } else { 20154 const pageIndexSet = new Set(), 20155 parity = this._spreadMode - 1; 20156 if (parity === -1) { 20157 pageIndexSet.add(pageNumber - 1); 20158 } else if (pageNumber % 2 !== parity) { 20159 pageIndexSet.add(pageNumber - 1); 20160 pageIndexSet.add(pageNumber); 20161 } else { 20162 pageIndexSet.add(pageNumber - 2); 20163 pageIndexSet.add(pageNumber - 1); 20164 } 20165 const spread = document.createElement("div"); 20166 spread.className = "spread"; 20167 if (this.isInPresentationMode) { 20168 const dummyPage = document.createElement("div"); 20169 dummyPage.className = "dummyPage"; 20170 spread.append(dummyPage); 20171 } 20172 for (const i of pageIndexSet) { 20173 const pageView = this._pages[i]; 20174 if (!pageView) { 20175 continue; 20176 } 20177 spread.append(pageView.div); 20178 state.pages.push(pageView); 20179 } 20180 viewer.append(spread); 20181 } 20182 state.scrollDown = pageNumber >= state.previousPageNumber; 20183 state.previousPageNumber = pageNumber; 20184 } 20185 _scrollUpdate() { 20186 if (this.pagesCount === 0) { 20187 return; 20188 } 20189 if (this.#scrollTimeoutId) { 20190 clearTimeout(this.#scrollTimeoutId); 20191 } 20192 this.#scrollTimeoutId = setTimeout(() => { 20193 this.#scrollTimeoutId = null; 20194 this.update(); 20195 }, 100); 20196 this.update(); 20197 } 20198 #scrollIntoView(pageView, pageSpot = null) { 20199 const { 20200 div, 20201 id 20202 } = pageView; 20203 if (this._currentPageNumber !== id) { 20204 this._setCurrentPageNumber(id); 20205 } 20206 if (this._scrollMode === ScrollMode.PAGE) { 20207 this.#ensurePageViewVisible(); 20208 this.update(); 20209 } 20210 if (!pageSpot && !this.isInPresentationMode) { 20211 const left = div.offsetLeft + div.clientLeft, 20212 right = left + div.clientWidth; 20213 const { 20214 scrollLeft, 20215 clientWidth 20216 } = this.container; 20217 if (this._scrollMode === ScrollMode.HORIZONTAL || left < scrollLeft || right > scrollLeft + clientWidth) { 20218 pageSpot = { 20219 left: 0, 20220 top: 0 20221 }; 20222 } 20223 } 20224 scrollIntoView(div, pageSpot); 20225 if (!this._currentScaleValue && this._location) { 20226 this._location = null; 20227 } 20228 } 20229 #isSameScale(newScale) { 20230 return newScale === this._currentScale || Math.abs(newScale - this._currentScale) < 1e-15; 20231 } 20232 #setScaleUpdatePages(newScale, newValue, { 20233 noScroll = false, 20234 preset = false, 20235 drawingDelay = -1, 20236 origin = null 20237 }) { 20238 this._currentScaleValue = newValue.toString(); 20239 if (this.#isSameScale(newScale)) { 20240 if (preset) { 20241 this.eventBus.dispatch("scalechanging", { 20242 source: this, 20243 scale: newScale, 20244 presetValue: newValue 20245 }); 20246 } 20247 return; 20248 } 20249 this.viewer.style.setProperty("--scale-factor", newScale * PixelsPerInch.PDF_TO_CSS_UNITS); 20250 const postponeDrawing = drawingDelay >= 0 && drawingDelay < 1000; 20251 this.refresh(true, { 20252 scale: newScale, 20253 drawingDelay: postponeDrawing ? drawingDelay : -1 20254 }); 20255 if (postponeDrawing) { 20256 this.#scaleTimeoutId = setTimeout(() => { 20257 this.#scaleTimeoutId = null; 20258 this.refresh(); 20259 }, drawingDelay); 20260 } 20261 const previousScale = this._currentScale; 20262 this._currentScale = newScale; 20263 if (!noScroll) { 20264 let page = this._currentPageNumber, 20265 dest; 20266 if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) { 20267 page = this._location.pageNumber; 20268 dest = [null, { 20269 name: "XYZ" 20270 }, this._location.left, this._location.top, null]; 20271 } 20272 this.scrollPageIntoView({ 20273 pageNumber: page, 20274 destArray: dest, 20275 allowNegativeOffset: true 20276 }); 20277 if (Array.isArray(origin)) { 20278 const scaleDiff = newScale / previousScale - 1; 20279 const [top, left] = this.containerTopLeft; 20280 this.container.scrollLeft += (origin[0] - left) * scaleDiff; 20281 this.container.scrollTop += (origin[1] - top) * scaleDiff; 20282 } 20283 } 20284 this.eventBus.dispatch("scalechanging", { 20285 source: this, 20286 scale: newScale, 20287 presetValue: preset ? newValue : undefined 20288 }); 20289 if (this.defaultRenderingQueue) { 20290 this.update(); 20291 } 20292 } 20293 get #pageWidthScaleFactor() { 20294 if (this._spreadMode !== SpreadMode.NONE && this._scrollMode !== ScrollMode.HORIZONTAL) { 20295 return 2; 20296 } 20297 return 1; 20298 } 20299 #setScale(value, options) { 20300 let scale = parseFloat(value); 20301 if (scale > 0) { 20302 options.preset = false;
20303 this.#setScaleUpdatePages(scale, value, options); 20304 } else { 20305 const currentPage = this._pages[this._currentPageNumber - 1]; 20306 if (!currentPage) { 20307 return; 20308 } 20309 let hPadding = SCROLLBAR_PADDING, 20310 vPadding = VERTICAL_PADDING; 20311 if (this.isInPresentationMode) { 20312 hPadding = vPadding = 4; 20313 if (this._spreadMode !== SpreadMode.NONE) { 20314 hPadding *= 2; 20315 } 20316 } else if (this.removePageBorders) { 20317 hPadding = vPadding = 0; 20318 } else if (this._scrollMode === ScrollMode.HORIZONTAL) { 20319 [hPadding, vPadding] = [vPadding, hPadding]; 20320 } 20321 const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this.#pageWidthScaleFactor; 20322 const pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale; 20323 switch (value) { 20324 case "page-actual": 20325 scale = 1; 20326 break; 20327 case "page-width": 20328 scale = pageWidthScale; 20329 break; 20330 case "page-height": 20331 scale = pageHeightScale; 20332 break; 20333 case "page-fit": 20334 scale = Math.min(pageWidthScale, pageHeightScale); 20335 break; 20336 case "auto": 20337 const horizontalScale = isPortraitOrientation(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale); 20338 scale = Math.min(MAX_AUTO_SCALE, horizontalScale); 20339 break; 20340 default: 20341 console.error(`#setScale: "${value}" is an unknown zoom value.`); 20342 return; 20343 } 20344 options.preset = true; 20345 this.#setScaleUpdatePages(scale, value, options); 20346 } 20347 } 20348 #resetCurrentPageView() { 20349 const pageView = this._pages[this._currentPageNumber - 1]; 20350 if (this.isInPresentationMode) { 20351 this.#setScale(this._currentScaleValue, { 20352 noScroll: true 20353 }); 20354 } 20355 this.#scrollIntoView(pageView); 20356 } 20357 pageLabelToPageNumber(label) { 20358 if (!this._pageLabels) { 20359 return null; 20360 } 20361 const i = this._pageLabels.indexOf(label); 20362 if (i < 0) { 20363 return null; 20364 } 20365 return i + 1; 20366 } 20367 scrollPageIntoView({ 20368 pageNumber, 20369 destArray = null, 20370 allowNegativeOffset = false, 20371 ignoreDestinationZoom = false, 20372 center = null 20373 }) { 20374 if (!this.pdfDocument) { 20375 return; 20376 } 20377 const pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1]; 20378 if (!pageView) { 20379 console.error(`scrollPageIntoView: "${pageNumber}" is not a valid pageNumber parameter.`); 20380 return; 20381 } 20382 if (this.isInPresentationMode || !destArray) { 20383 this._setCurrentPageNumber(pageNumber, true); 20384 return; 20385 } 20386 let x = 0, 20387 y = 0; 20388 let width = 0, 20389 height = 0, 20390 widthScale, 20391 heightScale; 20392 const changeOrientation = pageView.rotation % 180 !== 0; 20393 const pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / PixelsPerInch.PDF_TO_CSS_UNITS; 20394 const pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / PixelsPerInch.PDF_TO_CSS_UNITS; 20395 let scale = 0; 20396 switch (destArray[1].name) { 20397 case "XYZ": 20398 x = destArray[2]; 20399 y = destArray[3]; 20400 scale = destArray[4]; 20401 x = x !== null ? x : 0; 20402 y = y !== null ? y : pageHeight; 20403 break; 20404 case "Fit": 20405 case "FitB": 20406 scale = "page-fit"; 20407 break; 20408 case "FitH": 20409 case "FitBH": 20410 y = destArray[2]; 20411 scale = "page-width"; 20412 if (y === null && this._location) { 20413 x = this._location.left; 20414 y = this._location.top; 20415 } else if (typeof y !== "number" || y < 0) { 20416 y = pageHeight; 20417 } 20418 break; 20419 case "FitV": 20420 case "FitBV": 20421 x = destArray[2]; 20422 width = pageWidth; 20423 height = pageHeight; 20424 scale = "page-height"; 20425 break; 20426 case "FitR": 20427 x = destArray[2]; 20428 y = destArray[3]; 20429 width = destArray[4] - x; 20430 height = destArray[5] - y; 20431 let hPadding = SCROLLBAR_PADDING, 20432 vPadding = VERTICAL_PADDING; 20433 if (this.removePageBorders) { 20434 hPadding = vPadding = 0; 20435 } 20436 widthScale = (this.container.clientWidth - hPadding) / width / PixelsPerInch.PDF_TO_CSS_UNITS; 20437 heightScale = (this.container.clientHeight - vPadding) / height / PixelsPerInch.PDF_TO_CSS_UNITS; 20438 scale = Math.min(Math.abs(widthScale), Math.abs(heightScale)); 20439 break; 20440 default: 20441 console.error(`scrollPageIntoView: "${destArray[1].name}" is not a valid destination type.`); 20442 return; 20443 } 20444 if (!ignoreDestinationZoom) { 20445 if (scale && scale !== this._currentScale) { 20446 this.currentScaleValue = scale; 20447 } else if (this._currentScale === UNKNOWN_SCALE) { 20448 this.currentScaleValue = DEFAULT_SCALE_VALUE; 20449 } 20450 } 20451 if (scale === "page-fit" && !destArray[4]) { 20452 this.#scrollIntoView(pageView); 20453 return; 20454 } 20455 const boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)]; 20456 let left = Math.min(boundingRect[0][0], boundingRect[1][0]); 20457 let top = Math.min(boundingRect[0][1], boundingRect[1][1]); 20458 if (center) { 20459 if (center === "both" || center === "vertical") { 20460 top -= (this.container.clientHeight - Math.abs(boundingRect[1][1] - boundingRect[0][1])) / 2; 20461 } 20462 if (center === "both" || center === "horizontal") { 20463 left -= (this.container.clientWidth - Math.abs(boundingRect[1][0] - boundingRect[0][0])) / 2; 20464 } 20465 } else if (!allowNegativeOffset) { 20466 left = Math.max(left, 0); 20467 top = Math.max(top, 0); 20468 } 20469 this.#scrollIntoView(pageView, { 20470 left, 20471 top 20472 }); 20473 } 20474 _updateLocation(firstPage) { 20475 const currentScale = this._currentScale; 20476 const currentScaleValue = this._currentScaleValue; 20477 const normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue; 20478 const pageNumber = firstPage.id; 20479 const currentPageView = this._pages[pageNumber - 1]; 20480 const container = this.container; 20481 const topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y); 20482 const intLeft = Math.round(topLeft[0]); 20483 const intTop = Math.round(topLeft[1]); 20484 let pdfOpenParams = `#page=${pageNumber}`; 20485 if (!this.isInPresentationMode) { 20486 pdfOpenParams += `&zoom=${normalizedScaleValue},${intLeft},${intTop}`; 20487 } 20488 this._location = { 20489 pageNumber, 20490 scale: normalizedScaleValue, 20491 top: intTop, 20492 left: intLeft, 20493 rotation: this._pagesRotation, 20494 pdfOpenParams 20495 }; 20496 } 20497 update() { 20498 const visible = this._getVisiblePages(); 20499 const visiblePages = visible.views, 20500 numVisiblePages = visiblePages.length; 20501 if (numVisiblePages === 0) { 20502 return; 20503 } 20504 const newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1); 20505 this.#buffer.resize(newCacheSize, visible.ids); 20506 for (const { 20507 view, 20508 visibleArea 20509 } of visiblePages) { 20510 view.updateVisibleArea(visibleArea); 20511 } 20512 for (const view of this.#buffer) { 20513 if (!visible.ids.has(view.id)) { 20514 view.updateVisibleArea(null); 20515 } 20516 } 20517 this.renderingQueue.renderHighestPriority(visible); 20518 const isSimpleLayout = this._spreadMode === SpreadMode.NONE && (this._scrollMode === ScrollMode.PAGE || this._scrollMode === ScrollMode.VERTICAL); 20519 const currentPageNumber = this._currentPageNumber; 20520 let stillFullyVisible = false;
20521 for (const page of visiblePages) { 20522 if (page.percent < 100) { 20523 break; 20524 } 20525 if (page.id === currentPageNumber && isSimpleLayout) { 20526 stillFullyVisible = true; 20527 break; 20528 } 20529 } 20530 this._setCurrentPageNumber(stillFullyVisible ? this._currentPageNumber : visiblePages[0].id); 20531 this._updateLocation(visible.first); 20532 this.eventBus.dispatch("updateviewarea", { 20533 source: this, 20534 location: this._location 20535 }); 20536 } 20537 #switchToEditAnnotationMode() { 20538 const visible = this._getVisiblePages(); 20539 const pagesToRefresh = []; 20540 const { 20541 ids, 20542 views 20543 } = visible; 20544 for (const page of views) { 20545 const { 20546 view 20547 } = page; 20548 if (!view.hasEditableAnnotations()) { 20549 ids.delete(view.id); 20550 continue; 20551 } 20552 pagesToRefresh.push(page); 20553 } 20554 if (pagesToRefresh.length === 0) { 20555 return null; 20556 } 20557 this.renderingQueue.renderHighestPriority({ 20558 first: pagesToRefresh[0], 20559 last: pagesToRefresh.at(-1), 20560 views: pagesToRefresh, 20561 ids 20562 }); 20563 return ids; 20564 } 20565 containsElement(element) { 20566 return this.container.contains(element); 20567 } 20568 focus() { 20569 this.container.focus(); 20570 } 20571 get _isContainerRtl() { 20572 return getComputedStyle(this.container).direction === "rtl"; 20573 } 20574 get isInPresentationMode() { 20575 return this.presentationModeState === PresentationModeState.FULLSCREEN; 20576 } 20577 get isChangingPresentationMode() { 20578 return this.presentationModeState === PresentationModeState.CHANGING; 20579 } 20580 get isHorizontalScrollbarEnabled() { 20581 return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth; 20582 } 20583 get isVerticalScrollbarEnabled() { 20584 return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight; 20585 } 20586 _getVisiblePages() { 20587 const views = this._scrollMode === ScrollMode.PAGE ? this.#scrollModePageState.pages : this._pages, 20588 horizontal = this._scrollMode === ScrollMode.HORIZONTAL, 20589 rtl = horizontal && this._isContainerRtl; 20590 return getVisibleElements({ 20591 scrollEl: this.container, 20592 views, 20593 sortByVisibility: true, 20594 horizontal, 20595 rtl 20596 }); 20597 } 20598 cleanup() { 20599 for (const pageView of this._pages) { 20600 if (pageView.renderingState !== RenderingStates.FINISHED) { 20601 pageView.reset(); 20602 } 20603 } 20604 } 20605 _cancelRendering() { 20606 for (const pageView of this._pages) { 20607 pageView.cancelRendering(); 20608 } 20609 } 20610 async #ensurePdfPageLoaded(pageView) { 20611 if (pageView.pdfPage) { 20612 return pageView.pdfPage; 20613 } 20614 try { 20615 const pdfPage = await this.pdfDocument.getPage(pageView.id); 20616 if (!pageView.pdfPage) { 20617 pageView.setPdfPage(pdfPage); 20618 } 20619 return pdfPage; 20620 } catch (reason) { 20621 console.error("Unable to get page for page view", reason); 20622 return null; 20623 } 20624 } 20625 #getScrollAhead(visible) { 20626 if (visible.first?.id === 1) { 20627 return true; 20628 } else if (visible.last?.id === this.pagesCount) { 20629 return false; 20630 } 20631 switch (this._scrollMode) { 20632 case ScrollMode.PAGE: 20633 return this.#scrollModePageState.scrollDown; 20634 case ScrollMode.HORIZONTAL: 20635 return this.scroll.right; 20636 } 20637 return this.scroll.down; 20638 } 20639 forceRendering(currentlyVisiblePages) { 20640 const visiblePages = currentlyVisiblePages || this._getVisiblePages(); 20641 const scrollAhead = this.#getScrollAhead(visiblePages); 20642 const preRenderExtra = this._spreadMode !== SpreadMode.NONE && this._scrollMode !== ScrollMode.HORIZONTAL; 20643 const ignoreDetailViews = this.#scaleTimeoutId !== null || this.#scrollTimeoutId !== null && visiblePages.views.some(page => page.detailView?.renderingCancelled); 20644 const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead, preRenderExtra, ignoreDetailViews); 20645 if (pageView) { 20646 this.#ensurePdfPageLoaded(pageView).then(() => { 20647 this.renderingQueue.renderView(pageView); 20648 }); 20649 return true; 20650 } 20651 return false; 20652 } 20653 get hasEqualPageSizes() { 20654 const firstPageView = this._pages[0]; 20655 for (let i = 1, ii = this._pages.length; i < ii; ++i) { 20656 const pageView = this._pages[i]; 20657 if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) { 20658 return false;
20659 } 20660 } 20661 return true; 20662 } 20663 getPagesOverview() { 20664 let initialOrientation; 20665 return this._pages.map(pageView => { 20666 const viewport = pageView.pdfPage.getViewport({ 20667 scale: 1 20668 }); 20669 const orientation = isPortraitOrientation(viewport); 20670 if (initialOrientation === undefined) { 20671 initialOrientation = orientation; 20672 } else if (this.enablePrintAutoRotate && orientation !== initialOrientation) { 20673 return { 20674 width: viewport.height, 20675 height: viewport.width, 20676 rotation: (viewport.rotation - 90) % 360 20677 }; 20678 } 20679 return { 20680 width: viewport.width, 20681 height: viewport.height, 20682 rotation: viewport.rotation 20683 }; 20684 }); 20685 } 20686 get optionalContentConfigPromise() { 20687 if (!this.pdfDocument) { 20688 return Promise.resolve(null); 20689 } 20690 if (!this._optionalContentConfigPromise) { 20691 console.error("optionalContentConfigPromise: Not initialized yet."); 20692 return this.pdfDocument.getOptionalContentConfig({ 20693 intent: "display" 20694 }); 20695 } 20696 return this._optionalContentConfigPromise; 20697 } 20698 set optionalContentConfigPromise(promise) { 20699 if (!(promise instanceof Promise)) { 20700 throw new Error(`Invalid optionalContentConfigPromise: ${promise}`); 20701 } 20702 if (!this.pdfDocument) { 20703 return; 20704 } 20705 if (!this._optionalContentConfigPromise) { 20706 return; 20707 } 20708 this._optionalContentConfigPromise = promise; 20709 this.refresh(false, { 20710 optionalContentConfigPromise: promise 20711 }); 20712 this.eventBus.dispatch("optionalcontentconfigchanged", { 20713 source: this, 20714 promise 20715 }); 20716 } 20717 get scrollMode() { 20718 return this._scrollMode; 20719 } 20720 set scrollMode(mode) { 20721 if (this._scrollMode === mode) { 20722 return; 20723 } 20724 if (!isValidScrollMode(mode)) { 20725 throw new Error(`Invalid scroll mode: ${mode}`); 20726 } 20727 if (this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) { 20728 return; 20729 } 20730 this._previousScrollMode = this._scrollMode; 20731 this._scrollMode = mode; 20732 this.eventBus.dispatch("scrollmodechanged", { 20733 source: this, 20734 mode 20735 }); 20736 this._updateScrollMode(this._currentPageNumber); 20737 } 20738 _updateScrollMode(pageNumber = null) { 20739 const scrollMode = this._scrollMode, 20740 viewer = this.viewer; 20741 viewer.classList.toggle("scrollHorizontal", scrollMode === ScrollMode.HORIZONTAL); 20742 viewer.classList.toggle("scrollWrapped", scrollMode === ScrollMode.WRAPPED); 20743 if (!this.pdfDocument || !pageNumber) { 20744 return; 20745 } 20746 if (scrollMode === ScrollMode.PAGE) { 20747 this.#ensurePageViewVisible(); 20748 } else if (this._previousScrollMode === ScrollMode.PAGE) { 20749 this._updateSpreadMode(); 20750 } 20751 if (this._currentScaleValue && isNaN(this._currentScaleValue)) { 20752 this.#setScale(this._currentScaleValue, { 20753 noScroll: true 20754 }); 20755 } 20756 this._setCurrentPageNumber(pageNumber, true); 20757 this.update(); 20758 } 20759 get spreadMode() { 20760 return this._spreadMode; 20761 } 20762 set spreadMode(mode) { 20763 if (this._spreadMode === mode) { 20764 return; 20765 } 20766 if (!isValidSpreadMode(mode)) { 20767 throw new Error(`Invalid spread mode: ${mode}`); 20768 } 20769 this._spreadMode = mode; 20770 this.eventBus.dispatch("spreadmodechanged", { 20771 source: this, 20772 mode 20773 }); 20774 this._updateSpreadMode(this._currentPageNumber); 20775 } 20776 _updateSpreadMode(pageNumber = null) { 20777 if (!this.pdfDocument) { 20778 return; 20779 } 20780 const viewer = this.viewer, 20781 pages = this._pages; 20782 if (this._scrollMode === ScrollMode.PAGE) { 20783 this.#ensurePageViewVisible(); 20784 } else { 20785 viewer.textContent = ""; 20786 if (this._spreadMode === SpreadMode.NONE) { 20787 for (const pageView of this._pages) { 20788 viewer.append(pageView.div); 20789 } 20790 } else { 20791 const parity = this._spreadMode - 1; 20792 let spread = null; 20793 for (let i = 0, ii = pages.length; i < ii; ++i) { 20794 if (spread === null) { 20795 spread = document.createElement("div"); 20796 spread.className = "spread"; 20797 viewer.append(spread); 20798 } else if (i % 2 === parity) { 20799 spread = spread.cloneNode(false); 20800 viewer.append(spread); 20801 } 20802 spread.append(pages[i].div); 20803 } 20804 } 20805 } 20806 if (!pageNumber) { 20807 return; 20808 } 20809 if (this._currentScaleValue && isNaN(this._currentScaleValue)) { 20810 this.#setScale(this._currentScaleValue, { 20811 noScroll: true 20812 }); 20813 } 20814 this._setCurrentPageNumber(pageNumber, true); 20815 this.update(); 20816 } 20817 #getPageAdvance(currentPageNumber, previous = false) { 20818 switch (this._scrollMode) { 20819 case ScrollMode.WRAPPED: 20820 { 20821 const { 20822 views 20823 } = this._getVisiblePages(), 20824 pageLayout = new Map(); 20825 for (const { 20826 id, 20827 y, 20828 percent, 20829 widthPercent 20830 } of views) { 20831 if (percent === 0 || widthPercent < 100) { 20832 continue; 20833 } 20834 pageLayout.getOrInsertComputed(y, makeArr).push(id); 20835 } 20836 for (const yArray of pageLayout.values()) { 20837 const currentIndex = yArray.indexOf(currentPageNumber); 20838 if (currentIndex === -1) { 20839 continue; 20840 } 20841 const numPages = yArray.length; 20842 if (numPages === 1) { 20843 break; 20844 } 20845 if (previous) { 20846 for (let i = currentIndex - 1, ii = 0; i >= ii; i--) { 20847 const currentId = yArray[i], 20848 expectedId = yArray[i + 1] - 1; 20849 if (currentId < expectedId) { 20850 return currentPageNumber - expectedId; 20851 } 20852 } 20853 } else { 20854 for (let i = currentIndex + 1, ii = numPages; i < ii; i++) { 20855 const currentId = yArray[i], 20856 expectedId = yArray[i - 1] + 1; 20857 if (currentId > expectedId) { 20858 return expectedId - currentPageNumber; 20859 } 20860 } 20861 } 20862 if (previous) { 20863 const firstId = yArray[0]; 20864 if (firstId < currentPageNumber) { 20865 return currentPageNumber - firstId + 1; 20866 } 20867 } else { 20868 const lastId = yArray[numPages - 1]; 20869 if (lastId > currentPageNumber) { 20870 return lastId - currentPageNumber + 1; 20871 } 20872 } 20873 break; 20874 } 20875 break; 20876 } 20877 case ScrollMode.HORIZONTAL: 20878 { 20879 break; 20880 } 20881 case ScrollMode.PAGE: 20882 case ScrollMode.VERTICAL: 20883 { 20884 if (this._spreadMode === SpreadMode.NONE) { 20885 break; 20886 } 20887 const parity = this._spreadMode - 1; 20888 if (previous && currentPageNumber % 2 !== parity) { 20889 break; 20890 } else if (!previous && currentPageNumber % 2 === parity) { 20891 break; 20892 } 20893 const { 20894 views 20895 } = this._getVisiblePages(), 20896 expectedId = previous ? currentPageNumber - 1 : currentPageNumber + 1; 20897 for (const { 20898 id, 20899 percent, 20900 widthPercent 20901 } of views) { 20902 if (id !== expectedId) { 20903 continue; 20904 } 20905 if (percent > 0 && widthPercent === 100) { 20906 return 2; 20907 } 20908 break; 20909 } 20910 break; 20911 } 20912 } 20913 return 1; 20914 } 20915 nextPage() { 20916 const currentPageNumber = this._currentPageNumber, 20917 pagesCount = this.pagesCount; 20918 if (currentPageNumber >= pagesCount) { 20919 return false;
20920 } 20921 const advance = this.#getPageAdvance(currentPageNumber, false) || 1; 20922 this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount); 20923 return true; 20924 } 20925 previousPage() { 20926 const currentPageNumber = this._currentPageNumber; 20927 if (currentPageNumber <= 1) { 20928 return false; 20929 } 20930 const advance = this.#getPageAdvance(currentPageNumber, true) || 1; 20931 this.currentPageNumber = Math.max(currentPageNumber - advance, 1); 20932 return true; 20933 } 20934 updateScale({ 20935 drawingDelay, 20936 scaleFactor = null, 20937 steps = null, 20938 origin 20939 }) { 20940 if (steps === null && scaleFactor === null) { 20941 throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided."); 20942 } 20943 if (!this.pdfDocument) { 20944 return; 20945 } 20946 let newScale = this._currentScale; 20947 if (scaleFactor > 0 && scaleFactor !== 1) { 20948 newScale = Math.round(newScale * scaleFactor * 100) / 100; 20949 } else if (steps) { 20950 const delta = steps > 0 ? DEFAULT_SCALE_DELTA : 1 / DEFAULT_SCALE_DELTA; 20951 const round = steps > 0 ? Math.ceil : Math.floor; 20952 steps = Math.abs(steps); 20953 do { 20954 newScale = round((newScale * delta).toFixed(2) * 10) / 10; 20955 } while (--steps > 0); 20956 } 20957 newScale = MathClamp(newScale, MIN_SCALE, MAX_SCALE); 20958 this.#setScale(newScale, { 20959 noScroll: false, 20960 drawingDelay, 20961 origin 20962 }); 20963 } 20964 increaseScale(options = {}) { 20965 this.updateScale({ 20966 ...options, 20967 steps: options.steps ?? 1 20968 }); 20969 } 20970 decreaseScale(options = {}) { 20971 this.updateScale({ 20972 ...options, 20973 steps: -(options.steps ?? 1) 20974 }); 20975 } 20976 #updateContainerHeightCss(height = this.container.clientHeight) { 20977 if (height !== this.#previousContainerHeight) { 20978 this.#previousContainerHeight = height; 20979 docStyle.setProperty("--viewer-container-height", `${height}px`); 20980 } 20981 } 20982 #resizeObserverCallback(entries) { 20983 for (const entry of entries) { 20984 if (entry.target === this.container) { 20985 this.#updateContainerHeightCss(Math.floor(entry.borderBoxSize[0].blockSize)); 20986 this.#containerTopLeft = null; 20987 break; 20988 } 20989 } 20990 } 20991 get containerTopLeft() { 20992 return this.#containerTopLeft ||= [this.container.offsetTop, this.container.offsetLeft]; 20993 } 20994 #cleanupTimeouts() { 20995 if (this.#scaleTimeoutId !== null) { 20996 clearTimeout(this.#scaleTimeoutId); 20997 this.#scaleTimeoutId = null; 20998 } 20999 if (this.#scrollTimeoutId !== null) { 21000 clearTimeout(this.#scrollTimeoutId); 21001 this.#scrollTimeoutId = null; 21002 } 21003 } 21004 #cleanupSwitchAnnotationEditorMode() { 21005 this.#switchAnnotationEditorModeAC?.abort(); 21006 this.#switchAnnotationEditorModeAC = null; 21007 if (this.#switchAnnotationEditorModeTimeoutId !== null) { 21008 clearTimeout(this.#switchAnnotationEditorModeTimeoutId); 21009 this.#switchAnnotationEditorModeTimeoutId = null; 21010 } 21011 } 21012 #preloadEditingData(mode) { 21013 switch (mode) { 21014 case AnnotationEditorType.STAMP: 21015 this.#mlManager?.loadModel("altText"); 21016 break; 21017 case AnnotationEditorType.SIGNATURE: 21018 this.#signatureManager?.loadSignatures(); 21019 break; 21020 } 21021 } 21022 get annotationEditorMode() { 21023 return this.#annotationEditorUIManager ? this.#annotationEditorMode : AnnotationEditorType.DISABLE; 21024 } 21025 set annotationEditorMode({ 21026 mode, 21027 editId = null, 21028 isFromKeyboard = false, 21029 mustEnterInEditMode = false, 21030 editComment = false 21031 }) { 21032 if (!this.#annotationEditorUIManager) { 21033 throw new Error(`The AnnotationEditor is not enabled.`); 21034 } 21035 if (this.#annotationEditorMode === mode) { 21036 return; 21037 } 21038 if (!isValidAnnotationEditorMode(mode)) { 21039 throw new Error(`Invalid AnnotationEditor mode: ${mode}`); 21040 } 21041 if (!this.pdfDocument) { 21042 return; 21043 } 21044 this.#preloadEditingData(mode); 21045 const { 21046 eventBus, 21047 pdfDocument 21048 } = this; 21049 const updater = async () => { 21050 this.#cleanupSwitchAnnotationEditorMode(); 21051 this.#annotationEditorMode = mode; 21052 await this.#annotationEditorUIManager.updateMode(mode, editId, true, isFromKeyboard, mustEnterInEditMode, editComment); 21053 if (mode !== this.#annotationEditorMode || pdfDocument !== this.pdfDocument) { 21054 return; 21055 } 21056 eventBus.dispatch("annotationeditormodechanged", { 21057 source: this, 21058 mode 21059 }); 21060 }; 21061 if (mode === AnnotationEditorType.NONE || this.#annotationEditorMode === AnnotationEditorType.NONE) { 21062 const isEditing = mode !== AnnotationEditorType.NONE; 21063 if (!isEditing) { 21064 this.pdfDocument.annotationStorage.resetModifiedIds(); 21065 } 21066 this.cleanup(); 21067 for (const pageView of this._pages) { 21068 pageView.toggleEditingMode(isEditing); 21069 } 21070 const idsToRefresh = this.#switchToEditAnnotationMode(); 21071 if (isEditing && idsToRefresh) { 21072 this.#cleanupSwitchAnnotationEditorMode(); 21073 this.#switchAnnotationEditorModeAC = new AbortController(); 21074 const signal = AbortSignal.any([this.#eventAbortController.signal, this.#switchAnnotationEditorModeAC.signal]); 21075 eventBus._on("pagerendered", ({ 21076 pageNumber 21077 }) => { 21078 idsToRefresh.delete(pageNumber); 21079 if (idsToRefresh.size === 0) { 21080 this.#switchAnnotationEditorModeTimeoutId = setTimeout(updater, 0); 21081 } 21082 }, { 21083 signal 21084 }); 21085 return; 21086 } 21087 } 21088 updater(); 21089 } 21090 refresh(noUpdate = false, updateArgs = Object.create(null)) { 21091 if (!this.pdfDocument) { 21092 return; 21093 } 21094 for (const pageView of this._pages) { 21095 pageView.update(updateArgs); 21096 } 21097 this.#cleanupTimeouts(); 21098 if (!noUpdate) { 21099 this.update(); 21100 } 21101 } 21102} 21103 21104;// ./web/secondary_toolbar.js 21105 21106 21107 21108class SecondaryToolbar { 21109 #opts; 21110 constructor(options, eventBus) { 21111 this.#opts = options; 21112 const buttons = [{ 21113 element: options.presentationModeButton, 21114 eventName: "presentationmode", 21115 close: true 21116 }, {
21117 element: options.printButton, 21118 eventName: "print", 21119 close: true 21120 }, { 21121 element: options.downloadButton, 21122 eventName: "download", 21123 close: true 21124 }, { 21125 element: options.viewBookmarkButton, 21126 eventName: null, 21127 close: true 21128 }, { 21129 element: options.firstPageButton, 21130 eventName: "firstpage", 21131 close: true 21132 }, { 21133 element: options.lastPageButton, 21134 eventName: "lastpage", 21135 close: true 21136 }, { 21137 element: options.pageRotateCwButton, 21138 eventName: "rotatecw", 21139 close: false 21140 }, { 21141 element: options.pageRotateCcwButton, 21142 eventName: "rotateccw", 21143 close: false 21144 }, { 21145 element: options.cursorSelectToolButton, 21146 eventName: "switchcursortool", 21147 eventDetails: { 21148 tool: CursorTool.SELECT 21149 }, 21150 close: true 21151 }, { 21152 element: options.cursorHandToolButton, 21153 eventName: "switchcursortool", 21154 eventDetails: { 21155 tool: CursorTool.HAND 21156 }, 21157 close: true 21158 }, { 21159 element: options.scrollPageButton, 21160 eventName: "switchscrollmode", 21161 eventDetails: { 21162 mode: ScrollMode.PAGE 21163 }, 21164 close: true 21165 }, { 21166 element: options.scrollVerticalButton, 21167 eventName: "switchscrollmode", 21168 eventDetails: { 21169 mode: ScrollMode.VERTICAL 21170 }, 21171 close: true 21172 }, { 21173 element: options.scrollHorizontalButton, 21174 eventName: "switchscrollmode", 21175 eventDetails: { 21176 mode: ScrollMode.HORIZONTAL 21177 }, 21178 close: true 21179 }, { 21180 element: options.scrollWrappedButton, 21181 eventName: "switchscrollmode", 21182 eventDetails: { 21183 mode: ScrollMode.WRAPPED 21184 }, 21185 close: true 21186 }, { 21187 element: options.spreadNoneButton, 21188 eventName: "switchspreadmode", 21189 eventDetails: { 21190 mode: SpreadMode.NONE 21191 }, 21192 close: true 21193 }, { 21194 element: options.spreadOddButton, 21195 eventName: "switchspreadmode", 21196 eventDetails: { 21197 mode: SpreadMode.ODD 21198 }, 21199 close: true 21200 }, { 21201 element: options.spreadEvenButton, 21202 eventName: "switchspreadmode", 21203 eventDetails: { 21204 mode: SpreadMode.EVEN 21205 }, 21206 close: true 21207 }, { 21208 element: options.imageAltTextSettingsButton, 21209 eventName: "imagealttextsettings", 21210 close: true 21211 }, { 21212 element: options.documentPropertiesButton, 21213 eventName: "documentproperties", 21214 close: true 21215 }]; 21216 buttons.push({ 21217 element: options.openFileButton, 21218 eventName: "openfile", 21219 close: true 21220 }); 21221 this.eventBus = eventBus; 21222 this.opened = false; 21223 this.#bindListeners(buttons); 21224 this.reset(); 21225 } 21226 get isOpen() { 21227 return this.opened; 21228 } 21229 setPageNumber(pageNumber) { 21230 this.pageNumber = pageNumber; 21231 this.#updateUIState(); 21232 } 21233 setPagesCount(pagesCount) { 21234 this.pagesCount = pagesCount; 21235 this.#updateUIState(); 21236 } 21237 reset() { 21238 this.pageNumber = 0; 21239 this.pagesCount = 0; 21240 this.#updateUIState(); 21241 this.eventBus.dispatch("switchcursortool", { 21242 source: this, 21243 reset: true 21244 }); 21245 this.#scrollModeChanged({ 21246 mode: ScrollMode.VERTICAL 21247 }); 21248 this.#spreadModeChanged({ 21249 mode: SpreadMode.NONE 21250 }); 21251 } 21252 #updateUIState() { 21253 const { 21254 firstPageButton, 21255 lastPageButton, 21256 pageRotateCwButton, 21257 pageRotateCcwButton 21258 } = this.#opts; 21259 firstPageButton.disabled = this.pageNumber <= 1; 21260 lastPageButton.disabled = this.pageNumber >= this.pagesCount; 21261 pageRotateCwButton.disabled = this.pagesCount === 0; 21262 pageRotateCcwButton.disabled = this.pagesCount === 0; 21263 } 21264 #bindListeners(buttons) { 21265 const { 21266 eventBus 21267 } = this; 21268 const { 21269 toggleButton 21270 } = this.#opts; 21271 toggleButton.addEventListener("click", this.toggle.bind(this)); 21272 for (const { 21273 element, 21274 eventName, 21275 close, 21276 eventDetails 21277 } of buttons) { 21278 element.addEventListener("click", evt => { 21279 if (eventName !== null) { 21280 eventBus.dispatch(eventName, { 21281 source: this, 21282 ...eventDetails 21283 }); 21284 } 21285 if (close) { 21286 this.close(); 21287 } 21288 eventBus.dispatch("reporttelemetry", { 21289 source: this, 21290 details: { 21291 type: "buttons", 21292 data: {
21293 id: element.id 21294 } 21295 } 21296 }); 21297 }); 21298 } 21299 eventBus._on("cursortoolchanged", this.#cursorToolChanged.bind(this)); 21300 eventBus._on("scrollmodechanged", this.#scrollModeChanged.bind(this)); 21301 eventBus._on("spreadmodechanged", this.#spreadModeChanged.bind(this)); 21302 } 21303 #cursorToolChanged({ 21304 tool, 21305 disabled 21306 }) { 21307 const { 21308 cursorSelectToolButton, 21309 cursorHandToolButton 21310 } = this.#opts; 21311 toggleCheckedBtn(cursorSelectToolButton, tool === CursorTool.SELECT); 21312 toggleCheckedBtn(cursorHandToolButton, tool === CursorTool.HAND); 21313 cursorSelectToolButton.disabled = disabled; 21314 cursorHandToolButton.disabled = disabled; 21315 } 21316 #scrollModeChanged({ 21317 mode 21318 }) { 21319 const { 21320 scrollPageButton, 21321 scrollVerticalButton, 21322 scrollHorizontalButton, 21323 scrollWrappedButton, 21324 spreadNoneButton, 21325 spreadOddButton, 21326 spreadEvenButton 21327 } = this.#opts; 21328 toggleCheckedBtn(scrollPageButton, mode === ScrollMode.PAGE); 21329 toggleCheckedBtn(scrollVerticalButton, mode === ScrollMode.VERTICAL); 21330 toggleCheckedBtn(scrollHorizontalButton, mode === ScrollMode.HORIZONTAL); 21331 toggleCheckedBtn(scrollWrappedButton, mode === ScrollMode.WRAPPED); 21332 const forceScrollModePage = this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE; 21333 scrollPageButton.disabled = forceScrollModePage; 21334 scrollVerticalButton.disabled = forceScrollModePage; 21335 scrollHorizontalButton.disabled = forceScrollModePage; 21336 scrollWrappedButton.disabled = forceScrollModePage; 21337 const isHorizontal = mode === ScrollMode.HORIZONTAL; 21338 spreadNoneButton.disabled = isHorizontal; 21339 spreadOddButton.disabled = isHorizontal; 21340 spreadEvenButton.disabled = isHorizontal; 21341 } 21342 #spreadModeChanged({ 21343 mode 21344 }) { 21345 const { 21346 spreadNoneButton, 21347 spreadOddButton, 21348 spreadEvenButton 21349 } = this.#opts; 21350 toggleCheckedBtn(spreadNoneButton, mode === SpreadMode.NONE); 21351 toggleCheckedBtn(spreadOddButton, mode === SpreadMode.ODD); 21352 toggleCheckedBtn(spreadEvenButton, mode === SpreadMode.EVEN); 21353 } 21354 open() { 21355 if (this.opened) { 21356 return; 21357 } 21358 this.opened = true; 21359 const { 21360 toggleButton, 21361 toolbar 21362 } = this.#opts; 21363 toggleExpandedBtn(toggleButton, true, toolbar); 21364 } 21365 close() { 21366 if (!this.opened) { 21367 return; 21368 } 21369 this.opened = false; 21370 const { 21371 toggleButton, 21372 toolbar 21373 } = this.#opts; 21374 toggleExpandedBtn(toggleButton, false, toolbar); 21375 } 21376 toggle() { 21377 if (this.opened) { 21378 this.close(); 21379 } else { 21380 this.open(); 21381 } 21382 } 21383} 21384 21385;// ./web/signature_manager.js 21386 21387 21388 21389 21390 21391 21392 21393const DEFAULT_HEIGHT_IN_PAGE = 40; 21394class SignatureManager { 21395 #addButton; 21396 #tabsToAltText = null; 21397 #clearButton; 21398 #clearDescription; 21399 #currentEditor; 21400 #description; 21401 #dialog; 21402 #drawCurves = null; 21403 #drawPlaceholder; 21404 #drawPath = null; 21405 #drawPathString = ""; 21406 #drawPoints = null; 21407 #drawSVG; 21408 #drawThickness; 21409 #errorBar; 21410 #errorDescription; 21411 #errorTitle; 21412 #extractedSignatureData = null; 21413 #imagePath = null; 21414 #imagePicker; 21415 #imagePickerLink; 21416 #imagePlaceholder; 21417 #imageSVG; 21418 #saveCheckbox; 21419 #saveContainer; 21420 #tabButtons; 21421 #addSignatureToolbarButton; 21422 #loadSignaturesPromise = null; 21423 #typeInput; 21424 #currentTab = null; 21425 #currentTabAC = null; 21426 #hasDescriptionChanged = false; 21427 #eventBus; 21428 #isStorageFull = false; 21429 #l10n; 21430 #overlayManager; 21431 #editDescriptionDialog; 21432 #signatureStorage; 21433 #uiManager = null; 21434 static #l10nDescription = null; 21435 constructor({ 21436 dialog, 21437 panels, 21438 typeButton, 21439 typeInput, 21440 drawButton, 21441 drawPlaceholder, 21442 drawSVG, 21443 drawThickness, 21444 imageButton, 21445 imageSVG, 21446 imagePlaceholder, 21447 imagePicker, 21448 imagePickerLink, 21449 description, 21450 clearButton, 21451 cancelButton, 21452 addButton, 21453 errorCloseButton, 21454 errorBar, 21455 errorTitle, 21456 errorDescription, 21457 saveCheckbox, 21458 saveContainer 21459 }, editSignatureElements, addSignatureToolbarButton, overlayManager, l10n, signatureStorage, eventBus) { 21460 this.#addButton = addButton; 21461 this.#clearButton = clearButton; 21462 this.#clearDescription = description.lastElementChild; 21463 this.#description = description.firstElementChild; 21464 this.#dialog = dialog; 21465 this.#drawSVG = drawSVG; 21466 this.#drawPlaceholder = drawPlaceholder; 21467 this.#drawThickness = drawThickness; 21468 this.#errorBar = errorBar; 21469 this.#errorTitle = errorTitle; 21470 this.#errorDescription = errorDescription; 21471 this.#imageSVG = imageSVG; 21472 this.#imagePlaceholder = imagePlaceholder; 21473 this.#imagePicker = imagePicker; 21474 this.#imagePickerLink = imagePickerLink; 21475 this.#overlayManager = overlayManager;
21476 this.#saveCheckbox = saveCheckbox; 21477 this.#saveContainer = saveContainer; 21478 this.#addSignatureToolbarButton = addSignatureToolbarButton; 21479 this.#typeInput = typeInput; 21480 this.#l10n = l10n; 21481 this.#signatureStorage = signatureStorage; 21482 this.#eventBus = eventBus; 21483 this.#editDescriptionDialog = new EditDescriptionDialog(editSignatureElements, overlayManager); 21484 SignatureManager.#l10nDescription ||= Object.freeze({ 21485 signature: "pdfjs-editor-add-signature-description-default-when-drawing", 21486 errorUploadTitle: "pdfjs-editor-add-signature-image-upload-error-title", 21487 errorUploadDescription: "pdfjs-editor-add-signature-image-upload-error-description", 21488 errorNoDataTitle: "pdfjs-editor-add-signature-image-no-data-error-title", 21489 errorNoDataDescription: "pdfjs-editor-add-signature-image-no-data-error-description" 21490 }); 21491 dialog.addEventListener("close", this.#close.bind(this)); 21492 dialog.addEventListener("contextmenu", e => { 21493 const { 21494 target 21495 } = e; 21496 if (target !== this.#typeInput && target !== this.#description) { 21497 e.preventDefault(); 21498 } 21499 }); 21500 dialog.addEventListener("drop", e => { 21501 stopEvent(e); 21502 }); 21503 cancelButton.addEventListener("click", this.#cancel.bind(this)); 21504 addButton.addEventListener("click", this.#add.bind(this)); 21505 clearButton.addEventListener("click", () => { 21506 this.#reportTelemetry({ 21507 type: "signature", 21508 action: "pdfjs.signature.clear", 21509 data: { 21510 type: this.#currentTab 21511 } 21512 }); 21513 this.#initTab(null); 21514 }, { 21515 passive: true 21516 }); 21517 this.#description.addEventListener("input", () => { 21518 this.#clearDescription.disabled = this.#description.value === ""; 21519 }, { 21520 passive: true 21521 }); 21522 this.#clearDescription.addEventListener("click", () => { 21523 this.#description.value = ""; 21524 this.#clearDescription.disabled = true; 21525 }, { 21526 passive: true 21527 }); 21528 errorCloseButton.addEventListener("click", () => { 21529 errorBar.hidden = true; 21530 }, { 21531 passive: true 21532 }); 21533 this.#initTabButtons(typeButton, drawButton, imageButton, panels); 21534 imagePicker.accept = SupportedImageMimeTypes.join(","); 21535 eventBus._on("storedsignatureschanged", this.#signaturesChanged.bind(this)); 21536 overlayManager.register(dialog); 21537 } 21538 #initTabButtons(typeButton, drawButton, imageButton, panels) { 21539 const buttons = this.#tabButtons = new Map([["type", typeButton], ["draw", drawButton], ["image", imageButton]]); 21540 const tabCallback = e => { 21541 for (const [name, button] of buttons) { 21542 if (button === e.target) { 21543 button.setAttribute("aria-selected", true); 21544 button.setAttribute("tabindex", 0); 21545 panels.setAttribute("data-selected", name); 21546 this.#initTab(name); 21547 } else { 21548 button.setAttribute("aria-selected", false); 21549 button.setAttribute("tabindex", -1); 21550 } 21551 } 21552 }; 21553 const buttonsArray = Array.from(buttons.values()); 21554 for (let i = 0, ii = buttonsArray.length; i < ii; i++) { 21555 const button = buttonsArray[i]; 21556 button.addEventListener("click", tabCallback, { 21557 passive: true 21558 }); 21559 button.addEventListener("keydown", ({ 21560 key 21561 }) => { 21562 if (key !== "ArrowLeft" && key !== "ArrowRight") { 21563 return; 21564 } 21565 buttonsArray[i + (key === "ArrowLeft" ? -1 : 1)]?.focus(); 21566 }, { 21567 passive: true 21568 }); 21569 } 21570 } 21571 #resetCommon() { 21572 this.#hasDescriptionChanged = false; 21573 this.#description.value = ""; 21574 if (this.#currentTab) { 21575 this.#tabsToAltText.get(this.#currentTab).value = ""; 21576 } 21577 } 21578 #resetTab(name) { 21579 switch (name) { 21580 case "type": 21581 this.#typeInput.value = ""; 21582 break; 21583 case "draw": 21584 this.#drawCurves = null; 21585 this.#drawPoints = null; 21586 this.#drawPathString = ""; 21587 this.#drawPath?.remove(); 21588 this.#drawPath = null; 21589 this.#drawPlaceholder.hidden = false; 21590 this.#drawThickness.value = 1; 21591 break; 21592 case "image": 21593 this.#imagePlaceholder.hidden = false;
21594 this.#imagePath?.remove(); 21595 this.#imagePath = null; 21596 break; 21597 } 21598 } 21599 #initTab(name) { 21600 if (name && this.#currentTab === name) { 21601 return; 21602 } 21603 if (this.#currentTab) { 21604 this.#tabsToAltText.get(this.#currentTab).value = this.#description.value; 21605 } 21606 if (name) { 21607 this.#currentTab = name; 21608 } 21609 this.#errorBar.hidden = true; 21610 const reset = !name; 21611 if (reset) { 21612 this.#resetCommon(); 21613 } else { 21614 this.#description.value = this.#tabsToAltText.get(this.#currentTab).value; 21615 } 21616 this.#clearDescription.disabled = this.#description.value === ""; 21617 this.#currentTabAC?.abort(); 21618 this.#currentTabAC = new AbortController(); 21619 switch (this.#currentTab) { 21620 case "type": 21621 this.#initTypeTab(reset); 21622 break; 21623 case "draw": 21624 this.#initDrawTab(reset); 21625 break; 21626 case "image": 21627 this.#initImageTab(reset); 21628 break; 21629 } 21630 } 21631 #disableButtons(value) { 21632 if (!value || !this.#isStorageFull) { 21633 this.#saveCheckbox.disabled = !value; 21634 } 21635 this.#clearButton.disabled = this.#addButton.disabled = this.#description.disabled = !value; 21636 } 21637 #initTypeTab(reset) { 21638 if (reset) { 21639 this.#resetTab("type"); 21640 } 21641 this.#disableButtons(this.#typeInput.value); 21642 const { 21643 signal 21644 } = this.#currentTabAC; 21645 const options = { 21646 passive: true, 21647 signal 21648 }; 21649 this.#typeInput.addEventListener("input", () => { 21650 const { 21651 value 21652 } = this.#typeInput; 21653 if (!this.#hasDescriptionChanged) { 21654 this.#tabsToAltText.get("type").default = this.#description.value = value; 21655 this.#clearDescription.disabled = value === ""; 21656 } 21657 this.#disableButtons(value); 21658 }, options); 21659 this.#description.addEventListener("input", () => { 21660 this.#hasDescriptionChanged = this.#typeInput.value !== this.#description.value; 21661 }, options); 21662 } 21663 #initDrawTab(reset) { 21664 if (reset) { 21665 this.#resetTab("draw"); 21666 } 21667 this.#disableButtons(this.#drawPath); 21668 const { 21669 signal 21670 } = this.#currentTabAC; 21671 const options = { 21672 signal 21673 }; 21674 let currentPointerId = NaN; 21675 const drawCallback = e => { 21676 const { 21677 pointerId 21678 } = e; 21679 if (!isNaN(currentPointerId) && currentPointerId !== pointerId) { 21680 return; 21681 } 21682 currentPointerId = pointerId; 21683 e.preventDefault(); 21684 this.#drawSVG.setPointerCapture(pointerId); 21685 const { 21686 width: drawWidth, 21687 height: drawHeight 21688 } = this.#drawSVG.getBoundingClientRect(); 21689 let { 21690 offsetX, 21691 offsetY 21692 } = e; 21693 offsetX = Math.round(offsetX); 21694 offsetY = Math.round(offsetY); 21695 if (e.target === this.#drawPlaceholder) { 21696 this.#drawPlaceholder.hidden = true; 21697 } 21698 if (!this.#drawCurves) { 21699 this.#drawCurves = { 21700 width: drawWidth, 21701 height: drawHeight, 21702 thickness: parseInt(this.#drawThickness.value), 21703 curves: [] 21704 }; 21705 this.#disableButtons(true); 21706 const svgFactory = new DOMSVGFactory(); 21707 const path = this.#drawPath = svgFactory.createElement("path"); 21708 path.setAttribute("stroke-width", this.#drawThickness.value); 21709 this.#drawSVG.append(path); 21710 this.#drawSVG.addEventListener("pointerdown", drawCallback, options); 21711 this.#drawPlaceholder.removeEventListener("pointerdown", drawCallback); 21712 if (this.#description.value === "") { 21713 this.#l10n.get(SignatureManager.#l10nDescription.signature).then(description => { 21714 this.#tabsToAltText.get("draw").default = description; 21715 this.#description.value ||= description; 21716 this.#clearDescription.disabled = this.#description.value === ""; 21717 }); 21718 } 21719 } 21720 this.#drawPoints = [offsetX, offsetY]; 21721 this.#drawCurves.curves.push({ 21722 points: this.#drawPoints 21723 }); 21724 this.#drawPathString += `M ${offsetX} ${offsetY}`; 21725 this.#drawPath.setAttribute("d", this.#drawPathString); 21726 const finishDrawAC = new AbortController(); 21727 const listenerDrawOptions = { 21728 signal: AbortSignal.any([signal, finishDrawAC.signal]) 21729 }; 21730 this.#drawSVG.addEventListener("contextmenu", noContextMenu, listenerDrawOptions); 21731 this.#drawSVG.addEventListener("pointermove", evt => { 21732 evt.preventDefault(); 21733 let { 21734 offsetX: x, 21735 offsetY: y 21736 } = evt; 21737 x = Math.round(x); 21738 y = Math.round(y); 21739 const drawPoints = this.#drawPoints; 21740 if (x < 0 || y < 0 || x > drawWidth || y > drawHeight || x === drawPoints.at(-2) && y === drawPoints.at(-1)) { 21741 return; 21742 } 21743 if (drawPoints.length >= 4) { 21744 const [x1, y1, x2, y2] = drawPoints.slice(-4); 21745 this.#drawPathString += `C${(x1 + 5 * x2) / 6} ${(y1 + 5 * y2) / 6} ${(5 * x2 + x) / 6} ${(5 * y2 + y) / 6} ${(x2 + x) / 2} ${(y2 + y) / 2}`; 21746 } else { 21747 this.#drawPathString += `L${x} ${y}`; 21748 } 21749 drawPoints.push(x, y); 21750 this.#drawPath.setAttribute("d", this.#drawPathString); 21751 }, listenerDrawOptions); 21752 this.#drawSVG.addEventListener("pointerup", evt => { 21753 const { 21754 pointerId: pId 21755 } = evt; 21756 if (!isNaN(currentPointerId) && currentPointerId !== pId) { 21757 return; 21758 } 21759 currentPointerId = NaN; 21760 evt.preventDefault(); 21761 this.#drawSVG.releasePointerCapture(pId); 21762 finishDrawAC.abort(); 21763 if (this.#drawPoints.length === 2) { 21764 this.#drawPathString += `L${this.#drawPoints[0]} ${this.#drawPoints[1]}`; 21765 this.#drawPath.setAttribute("d", this.#drawPathString); 21766 } 21767 }, listenerDrawOptions); 21768 }; 21769 if (this.#drawCurves) { 21770 this.#drawSVG.addEventListener("pointerdown", drawCallback, options); 21771 } else { 21772 this.#drawPlaceholder.addEventListener("pointerdown", drawCallback, options); 21773 } 21774 this.#drawThickness.addEventListener("input", () => { 21775 const { 21776 value: thickness 21777 } = this.#drawThickness; 21778 this.#drawThickness.setAttribute("data-l10n-args", JSON.stringify({ 21779 thickness 21780 })); 21781 if (!this.#drawCurves) { 21782 return; 21783 } 21784 this.#drawPath.setAttribute("stroke-width", thickness); 21785 this.#drawCurves.thickness = thickness; 21786 }, options); 21787 } 21788 #showError(type) { 21789 this.#errorTitle.setAttribute("data-l10n-id", SignatureManager.#l10nDescription[`error${type}Title`]); 21790 this.#errorDescription.setAttribute("data-l10n-id", SignatureManager.#l10nDescription[`error${type}Description`]); 21791 this.#errorBar.hidden = false;
21792 } 21793 #initImageTab(reset) { 21794 if (reset) { 21795 this.#resetTab("image"); 21796 } 21797 this.#disableButtons(this.#imagePath); 21798 const { 21799 signal 21800 } = this.#currentTabAC; 21801 const options = { 21802 signal 21803 }; 21804 const passiveOptions = { 21805 passive: true, 21806 signal 21807 }; 21808 this.#imagePickerLink.addEventListener("keydown", e => { 21809 const { 21810 key 21811 } = e; 21812 if (key === "Enter" || key === " ") { 21813 stopEvent(e); 21814 this.#imagePicker.click(); 21815 } 21816 }, options); 21817 this.#imagePicker.addEventListener("click", () => { 21818 this.#dialog.classList.toggle("waiting", true); 21819 }, passiveOptions); 21820 this.#imagePicker.addEventListener("change", async () => { 21821 const file = this.#imagePicker.files?.[0]; 21822 if (!file || !SupportedImageMimeTypes.includes(file.type)) { 21823 this.#showError("Upload"); 21824 this.#dialog.classList.toggle("waiting", false); 21825 return; 21826 } 21827 await this.#extractSignature(file); 21828 }, passiveOptions); 21829 this.#imagePicker.addEventListener("cancel", () => { 21830 this.#dialog.classList.toggle("waiting", false); 21831 }, passiveOptions); 21832 this.#imagePlaceholder.addEventListener("dragover", e => { 21833 const { 21834 dataTransfer 21835 } = e; 21836 for (const { 21837 type 21838 } of dataTransfer.items) { 21839 if (!SupportedImageMimeTypes.includes(type)) { 21840 continue; 21841 } 21842 dataTransfer.dropEffect = dataTransfer.effectAllowed === "copy" ? "copy" : "move"; 21843 stopEvent(e); 21844 return; 21845 } 21846 dataTransfer.dropEffect = "none"; 21847 }, options); 21848 this.#imagePlaceholder.addEventListener("drop", e => { 21849 const { 21850 dataTransfer: { 21851 files 21852 } 21853 } = e; 21854 if (!files?.length) { 21855 return; 21856 } 21857 for (const file of files) { 21858 if (SupportedImageMimeTypes.includes(file.type)) { 21859 this.#extractSignature(file); 21860 break; 21861 } 21862 } 21863 stopEvent(e); 21864 this.#dialog.classList.toggle("waiting", true); 21865 }, options); 21866 } 21867 async #extractSignature(file) { 21868 let data; 21869 try { 21870 data = await this.#uiManager.imageManager.getFromFile(file); 21871 } catch (e) { 21872 console.error("SignatureManager.#extractSignature.", e); 21873 } 21874 if (!data) { 21875 this.#showError("Upload"); 21876 this.#dialog.classList.toggle("waiting", false); 21877 return; 21878 } 21879 const lineData = this.#extractedSignatureData = this.#currentEditor.getFromImage(data.bitmap); 21880 if (!lineData) { 21881 this.#showError("NoData"); 21882 this.#dialog.classList.toggle("waiting", false); 21883 return; 21884 } 21885 const { 21886 outline 21887 } = lineData; 21888 this.#imagePlaceholder.hidden = true; 21889 this.#disableButtons(true); 21890 const svgFactory = new DOMSVGFactory(); 21891 const path = this.#imagePath = svgFactory.createElement("path"); 21892 this.#imageSVG.setAttribute("viewBox", outline.viewBox); 21893 this.#imageSVG.setAttribute("preserveAspectRatio", "xMidYMid meet"); 21894 this.#imageSVG.append(path); 21895 path.setAttribute("d", outline.toSVGPath()); 21896 this.#tabsToAltText.get("image").default = file.name; 21897 if (this.#description.value === "") { 21898 this.#description.value = file.name || ""; 21899 this.#clearDescription.disabled = this.#description.value === ""; 21900 } 21901 this.#dialog.classList.toggle("waiting", false); 21902 } 21903 #getOutlineForType() { 21904 return this.#currentEditor.getFromText(this.#typeInput.value, window.getComputedStyle(this.#typeInput)); 21905 } 21906 #getOutlineForDraw() { 21907 const { 21908 width, 21909 height 21910 } = this.#drawSVG.getBoundingClientRect(); 21911 return this.#currentEditor.getDrawnSignature(this.#drawCurves, width, height); 21912 } 21913 #reportTelemetry(data) { 21914 this.#eventBus.dispatch("reporttelemetry", { 21915 source: this, 21916 details: { 21917 type: "editing", 21918 data 21919 } 21920 }); 21921 } 21922 #addToolbarButton(signatureData, uuid, description) { 21923 const { 21924 curves, 21925 areContours, 21926 thickness, 21927 width, 21928 height 21929 } = signatureData; 21930 const maxDim = Math.max(width, height); 21931 const outlineData = SignatureExtractor.processDrawnLines({ 21932 lines: { 21933 curves, 21934 thickness, 21935 width, 21936 height 21937 }, 21938 pageWidth: maxDim, 21939 pageHeight: maxDim, 21940 rotation: 0, 21941 innerMargin: 0, 21942 mustSmooth: false, 21943 areContours 21944 }); 21945 if (!outlineData) { 21946 return; 21947 } 21948 const { 21949 outline 21950 } = outlineData; 21951 const svgFactory = new DOMSVGFactory(); 21952 const div = document.createElement("div"); 21953 const button = document.createElement("button"); 21954 button.addEventListener("click", () => { 21955 this.#eventBus.dispatch("switchannotationeditorparams", { 21956 source: this, 21957 type: AnnotationEditorParamsType.CREATE, 21958 value: { 21959 signatureData: { 21960 lines: { 21961 curves, 21962 thickness, 21963 width, 21964 height 21965 }, 21966 mustSmooth: false, 21967 areContours, 21968 description, 21969 uuid, 21970 heightInPage: DEFAULT_HEIGHT_IN_PAGE 21971 } 21972 } 21973 }); 21974 }); 21975 div.append(button); 21976 div.classList.add("toolbarAddSignatureButtonContainer"); 21977 const svg = svgFactory.create(1, 1, true); 21978 button.append(svg); 21979 const span = document.createElement("span"); 21980 span.ariaHidden = true; 21981 button.append(span); 21982 button.classList.add("toolbarAddSignatureButton"); 21983 button.type = "button"; 21984 span.textContent = description; 21985 button.setAttribute("data-l10n-id", "pdfjs-editor-add-saved-signature-button"); 21986 button.setAttribute("data-l10n-args", JSON.stringify({ 21987 description 21988 })); 21989 button.tabIndex = 0; 21990 const path = svgFactory.createElement("path"); 21991 svg.append(path); 21992 svg.setAttribute("viewBox", outline.viewBox); 21993 svg.setAttribute("preserveAspectRatio", "xMidYMid meet"); 21994 if (areContours) {
21995 path.classList.add("contours"); 21996 } 21997 path.setAttribute("d", outline.toSVGPath()); 21998 const deleteButton = document.createElement("button"); 21999 div.append(deleteButton); 22000 deleteButton.classList.add("toolbarButton", "deleteButton"); 22001 deleteButton.setAttribute("data-l10n-id", "pdfjs-editor-delete-signature-button1"); 22002 deleteButton.type = "button"; 22003 deleteButton.tabIndex = 0; 22004 deleteButton.addEventListener("click", async () => { 22005 if (await this.#signatureStorage.delete(uuid)) { 22006 div.remove(); 22007 this.#reportTelemetry({ 22008 type: "signature", 22009 action: "pdfjs.signature.delete_saved", 22010 data: { 22011 savedCount: await this.#signatureStorage.size() 22012 } 22013 }); 22014 } 22015 }); 22016 const deleteSpan = document.createElement("span"); 22017 deleteButton.append(deleteSpan); 22018 deleteSpan.setAttribute("data-l10n-id", "pdfjs-editor-delete-signature-button-label1"); 22019 this.#addSignatureToolbarButton.before(div); 22020 } 22021 async #signaturesChanged() { 22022 const parent = this.#addSignatureToolbarButton.parentElement; 22023 while (parent.firstElementChild !== this.#addSignatureToolbarButton) { 22024 parent.firstElementChild.remove(); 22025 } 22026 this.#loadSignaturesPromise = null; 22027 await this.loadSignatures(true); 22028 } 22029 getSignature(params) { 22030 return this.open(params); 22031 } 22032 async loadSignatures(reload = false) { 22033 if (!this.#addSignatureToolbarButton || !reload && this.#addSignatureToolbarButton.previousElementSibling || !this.#signatureStorage) { 22034 return; 22035 } 22036 if (!this.#loadSignaturesPromise) { 22037 this.#loadSignaturesPromise = this.#signatureStorage.getAll().then(async signatures => [signatures, await Promise.all(Array.from(signatures.values(), ({ 22038 signatureData 22039 }) => SignatureExtractor.decompressSignature(signatureData)))]); 22040 if (!reload) { 22041 return; 22042 } 22043 } 22044 const [signatures, signaturesData] = await this.#loadSignaturesPromise; 22045 this.#loadSignaturesPromise = null; 22046 let i = 0; 22047 for (const [uuid, { 22048 description 22049 }] of signatures) { 22050 const data = signaturesData[i++]; 22051 if (!data) { 22052 continue; 22053 } 22054 data.curves = data.outlines.map(points => ({ 22055 points 22056 })); 22057 delete data.outlines; 22058 this.#addToolbarButton(data, uuid, description); 22059 } 22060 } 22061 async renderEditButton(editor) { 22062 const button = document.createElement("button"); 22063 button.classList.add("altText", "editDescription"); 22064 button.tabIndex = 0; 22065 if (editor.description) { 22066 button.title = editor.description; 22067 } 22068 const span = document.createElement("span"); 22069 button.append(span); 22070 span.setAttribute("data-l10n-id", "pdfjs-editor-add-signature-edit-button-label"); 22071 button.addEventListener("click", () => { 22072 this.#editDescriptionDialog.open(editor); 22073 }, { 22074 passive: true 22075 }); 22076 return button; 22077 } 22078 async open({ 22079 uiManager, 22080 editor 22081 }) { 22082 this.#tabsToAltText ||= new Map(this.#tabButtons.keys().map(name => [name, { 22083 value: "", 22084 default: "" 22085 }])); 22086 this.#uiManager = uiManager; 22087 this.#currentEditor = editor; 22088 this.#uiManager.removeEditListeners(); 22089 const isStorageFull = this.#isStorageFull = await this.#signatureStorage.isFull(); 22090 this.#saveContainer.classList.toggle("fullStorage", isStorageFull); 22091 this.#saveCheckbox.checked = !isStorageFull; 22092 await this.#overlayManager.open(this.#dialog); 22093 const tabType = this.#tabButtons.get("type"); 22094 tabType.focus(); 22095 tabType.click(); 22096 } 22097 #cancel() { 22098 this.#finish(); 22099 } 22100 #finish() { 22101 this.#overlayManager.closeIfActive(this.#dialog); 22102 } 22103 #close() { 22104 if (this.#currentEditor._drawId === null) { 22105 this.#currentEditor.remove(); 22106 } 22107 this.#uiManager?.addEditListeners(); 22108 this.#currentTabAC?.abort(); 22109 this.#currentTabAC = null; 22110 this.#uiManager = null; 22111 this.#currentEditor = null; 22112 this.#resetCommon(); 22113 for (const [name] of this.#tabButtons) { 22114 this.#resetTab(name); 22115 } 22116 this.#disableButtons(false); 22117 this.#currentTab = null; 22118 this.#tabsToAltText = null; 22119 } 22120 async #add() { 22121 let data; 22122 const type = this.#currentTab; 22123 switch (type) { 22124 case "type": 22125 data = this.#getOutlineForType(); 22126 break; 22127 case "draw": 22128 data = this.#getOutlineForDraw(); 22129 break; 22130 case "image": 22131 data = this.#extractedSignatureData; 22132 break; 22133 } 22134 let uuid = null; 22135 const description = this.#description.value; 22136 if (this.#saveCheckbox.checked) { 22137 const { 22138 newCurves, 22139 areContours, 22140 thickness, 22141 width, 22142 height 22143 } = data; 22144 const signatureData = await SignatureExtractor.compressSignature({ 22145 outlines: newCurves, 22146 areContours, 22147 thickness, 22148 width, 22149 height 22150 }); 22151 uuid = await this.#signatureStorage.create({ 22152 description, 22153 signatureData 22154 }); 22155 if (uuid) { 22156 this.#addToolbarButton({ 22157 curves: newCurves.map(points => ({ 22158 points 22159 })), 22160 areContours, 22161 thickness, 22162 width, 22163 height 22164 }, uuid, description); 22165 } else { 22166 console.warn("SignatureManager.add: cannot save the signature."); 22167 } 22168 } 22169 const altText = this.#tabsToAltText.get(type); 22170 this.#reportTelemetry({ 22171 type: "signature", 22172 action: "pdfjs.signature.created", 22173 data: { 22174 type, 22175 saved: !!uuid, 22176 savedCount: await this.#signatureStorage.size(), 22177 descriptionChanged: description !== altText.default 22178 } 22179 }); 22180 this.#currentEditor.addSignature(data, DEFAULT_HEIGHT_IN_PAGE, this.#description.value, uuid); 22181 this.#finish(); 22182 } 22183 destroy() { 22184 this.#uiManager = null; 22185 this.#finish(); 22186 } 22187} 22188class EditDescriptionDialog { 22189 #currentEditor; 22190 #previousDescription; 22191 #description; 22192 #dialog; 22193 #overlayManager; 22194 #signatureSVG; 22195 #uiManager; 22196 constructor({ 22197 dialog, 22198 description, 22199 cancelButton, 22200 updateButton, 22201 editSignatureView 22202 }, overlayManager) { 22203 const descriptionInput = this.#description = description.firstElementChild; 22204 this.#signatureSVG = editSignatureView; 22205 this.#dialog = dialog; 22206 this.#overlayManager = overlayManager; 22207 dialog.addEventListener("close", this.#close.bind(this)); 22208 dialog.addEventListener("contextmenu", e => { 22209 if (e.target !== this.#description) { 22210 e.preventDefault(); 22211 } 22212 }); 22213 cancelButton.addEventListener("click", this.#cancel.bind(this)); 22214 updateButton.addEventListener("click", this.#update.bind(this)); 22215 const clearDescription = description.lastElementChild; 22216 clearDescription.addEventListener("click", () => { 22217 descriptionInput.value = ""; 22218 clearDescription.disabled = true; 22219 updateButton.disabled = this.#previousDescription === ""; 22220 }); 22221 descriptionInput.addEventListener("input", () => { 22222 const { 22223 value 22224 } = descriptionInput; 22225 clearDescription.disabled = value === ""; 22226 updateButton.disabled = value === this.#previousDescription; 22227 editSignatureView.setAttribute("aria-label", value); 22228 }, {
22229 passive: true 22230 }); 22231 overlayManager.register(dialog); 22232 } 22233 async open(editor) { 22234 this.#uiManager = editor._uiManager; 22235 this.#currentEditor = editor; 22236 this.#previousDescription = this.#description.value = editor.description; 22237 this.#description.dispatchEvent(new Event("input")); 22238 this.#uiManager.removeEditListeners(); 22239 const { 22240 areContours, 22241 outline 22242 } = editor.getSignaturePreview(); 22243 const svgFactory = new DOMSVGFactory(); 22244 const path = svgFactory.createElement("path"); 22245 this.#signatureSVG.append(path); 22246 this.#signatureSVG.setAttribute("viewBox", outline.viewBox); 22247 path.setAttribute("d", outline.toSVGPath()); 22248 if (areContours) { 22249 path.classList.add("contours"); 22250 } 22251 await this.#overlayManager.open(this.#dialog); 22252 } 22253 async #update() { 22254 this.#currentEditor._reportTelemetry({ 22255 action: "pdfjs.signature.edit_description", 22256 data: { 22257 hasBeenChanged: true 22258 } 22259 }); 22260 this.#currentEditor.description = this.#description.value; 22261 this.#finish(); 22262 } 22263 #cancel() { 22264 this.#currentEditor._reportTelemetry({ 22265 action: "pdfjs.signature.edit_description", 22266 data: { 22267 hasBeenChanged: false 22268 } 22269 }); 22270 this.#finish(); 22271 } 22272 #finish() { 22273 this.#overlayManager.closeIfActive(this.#dialog); 22274 } 22275 #close() { 22276 this.#uiManager?.addEditListeners(); 22277 this.#uiManager = null; 22278 this.#currentEditor = null; 22279 this.#signatureSVG.firstElementChild.remove(); 22280 } 22281} 22282 22283;// ./web/toolbar.js 22284 22285 22286 22287class Toolbar { 22288 #colorPicker = null; 22289 #opts; 22290 constructor(options, eventBus, toolbarDensity = 0) { 22291 this.#opts = options; 22292 this.eventBus = eventBus; 22293 const buttons = [{ 22294 element: options.previous, 22295 eventName: "previouspage" 22296 }, { 22297 element: options.next, 22298 eventName: "nextpage" 22299 }, { 22300 element: options.zoomIn, 22301 eventName: "zoomin" 22302 }, { 22303 element: options.zoomOut, 22304 eventName: "zoomout" 22305 }, { 22306 element: options.print, 22307 eventName: "print" 22308 }, { 22309 element: options.download, 22310 eventName: "download" 22311 }, { 22312 element: options.editorCommentButton, 22313 eventName: "switchannotationeditormode", 22314 eventDetails: { 22315 get mode() { 22316 const { 22317 classList 22318 } = options.editorCommentButton; 22319 return classList.contains("toggled") ? AnnotationEditorType.NONE : AnnotationEditorType.POPUP; 22320 } 22321 } 22322 }, { 22323 element: options.editorFreeTextButton, 22324 eventName: "switchannotationeditormode", 22325 eventDetails: { 22326 get mode() { 22327 const { 22328 classList 22329 } = options.editorFreeTextButton; 22330 return classList.contains("toggled") ? AnnotationEditorType.NONE : AnnotationEditorType.FREETEXT; 22331 } 22332 } 22333 }, { 22334 element: options.editorHighlightButton, 22335 eventName: "switchannotationeditormode", 22336 eventDetails: { 22337 get mode() { 22338 const { 22339 classList 22340 } = options.editorHighlightButton; 22341 return classList.contains("toggled") ? AnnotationEditorType.NONE : AnnotationEditorType.HIGHLIGHT; 22342 } 22343 } 22344 }, { 22345 element: options.editorInkButton, 22346 eventName: "switchannotationeditormode", 22347 eventDetails: { 22348 get mode() { 22349 const { 22350 classList 22351 } = options.editorInkButton; 22352 return classList.contains("toggled") ? AnnotationEditorType.NONE : AnnotationEditorType.INK; 22353 } 22354 } 22355 }, { 22356 element: options.editorStampButton, 22357 eventName: "switchannotationeditormode", 22358 eventDetails: { 22359 get mode() { 22360 const { 22361 classList 22362 } = options.editorStampButton; 22363 return classList.contains("toggled") ? AnnotationEditorType.NONE : AnnotationEditorType.STAMP; 22364 } 22365 }, 22366 telemetry: { 22367 type: "editing", 22368 data: { 22369 action: "pdfjs.image.icon_click" 22370 } 22371 } 22372 }, { 22373 element: options.editorSignatureButton, 22374 eventName: "switchannotationeditormode", 22375 eventDetails: { 22376 get mode() { 22377 const { 22378 classList 22379 } = options.editorSignatureButton; 22380 return classList.contains("toggled") ? AnnotationEditorType.NONE : AnnotationEditorType.SIGNATURE; 22381 } 22382 } 22383 }]; 22384 this.#bindListeners(buttons); 22385 this.#updateToolbarDensity({ 22386 value: toolbarDensity 22387 }); 22388 this.reset(); 22389 } 22390 #updateToolbarDensity({ 22391 value 22392 }) { 22393 let name = "normal"; 22394 switch (value) { 22395 case 1: 22396 name = "compact"; 22397 break; 22398 case 2: 22399 name = "touch"; 22400 break; 22401 } 22402 document.documentElement.setAttribute("data-toolbar-density", name); 22403 } 22404 setPageNumber(pageNumber, pageLabel) { 22405 this.pageNumber = pageNumber; 22406 this.pageLabel = pageLabel; 22407 this.#updateUIState(false); 22408 } 22409 setPagesCount(pagesCount, hasPageLabels) { 22410 this.pagesCount = pagesCount; 22411 this.hasPageLabels = hasPageLabels; 22412 this.#updateUIState(true); 22413 } 22414 setPageScale(pageScaleValue, pageScale) { 22415 this.pageScaleValue = (pageScaleValue || pageScale).toString(); 22416 this.pageScale = pageScale; 22417 this.#updateUIState(false); 22418 } 22419 reset() { 22420 this.#colorPicker = null; 22421 this.pageNumber = 0; 22422 this.pageLabel = null; 22423 this.hasPageLabels = false;
22424 this.pagesCount = 0; 22425 this.pageScaleValue = DEFAULT_SCALE_VALUE; 22426 this.pageScale = DEFAULT_SCALE; 22427 this.#updateUIState(true); 22428 this.updateLoadingIndicatorState(); 22429 this.#editorModeChanged({ 22430 mode: AnnotationEditorType.DISABLE 22431 }); 22432 } 22433 #bindListeners(buttons) { 22434 const { 22435 eventBus 22436 } = this; 22437 const { 22438 editorHighlightColorPicker, 22439 editorHighlightButton, 22440 pageNumber, 22441 scaleSelect 22442 } = this.#opts; 22443 const self = this; 22444 for (const { 22445 element, 22446 eventName, 22447 eventDetails, 22448 telemetry 22449 } of buttons) { 22450 element.addEventListener("click", evt => { 22451 if (eventName !== null) { 22452 eventBus.dispatch(eventName, { 22453 source: this, 22454 ...eventDetails, 22455 isFromKeyboard: evt.detail === 0 22456 }); 22457 } 22458 if (telemetry) { 22459 eventBus.dispatch("reporttelemetry", { 22460 source: this, 22461 details: telemetry 22462 }); 22463 } 22464 }); 22465 } 22466 pageNumber.addEventListener("click", function () { 22467 this.select(); 22468 }); 22469 pageNumber.addEventListener("change", function () { 22470 eventBus.dispatch("pagenumberchanged", { 22471 source: self, 22472 value: this.value 22473 }); 22474 }); 22475 eventBus._on("pagesedited", ({ 22476 pagesMapper 22477 }) => { 22478 const pagesCount = pagesMapper.pagesNumber; 22479 if (pagesCount !== this.pagesCount) { 22480 this.setPagesCount(pagesCount, this.hasPageLabels); 22481 } 22482 }); 22483 scaleSelect.addEventListener("change", function () { 22484 if (this.value === "custom") { 22485 return; 22486 } 22487 eventBus.dispatch("scalechanged", { 22488 source: self, 22489 value: this.value 22490 }); 22491 }); 22492 scaleSelect.addEventListener("click", function ({ 22493 target 22494 }) { 22495 if (this.value === self.pageScaleValue && target.tagName.toUpperCase() === "OPTION") { 22496 this.blur(); 22497 } 22498 }); 22499 scaleSelect.oncontextmenu = noContextMenu; 22500 eventBus._on("annotationeditormodechanged", this.#editorModeChanged.bind(this)); 22501 eventBus._on("showannotationeditorui", ({ 22502 mode 22503 }) => { 22504 switch (mode) { 22505 case AnnotationEditorType.HIGHLIGHT: 22506 editorHighlightButton.click(); 22507 break; 22508 } 22509 }); 22510 eventBus._on("toolbardensity", this.#updateToolbarDensity.bind(this)); 22511 if (editorHighlightColorPicker) { 22512 eventBus._on("annotationeditoruimanager", ({ 22513 uiManager 22514 }) => { 22515 const cp = this.#colorPicker = new ColorPicker({ 22516 uiManager 22517 }); 22518 uiManager.setMainHighlightColorPicker(cp); 22519 editorHighlightColorPicker.append(cp.renderMainDropdown()); 22520 }); 22521 eventBus._on("mainhighlightcolorpickerupdatecolor", ({ 22522 value 22523 }) => { 22524 this.#colorPicker?.updateColor(value); 22525 }); 22526 } 22527 } 22528 #editorModeChanged({ 22529 mode 22530 }) { 22531 const { 22532 editorCommentButton, 22533 editorCommentParamsToolbar, 22534 editorFreeTextButton, 22535 editorFreeTextParamsToolbar, 22536 editorHighlightButton, 22537 editorHighlightParamsToolbar, 22538 editorInkButton, 22539 editorInkParamsToolbar, 22540 editorStampButton, 22541 editorStampParamsToolbar, 22542 editorSignatureButton, 22543 editorSignatureParamsToolbar 22544 } = this.#opts; 22545 toggleExpandedBtn(editorCommentButton, mode === AnnotationEditorType.POPUP, editorCommentParamsToolbar); 22546 toggleExpandedBtn(editorFreeTextButton, mode === AnnotationEditorType.FREETEXT, editorFreeTextParamsToolbar); 22547 toggleExpandedBtn(editorHighlightButton, mode === AnnotationEditorType.HIGHLIGHT, editorHighlightParamsToolbar); 22548 toggleExpandedBtn(editorInkButton, mode === AnnotationEditorType.INK, editorInkParamsToolbar); 22549 toggleExpandedBtn(editorStampButton, mode === AnnotationEditorType.STAMP, editorStampParamsToolbar); 22550 toggleExpandedBtn(editorSignatureButton, mode === AnnotationEditorType.SIGNATURE, editorSignatureParamsToolbar); 22551 editorCommentButton.disabled = editorFreeTextButton.disabled = editorHighlightButton.disabled = editorInkButton.disabled = editorStampButton.disabled = editorSignatureButton.disabled = mode === AnnotationEditorType.DISABLE; 22552 } 22553 #updateUIState(resetNumPages = false) { 22554 const { 22555 pageNumber, 22556 pagesCount, 22557 pageScaleValue, 22558 pageScale 22559 } = this; 22560 const opts = this.#opts; 22561 if (resetNumPages) { 22562 if (this.hasPageLabels) { 22563 opts.pageNumber.type = "text"; 22564 opts.numPages.setAttribute("data-l10n-id", "pdfjs-page-of-pages"); 22565 } else { 22566 opts.pageNumber.type = "number"; 22567 opts.numPages.setAttribute("data-l10n-id", "pdfjs-of-pages"); 22568 opts.numPages.setAttribute("data-l10n-args", JSON.stringify({ 22569 pagesCount 22570 })); 22571 } 22572 opts.pageNumber.max = pagesCount; 22573 } 22574 if (this.hasPageLabels) { 22575 opts.pageNumber.value = this.pageLabel; 22576 opts.numPages.setAttribute("data-l10n-args", JSON.stringify({ 22577 pageNumber, 22578 pagesCount 22579 })); 22580 } else { 22581 opts.pageNumber.value = pageNumber; 22582 } 22583 opts.previous.disabled = pageNumber <= 1; 22584 opts.next.disabled = pageNumber >= pagesCount; 22585 opts.zoomOut.disabled = pageScale <= MIN_SCALE; 22586 opts.zoomIn.disabled = pageScale >= MAX_SCALE; 22587 let predefinedValueFound = false;
22588 for (const option of opts.scaleSelect.options) { 22589 if (option.value !== pageScaleValue) { 22590 option.selected = false; 22591 continue; 22592 } 22593 option.selected = true; 22594 predefinedValueFound = true; 22595 } 22596 if (!predefinedValueFound) { 22597 opts.customScaleOption.selected = true; 22598 opts.customScaleOption.setAttribute("data-l10n-args", JSON.stringify({ 22599 scale: Math.round(pageScale * 10000) / 100 22600 })); 22601 } 22602 } 22603 updateLoadingIndicatorState(loading = false) { 22604 const { 22605 pageNumber 22606 } = this.#opts; 22607 pageNumber.classList.toggle("loading", loading); 22608 } 22609} 22610 22611;// ./web/view_history.js 22612 22613 22614 22615const DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20; 22616class ViewHistory { 22617 constructor(fingerprint, cacheSize = DEFAULT_VIEW_HISTORY_CACHE_SIZE) { 22618 this.fingerprint = fingerprint; 22619 this.cacheSize = cacheSize; 22620 this._initializedPromise = this._readFromStorage().then(databaseStr => { 22621 const database = JSON.parse(databaseStr || "{}"); 22622 let index = -1; 22623 if (!Array.isArray(database.files)) { 22624 database.files = []; 22625 } else { 22626 while (database.files.length >= this.cacheSize) { 22627 database.files.shift(); 22628 } 22629 for (let i = 0, ii = database.files.length; i < ii; i++) { 22630 const branch = database.files[i]; 22631 if (branch.fingerprint === this.fingerprint) { 22632 index = i; 22633 break; 22634 } 22635 } 22636 } 22637 if (index === -1) { 22638 index = database.files.push({ 22639 fingerprint: this.fingerprint 22640 }) - 1; 22641 } 22642 this.file = database.files[index]; 22643 this.database = database; 22644 }); 22645 } 22646 async _writeToStorage() { 22647 const databaseStr = JSON.stringify(this.database); 22648 localStorage.setItem("pdfjs.history", databaseStr); 22649 } 22650 async _readFromStorage() { 22651 return localStorage.getItem("pdfjs.history"); 22652 } 22653 async set(name, val) { 22654 await this._initializedPromise; 22655 this.file[name] = val; 22656 return this._writeToStorage(); 22657 } 22658 async setMultiple(properties) { 22659 await this._initializedPromise; 22660 for (const name in properties) { 22661 this.file[name] = properties[name]; 22662 } 22663 return this._writeToStorage(); 22664 } 22665 async get(name, defaultValue) { 22666 await this._initializedPromise; 22667 const val = this.file[name]; 22668 return val !== undefined ? val : defaultValue; 22669 } 22670 async getMultiple(properties) { 22671 await this._initializedPromise; 22672 const values = Object.create(null); 22673 for (const name in properties) { 22674 const val = this.file[name]; 22675 values[name] = val !== undefined ? val : properties[name]; 22676 } 22677 return values; 22678 } 22679} 22680 22681;// ./web/views_manager.js 22682 22683 22684 22685const SIDEBAR_WIDTH_VAR = "--viewsManager-width"; 22686const SIDEBAR_RESIZING_CLASS = "viewsManagerResizing"; 22687const UI_NOTIFICATION_CLASS = "pdfSidebarNotification"; 22688class ViewsManager extends Sidebar { 22689 static #l10nDescription = null; 22690 #hasAnimations = !window.matchMedia("(prefers-reduced-motion: reduce)").matches; 22691 constructor({ 22692 elements: { 22693 outerContainer, 22694 sidebarContainer, 22695 toggleButton, 22696 resizer, 22697 thumbnailButton, 22698 outlineButton, 22699 attachmentsButton, 22700 layersButton, 22701 thumbnailsView, 22702 outlinesView, 22703 attachmentsView, 22704 layersView, 22705 viewsManagerAddFileButton, 22706 viewsManagerCurrentOutlineButton, 22707 viewsManagerSelectorButton, 22708 viewsManagerSelectorOptions, 22709 viewsManagerHeaderLabel, 22710 viewsManagerStatus 22711 }, 22712 eventBus, 22713 l10n 22714 }) { 22715 super({ 22716 sidebar: sidebarContainer, 22717 resizer, 22718 toggleButton 22719 }, l10n.getDirection() === "ltr", false); 22720 this.isOpen = false; 22721 this.active = SidebarView.THUMBS; 22722 this.isInitialViewSet = false; 22723 this.isInitialEventDispatched = false; 22724 this.onToggled = null; 22725 this.onUpdateThumbnails = null; 22726 this.outerContainer = outerContainer; 22727 this.sidebarContainer = sidebarContainer; 22728 this.toggleButton = toggleButton; 22729 this.resizer = resizer; 22730 this.thumbnailButton = thumbnailButton; 22731 this.outlineButton = outlineButton; 22732 this.attachmentsButton = attachmentsButton; 22733 this.layersButton = layersButton; 22734 this.thumbnailsView = thumbnailsView; 22735 this.outlinesView = outlinesView; 22736 this.attachmentsView = attachmentsView; 22737 this.layersView = layersView; 22738 this.viewsManagerAddFileButton = viewsManagerAddFileButton; 22739 this.viewsManagerCurrentOutlineButton = viewsManagerCurrentOutlineButton; 22740 this.viewsManagerHeaderLabel = viewsManagerHeaderLabel; 22741 this.viewsManagerStatus = viewsManagerStatus; 22742 this.eventBus = eventBus; 22743 this.menu = new Menu(viewsManagerSelectorOptions, viewsManagerSelectorButton, [thumbnailButton, outlineButton, attachmentsButton, layersButton]); 22744 ViewsManager.#l10nDescription ||= Object.freeze({ 22745 pagesTitle: "pdfjs-views-manager-pages-title", 22746 outlinesTitle: "pdfjs-views-manager-outlines-title", 22747 attachmentsTitle: "pdfjs-views-manager-attachments-title", 22748 layersTitle: "pdfjs-views-manager-layers-title", 22749 notificationButton: "pdfjs-toggle-views-manager-notification-button", 22750 toggleButton: "pdfjs-toggle-views-manager-button" 22751 }); 22752 this.#addEventListeners(); 22753 } 22754 reset() { 22755 this.isInitialViewSet = false;
22756 this.isInitialEventDispatched = false; 22757 this.#hideUINotification(true); 22758 this.switchView(SidebarView.THUMBS); 22759 this.outlineButton.disabled = this.attachmentsButton.disabled = this.layersButton.disabled = false; 22760 this.viewsManagerCurrentOutlineButton.disabled = true; 22761 } 22762 get visibleView() { 22763 return this.isOpen ? this.active : SidebarView.NONE; 22764 } 22765 setInitialView(view = SidebarView.NONE) { 22766 if (this.isInitialViewSet) { 22767 return; 22768 } 22769 this.isInitialViewSet = true; 22770 if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) { 22771 this.#dispatchEvent(); 22772 return; 22773 } 22774 this.switchView(view, true); 22775 if (!this.isInitialEventDispatched) { 22776 this.#dispatchEvent(); 22777 } 22778 } 22779 switchView(view, forceOpen = false) { 22780 const isViewChanged = view !== this.active; 22781 let forceRendering = false; 22782 let titleL10nId = null; 22783 switch (view) { 22784 case SidebarView.NONE: 22785 if (this.isOpen) { 22786 this.close(); 22787 } 22788 return; 22789 case SidebarView.THUMBS: 22790 titleL10nId = "pagesTitle"; 22791 if (this.isOpen && isViewChanged) { 22792 forceRendering = true; 22793 } 22794 break; 22795 case SidebarView.OUTLINE: 22796 titleL10nId = "outlinesTitle"; 22797 if (this.outlineButton.disabled) { 22798 return; 22799 } 22800 break; 22801 case SidebarView.ATTACHMENTS: 22802 titleL10nId = "attachmentsTitle"; 22803 if (this.attachmentsButton.disabled) { 22804 return; 22805 } 22806 break; 22807 case SidebarView.LAYERS: 22808 titleL10nId = "layersTitle"; 22809 if (this.layersButton.disabled) { 22810 return; 22811 } 22812 break; 22813 default: 22814 console.error(`PDFSidebar.switchView: "${view}" is not a valid view.`); 22815 return; 22816 } 22817 this.viewsManagerStatus.hidden = view !== SidebarView.THUMBS; 22818 this.viewsManagerAddFileButton.hidden = view !== SidebarView.THUMBS; 22819 this.viewsManagerCurrentOutlineButton.hidden = view !== SidebarView.OUTLINE; 22820 this.viewsManagerHeaderLabel.setAttribute("data-l10n-id", ViewsManager.#l10nDescription[titleL10nId] || ""); 22821 this.active = view; 22822 toggleSelectedBtn(this.thumbnailButton, view === SidebarView.THUMBS, this.thumbnailsView); 22823 toggleSelectedBtn(this.outlineButton, view === SidebarView.OUTLINE, this.outlinesView); 22824 toggleSelectedBtn(this.attachmentsButton, view === SidebarView.ATTACHMENTS, this.attachmentsView); 22825 toggleSelectedBtn(this.layersButton, view === SidebarView.LAYERS, this.layersView); 22826 if (forceOpen && !this.isOpen) { 22827 this.open(); 22828 return; 22829 } 22830 if (forceRendering) { 22831 this.onUpdateThumbnails(); 22832 this.onToggled(); 22833 } 22834 if (isViewChanged) { 22835 this.#dispatchEvent(); 22836 } 22837 } 22838 open() { 22839 if (this.isOpen) { 22840 return; 22841 } 22842 this.isOpen = true; 22843 this.onResizing(this.width); 22844 this._sidebar.hidden = false; 22845 toggleExpandedBtn(this.toggleButton, true); 22846 this.switchView(this.active); 22847 if (this.#hasAnimations) { 22848 queueMicrotask(() => { 22849 this.outerContainer.classList.add("viewsManagerMoving", "viewsManagerOpen"); 22850 }); 22851 } else { 22852 this.outerContainer.classList.add("viewsManagerOpen"); 22853 this.eventBus.dispatch("resize", { 22854 source: this 22855 }); 22856 } 22857 if (this.active === SidebarView.THUMBS) { 22858 this.onUpdateThumbnails(); 22859 } 22860 this.onToggled(); 22861 this.#dispatchEvent(); 22862 this.#hideUINotification(); 22863 } 22864 close(evt = null) { 22865 if (!this.isOpen) { 22866 return; 22867 } 22868 this.isOpen = false; 22869 this._sidebar.hidden = true; 22870 toggleExpandedBtn(this.toggleButton, false); 22871 this.outerContainer.classList.add("viewsManagerMoving"); 22872 this.outerContainer.classList.remove("viewsManagerOpen"); 22873 this.onToggled(); 22874 this.#dispatchEvent(); 22875 if (evt?.detail > 0) { 22876 this.toggleButton.blur(); 22877 } 22878 } 22879 toggle(evt = null) { 22880 super.toggle(); 22881 if (this.isOpen) { 22882 this.close(evt); 22883 } else { 22884 this.open(); 22885 } 22886 } 22887 #dispatchEvent() { 22888 if (this.isInitialViewSet) { 22889 this.isInitialEventDispatched ||= true; 22890 } 22891 this.eventBus.dispatch("sidebarviewchanged", { 22892 source: this, 22893 view: this.visibleView 22894 }); 22895 } 22896 #showUINotification() { 22897 this.toggleButton.setAttribute("data-l10n-id", ViewsManager.#l10nDescription.notificationButton); 22898 if (!this.isOpen) { 22899 this.toggleButton.classList.add(UI_NOTIFICATION_CLASS); 22900 } 22901 } 22902 #hideUINotification(reset = false) { 22903 if (this.isOpen || reset) { 22904 this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS); 22905 } 22906 if (reset) { 22907 this.toggleButton.setAttribute("data-l10n-id", ViewsManager.#l10nDescription.toggleButton); 22908 } 22909 } 22910 #addEventListeners() { 22911 const { 22912 eventBus, 22913 outerContainer 22914 } = this; 22915 if (this.#hasAnimations) { 22916 this.sidebarContainer.addEventListener("transitionend", evt => { 22917 if (evt.target === this.sidebarContainer) { 22918 outerContainer.classList.remove("viewsManagerMoving"); 22919 eventBus.dispatch("resize", { 22920 source: this 22921 }); 22922 } 22923 }); 22924 } 22925 this.thumbnailButton.addEventListener("click", () => { 22926 this.switchView(SidebarView.THUMBS); 22927 }); 22928 this.outlineButton.addEventListener("click", () => { 22929 this.switchView(SidebarView.OUTLINE); 22930 }); 22931 this.outlineButton.addEventListener("dblclick", () => { 22932 eventBus.dispatch("toggleoutlinetree", { 22933 source: this 22934 }); 22935 }); 22936 this.attachmentsButton.addEventListener("click", () => { 22937 this.switchView(SidebarView.ATTACHMENTS); 22938 }); 22939 this.layersButton.addEventListener("click", () => { 22940 this.switchView(SidebarView.LAYERS); 22941 }); 22942 this.layersButton.addEventListener("dblclick", () => { 22943 eventBus.dispatch("resetlayers", { 22944 source: this 22945 }); 22946 }); 22947 this.viewsManagerCurrentOutlineButton.addEventListener("click", () => { 22948 eventBus.dispatch("currentoutlineitem", { 22949 source: this 22950 }); 22951 }); 22952 const onTreeLoaded = (count, button, view) => { 22953 button.disabled = !count; 22954 if (count) { 22955 this.#showUINotification(); 22956 } else if (this.active === view) { 22957 this.switchView(SidebarView.THUMBS); 22958 } 22959 }; 22960 eventBus._on("outlineloaded", evt => { 22961 onTreeLoaded(evt.outlineCount, this.outlineButton, SidebarView.OUTLINE); 22962 evt.currentOutlineItemPromise.then(enabled => { 22963 if (!this.isInitialViewSet) { 22964 return; 22965 } 22966 this.viewsManagerCurrentOutlineButton.disabled = !enabled; 22967 }); 22968 }); 22969 eventBus._on("attachmentsloaded", evt => { 22970 onTreeLoaded(evt.attachmentsCount, this.attachmentsButton, SidebarView.ATTACHMENTS); 22971 }); 22972 eventBus._on("layersloaded", evt => { 22973 onTreeLoaded(evt.layersCount, this.layersButton, SidebarView.LAYERS); 22974 }); 22975 eventBus._on("presentationmodechanged", evt => { 22976 if (evt.state === PresentationModeState.NORMAL && this.visibleView === SidebarView.THUMBS) { 22977 this.onUpdateThumbnails(); 22978 } 22979 }); 22980 } 22981 onStartResizing() { 22982 this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS); 22983 } 22984 onStopResizing() { 22985 this.eventBus.dispatch("resize", { 22986 source: this 22987 }); 22988 this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS); 22989 } 22990 onResizing(newWidth) { 22991 docStyle.setProperty(SIDEBAR_WIDTH_VAR, `${newWidth}px`); 22992 } 22993} 22994 22995;// ./web/app.js 22996 22997 22998 22999 23000 23001 23002 23003 23004 23005 23006 23007 23008 23009 23010 23011 23012 23013 23014 23015 23016 23017 23018 23019 23020 23021 23022 23023 23024 23025 23026 23027 23028 23029 23030 23031 23032 23033 23034 23035 23036 23037 23038 23039 23040 23041 23042 23043 23044 23045 23046 23047 23048 23049 23050const FORCE_PAGES_LOADED_TIMEOUT = 10000; 23051const ViewOnLoad = { 23052 UNKNOWN: -1, 23053 PREVIOUS: 0, 23054 INITIAL: 1 23055}; 23056const PDFViewerApplication = { 23057 initialBookmark: document.location.hash.substring(1), 23058 _initializedCapability: { 23059 ...Promise.withResolvers(), 23060 settled: false 23061 }, 23062 appConfig: null, 23063 pdfDocument: null, 23064 pdfLoadingTask: null, 23065 printService: null, 23066 pdfViewer: null,
23067 pdfThumbnailViewer: null, 23068 pdfRenderingQueue: null, 23069 pdfPresentationMode: null, 23070 pdfDocumentProperties: null, 23071 pdfLinkService: null, 23072 pdfTextExtractor: null, 23073 pdfHistory: null, 23074 viewsManager: null, 23075 pdfOutlineViewer: null, 23076 pdfAttachmentViewer: null, 23077 pdfLayerViewer: null, 23078 pdfCursorTools: null, 23079 pdfScriptingManager: null, 23080 store: null, 23081 downloadManager: null, 23082 overlayManager: null, 23083 preferences: new Preferences(), 23084 toolbar: null, 23085 secondaryToolbar: null, 23086 eventBus: null, 23087 l10n: null, 23088 annotationEditorParams: null, 23089 imageAltTextSettings: null, 23090 isInitialViewSet: false, 23091 isViewerEmbedded: window.parent !== window, 23092 url: "", 23093 baseUrl: "", 23094 mlManager: null, 23095 _downloadUrl: "", 23096 _eventBusAbortController: null, 23097 _windowAbortController: null, 23098 _globalAbortController: new AbortController(), 23099 documentInfo: null, 23100 metadata: null, 23101 _contentDispositionFilename: null, 23102 _contentLength: null, 23103 _saveInProgress: false, 23104 _wheelUnusedTicks: 0, 23105 _wheelUnusedFactor: 1, 23106 _touchManager: null, 23107 _touchUnusedTicks: 0, 23108 _touchUnusedFactor: 1, 23109 _PDFBug: null, 23110 _hasAnnotationEditors: false, 23111 _title: document.title, 23112 _printAnnotationStoragePromise: null, 23113 _isCtrlKeyDown: false, 23114 _caretBrowsing: null, 23115 _isScrolling: false, 23116 editorUndoBar: null, 23117 _printPermissionPromise: null, 23118 async initialize(appConfig) { 23119 this.appConfig = appConfig; 23120 try { 23121 await this.preferences.initializedPromise; 23122 } catch (ex) { 23123 console.error("initialize:", ex); 23124 } 23125 if (AppOptions.get("pdfBugEnabled")) { 23126 await this._parseHashParams(); 23127 } 23128 let mode; 23129 switch (AppOptions.get("viewerCssTheme")) { 23130 case 1: 23131 mode = "light"; 23132 break; 23133 case 2: 23134 mode = "dark"; 23135 break; 23136 } 23137 if (mode) { 23138 docStyle.setProperty("color-scheme", mode); 23139 } 23140 this.l10n = await this.externalServices.createL10n(); 23141 document.getElementsByTagName("html")[0].dir = this.l10n.getDirection(); 23142 this.l10n.translate(appConfig.appContainer || document.documentElement); 23143 if (this.isViewerEmbedded && AppOptions.get("externalLinkTarget") === LinkTarget.NONE) { 23144 AppOptions.set("externalLinkTarget", LinkTarget.TOP); 23145 } 23146 await this._initializeViewerComponents(); 23147 this.pdfTextExtractor = new PdfTextExtractor(this.externalServices); 23148 this.bindEvents(); 23149 this.bindWindowEvents(); 23150 this._initializedCapability.settled = true; 23151 this._initializedCapability.resolve(); 23152 }, 23153 async _parseHashParams() { 23154 const hash = document.location.hash.substring(1); 23155 if (!hash) { 23156 return; 23157 } 23158 const { 23159 mainContainer, 23160 viewerContainer 23161 } = this.appConfig, 23162 params = parseQueryString(hash); 23163 const loadPDFBug = async () => { 23164 if (this._PDFBug) { 23165 return; 23166 } 23167 const { 23168 PDFBug 23169 } = await import( 23170 /*webpackIgnore: true*/ 23171 /*@vite-ignore*/ 23172 AppOptions.get("debuggerSrc")); 23173 this._PDFBug = PDFBug; 23174 }; 23175 if (params.get("disableworker") === "true") { 23176 try { 23177 GlobalWorkerOptions.workerSrc ||= AppOptions.get("workerSrc"); 23178 await import( 23179 /*webpackIgnore: true*/ 23180 /*@vite-ignore*/ 23181 PDFWorker.workerSrc); 23182 AppOptions.set("workerPort", null); 23183 } catch (ex) { 23184 console.error("_parseHashParams:", ex); 23185 } 23186 } 23187 if (params.has("textlayer")) { 23188 switch (params.get("textlayer")) { 23189 case "off": 23190 AppOptions.set("textLayerMode", TextLayerMode.DISABLE); 23191 break; 23192 case "visible": 23193 case "shadow": 23194 case "hover": 23195 viewerContainer.classList.add(`textLayer-${params.get("textlayer")}`); 23196 try { 23197 await loadPDFBug(); 23198 this._PDFBug.loadCSS(); 23199 } catch (ex) { 23200 console.error("_parseHashParams:", ex); 23201 } 23202 break; 23203 } 23204 } 23205 if (params.has("pdfbug")) { 23206 const enabled = params.get("pdfbug").split(","); 23207 try { 23208 await loadPDFBug(); 23209 this._PDFBug.init(mainContainer, enabled); 23210 } catch (ex) { 23211 console.error("_parseHashParams:", ex); 23212 } 23213 const debugOpts = { 23214 pdfBug: true, 23215 fontExtraProperties: true 23216 }; 23217 if (globalThis.StepperManager?.enabled) { 23218 debugOpts.minDurationToUpdateCanvas = 0; 23219 } 23220 AppOptions.setAll(debugOpts); 23221 } 23222 if (params.has("locale")) { 23223 AppOptions.set("localeProperties", { 23224 lang: params.get("locale") 23225 }); 23226 } 23227 const opts = { 23228 disableAutoFetch: x => x === "true", 23229 disableFontFace: x => x === "true", 23230 disableHistory: x => x === "true", 23231 disableRange: x => x === "true", 23232 disableStream: x => x === "true", 23233 verbosity: x => x | 0 23234 }; 23235 for (const name in opts) { 23236 const check = opts[name], 23237 key = name.toLowerCase(); 23238 if (params.has(key)) { 23239 AppOptions.set(name, check(params.get(key))); 23240 } 23241 } 23242 }, 23243 async _initializeViewerComponents() { 23244 const { 23245 appConfig, 23246 externalServices, 23247 l10n, 23248 mlManager 23249 } = this; 23250 const abortSignal = this._globalAbortController.signal; 23251 const eventBus = new EventBus(); 23252 this.eventBus = AppOptions.eventBus = eventBus; 23253 mlManager?.setEventBus(eventBus, abortSignal); 23254 const overlayManager = this.overlayManager = new OverlayManager(); 23255 const renderingQueue = this.pdfRenderingQueue = new PDFRenderingQueue(); 23256 renderingQueue.onIdle = this._cleanup.bind(this); 23257 const linkService = this.pdfLinkService = new PDFLinkService({ 23258 eventBus, 23259 externalLinkTarget: AppOptions.get("externalLinkTarget"), 23260 externalLinkRel: AppOptions.get("externalLinkRel"), 23261 ignoreDestinationZoom: AppOptions.get("ignoreDestinationZoom") 23262 }); 23263 const downloadManager = this.downloadManager = new DownloadManager(); 23264 const findController = this.findController = new PDFFindController({ 23265 linkService, 23266 eventBus, 23267 updateMatchesCountOnProgress: true 23268 }); 23269 const pdfScriptingManager = this.pdfScriptingManager = new PDFScriptingManager({ 23270 eventBus, 23271 externalServices, 23272 docProperties: this._scriptingDocProperties.bind(this) 23273 }); 23274 const container = appConfig.mainContainer, 23275 viewer = appConfig.viewerContainer; 23276 const annotationEditorMode = AppOptions.get("annotationEditorMode"); 23277 const hasForcedColors = AppOptions.get("forcePageColors") || window.matchMedia("(forced-colors: active)").matches; 23278 const pageColors = hasForcedColors ? {
23279 background: AppOptions.get("pageColorsBackground"), 23280 foreground: AppOptions.get("pageColorsForeground") 23281 } : null; 23282 let altTextManager; 23283 if (AppOptions.get("enableUpdatedAddImage")) { 23284 altTextManager = appConfig.newAltTextDialog ? new NewAltTextManager(appConfig.newAltTextDialog, overlayManager, eventBus) : null; 23285 } else { 23286 altTextManager = appConfig.altTextDialog ? new AltTextManager(appConfig.altTextDialog, container, overlayManager, eventBus) : null; 23287 } 23288 if (appConfig.editorUndoBar) { 23289 this.editorUndoBar = new EditorUndoBar(appConfig.editorUndoBar, eventBus); 23290 } 23291 const signatureManager = AppOptions.get("enableSignatureEditor") && appConfig.addSignatureDialog ? new SignatureManager(appConfig.addSignatureDialog, appConfig.editSignatureDialog, appConfig.annotationEditorParams?.editorSignatureAddSignature || null, overlayManager, l10n, externalServices.createSignatureStorage(eventBus, abortSignal), eventBus) : null; 23292 const ltr = appConfig.viewerContainer ? getComputedStyle(appConfig.viewerContainer).direction === "ltr" : true; 23293 const commentManager = AppOptions.get("enableComment") && appConfig.editCommentDialog ? new CommentManager(appConfig.editCommentDialog, { 23294 learnMoreUrl: AppOptions.get("commentLearnMoreUrl"), 23295 sidebar: appConfig.annotationEditorParams?.editorCommentsSidebar || null, 23296 sidebarResizer: appConfig.annotationEditorParams?.editorCommentsSidebarResizer || null, 23297 commentsList: appConfig.annotationEditorParams?.editorCommentsSidebarList || null, 23298 commentCount: appConfig.annotationEditorParams?.editorCommentsSidebarCount || null, 23299 sidebarTitle: appConfig.annotationEditorParams?.editorCommentsSidebarTitle || null, 23300 closeButton: appConfig.annotationEditorParams?.editorCommentsSidebarCloseButton || null, 23301 commentToolbarButton: appConfig.toolbar?.editorCommentButton || null 23302 }, eventBus, linkService, overlayManager, ltr, hasForcedColors) : null; 23303 const enableHWA = AppOptions.get("enableHWA"), 23304 maxCanvasPixels = AppOptions.get("maxCanvasPixels"), 23305 maxCanvasDim = AppOptions.get("maxCanvasDim"), 23306 capCanvasAreaFactor = AppOptions.get("capCanvasAreaFactor"); 23307 const pdfViewer = this.pdfViewer = new PDFViewer({ 23308 container, 23309 viewer, 23310 viewerAlert: appConfig.viewerAlert, 23311 eventBus, 23312 renderingQueue, 23313 linkService, 23314 downloadManager, 23315 altTextManager, 23316 commentManager, 23317 signatureManager, 23318 editorUndoBar: this.editorUndoBar, 23319 findController, 23320 scriptingManager: AppOptions.get("enableScripting") && pdfScriptingManager, 23321 l10n, 23322 textLayerMode: AppOptions.get("textLayerMode"), 23323 annotationMode: AppOptions.get("annotationMode"), 23324 annotationEditorMode, 23325 annotationEditorHighlightColors: AppOptions.get("highlightEditorColors"), 23326 enableHighlightFloatingButton: AppOptions.get("enableHighlightFloatingButton"), 23327 enableUpdatedAddImage: AppOptions.get("enableUpdatedAddImage"), 23328 enableNewAltTextWhenAddingImage: AppOptions.get("enableNewAltTextWhenAddingImage"), 23329 imageResourcesPath: AppOptions.get("imageResourcesPath"), 23330 enablePrintAutoRotate: AppOptions.get("enablePrintAutoRotate"), 23331 maxCanvasPixels, 23332 maxCanvasDim, 23333 capCanvasAreaFactor, 23334 enableDetailCanvas: AppOptions.get("enableDetailCanvas"), 23335 enablePermissions: AppOptions.get("enablePermissions"), 23336 enableOptimizedPartialRendering: AppOptions.get("enableOptimizedPartialRendering"), 23337 pageColors, 23338 mlManager, 23339 abortSignal, 23340 enableHWA, 23341 supportsPinchToZoom: this.supportsPinchToZoom, 23342 enableAutoLinking: AppOptions.get("enableAutoLinking"), 23343 minDurationToUpdateCanvas: AppOptions.get("minDurationToUpdateCanvas") 23344 }); 23345 renderingQueue.setViewer(pdfViewer); 23346 linkService.setViewer(pdfViewer); 23347 pdfScriptingManager.setViewer(pdfViewer); 23348 if (appConfig.viewsManager?.thumbnailsView) { 23349 this.pdfThumbnailViewer = new PDFThumbnailViewer({ 23350 container: appConfig.viewsManager.thumbnailsView, 23351 eventBus, 23352 renderingQueue, 23353 linkService, 23354 maxCanvasPixels, 23355 maxCanvasDim, 23356 pageColors, 23357 abortSignal, 23358 enableHWA, 23359 enableSplitMerge: AppOptions.get("enableSplitMerge"), 23360 manageMenu: appConfig.viewsManager.manageMenu, 23361 addFileButton: appConfig.viewsManager.viewsManagerAddFileButton 23362 });
23363 renderingQueue.setThumbnailViewer(this.pdfThumbnailViewer); 23364 } 23365 if (!this.isViewerEmbedded && !AppOptions.get("disableHistory")) { 23366 this.pdfHistory = new PDFHistory({ 23367 linkService, 23368 eventBus 23369 }); 23370 linkService.setHistory(this.pdfHistory); 23371 } 23372 if (!this.supportsIntegratedFind && appConfig.findBar) { 23373 this.findBar = new PDFFindBar(appConfig.findBar, appConfig.principalContainer, eventBus); 23374 } 23375 if (appConfig.annotationEditorParams) { 23376 if (annotationEditorMode !== AnnotationEditorType.DISABLE) { 23377 const editorSignatureButton = appConfig.toolbar?.editorSignatureButton; 23378 if (editorSignatureButton && AppOptions.get("enableSignatureEditor")) { 23379 editorSignatureButton.parentElement.hidden = false; 23380 } 23381 const editorCommentButton = appConfig.toolbar?.editorCommentButton; 23382 if (editorCommentButton && AppOptions.get("enableComment")) { 23383 editorCommentButton.parentElement.hidden = false; 23384 } 23385 this.annotationEditorParams = new AnnotationEditorParams(appConfig.annotationEditorParams, eventBus); 23386 } else { 23387 for (const id of ["editorModeButtons", "editorModeSeparator"]) { 23388 document.getElementById(id)?.classList.add("hidden"); 23389 } 23390 } 23391 } 23392 if (mlManager && appConfig.secondaryToolbar?.imageAltTextSettingsButton) { 23393 this.imageAltTextSettings = new ImageAltTextSettings(appConfig.altTextSettingsDialog, overlayManager, eventBus, mlManager); 23394 } 23395 if (appConfig.documentProperties) { 23396 this.pdfDocumentProperties = new PDFDocumentProperties(appConfig.documentProperties, overlayManager, eventBus, l10n, () => this._docFilename, () => this._docTitle); 23397 } 23398 if (appConfig.secondaryToolbar?.cursorHandToolButton) { 23399 this.pdfCursorTools = new PDFCursorTools({ 23400 container, 23401 eventBus, 23402 cursorToolOnLoad: AppOptions.get("cursorToolOnLoad") 23403 }); 23404 } 23405 if (appConfig.toolbar) { 23406 this.toolbar = new Toolbar(appConfig.toolbar, eventBus, AppOptions.get("toolbarDensity")); 23407 } 23408 if (appConfig.secondaryToolbar) { 23409 if (AppOptions.get("enableAltText")) { 23410 appConfig.secondaryToolbar.imageAltTextSettingsButton?.classList.remove("hidden"); 23411 appConfig.secondaryToolbar.imageAltTextSettingsSeparator?.classList.remove("hidden"); 23412 } 23413 this.secondaryToolbar = new SecondaryToolbar(appConfig.secondaryToolbar, eventBus); 23414 } 23415 if (this.supportsFullscreen && appConfig.secondaryToolbar?.presentationModeButton) { 23416 this.pdfPresentationMode = new PDFPresentationMode({ 23417 container, 23418 pdfViewer, 23419 eventBus 23420 }); 23421 } 23422 if (appConfig.passwordOverlay) { 23423 this.passwordPrompt = new PasswordPrompt(appConfig.passwordOverlay, overlayManager, this.isViewerEmbedded); 23424 } 23425 if (appConfig.viewsManager?.outlinesView) { 23426 this.pdfOutlineViewer = new PDFOutlineViewer({ 23427 container: appConfig.viewsManager.outlinesView, 23428 eventBus, 23429 l10n, 23430 linkService, 23431 downloadManager 23432 }); 23433 } 23434 if (appConfig.viewsManager?.attachmentsView) { 23435 this.pdfAttachmentViewer = new PDFAttachmentViewer({ 23436 container: appConfig.viewsManager.attachmentsView, 23437 eventBus, 23438 l10n, 23439 downloadManager 23440 }); 23441 } 23442 if (appConfig.viewsManager?.layersView) { 23443 this.pdfLayerViewer = new PDFLayerViewer({ 23444 container: appConfig.viewsManager.layersView, 23445 eventBus, 23446 l10n 23447 }); 23448 } 23449 if (appConfig.viewsManager) { 23450 this.viewsManager = new ViewsManager({ 23451 elements: appConfig.viewsManager, 23452 eventBus, 23453 l10n 23454 }); 23455 this.viewsManager.onToggled = this.forceRendering.bind(this); 23456 this.viewsManager.onUpdateThumbnails = () => { 23457 for (const pageView of pdfViewer.getCachedPageViews()) { 23458 if (pageView.renderingState === RenderingStates.FINISHED) { 23459 this.pdfThumbnailViewer.getThumbnail(pageView.id - 1)?.setImage(pageView); 23460 } 23461 } 23462 this.pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber); 23463 }; 23464 } 23465 }, 23466 async run(config) { 23467 await this.initialize(config); 23468 const { 23469 appConfig, 23470 eventBus 23471 } = this; 23472 let file; 23473 const queryString = document.location.search.substring(1); 23474 const params = parseQueryString(queryString); 23475 file = params.get("file") ?? AppOptions.get("defaultUrl"); 23476 try { 23477 file = new URL(file).href; 23478 } catch { 23479 file = encodeURIComponent(file).replaceAll("%2F", "/"); 23480 } 23481 validateFileURL(file); 23482 const fileInput = this._openFileInput = document.createElement("input"); 23483 fileInput.id = "fileInput"; 23484 fileInput.hidden = true; 23485 fileInput.type = "file"; 23486 fileInput.value = null; 23487 document.body.append(fileInput); 23488 fileInput.addEventListener("change", function (evt) { 23489 const { 23490 files 23491 } = evt.target; 23492 if (!files || files.length === 0) { 23493 return; 23494 } 23495 eventBus.dispatch("fileinputchange", { 23496 source: this, 23497 fileInput: evt.target 23498 }); 23499 }); 23500 appConfig.mainContainer.addEventListener("dragover", function (evt) { 23501 for (const item of evt.dataTransfer.items) { 23502 if (item.type === "application/pdf") { 23503 evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === "copy" ? "copy" : "move"; 23504 stopEvent(evt); 23505 return; 23506 } 23507 } 23508 }); 23509 appConfig.mainContainer.addEventListener("drop", function (evt) { 23510 if (evt.dataTransfer.files?.[0].type !== "application/pdf") { 23511 return; 23512 } 23513 stopEvent(evt); 23514 eventBus.dispatch("fileinputchange", { 23515 source: this, 23516 fileInput: evt.dataTransfer 23517 }); 23518 }); 23519 if (!AppOptions.get("supportsDocumentFonts")) { 23520 AppOptions.set("disableFontFace", true); 23521 this.l10n.get("pdfjs-web-fonts-disabled").then(msg => { 23522 console.warn(msg); 23523 }); 23524 } 23525 const togglePrintingButtons = visible => { 23526 appConfig.toolbar?.print?.classList.toggle("hidden", !visible); 23527 appConfig.secondaryToolbar?.printButton.classList.toggle("hidden", !visible); 23528 }; 23529 if (!this.supportsPrinting) { 23530 togglePrintingButtons(false); 23531 } else { 23532 eventBus.on("printingallowed", ({ 23533 isAllowed 23534 }) => togglePrintingButtons(isAllowed)); 23535 } 23536 if (!this.supportsFullscreen) { 23537 appConfig.secondaryToolbar?.presentationModeButton.classList.add("hidden"); 23538 } 23539 if (this.supportsIntegratedFind) { 23540 appConfig.findBar?.toggleButton?.classList.add("hidden"); 23541 } 23542 if (file) { 23543 this.open({ 23544 url: file 23545 }); 23546 } else { 23547 this._hideViewBookmark(); 23548 } 23549 }, 23550 get externalServices() { 23551 return shadow(this, "externalServices", new ExternalServices()); 23552 }, 23553 get initialized() { 23554 return this._initializedCapability.settled; 23555 }, 23556 get initializedPromise() { 23557 return this._initializedCapability.promise; 23558 }, 23559 updateZoom(steps, scaleFactor, origin) { 23560 if (this.pdfViewer.isInPresentationMode) { 23561 return; 23562 } 23563 this.pdfViewer.updateScale({ 23564 drawingDelay: AppOptions.get("defaultZoomDelay"), 23565 steps, 23566 scaleFactor, 23567 origin 23568 }); 23569 }, 23570 zoomIn() { 23571 this.updateZoom(1); 23572 }, 23573 zoomOut() { 23574 this.updateZoom(-1); 23575 }, 23576 zoomReset() { 23577 if (this.pdfViewer.isInPresentationMode) { 23578 return; 23579 } 23580 this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE; 23581 }, 23582 touchPinchCallback(origin, prevDistance, distance) { 23583 if (this.supportsPinchToZoom) { 23584 const newScaleFactor = this._accumulateFactor(this.pdfViewer.currentScale, distance / prevDistance, "_touchUnusedFactor"); 23585 this.updateZoom(null, newScaleFactor, origin); 23586 } else { 23587 const PIXELS_PER_LINE_SCALE = 30; 23588 const ticks = this._accumulateTicks((distance - prevDistance) / PIXELS_PER_LINE_SCALE, "_touchUnusedTicks"); 23589 this.updateZoom(ticks, null, origin); 23590 } 23591 }, 23592 touchPinchEndCallback() { 23593 this._touchUnusedTicks = 0; 23594 this._touchUnusedFactor = 1; 23595 }, 23596 get pagesCount() { 23597 return this.pdfDocument ? this.pdfDocument.numPages : 0; 23598 }, 23599 get page() { 23600 return this.pdfViewer.currentPageNumber; 23601 }, 23602 set page(val) { 23603 this.pdfViewer.currentPageNumber = val; 23604 }, 23605 get supportsPrinting() {
23606 return shadow(this, "supportsPrinting", AppOptions.get("supportsPrinting") && PDFPrintServiceFactory.supportsPrinting); 23607 }, 23608 get supportsFullscreen() { 23609 return shadow(this, "supportsFullscreen", document.fullscreenEnabled); 23610 }, 23611 get supportsPinchToZoom() { 23612 return shadow(this, "supportsPinchToZoom", AppOptions.get("supportsPinchToZoom")); 23613 }, 23614 get supportsIntegratedFind() { 23615 return shadow(this, "supportsIntegratedFind", AppOptions.get("supportsIntegratedFind")); 23616 }, 23617 get loadingBar() { 23618 const barElement = document.getElementById("loadingBar"); 23619 const bar = barElement ? new ProgressBar(barElement) : null; 23620 return shadow(this, "loadingBar", bar); 23621 }, 23622 get supportsMouseWheelZoomCtrlKey() { 23623 return shadow(this, "supportsMouseWheelZoomCtrlKey", AppOptions.get("supportsMouseWheelZoomCtrlKey")); 23624 }, 23625 get supportsMouseWheelZoomMetaKey() { 23626 return shadow(this, "supportsMouseWheelZoomMetaKey", AppOptions.get("supportsMouseWheelZoomMetaKey")); 23627 }, 23628 get supportsCaretBrowsingMode() { 23629 return AppOptions.get("supportsCaretBrowsingMode"); 23630 }, 23631 moveCaret(isUp, select) { 23632 this._caretBrowsing ||= new CaretBrowsingMode(this._globalAbortController.signal, this.appConfig.mainContainer, this.appConfig.viewerContainer, this.appConfig.toolbar?.container); 23633 this._caretBrowsing.moveCaret(isUp, select); 23634 }, 23635 setTitleUsingUrl(url = "", downloadUrl = null) { 23636 this.url = url; 23637 this.baseUrl = updateUrlHash(url, "", true); 23638 if (downloadUrl) { 23639 this._downloadUrl = downloadUrl === url ? this.baseUrl : updateUrlHash(downloadUrl, "", true); 23640 } 23641 if (isDataScheme(url)) { 23642 this._hideViewBookmark(); 23643 } 23644 let title = getPdfFilenameFromUrl(url, ""); 23645 if (!title) { 23646 try { 23647 title = decodeURIComponent(getFilenameFromUrl(url)); 23648 } catch {} 23649 } 23650 this.setTitle(title || url); 23651 }, 23652 setTitle(title = this._title) { 23653 this._title = title; 23654 if (this.isViewerEmbedded) { 23655 return; 23656 } 23657 const editorIndicator = this._hasAnnotationEditors && !this.pdfRenderingQueue.printing; 23658 document.title = `${editorIndicator ? "* " : ""}${title}`; 23659 }, 23660 get _docFilename() { 23661 return this._contentDispositionFilename || getPdfFilenameFromUrl(this.url); 23662 }, 23663 get _docTitle() { 23664 const { 23665 documentInfo, 23666 metadata 23667 } = this; 23668 const title = metadata?.get("dc:title"); 23669 if (title) { 23670 if (title !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(title)) { 23671 return title; 23672 } 23673 } 23674 return documentInfo.Title; 23675 }, 23676 _hideViewBookmark() { 23677 const { 23678 secondaryToolbar 23679 } = this.appConfig; 23680 secondaryToolbar?.viewBookmarkButton.classList.add("hidden"); 23681 if (secondaryToolbar?.presentationModeButton.classList.contains("hidden")) { 23682 document.getElementById("viewBookmarkSeparator")?.classList.add("hidden"); 23683 } 23684 }, 23685 async close() { 23686 this._unblockDocumentLoadEvent(); 23687 this._hideViewBookmark(); 23688 if (!this.pdfLoadingTask) { 23689 return; 23690 } 23691 if (this.pdfDocument?.annotationStorage.size > 0 && this._annotationStorageModified) { 23692 try { 23693 await this.save(); 23694 } catch {} 23695 } 23696 const promises = []; 23697 promises.push(this.pdfLoadingTask.destroy()); 23698 this.pdfLoadingTask = null; 23699 if (this.pdfDocument) { 23700 this.pdfDocument = null; 23701 this.pdfThumbnailViewer?.setDocument(null); 23702 this.pdfViewer.setDocument(null); 23703 this.pdfLinkService.setDocument(null); 23704 this.pdfDocumentProperties?.setDocument(null); 23705 this.pdfTextExtractor?.setViewer(null); 23706 } 23707 this.pdfLinkService.externalLinkEnabled = true; 23708 this.store = null; 23709 this.isInitialViewSet = false; 23710 this.url = ""; 23711 this.baseUrl = ""; 23712 this._downloadUrl = ""; 23713 this.documentInfo = null; 23714 this.metadata = null; 23715 this._contentDispositionFilename = null; 23716 this._contentLength = null; 23717 this._saveInProgress = false; 23718 this._hasAnnotationEditors = false; 23719 promises.push(this.pdfScriptingManager.destroyPromise, this.passwordPrompt.close()); 23720 this.setTitle(); 23721 this.viewsManager?.reset(); 23722 this.pdfOutlineViewer?.reset(); 23723 this.pdfAttachmentViewer?.reset(); 23724 this.pdfLayerViewer?.reset(); 23725 this.pdfHistory?.reset(); 23726 this.findBar?.reset(); 23727 this.toolbar?.reset(); 23728 this.secondaryToolbar?.reset(); 23729 this._PDFBug?.cleanup(); 23730 await Promise.all(promises); 23731 }, 23732 async open(args) { 23733 if (this.pdfLoadingTask) { 23734 await this.close(); 23735 } 23736 const workerParams = AppOptions.getAll(OptionKind.WORKER);
23737 Object.assign(GlobalWorkerOptions, workerParams); 23738 if (args.url) { 23739 this.setTitleUsingUrl(args.originalUrl || args.url, args.url); 23740 } 23741 const apiParams = AppOptions.getAll(OptionKind.API); 23742 const loadingTask = getDocument({ 23743 ...apiParams, 23744 ...args 23745 }); 23746 this.pdfLoadingTask = loadingTask; 23747 loadingTask.onPassword = (updateCallback, reason) => { 23748 if (this.isViewerEmbedded) { 23749 this._unblockDocumentLoadEvent(); 23750 } 23751 this.pdfLinkService.externalLinkEnabled = false; 23752 this.passwordPrompt.setUpdateCallback(updateCallback, reason); 23753 this.passwordPrompt.open(); 23754 }; 23755 loadingTask.onProgress = evt => this.progress(evt.percent); 23756 return loadingTask.promise.then(pdfDocument => { 23757 this.load(pdfDocument); 23758 }, reason => { 23759 if (loadingTask !== this.pdfLoadingTask) { 23760 return undefined; 23761 } 23762 let key = "pdfjs-loading-error"; 23763 if (reason instanceof InvalidPDFException) { 23764 key = "pdfjs-invalid-file-error"; 23765 } else if (reason instanceof ResponseException) { 23766 key = reason.missing ? "pdfjs-missing-file-error" : "pdfjs-unexpected-response-error"; 23767 } 23768 return this._documentError(key, { 23769 message: reason.message 23770 }).then(() => { 23771 throw reason; 23772 }); 23773 }); 23774 }, 23775 async download() { 23776 let data; 23777 try { 23778 data = await (this.pdfDocument ? this.pdfDocument.getData() : this.pdfLoadingTask.getData()); 23779 } catch {} 23780 this.downloadManager.download(data, this._downloadUrl, this._docFilename); 23781 }, 23782 async save() { 23783 if (this._saveInProgress) { 23784 return; 23785 } 23786 this._saveInProgress = true; 23787 await this.pdfScriptingManager.dispatchWillSave(); 23788 try { 23789 const data = await this.pdfDocument.saveDocument(); 23790 this.downloadManager.download(data, this._downloadUrl, this._docFilename); 23791 } catch (reason) { 23792 console.error(`Error when saving the document:`, reason); 23793 await this.download(); 23794 } finally { 23795 await this.pdfScriptingManager.dispatchDidSave(); 23796 this._saveInProgress = false; 23797 } 23798 const editorStats = this.pdfDocument?.annotationStorage.editorStats; 23799 if (editorStats) { 23800 this.externalServices.reportTelemetry({ 23801 type: "editing", 23802 data: { 23803 type: "save", 23804 stats: editorStats 23805 } 23806 }); 23807 } 23808 }, 23809 async downloadOrSave() { 23810 const { 23811 classList 23812 } = this.appConfig.appContainer; 23813 classList.add("wait"); 23814 await (this.pdfDocument?.annotationStorage.size > 0 ? this.save() : this.download()); 23815 classList.remove("wait"); 23816 }, 23817 async _documentError(key, moreInfo = null) { 23818 this._unblockDocumentLoadEvent(); 23819 const message = await this._otherError(key || "pdfjs-loading-error", moreInfo); 23820 this.eventBus.dispatch("documenterror", { 23821 source: this, 23822 message, 23823 reason: moreInfo?.message ?? null 23824 }); 23825 }, 23826 async _otherError(key, moreInfo = null) { 23827 const message = await this.l10n.get(key); 23828 const moreInfoText = [`PDF.js v${version || "?"} (build: ${build || "?"})`]; 23829 if (moreInfo) { 23830 moreInfoText.push(`Message: ${moreInfo.message}`); 23831 if (moreInfo.stack) { 23832 moreInfoText.push(`Stack: ${moreInfo.stack}`); 23833 } else { 23834 if (moreInfo.filename) { 23835 moreInfoText.push(`File: ${moreInfo.filename}`); 23836 } 23837 if (moreInfo.lineNumber) { 23838 moreInfoText.push(`Line: ${moreInfo.lineNumber}`); 23839 } 23840 } 23841 } 23842 console.error(`${message}\n\n${moreInfoText.join("\n")}`); 23843 return message; 23844 }, 23845 progress(percent) { 23846 if (!this.loadingBar || percent <= this.loadingBar.percent) { 23847 return; 23848 } 23849 this.loadingBar.percent = percent; 23850 if (this.pdfDocument?.loadingParams.disableAutoFetch ?? AppOptions.get("disableAutoFetch")) { 23851 this.loadingBar.setDisableAutoFetch(); 23852 } 23853 }, 23854 load(pdfDocument) { 23855 this.pdfDocument = pdfDocument; 23856 this._printPermissionPromise = new Promise(resolve => { 23857 this.eventBus.on("printingallowed", ({ 23858 isAllowed 23859 }) => { 23860 resolve(isAllowed); 23861 }, { 23862 once: true 23863 }); 23864 }); 23865 pdfDocument.getDownloadInfo().then(({ 23866 length 23867 }) => { 23868 this._contentLength = length; 23869 this.loadingBar?.hide(); 23870 firstPagePromise.then(() => { 23871 this.eventBus.dispatch("documentloaded", { 23872 source: this 23873 }); 23874 }); 23875 }); 23876 const pageLayoutPromise = pdfDocument.getPageLayout().catch(() => {}); 23877 const pageModePromise = pdfDocument.getPageMode().catch(() => {}); 23878 const openActionPromise = pdfDocument.getOpenAction().catch(() => {}); 23879 this.toolbar?.setPagesCount(pdfDocument.numPages, false); 23880 this.secondaryToolbar?.setPagesCount(pdfDocument.numPages); 23881 this.pdfLinkService.setDocument(pdfDocument); 23882 this.pdfDocumentProperties?.setDocument(pdfDocument); 23883 const pdfViewer = this.pdfViewer; 23884 pdfViewer.setDocument(pdfDocument); 23885 this.pdfTextExtractor.setViewer(pdfViewer); 23886 const { 23887 firstPagePromise, 23888 onePageRendered, 23889 pagesPromise 23890 } = pdfViewer;
23891 this.pdfThumbnailViewer?.setDocument(pdfDocument); 23892 const storedPromise = (this.store = new ViewHistory(pdfDocument.fingerprints[0])).getMultiple({ 23893 page: null, 23894 zoom: DEFAULT_SCALE_VALUE, 23895 scrollLeft: "0", 23896 scrollTop: "0", 23897 rotation: null, 23898 sidebarView: SidebarView.UNKNOWN, 23899 scrollMode: ScrollMode.UNKNOWN, 23900 spreadMode: SpreadMode.UNKNOWN 23901 }).catch(() => {}); 23902 firstPagePromise.then(pdfPage => { 23903 this.loadingBar?.setWidth(this.appConfig.viewerContainer); 23904 this._initializeAnnotationStorageCallbacks(pdfDocument); 23905 Promise.all([animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then(async ([timeStamp, stored, pageLayout, pageMode, openAction]) => { 23906 const viewOnLoad = AppOptions.get("viewOnLoad"); 23907 this._initializePdfHistory({ 23908 fingerprint: pdfDocument.fingerprints[0], 23909 viewOnLoad, 23910 initialDest: openAction?.dest 23911 }); 23912 const initialBookmark = this.initialBookmark; 23913 const zoom = AppOptions.get("defaultZoomValue"); 23914 let hash = zoom ? `zoom=${zoom}` : null; 23915 let rotation = null; 23916 let sidebarView = AppOptions.get("sidebarViewOnLoad"); 23917 let scrollMode = AppOptions.get("scrollModeOnLoad"); 23918 let spreadMode = AppOptions.get("spreadModeOnLoad"); 23919 if (stored?.page && viewOnLoad !== ViewOnLoad.INITIAL) { 23920 hash = `page=${stored.page}&zoom=${zoom || stored.zoom},` + `${stored.scrollLeft},${stored.scrollTop}`; 23921 rotation = parseInt(stored.rotation, 10); 23922 if (sidebarView === SidebarView.UNKNOWN) { 23923 sidebarView = stored.sidebarView | 0; 23924 } 23925 if (scrollMode === ScrollMode.UNKNOWN) { 23926 scrollMode = stored.scrollMode | 0; 23927 } 23928 if (spreadMode === SpreadMode.UNKNOWN) { 23929 spreadMode = stored.spreadMode | 0; 23930 } 23931 } 23932 if (pageMode && sidebarView === SidebarView.UNKNOWN) { 23933 sidebarView = apiPageModeToSidebarView(pageMode); 23934 } 23935 if (pageLayout && scrollMode === ScrollMode.UNKNOWN && spreadMode === SpreadMode.UNKNOWN) { 23936 const modes = apiPageLayoutToViewerModes(pageLayout); 23937 spreadMode = modes.spreadMode; 23938 } 23939 this.setInitialView(hash, { 23940 rotation, 23941 sidebarView, 23942 scrollMode, 23943 spreadMode 23944 }); 23945 this.eventBus.dispatch("documentinit", { 23946 source: this 23947 }); 23948 await Promise.race([pagesPromise, new Promise(resolve => { 23949 setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT); 23950 })]); 23951 if (!initialBookmark && !hash) { 23952 return; 23953 } 23954 if (pdfViewer.hasEqualPageSizes) { 23955 return; 23956 } 23957 this.initialBookmark = initialBookmark; 23958 pdfViewer.currentScaleValue = pdfViewer.currentScaleValue; 23959 this.setInitialView(hash); 23960 }).catch(() => { 23961 this.setInitialView(); 23962 }).then(function () { 23963 pdfViewer.update(); 23964 }); 23965 }); 23966 pagesPromise.then(() => { 23967 this._unblockDocumentLoadEvent(); 23968 this._initializeAutoPrint(pdfDocument, openActionPromise); 23969 }, reason => { 23970 this._documentError("pdfjs-loading-error", { 23971 message: reason.message 23972 }); 23973 }); 23974 onePageRendered.then(data => { 23975 this.externalServices.reportTelemetry({ 23976 type: "pageInfo", 23977 timestamp: data.timestamp 23978 }); 23979 if (this.pdfOutlineViewer) { 23980 pdfDocument.getOutline().then(outline => { 23981 if (pdfDocument !== this.pdfDocument) { 23982 return; 23983 } 23984 this.pdfOutlineViewer.render({ 23985 outline, 23986 pdfDocument 23987 }); 23988 }); 23989 } 23990 if (this.pdfAttachmentViewer) { 23991 pdfDocument.getAttachments().then(attachments => { 23992 if (pdfDocument !== this.pdfDocument) { 23993 return; 23994 } 23995 this.pdfAttachmentViewer.render({ 23996 attachments 23997 }); 23998 }); 23999 } 24000 if (this.pdfLayerViewer) { 24001 pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => { 24002 if (pdfDocument !== this.pdfDocument) { 24003 return; 24004 } 24005 this.pdfLayerViewer.render({ 24006 optionalContentConfig, 24007 pdfDocument 24008 }); 24009 }); 24010 } 24011 }); 24012 this._initializePageLabels(pdfDocument); 24013 this._initializeMetadata(pdfDocument); 24014 }, 24015 async _scriptingDocProperties(pdfDocument) { 24016 if (!this.documentInfo) { 24017 await new Promise(resolve => { 24018 this.eventBus._on("metadataloaded", resolve, { 24019 once: true 24020 }); 24021 }); 24022 if (pdfDocument !== this.pdfDocument) { 24023 return null; 24024 } 24025 } 24026 if (!this._contentLength) { 24027 await new Promise(resolve => { 24028 this.eventBus._on("documentloaded", resolve, { 24029 once: true 24030 }); 24031 }); 24032 if (pdfDocument !== this.pdfDocument) { 24033 return null; 24034 } 24035 } 24036 return { 24037 ...this.documentInfo, 24038 baseURL: this.baseUrl, 24039 filesize: this._contentLength, 24040 filename: this._docFilename, 24041 metadata: this.metadata?.getRaw(), 24042 authors: this.metadata?.get("dc:creator"), 24043 numPages: this.pagesCount, 24044 URL: this.url 24045 }; 24046 }, 24047 async _initializeAutoPrint(pdfDocument, openActionPromise) { 24048 const [openAction, jsActions] = await Promise.all([openActionPromise, this.pdfViewer.enableScripting ? null : pdfDocument.getJSActions()]); 24049 if (pdfDocument !== this.pdfDocument) { 24050 return; 24051 } 24052 let triggerAutoPrint = openAction?.action === "Print"; 24053 if (jsActions) { 24054 console.warn("Warning: JavaScript support is not enabled"); 24055 for (const name in jsActions) { 24056 if (triggerAutoPrint) { 24057 break; 24058 } 24059 switch (name) { 24060 case "WillClose": 24061 case "WillSave": 24062 case "DidSave": 24063 case "WillPrint": 24064 case "DidPrint": 24065 continue; 24066 } 24067 triggerAutoPrint = jsActions[name].some(js => AutoPrintRegExp.test(js)); 24068 } 24069 } 24070 if (triggerAutoPrint) { 24071 this.triggerPrinting(); 24072 } 24073 }, 24074 async _initializeMetadata(pdfDocument) { 24075 const { 24076 info, 24077 metadata, 24078 contentDispositionFilename, 24079 contentLength, 24080 hasStructTree 24081 } = await pdfDocument.getMetadata(); 24082 if (pdfDocument !== this.pdfDocument) { 24083 return; 24084 } 24085 this.externalServices.reportTelemetry({ 24086 type: "taggedPDF",
24087 data: hasStructTree 24088 }); 24089 this.documentInfo = info; 24090 this.metadata = metadata; 24091 this._contentDispositionFilename ??= contentDispositionFilename; 24092 this._contentLength ??= contentLength; 24093 console.log(`PDF ${pdfDocument.fingerprints[0]} [${info.PDFFormatVersion} ` + `${(metadata?.get("pdf:producer") || info.Producer || "-").trim()} / ` + `${(metadata?.get("xmp:creatortool") || info.Creator || "-").trim()}` + `] (PDF.js: ${version || "?"} [${build || "?"}])`); 24094 const pdfTitle = this._docTitle; 24095 if (pdfTitle) { 24096 this.setTitle(`${pdfTitle} - ${this._contentDispositionFilename || this._title}`); 24097 } else if (this._contentDispositionFilename) { 24098 this.setTitle(this._contentDispositionFilename); 24099 } 24100 if (info.IsXFAPresent && !info.IsAcroFormPresent && !pdfDocument.isPureXfa) { 24101 if (pdfDocument.loadingParams.enableXfa) { 24102 console.warn("Warning: XFA Foreground documents are not supported"); 24103 } else { 24104 console.warn("Warning: XFA support is not enabled"); 24105 } 24106 } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !this.pdfViewer.renderForms) { 24107 console.warn("Warning: Interactive form support is not enabled"); 24108 } 24109 if (info.IsSignaturesPresent) { 24110 console.warn("Warning: Digital signatures validation is not supported"); 24111 } 24112 this.eventBus.dispatch("metadataloaded", { 24113 source: this 24114 }); 24115 }, 24116 async _initializePageLabels(pdfDocument) { 24117 const labels = await pdfDocument.getPageLabels(); 24118 if (pdfDocument !== this.pdfDocument) { 24119 return; 24120 } 24121 if (!labels || AppOptions.get("disablePageLabels")) { 24122 return; 24123 } 24124 const numLabels = labels.length; 24125 let standardLabels = 0, 24126 emptyLabels = 0; 24127 for (let i = 0; i < numLabels; i++) { 24128 const label = labels[i]; 24129 if (label === (i + 1).toString()) { 24130 standardLabels++; 24131 } else if (label === "") { 24132 emptyLabels++; 24133 } else { 24134 break; 24135 } 24136 } 24137 if (standardLabels >= numLabels || emptyLabels >= numLabels) { 24138 return; 24139 } 24140 const { 24141 pdfViewer, 24142 pdfThumbnailViewer, 24143 toolbar 24144 } = this; 24145 pdfViewer.setPageLabels(labels); 24146 pdfThumbnailViewer?.setPageLabels(labels); 24147 toolbar?.setPagesCount(numLabels, true); 24148 toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel); 24149 }, 24150 _initializePdfHistory({ 24151 fingerprint, 24152 viewOnLoad, 24153 initialDest = null 24154 }) { 24155 if (!this.pdfHistory) { 24156 return; 24157 } 24158 this.pdfHistory.initialize({ 24159 fingerprint, 24160 resetHistory: viewOnLoad === ViewOnLoad.INITIAL, 24161 updateUrl: AppOptions.get("historyUpdateUrl") 24162 }); 24163 if (this.pdfHistory.initialBookmark) { 24164 this.initialBookmark = this.pdfHistory.initialBookmark; 24165 this.initialRotation = this.pdfHistory.initialRotation; 24166 } 24167 if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) { 24168 this.initialBookmark = JSON.stringify(initialDest); 24169 this.pdfHistory.push({ 24170 explicitDest: initialDest, 24171 pageNumber: null 24172 }); 24173 } 24174 }, 24175 _initializeAnnotationStorageCallbacks(pdfDocument) { 24176 if (pdfDocument !== this.pdfDocument) { 24177 return; 24178 } 24179 const { 24180 annotationStorage 24181 } = pdfDocument; 24182 annotationStorage.onSetModified = () => { 24183 window.addEventListener("beforeunload", beforeUnload); 24184 this._annotationStorageModified = true; 24185 }; 24186 annotationStorage.onResetModified = () => { 24187 window.removeEventListener("beforeunload", beforeUnload); 24188 delete this._annotationStorageModified; 24189 }; 24190 annotationStorage.onAnnotationEditor = typeStr => { 24191 this._hasAnnotationEditors = !!typeStr; 24192 this.setTitle(); 24193 }; 24194 }, 24195 setInitialView(storedHash, { 24196 rotation, 24197 sidebarView, 24198 scrollMode, 24199 spreadMode 24200 } = {}) { 24201 const setRotation = angle => { 24202 if (isValidRotation(angle)) { 24203 this.pdfViewer.pagesRotation = angle; 24204 } 24205 }; 24206 const setViewerModes = (scroll, spread) => { 24207 if (isValidScrollMode(scroll)) { 24208 this.pdfViewer.scrollMode = scroll; 24209 } 24210 if (isValidSpreadMode(spread)) { 24211 this.pdfViewer.spreadMode = spread; 24212 } 24213 }; 24214 this.isInitialViewSet = true; 24215 this.viewsManager?.setInitialView(sidebarView);
24216 setViewerModes(scrollMode, spreadMode); 24217 if (this.initialBookmark) { 24218 setRotation(this.initialRotation); 24219 delete this.initialRotation; 24220 this.pdfLinkService.setHash(this.initialBookmark); 24221 this.initialBookmark = null; 24222 } else if (storedHash) { 24223 setRotation(rotation); 24224 this.pdfLinkService.setHash(storedHash); 24225 } 24226 this.toolbar?.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel); 24227 this.secondaryToolbar?.setPageNumber(this.pdfViewer.currentPageNumber); 24228 if (!this.pdfViewer.currentScaleValue) { 24229 this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE; 24230 } 24231 }, 24232 _cleanup() { 24233 if (!this.pdfDocument) { 24234 return; 24235 } 24236 this.pdfViewer.cleanup(); 24237 this.pdfThumbnailViewer?.cleanup(); 24238 this.pdfDocument.cleanup(AppOptions.get("fontExtraProperties")); 24239 }, 24240 forceRendering() { 24241 this.pdfRenderingQueue.printing = !!this.printService; 24242 this.pdfRenderingQueue.isThumbnailViewEnabled = this.viewsManager?.visibleView === SidebarView.THUMBS; 24243 this.pdfRenderingQueue.renderHighestPriority(); 24244 }, 24245 beforePrint() { 24246 this._printAnnotationStoragePromise = this.pdfScriptingManager.dispatchWillPrint().catch(() => {}).then(() => this.pdfDocument?.annotationStorage.print); 24247 if (this.printService) { 24248 return; 24249 } 24250 if (!this.supportsPrinting || !this.pdfViewer.printingAllowed) { 24251 this._otherError("pdfjs-printing-not-supported"); 24252 return; 24253 } 24254 if (!this.pdfViewer.pageViewsReady) { 24255 this.l10n.get("pdfjs-printing-not-ready").then(msg => { 24256 window.alert(msg); 24257 }); 24258 return; 24259 } 24260 this.printService = PDFPrintServiceFactory.createPrintService({ 24261 pdfDocument: this.pdfDocument, 24262 pagesOverview: this.pdfViewer.getPagesOverview(), 24263 printContainer: this.appConfig.printContainer, 24264 printResolution: AppOptions.get("printResolution"), 24265 printAnnotationStoragePromise: this._printAnnotationStoragePromise 24266 }); 24267 this.forceRendering(); 24268 this.setTitle(); 24269 this.printService.layout(); 24270 if (this._hasAnnotationEditors) { 24271 this.externalServices.reportTelemetry({ 24272 type: "editing", 24273 data: { 24274 type: "print", 24275 stats: this.pdfDocument?.annotationStorage.editorStats 24276 } 24277 }); 24278 } 24279 }, 24280 afterPrint() { 24281 if (this._printAnnotationStoragePromise) { 24282 this._printAnnotationStoragePromise.then(() => { 24283 this.pdfScriptingManager.dispatchDidPrint(); 24284 }); 24285 this._printAnnotationStoragePromise = null; 24286 } 24287 if (this.printService) { 24288 this.printService.destroy(); 24289 this.printService = null; 24290 this.pdfDocument?.annotationStorage.resetModified(); 24291 } 24292 this.forceRendering(); 24293 this.setTitle(); 24294 }, 24295 rotatePages(delta) { 24296 this.pdfViewer.pagesRotation += delta; 24297 }, 24298 requestPresentationMode() { 24299 this.pdfPresentationMode?.request(); 24300 }, 24301 async triggerPrinting() { 24302 if (this.supportsPrinting && (await this._printPermissionPromise)) { 24303 window.print(); 24304 } 24305 }, 24306 bindEvents() { 24307 if (this._eventBusAbortController) { 24308 return; 24309 } 24310 const ac = this._eventBusAbortController = new AbortController(); 24311 const opts = { 24312 signal: ac.signal 24313 }; 24314 const { 24315 eventBus, 24316 externalServices, 24317 pdfDocumentProperties, 24318 pdfViewer, 24319 preferences 24320 } = this; 24321 eventBus._on("resize", onResize.bind(this), opts); 24322 eventBus._on("hashchange", onHashchange.bind(this), opts); 24323 eventBus._on("beforeprint", this.beforePrint.bind(this), opts); 24324 eventBus._on("afterprint", this.afterPrint.bind(this), opts); 24325 eventBus._on("pagerender", onPageRender.bind(this), opts); 24326 eventBus._on("pagerendered", onPageRendered.bind(this), opts); 24327 eventBus._on("updateviewarea", onUpdateViewarea.bind(this), opts); 24328 eventBus._on("pagechanging", onPageChanging.bind(this), opts); 24329 eventBus._on("scalechanging", onScaleChanging.bind(this), opts); 24330 eventBus._on("rotationchanging", onRotationChanging.bind(this), opts); 24331 eventBus._on("sidebarviewchanged", onSidebarViewChanged.bind(this), opts); 24332 eventBus._on("pagemode", onPageMode.bind(this), opts); 24333 eventBus._on("namedaction", onNamedAction.bind(this), opts); 24334 eventBus._on("presentationmodechanged", evt => pdfViewer.presentationModeState = evt.state, opts); 24335 eventBus._on("presentationmode", this.requestPresentationMode.bind(this), opts); 24336 eventBus._on("switchannotationeditormode", evt => pdfViewer.annotationEditorMode = evt, opts); 24337 eventBus._on("print", this.triggerPrinting.bind(this), opts); 24338 eventBus._on("download", this.downloadOrSave.bind(this), opts); 24339 eventBus._on("firstpage", () => this.page = 1, opts); 24340 eventBus._on("lastpage", () => this.page = this.pagesCount, opts); 24341 eventBus._on("nextpage", () => pdfViewer.nextPage(), opts); 24342 eventBus._on("previouspage", () => pdfViewer.previousPage(), opts); 24343 eventBus._on("zoomin", this.zoomIn.bind(this), opts); 24344 eventBus._on("zoomout", this.zoomOut.bind(this), opts); 24345 eventBus._on("zoomreset", this.zoomReset.bind(this), opts); 24346 eventBus._on("pagenumberchanged", onPageNumberChanged.bind(this), opts); 24347 eventBus._on("scalechanged", evt => pdfViewer.currentScaleValue = evt.value, opts); 24348 eventBus._on("rotatecw", this.rotatePages.bind(this, 90), opts); 24349 eventBus._on("rotateccw", this.rotatePages.bind(this, -90), opts); 24350 eventBus._on("optionalcontentconfig", evt => pdfViewer.optionalContentConfigPromise = evt.promise, opts); 24351 eventBus._on("switchscrollmode", evt => pdfViewer.scrollMode = evt.mode, opts); 24352 eventBus._on("scrollmodechanged", onViewerModesChanged.bind(this, "scrollMode"), opts); 24353 eventBus._on("switchspreadmode", evt => pdfViewer.spreadMode = evt.mode, opts); 24354 eventBus._on("spreadmodechanged", onViewerModesChanged.bind(this, "spreadMode"), opts); 24355 eventBus._on("imagealttextsettings", onImageAltTextSettings.bind(this), opts); 24356 eventBus._on("documentproperties", () => pdfDocumentProperties?.open(), opts); 24357 eventBus._on("findfromurlhash", onFindFromUrlHash.bind(this), opts); 24358 eventBus._on("updatefindmatchescount", onUpdateFindMatchesCount.bind(this), opts);
24359 eventBus._on("updatefindcontrolstate", onUpdateFindControlState.bind(this), opts); 24360 eventBus._on("fileinputchange", onFileInputChange.bind(this), opts); 24361 eventBus._on("openfile", onOpenFile.bind(this), opts); 24362 eventBus._on("pagesedited", this.onPagesEdited.bind(this), opts); 24363 eventBus._on("savepageseditedpdf", this.onSavePagesEditedPDF.bind(this), opts); 24364 }, 24365 bindWindowEvents() { 24366 if (this._windowAbortController) { 24367 return; 24368 } 24369 this._windowAbortController = new AbortController(); 24370 const { 24371 eventBus, 24372 appConfig: { 24373 mainContainer 24374 }, 24375 pdfViewer, 24376 _windowAbortController: { 24377 signal 24378 } 24379 } = this; 24380 this._touchManager = new TouchManager({ 24381 container: window, 24382 isPinchingDisabled: () => pdfViewer.isInPresentationMode, 24383 isPinchingStopped: () => this.overlayManager?.active, 24384 onPinching: this.touchPinchCallback.bind(this), 24385 onPinchEnd: this.touchPinchEndCallback.bind(this), 24386 signal 24387 }); 24388 function addWindowResolutionChange(evt = null) { 24389 if (evt) { 24390 pdfViewer.refresh(); 24391 } 24392 const mediaQueryList = window.matchMedia(`(resolution: ${OutputScale.pixelRatio}dppx)`); 24393 mediaQueryList.addEventListener("change", addWindowResolutionChange, { 24394 once: true, 24395 signal 24396 }); 24397 } 24398 addWindowResolutionChange(); 24399 window.addEventListener("wheel", onWheel.bind(this), { 24400 passive: false, 24401 signal 24402 }); 24403 window.addEventListener("click", onClick.bind(this), { 24404 signal 24405 }); 24406 window.addEventListener("keydown", onKeyDown.bind(this), { 24407 signal 24408 }); 24409 window.addEventListener("keyup", onKeyUp.bind(this), { 24410 signal 24411 }); 24412 window.addEventListener("resize", () => eventBus.dispatch("resize", { 24413 source: window 24414 }), { 24415 signal 24416 }); 24417 window.addEventListener("hashchange", () => { 24418 eventBus.dispatch("hashchange", { 24419 source: window, 24420 hash: document.location.hash.substring(1) 24421 }); 24422 }, { 24423 signal 24424 }); 24425 window.addEventListener("beforeprint", () => eventBus.dispatch("beforeprint", { 24426 source: window 24427 }), { 24428 signal 24429 }); 24430 window.addEventListener("afterprint", () => eventBus.dispatch("afterprint", { 24431 source: window 24432 }), { 24433 signal 24434 }); 24435 window.addEventListener("updatefromsandbox", evt => { 24436 eventBus.dispatch("updatefromsandbox", { 24437 source: window, 24438 detail: evt.detail 24439 }); 24440 }, { 24441 signal 24442 }); 24443 if (!("onscrollend" in document.documentElement)) { 24444 return; 24445 } 24446 ({ 24447 scrollTop: this._lastScrollTop, 24448 scrollLeft: this._lastScrollLeft 24449 } = mainContainer); 24450 let scrollendTimeoutID, scrollAbortController; 24451 const scrollend = () => { 24452 ({ 24453 scrollTop: this._lastScrollTop, 24454 scrollLeft: this._lastScrollLeft 24455 } = mainContainer); 24456 clearTimeout(scrollendTimeoutID); 24457 if (this._isScrolling) { 24458 scrollAbortController.abort(); 24459 scrollAbortController = null; 24460 this._isScrolling = false; 24461 } 24462 }; 24463 const scroll = () => { 24464 if (this._isCtrlKeyDown) { 24465 return; 24466 } 24467 if (this._lastScrollTop === mainContainer.scrollTop && this._lastScrollLeft === mainContainer.scrollLeft) { 24468 return; 24469 } 24470 if (!this._isScrolling) { 24471 scrollAbortController = new AbortController(); 24472 const abortSignal = AbortSignal.any([scrollAbortController.signal, signal]); 24473 mainContainer.addEventListener("scrollend", scrollend, { 24474 signal: abortSignal 24475 }); 24476 mainContainer.addEventListener("blur", scrollend, { 24477 signal: abortSignal 24478 }); 24479 this._isScrolling = true; 24480 } 24481 clearTimeout(scrollendTimeoutID); 24482 scrollendTimeoutID = setTimeout(scrollend, 100); 24483 }; 24484 mainContainer.addEventListener("scroll", scroll, { 24485 passive: true, 24486 signal 24487 }); 24488 }, 24489 unbindEvents() { 24490 this._eventBusAbortController?.abort(); 24491 this._eventBusAbortController = null; 24492 }, 24493 unbindWindowEvents() { 24494 this._windowAbortController?.abort(); 24495 this._windowAbortController = null; 24496 this._touchManager = null; 24497 }, 24498 async testingClose() { 24499 this.unbindEvents(); 24500 this.unbindWindowEvents(); 24501 this._globalAbortController?.abort(); 24502 this._globalAbortController = null; 24503 this.findBar?.close(); 24504 await Promise.all([this.l10n?.destroy(), this.close()]); 24505 }, 24506 onPagesEdited(data) { 24507 this.pdfViewer.onPagesEdited(data); 24508 }, 24509 async onSavePagesEditedPDF({ 24510 data: extractParams 24511 }) { 24512 if (!this.pdfDocument) { 24513 return; 24514 } 24515 const modifiedPdfBytes = await this.pdfDocument.extractPages(extractParams); 24516 if (!modifiedPdfBytes) { 24517 console.error("Something wrong happened when saving the edited PDF.\nPlease file a bug."); 24518 return; 24519 } 24520 this.downloadManager.download(modifiedPdfBytes, this._downloadUrl, this._docFilename); 24521 }, 24522 _accumulateTicks(ticks, prop) { 24523 if (this[prop] > 0 && ticks < 0 || this[prop] < 0 && ticks > 0) { 24524 this[prop] = 0; 24525 } 24526 this[prop] += ticks; 24527 const wholeTicks = Math.trunc(this[prop]); 24528 this[prop] -= wholeTicks; 24529 return wholeTicks; 24530 }, 24531 _accumulateFactor(previousScale, factor, prop) { 24532 if (factor === 1) { 24533 return 1; 24534 } 24535 if (this[prop] > 1 && factor < 1 || this[prop] < 1 && factor > 1) { 24536 this[prop] = 1; 24537 } 24538 const newFactor = Math.floor(previousScale * factor * this[prop] * 100) / (100 * previousScale); 24539 this[prop] = factor / newFactor; 24540 return newFactor; 24541 }, 24542 _unblockDocumentLoadEvent() { 24543 document.blockUnblockOnload?.(false); 24544 this._unblockDocumentLoadEvent = () => {}; 24545 }, 24546 get scriptingReady() { 24547 return this.pdfScriptingManager.ready; 24548 } 24549}; 24550initCom(PDFViewerApplication); 24551PDFPrintServiceFactory.initGlobals(PDFViewerApplication); 24552{ 24553 const HOSTED_VIEWER_ORIGINS = new Set(["null", "http://mozilla.github.io", "https://mozilla.github.io"]);
24554 var validateFileURL = function (file) { 24555 if (!file) { 24556 return; 24557 } 24558 const viewerOrigin = URL.parse(window.location)?.origin || "null"; 24559 if (HOSTED_VIEWER_ORIGINS.has(viewerOrigin)) { 24560 return; 24561 } 24562 const fileOrigin = URL.parse(file, window.location)?.origin; 24563 if (fileOrigin === viewerOrigin) { 24564 return; 24565 } 24566 const ex = new Error("file origin does not match viewer's"); 24567 PDFViewerApplication._documentError("pdfjs-loading-error", { 24568 message: ex.message 24569 }); 24570 throw ex; 24571 }; 24572 var onFileInputChange = function (evt) { 24573 if (this.pdfViewer?.isInPresentationMode) { 24574 return; 24575 } 24576 const file = evt.fileInput.files[0]; 24577 this.open({ 24578 url: URL.createObjectURL(file), 24579 originalUrl: encodeURIComponent(file.name) 24580 }); 24581 }; 24582 var onOpenFile = function (evt) { 24583 this._openFileInput?.click(); 24584 }; 24585} 24586function onPageRender({ 24587 pageNumber 24588}) { 24589 if (pageNumber === this.page) { 24590 this.toolbar?.updateLoadingIndicatorState(true); 24591 } 24592} 24593function onPageRendered({ 24594 pageNumber, 24595 isDetailView, 24596 error 24597}) { 24598 if (pageNumber === this.page) { 24599 this.toolbar?.updateLoadingIndicatorState(false); 24600 } 24601 if (!isDetailView && this.viewsManager?.visibleView === SidebarView.THUMBS) { 24602 const pageView = this.pdfViewer.getPageView(pageNumber - 1); 24603 const thumbnailView = this.pdfThumbnailViewer?.getThumbnail(pageNumber - 1); 24604 if (pageView) { 24605 thumbnailView?.setImage(pageView); 24606 } 24607 } 24608 if (error) { 24609 this._otherError("pdfjs-rendering-error", error); 24610 } 24611} 24612function onPageMode({ 24613 mode 24614}) { 24615 let view; 24616 switch (mode) { 24617 case "thumbs": 24618 view = SidebarView.THUMBS; 24619 break; 24620 case "bookmarks": 24621 case "outline": 24622 view = SidebarView.OUTLINE; 24623 break; 24624 case "attachments": 24625 view = SidebarView.ATTACHMENTS; 24626 break; 24627 case "layers": 24628 view = SidebarView.LAYERS; 24629 break; 24630 case "none": 24631 view = SidebarView.NONE; 24632 break; 24633 default: 24634 console.error('Invalid "pagemode" hash parameter: ' + mode); 24635 return; 24636 } 24637 this.viewsManager?.switchView(view, true); 24638} 24639function onNamedAction(evt) { 24640 switch (evt.action) { 24641 case "GoToPage": 24642 this.appConfig.toolbar?.pageNumber.select(); 24643 break; 24644 case "Find": 24645 if (!this.supportsIntegratedFind) { 24646 this.findBar?.toggle(); 24647 } 24648 break; 24649 case "Print": 24650 this.triggerPrinting(); 24651 break; 24652 case "SaveAs": 24653 this.downloadOrSave(); 24654 break; 24655 } 24656} 24657function onSidebarViewChanged({ 24658 view 24659}) { 24660 this.pdfRenderingQueue.isThumbnailViewEnabled = view === SidebarView.THUMBS; 24661 if (this.isInitialViewSet) { 24662 this.store?.set("sidebarView", view).catch(() => {}); 24663 } 24664} 24665function onUpdateViewarea({ 24666 location 24667}) { 24668 if (this.isInitialViewSet) { 24669 this.store?.setMultiple({ 24670 page: location.pageNumber, 24671 zoom: location.scale, 24672 scrollLeft: location.left, 24673 scrollTop: location.top, 24674 rotation: location.rotation 24675 }).catch(() => {}); 24676 } 24677 if (this.appConfig.secondaryToolbar) { 24678 this.appConfig.secondaryToolbar.viewBookmarkButton.href = this.pdfLinkService.getAnchorUrl(location.pdfOpenParams); 24679 } 24680} 24681function onViewerModesChanged(name, evt) { 24682 if (this.isInitialViewSet && !this.pdfViewer.isInPresentationMode) { 24683 this.store?.set(name, evt.mode).catch(() => {}); 24684 } 24685} 24686function onResize() { 24687 const { 24688 pdfDocument, 24689 pdfViewer, 24690 pdfRenderingQueue 24691 } = this; 24692 if (pdfRenderingQueue.printing && window.matchMedia("print").matches) { 24693 return; 24694 } 24695 if (!pdfDocument) { 24696 return; 24697 } 24698 const currentScaleValue = pdfViewer.currentScaleValue; 24699 if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") { 24700 pdfViewer.currentScaleValue = currentScaleValue; 24701 } 24702 pdfViewer.update(); 24703} 24704function onHashchange(evt) { 24705 const hash = evt.hash; 24706 if (!hash) { 24707 return; 24708 } 24709 if (!this.isInitialViewSet) { 24710 this.initialBookmark = hash; 24711 } else if (!this.pdfHistory?.popStateInProgress) { 24712 this.pdfLinkService.setHash(hash); 24713 } 24714} 24715function onPageNumberChanged(evt) { 24716 const { 24717 pdfViewer 24718 } = this; 24719 if (evt.value !== "") { 24720 this.pdfLinkService.goToPage(evt.value); 24721 } 24722 if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) { 24723 this.toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel); 24724 } 24725} 24726function onImageAltTextSettings() { 24727 this.imageAltTextSettings?.open({ 24728 enableGuessAltText: AppOptions.get("enableGuessAltText"), 24729 enableNewAltTextWhenAddingImage: AppOptions.get("enableNewAltTextWhenAddingImage") 24730 }); 24731} 24732function onFindFromUrlHash(evt) { 24733 this.eventBus.dispatch("find", { 24734 source: evt.source, 24735 type: "", 24736 query: evt.query, 24737 caseSensitive: false, 24738 entireWord: false, 24739 highlightAll: true, 24740 findPrevious: false, 24741 matchDiacritics: true 24742 }); 24743} 24744function onUpdateFindMatchesCount({ 24745 matchesCount 24746}) { 24747 if (this.supportsIntegratedFind) { 24748 this.externalServices.updateFindMatchesCount(matchesCount); 24749 } else { 24750 this.findBar?.updateResultsCount(matchesCount); 24751 } 24752} 24753function onUpdateFindControlState({ 24754 state, 24755 previous, 24756 entireWord, 24757 matchesCount, 24758 rawQuery 24759}) { 24760 if (this.supportsIntegratedFind) { 24761 this.externalServices.updateFindControlState({ 24762 result: state, 24763 findPrevious: previous, 24764 entireWord, 24765 matchesCount, 24766 rawQuery 24767 }); 24768 } else { 24769 this.findBar?.updateUIState(state, previous, matchesCount); 24770 } 24771} 24772function onScaleChanging(evt) { 24773 this.toolbar?.setPageScale(evt.presetValue, evt.scale);
24774 this.pdfViewer.update(); 24775} 24776function onRotationChanging(evt) { 24777 if (this.pdfThumbnailViewer) { 24778 this.pdfThumbnailViewer.pagesRotation = evt.pagesRotation; 24779 } 24780 this.forceRendering(); 24781 this.pdfViewer.currentPageNumber = evt.pageNumber; 24782} 24783function onPageChanging({ 24784 pageNumber, 24785 pageLabel 24786}) { 24787 this.toolbar?.setPageNumber(pageNumber, pageLabel); 24788 this.secondaryToolbar?.setPageNumber(pageNumber); 24789 if (this.viewsManager?.visibleView === SidebarView.THUMBS) { 24790 this.pdfThumbnailViewer?.scrollThumbnailIntoView(pageNumber); 24791 } 24792 const currentPage = this.pdfViewer.getPageView(pageNumber - 1); 24793 this.toolbar?.updateLoadingIndicatorState(currentPage?.renderingState === RenderingStates.RUNNING); 24794} 24795function onWheel(evt) { 24796 const { 24797 pdfViewer, 24798 supportsMouseWheelZoomCtrlKey, 24799 supportsMouseWheelZoomMetaKey, 24800 supportsPinchToZoom 24801 } = this; 24802 if (pdfViewer.isInPresentationMode) { 24803 return; 24804 } 24805 const deltaMode = evt.deltaMode; 24806 let scaleFactor = Math.exp(-evt.deltaY / 100); 24807 const isBuiltInMac = false; 24808 const isPinchToZoom = evt.ctrlKey && !this._isCtrlKeyDown && deltaMode === WheelEvent.DOM_DELTA_PIXEL && evt.deltaX === 0 && (Math.abs(scaleFactor - 1) < 0.05 || isBuiltInMac) && evt.deltaZ === 0; 24809 const origin = [evt.clientX, evt.clientY]; 24810 if (isPinchToZoom || evt.ctrlKey && supportsMouseWheelZoomCtrlKey || evt.metaKey && supportsMouseWheelZoomMetaKey) { 24811 evt.preventDefault(); 24812 if (this._isScrolling || document.visibilityState === "hidden" || this.overlayManager.active) { 24813 return; 24814 } 24815 if (isPinchToZoom && supportsPinchToZoom) { 24816 scaleFactor = this._accumulateFactor(pdfViewer.currentScale, scaleFactor, "_wheelUnusedFactor"); 24817 this.updateZoom(null, scaleFactor, origin); 24818 } else { 24819 const delta = normalizeWheelEventDirection(evt); 24820 let ticks = 0; 24821 if (deltaMode === WheelEvent.DOM_DELTA_LINE || deltaMode === WheelEvent.DOM_DELTA_PAGE) { 24822 ticks = Math.abs(delta) >= 1 ? Math.sign(delta) : this._accumulateTicks(delta, "_wheelUnusedTicks"); 24823 } else { 24824 const PIXELS_PER_LINE_SCALE = 30; 24825 ticks = this._accumulateTicks(delta / PIXELS_PER_LINE_SCALE, "_wheelUnusedTicks"); 24826 } 24827 this.updateZoom(ticks, null, origin); 24828 } 24829 } 24830} 24831function closeSecondaryToolbar({ 24832 target 24833}) { 24834 if (!this.secondaryToolbar?.isOpen) { 24835 return; 24836 } 24837 const { 24838 toolbar, 24839 secondaryToolbar 24840 } = this.appConfig; 24841 if (this.pdfViewer.containsElement(target) || toolbar?.container.contains(target) && !secondaryToolbar?.toolbar.contains(target) && !secondaryToolbar?.toggleButton.contains(target)) { 24842 this.secondaryToolbar.close(); 24843 } 24844} 24845function closeEditorUndoBar(evt) { 24846 if (!this.editorUndoBar?.isOpen) { 24847 return; 24848 } 24849 if (this.appConfig.secondaryToolbar?.toolbar.contains(evt.target)) { 24850 this.editorUndoBar.hide(); 24851 } 24852} 24853function onClick(evt) { 24854 closeSecondaryToolbar.call(this, evt); 24855 closeEditorUndoBar.call(this, evt); 24856} 24857function onKeyUp(evt) { 24858 if (evt.key === "Control") { 24859 this._isCtrlKeyDown = false; 24860 } 24861} 24862function onKeyDown(evt) { 24863 this._isCtrlKeyDown = evt.key === "Control"; 24864 if (this.editorUndoBar?.isOpen && evt.keyCode !== 9 && evt.keyCode !== 16 && !((evt.keyCode === 13 || evt.keyCode === 32) && getActiveOrFocusedElement() === this.appConfig.editorUndoBar.undoButton)) { 24865 this.editorUndoBar.hide(); 24866 } 24867 if (this.overlayManager.active) { 24868 return; 24869 } 24870 const { 24871 eventBus, 24872 pdfViewer 24873 } = this; 24874 const isViewerInPresentationMode = pdfViewer.isInPresentationMode; 24875 let handled = false, 24876 ensureViewerFocused = false; 24877 const cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0); 24878 if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) { 24879 switch (evt.keyCode) { 24880 case 70: 24881 if (!this.supportsIntegratedFind && !evt.shiftKey) { 24882 this.findBar?.open(); 24883 handled = true; 24884 } 24885 break; 24886 case 71: 24887 if (!this.supportsIntegratedFind) { 24888 const { 24889 state 24890 } = this.findController; 24891 if (state) { 24892 const newState = { 24893 source: window, 24894 type: "again", 24895 findPrevious: cmd === 5 || cmd === 12 24896 }; 24897 eventBus.dispatch("find", { 24898 ...state, 24899 ...newState 24900 }); 24901 } 24902 handled = true; 24903 } 24904 break; 24905 case 61: 24906 case 107: 24907 case 187: 24908 case 171: 24909 this.zoomIn(); 24910 handled = true; 24911 break; 24912 case 173: 24913 case 109: 24914 case 189: 24915 this.zoomOut(); 24916 handled = true; 24917 break; 24918 case 48: 24919 case 96: 24920 if (!isViewerInPresentationMode) { 24921 setTimeout(() => { 24922 this.zoomReset(); 24923 }); 24924 handled = false;
24925 } 24926 break; 24927 case 38: 24928 if (isViewerInPresentationMode || this.page > 1) { 24929 this.page = 1; 24930 handled = true; 24931 ensureViewerFocused = true; 24932 } 24933 break; 24934 case 40: 24935 if (isViewerInPresentationMode || this.page < this.pagesCount) { 24936 this.page = this.pagesCount; 24937 handled = true; 24938 ensureViewerFocused = true; 24939 } 24940 break; 24941 } 24942 } 24943 if (cmd === 1 || cmd === 8) { 24944 switch (evt.keyCode) { 24945 case 83: 24946 eventBus.dispatch("download", { 24947 source: window 24948 }); 24949 handled = true; 24950 break; 24951 case 79: 24952 { 24953 eventBus.dispatch("openfile", { 24954 source: window 24955 }); 24956 handled = true; 24957 } 24958 break; 24959 } 24960 } 24961 if (cmd === 3 || cmd === 10) { 24962 switch (evt.keyCode) { 24963 case 80: 24964 this.requestPresentationMode(); 24965 handled = true; 24966 this.externalServices.reportTelemetry({ 24967 type: "buttons", 24968 data: { 24969 id: "presentationModeKeyboard" 24970 } 24971 }); 24972 break; 24973 case 71: 24974 if (this.appConfig.toolbar) { 24975 this.appConfig.toolbar.pageNumber.select(); 24976 handled = true; 24977 } 24978 break; 24979 } 24980 } 24981 if (handled) { 24982 if (ensureViewerFocused && !isViewerInPresentationMode) {
24983 pdfViewer.focus(); 24984 } 24985 evt.preventDefault(); 24986 return; 24987 } 24988 const curElement = getActiveOrFocusedElement(); 24989 const curElementTagName = curElement?.tagName.toUpperCase(); 24990 if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElementTagName === "BUTTON" && evt.keyCode === 32 || curElement?.isContentEditable) { 24991 if (evt.keyCode !== 27) { 24992 return; 24993 } 24994 } 24995 if (cmd === 0) { 24996 let turnPage = 0, 24997 turnOnlyIfPageFit = false; 24998 switch (evt.keyCode) { 24999 case 38: 25000 if (this.supportsCaretBrowsingMode) { 25001 this.moveCaret(true, false); 25002 handled = true; 25003 break; 25004 } 25005 case 33: 25006 if (pdfViewer.isVerticalScrollbarEnabled) { 25007 turnOnlyIfPageFit = true; 25008 } 25009 turnPage = -1; 25010 break; 25011 case 8: 25012 if (!isViewerInPresentationMode) { 25013 turnOnlyIfPageFit = true; 25014 } 25015 turnPage = -1; 25016 break; 25017 case 37: 25018 if (this.supportsCaretBrowsingMode) { 25019 return; 25020 } 25021 if (pdfViewer.isHorizontalScrollbarEnabled) { 25022 turnOnlyIfPageFit = true; 25023 } 25024 case 75: 25025 case 80: 25026 turnPage = -1; 25027 break; 25028 case 27: 25029 if (this.secondaryToolbar?.isOpen) { 25030 this.secondaryToolbar.close(); 25031 handled = true; 25032 } 25033 if (!this.supportsIntegratedFind && this.findBar?.opened) { 25034 this.findBar.close(); 25035 handled = true; 25036 } 25037 break; 25038 case 40: 25039 if (this.supportsCaretBrowsingMode) { 25040 this.moveCaret(false, false); 25041 handled = true; 25042 break; 25043 } 25044 case 34: 25045 if (pdfViewer.isVerticalScrollbarEnabled) { 25046 turnOnlyIfPageFit = true; 25047 } 25048 turnPage = 1; 25049 break; 25050 case 32: 25051 if (!isViewerInPresentationMode) { 25052 turnOnlyIfPageFit = true; 25053 } 25054 turnPage = 1; 25055 break; 25056 case 39: 25057 if (this.supportsCaretBrowsingMode) { 25058 return; 25059 } 25060 if (pdfViewer.isHorizontalScrollbarEnabled) { 25061 turnOnlyIfPageFit = true; 25062 } 25063 case 74: 25064 case 78: 25065 turnPage = 1; 25066 break; 25067 case 36: 25068 if (isViewerInPresentationMode || this.page > 1) { 25069 this.page = 1; 25070 handled = true; 25071 ensureViewerFocused = true; 25072 } 25073 break; 25074 case 35: 25075 if (isViewerInPresentationMode || this.page < this.pagesCount) { 25076 this.page = this.pagesCount; 25077 handled = true; 25078 ensureViewerFocused = true; 25079 } 25080 break; 25081 case 83: 25082 this.pdfCursorTools?.switchTool(CursorTool.SELECT); 25083 break; 25084 case 72: 25085 this.pdfCursorTools?.switchTool(CursorTool.HAND); 25086 break; 25087 case 82: 25088 this.rotatePages(90); 25089 break; 25090 case 115: 25091 this.viewsManager?.toggle(); 25092 break; 25093 } 25094 if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) { 25095 if (turnPage > 0) { 25096 pdfViewer.nextPage(); 25097 } else { 25098 pdfViewer.previousPage(); 25099 } 25100 handled = true; 25101 } 25102 } 25103 if (cmd === 4) { 25104 switch (evt.keyCode) { 25105 case 32: 25106 if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") { 25107 break; 25108 } 25109 pdfViewer.previousPage(); 25110 handled = true; 25111 break; 25112 case 38: 25113 this.moveCaret(true, true); 25114 handled = true; 25115 break; 25116 case 40: 25117 this.moveCaret(false, true); 25118 handled = true; 25119 break; 25120 case 82: 25121 this.rotatePages(-90); 25122 break; 25123 } 25124 } 25125 if (!handled && !isViewerInPresentationMode) { 25126 if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") { 25127 ensureViewerFocused = true; 25128 } 25129 } 25130 if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
vendor: 13,828 bytes, lines 25131-25373
25131 pdfViewer.focus(); 25132 } 25133 if (handled) { 25134 evt.preventDefault(); 25135 } 25136} 25137function beforeUnload(evt) { 25138 evt.preventDefault(); 25139 evt.returnValue = ""; 25140 return false; 25141} 25142 25143;// ./web/viewer.js 25144 25145 25146 25147 25148 25149const AppConstants = { 25150 LinkTarget: LinkTarget, 25151 RenderingStates: RenderingStates, 25152 ScrollMode: ScrollMode, 25153 SpreadMode: SpreadMode 25154}; 25155window.PDFViewerApplication = PDFViewerApplication; 25156window.PDFViewerApplicationConstants = AppConstants; 25157window.PDFViewerApplicationOptions = AppOptions; 25158function getViewerConfiguration() { 25159 return { 25160 appContainer: document.body, 25161 principalContainer: document.getElementById("mainContainer"), 25162 mainContainer: document.getElementById("viewerContainer"), 25163 viewerContainer: document.getElementById("viewer"), 25164 viewerAlert: document.getElementById("viewer-alert"), 25165 toolbar: { 25166 container: document.getElementById("toolbarContainer"), 25167 numPages: document.getElementById("numPages"), 25168 pageNumber: document.getElementById("pageNumber"), 25169 scaleSelect: document.getElementById("scaleSelect"), 25170 customScaleOption: document.getElementById("customScaleOption"), 25171 previous: document.getElementById("previous"), 25172 next: document.getElementById("next"), 25173 zoomIn: document.getElementById("zoomInButton"), 25174 zoomOut: document.getElementById("zoomOutButton"), 25175 print: document.getElementById("printButton"), 25176 editorCommentButton: document.getElementById("editorCommentButton"), 25177 editorCommentParamsToolbar: document.getElementById("editorCommentParamsToolbar"), 25178 editorFreeTextButton: document.getElementById("editorFreeTextButton"), 25179 editorFreeTextParamsToolbar: document.getElementById("editorFreeTextParamsToolbar"), 25180 editorHighlightButton: document.getElementById("editorHighlightButton"), 25181 editorHighlightParamsToolbar: document.getElementById("editorHighlightParamsToolbar"), 25182 editorHighlightColorPicker: document.getElementById("editorHighlightColorPicker"), 25183 editorInkButton: document.getElementById("editorInkButton"), 25184 editorInkParamsToolbar: document.getElementById("editorInkParamsToolbar"), 25185 editorStampButton: document.getElementById("editorStampButton"), 25186 editorStampParamsToolbar: document.getElementById("editorStampParamsToolbar"), 25187 editorSignatureButton: document.getElementById("editorSignatureButton"), 25188 editorSignatureParamsToolbar: document.getElementById("editorSignatureParamsToolbar"), 25189 download: document.getElementById("downloadButton") 25190 }, 25191 secondaryToolbar: { 25192 toolbar: document.getElementById("secondaryToolbar"), 25193 toggleButton: document.getElementById("secondaryToolbarToggleButton"), 25194 presentationModeButton: document.getElementById("presentationMode"), 25195 openFileButton: document.getElementById("secondaryOpenFile"), 25196 printButton: document.getElementById("secondaryPrint"), 25197 downloadButton: document.getElementById("secondaryDownload"), 25198 viewBookmarkButton: document.getElementById("viewBookmark"), 25199 firstPageButton: document.getElementById("firstPage"), 25200 lastPageButton: document.getElementById("lastPage"), 25201 pageRotateCwButton: document.getElementById("pageRotateCw"), 25202 pageRotateCcwButton: document.getElementById("pageRotateCcw"), 25203 cursorSelectToolButton: document.getElementById("cursorSelectTool"), 25204 cursorHandToolButton: document.getElementById("cursorHandTool"), 25205 scrollPageButton: document.getElementById("scrollPage"), 25206 scrollVerticalButton: document.getElementById("scrollVertical"), 25207 scrollHorizontalButton: document.getElementById("scrollHorizontal"), 25208 scrollWrappedButton: document.getElementById("scrollWrapped"), 25209 spreadNoneButton: document.getElementById("spreadNone"), 25210 spreadOddButton: document.getElementById("spreadOdd"), 25211 spreadEvenButton: document.getElementById("spreadEven"), 25212 imageAltTextSettingsButton: document.getElementById("imageAltTextSettings"), 25213 imageAltTextSettingsSeparator: document.getElementById("imageAltTextSettingsSeparator"), 25214 documentPropertiesButton: document.getElementById("documentProperties") 25215 }, 25216 viewsManager: { 25217 outerContainer: document.getElementById("outerContainer"), 25218 toggleButton: document.getElementById("viewsManagerToggleButton"), 25219 sidebarContainer: document.getElementById("viewsManager"), 25220 resizer: document.getElementById("viewsManagerResizer"), 25221 thumbnailButton: document.getElementById("thumbnailsViewMenu"), 25222 outlineButton: document.getElementById("outlinesViewMenu"), 25223 attachmentsButton: document.getElementById("attachmentsViewMenu"), 25224 layersButton: document.getElementById("layersViewMenu"), 25225 viewsManagerSelectorButton: document.getElementById("viewsManagerSelectorButton"), 25226 viewsManagerSelectorOptions: document.getElementById("viewsManagerSelectorOptions"), 25227 thumbnailsView: document.getElementById("thumbnailsView"), 25228 outlinesView: document.getElementById("outlinesView"), 25229 attachmentsView: document.getElementById("attachmentsView"), 25230 layersView: document.getElementById("layersView"), 25231 viewsManagerAddFileButton: document.getElementById("viewsManagerAddFileButton"), 25232 viewsManagerCurrentOutlineButton: document.getElementById("viewsManagerCurrentOutlineButton"), 25233 viewsManagerHeaderLabel: document.getElementById("viewsManagerHeaderLabel"), 25234 viewsManagerStatus: document.getElementById("viewsManagerStatus"), 25235 manageMenu: { 25236 button: document.getElementById("viewsManagerStatusActionButton"), 25237 menu: document.getElementById("viewsManagerStatusActionOptions"), 25238 copy: document.getElementById("viewsManagerStatusActionCopy"), 25239 cut: document.getElementById("viewsManagerStatusActionCut"), 25240 delete: document.getElementById("viewsManagerStatusActionDelete"), 25241 saveAs: document.getElementById("viewsManagerStatusActionSaveAs") 25242 } 25243 }, 25244 findBar: { 25245 bar: document.getElementById("findbar"), 25246 toggleButton: document.getElementById("viewFindButton"), 25247 findField: document.getElementById("findInput"), 25248 highlightAllCheckbox: document.getElementById("findHighlightAll"), 25249 caseSensitiveCheckbox: document.getElementById("findMatchCase"), 25250 matchDiacriticsCheckbox: document.getElementById("findMatchDiacritics"), 25251 entireWordCheckbox: document.getElementById("findEntireWord"), 25252 findMsg: document.getElementById("findMsg"), 25253 findResultsCount: document.getElementById("findResultsCount"), 25254 findPreviousButton: document.getElementById("findPreviousButton"), 25255 findNextButton: document.getElementById("findNextButton") 25256 }, 25257 passwordOverlay: { 25258 dialog: document.getElementById("passwordDialog"), 25259 label: document.getElementById("passwordText"), 25260 input: document.getElementById("password"), 25261 submitButton: document.getElementById("passwordSubmit"), 25262 cancelButton: document.getElementById("passwordCancel") 25263 }, 25264 documentProperties: { 25265 dialog: document.getElementById("documentPropertiesDialog"), 25266 closeButton: document.getElementById("documentPropertiesClose"), 25267 fields: { 25268 fileName: document.getElementById("fileNameField"), 25269 fileSize: document.getElementById("fileSizeField"), 25270 title: document.getElementById("titleField"), 25271 author: document.getElementById("authorField"), 25272 subject: document.getElementById("subjectField"), 25273 keywords: document.getElementById("keywordsField"), 25274 creationDate: document.getElementById("creationDateField"), 25275 modificationDate: document.getElementById("modificationDateField"), 25276 creator: document.getElementById("creatorField"), 25277 producer: document.getElementById("producerField"), 25278 version: document.getElementById("versionField"), 25279 pageCount: document.getElementById("pageCountField"), 25280 pageSize: document.getElementById("pageSizeField"), 25281 linearized: document.getElementById("linearizedField") 25282 } 25283 }, 25284 altTextDialog: { 25285 dialog: document.getElementById("altTextDialog"), 25286 optionDescription: document.getElementById("descriptionButton"), 25287 optionDecorative: document.getElementById("decorativeButton"), 25288 textarea: document.getElementById("descriptionTextarea"), 25289 cancelButton: document.getElementById("altTextCancel"), 25290 saveButton: document.getElementById("altTextSave") 25291 }, 25292 newAltTextDialog: { 25293 dialog: document.getElementById("newAltTextDialog"), 25294 title: document.getElementById("newAltTextTitle"), 25295 descriptionContainer: document.getElementById("newAltTextDescriptionContainer"), 25296 textarea: document.getElementById("newAltTextDescriptionTextarea"), 25297 disclaimer: document.getElementById("newAltTextDisclaimer"), 25298 learnMore: document.getElementById("newAltTextLearnMore"), 25299 imagePreview: document.getElementById("newAltTextImagePreview"), 25300 createAutomatically: document.getElementById("newAltTextCreateAutomatically"), 25301 createAutomaticallyButton: document.getElementById("newAltTextCreateAutomaticallyButton"), 25302 downloadModel: document.getElementById("newAltTextDownloadModel"), 25303 downloadModelDescription: document.getElementById("newAltTextDownloadModelDescription"), 25304 error: document.getElementById("newAltTextError"), 25305 errorCloseButton: document.getElementById("newAltTextCloseButton"), 25306 cancelButton: document.getElementById("newAltTextCancel"), 25307 notNowButton: document.getElementById("newAltTextNotNow"), 25308 saveButton: document.getElementById("newAltTextSave") 25309 }, 25310 altTextSettingsDialog: { 25311 dialog: document.getElementById("altTextSettingsDialog"), 25312 createModelButton: document.getElementById("createModelButton"), 25313 learnMore: document.getElementById("altTextSettingsLearnMore"), 25314 showAltTextDialogButton: document.getElementById("showAltTextDialogButton"), 25315 altTextSettingsCloseButton: document.getElementById("altTextSettingsCloseButton"), 25316 closeButton: document.getElementById("altTextSettingsCloseButton") 25317 }, 25318 addSignatureDialog: { 25319 dialog: document.getElementById("addSignatureDialog"), 25320 panels: document.getElementById("addSignatureActionContainer"), 25321 typeButton: document.getElementById("addSignatureTypeButton"), 25322 typeInput: document.getElementById("addSignatureTypeInput"), 25323 drawButton: document.getElementById("addSignatureDrawButton"), 25324 drawSVG: document.getElementById("addSignatureDraw"), 25325 drawPlaceholder: document.getElementById("addSignatureDrawPlaceholder"), 25326 drawThickness: document.getElementById("addSignatureDrawThickness"), 25327 imageButton: document.getElementById("addSignatureImageButton"), 25328 imageSVG: document.getElementById("addSignatureImage"), 25329 imagePlaceholder: document.getElementById("addSignatureImagePlaceholder"), 25330 imagePicker: document.getElementById("addSignatureFilePicker"), 25331 imagePickerLink: document.getElementById("addSignatureImageBrowse"), 25332 description: document.getElementById("addSignatureDescription"), 25333 clearButton: document.getElementById("clearSignatureButton"), 25334 saveContainer: document.getElementById("addSignatureSaveContainer"), 25335 saveCheckbox: document.getElementById("addSignatureSaveCheckbox"), 25336 errorBar: document.getElementById("addSignatureError"), 25337 errorTitle: document.getElementById("addSignatureErrorTitle"), 25338 errorDescription: document.getElementById("addSignatureErrorDescription"), 25339 errorCloseButton: document.getElementById("addSignatureErrorCloseButton"), 25340 cancelButton: document.getElementById("addSignatureCancelButton"), 25341 addButton: document.getElementById("addSignatureAddButton") 25342 }, 25343 editSignatureDialog: { 25344 dialog: document.getElementById("editSignatureDescriptionDialog"), 25345 description: document.getElementById("editSignatureDescription"), 25346 editSignatureView: document.getElementById("editSignatureView"), 25347 cancelButton: document.getElementById("editSignatureCancelButton"), 25348 updateButton: document.getElementById("editSignatureUpdateButton") 25349 }, 25350 annotationEditorParams: { 25351 editorCommentsSidebar: document.getElementById("editorCommentsSidebar"), 25352 editorCommentsSidebarCount: document.getElementById("editorCommentsSidebarCount"), 25353 editorCommentsSidebarTitle: document.getElementById("editorCommentsSidebarTitle"), 25354 editorCommentsSidebarCloseButton: document.getElementById("editorCommentsSidebarCloseButton"), 25355 editorCommentsSidebarList: document.getElementById("editorCommentsSidebarList"), 25356 editorCommentsSidebarResizer: document.getElementById("editorCommentsSidebarResizer"), 25357 editorFreeTextFontSize: document.getElementById("editorFreeTextFontSize"), 25358 editorFreeTextColor: document.getElementById("editorFreeTextColor"), 25359 editorInkColor: document.getElementById("editorInkColor"), 25360 editorInkThickness: document.getElementById("editorInkThickness"), 25361 editorInkOpacity: document.getElementById("editorInkOpacity"), 25362 editorStampAddImage: document.getElementById("editorStampAddImage"), 25363 editorSignatureAddSignature: document.getElementById("editorSignatureAddSignature"), 25364 editorFreeHighlightThickness: document.getElementById("editorFreeHighlightThickness"), 25365 editorHighlightShowAll: document.getElementById("editorHighlightShowAll") 25366 }, 25367 printContainer: document.getElementById("printContainer"), 25368 editorUndoBar: { 25369 container: document.getElementById("editorUndoBar"), 25370 message: document.getElementById("editorUndoBarMessage"), 25371 undoButton: document.getElementById("editorUndoBarUndoButton"), 25372 closeButton: document.getElementById("editorUndoBarCloseButton") 25373 },
25374 editCommentDialog: { 25375 dialog: document.getElementById("commentManagerDialog"), 25376 toolbar: document.getElementById("commentManagerToolbar"), 25377 title: document.getElementById("commentManagerTitle"), 25378 textInput: document.getElementById("commentManagerTextInput"), 25379 cancelButton: document.getElementById("commentManagerCancelButton"), 25380 saveButton: document.getElementById("commentManagerSaveButton") 25381 } 25382 }; 25383} 25384function webViewerLoad() { 25385 const config = getViewerConfiguration(); 25386 const event = new CustomEvent("webviewerloaded", { 25387 bubbles: true, 25388 cancelable: true, 25389 detail: { 25390 source: window 25391 } 25392 }); 25393 try { 25394 parent.document.dispatchEvent(event); 25395 } catch (ex) { 25396 console.error("webviewerloaded:", ex); 25397 document.dispatchEvent(event); 25398 } 25399 PDFViewerApplication.run(config); 25400} 25401document.blockUnblockOnload?.(true); 25402if (document.readyState === "interactive" || document.readyState === "complete") { 25403 webViewerLoad(); 25404} else { 25405 document.addEventListener("DOMContentLoaded", webViewerLoad, true); 25406} 25407 25408export { PDFViewerApplication, AppConstants as PDFViewerApplicationConstants, AppOptions as PDFViewerApplicationOptions }; 25409 25410//# sourceMappingURL=viewer.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.