images
2 years ago
locale
2 years ago
ep-scripts.js
1 year ago
ep-styles.css
1 year ago
viewer.css
2 years ago
viewer.html
2 years ago
viewer.js
1 year ago
viewer.js
18606 lines
| 1 | /** |
| 2 | * @licstart The following is the entire license notice for the |
| 3 | * JavaScript code in this page |
| 4 | * |
| 5 | * Copyright 2023 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 | /******/ var __webpack_modules__ = ({ |
| 24 | |
| 25 | /***/ 9306: |
| 26 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 27 | |
| 28 | |
| 29 | var isCallable = __webpack_require__(4901); |
| 30 | var tryToString = __webpack_require__(6823); |
| 31 | |
| 32 | var $TypeError = TypeError; |
| 33 | |
| 34 | // `Assert: IsCallable(argument) is true` |
| 35 | module.exports = function (argument) { |
| 36 | if (isCallable(argument)) return argument; |
| 37 | throw new $TypeError(tryToString(argument) + ' is not a function'); |
| 38 | }; |
| 39 | |
| 40 | |
| 41 | /***/ }), |
| 42 | |
| 43 | /***/ 3506: |
| 44 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 45 | |
| 46 | |
| 47 | var isPossiblePrototype = __webpack_require__(3925); |
| 48 | |
| 49 | var $String = String; |
| 50 | var $TypeError = TypeError; |
| 51 | |
| 52 | module.exports = function (argument) { |
| 53 | if (isPossiblePrototype(argument)) return argument; |
| 54 | throw new $TypeError("Can't set " + $String(argument) + ' as a prototype'); |
| 55 | }; |
| 56 | |
| 57 | |
| 58 | /***/ }), |
| 59 | |
| 60 | /***/ 7080: |
| 61 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 62 | |
| 63 | |
| 64 | var has = (__webpack_require__(4402).has); |
| 65 | |
| 66 | // Perform ? RequireInternalSlot(M, [[SetData]]) |
| 67 | module.exports = function (it) { |
| 68 | has(it); |
| 69 | return it; |
| 70 | }; |
| 71 | |
| 72 | |
| 73 | /***/ }), |
| 74 | |
| 75 | /***/ 679: |
| 76 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 77 | |
| 78 | |
| 79 | var isPrototypeOf = __webpack_require__(1625); |
| 80 | |
| 81 | var $TypeError = TypeError; |
| 82 | |
| 83 | module.exports = function (it, Prototype) { |
| 84 | if (isPrototypeOf(Prototype, it)) return it; |
| 85 | throw new $TypeError('Incorrect invocation'); |
| 86 | }; |
| 87 | |
| 88 | |
| 89 | /***/ }), |
| 90 | |
| 91 | /***/ 8551: |
| 92 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 93 | |
| 94 | |
| 95 | var isObject = __webpack_require__(34); |
| 96 | |
| 97 | var $String = String; |
| 98 | var $TypeError = TypeError; |
| 99 | |
| 100 | // `Assert: Type(argument) is Object` |
| 101 | module.exports = function (argument) { |
| 102 | if (isObject(argument)) return argument; |
| 103 | throw new $TypeError($String(argument) + ' is not an object'); |
| 104 | }; |
| 105 | |
| 106 | |
| 107 | /***/ }), |
| 108 | |
| 109 | /***/ 9617: |
| 110 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 111 | |
| 112 | |
| 113 | var toIndexedObject = __webpack_require__(5397); |
| 114 | var toAbsoluteIndex = __webpack_require__(5610); |
| 115 | var lengthOfArrayLike = __webpack_require__(6198); |
| 116 | |
| 117 | // `Array.prototype.{ indexOf, includes }` methods implementation |
| 118 | var createMethod = function (IS_INCLUDES) { |
| 119 | return function ($this, el, fromIndex) { |
| 120 | var O = toIndexedObject($this); |
| 121 | var length = lengthOfArrayLike(O); |
| 122 | if (length === 0) return !IS_INCLUDES && -1; |
| 123 | var index = toAbsoluteIndex(fromIndex, length); |
| 124 | var value; |
| 125 | // Array#includes uses SameValueZero equality algorithm |
| 126 | // eslint-disable-next-line no-self-compare -- NaN check |
| 127 | if (IS_INCLUDES && el !== el) while (length > index) { |
| 128 | value = O[index++]; |
| 129 | // eslint-disable-next-line no-self-compare -- NaN check |
| 130 | if (value !== value) return true; |
| 131 | // Array#indexOf ignores holes, Array#includes - not |
| 132 | } else for (;length > index; index++) { |
| 133 | if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; |
| 134 | } return !IS_INCLUDES && -1; |
| 135 | }; |
| 136 | }; |
| 137 | |
| 138 | module.exports = { |
| 139 | // `Array.prototype.includes` method |
| 140 | // https://tc39.es/ecma262/#sec-array.prototype.includes |
| 141 | includes: createMethod(true), |
| 142 | // `Array.prototype.indexOf` method |
| 143 | // https://tc39.es/ecma262/#sec-array.prototype.indexof |
| 144 | indexOf: createMethod(false) |
| 145 | }; |
| 146 | |
| 147 | |
| 148 | /***/ }), |
| 149 | |
| 150 | /***/ 4527: |
| 151 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 152 | |
| 153 | |
| 154 | var DESCRIPTORS = __webpack_require__(3724); |
| 155 | var isArray = __webpack_require__(4376); |
| 156 | |
| 157 | var $TypeError = TypeError; |
| 158 | // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe |
| 159 | var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; |
| 160 | |
| 161 | // Safari < 13 does not throw an error in this case |
| 162 | var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !function () { |
| 163 | // makes no sense without proper strict mode support |
| 164 | if (this !== undefined) return true; |
| 165 | try { |
| 166 | // eslint-disable-next-line es/no-object-defineproperty -- safe |
| 167 | Object.defineProperty([], 'length', { writable: false }).length = 1; |
| 168 | } catch (error) { |
| 169 | return error instanceof TypeError; |
| 170 | } |
| 171 | }(); |
| 172 | |
| 173 | module.exports = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) { |
| 174 | if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) { |
| 175 | throw new $TypeError('Cannot set read only .length'); |
| 176 | } return O.length = length; |
| 177 | } : function (O, length) { |
| 178 | return O.length = length; |
| 179 | }; |
| 180 | |
| 181 | |
| 182 | /***/ }), |
| 183 | |
| 184 | /***/ 6319: |
| 185 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 186 | |
| 187 | |
| 188 | var anObject = __webpack_require__(8551); |
| 189 | var iteratorClose = __webpack_require__(9539); |
| 190 | |
| 191 | // call something on iterator step with safe closing on error |
| 192 | module.exports = function (iterator, fn, value, ENTRIES) { |
| 193 | try { |
| 194 | return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value); |
| 195 | } catch (error) { |
| 196 | iteratorClose(iterator, 'throw', error); |
| 197 | } |
| 198 | }; |
| 199 | |
| 200 | |
| 201 | /***/ }), |
| 202 | |
| 203 | /***/ 4576: |
| 204 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 205 | |
| 206 | |
| 207 | var uncurryThis = __webpack_require__(9504); |
| 208 | |
| 209 | var toString = uncurryThis({}.toString); |
| 210 | var stringSlice = uncurryThis(''.slice); |
| 211 | |
| 212 | module.exports = function (it) { |
| 213 | return stringSlice(toString(it), 8, -1); |
| 214 | }; |
| 215 | |
| 216 | |
| 217 | /***/ }), |
| 218 | |
| 219 | /***/ 6955: |
| 220 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 221 | |
| 222 | |
| 223 | var TO_STRING_TAG_SUPPORT = __webpack_require__(2140); |
| 224 | var isCallable = __webpack_require__(4901); |
| 225 | var classofRaw = __webpack_require__(4576); |
| 226 | var wellKnownSymbol = __webpack_require__(8227); |
| 227 | |
| 228 | var TO_STRING_TAG = wellKnownSymbol('toStringTag'); |
| 229 | var $Object = Object; |
| 230 | |
| 231 | // ES3 wrong here |
| 232 | var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) === 'Arguments'; |
| 233 | |
| 234 | // fallback for IE11 Script Access Denied error |
| 235 | var tryGet = function (it, key) { |
| 236 | try { |
| 237 | return it[key]; |
| 238 | } catch (error) { /* empty */ } |
| 239 | }; |
| 240 | |
| 241 | // getting tag from ES6+ `Object.prototype.toString` |
| 242 | module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) { |
| 243 | var O, tag, result; |
| 244 | return it === undefined ? 'Undefined' : it === null ? 'Null' |
| 245 | // @@toStringTag case |
| 246 | : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag |
| 247 | // builtinTag case |
| 248 | : CORRECT_ARGUMENTS ? classofRaw(O) |
| 249 | // ES3 arguments fallback |
| 250 | : (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result; |
| 251 | }; |
| 252 | |
| 253 | |
| 254 | /***/ }), |
| 255 | |
| 256 | /***/ 7740: |
| 257 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 258 | |
| 259 | |
| 260 | var hasOwn = __webpack_require__(9297); |
| 261 | var ownKeys = __webpack_require__(5031); |
| 262 | var getOwnPropertyDescriptorModule = __webpack_require__(7347); |
| 263 | var definePropertyModule = __webpack_require__(4913); |
| 264 | |
| 265 | module.exports = function (target, source, exceptions) { |
| 266 | var keys = ownKeys(source); |
| 267 | var defineProperty = definePropertyModule.f; |
| 268 | var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f; |
| 269 | for (var i = 0; i < keys.length; i++) { |
| 270 | var key = keys[i]; |
| 271 | if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) { |
| 272 | defineProperty(target, key, getOwnPropertyDescriptor(source, key)); |
| 273 | } |
| 274 | } |
| 275 | }; |
| 276 | |
| 277 | |
| 278 | /***/ }), |
| 279 | |
| 280 | /***/ 2211: |
| 281 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 282 | |
| 283 | |
| 284 | var fails = __webpack_require__(9039); |
| 285 | |
| 286 | module.exports = !fails(function () { |
| 287 | function F() { /* empty */ } |
| 288 | F.prototype.constructor = null; |
| 289 | // eslint-disable-next-line es/no-object-getprototypeof -- required for testing |
| 290 | return Object.getPrototypeOf(new F()) !== F.prototype; |
| 291 | }); |
| 292 | |
| 293 | |
| 294 | /***/ }), |
| 295 | |
| 296 | /***/ 2529: |
| 297 | /***/ ((module) => { |
| 298 | |
| 299 | |
| 300 | // `CreateIterResultObject` abstract operation |
| 301 | // https://tc39.es/ecma262/#sec-createiterresultobject |
| 302 | module.exports = function (value, done) { |
| 303 | return { value: value, done: done }; |
| 304 | }; |
| 305 | |
| 306 | |
| 307 | /***/ }), |
| 308 | |
| 309 | /***/ 6699: |
| 310 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 311 | |
| 312 | |
| 313 | var DESCRIPTORS = __webpack_require__(3724); |
| 314 | var definePropertyModule = __webpack_require__(4913); |
| 315 | var createPropertyDescriptor = __webpack_require__(6980); |
| 316 | |
| 317 | module.exports = DESCRIPTORS ? function (object, key, value) { |
| 318 | return definePropertyModule.f(object, key, createPropertyDescriptor(1, value)); |
| 319 | } : function (object, key, value) { |
| 320 | object[key] = value; |
| 321 | return object; |
| 322 | }; |
| 323 | |
| 324 | |
| 325 | /***/ }), |
| 326 | |
| 327 | /***/ 6980: |
| 328 | /***/ ((module) => { |
| 329 | |
| 330 | |
| 331 | module.exports = function (bitmap, value) { |
| 332 | return { |
| 333 | enumerable: !(bitmap & 1), |
| 334 | configurable: !(bitmap & 2), |
| 335 | writable: !(bitmap & 4), |
| 336 | value: value |
| 337 | }; |
| 338 | }; |
| 339 | |
| 340 | |
| 341 | /***/ }), |
| 342 | |
| 343 | /***/ 4659: |
| 344 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 345 | |
| 346 | |
| 347 | var DESCRIPTORS = __webpack_require__(3724); |
| 348 | var definePropertyModule = __webpack_require__(4913); |
| 349 | var createPropertyDescriptor = __webpack_require__(6980); |
| 350 | |
| 351 | module.exports = function (object, key, value) { |
| 352 | if (DESCRIPTORS) definePropertyModule.f(object, key, createPropertyDescriptor(0, value)); |
| 353 | else object[key] = value; |
| 354 | }; |
| 355 | |
| 356 | |
| 357 | /***/ }), |
| 358 | |
| 359 | /***/ 2106: |
| 360 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 361 | |
| 362 | |
| 363 | var makeBuiltIn = __webpack_require__(283); |
| 364 | var defineProperty = __webpack_require__(4913); |
| 365 | |
| 366 | module.exports = function (target, name, descriptor) { |
| 367 | if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true }); |
| 368 | if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true }); |
| 369 | return defineProperty.f(target, name, descriptor); |
| 370 | }; |
| 371 | |
| 372 | |
| 373 | /***/ }), |
| 374 | |
| 375 | /***/ 6840: |
| 376 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 377 | |
| 378 | |
| 379 | var isCallable = __webpack_require__(4901); |
| 380 | var definePropertyModule = __webpack_require__(4913); |
| 381 | var makeBuiltIn = __webpack_require__(283); |
| 382 | var defineGlobalProperty = __webpack_require__(9433); |
| 383 | |
| 384 | module.exports = function (O, key, value, options) { |
| 385 | if (!options) options = {}; |
| 386 | var simple = options.enumerable; |
| 387 | var name = options.name !== undefined ? options.name : key; |
| 388 | if (isCallable(value)) makeBuiltIn(value, name, options); |
| 389 | if (options.global) { |
| 390 | if (simple) O[key] = value; |
| 391 | else defineGlobalProperty(key, value); |
| 392 | } else { |
| 393 | try { |
| 394 | if (!options.unsafe) delete O[key]; |
| 395 | else if (O[key]) simple = true; |
| 396 | } catch (error) { /* empty */ } |
| 397 | if (simple) O[key] = value; |
| 398 | else definePropertyModule.f(O, key, { |
| 399 | value: value, |
| 400 | enumerable: false, |
| 401 | configurable: !options.nonConfigurable, |
| 402 | writable: !options.nonWritable |
| 403 | }); |
| 404 | } return O; |
| 405 | }; |
| 406 | |
| 407 | |
| 408 | /***/ }), |
| 409 | |
| 410 | /***/ 6279: |
| 411 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 412 | |
| 413 | |
| 414 | var defineBuiltIn = __webpack_require__(6840); |
| 415 | |
| 416 | module.exports = function (target, src, options) { |
| 417 | for (var key in src) defineBuiltIn(target, key, src[key], options); |
| 418 | return target; |
| 419 | }; |
| 420 | |
| 421 | |
| 422 | /***/ }), |
| 423 | |
| 424 | /***/ 9433: |
| 425 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 426 | |
| 427 | |
| 428 | var global = __webpack_require__(4475); |
| 429 | |
| 430 | // eslint-disable-next-line es/no-object-defineproperty -- safe |
| 431 | var defineProperty = Object.defineProperty; |
| 432 | |
| 433 | module.exports = function (key, value) { |
| 434 | try { |
| 435 | defineProperty(global, key, { value: value, configurable: true, writable: true }); |
| 436 | } catch (error) { |
| 437 | global[key] = value; |
| 438 | } return value; |
| 439 | }; |
| 440 | |
| 441 | |
| 442 | /***/ }), |
| 443 | |
| 444 | /***/ 3724: |
| 445 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 446 | |
| 447 | |
| 448 | var fails = __webpack_require__(9039); |
| 449 | |
| 450 | // Detect IE8's incomplete defineProperty implementation |
| 451 | module.exports = !fails(function () { |
| 452 | // eslint-disable-next-line es/no-object-defineproperty -- required for testing |
| 453 | return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] !== 7; |
| 454 | }); |
| 455 | |
| 456 | |
| 457 | /***/ }), |
| 458 | |
| 459 | /***/ 4055: |
| 460 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 461 | |
| 462 | |
| 463 | var global = __webpack_require__(4475); |
| 464 | var isObject = __webpack_require__(34); |
| 465 | |
| 466 | var document = global.document; |
| 467 | // typeof document.createElement is 'object' in old IE |
| 468 | var EXISTS = isObject(document) && isObject(document.createElement); |
| 469 | |
| 470 | module.exports = function (it) { |
| 471 | return EXISTS ? document.createElement(it) : {}; |
| 472 | }; |
| 473 | |
| 474 | |
| 475 | /***/ }), |
| 476 | |
| 477 | /***/ 6837: |
| 478 | /***/ ((module) => { |
| 479 | |
| 480 | |
| 481 | var $TypeError = TypeError; |
| 482 | var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991 |
| 483 | |
| 484 | module.exports = function (it) { |
| 485 | if (it > MAX_SAFE_INTEGER) throw $TypeError('Maximum allowed index exceeded'); |
| 486 | return it; |
| 487 | }; |
| 488 | |
| 489 | |
| 490 | /***/ }), |
| 491 | |
| 492 | /***/ 5002: |
| 493 | /***/ ((module) => { |
| 494 | |
| 495 | |
| 496 | module.exports = { |
| 497 | IndexSizeError: { s: 'INDEX_SIZE_ERR', c: 1, m: 1 }, |
| 498 | DOMStringSizeError: { s: 'DOMSTRING_SIZE_ERR', c: 2, m: 0 }, |
| 499 | HierarchyRequestError: { s: 'HIERARCHY_REQUEST_ERR', c: 3, m: 1 }, |
| 500 | WrongDocumentError: { s: 'WRONG_DOCUMENT_ERR', c: 4, m: 1 }, |
| 501 | InvalidCharacterError: { s: 'INVALID_CHARACTER_ERR', c: 5, m: 1 }, |
| 502 | NoDataAllowedError: { s: 'NO_DATA_ALLOWED_ERR', c: 6, m: 0 }, |
| 503 | NoModificationAllowedError: { s: 'NO_MODIFICATION_ALLOWED_ERR', c: 7, m: 1 }, |
| 504 | NotFoundError: { s: 'NOT_FOUND_ERR', c: 8, m: 1 }, |
| 505 | NotSupportedError: { s: 'NOT_SUPPORTED_ERR', c: 9, m: 1 }, |
| 506 | InUseAttributeError: { s: 'INUSE_ATTRIBUTE_ERR', c: 10, m: 1 }, |
| 507 | InvalidStateError: { s: 'INVALID_STATE_ERR', c: 11, m: 1 }, |
| 508 | SyntaxError: { s: 'SYNTAX_ERR', c: 12, m: 1 }, |
| 509 | InvalidModificationError: { s: 'INVALID_MODIFICATION_ERR', c: 13, m: 1 }, |
| 510 | NamespaceError: { s: 'NAMESPACE_ERR', c: 14, m: 1 }, |
| 511 | InvalidAccessError: { s: 'INVALID_ACCESS_ERR', c: 15, m: 1 }, |
| 512 | ValidationError: { s: 'VALIDATION_ERR', c: 16, m: 0 }, |
| 513 | TypeMismatchError: { s: 'TYPE_MISMATCH_ERR', c: 17, m: 1 }, |
| 514 | SecurityError: { s: 'SECURITY_ERR', c: 18, m: 1 }, |
| 515 | NetworkError: { s: 'NETWORK_ERR', c: 19, m: 1 }, |
| 516 | AbortError: { s: 'ABORT_ERR', c: 20, m: 1 }, |
| 517 | URLMismatchError: { s: 'URL_MISMATCH_ERR', c: 21, m: 1 }, |
| 518 | QuotaExceededError: { s: 'QUOTA_EXCEEDED_ERR', c: 22, m: 1 }, |
| 519 | TimeoutError: { s: 'TIMEOUT_ERR', c: 23, m: 1 }, |
| 520 | InvalidNodeTypeError: { s: 'INVALID_NODE_TYPE_ERR', c: 24, m: 1 }, |
| 521 | DataCloneError: { s: 'DATA_CLONE_ERR', c: 25, m: 1 } |
| 522 | }; |
| 523 | |
| 524 | |
| 525 | /***/ }), |
| 526 | |
| 527 | /***/ 9392: |
| 528 | /***/ ((module) => { |
| 529 | |
| 530 | |
| 531 | module.exports = typeof navigator != 'undefined' && String(navigator.userAgent) || ''; |
| 532 | |
| 533 | |
| 534 | /***/ }), |
| 535 | |
| 536 | /***/ 7388: |
| 537 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 538 | |
| 539 | |
| 540 | var global = __webpack_require__(4475); |
| 541 | var userAgent = __webpack_require__(9392); |
| 542 | |
| 543 | var process = global.process; |
| 544 | var Deno = global.Deno; |
| 545 | var versions = process && process.versions || Deno && Deno.version; |
| 546 | var v8 = versions && versions.v8; |
| 547 | var match, version; |
| 548 | |
| 549 | if (v8) { |
| 550 | match = v8.split('.'); |
| 551 | // in old Chrome, versions of V8 isn't V8 = Chrome / 10 |
| 552 | // but their correct versions are not interesting for us |
| 553 | version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); |
| 554 | } |
| 555 | |
| 556 | // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0` |
| 557 | // so check `userAgent` even if `.v8` exists, but 0 |
| 558 | if (!version && userAgent) { |
| 559 | match = userAgent.match(/Edge\/(\d+)/); |
| 560 | if (!match || match[1] >= 74) { |
| 561 | match = userAgent.match(/Chrome\/(\d+)/); |
| 562 | if (match) version = +match[1]; |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | module.exports = version; |
| 567 | |
| 568 | |
| 569 | /***/ }), |
| 570 | |
| 571 | /***/ 8727: |
| 572 | /***/ ((module) => { |
| 573 | |
| 574 | |
| 575 | // IE8- don't enum bug keys |
| 576 | module.exports = [ |
| 577 | 'constructor', |
| 578 | 'hasOwnProperty', |
| 579 | 'isPrototypeOf', |
| 580 | 'propertyIsEnumerable', |
| 581 | 'toLocaleString', |
| 582 | 'toString', |
| 583 | 'valueOf' |
| 584 | ]; |
| 585 | |
| 586 | |
| 587 | /***/ }), |
| 588 | |
| 589 | /***/ 6193: |
| 590 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 591 | |
| 592 | |
| 593 | var uncurryThis = __webpack_require__(9504); |
| 594 | |
| 595 | var $Error = Error; |
| 596 | var replace = uncurryThis(''.replace); |
| 597 | |
| 598 | var TEST = (function (arg) { return String(new $Error(arg).stack); })('zxcasd'); |
| 599 | // eslint-disable-next-line redos/no-vulnerable -- safe |
| 600 | var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/; |
| 601 | var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST); |
| 602 | |
| 603 | module.exports = function (stack, dropEntries) { |
| 604 | if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) { |
| 605 | while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, ''); |
| 606 | } return stack; |
| 607 | }; |
| 608 | |
| 609 | |
| 610 | /***/ }), |
| 611 | |
| 612 | /***/ 6518: |
| 613 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 614 | |
| 615 | |
| 616 | var global = __webpack_require__(4475); |
| 617 | var getOwnPropertyDescriptor = (__webpack_require__(7347).f); |
| 618 | var createNonEnumerableProperty = __webpack_require__(6699); |
| 619 | var defineBuiltIn = __webpack_require__(6840); |
| 620 | var defineGlobalProperty = __webpack_require__(9433); |
| 621 | var copyConstructorProperties = __webpack_require__(7740); |
| 622 | var isForced = __webpack_require__(2796); |
| 623 | |
| 624 | /* |
| 625 | options.target - name of the target object |
| 626 | options.global - target is the global object |
| 627 | options.stat - export as static methods of target |
| 628 | options.proto - export as prototype methods of target |
| 629 | options.real - real prototype method for the `pure` version |
| 630 | options.forced - export even if the native feature is available |
| 631 | options.bind - bind methods to the target, required for the `pure` version |
| 632 | options.wrap - wrap constructors to preventing global pollution, required for the `pure` version |
| 633 | options.unsafe - use the simple assignment of property instead of delete + defineProperty |
| 634 | options.sham - add a flag to not completely full polyfills |
| 635 | options.enumerable - export as enumerable property |
| 636 | options.dontCallGetSet - prevent calling a getter on target |
| 637 | options.name - the .name of the function if it does not match the key |
| 638 | */ |
| 639 | module.exports = function (options, source) { |
| 640 | var TARGET = options.target; |
| 641 | var GLOBAL = options.global; |
| 642 | var STATIC = options.stat; |
| 643 | var FORCED, target, key, targetProperty, sourceProperty, descriptor; |
| 644 | if (GLOBAL) { |
| 645 | target = global; |
| 646 | } else if (STATIC) { |
| 647 | target = global[TARGET] || defineGlobalProperty(TARGET, {}); |
| 648 | } else { |
| 649 | target = global[TARGET] && global[TARGET].prototype; |
| 650 | } |
| 651 | if (target) for (key in source) { |
| 652 | sourceProperty = source[key]; |
| 653 | if (options.dontCallGetSet) { |
| 654 | descriptor = getOwnPropertyDescriptor(target, key); |
| 655 | targetProperty = descriptor && descriptor.value; |
| 656 | } else targetProperty = target[key]; |
| 657 | FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); |
| 658 | // contained in target |
| 659 | if (!FORCED && targetProperty !== undefined) { |
| 660 | if (typeof sourceProperty == typeof targetProperty) continue; |
| 661 | copyConstructorProperties(sourceProperty, targetProperty); |
| 662 | } |
| 663 | // add a flag to not completely full polyfills |
| 664 | if (options.sham || (targetProperty && targetProperty.sham)) { |
| 665 | createNonEnumerableProperty(sourceProperty, 'sham', true); |
| 666 | } |
| 667 | defineBuiltIn(target, key, sourceProperty, options); |
| 668 | } |
| 669 | }; |
| 670 | |
| 671 | |
| 672 | /***/ }), |
| 673 | |
| 674 | /***/ 9039: |
| 675 | /***/ ((module) => { |
| 676 | |
| 677 | |
| 678 | module.exports = function (exec) { |
| 679 | try { |
| 680 | return !!exec(); |
| 681 | } catch (error) { |
| 682 | return true; |
| 683 | } |
| 684 | }; |
| 685 | |
| 686 | |
| 687 | /***/ }), |
| 688 | |
| 689 | /***/ 6080: |
| 690 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 691 | |
| 692 | |
| 693 | var uncurryThis = __webpack_require__(7476); |
| 694 | var aCallable = __webpack_require__(9306); |
| 695 | var NATIVE_BIND = __webpack_require__(616); |
| 696 | |
| 697 | var bind = uncurryThis(uncurryThis.bind); |
| 698 | |
| 699 | // optional / simple context binding |
| 700 | module.exports = function (fn, that) { |
| 701 | aCallable(fn); |
| 702 | return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function (/* ...args */) { |
| 703 | return fn.apply(that, arguments); |
| 704 | }; |
| 705 | }; |
| 706 | |
| 707 | |
| 708 | /***/ }), |
| 709 | |
| 710 | /***/ 616: |
| 711 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 712 | |
| 713 | |
| 714 | var fails = __webpack_require__(9039); |
| 715 | |
| 716 | module.exports = !fails(function () { |
| 717 | // eslint-disable-next-line es/no-function-prototype-bind -- safe |
| 718 | var test = (function () { /* empty */ }).bind(); |
| 719 | // eslint-disable-next-line no-prototype-builtins -- safe |
| 720 | return typeof test != 'function' || test.hasOwnProperty('prototype'); |
| 721 | }); |
| 722 | |
| 723 | |
| 724 | /***/ }), |
| 725 | |
| 726 | /***/ 9565: |
| 727 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 728 | |
| 729 | |
| 730 | var NATIVE_BIND = __webpack_require__(616); |
| 731 | |
| 732 | var call = Function.prototype.call; |
| 733 | |
| 734 | module.exports = NATIVE_BIND ? call.bind(call) : function () { |
| 735 | return call.apply(call, arguments); |
| 736 | }; |
| 737 | |
| 738 | |
| 739 | /***/ }), |
| 740 | |
| 741 | /***/ 350: |
| 742 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 743 | |
| 744 | |
| 745 | var DESCRIPTORS = __webpack_require__(3724); |
| 746 | var hasOwn = __webpack_require__(9297); |
| 747 | |
| 748 | var FunctionPrototype = Function.prototype; |
| 749 | // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe |
| 750 | var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor; |
| 751 | |
| 752 | var EXISTS = hasOwn(FunctionPrototype, 'name'); |
| 753 | // additional protection from minified / mangled / dropped function names |
| 754 | var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something'; |
| 755 | var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable)); |
| 756 | |
| 757 | module.exports = { |
| 758 | EXISTS: EXISTS, |
| 759 | PROPER: PROPER, |
| 760 | CONFIGURABLE: CONFIGURABLE |
| 761 | }; |
| 762 | |
| 763 | |
| 764 | /***/ }), |
| 765 | |
| 766 | /***/ 6706: |
| 767 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 768 | |
| 769 | |
| 770 | var uncurryThis = __webpack_require__(9504); |
| 771 | var aCallable = __webpack_require__(9306); |
| 772 | |
| 773 | module.exports = function (object, key, method) { |
| 774 | try { |
| 775 | // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe |
| 776 | return uncurryThis(aCallable(Object.getOwnPropertyDescriptor(object, key)[method])); |
| 777 | } catch (error) { /* empty */ } |
| 778 | }; |
| 779 | |
| 780 | |
| 781 | /***/ }), |
| 782 | |
| 783 | /***/ 7476: |
| 784 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 785 | |
| 786 | |
| 787 | var classofRaw = __webpack_require__(4576); |
| 788 | var uncurryThis = __webpack_require__(9504); |
| 789 | |
| 790 | module.exports = function (fn) { |
| 791 | // Nashorn bug: |
| 792 | // https://github.com/zloirock/core-js/issues/1128 |
| 793 | // https://github.com/zloirock/core-js/issues/1130 |
| 794 | if (classofRaw(fn) === 'Function') return uncurryThis(fn); |
| 795 | }; |
| 796 | |
| 797 | |
| 798 | /***/ }), |
| 799 | |
| 800 | /***/ 9504: |
| 801 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 802 | |
| 803 | |
| 804 | var NATIVE_BIND = __webpack_require__(616); |
| 805 | |
| 806 | var FunctionPrototype = Function.prototype; |
| 807 | var call = FunctionPrototype.call; |
| 808 | var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call); |
| 809 | |
| 810 | module.exports = NATIVE_BIND ? uncurryThisWithBind : function (fn) { |
| 811 | return function () { |
| 812 | return call.apply(fn, arguments); |
| 813 | }; |
| 814 | }; |
| 815 | |
| 816 | |
| 817 | /***/ }), |
| 818 | |
| 819 | /***/ 7751: |
| 820 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 821 | |
| 822 | |
| 823 | var global = __webpack_require__(4475); |
| 824 | var isCallable = __webpack_require__(4901); |
| 825 | |
| 826 | var aFunction = function (argument) { |
| 827 | return isCallable(argument) ? argument : undefined; |
| 828 | }; |
| 829 | |
| 830 | module.exports = function (namespace, method) { |
| 831 | return arguments.length < 2 ? aFunction(global[namespace]) : global[namespace] && global[namespace][method]; |
| 832 | }; |
| 833 | |
| 834 | |
| 835 | /***/ }), |
| 836 | |
| 837 | /***/ 1767: |
| 838 | /***/ ((module) => { |
| 839 | |
| 840 | |
| 841 | // `GetIteratorDirect(obj)` abstract operation |
| 842 | // https://tc39.es/proposal-iterator-helpers/#sec-getiteratordirect |
| 843 | module.exports = function (obj) { |
| 844 | return { |
| 845 | iterator: obj, |
| 846 | next: obj.next, |
| 847 | done: false |
| 848 | }; |
| 849 | }; |
| 850 | |
| 851 | |
| 852 | /***/ }), |
| 853 | |
| 854 | /***/ 851: |
| 855 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 856 | |
| 857 | |
| 858 | var classof = __webpack_require__(6955); |
| 859 | var getMethod = __webpack_require__(5966); |
| 860 | var isNullOrUndefined = __webpack_require__(4117); |
| 861 | var Iterators = __webpack_require__(6269); |
| 862 | var wellKnownSymbol = __webpack_require__(8227); |
| 863 | |
| 864 | var ITERATOR = wellKnownSymbol('iterator'); |
| 865 | |
| 866 | module.exports = function (it) { |
| 867 | if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR) |
| 868 | || getMethod(it, '@@iterator') |
| 869 | || Iterators[classof(it)]; |
| 870 | }; |
| 871 | |
| 872 | |
| 873 | /***/ }), |
| 874 | |
| 875 | /***/ 81: |
| 876 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 877 | |
| 878 | |
| 879 | var call = __webpack_require__(9565); |
| 880 | var aCallable = __webpack_require__(9306); |
| 881 | var anObject = __webpack_require__(8551); |
| 882 | var tryToString = __webpack_require__(6823); |
| 883 | var getIteratorMethod = __webpack_require__(851); |
| 884 | |
| 885 | var $TypeError = TypeError; |
| 886 | |
| 887 | module.exports = function (argument, usingIterator) { |
| 888 | var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator; |
| 889 | if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument)); |
| 890 | throw new $TypeError(tryToString(argument) + ' is not iterable'); |
| 891 | }; |
| 892 | |
| 893 | |
| 894 | /***/ }), |
| 895 | |
| 896 | /***/ 5966: |
| 897 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 898 | |
| 899 | |
| 900 | var aCallable = __webpack_require__(9306); |
| 901 | var isNullOrUndefined = __webpack_require__(4117); |
| 902 | |
| 903 | // `GetMethod` abstract operation |
| 904 | // https://tc39.es/ecma262/#sec-getmethod |
| 905 | module.exports = function (V, P) { |
| 906 | var func = V[P]; |
| 907 | return isNullOrUndefined(func) ? undefined : aCallable(func); |
| 908 | }; |
| 909 | |
| 910 | |
| 911 | /***/ }), |
| 912 | |
| 913 | /***/ 3789: |
| 914 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 915 | |
| 916 | |
| 917 | var aCallable = __webpack_require__(9306); |
| 918 | var anObject = __webpack_require__(8551); |
| 919 | var call = __webpack_require__(9565); |
| 920 | var toIntegerOrInfinity = __webpack_require__(1291); |
| 921 | var getIteratorDirect = __webpack_require__(1767); |
| 922 | |
| 923 | var INVALID_SIZE = 'Invalid size'; |
| 924 | var $RangeError = RangeError; |
| 925 | var $TypeError = TypeError; |
| 926 | var max = Math.max; |
| 927 | |
| 928 | var SetRecord = function (set, intSize) { |
| 929 | this.set = set; |
| 930 | this.size = max(intSize, 0); |
| 931 | this.has = aCallable(set.has); |
| 932 | this.keys = aCallable(set.keys); |
| 933 | }; |
| 934 | |
| 935 | SetRecord.prototype = { |
| 936 | getIterator: function () { |
| 937 | return getIteratorDirect(anObject(call(this.keys, this.set))); |
| 938 | }, |
| 939 | includes: function (it) { |
| 940 | return call(this.has, this.set, it); |
| 941 | } |
| 942 | }; |
| 943 | |
| 944 | // `GetSetRecord` abstract operation |
| 945 | // https://tc39.es/proposal-set-methods/#sec-getsetrecord |
| 946 | module.exports = function (obj) { |
| 947 | anObject(obj); |
| 948 | var numSize = +obj.size; |
| 949 | // NOTE: If size is undefined, then numSize will be NaN |
| 950 | // eslint-disable-next-line no-self-compare -- NaN check |
| 951 | if (numSize !== numSize) throw new $TypeError(INVALID_SIZE); |
| 952 | var intSize = toIntegerOrInfinity(numSize); |
| 953 | if (intSize < 0) throw new $RangeError(INVALID_SIZE); |
| 954 | return new SetRecord(obj, intSize); |
| 955 | }; |
| 956 | |
| 957 | |
| 958 | /***/ }), |
| 959 | |
| 960 | /***/ 4475: |
| 961 | /***/ (function(module) { |
| 962 | |
| 963 | |
| 964 | var check = function (it) { |
| 965 | return it && it.Math === Math && it; |
| 966 | }; |
| 967 | |
| 968 | // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 |
| 969 | module.exports = |
| 970 | // eslint-disable-next-line es/no-global-this -- safe |
| 971 | check(typeof globalThis == 'object' && globalThis) || |
| 972 | check(typeof window == 'object' && window) || |
| 973 | // eslint-disable-next-line no-restricted-globals -- safe |
| 974 | check(typeof self == 'object' && self) || |
| 975 | check(typeof global == 'object' && global) || |
| 976 | check(typeof this == 'object' && this) || |
| 977 | // eslint-disable-next-line no-new-func -- fallback |
| 978 | (function () { return this; })() || Function('return this')(); |
| 979 | |
| 980 | |
| 981 | /***/ }), |
| 982 | |
| 983 | /***/ 9297: |
| 984 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 985 | |
| 986 | |
| 987 | var uncurryThis = __webpack_require__(9504); |
| 988 | var toObject = __webpack_require__(8981); |
| 989 | |
| 990 | var hasOwnProperty = uncurryThis({}.hasOwnProperty); |
| 991 | |
| 992 | // `HasOwnProperty` abstract operation |
| 993 | // https://tc39.es/ecma262/#sec-hasownproperty |
| 994 | // eslint-disable-next-line es/no-object-hasown -- safe |
| 995 | module.exports = Object.hasOwn || function hasOwn(it, key) { |
| 996 | return hasOwnProperty(toObject(it), key); |
| 997 | }; |
| 998 | |
| 999 | |
| 1000 | /***/ }), |
| 1001 | |
| 1002 | /***/ 421: |
| 1003 | /***/ ((module) => { |
| 1004 | |
| 1005 | |
| 1006 | module.exports = {}; |
| 1007 | |
| 1008 | |
| 1009 | /***/ }), |
| 1010 | |
| 1011 | /***/ 397: |
| 1012 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1013 | |
| 1014 | |
| 1015 | var getBuiltIn = __webpack_require__(7751); |
| 1016 | |
| 1017 | module.exports = getBuiltIn('document', 'documentElement'); |
| 1018 | |
| 1019 | |
| 1020 | /***/ }), |
| 1021 | |
| 1022 | /***/ 5917: |
| 1023 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1024 | |
| 1025 | |
| 1026 | var DESCRIPTORS = __webpack_require__(3724); |
| 1027 | var fails = __webpack_require__(9039); |
| 1028 | var createElement = __webpack_require__(4055); |
| 1029 | |
| 1030 | // Thanks to IE8 for its funny defineProperty |
| 1031 | module.exports = !DESCRIPTORS && !fails(function () { |
| 1032 | // eslint-disable-next-line es/no-object-defineproperty -- required for testing |
| 1033 | return Object.defineProperty(createElement('div'), 'a', { |
| 1034 | get: function () { return 7; } |
| 1035 | }).a !== 7; |
| 1036 | }); |
| 1037 | |
| 1038 | |
| 1039 | /***/ }), |
| 1040 | |
| 1041 | /***/ 7055: |
| 1042 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1043 | |
| 1044 | |
| 1045 | var uncurryThis = __webpack_require__(9504); |
| 1046 | var fails = __webpack_require__(9039); |
| 1047 | var classof = __webpack_require__(4576); |
| 1048 | |
| 1049 | var $Object = Object; |
| 1050 | var split = uncurryThis(''.split); |
| 1051 | |
| 1052 | // fallback for non-array-like ES3 and non-enumerable old V8 strings |
| 1053 | module.exports = fails(function () { |
| 1054 | // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 |
| 1055 | // eslint-disable-next-line no-prototype-builtins -- safe |
| 1056 | return !$Object('z').propertyIsEnumerable(0); |
| 1057 | }) ? function (it) { |
| 1058 | return classof(it) === 'String' ? split(it, '') : $Object(it); |
| 1059 | } : $Object; |
| 1060 | |
| 1061 | |
| 1062 | /***/ }), |
| 1063 | |
| 1064 | /***/ 3167: |
| 1065 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1066 | |
| 1067 | |
| 1068 | var isCallable = __webpack_require__(4901); |
| 1069 | var isObject = __webpack_require__(34); |
| 1070 | var setPrototypeOf = __webpack_require__(2967); |
| 1071 | |
| 1072 | // makes subclassing work correct for wrapped built-ins |
| 1073 | module.exports = function ($this, dummy, Wrapper) { |
| 1074 | var NewTarget, NewTargetPrototype; |
| 1075 | if ( |
| 1076 | // it can work only with native `setPrototypeOf` |
| 1077 | setPrototypeOf && |
| 1078 | // we haven't completely correct pre-ES6 way for getting `new.target`, so use this |
| 1079 | isCallable(NewTarget = dummy.constructor) && |
| 1080 | NewTarget !== Wrapper && |
| 1081 | isObject(NewTargetPrototype = NewTarget.prototype) && |
| 1082 | NewTargetPrototype !== Wrapper.prototype |
| 1083 | ) setPrototypeOf($this, NewTargetPrototype); |
| 1084 | return $this; |
| 1085 | }; |
| 1086 | |
| 1087 | |
| 1088 | /***/ }), |
| 1089 | |
| 1090 | /***/ 3706: |
| 1091 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1092 | |
| 1093 | |
| 1094 | var uncurryThis = __webpack_require__(9504); |
| 1095 | var isCallable = __webpack_require__(4901); |
| 1096 | var store = __webpack_require__(7629); |
| 1097 | |
| 1098 | var functionToString = uncurryThis(Function.toString); |
| 1099 | |
| 1100 | // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper |
| 1101 | if (!isCallable(store.inspectSource)) { |
| 1102 | store.inspectSource = function (it) { |
| 1103 | return functionToString(it); |
| 1104 | }; |
| 1105 | } |
| 1106 | |
| 1107 | module.exports = store.inspectSource; |
| 1108 | |
| 1109 | |
| 1110 | /***/ }), |
| 1111 | |
| 1112 | /***/ 1181: |
| 1113 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1114 | |
| 1115 | |
| 1116 | var NATIVE_WEAK_MAP = __webpack_require__(8622); |
| 1117 | var global = __webpack_require__(4475); |
| 1118 | var isObject = __webpack_require__(34); |
| 1119 | var createNonEnumerableProperty = __webpack_require__(6699); |
| 1120 | var hasOwn = __webpack_require__(9297); |
| 1121 | var shared = __webpack_require__(7629); |
| 1122 | var sharedKey = __webpack_require__(6119); |
| 1123 | var hiddenKeys = __webpack_require__(421); |
| 1124 | |
| 1125 | var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; |
| 1126 | var TypeError = global.TypeError; |
| 1127 | var WeakMap = global.WeakMap; |
| 1128 | var set, get, has; |
| 1129 | |
| 1130 | var enforce = function (it) { |
| 1131 | return has(it) ? get(it) : set(it, {}); |
| 1132 | }; |
| 1133 | |
| 1134 | var getterFor = function (TYPE) { |
| 1135 | return function (it) { |
| 1136 | var state; |
| 1137 | if (!isObject(it) || (state = get(it)).type !== TYPE) { |
| 1138 | throw new TypeError('Incompatible receiver, ' + TYPE + ' required'); |
| 1139 | } return state; |
| 1140 | }; |
| 1141 | }; |
| 1142 | |
| 1143 | if (NATIVE_WEAK_MAP || shared.state) { |
| 1144 | var store = shared.state || (shared.state = new WeakMap()); |
| 1145 | /* eslint-disable no-self-assign -- prototype methods protection */ |
| 1146 | store.get = store.get; |
| 1147 | store.has = store.has; |
| 1148 | store.set = store.set; |
| 1149 | /* eslint-enable no-self-assign -- prototype methods protection */ |
| 1150 | set = function (it, metadata) { |
| 1151 | if (store.has(it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED); |
| 1152 | metadata.facade = it; |
| 1153 | store.set(it, metadata); |
| 1154 | return metadata; |
| 1155 | }; |
| 1156 | get = function (it) { |
| 1157 | return store.get(it) || {}; |
| 1158 | }; |
| 1159 | has = function (it) { |
| 1160 | return store.has(it); |
| 1161 | }; |
| 1162 | } else { |
| 1163 | var STATE = sharedKey('state'); |
| 1164 | hiddenKeys[STATE] = true; |
| 1165 | set = function (it, metadata) { |
| 1166 | if (hasOwn(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED); |
| 1167 | metadata.facade = it; |
| 1168 | createNonEnumerableProperty(it, STATE, metadata); |
| 1169 | return metadata; |
| 1170 | }; |
| 1171 | get = function (it) { |
| 1172 | return hasOwn(it, STATE) ? it[STATE] : {}; |
| 1173 | }; |
| 1174 | has = function (it) { |
| 1175 | return hasOwn(it, STATE); |
| 1176 | }; |
| 1177 | } |
| 1178 | |
| 1179 | module.exports = { |
| 1180 | set: set, |
| 1181 | get: get, |
| 1182 | has: has, |
| 1183 | enforce: enforce, |
| 1184 | getterFor: getterFor |
| 1185 | }; |
| 1186 | |
| 1187 | |
| 1188 | /***/ }), |
| 1189 | |
| 1190 | /***/ 4209: |
| 1191 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1192 | |
| 1193 | |
| 1194 | var wellKnownSymbol = __webpack_require__(8227); |
| 1195 | var Iterators = __webpack_require__(6269); |
| 1196 | |
| 1197 | var ITERATOR = wellKnownSymbol('iterator'); |
| 1198 | var ArrayPrototype = Array.prototype; |
| 1199 | |
| 1200 | // check on default Array iterator |
| 1201 | module.exports = function (it) { |
| 1202 | return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it); |
| 1203 | }; |
| 1204 | |
| 1205 | |
| 1206 | /***/ }), |
| 1207 | |
| 1208 | /***/ 4376: |
| 1209 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1210 | |
| 1211 | |
| 1212 | var classof = __webpack_require__(4576); |
| 1213 | |
| 1214 | // `IsArray` abstract operation |
| 1215 | // https://tc39.es/ecma262/#sec-isarray |
| 1216 | // eslint-disable-next-line es/no-array-isarray -- safe |
| 1217 | module.exports = Array.isArray || function isArray(argument) { |
| 1218 | return classof(argument) === 'Array'; |
| 1219 | }; |
| 1220 | |
| 1221 | |
| 1222 | /***/ }), |
| 1223 | |
| 1224 | /***/ 4901: |
| 1225 | /***/ ((module) => { |
| 1226 | |
| 1227 | |
| 1228 | // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot |
| 1229 | var documentAll = typeof document == 'object' && document.all; |
| 1230 | |
| 1231 | // `IsCallable` abstract operation |
| 1232 | // https://tc39.es/ecma262/#sec-iscallable |
| 1233 | // eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing |
| 1234 | module.exports = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) { |
| 1235 | return typeof argument == 'function' || argument === documentAll; |
| 1236 | } : function (argument) { |
| 1237 | return typeof argument == 'function'; |
| 1238 | }; |
| 1239 | |
| 1240 | |
| 1241 | /***/ }), |
| 1242 | |
| 1243 | /***/ 2796: |
| 1244 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1245 | |
| 1246 | |
| 1247 | var fails = __webpack_require__(9039); |
| 1248 | var isCallable = __webpack_require__(4901); |
| 1249 | |
| 1250 | var replacement = /#|\.prototype\./; |
| 1251 | |
| 1252 | var isForced = function (feature, detection) { |
| 1253 | var value = data[normalize(feature)]; |
| 1254 | return value === POLYFILL ? true |
| 1255 | : value === NATIVE ? false |
| 1256 | : isCallable(detection) ? fails(detection) |
| 1257 | : !!detection; |
| 1258 | }; |
| 1259 | |
| 1260 | var normalize = isForced.normalize = function (string) { |
| 1261 | return String(string).replace(replacement, '.').toLowerCase(); |
| 1262 | }; |
| 1263 | |
| 1264 | var data = isForced.data = {}; |
| 1265 | var NATIVE = isForced.NATIVE = 'N'; |
| 1266 | var POLYFILL = isForced.POLYFILL = 'P'; |
| 1267 | |
| 1268 | module.exports = isForced; |
| 1269 | |
| 1270 | |
| 1271 | /***/ }), |
| 1272 | |
| 1273 | /***/ 4117: |
| 1274 | /***/ ((module) => { |
| 1275 | |
| 1276 | |
| 1277 | // we can't use just `it == null` since of `document.all` special case |
| 1278 | // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec |
| 1279 | module.exports = function (it) { |
| 1280 | return it === null || it === undefined; |
| 1281 | }; |
| 1282 | |
| 1283 | |
| 1284 | /***/ }), |
| 1285 | |
| 1286 | /***/ 34: |
| 1287 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1288 | |
| 1289 | |
| 1290 | var isCallable = __webpack_require__(4901); |
| 1291 | |
| 1292 | module.exports = function (it) { |
| 1293 | return typeof it == 'object' ? it !== null : isCallable(it); |
| 1294 | }; |
| 1295 | |
| 1296 | |
| 1297 | /***/ }), |
| 1298 | |
| 1299 | /***/ 3925: |
| 1300 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1301 | |
| 1302 | |
| 1303 | var isObject = __webpack_require__(34); |
| 1304 | |
| 1305 | module.exports = function (argument) { |
| 1306 | return isObject(argument) || argument === null; |
| 1307 | }; |
| 1308 | |
| 1309 | |
| 1310 | /***/ }), |
| 1311 | |
| 1312 | /***/ 6395: |
| 1313 | /***/ ((module) => { |
| 1314 | |
| 1315 | |
| 1316 | module.exports = false; |
| 1317 | |
| 1318 | |
| 1319 | /***/ }), |
| 1320 | |
| 1321 | /***/ 757: |
| 1322 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1323 | |
| 1324 | |
| 1325 | var getBuiltIn = __webpack_require__(7751); |
| 1326 | var isCallable = __webpack_require__(4901); |
| 1327 | var isPrototypeOf = __webpack_require__(1625); |
| 1328 | var USE_SYMBOL_AS_UID = __webpack_require__(7040); |
| 1329 | |
| 1330 | var $Object = Object; |
| 1331 | |
| 1332 | module.exports = USE_SYMBOL_AS_UID ? function (it) { |
| 1333 | return typeof it == 'symbol'; |
| 1334 | } : function (it) { |
| 1335 | var $Symbol = getBuiltIn('Symbol'); |
| 1336 | return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it)); |
| 1337 | }; |
| 1338 | |
| 1339 | |
| 1340 | /***/ }), |
| 1341 | |
| 1342 | /***/ 507: |
| 1343 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1344 | |
| 1345 | |
| 1346 | var call = __webpack_require__(9565); |
| 1347 | |
| 1348 | module.exports = function (record, fn, ITERATOR_INSTEAD_OF_RECORD) { |
| 1349 | var iterator = ITERATOR_INSTEAD_OF_RECORD ? record : record.iterator; |
| 1350 | var next = record.next; |
| 1351 | var step, result; |
| 1352 | while (!(step = call(next, iterator)).done) { |
| 1353 | result = fn(step.value); |
| 1354 | if (result !== undefined) return result; |
| 1355 | } |
| 1356 | }; |
| 1357 | |
| 1358 | |
| 1359 | /***/ }), |
| 1360 | |
| 1361 | /***/ 2652: |
| 1362 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1363 | |
| 1364 | |
| 1365 | var bind = __webpack_require__(6080); |
| 1366 | var call = __webpack_require__(9565); |
| 1367 | var anObject = __webpack_require__(8551); |
| 1368 | var tryToString = __webpack_require__(6823); |
| 1369 | var isArrayIteratorMethod = __webpack_require__(4209); |
| 1370 | var lengthOfArrayLike = __webpack_require__(6198); |
| 1371 | var isPrototypeOf = __webpack_require__(1625); |
| 1372 | var getIterator = __webpack_require__(81); |
| 1373 | var getIteratorMethod = __webpack_require__(851); |
| 1374 | var iteratorClose = __webpack_require__(9539); |
| 1375 | |
| 1376 | var $TypeError = TypeError; |
| 1377 | |
| 1378 | var Result = function (stopped, result) { |
| 1379 | this.stopped = stopped; |
| 1380 | this.result = result; |
| 1381 | }; |
| 1382 | |
| 1383 | var ResultPrototype = Result.prototype; |
| 1384 | |
| 1385 | module.exports = function (iterable, unboundFunction, options) { |
| 1386 | var that = options && options.that; |
| 1387 | var AS_ENTRIES = !!(options && options.AS_ENTRIES); |
| 1388 | var IS_RECORD = !!(options && options.IS_RECORD); |
| 1389 | var IS_ITERATOR = !!(options && options.IS_ITERATOR); |
| 1390 | var INTERRUPTED = !!(options && options.INTERRUPTED); |
| 1391 | var fn = bind(unboundFunction, that); |
| 1392 | var iterator, iterFn, index, length, result, next, step; |
| 1393 | |
| 1394 | var stop = function (condition) { |
| 1395 | if (iterator) iteratorClose(iterator, 'normal', condition); |
| 1396 | return new Result(true, condition); |
| 1397 | }; |
| 1398 | |
| 1399 | var callFn = function (value) { |
| 1400 | if (AS_ENTRIES) { |
| 1401 | anObject(value); |
| 1402 | return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]); |
| 1403 | } return INTERRUPTED ? fn(value, stop) : fn(value); |
| 1404 | }; |
| 1405 | |
| 1406 | if (IS_RECORD) { |
| 1407 | iterator = iterable.iterator; |
| 1408 | } else if (IS_ITERATOR) { |
| 1409 | iterator = iterable; |
| 1410 | } else { |
| 1411 | iterFn = getIteratorMethod(iterable); |
| 1412 | if (!iterFn) throw new $TypeError(tryToString(iterable) + ' is not iterable'); |
| 1413 | // optimisation for array iterators |
| 1414 | if (isArrayIteratorMethod(iterFn)) { |
| 1415 | for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) { |
| 1416 | result = callFn(iterable[index]); |
| 1417 | if (result && isPrototypeOf(ResultPrototype, result)) return result; |
| 1418 | } return new Result(false); |
| 1419 | } |
| 1420 | iterator = getIterator(iterable, iterFn); |
| 1421 | } |
| 1422 | |
| 1423 | next = IS_RECORD ? iterable.next : iterator.next; |
| 1424 | while (!(step = call(next, iterator)).done) { |
| 1425 | try { |
| 1426 | result = callFn(step.value); |
| 1427 | } catch (error) { |
| 1428 | iteratorClose(iterator, 'throw', error); |
| 1429 | } |
| 1430 | if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result; |
| 1431 | } return new Result(false); |
| 1432 | }; |
| 1433 | |
| 1434 | |
| 1435 | /***/ }), |
| 1436 | |
| 1437 | /***/ 9539: |
| 1438 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1439 | |
| 1440 | |
| 1441 | var call = __webpack_require__(9565); |
| 1442 | var anObject = __webpack_require__(8551); |
| 1443 | var getMethod = __webpack_require__(5966); |
| 1444 | |
| 1445 | module.exports = function (iterator, kind, value) { |
| 1446 | var innerResult, innerError; |
| 1447 | anObject(iterator); |
| 1448 | try { |
| 1449 | innerResult = getMethod(iterator, 'return'); |
| 1450 | if (!innerResult) { |
| 1451 | if (kind === 'throw') throw value; |
| 1452 | return value; |
| 1453 | } |
| 1454 | innerResult = call(innerResult, iterator); |
| 1455 | } catch (error) { |
| 1456 | innerError = true; |
| 1457 | innerResult = error; |
| 1458 | } |
| 1459 | if (kind === 'throw') throw value; |
| 1460 | if (innerError) throw innerResult; |
| 1461 | anObject(innerResult); |
| 1462 | return value; |
| 1463 | }; |
| 1464 | |
| 1465 | |
| 1466 | /***/ }), |
| 1467 | |
| 1468 | /***/ 9462: |
| 1469 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1470 | |
| 1471 | |
| 1472 | var call = __webpack_require__(9565); |
| 1473 | var create = __webpack_require__(2360); |
| 1474 | var createNonEnumerableProperty = __webpack_require__(6699); |
| 1475 | var defineBuiltIns = __webpack_require__(6279); |
| 1476 | var wellKnownSymbol = __webpack_require__(8227); |
| 1477 | var InternalStateModule = __webpack_require__(1181); |
| 1478 | var getMethod = __webpack_require__(5966); |
| 1479 | var IteratorPrototype = (__webpack_require__(7657).IteratorPrototype); |
| 1480 | var createIterResultObject = __webpack_require__(2529); |
| 1481 | var iteratorClose = __webpack_require__(9539); |
| 1482 | |
| 1483 | var TO_STRING_TAG = wellKnownSymbol('toStringTag'); |
| 1484 | var ITERATOR_HELPER = 'IteratorHelper'; |
| 1485 | var WRAP_FOR_VALID_ITERATOR = 'WrapForValidIterator'; |
| 1486 | var setInternalState = InternalStateModule.set; |
| 1487 | |
| 1488 | var createIteratorProxyPrototype = function (IS_ITERATOR) { |
| 1489 | var getInternalState = InternalStateModule.getterFor(IS_ITERATOR ? WRAP_FOR_VALID_ITERATOR : ITERATOR_HELPER); |
| 1490 | |
| 1491 | return defineBuiltIns(create(IteratorPrototype), { |
| 1492 | next: function next() { |
| 1493 | var state = getInternalState(this); |
| 1494 | // for simplification: |
| 1495 | // for `%WrapForValidIteratorPrototype%.next` our `nextHandler` returns `IterResultObject` |
| 1496 | // for `%IteratorHelperPrototype%.next` - just a value |
| 1497 | if (IS_ITERATOR) return state.nextHandler(); |
| 1498 | try { |
| 1499 | var result = state.done ? undefined : state.nextHandler(); |
| 1500 | return createIterResultObject(result, state.done); |
| 1501 | } catch (error) { |
| 1502 | state.done = true; |
| 1503 | throw error; |
| 1504 | } |
| 1505 | }, |
| 1506 | 'return': function () { |
| 1507 | var state = getInternalState(this); |
| 1508 | var iterator = state.iterator; |
| 1509 | state.done = true; |
| 1510 | if (IS_ITERATOR) { |
| 1511 | var returnMethod = getMethod(iterator, 'return'); |
| 1512 | return returnMethod ? call(returnMethod, iterator) : createIterResultObject(undefined, true); |
| 1513 | } |
| 1514 | if (state.inner) try { |
| 1515 | iteratorClose(state.inner.iterator, 'normal'); |
| 1516 | } catch (error) { |
| 1517 | return iteratorClose(iterator, 'throw', error); |
| 1518 | } |
| 1519 | iteratorClose(iterator, 'normal'); |
| 1520 | return createIterResultObject(undefined, true); |
| 1521 | } |
| 1522 | }); |
| 1523 | }; |
| 1524 | |
| 1525 | var WrapForValidIteratorPrototype = createIteratorProxyPrototype(true); |
| 1526 | var IteratorHelperPrototype = createIteratorProxyPrototype(false); |
| 1527 | |
| 1528 | createNonEnumerableProperty(IteratorHelperPrototype, TO_STRING_TAG, 'Iterator Helper'); |
| 1529 | |
| 1530 | module.exports = function (nextHandler, IS_ITERATOR) { |
| 1531 | var IteratorProxy = function Iterator(record, state) { |
| 1532 | if (state) { |
| 1533 | state.iterator = record.iterator; |
| 1534 | state.next = record.next; |
| 1535 | } else state = record; |
| 1536 | state.type = IS_ITERATOR ? WRAP_FOR_VALID_ITERATOR : ITERATOR_HELPER; |
| 1537 | state.nextHandler = nextHandler; |
| 1538 | state.counter = 0; |
| 1539 | state.done = false; |
| 1540 | setInternalState(this, state); |
| 1541 | }; |
| 1542 | |
| 1543 | IteratorProxy.prototype = IS_ITERATOR ? WrapForValidIteratorPrototype : IteratorHelperPrototype; |
| 1544 | |
| 1545 | return IteratorProxy; |
| 1546 | }; |
| 1547 | |
| 1548 | |
| 1549 | /***/ }), |
| 1550 | |
| 1551 | /***/ 713: |
| 1552 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1553 | |
| 1554 | |
| 1555 | var call = __webpack_require__(9565); |
| 1556 | var aCallable = __webpack_require__(9306); |
| 1557 | var anObject = __webpack_require__(8551); |
| 1558 | var getIteratorDirect = __webpack_require__(1767); |
| 1559 | var createIteratorProxy = __webpack_require__(9462); |
| 1560 | var callWithSafeIterationClosing = __webpack_require__(6319); |
| 1561 | |
| 1562 | var IteratorProxy = createIteratorProxy(function () { |
| 1563 | var iterator = this.iterator; |
| 1564 | var result = anObject(call(this.next, iterator)); |
| 1565 | var done = this.done = !!result.done; |
| 1566 | if (!done) return callWithSafeIterationClosing(iterator, this.mapper, [result.value, this.counter++], true); |
| 1567 | }); |
| 1568 | |
| 1569 | // `Iterator.prototype.map` method |
| 1570 | // https://github.com/tc39/proposal-iterator-helpers |
| 1571 | module.exports = function map(mapper) { |
| 1572 | anObject(this); |
| 1573 | aCallable(mapper); |
| 1574 | return new IteratorProxy(getIteratorDirect(this), { |
| 1575 | mapper: mapper |
| 1576 | }); |
| 1577 | }; |
| 1578 | |
| 1579 | |
| 1580 | /***/ }), |
| 1581 | |
| 1582 | /***/ 7657: |
| 1583 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1584 | |
| 1585 | |
| 1586 | var fails = __webpack_require__(9039); |
| 1587 | var isCallable = __webpack_require__(4901); |
| 1588 | var isObject = __webpack_require__(34); |
| 1589 | var create = __webpack_require__(2360); |
| 1590 | var getPrototypeOf = __webpack_require__(2787); |
| 1591 | var defineBuiltIn = __webpack_require__(6840); |
| 1592 | var wellKnownSymbol = __webpack_require__(8227); |
| 1593 | var IS_PURE = __webpack_require__(6395); |
| 1594 | |
| 1595 | var ITERATOR = wellKnownSymbol('iterator'); |
| 1596 | var BUGGY_SAFARI_ITERATORS = false; |
| 1597 | |
| 1598 | // `%IteratorPrototype%` object |
| 1599 | // https://tc39.es/ecma262/#sec-%iteratorprototype%-object |
| 1600 | var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator; |
| 1601 | |
| 1602 | /* eslint-disable es/no-array-prototype-keys -- safe */ |
| 1603 | if ([].keys) { |
| 1604 | arrayIterator = [].keys(); |
| 1605 | // Safari 8 has buggy iterators w/o `next` |
| 1606 | if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true; |
| 1607 | else { |
| 1608 | PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator)); |
| 1609 | if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype; |
| 1610 | } |
| 1611 | } |
| 1612 | |
| 1613 | var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype) || fails(function () { |
| 1614 | var test = {}; |
| 1615 | // FF44- legacy iterators case |
| 1616 | return IteratorPrototype[ITERATOR].call(test) !== test; |
| 1617 | }); |
| 1618 | |
| 1619 | if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {}; |
| 1620 | else if (IS_PURE) IteratorPrototype = create(IteratorPrototype); |
| 1621 | |
| 1622 | // `%IteratorPrototype%[@@iterator]()` method |
| 1623 | // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator |
| 1624 | if (!isCallable(IteratorPrototype[ITERATOR])) { |
| 1625 | defineBuiltIn(IteratorPrototype, ITERATOR, function () { |
| 1626 | return this; |
| 1627 | }); |
| 1628 | } |
| 1629 | |
| 1630 | module.exports = { |
| 1631 | IteratorPrototype: IteratorPrototype, |
| 1632 | BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS |
| 1633 | }; |
| 1634 | |
| 1635 | |
| 1636 | /***/ }), |
| 1637 | |
| 1638 | /***/ 6269: |
| 1639 | /***/ ((module) => { |
| 1640 | |
| 1641 | |
| 1642 | module.exports = {}; |
| 1643 | |
| 1644 | |
| 1645 | /***/ }), |
| 1646 | |
| 1647 | /***/ 6198: |
| 1648 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1649 | |
| 1650 | |
| 1651 | var toLength = __webpack_require__(8014); |
| 1652 | |
| 1653 | // `LengthOfArrayLike` abstract operation |
| 1654 | // https://tc39.es/ecma262/#sec-lengthofarraylike |
| 1655 | module.exports = function (obj) { |
| 1656 | return toLength(obj.length); |
| 1657 | }; |
| 1658 | |
| 1659 | |
| 1660 | /***/ }), |
| 1661 | |
| 1662 | /***/ 283: |
| 1663 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1664 | |
| 1665 | |
| 1666 | var uncurryThis = __webpack_require__(9504); |
| 1667 | var fails = __webpack_require__(9039); |
| 1668 | var isCallable = __webpack_require__(4901); |
| 1669 | var hasOwn = __webpack_require__(9297); |
| 1670 | var DESCRIPTORS = __webpack_require__(3724); |
| 1671 | var CONFIGURABLE_FUNCTION_NAME = (__webpack_require__(350).CONFIGURABLE); |
| 1672 | var inspectSource = __webpack_require__(3706); |
| 1673 | var InternalStateModule = __webpack_require__(1181); |
| 1674 | |
| 1675 | var enforceInternalState = InternalStateModule.enforce; |
| 1676 | var getInternalState = InternalStateModule.get; |
| 1677 | var $String = String; |
| 1678 | // eslint-disable-next-line es/no-object-defineproperty -- safe |
| 1679 | var defineProperty = Object.defineProperty; |
| 1680 | var stringSlice = uncurryThis(''.slice); |
| 1681 | var replace = uncurryThis(''.replace); |
| 1682 | var join = uncurryThis([].join); |
| 1683 | |
| 1684 | var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function () { |
| 1685 | return defineProperty(function () { /* empty */ }, 'length', { value: 8 }).length !== 8; |
| 1686 | }); |
| 1687 | |
| 1688 | var TEMPLATE = String(String).split('String'); |
| 1689 | |
| 1690 | var makeBuiltIn = module.exports = function (value, name, options) { |
| 1691 | if (stringSlice($String(name), 0, 7) === 'Symbol(') { |
| 1692 | name = '[' + replace($String(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']'; |
| 1693 | } |
| 1694 | if (options && options.getter) name = 'get ' + name; |
| 1695 | if (options && options.setter) name = 'set ' + name; |
| 1696 | if (!hasOwn(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) { |
| 1697 | if (DESCRIPTORS) defineProperty(value, 'name', { value: name, configurable: true }); |
| 1698 | else value.name = name; |
| 1699 | } |
| 1700 | if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) { |
| 1701 | defineProperty(value, 'length', { value: options.arity }); |
| 1702 | } |
| 1703 | try { |
| 1704 | if (options && hasOwn(options, 'constructor') && options.constructor) { |
| 1705 | if (DESCRIPTORS) defineProperty(value, 'prototype', { writable: false }); |
| 1706 | // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable |
| 1707 | } else if (value.prototype) value.prototype = undefined; |
| 1708 | } catch (error) { /* empty */ } |
| 1709 | var state = enforceInternalState(value); |
| 1710 | if (!hasOwn(state, 'source')) { |
| 1711 | state.source = join(TEMPLATE, typeof name == 'string' ? name : ''); |
| 1712 | } return value; |
| 1713 | }; |
| 1714 | |
| 1715 | // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative |
| 1716 | // eslint-disable-next-line no-extend-native -- required |
| 1717 | Function.prototype.toString = makeBuiltIn(function toString() { |
| 1718 | return isCallable(this) && getInternalState(this).source || inspectSource(this); |
| 1719 | }, 'toString'); |
| 1720 | |
| 1721 | |
| 1722 | /***/ }), |
| 1723 | |
| 1724 | /***/ 741: |
| 1725 | /***/ ((module) => { |
| 1726 | |
| 1727 | |
| 1728 | var ceil = Math.ceil; |
| 1729 | var floor = Math.floor; |
| 1730 | |
| 1731 | // `Math.trunc` method |
| 1732 | // https://tc39.es/ecma262/#sec-math.trunc |
| 1733 | // eslint-disable-next-line es/no-math-trunc -- safe |
| 1734 | module.exports = Math.trunc || function trunc(x) { |
| 1735 | var n = +x; |
| 1736 | return (n > 0 ? floor : ceil)(n); |
| 1737 | }; |
| 1738 | |
| 1739 | |
| 1740 | /***/ }), |
| 1741 | |
| 1742 | /***/ 6043: |
| 1743 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1744 | |
| 1745 | |
| 1746 | var aCallable = __webpack_require__(9306); |
| 1747 | |
| 1748 | var $TypeError = TypeError; |
| 1749 | |
| 1750 | var PromiseCapability = function (C) { |
| 1751 | var resolve, reject; |
| 1752 | this.promise = new C(function ($$resolve, $$reject) { |
| 1753 | if (resolve !== undefined || reject !== undefined) throw new $TypeError('Bad Promise constructor'); |
| 1754 | resolve = $$resolve; |
| 1755 | reject = $$reject; |
| 1756 | }); |
| 1757 | this.resolve = aCallable(resolve); |
| 1758 | this.reject = aCallable(reject); |
| 1759 | }; |
| 1760 | |
| 1761 | // `NewPromiseCapability` abstract operation |
| 1762 | // https://tc39.es/ecma262/#sec-newpromisecapability |
| 1763 | module.exports.f = function (C) { |
| 1764 | return new PromiseCapability(C); |
| 1765 | }; |
| 1766 | |
| 1767 | |
| 1768 | /***/ }), |
| 1769 | |
| 1770 | /***/ 2603: |
| 1771 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1772 | |
| 1773 | |
| 1774 | var toString = __webpack_require__(655); |
| 1775 | |
| 1776 | module.exports = function (argument, $default) { |
| 1777 | return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument); |
| 1778 | }; |
| 1779 | |
| 1780 | |
| 1781 | /***/ }), |
| 1782 | |
| 1783 | /***/ 2360: |
| 1784 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 1785 | |
| 1786 | |
| 1787 | /* global ActiveXObject -- old IE, WSH */ |
| 1788 | var anObject = __webpack_require__(8551); |
| 1789 | var definePropertiesModule = __webpack_require__(6801); |
| 1790 | var enumBugKeys = __webpack_require__(8727); |
| 1791 | var hiddenKeys = __webpack_require__(421); |
| 1792 | var html = __webpack_require__(397); |
| 1793 | var documentCreateElement = __webpack_require__(4055); |
| 1794 | var sharedKey = __webpack_require__(6119); |
| 1795 | |
| 1796 | var GT = '>'; |
| 1797 | var LT = '<'; |
| 1798 | var PROTOTYPE = 'prototype'; |
| 1799 | var SCRIPT = 'script'; |
| 1800 | var IE_PROTO = sharedKey('IE_PROTO'); |
| 1801 | |
| 1802 | var EmptyConstructor = function () { /* empty */ }; |
| 1803 | |
| 1804 | var scriptTag = function (content) { |
| 1805 | return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; |
| 1806 | }; |
| 1807 | |
| 1808 | // Create object with fake `null` prototype: use ActiveX Object with cleared prototype |
| 1809 | var NullProtoObjectViaActiveX = function (activeXDocument) { |
| 1810 | activeXDocument.write(scriptTag('')); |
| 1811 | activeXDocument.close(); |
| 1812 | var temp = activeXDocument.parentWindow.Object; |
| 1813 | activeXDocument = null; // avoid memory leak |
| 1814 | return temp; |
| 1815 | }; |
| 1816 | |
| 1817 | // Create object with fake `null` prototype: use iframe Object with cleared prototype |
| 1818 | var NullProtoObjectViaIFrame = function () { |
| 1819 | // Thrash, waste and sodomy: IE GC bug |
| 1820 | var iframe = documentCreateElement('iframe'); |
| 1821 | var JS = 'java' + SCRIPT + ':'; |
| 1822 | var iframeDocument; |
| 1823 | iframe.style.display = 'none'; |
| 1824 | html.appendChild(iframe); |
| 1825 | // https://github.com/zloirock/core-js/issues/475 |
| 1826 | iframe.src = String(JS); |
| 1827 | iframeDocument = iframe.contentWindow.document; |
| 1828 | iframeDocument.open(); |
| 1829 | iframeDocument.write(scriptTag('document.F=Object')); |
| 1830 | iframeDocument.close(); |
| 1831 | return iframeDocument.F; |
| 1832 | }; |
| 1833 | |
| 1834 | // Check for document.domain and active x support |
| 1835 | // No need to use active x approach when document.domain is not set |
| 1836 | // see https://github.com/es-shims/es5-shim/issues/150 |
| 1837 | // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 |
| 1838 | // avoid IE GC bug |
| 1839 | var activeXDocument; |
| 1840 | var NullProtoObject = function () { |
| 1841 | try { |
| 1842 | activeXDocument = new ActiveXObject('htmlfile'); |
| 1843 | } catch (error) { /* ignore */ } |
| 1844 | NullProtoObject = typeof document != 'undefined' |
| 1845 | ? document.domain && activeXDocument |
| 1846 | ? NullProtoObjectViaActiveX(activeXDocument) // old IE |
| 1847 | : NullProtoObjectViaIFrame() |
| 1848 | : NullProtoObjectViaActiveX(activeXDocument); // WSH |
| 1849 | var length = enumBugKeys.length; |
| 1850 | while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; |
| 1851 | return NullProtoObject(); |
| 1852 | }; |
| 1853 | |
| 1854 | hiddenKeys[IE_PROTO] = true; |
| 1855 | |
| 1856 | // `Object.create` method |
| 1857 | // https://tc39.es/ecma262/#sec-object.create |
| 1858 | // eslint-disable-next-line es/no-object-create -- safe |
| 1859 | module.exports = Object.create || function create(O, Properties) { |
| 1860 | var result; |
| 1861 | if (O !== null) { |
| 1862 | EmptyConstructor[PROTOTYPE] = anObject(O); |
| 1863 | result = new EmptyConstructor(); |
| 1864 | EmptyConstructor[PROTOTYPE] = null; |
| 1865 | // add "__proto__" for Object.getPrototypeOf polyfill |
| 1866 | result[IE_PROTO] = O; |
| 1867 | } else result = NullProtoObject(); |
| 1868 | return Properties === undefined ? result : definePropertiesModule.f(result, Properties); |
| 1869 | }; |
| 1870 | |
| 1871 | |
| 1872 | /***/ }), |
| 1873 | |
| 1874 | /***/ 6801: |
| 1875 | /***/ ((__unused_webpack_module, exports, __webpack_require__) => { |
| 1876 | |
| 1877 | |
| 1878 | var DESCRIPTORS = __webpack_require__(3724); |
| 1879 | var V8_PROTOTYPE_DEFINE_BUG = __webpack_require__(8686); |
| 1880 | var definePropertyModule = __webpack_require__(4913); |
| 1881 | var anObject = __webpack_require__(8551); |
| 1882 | var toIndexedObject = __webpack_require__(5397); |
| 1883 | var objectKeys = __webpack_require__(1072); |
| 1884 | |
| 1885 | // `Object.defineProperties` method |
| 1886 | // https://tc39.es/ecma262/#sec-object.defineproperties |
| 1887 | // eslint-disable-next-line es/no-object-defineproperties -- safe |
| 1888 | exports.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) { |
| 1889 | anObject(O); |
| 1890 | var props = toIndexedObject(Properties); |
| 1891 | var keys = objectKeys(Properties); |
| 1892 | var length = keys.length; |
| 1893 | var index = 0; |
| 1894 | var key; |
| 1895 | while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]); |
| 1896 | return O; |
| 1897 | }; |
| 1898 | |
| 1899 | |
| 1900 | /***/ }), |
| 1901 | |
| 1902 | /***/ 4913: |
| 1903 | /***/ ((__unused_webpack_module, exports, __webpack_require__) => { |
| 1904 | |
| 1905 | |
| 1906 | var DESCRIPTORS = __webpack_require__(3724); |
| 1907 | var IE8_DOM_DEFINE = __webpack_require__(5917); |
| 1908 | var V8_PROTOTYPE_DEFINE_BUG = __webpack_require__(8686); |
| 1909 | var anObject = __webpack_require__(8551); |
| 1910 | var toPropertyKey = __webpack_require__(6969); |
| 1911 | |
| 1912 | var $TypeError = TypeError; |
| 1913 | // eslint-disable-next-line es/no-object-defineproperty -- safe |
| 1914 | var $defineProperty = Object.defineProperty; |
| 1915 | // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe |
| 1916 | var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; |
| 1917 | var ENUMERABLE = 'enumerable'; |
| 1918 | var CONFIGURABLE = 'configurable'; |
| 1919 | var WRITABLE = 'writable'; |
| 1920 | |
| 1921 | // `Object.defineProperty` method |
| 1922 | // https://tc39.es/ecma262/#sec-object.defineproperty |
| 1923 | exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) { |
| 1924 | anObject(O); |
| 1925 | P = toPropertyKey(P); |
| 1926 | anObject(Attributes); |
| 1927 | if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) { |
| 1928 | var current = $getOwnPropertyDescriptor(O, P); |
| 1929 | if (current && current[WRITABLE]) { |
| 1930 | O[P] = Attributes.value; |
| 1931 | Attributes = { |
| 1932 | configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE], |
| 1933 | enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE], |
| 1934 | writable: false |
| 1935 | }; |
| 1936 | } |
| 1937 | } return $defineProperty(O, P, Attributes); |
| 1938 | } : $defineProperty : function defineProperty(O, P, Attributes) { |
| 1939 | anObject(O); |
| 1940 | P = toPropertyKey(P); |
| 1941 | anObject(Attributes); |
| 1942 | if (IE8_DOM_DEFINE) try { |
| 1943 | return $defineProperty(O, P, Attributes); |
| 1944 | } catch (error) { /* empty */ } |
| 1945 | if ('get' in Attributes || 'set' in Attributes) throw new $TypeError('Accessors not supported'); |
| 1946 | if ('value' in Attributes) O[P] = Attributes.value; |
| 1947 | return O; |
| 1948 | }; |
| 1949 | |
| 1950 | |
| 1951 | /***/ }), |
| 1952 | |
| 1953 | /***/ 7347: |
| 1954 | /***/ ((__unused_webpack_module, exports, __webpack_require__) => { |
| 1955 | |
| 1956 | |
| 1957 | var DESCRIPTORS = __webpack_require__(3724); |
| 1958 | var call = __webpack_require__(9565); |
| 1959 | var propertyIsEnumerableModule = __webpack_require__(8773); |
| 1960 | var createPropertyDescriptor = __webpack_require__(6980); |
| 1961 | var toIndexedObject = __webpack_require__(5397); |
| 1962 | var toPropertyKey = __webpack_require__(6969); |
| 1963 | var hasOwn = __webpack_require__(9297); |
| 1964 | var IE8_DOM_DEFINE = __webpack_require__(5917); |
| 1965 | |
| 1966 | // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe |
| 1967 | var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; |
| 1968 | |
| 1969 | // `Object.getOwnPropertyDescriptor` method |
| 1970 | // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor |
| 1971 | exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { |
| 1972 | O = toIndexedObject(O); |
| 1973 | P = toPropertyKey(P); |
| 1974 | if (IE8_DOM_DEFINE) try { |
| 1975 | return $getOwnPropertyDescriptor(O, P); |
| 1976 | } catch (error) { /* empty */ } |
| 1977 | if (hasOwn(O, P)) return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]); |
| 1978 | }; |
| 1979 | |
| 1980 | |
| 1981 | /***/ }), |
| 1982 | |
| 1983 | /***/ 8480: |
| 1984 | /***/ ((__unused_webpack_module, exports, __webpack_require__) => { |
| 1985 | |
| 1986 | |
| 1987 | var internalObjectKeys = __webpack_require__(1828); |
| 1988 | var enumBugKeys = __webpack_require__(8727); |
| 1989 | |
| 1990 | var hiddenKeys = enumBugKeys.concat('length', 'prototype'); |
| 1991 | |
| 1992 | // `Object.getOwnPropertyNames` method |
| 1993 | // https://tc39.es/ecma262/#sec-object.getownpropertynames |
| 1994 | // eslint-disable-next-line es/no-object-getownpropertynames -- safe |
| 1995 | exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { |
| 1996 | return internalObjectKeys(O, hiddenKeys); |
| 1997 | }; |
| 1998 | |
| 1999 | |
| 2000 | /***/ }), |
| 2001 | |
| 2002 | /***/ 3717: |
| 2003 | /***/ ((__unused_webpack_module, exports) => { |
| 2004 | |
| 2005 | |
| 2006 | // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe |
| 2007 | exports.f = Object.getOwnPropertySymbols; |
| 2008 | |
| 2009 | |
| 2010 | /***/ }), |
| 2011 | |
| 2012 | /***/ 2787: |
| 2013 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2014 | |
| 2015 | |
| 2016 | var hasOwn = __webpack_require__(9297); |
| 2017 | var isCallable = __webpack_require__(4901); |
| 2018 | var toObject = __webpack_require__(8981); |
| 2019 | var sharedKey = __webpack_require__(6119); |
| 2020 | var CORRECT_PROTOTYPE_GETTER = __webpack_require__(2211); |
| 2021 | |
| 2022 | var IE_PROTO = sharedKey('IE_PROTO'); |
| 2023 | var $Object = Object; |
| 2024 | var ObjectPrototype = $Object.prototype; |
| 2025 | |
| 2026 | // `Object.getPrototypeOf` method |
| 2027 | // https://tc39.es/ecma262/#sec-object.getprototypeof |
| 2028 | // eslint-disable-next-line es/no-object-getprototypeof -- safe |
| 2029 | module.exports = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) { |
| 2030 | var object = toObject(O); |
| 2031 | if (hasOwn(object, IE_PROTO)) return object[IE_PROTO]; |
| 2032 | var constructor = object.constructor; |
| 2033 | if (isCallable(constructor) && object instanceof constructor) { |
| 2034 | return constructor.prototype; |
| 2035 | } return object instanceof $Object ? ObjectPrototype : null; |
| 2036 | }; |
| 2037 | |
| 2038 | |
| 2039 | /***/ }), |
| 2040 | |
| 2041 | /***/ 1625: |
| 2042 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2043 | |
| 2044 | |
| 2045 | var uncurryThis = __webpack_require__(9504); |
| 2046 | |
| 2047 | module.exports = uncurryThis({}.isPrototypeOf); |
| 2048 | |
| 2049 | |
| 2050 | /***/ }), |
| 2051 | |
| 2052 | /***/ 1828: |
| 2053 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2054 | |
| 2055 | |
| 2056 | var uncurryThis = __webpack_require__(9504); |
| 2057 | var hasOwn = __webpack_require__(9297); |
| 2058 | var toIndexedObject = __webpack_require__(5397); |
| 2059 | var indexOf = (__webpack_require__(9617).indexOf); |
| 2060 | var hiddenKeys = __webpack_require__(421); |
| 2061 | |
| 2062 | var push = uncurryThis([].push); |
| 2063 | |
| 2064 | module.exports = function (object, names) { |
| 2065 | var O = toIndexedObject(object); |
| 2066 | var i = 0; |
| 2067 | var result = []; |
| 2068 | var key; |
| 2069 | for (key in O) !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key); |
| 2070 | // Don't enum bug & hidden keys |
| 2071 | while (names.length > i) if (hasOwn(O, key = names[i++])) { |
| 2072 | ~indexOf(result, key) || push(result, key); |
| 2073 | } |
| 2074 | return result; |
| 2075 | }; |
| 2076 | |
| 2077 | |
| 2078 | /***/ }), |
| 2079 | |
| 2080 | /***/ 1072: |
| 2081 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2082 | |
| 2083 | |
| 2084 | var internalObjectKeys = __webpack_require__(1828); |
| 2085 | var enumBugKeys = __webpack_require__(8727); |
| 2086 | |
| 2087 | // `Object.keys` method |
| 2088 | // https://tc39.es/ecma262/#sec-object.keys |
| 2089 | // eslint-disable-next-line es/no-object-keys -- safe |
| 2090 | module.exports = Object.keys || function keys(O) { |
| 2091 | return internalObjectKeys(O, enumBugKeys); |
| 2092 | }; |
| 2093 | |
| 2094 | |
| 2095 | /***/ }), |
| 2096 | |
| 2097 | /***/ 8773: |
| 2098 | /***/ ((__unused_webpack_module, exports) => { |
| 2099 | |
| 2100 | |
| 2101 | var $propertyIsEnumerable = {}.propertyIsEnumerable; |
| 2102 | // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe |
| 2103 | var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; |
| 2104 | |
| 2105 | // Nashorn ~ JDK8 bug |
| 2106 | var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1); |
| 2107 | |
| 2108 | // `Object.prototype.propertyIsEnumerable` method implementation |
| 2109 | // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable |
| 2110 | exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) { |
| 2111 | var descriptor = getOwnPropertyDescriptor(this, V); |
| 2112 | return !!descriptor && descriptor.enumerable; |
| 2113 | } : $propertyIsEnumerable; |
| 2114 | |
| 2115 | |
| 2116 | /***/ }), |
| 2117 | |
| 2118 | /***/ 2967: |
| 2119 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2120 | |
| 2121 | |
| 2122 | /* eslint-disable no-proto -- safe */ |
| 2123 | var uncurryThisAccessor = __webpack_require__(6706); |
| 2124 | var isObject = __webpack_require__(34); |
| 2125 | var requireObjectCoercible = __webpack_require__(7750); |
| 2126 | var aPossiblePrototype = __webpack_require__(3506); |
| 2127 | |
| 2128 | // `Object.setPrototypeOf` method |
| 2129 | // https://tc39.es/ecma262/#sec-object.setprototypeof |
| 2130 | // Works with __proto__ only. Old v8 can't work with null proto objects. |
| 2131 | // eslint-disable-next-line es/no-object-setprototypeof -- safe |
| 2132 | module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () { |
| 2133 | var CORRECT_SETTER = false; |
| 2134 | var test = {}; |
| 2135 | var setter; |
| 2136 | try { |
| 2137 | setter = uncurryThisAccessor(Object.prototype, '__proto__', 'set'); |
| 2138 | setter(test, []); |
| 2139 | CORRECT_SETTER = test instanceof Array; |
| 2140 | } catch (error) { /* empty */ } |
| 2141 | return function setPrototypeOf(O, proto) { |
| 2142 | requireObjectCoercible(O); |
| 2143 | aPossiblePrototype(proto); |
| 2144 | if (!isObject(O)) return O; |
| 2145 | if (CORRECT_SETTER) setter(O, proto); |
| 2146 | else O.__proto__ = proto; |
| 2147 | return O; |
| 2148 | }; |
| 2149 | }() : undefined); |
| 2150 | |
| 2151 | |
| 2152 | /***/ }), |
| 2153 | |
| 2154 | /***/ 4270: |
| 2155 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2156 | |
| 2157 | |
| 2158 | var call = __webpack_require__(9565); |
| 2159 | var isCallable = __webpack_require__(4901); |
| 2160 | var isObject = __webpack_require__(34); |
| 2161 | |
| 2162 | var $TypeError = TypeError; |
| 2163 | |
| 2164 | // `OrdinaryToPrimitive` abstract operation |
| 2165 | // https://tc39.es/ecma262/#sec-ordinarytoprimitive |
| 2166 | module.exports = function (input, pref) { |
| 2167 | var fn, val; |
| 2168 | if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val; |
| 2169 | if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val; |
| 2170 | if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val; |
| 2171 | throw new $TypeError("Can't convert object to primitive value"); |
| 2172 | }; |
| 2173 | |
| 2174 | |
| 2175 | /***/ }), |
| 2176 | |
| 2177 | /***/ 5031: |
| 2178 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2179 | |
| 2180 | |
| 2181 | var getBuiltIn = __webpack_require__(7751); |
| 2182 | var uncurryThis = __webpack_require__(9504); |
| 2183 | var getOwnPropertyNamesModule = __webpack_require__(8480); |
| 2184 | var getOwnPropertySymbolsModule = __webpack_require__(3717); |
| 2185 | var anObject = __webpack_require__(8551); |
| 2186 | |
| 2187 | var concat = uncurryThis([].concat); |
| 2188 | |
| 2189 | // all object keys, includes non-enumerable and symbols |
| 2190 | module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { |
| 2191 | var keys = getOwnPropertyNamesModule.f(anObject(it)); |
| 2192 | var getOwnPropertySymbols = getOwnPropertySymbolsModule.f; |
| 2193 | return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys; |
| 2194 | }; |
| 2195 | |
| 2196 | |
| 2197 | /***/ }), |
| 2198 | |
| 2199 | /***/ 8235: |
| 2200 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2201 | |
| 2202 | |
| 2203 | var uncurryThis = __webpack_require__(9504); |
| 2204 | var hasOwn = __webpack_require__(9297); |
| 2205 | |
| 2206 | var $SyntaxError = SyntaxError; |
| 2207 | var $parseInt = parseInt; |
| 2208 | var fromCharCode = String.fromCharCode; |
| 2209 | var at = uncurryThis(''.charAt); |
| 2210 | var slice = uncurryThis(''.slice); |
| 2211 | var exec = uncurryThis(/./.exec); |
| 2212 | |
| 2213 | var codePoints = { |
| 2214 | '\\"': '"', |
| 2215 | '\\\\': '\\', |
| 2216 | '\\/': '/', |
| 2217 | '\\b': '\b', |
| 2218 | '\\f': '\f', |
| 2219 | '\\n': '\n', |
| 2220 | '\\r': '\r', |
| 2221 | '\\t': '\t' |
| 2222 | }; |
| 2223 | |
| 2224 | var IS_4_HEX_DIGITS = /^[\da-f]{4}$/i; |
| 2225 | // eslint-disable-next-line regexp/no-control-character -- safe |
| 2226 | var IS_C0_CONTROL_CODE = /^[\u0000-\u001F]$/; |
| 2227 | |
| 2228 | module.exports = function (source, i) { |
| 2229 | var unterminated = true; |
| 2230 | var value = ''; |
| 2231 | while (i < source.length) { |
| 2232 | var chr = at(source, i); |
| 2233 | if (chr === '\\') { |
| 2234 | var twoChars = slice(source, i, i + 2); |
| 2235 | if (hasOwn(codePoints, twoChars)) { |
| 2236 | value += codePoints[twoChars]; |
| 2237 | i += 2; |
| 2238 | } else if (twoChars === '\\u') { |
| 2239 | i += 2; |
| 2240 | var fourHexDigits = slice(source, i, i + 4); |
| 2241 | if (!exec(IS_4_HEX_DIGITS, fourHexDigits)) throw new $SyntaxError('Bad Unicode escape at: ' + i); |
| 2242 | value += fromCharCode($parseInt(fourHexDigits, 16)); |
| 2243 | i += 4; |
| 2244 | } else throw new $SyntaxError('Unknown escape sequence: "' + twoChars + '"'); |
| 2245 | } else if (chr === '"') { |
| 2246 | unterminated = false; |
| 2247 | i++; |
| 2248 | break; |
| 2249 | } else { |
| 2250 | if (exec(IS_C0_CONTROL_CODE, chr)) throw new $SyntaxError('Bad control character in string literal at: ' + i); |
| 2251 | value += chr; |
| 2252 | i++; |
| 2253 | } |
| 2254 | } |
| 2255 | if (unterminated) throw new $SyntaxError('Unterminated string at: ' + i); |
| 2256 | return { value: value, end: i }; |
| 2257 | }; |
| 2258 | |
| 2259 | |
| 2260 | /***/ }), |
| 2261 | |
| 2262 | /***/ 7750: |
| 2263 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2264 | |
| 2265 | |
| 2266 | var isNullOrUndefined = __webpack_require__(4117); |
| 2267 | |
| 2268 | var $TypeError = TypeError; |
| 2269 | |
| 2270 | // `RequireObjectCoercible` abstract operation |
| 2271 | // https://tc39.es/ecma262/#sec-requireobjectcoercible |
| 2272 | module.exports = function (it) { |
| 2273 | if (isNullOrUndefined(it)) throw new $TypeError("Can't call method on " + it); |
| 2274 | return it; |
| 2275 | }; |
| 2276 | |
| 2277 | |
| 2278 | /***/ }), |
| 2279 | |
| 2280 | /***/ 9286: |
| 2281 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2282 | |
| 2283 | |
| 2284 | var SetHelpers = __webpack_require__(4402); |
| 2285 | var iterate = __webpack_require__(8469); |
| 2286 | |
| 2287 | var Set = SetHelpers.Set; |
| 2288 | var add = SetHelpers.add; |
| 2289 | |
| 2290 | module.exports = function (set) { |
| 2291 | var result = new Set(); |
| 2292 | iterate(set, function (it) { |
| 2293 | add(result, it); |
| 2294 | }); |
| 2295 | return result; |
| 2296 | }; |
| 2297 | |
| 2298 | |
| 2299 | /***/ }), |
| 2300 | |
| 2301 | /***/ 3440: |
| 2302 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2303 | |
| 2304 | |
| 2305 | var aSet = __webpack_require__(7080); |
| 2306 | var SetHelpers = __webpack_require__(4402); |
| 2307 | var clone = __webpack_require__(9286); |
| 2308 | var size = __webpack_require__(5170); |
| 2309 | var getSetRecord = __webpack_require__(3789); |
| 2310 | var iterateSet = __webpack_require__(8469); |
| 2311 | var iterateSimple = __webpack_require__(507); |
| 2312 | |
| 2313 | var has = SetHelpers.has; |
| 2314 | var remove = SetHelpers.remove; |
| 2315 | |
| 2316 | // `Set.prototype.difference` method |
| 2317 | // https://github.com/tc39/proposal-set-methods |
| 2318 | module.exports = function difference(other) { |
| 2319 | var O = aSet(this); |
| 2320 | var otherRec = getSetRecord(other); |
| 2321 | var result = clone(O); |
| 2322 | if (size(O) <= otherRec.size) iterateSet(O, function (e) { |
| 2323 | if (otherRec.includes(e)) remove(result, e); |
| 2324 | }); |
| 2325 | else iterateSimple(otherRec.getIterator(), function (e) { |
| 2326 | if (has(O, e)) remove(result, e); |
| 2327 | }); |
| 2328 | return result; |
| 2329 | }; |
| 2330 | |
| 2331 | |
| 2332 | /***/ }), |
| 2333 | |
| 2334 | /***/ 4402: |
| 2335 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2336 | |
| 2337 | |
| 2338 | var uncurryThis = __webpack_require__(9504); |
| 2339 | |
| 2340 | // eslint-disable-next-line es/no-set -- safe |
| 2341 | var SetPrototype = Set.prototype; |
| 2342 | |
| 2343 | module.exports = { |
| 2344 | // eslint-disable-next-line es/no-set -- safe |
| 2345 | Set: Set, |
| 2346 | add: uncurryThis(SetPrototype.add), |
| 2347 | has: uncurryThis(SetPrototype.has), |
| 2348 | remove: uncurryThis(SetPrototype['delete']), |
| 2349 | proto: SetPrototype |
| 2350 | }; |
| 2351 | |
| 2352 | |
| 2353 | /***/ }), |
| 2354 | |
| 2355 | /***/ 8750: |
| 2356 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2357 | |
| 2358 | |
| 2359 | var aSet = __webpack_require__(7080); |
| 2360 | var SetHelpers = __webpack_require__(4402); |
| 2361 | var size = __webpack_require__(5170); |
| 2362 | var getSetRecord = __webpack_require__(3789); |
| 2363 | var iterateSet = __webpack_require__(8469); |
| 2364 | var iterateSimple = __webpack_require__(507); |
| 2365 | |
| 2366 | var Set = SetHelpers.Set; |
| 2367 | var add = SetHelpers.add; |
| 2368 | var has = SetHelpers.has; |
| 2369 | |
| 2370 | // `Set.prototype.intersection` method |
| 2371 | // https://github.com/tc39/proposal-set-methods |
| 2372 | module.exports = function intersection(other) { |
| 2373 | var O = aSet(this); |
| 2374 | var otherRec = getSetRecord(other); |
| 2375 | var result = new Set(); |
| 2376 | |
| 2377 | if (size(O) > otherRec.size) { |
| 2378 | iterateSimple(otherRec.getIterator(), function (e) { |
| 2379 | if (has(O, e)) add(result, e); |
| 2380 | }); |
| 2381 | } else { |
| 2382 | iterateSet(O, function (e) { |
| 2383 | if (otherRec.includes(e)) add(result, e); |
| 2384 | }); |
| 2385 | } |
| 2386 | |
| 2387 | return result; |
| 2388 | }; |
| 2389 | |
| 2390 | |
| 2391 | /***/ }), |
| 2392 | |
| 2393 | /***/ 4449: |
| 2394 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2395 | |
| 2396 | |
| 2397 | var aSet = __webpack_require__(7080); |
| 2398 | var has = (__webpack_require__(4402).has); |
| 2399 | var size = __webpack_require__(5170); |
| 2400 | var getSetRecord = __webpack_require__(3789); |
| 2401 | var iterateSet = __webpack_require__(8469); |
| 2402 | var iterateSimple = __webpack_require__(507); |
| 2403 | var iteratorClose = __webpack_require__(9539); |
| 2404 | |
| 2405 | // `Set.prototype.isDisjointFrom` method |
| 2406 | // https://tc39.github.io/proposal-set-methods/#Set.prototype.isDisjointFrom |
| 2407 | module.exports = function isDisjointFrom(other) { |
| 2408 | var O = aSet(this); |
| 2409 | var otherRec = getSetRecord(other); |
| 2410 | if (size(O) <= otherRec.size) return iterateSet(O, function (e) { |
| 2411 | if (otherRec.includes(e)) return false; |
| 2412 | }, true) !== false; |
| 2413 | var iterator = otherRec.getIterator(); |
| 2414 | return iterateSimple(iterator, function (e) { |
| 2415 | if (has(O, e)) return iteratorClose(iterator, 'normal', false); |
| 2416 | }) !== false; |
| 2417 | }; |
| 2418 | |
| 2419 | |
| 2420 | /***/ }), |
| 2421 | |
| 2422 | /***/ 3838: |
| 2423 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2424 | |
| 2425 | |
| 2426 | var aSet = __webpack_require__(7080); |
| 2427 | var size = __webpack_require__(5170); |
| 2428 | var iterate = __webpack_require__(8469); |
| 2429 | var getSetRecord = __webpack_require__(3789); |
| 2430 | |
| 2431 | // `Set.prototype.isSubsetOf` method |
| 2432 | // https://tc39.github.io/proposal-set-methods/#Set.prototype.isSubsetOf |
| 2433 | module.exports = function isSubsetOf(other) { |
| 2434 | var O = aSet(this); |
| 2435 | var otherRec = getSetRecord(other); |
| 2436 | if (size(O) > otherRec.size) return false; |
| 2437 | return iterate(O, function (e) { |
| 2438 | if (!otherRec.includes(e)) return false; |
| 2439 | }, true) !== false; |
| 2440 | }; |
| 2441 | |
| 2442 | |
| 2443 | /***/ }), |
| 2444 | |
| 2445 | /***/ 8527: |
| 2446 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2447 | |
| 2448 | |
| 2449 | var aSet = __webpack_require__(7080); |
| 2450 | var has = (__webpack_require__(4402).has); |
| 2451 | var size = __webpack_require__(5170); |
| 2452 | var getSetRecord = __webpack_require__(3789); |
| 2453 | var iterateSimple = __webpack_require__(507); |
| 2454 | var iteratorClose = __webpack_require__(9539); |
| 2455 | |
| 2456 | // `Set.prototype.isSupersetOf` method |
| 2457 | // https://tc39.github.io/proposal-set-methods/#Set.prototype.isSupersetOf |
| 2458 | module.exports = function isSupersetOf(other) { |
| 2459 | var O = aSet(this); |
| 2460 | var otherRec = getSetRecord(other); |
| 2461 | if (size(O) < otherRec.size) return false; |
| 2462 | var iterator = otherRec.getIterator(); |
| 2463 | return iterateSimple(iterator, function (e) { |
| 2464 | if (!has(O, e)) return iteratorClose(iterator, 'normal', false); |
| 2465 | }) !== false; |
| 2466 | }; |
| 2467 | |
| 2468 | |
| 2469 | /***/ }), |
| 2470 | |
| 2471 | /***/ 8469: |
| 2472 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2473 | |
| 2474 | |
| 2475 | var uncurryThis = __webpack_require__(9504); |
| 2476 | var iterateSimple = __webpack_require__(507); |
| 2477 | var SetHelpers = __webpack_require__(4402); |
| 2478 | |
| 2479 | var Set = SetHelpers.Set; |
| 2480 | var SetPrototype = SetHelpers.proto; |
| 2481 | var forEach = uncurryThis(SetPrototype.forEach); |
| 2482 | var keys = uncurryThis(SetPrototype.keys); |
| 2483 | var next = keys(new Set()).next; |
| 2484 | |
| 2485 | module.exports = function (set, fn, interruptible) { |
| 2486 | return interruptible ? iterateSimple({ iterator: keys(set), next: next }, fn) : forEach(set, fn); |
| 2487 | }; |
| 2488 | |
| 2489 | |
| 2490 | /***/ }), |
| 2491 | |
| 2492 | /***/ 4916: |
| 2493 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2494 | |
| 2495 | |
| 2496 | var getBuiltIn = __webpack_require__(7751); |
| 2497 | |
| 2498 | var createSetLike = function (size) { |
| 2499 | return { |
| 2500 | size: size, |
| 2501 | has: function () { |
| 2502 | return false; |
| 2503 | }, |
| 2504 | keys: function () { |
| 2505 | return { |
| 2506 | next: function () { |
| 2507 | return { done: true }; |
| 2508 | } |
| 2509 | }; |
| 2510 | } |
| 2511 | }; |
| 2512 | }; |
| 2513 | |
| 2514 | module.exports = function (name) { |
| 2515 | var Set = getBuiltIn('Set'); |
| 2516 | try { |
| 2517 | new Set()[name](createSetLike(0)); |
| 2518 | try { |
| 2519 | // late spec change, early WebKit ~ Safari 17.0 beta implementation does not pass it |
| 2520 | // https://github.com/tc39/proposal-set-methods/pull/88 |
| 2521 | new Set()[name](createSetLike(-1)); |
| 2522 | return false; |
| 2523 | } catch (error2) { |
| 2524 | return true; |
| 2525 | } |
| 2526 | } catch (error) { |
| 2527 | return false; |
| 2528 | } |
| 2529 | }; |
| 2530 | |
| 2531 | |
| 2532 | /***/ }), |
| 2533 | |
| 2534 | /***/ 5170: |
| 2535 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2536 | |
| 2537 | |
| 2538 | var uncurryThisAccessor = __webpack_require__(6706); |
| 2539 | var SetHelpers = __webpack_require__(4402); |
| 2540 | |
| 2541 | module.exports = uncurryThisAccessor(SetHelpers.proto, 'size', 'get') || function (set) { |
| 2542 | return set.size; |
| 2543 | }; |
| 2544 | |
| 2545 | |
| 2546 | /***/ }), |
| 2547 | |
| 2548 | /***/ 3650: |
| 2549 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2550 | |
| 2551 | |
| 2552 | var aSet = __webpack_require__(7080); |
| 2553 | var SetHelpers = __webpack_require__(4402); |
| 2554 | var clone = __webpack_require__(9286); |
| 2555 | var getSetRecord = __webpack_require__(3789); |
| 2556 | var iterateSimple = __webpack_require__(507); |
| 2557 | |
| 2558 | var add = SetHelpers.add; |
| 2559 | var has = SetHelpers.has; |
| 2560 | var remove = SetHelpers.remove; |
| 2561 | |
| 2562 | // `Set.prototype.symmetricDifference` method |
| 2563 | // https://github.com/tc39/proposal-set-methods |
| 2564 | module.exports = function symmetricDifference(other) { |
| 2565 | var O = aSet(this); |
| 2566 | var keysIter = getSetRecord(other).getIterator(); |
| 2567 | var result = clone(O); |
| 2568 | iterateSimple(keysIter, function (e) { |
| 2569 | if (has(O, e)) remove(result, e); |
| 2570 | else add(result, e); |
| 2571 | }); |
| 2572 | return result; |
| 2573 | }; |
| 2574 | |
| 2575 | |
| 2576 | /***/ }), |
| 2577 | |
| 2578 | /***/ 4204: |
| 2579 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2580 | |
| 2581 | |
| 2582 | var aSet = __webpack_require__(7080); |
| 2583 | var add = (__webpack_require__(4402).add); |
| 2584 | var clone = __webpack_require__(9286); |
| 2585 | var getSetRecord = __webpack_require__(3789); |
| 2586 | var iterateSimple = __webpack_require__(507); |
| 2587 | |
| 2588 | // `Set.prototype.union` method |
| 2589 | // https://github.com/tc39/proposal-set-methods |
| 2590 | module.exports = function union(other) { |
| 2591 | var O = aSet(this); |
| 2592 | var keysIter = getSetRecord(other).getIterator(); |
| 2593 | var result = clone(O); |
| 2594 | iterateSimple(keysIter, function (it) { |
| 2595 | add(result, it); |
| 2596 | }); |
| 2597 | return result; |
| 2598 | }; |
| 2599 | |
| 2600 | |
| 2601 | /***/ }), |
| 2602 | |
| 2603 | /***/ 6119: |
| 2604 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2605 | |
| 2606 | |
| 2607 | var shared = __webpack_require__(5745); |
| 2608 | var uid = __webpack_require__(3392); |
| 2609 | |
| 2610 | var keys = shared('keys'); |
| 2611 | |
| 2612 | module.exports = function (key) { |
| 2613 | return keys[key] || (keys[key] = uid(key)); |
| 2614 | }; |
| 2615 | |
| 2616 | |
| 2617 | /***/ }), |
| 2618 | |
| 2619 | /***/ 7629: |
| 2620 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2621 | |
| 2622 | |
| 2623 | var IS_PURE = __webpack_require__(6395); |
| 2624 | var globalThis = __webpack_require__(4475); |
| 2625 | var defineGlobalProperty = __webpack_require__(9433); |
| 2626 | |
| 2627 | var SHARED = '__core-js_shared__'; |
| 2628 | var store = module.exports = globalThis[SHARED] || defineGlobalProperty(SHARED, {}); |
| 2629 | |
| 2630 | (store.versions || (store.versions = [])).push({ |
| 2631 | version: '3.37.1', |
| 2632 | mode: IS_PURE ? 'pure' : 'global', |
| 2633 | copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)', |
| 2634 | license: 'https://github.com/zloirock/core-js/blob/v3.37.1/LICENSE', |
| 2635 | source: 'https://github.com/zloirock/core-js' |
| 2636 | }); |
| 2637 | |
| 2638 | |
| 2639 | /***/ }), |
| 2640 | |
| 2641 | /***/ 5745: |
| 2642 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2643 | |
| 2644 | |
| 2645 | var store = __webpack_require__(7629); |
| 2646 | |
| 2647 | module.exports = function (key, value) { |
| 2648 | return store[key] || (store[key] = value || {}); |
| 2649 | }; |
| 2650 | |
| 2651 | |
| 2652 | /***/ }), |
| 2653 | |
| 2654 | /***/ 4495: |
| 2655 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2656 | |
| 2657 | |
| 2658 | /* eslint-disable es/no-symbol -- required for testing */ |
| 2659 | var V8_VERSION = __webpack_require__(7388); |
| 2660 | var fails = __webpack_require__(9039); |
| 2661 | var global = __webpack_require__(4475); |
| 2662 | |
| 2663 | var $String = global.String; |
| 2664 | |
| 2665 | // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing |
| 2666 | module.exports = !!Object.getOwnPropertySymbols && !fails(function () { |
| 2667 | var symbol = Symbol('symbol detection'); |
| 2668 | // Chrome 38 Symbol has incorrect toString conversion |
| 2669 | // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances |
| 2670 | // nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will, |
| 2671 | // of course, fail. |
| 2672 | return !$String(symbol) || !(Object(symbol) instanceof Symbol) || |
| 2673 | // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances |
| 2674 | !Symbol.sham && V8_VERSION && V8_VERSION < 41; |
| 2675 | }); |
| 2676 | |
| 2677 | |
| 2678 | /***/ }), |
| 2679 | |
| 2680 | /***/ 5610: |
| 2681 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2682 | |
| 2683 | |
| 2684 | var toIntegerOrInfinity = __webpack_require__(1291); |
| 2685 | |
| 2686 | var max = Math.max; |
| 2687 | var min = Math.min; |
| 2688 | |
| 2689 | // Helper for a popular repeating case of the spec: |
| 2690 | // Let integer be ? ToInteger(index). |
| 2691 | // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). |
| 2692 | module.exports = function (index, length) { |
| 2693 | var integer = toIntegerOrInfinity(index); |
| 2694 | return integer < 0 ? max(integer + length, 0) : min(integer, length); |
| 2695 | }; |
| 2696 | |
| 2697 | |
| 2698 | /***/ }), |
| 2699 | |
| 2700 | /***/ 5397: |
| 2701 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2702 | |
| 2703 | |
| 2704 | // toObject with fallback for non-array-like ES3 strings |
| 2705 | var IndexedObject = __webpack_require__(7055); |
| 2706 | var requireObjectCoercible = __webpack_require__(7750); |
| 2707 | |
| 2708 | module.exports = function (it) { |
| 2709 | return IndexedObject(requireObjectCoercible(it)); |
| 2710 | }; |
| 2711 | |
| 2712 | |
| 2713 | /***/ }), |
| 2714 | |
| 2715 | /***/ 1291: |
| 2716 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2717 | |
| 2718 | |
| 2719 | var trunc = __webpack_require__(741); |
| 2720 | |
| 2721 | // `ToIntegerOrInfinity` abstract operation |
| 2722 | // https://tc39.es/ecma262/#sec-tointegerorinfinity |
| 2723 | module.exports = function (argument) { |
| 2724 | var number = +argument; |
| 2725 | // eslint-disable-next-line no-self-compare -- NaN check |
| 2726 | return number !== number || number === 0 ? 0 : trunc(number); |
| 2727 | }; |
| 2728 | |
| 2729 | |
| 2730 | /***/ }), |
| 2731 | |
| 2732 | /***/ 8014: |
| 2733 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2734 | |
| 2735 | |
| 2736 | var toIntegerOrInfinity = __webpack_require__(1291); |
| 2737 | |
| 2738 | var min = Math.min; |
| 2739 | |
| 2740 | // `ToLength` abstract operation |
| 2741 | // https://tc39.es/ecma262/#sec-tolength |
| 2742 | module.exports = function (argument) { |
| 2743 | var len = toIntegerOrInfinity(argument); |
| 2744 | return len > 0 ? min(len, 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 |
| 2745 | }; |
| 2746 | |
| 2747 | |
| 2748 | /***/ }), |
| 2749 | |
| 2750 | /***/ 8981: |
| 2751 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2752 | |
| 2753 | |
| 2754 | var requireObjectCoercible = __webpack_require__(7750); |
| 2755 | |
| 2756 | var $Object = Object; |
| 2757 | |
| 2758 | // `ToObject` abstract operation |
| 2759 | // https://tc39.es/ecma262/#sec-toobject |
| 2760 | module.exports = function (argument) { |
| 2761 | return $Object(requireObjectCoercible(argument)); |
| 2762 | }; |
| 2763 | |
| 2764 | |
| 2765 | /***/ }), |
| 2766 | |
| 2767 | /***/ 2777: |
| 2768 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2769 | |
| 2770 | |
| 2771 | var call = __webpack_require__(9565); |
| 2772 | var isObject = __webpack_require__(34); |
| 2773 | var isSymbol = __webpack_require__(757); |
| 2774 | var getMethod = __webpack_require__(5966); |
| 2775 | var ordinaryToPrimitive = __webpack_require__(4270); |
| 2776 | var wellKnownSymbol = __webpack_require__(8227); |
| 2777 | |
| 2778 | var $TypeError = TypeError; |
| 2779 | var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); |
| 2780 | |
| 2781 | // `ToPrimitive` abstract operation |
| 2782 | // https://tc39.es/ecma262/#sec-toprimitive |
| 2783 | module.exports = function (input, pref) { |
| 2784 | if (!isObject(input) || isSymbol(input)) return input; |
| 2785 | var exoticToPrim = getMethod(input, TO_PRIMITIVE); |
| 2786 | var result; |
| 2787 | if (exoticToPrim) { |
| 2788 | if (pref === undefined) pref = 'default'; |
| 2789 | result = call(exoticToPrim, input, pref); |
| 2790 | if (!isObject(result) || isSymbol(result)) return result; |
| 2791 | throw new $TypeError("Can't convert object to primitive value"); |
| 2792 | } |
| 2793 | if (pref === undefined) pref = 'number'; |
| 2794 | return ordinaryToPrimitive(input, pref); |
| 2795 | }; |
| 2796 | |
| 2797 | |
| 2798 | /***/ }), |
| 2799 | |
| 2800 | /***/ 6969: |
| 2801 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2802 | |
| 2803 | |
| 2804 | var toPrimitive = __webpack_require__(2777); |
| 2805 | var isSymbol = __webpack_require__(757); |
| 2806 | |
| 2807 | // `ToPropertyKey` abstract operation |
| 2808 | // https://tc39.es/ecma262/#sec-topropertykey |
| 2809 | module.exports = function (argument) { |
| 2810 | var key = toPrimitive(argument, 'string'); |
| 2811 | return isSymbol(key) ? key : key + ''; |
| 2812 | }; |
| 2813 | |
| 2814 | |
| 2815 | /***/ }), |
| 2816 | |
| 2817 | /***/ 2140: |
| 2818 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2819 | |
| 2820 | |
| 2821 | var wellKnownSymbol = __webpack_require__(8227); |
| 2822 | |
| 2823 | var TO_STRING_TAG = wellKnownSymbol('toStringTag'); |
| 2824 | var test = {}; |
| 2825 | |
| 2826 | test[TO_STRING_TAG] = 'z'; |
| 2827 | |
| 2828 | module.exports = String(test) === '[object z]'; |
| 2829 | |
| 2830 | |
| 2831 | /***/ }), |
| 2832 | |
| 2833 | /***/ 655: |
| 2834 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2835 | |
| 2836 | |
| 2837 | var classof = __webpack_require__(6955); |
| 2838 | |
| 2839 | var $String = String; |
| 2840 | |
| 2841 | module.exports = function (argument) { |
| 2842 | if (classof(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string'); |
| 2843 | return $String(argument); |
| 2844 | }; |
| 2845 | |
| 2846 | |
| 2847 | /***/ }), |
| 2848 | |
| 2849 | /***/ 6823: |
| 2850 | /***/ ((module) => { |
| 2851 | |
| 2852 | |
| 2853 | var $String = String; |
| 2854 | |
| 2855 | module.exports = function (argument) { |
| 2856 | try { |
| 2857 | return $String(argument); |
| 2858 | } catch (error) { |
| 2859 | return 'Object'; |
| 2860 | } |
| 2861 | }; |
| 2862 | |
| 2863 | |
| 2864 | /***/ }), |
| 2865 | |
| 2866 | /***/ 3392: |
| 2867 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2868 | |
| 2869 | |
| 2870 | var uncurryThis = __webpack_require__(9504); |
| 2871 | |
| 2872 | var id = 0; |
| 2873 | var postfix = Math.random(); |
| 2874 | var toString = uncurryThis(1.0.toString); |
| 2875 | |
| 2876 | module.exports = function (key) { |
| 2877 | return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36); |
| 2878 | }; |
| 2879 | |
| 2880 | |
| 2881 | /***/ }), |
| 2882 | |
| 2883 | /***/ 7040: |
| 2884 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2885 | |
| 2886 | |
| 2887 | /* eslint-disable es/no-symbol -- required for testing */ |
| 2888 | var NATIVE_SYMBOL = __webpack_require__(4495); |
| 2889 | |
| 2890 | module.exports = NATIVE_SYMBOL |
| 2891 | && !Symbol.sham |
| 2892 | && typeof Symbol.iterator == 'symbol'; |
| 2893 | |
| 2894 | |
| 2895 | /***/ }), |
| 2896 | |
| 2897 | /***/ 8686: |
| 2898 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2899 | |
| 2900 | |
| 2901 | var DESCRIPTORS = __webpack_require__(3724); |
| 2902 | var fails = __webpack_require__(9039); |
| 2903 | |
| 2904 | // V8 ~ Chrome 36- |
| 2905 | // https://bugs.chromium.org/p/v8/issues/detail?id=3334 |
| 2906 | module.exports = DESCRIPTORS && fails(function () { |
| 2907 | // eslint-disable-next-line es/no-object-defineproperty -- required for testing |
| 2908 | return Object.defineProperty(function () { /* empty */ }, 'prototype', { |
| 2909 | value: 42, |
| 2910 | writable: false |
| 2911 | }).prototype !== 42; |
| 2912 | }); |
| 2913 | |
| 2914 | |
| 2915 | /***/ }), |
| 2916 | |
| 2917 | /***/ 2812: |
| 2918 | /***/ ((module) => { |
| 2919 | |
| 2920 | |
| 2921 | var $TypeError = TypeError; |
| 2922 | |
| 2923 | module.exports = function (passed, required) { |
| 2924 | if (passed < required) throw new $TypeError('Not enough arguments'); |
| 2925 | return passed; |
| 2926 | }; |
| 2927 | |
| 2928 | |
| 2929 | /***/ }), |
| 2930 | |
| 2931 | /***/ 8622: |
| 2932 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2933 | |
| 2934 | |
| 2935 | var global = __webpack_require__(4475); |
| 2936 | var isCallable = __webpack_require__(4901); |
| 2937 | |
| 2938 | var WeakMap = global.WeakMap; |
| 2939 | |
| 2940 | module.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap)); |
| 2941 | |
| 2942 | |
| 2943 | /***/ }), |
| 2944 | |
| 2945 | /***/ 8227: |
| 2946 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 2947 | |
| 2948 | |
| 2949 | var global = __webpack_require__(4475); |
| 2950 | var shared = __webpack_require__(5745); |
| 2951 | var hasOwn = __webpack_require__(9297); |
| 2952 | var uid = __webpack_require__(3392); |
| 2953 | var NATIVE_SYMBOL = __webpack_require__(4495); |
| 2954 | var USE_SYMBOL_AS_UID = __webpack_require__(7040); |
| 2955 | |
| 2956 | var Symbol = global.Symbol; |
| 2957 | var WellKnownSymbolsStore = shared('wks'); |
| 2958 | var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol['for'] || Symbol : Symbol && Symbol.withoutSetter || uid; |
| 2959 | |
| 2960 | module.exports = function (name) { |
| 2961 | if (!hasOwn(WellKnownSymbolsStore, name)) { |
| 2962 | WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn(Symbol, name) |
| 2963 | ? Symbol[name] |
| 2964 | : createWellKnownSymbol('Symbol.' + name); |
| 2965 | } return WellKnownSymbolsStore[name]; |
| 2966 | }; |
| 2967 | |
| 2968 | |
| 2969 | /***/ }), |
| 2970 | |
| 2971 | /***/ 4114: |
| 2972 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 2973 | |
| 2974 | |
| 2975 | var $ = __webpack_require__(6518); |
| 2976 | var toObject = __webpack_require__(8981); |
| 2977 | var lengthOfArrayLike = __webpack_require__(6198); |
| 2978 | var setArrayLength = __webpack_require__(4527); |
| 2979 | var doesNotExceedSafeInteger = __webpack_require__(6837); |
| 2980 | var fails = __webpack_require__(9039); |
| 2981 | |
| 2982 | var INCORRECT_TO_LENGTH = fails(function () { |
| 2983 | return [].push.call({ length: 0x100000000 }, 1) !== 4294967297; |
| 2984 | }); |
| 2985 | |
| 2986 | // V8 <= 121 and Safari <= 15.4; FF < 23 throws InternalError |
| 2987 | // https://bugs.chromium.org/p/v8/issues/detail?id=12681 |
| 2988 | var properErrorOnNonWritableLength = function () { |
| 2989 | try { |
| 2990 | // eslint-disable-next-line es/no-object-defineproperty -- safe |
| 2991 | Object.defineProperty([], 'length', { writable: false }).push(); |
| 2992 | } catch (error) { |
| 2993 | return error instanceof TypeError; |
| 2994 | } |
| 2995 | }; |
| 2996 | |
| 2997 | var FORCED = INCORRECT_TO_LENGTH || !properErrorOnNonWritableLength(); |
| 2998 | |
| 2999 | // `Array.prototype.push` method |
| 3000 | // https://tc39.es/ecma262/#sec-array.prototype.push |
| 3001 | $({ target: 'Array', proto: true, arity: 1, forced: FORCED }, { |
| 3002 | // eslint-disable-next-line no-unused-vars -- required for `.length` |
| 3003 | push: function push(item) { |
| 3004 | var O = toObject(this); |
| 3005 | var len = lengthOfArrayLike(O); |
| 3006 | var argCount = arguments.length; |
| 3007 | doesNotExceedSafeInteger(len + argCount); |
| 3008 | for (var i = 0; i < argCount; i++) { |
| 3009 | O[len] = arguments[i]; |
| 3010 | len++; |
| 3011 | } |
| 3012 | setArrayLength(O, len); |
| 3013 | return len; |
| 3014 | } |
| 3015 | }); |
| 3016 | |
| 3017 | |
| 3018 | /***/ }), |
| 3019 | |
| 3020 | /***/ 4628: |
| 3021 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3022 | |
| 3023 | |
| 3024 | var $ = __webpack_require__(6518); |
| 3025 | var newPromiseCapabilityModule = __webpack_require__(6043); |
| 3026 | |
| 3027 | // `Promise.withResolvers` method |
| 3028 | // https://github.com/tc39/proposal-promise-with-resolvers |
| 3029 | $({ target: 'Promise', stat: true }, { |
| 3030 | withResolvers: function withResolvers() { |
| 3031 | var promiseCapability = newPromiseCapabilityModule.f(this); |
| 3032 | return { |
| 3033 | promise: promiseCapability.promise, |
| 3034 | resolve: promiseCapability.resolve, |
| 3035 | reject: promiseCapability.reject |
| 3036 | }; |
| 3037 | } |
| 3038 | }); |
| 3039 | |
| 3040 | |
| 3041 | /***/ }), |
| 3042 | |
| 3043 | /***/ 7642: |
| 3044 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3045 | |
| 3046 | |
| 3047 | var $ = __webpack_require__(6518); |
| 3048 | var difference = __webpack_require__(3440); |
| 3049 | var setMethodAcceptSetLike = __webpack_require__(4916); |
| 3050 | |
| 3051 | // `Set.prototype.difference` method |
| 3052 | // https://github.com/tc39/proposal-set-methods |
| 3053 | $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('difference') }, { |
| 3054 | difference: difference |
| 3055 | }); |
| 3056 | |
| 3057 | |
| 3058 | /***/ }), |
| 3059 | |
| 3060 | /***/ 8004: |
| 3061 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3062 | |
| 3063 | |
| 3064 | var $ = __webpack_require__(6518); |
| 3065 | var fails = __webpack_require__(9039); |
| 3066 | var intersection = __webpack_require__(8750); |
| 3067 | var setMethodAcceptSetLike = __webpack_require__(4916); |
| 3068 | |
| 3069 | var INCORRECT = !setMethodAcceptSetLike('intersection') || fails(function () { |
| 3070 | // eslint-disable-next-line es/no-array-from, es/no-set -- testing |
| 3071 | return String(Array.from(new Set([1, 2, 3]).intersection(new Set([3, 2])))) !== '3,2'; |
| 3072 | }); |
| 3073 | |
| 3074 | // `Set.prototype.intersection` method |
| 3075 | // https://github.com/tc39/proposal-set-methods |
| 3076 | $({ target: 'Set', proto: true, real: true, forced: INCORRECT }, { |
| 3077 | intersection: intersection |
| 3078 | }); |
| 3079 | |
| 3080 | |
| 3081 | /***/ }), |
| 3082 | |
| 3083 | /***/ 3853: |
| 3084 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3085 | |
| 3086 | |
| 3087 | var $ = __webpack_require__(6518); |
| 3088 | var isDisjointFrom = __webpack_require__(4449); |
| 3089 | var setMethodAcceptSetLike = __webpack_require__(4916); |
| 3090 | |
| 3091 | // `Set.prototype.isDisjointFrom` method |
| 3092 | // https://github.com/tc39/proposal-set-methods |
| 3093 | $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isDisjointFrom') }, { |
| 3094 | isDisjointFrom: isDisjointFrom |
| 3095 | }); |
| 3096 | |
| 3097 | |
| 3098 | /***/ }), |
| 3099 | |
| 3100 | /***/ 5876: |
| 3101 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3102 | |
| 3103 | |
| 3104 | var $ = __webpack_require__(6518); |
| 3105 | var isSubsetOf = __webpack_require__(3838); |
| 3106 | var setMethodAcceptSetLike = __webpack_require__(4916); |
| 3107 | |
| 3108 | // `Set.prototype.isSubsetOf` method |
| 3109 | // https://github.com/tc39/proposal-set-methods |
| 3110 | $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isSubsetOf') }, { |
| 3111 | isSubsetOf: isSubsetOf |
| 3112 | }); |
| 3113 | |
| 3114 | |
| 3115 | /***/ }), |
| 3116 | |
| 3117 | /***/ 2475: |
| 3118 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3119 | |
| 3120 | |
| 3121 | var $ = __webpack_require__(6518); |
| 3122 | var isSupersetOf = __webpack_require__(8527); |
| 3123 | var setMethodAcceptSetLike = __webpack_require__(4916); |
| 3124 | |
| 3125 | // `Set.prototype.isSupersetOf` method |
| 3126 | // https://github.com/tc39/proposal-set-methods |
| 3127 | $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isSupersetOf') }, { |
| 3128 | isSupersetOf: isSupersetOf |
| 3129 | }); |
| 3130 | |
| 3131 | |
| 3132 | /***/ }), |
| 3133 | |
| 3134 | /***/ 5024: |
| 3135 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3136 | |
| 3137 | |
| 3138 | var $ = __webpack_require__(6518); |
| 3139 | var symmetricDifference = __webpack_require__(3650); |
| 3140 | var setMethodAcceptSetLike = __webpack_require__(4916); |
| 3141 | |
| 3142 | // `Set.prototype.symmetricDifference` method |
| 3143 | // https://github.com/tc39/proposal-set-methods |
| 3144 | $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('symmetricDifference') }, { |
| 3145 | symmetricDifference: symmetricDifference |
| 3146 | }); |
| 3147 | |
| 3148 | |
| 3149 | /***/ }), |
| 3150 | |
| 3151 | /***/ 1698: |
| 3152 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3153 | |
| 3154 | |
| 3155 | var $ = __webpack_require__(6518); |
| 3156 | var union = __webpack_require__(4204); |
| 3157 | var setMethodAcceptSetLike = __webpack_require__(4916); |
| 3158 | |
| 3159 | // `Set.prototype.union` method |
| 3160 | // https://github.com/tc39/proposal-set-methods |
| 3161 | $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('union') }, { |
| 3162 | union: union |
| 3163 | }); |
| 3164 | |
| 3165 | |
| 3166 | /***/ }), |
| 3167 | |
| 3168 | /***/ 8992: |
| 3169 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3170 | |
| 3171 | |
| 3172 | var $ = __webpack_require__(6518); |
| 3173 | var global = __webpack_require__(4475); |
| 3174 | var anInstance = __webpack_require__(679); |
| 3175 | var anObject = __webpack_require__(8551); |
| 3176 | var isCallable = __webpack_require__(4901); |
| 3177 | var getPrototypeOf = __webpack_require__(2787); |
| 3178 | var defineBuiltInAccessor = __webpack_require__(2106); |
| 3179 | var createProperty = __webpack_require__(4659); |
| 3180 | var fails = __webpack_require__(9039); |
| 3181 | var hasOwn = __webpack_require__(9297); |
| 3182 | var wellKnownSymbol = __webpack_require__(8227); |
| 3183 | var IteratorPrototype = (__webpack_require__(7657).IteratorPrototype); |
| 3184 | var DESCRIPTORS = __webpack_require__(3724); |
| 3185 | var IS_PURE = __webpack_require__(6395); |
| 3186 | |
| 3187 | var CONSTRUCTOR = 'constructor'; |
| 3188 | var ITERATOR = 'Iterator'; |
| 3189 | var TO_STRING_TAG = wellKnownSymbol('toStringTag'); |
| 3190 | |
| 3191 | var $TypeError = TypeError; |
| 3192 | var NativeIterator = global[ITERATOR]; |
| 3193 | |
| 3194 | // FF56- have non-standard global helper `Iterator` |
| 3195 | var FORCED = IS_PURE |
| 3196 | || !isCallable(NativeIterator) |
| 3197 | || NativeIterator.prototype !== IteratorPrototype |
| 3198 | // FF44- non-standard `Iterator` passes previous tests |
| 3199 | || !fails(function () { NativeIterator({}); }); |
| 3200 | |
| 3201 | var IteratorConstructor = function Iterator() { |
| 3202 | anInstance(this, IteratorPrototype); |
| 3203 | if (getPrototypeOf(this) === IteratorPrototype) throw new $TypeError('Abstract class Iterator not directly constructable'); |
| 3204 | }; |
| 3205 | |
| 3206 | var defineIteratorPrototypeAccessor = function (key, value) { |
| 3207 | if (DESCRIPTORS) { |
| 3208 | defineBuiltInAccessor(IteratorPrototype, key, { |
| 3209 | configurable: true, |
| 3210 | get: function () { |
| 3211 | return value; |
| 3212 | }, |
| 3213 | set: function (replacement) { |
| 3214 | anObject(this); |
| 3215 | if (this === IteratorPrototype) throw new $TypeError("You can't redefine this property"); |
| 3216 | if (hasOwn(this, key)) this[key] = replacement; |
| 3217 | else createProperty(this, key, replacement); |
| 3218 | } |
| 3219 | }); |
| 3220 | } else IteratorPrototype[key] = value; |
| 3221 | }; |
| 3222 | |
| 3223 | if (!hasOwn(IteratorPrototype, TO_STRING_TAG)) defineIteratorPrototypeAccessor(TO_STRING_TAG, ITERATOR); |
| 3224 | |
| 3225 | if (FORCED || !hasOwn(IteratorPrototype, CONSTRUCTOR) || IteratorPrototype[CONSTRUCTOR] === Object) { |
| 3226 | defineIteratorPrototypeAccessor(CONSTRUCTOR, IteratorConstructor); |
| 3227 | } |
| 3228 | |
| 3229 | IteratorConstructor.prototype = IteratorPrototype; |
| 3230 | |
| 3231 | // `Iterator` constructor |
| 3232 | // https://github.com/tc39/proposal-iterator-helpers |
| 3233 | $({ global: true, constructor: true, forced: FORCED }, { |
| 3234 | Iterator: IteratorConstructor |
| 3235 | }); |
| 3236 | |
| 3237 | |
| 3238 | /***/ }), |
| 3239 | |
| 3240 | /***/ 3215: |
| 3241 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3242 | |
| 3243 | |
| 3244 | var $ = __webpack_require__(6518); |
| 3245 | var iterate = __webpack_require__(2652); |
| 3246 | var aCallable = __webpack_require__(9306); |
| 3247 | var anObject = __webpack_require__(8551); |
| 3248 | var getIteratorDirect = __webpack_require__(1767); |
| 3249 | |
| 3250 | // `Iterator.prototype.every` method |
| 3251 | // https://github.com/tc39/proposal-iterator-helpers |
| 3252 | $({ target: 'Iterator', proto: true, real: true }, { |
| 3253 | every: function every(predicate) { |
| 3254 | anObject(this); |
| 3255 | aCallable(predicate); |
| 3256 | var record = getIteratorDirect(this); |
| 3257 | var counter = 0; |
| 3258 | return !iterate(record, function (value, stop) { |
| 3259 | if (!predicate(value, counter++)) return stop(); |
| 3260 | }, { IS_RECORD: true, INTERRUPTED: true }).stopped; |
| 3261 | } |
| 3262 | }); |
| 3263 | |
| 3264 | |
| 3265 | /***/ }), |
| 3266 | |
| 3267 | /***/ 4520: |
| 3268 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3269 | |
| 3270 | |
| 3271 | var $ = __webpack_require__(6518); |
| 3272 | var call = __webpack_require__(9565); |
| 3273 | var aCallable = __webpack_require__(9306); |
| 3274 | var anObject = __webpack_require__(8551); |
| 3275 | var getIteratorDirect = __webpack_require__(1767); |
| 3276 | var createIteratorProxy = __webpack_require__(9462); |
| 3277 | var callWithSafeIterationClosing = __webpack_require__(6319); |
| 3278 | var IS_PURE = __webpack_require__(6395); |
| 3279 | |
| 3280 | var IteratorProxy = createIteratorProxy(function () { |
| 3281 | var iterator = this.iterator; |
| 3282 | var predicate = this.predicate; |
| 3283 | var next = this.next; |
| 3284 | var result, done, value; |
| 3285 | while (true) { |
| 3286 | result = anObject(call(next, iterator)); |
| 3287 | done = this.done = !!result.done; |
| 3288 | if (done) return; |
| 3289 | value = result.value; |
| 3290 | if (callWithSafeIterationClosing(iterator, predicate, [value, this.counter++], true)) return value; |
| 3291 | } |
| 3292 | }); |
| 3293 | |
| 3294 | // `Iterator.prototype.filter` method |
| 3295 | // https://github.com/tc39/proposal-iterator-helpers |
| 3296 | $({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, { |
| 3297 | filter: function filter(predicate) { |
| 3298 | anObject(this); |
| 3299 | aCallable(predicate); |
| 3300 | return new IteratorProxy(getIteratorDirect(this), { |
| 3301 | predicate: predicate |
| 3302 | }); |
| 3303 | } |
| 3304 | }); |
| 3305 | |
| 3306 | |
| 3307 | /***/ }), |
| 3308 | |
| 3309 | /***/ 3949: |
| 3310 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3311 | |
| 3312 | |
| 3313 | var $ = __webpack_require__(6518); |
| 3314 | var iterate = __webpack_require__(2652); |
| 3315 | var aCallable = __webpack_require__(9306); |
| 3316 | var anObject = __webpack_require__(8551); |
| 3317 | var getIteratorDirect = __webpack_require__(1767); |
| 3318 | |
| 3319 | // `Iterator.prototype.forEach` method |
| 3320 | // https://github.com/tc39/proposal-iterator-helpers |
| 3321 | $({ target: 'Iterator', proto: true, real: true }, { |
| 3322 | forEach: function forEach(fn) { |
| 3323 | anObject(this); |
| 3324 | aCallable(fn); |
| 3325 | var record = getIteratorDirect(this); |
| 3326 | var counter = 0; |
| 3327 | iterate(record, function (value) { |
| 3328 | fn(value, counter++); |
| 3329 | }, { IS_RECORD: true }); |
| 3330 | } |
| 3331 | }); |
| 3332 | |
| 3333 | |
| 3334 | /***/ }), |
| 3335 | |
| 3336 | /***/ 1454: |
| 3337 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3338 | |
| 3339 | |
| 3340 | var $ = __webpack_require__(6518); |
| 3341 | var map = __webpack_require__(713); |
| 3342 | var IS_PURE = __webpack_require__(6395); |
| 3343 | |
| 3344 | // `Iterator.prototype.map` method |
| 3345 | // https://github.com/tc39/proposal-iterator-helpers |
| 3346 | $({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, { |
| 3347 | map: map |
| 3348 | }); |
| 3349 | |
| 3350 | |
| 3351 | /***/ }), |
| 3352 | |
| 3353 | /***/ 7550: |
| 3354 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3355 | |
| 3356 | |
| 3357 | var $ = __webpack_require__(6518); |
| 3358 | var iterate = __webpack_require__(2652); |
| 3359 | var aCallable = __webpack_require__(9306); |
| 3360 | var anObject = __webpack_require__(8551); |
| 3361 | var getIteratorDirect = __webpack_require__(1767); |
| 3362 | |
| 3363 | // `Iterator.prototype.some` method |
| 3364 | // https://github.com/tc39/proposal-iterator-helpers |
| 3365 | $({ target: 'Iterator', proto: true, real: true }, { |
| 3366 | some: function some(predicate) { |
| 3367 | anObject(this); |
| 3368 | aCallable(predicate); |
| 3369 | var record = getIteratorDirect(this); |
| 3370 | var counter = 0; |
| 3371 | return iterate(record, function (value, stop) { |
| 3372 | if (predicate(value, counter++)) return stop(); |
| 3373 | }, { IS_RECORD: true, INTERRUPTED: true }).stopped; |
| 3374 | } |
| 3375 | }); |
| 3376 | |
| 3377 | |
| 3378 | /***/ }), |
| 3379 | |
| 3380 | /***/ 8335: |
| 3381 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3382 | |
| 3383 | |
| 3384 | var $ = __webpack_require__(6518); |
| 3385 | var DESCRIPTORS = __webpack_require__(3724); |
| 3386 | var global = __webpack_require__(4475); |
| 3387 | var getBuiltIn = __webpack_require__(7751); |
| 3388 | var uncurryThis = __webpack_require__(9504); |
| 3389 | var call = __webpack_require__(9565); |
| 3390 | var isCallable = __webpack_require__(4901); |
| 3391 | var isObject = __webpack_require__(34); |
| 3392 | var isArray = __webpack_require__(4376); |
| 3393 | var hasOwn = __webpack_require__(9297); |
| 3394 | var toString = __webpack_require__(655); |
| 3395 | var lengthOfArrayLike = __webpack_require__(6198); |
| 3396 | var createProperty = __webpack_require__(4659); |
| 3397 | var fails = __webpack_require__(9039); |
| 3398 | var parseJSONString = __webpack_require__(8235); |
| 3399 | var NATIVE_SYMBOL = __webpack_require__(4495); |
| 3400 | |
| 3401 | var JSON = global.JSON; |
| 3402 | var Number = global.Number; |
| 3403 | var SyntaxError = global.SyntaxError; |
| 3404 | var nativeParse = JSON && JSON.parse; |
| 3405 | var enumerableOwnProperties = getBuiltIn('Object', 'keys'); |
| 3406 | // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe |
| 3407 | var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; |
| 3408 | var at = uncurryThis(''.charAt); |
| 3409 | var slice = uncurryThis(''.slice); |
| 3410 | var exec = uncurryThis(/./.exec); |
| 3411 | var push = uncurryThis([].push); |
| 3412 | |
| 3413 | var IS_DIGIT = /^\d$/; |
| 3414 | var IS_NON_ZERO_DIGIT = /^[1-9]$/; |
| 3415 | var IS_NUMBER_START = /^(?:-|\d)$/; |
| 3416 | var IS_WHITESPACE = /^[\t\n\r ]$/; |
| 3417 | |
| 3418 | var PRIMITIVE = 0; |
| 3419 | var OBJECT = 1; |
| 3420 | |
| 3421 | var $parse = function (source, reviver) { |
| 3422 | source = toString(source); |
| 3423 | var context = new Context(source, 0, ''); |
| 3424 | var root = context.parse(); |
| 3425 | var value = root.value; |
| 3426 | var endIndex = context.skip(IS_WHITESPACE, root.end); |
| 3427 | if (endIndex < source.length) { |
| 3428 | throw new SyntaxError('Unexpected extra character: "' + at(source, endIndex) + '" after the parsed data at: ' + endIndex); |
| 3429 | } |
| 3430 | return isCallable(reviver) ? internalize({ '': value }, '', reviver, root) : value; |
| 3431 | }; |
| 3432 | |
| 3433 | var internalize = function (holder, name, reviver, node) { |
| 3434 | var val = holder[name]; |
| 3435 | var unmodified = node && val === node.value; |
| 3436 | var context = unmodified && typeof node.source == 'string' ? { source: node.source } : {}; |
| 3437 | var elementRecordsLen, keys, len, i, P; |
| 3438 | if (isObject(val)) { |
| 3439 | var nodeIsArray = isArray(val); |
| 3440 | var nodes = unmodified ? node.nodes : nodeIsArray ? [] : {}; |
| 3441 | if (nodeIsArray) { |
| 3442 | elementRecordsLen = nodes.length; |
| 3443 | len = lengthOfArrayLike(val); |
| 3444 | for (i = 0; i < len; i++) { |
| 3445 | internalizeProperty(val, i, internalize(val, '' + i, reviver, i < elementRecordsLen ? nodes[i] : undefined)); |
| 3446 | } |
| 3447 | } else { |
| 3448 | keys = enumerableOwnProperties(val); |
| 3449 | len = lengthOfArrayLike(keys); |
| 3450 | for (i = 0; i < len; i++) { |
| 3451 | P = keys[i]; |
| 3452 | internalizeProperty(val, P, internalize(val, P, reviver, hasOwn(nodes, P) ? nodes[P] : undefined)); |
| 3453 | } |
| 3454 | } |
| 3455 | } |
| 3456 | return call(reviver, holder, name, val, context); |
| 3457 | }; |
| 3458 | |
| 3459 | var internalizeProperty = function (object, key, value) { |
| 3460 | if (DESCRIPTORS) { |
| 3461 | var descriptor = getOwnPropertyDescriptor(object, key); |
| 3462 | if (descriptor && !descriptor.configurable) return; |
| 3463 | } |
| 3464 | if (value === undefined) delete object[key]; |
| 3465 | else createProperty(object, key, value); |
| 3466 | }; |
| 3467 | |
| 3468 | var Node = function (value, end, source, nodes) { |
| 3469 | this.value = value; |
| 3470 | this.end = end; |
| 3471 | this.source = source; |
| 3472 | this.nodes = nodes; |
| 3473 | }; |
| 3474 | |
| 3475 | var Context = function (source, index) { |
| 3476 | this.source = source; |
| 3477 | this.index = index; |
| 3478 | }; |
| 3479 | |
| 3480 | // https://www.json.org/json-en.html |
| 3481 | Context.prototype = { |
| 3482 | fork: function (nextIndex) { |
| 3483 | return new Context(this.source, nextIndex); |
| 3484 | }, |
| 3485 | parse: function () { |
| 3486 | var source = this.source; |
| 3487 | var i = this.skip(IS_WHITESPACE, this.index); |
| 3488 | var fork = this.fork(i); |
| 3489 | var chr = at(source, i); |
| 3490 | if (exec(IS_NUMBER_START, chr)) return fork.number(); |
| 3491 | switch (chr) { |
| 3492 | case '{': |
| 3493 | return fork.object(); |
| 3494 | case '[': |
| 3495 | return fork.array(); |
| 3496 | case '"': |
| 3497 | return fork.string(); |
| 3498 | case 't': |
| 3499 | return fork.keyword(true); |
| 3500 | case 'f': |
| 3501 | return fork.keyword(false); |
| 3502 | case 'n': |
| 3503 | return fork.keyword(null); |
| 3504 | } throw new SyntaxError('Unexpected character: "' + chr + '" at: ' + i); |
| 3505 | }, |
| 3506 | node: function (type, value, start, end, nodes) { |
| 3507 | return new Node(value, end, type ? null : slice(this.source, start, end), nodes); |
| 3508 | }, |
| 3509 | object: function () { |
| 3510 | var source = this.source; |
| 3511 | var i = this.index + 1; |
| 3512 | var expectKeypair = false; |
| 3513 | var object = {}; |
| 3514 | var nodes = {}; |
| 3515 | while (i < source.length) { |
| 3516 | i = this.until(['"', '}'], i); |
| 3517 | if (at(source, i) === '}' && !expectKeypair) { |
| 3518 | i++; |
| 3519 | break; |
| 3520 | } |
| 3521 | // Parsing the key |
| 3522 | var result = this.fork(i).string(); |
| 3523 | var key = result.value; |
| 3524 | i = result.end; |
| 3525 | i = this.until([':'], i) + 1; |
| 3526 | // Parsing value |
| 3527 | i = this.skip(IS_WHITESPACE, i); |
| 3528 | result = this.fork(i).parse(); |
| 3529 | createProperty(nodes, key, result); |
| 3530 | createProperty(object, key, result.value); |
| 3531 | i = this.until([',', '}'], result.end); |
| 3532 | var chr = at(source, i); |
| 3533 | if (chr === ',') { |
| 3534 | expectKeypair = true; |
| 3535 | i++; |
| 3536 | } else if (chr === '}') { |
| 3537 | i++; |
| 3538 | break; |
| 3539 | } |
| 3540 | } |
| 3541 | return this.node(OBJECT, object, this.index, i, nodes); |
| 3542 | }, |
| 3543 | array: function () { |
| 3544 | var source = this.source; |
| 3545 | var i = this.index + 1; |
| 3546 | var expectElement = false; |
| 3547 | var array = []; |
| 3548 | var nodes = []; |
| 3549 | while (i < source.length) { |
| 3550 | i = this.skip(IS_WHITESPACE, i); |
| 3551 | if (at(source, i) === ']' && !expectElement) { |
| 3552 | i++; |
| 3553 | break; |
| 3554 | } |
| 3555 | var result = this.fork(i).parse(); |
| 3556 | push(nodes, result); |
| 3557 | push(array, result.value); |
| 3558 | i = this.until([',', ']'], result.end); |
| 3559 | if (at(source, i) === ',') { |
| 3560 | expectElement = true; |
| 3561 | i++; |
| 3562 | } else if (at(source, i) === ']') { |
| 3563 | i++; |
| 3564 | break; |
| 3565 | } |
| 3566 | } |
| 3567 | return this.node(OBJECT, array, this.index, i, nodes); |
| 3568 | }, |
| 3569 | string: function () { |
| 3570 | var index = this.index; |
| 3571 | var parsed = parseJSONString(this.source, this.index + 1); |
| 3572 | return this.node(PRIMITIVE, parsed.value, index, parsed.end); |
| 3573 | }, |
| 3574 | number: function () { |
| 3575 | var source = this.source; |
| 3576 | var startIndex = this.index; |
| 3577 | var i = startIndex; |
| 3578 | if (at(source, i) === '-') i++; |
| 3579 | if (at(source, i) === '0') i++; |
| 3580 | else if (exec(IS_NON_ZERO_DIGIT, at(source, i))) i = this.skip(IS_DIGIT, ++i); |
| 3581 | else throw new SyntaxError('Failed to parse number at: ' + i); |
| 3582 | if (at(source, i) === '.') i = this.skip(IS_DIGIT, ++i); |
| 3583 | if (at(source, i) === 'e' || at(source, i) === 'E') { |
| 3584 | i++; |
| 3585 | if (at(source, i) === '+' || at(source, i) === '-') i++; |
| 3586 | var exponentStartIndex = i; |
| 3587 | i = this.skip(IS_DIGIT, i); |
| 3588 | if (exponentStartIndex === i) throw new SyntaxError("Failed to parse number's exponent value at: " + i); |
| 3589 | } |
| 3590 | return this.node(PRIMITIVE, Number(slice(source, startIndex, i)), startIndex, i); |
| 3591 | }, |
| 3592 | keyword: function (value) { |
| 3593 | var keyword = '' + value; |
| 3594 | var index = this.index; |
| 3595 | var endIndex = index + keyword.length; |
| 3596 | if (slice(this.source, index, endIndex) !== keyword) throw new SyntaxError('Failed to parse value at: ' + index); |
| 3597 | return this.node(PRIMITIVE, value, index, endIndex); |
| 3598 | }, |
| 3599 | skip: function (regex, i) { |
| 3600 | var source = this.source; |
| 3601 | for (; i < source.length; i++) if (!exec(regex, at(source, i))) break; |
| 3602 | return i; |
| 3603 | }, |
| 3604 | until: function (array, i) { |
| 3605 | i = this.skip(IS_WHITESPACE, i); |
| 3606 | var chr = at(this.source, i); |
| 3607 | for (var j = 0; j < array.length; j++) if (array[j] === chr) return i; |
| 3608 | throw new SyntaxError('Unexpected character: "' + chr + '" at: ' + i); |
| 3609 | } |
| 3610 | }; |
| 3611 | |
| 3612 | var NO_SOURCE_SUPPORT = fails(function () { |
| 3613 | var unsafeInt = '9007199254740993'; |
| 3614 | var source; |
| 3615 | nativeParse(unsafeInt, function (key, value, context) { |
| 3616 | source = context.source; |
| 3617 | }); |
| 3618 | return source !== unsafeInt; |
| 3619 | }); |
| 3620 | |
| 3621 | var PROPER_BASE_PARSE = NATIVE_SYMBOL && !fails(function () { |
| 3622 | // Safari 9 bug |
| 3623 | return 1 / nativeParse('-0 \t') !== -Infinity; |
| 3624 | }); |
| 3625 | |
| 3626 | // `JSON.parse` method |
| 3627 | // https://tc39.es/ecma262/#sec-json.parse |
| 3628 | // https://github.com/tc39/proposal-json-parse-with-source |
| 3629 | $({ target: 'JSON', stat: true, forced: NO_SOURCE_SUPPORT }, { |
| 3630 | parse: function parse(text, reviver) { |
| 3631 | return PROPER_BASE_PARSE && !isCallable(reviver) ? nativeParse(text) : $parse(text, reviver); |
| 3632 | } |
| 3633 | }); |
| 3634 | |
| 3635 | |
| 3636 | /***/ }), |
| 3637 | |
| 3638 | /***/ 3375: |
| 3639 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3640 | |
| 3641 | |
| 3642 | // TODO: Remove from `core-js@4` |
| 3643 | __webpack_require__(7642); |
| 3644 | |
| 3645 | |
| 3646 | /***/ }), |
| 3647 | |
| 3648 | /***/ 9225: |
| 3649 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3650 | |
| 3651 | |
| 3652 | // TODO: Remove from `core-js@4` |
| 3653 | __webpack_require__(8004); |
| 3654 | |
| 3655 | |
| 3656 | /***/ }), |
| 3657 | |
| 3658 | /***/ 3972: |
| 3659 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3660 | |
| 3661 | |
| 3662 | // TODO: Remove from `core-js@4` |
| 3663 | __webpack_require__(3853); |
| 3664 | |
| 3665 | |
| 3666 | /***/ }), |
| 3667 | |
| 3668 | /***/ 9209: |
| 3669 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3670 | |
| 3671 | |
| 3672 | // TODO: Remove from `core-js@4` |
| 3673 | __webpack_require__(5876); |
| 3674 | |
| 3675 | |
| 3676 | /***/ }), |
| 3677 | |
| 3678 | /***/ 5714: |
| 3679 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3680 | |
| 3681 | |
| 3682 | // TODO: Remove from `core-js@4` |
| 3683 | __webpack_require__(2475); |
| 3684 | |
| 3685 | |
| 3686 | /***/ }), |
| 3687 | |
| 3688 | /***/ 7561: |
| 3689 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3690 | |
| 3691 | |
| 3692 | // TODO: Remove from `core-js@4` |
| 3693 | __webpack_require__(5024); |
| 3694 | |
| 3695 | |
| 3696 | /***/ }), |
| 3697 | |
| 3698 | /***/ 6197: |
| 3699 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3700 | |
| 3701 | |
| 3702 | // TODO: Remove from `core-js@4` |
| 3703 | __webpack_require__(1698); |
| 3704 | |
| 3705 | |
| 3706 | /***/ }), |
| 3707 | |
| 3708 | /***/ 4979: |
| 3709 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3710 | |
| 3711 | |
| 3712 | var $ = __webpack_require__(6518); |
| 3713 | var global = __webpack_require__(4475); |
| 3714 | var getBuiltIn = __webpack_require__(7751); |
| 3715 | var createPropertyDescriptor = __webpack_require__(6980); |
| 3716 | var defineProperty = (__webpack_require__(4913).f); |
| 3717 | var hasOwn = __webpack_require__(9297); |
| 3718 | var anInstance = __webpack_require__(679); |
| 3719 | var inheritIfRequired = __webpack_require__(3167); |
| 3720 | var normalizeStringArgument = __webpack_require__(2603); |
| 3721 | var DOMExceptionConstants = __webpack_require__(5002); |
| 3722 | var clearErrorStack = __webpack_require__(6193); |
| 3723 | var DESCRIPTORS = __webpack_require__(3724); |
| 3724 | var IS_PURE = __webpack_require__(6395); |
| 3725 | |
| 3726 | var DOM_EXCEPTION = 'DOMException'; |
| 3727 | var Error = getBuiltIn('Error'); |
| 3728 | var NativeDOMException = getBuiltIn(DOM_EXCEPTION); |
| 3729 | |
| 3730 | var $DOMException = function DOMException() { |
| 3731 | anInstance(this, DOMExceptionPrototype); |
| 3732 | var argumentsLength = arguments.length; |
| 3733 | var message = normalizeStringArgument(argumentsLength < 1 ? undefined : arguments[0]); |
| 3734 | var name = normalizeStringArgument(argumentsLength < 2 ? undefined : arguments[1], 'Error'); |
| 3735 | var that = new NativeDOMException(message, name); |
| 3736 | var error = new Error(message); |
| 3737 | error.name = DOM_EXCEPTION; |
| 3738 | defineProperty(that, 'stack', createPropertyDescriptor(1, clearErrorStack(error.stack, 1))); |
| 3739 | inheritIfRequired(that, this, $DOMException); |
| 3740 | return that; |
| 3741 | }; |
| 3742 | |
| 3743 | var DOMExceptionPrototype = $DOMException.prototype = NativeDOMException.prototype; |
| 3744 | |
| 3745 | var ERROR_HAS_STACK = 'stack' in new Error(DOM_EXCEPTION); |
| 3746 | var DOM_EXCEPTION_HAS_STACK = 'stack' in new NativeDOMException(1, 2); |
| 3747 | |
| 3748 | // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe |
| 3749 | var descriptor = NativeDOMException && DESCRIPTORS && Object.getOwnPropertyDescriptor(global, DOM_EXCEPTION); |
| 3750 | |
| 3751 | // Bun ~ 0.1.1 DOMException have incorrect descriptor and we can't redefine it |
| 3752 | // https://github.com/Jarred-Sumner/bun/issues/399 |
| 3753 | var BUGGY_DESCRIPTOR = !!descriptor && !(descriptor.writable && descriptor.configurable); |
| 3754 | |
| 3755 | var FORCED_CONSTRUCTOR = ERROR_HAS_STACK && !BUGGY_DESCRIPTOR && !DOM_EXCEPTION_HAS_STACK; |
| 3756 | |
| 3757 | // `DOMException` constructor patch for `.stack` where it's required |
| 3758 | // https://webidl.spec.whatwg.org/#es-DOMException-specialness |
| 3759 | $({ global: true, constructor: true, forced: IS_PURE || FORCED_CONSTRUCTOR }, { // TODO: fix export logic |
| 3760 | DOMException: FORCED_CONSTRUCTOR ? $DOMException : NativeDOMException |
| 3761 | }); |
| 3762 | |
| 3763 | var PolyfilledDOMException = getBuiltIn(DOM_EXCEPTION); |
| 3764 | var PolyfilledDOMExceptionPrototype = PolyfilledDOMException.prototype; |
| 3765 | |
| 3766 | if (PolyfilledDOMExceptionPrototype.constructor !== PolyfilledDOMException) { |
| 3767 | if (!IS_PURE) { |
| 3768 | defineProperty(PolyfilledDOMExceptionPrototype, 'constructor', createPropertyDescriptor(1, PolyfilledDOMException)); |
| 3769 | } |
| 3770 | |
| 3771 | for (var key in DOMExceptionConstants) if (hasOwn(DOMExceptionConstants, key)) { |
| 3772 | var constant = DOMExceptionConstants[key]; |
| 3773 | var constantName = constant.s; |
| 3774 | if (!hasOwn(PolyfilledDOMException, constantName)) { |
| 3775 | defineProperty(PolyfilledDOMException, constantName, createPropertyDescriptor(6, constant.c)); |
| 3776 | } |
| 3777 | } |
| 3778 | } |
| 3779 | |
| 3780 | |
| 3781 | /***/ }), |
| 3782 | |
| 3783 | /***/ 4603: |
| 3784 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3785 | |
| 3786 | |
| 3787 | var defineBuiltIn = __webpack_require__(6840); |
| 3788 | var uncurryThis = __webpack_require__(9504); |
| 3789 | var toString = __webpack_require__(655); |
| 3790 | var validateArgumentsLength = __webpack_require__(2812); |
| 3791 | |
| 3792 | var $URLSearchParams = URLSearchParams; |
| 3793 | var URLSearchParamsPrototype = $URLSearchParams.prototype; |
| 3794 | var append = uncurryThis(URLSearchParamsPrototype.append); |
| 3795 | var $delete = uncurryThis(URLSearchParamsPrototype['delete']); |
| 3796 | var forEach = uncurryThis(URLSearchParamsPrototype.forEach); |
| 3797 | var push = uncurryThis([].push); |
| 3798 | var params = new $URLSearchParams('a=1&a=2&b=3'); |
| 3799 | |
| 3800 | params['delete']('a', 1); |
| 3801 | // `undefined` case is a Chromium 117 bug |
| 3802 | // https://bugs.chromium.org/p/v8/issues/detail?id=14222 |
| 3803 | params['delete']('b', undefined); |
| 3804 | |
| 3805 | if (params + '' !== 'a=2') { |
| 3806 | defineBuiltIn(URLSearchParamsPrototype, 'delete', function (name /* , value */) { |
| 3807 | var length = arguments.length; |
| 3808 | var $value = length < 2 ? undefined : arguments[1]; |
| 3809 | if (length && $value === undefined) return $delete(this, name); |
| 3810 | var entries = []; |
| 3811 | forEach(this, function (v, k) { // also validates `this` |
| 3812 | push(entries, { key: k, value: v }); |
| 3813 | }); |
| 3814 | validateArgumentsLength(length, 1); |
| 3815 | var key = toString(name); |
| 3816 | var value = toString($value); |
| 3817 | var index = 0; |
| 3818 | var dindex = 0; |
| 3819 | var found = false; |
| 3820 | var entriesLength = entries.length; |
| 3821 | var entry; |
| 3822 | while (index < entriesLength) { |
| 3823 | entry = entries[index++]; |
| 3824 | if (found || entry.key === key) { |
| 3825 | found = true; |
| 3826 | $delete(this, entry.key); |
| 3827 | } else dindex++; |
| 3828 | } |
| 3829 | while (dindex < entriesLength) { |
| 3830 | entry = entries[dindex++]; |
| 3831 | if (!(entry.key === key && entry.value === value)) append(this, entry.key, entry.value); |
| 3832 | } |
| 3833 | }, { enumerable: true, unsafe: true }); |
| 3834 | } |
| 3835 | |
| 3836 | |
| 3837 | /***/ }), |
| 3838 | |
| 3839 | /***/ 7566: |
| 3840 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3841 | |
| 3842 | |
| 3843 | var defineBuiltIn = __webpack_require__(6840); |
| 3844 | var uncurryThis = __webpack_require__(9504); |
| 3845 | var toString = __webpack_require__(655); |
| 3846 | var validateArgumentsLength = __webpack_require__(2812); |
| 3847 | |
| 3848 | var $URLSearchParams = URLSearchParams; |
| 3849 | var URLSearchParamsPrototype = $URLSearchParams.prototype; |
| 3850 | var getAll = uncurryThis(URLSearchParamsPrototype.getAll); |
| 3851 | var $has = uncurryThis(URLSearchParamsPrototype.has); |
| 3852 | var params = new $URLSearchParams('a=1'); |
| 3853 | |
| 3854 | // `undefined` case is a Chromium 117 bug |
| 3855 | // https://bugs.chromium.org/p/v8/issues/detail?id=14222 |
| 3856 | if (params.has('a', 2) || !params.has('a', undefined)) { |
| 3857 | defineBuiltIn(URLSearchParamsPrototype, 'has', function has(name /* , value */) { |
| 3858 | var length = arguments.length; |
| 3859 | var $value = length < 2 ? undefined : arguments[1]; |
| 3860 | if (length && $value === undefined) return $has(this, name); |
| 3861 | var values = getAll(this, name); // also validates `this` |
| 3862 | validateArgumentsLength(length, 1); |
| 3863 | var value = toString($value); |
| 3864 | var index = 0; |
| 3865 | while (index < values.length) { |
| 3866 | if (values[index++] === value) return true; |
| 3867 | } return false; |
| 3868 | }, { enumerable: true, unsafe: true }); |
| 3869 | } |
| 3870 | |
| 3871 | |
| 3872 | /***/ }), |
| 3873 | |
| 3874 | /***/ 8721: |
| 3875 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { |
| 3876 | |
| 3877 | |
| 3878 | var DESCRIPTORS = __webpack_require__(3724); |
| 3879 | var uncurryThis = __webpack_require__(9504); |
| 3880 | var defineBuiltInAccessor = __webpack_require__(2106); |
| 3881 | |
| 3882 | var URLSearchParamsPrototype = URLSearchParams.prototype; |
| 3883 | var forEach = uncurryThis(URLSearchParamsPrototype.forEach); |
| 3884 | |
| 3885 | // `URLSearchParams.prototype.size` getter |
| 3886 | // https://github.com/whatwg/url/pull/734 |
| 3887 | if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) { |
| 3888 | defineBuiltInAccessor(URLSearchParamsPrototype, 'size', { |
| 3889 | get: function size() { |
| 3890 | var count = 0; |
| 3891 | forEach(this, function () { count++; }); |
| 3892 | return count; |
| 3893 | }, |
| 3894 | configurable: true, |
| 3895 | enumerable: true |
| 3896 | }); |
| 3897 | } |
| 3898 | |
| 3899 | |
| 3900 | /***/ }) |
| 3901 | |
| 3902 | /******/ }); |
| 3903 | /************************************************************************/ |
| 3904 | /******/ // The module cache |
| 3905 | /******/ var __webpack_module_cache__ = {}; |
| 3906 | /******/ |
| 3907 | /******/ // The require function |
| 3908 | /******/ function __webpack_require__(moduleId) { |
| 3909 | /******/ // Check if module is in cache |
| 3910 | /******/ var cachedModule = __webpack_module_cache__[moduleId]; |
| 3911 | /******/ if (cachedModule !== undefined) { |
| 3912 | /******/ return cachedModule.exports; |
| 3913 | /******/ } |
| 3914 | /******/ // Create a new module (and put it into the cache) |
| 3915 | /******/ var module = __webpack_module_cache__[moduleId] = { |
| 3916 | /******/ // no module.id needed |
| 3917 | /******/ // no module.loaded needed |
| 3918 | /******/ exports: {} |
| 3919 | /******/ }; |
| 3920 | /******/ |
| 3921 | /******/ // Execute the module function |
| 3922 | /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
| 3923 | /******/ |
| 3924 | /******/ // Return the exports of the module |
| 3925 | /******/ return module.exports; |
| 3926 | /******/ } |
| 3927 | /******/ |
| 3928 | /************************************************************************/ |
| 3929 | /******/ /* webpack/runtime/define property getters */ |
| 3930 | /******/ (() => { |
| 3931 | /******/ // define getter functions for harmony exports |
| 3932 | /******/ __webpack_require__.d = (exports, definition) => { |
| 3933 | /******/ for(var key in definition) { |
| 3934 | /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
| 3935 | /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
| 3936 | /******/ } |
| 3937 | /******/ } |
| 3938 | /******/ }; |
| 3939 | /******/ })(); |
| 3940 | /******/ |
| 3941 | /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 3942 | /******/ (() => { |
| 3943 | /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
| 3944 | /******/ })(); |
| 3945 | /******/ |
| 3946 | /************************************************************************/ |
| 3947 | var __webpack_exports__ = {}; |
| 3948 | // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. |
| 3949 | (() => { |
| 3950 | |
| 3951 | // EXPORTS |
| 3952 | __webpack_require__.d(__webpack_exports__, { |
| 3953 | PDFViewerApplication: () => (/* reexport */ PDFViewerApplication), |
| 3954 | PDFViewerApplicationConstants: () => (/* binding */ AppConstants), |
| 3955 | PDFViewerApplicationOptions: () => (/* reexport */ AppOptions) |
| 3956 | }); |
| 3957 | |
| 3958 | // EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.push.js |
| 3959 | var es_array_push = __webpack_require__(4114); |
| 3960 | // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.difference.v2.js |
| 3961 | var esnext_set_difference_v2 = __webpack_require__(3375); |
| 3962 | // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.intersection.v2.js |
| 3963 | var esnext_set_intersection_v2 = __webpack_require__(9225); |
| 3964 | // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.is-disjoint-from.v2.js |
| 3965 | var esnext_set_is_disjoint_from_v2 = __webpack_require__(3972); |
| 3966 | // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.is-subset-of.v2.js |
| 3967 | var esnext_set_is_subset_of_v2 = __webpack_require__(9209); |
| 3968 | // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.is-superset-of.v2.js |
| 3969 | var esnext_set_is_superset_of_v2 = __webpack_require__(5714); |
| 3970 | // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.symmetric-difference.v2.js |
| 3971 | var esnext_set_symmetric_difference_v2 = __webpack_require__(7561); |
| 3972 | // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.set.union.v2.js |
| 3973 | var esnext_set_union_v2 = __webpack_require__(6197); |
| 3974 | // EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.delete.js |
| 3975 | var web_url_search_params_delete = __webpack_require__(4603); |
| 3976 | // EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.has.js |
| 3977 | var web_url_search_params_has = __webpack_require__(7566); |
| 3978 | // EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.size.js |
| 3979 | var web_url_search_params_size = __webpack_require__(8721); |
| 3980 | ;// CONCATENATED MODULE: ./web/ui_utils.js |
| 3981 | |
| 3982 | |
| 3983 | |
| 3984 | |
| 3985 | |
| 3986 | |
| 3987 | |
| 3988 | |
| 3989 | |
| 3990 | |
| 3991 | |
| 3992 | const DEFAULT_SCALE_VALUE = "auto"; |
| 3993 | const DEFAULT_SCALE = 1.0; |
| 3994 | const DEFAULT_SCALE_DELTA = 1.1; |
| 3995 | const MIN_SCALE = 0.1; |
| 3996 | const MAX_SCALE = 10.0; |
| 3997 | const UNKNOWN_SCALE = 0; |
| 3998 | const MAX_AUTO_SCALE = 1.25; |
| 3999 | const SCROLLBAR_PADDING = 40; |
| 4000 | const VERTICAL_PADDING = 5; |
| 4001 | const RenderingStates = { |
| 4002 | INITIAL: 0, |
| 4003 | RUNNING: 1, |
| 4004 | PAUSED: 2, |
| 4005 | FINISHED: 3 |
| 4006 | }; |
| 4007 | const PresentationModeState = { |
| 4008 | UNKNOWN: 0, |
| 4009 | NORMAL: 1, |
| 4010 | CHANGING: 2, |
| 4011 | FULLSCREEN: 3 |
| 4012 | }; |
| 4013 | const SidebarView = { |
| 4014 | UNKNOWN: -1, |
| 4015 | NONE: 0, |
| 4016 | THUMBS: 1, |
| 4017 | OUTLINE: 2, |
| 4018 | ATTACHMENTS: 3, |
| 4019 | LAYERS: 4 |
| 4020 | }; |
| 4021 | const TextLayerMode = { |
| 4022 | DISABLE: 0, |
| 4023 | ENABLE: 1, |
| 4024 | ENABLE_PERMISSIONS: 2 |
| 4025 | }; |
| 4026 | const ScrollMode = { |
| 4027 | UNKNOWN: -1, |
| 4028 | VERTICAL: 0, |
| 4029 | HORIZONTAL: 1, |
| 4030 | WRAPPED: 2, |
| 4031 | PAGE: 3 |
| 4032 | }; |
| 4033 | const SpreadMode = { |
| 4034 | UNKNOWN: -1, |
| 4035 | NONE: 0, |
| 4036 | ODD: 1, |
| 4037 | EVEN: 2 |
| 4038 | }; |
| 4039 | const CursorTool = { |
| 4040 | SELECT: 0, |
| 4041 | HAND: 1, |
| 4042 | ZOOM: 2 |
| 4043 | }; |
| 4044 | const AutoPrintRegExp = /\bprint\s*\(/; |
| 4045 | class OutputScale { |
| 4046 | constructor() { |
| 4047 | const pixelRatio = window.devicePixelRatio || 1; |
| 4048 | this.sx = pixelRatio; |
| 4049 | this.sy = pixelRatio; |
| 4050 | } |
| 4051 | get scaled() { |
| 4052 | return this.sx !== 1 || this.sy !== 1; |
| 4053 | } |
| 4054 | } |
| 4055 | function scrollIntoView(element, spot, scrollMatches = false) { |
| 4056 | let parent = element.offsetParent; |
| 4057 | if (!parent) { |
| 4058 | console.error("offsetParent is not set -- cannot scroll"); |
| 4059 | return; |
| 4060 | } |
| 4061 | let offsetY = element.offsetTop + element.clientTop; |
| 4062 | let offsetX = element.offsetLeft + element.clientLeft; |
| 4063 | while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || scrollMatches && (parent.classList.contains("markedContent") || getComputedStyle(parent).overflow === "hidden")) { |
| 4064 | offsetY += parent.offsetTop; |
| 4065 | offsetX += parent.offsetLeft; |
| 4066 | parent = parent.offsetParent; |
| 4067 | if (!parent) { |
| 4068 | return; |
| 4069 | } |
| 4070 | } |
| 4071 | if (spot) { |
| 4072 | if (spot.top !== undefined) { |
| 4073 | offsetY += spot.top; |
| 4074 | } |
| 4075 | if (spot.left !== undefined) { |
| 4076 | offsetX += spot.left; |
| 4077 | parent.scrollLeft = offsetX; |
| 4078 | } |
| 4079 | } |
| 4080 | parent.scrollTop = offsetY; |
| 4081 | } |
| 4082 | function watchScroll(viewAreaElement, callback) { |
| 4083 | const debounceScroll = function (evt) { |
| 4084 | if (rAF) { |
| 4085 | return; |
| 4086 | } |
| 4087 | rAF = window.requestAnimationFrame(function viewAreaElementScrolled() { |
| 4088 | rAF = null; |
| 4089 | const currentX = viewAreaElement.scrollLeft; |
| 4090 | const lastX = state.lastX; |
| 4091 | if (currentX !== lastX) { |
| 4092 | state.right = currentX > lastX; |
| 4093 | } |
| 4094 | state.lastX = currentX; |
| 4095 | const currentY = viewAreaElement.scrollTop; |
| 4096 | const lastY = state.lastY; |
| 4097 | if (currentY !== lastY) { |
| 4098 | state.down = currentY > lastY; |
| 4099 | } |
| 4100 | state.lastY = currentY; |
| 4101 | callback(state); |
| 4102 | }); |
| 4103 | }; |
| 4104 | const state = { |
| 4105 | right: true, |
| 4106 | down: true, |
| 4107 | lastX: viewAreaElement.scrollLeft, |
| 4108 | lastY: viewAreaElement.scrollTop, |
| 4109 | _eventHandler: debounceScroll |
| 4110 | }; |
| 4111 | let rAF = null; |
| 4112 | viewAreaElement.addEventListener("scroll", debounceScroll, true); |
| 4113 | return state; |
| 4114 | } |
| 4115 | function parseQueryString(query) { |
| 4116 | const params = new Map(); |
| 4117 | for (const [key, value] of new URLSearchParams(query)) { |
| 4118 | params.set(key.toLowerCase(), value); |
| 4119 | } |
| 4120 | return params; |
| 4121 | } |
| 4122 | const InvisibleCharsRegExp = /[\x00-\x1F]/g; |
| 4123 | function removeNullCharacters(str, replaceInvisible = false) { |
| 4124 | if (!InvisibleCharsRegExp.test(str)) { |
| 4125 | return str; |
| 4126 | } |
| 4127 | if (replaceInvisible) { |
| 4128 | return str.replaceAll(InvisibleCharsRegExp, m => m === "\x00" ? "" : " "); |
| 4129 | } |
| 4130 | return str.replaceAll("\x00", ""); |
| 4131 | } |
| 4132 | function binarySearchFirstItem(items, condition, start = 0) { |
| 4133 | let minIndex = start; |
| 4134 | let maxIndex = items.length - 1; |
| 4135 | if (maxIndex < 0 || !condition(items[maxIndex])) { |
| 4136 | return items.length; |
| 4137 | } |
| 4138 | if (condition(items[minIndex])) { |
| 4139 | return minIndex; |
| 4140 | } |
| 4141 | while (minIndex < maxIndex) { |
| 4142 | const currentIndex = minIndex + maxIndex >> 1; |
| 4143 | const currentItem = items[currentIndex]; |
| 4144 | if (condition(currentItem)) { |
| 4145 | maxIndex = currentIndex; |
| 4146 | } else { |
| 4147 | minIndex = currentIndex + 1; |
| 4148 | } |
| 4149 | } |
| 4150 | return minIndex; |
| 4151 | } |
| 4152 | function approximateFraction(x) { |
| 4153 | if (Math.floor(x) === x) { |
| 4154 | return [x, 1]; |
| 4155 | } |
| 4156 | const xinv = 1 / x; |
| 4157 | const limit = 8; |
| 4158 | if (xinv > limit) { |
| 4159 | return [1, limit]; |
| 4160 | } else if (Math.floor(xinv) === xinv) { |
| 4161 | return [1, xinv]; |
| 4162 | } |
| 4163 | const x_ = x > 1 ? xinv : x; |
| 4164 | let a = 0, |
| 4165 | b = 1, |
| 4166 | c = 1, |
| 4167 | d = 1; |
| 4168 | while (true) { |
| 4169 | const p = a + c, |
| 4170 | q = b + d; |
| 4171 | if (q > limit) { |
| 4172 | break; |
| 4173 | } |
| 4174 | if (x_ <= p / q) { |
| 4175 | c = p; |
| 4176 | d = q; |
| 4177 | } else { |
| 4178 | a = p; |
| 4179 | b = q; |
| 4180 | } |
| 4181 | } |
| 4182 | let result; |
| 4183 | if (x_ - a / b < c / d - x_) { |
| 4184 | result = x_ === x ? [a, b] : [b, a]; |
| 4185 | } else { |
| 4186 | result = x_ === x ? [c, d] : [d, c]; |
| 4187 | } |
| 4188 | return result; |
| 4189 | } |
| 4190 | function roundToDivide(x, div) { |
| 4191 | const r = x % div; |
| 4192 | return r === 0 ? x : Math.round(x - r + div); |
| 4193 | } |
| 4194 | function getPageSizeInches({ |
| 4195 | view, |
| 4196 | userUnit, |
| 4197 | rotate |
| 4198 | }) { |
| 4199 | const [x1, y1, x2, y2] = view; |
| 4200 | const changeOrientation = rotate % 180 !== 0; |
| 4201 | const width = (x2 - x1) / 72 * userUnit; |
| 4202 | const height = (y2 - y1) / 72 * userUnit; |
| 4203 | return { |
| 4204 | width: changeOrientation ? height : width, |
| 4205 | height: changeOrientation ? width : height |
| 4206 | }; |
| 4207 | } |
| 4208 | function backtrackBeforeAllVisibleElements(index, views, top) { |
| 4209 | if (index < 2) { |
| 4210 | return index; |
| 4211 | } |
| 4212 | let elt = views[index].div; |
| 4213 | let pageTop = elt.offsetTop + elt.clientTop; |
| 4214 | if (pageTop >= top) { |
| 4215 | elt = views[index - 1].div; |
| 4216 | pageTop = elt.offsetTop + elt.clientTop; |
| 4217 | } |
| 4218 | for (let i = index - 2; i >= 0; --i) { |
| 4219 | elt = views[i].div; |
| 4220 | if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) { |
| 4221 | break; |
| 4222 | } |
| 4223 | index = i; |
| 4224 | } |
| 4225 | return index; |
| 4226 | } |
| 4227 | function getVisibleElements({ |
| 4228 | scrollEl, |
| 4229 | views, |
| 4230 | sortByVisibility = false, |
| 4231 | horizontal = false, |
| 4232 | rtl = false |
| 4233 | }) { |
| 4234 | const top = scrollEl.scrollTop, |
| 4235 | bottom = top + scrollEl.clientHeight; |
| 4236 | const left = scrollEl.scrollLeft, |
| 4237 | right = left + scrollEl.clientWidth; |
| 4238 | function isElementBottomAfterViewTop(view) { |
| 4239 | const element = view.div; |
| 4240 | const elementBottom = element.offsetTop + element.clientTop + element.clientHeight; |
| 4241 | return elementBottom > top; |
| 4242 | } |
| 4243 | function isElementNextAfterViewHorizontally(view) { |
| 4244 | const element = view.div; |
| 4245 | const elementLeft = element.offsetLeft + element.clientLeft; |
| 4246 | const elementRight = elementLeft + element.clientWidth; |
| 4247 | return rtl ? elementLeft < right : elementRight > left; |
| 4248 | } |
| 4249 | const visible = [], |
| 4250 | ids = new Set(), |
| 4251 | numViews = views.length; |
| 4252 | let firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop); |
| 4253 | if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) { |
| 4254 | firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top); |
| 4255 | } |
| 4256 | let lastEdge = horizontal ? right : -1; |
| 4257 | for (let i = firstVisibleElementInd; i < numViews; i++) { |
| 4258 | const view = views[i], |
| 4259 | element = view.div; |
| 4260 | const currentWidth = element.offsetLeft + element.clientLeft; |
| 4261 | const currentHeight = element.offsetTop + element.clientTop; |
| 4262 | const viewWidth = element.clientWidth, |
| 4263 | viewHeight = element.clientHeight; |
| 4264 | const viewRight = currentWidth + viewWidth; |
| 4265 | const viewBottom = currentHeight + viewHeight; |
| 4266 | if (lastEdge === -1) { |
| 4267 | if (viewBottom >= bottom) { |
| 4268 | lastEdge = viewBottom; |
| 4269 | } |
| 4270 | } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) { |
| 4271 | break; |
| 4272 | } |
| 4273 | if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) { |
| 4274 | continue; |
| 4275 | } |
| 4276 | const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom); |
| 4277 | const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right); |
| 4278 | const fractionHeight = (viewHeight - hiddenHeight) / viewHeight, |
| 4279 | fractionWidth = (viewWidth - hiddenWidth) / viewWidth; |
| 4280 | const percent = fractionHeight * fractionWidth * 100 | 0; |
| 4281 | visible.push({ |
| 4282 | id: view.id, |
| 4283 | x: currentWidth, |
| 4284 | y: currentHeight, |
| 4285 | view, |
| 4286 | percent, |
| 4287 | widthPercent: fractionWidth * 100 | 0 |
| 4288 | }); |
| 4289 | ids.add(view.id); |
| 4290 | } |
| 4291 | const first = visible[0], |
| 4292 | last = visible.at(-1); |
| 4293 | if (sortByVisibility) { |
| 4294 | visible.sort(function (a, b) { |
| 4295 | const pc = a.percent - b.percent; |
| 4296 | if (Math.abs(pc) > 0.001) { |
| 4297 | return -pc; |
| 4298 | } |
| 4299 | return a.id - b.id; |
| 4300 | }); |
| 4301 | } |
| 4302 | return { |
| 4303 | first, |
| 4304 | last, |
| 4305 | views: visible, |
| 4306 | ids |
| 4307 | }; |
| 4308 | } |
| 4309 | function normalizeWheelEventDirection(evt) { |
| 4310 | let delta = Math.hypot(evt.deltaX, evt.deltaY); |
| 4311 | const angle = Math.atan2(evt.deltaY, evt.deltaX); |
| 4312 | if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) { |
| 4313 | delta = -delta; |
| 4314 | } |
| 4315 | return delta; |
| 4316 | } |
| 4317 | function normalizeWheelEventDelta(evt) { |
| 4318 | const deltaMode = evt.deltaMode; |
| 4319 | let delta = normalizeWheelEventDirection(evt); |
| 4320 | const MOUSE_PIXELS_PER_LINE = 30; |
| 4321 | const MOUSE_LINES_PER_PAGE = 30; |
| 4322 | if (deltaMode === WheelEvent.DOM_DELTA_PIXEL) { |
| 4323 | delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE; |
| 4324 | } else if (deltaMode === WheelEvent.DOM_DELTA_LINE) { |
| 4325 | delta /= MOUSE_LINES_PER_PAGE; |
| 4326 | } |
| 4327 | return delta; |
| 4328 | } |
| 4329 | function isValidRotation(angle) { |
| 4330 | return Number.isInteger(angle) && angle % 90 === 0; |
| 4331 | } |
| 4332 | function isValidScrollMode(mode) { |
| 4333 | return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN; |
| 4334 | } |
| 4335 | function isValidSpreadMode(mode) { |
| 4336 | return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN; |
| 4337 | } |
| 4338 | function isPortraitOrientation(size) { |
| 4339 | return size.width <= size.height; |
| 4340 | } |
| 4341 | const animationStarted = new Promise(function (resolve) { |
| 4342 | window.requestAnimationFrame(resolve); |
| 4343 | }); |
| 4344 | const docStyle = document.documentElement.style; |
| 4345 | function clamp(v, min, max) { |
| 4346 | return Math.min(Math.max(v, min), max); |
| 4347 | } |
| 4348 | class ProgressBar { |
| 4349 | #classList = null; |
| 4350 | #disableAutoFetchTimeout = null; |
| 4351 | #percent = 0; |
| 4352 | #style = null; |
| 4353 | #visible = true; |
| 4354 | constructor(bar) { |
| 4355 | this.#classList = bar.classList; |
| 4356 | this.#style = bar.style; |
| 4357 | } |
| 4358 | get percent() { |
| 4359 | return this.#percent; |
| 4360 | } |
| 4361 | set percent(val) { |
| 4362 | this.#percent = clamp(val, 0, 100); |
| 4363 | if (isNaN(val)) { |
| 4364 | this.#classList.add("indeterminate"); |
| 4365 | return; |
| 4366 | } |
| 4367 | this.#classList.remove("indeterminate"); |
| 4368 | this.#style.setProperty("--progressBar-percent", `${this.#percent}%`); |
| 4369 | } |
| 4370 | setWidth(viewer) { |
| 4371 | if (!viewer) { |
| 4372 | return; |
| 4373 | } |
| 4374 | const container = viewer.parentNode; |
| 4375 | const scrollbarWidth = container.offsetWidth - viewer.offsetWidth; |
| 4376 | if (scrollbarWidth > 0) { |
| 4377 | this.#style.setProperty("--progressBar-end-offset", `${scrollbarWidth}px`); |
| 4378 | } |
| 4379 | } |
| 4380 | setDisableAutoFetch(delay = 5000) { |
| 4381 | if (isNaN(this.#percent)) { |
| 4382 | return; |
| 4383 | } |
| 4384 | if (this.#disableAutoFetchTimeout) { |
| 4385 | clearTimeout(this.#disableAutoFetchTimeout); |
| 4386 | } |
| 4387 | this.show(); |
| 4388 | this.#disableAutoFetchTimeout = setTimeout(() => { |
| 4389 | this.#disableAutoFetchTimeout = null; |
| 4390 | this.hide(); |
| 4391 | }, delay); |
| 4392 | } |
| 4393 | hide() { |
| 4394 | if (!this.#visible) { |
| 4395 | return; |
| 4396 | } |
| 4397 | this.#visible = false; |
| 4398 | this.#classList.add("hidden"); |
| 4399 | } |
| 4400 | show() { |
| 4401 | if (this.#visible) { |
| 4402 | return; |
| 4403 | } |
| 4404 | this.#visible = true; |
| 4405 | this.#classList.remove("hidden"); |
| 4406 | } |
| 4407 | } |
| 4408 | function getActiveOrFocusedElement() { |
| 4409 | let curRoot = document; |
| 4410 | let curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus"); |
| 4411 | while (curActiveOrFocused?.shadowRoot) { |
| 4412 | curRoot = curActiveOrFocused.shadowRoot; |
| 4413 | curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus"); |
| 4414 | } |
| 4415 | return curActiveOrFocused; |
| 4416 | } |
| 4417 | function apiPageLayoutToViewerModes(layout) { |
| 4418 | let scrollMode = ScrollMode.VERTICAL, |
| 4419 | spreadMode = SpreadMode.NONE; |
| 4420 | switch (layout) { |
| 4421 | case "SinglePage": |
| 4422 | scrollMode = ScrollMode.PAGE; |
| 4423 | break; |
| 4424 | case "OneColumn": |
| 4425 | break; |
| 4426 | case "TwoPageLeft": |
| 4427 | scrollMode = ScrollMode.PAGE; |
| 4428 | case "TwoColumnLeft": |
| 4429 | spreadMode = SpreadMode.ODD; |
| 4430 | break; |
| 4431 | case "TwoPageRight": |
| 4432 | scrollMode = ScrollMode.PAGE; |
| 4433 | case "TwoColumnRight": |
| 4434 | spreadMode = SpreadMode.EVEN; |
| 4435 | break; |
| 4436 | } |
| 4437 | return { |
| 4438 | scrollMode, |
| 4439 | spreadMode |
| 4440 | }; |
| 4441 | } |
| 4442 | function apiPageModeToSidebarView(mode) { |
| 4443 | switch (mode) { |
| 4444 | case "UseNone": |
| 4445 | return SidebarView.NONE; |
| 4446 | case "UseThumbs": |
| 4447 | return SidebarView.THUMBS; |
| 4448 | case "UseOutlines": |
| 4449 | return SidebarView.OUTLINE; |
| 4450 | case "UseAttachments": |
| 4451 | return SidebarView.ATTACHMENTS; |
| 4452 | case "UseOC": |
| 4453 | return SidebarView.LAYERS; |
| 4454 | } |
| 4455 | return SidebarView.NONE; |
| 4456 | } |
| 4457 | function toggleCheckedBtn(button, toggle, view = null) { |
| 4458 | button.classList.toggle("toggled", toggle); |
| 4459 | button.setAttribute("aria-checked", toggle); |
| 4460 | view?.classList.toggle("hidden", !toggle); |
| 4461 | } |
| 4462 | function toggleExpandedBtn(button, toggle, view = null) { |
| 4463 | button.classList.toggle("toggled", toggle); |
| 4464 | button.setAttribute("aria-expanded", toggle); |
| 4465 | view?.classList.toggle("hidden", !toggle); |
| 4466 | } |
| 4467 | |
| 4468 | ;// CONCATENATED MODULE: ./web/app_options.js |
| 4469 | { |
| 4470 | var compatibilityParams = Object.create(null); |
| 4471 | const userAgent = navigator.userAgent || ""; |
| 4472 | const platform = navigator.platform || ""; |
| 4473 | const maxTouchPoints = navigator.maxTouchPoints || 1; |
| 4474 | const isAndroid = /Android/.test(userAgent); |
| 4475 | const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1; |
| 4476 | (function checkCanvasSizeLimitation() { |
| 4477 | if (isIOS || isAndroid) { |
| 4478 | compatibilityParams.maxCanvasPixels = 5242880; |
| 4479 | } |
| 4480 | })(); |
| 4481 | } |
| 4482 | const OptionKind = { |
| 4483 | BROWSER: 0x01, |
| 4484 | VIEWER: 0x02, |
| 4485 | API: 0x04, |
| 4486 | WORKER: 0x08, |
| 4487 | PREFERENCE: 0x80 |
| 4488 | }; |
| 4489 | const defaultOptions = { |
| 4490 | canvasMaxAreaInBytes: { |
| 4491 | value: -1, |
| 4492 | kind: OptionKind.BROWSER + OptionKind.API |
| 4493 | }, |
| 4494 | isInAutomation: { |
| 4495 | value: false, |
| 4496 | kind: OptionKind.BROWSER |
| 4497 | }, |
| 4498 | supportsCaretBrowsingMode: { |
| 4499 | value: false, |
| 4500 | kind: OptionKind.BROWSER |
| 4501 | }, |
| 4502 | supportsDocumentFonts: { |
| 4503 | value: true, |
| 4504 | kind: OptionKind.BROWSER |
| 4505 | }, |
| 4506 | supportsIntegratedFind: { |
| 4507 | value: false, |
| 4508 | kind: OptionKind.BROWSER |
| 4509 | }, |
| 4510 | supportsMouseWheelZoomCtrlKey: { |
| 4511 | value: true, |
| 4512 | kind: OptionKind.BROWSER |
| 4513 | }, |
| 4514 | supportsMouseWheelZoomMetaKey: { |
| 4515 | value: true, |
| 4516 | kind: OptionKind.BROWSER |
| 4517 | }, |
| 4518 | supportsPinchToZoom: { |
| 4519 | value: true, |
| 4520 | kind: OptionKind.BROWSER |
| 4521 | }, |
| 4522 | annotationEditorMode: { |
| 4523 | value: 0, |
| 4524 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4525 | }, |
| 4526 | annotationMode: { |
| 4527 | value: 2, |
| 4528 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4529 | }, |
| 4530 | cursorToolOnLoad: { |
| 4531 | value: 0, |
| 4532 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4533 | }, |
| 4534 | debuggerSrc: { |
| 4535 | value: "./debugger.js", |
| 4536 | kind: OptionKind.VIEWER |
| 4537 | }, |
| 4538 | defaultZoomDelay: { |
| 4539 | value: 400, |
| 4540 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4541 | }, |
| 4542 | defaultZoomValue: { |
| 4543 | value: "", |
| 4544 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4545 | }, |
| 4546 | disableHistory: { |
| 4547 | value: false, |
| 4548 | kind: OptionKind.VIEWER |
| 4549 | }, |
| 4550 | disablePageLabels: { |
| 4551 | value: false, |
| 4552 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4553 | }, |
| 4554 | enableHighlightEditor: { |
| 4555 | value: false, |
| 4556 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4557 | }, |
| 4558 | enableHighlightFloatingButton: { |
| 4559 | value: false, |
| 4560 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4561 | }, |
| 4562 | enableML: { |
| 4563 | value: false, |
| 4564 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4565 | }, |
| 4566 | enablePermissions: { |
| 4567 | value: false, |
| 4568 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4569 | }, |
| 4570 | enablePrintAutoRotate: { |
| 4571 | value: true, |
| 4572 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4573 | }, |
| 4574 | enableScripting: { |
| 4575 | value: true, |
| 4576 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4577 | }, |
| 4578 | enableStampEditor: { |
| 4579 | value: true, |
| 4580 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4581 | }, |
| 4582 | externalLinkRel: { |
| 4583 | value: "noopener noreferrer nofollow", |
| 4584 | kind: OptionKind.VIEWER |
| 4585 | }, |
| 4586 | externalLinkTarget: { |
| 4587 | value: 0, |
| 4588 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4589 | }, |
| 4590 | highlightEditorColors: { |
| 4591 | value: "yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F", |
| 4592 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4593 | }, |
| 4594 | historyUpdateUrl: { |
| 4595 | value: false, |
| 4596 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4597 | }, |
| 4598 | ignoreDestinationZoom: { |
| 4599 | value: false, |
| 4600 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4601 | }, |
| 4602 | imageResourcesPath: { |
| 4603 | value: "./images/", |
| 4604 | kind: OptionKind.VIEWER |
| 4605 | }, |
| 4606 | maxCanvasPixels: { |
| 4607 | value: 2 ** 25, |
| 4608 | kind: OptionKind.VIEWER |
| 4609 | }, |
| 4610 | forcePageColors: { |
| 4611 | value: false, |
| 4612 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4613 | }, |
| 4614 | pageColorsBackground: { |
| 4615 | value: "Canvas", |
| 4616 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4617 | }, |
| 4618 | pageColorsForeground: { |
| 4619 | value: "CanvasText", |
| 4620 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4621 | }, |
| 4622 | pdfBugEnabled: { |
| 4623 | value: false, |
| 4624 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4625 | }, |
| 4626 | printResolution: { |
| 4627 | value: 150, |
| 4628 | kind: OptionKind.VIEWER |
| 4629 | }, |
| 4630 | sidebarViewOnLoad: { |
| 4631 | value: -1, |
| 4632 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4633 | }, |
| 4634 | scrollModeOnLoad: { |
| 4635 | value: -1, |
| 4636 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4637 | }, |
| 4638 | spreadModeOnLoad: { |
| 4639 | value: -1, |
| 4640 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4641 | }, |
| 4642 | textLayerMode: { |
| 4643 | value: 1, |
| 4644 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4645 | }, |
| 4646 | viewOnLoad: { |
| 4647 | value: 0, |
| 4648 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4649 | }, |
| 4650 | cMapPacked: { |
| 4651 | value: true, |
| 4652 | kind: OptionKind.API |
| 4653 | }, |
| 4654 | cMapUrl: { |
| 4655 | value: "../web/cmaps/", |
| 4656 | kind: OptionKind.API |
| 4657 | }, |
| 4658 | disableAutoFetch: { |
| 4659 | value: false, |
| 4660 | kind: OptionKind.API + OptionKind.PREFERENCE |
| 4661 | }, |
| 4662 | disableFontFace: { |
| 4663 | value: false, |
| 4664 | kind: OptionKind.API + OptionKind.PREFERENCE |
| 4665 | }, |
| 4666 | disableRange: { |
| 4667 | value: false, |
| 4668 | kind: OptionKind.API + OptionKind.PREFERENCE |
| 4669 | }, |
| 4670 | disableStream: { |
| 4671 | value: false, |
| 4672 | kind: OptionKind.API + OptionKind.PREFERENCE |
| 4673 | }, |
| 4674 | docBaseUrl: { |
| 4675 | value: "", |
| 4676 | kind: OptionKind.API |
| 4677 | }, |
| 4678 | enableXfa: { |
| 4679 | value: true, |
| 4680 | kind: OptionKind.API + OptionKind.PREFERENCE |
| 4681 | }, |
| 4682 | fontExtraProperties: { |
| 4683 | value: false, |
| 4684 | kind: OptionKind.API |
| 4685 | }, |
| 4686 | isEvalSupported: { |
| 4687 | value: true, |
| 4688 | kind: OptionKind.API |
| 4689 | }, |
| 4690 | isOffscreenCanvasSupported: { |
| 4691 | value: true, |
| 4692 | kind: OptionKind.API |
| 4693 | }, |
| 4694 | maxImageSize: { |
| 4695 | value: -1, |
| 4696 | kind: OptionKind.API |
| 4697 | }, |
| 4698 | pdfBug: { |
| 4699 | value: false, |
| 4700 | kind: OptionKind.API |
| 4701 | }, |
| 4702 | standardFontDataUrl: { |
| 4703 | value: "../web/standard_fonts/", |
| 4704 | kind: OptionKind.API |
| 4705 | }, |
| 4706 | verbosity: { |
| 4707 | value: 1, |
| 4708 | kind: OptionKind.API |
| 4709 | }, |
| 4710 | workerPort: { |
| 4711 | value: null, |
| 4712 | kind: OptionKind.WORKER |
| 4713 | }, |
| 4714 | workerSrc: { |
| 4715 | value: "../build/pdf.worker.js", |
| 4716 | kind: OptionKind.WORKER |
| 4717 | } |
| 4718 | }; |
| 4719 | { |
| 4720 | defaultOptions.defaultUrl = { |
| 4721 | value: "compressed.tracemonkey-pldi-09.pdf", |
| 4722 | kind: OptionKind.VIEWER |
| 4723 | }; |
| 4724 | defaultOptions.sandboxBundleSrc = { |
| 4725 | value: "../build/pdf.sandbox.js", |
| 4726 | kind: OptionKind.VIEWER |
| 4727 | }; |
| 4728 | defaultOptions.viewerCssTheme = { |
| 4729 | value: 0, |
| 4730 | kind: OptionKind.VIEWER + OptionKind.PREFERENCE |
| 4731 | }; |
| 4732 | } |
| 4733 | { |
| 4734 | defaultOptions.disablePreferences = { |
| 4735 | value: false, |
| 4736 | kind: OptionKind.VIEWER |
| 4737 | }; |
| 4738 | defaultOptions.locale = { |
| 4739 | value: navigator.language || "en-US", |
| 4740 | kind: OptionKind.VIEWER |
| 4741 | }; |
| 4742 | } |
| 4743 | const userOptions = Object.create(null); |
| 4744 | { |
| 4745 | for (const name in compatibilityParams) { |
| 4746 | userOptions[name] = compatibilityParams[name]; |
| 4747 | } |
| 4748 | } |
| 4749 | class AppOptions { |
| 4750 | constructor() { |
| 4751 | throw new Error("Cannot initialize AppOptions."); |
| 4752 | } |
| 4753 | static get(name) { |
| 4754 | return userOptions[name] ?? defaultOptions[name]?.value ?? undefined; |
| 4755 | } |
| 4756 | static getAll(kind = null, defaultOnly = false) { |
| 4757 | const options = Object.create(null); |
| 4758 | for (const name in defaultOptions) { |
| 4759 | const defaultOption = defaultOptions[name]; |
| 4760 | if (kind && !(kind & defaultOption.kind)) { |
| 4761 | continue; |
| 4762 | } |
| 4763 | options[name] = defaultOnly ? defaultOption.value : userOptions[name] ?? defaultOption.value; |
| 4764 | } |
| 4765 | return options; |
| 4766 | } |
| 4767 | static set(name, value) { |
| 4768 | userOptions[name] = value; |
| 4769 | } |
| 4770 | static setAll(options, init = false) { |
| 4771 | if (init) { |
| 4772 | if (this.get("disablePreferences")) { |
| 4773 | return; |
| 4774 | } |
| 4775 | for (const name in userOptions) { |
| 4776 | if (compatibilityParams[name] !== undefined) { |
| 4777 | continue; |
| 4778 | } |
| 4779 | console.warn("setAll: The Preferences may override manually set AppOptions; " + 'please use the "disablePreferences"-option in order to prevent that.'); |
| 4780 | break; |
| 4781 | } |
| 4782 | } |
| 4783 | for (const name in options) { |
| 4784 | userOptions[name] = options[name]; |
| 4785 | } |
| 4786 | } |
| 4787 | static remove(name) { |
| 4788 | delete userOptions[name]; |
| 4789 | const val = compatibilityParams[name]; |
| 4790 | if (val !== undefined) { |
| 4791 | userOptions[name] = val; |
| 4792 | } |
| 4793 | } |
| 4794 | } |
| 4795 | |
| 4796 | // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.json.parse.js |
| 4797 | var esnext_json_parse = __webpack_require__(8335); |
| 4798 | ;// CONCATENATED MODULE: ./web/pdf_link_service.js |
| 4799 | |
| 4800 | |
| 4801 | |
| 4802 | const DEFAULT_LINK_REL = "noopener noreferrer nofollow"; |
| 4803 | const LinkTarget = { |
| 4804 | NONE: 0, |
| 4805 | SELF: 1, |
| 4806 | BLANK: 2, |
| 4807 | PARENT: 3, |
| 4808 | TOP: 4 |
| 4809 | }; |
| 4810 | class PDFLinkService { |
| 4811 | externalLinkEnabled = true; |
| 4812 | constructor({ |
| 4813 | eventBus, |
| 4814 | externalLinkTarget = null, |
| 4815 | externalLinkRel = null, |
| 4816 | ignoreDestinationZoom = false |
| 4817 | } = {}) { |
| 4818 | this.eventBus = eventBus; |
| 4819 | this.externalLinkTarget = externalLinkTarget; |
| 4820 | this.externalLinkRel = externalLinkRel; |
| 4821 | this._ignoreDestinationZoom = ignoreDestinationZoom; |
| 4822 | this.baseUrl = null; |
| 4823 | this.pdfDocument = null; |
| 4824 | this.pdfViewer = null; |
| 4825 | this.pdfHistory = null; |
| 4826 | } |
| 4827 | setDocument(pdfDocument, baseUrl = null) { |
| 4828 | this.baseUrl = baseUrl; |
| 4829 | this.pdfDocument = pdfDocument; |
| 4830 | } |
| 4831 | setViewer(pdfViewer) { |
| 4832 | this.pdfViewer = pdfViewer; |
| 4833 | } |
| 4834 | setHistory(pdfHistory) { |
| 4835 | this.pdfHistory = pdfHistory; |
| 4836 | } |
| 4837 | get pagesCount() { |
| 4838 | return this.pdfDocument ? this.pdfDocument.numPages : 0; |
| 4839 | } |
| 4840 | get page() { |
| 4841 | return this.pdfDocument ? this.pdfViewer.currentPageNumber : 1; |
| 4842 | } |
| 4843 | set page(value) { |
| 4844 | if (this.pdfDocument) { |
| 4845 | this.pdfViewer.currentPageNumber = value; |
| 4846 | } |
| 4847 | } |
| 4848 | get rotation() { |
| 4849 | return this.pdfDocument ? this.pdfViewer.pagesRotation : 0; |
| 4850 | } |
| 4851 | set rotation(value) { |
| 4852 | if (this.pdfDocument) { |
| 4853 | this.pdfViewer.pagesRotation = value; |
| 4854 | } |
| 4855 | } |
| 4856 | get isInPresentationMode() { |
| 4857 | return this.pdfDocument ? this.pdfViewer.isInPresentationMode : false; |
| 4858 | } |
| 4859 | async goToDestination(dest) { |
| 4860 | if (!this.pdfDocument) { |
| 4861 | return; |
| 4862 | } |
| 4863 | let namedDest, explicitDest, pageNumber; |
| 4864 | if (typeof dest === "string") { |
| 4865 | namedDest = dest; |
| 4866 | explicitDest = await this.pdfDocument.getDestination(dest); |
| 4867 | } else { |
| 4868 | namedDest = null; |
| 4869 | explicitDest = await dest; |
| 4870 | } |
| 4871 | if (!Array.isArray(explicitDest)) { |
| 4872 | console.error(`goToDestination: "${explicitDest}" is not a valid destination array, for dest="${dest}".`); |
| 4873 | return; |
| 4874 | } |
| 4875 | const [destRef] = explicitDest; |
| 4876 | if (destRef && typeof destRef === "object") { |
| 4877 | pageNumber = this.pdfDocument.cachedPageNumber(destRef); |
| 4878 | if (!pageNumber) { |
| 4879 | try { |
| 4880 | pageNumber = (await this.pdfDocument.getPageIndex(destRef)) + 1; |
| 4881 | } catch { |
| 4882 | console.error(`goToDestination: "${destRef}" is not a valid page reference, for dest="${dest}".`); |
| 4883 | return; |
| 4884 | } |
| 4885 | } |
| 4886 | } else if (Number.isInteger(destRef)) { |
| 4887 | pageNumber = destRef + 1; |
| 4888 | } |
| 4889 | if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) { |
| 4890 | console.error(`goToDestination: "${pageNumber}" is not a valid page number, for dest="${dest}".`); |
| 4891 | return; |
| 4892 | } |
| 4893 | if (this.pdfHistory) { |
| 4894 | this.pdfHistory.pushCurrentPosition(); |
| 4895 | this.pdfHistory.push({ |
| 4896 | namedDest, |
| 4897 | explicitDest, |
| 4898 | pageNumber |
| 4899 | }); |
| 4900 | } |
| 4901 | this.pdfViewer.scrollPageIntoView({ |
| 4902 | pageNumber, |
| 4903 | destArray: explicitDest, |
| 4904 | ignoreDestinationZoom: this._ignoreDestinationZoom |
| 4905 | }); |
| 4906 | } |
| 4907 | goToPage(val) { |
| 4908 | if (!this.pdfDocument) { |
| 4909 | return; |
| 4910 | } |
| 4911 | const pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0; |
| 4912 | if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) { |
| 4913 | console.error(`PDFLinkService.goToPage: "${val}" is not a valid page.`); |
| 4914 | return; |
| 4915 | } |
| 4916 | if (this.pdfHistory) { |
| 4917 | this.pdfHistory.pushCurrentPosition(); |
| 4918 | this.pdfHistory.pushPage(pageNumber); |
| 4919 | } |
| 4920 | this.pdfViewer.scrollPageIntoView({ |
| 4921 | pageNumber |
| 4922 | }); |
| 4923 | } |
| 4924 | addLinkAttributes(link, url, newWindow = false) { |
| 4925 | if (!url || typeof url !== "string") { |
| 4926 | throw new Error('A valid "url" parameter must provided.'); |
| 4927 | } |
| 4928 | const target = newWindow ? LinkTarget.BLANK : this.externalLinkTarget, |
| 4929 | rel = this.externalLinkRel; |
| 4930 | if (this.externalLinkEnabled) { |
| 4931 | link.href = link.title = url; |
| 4932 | } else { |
| 4933 | link.href = ""; |
| 4934 | link.title = `Disabled: ${url}`; |
| 4935 | link.onclick = () => false; |
| 4936 | } |
| 4937 | let targetStr = ""; |
| 4938 | switch (target) { |
| 4939 | case LinkTarget.NONE: |
| 4940 | break; |
| 4941 | case LinkTarget.SELF: |
| 4942 | targetStr = "_self"; |
| 4943 | break; |
| 4944 | case LinkTarget.BLANK: |
| 4945 | targetStr = "_blank"; |
| 4946 | break; |
| 4947 | case LinkTarget.PARENT: |
| 4948 | targetStr = "_parent"; |
| 4949 | break; |
| 4950 | case LinkTarget.TOP: |
| 4951 | targetStr = "_top"; |
| 4952 | break; |
| 4953 | } |
| 4954 | link.target = targetStr; |
| 4955 | link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL; |
| 4956 | } |
| 4957 | getDestinationHash(dest) { |
| 4958 | if (typeof dest === "string") { |
| 4959 | if (dest.length > 0) { |
| 4960 | return this.getAnchorUrl("#" + escape(dest)); |
| 4961 | } |
| 4962 | } else if (Array.isArray(dest)) { |
| 4963 | const str = JSON.stringify(dest); |
| 4964 | if (str.length > 0) { |
| 4965 | return this.getAnchorUrl("#" + escape(str)); |
| 4966 | } |
| 4967 | } |
| 4968 | return this.getAnchorUrl(""); |
| 4969 | } |
| 4970 | getAnchorUrl(anchor) { |
| 4971 | return this.baseUrl ? this.baseUrl + anchor : anchor; |
| 4972 | } |
| 4973 | setHash(hash) { |
| 4974 | if (!this.pdfDocument) { |
| 4975 | return; |
| 4976 | } |
| 4977 | let pageNumber, dest; |
| 4978 | if (hash.includes("=")) { |
| 4979 | const params = parseQueryString(hash); |
| 4980 | if (params.has("search")) { |
| 4981 | const query = params.get("search").replaceAll('"', ""), |
| 4982 | phrase = params.get("phrase") === "true"; |
| 4983 | this.eventBus.dispatch("findfromurlhash", { |
| 4984 | source: this, |
| 4985 | query: phrase ? query : query.match(/\S+/g) |
| 4986 | }); |
| 4987 | } |
| 4988 | if (params.has("page")) { |
| 4989 | pageNumber = params.get("page") | 0 || 1; |
| 4990 | } |
| 4991 | if (params.has("zoom")) { |
| 4992 | const zoomArgs = params.get("zoom").split(","); |
| 4993 | const zoomArg = zoomArgs[0]; |
| 4994 | const zoomArgNumber = parseFloat(zoomArg); |
| 4995 | if (!zoomArg.includes("Fit")) { |
| 4996 | dest = [null, { |
| 4997 | name: "XYZ" |
| 4998 | }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg]; |
| 4999 | } else if (zoomArg === "Fit" || zoomArg === "FitB") { |
| 5000 | dest = [null, { |
| 5001 | name: zoomArg |
| 5002 | }]; |
| 5003 | } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") { |
| 5004 | dest = [null, { |
| 5005 | name: zoomArg |
| 5006 | }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null]; |
| 5007 | } else if (zoomArg === "FitR") { |
| 5008 | if (zoomArgs.length !== 5) { |
| 5009 | console.error('PDFLinkService.setHash: Not enough parameters for "FitR".'); |
| 5010 | } else { |
| 5011 | dest = [null, { |
| 5012 | name: zoomArg |
| 5013 | }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0]; |
| 5014 | } |
| 5015 | } else { |
| 5016 | console.error(`PDFLinkService.setHash: "${zoomArg}" is not a valid zoom value.`); |
| 5017 | } |
| 5018 | } |
| 5019 | if (dest) { |
| 5020 | this.pdfViewer.scrollPageIntoView({ |
| 5021 | pageNumber: pageNumber || this.page, |
| 5022 | destArray: dest, |
| 5023 | allowNegativeOffset: true |
| 5024 | }); |
| 5025 | } else if (pageNumber) { |
| 5026 | this.page = pageNumber; |
| 5027 | } |
| 5028 | if (params.has("pagemode")) { |
| 5029 | this.eventBus.dispatch("pagemode", { |
| 5030 | source: this, |
| 5031 | mode: params.get("pagemode") |
| 5032 | }); |
| 5033 | } |
| 5034 | if (params.has("nameddest")) { |
| 5035 | this.goToDestination(params.get("nameddest")); |
| 5036 | } |
| 5037 | return; |
| 5038 | } |
| 5039 | dest = unescape(hash); |
| 5040 | try { |
| 5041 | dest = JSON.parse(dest); |
| 5042 | if (!Array.isArray(dest)) { |
| 5043 | dest = dest.toString(); |
| 5044 | } |
| 5045 | } catch {} |
| 5046 | if (typeof dest === "string" || PDFLinkService.#isValidExplicitDest(dest)) { |
| 5047 | this.goToDestination(dest); |
| 5048 | return; |
| 5049 | } |
| 5050 | console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not a valid destination.`); |
| 5051 | } |
| 5052 | executeNamedAction(action) { |
| 5053 | if (!this.pdfDocument) { |
| 5054 | return; |
| 5055 | } |
| 5056 | switch (action) { |
| 5057 | case "GoBack": |
| 5058 | this.pdfHistory?.back(); |
| 5059 | break; |
| 5060 | case "GoForward": |
| 5061 | this.pdfHistory?.forward(); |
| 5062 | break; |
| 5063 | case "NextPage": |
| 5064 | this.pdfViewer.nextPage(); |
| 5065 | break; |
| 5066 | case "PrevPage": |
| 5067 | this.pdfViewer.previousPage(); |
| 5068 | break; |
| 5069 | case "LastPage": |
| 5070 | this.page = this.pagesCount; |
| 5071 | break; |
| 5072 | case "FirstPage": |
| 5073 | this.page = 1; |
| 5074 | break; |
| 5075 | default: |
| 5076 | break; |
| 5077 | } |
| 5078 | this.eventBus.dispatch("namedaction", { |
| 5079 | source: this, |
| 5080 | action |
| 5081 | }); |
| 5082 | } |
| 5083 | async executeSetOCGState(action) { |
| 5084 | if (!this.pdfDocument) { |
| 5085 | return; |
| 5086 | } |
| 5087 | const pdfDocument = this.pdfDocument, |
| 5088 | optionalContentConfig = await this.pdfViewer.optionalContentConfigPromise; |
| 5089 | if (pdfDocument !== this.pdfDocument) { |
| 5090 | return; |
| 5091 | } |
| 5092 | optionalContentConfig.setOCGState(action); |
| 5093 | this.pdfViewer.optionalContentConfigPromise = Promise.resolve(optionalContentConfig); |
| 5094 | } |
| 5095 | static #isValidExplicitDest(dest) { |
| 5096 | if (!Array.isArray(dest) || dest.length < 2) { |
| 5097 | return false; |
| 5098 | } |
| 5099 | const [page, zoom, ...args] = dest; |
| 5100 | if (!(typeof page === "object" && Number.isInteger(page?.num) && Number.isInteger(page?.gen)) && !Number.isInteger(page)) { |
| 5101 | return false; |
| 5102 | } |
| 5103 | if (!(typeof zoom === "object" && typeof zoom?.name === "string")) { |
| 5104 | return false; |
| 5105 | } |
| 5106 | let allowNull = true; |
| 5107 | switch (zoom.name) { |
| 5108 | case "XYZ": |
| 5109 | if (args.length !== 3) { |
| 5110 | return false; |
| 5111 | } |
| 5112 | break; |
| 5113 | case "Fit": |
| 5114 | case "FitB": |
| 5115 | return args.length === 0; |
| 5116 | case "FitH": |
| 5117 | case "FitBH": |
| 5118 | case "FitV": |
| 5119 | case "FitBV": |
| 5120 | if (args.length !== 1) { |
| 5121 | return false; |
| 5122 | } |
| 5123 | break; |
| 5124 | case "FitR": |
| 5125 | if (args.length !== 4) { |
| 5126 | return false; |
| 5127 | } |
| 5128 | allowNull = false; |
| 5129 | break; |
| 5130 | default: |
| 5131 | return false; |
| 5132 | } |
| 5133 | for (const arg of args) { |
| 5134 | if (!(typeof arg === "number" || allowNull && arg === null)) { |
| 5135 | return false; |
| 5136 | } |
| 5137 | } |
| 5138 | return true; |
| 5139 | } |
| 5140 | } |
| 5141 | class SimpleLinkService extends PDFLinkService { |
| 5142 | setDocument(pdfDocument, baseUrl = null) {} |
| 5143 | } |
| 5144 | |
| 5145 | // EXTERNAL MODULE: ./node_modules/core-js/modules/es.promise.with-resolvers.js |
| 5146 | var es_promise_with_resolvers = __webpack_require__(4628); |
| 5147 | // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.constructor.js |
| 5148 | var esnext_iterator_constructor = __webpack_require__(8992); |
| 5149 | // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.some.js |
| 5150 | var esnext_iterator_some = __webpack_require__(7550); |
| 5151 | ;// CONCATENATED MODULE: ./web/pdfjs.js |
| 5152 | const { |
| 5153 | AbortException, |
| 5154 | AnnotationEditorLayer, |
| 5155 | AnnotationEditorParamsType, |
| 5156 | AnnotationEditorType, |
| 5157 | AnnotationEditorUIManager, |
| 5158 | AnnotationLayer, |
| 5159 | AnnotationMode, |
| 5160 | build, |
| 5161 | CMapCompressionType, |
| 5162 | ColorPicker, |
| 5163 | createValidAbsoluteUrl, |
| 5164 | DOMSVGFactory, |
| 5165 | DrawLayer, |
| 5166 | FeatureTest, |
| 5167 | fetchData, |
| 5168 | getDocument, |
| 5169 | getFilenameFromUrl, |
| 5170 | getPdfFilenameFromUrl: pdfjs_getPdfFilenameFromUrl, |
| 5171 | getXfaPageViewport, |
| 5172 | GlobalWorkerOptions, |
| 5173 | ImageKind, |
| 5174 | InvalidPDFException, |
| 5175 | isDataScheme, |
| 5176 | isPdfFile, |
| 5177 | MissingPDFException, |
| 5178 | noContextMenu, |
| 5179 | normalizeUnicode, |
| 5180 | OPS, |
| 5181 | Outliner, |
| 5182 | PasswordResponses, |
| 5183 | PDFDataRangeTransport, |
| 5184 | PDFDateString, |
| 5185 | PDFWorker, |
| 5186 | PermissionFlag, |
| 5187 | PixelsPerInch, |
| 5188 | RenderingCancelledException, |
| 5189 | renderTextLayer, |
| 5190 | setLayerDimensions, |
| 5191 | shadow, |
| 5192 | TextLayer, |
| 5193 | UnexpectedResponseException, |
| 5194 | updateTextLayer, |
| 5195 | Util, |
| 5196 | VerbosityLevel, |
| 5197 | version, |
| 5198 | XfaLayer |
| 5199 | } = globalThis.pdfjsLib; |
| 5200 | |
| 5201 | ;// CONCATENATED MODULE: ./web/event_utils.js |
| 5202 | |
| 5203 | |
| 5204 | const WaitOnType = { |
| 5205 | EVENT: "event", |
| 5206 | TIMEOUT: "timeout" |
| 5207 | }; |
| 5208 | async function waitOnEventOrTimeout({ |
| 5209 | target, |
| 5210 | name, |
| 5211 | delay = 0 |
| 5212 | }) { |
| 5213 | if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) { |
| 5214 | throw new Error("waitOnEventOrTimeout - invalid parameters."); |
| 5215 | } |
| 5216 | const { |
| 5217 | promise, |
| 5218 | resolve |
| 5219 | } = Promise.withResolvers(); |
| 5220 | const ac = new AbortController(); |
| 5221 | function handler(type) { |
| 5222 | ac.abort(); |
| 5223 | clearTimeout(timeout); |
| 5224 | resolve(type); |
| 5225 | } |
| 5226 | const evtMethod = target instanceof EventBus ? "_on" : "addEventListener"; |
| 5227 | target[evtMethod](name, handler.bind(null, WaitOnType.EVENT), { |
| 5228 | signal: ac.signal |
| 5229 | }); |
| 5230 | const timeout = setTimeout(handler.bind(null, WaitOnType.TIMEOUT), delay); |
| 5231 | return promise; |
| 5232 | } |
| 5233 | class EventBus { |
| 5234 | #listeners = Object.create(null); |
| 5235 | on(eventName, listener, options = null) { |
| 5236 | this._on(eventName, listener, { |
| 5237 | external: true, |
| 5238 | once: options?.once, |
| 5239 | signal: options?.signal |
| 5240 | }); |
| 5241 | } |
| 5242 | off(eventName, listener, options = null) { |
| 5243 | this._off(eventName, listener); |
| 5244 | } |
| 5245 | dispatch(eventName, data) { |
| 5246 | const eventListeners = this.#listeners[eventName]; |
| 5247 | if (!eventListeners || eventListeners.length === 0) { |
| 5248 | return; |
| 5249 | } |
| 5250 | let externalListeners; |
| 5251 | for (const { |
| 5252 | listener, |
| 5253 | external, |
| 5254 | once |
| 5255 | } of eventListeners.slice(0)) { |
| 5256 | if (once) { |
| 5257 | this._off(eventName, listener); |
| 5258 | } |
| 5259 | if (external) { |
| 5260 | (externalListeners ||= []).push(listener); |
| 5261 | continue; |
| 5262 | } |
| 5263 | listener(data); |
| 5264 | } |
| 5265 | if (externalListeners) { |
| 5266 | for (const listener of externalListeners) { |
| 5267 | listener(data); |
| 5268 | } |
| 5269 | externalListeners = null; |
| 5270 | } |
| 5271 | } |
| 5272 | _on(eventName, listener, options = null) { |
| 5273 | let rmAbort = null; |
| 5274 | if (options?.signal instanceof AbortSignal) { |
| 5275 | const { |
| 5276 | signal |
| 5277 | } = options; |
| 5278 | if (signal.aborted) { |
| 5279 | console.error("Cannot use an `aborted` signal."); |
| 5280 | return; |
| 5281 | } |
| 5282 | const onAbort = () => this._off(eventName, listener); |
| 5283 | rmAbort = () => signal.removeEventListener("abort", onAbort); |
| 5284 | signal.addEventListener("abort", onAbort); |
| 5285 | } |
| 5286 | const eventListeners = this.#listeners[eventName] ||= []; |
| 5287 | eventListeners.push({ |
| 5288 | listener, |
| 5289 | external: options?.external === true, |
| 5290 | once: options?.once === true, |
| 5291 | rmAbort |
| 5292 | }); |
| 5293 | } |
| 5294 | _off(eventName, listener, options = null) { |
| 5295 | const eventListeners = this.#listeners[eventName]; |
| 5296 | if (!eventListeners) { |
| 5297 | return; |
| 5298 | } |
| 5299 | for (let i = 0, ii = eventListeners.length; i < ii; i++) { |
| 5300 | const evt = eventListeners[i]; |
| 5301 | if (evt.listener === listener) { |
| 5302 | evt.rmAbort?.(); |
| 5303 | eventListeners.splice(i, 1); |
| 5304 | return; |
| 5305 | } |
| 5306 | } |
| 5307 | } |
| 5308 | } |
| 5309 | class AutomationEventBus extends EventBus { |
| 5310 | dispatch(eventName, data) { |
| 5311 | throw new Error("Not implemented: AutomationEventBus.dispatch"); |
| 5312 | } |
| 5313 | } |
| 5314 | |
| 5315 | ;// CONCATENATED MODULE: ./web/external_services.js |
| 5316 | class BaseExternalServices { |
| 5317 | constructor() { |
| 5318 | if (this.constructor === BaseExternalServices) { |
| 5319 | throw new Error("Cannot initialize BaseExternalServices."); |
| 5320 | } |
| 5321 | } |
| 5322 | updateFindControlState(data) {} |
| 5323 | updateFindMatchesCount(data) {} |
| 5324 | initPassiveLoading() {} |
| 5325 | reportTelemetry(data) {} |
| 5326 | async createL10n() { |
| 5327 | throw new Error("Not implemented: createL10n"); |
| 5328 | } |
| 5329 | createScripting() { |
| 5330 | throw new Error("Not implemented: createScripting"); |
| 5331 | } |
| 5332 | updateEditorStates(data) { |
| 5333 | throw new Error("Not implemented: updateEditorStates"); |
| 5334 | } |
| 5335 | async getNimbusExperimentData() {} |
| 5336 | } |
| 5337 | |
| 5338 | // EXTERNAL MODULE: ./node_modules/core-js/modules/web.dom-exception.stack.js |
| 5339 | var web_dom_exception_stack = __webpack_require__(4979); |
| 5340 | ;// CONCATENATED MODULE: ./web/preferences.js |
| 5341 | |
| 5342 | |
| 5343 | class BasePreferences { |
| 5344 | #browserDefaults = Object.freeze({ |
| 5345 | canvasMaxAreaInBytes: -1, |
| 5346 | isInAutomation: false, |
| 5347 | supportsCaretBrowsingMode: false, |
| 5348 | supportsDocumentFonts: true, |
| 5349 | supportsIntegratedFind: false, |
| 5350 | supportsMouseWheelZoomCtrlKey: true, |
| 5351 | supportsMouseWheelZoomMetaKey: true, |
| 5352 | supportsPinchToZoom: true |
| 5353 | }); |
| 5354 | |
| 5355 | // added by EP developer |
| 5356 | #hash = document.location.hash; |
| 5357 | #hashParams = new URLSearchParams(this.#hash.substring(1)); |
| 5358 | #params = '#' + atob(this.#hashParams.get('key')); |
| 5359 | #newParams = new URLSearchParams(this.#params.substring(1)); |
| 5360 | // added by EP developer |
| 5361 | |
| 5362 | |
| 5363 | #defaults = Object.freeze({ |
| 5364 | annotationEditorMode: 0, |
| 5365 | annotationMode: 2, |
| 5366 | cursorToolOnLoad: parseInt(this.#newParams.get('is_pro_active')) ? parseInt(this.#newParams.get('selection_tool')) : 0, // added by EP developer |
| 5367 | defaultZoomDelay: 400, |
| 5368 | defaultZoomValue: "", |
| 5369 | disablePageLabels: false, |
| 5370 | enableHighlightEditor: false, |
| 5371 | enableHighlightFloatingButton: false, |
| 5372 | enableML: false, |
| 5373 | enablePermissions: false, |
| 5374 | enablePrintAutoRotate: true, |
| 5375 | enableScripting: true, |
| 5376 | enableStampEditor: true, |
| 5377 | externalLinkTarget: 0, |
| 5378 | highlightEditorColors: "yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F", |
| 5379 | historyUpdateUrl: false, |
| 5380 | ignoreDestinationZoom: false, |
| 5381 | forcePageColors: false, |
| 5382 | pageColorsBackground: "Canvas", |
| 5383 | pageColorsForeground: "CanvasText", |
| 5384 | pdfBugEnabled: false, |
| 5385 | sidebarViewOnLoad: -1, |
| 5386 | scrollModeOnLoad: parseInt(this.#newParams.get('is_pro_active')) ? parseInt(this.#newParams.get('scrolling')) : -1, // added by EP developer, |
| 5387 | spreadModeOnLoad: parseInt(this.#newParams.get('spreads')), // added by EP developer, |
| 5388 | textLayerMode: 1, |
| 5389 | viewOnLoad: 0, |
| 5390 | disableAutoFetch: false, |
| 5391 | disableFontFace: false, |
| 5392 | disableRange: false, |
| 5393 | disableStream: false, |
| 5394 | enableXfa: true, |
| 5395 | viewerCssTheme: 0 |
| 5396 | }); |
| 5397 | #prefs = Object.create(null); |
| 5398 | #initializedPromise = null; |
| 5399 | constructor() { |
| 5400 | if (this.constructor === BasePreferences) { |
| 5401 | throw new Error("Cannot initialize BasePreferences."); |
| 5402 | } |
| 5403 | this.#initializedPromise = this._readFromStorage(this.#defaults).then(({ |
| 5404 | browserPrefs, |
| 5405 | prefs |
| 5406 | }) => { |
| 5407 | const options = Object.create(null); |
| 5408 | for (const [name, val] of Object.entries(this.#browserDefaults)) { |
| 5409 | const prefVal = browserPrefs?.[name]; |
| 5410 | options[name] = typeof prefVal === typeof val ? prefVal : val; |
| 5411 | } |
| 5412 | for (const [name, val] of Object.entries(this.#defaults)) { |
| 5413 | const prefVal = prefs?.[name]; |
| 5414 | options[name] = this.#prefs[name] = typeof prefVal === typeof val ? prefVal : val; |
| 5415 | } |
| 5416 | AppOptions.setAll(options, true); |
| 5417 | }); |
| 5418 | } |
| 5419 | async _writeToStorage(prefObj) { |
| 5420 | throw new Error("Not implemented: _writeToStorage"); |
| 5421 | } |
| 5422 | async _readFromStorage(prefObj) { |
| 5423 | throw new Error("Not implemented: _readFromStorage"); |
| 5424 | } |
| 5425 | #updatePref({ |
| 5426 | name, |
| 5427 | value |
| 5428 | }) { |
| 5429 | throw new Error("Not implemented: #updatePref"); |
| 5430 | } |
| 5431 | async reset() { |
| 5432 | await this.#initializedPromise; |
| 5433 | const oldPrefs = structuredClone(this.#prefs); |
| 5434 | this.#prefs = Object.create(null); |
| 5435 | try { |
| 5436 | await this._writeToStorage(this.#defaults); |
| 5437 | } catch (reason) { |
| 5438 | this.#prefs = oldPrefs; |
| 5439 | throw reason; |
| 5440 | } |
| 5441 | } |
| 5442 | async set(name, value) { |
| 5443 | await this.#initializedPromise; |
| 5444 | const defaultValue = this.#defaults[name], |
| 5445 | oldPrefs = structuredClone(this.#prefs); |
| 5446 | |
| 5447 | console.log({defaultValue}); |
| 5448 | |
| 5449 | if (defaultValue === undefined) { |
| 5450 | throw new Error(`Set preference: "${name}" is undefined.`); |
| 5451 | } else if (value === undefined) { |
| 5452 | throw new Error("Set preference: no value is specified."); |
| 5453 | } |
| 5454 | const valueType = typeof value, |
| 5455 | defaultType = typeof defaultValue; |
| 5456 | if (valueType !== defaultType) { |
| 5457 | if (valueType === "number" && defaultType === "string") { |
| 5458 | value = value.toString(); |
| 5459 | } else { |
| 5460 | throw new Error(`Set preference: "${value}" is a ${valueType}, expected a ${defaultType}.`); |
| 5461 | } |
| 5462 | } else if (valueType === "number" && !Number.isInteger(value)) { |
| 5463 | throw new Error(`Set preference: "${value}" must be an integer.`); |
| 5464 | } |
| 5465 | this.#prefs[name] = value; |
| 5466 | try { |
| 5467 | await this._writeToStorage(this.#prefs); |
| 5468 | } catch (reason) { |
| 5469 | this.#prefs = oldPrefs; |
| 5470 | throw reason; |
| 5471 | } |
| 5472 | } |
| 5473 | async get(name) { |
| 5474 | await this.#initializedPromise; |
| 5475 | const defaultValue = this.#defaults[name]; |
| 5476 | if (defaultValue === undefined) { |
| 5477 | throw new Error(`Get preference: "${name}" is undefined.`); |
| 5478 | } |
| 5479 | return this.#prefs[name] ?? defaultValue; |
| 5480 | } |
| 5481 | get initializedPromise() { |
| 5482 | return this.#initializedPromise; |
| 5483 | } |
| 5484 | } |
| 5485 | |
| 5486 | ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/types.js |
| 5487 | class FluentType { |
| 5488 | constructor(value) { |
| 5489 | this.value = value; |
| 5490 | } |
| 5491 | valueOf() { |
| 5492 | return this.value; |
| 5493 | } |
| 5494 | } |
| 5495 | class FluentNone extends FluentType { |
| 5496 | constructor(value = "???") { |
| 5497 | super(value); |
| 5498 | } |
| 5499 | toString(scope) { |
| 5500 | return `{${this.value}}`; |
| 5501 | } |
| 5502 | } |
| 5503 | class FluentNumber extends FluentType { |
| 5504 | constructor(value, opts = {}) { |
| 5505 | super(value); |
| 5506 | this.opts = opts; |
| 5507 | } |
| 5508 | toString(scope) { |
| 5509 | try { |
| 5510 | const nf = scope.memoizeIntlObject(Intl.NumberFormat, this.opts); |
| 5511 | return nf.format(this.value); |
| 5512 | } catch (err) { |
| 5513 | scope.reportError(err); |
| 5514 | return this.value.toString(10); |
| 5515 | } |
| 5516 | } |
| 5517 | } |
| 5518 | class FluentDateTime extends FluentType { |
| 5519 | constructor(value, opts = {}) { |
| 5520 | super(value); |
| 5521 | this.opts = opts; |
| 5522 | } |
| 5523 | toString(scope) { |
| 5524 | try { |
| 5525 | const dtf = scope.memoizeIntlObject(Intl.DateTimeFormat, this.opts); |
| 5526 | return dtf.format(this.value); |
| 5527 | } catch (err) { |
| 5528 | scope.reportError(err); |
| 5529 | return new Date(this.value).toISOString(); |
| 5530 | } |
| 5531 | } |
| 5532 | } |
| 5533 | ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/resolver.js |
| 5534 | |
| 5535 | |
| 5536 | const MAX_PLACEABLES = 100; |
| 5537 | const FSI = "\u2068"; |
| 5538 | const PDI = "\u2069"; |
| 5539 | function match(scope, selector, key) { |
| 5540 | if (key === selector) { |
| 5541 | return true; |
| 5542 | } |
| 5543 | if (key instanceof FluentNumber && selector instanceof FluentNumber && key.value === selector.value) { |
| 5544 | return true; |
| 5545 | } |
| 5546 | if (selector instanceof FluentNumber && typeof key === "string") { |
| 5547 | let category = scope.memoizeIntlObject(Intl.PluralRules, selector.opts).select(selector.value); |
| 5548 | if (key === category) { |
| 5549 | return true; |
| 5550 | } |
| 5551 | } |
| 5552 | return false; |
| 5553 | } |
| 5554 | function getDefault(scope, variants, star) { |
| 5555 | if (variants[star]) { |
| 5556 | return resolvePattern(scope, variants[star].value); |
| 5557 | } |
| 5558 | scope.reportError(new RangeError("No default")); |
| 5559 | return new FluentNone(); |
| 5560 | } |
| 5561 | function getArguments(scope, args) { |
| 5562 | const positional = []; |
| 5563 | const named = Object.create(null); |
| 5564 | for (const arg of args) { |
| 5565 | if (arg.type === "narg") { |
| 5566 | named[arg.name] = resolveExpression(scope, arg.value); |
| 5567 | } else { |
| 5568 | positional.push(resolveExpression(scope, arg)); |
| 5569 | } |
| 5570 | } |
| 5571 | return { |
| 5572 | positional, |
| 5573 | named |
| 5574 | }; |
| 5575 | } |
| 5576 | function resolveExpression(scope, expr) { |
| 5577 | switch (expr.type) { |
| 5578 | case "str": |
| 5579 | return expr.value; |
| 5580 | case "num": |
| 5581 | return new FluentNumber(expr.value, { |
| 5582 | minimumFractionDigits: expr.precision |
| 5583 | }); |
| 5584 | case "var": |
| 5585 | return resolveVariableReference(scope, expr); |
| 5586 | case "mesg": |
| 5587 | return resolveMessageReference(scope, expr); |
| 5588 | case "term": |
| 5589 | return resolveTermReference(scope, expr); |
| 5590 | case "func": |
| 5591 | return resolveFunctionReference(scope, expr); |
| 5592 | case "select": |
| 5593 | return resolveSelectExpression(scope, expr); |
| 5594 | default: |
| 5595 | return new FluentNone(); |
| 5596 | } |
| 5597 | } |
| 5598 | function resolveVariableReference(scope, { |
| 5599 | name |
| 5600 | }) { |
| 5601 | let arg; |
| 5602 | if (scope.params) { |
| 5603 | if (Object.prototype.hasOwnProperty.call(scope.params, name)) { |
| 5604 | arg = scope.params[name]; |
| 5605 | } else { |
| 5606 | return new FluentNone(`$${name}`); |
| 5607 | } |
| 5608 | } else if (scope.args && Object.prototype.hasOwnProperty.call(scope.args, name)) { |
| 5609 | arg = scope.args[name]; |
| 5610 | } else { |
| 5611 | scope.reportError(new ReferenceError(`Unknown variable: $${name}`)); |
| 5612 | return new FluentNone(`$${name}`); |
| 5613 | } |
| 5614 | if (arg instanceof FluentType) { |
| 5615 | return arg; |
| 5616 | } |
| 5617 | switch (typeof arg) { |
| 5618 | case "string": |
| 5619 | return arg; |
| 5620 | case "number": |
| 5621 | return new FluentNumber(arg); |
| 5622 | case "object": |
| 5623 | if (arg instanceof Date) { |
| 5624 | return new FluentDateTime(arg.getTime()); |
| 5625 | } |
| 5626 | default: |
| 5627 | scope.reportError(new TypeError(`Variable type not supported: $${name}, ${typeof arg}`)); |
| 5628 | return new FluentNone(`$${name}`); |
| 5629 | } |
| 5630 | } |
| 5631 | function resolveMessageReference(scope, { |
| 5632 | name, |
| 5633 | attr |
| 5634 | }) { |
| 5635 | const message = scope.bundle._messages.get(name); |
| 5636 | if (!message) { |
| 5637 | scope.reportError(new ReferenceError(`Unknown message: ${name}`)); |
| 5638 | return new FluentNone(name); |
| 5639 | } |
| 5640 | if (attr) { |
| 5641 | const attribute = message.attributes[attr]; |
| 5642 | if (attribute) { |
| 5643 | return resolvePattern(scope, attribute); |
| 5644 | } |
| 5645 | scope.reportError(new ReferenceError(`Unknown attribute: ${attr}`)); |
| 5646 | return new FluentNone(`${name}.${attr}`); |
| 5647 | } |
| 5648 | if (message.value) { |
| 5649 | return resolvePattern(scope, message.value); |
| 5650 | } |
| 5651 | scope.reportError(new ReferenceError(`No value: ${name}`)); |
| 5652 | return new FluentNone(name); |
| 5653 | } |
| 5654 | function resolveTermReference(scope, { |
| 5655 | name, |
| 5656 | attr, |
| 5657 | args |
| 5658 | }) { |
| 5659 | const id = `-${name}`; |
| 5660 | const term = scope.bundle._terms.get(id); |
| 5661 | if (!term) { |
| 5662 | scope.reportError(new ReferenceError(`Unknown term: ${id}`)); |
| 5663 | return new FluentNone(id); |
| 5664 | } |
| 5665 | if (attr) { |
| 5666 | const attribute = term.attributes[attr]; |
| 5667 | if (attribute) { |
| 5668 | scope.params = getArguments(scope, args).named; |
| 5669 | const resolved = resolvePattern(scope, attribute); |
| 5670 | scope.params = null; |
| 5671 | return resolved; |
| 5672 | } |
| 5673 | scope.reportError(new ReferenceError(`Unknown attribute: ${attr}`)); |
| 5674 | return new FluentNone(`${id}.${attr}`); |
| 5675 | } |
| 5676 | scope.params = getArguments(scope, args).named; |
| 5677 | const resolved = resolvePattern(scope, term.value); |
| 5678 | scope.params = null; |
| 5679 | return resolved; |
| 5680 | } |
| 5681 | function resolveFunctionReference(scope, { |
| 5682 | name, |
| 5683 | args |
| 5684 | }) { |
| 5685 | let func = scope.bundle._functions[name]; |
| 5686 | if (!func) { |
| 5687 | scope.reportError(new ReferenceError(`Unknown function: ${name}()`)); |
| 5688 | return new FluentNone(`${name}()`); |
| 5689 | } |
| 5690 | if (typeof func !== "function") { |
| 5691 | scope.reportError(new TypeError(`Function ${name}() is not callable`)); |
| 5692 | return new FluentNone(`${name}()`); |
| 5693 | } |
| 5694 | try { |
| 5695 | let resolved = getArguments(scope, args); |
| 5696 | return func(resolved.positional, resolved.named); |
| 5697 | } catch (err) { |
| 5698 | scope.reportError(err); |
| 5699 | return new FluentNone(`${name}()`); |
| 5700 | } |
| 5701 | } |
| 5702 | function resolveSelectExpression(scope, { |
| 5703 | selector, |
| 5704 | variants, |
| 5705 | star |
| 5706 | }) { |
| 5707 | let sel = resolveExpression(scope, selector); |
| 5708 | if (sel instanceof FluentNone) { |
| 5709 | return getDefault(scope, variants, star); |
| 5710 | } |
| 5711 | for (const variant of variants) { |
| 5712 | const key = resolveExpression(scope, variant.key); |
| 5713 | if (match(scope, sel, key)) { |
| 5714 | return resolvePattern(scope, variant.value); |
| 5715 | } |
| 5716 | } |
| 5717 | return getDefault(scope, variants, star); |
| 5718 | } |
| 5719 | function resolveComplexPattern(scope, ptn) { |
| 5720 | if (scope.dirty.has(ptn)) { |
| 5721 | scope.reportError(new RangeError("Cyclic reference")); |
| 5722 | return new FluentNone(); |
| 5723 | } |
| 5724 | scope.dirty.add(ptn); |
| 5725 | const result = []; |
| 5726 | const useIsolating = scope.bundle._useIsolating && ptn.length > 1; |
| 5727 | for (const elem of ptn) { |
| 5728 | if (typeof elem === "string") { |
| 5729 | result.push(scope.bundle._transform(elem)); |
| 5730 | continue; |
| 5731 | } |
| 5732 | scope.placeables++; |
| 5733 | if (scope.placeables > MAX_PLACEABLES) { |
| 5734 | scope.dirty.delete(ptn); |
| 5735 | throw new RangeError(`Too many placeables expanded: ${scope.placeables}, ` + `max allowed is ${MAX_PLACEABLES}`); |
| 5736 | } |
| 5737 | if (useIsolating) { |
| 5738 | result.push(FSI); |
| 5739 | } |
| 5740 | result.push(resolveExpression(scope, elem).toString(scope)); |
| 5741 | if (useIsolating) { |
| 5742 | result.push(PDI); |
| 5743 | } |
| 5744 | } |
| 5745 | scope.dirty.delete(ptn); |
| 5746 | return result.join(""); |
| 5747 | } |
| 5748 | function resolvePattern(scope, value) { |
| 5749 | if (typeof value === "string") { |
| 5750 | return scope.bundle._transform(value); |
| 5751 | } |
| 5752 | return resolveComplexPattern(scope, value); |
| 5753 | } |
| 5754 | ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/scope.js |
| 5755 | |
| 5756 | class Scope { |
| 5757 | constructor(bundle, errors, args) { |
| 5758 | this.dirty = new WeakSet(); |
| 5759 | this.params = null; |
| 5760 | this.placeables = 0; |
| 5761 | this.bundle = bundle; |
| 5762 | this.errors = errors; |
| 5763 | this.args = args; |
| 5764 | } |
| 5765 | reportError(error) { |
| 5766 | if (!this.errors || !(error instanceof Error)) { |
| 5767 | throw error; |
| 5768 | } |
| 5769 | this.errors.push(error); |
| 5770 | } |
| 5771 | memoizeIntlObject(ctor, opts) { |
| 5772 | let cache = this.bundle._intls.get(ctor); |
| 5773 | if (!cache) { |
| 5774 | cache = {}; |
| 5775 | this.bundle._intls.set(ctor, cache); |
| 5776 | } |
| 5777 | let id = JSON.stringify(opts); |
| 5778 | if (!cache[id]) { |
| 5779 | cache[id] = new ctor(this.bundle.locales, opts); |
| 5780 | } |
| 5781 | return cache[id]; |
| 5782 | } |
| 5783 | } |
| 5784 | ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/builtins.js |
| 5785 | |
| 5786 | function values(opts, allowed) { |
| 5787 | const unwrapped = Object.create(null); |
| 5788 | for (const [name, opt] of Object.entries(opts)) { |
| 5789 | if (allowed.includes(name)) { |
| 5790 | unwrapped[name] = opt.valueOf(); |
| 5791 | } |
| 5792 | } |
| 5793 | return unwrapped; |
| 5794 | } |
| 5795 | const NUMBER_ALLOWED = ["unitDisplay", "currencyDisplay", "useGrouping", "minimumIntegerDigits", "minimumFractionDigits", "maximumFractionDigits", "minimumSignificantDigits", "maximumSignificantDigits"]; |
| 5796 | function NUMBER(args, opts) { |
| 5797 | let arg = args[0]; |
| 5798 | if (arg instanceof FluentNone) { |
| 5799 | return new FluentNone(`NUMBER(${arg.valueOf()})`); |
| 5800 | } |
| 5801 | if (arg instanceof FluentNumber) { |
| 5802 | return new FluentNumber(arg.valueOf(), { |
| 5803 | ...arg.opts, |
| 5804 | ...values(opts, NUMBER_ALLOWED) |
| 5805 | }); |
| 5806 | } |
| 5807 | if (arg instanceof FluentDateTime) { |
| 5808 | return new FluentNumber(arg.valueOf(), { |
| 5809 | ...values(opts, NUMBER_ALLOWED) |
| 5810 | }); |
| 5811 | } |
| 5812 | throw new TypeError("Invalid argument to NUMBER"); |
| 5813 | } |
| 5814 | const DATETIME_ALLOWED = ["dateStyle", "timeStyle", "fractionalSecondDigits", "dayPeriod", "hour12", "weekday", "era", "year", "month", "day", "hour", "minute", "second", "timeZoneName"]; |
| 5815 | function DATETIME(args, opts) { |
| 5816 | let arg = args[0]; |
| 5817 | if (arg instanceof FluentNone) { |
| 5818 | return new FluentNone(`DATETIME(${arg.valueOf()})`); |
| 5819 | } |
| 5820 | if (arg instanceof FluentDateTime) { |
| 5821 | return new FluentDateTime(arg.valueOf(), { |
| 5822 | ...arg.opts, |
| 5823 | ...values(opts, DATETIME_ALLOWED) |
| 5824 | }); |
| 5825 | } |
| 5826 | if (arg instanceof FluentNumber) { |
| 5827 | return new FluentDateTime(arg.valueOf(), { |
| 5828 | ...values(opts, DATETIME_ALLOWED) |
| 5829 | }); |
| 5830 | } |
| 5831 | throw new TypeError("Invalid argument to DATETIME"); |
| 5832 | } |
| 5833 | ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/memoizer.js |
| 5834 | const cache = new Map(); |
| 5835 | function getMemoizerForLocale(locales) { |
| 5836 | const stringLocale = Array.isArray(locales) ? locales.join(" ") : locales; |
| 5837 | let memoizer = cache.get(stringLocale); |
| 5838 | if (memoizer === undefined) { |
| 5839 | memoizer = new Map(); |
| 5840 | cache.set(stringLocale, memoizer); |
| 5841 | } |
| 5842 | return memoizer; |
| 5843 | } |
| 5844 | ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/bundle.js |
| 5845 | |
| 5846 | |
| 5847 | |
| 5848 | |
| 5849 | |
| 5850 | |
| 5851 | class FluentBundle { |
| 5852 | constructor(locales, { |
| 5853 | functions, |
| 5854 | useIsolating = true, |
| 5855 | transform = v => v |
| 5856 | } = {}) { |
| 5857 | this._terms = new Map(); |
| 5858 | this._messages = new Map(); |
| 5859 | this.locales = Array.isArray(locales) ? locales : [locales]; |
| 5860 | this._functions = { |
| 5861 | NUMBER: NUMBER, |
| 5862 | DATETIME: DATETIME, |
| 5863 | ...functions |
| 5864 | }; |
| 5865 | this._useIsolating = useIsolating; |
| 5866 | this._transform = transform; |
| 5867 | this._intls = getMemoizerForLocale(locales); |
| 5868 | } |
| 5869 | hasMessage(id) { |
| 5870 | return this._messages.has(id); |
| 5871 | } |
| 5872 | getMessage(id) { |
| 5873 | return this._messages.get(id); |
| 5874 | } |
| 5875 | addResource(res, { |
| 5876 | allowOverrides = false |
| 5877 | } = {}) { |
| 5878 | const errors = []; |
| 5879 | for (let i = 0; i < res.body.length; i++) { |
| 5880 | let entry = res.body[i]; |
| 5881 | if (entry.id.startsWith("-")) { |
| 5882 | if (allowOverrides === false && this._terms.has(entry.id)) { |
| 5883 | errors.push(new Error(`Attempt to override an existing term: "${entry.id}"`)); |
| 5884 | continue; |
| 5885 | } |
| 5886 | this._terms.set(entry.id, entry); |
| 5887 | } else { |
| 5888 | if (allowOverrides === false && this._messages.has(entry.id)) { |
| 5889 | errors.push(new Error(`Attempt to override an existing message: "${entry.id}"`)); |
| 5890 | continue; |
| 5891 | } |
| 5892 | this._messages.set(entry.id, entry); |
| 5893 | } |
| 5894 | } |
| 5895 | return errors; |
| 5896 | } |
| 5897 | formatPattern(pattern, args = null, errors = null) { |
| 5898 | if (typeof pattern === "string") { |
| 5899 | return this._transform(pattern); |
| 5900 | } |
| 5901 | let scope = new Scope(this, errors, args); |
| 5902 | try { |
| 5903 | let value = resolveComplexPattern(scope, pattern); |
| 5904 | return value.toString(scope); |
| 5905 | } catch (err) { |
| 5906 | if (scope.errors && err instanceof Error) { |
| 5907 | scope.errors.push(err); |
| 5908 | return new FluentNone().toString(scope); |
| 5909 | } |
| 5910 | throw err; |
| 5911 | } |
| 5912 | } |
| 5913 | } |
| 5914 | ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/resource.js |
| 5915 | |
| 5916 | const RE_MESSAGE_START = /^(-?[a-zA-Z][\w-]*) *= */gm; |
| 5917 | const RE_ATTRIBUTE_START = /\.([a-zA-Z][\w-]*) *= */y; |
| 5918 | const RE_VARIANT_START = /\*?\[/y; |
| 5919 | const RE_NUMBER_LITERAL = /(-?[0-9]+(?:\.([0-9]+))?)/y; |
| 5920 | const RE_IDENTIFIER = /([a-zA-Z][\w-]*)/y; |
| 5921 | const RE_REFERENCE = /([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y; |
| 5922 | const RE_FUNCTION_NAME = /^[A-Z][A-Z0-9_-]*$/; |
| 5923 | const RE_TEXT_RUN = /([^{}\n\r]+)/y; |
| 5924 | const RE_STRING_RUN = /([^\\"\n\r]*)/y; |
| 5925 | const RE_STRING_ESCAPE = /\\([\\"])/y; |
| 5926 | const RE_UNICODE_ESCAPE = /\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y; |
| 5927 | const RE_LEADING_NEWLINES = /^\n+/; |
| 5928 | const RE_TRAILING_SPACES = / +$/; |
| 5929 | const RE_BLANK_LINES = / *\r?\n/g; |
| 5930 | const RE_INDENT = /( *)$/; |
| 5931 | const TOKEN_BRACE_OPEN = /{\s*/y; |
| 5932 | const TOKEN_BRACE_CLOSE = /\s*}/y; |
| 5933 | const TOKEN_BRACKET_OPEN = /\[\s*/y; |
| 5934 | const TOKEN_BRACKET_CLOSE = /\s*] */y; |
| 5935 | const TOKEN_PAREN_OPEN = /\s*\(\s*/y; |
| 5936 | const TOKEN_ARROW = /\s*->\s*/y; |
| 5937 | const TOKEN_COLON = /\s*:\s*/y; |
| 5938 | const TOKEN_COMMA = /\s*,?\s*/y; |
| 5939 | const TOKEN_BLANK = /\s+/y; |
| 5940 | class FluentResource { |
| 5941 | constructor(source) { |
| 5942 | this.body = []; |
| 5943 | RE_MESSAGE_START.lastIndex = 0; |
| 5944 | let cursor = 0; |
| 5945 | while (true) { |
| 5946 | let next = RE_MESSAGE_START.exec(source); |
| 5947 | if (next === null) { |
| 5948 | break; |
| 5949 | } |
| 5950 | cursor = RE_MESSAGE_START.lastIndex; |
| 5951 | try { |
| 5952 | this.body.push(parseMessage(next[1])); |
| 5953 | } catch (err) { |
| 5954 | if (err instanceof SyntaxError) { |
| 5955 | continue; |
| 5956 | } |
| 5957 | throw err; |
| 5958 | } |
| 5959 | } |
| 5960 | function test(re) { |
| 5961 | re.lastIndex = cursor; |
| 5962 | return re.test(source); |
| 5963 | } |
| 5964 | function consumeChar(char, errorClass) { |
| 5965 | if (source[cursor] === char) { |
| 5966 | cursor++; |
| 5967 | return true; |
| 5968 | } |
| 5969 | if (errorClass) { |
| 5970 | throw new errorClass(`Expected ${char}`); |
| 5971 | } |
| 5972 | return false; |
| 5973 | } |
| 5974 | function consumeToken(re, errorClass) { |
| 5975 | if (test(re)) { |
| 5976 | cursor = re.lastIndex; |
| 5977 | return true; |
| 5978 | } |
| 5979 | if (errorClass) { |
| 5980 | throw new errorClass(`Expected ${re.toString()}`); |
| 5981 | } |
| 5982 | return false; |
| 5983 | } |
| 5984 | function match(re) { |
| 5985 | re.lastIndex = cursor; |
| 5986 | let result = re.exec(source); |
| 5987 | if (result === null) { |
| 5988 | throw new SyntaxError(`Expected ${re.toString()}`); |
| 5989 | } |
| 5990 | cursor = re.lastIndex; |
| 5991 | return result; |
| 5992 | } |
| 5993 | function match1(re) { |
| 5994 | return match(re)[1]; |
| 5995 | } |
| 5996 | function parseMessage(id) { |
| 5997 | let value = parsePattern(); |
| 5998 | let attributes = parseAttributes(); |
| 5999 | if (value === null && Object.keys(attributes).length === 0) { |
| 6000 | throw new SyntaxError("Expected message value or attributes"); |
| 6001 | } |
| 6002 | return { |
| 6003 | id, |
| 6004 | value, |
| 6005 | attributes |
| 6006 | }; |
| 6007 | } |
| 6008 | function parseAttributes() { |
| 6009 | let attrs = Object.create(null); |
| 6010 | while (test(RE_ATTRIBUTE_START)) { |
| 6011 | let name = match1(RE_ATTRIBUTE_START); |
| 6012 | let value = parsePattern(); |
| 6013 | if (value === null) { |
| 6014 | throw new SyntaxError("Expected attribute value"); |
| 6015 | } |
| 6016 | attrs[name] = value; |
| 6017 | } |
| 6018 | return attrs; |
| 6019 | } |
| 6020 | function parsePattern() { |
| 6021 | let first; |
| 6022 | if (test(RE_TEXT_RUN)) { |
| 6023 | first = match1(RE_TEXT_RUN); |
| 6024 | } |
| 6025 | if (source[cursor] === "{" || source[cursor] === "}") { |
| 6026 | return parsePatternElements(first ? [first] : [], Infinity); |
| 6027 | } |
| 6028 | let indent = parseIndent(); |
| 6029 | if (indent) { |
| 6030 | if (first) { |
| 6031 | return parsePatternElements([first, indent], indent.length); |
| 6032 | } |
| 6033 | indent.value = trim(indent.value, RE_LEADING_NEWLINES); |
| 6034 | return parsePatternElements([indent], indent.length); |
| 6035 | } |
| 6036 | if (first) { |
| 6037 | return trim(first, RE_TRAILING_SPACES); |
| 6038 | } |
| 6039 | return null; |
| 6040 | } |
| 6041 | function parsePatternElements(elements = [], commonIndent) { |
| 6042 | while (true) { |
| 6043 | if (test(RE_TEXT_RUN)) { |
| 6044 | elements.push(match1(RE_TEXT_RUN)); |
| 6045 | continue; |
| 6046 | } |
| 6047 | if (source[cursor] === "{") { |
| 6048 | elements.push(parsePlaceable()); |
| 6049 | continue; |
| 6050 | } |
| 6051 | if (source[cursor] === "}") { |
| 6052 | throw new SyntaxError("Unbalanced closing brace"); |
| 6053 | } |
| 6054 | let indent = parseIndent(); |
| 6055 | if (indent) { |
| 6056 | elements.push(indent); |
| 6057 | commonIndent = Math.min(commonIndent, indent.length); |
| 6058 | continue; |
| 6059 | } |
| 6060 | break; |
| 6061 | } |
| 6062 | let lastIndex = elements.length - 1; |
| 6063 | let lastElement = elements[lastIndex]; |
| 6064 | if (typeof lastElement === "string") { |
| 6065 | elements[lastIndex] = trim(lastElement, RE_TRAILING_SPACES); |
| 6066 | } |
| 6067 | let baked = []; |
| 6068 | for (let element of elements) { |
| 6069 | if (element instanceof Indent) { |
| 6070 | element = element.value.slice(0, element.value.length - commonIndent); |
| 6071 | } |
| 6072 | if (element) { |
| 6073 | baked.push(element); |
| 6074 | } |
| 6075 | } |
| 6076 | return baked; |
| 6077 | } |
| 6078 | function parsePlaceable() { |
| 6079 | consumeToken(TOKEN_BRACE_OPEN, SyntaxError); |
| 6080 | let selector = parseInlineExpression(); |
| 6081 | if (consumeToken(TOKEN_BRACE_CLOSE)) { |
| 6082 | return selector; |
| 6083 | } |
| 6084 | if (consumeToken(TOKEN_ARROW)) { |
| 6085 | let variants = parseVariants(); |
| 6086 | consumeToken(TOKEN_BRACE_CLOSE, SyntaxError); |
| 6087 | return { |
| 6088 | type: "select", |
| 6089 | selector, |
| 6090 | ...variants |
| 6091 | }; |
| 6092 | } |
| 6093 | throw new SyntaxError("Unclosed placeable"); |
| 6094 | } |
| 6095 | function parseInlineExpression() { |
| 6096 | if (source[cursor] === "{") { |
| 6097 | return parsePlaceable(); |
| 6098 | } |
| 6099 | if (test(RE_REFERENCE)) { |
| 6100 | let [, sigil, name, attr = null] = match(RE_REFERENCE); |
| 6101 | if (sigil === "$") { |
| 6102 | return { |
| 6103 | type: "var", |
| 6104 | name |
| 6105 | }; |
| 6106 | } |
| 6107 | if (consumeToken(TOKEN_PAREN_OPEN)) { |
| 6108 | let args = parseArguments(); |
| 6109 | if (sigil === "-") { |
| 6110 | return { |
| 6111 | type: "term", |
| 6112 | name, |
| 6113 | attr, |
| 6114 | args |
| 6115 | }; |
| 6116 | } |
| 6117 | if (RE_FUNCTION_NAME.test(name)) { |
| 6118 | return { |
| 6119 | type: "func", |
| 6120 | name, |
| 6121 | args |
| 6122 | }; |
| 6123 | } |
| 6124 | throw new SyntaxError("Function names must be all upper-case"); |
| 6125 | } |
| 6126 | if (sigil === "-") { |
| 6127 | return { |
| 6128 | type: "term", |
| 6129 | name, |
| 6130 | attr, |
| 6131 | args: [] |
| 6132 | }; |
| 6133 | } |
| 6134 | return { |
| 6135 | type: "mesg", |
| 6136 | name, |
| 6137 | attr |
| 6138 | }; |
| 6139 | } |
| 6140 | return parseLiteral(); |
| 6141 | } |
| 6142 | function parseArguments() { |
| 6143 | let args = []; |
| 6144 | while (true) { |
| 6145 | switch (source[cursor]) { |
| 6146 | case ")": |
| 6147 | cursor++; |
| 6148 | return args; |
| 6149 | case undefined: |
| 6150 | throw new SyntaxError("Unclosed argument list"); |
| 6151 | } |
| 6152 | args.push(parseArgument()); |
| 6153 | consumeToken(TOKEN_COMMA); |
| 6154 | } |
| 6155 | } |
| 6156 | function parseArgument() { |
| 6157 | let expr = parseInlineExpression(); |
| 6158 | if (expr.type !== "mesg") { |
| 6159 | return expr; |
| 6160 | } |
| 6161 | if (consumeToken(TOKEN_COLON)) { |
| 6162 | return { |
| 6163 | type: "narg", |
| 6164 | name: expr.name, |
| 6165 | value: parseLiteral() |
| 6166 | }; |
| 6167 | } |
| 6168 | return expr; |
| 6169 | } |
| 6170 | function parseVariants() { |
| 6171 | let variants = []; |
| 6172 | let count = 0; |
| 6173 | let star; |
| 6174 | while (test(RE_VARIANT_START)) { |
| 6175 | if (consumeChar("*")) { |
| 6176 | star = count; |
| 6177 | } |
| 6178 | let key = parseVariantKey(); |
| 6179 | let value = parsePattern(); |
| 6180 | if (value === null) { |
| 6181 | throw new SyntaxError("Expected variant value"); |
| 6182 | } |
| 6183 | variants[count++] = { |
| 6184 | key, |
| 6185 | value |
| 6186 | }; |
| 6187 | } |
| 6188 | if (count === 0) { |
| 6189 | return null; |
| 6190 | } |
| 6191 | if (star === undefined) { |
| 6192 | throw new SyntaxError("Expected default variant"); |
| 6193 | } |
| 6194 | return { |
| 6195 | variants, |
| 6196 | star |
| 6197 | }; |
| 6198 | } |
| 6199 | function parseVariantKey() { |
| 6200 | consumeToken(TOKEN_BRACKET_OPEN, SyntaxError); |
| 6201 | let key; |
| 6202 | if (test(RE_NUMBER_LITERAL)) { |
| 6203 | key = parseNumberLiteral(); |
| 6204 | } else { |
| 6205 | key = { |
| 6206 | type: "str", |
| 6207 | value: match1(RE_IDENTIFIER) |
| 6208 | }; |
| 6209 | } |
| 6210 | consumeToken(TOKEN_BRACKET_CLOSE, SyntaxError); |
| 6211 | return key; |
| 6212 | } |
| 6213 | function parseLiteral() { |
| 6214 | if (test(RE_NUMBER_LITERAL)) { |
| 6215 | return parseNumberLiteral(); |
| 6216 | } |
| 6217 | if (source[cursor] === '"') { |
| 6218 | return parseStringLiteral(); |
| 6219 | } |
| 6220 | throw new SyntaxError("Invalid expression"); |
| 6221 | } |
| 6222 | function parseNumberLiteral() { |
| 6223 | let [, value, fraction = ""] = match(RE_NUMBER_LITERAL); |
| 6224 | let precision = fraction.length; |
| 6225 | return { |
| 6226 | type: "num", |
| 6227 | value: parseFloat(value), |
| 6228 | precision |
| 6229 | }; |
| 6230 | } |
| 6231 | function parseStringLiteral() { |
| 6232 | consumeChar('"', SyntaxError); |
| 6233 | let value = ""; |
| 6234 | while (true) { |
| 6235 | value += match1(RE_STRING_RUN); |
| 6236 | if (source[cursor] === "\\") { |
| 6237 | value += parseEscapeSequence(); |
| 6238 | continue; |
| 6239 | } |
| 6240 | if (consumeChar('"')) { |
| 6241 | return { |
| 6242 | type: "str", |
| 6243 | value |
| 6244 | }; |
| 6245 | } |
| 6246 | throw new SyntaxError("Unclosed string literal"); |
| 6247 | } |
| 6248 | } |
| 6249 | function parseEscapeSequence() { |
| 6250 | if (test(RE_STRING_ESCAPE)) { |
| 6251 | return match1(RE_STRING_ESCAPE); |
| 6252 | } |
| 6253 | if (test(RE_UNICODE_ESCAPE)) { |
| 6254 | let [, codepoint4, codepoint6] = match(RE_UNICODE_ESCAPE); |
| 6255 | let codepoint = parseInt(codepoint4 || codepoint6, 16); |
| 6256 | return codepoint <= 0xd7ff || 0xe000 <= codepoint ? String.fromCodePoint(codepoint) : "�"; |
| 6257 | } |
| 6258 | throw new SyntaxError("Unknown escape sequence"); |
| 6259 | } |
| 6260 | function parseIndent() { |
| 6261 | let start = cursor; |
| 6262 | consumeToken(TOKEN_BLANK); |
| 6263 | switch (source[cursor]) { |
| 6264 | case ".": |
| 6265 | case "[": |
| 6266 | case "*": |
| 6267 | case "}": |
| 6268 | case undefined: |
| 6269 | return false; |
| 6270 | case "{": |
| 6271 | return makeIndent(source.slice(start, cursor)); |
| 6272 | } |
| 6273 | if (source[cursor - 1] === " ") { |
| 6274 | return makeIndent(source.slice(start, cursor)); |
| 6275 | } |
| 6276 | return false; |
| 6277 | } |
| 6278 | function trim(text, re) { |
| 6279 | return text.replace(re, ""); |
| 6280 | } |
| 6281 | function makeIndent(blank) { |
| 6282 | let value = blank.replace(RE_BLANK_LINES, "\n"); |
| 6283 | let length = RE_INDENT.exec(blank)[1].length; |
| 6284 | return new Indent(value, length); |
| 6285 | } |
| 6286 | } |
| 6287 | } |
| 6288 | class Indent { |
| 6289 | constructor(value, length) { |
| 6290 | this.value = value; |
| 6291 | this.length = length; |
| 6292 | } |
| 6293 | } |
| 6294 | ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/index.js |
| 6295 | |
| 6296 | |
| 6297 | |
| 6298 | // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.map.js |
| 6299 | var esnext_iterator_map = __webpack_require__(1454); |
| 6300 | ;// CONCATENATED MODULE: ./node_modules/@fluent/dom/esm/overlay.js |
| 6301 | |
| 6302 | const reOverlay = /<|&#?\w+;/; |
| 6303 | const TEXT_LEVEL_ELEMENTS = { |
| 6304 | "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"] |
| 6305 | }; |
| 6306 | const LOCALIZABLE_ATTRIBUTES = { |
| 6307 | "http://www.w3.org/1999/xhtml": { |
| 6308 | global: ["title", "aria-label", "aria-valuetext"], |
| 6309 | a: ["download"], |
| 6310 | area: ["download", "alt"], |
| 6311 | input: ["alt", "placeholder"], |
| 6312 | menuitem: ["label"], |
| 6313 | menu: ["label"], |
| 6314 | optgroup: ["label"], |
| 6315 | option: ["label"], |
| 6316 | track: ["label"], |
| 6317 | img: ["alt"], |
| 6318 | textarea: ["placeholder"], |
| 6319 | th: ["abbr"] |
| 6320 | }, |
| 6321 | "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul": { |
| 6322 | global: ["accesskey", "aria-label", "aria-valuetext", "label", "title", "tooltiptext"], |
| 6323 | description: ["value"], |
| 6324 | key: ["key", "keycode"], |
| 6325 | label: ["value"], |
| 6326 | textbox: ["placeholder", "value"] |
| 6327 | } |
| 6328 | }; |
| 6329 | function translateElement(element, translation) { |
| 6330 | const { |
| 6331 | value |
| 6332 | } = translation; |
| 6333 | if (typeof value === "string") { |
| 6334 | if (element.localName === "title" && element.namespaceURI === "http://www.w3.org/1999/xhtml") { |
| 6335 | element.textContent = value; |
| 6336 | } else if (!reOverlay.test(value)) { |
| 6337 | element.textContent = value; |
| 6338 | } else { |
| 6339 | const templateElement = element.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml", "template"); |
| 6340 | templateElement.innerHTML = value; |
| 6341 | overlayChildNodes(templateElement.content, element); |
| 6342 | } |
| 6343 | } |
| 6344 | overlayAttributes(translation, element); |
| 6345 | } |
| 6346 | function overlayChildNodes(fromFragment, toElement) { |
| 6347 | for (const childNode of fromFragment.childNodes) { |
| 6348 | if (childNode.nodeType === childNode.TEXT_NODE) { |
| 6349 | continue; |
| 6350 | } |
| 6351 | if (childNode.hasAttribute("data-l10n-name")) { |
| 6352 | const sanitized = getNodeForNamedElement(toElement, childNode); |
| 6353 | fromFragment.replaceChild(sanitized, childNode); |
| 6354 | continue; |
| 6355 | } |
| 6356 | if (isElementAllowed(childNode)) { |
| 6357 | const sanitized = createSanitizedElement(childNode); |
| 6358 | fromFragment.replaceChild(sanitized, childNode); |
| 6359 | continue; |
| 6360 | } |
| 6361 | 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."); |
| 6362 | fromFragment.replaceChild(createTextNodeFromTextContent(childNode), childNode); |
| 6363 | } |
| 6364 | toElement.textContent = ""; |
| 6365 | toElement.appendChild(fromFragment); |
| 6366 | } |
| 6367 | function hasAttribute(attributes, name) { |
| 6368 | if (!attributes) { |
| 6369 | return false; |
| 6370 | } |
| 6371 | for (let attr of attributes) { |
| 6372 | if (attr.name === name) { |
| 6373 | return true; |
| 6374 | } |
| 6375 | } |
| 6376 | return false; |
| 6377 | } |
| 6378 | function overlayAttributes(fromElement, toElement) { |
| 6379 | const explicitlyAllowed = toElement.hasAttribute("data-l10n-attrs") ? toElement.getAttribute("data-l10n-attrs").split(",").map(i => i.trim()) : null; |
| 6380 | for (const attr of Array.from(toElement.attributes)) { |
| 6381 | if (isAttrNameLocalizable(attr.name, toElement, explicitlyAllowed) && !hasAttribute(fromElement.attributes, attr.name)) { |
| 6382 | toElement.removeAttribute(attr.name); |
| 6383 | } |
| 6384 | } |
| 6385 | if (!fromElement.attributes) { |
| 6386 | return; |
| 6387 | } |
| 6388 | for (const attr of Array.from(fromElement.attributes)) { |
| 6389 | if (isAttrNameLocalizable(attr.name, toElement, explicitlyAllowed) && toElement.getAttribute(attr.name) !== attr.value) { |
| 6390 | toElement.setAttribute(attr.name, attr.value); |
| 6391 | } |
| 6392 | } |
| 6393 | } |
| 6394 | function getNodeForNamedElement(sourceElement, translatedChild) { |
| 6395 | const childName = translatedChild.getAttribute("data-l10n-name"); |
| 6396 | const sourceChild = sourceElement.querySelector(`[data-l10n-name="${childName}"]`); |
| 6397 | if (!sourceChild) { |
| 6398 | console.warn(`An element named "${childName}" wasn't found in the source.`); |
| 6399 | return createTextNodeFromTextContent(translatedChild); |
| 6400 | } |
| 6401 | if (sourceChild.localName !== translatedChild.localName) { |
| 6402 | 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}).`); |
| 6403 | return createTextNodeFromTextContent(translatedChild); |
| 6404 | } |
| 6405 | sourceElement.removeChild(sourceChild); |
| 6406 | const clone = sourceChild.cloneNode(false); |
| 6407 | return shallowPopulateUsing(translatedChild, clone); |
| 6408 | } |
| 6409 | function createSanitizedElement(element) { |
| 6410 | const clone = element.ownerDocument.createElement(element.localName); |
| 6411 | return shallowPopulateUsing(element, clone); |
| 6412 | } |
| 6413 | function createTextNodeFromTextContent(element) { |
| 6414 | return element.ownerDocument.createTextNode(element.textContent); |
| 6415 | } |
| 6416 | function isElementAllowed(element) { |
| 6417 | const allowed = TEXT_LEVEL_ELEMENTS[element.namespaceURI]; |
| 6418 | return allowed && allowed.includes(element.localName); |
| 6419 | } |
| 6420 | function isAttrNameLocalizable(name, element, explicitlyAllowed = null) { |
| 6421 | if (explicitlyAllowed && explicitlyAllowed.includes(name)) { |
| 6422 | return true; |
| 6423 | } |
| 6424 | const allowed = LOCALIZABLE_ATTRIBUTES[element.namespaceURI]; |
| 6425 | if (!allowed) { |
| 6426 | return false; |
| 6427 | } |
| 6428 | const attrName = name.toLowerCase(); |
| 6429 | const elemName = element.localName; |
| 6430 | if (allowed.global.includes(attrName)) { |
| 6431 | return true; |
| 6432 | } |
| 6433 | if (!allowed[elemName]) { |
| 6434 | return false; |
| 6435 | } |
| 6436 | if (allowed[elemName].includes(attrName)) { |
| 6437 | return true; |
| 6438 | } |
| 6439 | if (element.namespaceURI === "http://www.w3.org/1999/xhtml" && elemName === "input" && attrName === "value") { |
| 6440 | const type = element.type.toLowerCase(); |
| 6441 | if (type === "submit" || type === "button" || type === "reset") { |
| 6442 | return true; |
| 6443 | } |
| 6444 | } |
| 6445 | return false; |
| 6446 | } |
| 6447 | function shallowPopulateUsing(fromElement, toElement) { |
| 6448 | toElement.textContent = fromElement.textContent; |
| 6449 | overlayAttributes(fromElement, toElement); |
| 6450 | return toElement; |
| 6451 | } |
| 6452 | // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.filter.js |
| 6453 | var esnext_iterator_filter = __webpack_require__(4520); |
| 6454 | // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.for-each.js |
| 6455 | var esnext_iterator_for_each = __webpack_require__(3949); |
| 6456 | ;// CONCATENATED MODULE: ./node_modules/cached-iterable/src/cached_iterable.js |
| 6457 | class CachedIterable extends Array { |
| 6458 | static from(iterable) { |
| 6459 | if (iterable instanceof this) { |
| 6460 | return iterable; |
| 6461 | } |
| 6462 | return new this(iterable); |
| 6463 | } |
| 6464 | } |
| 6465 | ;// CONCATENATED MODULE: ./node_modules/cached-iterable/src/cached_sync_iterable.js |
| 6466 | |
| 6467 | |
| 6468 | class CachedSyncIterable extends CachedIterable { |
| 6469 | constructor(iterable) { |
| 6470 | super(); |
| 6471 | if (Symbol.iterator in Object(iterable)) { |
| 6472 | this.iterator = iterable[Symbol.iterator](); |
| 6473 | } else { |
| 6474 | throw new TypeError("Argument must implement the iteration protocol."); |
| 6475 | } |
| 6476 | } |
| 6477 | [Symbol.iterator]() { |
| 6478 | const cached = this; |
| 6479 | let cur = 0; |
| 6480 | return { |
| 6481 | next() { |
| 6482 | if (cached.length <= cur) { |
| 6483 | cached.push(cached.iterator.next()); |
| 6484 | } |
| 6485 | return cached[cur++]; |
| 6486 | } |
| 6487 | }; |
| 6488 | } |
| 6489 | touchNext(count = 1) { |
| 6490 | let idx = 0; |
| 6491 | while (idx++ < count) { |
| 6492 | const last = this[this.length - 1]; |
| 6493 | if (last && last.done) { |
| 6494 | break; |
| 6495 | } |
| 6496 | this.push(this.iterator.next()); |
| 6497 | } |
| 6498 | return this[this.length - 1]; |
| 6499 | } |
| 6500 | } |
| 6501 | ;// CONCATENATED MODULE: ./node_modules/cached-iterable/src/cached_async_iterable.js |
| 6502 | |
| 6503 | |
| 6504 | class CachedAsyncIterable extends CachedIterable { |
| 6505 | constructor(iterable) { |
| 6506 | super(); |
| 6507 | if (Symbol.asyncIterator in Object(iterable)) { |
| 6508 | this.iterator = iterable[Symbol.asyncIterator](); |
| 6509 | } else if (Symbol.iterator in Object(iterable)) { |
| 6510 | this.iterator = iterable[Symbol.iterator](); |
| 6511 | } else { |
| 6512 | throw new TypeError("Argument must implement the iteration protocol."); |
| 6513 | } |
| 6514 | } |
| 6515 | [Symbol.asyncIterator]() { |
| 6516 | const cached = this; |
| 6517 | let cur = 0; |
| 6518 | return { |
| 6519 | async next() { |
| 6520 | if (cached.length <= cur) { |
| 6521 | cached.push(cached.iterator.next()); |
| 6522 | } |
| 6523 | return cached[cur++]; |
| 6524 | } |
| 6525 | }; |
| 6526 | } |
| 6527 | async touchNext(count = 1) { |
| 6528 | let idx = 0; |
| 6529 | while (idx++ < count) { |
| 6530 | const last = this[this.length - 1]; |
| 6531 | if (last && (await last).done) { |
| 6532 | break; |
| 6533 | } |
| 6534 | this.push(this.iterator.next()); |
| 6535 | } |
| 6536 | return this[this.length - 1]; |
| 6537 | } |
| 6538 | } |
| 6539 | ;// CONCATENATED MODULE: ./node_modules/cached-iterable/src/index.js |
| 6540 | |
| 6541 | |
| 6542 | ;// CONCATENATED MODULE: ./node_modules/@fluent/dom/esm/localization.js |
| 6543 | |
| 6544 | |
| 6545 | |
| 6546 | |
| 6547 | |
| 6548 | |
| 6549 | |
| 6550 | |
| 6551 | |
| 6552 | |
| 6553 | |
| 6554 | |
| 6555 | class Localization { |
| 6556 | constructor(resourceIds = [], generateBundles) { |
| 6557 | this.resourceIds = resourceIds; |
| 6558 | this.generateBundles = generateBundles; |
| 6559 | this.onChange(true); |
| 6560 | } |
| 6561 | addResourceIds(resourceIds, eager = false) { |
| 6562 | this.resourceIds.push(...resourceIds); |
| 6563 | this.onChange(eager); |
| 6564 | return this.resourceIds.length; |
| 6565 | } |
| 6566 | removeResourceIds(resourceIds) { |
| 6567 | this.resourceIds = this.resourceIds.filter(r => !resourceIds.includes(r)); |
| 6568 | this.onChange(); |
| 6569 | return this.resourceIds.length; |
| 6570 | } |
| 6571 | async formatWithFallback(keys, method) { |
| 6572 | const translations = []; |
| 6573 | let hasAtLeastOneBundle = false; |
| 6574 | for await (const bundle of this.bundles) { |
| 6575 | hasAtLeastOneBundle = true; |
| 6576 | const missingIds = keysFromBundle(method, bundle, keys, translations); |
| 6577 | if (missingIds.size === 0) { |
| 6578 | break; |
| 6579 | } |
| 6580 | if (typeof console !== "undefined") { |
| 6581 | const locale = bundle.locales[0]; |
| 6582 | const ids = Array.from(missingIds).join(", "); |
| 6583 | console.warn(`[fluent] Missing translations in ${locale}: ${ids}`); |
| 6584 | } |
| 6585 | } |
| 6586 | if (!hasAtLeastOneBundle && typeof console !== "undefined") { |
| 6587 | console.warn(`[fluent] Request for keys failed because no resource bundles got generated. |
| 6588 | keys: ${JSON.stringify(keys)}. |
| 6589 | resourceIds: ${JSON.stringify(this.resourceIds)}.`); |
| 6590 | } |
| 6591 | return translations; |
| 6592 | } |
| 6593 | formatMessages(keys) { |
| 6594 | return this.formatWithFallback(keys, messageFromBundle); |
| 6595 | } |
| 6596 | formatValues(keys) { |
| 6597 | return this.formatWithFallback(keys, valueFromBundle); |
| 6598 | } |
| 6599 | async formatValue(id, args) { |
| 6600 | const [val] = await this.formatValues([{ |
| 6601 | id, |
| 6602 | args |
| 6603 | }]); |
| 6604 | return val; |
| 6605 | } |
| 6606 | handleEvent() { |
| 6607 | this.onChange(); |
| 6608 | } |
| 6609 | onChange(eager = false) { |
| 6610 | this.bundles = CachedAsyncIterable.from(this.generateBundles(this.resourceIds)); |
| 6611 | if (eager) { |
| 6612 | this.bundles.touchNext(2); |
| 6613 | } |
| 6614 | } |
| 6615 | } |
| 6616 | function valueFromBundle(bundle, errors, message, args) { |
| 6617 | if (message.value) { |
| 6618 | return bundle.formatPattern(message.value, args, errors); |
| 6619 | } |
| 6620 | return null; |
| 6621 | } |
| 6622 | function messageFromBundle(bundle, errors, message, args) { |
| 6623 | const formatted = { |
| 6624 | value: null, |
| 6625 | attributes: null |
| 6626 | }; |
| 6627 | if (message.value) { |
| 6628 | formatted.value = bundle.formatPattern(message.value, args, errors); |
| 6629 | } |
| 6630 | let attrNames = Object.keys(message.attributes); |
| 6631 | if (attrNames.length > 0) { |
| 6632 | formatted.attributes = new Array(attrNames.length); |
| 6633 | for (let [i, name] of attrNames.entries()) { |
| 6634 | let value = bundle.formatPattern(message.attributes[name], args, errors); |
| 6635 | formatted.attributes[i] = { |
| 6636 | name, |
| 6637 | value |
| 6638 | }; |
| 6639 | } |
| 6640 | } |
| 6641 | return formatted; |
| 6642 | } |
| 6643 | function keysFromBundle(method, bundle, keys, translations) { |
| 6644 | const messageErrors = []; |
| 6645 | const missingIds = new Set(); |
| 6646 | keys.forEach(({ |
| 6647 | id, |
| 6648 | args |
| 6649 | }, i) => { |
| 6650 | if (translations[i] !== undefined) { |
| 6651 | return; |
| 6652 | } |
| 6653 | let message = bundle.getMessage(id); |
| 6654 | if (message) { |
| 6655 | messageErrors.length = 0; |
| 6656 | translations[i] = method(bundle, messageErrors, message, args); |
| 6657 | if (messageErrors.length > 0 && typeof console !== "undefined") { |
| 6658 | const locale = bundle.locales[0]; |
| 6659 | const errors = messageErrors.join(", "); |
| 6660 | console.warn(`[fluent][resolver] errors in ${locale}/${id}: ${errors}.`); |
| 6661 | } |
| 6662 | } else { |
| 6663 | missingIds.add(id); |
| 6664 | } |
| 6665 | }); |
| 6666 | return missingIds; |
| 6667 | } |
| 6668 | ;// CONCATENATED MODULE: ./node_modules/@fluent/dom/esm/dom_localization.js |
| 6669 | |
| 6670 | |
| 6671 | |
| 6672 | |
| 6673 | |
| 6674 | |
| 6675 | |
| 6676 | |
| 6677 | |
| 6678 | |
| 6679 | |
| 6680 | |
| 6681 | const L10NID_ATTR_NAME = "data-l10n-id"; |
| 6682 | const L10NARGS_ATTR_NAME = "data-l10n-args"; |
| 6683 | const L10N_ELEMENT_QUERY = `[${L10NID_ATTR_NAME}]`; |
| 6684 | class DOMLocalization extends Localization { |
| 6685 | constructor(resourceIds, generateBundles) { |
| 6686 | super(resourceIds, generateBundles); |
| 6687 | this.roots = new Set(); |
| 6688 | this.pendingrAF = null; |
| 6689 | this.pendingElements = new Set(); |
| 6690 | this.windowElement = null; |
| 6691 | this.mutationObserver = null; |
| 6692 | this.observerConfig = { |
| 6693 | attributes: true, |
| 6694 | characterData: false, |
| 6695 | childList: true, |
| 6696 | subtree: true, |
| 6697 | attributeFilter: [L10NID_ATTR_NAME, L10NARGS_ATTR_NAME] |
| 6698 | }; |
| 6699 | } |
| 6700 | onChange(eager = false) { |
| 6701 | super.onChange(eager); |
| 6702 | if (this.roots) { |
| 6703 | this.translateRoots(); |
| 6704 | } |
| 6705 | } |
| 6706 | setAttributes(element, id, args) { |
| 6707 | element.setAttribute(L10NID_ATTR_NAME, id); |
| 6708 | if (args) { |
| 6709 | element.setAttribute(L10NARGS_ATTR_NAME, JSON.stringify(args)); |
| 6710 | } else { |
| 6711 | element.removeAttribute(L10NARGS_ATTR_NAME); |
| 6712 | } |
| 6713 | return element; |
| 6714 | } |
| 6715 | getAttributes(element) { |
| 6716 | return { |
| 6717 | id: element.getAttribute(L10NID_ATTR_NAME), |
| 6718 | args: JSON.parse(element.getAttribute(L10NARGS_ATTR_NAME) || null) |
| 6719 | }; |
| 6720 | } |
| 6721 | connectRoot(newRoot) { |
| 6722 | for (const root of this.roots) { |
| 6723 | if (root === newRoot || root.contains(newRoot) || newRoot.contains(root)) { |
| 6724 | throw new Error("Cannot add a root that overlaps with existing root."); |
| 6725 | } |
| 6726 | } |
| 6727 | if (this.windowElement) { |
| 6728 | if (this.windowElement !== newRoot.ownerDocument.defaultView) { |
| 6729 | throw new Error(`Cannot connect a root: |
| 6730 | DOMLocalization already has a root from a different window.`); |
| 6731 | } |
| 6732 | } else { |
| 6733 | this.windowElement = newRoot.ownerDocument.defaultView; |
| 6734 | this.mutationObserver = new this.windowElement.MutationObserver(mutations => this.translateMutations(mutations)); |
| 6735 | } |
| 6736 | this.roots.add(newRoot); |
| 6737 | this.mutationObserver.observe(newRoot, this.observerConfig); |
| 6738 | } |
| 6739 | disconnectRoot(root) { |
| 6740 | this.roots.delete(root); |
| 6741 | this.pauseObserving(); |
| 6742 | if (this.roots.size === 0) { |
| 6743 | this.mutationObserver = null; |
| 6744 | this.windowElement = null; |
| 6745 | this.pendingrAF = null; |
| 6746 | this.pendingElements.clear(); |
| 6747 | return true; |
| 6748 | } |
| 6749 | this.resumeObserving(); |
| 6750 | return false; |
| 6751 | } |
| 6752 | translateRoots() { |
| 6753 | const roots = Array.from(this.roots); |
| 6754 | return Promise.all(roots.map(root => this.translateFragment(root))); |
| 6755 | } |
| 6756 | pauseObserving() { |
| 6757 | if (!this.mutationObserver) { |
| 6758 | return; |
| 6759 | } |
| 6760 | this.translateMutations(this.mutationObserver.takeRecords()); |
| 6761 | this.mutationObserver.disconnect(); |
| 6762 | } |
| 6763 | resumeObserving() { |
| 6764 | if (!this.mutationObserver) { |
| 6765 | return; |
| 6766 | } |
| 6767 | for (const root of this.roots) { |
| 6768 | this.mutationObserver.observe(root, this.observerConfig); |
| 6769 | } |
| 6770 | } |
| 6771 | translateMutations(mutations) { |
| 6772 | for (const mutation of mutations) { |
| 6773 | switch (mutation.type) { |
| 6774 | case "attributes": |
| 6775 | if (mutation.target.hasAttribute("data-l10n-id")) { |
| 6776 | this.pendingElements.add(mutation.target); |
| 6777 | } |
| 6778 | break; |
| 6779 | case "childList": |
| 6780 | for (const addedNode of mutation.addedNodes) { |
| 6781 | if (addedNode.nodeType === addedNode.ELEMENT_NODE) { |
| 6782 | if (addedNode.childElementCount) { |
| 6783 | for (const element of this.getTranslatables(addedNode)) { |
| 6784 | this.pendingElements.add(element); |
| 6785 | } |
| 6786 | } else if (addedNode.hasAttribute(L10NID_ATTR_NAME)) { |
| 6787 | this.pendingElements.add(addedNode); |
| 6788 | } |
| 6789 | } |
| 6790 | } |
| 6791 | break; |
| 6792 | } |
| 6793 | } |
| 6794 | if (this.pendingElements.size > 0) { |
| 6795 | if (this.pendingrAF === null) { |
| 6796 | this.pendingrAF = this.windowElement.requestAnimationFrame(() => { |
| 6797 | this.translateElements(Array.from(this.pendingElements)); |
| 6798 | this.pendingElements.clear(); |
| 6799 | this.pendingrAF = null; |
| 6800 | }); |
| 6801 | } |
| 6802 | } |
| 6803 | } |
| 6804 | translateFragment(frag) { |
| 6805 | return this.translateElements(this.getTranslatables(frag)); |
| 6806 | } |
| 6807 | async translateElements(elements) { |
| 6808 | if (!elements.length) { |
| 6809 | return undefined; |
| 6810 | } |
| 6811 | const keys = elements.map(this.getKeysForElement); |
| 6812 | const translations = await this.formatMessages(keys); |
| 6813 | return this.applyTranslations(elements, translations); |
| 6814 | } |
| 6815 | applyTranslations(elements, translations) { |
| 6816 | this.pauseObserving(); |
| 6817 | for (let i = 0; i < elements.length; i++) { |
| 6818 | if (translations[i] !== undefined) { |
| 6819 | translateElement(elements[i], translations[i]); |
| 6820 | } |
| 6821 | } |
| 6822 | this.resumeObserving(); |
| 6823 | } |
| 6824 | getTranslatables(element) { |
| 6825 | const nodes = Array.from(element.querySelectorAll(L10N_ELEMENT_QUERY)); |
| 6826 | if (typeof element.hasAttribute === "function" && element.hasAttribute(L10NID_ATTR_NAME)) { |
| 6827 | nodes.push(element); |
| 6828 | } |
| 6829 | return nodes; |
| 6830 | } |
| 6831 | getKeysForElement(element) { |
| 6832 | return { |
| 6833 | id: element.getAttribute(L10NID_ATTR_NAME), |
| 6834 | args: JSON.parse(element.getAttribute(L10NARGS_ATTR_NAME) || null) |
| 6835 | }; |
| 6836 | } |
| 6837 | } |
| 6838 | ;// CONCATENATED MODULE: ./node_modules/@fluent/dom/esm/index.js |
| 6839 | |
| 6840 | |
| 6841 | ;// CONCATENATED MODULE: ./web/l10n.js |
| 6842 | |
| 6843 | class L10n { |
| 6844 | #dir; |
| 6845 | #lang; |
| 6846 | #l10n; |
| 6847 | constructor({ |
| 6848 | lang, |
| 6849 | isRTL |
| 6850 | }, l10n = null) { |
| 6851 | this.#lang = L10n.#fixupLangCode(lang); |
| 6852 | this.#l10n = l10n; |
| 6853 | this.#dir = isRTL ?? L10n.#isRTL(this.#lang) ? "rtl" : "ltr"; |
| 6854 | } |
| 6855 | _setL10n(l10n) { |
| 6856 | this.#l10n = l10n; |
| 6857 | } |
| 6858 | getLanguage() { |
| 6859 | return this.#lang; |
| 6860 | } |
| 6861 | getDirection() { |
| 6862 | return this.#dir; |
| 6863 | } |
| 6864 | async get(ids, args = null, fallback) { |
| 6865 | if (Array.isArray(ids)) { |
| 6866 | ids = ids.map(id => ({ |
| 6867 | id |
| 6868 | })); |
| 6869 | const messages = await this.#l10n.formatMessages(ids); |
| 6870 | return messages.map(message => message.value); |
| 6871 | } |
| 6872 | const messages = await this.#l10n.formatMessages([{ |
| 6873 | id: ids, |
| 6874 | args |
| 6875 | }]); |
| 6876 | return messages?.[0].value || fallback; |
| 6877 | } |
| 6878 | async translate(element) { |
| 6879 | try { |
| 6880 | this.#l10n.connectRoot(element); |
| 6881 | await this.#l10n.translateRoots(); |
| 6882 | } catch {} |
| 6883 | } |
| 6884 | pause() { |
| 6885 | this.#l10n.pauseObserving(); |
| 6886 | } |
| 6887 | resume() { |
| 6888 | this.#l10n.resumeObserving(); |
| 6889 | } |
| 6890 | static #fixupLangCode(langCode) { |
| 6891 | langCode = langCode?.toLowerCase() || "en-us"; |
| 6892 | const PARTIAL_LANG_CODES = { |
| 6893 | en: "en-us", |
| 6894 | es: "es-es", |
| 6895 | fy: "fy-nl", |
| 6896 | ga: "ga-ie", |
| 6897 | gu: "gu-in", |
| 6898 | hi: "hi-in", |
| 6899 | hy: "hy-am", |
| 6900 | nb: "nb-no", |
| 6901 | ne: "ne-np", |
| 6902 | nn: "nn-no", |
| 6903 | pa: "pa-in", |
| 6904 | pt: "pt-pt", |
| 6905 | sv: "sv-se", |
| 6906 | zh: "zh-cn" |
| 6907 | }; |
| 6908 | return PARTIAL_LANG_CODES[langCode] || langCode; |
| 6909 | } |
| 6910 | static #isRTL(lang) { |
| 6911 | const shortCode = lang.split("-", 1)[0]; |
| 6912 | return ["ar", "he", "fa", "ps", "ur"].includes(shortCode); |
| 6913 | } |
| 6914 | } |
| 6915 | const GenericL10n = null; |
| 6916 | |
| 6917 | ;// CONCATENATED MODULE: ./web/genericl10n.js |
| 6918 | |
| 6919 | |
| 6920 | |
| 6921 | |
| 6922 | |
| 6923 | |
| 6924 | |
| 6925 | |
| 6926 | function createBundle(lang, text) { |
| 6927 | const resource = new FluentResource(text); |
| 6928 | const bundle = new FluentBundle(lang); |
| 6929 | const errors = bundle.addResource(resource); |
| 6930 | if (errors.length) { |
| 6931 | console.error("L10n errors", errors); |
| 6932 | } |
| 6933 | return bundle; |
| 6934 | } |
| 6935 | class genericl10n_GenericL10n extends L10n { |
| 6936 | constructor(lang) { |
| 6937 | super({ |
| 6938 | lang |
| 6939 | }); |
| 6940 | const generateBundles = !lang ? genericl10n_GenericL10n.#generateBundlesFallback.bind(genericl10n_GenericL10n, this.getLanguage()) : genericl10n_GenericL10n.#generateBundles.bind(genericl10n_GenericL10n, "en-us", this.getLanguage()); |
| 6941 | this._setL10n(new DOMLocalization([], generateBundles)); |
| 6942 | } |
| 6943 | static async *#generateBundles(defaultLang, baseLang) { |
| 6944 | const { |
| 6945 | baseURL, |
| 6946 | paths |
| 6947 | } = await this.#getPaths(); |
| 6948 | const langs = [baseLang]; |
| 6949 | if (defaultLang !== baseLang) { |
| 6950 | const shortLang = baseLang.split("-", 1)[0]; |
| 6951 | if (shortLang !== baseLang) { |
| 6952 | langs.push(shortLang); |
| 6953 | } |
| 6954 | langs.push(defaultLang); |
| 6955 | } |
| 6956 | for (const lang of langs) { |
| 6957 | const bundle = await this.#createBundle(lang, baseURL, paths); |
| 6958 | if (bundle) { |
| 6959 | yield bundle; |
| 6960 | } |
| 6961 | if (lang === "en-us") { |
| 6962 | yield this.#createBundleFallback(lang); |
| 6963 | } |
| 6964 | } |
| 6965 | } |
| 6966 | static async #createBundle(lang, baseURL, paths) { |
| 6967 | const path = paths[lang]; |
| 6968 | if (!path) { |
| 6969 | return null; |
| 6970 | } |
| 6971 | const url = new URL(path, baseURL); |
| 6972 | const text = await fetchData(url, "text"); |
| 6973 | return createBundle(lang, text); |
| 6974 | } |
| 6975 | static async #getPaths() { |
| 6976 | try { |
| 6977 | const { |
| 6978 | href |
| 6979 | } = document.querySelector(`link[type="application/l10n"]`); |
| 6980 | const paths = await fetchData(href, "json"); |
| 6981 | return { |
| 6982 | baseURL: href.replace(/[^/]*$/, "") || "./", |
| 6983 | paths |
| 6984 | }; |
| 6985 | } catch {} |
| 6986 | return { |
| 6987 | baseURL: "./", |
| 6988 | paths: Object.create(null) |
| 6989 | }; |
| 6990 | } |
| 6991 | static async *#generateBundlesFallback(lang) { |
| 6992 | yield this.#createBundleFallback(lang); |
| 6993 | } |
| 6994 | static async #createBundleFallback(lang) { |
| 6995 | 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-kb = { $size_kb } KB ({ $size_b } bytes)\npdfjs-document-properties-mb = { $size_mb } MB ({ $size_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-string = { $date }, { $time }\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-toggle-sidebar-button =\n .title = Toggle Sidebar\npdfjs-toggle-sidebar-notification-button =\n .title = Toggle Sidebar (document contains outline/attachments/layers)\npdfjs-toggle-sidebar-button-label = Toggle Sidebar\npdfjs-document-outline-button =\n .title = Show Document Outline (double-click to expand/collapse all items)\npdfjs-document-outline-button-label = Document Outline\npdfjs-attachments-button =\n .title = Show Attachments\npdfjs-attachments-button-label = Attachments\npdfjs-layers-button =\n .title = Show Layers (double-click to reset all layers to the default state)\npdfjs-layers-button-label = Layers\npdfjs-thumbs-button =\n .title = Show Thumbnails\npdfjs-thumbs-button-label = Thumbnails\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-title =\n .title = Page { $page }\npdfjs-thumb-page-canvas =\n .aria-label = Thumbnail of 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-string = { $date }, { $time }\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-free-text-button-label = Text\npdfjs-editor-ink-button =\n .title = Draw\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-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-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-free-text =\n .aria-label = Text Editor\npdfjs-free-text-default-content = Start typing\u2026\npdfjs-ink =\n .aria-label = Draw Editor\npdfjs-ink-canvas =\n .aria-label = User-created image\npdfjs-editor-alt-text-button-label = Alt text\npdfjs-editor-alt-text-edit-button-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-label-top-left = Top left corner \u2014 resize\npdfjs-editor-resizer-label-top-middle = Top middle \u2014 resize\npdfjs-editor-resizer-label-top-right = Top right corner \u2014 resize\npdfjs-editor-resizer-label-middle-right = Middle right \u2014 resize\npdfjs-editor-resizer-label-bottom-right = Bottom right corner \u2014 resize\npdfjs-editor-resizer-label-bottom-middle = Bottom middle \u2014 resize\npdfjs-editor-resizer-label-bottom-left = Bottom left corner \u2014 resize\npdfjs-editor-resizer-label-middle-left = 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"; |
| 6996 | return createBundle(lang, text); |
| 6997 | } |
| 6998 | } |
| 6999 | |
| 7000 | ;// CONCATENATED MODULE: ./web/generic_scripting.js |
| 7001 | |
| 7002 | async function docProperties(pdfDocument) { |
| 7003 | const url = "", |
| 7004 | baseUrl = url.split("#", 1)[0]; |
| 7005 | let { |
| 7006 | info, |
| 7007 | metadata, |
| 7008 | contentDispositionFilename, |
| 7009 | contentLength |
| 7010 | } = await pdfDocument.getMetadata(); |
| 7011 | if (!contentLength) { |
| 7012 | const { |
| 7013 | length |
| 7014 | } = await pdfDocument.getDownloadInfo(); |
| 7015 | contentLength = length; |
| 7016 | } |
| 7017 | return { |
| 7018 | ...info, |
| 7019 | baseURL: baseUrl, |
| 7020 | filesize: contentLength, |
| 7021 | filename: contentDispositionFilename || getPdfFilenameFromUrl(url), |
| 7022 | metadata: metadata?.getRaw(), |
| 7023 | authors: metadata?.get("dc:creator"), |
| 7024 | numPages: pdfDocument.numPages, |
| 7025 | URL: url |
| 7026 | }; |
| 7027 | } |
| 7028 | class GenericScripting { |
| 7029 | constructor(sandboxBundleSrc) { |
| 7030 | this._ready = new Promise((resolve, reject) => { |
| 7031 | const sandbox = import( /*webpackIgnore: true*/sandboxBundleSrc); |
| 7032 | sandbox.then(pdfjsSandbox => { |
| 7033 | resolve(pdfjsSandbox.QuickJSSandbox()); |
| 7034 | }).catch(reject); |
| 7035 | }); |
| 7036 | } |
| 7037 | async createSandbox(data) { |
| 7038 | const sandbox = await this._ready; |
| 7039 | sandbox.create(data); |
| 7040 | } |
| 7041 | async dispatchEventInSandbox(event) { |
| 7042 | const sandbox = await this._ready; |
| 7043 | setTimeout(() => sandbox.dispatchEvent(event), 0); |
| 7044 | } |
| 7045 | async destroySandbox() { |
| 7046 | const sandbox = await this._ready; |
| 7047 | sandbox.nukeSandbox(); |
| 7048 | } |
| 7049 | } |
| 7050 | |
| 7051 | ;// CONCATENATED MODULE: ./web/genericcom.js |
| 7052 | |
| 7053 | |
| 7054 | |
| 7055 | |
| 7056 | |
| 7057 | |
| 7058 | function initCom(app) {} |
| 7059 | class Preferences extends BasePreferences { |
| 7060 | async _writeToStorage(prefObj) { |
| 7061 | localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj)); |
| 7062 | } |
| 7063 | async _readFromStorage(prefObj) { |
| 7064 | return { |
| 7065 | prefs: JSON.parse(localStorage.getItem("pdfjs.preferences")) |
| 7066 | }; |
| 7067 | } |
| 7068 | } |
| 7069 | class ExternalServices extends BaseExternalServices { |
| 7070 | async createL10n() { |
| 7071 | return new genericl10n_GenericL10n(AppOptions.get("locale")); |
| 7072 | } |
| 7073 | createScripting() { |
| 7074 | return new GenericScripting(AppOptions.get("sandboxBundleSrc")); |
| 7075 | } |
| 7076 | } |
| 7077 | class MLManager { |
| 7078 | async guess() { |
| 7079 | return null; |
| 7080 | } |
| 7081 | } |
| 7082 | |
| 7083 | ;// CONCATENATED MODULE: ./web/alt_text_manager.js |
| 7084 | |
| 7085 | class AltTextManager { |
| 7086 | #boundUpdateUIState = this.#updateUIState.bind(this); |
| 7087 | #boundSetPosition = this.#setPosition.bind(this); |
| 7088 | #boundOnClick = this.#onClick.bind(this); |
| 7089 | #currentEditor = null; |
| 7090 | #cancelButton; |
| 7091 | #dialog; |
| 7092 | #eventBus; |
| 7093 | #hasUsedPointer = false; |
| 7094 | #optionDescription; |
| 7095 | #optionDecorative; |
| 7096 | #overlayManager; |
| 7097 | #saveButton; |
| 7098 | #textarea; |
| 7099 | #uiManager; |
| 7100 | #previousAltText = null; |
| 7101 | #svgElement = null; |
| 7102 | #rectElement = null; |
| 7103 | #container; |
| 7104 | #telemetryData = null; |
| 7105 | constructor({ |
| 7106 | dialog, |
| 7107 | optionDescription, |
| 7108 | optionDecorative, |
| 7109 | textarea, |
| 7110 | cancelButton, |
| 7111 | saveButton |
| 7112 | }, container, overlayManager, eventBus) { |
| 7113 | this.#dialog = dialog; |
| 7114 | this.#optionDescription = optionDescription; |
| 7115 | this.#optionDecorative = optionDecorative; |
| 7116 | this.#textarea = textarea; |
| 7117 | this.#cancelButton = cancelButton; |
| 7118 | this.#saveButton = saveButton; |
| 7119 | this.#overlayManager = overlayManager; |
| 7120 | this.#eventBus = eventBus; |
| 7121 | this.#container = container; |
| 7122 | dialog.addEventListener("close", this.#close.bind(this)); |
| 7123 | dialog.addEventListener("contextmenu", event => { |
| 7124 | if (event.target !== this.#textarea) { |
| 7125 | event.preventDefault(); |
| 7126 | } |
| 7127 | }); |
| 7128 | cancelButton.addEventListener("click", this.#finish.bind(this)); |
| 7129 | saveButton.addEventListener("click", this.#save.bind(this)); |
| 7130 | optionDescription.addEventListener("change", this.#boundUpdateUIState); |
| 7131 | optionDecorative.addEventListener("change", this.#boundUpdateUIState); |
| 7132 | this.#overlayManager.register(dialog); |
| 7133 | } |
| 7134 | get _elements() { |
| 7135 | return shadow(this, "_elements", [this.#optionDescription, this.#optionDecorative, this.#textarea, this.#saveButton, this.#cancelButton]); |
| 7136 | } |
| 7137 | #createSVGElement() { |
| 7138 | if (this.#svgElement) { |
| 7139 | return; |
| 7140 | } |
| 7141 | const svgFactory = new DOMSVGFactory(); |
| 7142 | const svg = this.#svgElement = svgFactory.createElement("svg"); |
| 7143 | svg.setAttribute("width", "0"); |
| 7144 | svg.setAttribute("height", "0"); |
| 7145 | const defs = svgFactory.createElement("defs"); |
| 7146 | svg.append(defs); |
| 7147 | const mask = svgFactory.createElement("mask"); |
| 7148 | defs.append(mask); |
| 7149 | mask.setAttribute("id", "alttext-manager-mask"); |
| 7150 | mask.setAttribute("maskContentUnits", "objectBoundingBox"); |
| 7151 | let rect = svgFactory.createElement("rect"); |
| 7152 | mask.append(rect); |
| 7153 | rect.setAttribute("fill", "white"); |
| 7154 | rect.setAttribute("width", "1"); |
| 7155 | rect.setAttribute("height", "1"); |
| 7156 | rect.setAttribute("x", "0"); |
| 7157 | rect.setAttribute("y", "0"); |
| 7158 | rect = this.#rectElement = svgFactory.createElement("rect"); |
| 7159 | mask.append(rect); |
| 7160 | rect.setAttribute("fill", "black"); |
| 7161 | this.#dialog.append(svg); |
| 7162 | } |
| 7163 | async editAltText(uiManager, editor) { |
| 7164 | if (this.#currentEditor || !editor) { |
| 7165 | return; |
| 7166 | } |
| 7167 | this.#createSVGElement(); |
| 7168 | this.#hasUsedPointer = false; |
| 7169 | for (const element of this._elements) { |
| 7170 | element.addEventListener("click", this.#boundOnClick); |
| 7171 | } |
| 7172 | const { |
| 7173 | altText, |
| 7174 | decorative |
| 7175 | } = editor.altTextData; |
| 7176 | if (decorative === true) { |
| 7177 | this.#optionDecorative.checked = true; |
| 7178 | this.#optionDescription.checked = false; |
| 7179 | } else { |
| 7180 | this.#optionDecorative.checked = false; |
| 7181 | this.#optionDescription.checked = true; |
| 7182 | } |
| 7183 | this.#previousAltText = this.#textarea.value = altText?.trim() || ""; |
| 7184 | this.#updateUIState(); |
| 7185 | this.#currentEditor = editor; |
| 7186 | this.#uiManager = uiManager; |
| 7187 | this.#uiManager.removeEditListeners(); |
| 7188 | this.#eventBus._on("resize", this.#boundSetPosition); |
| 7189 | try { |
| 7190 | await this.#overlayManager.open(this.#dialog); |
| 7191 | this.#setPosition(); |
| 7192 | } catch (ex) { |
| 7193 | this.#close(); |
| 7194 | throw ex; |
| 7195 | } |
| 7196 | } |
| 7197 | #setPosition() { |
| 7198 | if (!this.#currentEditor) { |
| 7199 | return; |
| 7200 | } |
| 7201 | const dialog = this.#dialog; |
| 7202 | const { |
| 7203 | style |
| 7204 | } = dialog; |
| 7205 | const { |
| 7206 | x: containerX, |
| 7207 | y: containerY, |
| 7208 | width: containerW, |
| 7209 | height: containerH |
| 7210 | } = this.#container.getBoundingClientRect(); |
| 7211 | const { |
| 7212 | innerWidth: windowW, |
| 7213 | innerHeight: windowH |
| 7214 | } = window; |
| 7215 | const { |
| 7216 | width: dialogW, |
| 7217 | height: dialogH |
| 7218 | } = dialog.getBoundingClientRect(); |
| 7219 | const { |
| 7220 | x, |
| 7221 | y, |
| 7222 | width, |
| 7223 | height |
| 7224 | } = this.#currentEditor.getClientDimensions(); |
| 7225 | const MARGIN = 10; |
| 7226 | const isLTR = this.#uiManager.direction === "ltr"; |
| 7227 | const xs = Math.max(x, containerX); |
| 7228 | const xe = Math.min(x + width, containerX + containerW); |
| 7229 | const ys = Math.max(y, containerY); |
| 7230 | const ye = Math.min(y + height, containerY + containerH); |
| 7231 | this.#rectElement.setAttribute("width", `${(xe - xs) / windowW}`); |
| 7232 | this.#rectElement.setAttribute("height", `${(ye - ys) / windowH}`); |
| 7233 | this.#rectElement.setAttribute("x", `${xs / windowW}`); |
| 7234 | this.#rectElement.setAttribute("y", `${ys / windowH}`); |
| 7235 | let left = null; |
| 7236 | let top = Math.max(y, 0); |
| 7237 | top += Math.min(windowH - (top + dialogH), 0); |
| 7238 | if (isLTR) { |
| 7239 | if (x + width + MARGIN + dialogW < windowW) { |
| 7240 | left = x + width + MARGIN; |
| 7241 | } else if (x > dialogW + MARGIN) { |
| 7242 | left = x - dialogW - MARGIN; |
| 7243 | } |
| 7244 | } else if (x > dialogW + MARGIN) { |
| 7245 | left = x - dialogW - MARGIN; |
| 7246 | } else if (x + width + MARGIN + dialogW < windowW) { |
| 7247 | left = x + width + MARGIN; |
| 7248 | } |
| 7249 | if (left === null) { |
| 7250 | top = null; |
| 7251 | left = Math.max(x, 0); |
| 7252 | left += Math.min(windowW - (left + dialogW), 0); |
| 7253 | if (y > dialogH + MARGIN) { |
| 7254 | top = y - dialogH - MARGIN; |
| 7255 | } else if (y + height + MARGIN + dialogH < windowH) { |
| 7256 | top = y + height + MARGIN; |
| 7257 | } |
| 7258 | } |
| 7259 | if (top !== null) { |
| 7260 | dialog.classList.add("positioned"); |
| 7261 | if (isLTR) { |
| 7262 | style.left = `${left}px`; |
| 7263 | } else { |
| 7264 | style.right = `${windowW - left - dialogW}px`; |
| 7265 | } |
| 7266 | style.top = `${top}px`; |
| 7267 | } else { |
| 7268 | dialog.classList.remove("positioned"); |
| 7269 | style.left = ""; |
| 7270 | style.top = ""; |
| 7271 | } |
| 7272 | } |
| 7273 | #finish() { |
| 7274 | if (this.#overlayManager.active === this.#dialog) { |
| 7275 | this.#overlayManager.close(this.#dialog); |
| 7276 | } |
| 7277 | } |
| 7278 | #close() { |
| 7279 | this.#currentEditor._reportTelemetry(this.#telemetryData || { |
| 7280 | action: "alt_text_cancel", |
| 7281 | alt_text_keyboard: !this.#hasUsedPointer |
| 7282 | }); |
| 7283 | this.#telemetryData = null; |
| 7284 | this.#removeOnClickListeners(); |
| 7285 | this.#uiManager?.addEditListeners(); |
| 7286 | this.#eventBus._off("resize", this.#boundSetPosition); |
| 7287 | this.#currentEditor.altTextFinish(); |
| 7288 | this.#currentEditor = null; |
| 7289 | this.#uiManager = null; |
| 7290 | } |
| 7291 | #updateUIState() { |
| 7292 | this.#textarea.disabled = this.#optionDecorative.checked; |
| 7293 | } |
| 7294 | #save() { |
| 7295 | const altText = this.#textarea.value.trim(); |
| 7296 | const decorative = this.#optionDecorative.checked; |
| 7297 | this.#currentEditor.altTextData = { |
| 7298 | altText, |
| 7299 | decorative |
| 7300 | }; |
| 7301 | this.#telemetryData = { |
| 7302 | action: "alt_text_save", |
| 7303 | alt_text_description: !!altText, |
| 7304 | alt_text_edit: !!this.#previousAltText && this.#previousAltText !== altText, |
| 7305 | alt_text_decorative: decorative, |
| 7306 | alt_text_keyboard: !this.#hasUsedPointer |
| 7307 | }; |
| 7308 | this.#finish(); |
| 7309 | } |
| 7310 | #onClick(evt) { |
| 7311 | if (evt.detail === 0) { |
| 7312 | return; |
| 7313 | } |
| 7314 | this.#hasUsedPointer = true; |
| 7315 | this.#removeOnClickListeners(); |
| 7316 | } |
| 7317 | #removeOnClickListeners() { |
| 7318 | for (const element of this._elements) { |
| 7319 | element.removeEventListener("click", this.#boundOnClick); |
| 7320 | } |
| 7321 | } |
| 7322 | destroy() { |
| 7323 | this.#uiManager = null; |
| 7324 | this.#finish(); |
| 7325 | this.#svgElement?.remove(); |
| 7326 | this.#svgElement = this.#rectElement = null; |
| 7327 | } |
| 7328 | } |
| 7329 | |
| 7330 | ;// CONCATENATED MODULE: ./web/annotation_editor_params.js |
| 7331 | |
| 7332 | class AnnotationEditorParams { |
| 7333 | constructor(options, eventBus) { |
| 7334 | this.eventBus = eventBus; |
| 7335 | this.#bindListeners(options); |
| 7336 | } |
| 7337 | #bindListeners({ |
| 7338 | editorFreeTextFontSize, |
| 7339 | editorFreeTextColor, |
| 7340 | editorInkColor, |
| 7341 | editorInkThickness, |
| 7342 | editorInkOpacity, |
| 7343 | editorStampAddImage, |
| 7344 | editorFreeHighlightThickness, |
| 7345 | editorHighlightShowAll |
| 7346 | }) { |
| 7347 | const dispatchEvent = (typeStr, value) => { |
| 7348 | this.eventBus.dispatch("switchannotationeditorparams", { |
| 7349 | source: this, |
| 7350 | type: AnnotationEditorParamsType[typeStr], |
| 7351 | value |
| 7352 | }); |
| 7353 | }; |
| 7354 | editorFreeTextFontSize.addEventListener("input", function () { |
| 7355 | dispatchEvent("FREETEXT_SIZE", this.valueAsNumber); |
| 7356 | }); |
| 7357 | editorFreeTextColor.addEventListener("input", function () { |
| 7358 | dispatchEvent("FREETEXT_COLOR", this.value); |
| 7359 | }); |
| 7360 | editorInkColor.addEventListener("input", function () { |
| 7361 | dispatchEvent("INK_COLOR", this.value); |
| 7362 | }); |
| 7363 | editorInkThickness.addEventListener("input", function () { |
| 7364 | dispatchEvent("INK_THICKNESS", this.valueAsNumber); |
| 7365 | }); |
| 7366 | editorInkOpacity.addEventListener("input", function () { |
| 7367 | dispatchEvent("INK_OPACITY", this.valueAsNumber); |
| 7368 | }); |
| 7369 | editorStampAddImage.addEventListener("click", () => { |
| 7370 | dispatchEvent("CREATE"); |
| 7371 | }); |
| 7372 | editorFreeHighlightThickness.addEventListener("input", function () { |
| 7373 | dispatchEvent("HIGHLIGHT_THICKNESS", this.valueAsNumber); |
| 7374 | }); |
| 7375 | editorHighlightShowAll.addEventListener("click", function () { |
| 7376 | const checked = this.getAttribute("aria-pressed") === "true"; |
| 7377 | this.setAttribute("aria-pressed", !checked); |
| 7378 | dispatchEvent("HIGHLIGHT_SHOW_ALL", !checked); |
| 7379 | }); |
| 7380 | this.eventBus._on("annotationeditorparamschanged", evt => { |
| 7381 | for (const [type, value] of evt.details) { |
| 7382 | switch (type) { |
| 7383 | case AnnotationEditorParamsType.FREETEXT_SIZE: |
| 7384 | editorFreeTextFontSize.value = value; |
| 7385 | break; |
| 7386 | case AnnotationEditorParamsType.FREETEXT_COLOR: |
| 7387 | editorFreeTextColor.value = value; |
| 7388 | break; |
| 7389 | case AnnotationEditorParamsType.INK_COLOR: |
| 7390 | editorInkColor.value = value; |
| 7391 | break; |
| 7392 | case AnnotationEditorParamsType.INK_THICKNESS: |
| 7393 | editorInkThickness.value = value; |
| 7394 | break; |
| 7395 | case AnnotationEditorParamsType.INK_OPACITY: |
| 7396 | editorInkOpacity.value = value; |
| 7397 | break; |
| 7398 | case AnnotationEditorParamsType.HIGHLIGHT_THICKNESS: |
| 7399 | editorFreeHighlightThickness.value = value; |
| 7400 | break; |
| 7401 | case AnnotationEditorParamsType.HIGHLIGHT_FREE: |
| 7402 | editorFreeHighlightThickness.disabled = !value; |
| 7403 | break; |
| 7404 | case AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL: |
| 7405 | editorHighlightShowAll.setAttribute("aria-pressed", value); |
| 7406 | break; |
| 7407 | } |
| 7408 | } |
| 7409 | }); |
| 7410 | } |
| 7411 | } |
| 7412 | |
| 7413 | ;// CONCATENATED MODULE: ./web/caret_browsing.js |
| 7414 | |
| 7415 | const PRECISION = 1e-1; |
| 7416 | class CaretBrowsingMode { |
| 7417 | #mainContainer; |
| 7418 | #toolBarHeight; |
| 7419 | #viewerContainer; |
| 7420 | constructor(mainContainer, viewerContainer, toolbarContainer) { |
| 7421 | this.#mainContainer = mainContainer; |
| 7422 | this.#viewerContainer = viewerContainer; |
| 7423 | this.#toolBarHeight = toolbarContainer?.getBoundingClientRect().height ?? 0; |
| 7424 | } |
| 7425 | #isOnSameLine(rect1, rect2) { |
| 7426 | const top1 = rect1.y; |
| 7427 | const bot1 = rect1.bottom; |
| 7428 | const mid1 = rect1.y + rect1.height / 2; |
| 7429 | const top2 = rect2.y; |
| 7430 | const bot2 = rect2.bottom; |
| 7431 | const mid2 = rect2.y + rect2.height / 2; |
| 7432 | return top1 <= mid2 && mid2 <= bot1 || top2 <= mid1 && mid1 <= bot2; |
| 7433 | } |
| 7434 | #isUnderOver(rect, x, y, isUp) { |
| 7435 | const midY = rect.y + rect.height / 2; |
| 7436 | return (isUp ? y >= midY : y <= midY) && rect.x - PRECISION <= x && x <= rect.right + PRECISION; |
| 7437 | } |
| 7438 | #isVisible(rect) { |
| 7439 | return rect.top >= this.#toolBarHeight && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth); |
| 7440 | } |
| 7441 | #getCaretPosition(selection, isUp) { |
| 7442 | const { |
| 7443 | focusNode, |
| 7444 | focusOffset |
| 7445 | } = selection; |
| 7446 | const range = document.createRange(); |
| 7447 | range.setStart(focusNode, focusOffset); |
| 7448 | range.setEnd(focusNode, focusOffset); |
| 7449 | const rect = range.getBoundingClientRect(); |
| 7450 | return [rect.x, isUp ? rect.top : rect.bottom]; |
| 7451 | } |
| 7452 | static #caretPositionFromPoint(x, y) { |
| 7453 | if (!document.caretPositionFromPoint) { |
| 7454 | const { |
| 7455 | startContainer: offsetNode, |
| 7456 | startOffset: offset |
| 7457 | } = document.caretRangeFromPoint(x, y); |
| 7458 | return { |
| 7459 | offsetNode, |
| 7460 | offset |
| 7461 | }; |
| 7462 | } |
| 7463 | return document.caretPositionFromPoint(x, y); |
| 7464 | } |
| 7465 | #setCaretPositionHelper(selection, caretX, select, element, rect) { |
| 7466 | rect ||= element.getBoundingClientRect(); |
| 7467 | if (caretX <= rect.x + PRECISION) { |
| 7468 | if (select) { |
| 7469 | selection.extend(element.firstChild, 0); |
| 7470 | } else { |
| 7471 | selection.setPosition(element.firstChild, 0); |
| 7472 | } |
| 7473 | return; |
| 7474 | } |
| 7475 | if (rect.right - PRECISION <= caretX) { |
| 7476 | const { |
| 7477 | lastChild |
| 7478 | } = element; |
| 7479 | if (select) { |
| 7480 | selection.extend(lastChild, lastChild.length); |
| 7481 | } else { |
| 7482 | selection.setPosition(lastChild, lastChild.length); |
| 7483 | } |
| 7484 | return; |
| 7485 | } |
| 7486 | const midY = rect.y + rect.height / 2; |
| 7487 | let caretPosition = CaretBrowsingMode.#caretPositionFromPoint(caretX, midY); |
| 7488 | let parentElement = caretPosition.offsetNode?.parentElement; |
| 7489 | if (parentElement && parentElement !== element) { |
| 7490 | const elementsAtPoint = document.elementsFromPoint(caretX, midY); |
| 7491 | const savedVisibilities = []; |
| 7492 | for (const el of elementsAtPoint) { |
| 7493 | if (el === element) { |
| 7494 | break; |
| 7495 | } |
| 7496 | const { |
| 7497 | style |
| 7498 | } = el; |
| 7499 | savedVisibilities.push([el, style.visibility]); |
| 7500 | style.visibility = "hidden"; |
| 7501 | } |
| 7502 | caretPosition = CaretBrowsingMode.#caretPositionFromPoint(caretX, midY); |
| 7503 | parentElement = caretPosition.offsetNode?.parentElement; |
| 7504 | for (const [el, visibility] of savedVisibilities) { |
| 7505 | el.style.visibility = visibility; |
| 7506 | } |
| 7507 | } |
| 7508 | if (parentElement !== element) { |
| 7509 | if (select) { |
| 7510 | selection.extend(element.firstChild, 0); |
| 7511 | } else { |
| 7512 | selection.setPosition(element.firstChild, 0); |
| 7513 | } |
| 7514 | return; |
| 7515 | } |
| 7516 | if (select) { |
| 7517 | selection.extend(caretPosition.offsetNode, caretPosition.offset); |
| 7518 | } else { |
| 7519 | selection.setPosition(caretPosition.offsetNode, caretPosition.offset); |
| 7520 | } |
| 7521 | } |
| 7522 | #setCaretPosition(select, selection, newLineElement, newLineElementRect, caretX) { |
| 7523 | if (this.#isVisible(newLineElementRect)) { |
| 7524 | this.#setCaretPositionHelper(selection, caretX, select, newLineElement, newLineElementRect); |
| 7525 | return; |
| 7526 | } |
| 7527 | this.#mainContainer.addEventListener("scrollend", this.#setCaretPositionHelper.bind(this, selection, caretX, select, newLineElement, null), { |
| 7528 | once: true |
| 7529 | }); |
| 7530 | newLineElement.scrollIntoView(); |
| 7531 | } |
| 7532 | #getNodeOnNextPage(textLayer, isUp) { |
| 7533 | while (true) { |
| 7534 | const page = textLayer.closest(".page"); |
| 7535 | const pageNumber = parseInt(page.getAttribute("data-page-number")); |
| 7536 | const nextPage = isUp ? pageNumber - 1 : pageNumber + 1; |
| 7537 | textLayer = this.#viewerContainer.querySelector(`.page[data-page-number="${nextPage}"] .textLayer`); |
| 7538 | if (!textLayer) { |
| 7539 | return null; |
| 7540 | } |
| 7541 | const walker = document.createTreeWalker(textLayer, NodeFilter.SHOW_TEXT); |
| 7542 | const node = isUp ? walker.lastChild() : walker.firstChild(); |
| 7543 | if (node) { |
| 7544 | return node; |
| 7545 | } |
| 7546 | } |
| 7547 | } |
| 7548 | moveCaret(isUp, select) { |
| 7549 | const selection = document.getSelection(); |
| 7550 | if (selection.rangeCount === 0) { |
| 7551 | return; |
| 7552 | } |
| 7553 | const { |
| 7554 | focusNode |
| 7555 | } = selection; |
| 7556 | const focusElement = focusNode.nodeType !== Node.ELEMENT_NODE ? focusNode.parentElement : focusNode; |
| 7557 | const root = focusElement.closest(".textLayer"); |
| 7558 | if (!root) { |
| 7559 | return; |
| 7560 | } |
| 7561 | const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT); |
| 7562 | walker.currentNode = focusNode; |
| 7563 | const focusRect = focusElement.getBoundingClientRect(); |
| 7564 | let newLineElement = null; |
| 7565 | const nodeIterator = (isUp ? walker.previousSibling : walker.nextSibling).bind(walker); |
| 7566 | while (nodeIterator()) { |
| 7567 | const element = walker.currentNode.parentElement; |
| 7568 | if (!this.#isOnSameLine(focusRect, element.getBoundingClientRect())) { |
| 7569 | newLineElement = element; |
| 7570 | break; |
| 7571 | } |
| 7572 | } |
| 7573 | if (!newLineElement) { |
| 7574 | const node = this.#getNodeOnNextPage(root, isUp); |
| 7575 | if (!node) { |
| 7576 | return; |
| 7577 | } |
| 7578 | if (select) { |
| 7579 | const lastNode = (isUp ? walker.firstChild() : walker.lastChild()) || focusNode; |
| 7580 | selection.extend(lastNode, isUp ? 0 : lastNode.length); |
| 7581 | const range = document.createRange(); |
| 7582 | range.setStart(node, isUp ? node.length : 0); |
| 7583 | range.setEnd(node, isUp ? node.length : 0); |
| 7584 | selection.addRange(range); |
| 7585 | return; |
| 7586 | } |
| 7587 | const [caretX] = this.#getCaretPosition(selection, isUp); |
| 7588 | const { |
| 7589 | parentElement |
| 7590 | } = node; |
| 7591 | this.#setCaretPosition(select, selection, parentElement, parentElement.getBoundingClientRect(), caretX); |
| 7592 | return; |
| 7593 | } |
| 7594 | const [caretX, caretY] = this.#getCaretPosition(selection, isUp); |
| 7595 | const newLineElementRect = newLineElement.getBoundingClientRect(); |
| 7596 | if (this.#isUnderOver(newLineElementRect, caretX, caretY, isUp)) { |
| 7597 | this.#setCaretPosition(select, selection, newLineElement, newLineElementRect, caretX); |
| 7598 | return; |
| 7599 | } |
| 7600 | while (nodeIterator()) { |
| 7601 | const element = walker.currentNode.parentElement; |
| 7602 | const elementRect = element.getBoundingClientRect(); |
| 7603 | if (!this.#isOnSameLine(newLineElementRect, elementRect)) { |
| 7604 | break; |
| 7605 | } |
| 7606 | if (this.#isUnderOver(elementRect, caretX, caretY, isUp)) { |
| 7607 | this.#setCaretPosition(select, selection, element, elementRect, caretX); |
| 7608 | return; |
| 7609 | } |
| 7610 | } |
| 7611 | this.#setCaretPosition(select, selection, newLineElement, newLineElementRect, caretX); |
| 7612 | } |
| 7613 | } |
| 7614 | |
| 7615 | ;// CONCATENATED MODULE: ./web/download_manager.js |
| 7616 | |
| 7617 | |
| 7618 | |
| 7619 | |
| 7620 | function download(blobUrl, filename) { |
| 7621 | const a = document.createElement("a"); |
| 7622 | if (!a.click) { |
| 7623 | throw new Error('DownloadManager: "a.click()" is not supported.'); |
| 7624 | } |
| 7625 | a.href = blobUrl; |
| 7626 | a.target = "_parent"; |
| 7627 | if ("download" in a) { |
| 7628 | a.download = filename; |
| 7629 | } |
| 7630 | (document.body || document.documentElement).append(a); |
| 7631 | a.click(); |
| 7632 | a.remove(); |
| 7633 | } |
| 7634 | class DownloadManager { |
| 7635 | #openBlobUrls = new WeakMap(); |
| 7636 | downloadUrl(url, filename, _options) { |
| 7637 | if (!createValidAbsoluteUrl(url, "http://example.com")) { |
| 7638 | console.error(`downloadUrl - not a valid URL: ${url}`); |
| 7639 | return; |
| 7640 | } |
| 7641 | download(url + "#pdfjs.action=download", filename); |
| 7642 | } |
| 7643 | downloadData(data, filename, contentType) { |
| 7644 | const blobUrl = URL.createObjectURL(new Blob([data], { |
| 7645 | type: contentType |
| 7646 | })); |
| 7647 | download(blobUrl, filename); |
| 7648 | } |
| 7649 | openOrDownloadData(data, filename, dest = null) { |
| 7650 | const isPdfData = isPdfFile(filename); |
| 7651 | const contentType = isPdfData ? "application/pdf" : ""; |
| 7652 | if (isPdfData) { |
| 7653 | let blobUrl = this.#openBlobUrls.get(data); |
| 7654 | if (!blobUrl) { |
| 7655 | blobUrl = URL.createObjectURL(new Blob([data], { |
| 7656 | type: contentType |
| 7657 | })); |
| 7658 | this.#openBlobUrls.set(data, blobUrl); |
| 7659 | } |
| 7660 | let viewerUrl; |
| 7661 | viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename); |
| 7662 | if (dest) { |
| 7663 | viewerUrl += `#${escape(dest)}`; |
| 7664 | } |
| 7665 | try { |
| 7666 | window.open(viewerUrl); |
| 7667 | return true; |
| 7668 | } catch (ex) { |
| 7669 | console.error(`openOrDownloadData: ${ex}`); |
| 7670 | URL.revokeObjectURL(blobUrl); |
| 7671 | this.#openBlobUrls.delete(data); |
| 7672 | } |
| 7673 | } |
| 7674 | this.downloadData(data, filename, contentType); |
| 7675 | return false; |
| 7676 | } |
| 7677 | download(blob, url, filename, _options) { |
| 7678 | const blobUrl = URL.createObjectURL(blob); |
| 7679 | download(blobUrl, filename); |
| 7680 | } |
| 7681 | } |
| 7682 | |
| 7683 | ;// CONCATENATED MODULE: ./web/overlay_manager.js |
| 7684 | class OverlayManager { |
| 7685 | #overlays = new WeakMap(); |
| 7686 | #active = null; |
| 7687 | get active() { |
| 7688 | return this.#active; |
| 7689 | } |
| 7690 | async register(dialog, canForceClose = false) { |
| 7691 | if (typeof dialog !== "object") { |
| 7692 | throw new Error("Not enough parameters."); |
| 7693 | } else if (this.#overlays.has(dialog)) { |
| 7694 | throw new Error("The overlay is already registered."); |
| 7695 | } |
| 7696 | this.#overlays.set(dialog, { |
| 7697 | canForceClose |
| 7698 | }); |
| 7699 | dialog.addEventListener("cancel", evt => { |
| 7700 | this.#active = null; |
| 7701 | }); |
| 7702 | } |
| 7703 | async open(dialog) { |
| 7704 | if (!this.#overlays.has(dialog)) { |
| 7705 | throw new Error("The overlay does not exist."); |
| 7706 | } else if (this.#active) { |
| 7707 | if (this.#active === dialog) { |
| 7708 | throw new Error("The overlay is already active."); |
| 7709 | } else if (this.#overlays.get(dialog).canForceClose) { |
| 7710 | await this.close(); |
| 7711 | } else { |
| 7712 | throw new Error("Another overlay is currently active."); |
| 7713 | } |
| 7714 | } |
| 7715 | this.#active = dialog; |
| 7716 | dialog.showModal(); |
| 7717 | } |
| 7718 | async close(dialog = this.#active) { |
| 7719 | if (!this.#overlays.has(dialog)) { |
| 7720 | throw new Error("The overlay does not exist."); |
| 7721 | } else if (!this.#active) { |
| 7722 | throw new Error("The overlay is currently not active."); |
| 7723 | } else if (this.#active !== dialog) { |
| 7724 | throw new Error("Another overlay is currently active."); |
| 7725 | } |
| 7726 | dialog.close(); |
| 7727 | this.#active = null; |
| 7728 | } |
| 7729 | } |
| 7730 | |
| 7731 | ;// CONCATENATED MODULE: ./web/password_prompt.js |
| 7732 | |
| 7733 | |
| 7734 | class PasswordPrompt { |
| 7735 | #activeCapability = null; |
| 7736 | #updateCallback = null; |
| 7737 | #reason = null; |
| 7738 | constructor(options, overlayManager, isViewerEmbedded = false) { |
| 7739 | this.dialog = options.dialog; |
| 7740 | this.label = options.label; |
| 7741 | this.input = options.input; |
| 7742 | this.submitButton = options.submitButton; |
| 7743 | this.cancelButton = options.cancelButton; |
| 7744 | this.overlayManager = overlayManager; |
| 7745 | this._isViewerEmbedded = isViewerEmbedded; |
| 7746 | this.submitButton.addEventListener("click", this.#verify.bind(this)); |
| 7747 | this.cancelButton.addEventListener("click", this.close.bind(this)); |
| 7748 | this.input.addEventListener("keydown", e => { |
| 7749 | if (e.keyCode === 13) { |
| 7750 | this.#verify(); |
| 7751 | } |
| 7752 | }); |
| 7753 | this.overlayManager.register(this.dialog, true); |
| 7754 | this.dialog.addEventListener("close", this.#cancel.bind(this)); |
| 7755 | } |
| 7756 | async open() { |
| 7757 | await this.#activeCapability?.promise; |
| 7758 | this.#activeCapability = Promise.withResolvers(); |
| 7759 | try { |
| 7760 | await this.overlayManager.open(this.dialog); |
| 7761 | } catch (ex) { |
| 7762 | this.#activeCapability.resolve(); |
| 7763 | throw ex; |
| 7764 | } |
| 7765 | const passwordIncorrect = this.#reason === PasswordResponses.INCORRECT_PASSWORD; |
| 7766 | if (!this._isViewerEmbedded || passwordIncorrect) { |
| 7767 | this.input.focus(); |
| 7768 | } |
| 7769 | this.label.setAttribute("data-l10n-id", `pdfjs-password-${passwordIncorrect ? "invalid" : "label"}`); |
| 7770 | } |
| 7771 | async close() { |
| 7772 | if (this.overlayManager.active === this.dialog) { |
| 7773 | this.overlayManager.close(this.dialog); |
| 7774 | } |
| 7775 | } |
| 7776 | #verify() { |
| 7777 | const password = this.input.value; |
| 7778 | if (password?.length > 0) { |
| 7779 | this.#invokeCallback(password); |
| 7780 | } |
| 7781 | } |
| 7782 | #cancel() { |
| 7783 | this.#invokeCallback(new Error("PasswordPrompt cancelled.")); |
| 7784 | this.#activeCapability.resolve(); |
| 7785 | } |
| 7786 | #invokeCallback(password) { |
| 7787 | if (!this.#updateCallback) { |
| 7788 | return; |
| 7789 | } |
| 7790 | this.close(); |
| 7791 | this.input.value = ""; |
| 7792 | this.#updateCallback(password); |
| 7793 | this.#updateCallback = null; |
| 7794 | } |
| 7795 | async setUpdateCallback(updateCallback, reason) { |
| 7796 | if (this.#activeCapability) { |
| 7797 | await this.#activeCapability.promise; |
| 7798 | } |
| 7799 | this.#updateCallback = updateCallback; |
| 7800 | this.#reason = reason; |
| 7801 | } |
| 7802 | } |
| 7803 | |
| 7804 | ;// CONCATENATED MODULE: ./web/base_tree_viewer.js |
| 7805 | |
| 7806 | const TREEITEM_OFFSET_TOP = -100; |
| 7807 | const TREEITEM_SELECTED_CLASS = "selected"; |
| 7808 | class BaseTreeViewer { |
| 7809 | constructor(options) { |
| 7810 | if (this.constructor === BaseTreeViewer) { |
| 7811 | throw new Error("Cannot initialize BaseTreeViewer."); |
| 7812 | } |
| 7813 | this.container = options.container; |
| 7814 | this.eventBus = options.eventBus; |
| 7815 | this._l10n = options.l10n; |
| 7816 | this.reset(); |
| 7817 | } |
| 7818 | reset() { |
| 7819 | this._pdfDocument = null; |
| 7820 | this._lastToggleIsShow = true; |
| 7821 | this._currentTreeItem = null; |
| 7822 | this.container.textContent = ""; |
| 7823 | this.container.classList.remove("treeWithDeepNesting"); |
| 7824 | } |
| 7825 | _dispatchEvent(count) { |
| 7826 | throw new Error("Not implemented: _dispatchEvent"); |
| 7827 | } |
| 7828 | _bindLink(element, params) { |
| 7829 | throw new Error("Not implemented: _bindLink"); |
| 7830 | } |
| 7831 | _normalizeTextContent(str) { |
| 7832 | return removeNullCharacters(str, true) || "\u2013"; |
| 7833 | } |
| 7834 | _addToggleButton(div, hidden = false) { |
| 7835 | const toggler = document.createElement("div"); |
| 7836 | toggler.className = "treeItemToggler"; |
| 7837 | if (hidden) { |
| 7838 | toggler.classList.add("treeItemsHidden"); |
| 7839 | } |
| 7840 | toggler.onclick = evt => { |
| 7841 | evt.stopPropagation(); |
| 7842 | toggler.classList.toggle("treeItemsHidden"); |
| 7843 | if (evt.shiftKey) { |
| 7844 | const shouldShowAll = !toggler.classList.contains("treeItemsHidden"); |
| 7845 | this._toggleTreeItem(div, shouldShowAll); |
| 7846 | } |
| 7847 | }; |
| 7848 | div.prepend(toggler); |
| 7849 | } |
| 7850 | _toggleTreeItem(root, show = false) { |
| 7851 | this._l10n.pause(); |
| 7852 | this._lastToggleIsShow = show; |
| 7853 | for (const toggler of root.querySelectorAll(".treeItemToggler")) { |
| 7854 | toggler.classList.toggle("treeItemsHidden", !show); |
| 7855 | } |
| 7856 | this._l10n.resume(); |
| 7857 | } |
| 7858 | _toggleAllTreeItems() { |
| 7859 | this._toggleTreeItem(this.container, !this._lastToggleIsShow); |
| 7860 | } |
| 7861 | _finishRendering(fragment, count, hasAnyNesting = false) { |
| 7862 | if (hasAnyNesting) { |
| 7863 | this.container.classList.add("treeWithDeepNesting"); |
| 7864 | this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden"); |
| 7865 | } |
| 7866 | this._l10n.pause(); |
| 7867 | this.container.append(fragment); |
| 7868 | this._l10n.resume(); |
| 7869 | this._dispatchEvent(count); |
| 7870 | } |
| 7871 | render(params) { |
| 7872 | throw new Error("Not implemented: render"); |
| 7873 | } |
| 7874 | _updateCurrentTreeItem(treeItem = null) { |
| 7875 | if (this._currentTreeItem) { |
| 7876 | this._currentTreeItem.classList.remove(TREEITEM_SELECTED_CLASS); |
| 7877 | this._currentTreeItem = null; |
| 7878 | } |
| 7879 | if (treeItem) { |
| 7880 | treeItem.classList.add(TREEITEM_SELECTED_CLASS); |
| 7881 | this._currentTreeItem = treeItem; |
| 7882 | } |
| 7883 | } |
| 7884 | _scrollToCurrentTreeItem(treeItem) { |
| 7885 | if (!treeItem) { |
| 7886 | return; |
| 7887 | } |
| 7888 | this._l10n.pause(); |
| 7889 | let currentNode = treeItem.parentNode; |
| 7890 | while (currentNode && currentNode !== this.container) { |
| 7891 | if (currentNode.classList.contains("treeItem")) { |
| 7892 | const toggler = currentNode.firstElementChild; |
| 7893 | toggler?.classList.remove("treeItemsHidden"); |
| 7894 | } |
| 7895 | currentNode = currentNode.parentNode; |
| 7896 | } |
| 7897 | this._l10n.resume(); |
| 7898 | this._updateCurrentTreeItem(treeItem); |
| 7899 | this.container.scrollTo(treeItem.offsetLeft, treeItem.offsetTop + TREEITEM_OFFSET_TOP); |
| 7900 | } |
| 7901 | } |
| 7902 | |
| 7903 | ;// CONCATENATED MODULE: ./web/pdf_attachment_viewer.js |
| 7904 | |
| 7905 | |
| 7906 | |
| 7907 | class PDFAttachmentViewer extends BaseTreeViewer { |
| 7908 | constructor(options) { |
| 7909 | super(options); |
| 7910 | this.downloadManager = options.downloadManager; |
| 7911 | this.eventBus._on("fileattachmentannotation", this.#appendAttachment.bind(this)); |
| 7912 | } |
| 7913 | reset(keepRenderedCapability = false) { |
| 7914 | super.reset(); |
| 7915 | this._attachments = null; |
| 7916 | if (!keepRenderedCapability) { |
| 7917 | this._renderedCapability = Promise.withResolvers(); |
| 7918 | } |
| 7919 | this._pendingDispatchEvent = false; |
| 7920 | } |
| 7921 | async _dispatchEvent(attachmentsCount) { |
| 7922 | this._renderedCapability.resolve(); |
| 7923 | if (attachmentsCount === 0 && !this._pendingDispatchEvent) { |
| 7924 | this._pendingDispatchEvent = true; |
| 7925 | await waitOnEventOrTimeout({ |
| 7926 | target: this.eventBus, |
| 7927 | name: "annotationlayerrendered", |
| 7928 | delay: 1000 |
| 7929 | }); |
| 7930 | if (!this._pendingDispatchEvent) { |
| 7931 | return; |
| 7932 | } |
| 7933 | } |
| 7934 | this._pendingDispatchEvent = false; |
| 7935 | this.eventBus.dispatch("attachmentsloaded", { |
| 7936 | source: this, |
| 7937 | attachmentsCount |
| 7938 | }); |
| 7939 | } |
| 7940 | _bindLink(element, { |
| 7941 | content, |
| 7942 | description, |
| 7943 | filename |
| 7944 | }) { |
| 7945 | if (description) { |
| 7946 | element.title = description; |
| 7947 | } |
| 7948 | element.onclick = () => { |
| 7949 | this.downloadManager.openOrDownloadData(content, filename); |
| 7950 | return false; |
| 7951 | }; |
| 7952 | } |
| 7953 | render({ |
| 7954 | attachments, |
| 7955 | keepRenderedCapability = false |
| 7956 | }) { |
| 7957 | if (this._attachments) { |
| 7958 | this.reset(keepRenderedCapability); |
| 7959 | } |
| 7960 | this._attachments = attachments || null; |
| 7961 | if (!attachments) { |
| 7962 | this._dispatchEvent(0); |
| 7963 | return; |
| 7964 | } |
| 7965 | const fragment = document.createDocumentFragment(); |
| 7966 | let attachmentsCount = 0; |
| 7967 | for (const name in attachments) { |
| 7968 | const item = attachments[name]; |
| 7969 | const div = document.createElement("div"); |
| 7970 | div.className = "treeItem"; |
| 7971 | const element = document.createElement("a"); |
| 7972 | this._bindLink(element, item); |
| 7973 | element.textContent = this._normalizeTextContent(item.filename); |
| 7974 | div.append(element); |
| 7975 | fragment.append(div); |
| 7976 | attachmentsCount++; |
| 7977 | } |
| 7978 | this._finishRendering(fragment, attachmentsCount); |
| 7979 | } |
| 7980 | #appendAttachment(item) { |
| 7981 | const renderedPromise = this._renderedCapability.promise; |
| 7982 | renderedPromise.then(() => { |
| 7983 | if (renderedPromise !== this._renderedCapability.promise) { |
| 7984 | return; |
| 7985 | } |
| 7986 | const attachments = this._attachments || Object.create(null); |
| 7987 | for (const name in attachments) { |
| 7988 | if (item.filename === name) { |
| 7989 | return; |
| 7990 | } |
| 7991 | } |
| 7992 | attachments[item.filename] = item; |
| 7993 | this.render({ |
| 7994 | attachments, |
| 7995 | keepRenderedCapability: true |
| 7996 | }); |
| 7997 | }); |
| 7998 | } |
| 7999 | } |
| 8000 | |
| 8001 | ;// CONCATENATED MODULE: ./web/grab_to_pan.js |
| 8002 | const CSS_CLASS_GRAB = "grab-to-pan-grab"; |
| 8003 | class GrabToPan { |
| 8004 | constructor({ |
| 8005 | element |
| 8006 | }) { |
| 8007 | this.element = element; |
| 8008 | this.document = element.ownerDocument; |
| 8009 | this.activate = this.activate.bind(this); |
| 8010 | this.deactivate = this.deactivate.bind(this); |
| 8011 | this.toggle = this.toggle.bind(this); |
| 8012 | this._onMouseDown = this.#onMouseDown.bind(this); |
| 8013 | this._onMouseMove = this.#onMouseMove.bind(this); |
| 8014 | this._endPan = this.#endPan.bind(this); |
| 8015 | const overlay = this.overlay = document.createElement("div"); |
| 8016 | overlay.className = "grab-to-pan-grabbing"; |
| 8017 | } |
| 8018 | activate() { |
| 8019 | if (!this.active) { |
| 8020 | this.active = true; |
| 8021 | this.element.addEventListener("mousedown", this._onMouseDown, true); |
| 8022 | this.element.classList.add(CSS_CLASS_GRAB); |
| 8023 | } |
| 8024 | } |
| 8025 | deactivate() { |
| 8026 | if (this.active) { |
| 8027 | this.active = false; |
| 8028 | this.element.removeEventListener("mousedown", this._onMouseDown, true); |
| 8029 | this._endPan(); |
| 8030 | this.element.classList.remove(CSS_CLASS_GRAB); |
| 8031 | } |
| 8032 | } |
| 8033 | toggle() { |
| 8034 | if (this.active) { |
| 8035 | this.deactivate(); |
| 8036 | } else { |
| 8037 | this.activate(); |
| 8038 | } |
| 8039 | } |
| 8040 | ignoreTarget(node) { |
| 8041 | return node.matches("a[href], a[href] *, input, textarea, button, button *, select, option"); |
| 8042 | } |
| 8043 | #onMouseDown(event) { |
| 8044 | if (event.button !== 0 || this.ignoreTarget(event.target)) { |
| 8045 | return; |
| 8046 | } |
| 8047 | if (event.originalTarget) { |
| 8048 | try { |
| 8049 | event.originalTarget.tagName; |
| 8050 | } catch { |
| 8051 | return; |
| 8052 | } |
| 8053 | } |
| 8054 | this.scrollLeftStart = this.element.scrollLeft; |
| 8055 | this.scrollTopStart = this.element.scrollTop; |
| 8056 | this.clientXStart = event.clientX; |
| 8057 | this.clientYStart = event.clientY; |
| 8058 | this.document.addEventListener("mousemove", this._onMouseMove, true); |
| 8059 | this.document.addEventListener("mouseup", this._endPan, true); |
| 8060 | this.element.addEventListener("scroll", this._endPan, true); |
| 8061 | event.preventDefault(); |
| 8062 | event.stopPropagation(); |
| 8063 | const focusedElement = document.activeElement; |
| 8064 | if (focusedElement && !focusedElement.contains(event.target)) { |
| 8065 | focusedElement.blur(); |
| 8066 | } |
| 8067 | } |
| 8068 | #onMouseMove(event) { |
| 8069 | this.element.removeEventListener("scroll", this._endPan, true); |
| 8070 | if (!(event.buttons & 1)) { |
| 8071 | this._endPan(); |
| 8072 | return; |
| 8073 | } |
| 8074 | const xDiff = event.clientX - this.clientXStart; |
| 8075 | const yDiff = event.clientY - this.clientYStart; |
| 8076 | this.element.scrollTo({ |
| 8077 | top: this.scrollTopStart - yDiff, |
| 8078 | left: this.scrollLeftStart - xDiff, |
| 8079 | behavior: "instant" |
| 8080 | }); |
| 8081 | if (!this.overlay.parentNode) { |
| 8082 | document.body.append(this.overlay); |
| 8083 | } |
| 8084 | } |
| 8085 | #endPan() { |
| 8086 | this.element.removeEventListener("scroll", this._endPan, true); |
| 8087 | this.document.removeEventListener("mousemove", this._onMouseMove, true); |
| 8088 | this.document.removeEventListener("mouseup", this._endPan, true); |
| 8089 | this.overlay.remove(); |
| 8090 | } |
| 8091 | } |
| 8092 | |
| 8093 | ;// CONCATENATED MODULE: ./web/pdf_cursor_tools.js |
| 8094 | |
| 8095 | |
| 8096 | |
| 8097 | class PDFCursorTools { |
| 8098 | #active = CursorTool.SELECT; |
| 8099 | #prevActive = null; |
| 8100 | constructor({ |
| 8101 | container, |
| 8102 | eventBus, |
| 8103 | cursorToolOnLoad = CursorTool.SELECT |
| 8104 | }) { |
| 8105 | this.container = container; |
| 8106 | this.eventBus = eventBus; |
| 8107 | this.#addEventListeners(); |
| 8108 | Promise.resolve().then(() => { |
| 8109 | this.switchTool(cursorToolOnLoad); |
| 8110 | }); |
| 8111 | } |
| 8112 | get activeTool() { |
| 8113 | return this.#active; |
| 8114 | } |
| 8115 | switchTool(tool) { |
| 8116 | if (this.#prevActive !== null) { |
| 8117 | return; |
| 8118 | } |
| 8119 | if (tool === this.#active) { |
| 8120 | return; |
| 8121 | } |
| 8122 | const disableActiveTool = () => { |
| 8123 | switch (this.#active) { |
| 8124 | case CursorTool.SELECT: |
| 8125 | break; |
| 8126 | case CursorTool.HAND: |
| 8127 | this._handTool.deactivate(); |
| 8128 | break; |
| 8129 | case CursorTool.ZOOM: |
| 8130 | } |
| 8131 | }; |
| 8132 | switch (tool) { |
| 8133 | case CursorTool.SELECT: |
| 8134 | disableActiveTool(); |
| 8135 | break; |
| 8136 | case CursorTool.HAND: |
| 8137 | disableActiveTool(); |
| 8138 | this._handTool.activate(); |
| 8139 | break; |
| 8140 | case CursorTool.ZOOM: |
| 8141 | default: |
| 8142 | console.error(`switchTool: "${tool}" is an unsupported value.`); |
| 8143 | return; |
| 8144 | } |
| 8145 | this.#active = tool; |
| 8146 | this.eventBus.dispatch("cursortoolchanged", { |
| 8147 | source: this, |
| 8148 | tool |
| 8149 | }); |
| 8150 | } |
| 8151 | #addEventListeners() { |
| 8152 | this.eventBus._on("switchcursortool", evt => { |
| 8153 | if (!evt.reset) { |
| 8154 | this.switchTool(evt.tool); |
| 8155 | } else if (this.#prevActive !== null) { |
| 8156 | annotationEditorMode = AnnotationEditorType.NONE; |
| 8157 | presentationModeState = PresentationModeState.NORMAL; |
| 8158 | enableActive(); |
| 8159 | } |
| 8160 | }); |
| 8161 | let annotationEditorMode = AnnotationEditorType.NONE, |
| 8162 | presentationModeState = PresentationModeState.NORMAL; |
| 8163 | const disableActive = () => { |
| 8164 | const prevActive = this.#active; |
| 8165 | this.switchTool(CursorTool.SELECT); |
| 8166 | this.#prevActive ??= prevActive; |
| 8167 | }; |
| 8168 | const enableActive = () => { |
| 8169 | const prevActive = this.#prevActive; |
| 8170 | if (prevActive !== null && annotationEditorMode === AnnotationEditorType.NONE && presentationModeState === PresentationModeState.NORMAL) { |
| 8171 | this.#prevActive = null; |
| 8172 | this.switchTool(prevActive); |
| 8173 | } |
| 8174 | }; |
| 8175 | this.eventBus._on("annotationeditormodechanged", ({ |
| 8176 | mode |
| 8177 | }) => { |
| 8178 | annotationEditorMode = mode; |
| 8179 | if (mode === AnnotationEditorType.NONE) { |
| 8180 | enableActive(); |
| 8181 | } else { |
| 8182 | disableActive(); |
| 8183 | } |
| 8184 | }); |
| 8185 | this.eventBus._on("presentationmodechanged", ({ |
| 8186 | state |
| 8187 | }) => { |
| 8188 | presentationModeState = state; |
| 8189 | if (state === PresentationModeState.NORMAL) { |
| 8190 | enableActive(); |
| 8191 | } else if (state === PresentationModeState.FULLSCREEN) { |
| 8192 | disableActive(); |
| 8193 | } |
| 8194 | }); |
| 8195 | } |
| 8196 | get _handTool() { |
| 8197 | return shadow(this, "_handTool", new GrabToPan({ |
| 8198 | element: this.container |
| 8199 | })); |
| 8200 | } |
| 8201 | } |
| 8202 | |
| 8203 | ;// CONCATENATED MODULE: ./web/pdf_document_properties.js |
| 8204 | |
| 8205 | |
| 8206 | |
| 8207 | const DEFAULT_FIELD_CONTENT = "-"; |
| 8208 | const NON_METRIC_LOCALES = ["en-us", "en-lr", "my"]; |
| 8209 | const US_PAGE_NAMES = { |
| 8210 | "8.5x11": "letter", |
| 8211 | "8.5x14": "legal" |
| 8212 | }; |
| 8213 | const METRIC_PAGE_NAMES = { |
| 8214 | "297x420": "a-three", |
| 8215 | "210x297": "a-four" |
| 8216 | }; |
| 8217 | function getPageName(size, isPortrait, pageNames) { |
| 8218 | const width = isPortrait ? size.width : size.height; |
| 8219 | const height = isPortrait ? size.height : size.width; |
| 8220 | return pageNames[`${width}x${height}`]; |
| 8221 | } |
| 8222 | class PDFDocumentProperties { |
| 8223 | #fieldData = null; |
| 8224 | constructor({ |
| 8225 | dialog, |
| 8226 | fields, |
| 8227 | closeButton |
| 8228 | }, overlayManager, eventBus, l10n, fileNameLookup) { |
| 8229 | this.dialog = dialog; |
| 8230 | this.fields = fields; |
| 8231 | this.overlayManager = overlayManager; |
| 8232 | this.l10n = l10n; |
| 8233 | this._fileNameLookup = fileNameLookup; |
| 8234 | this.#reset(); |
| 8235 | closeButton.addEventListener("click", this.close.bind(this)); |
| 8236 | this.overlayManager.register(this.dialog); |
| 8237 | eventBus._on("pagechanging", evt => { |
| 8238 | this._currentPageNumber = evt.pageNumber; |
| 8239 | }); |
| 8240 | eventBus._on("rotationchanging", evt => { |
| 8241 | this._pagesRotation = evt.pagesRotation; |
| 8242 | }); |
| 8243 | this._isNonMetricLocale = NON_METRIC_LOCALES.includes(l10n.getLanguage()); |
| 8244 | } |
| 8245 | async open() { |
| 8246 | await Promise.all([this.overlayManager.open(this.dialog), this._dataAvailableCapability.promise]); |
| 8247 | const currentPageNumber = this._currentPageNumber; |
| 8248 | const pagesRotation = this._pagesRotation; |
| 8249 | if (this.#fieldData && currentPageNumber === this.#fieldData._currentPageNumber && pagesRotation === this.#fieldData._pagesRotation) { |
| 8250 | this.#updateUI(); |
| 8251 | return; |
| 8252 | } |
| 8253 | const { |
| 8254 | info, |
| 8255 | contentLength |
| 8256 | } = await this.pdfDocument.getMetadata(); |
| 8257 | const [fileName, fileSize, creationDate, modificationDate, pageSize, isLinearized] = await Promise.all([this._fileNameLookup(), this.#parseFileSize(contentLength), this.#parseDate(info.CreationDate), this.#parseDate(info.ModDate), this.pdfDocument.getPage(currentPageNumber).then(pdfPage => { |
| 8258 | return this.#parsePageSize(getPageSizeInches(pdfPage), pagesRotation); |
| 8259 | }), this.#parseLinearization(info.IsLinearized)]); |
| 8260 | this.#fieldData = Object.freeze({ |
| 8261 | fileName, |
| 8262 | fileSize, |
| 8263 | title: info.Title, |
| 8264 | author: info.Author, |
| 8265 | subject: info.Subject, |
| 8266 | keywords: info.Keywords, |
| 8267 | creationDate, |
| 8268 | modificationDate, |
| 8269 | creator: info.Creator, |
| 8270 | producer: info.Producer, |
| 8271 | version: info.PDFFormatVersion, |
| 8272 | pageCount: this.pdfDocument.numPages, |
| 8273 | pageSize, |
| 8274 | linearized: isLinearized, |
| 8275 | _currentPageNumber: currentPageNumber, |
| 8276 | _pagesRotation: pagesRotation |
| 8277 | }); |
| 8278 | this.#updateUI(); |
| 8279 | const { |
| 8280 | length |
| 8281 | } = await this.pdfDocument.getDownloadInfo(); |
| 8282 | if (contentLength === length) { |
| 8283 | return; |
| 8284 | } |
| 8285 | const data = Object.assign(Object.create(null), this.#fieldData); |
| 8286 | data.fileSize = await this.#parseFileSize(length); |
| 8287 | this.#fieldData = Object.freeze(data); |
| 8288 | this.#updateUI(); |
| 8289 | } |
| 8290 | async close() { |
| 8291 | this.overlayManager.close(this.dialog); |
| 8292 | } |
| 8293 | setDocument(pdfDocument) { |
| 8294 | if (this.pdfDocument) { |
| 8295 | this.#reset(); |
| 8296 | this.#updateUI(true); |
| 8297 | } |
| 8298 | if (!pdfDocument) { |
| 8299 | return; |
| 8300 | } |
| 8301 | this.pdfDocument = pdfDocument; |
| 8302 | this._dataAvailableCapability.resolve(); |
| 8303 | } |
| 8304 | #reset() { |
| 8305 | this.pdfDocument = null; |
| 8306 | this.#fieldData = null; |
| 8307 | this._dataAvailableCapability = Promise.withResolvers(); |
| 8308 | this._currentPageNumber = 1; |
| 8309 | this._pagesRotation = 0; |
| 8310 | } |
| 8311 | #updateUI(reset = false) { |
| 8312 | if (reset || !this.#fieldData) { |
| 8313 | for (const id in this.fields) { |
| 8314 | this.fields[id].textContent = DEFAULT_FIELD_CONTENT; |
| 8315 | } |
| 8316 | return; |
| 8317 | } |
| 8318 | if (this.overlayManager.active !== this.dialog) { |
| 8319 | return; |
| 8320 | } |
| 8321 | for (const id in this.fields) { |
| 8322 | const content = this.#fieldData[id]; |
| 8323 | this.fields[id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT; |
| 8324 | } |
| 8325 | } |
| 8326 | async #parseFileSize(fileSize = 0) { |
| 8327 | const kb = fileSize / 1024, |
| 8328 | mb = kb / 1024; |
| 8329 | if (!kb) { |
| 8330 | return undefined; |
| 8331 | } |
| 8332 | return this.l10n.get(`pdfjs-document-properties-${mb >= 1 ? "mb" : "kb"}`, { |
| 8333 | size_mb: mb >= 1 && (+mb.toPrecision(3)).toLocaleString(), |
| 8334 | size_kb: mb < 1 && (+kb.toPrecision(3)).toLocaleString(), |
| 8335 | size_b: fileSize.toLocaleString() |
| 8336 | }); |
| 8337 | } |
| 8338 | async #parsePageSize(pageSizeInches, pagesRotation) { |
| 8339 | if (!pageSizeInches) { |
| 8340 | return undefined; |
| 8341 | } |
| 8342 | if (pagesRotation % 180 !== 0) { |
| 8343 | pageSizeInches = { |
| 8344 | width: pageSizeInches.height, |
| 8345 | height: pageSizeInches.width |
| 8346 | }; |
| 8347 | } |
| 8348 | const isPortrait = isPortraitOrientation(pageSizeInches); |
| 8349 | let sizeInches = { |
| 8350 | width: Math.round(pageSizeInches.width * 100) / 100, |
| 8351 | height: Math.round(pageSizeInches.height * 100) / 100 |
| 8352 | }; |
| 8353 | let sizeMillimeters = { |
| 8354 | width: Math.round(pageSizeInches.width * 25.4 * 10) / 10, |
| 8355 | height: Math.round(pageSizeInches.height * 25.4 * 10) / 10 |
| 8356 | }; |
| 8357 | let rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES); |
| 8358 | if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) { |
| 8359 | const exactMillimeters = { |
| 8360 | width: pageSizeInches.width * 25.4, |
| 8361 | height: pageSizeInches.height * 25.4 |
| 8362 | }; |
| 8363 | const intMillimeters = { |
| 8364 | width: Math.round(sizeMillimeters.width), |
| 8365 | height: Math.round(sizeMillimeters.height) |
| 8366 | }; |
| 8367 | if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) { |
| 8368 | rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES); |
| 8369 | if (rawName) { |
| 8370 | sizeInches = { |
| 8371 | width: Math.round(intMillimeters.width / 25.4 * 100) / 100, |
| 8372 | height: Math.round(intMillimeters.height / 25.4 * 100) / 100 |
| 8373 | }; |
| 8374 | sizeMillimeters = intMillimeters; |
| 8375 | } |
| 8376 | } |
| 8377 | } |
| 8378 | const [{ |
| 8379 | width, |
| 8380 | height |
| 8381 | }, unit, name, orientation] = await Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get(`pdfjs-document-properties-page-size-unit-${this._isNonMetricLocale ? "inches" : "millimeters"}`), rawName && this.l10n.get(`pdfjs-document-properties-page-size-name-${rawName}`), this.l10n.get(`pdfjs-document-properties-page-size-orientation-${isPortrait ? "portrait" : "landscape"}`)]); |
| 8382 | return this.l10n.get(`pdfjs-document-properties-page-size-dimension-${name ? "name-" : ""}string`, { |
| 8383 | width: width.toLocaleString(), |
| 8384 | height: height.toLocaleString(), |
| 8385 | unit, |
| 8386 | name, |
| 8387 | orientation |
| 8388 | }); |
| 8389 | } |
| 8390 | async #parseDate(inputDate) { |
| 8391 | const dateObject = PDFDateString.toDateObject(inputDate); |
| 8392 | if (!dateObject) { |
| 8393 | return undefined; |
| 8394 | } |
| 8395 | return this.l10n.get("pdfjs-document-properties-date-string", { |
| 8396 | date: dateObject.toLocaleDateString(), |
| 8397 | time: dateObject.toLocaleTimeString() |
| 8398 | }); |
| 8399 | } |
| 8400 | #parseLinearization(isLinearized) { |
| 8401 | return this.l10n.get(`pdfjs-document-properties-linearized-${isLinearized ? "yes" : "no"}`); |
| 8402 | } |
| 8403 | } |
| 8404 | |
| 8405 | ;// CONCATENATED MODULE: ./web/pdf_find_utils.js |
| 8406 | |
| 8407 | const CharacterType = { |
| 8408 | SPACE: 0, |
| 8409 | ALPHA_LETTER: 1, |
| 8410 | PUNCT: 2, |
| 8411 | HAN_LETTER: 3, |
| 8412 | KATAKANA_LETTER: 4, |
| 8413 | HIRAGANA_LETTER: 5, |
| 8414 | HALFWIDTH_KATAKANA_LETTER: 6, |
| 8415 | THAI_LETTER: 7 |
| 8416 | }; |
| 8417 | function isAlphabeticalScript(charCode) { |
| 8418 | return charCode < 0x2e80; |
| 8419 | } |
| 8420 | function isAscii(charCode) { |
| 8421 | return (charCode & 0xff80) === 0; |
| 8422 | } |
| 8423 | function isAsciiAlpha(charCode) { |
| 8424 | return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a; |
| 8425 | } |
| 8426 | function isAsciiDigit(charCode) { |
| 8427 | return charCode >= 0x30 && charCode <= 0x39; |
| 8428 | } |
| 8429 | function isAsciiSpace(charCode) { |
| 8430 | return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a; |
| 8431 | } |
| 8432 | function isHan(charCode) { |
| 8433 | return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff; |
| 8434 | } |
| 8435 | function isKatakana(charCode) { |
| 8436 | return charCode >= 0x30a0 && charCode <= 0x30ff; |
| 8437 | } |
| 8438 | function isHiragana(charCode) { |
| 8439 | return charCode >= 0x3040 && charCode <= 0x309f; |
| 8440 | } |
| 8441 | function isHalfwidthKatakana(charCode) { |
| 8442 | return charCode >= 0xff60 && charCode <= 0xff9f; |
| 8443 | } |
| 8444 | function isThai(charCode) { |
| 8445 | return (charCode & 0xff80) === 0x0e00; |
| 8446 | } |
| 8447 | function getCharacterType(charCode) { |
| 8448 | if (isAlphabeticalScript(charCode)) { |
| 8449 | if (isAscii(charCode)) { |
| 8450 | if (isAsciiSpace(charCode)) { |
| 8451 | return CharacterType.SPACE; |
| 8452 | } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) { |
| 8453 | return CharacterType.ALPHA_LETTER; |
| 8454 | } |
| 8455 | return CharacterType.PUNCT; |
| 8456 | } else if (isThai(charCode)) { |
| 8457 | return CharacterType.THAI_LETTER; |
| 8458 | } else if (charCode === 0xa0) { |
| 8459 | return CharacterType.SPACE; |
| 8460 | } |
| 8461 | return CharacterType.ALPHA_LETTER; |
| 8462 | } |
| 8463 | if (isHan(charCode)) { |
| 8464 | return CharacterType.HAN_LETTER; |
| 8465 | } else if (isKatakana(charCode)) { |
| 8466 | return CharacterType.KATAKANA_LETTER; |
| 8467 | } else if (isHiragana(charCode)) { |
| 8468 | return CharacterType.HIRAGANA_LETTER; |
| 8469 | } else if (isHalfwidthKatakana(charCode)) { |
| 8470 | return CharacterType.HALFWIDTH_KATAKANA_LETTER; |
| 8471 | } |
| 8472 | return CharacterType.ALPHA_LETTER; |
| 8473 | } |
| 8474 | let NormalizeWithNFKC; |
| 8475 | function getNormalizeWithNFKC() { |
| 8476 | NormalizeWithNFKC ||= ` ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-� |
| 8477 | ·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃� |
| 8478 | -ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-� |
| 8479 | �� |
| 8480 | |
| 8481 | -� |
| 8482 | �� |
| 8483 | �-� |
| 8484 | �↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩`; |
| 8485 | return NormalizeWithNFKC; |
| 8486 | } |
| 8487 | |
| 8488 | ;// CONCATENATED MODULE: ./web/pdf_find_controller.js |
| 8489 | |
| 8490 | |
| 8491 | |
| 8492 | |
| 8493 | |
| 8494 | |
| 8495 | |
| 8496 | |
| 8497 | |
| 8498 | |
| 8499 | |
| 8500 | |
| 8501 | |
| 8502 | |
| 8503 | const FindState = { |
| 8504 | FOUND: 0, |
| 8505 | NOT_FOUND: 1, |
| 8506 | WRAPPED: 2, |
| 8507 | PENDING: 3 |
| 8508 | }; |
| 8509 | const FIND_TIMEOUT = 250; |
| 8510 | const MATCH_SCROLL_OFFSET_TOP = -50; |
| 8511 | const MATCH_SCROLL_OFFSET_LEFT = -400; |
| 8512 | const CHARACTERS_TO_NORMALIZE = { |
| 8513 | "\u2010": "-", |
| 8514 | "\u2018": "'", |
| 8515 | "\u2019": "'", |
| 8516 | "\u201A": "'", |
| 8517 | "\u201B": "'", |
| 8518 | "\u201C": '"', |
| 8519 | "\u201D": '"', |
| 8520 | "\u201E": '"', |
| 8521 | "\u201F": '"', |
| 8522 | "\u00BC": "1/4", |
| 8523 | "\u00BD": "1/2", |
| 8524 | "\u00BE": "3/4" |
| 8525 | }; |
| 8526 | const 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]); |
| 8527 | let DIACRITICS_EXCEPTION_STR; |
| 8528 | const DIACRITICS_REG_EXP = /\p{M}+/gu; |
| 8529 | const SPECIAL_CHARS_REG_EXP = /([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu; |
| 8530 | const NOT_DIACRITIC_FROM_END_REG_EXP = /([^\p{M}])\p{M}*$/u; |
| 8531 | const NOT_DIACRITIC_FROM_START_REG_EXP = /^\p{M}*([^\p{M}])/u; |
| 8532 | const SYLLABLES_REG_EXP = /[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g; |
| 8533 | const SYLLABLES_LENGTHS = new Map(); |
| 8534 | const FIRST_CHAR_SYLLABLES_REG_EXP = "[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]"; |
| 8535 | const NFKC_CHARS_TO_NORMALIZE = new Map(); |
| 8536 | let noSyllablesRegExp = null; |
| 8537 | let withSyllablesRegExp = null; |
| 8538 | function normalize(text) { |
| 8539 | const syllablePositions = []; |
| 8540 | let m; |
| 8541 | while ((m = SYLLABLES_REG_EXP.exec(text)) !== null) { |
| 8542 | let { |
| 8543 | index |
| 8544 | } = m; |
| 8545 | for (const char of m[0]) { |
| 8546 | let len = SYLLABLES_LENGTHS.get(char); |
| 8547 | if (!len) { |
| 8548 | len = char.normalize("NFD").length; |
| 8549 | SYLLABLES_LENGTHS.set(char, len); |
| 8550 | } |
| 8551 | syllablePositions.push([len, index++]); |
| 8552 | } |
| 8553 | } |
| 8554 | let normalizationRegex; |
| 8555 | if (syllablePositions.length === 0 && noSyllablesRegExp) { |
| 8556 | normalizationRegex = noSyllablesRegExp; |
| 8557 | } else if (syllablePositions.length > 0 && withSyllablesRegExp) { |
| 8558 | normalizationRegex = withSyllablesRegExp; |
| 8559 | } else { |
| 8560 | const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join(""); |
| 8561 | const toNormalizeWithNFKC = getNormalizeWithNFKC(); |
| 8562 | const CJK = "(?:\\p{Ideographic}|[\u3040-\u30FF])"; |
| 8563 | const HKDiacritics = "(?:\u3099|\u309A)"; |
| 8564 | const regexp = `([${replace}])|([${toNormalizeWithNFKC}])|(${HKDiacritics}\\n)|(\\p{M}+(?:-\\n)?)|(\\S-\\n)|(${CJK}\\n)|(\\n)`; |
| 8565 | if (syllablePositions.length === 0) { |
| 8566 | normalizationRegex = noSyllablesRegExp = new RegExp(regexp + "|(\\u0000)", "gum"); |
| 8567 | } else { |
| 8568 | normalizationRegex = withSyllablesRegExp = new RegExp(regexp + `|(${FIRST_CHAR_SYLLABLES_REG_EXP})`, "gum"); |
| 8569 | } |
| 8570 | } |
| 8571 | const rawDiacriticsPositions = []; |
| 8572 | while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) { |
| 8573 | rawDiacriticsPositions.push([m[0].length, m.index]); |
| 8574 | } |
| 8575 | let normalized = text.normalize("NFD"); |
| 8576 | const positions = [[0, 0]]; |
| 8577 | let rawDiacriticsIndex = 0; |
| 8578 | let syllableIndex = 0; |
| 8579 | let shift = 0; |
| 8580 | let shiftOrigin = 0; |
| 8581 | let eol = 0; |
| 8582 | let hasDiacritics = false; |
| 8583 | normalized = normalized.replace(normalizationRegex, (match, p1, p2, p3, p4, p5, p6, p7, p8, i) => { |
| 8584 | i -= shiftOrigin; |
| 8585 | if (p1) { |
| 8586 | const replacement = CHARACTERS_TO_NORMALIZE[p1]; |
| 8587 | const jj = replacement.length; |
| 8588 | for (let j = 1; j < jj; j++) { |
| 8589 | positions.push([i - shift + j, shift - j]); |
| 8590 | } |
| 8591 | shift -= jj - 1; |
| 8592 | return replacement; |
| 8593 | } |
| 8594 | if (p2) { |
| 8595 | let replacement = NFKC_CHARS_TO_NORMALIZE.get(p2); |
| 8596 | if (!replacement) { |
| 8597 | replacement = p2.normalize("NFKC"); |
| 8598 | NFKC_CHARS_TO_NORMALIZE.set(p2, replacement); |
| 8599 | } |
| 8600 | const jj = replacement.length; |
| 8601 | for (let j = 1; j < jj; j++) { |
| 8602 | positions.push([i - shift + j, shift - j]); |
| 8603 | } |
| 8604 | shift -= jj - 1; |
| 8605 | return replacement; |
| 8606 | } |
| 8607 | if (p3) { |
| 8608 | hasDiacritics = true; |
| 8609 | if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) { |
| 8610 | ++rawDiacriticsIndex; |
| 8611 | } else { |
| 8612 | positions.push([i - 1 - shift + 1, shift - 1]); |
| 8613 | shift -= 1; |
| 8614 | shiftOrigin += 1; |
| 8615 | } |
| 8616 | positions.push([i - shift + 1, shift]); |
| 8617 | shiftOrigin += 1; |
| 8618 | eol += 1; |
| 8619 | return p3.charAt(0); |
| 8620 | } |
| 8621 | if (p4) { |
| 8622 | const hasTrailingDashEOL = p4.endsWith("\n"); |
| 8623 | const len = hasTrailingDashEOL ? p4.length - 2 : p4.length; |
| 8624 | hasDiacritics = true; |
| 8625 | let jj = len; |
| 8626 | if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) { |
| 8627 | jj -= rawDiacriticsPositions[rawDiacriticsIndex][0]; |
| 8628 | ++rawDiacriticsIndex; |
| 8629 | } |
| 8630 | for (let j = 1; j <= jj; j++) { |
| 8631 | positions.push([i - 1 - shift + j, shift - j]); |
| 8632 | } |
| 8633 | shift -= jj; |
| 8634 | shiftOrigin += jj; |
| 8635 | if (hasTrailingDashEOL) { |
| 8636 | i += len - 1; |
| 8637 | positions.push([i - shift + 1, 1 + shift]); |
| 8638 | shift += 1; |
| 8639 | shiftOrigin += 1; |
| 8640 | eol += 1; |
| 8641 | return p4.slice(0, len); |
| 8642 | } |
| 8643 | return p4; |
| 8644 | } |
| 8645 | if (p5) { |
| 8646 | const len = p5.length - 2; |
| 8647 | positions.push([i - shift + len, 1 + shift]); |
| 8648 | shift += 1; |
| 8649 | shiftOrigin += 1; |
| 8650 | eol += 1; |
| 8651 | return p5.slice(0, -2); |
| 8652 | } |
| 8653 | if (p6) { |
| 8654 | const len = p6.length - 1; |
| 8655 | positions.push([i - shift + len, shift]); |
| 8656 | shiftOrigin += 1; |
| 8657 | eol += 1; |
| 8658 | return p6.slice(0, -1); |
| 8659 | } |
| 8660 | if (p7) { |
| 8661 | positions.push([i - shift + 1, shift - 1]); |
| 8662 | shift -= 1; |
| 8663 | shiftOrigin += 1; |
| 8664 | eol += 1; |
| 8665 | return " "; |
| 8666 | } |
| 8667 | if (i + eol === syllablePositions[syllableIndex]?.[1]) { |
| 8668 | const newCharLen = syllablePositions[syllableIndex][0] - 1; |
| 8669 | ++syllableIndex; |
| 8670 | for (let j = 1; j <= newCharLen; j++) { |
| 8671 | positions.push([i - (shift - j), shift - j]); |
| 8672 | } |
| 8673 | shift -= newCharLen; |
| 8674 | shiftOrigin += newCharLen; |
| 8675 | } |
| 8676 | return p8; |
| 8677 | }); |
| 8678 | positions.push([normalized.length, shift]); |
| 8679 | return [normalized, positions, hasDiacritics]; |
| 8680 | } |
| 8681 | function getOriginalIndex(diffs, pos, len) { |
| 8682 | if (!diffs) { |
| 8683 | return [pos, len]; |
| 8684 | } |
| 8685 | const start = pos; |
| 8686 | const end = pos + len - 1; |
| 8687 | let i = binarySearchFirstItem(diffs, x => x[0] >= start); |
| 8688 | if (diffs[i][0] > start) { |
| 8689 | --i; |
| 8690 | } |
| 8691 | let j = binarySearchFirstItem(diffs, x => x[0] >= end, i); |
| 8692 | if (diffs[j][0] > end) { |
| 8693 | --j; |
| 8694 | } |
| 8695 | const oldStart = start + diffs[i][1]; |
| 8696 | const oldEnd = end + diffs[j][1]; |
| 8697 | const oldLen = oldEnd + 1 - oldStart; |
| 8698 | return [oldStart, oldLen]; |
| 8699 | } |
| 8700 | class PDFFindController { |
| 8701 | #state = null; |
| 8702 | #updateMatchesCountOnProgress = true; |
| 8703 | #visitedPagesCount = 0; |
| 8704 | constructor({ |
| 8705 | linkService, |
| 8706 | eventBus, |
| 8707 | updateMatchesCountOnProgress = true |
| 8708 | }) { |
| 8709 | this._linkService = linkService; |
| 8710 | this._eventBus = eventBus; |
| 8711 | this.#updateMatchesCountOnProgress = updateMatchesCountOnProgress; |
| 8712 | this.onIsPageVisible = null; |
| 8713 | this.#reset(); |
| 8714 | eventBus._on("find", this.#onFind.bind(this)); |
| 8715 | eventBus._on("findbarclose", this.#onFindBarClose.bind(this)); |
| 8716 | } |
| 8717 | get highlightMatches() { |
| 8718 | return this._highlightMatches; |
| 8719 | } |
| 8720 | get pageMatches() { |
| 8721 | return this._pageMatches; |
| 8722 | } |
| 8723 | get pageMatchesLength() { |
| 8724 | return this._pageMatchesLength; |
| 8725 | } |
| 8726 | get selected() { |
| 8727 | return this._selected; |
| 8728 | } |
| 8729 | get state() { |
| 8730 | return this.#state; |
| 8731 | } |
| 8732 | setDocument(pdfDocument) { |
| 8733 | if (this._pdfDocument) { |
| 8734 | this.#reset(); |
| 8735 | } |
| 8736 | if (!pdfDocument) { |
| 8737 | return; |
| 8738 | } |
| 8739 | this._pdfDocument = pdfDocument; |
| 8740 | this._firstPageCapability.resolve(); |
| 8741 | } |
| 8742 | #onFind(state) { |
| 8743 | if (!state) { |
| 8744 | return; |
| 8745 | } |
| 8746 | const pdfDocument = this._pdfDocument; |
| 8747 | const { |
| 8748 | type |
| 8749 | } = state; |
| 8750 | if (this.#state === null || this.#shouldDirtyMatch(state)) { |
| 8751 | this._dirtyMatch = true; |
| 8752 | } |
| 8753 | this.#state = state; |
| 8754 | if (type !== "highlightallchange") { |
| 8755 | this.#updateUIState(FindState.PENDING); |
| 8756 | } |
| 8757 | this._firstPageCapability.promise.then(() => { |
| 8758 | if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) { |
| 8759 | return; |
| 8760 | } |
| 8761 | this.#extractText(); |
| 8762 | const findbarClosed = !this._highlightMatches; |
| 8763 | const pendingTimeout = !!this._findTimeout; |
| 8764 | if (this._findTimeout) { |
| 8765 | clearTimeout(this._findTimeout); |
| 8766 | this._findTimeout = null; |
| 8767 | } |
| 8768 | if (!type) { |
| 8769 | this._findTimeout = setTimeout(() => { |
| 8770 | this.#nextMatch(); |
| 8771 | this._findTimeout = null; |
| 8772 | }, FIND_TIMEOUT); |
| 8773 | } else if (this._dirtyMatch) { |
| 8774 | this.#nextMatch(); |
| 8775 | } else if (type === "again") { |
| 8776 | this.#nextMatch(); |
| 8777 | if (findbarClosed && this.#state.highlightAll) { |
| 8778 | this.#updateAllPages(); |
| 8779 | } |
| 8780 | } else if (type === "highlightallchange") { |
| 8781 | if (pendingTimeout) { |
| 8782 | this.#nextMatch(); |
| 8783 | } else { |
| 8784 | this._highlightMatches = true; |
| 8785 | } |
| 8786 | this.#updateAllPages(); |
| 8787 | } else { |
| 8788 | this.#nextMatch(); |
| 8789 | } |
| 8790 | }); |
| 8791 | } |
| 8792 | scrollMatchIntoView({ |
| 8793 | element = null, |
| 8794 | selectedLeft = 0, |
| 8795 | pageIndex = -1, |
| 8796 | matchIndex = -1 |
| 8797 | }) { |
| 8798 | if (!this._scrollMatches || !element) { |
| 8799 | return; |
| 8800 | } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) { |
| 8801 | return; |
| 8802 | } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) { |
| 8803 | return; |
| 8804 | } |
| 8805 | this._scrollMatches = false; |
| 8806 | const spot = { |
| 8807 | top: MATCH_SCROLL_OFFSET_TOP, |
| 8808 | left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT |
| 8809 | }; |
| 8810 | scrollIntoView(element, spot, true); |
| 8811 | } |
| 8812 | #reset() { |
| 8813 | this._highlightMatches = false; |
| 8814 | this._scrollMatches = false; |
| 8815 | this._pdfDocument = null; |
| 8816 | this._pageMatches = []; |
| 8817 | this._pageMatchesLength = []; |
| 8818 | this.#visitedPagesCount = 0; |
| 8819 | this.#state = null; |
| 8820 | this._selected = { |
| 8821 | pageIdx: -1, |
| 8822 | matchIdx: -1 |
| 8823 | }; |
| 8824 | this._offset = { |
| 8825 | pageIdx: null, |
| 8826 | matchIdx: null, |
| 8827 | wrapped: false |
| 8828 | }; |
| 8829 | this._extractTextPromises = []; |
| 8830 | this._pageContents = []; |
| 8831 | this._pageDiffs = []; |
| 8832 | this._hasDiacritics = []; |
| 8833 | this._matchesCountTotal = 0; |
| 8834 | this._pagesToSearch = null; |
| 8835 | this._pendingFindMatches = new Set(); |
| 8836 | this._resumePageIdx = null; |
| 8837 | this._dirtyMatch = false; |
| 8838 | clearTimeout(this._findTimeout); |
| 8839 | this._findTimeout = null; |
| 8840 | this._firstPageCapability = Promise.withResolvers(); |
| 8841 | } |
| 8842 | get #query() { |
| 8843 | const { |
| 8844 | query |
| 8845 | } = this.#state; |
| 8846 | if (typeof query === "string") { |
| 8847 | if (query !== this._rawQuery) { |
| 8848 | this._rawQuery = query; |
| 8849 | [this._normalizedQuery] = normalize(query); |
| 8850 | } |
| 8851 | return this._normalizedQuery; |
| 8852 | } |
| 8853 | return (query || []).filter(q => !!q).map(q => normalize(q)[0]); |
| 8854 | } |
| 8855 | #shouldDirtyMatch(state) { |
| 8856 | const newQuery = state.query, |
| 8857 | prevQuery = this.#state.query; |
| 8858 | const newType = typeof newQuery, |
| 8859 | prevType = typeof prevQuery; |
| 8860 | if (newType !== prevType) { |
| 8861 | return true; |
| 8862 | } |
| 8863 | if (newType === "string") { |
| 8864 | if (newQuery !== prevQuery) { |
| 8865 | return true; |
| 8866 | } |
| 8867 | } else if (JSON.stringify(newQuery) !== JSON.stringify(prevQuery)) { |
| 8868 | return true; |
| 8869 | } |
| 8870 | switch (state.type) { |
| 8871 | case "again": |
| 8872 | const pageNumber = this._selected.pageIdx + 1; |
| 8873 | const linkService = this._linkService; |
| 8874 | return pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !(this.onIsPageVisible?.(pageNumber) ?? true); |
| 8875 | case "highlightallchange": |
| 8876 | return false; |
| 8877 | } |
| 8878 | return true; |
| 8879 | } |
| 8880 | #isEntireWord(content, startIdx, length) { |
| 8881 | let match = content.slice(0, startIdx).match(NOT_DIACRITIC_FROM_END_REG_EXP); |
| 8882 | if (match) { |
| 8883 | const first = content.charCodeAt(startIdx); |
| 8884 | const limit = match[1].charCodeAt(0); |
| 8885 | if (getCharacterType(first) === getCharacterType(limit)) { |
| 8886 | return false; |
| 8887 | } |
| 8888 | } |
| 8889 | match = content.slice(startIdx + length).match(NOT_DIACRITIC_FROM_START_REG_EXP); |
| 8890 | if (match) { |
| 8891 | const last = content.charCodeAt(startIdx + length - 1); |
| 8892 | const limit = match[1].charCodeAt(0); |
| 8893 | if (getCharacterType(last) === getCharacterType(limit)) { |
| 8894 | return false; |
| 8895 | } |
| 8896 | } |
| 8897 | return true; |
| 8898 | } |
| 8899 | #calculateRegExpMatch(query, entireWord, pageIndex, pageContent) { |
| 8900 | const matches = this._pageMatches[pageIndex] = []; |
| 8901 | const matchesLength = this._pageMatchesLength[pageIndex] = []; |
| 8902 | if (!query) { |
| 8903 | return; |
| 8904 | } |
| 8905 | const diffs = this._pageDiffs[pageIndex]; |
| 8906 | let match; |
| 8907 | while ((match = query.exec(pageContent)) !== null) { |
| 8908 | if (entireWord && !this.#isEntireWord(pageContent, match.index, match[0].length)) { |
| 8909 | continue; |
| 8910 | } |
| 8911 | const [matchPos, matchLen] = getOriginalIndex(diffs, match.index, match[0].length); |
| 8912 | if (matchLen) { |
| 8913 | matches.push(matchPos); |
| 8914 | matchesLength.push(matchLen); |
| 8915 | } |
| 8916 | } |
| 8917 | } |
| 8918 | #convertToRegExpString(query, hasDiacritics) { |
| 8919 | const { |
| 8920 | matchDiacritics |
| 8921 | } = this.#state; |
| 8922 | let isUnicode = false; |
| 8923 | query = query.replaceAll(SPECIAL_CHARS_REG_EXP, (match, p1, p2, p3, p4, p5) => { |
| 8924 | if (p1) { |
| 8925 | return `[ ]*\\${p1}[ ]*`; |
| 8926 | } |
| 8927 | if (p2) { |
| 8928 | return `[ ]*${p2}[ ]*`; |
| 8929 | } |
| 8930 | if (p3) { |
| 8931 | return "[ ]+"; |
| 8932 | } |
| 8933 | if (matchDiacritics) { |
| 8934 | return p4 || p5; |
| 8935 | } |
| 8936 | if (p4) { |
| 8937 | return DIACRITICS_EXCEPTION.has(p4.charCodeAt(0)) ? p4 : ""; |
| 8938 | } |
| 8939 | if (hasDiacritics) { |
| 8940 | isUnicode = true; |
| 8941 | return `${p5}\\p{M}*`; |
| 8942 | } |
| 8943 | return p5; |
| 8944 | }); |
| 8945 | const trailingSpaces = "[ ]*"; |
| 8946 | if (query.endsWith(trailingSpaces)) { |
| 8947 | query = query.slice(0, query.length - trailingSpaces.length); |
| 8948 | } |
| 8949 | if (matchDiacritics) { |
| 8950 | if (hasDiacritics) { |
| 8951 | DIACRITICS_EXCEPTION_STR ||= String.fromCharCode(...DIACRITICS_EXCEPTION); |
| 8952 | isUnicode = true; |
| 8953 | query = `${query}(?=[${DIACRITICS_EXCEPTION_STR}]|[^\\p{M}]|$)`; |
| 8954 | } |
| 8955 | } |
| 8956 | return [isUnicode, query]; |
| 8957 | } |
| 8958 | #calculateMatch(pageIndex) { |
| 8959 | let query = this.#query; |
| 8960 | if (query.length === 0) { |
| 8961 | return; |
| 8962 | } |
| 8963 | const { |
| 8964 | caseSensitive, |
| 8965 | entireWord |
| 8966 | } = this.#state; |
| 8967 | const pageContent = this._pageContents[pageIndex]; |
| 8968 | const hasDiacritics = this._hasDiacritics[pageIndex]; |
| 8969 | let isUnicode = false; |
| 8970 | if (typeof query === "string") { |
| 8971 | [isUnicode, query] = this.#convertToRegExpString(query, hasDiacritics); |
| 8972 | } else { |
| 8973 | query = query.sort().reverse().map(q => { |
| 8974 | const [isUnicodePart, queryPart] = this.#convertToRegExpString(q, hasDiacritics); |
| 8975 | isUnicode ||= isUnicodePart; |
| 8976 | return `(${queryPart})`; |
| 8977 | }).join("|"); |
| 8978 | } |
| 8979 | const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`; |
| 8980 | query = query ? new RegExp(query, flags) : null; |
| 8981 | this.#calculateRegExpMatch(query, entireWord, pageIndex, pageContent); |
| 8982 | if (this.#state.highlightAll) { |
| 8983 | this.#updatePage(pageIndex); |
| 8984 | } |
| 8985 | if (this._resumePageIdx === pageIndex) { |
| 8986 | this._resumePageIdx = null; |
| 8987 | this.#nextPageMatch(); |
| 8988 | } |
| 8989 | const pageMatchesCount = this._pageMatches[pageIndex].length; |
| 8990 | this._matchesCountTotal += pageMatchesCount; |
| 8991 | if (this.#updateMatchesCountOnProgress) { |
| 8992 | if (pageMatchesCount > 0) { |
| 8993 | this.#updateUIResultsCount(); |
| 8994 | } |
| 8995 | } else if (++this.#visitedPagesCount === this._linkService.pagesCount) { |
| 8996 | this.#updateUIResultsCount(); |
| 8997 | } |
| 8998 | } |
| 8999 | #extractText() { |
| 9000 | if (this._extractTextPromises.length > 0) { |
| 9001 | return; |
| 9002 | } |
| 9003 | let deferred = Promise.resolve(); |
| 9004 | const textOptions = { |
| 9005 | disableNormalization: true |
| 9006 | }; |
| 9007 | for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) { |
| 9008 | const { |
| 9009 | promise, |
| 9010 | resolve |
| 9011 | } = Promise.withResolvers(); |
| 9012 | this._extractTextPromises[i] = promise; |
| 9013 | deferred = deferred.then(() => { |
| 9014 | return this._pdfDocument.getPage(i + 1).then(pdfPage => pdfPage.getTextContent(textOptions)).then(textContent => { |
| 9015 | const strBuf = []; |
| 9016 | for (const textItem of textContent.items) { |
| 9017 | strBuf.push(textItem.str); |
| 9018 | if (textItem.hasEOL) { |
| 9019 | strBuf.push("\n"); |
| 9020 | } |
| 9021 | } |
| 9022 | [this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] = normalize(strBuf.join("")); |
| 9023 | resolve(); |
| 9024 | }, reason => { |
| 9025 | console.error(`Unable to get text content for page ${i + 1}`, reason); |
| 9026 | this._pageContents[i] = ""; |
| 9027 | this._pageDiffs[i] = null; |
| 9028 | this._hasDiacritics[i] = false; |
| 9029 | resolve(); |
| 9030 | }); |
| 9031 | }); |
| 9032 | } |
| 9033 | } |
| 9034 | #updatePage(index) { |
| 9035 | if (this._scrollMatches && this._selected.pageIdx === index) { |
| 9036 | this._linkService.page = index + 1; |
| 9037 | } |
| 9038 | this._eventBus.dispatch("updatetextlayermatches", { |
| 9039 | source: this, |
| 9040 | pageIndex: index |
| 9041 | }); |
| 9042 | } |
| 9043 | #updateAllPages() { |
| 9044 | this._eventBus.dispatch("updatetextlayermatches", { |
| 9045 | source: this, |
| 9046 | pageIndex: -1 |
| 9047 | }); |
| 9048 | } |
| 9049 | #nextMatch() { |
| 9050 | const previous = this.#state.findPrevious; |
| 9051 | const currentPageIndex = this._linkService.page - 1; |
| 9052 | const numPages = this._linkService.pagesCount; |
| 9053 | this._highlightMatches = true; |
| 9054 | if (this._dirtyMatch) { |
| 9055 | this._dirtyMatch = false; |
| 9056 | this._selected.pageIdx = this._selected.matchIdx = -1; |
| 9057 | this._offset.pageIdx = currentPageIndex; |
| 9058 | this._offset.matchIdx = null; |
| 9059 | this._offset.wrapped = false; |
| 9060 | this._resumePageIdx = null; |
| 9061 | this._pageMatches.length = 0; |
| 9062 | this._pageMatchesLength.length = 0; |
| 9063 | this.#visitedPagesCount = 0; |
| 9064 | this._matchesCountTotal = 0; |
| 9065 | this.#updateAllPages(); |
| 9066 | for (let i = 0; i < numPages; i++) { |
| 9067 | if (this._pendingFindMatches.has(i)) { |
| 9068 | continue; |
| 9069 | } |
| 9070 | this._pendingFindMatches.add(i); |
| 9071 | this._extractTextPromises[i].then(() => { |
| 9072 | this._pendingFindMatches.delete(i); |
| 9073 | this.#calculateMatch(i); |
| 9074 | }); |
| 9075 | } |
| 9076 | } |
| 9077 | const query = this.#query; |
| 9078 | if (query.length === 0) { |
| 9079 | this.#updateUIState(FindState.FOUND); |
| 9080 | return; |
| 9081 | } |
| 9082 | if (this._resumePageIdx) { |
| 9083 | return; |
| 9084 | } |
| 9085 | const offset = this._offset; |
| 9086 | this._pagesToSearch = numPages; |
| 9087 | if (offset.matchIdx !== null) { |
| 9088 | const numPageMatches = this._pageMatches[offset.pageIdx].length; |
| 9089 | if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) { |
| 9090 | offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1; |
| 9091 | this.#updateMatch(true); |
| 9092 | return; |
| 9093 | } |
| 9094 | this.#advanceOffsetPage(previous); |
| 9095 | } |
| 9096 | this.#nextPageMatch(); |
| 9097 | } |
| 9098 | #matchesReady(matches) { |
| 9099 | const offset = this._offset; |
| 9100 | const numMatches = matches.length; |
| 9101 | const previous = this.#state.findPrevious; |
| 9102 | if (numMatches) { |
| 9103 | offset.matchIdx = previous ? numMatches - 1 : 0; |
| 9104 | this.#updateMatch(true); |
| 9105 | return true; |
| 9106 | } |
| 9107 | this.#advanceOffsetPage(previous); |
| 9108 | if (offset.wrapped) { |
| 9109 | offset.matchIdx = null; |
| 9110 | if (this._pagesToSearch < 0) { |
| 9111 | this.#updateMatch(false); |
| 9112 | return true; |
| 9113 | } |
| 9114 | } |
| 9115 | return false; |
| 9116 | } |
| 9117 | #nextPageMatch() { |
| 9118 | if (this._resumePageIdx !== null) { |
| 9119 | console.error("There can only be one pending page."); |
| 9120 | } |
| 9121 | let matches = null; |
| 9122 | do { |
| 9123 | const pageIdx = this._offset.pageIdx; |
| 9124 | matches = this._pageMatches[pageIdx]; |
| 9125 | if (!matches) { |
| 9126 | this._resumePageIdx = pageIdx; |
| 9127 | break; |
| 9128 | } |
| 9129 | } while (!this.#matchesReady(matches)); |
| 9130 | } |
| 9131 | #advanceOffsetPage(previous) { |
| 9132 | const offset = this._offset; |
| 9133 | const numPages = this._linkService.pagesCount; |
| 9134 | offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1; |
| 9135 | offset.matchIdx = null; |
| 9136 | this._pagesToSearch--; |
| 9137 | if (offset.pageIdx >= numPages || offset.pageIdx < 0) { |
| 9138 | offset.pageIdx = previous ? numPages - 1 : 0; |
| 9139 | offset.wrapped = true; |
| 9140 | } |
| 9141 | } |
| 9142 | #updateMatch(found = false) { |
| 9143 | let state = FindState.NOT_FOUND; |
| 9144 | const wrapped = this._offset.wrapped; |
| 9145 | this._offset.wrapped = false; |
| 9146 | if (found) { |
| 9147 | const previousPage = this._selected.pageIdx; |
| 9148 | this._selected.pageIdx = this._offset.pageIdx; |
| 9149 | this._selected.matchIdx = this._offset.matchIdx; |
| 9150 | state = wrapped ? FindState.WRAPPED : FindState.FOUND; |
| 9151 | if (previousPage !== -1 && previousPage !== this._selected.pageIdx) { |
| 9152 | this.#updatePage(previousPage); |
| 9153 | } |
| 9154 | } |
| 9155 | this.#updateUIState(state, this.#state.findPrevious); |
| 9156 | if (this._selected.pageIdx !== -1) { |
| 9157 | this._scrollMatches = true; |
| 9158 | this.#updatePage(this._selected.pageIdx); |
| 9159 | } |
| 9160 | } |
| 9161 | #onFindBarClose(evt) { |
| 9162 | const pdfDocument = this._pdfDocument; |
| 9163 | this._firstPageCapability.promise.then(() => { |
| 9164 | if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) { |
| 9165 | return; |
| 9166 | } |
| 9167 | if (this._findTimeout) { |
| 9168 | clearTimeout(this._findTimeout); |
| 9169 | this._findTimeout = null; |
| 9170 | } |
| 9171 | if (this._resumePageIdx) { |
| 9172 | this._resumePageIdx = null; |
| 9173 | this._dirtyMatch = true; |
| 9174 | } |
| 9175 | this.#updateUIState(FindState.FOUND); |
| 9176 | this._highlightMatches = false; |
| 9177 | this.#updateAllPages(); |
| 9178 | }); |
| 9179 | } |
| 9180 | #requestMatchesCount() { |
| 9181 | const { |
| 9182 | pageIdx, |
| 9183 | matchIdx |
| 9184 | } = this._selected; |
| 9185 | let current = 0, |
| 9186 | total = this._matchesCountTotal; |
| 9187 | if (matchIdx !== -1) { |
| 9188 | for (let i = 0; i < pageIdx; i++) { |
| 9189 | current += this._pageMatches[i]?.length || 0; |
| 9190 | } |
| 9191 | current += matchIdx + 1; |
| 9192 | } |
| 9193 | if (current < 1 || current > total) { |
| 9194 | current = total = 0; |
| 9195 | } |
| 9196 | return { |
| 9197 | current, |
| 9198 | total |
| 9199 | }; |
| 9200 | } |
| 9201 | #updateUIResultsCount() { |
| 9202 | this._eventBus.dispatch("updatefindmatchescount", { |
| 9203 | source: this, |
| 9204 | matchesCount: this.#requestMatchesCount() |
| 9205 | }); |
| 9206 | } |
| 9207 | #updateUIState(state, previous = false) { |
| 9208 | if (!this.#updateMatchesCountOnProgress && (this.#visitedPagesCount !== this._linkService.pagesCount || state === FindState.PENDING)) { |
| 9209 | return; |
| 9210 | } |
| 9211 | this._eventBus.dispatch("updatefindcontrolstate", { |
| 9212 | source: this, |
| 9213 | state, |
| 9214 | previous, |
| 9215 | matchesCount: this.#requestMatchesCount(), |
| 9216 | rawQuery: this.#state?.query ?? null |
| 9217 | }); |
| 9218 | } |
| 9219 | } |
| 9220 | |
| 9221 | ;// CONCATENATED MODULE: ./web/pdf_find_bar.js |
| 9222 | |
| 9223 | |
| 9224 | const MATCHES_COUNT_LIMIT = 1000; |
| 9225 | class PDFFindBar { |
| 9226 | #resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this)); |
| 9227 | constructor(options, eventBus) { |
| 9228 | this.opened = false; |
| 9229 | this.bar = options.bar; |
| 9230 | this.toggleButton = options.toggleButton; |
| 9231 | this.findField = options.findField; |
| 9232 | this.highlightAll = options.highlightAllCheckbox; |
| 9233 | this.caseSensitive = options.caseSensitiveCheckbox; |
| 9234 | this.matchDiacritics = options.matchDiacriticsCheckbox; |
| 9235 | this.entireWord = options.entireWordCheckbox; |
| 9236 | this.findMsg = options.findMsg; |
| 9237 | this.findResultsCount = options.findResultsCount; |
| 9238 | this.findPreviousButton = options.findPreviousButton; |
| 9239 | this.findNextButton = options.findNextButton; |
| 9240 | this.eventBus = eventBus; |
| 9241 | this.toggleButton.addEventListener("click", () => { |
| 9242 | this.toggle(); |
| 9243 | }); |
| 9244 | this.findField.addEventListener("input", () => { |
| 9245 | this.dispatchEvent(""); |
| 9246 | }); |
| 9247 | this.bar.addEventListener("keydown", e => { |
| 9248 | switch (e.keyCode) { |
| 9249 | case 13: |
| 9250 | if (e.target === this.findField) { |
| 9251 | this.dispatchEvent("again", e.shiftKey); |
| 9252 | } |
| 9253 | break; |
| 9254 | case 27: |
| 9255 | this.close(); |
| 9256 | break; |
| 9257 | } |
| 9258 | }); |
| 9259 | this.findPreviousButton.addEventListener("click", () => { |
| 9260 | this.dispatchEvent("again", true); |
| 9261 | }); |
| 9262 | this.findNextButton.addEventListener("click", () => { |
| 9263 | this.dispatchEvent("again", false); |
| 9264 | }); |
| 9265 | this.highlightAll.addEventListener("click", () => { |
| 9266 | this.dispatchEvent("highlightallchange"); |
| 9267 | }); |
| 9268 | this.caseSensitive.addEventListener("click", () => { |
| 9269 | this.dispatchEvent("casesensitivitychange"); |
| 9270 | }); |
| 9271 | this.entireWord.addEventListener("click", () => { |
| 9272 | this.dispatchEvent("entirewordchange"); |
| 9273 | }); |
| 9274 | this.matchDiacritics.addEventListener("click", () => { |
| 9275 | this.dispatchEvent("diacriticmatchingchange"); |
| 9276 | }); |
| 9277 | } |
| 9278 | reset() { |
| 9279 | this.updateUIState(); |
| 9280 | } |
| 9281 | dispatchEvent(type, findPrev = false) { |
| 9282 | this.eventBus.dispatch("find", { |
| 9283 | source: this, |
| 9284 | type, |
| 9285 | query: this.findField.value, |
| 9286 | caseSensitive: this.caseSensitive.checked, |
| 9287 | entireWord: this.entireWord.checked, |
| 9288 | highlightAll: this.highlightAll.checked, |
| 9289 | findPrevious: findPrev, |
| 9290 | matchDiacritics: this.matchDiacritics.checked |
| 9291 | }); |
| 9292 | } |
| 9293 | updateUIState(state, previous, matchesCount) { |
| 9294 | const { |
| 9295 | findField, |
| 9296 | findMsg |
| 9297 | } = this; |
| 9298 | let findMsgId = "", |
| 9299 | status = ""; |
| 9300 | switch (state) { |
| 9301 | case FindState.FOUND: |
| 9302 | break; |
| 9303 | case FindState.PENDING: |
| 9304 | status = "pending"; |
| 9305 | break; |
| 9306 | case FindState.NOT_FOUND: |
| 9307 | findMsgId = "pdfjs-find-not-found"; |
| 9308 | status = "notFound"; |
| 9309 | break; |
| 9310 | case FindState.WRAPPED: |
| 9311 | findMsgId = `pdfjs-find-reached-${previous ? "top" : "bottom"}`; |
| 9312 | break; |
| 9313 | } |
| 9314 | findField.setAttribute("data-status", status); |
| 9315 | findField.setAttribute("aria-invalid", state === FindState.NOT_FOUND); |
| 9316 | findMsg.setAttribute("data-status", status); |
| 9317 | if (findMsgId) { |
| 9318 | findMsg.setAttribute("data-l10n-id", findMsgId); |
| 9319 | } else { |
| 9320 | findMsg.removeAttribute("data-l10n-id"); |
| 9321 | findMsg.textContent = ""; |
| 9322 | } |
| 9323 | this.updateResultsCount(matchesCount); |
| 9324 | } |
| 9325 | updateResultsCount({ |
| 9326 | current = 0, |
| 9327 | total = 0 |
| 9328 | } = {}) { |
| 9329 | const { |
| 9330 | findResultsCount |
| 9331 | } = this; |
| 9332 | if (total > 0) { |
| 9333 | const limit = MATCHES_COUNT_LIMIT; |
| 9334 | findResultsCount.setAttribute("data-l10n-id", `pdfjs-find-match-count${total > limit ? "-limit" : ""}`); |
| 9335 | findResultsCount.setAttribute("data-l10n-args", JSON.stringify({ |
| 9336 | limit, |
| 9337 | current, |
| 9338 | total |
| 9339 | })); |
| 9340 | } else { |
| 9341 | findResultsCount.removeAttribute("data-l10n-id"); |
| 9342 | findResultsCount.textContent = ""; |
| 9343 | } |
| 9344 | } |
| 9345 | open() { |
| 9346 | if (!this.opened) { |
| 9347 | this.#resizeObserver.observe(this.bar.parentNode); |
| 9348 | this.#resizeObserver.observe(this.bar); |
| 9349 | this.opened = true; |
| 9350 | toggleExpandedBtn(this.toggleButton, true, this.bar); |
| 9351 | } |
| 9352 | this.findField.select(); |
| 9353 | this.findField.focus(); |
| 9354 | } |
| 9355 | close() { |
| 9356 | if (!this.opened) { |
| 9357 | return; |
| 9358 | } |
| 9359 | this.#resizeObserver.disconnect(); |
| 9360 | this.opened = false; |
| 9361 | toggleExpandedBtn(this.toggleButton, false, this.bar); |
| 9362 | this.eventBus.dispatch("findbarclose", { |
| 9363 | source: this |
| 9364 | }); |
| 9365 | } |
| 9366 | toggle() { |
| 9367 | if (this.opened) { |
| 9368 | this.close(); |
| 9369 | } else { |
| 9370 | this.open(); |
| 9371 | } |
| 9372 | } |
| 9373 | #resizeObserverCallback(entries) { |
| 9374 | const { |
| 9375 | bar |
| 9376 | } = this; |
| 9377 | bar.classList.remove("wrapContainers"); |
| 9378 | const findbarHeight = bar.clientHeight; |
| 9379 | const inputContainerHeight = bar.firstElementChild.clientHeight; |
| 9380 | if (findbarHeight > inputContainerHeight) { |
| 9381 | bar.classList.add("wrapContainers"); |
| 9382 | } |
| 9383 | } |
| 9384 | } |
| 9385 | |
| 9386 | ;// CONCATENATED MODULE: ./web/pdf_history.js |
| 9387 | |
| 9388 | |
| 9389 | const HASH_CHANGE_TIMEOUT = 1000; |
| 9390 | const POSITION_UPDATED_THRESHOLD = 50; |
| 9391 | const UPDATE_VIEWAREA_TIMEOUT = 1000; |
| 9392 | function getCurrentHash() { |
| 9393 | return document.location.hash; |
| 9394 | } |
| 9395 | class PDFHistory { |
| 9396 | #eventAbortController = null; |
| 9397 | constructor({ |
| 9398 | linkService, |
| 9399 | eventBus |
| 9400 | }) { |
| 9401 | this.linkService = linkService; |
| 9402 | this.eventBus = eventBus; |
| 9403 | this._initialized = false; |
| 9404 | this._fingerprint = ""; |
| 9405 | this.reset(); |
| 9406 | this.eventBus._on("pagesinit", () => { |
| 9407 | this._isPagesLoaded = false; |
| 9408 | this.eventBus._on("pagesloaded", evt => { |
| 9409 | this._isPagesLoaded = !!evt.pagesCount; |
| 9410 | }, { |
| 9411 | once: true |
| 9412 | }); |
| 9413 | }); |
| 9414 | } |
| 9415 | initialize({ |
| 9416 | fingerprint, |
| 9417 | resetHistory = false, |
| 9418 | updateUrl = false |
| 9419 | }) { |
| 9420 | if (!fingerprint || typeof fingerprint !== "string") { |
| 9421 | console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.'); |
| 9422 | return; |
| 9423 | } |
| 9424 | if (this._initialized) { |
| 9425 | this.reset(); |
| 9426 | } |
| 9427 | const reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint; |
| 9428 | this._fingerprint = fingerprint; |
| 9429 | this._updateUrl = updateUrl === true; |
| 9430 | this._initialized = true; |
| 9431 | this.#bindEvents(); |
| 9432 | const state = window.history.state; |
| 9433 | this._popStateInProgress = false; |
| 9434 | this._blockHashChange = 0; |
| 9435 | this._currentHash = getCurrentHash(); |
| 9436 | this._numPositionUpdates = 0; |
| 9437 | this._uid = this._maxUid = 0; |
| 9438 | this._destination = null; |
| 9439 | this._position = null; |
| 9440 | if (!this.#isValidState(state, true) || resetHistory) { |
| 9441 | const { |
| 9442 | hash, |
| 9443 | page, |
| 9444 | rotation |
| 9445 | } = this.#parseCurrentHash(true); |
| 9446 | if (!hash || reInitialized || resetHistory) { |
| 9447 | this.#pushOrReplaceState(null, true); |
| 9448 | return; |
| 9449 | } |
| 9450 | this.#pushOrReplaceState({ |
| 9451 | hash, |
| 9452 | page, |
| 9453 | rotation |
| 9454 | }, true); |
| 9455 | return; |
| 9456 | } |
| 9457 | const destination = state.destination; |
| 9458 | this.#updateInternalState(destination, state.uid, true); |
| 9459 | if (destination.rotation !== undefined) { |
| 9460 | this._initialRotation = destination.rotation; |
| 9461 | } |
| 9462 | if (destination.dest) { |
| 9463 | this._initialBookmark = JSON.stringify(destination.dest); |
| 9464 | this._destination.page = null; |
| 9465 | } else if (destination.hash) { |
| 9466 | this._initialBookmark = destination.hash; |
| 9467 | } else if (destination.page) { |
| 9468 | this._initialBookmark = `page=${destination.page}`; |
| 9469 | } |
| 9470 | } |
| 9471 | reset() { |
| 9472 | if (this._initialized) { |
| 9473 | this.#pageHide(); |
| 9474 | this._initialized = false; |
| 9475 | this.#unbindEvents(); |
| 9476 | } |
| 9477 | if (this._updateViewareaTimeout) { |
| 9478 | clearTimeout(this._updateViewareaTimeout); |
| 9479 | this._updateViewareaTimeout = null; |
| 9480 | } |
| 9481 | this._initialBookmark = null; |
| 9482 | this._initialRotation = null; |
| 9483 | } |
| 9484 | push({ |
| 9485 | namedDest = null, |
| 9486 | explicitDest, |
| 9487 | pageNumber |
| 9488 | }) { |
| 9489 | if (!this._initialized) { |
| 9490 | return; |
| 9491 | } |
| 9492 | if (namedDest && typeof namedDest !== "string") { |
| 9493 | console.error("PDFHistory.push: " + `"${namedDest}" is not a valid namedDest parameter.`); |
| 9494 | return; |
| 9495 | } else if (!Array.isArray(explicitDest)) { |
| 9496 | console.error("PDFHistory.push: " + `"${explicitDest}" is not a valid explicitDest parameter.`); |
| 9497 | return; |
| 9498 | } else if (!this.#isValidPage(pageNumber)) { |
| 9499 | if (pageNumber !== null || this._destination) { |
| 9500 | console.error("PDFHistory.push: " + `"${pageNumber}" is not a valid pageNumber parameter.`); |
| 9501 | return; |
| 9502 | } |
| 9503 | } |
| 9504 | const hash = namedDest || JSON.stringify(explicitDest); |
| 9505 | if (!hash) { |
| 9506 | return; |
| 9507 | } |
| 9508 | let forceReplace = false; |
| 9509 | if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) { |
| 9510 | if (this._destination.page) { |
| 9511 | return; |
| 9512 | } |
| 9513 | forceReplace = true; |
| 9514 | } |
| 9515 | if (this._popStateInProgress && !forceReplace) { |
| 9516 | return; |
| 9517 | } |
| 9518 | this.#pushOrReplaceState({ |
| 9519 | dest: explicitDest, |
| 9520 | hash, |
| 9521 | page: pageNumber, |
| 9522 | rotation: this.linkService.rotation |
| 9523 | }, forceReplace); |
| 9524 | if (!this._popStateInProgress) { |
| 9525 | this._popStateInProgress = true; |
| 9526 | Promise.resolve().then(() => { |
| 9527 | this._popStateInProgress = false; |
| 9528 | }); |
| 9529 | } |
| 9530 | } |
| 9531 | pushPage(pageNumber) { |
| 9532 | if (!this._initialized) { |
| 9533 | return; |
| 9534 | } |
| 9535 | if (!this.#isValidPage(pageNumber)) { |
| 9536 | console.error(`PDFHistory.pushPage: "${pageNumber}" is not a valid page number.`); |
| 9537 | return; |
| 9538 | } |
| 9539 | if (this._destination?.page === pageNumber) { |
| 9540 | return; |
| 9541 | } |
| 9542 | if (this._popStateInProgress) { |
| 9543 | return; |
| 9544 | } |
| 9545 | this.#pushOrReplaceState({ |
| 9546 | dest: null, |
| 9547 | hash: `page=${pageNumber}`, |
| 9548 | page: pageNumber, |
| 9549 | rotation: this.linkService.rotation |
| 9550 | }); |
| 9551 | if (!this._popStateInProgress) { |
| 9552 | this._popStateInProgress = true; |
| 9553 | Promise.resolve().then(() => { |
| 9554 | this._popStateInProgress = false; |
| 9555 | }); |
| 9556 | } |
| 9557 | } |
| 9558 | pushCurrentPosition() { |
| 9559 | if (!this._initialized || this._popStateInProgress) { |
| 9560 | return; |
| 9561 | } |
| 9562 | this.#tryPushCurrentPosition(); |
| 9563 | } |
| 9564 | back() { |
| 9565 | if (!this._initialized || this._popStateInProgress) { |
| 9566 | return; |
| 9567 | } |
| 9568 | const state = window.history.state; |
| 9569 | if (this.#isValidState(state) && state.uid > 0) { |
| 9570 | window.history.back(); |
| 9571 | } |
| 9572 | } |
| 9573 | forward() { |
| 9574 | if (!this._initialized || this._popStateInProgress) { |
| 9575 | return; |
| 9576 | } |
| 9577 | const state = window.history.state; |
| 9578 | if (this.#isValidState(state) && state.uid < this._maxUid) { |
| 9579 | window.history.forward(); |
| 9580 | } |
| 9581 | } |
| 9582 | get popStateInProgress() { |
| 9583 | return this._initialized && (this._popStateInProgress || this._blockHashChange > 0); |
| 9584 | } |
| 9585 | get initialBookmark() { |
| 9586 | return this._initialized ? this._initialBookmark : null; |
| 9587 | } |
| 9588 | get initialRotation() { |
| 9589 | return this._initialized ? this._initialRotation : null; |
| 9590 | } |
| 9591 | #pushOrReplaceState(destination, forceReplace = false) { |
| 9592 | const shouldReplace = forceReplace || !this._destination; |
| 9593 | const newState = { |
| 9594 | fingerprint: this._fingerprint, |
| 9595 | uid: shouldReplace ? this._uid : this._uid + 1, |
| 9596 | destination |
| 9597 | }; |
| 9598 | this.#updateInternalState(destination, newState.uid); |
| 9599 | let newUrl; |
| 9600 | if (this._updateUrl && destination?.hash) { |
| 9601 | const baseUrl = document.location.href.split("#", 1)[0]; |
| 9602 | if (!baseUrl.startsWith("file://")) { |
| 9603 | newUrl = `${baseUrl}#${destination.hash}`; |
| 9604 | } |
| 9605 | } |
| 9606 | if (shouldReplace) { |
| 9607 | window.history.replaceState(newState, "", newUrl); |
| 9608 | } else { |
| 9609 | window.history.pushState(newState, "", newUrl); |
| 9610 | } |
| 9611 | } |
| 9612 | #tryPushCurrentPosition(temporary = false) { |
| 9613 | if (!this._position) { |
| 9614 | return; |
| 9615 | } |
| 9616 | let position = this._position; |
| 9617 | if (temporary) { |
| 9618 | position = Object.assign(Object.create(null), this._position); |
| 9619 | position.temporary = true; |
| 9620 | } |
| 9621 | if (!this._destination) { |
| 9622 | this.#pushOrReplaceState(position); |
| 9623 | return; |
| 9624 | } |
| 9625 | if (this._destination.temporary) { |
| 9626 | this.#pushOrReplaceState(position, true); |
| 9627 | return; |
| 9628 | } |
| 9629 | if (this._destination.hash === position.hash) { |
| 9630 | return; |
| 9631 | } |
| 9632 | if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) { |
| 9633 | return; |
| 9634 | } |
| 9635 | let forceReplace = false; |
| 9636 | if (this._destination.page >= position.first && this._destination.page <= position.page) { |
| 9637 | if (this._destination.dest !== undefined || !this._destination.first) { |
| 9638 | return; |
| 9639 | } |
| 9640 | forceReplace = true; |
| 9641 | } |
| 9642 | this.#pushOrReplaceState(position, forceReplace); |
| 9643 | } |
| 9644 | #isValidPage(val) { |
| 9645 | return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount; |
| 9646 | } |
| 9647 | #isValidState(state, checkReload = false) { |
| 9648 | if (!state) { |
| 9649 | return false; |
| 9650 | } |
| 9651 | if (state.fingerprint !== this._fingerprint) { |
| 9652 | if (checkReload) { |
| 9653 | if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) { |
| 9654 | return false; |
| 9655 | } |
| 9656 | const [perfEntry] = performance.getEntriesByType("navigation"); |
| 9657 | if (perfEntry?.type !== "reload") { |
| 9658 | return false; |
| 9659 | } |
| 9660 | } else { |
| 9661 | return false; |
| 9662 | } |
| 9663 | } |
| 9664 | if (!Number.isInteger(state.uid) || state.uid < 0) { |
| 9665 | return false; |
| 9666 | } |
| 9667 | if (state.destination === null || typeof state.destination !== "object") { |
| 9668 | return false; |
| 9669 | } |
| 9670 | return true; |
| 9671 | } |
| 9672 | #updateInternalState(destination, uid, removeTemporary = false) { |
| 9673 | if (this._updateViewareaTimeout) { |
| 9674 | clearTimeout(this._updateViewareaTimeout); |
| 9675 | this._updateViewareaTimeout = null; |
| 9676 | } |
| 9677 | if (removeTemporary && destination?.temporary) { |
| 9678 | delete destination.temporary; |
| 9679 | } |
| 9680 | this._destination = destination; |
| 9681 | this._uid = uid; |
| 9682 | this._maxUid = Math.max(this._maxUid, uid); |
| 9683 | this._numPositionUpdates = 0; |
| 9684 | } |
| 9685 | #parseCurrentHash(checkNameddest = false) { |
| 9686 | const hash = unescape(getCurrentHash()).substring(1); |
| 9687 | const params = parseQueryString(hash); |
| 9688 | const nameddest = params.get("nameddest") || ""; |
| 9689 | let page = params.get("page") | 0; |
| 9690 | if (!this.#isValidPage(page) || checkNameddest && nameddest.length > 0) { |
| 9691 | page = null; |
| 9692 | } |
| 9693 | return { |
| 9694 | hash, |
| 9695 | page, |
| 9696 | rotation: this.linkService.rotation |
| 9697 | }; |
| 9698 | } |
| 9699 | #updateViewarea({ |
| 9700 | location |
| 9701 | }) { |
| 9702 | if (this._updateViewareaTimeout) { |
| 9703 | clearTimeout(this._updateViewareaTimeout); |
| 9704 | this._updateViewareaTimeout = null; |
| 9705 | } |
| 9706 | this._position = { |
| 9707 | hash: location.pdfOpenParams.substring(1), |
| 9708 | page: this.linkService.page, |
| 9709 | first: location.pageNumber, |
| 9710 | rotation: location.rotation |
| 9711 | }; |
| 9712 | if (this._popStateInProgress) { |
| 9713 | return; |
| 9714 | } |
| 9715 | if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) { |
| 9716 | this._numPositionUpdates++; |
| 9717 | } |
| 9718 | if (UPDATE_VIEWAREA_TIMEOUT > 0) { |
| 9719 | this._updateViewareaTimeout = setTimeout(() => { |
| 9720 | if (!this._popStateInProgress) { |
| 9721 | this.#tryPushCurrentPosition(true); |
| 9722 | } |
| 9723 | this._updateViewareaTimeout = null; |
| 9724 | }, UPDATE_VIEWAREA_TIMEOUT); |
| 9725 | } |
| 9726 | } |
| 9727 | #popState({ |
| 9728 | state |
| 9729 | }) { |
| 9730 | const newHash = getCurrentHash(), |
| 9731 | hashChanged = this._currentHash !== newHash; |
| 9732 | this._currentHash = newHash; |
| 9733 | if (!state) { |
| 9734 | this._uid++; |
| 9735 | const { |
| 9736 | hash, |
| 9737 | page, |
| 9738 | rotation |
| 9739 | } = this.#parseCurrentHash(); |
| 9740 | this.#pushOrReplaceState({ |
| 9741 | hash, |
| 9742 | page, |
| 9743 | rotation |
| 9744 | }, true); |
| 9745 | return; |
| 9746 | } |
| 9747 | if (!this.#isValidState(state)) { |
| 9748 | return; |
| 9749 | } |
| 9750 | this._popStateInProgress = true; |
| 9751 | if (hashChanged) { |
| 9752 | this._blockHashChange++; |
| 9753 | waitOnEventOrTimeout({ |
| 9754 | target: window, |
| 9755 | name: "hashchange", |
| 9756 | delay: HASH_CHANGE_TIMEOUT |
| 9757 | }).then(() => { |
| 9758 | this._blockHashChange--; |
| 9759 | }); |
| 9760 | } |
| 9761 | const destination = state.destination; |
| 9762 | this.#updateInternalState(destination, state.uid, true); |
| 9763 | if (isValidRotation(destination.rotation)) { |
| 9764 | this.linkService.rotation = destination.rotation; |
| 9765 | } |
| 9766 | if (destination.dest) { |
| 9767 | this.linkService.goToDestination(destination.dest); |
| 9768 | } else if (destination.hash) { |
| 9769 | this.linkService.setHash(destination.hash); |
| 9770 | } else if (destination.page) { |
| 9771 | this.linkService.page = destination.page; |
| 9772 | } |
| 9773 | Promise.resolve().then(() => { |
| 9774 | this._popStateInProgress = false; |
| 9775 | }); |
| 9776 | } |
| 9777 | #pageHide() { |
| 9778 | if (!this._destination || this._destination.temporary) { |
| 9779 | this.#tryPushCurrentPosition(); |
| 9780 | } |
| 9781 | } |
| 9782 | #bindEvents() { |
| 9783 | if (this.#eventAbortController) { |
| 9784 | return; |
| 9785 | } |
| 9786 | this.#eventAbortController = new AbortController(); |
| 9787 | const { |
| 9788 | signal |
| 9789 | } = this.#eventAbortController; |
| 9790 | this.eventBus._on("updateviewarea", this.#updateViewarea.bind(this), { |
| 9791 | signal |
| 9792 | }); |
| 9793 | window.addEventListener("popstate", this.#popState.bind(this), { |
| 9794 | signal |
| 9795 | }); |
| 9796 | window.addEventListener("pagehide", this.#pageHide.bind(this), { |
| 9797 | signal |
| 9798 | }); |
| 9799 | } |
| 9800 | #unbindEvents() { |
| 9801 | this.#eventAbortController?.abort(); |
| 9802 | this.#eventAbortController = null; |
| 9803 | } |
| 9804 | } |
| 9805 | function isDestHashesEqual(destHash, pushHash) { |
| 9806 | if (typeof destHash !== "string" || typeof pushHash !== "string") { |
| 9807 | return false; |
| 9808 | } |
| 9809 | if (destHash === pushHash) { |
| 9810 | return true; |
| 9811 | } |
| 9812 | const nameddest = parseQueryString(destHash).get("nameddest"); |
| 9813 | if (nameddest === pushHash) { |
| 9814 | return true; |
| 9815 | } |
| 9816 | return false; |
| 9817 | } |
| 9818 | function isDestArraysEqual(firstDest, secondDest) { |
| 9819 | function isEntryEqual(first, second) { |
| 9820 | if (typeof first !== typeof second) { |
| 9821 | return false; |
| 9822 | } |
| 9823 | if (Array.isArray(first) || Array.isArray(second)) { |
| 9824 | return false; |
| 9825 | } |
| 9826 | if (first !== null && typeof first === "object" && second !== null) { |
| 9827 | if (Object.keys(first).length !== Object.keys(second).length) { |
| 9828 | return false; |
| 9829 | } |
| 9830 | for (const key in first) { |
| 9831 | if (!isEntryEqual(first[key], second[key])) { |
| 9832 | return false; |
| 9833 | } |
| 9834 | } |
| 9835 | return true; |
| 9836 | } |
| 9837 | return first === second || Number.isNaN(first) && Number.isNaN(second); |
| 9838 | } |
| 9839 | if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) { |
| 9840 | return false; |
| 9841 | } |
| 9842 | if (firstDest.length !== secondDest.length) { |
| 9843 | return false; |
| 9844 | } |
| 9845 | for (let i = 0, ii = firstDest.length; i < ii; i++) { |
| 9846 | if (!isEntryEqual(firstDest[i], secondDest[i])) { |
| 9847 | return false; |
| 9848 | } |
| 9849 | } |
| 9850 | return true; |
| 9851 | } |
| 9852 | |
| 9853 | ;// CONCATENATED MODULE: ./web/pdf_layer_viewer.js |
| 9854 | |
| 9855 | |
| 9856 | class PDFLayerViewer extends BaseTreeViewer { |
| 9857 | constructor(options) { |
| 9858 | super(options); |
| 9859 | this.eventBus._on("optionalcontentconfigchanged", evt => { |
| 9860 | this.#updateLayers(evt.promise); |
| 9861 | }); |
| 9862 | this.eventBus._on("resetlayers", () => { |
| 9863 | this.#updateLayers(); |
| 9864 | }); |
| 9865 | this.eventBus._on("togglelayerstree", this._toggleAllTreeItems.bind(this)); |
| 9866 | } |
| 9867 | reset() { |
| 9868 | super.reset(); |
| 9869 | this._optionalContentConfig = null; |
| 9870 | this._optionalContentHash = null; |
| 9871 | } |
| 9872 | _dispatchEvent(layersCount) { |
| 9873 | this.eventBus.dispatch("layersloaded", { |
| 9874 | source: this, |
| 9875 | layersCount |
| 9876 | }); |
| 9877 | } |
| 9878 | _bindLink(element, { |
| 9879 | groupId, |
| 9880 | input |
| 9881 | }) { |
| 9882 | const setVisibility = () => { |
| 9883 | this._optionalContentConfig.setVisibility(groupId, input.checked); |
| 9884 | this._optionalContentHash = this._optionalContentConfig.getHash(); |
| 9885 | this.eventBus.dispatch("optionalcontentconfig", { |
| 9886 | source: this, |
| 9887 | promise: Promise.resolve(this._optionalContentConfig) |
| 9888 | }); |
| 9889 | }; |
| 9890 | element.onclick = evt => { |
| 9891 | if (evt.target === input) { |
| 9892 | setVisibility(); |
| 9893 | return true; |
| 9894 | } else if (evt.target !== element) { |
| 9895 | return true; |
| 9896 | } |
| 9897 | input.checked = !input.checked; |
| 9898 | setVisibility(); |
| 9899 | return false; |
| 9900 | }; |
| 9901 | } |
| 9902 | async _setNestedName(element, { |
| 9903 | name = null |
| 9904 | }) { |
| 9905 | if (typeof name === "string") { |
| 9906 | element.textContent = this._normalizeTextContent(name); |
| 9907 | return; |
| 9908 | } |
| 9909 | element.textContent = await this._l10n.get("pdfjs-additional-layers"); |
| 9910 | element.style.fontStyle = "italic"; |
| 9911 | } |
| 9912 | _addToggleButton(div, { |
| 9913 | name = null |
| 9914 | }) { |
| 9915 | super._addToggleButton(div, name === null); |
| 9916 | } |
| 9917 | _toggleAllTreeItems() { |
| 9918 | if (!this._optionalContentConfig) { |
| 9919 | return; |
| 9920 | } |
| 9921 | super._toggleAllTreeItems(); |
| 9922 | } |
| 9923 | render({ |
| 9924 | optionalContentConfig, |
| 9925 | pdfDocument |
| 9926 | }) { |
| 9927 | if (this._optionalContentConfig) { |
| 9928 | this.reset(); |
| 9929 | } |
| 9930 | this._optionalContentConfig = optionalContentConfig || null; |
| 9931 | this._pdfDocument = pdfDocument || null; |
| 9932 | const groups = optionalContentConfig?.getOrder(); |
| 9933 | if (!groups) { |
| 9934 | this._dispatchEvent(0); |
| 9935 | return; |
| 9936 | } |
| 9937 | this._optionalContentHash = optionalContentConfig.getHash(); |
| 9938 | const fragment = document.createDocumentFragment(), |
| 9939 | queue = [{ |
| 9940 | parent: fragment, |
| 9941 | groups |
| 9942 | }]; |
| 9943 | let layersCount = 0, |
| 9944 | hasAnyNesting = false; |
| 9945 | while (queue.length > 0) { |
| 9946 | const levelData = queue.shift(); |
| 9947 | for (const groupId of levelData.groups) { |
| 9948 | const div = document.createElement("div"); |
| 9949 | div.className = "treeItem"; |
| 9950 | const element = document.createElement("a"); |
| 9951 | div.append(element); |
| 9952 | if (typeof groupId === "object") { |
| 9953 | hasAnyNesting = true; |
| 9954 | this._addToggleButton(div, groupId); |
| 9955 | this._setNestedName(element, groupId); |
| 9956 | const itemsDiv = document.createElement("div"); |
| 9957 | itemsDiv.className = "treeItems"; |
| 9958 | div.append(itemsDiv); |
| 9959 | queue.push({ |
| 9960 | parent: itemsDiv, |
| 9961 | groups: groupId.order |
| 9962 | }); |
| 9963 | } else { |
| 9964 | const group = optionalContentConfig.getGroup(groupId); |
| 9965 | const input = document.createElement("input"); |
| 9966 | this._bindLink(element, { |
| 9967 | groupId, |
| 9968 | input |
| 9969 | }); |
| 9970 | input.type = "checkbox"; |
| 9971 | input.checked = group.visible; |
| 9972 | const label = document.createElement("label"); |
| 9973 | label.textContent = this._normalizeTextContent(group.name); |
| 9974 | label.append(input); |
| 9975 | element.append(label); |
| 9976 | layersCount++; |
| 9977 | } |
| 9978 | levelData.parent.append(div); |
| 9979 | } |
| 9980 | } |
| 9981 | this._finishRendering(fragment, layersCount, hasAnyNesting); |
| 9982 | } |
| 9983 | async #updateLayers(promise = null) { |
| 9984 | if (!this._optionalContentConfig) { |
| 9985 | return; |
| 9986 | } |
| 9987 | const pdfDocument = this._pdfDocument; |
| 9988 | const optionalContentConfig = await (promise || pdfDocument.getOptionalContentConfig({ |
| 9989 | intent: "display" |
| 9990 | })); |
| 9991 | if (pdfDocument !== this._pdfDocument) { |
| 9992 | return; |
| 9993 | } |
| 9994 | if (promise) { |
| 9995 | if (optionalContentConfig.getHash() === this._optionalContentHash) { |
| 9996 | return; |
| 9997 | } |
| 9998 | } else { |
| 9999 | this.eventBus.dispatch("optionalcontentconfig", { |
| 10000 | source: this, |
| 10001 | promise: Promise.resolve(optionalContentConfig) |
| 10002 | }); |
| 10003 | } |
| 10004 | this.render({ |
| 10005 | optionalContentConfig, |
| 10006 | pdfDocument: this._pdfDocument |
| 10007 | }); |
| 10008 | } |
| 10009 | } |
| 10010 | |
| 10011 | ;// CONCATENATED MODULE: ./web/pdf_outline_viewer.js |
| 10012 | |
| 10013 | |
| 10014 | |
| 10015 | |
| 10016 | class PDFOutlineViewer extends BaseTreeViewer { |
| 10017 | constructor(options) { |
| 10018 | super(options); |
| 10019 | this.linkService = options.linkService; |
| 10020 | this.downloadManager = options.downloadManager; |
| 10021 | this.eventBus._on("toggleoutlinetree", this._toggleAllTreeItems.bind(this)); |
| 10022 | this.eventBus._on("currentoutlineitem", this._currentOutlineItem.bind(this)); |
| 10023 | this.eventBus._on("pagechanging", evt => { |
| 10024 | this._currentPageNumber = evt.pageNumber; |
| 10025 | }); |
| 10026 | this.eventBus._on("pagesloaded", evt => { |
| 10027 | this._isPagesLoaded = !!evt.pagesCount; |
| 10028 | this._currentOutlineItemCapability?.resolve(this._isPagesLoaded); |
| 10029 | }); |
| 10030 | this.eventBus._on("sidebarviewchanged", evt => { |
| 10031 | this._sidebarView = evt.view; |
| 10032 | }); |
| 10033 | } |
| 10034 | reset() { |
| 10035 | super.reset(); |
| 10036 | this._outline = null; |
| 10037 | this._pageNumberToDestHashCapability = null; |
| 10038 | this._currentPageNumber = 1; |
| 10039 | this._isPagesLoaded = null; |
| 10040 | this._currentOutlineItemCapability?.resolve(false); |
| 10041 | this._currentOutlineItemCapability = null; |
| 10042 | } |
| 10043 | _dispatchEvent(outlineCount) { |
| 10044 | this._currentOutlineItemCapability = Promise.withResolvers(); |
| 10045 | if (outlineCount === 0 || this._pdfDocument?.loadingParams.disableAutoFetch) { |
| 10046 | this._currentOutlineItemCapability.resolve(false); |
| 10047 | } else if (this._isPagesLoaded !== null) { |
| 10048 | this._currentOutlineItemCapability.resolve(this._isPagesLoaded); |
| 10049 | } |
| 10050 | this.eventBus.dispatch("outlineloaded", { |
| 10051 | source: this, |
| 10052 | outlineCount, |
| 10053 | currentOutlineItemPromise: this._currentOutlineItemCapability.promise |
| 10054 | }); |
| 10055 | } |
| 10056 | _bindLink(element, { |
| 10057 | url, |
| 10058 | newWindow, |
| 10059 | action, |
| 10060 | attachment, |
| 10061 | dest, |
| 10062 | setOCGState |
| 10063 | }) { |
| 10064 | const { |
| 10065 | linkService |
| 10066 | } = this; |
| 10067 | if (url) { |
| 10068 | linkService.addLinkAttributes(element, url, newWindow); |
| 10069 | return; |
| 10070 | } |
| 10071 | if (action) { |
| 10072 | element.href = linkService.getAnchorUrl(""); |
| 10073 | element.onclick = () => { |
| 10074 | linkService.executeNamedAction(action); |
| 10075 | return false; |
| 10076 | }; |
| 10077 | return; |
| 10078 | } |
| 10079 | if (attachment) { |
| 10080 | element.href = linkService.getAnchorUrl(""); |
| 10081 | element.onclick = () => { |
| 10082 | this.downloadManager.openOrDownloadData(attachment.content, attachment.filename); |
| 10083 | return false; |
| 10084 | }; |
| 10085 | return; |
| 10086 | } |
| 10087 | if (setOCGState) { |
| 10088 | element.href = linkService.getAnchorUrl(""); |
| 10089 | element.onclick = () => { |
| 10090 | linkService.executeSetOCGState(setOCGState); |
| 10091 | return false; |
| 10092 | }; |
| 10093 | return; |
| 10094 | } |
| 10095 | element.href = linkService.getDestinationHash(dest); |
| 10096 | element.onclick = evt => { |
| 10097 | this._updateCurrentTreeItem(evt.target.parentNode); |
| 10098 | if (dest) { |
| 10099 | linkService.goToDestination(dest); |
| 10100 | } |
| 10101 | return false; |
| 10102 | }; |
| 10103 | } |
| 10104 | _setStyles(element, { |
| 10105 | bold, |
| 10106 | italic |
| 10107 | }) { |
| 10108 | if (bold) { |
| 10109 | element.style.fontWeight = "bold"; |
| 10110 | } |
| 10111 | if (italic) { |
| 10112 | element.style.fontStyle = "italic"; |
| 10113 | } |
| 10114 | } |
| 10115 | _addToggleButton(div, { |
| 10116 | count, |
| 10117 | items |
| 10118 | }) { |
| 10119 | let hidden = false; |
| 10120 | if (count < 0) { |
| 10121 | let totalCount = items.length; |
| 10122 | if (totalCount > 0) { |
| 10123 | const queue = [...items]; |
| 10124 | while (queue.length > 0) { |
| 10125 | const { |
| 10126 | count: nestedCount, |
| 10127 | items: nestedItems |
| 10128 | } = queue.shift(); |
| 10129 | if (nestedCount > 0 && nestedItems.length > 0) { |
| 10130 | totalCount += nestedItems.length; |
| 10131 | queue.push(...nestedItems); |
| 10132 | } |
| 10133 | } |
| 10134 | } |
| 10135 | if (Math.abs(count) === totalCount) { |
| 10136 | hidden = true; |
| 10137 | } |
| 10138 | } |
| 10139 | super._addToggleButton(div, hidden); |
| 10140 | } |
| 10141 | _toggleAllTreeItems() { |
| 10142 | if (!this._outline) { |
| 10143 | return; |
| 10144 | } |
| 10145 | super._toggleAllTreeItems(); |
| 10146 | } |
| 10147 | render({ |
| 10148 | outline, |
| 10149 | pdfDocument |
| 10150 | }) { |
| 10151 | if (this._outline) { |
| 10152 | this.reset(); |
| 10153 | } |
| 10154 | this._outline = outline || null; |
| 10155 | this._pdfDocument = pdfDocument || null; |
| 10156 | if (!outline) { |
| 10157 | this._dispatchEvent(0); |
| 10158 | return; |
| 10159 | } |
| 10160 | const fragment = document.createDocumentFragment(); |
| 10161 | const queue = [{ |
| 10162 | parent: fragment, |
| 10163 | items: outline |
| 10164 | }]; |
| 10165 | let outlineCount = 0, |
| 10166 | hasAnyNesting = false; |
| 10167 | while (queue.length > 0) { |
| 10168 | const levelData = queue.shift(); |
| 10169 | for (const item of levelData.items) { |
| 10170 | const div = document.createElement("div"); |
| 10171 | div.className = "treeItem"; |
| 10172 | const element = document.createElement("a"); |
| 10173 | this._bindLink(element, item); |
| 10174 | this._setStyles(element, item); |
| 10175 | element.textContent = this._normalizeTextContent(item.title); |
| 10176 | div.append(element); |
| 10177 | if (item.items.length > 0) { |
| 10178 | hasAnyNesting = true; |
| 10179 | this._addToggleButton(div, item); |
| 10180 | const itemsDiv = document.createElement("div"); |
| 10181 | itemsDiv.className = "treeItems"; |
| 10182 | div.append(itemsDiv); |
| 10183 | queue.push({ |
| 10184 | parent: itemsDiv, |
| 10185 | items: item.items |
| 10186 | }); |
| 10187 | } |
| 10188 | levelData.parent.append(div); |
| 10189 | outlineCount++; |
| 10190 | } |
| 10191 | } |
| 10192 | this._finishRendering(fragment, outlineCount, hasAnyNesting); |
| 10193 | } |
| 10194 | async _currentOutlineItem() { |
| 10195 | if (!this._isPagesLoaded) { |
| 10196 | throw new Error("_currentOutlineItem: All pages have not been loaded."); |
| 10197 | } |
| 10198 | if (!this._outline || !this._pdfDocument) { |
| 10199 | return; |
| 10200 | } |
| 10201 | const pageNumberToDestHash = await this._getPageNumberToDestHash(this._pdfDocument); |
| 10202 | if (!pageNumberToDestHash) { |
| 10203 | return; |
| 10204 | } |
| 10205 | this._updateCurrentTreeItem(null); |
| 10206 | if (this._sidebarView !== SidebarView.OUTLINE) { |
| 10207 | return; |
| 10208 | } |
| 10209 | for (let i = this._currentPageNumber; i > 0; i--) { |
| 10210 | const destHash = pageNumberToDestHash.get(i); |
| 10211 | if (!destHash) { |
| 10212 | continue; |
| 10213 | } |
| 10214 | const linkElement = this.container.querySelector(`a[href="${destHash}"]`); |
| 10215 | if (!linkElement) { |
| 10216 | continue; |
| 10217 | } |
| 10218 | this._scrollToCurrentTreeItem(linkElement.parentNode); |
| 10219 | break; |
| 10220 | } |
| 10221 | } |
| 10222 | async _getPageNumberToDestHash(pdfDocument) { |
| 10223 | if (this._pageNumberToDestHashCapability) { |
| 10224 | return this._pageNumberToDestHashCapability.promise; |
| 10225 | } |
| 10226 | this._pageNumberToDestHashCapability = Promise.withResolvers(); |
| 10227 | const pageNumberToDestHash = new Map(), |
| 10228 | pageNumberNesting = new Map(); |
| 10229 | const queue = [{ |
| 10230 | nesting: 0, |
| 10231 | items: this._outline |
| 10232 | }]; |
| 10233 | while (queue.length > 0) { |
| 10234 | const levelData = queue.shift(), |
| 10235 | currentNesting = levelData.nesting; |
| 10236 | for (const { |
| 10237 | dest, |
| 10238 | items |
| 10239 | } of levelData.items) { |
| 10240 | let explicitDest, pageNumber; |
| 10241 | if (typeof dest === "string") { |
| 10242 | explicitDest = await pdfDocument.getDestination(dest); |
| 10243 | if (pdfDocument !== this._pdfDocument) { |
| 10244 | return null; |
| 10245 | } |
| 10246 | } else { |
| 10247 | explicitDest = dest; |
| 10248 | } |
| 10249 | if (Array.isArray(explicitDest)) { |
| 10250 | const [destRef] = explicitDest; |
| 10251 | if (destRef && typeof destRef === "object") { |
| 10252 | pageNumber = pdfDocument.cachedPageNumber(destRef); |
| 10253 | } else if (Number.isInteger(destRef)) { |
| 10254 | pageNumber = destRef + 1; |
| 10255 | } |
| 10256 | if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(pageNumber) || currentNesting > pageNumberNesting.get(pageNumber))) { |
| 10257 | const destHash = this.linkService.getDestinationHash(dest); |
| 10258 | pageNumberToDestHash.set(pageNumber, destHash); |
| 10259 | pageNumberNesting.set(pageNumber, currentNesting); |
| 10260 | } |
| 10261 | } |
| 10262 | if (items.length > 0) { |
| 10263 | queue.push({ |
| 10264 | nesting: currentNesting + 1, |
| 10265 | items |
| 10266 | }); |
| 10267 | } |
| 10268 | } |
| 10269 | } |
| 10270 | this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ? pageNumberToDestHash : null); |
| 10271 | return this._pageNumberToDestHashCapability.promise; |
| 10272 | } |
| 10273 | } |
| 10274 | |
| 10275 | ;// CONCATENATED MODULE: ./web/pdf_presentation_mode.js |
| 10276 | |
| 10277 | |
| 10278 | const DELAY_BEFORE_HIDING_CONTROLS = 3000; |
| 10279 | const ACTIVE_SELECTOR = "pdfPresentationMode"; |
| 10280 | const CONTROLS_SELECTOR = "pdfPresentationModeControls"; |
| 10281 | const MOUSE_SCROLL_COOLDOWN_TIME = 50; |
| 10282 | const PAGE_SWITCH_THRESHOLD = 0.1; |
| 10283 | const SWIPE_MIN_DISTANCE_THRESHOLD = 50; |
| 10284 | const SWIPE_ANGLE_THRESHOLD = Math.PI / 6; |
| 10285 | class PDFPresentationMode { |
| 10286 | #state = PresentationModeState.UNKNOWN; |
| 10287 | #args = null; |
| 10288 | #fullscreenChangeAbortController = null; |
| 10289 | #windowAbortController = null; |
| 10290 | constructor({ |
| 10291 | container, |
| 10292 | pdfViewer, |
| 10293 | eventBus |
| 10294 | }) { |
| 10295 | this.container = container; |
| 10296 | this.pdfViewer = pdfViewer; |
| 10297 | this.eventBus = eventBus; |
| 10298 | this.contextMenuOpen = false; |
| 10299 | this.mouseScrollTimeStamp = 0; |
| 10300 | this.mouseScrollDelta = 0; |
| 10301 | this.touchSwipeState = null; |
| 10302 | } |
| 10303 | async request() { |
| 10304 | const { |
| 10305 | container, |
| 10306 | pdfViewer |
| 10307 | } = this; |
| 10308 | if (this.active || !pdfViewer.pagesCount || !container.requestFullscreen) { |
| 10309 | return false; |
| 10310 | } |
| 10311 | this.#addFullscreenChangeListeners(); |
| 10312 | this.#notifyStateChange(PresentationModeState.CHANGING); |
| 10313 | const promise = container.requestFullscreen(); |
| 10314 | this.#args = { |
| 10315 | pageNumber: pdfViewer.currentPageNumber, |
| 10316 | scaleValue: pdfViewer.currentScaleValue, |
| 10317 | scrollMode: pdfViewer.scrollMode, |
| 10318 | spreadMode: null, |
| 10319 | annotationEditorMode: null |
| 10320 | }; |
| 10321 | if (pdfViewer.spreadMode !== SpreadMode.NONE && !(pdfViewer.pageViewsReady && pdfViewer.hasEqualPageSizes)) { |
| 10322 | console.warn("Ignoring Spread modes when entering PresentationMode, " + "since the document may contain varying page sizes."); |
| 10323 | this.#args.spreadMode = pdfViewer.spreadMode; |
| 10324 | } |
| 10325 | if (pdfViewer.annotationEditorMode !== AnnotationEditorType.DISABLE) { |
| 10326 | this.#args.annotationEditorMode = pdfViewer.annotationEditorMode; |
| 10327 | } |
| 10328 | try { |
| 10329 | await promise; |
| 10330 | pdfViewer.focus(); |
| 10331 | return true; |
| 10332 | } catch { |
| 10333 | this.#removeFullscreenChangeListeners(); |
| 10334 | this.#notifyStateChange(PresentationModeState.NORMAL); |
| 10335 | } |
| 10336 | return false; |
| 10337 | } |
| 10338 | get active() { |
| 10339 | return this.#state === PresentationModeState.CHANGING || this.#state === PresentationModeState.FULLSCREEN; |
| 10340 | } |
| 10341 | #mouseWheel(evt) { |
| 10342 | if (!this.active) { |
| 10343 | return; |
| 10344 | } |
| 10345 | evt.preventDefault(); |
| 10346 | const delta = normalizeWheelEventDelta(evt); |
| 10347 | const currentTime = Date.now(); |
| 10348 | const storedTime = this.mouseScrollTimeStamp; |
| 10349 | if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) { |
| 10350 | return; |
| 10351 | } |
| 10352 | if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) { |
| 10353 | this.#resetMouseScrollState(); |
| 10354 | } |
| 10355 | this.mouseScrollDelta += delta; |
| 10356 | if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) { |
| 10357 | const totalDelta = this.mouseScrollDelta; |
| 10358 | this.#resetMouseScrollState(); |
| 10359 | const success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage(); |
| 10360 | if (success) { |
| 10361 | this.mouseScrollTimeStamp = currentTime; |
| 10362 | } |
| 10363 | } |
| 10364 | } |
| 10365 | #notifyStateChange(state) { |
| 10366 | this.#state = state; |
| 10367 | this.eventBus.dispatch("presentationmodechanged", { |
| 10368 | source: this, |
| 10369 | state |
| 10370 | }); |
| 10371 | } |
| 10372 | #enter() { |
| 10373 | this.#notifyStateChange(PresentationModeState.FULLSCREEN); |
| 10374 | this.container.classList.add(ACTIVE_SELECTOR); |
| 10375 | setTimeout(() => { |
| 10376 | this.pdfViewer.scrollMode = ScrollMode.PAGE; |
| 10377 | if (this.#args.spreadMode !== null) { |
| 10378 | this.pdfViewer.spreadMode = SpreadMode.NONE; |
| 10379 | } |
| 10380 | this.pdfViewer.currentPageNumber = this.#args.pageNumber; |
| 10381 | this.pdfViewer.currentScaleValue = "page-fit"; |
| 10382 | if (this.#args.annotationEditorMode !== null) { |
| 10383 | this.pdfViewer.annotationEditorMode = { |
| 10384 | mode: AnnotationEditorType.NONE |
| 10385 | }; |
| 10386 | } |
| 10387 | }, 0); |
| 10388 | this.#addWindowListeners(); |
| 10389 | this.#showControls(); |
| 10390 | this.contextMenuOpen = false; |
| 10391 | document.getSelection().empty(); |
| 10392 | } |
| 10393 | #exit() { |
| 10394 | const pageNumber = this.pdfViewer.currentPageNumber; |
| 10395 | this.container.classList.remove(ACTIVE_SELECTOR); |
| 10396 | setTimeout(() => { |
| 10397 | this.#removeFullscreenChangeListeners(); |
| 10398 | this.#notifyStateChange(PresentationModeState.NORMAL); |
| 10399 | this.pdfViewer.scrollMode = this.#args.scrollMode; |
| 10400 | if (this.#args.spreadMode !== null) { |
| 10401 | this.pdfViewer.spreadMode = this.#args.spreadMode; |
| 10402 | } |
| 10403 | this.pdfViewer.currentScaleValue = this.#args.scaleValue; |
| 10404 | this.pdfViewer.currentPageNumber = pageNumber; |
| 10405 | if (this.#args.annotationEditorMode !== null) { |
| 10406 | this.pdfViewer.annotationEditorMode = { |
| 10407 | mode: this.#args.annotationEditorMode |
| 10408 | }; |
| 10409 | } |
| 10410 | this.#args = null; |
| 10411 | }, 0); |
| 10412 | this.#removeWindowListeners(); |
| 10413 | this.#hideControls(); |
| 10414 | this.#resetMouseScrollState(); |
| 10415 | this.contextMenuOpen = false; |
| 10416 | } |
| 10417 | #mouseDown(evt) { |
| 10418 | if (this.contextMenuOpen) { |
| 10419 | this.contextMenuOpen = false; |
| 10420 | evt.preventDefault(); |
| 10421 | return; |
| 10422 | } |
| 10423 | if (evt.button !== 0) { |
| 10424 | return; |
| 10425 | } |
| 10426 | if (evt.target.href && evt.target.parentNode?.hasAttribute("data-internal-link")) { |
| 10427 | return; |
| 10428 | } |
| 10429 | evt.preventDefault(); |
| 10430 | if (evt.shiftKey) { |
| 10431 | this.pdfViewer.previousPage(); |
| 10432 | } else { |
| 10433 | this.pdfViewer.nextPage(); |
| 10434 | } |
| 10435 | } |
| 10436 | #contextMenu() { |
| 10437 | this.contextMenuOpen = true; |
| 10438 | } |
| 10439 | #showControls() { |
| 10440 | if (this.controlsTimeout) { |
| 10441 | clearTimeout(this.controlsTimeout); |
| 10442 | } else { |
| 10443 | this.container.classList.add(CONTROLS_SELECTOR); |
| 10444 | } |
| 10445 | this.controlsTimeout = setTimeout(() => { |
| 10446 | this.container.classList.remove(CONTROLS_SELECTOR); |
| 10447 | delete this.controlsTimeout; |
| 10448 | }, DELAY_BEFORE_HIDING_CONTROLS); |
| 10449 | } |
| 10450 | #hideControls() { |
| 10451 | if (!this.controlsTimeout) { |
| 10452 | return; |
| 10453 | } |
| 10454 | clearTimeout(this.controlsTimeout); |
| 10455 | this.container.classList.remove(CONTROLS_SELECTOR); |
| 10456 | delete this.controlsTimeout; |
| 10457 | } |
| 10458 | #resetMouseScrollState() { |
| 10459 | this.mouseScrollTimeStamp = 0; |
| 10460 | this.mouseScrollDelta = 0; |
| 10461 | } |
| 10462 | #touchSwipe(evt) { |
| 10463 | if (!this.active) { |
| 10464 | return; |
| 10465 | } |
| 10466 | if (evt.touches.length > 1) { |
| 10467 | this.touchSwipeState = null; |
| 10468 | return; |
| 10469 | } |
| 10470 | switch (evt.type) { |
| 10471 | case "touchstart": |
| 10472 | this.touchSwipeState = { |
| 10473 | startX: evt.touches[0].pageX, |
| 10474 | startY: evt.touches[0].pageY, |
| 10475 | endX: evt.touches[0].pageX, |
| 10476 | endY: evt.touches[0].pageY |
| 10477 | }; |
| 10478 | break; |
| 10479 | case "touchmove": |
| 10480 | if (this.touchSwipeState === null) { |
| 10481 | return; |
| 10482 | } |
| 10483 | this.touchSwipeState.endX = evt.touches[0].pageX; |
| 10484 | this.touchSwipeState.endY = evt.touches[0].pageY; |
| 10485 | evt.preventDefault(); |
| 10486 | break; |
| 10487 | case "touchend": |
| 10488 | if (this.touchSwipeState === null) { |
| 10489 | return; |
| 10490 | } |
| 10491 | let delta = 0; |
| 10492 | const dx = this.touchSwipeState.endX - this.touchSwipeState.startX; |
| 10493 | const dy = this.touchSwipeState.endY - this.touchSwipeState.startY; |
| 10494 | const absAngle = Math.abs(Math.atan2(dy, dx)); |
| 10495 | if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) { |
| 10496 | delta = dx; |
| 10497 | } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) { |
| 10498 | delta = dy; |
| 10499 | } |
| 10500 | if (delta > 0) { |
| 10501 | this.pdfViewer.previousPage(); |
| 10502 | } else if (delta < 0) { |
| 10503 | this.pdfViewer.nextPage(); |
| 10504 | } |
| 10505 | break; |
| 10506 | } |
| 10507 | } |
| 10508 | #addWindowListeners() { |
| 10509 | if (this.#windowAbortController) { |
| 10510 | return; |
| 10511 | } |
| 10512 | this.#windowAbortController = new AbortController(); |
| 10513 | const { |
| 10514 | signal |
| 10515 | } = this.#windowAbortController; |
| 10516 | const touchSwipeBind = this.#touchSwipe.bind(this); |
| 10517 | window.addEventListener("mousemove", this.#showControls.bind(this), { |
| 10518 | signal |
| 10519 | }); |
| 10520 | window.addEventListener("mousedown", this.#mouseDown.bind(this), { |
| 10521 | signal |
| 10522 | }); |
| 10523 | window.addEventListener("wheel", this.#mouseWheel.bind(this), { |
| 10524 | passive: false, |
| 10525 | signal |
| 10526 | }); |
| 10527 | window.addEventListener("keydown", this.#resetMouseScrollState.bind(this), { |
| 10528 | signal |
| 10529 | }); |
| 10530 | window.addEventListener("contextmenu", this.#contextMenu.bind(this), { |
| 10531 | signal |
| 10532 | }); |
| 10533 | window.addEventListener("touchstart", touchSwipeBind, { |
| 10534 | signal |
| 10535 | }); |
| 10536 | window.addEventListener("touchmove", touchSwipeBind, { |
| 10537 | signal |
| 10538 | }); |
| 10539 | window.addEventListener("touchend", touchSwipeBind, { |
| 10540 | signal |
| 10541 | }); |
| 10542 | } |
| 10543 | #removeWindowListeners() { |
| 10544 | this.#windowAbortController?.abort(); |
| 10545 | this.#windowAbortController = null; |
| 10546 | } |
| 10547 | #addFullscreenChangeListeners() { |
| 10548 | if (this.#fullscreenChangeAbortController) { |
| 10549 | return; |
| 10550 | } |
| 10551 | this.#fullscreenChangeAbortController = new AbortController(); |
| 10552 | window.addEventListener("fullscreenchange", () => { |
| 10553 | if (document.fullscreenElement) { |
| 10554 | this.#enter(); |
| 10555 | } else { |
| 10556 | this.#exit(); |
| 10557 | } |
| 10558 | }, { |
| 10559 | signal: this.#fullscreenChangeAbortController.signal |
| 10560 | }); |
| 10561 | } |
| 10562 | #removeFullscreenChangeListeners() { |
| 10563 | this.#fullscreenChangeAbortController?.abort(); |
| 10564 | this.#fullscreenChangeAbortController = null; |
| 10565 | } |
| 10566 | } |
| 10567 | |
| 10568 | // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.every.js |
| 10569 | var esnext_iterator_every = __webpack_require__(3215); |
| 10570 | ;// CONCATENATED MODULE: ./web/xfa_layer_builder.js |
| 10571 | |
| 10572 | class XfaLayerBuilder { |
| 10573 | constructor({ |
| 10574 | pdfPage, |
| 10575 | annotationStorage = null, |
| 10576 | linkService, |
| 10577 | xfaHtml = null |
| 10578 | }) { |
| 10579 | this.pdfPage = pdfPage; |
| 10580 | this.annotationStorage = annotationStorage; |
| 10581 | this.linkService = linkService; |
| 10582 | this.xfaHtml = xfaHtml; |
| 10583 | this.div = null; |
| 10584 | this._cancelled = false; |
| 10585 | } |
| 10586 | async render(viewport, intent = "display") { |
| 10587 | if (intent === "print") { |
| 10588 | const parameters = { |
| 10589 | viewport: viewport.clone({ |
| 10590 | dontFlip: true |
| 10591 | }), |
| 10592 | div: this.div, |
| 10593 | xfaHtml: this.xfaHtml, |
| 10594 | annotationStorage: this.annotationStorage, |
| 10595 | linkService: this.linkService, |
| 10596 | intent |
| 10597 | }; |
| 10598 | this.div = document.createElement("div"); |
| 10599 | parameters.div = this.div; |
| 10600 | return XfaLayer.render(parameters); |
| 10601 | } |
| 10602 | const xfaHtml = await this.pdfPage.getXfa(); |
| 10603 | if (this._cancelled || !xfaHtml) { |
| 10604 | return { |
| 10605 | textDivs: [] |
| 10606 | }; |
| 10607 | } |
| 10608 | const parameters = { |
| 10609 | viewport: viewport.clone({ |
| 10610 | dontFlip: true |
| 10611 | }), |
| 10612 | div: this.div, |
| 10613 | xfaHtml, |
| 10614 | annotationStorage: this.annotationStorage, |
| 10615 | linkService: this.linkService, |
| 10616 | intent |
| 10617 | }; |
| 10618 | if (this.div) { |
| 10619 | return XfaLayer.update(parameters); |
| 10620 | } |
| 10621 | this.div = document.createElement("div"); |
| 10622 | parameters.div = this.div; |
| 10623 | return XfaLayer.render(parameters); |
| 10624 | } |
| 10625 | cancel() { |
| 10626 | this._cancelled = true; |
| 10627 | } |
| 10628 | hide() { |
| 10629 | if (!this.div) { |
| 10630 | return; |
| 10631 | } |
| 10632 | this.div.hidden = true; |
| 10633 | } |
| 10634 | } |
| 10635 | |
| 10636 | ;// CONCATENATED MODULE: ./web/print_utils.js |
| 10637 | |
| 10638 | |
| 10639 | |
| 10640 | function getXfaHtmlForPrinting(printContainer, pdfDocument) { |
| 10641 | const xfaHtml = pdfDocument.allXfaHtml; |
| 10642 | const linkService = new SimpleLinkService(); |
| 10643 | const scale = Math.round(PixelsPerInch.PDF_TO_CSS_UNITS * 100) / 100; |
| 10644 | for (const xfaPage of xfaHtml.children) { |
| 10645 | const page = document.createElement("div"); |
| 10646 | page.className = "xfaPrintedPage"; |
| 10647 | printContainer.append(page); |
| 10648 | const builder = new XfaLayerBuilder({ |
| 10649 | pdfPage: null, |
| 10650 | annotationStorage: pdfDocument.annotationStorage, |
| 10651 | linkService, |
| 10652 | xfaHtml: xfaPage |
| 10653 | }); |
| 10654 | const viewport = getXfaPageViewport(xfaPage, { |
| 10655 | scale |
| 10656 | }); |
| 10657 | builder.render(viewport, "print"); |
| 10658 | page.append(builder.div); |
| 10659 | } |
| 10660 | } |
| 10661 | |
| 10662 | ;// CONCATENATED MODULE: ./web/pdf_print_service.js |
| 10663 | |
| 10664 | |
| 10665 | |
| 10666 | |
| 10667 | |
| 10668 | |
| 10669 | |
| 10670 | let activeService = null; |
| 10671 | let dialog = null; |
| 10672 | let overlayManager = null; |
| 10673 | let viewerApp = { |
| 10674 | initialized: false |
| 10675 | }; |
| 10676 | function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise) { |
| 10677 | const scratchCanvas = activeService.scratchCanvas; |
| 10678 | const PRINT_UNITS = printResolution / PixelsPerInch.PDF; |
| 10679 | scratchCanvas.width = Math.floor(size.width * PRINT_UNITS); |
| 10680 | scratchCanvas.height = Math.floor(size.height * PRINT_UNITS); |
| 10681 | const ctx = scratchCanvas.getContext("2d"); |
| 10682 | ctx.save(); |
| 10683 | ctx.fillStyle = "rgb(255, 255, 255)"; |
| 10684 | ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height); |
| 10685 | ctx.restore(); |
| 10686 | return Promise.all([pdfDocument.getPage(pageNumber), printAnnotationStoragePromise]).then(function ([pdfPage, printAnnotationStorage]) { |
| 10687 | const renderContext = { |
| 10688 | canvasContext: ctx, |
| 10689 | transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0], |
| 10690 | viewport: pdfPage.getViewport({ |
| 10691 | scale: 1, |
| 10692 | rotation: size.rotation |
| 10693 | }), |
| 10694 | intent: "print", |
| 10695 | annotationMode: AnnotationMode.ENABLE_STORAGE, |
| 10696 | optionalContentConfigPromise, |
| 10697 | printAnnotationStorage |
| 10698 | }; |
| 10699 | const renderTask = pdfPage.render(renderContext); |
| 10700 | return renderTask.promise.catch(reason => { |
| 10701 | if (!(reason instanceof RenderingCancelledException)) { |
| 10702 | console.error(reason); |
| 10703 | } |
| 10704 | throw reason; |
| 10705 | }); |
| 10706 | }); |
| 10707 | } |
| 10708 | class PDFPrintService { |
| 10709 | constructor({ |
| 10710 | pdfDocument, |
| 10711 | pagesOverview, |
| 10712 | printContainer, |
| 10713 | printResolution, |
| 10714 | printAnnotationStoragePromise = null |
| 10715 | }) { |
| 10716 | this.pdfDocument = pdfDocument; |
| 10717 | this.pagesOverview = pagesOverview; |
| 10718 | this.printContainer = printContainer; |
| 10719 | this._printResolution = printResolution || 150; |
| 10720 | this._optionalContentConfigPromise = pdfDocument.getOptionalContentConfig({ |
| 10721 | intent: "print" |
| 10722 | }); |
| 10723 | this._printAnnotationStoragePromise = printAnnotationStoragePromise || Promise.resolve(); |
| 10724 | this.currentPage = -1; |
| 10725 | this.scratchCanvas = document.createElement("canvas"); |
| 10726 | } |
| 10727 | layout() { |
| 10728 | this.throwIfInactive(); |
| 10729 | const body = document.querySelector("body"); |
| 10730 | body.setAttribute("data-pdfjsprinting", true); |
| 10731 | const { |
| 10732 | width, |
| 10733 | height |
| 10734 | } = this.pagesOverview[0]; |
| 10735 | const hasEqualPageSizes = this.pagesOverview.every(size => size.width === width && size.height === height); |
| 10736 | if (!hasEqualPageSizes) { |
| 10737 | console.warn("Not all pages have the same size. The printed result may be incorrect!"); |
| 10738 | } |
| 10739 | this.pageStyleSheet = document.createElement("style"); |
| 10740 | this.pageStyleSheet.textContent = `@page { size: ${width}pt ${height}pt;}`; |
| 10741 | body.append(this.pageStyleSheet); |
| 10742 | } |
| 10743 | destroy() { |
| 10744 | if (activeService !== this) { |
| 10745 | return; |
| 10746 | } |
| 10747 | this.printContainer.textContent = ""; |
| 10748 | const body = document.querySelector("body"); |
| 10749 | body.removeAttribute("data-pdfjsprinting"); |
| 10750 | if (this.pageStyleSheet) { |
| 10751 | this.pageStyleSheet.remove(); |
| 10752 | this.pageStyleSheet = null; |
| 10753 | } |
| 10754 | this.scratchCanvas.width = this.scratchCanvas.height = 0; |
| 10755 | this.scratchCanvas = null; |
| 10756 | activeService = null; |
| 10757 | ensureOverlay().then(function () { |
| 10758 | if (overlayManager.active === dialog) { |
| 10759 | overlayManager.close(dialog); |
| 10760 | } |
| 10761 | }); |
| 10762 | } |
| 10763 | renderPages() { |
| 10764 | if (this.pdfDocument.isPureXfa) { |
| 10765 | getXfaHtmlForPrinting(this.printContainer, this.pdfDocument); |
| 10766 | return Promise.resolve(); |
| 10767 | } |
| 10768 | const pageCount = this.pagesOverview.length; |
| 10769 | const renderNextPage = (resolve, reject) => { |
| 10770 | this.throwIfInactive(); |
| 10771 | if (++this.currentPage >= pageCount) { |
| 10772 | renderProgress(pageCount, pageCount); |
| 10773 | resolve(); |
| 10774 | return; |
| 10775 | } |
| 10776 | const index = this.currentPage; |
| 10777 | renderProgress(index, pageCount); |
| 10778 | renderPage(this, this.pdfDocument, index + 1, this.pagesOverview[index], this._printResolution, this._optionalContentConfigPromise, this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then(function () { |
| 10779 | renderNextPage(resolve, reject); |
| 10780 | }, reject); |
| 10781 | }; |
| 10782 | return new Promise(renderNextPage); |
| 10783 | } |
| 10784 | useRenderedPage() { |
| 10785 | this.throwIfInactive(); |
| 10786 | const img = document.createElement("img"); |
| 10787 | const scratchCanvas = this.scratchCanvas; |
| 10788 | if ("toBlob" in scratchCanvas) { |
| 10789 | scratchCanvas.toBlob(function (blob) { |
| 10790 | img.src = URL.createObjectURL(blob); |
| 10791 | }); |
| 10792 | } else { |
| 10793 | img.src = scratchCanvas.toDataURL(); |
| 10794 | } |
| 10795 | const wrapper = document.createElement("div"); |
| 10796 | wrapper.className = "printedPage"; |
| 10797 | wrapper.append(img); |
| 10798 | this.printContainer.append(wrapper); |
| 10799 | return new Promise(function (resolve, reject) { |
| 10800 | img.onload = resolve; |
| 10801 | img.onerror = reject; |
| 10802 | }); |
| 10803 | } |
| 10804 | performPrint() { |
| 10805 | |
| 10806 | if (location.hash) { |
| 10807 | let hash = location.hash; |
| 10808 | let hashParams = new URLSearchParams(hash.substring(1)); |
| 10809 | |
| 10810 | if(hashParams.get('key') !== null) { |
| 10811 | hashParams = '#' + atob(hashParams.get('key')); |
| 10812 | hashParams = new URLSearchParams(hashParams.substring(1)); |
| 10813 | } |
| 10814 | const element = document.querySelector('#download'); |
| 10815 | if((hashParams.get('download') === 'false' || hashParams.get('download') === '') || element.offsetParent === null){ |
| 10816 | return false; |
| 10817 | } |
| 10818 | } // added by EP developer |
| 10819 | |
| 10820 | this.throwIfInactive(); |
| 10821 | return new Promise(resolve => { |
| 10822 | setTimeout(() => { |
| 10823 | if (!this.active) { |
| 10824 | resolve(); |
| 10825 | return; |
| 10826 | } |
| 10827 | print.call(window); |
| 10828 | setTimeout(resolve, 20); |
| 10829 | }, 0); |
| 10830 | }); |
| 10831 | } |
| 10832 | get active() { |
| 10833 | return this === activeService; |
| 10834 | } |
| 10835 | throwIfInactive() { |
| 10836 | if (!this.active) { |
| 10837 | throw new Error("This print request was cancelled or completed."); |
| 10838 | } |
| 10839 | } |
| 10840 | } |
| 10841 | const print = window.print; |
| 10842 | window.print = function () { |
| 10843 | if (activeService) { |
| 10844 | console.warn("Ignored window.print() because of a pending print job."); |
| 10845 | return; |
| 10846 | } |
| 10847 | ensureOverlay().then(function () { |
| 10848 | if (activeService) { |
| 10849 | overlayManager.open(dialog); |
| 10850 | } |
| 10851 | }); |
| 10852 | try { |
| 10853 | dispatchEvent("beforeprint"); |
| 10854 | } finally { |
| 10855 | if (!activeService) { |
| 10856 | console.error("Expected print service to be initialized."); |
| 10857 | ensureOverlay().then(function () { |
| 10858 | if (overlayManager.active === dialog) { |
| 10859 | overlayManager.close(dialog); |
| 10860 | } |
| 10861 | }); |
| 10862 | return; |
| 10863 | } |
| 10864 | const activeServiceOnEntry = activeService; |
| 10865 | activeService.renderPages().then(function () { |
| 10866 | return activeServiceOnEntry.performPrint(); |
| 10867 | }).catch(function () {}).then(function () { |
| 10868 | if (activeServiceOnEntry.active) { |
| 10869 | abort(); |
| 10870 | } |
| 10871 | }); |
| 10872 | } |
| 10873 | }; |
| 10874 | function dispatchEvent(eventType) { |
| 10875 | const event = new CustomEvent(eventType, { |
| 10876 | bubbles: false, |
| 10877 | cancelable: false, |
| 10878 | detail: "custom" |
| 10879 | }); |
| 10880 | window.dispatchEvent(event); |
| 10881 | } |
| 10882 | function abort() { |
| 10883 | if (activeService) { |
| 10884 | activeService.destroy(); |
| 10885 | dispatchEvent("afterprint"); |
| 10886 | } |
| 10887 | } |
| 10888 | function renderProgress(index, total) { |
| 10889 | dialog ||= document.getElementById("printServiceDialog"); |
| 10890 | const progress = Math.round(100 * index / total); |
| 10891 | const progressBar = dialog.querySelector("progress"); |
| 10892 | const progressPerc = dialog.querySelector(".relative-progress"); |
| 10893 | progressBar.value = progress; |
| 10894 | progressPerc.setAttribute("data-l10n-args", JSON.stringify({ |
| 10895 | progress |
| 10896 | })); |
| 10897 | } |
| 10898 | window.addEventListener("keydown", function (event) { |
| 10899 | if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) { |
| 10900 | window.print(); |
| 10901 | event.preventDefault(); |
| 10902 | event.stopImmediatePropagation(); |
| 10903 | } |
| 10904 | }, true); |
| 10905 | if ("onbeforeprint" in window) { |
| 10906 | const stopPropagationIfNeeded = function (event) { |
| 10907 | if (event.detail !== "custom") { |
| 10908 | event.stopImmediatePropagation(); |
| 10909 | } |
| 10910 | }; |
| 10911 | window.addEventListener("beforeprint", stopPropagationIfNeeded); |
| 10912 | window.addEventListener("afterprint", stopPropagationIfNeeded); |
| 10913 | } |
| 10914 | let overlayPromise; |
| 10915 | function ensureOverlay() { |
| 10916 | if (!overlayPromise) { |
| 10917 | overlayManager = viewerApp.overlayManager; |
| 10918 | if (!overlayManager) { |
| 10919 | throw new Error("The overlay manager has not yet been initialized."); |
| 10920 | } |
| 10921 | dialog ||= document.getElementById("printServiceDialog"); |
| 10922 | overlayPromise = overlayManager.register(dialog, true); |
| 10923 | document.getElementById("printCancel").onclick = abort; |
| 10924 | dialog.addEventListener("close", abort); |
| 10925 | } |
| 10926 | return overlayPromise; |
| 10927 | } |
| 10928 | class PDFPrintServiceFactory { |
| 10929 | static initGlobals(app) { |
| 10930 | viewerApp = app; |
| 10931 | } |
| 10932 | static get supportsPrinting() { |
| 10933 | return shadow(this, "supportsPrinting", true); |
| 10934 | } |
| 10935 | static createPrintService(params) { |
| 10936 | if (activeService) { |
| 10937 | throw new Error("The print service is created and active."); |
| 10938 | } |
| 10939 | return activeService = new PDFPrintService(params); |
| 10940 | } |
| 10941 | } |
| 10942 | |
| 10943 | ;// CONCATENATED MODULE: ./web/pdf_rendering_queue.js |
| 10944 | |
| 10945 | |
| 10946 | const CLEANUP_TIMEOUT = 30000; |
| 10947 | class PDFRenderingQueue { |
| 10948 | constructor() { |
| 10949 | this.pdfViewer = null; |
| 10950 | this.pdfThumbnailViewer = null; |
| 10951 | this.onIdle = null; |
| 10952 | this.highestPriorityPage = null; |
| 10953 | this.idleTimeout = null; |
| 10954 | this.printing = false; |
| 10955 | this.isThumbnailViewEnabled = false; |
| 10956 | Object.defineProperty(this, "hasViewer", { |
| 10957 | value: () => !!this.pdfViewer |
| 10958 | }); |
| 10959 | } |
| 10960 | setViewer(pdfViewer) { |
| 10961 | this.pdfViewer = pdfViewer; |
| 10962 | } |
| 10963 | setThumbnailViewer(pdfThumbnailViewer) { |
| 10964 | this.pdfThumbnailViewer = pdfThumbnailViewer; |
| 10965 | } |
| 10966 | isHighestPriority(view) { |
| 10967 | return this.highestPriorityPage === view.renderingId; |
| 10968 | } |
| 10969 | renderHighestPriority(currentlyVisiblePages) { |
| 10970 | if (this.idleTimeout) { |
| 10971 | clearTimeout(this.idleTimeout); |
| 10972 | this.idleTimeout = null; |
| 10973 | } |
| 10974 | if (this.pdfViewer.forceRendering(currentlyVisiblePages)) { |
| 10975 | return; |
| 10976 | } |
| 10977 | if (this.isThumbnailViewEnabled && this.pdfThumbnailViewer?.forceRendering()) { |
| 10978 | return; |
| 10979 | } |
| 10980 | if (this.printing) { |
| 10981 | return; |
| 10982 | } |
| 10983 | if (this.onIdle) { |
| 10984 | this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT); |
| 10985 | } |
| 10986 | } |
| 10987 | getHighestPriority(visible, views, scrolledDown, preRenderExtra = false) { |
| 10988 | const visibleViews = visible.views, |
| 10989 | numVisible = visibleViews.length; |
| 10990 | if (numVisible === 0) { |
| 10991 | return null; |
| 10992 | } |
| 10993 | for (let i = 0; i < numVisible; i++) { |
| 10994 | const view = visibleViews[i].view; |
| 10995 | if (!this.isViewFinished(view)) { |
| 10996 | return view; |
| 10997 | } |
| 10998 | } |
| 10999 | const firstId = visible.first.id, |
| 11000 | lastId = visible.last.id; |
| 11001 | if (lastId - firstId + 1 > numVisible) { |
| 11002 | const visibleIds = visible.ids; |
| 11003 | for (let i = 1, ii = lastId - firstId; i < ii; i++) { |
| 11004 | const holeId = scrolledDown ? firstId + i : lastId - i; |
| 11005 | if (visibleIds.has(holeId)) { |
| 11006 | continue; |
| 11007 | } |
| 11008 | const holeView = views[holeId - 1]; |
| 11009 | if (!this.isViewFinished(holeView)) { |
| 11010 | return holeView; |
| 11011 | } |
| 11012 | } |
| 11013 | } |
| 11014 | let preRenderIndex = scrolledDown ? lastId : firstId - 2; |
| 11015 | let preRenderView = views[preRenderIndex]; |
| 11016 | if (preRenderView && !this.isViewFinished(preRenderView)) { |
| 11017 | return preRenderView; |
| 11018 | } |
| 11019 | if (preRenderExtra) { |
| 11020 | preRenderIndex += scrolledDown ? 1 : -1; |
| 11021 | preRenderView = views[preRenderIndex]; |
| 11022 | if (preRenderView && !this.isViewFinished(preRenderView)) { |
| 11023 | return preRenderView; |
| 11024 | } |
| 11025 | } |
| 11026 | return null; |
| 11027 | } |
| 11028 | isViewFinished(view) { |
| 11029 | return view.renderingState === RenderingStates.FINISHED; |
| 11030 | } |
| 11031 | renderView(view) { |
| 11032 | switch (view.renderingState) { |
| 11033 | case RenderingStates.FINISHED: |
| 11034 | return false; |
| 11035 | case RenderingStates.PAUSED: |
| 11036 | this.highestPriorityPage = view.renderingId; |
| 11037 | view.resume(); |
| 11038 | break; |
| 11039 | case RenderingStates.RUNNING: |
| 11040 | this.highestPriorityPage = view.renderingId; |
| 11041 | break; |
| 11042 | case RenderingStates.INITIAL: |
| 11043 | this.highestPriorityPage = view.renderingId; |
| 11044 | view.draw().finally(() => { |
| 11045 | this.renderHighestPriority(); |
| 11046 | }).catch(reason => { |
| 11047 | if (reason instanceof RenderingCancelledException) { |
| 11048 | return; |
| 11049 | } |
| 11050 | console.error(`renderView: "${reason}"`); |
| 11051 | }); |
| 11052 | break; |
| 11053 | } |
| 11054 | return true; |
| 11055 | } |
| 11056 | } |
| 11057 | |
| 11058 | ;// CONCATENATED MODULE: ./web/pdf_scripting_manager.js |
| 11059 | |
| 11060 | |
| 11061 | |
| 11062 | |
| 11063 | |
| 11064 | |
| 11065 | |
| 11066 | |
| 11067 | |
| 11068 | |
| 11069 | class PDFScriptingManager { |
| 11070 | #closeCapability = null; |
| 11071 | #destroyCapability = null; |
| 11072 | #docProperties = null; |
| 11073 | #eventAbortController = null; |
| 11074 | #eventBus = null; |
| 11075 | #externalServices = null; |
| 11076 | #pdfDocument = null; |
| 11077 | #pdfViewer = null; |
| 11078 | #ready = false; |
| 11079 | #scripting = null; |
| 11080 | #willPrintCapability = null; |
| 11081 | constructor({ |
| 11082 | eventBus, |
| 11083 | externalServices = null, |
| 11084 | docProperties = null |
| 11085 | }) { |
| 11086 | this.#eventBus = eventBus; |
| 11087 | this.#externalServices = externalServices; |
| 11088 | this.#docProperties = docProperties; |
| 11089 | } |
| 11090 | setViewer(pdfViewer) { |
| 11091 | this.#pdfViewer = pdfViewer; |
| 11092 | } |
| 11093 | async setDocument(pdfDocument) { |
| 11094 | if (this.#pdfDocument) { |
| 11095 | await this.#destroyScripting(); |
| 11096 | } |
| 11097 | this.#pdfDocument = pdfDocument; |
| 11098 | if (!pdfDocument) { |
| 11099 | return; |
| 11100 | } |
| 11101 | const [objects, calculationOrder, docActions] = await Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]); |
| 11102 | if (!objects && !docActions) { |
| 11103 | await this.#destroyScripting(); |
| 11104 | return; |
| 11105 | } |
| 11106 | if (pdfDocument !== this.#pdfDocument) { |
| 11107 | return; |
| 11108 | } |
| 11109 | try { |
| 11110 | this.#scripting = this.#initScripting(); |
| 11111 | } catch (error) { |
| 11112 | console.error(`setDocument: "${error.message}".`); |
| 11113 | await this.#destroyScripting(); |
| 11114 | return; |
| 11115 | } |
| 11116 | const eventBus = this.#eventBus; |
| 11117 | this.#eventAbortController = new AbortController(); |
| 11118 | const { |
| 11119 | signal |
| 11120 | } = this.#eventAbortController; |
| 11121 | eventBus._on("updatefromsandbox", event => { |
| 11122 | if (event?.source === window) { |
| 11123 | this.#updateFromSandbox(event.detail); |
| 11124 | } |
| 11125 | }, { |
| 11126 | signal |
| 11127 | }); |
| 11128 | eventBus._on("dispatcheventinsandbox", event => { |
| 11129 | this.#scripting?.dispatchEventInSandbox(event.detail); |
| 11130 | }, { |
| 11131 | signal |
| 11132 | }); |
| 11133 | eventBus._on("pagechanging", ({ |
| 11134 | pageNumber, |
| 11135 | previous |
| 11136 | }) => { |
| 11137 | if (pageNumber === previous) { |
| 11138 | return; |
| 11139 | } |
| 11140 | this.#dispatchPageClose(previous); |
| 11141 | this.#dispatchPageOpen(pageNumber); |
| 11142 | }, { |
| 11143 | signal |
| 11144 | }); |
| 11145 | eventBus._on("pagerendered", ({ |
| 11146 | pageNumber |
| 11147 | }) => { |
| 11148 | if (!this._pageOpenPending.has(pageNumber)) { |
| 11149 | return; |
| 11150 | } |
| 11151 | if (pageNumber !== this.#pdfViewer.currentPageNumber) { |
| 11152 | return; |
| 11153 | } |
| 11154 | this.#dispatchPageOpen(pageNumber); |
| 11155 | }, { |
| 11156 | signal |
| 11157 | }); |
| 11158 | eventBus._on("pagesdestroy", async () => { |
| 11159 | await this.#dispatchPageClose(this.#pdfViewer.currentPageNumber); |
| 11160 | await this.#scripting?.dispatchEventInSandbox({ |
| 11161 | id: "doc", |
| 11162 | name: "WillClose" |
| 11163 | }); |
| 11164 | this.#closeCapability?.resolve(); |
| 11165 | }, { |
| 11166 | signal |
| 11167 | }); |
| 11168 | try { |
| 11169 | const docProperties = await this.#docProperties(pdfDocument); |
| 11170 | if (pdfDocument !== this.#pdfDocument) { |
| 11171 | return; |
| 11172 | } |
| 11173 | await this.#scripting.createSandbox({ |
| 11174 | objects, |
| 11175 | calculationOrder, |
| 11176 | appInfo: { |
| 11177 | platform: navigator.platform, |
| 11178 | language: navigator.language |
| 11179 | }, |
| 11180 | docInfo: { |
| 11181 | ...docProperties, |
| 11182 | actions: docActions |
| 11183 | } |
| 11184 | }); |
| 11185 | eventBus.dispatch("sandboxcreated", { |
| 11186 | source: this |
| 11187 | }); |
| 11188 | } catch (error) { |
| 11189 | console.error(`setDocument: "${error.message}".`); |
| 11190 | await this.#destroyScripting(); |
| 11191 | return; |
| 11192 | } |
| 11193 | await this.#scripting?.dispatchEventInSandbox({ |
| 11194 | id: "doc", |
| 11195 | name: "Open" |
| 11196 | }); |
| 11197 | await this.#dispatchPageOpen(this.#pdfViewer.currentPageNumber, true); |
| 11198 | Promise.resolve().then(() => { |
| 11199 | if (pdfDocument === this.#pdfDocument) { |
| 11200 | this.#ready = true; |
| 11201 | } |
| 11202 | }); |
| 11203 | } |
| 11204 | async dispatchWillSave() { |
| 11205 | return this.#scripting?.dispatchEventInSandbox({ |
| 11206 | id: "doc", |
| 11207 | name: "WillSave" |
| 11208 | }); |
| 11209 | } |
| 11210 | async dispatchDidSave() { |
| 11211 | return this.#scripting?.dispatchEventInSandbox({ |
| 11212 | id: "doc", |
| 11213 | name: "DidSave" |
| 11214 | }); |
| 11215 | } |
| 11216 | async dispatchWillPrint() { |
| 11217 | if (!this.#scripting) { |
| 11218 | return; |
| 11219 | } |
| 11220 | await this.#willPrintCapability?.promise; |
| 11221 | this.#willPrintCapability = Promise.withResolvers(); |
| 11222 | try { |
| 11223 | await this.#scripting.dispatchEventInSandbox({ |
| 11224 | id: "doc", |
| 11225 | name: "WillPrint" |
| 11226 | }); |
| 11227 | } catch (ex) { |
| 11228 | this.#willPrintCapability.resolve(); |
| 11229 | this.#willPrintCapability = null; |
| 11230 | throw ex; |
| 11231 | } |
| 11232 | await this.#willPrintCapability.promise; |
| 11233 | } |
| 11234 | async dispatchDidPrint() { |
| 11235 | return this.#scripting?.dispatchEventInSandbox({ |
| 11236 | id: "doc", |
| 11237 | name: "DidPrint" |
| 11238 | }); |
| 11239 | } |
| 11240 | get destroyPromise() { |
| 11241 | return this.#destroyCapability?.promise || null; |
| 11242 | } |
| 11243 | get ready() { |
| 11244 | return this.#ready; |
| 11245 | } |
| 11246 | get _pageOpenPending() { |
| 11247 | return shadow(this, "_pageOpenPending", new Set()); |
| 11248 | } |
| 11249 | get _visitedPages() { |
| 11250 | return shadow(this, "_visitedPages", new Map()); |
| 11251 | } |
| 11252 | async #updateFromSandbox(detail) { |
| 11253 | const pdfViewer = this.#pdfViewer; |
| 11254 | const isInPresentationMode = pdfViewer.isInPresentationMode || pdfViewer.isChangingPresentationMode; |
| 11255 | const { |
| 11256 | id, |
| 11257 | siblings, |
| 11258 | command, |
| 11259 | value |
| 11260 | } = detail; |
| 11261 | if (!id) { |
| 11262 | switch (command) { |
| 11263 | case "clear": |
| 11264 | console.clear(); |
| 11265 | break; |
| 11266 | case "error": |
| 11267 | console.error(value); |
| 11268 | break; |
| 11269 | case "layout": |
| 11270 | if (!isInPresentationMode) { |
| 11271 | const modes = apiPageLayoutToViewerModes(value); |
| 11272 | pdfViewer.spreadMode = modes.spreadMode; |
| 11273 | } |
| 11274 | break; |
| 11275 | case "page-num": |
| 11276 | pdfViewer.currentPageNumber = value + 1; |
| 11277 | break; |
| 11278 | case "print": |
| 11279 | await pdfViewer.pagesPromise; |
| 11280 | this.#eventBus.dispatch("print", { |
| 11281 | source: this |
| 11282 | }); |
| 11283 | break; |
| 11284 | case "println": |
| 11285 | console.log(value); |
| 11286 | break; |
| 11287 | case "zoom": |
| 11288 | if (!isInPresentationMode) { |
| 11289 | pdfViewer.currentScaleValue = value; |
| 11290 | } |
| 11291 | break; |
| 11292 | case "SaveAs": |
| 11293 | this.#eventBus.dispatch("download", { |
| 11294 | source: this |
| 11295 | }); |
| 11296 | break; |
| 11297 | case "FirstPage": |
| 11298 | pdfViewer.currentPageNumber = 1; |
| 11299 | break; |
| 11300 | case "LastPage": |
| 11301 | pdfViewer.currentPageNumber = pdfViewer.pagesCount; |
| 11302 | break; |
| 11303 | case "NextPage": |
| 11304 | pdfViewer.nextPage(); |
| 11305 | break; |
| 11306 | case "PrevPage": |
| 11307 | pdfViewer.previousPage(); |
| 11308 | break; |
| 11309 | case "ZoomViewIn": |
| 11310 | if (!isInPresentationMode) { |
| 11311 | pdfViewer.increaseScale(); |
| 11312 | } |
| 11313 | break; |
| 11314 | case "ZoomViewOut": |
| 11315 | if (!isInPresentationMode) { |
| 11316 | pdfViewer.decreaseScale(); |
| 11317 | } |
| 11318 | break; |
| 11319 | case "WillPrintFinished": |
| 11320 | this.#willPrintCapability?.resolve(); |
| 11321 | this.#willPrintCapability = null; |
| 11322 | break; |
| 11323 | } |
| 11324 | return; |
| 11325 | } |
| 11326 | if (isInPresentationMode && detail.focus) { |
| 11327 | return; |
| 11328 | } |
| 11329 | delete detail.id; |
| 11330 | delete detail.siblings; |
| 11331 | const ids = siblings ? [id, ...siblings] : [id]; |
| 11332 | for (const elementId of ids) { |
| 11333 | const element = document.querySelector(`[data-element-id="${elementId}"]`); |
| 11334 | if (element) { |
| 11335 | element.dispatchEvent(new CustomEvent("updatefromsandbox", { |
| 11336 | detail |
| 11337 | })); |
| 11338 | } else { |
| 11339 | this.#pdfDocument?.annotationStorage.setValue(elementId, detail); |
| 11340 | } |
| 11341 | } |
| 11342 | } |
| 11343 | async #dispatchPageOpen(pageNumber, initialize = false) { |
| 11344 | const pdfDocument = this.#pdfDocument, |
| 11345 | visitedPages = this._visitedPages; |
| 11346 | if (initialize) { |
| 11347 | this.#closeCapability = Promise.withResolvers(); |
| 11348 | } |
| 11349 | if (!this.#closeCapability) { |
| 11350 | return; |
| 11351 | } |
| 11352 | const pageView = this.#pdfViewer.getPageView(pageNumber - 1); |
| 11353 | if (pageView?.renderingState !== RenderingStates.FINISHED) { |
| 11354 | this._pageOpenPending.add(pageNumber); |
| 11355 | return; |
| 11356 | } |
| 11357 | this._pageOpenPending.delete(pageNumber); |
| 11358 | const actionsPromise = (async () => { |
| 11359 | const actions = await (!visitedPages.has(pageNumber) ? pageView.pdfPage?.getJSActions() : null); |
| 11360 | if (pdfDocument !== this.#pdfDocument) { |
| 11361 | return; |
| 11362 | } |
| 11363 | await this.#scripting?.dispatchEventInSandbox({ |
| 11364 | id: "page", |
| 11365 | name: "PageOpen", |
| 11366 | pageNumber, |
| 11367 | actions |
| 11368 | }); |
| 11369 | })(); |
| 11370 | visitedPages.set(pageNumber, actionsPromise); |
| 11371 | } |
| 11372 | async #dispatchPageClose(pageNumber) { |
| 11373 | const pdfDocument = this.#pdfDocument, |
| 11374 | visitedPages = this._visitedPages; |
| 11375 | if (!this.#closeCapability) { |
| 11376 | return; |
| 11377 | } |
| 11378 | if (this._pageOpenPending.has(pageNumber)) { |
| 11379 | return; |
| 11380 | } |
| 11381 | const actionsPromise = visitedPages.get(pageNumber); |
| 11382 | if (!actionsPromise) { |
| 11383 | return; |
| 11384 | } |
| 11385 | visitedPages.set(pageNumber, null); |
| 11386 | await actionsPromise; |
| 11387 | if (pdfDocument !== this.#pdfDocument) { |
| 11388 | return; |
| 11389 | } |
| 11390 | await this.#scripting?.dispatchEventInSandbox({ |
| 11391 | id: "page", |
| 11392 | name: "PageClose", |
| 11393 | pageNumber |
| 11394 | }); |
| 11395 | } |
| 11396 | #initScripting() { |
| 11397 | this.#destroyCapability = Promise.withResolvers(); |
| 11398 | if (this.#scripting) { |
| 11399 | throw new Error("#initScripting: Scripting already exists."); |
| 11400 | } |
| 11401 | return this.#externalServices.createScripting(); |
| 11402 | } |
| 11403 | async #destroyScripting() { |
| 11404 | if (!this.#scripting) { |
| 11405 | this.#pdfDocument = null; |
| 11406 | this.#destroyCapability?.resolve(); |
| 11407 | return; |
| 11408 | } |
| 11409 | if (this.#closeCapability) { |
| 11410 | await Promise.race([this.#closeCapability.promise, new Promise(resolve => { |
| 11411 | setTimeout(resolve, 1000); |
| 11412 | })]).catch(() => {}); |
| 11413 | this.#closeCapability = null; |
| 11414 | } |
| 11415 | this.#pdfDocument = null; |
| 11416 | try { |
| 11417 | await this.#scripting.destroySandbox(); |
| 11418 | } catch {} |
| 11419 | this.#willPrintCapability?.reject(new Error("Scripting destroyed.")); |
| 11420 | this.#willPrintCapability = null; |
| 11421 | this.#eventAbortController?.abort(); |
| 11422 | this.#eventAbortController = null; |
| 11423 | this._pageOpenPending.clear(); |
| 11424 | this._visitedPages.clear(); |
| 11425 | this.#scripting = null; |
| 11426 | this.#ready = false; |
| 11427 | this.#destroyCapability?.resolve(); |
| 11428 | } |
| 11429 | } |
| 11430 | |
| 11431 | ;// CONCATENATED MODULE: ./web/pdf_sidebar.js |
| 11432 | |
| 11433 | const SIDEBAR_WIDTH_VAR = "--sidebar-width"; |
| 11434 | const SIDEBAR_MIN_WIDTH = 200; |
| 11435 | const SIDEBAR_RESIZING_CLASS = "sidebarResizing"; |
| 11436 | const UI_NOTIFICATION_CLASS = "pdfSidebarNotification"; |
| 11437 | class PDFSidebar { |
| 11438 | #isRTL = false; |
| 11439 | #mouseMoveBound = this.#mouseMove.bind(this); |
| 11440 | #mouseUpBound = this.#mouseUp.bind(this); |
| 11441 | #outerContainerWidth = null; |
| 11442 | #width = null; |
| 11443 | constructor({ |
| 11444 | elements, |
| 11445 | eventBus, |
| 11446 | l10n |
| 11447 | }) { |
| 11448 | this.isOpen = false; |
| 11449 | this.active = SidebarView.THUMBS; |
| 11450 | this.isInitialViewSet = false; |
| 11451 | this.isInitialEventDispatched = false; |
| 11452 | this.onToggled = null; |
| 11453 | this.onUpdateThumbnails = null; |
| 11454 | this.outerContainer = elements.outerContainer; |
| 11455 | this.sidebarContainer = elements.sidebarContainer; |
| 11456 | this.toggleButton = elements.toggleButton; |
| 11457 | this.resizer = elements.resizer; |
| 11458 | this.thumbnailButton = elements.thumbnailButton; |
| 11459 | this.outlineButton = elements.outlineButton; |
| 11460 | this.attachmentsButton = elements.attachmentsButton; |
| 11461 | this.layersButton = elements.layersButton; |
| 11462 | this.thumbnailView = elements.thumbnailView; |
| 11463 | this.outlineView = elements.outlineView; |
| 11464 | this.attachmentsView = elements.attachmentsView; |
| 11465 | this.layersView = elements.layersView; |
| 11466 | this._currentOutlineItemButton = elements.currentOutlineItemButton; |
| 11467 | this.eventBus = eventBus; |
| 11468 | this.#isRTL = l10n.getDirection() === "rtl"; |
| 11469 | this.#addEventListeners(); |
| 11470 | } |
| 11471 | reset() { |
| 11472 | this.isInitialViewSet = false; |
| 11473 | this.isInitialEventDispatched = false; |
| 11474 | this.#hideUINotification(true); |
| 11475 | this.switchView(SidebarView.THUMBS); |
| 11476 | this.outlineButton.disabled = false; |
| 11477 | this.attachmentsButton.disabled = false; |
| 11478 | this.layersButton.disabled = false; |
| 11479 | this._currentOutlineItemButton.disabled = true; |
| 11480 | } |
| 11481 | get visibleView() { |
| 11482 | return this.isOpen ? this.active : SidebarView.NONE; |
| 11483 | } |
| 11484 | setInitialView(view = SidebarView.NONE) { |
| 11485 | if (this.isInitialViewSet) { |
| 11486 | return; |
| 11487 | } |
| 11488 | this.isInitialViewSet = true; |
| 11489 | if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) { |
| 11490 | this.#dispatchEvent(); |
| 11491 | return; |
| 11492 | } |
| 11493 | this.switchView(view, true); |
| 11494 | if (!this.isInitialEventDispatched) { |
| 11495 | this.#dispatchEvent(); |
| 11496 | } |
| 11497 | } |
| 11498 | switchView(view, forceOpen = false) { |
| 11499 | const isViewChanged = view !== this.active; |
| 11500 | let forceRendering = false; |
| 11501 | switch (view) { |
| 11502 | case SidebarView.NONE: |
| 11503 | if (this.isOpen) { |
| 11504 | this.close(); |
| 11505 | } |
| 11506 | return; |
| 11507 | case SidebarView.THUMBS: |
| 11508 | if (this.isOpen && isViewChanged) { |
| 11509 | forceRendering = true; |
| 11510 | } |
| 11511 | break; |
| 11512 | case SidebarView.OUTLINE: |
| 11513 | if (this.outlineButton.disabled) { |
| 11514 | return; |
| 11515 | } |
| 11516 | break; |
| 11517 | case SidebarView.ATTACHMENTS: |
| 11518 | if (this.attachmentsButton.disabled) { |
| 11519 | return; |
| 11520 | } |
| 11521 | break; |
| 11522 | case SidebarView.LAYERS: |
| 11523 | if (this.layersButton.disabled) { |
| 11524 | return; |
| 11525 | } |
| 11526 | break; |
| 11527 | default: |
| 11528 | console.error(`PDFSidebar.switchView: "${view}" is not a valid view.`); |
| 11529 | return; |
| 11530 | } |
| 11531 | this.active = view; |
| 11532 | toggleCheckedBtn(this.thumbnailButton, view === SidebarView.THUMBS, this.thumbnailView); |
| 11533 | toggleCheckedBtn(this.outlineButton, view === SidebarView.OUTLINE, this.outlineView); |
| 11534 | toggleCheckedBtn(this.attachmentsButton, view === SidebarView.ATTACHMENTS, this.attachmentsView); |
| 11535 | toggleCheckedBtn(this.layersButton, view === SidebarView.LAYERS, this.layersView); |
| 11536 | if (forceOpen && !this.isOpen) { |
| 11537 | this.open(); |
| 11538 | return; |
| 11539 | } |
| 11540 | if (forceRendering) { |
| 11541 | this.onUpdateThumbnails(); |
| 11542 | this.onToggled(); |
| 11543 | } |
| 11544 | if (isViewChanged) { |
| 11545 | this.#dispatchEvent(); |
| 11546 | } |
| 11547 | } |
| 11548 | open() { |
| 11549 | if (this.isOpen) { |
| 11550 | return; |
| 11551 | } |
| 11552 | this.isOpen = true; |
| 11553 | toggleExpandedBtn(this.toggleButton, true); |
| 11554 | this.outerContainer.classList.add("sidebarMoving", "sidebarOpen"); |
| 11555 | if (this.active === SidebarView.THUMBS) { |
| 11556 | this.onUpdateThumbnails(); |
| 11557 | } |
| 11558 | this.onToggled(); |
| 11559 | this.#dispatchEvent(); |
| 11560 | this.#hideUINotification(); |
| 11561 | } |
| 11562 | close(evt = null) { |
| 11563 | if (!this.isOpen) { |
| 11564 | return; |
| 11565 | } |
| 11566 | this.isOpen = false; |
| 11567 | toggleExpandedBtn(this.toggleButton, false); |
| 11568 | this.outerContainer.classList.add("sidebarMoving"); |
| 11569 | this.outerContainer.classList.remove("sidebarOpen"); |
| 11570 | this.onToggled(); |
| 11571 | this.#dispatchEvent(); |
| 11572 | if (evt?.detail > 0) { |
| 11573 | this.toggleButton.blur(); |
| 11574 | } |
| 11575 | } |
| 11576 | toggle(evt = null) { |
| 11577 | if (this.isOpen) { |
| 11578 | this.close(evt); |
| 11579 | } else { |
| 11580 | this.open(); |
| 11581 | } |
| 11582 | } |
| 11583 | #dispatchEvent() { |
| 11584 | if (this.isInitialViewSet) { |
| 11585 | this.isInitialEventDispatched ||= true; |
| 11586 | } |
| 11587 | this.eventBus.dispatch("sidebarviewchanged", { |
| 11588 | source: this, |
| 11589 | view: this.visibleView |
| 11590 | }); |
| 11591 | } |
| 11592 | #showUINotification() { |
| 11593 | this.toggleButton.setAttribute("data-l10n-id", "pdfjs-toggle-sidebar-notification-button"); |
| 11594 | if (!this.isOpen) { |
| 11595 | this.toggleButton.classList.add(UI_NOTIFICATION_CLASS); |
| 11596 | } |
| 11597 | } |
| 11598 | #hideUINotification(reset = false) { |
| 11599 | if (this.isOpen || reset) { |
| 11600 | this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS); |
| 11601 | } |
| 11602 | if (reset) { |
| 11603 | this.toggleButton.setAttribute("data-l10n-id", "pdfjs-toggle-sidebar-button"); |
| 11604 | } |
| 11605 | } |
| 11606 | #addEventListeners() { |
| 11607 | this.sidebarContainer.addEventListener("transitionend", evt => { |
| 11608 | if (evt.target === this.sidebarContainer) { |
| 11609 | this.outerContainer.classList.remove("sidebarMoving"); |
| 11610 | this.eventBus.dispatch("resize", { |
| 11611 | source: this |
| 11612 | }); |
| 11613 | } |
| 11614 | }); |
| 11615 | this.toggleButton.addEventListener("click", evt => { |
| 11616 | this.toggle(evt); |
| 11617 | }); |
| 11618 | this.thumbnailButton.addEventListener("click", () => { |
| 11619 | this.switchView(SidebarView.THUMBS); |
| 11620 | }); |
| 11621 | this.outlineButton.addEventListener("click", () => { |
| 11622 | this.switchView(SidebarView.OUTLINE); |
| 11623 | }); |
| 11624 | this.outlineButton.addEventListener("dblclick", () => { |
| 11625 | this.eventBus.dispatch("toggleoutlinetree", { |
| 11626 | source: this |
| 11627 | }); |
| 11628 | }); |
| 11629 | this.attachmentsButton.addEventListener("click", () => { |
| 11630 | this.switchView(SidebarView.ATTACHMENTS); |
| 11631 | }); |
| 11632 | this.layersButton.addEventListener("click", () => { |
| 11633 | this.switchView(SidebarView.LAYERS); |
| 11634 | }); |
| 11635 | this.layersButton.addEventListener("dblclick", () => { |
| 11636 | this.eventBus.dispatch("resetlayers", { |
| 11637 | source: this |
| 11638 | }); |
| 11639 | }); |
| 11640 | this._currentOutlineItemButton.addEventListener("click", () => { |
| 11641 | this.eventBus.dispatch("currentoutlineitem", { |
| 11642 | source: this |
| 11643 | }); |
| 11644 | }); |
| 11645 | const onTreeLoaded = (count, button, view) => { |
| 11646 | button.disabled = !count; |
| 11647 | if (count) { |
| 11648 | this.#showUINotification(); |
| 11649 | } else if (this.active === view) { |
| 11650 | this.switchView(SidebarView.THUMBS); |
| 11651 | } |
| 11652 | }; |
| 11653 | this.eventBus._on("outlineloaded", evt => { |
| 11654 | onTreeLoaded(evt.outlineCount, this.outlineButton, SidebarView.OUTLINE); |
| 11655 | evt.currentOutlineItemPromise.then(enabled => { |
| 11656 | if (!this.isInitialViewSet) { |
| 11657 | return; |
| 11658 | } |
| 11659 | this._currentOutlineItemButton.disabled = !enabled; |
| 11660 | }); |
| 11661 | }); |
| 11662 | this.eventBus._on("attachmentsloaded", evt => { |
| 11663 | onTreeLoaded(evt.attachmentsCount, this.attachmentsButton, SidebarView.ATTACHMENTS); |
| 11664 | }); |
| 11665 | this.eventBus._on("layersloaded", evt => { |
| 11666 | onTreeLoaded(evt.layersCount, this.layersButton, SidebarView.LAYERS); |
| 11667 | }); |
| 11668 | this.eventBus._on("presentationmodechanged", evt => { |
| 11669 | if (evt.state === PresentationModeState.NORMAL && this.visibleView === SidebarView.THUMBS) { |
| 11670 | this.onUpdateThumbnails(); |
| 11671 | } |
| 11672 | }); |
| 11673 | this.resizer.addEventListener("mousedown", evt => { |
| 11674 | if (evt.button !== 0) { |
| 11675 | return; |
| 11676 | } |
| 11677 | this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS); |
| 11678 | window.addEventListener("mousemove", this.#mouseMoveBound); |
| 11679 | window.addEventListener("mouseup", this.#mouseUpBound); |
| 11680 | }); |
| 11681 | this.eventBus._on("resize", evt => { |
| 11682 | if (evt.source !== window) { |
| 11683 | return; |
| 11684 | } |
| 11685 | this.#outerContainerWidth = null; |
| 11686 | if (!this.#width) { |
| 11687 | return; |
| 11688 | } |
| 11689 | if (!this.isOpen) { |
| 11690 | this.#updateWidth(this.#width); |
| 11691 | return; |
| 11692 | } |
| 11693 | this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS); |
| 11694 | const updated = this.#updateWidth(this.#width); |
| 11695 | Promise.resolve().then(() => { |
| 11696 | this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS); |
| 11697 | if (updated) { |
| 11698 | this.eventBus.dispatch("resize", { |
| 11699 | source: this |
| 11700 | }); |
| 11701 | } |
| 11702 | }); |
| 11703 | }); |
| 11704 | } |
| 11705 | get outerContainerWidth() { |
| 11706 | return this.#outerContainerWidth ||= this.outerContainer.clientWidth; |
| 11707 | } |
| 11708 | #updateWidth(width = 0) { |
| 11709 | const maxWidth = Math.floor(this.outerContainerWidth / 2); |
| 11710 | if (width > maxWidth) { |
| 11711 | width = maxWidth; |
| 11712 | } |
| 11713 | if (width < SIDEBAR_MIN_WIDTH) { |
| 11714 | width = SIDEBAR_MIN_WIDTH; |
| 11715 | } |
| 11716 | if (width === this.#width) { |
| 11717 | return false; |
| 11718 | } |
| 11719 | this.#width = width; |
| 11720 | docStyle.setProperty(SIDEBAR_WIDTH_VAR, `${width}px`); |
| 11721 | return true; |
| 11722 | } |
| 11723 | #mouseMove(evt) { |
| 11724 | let width = evt.clientX; |
| 11725 | if (this.#isRTL) { |
| 11726 | width = this.outerContainerWidth - width; |
| 11727 | } |
| 11728 | this.#updateWidth(width); |
| 11729 | } |
| 11730 | #mouseUp(evt) { |
| 11731 | this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS); |
| 11732 | this.eventBus.dispatch("resize", { |
| 11733 | source: this |
| 11734 | }); |
| 11735 | window.removeEventListener("mousemove", this.#mouseMoveBound); |
| 11736 | window.removeEventListener("mouseup", this.#mouseUpBound); |
| 11737 | } |
| 11738 | } |
| 11739 | |
| 11740 | ;// CONCATENATED MODULE: ./web/pdf_thumbnail_view.js |
| 11741 | |
| 11742 | |
| 11743 | const DRAW_UPSCALE_FACTOR = 2; |
| 11744 | const MAX_NUM_SCALING_STEPS = 3; |
| 11745 | const THUMBNAIL_WIDTH = 98; |
| 11746 | class TempImageFactory { |
| 11747 | static #tempCanvas = null; |
| 11748 | static getCanvas(width, height) { |
| 11749 | const tempCanvas = this.#tempCanvas ||= document.createElement("canvas"); |
| 11750 | tempCanvas.width = width; |
| 11751 | tempCanvas.height = height; |
| 11752 | const ctx = tempCanvas.getContext("2d", { |
| 11753 | alpha: false |
| 11754 | }); |
| 11755 | ctx.save(); |
| 11756 | ctx.fillStyle = "rgb(255, 255, 255)"; |
| 11757 | ctx.fillRect(0, 0, width, height); |
| 11758 | ctx.restore(); |
| 11759 | return [tempCanvas, tempCanvas.getContext("2d")]; |
| 11760 | } |
| 11761 | static destroyCanvas() { |
| 11762 | const tempCanvas = this.#tempCanvas; |
| 11763 | if (tempCanvas) { |
| 11764 | tempCanvas.width = 0; |
| 11765 | tempCanvas.height = 0; |
| 11766 | } |
| 11767 | this.#tempCanvas = null; |
| 11768 | } |
| 11769 | } |
| 11770 | class PDFThumbnailView { |
| 11771 | constructor({ |
| 11772 | container, |
| 11773 | eventBus, |
| 11774 | id, |
| 11775 | defaultViewport, |
| 11776 | optionalContentConfigPromise, |
| 11777 | linkService, |
| 11778 | renderingQueue, |
| 11779 | pageColors |
| 11780 | }) { |
| 11781 | this.id = id; |
| 11782 | this.renderingId = "thumbnail" + id; |
| 11783 | this.pageLabel = null; |
| 11784 | this.pdfPage = null; |
| 11785 | this.rotation = 0; |
| 11786 | this.viewport = defaultViewport; |
| 11787 | this.pdfPageRotate = defaultViewport.rotation; |
| 11788 | this._optionalContentConfigPromise = optionalContentConfigPromise || null; |
| 11789 | this.pageColors = pageColors || null; |
| 11790 | this.eventBus = eventBus; |
| 11791 | this.linkService = linkService; |
| 11792 | this.renderingQueue = renderingQueue; |
| 11793 | this.renderTask = null; |
| 11794 | this.renderingState = RenderingStates.INITIAL; |
| 11795 | this.resume = null; |
| 11796 | const anchor = document.createElement("a"); |
| 11797 | anchor.href = linkService.getAnchorUrl("#page=" + id); |
| 11798 | anchor.setAttribute("data-l10n-id", "pdfjs-thumb-page-title"); |
| 11799 | anchor.setAttribute("data-l10n-args", this.#pageL10nArgs); |
| 11800 | anchor.onclick = function () { |
| 11801 | linkService.goToPage(id); |
| 11802 | return false; |
| 11803 | }; |
| 11804 | this.anchor = anchor; |
| 11805 | const div = document.createElement("div"); |
| 11806 | div.className = "thumbnail"; |
| 11807 | div.setAttribute("data-page-number", this.id); |
| 11808 | this.div = div; |
| 11809 | this.#updateDims(); |
| 11810 | const img = document.createElement("div"); |
| 11811 | img.className = "thumbnailImage"; |
| 11812 | this._placeholderImg = img; |
| 11813 | div.append(img); |
| 11814 | anchor.append(div); |
| 11815 | container.append(anchor); |
| 11816 | } |
| 11817 | #updateDims() { |
| 11818 | const { |
| 11819 | width, |
| 11820 | height |
| 11821 | } = this.viewport; |
| 11822 | const ratio = width / height; |
| 11823 | this.canvasWidth = THUMBNAIL_WIDTH; |
| 11824 | this.canvasHeight = this.canvasWidth / ratio | 0; |
| 11825 | this.scale = this.canvasWidth / width; |
| 11826 | const { |
| 11827 | style |
| 11828 | } = this.div; |
| 11829 | style.setProperty("--thumbnail-width", `${this.canvasWidth}px`); |
| 11830 | style.setProperty("--thumbnail-height", `${this.canvasHeight}px`); |
| 11831 | } |
| 11832 | setPdfPage(pdfPage) { |
| 11833 | this.pdfPage = pdfPage; |
| 11834 | this.pdfPageRotate = pdfPage.rotate; |
| 11835 | const totalRotation = (this.rotation + this.pdfPageRotate) % 360; |
| 11836 | this.viewport = pdfPage.getViewport({ |
| 11837 | scale: 1, |
| 11838 | rotation: totalRotation |
| 11839 | }); |
| 11840 | this.reset(); |
| 11841 | } |
| 11842 | reset() { |
| 11843 | this.cancelRendering(); |
| 11844 | this.renderingState = RenderingStates.INITIAL; |
| 11845 | this.div.removeAttribute("data-loaded"); |
| 11846 | this.image?.replaceWith(this._placeholderImg); |
| 11847 | this.#updateDims(); |
| 11848 | if (this.image) { |
| 11849 | this.image.removeAttribute("src"); |
| 11850 | delete this.image; |
| 11851 | } |
| 11852 | } |
| 11853 | update({ |
| 11854 | rotation = null |
| 11855 | }) { |
| 11856 | if (typeof rotation === "number") { |
| 11857 | this.rotation = rotation; |
| 11858 | } |
| 11859 | const totalRotation = (this.rotation + this.pdfPageRotate) % 360; |
| 11860 | this.viewport = this.viewport.clone({ |
| 11861 | scale: 1, |
| 11862 | rotation: totalRotation |
| 11863 | }); |
| 11864 | this.reset(); |
| 11865 | } |
| 11866 | cancelRendering() { |
| 11867 | if (this.renderTask) { |
| 11868 | this.renderTask.cancel(); |
| 11869 | this.renderTask = null; |
| 11870 | } |
| 11871 | this.resume = null; |
| 11872 | } |
| 11873 | #getPageDrawContext(upscaleFactor = 1) { |
| 11874 | const canvas = document.createElement("canvas"); |
| 11875 | const ctx = canvas.getContext("2d", { |
| 11876 | alpha: false |
| 11877 | }); |
| 11878 | const outputScale = new OutputScale(); |
| 11879 | canvas.width = upscaleFactor * this.canvasWidth * outputScale.sx | 0; |
| 11880 | canvas.height = upscaleFactor * this.canvasHeight * outputScale.sy | 0; |
| 11881 | const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null; |
| 11882 | return { |
| 11883 | ctx, |
| 11884 | canvas, |
| 11885 | transform |
| 11886 | }; |
| 11887 | } |
| 11888 | #convertCanvasToImage(canvas) { |
| 11889 | if (this.renderingState !== RenderingStates.FINISHED) { |
| 11890 | throw new Error("#convertCanvasToImage: Rendering has not finished."); |
| 11891 | } |
| 11892 | const reducedCanvas = this.#reduceImage(canvas); |
| 11893 | const image = document.createElement("img"); |
| 11894 | image.className = "thumbnailImage"; |
| 11895 | image.setAttribute("data-l10n-id", "pdfjs-thumb-page-canvas"); |
| 11896 | image.setAttribute("data-l10n-args", this.#pageL10nArgs); |
| 11897 | image.src = reducedCanvas.toDataURL(); |
| 11898 | this.image = image; |
| 11899 | this.div.setAttribute("data-loaded", true); |
| 11900 | this._placeholderImg.replaceWith(image); |
| 11901 | reducedCanvas.width = 0; |
| 11902 | reducedCanvas.height = 0; |
| 11903 | } |
| 11904 | async #finishRenderTask(renderTask, canvas, error = null) { |
| 11905 | if (renderTask === this.renderTask) { |
| 11906 | this.renderTask = null; |
| 11907 | } |
| 11908 | if (error instanceof RenderingCancelledException) { |
| 11909 | return; |
| 11910 | } |
| 11911 | this.renderingState = RenderingStates.FINISHED; |
| 11912 | this.#convertCanvasToImage(canvas); |
| 11913 | if (error) { |
| 11914 | throw error; |
| 11915 | } |
| 11916 | } |
| 11917 | async draw() { |
| 11918 | if (this.renderingState !== RenderingStates.INITIAL) { |
| 11919 | console.error("Must be in new state before drawing"); |
| 11920 | return undefined; |
| 11921 | } |
| 11922 | const { |
| 11923 | pdfPage |
| 11924 | } = this; |
| 11925 | if (!pdfPage) { |
| 11926 | this.renderingState = RenderingStates.FINISHED; |
| 11927 | throw new Error("pdfPage is not loaded"); |
| 11928 | } |
| 11929 | this.renderingState = RenderingStates.RUNNING; |
| 11930 | const { |
| 11931 | ctx, |
| 11932 | canvas, |
| 11933 | transform |
| 11934 | } = this.#getPageDrawContext(DRAW_UPSCALE_FACTOR); |
| 11935 | const drawViewport = this.viewport.clone({ |
| 11936 | scale: DRAW_UPSCALE_FACTOR * this.scale |
| 11937 | }); |
| 11938 | const renderContinueCallback = cont => { |
| 11939 | if (!this.renderingQueue.isHighestPriority(this)) { |
| 11940 | this.renderingState = RenderingStates.PAUSED; |
| 11941 | this.resume = () => { |
| 11942 | this.renderingState = RenderingStates.RUNNING; |
| 11943 | cont(); |
| 11944 | }; |
| 11945 | return; |
| 11946 | } |
| 11947 | cont(); |
| 11948 | }; |
| 11949 | const renderContext = { |
| 11950 | canvasContext: ctx, |
| 11951 | transform, |
| 11952 | viewport: drawViewport, |
| 11953 | optionalContentConfigPromise: this._optionalContentConfigPromise, |
| 11954 | pageColors: this.pageColors |
| 11955 | }; |
| 11956 | const renderTask = this.renderTask = pdfPage.render(renderContext); |
| 11957 | renderTask.onContinue = renderContinueCallback; |
| 11958 | const resultPromise = renderTask.promise.then(() => this.#finishRenderTask(renderTask, canvas), error => this.#finishRenderTask(renderTask, canvas, error)); |
| 11959 | resultPromise.finally(() => { |
| 11960 | canvas.width = 0; |
| 11961 | canvas.height = 0; |
| 11962 | this.eventBus.dispatch("thumbnailrendered", { |
| 11963 | source: this, |
| 11964 | pageNumber: this.id, |
| 11965 | pdfPage: this.pdfPage |
| 11966 | }); |
| 11967 | }); |
| 11968 | return resultPromise; |
| 11969 | } |
| 11970 | setImage(pageView) { |
| 11971 | if (this.renderingState !== RenderingStates.INITIAL) { |
| 11972 | return; |
| 11973 | } |
| 11974 | const { |
| 11975 | thumbnailCanvas: canvas, |
| 11976 | pdfPage, |
| 11977 | scale |
| 11978 | } = pageView; |
| 11979 | if (!canvas) { |
| 11980 | return; |
| 11981 | } |
| 11982 | if (!this.pdfPage) { |
| 11983 | this.setPdfPage(pdfPage); |
| 11984 | } |
| 11985 | if (scale < this.scale) { |
| 11986 | return; |
| 11987 | } |
| 11988 | this.renderingState = RenderingStates.FINISHED; |
| 11989 | this.#convertCanvasToImage(canvas); |
| 11990 | } |
| 11991 | #reduceImage(img) { |
| 11992 | const { |
| 11993 | ctx, |
| 11994 | canvas |
| 11995 | } = this.#getPageDrawContext(); |
| 11996 | if (img.width <= 2 * canvas.width) { |
| 11997 | ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height); |
| 11998 | return canvas; |
| 11999 | } |
| 12000 | let reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS; |
| 12001 | let reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS; |
| 12002 | const [reducedImage, reducedImageCtx] = TempImageFactory.getCanvas(reducedWidth, reducedHeight); |
| 12003 | while (reducedWidth > img.width || reducedHeight > img.height) { |
| 12004 | reducedWidth >>= 1; |
| 12005 | reducedHeight >>= 1; |
| 12006 | } |
| 12007 | reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight); |
| 12008 | while (reducedWidth > 2 * canvas.width) { |
| 12009 | reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1); |
| 12010 | reducedWidth >>= 1; |
| 12011 | reducedHeight >>= 1; |
| 12012 | } |
| 12013 | ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height); |
| 12014 | return canvas; |
| 12015 | } |
| 12016 | get #pageL10nArgs() { |
| 12017 | return JSON.stringify({ |
| 12018 | page: this.pageLabel ?? this.id |
| 12019 | }); |
| 12020 | } |
| 12021 | setPageLabel(label) { |
| 12022 | this.pageLabel = typeof label === "string" ? label : null; |
| 12023 | this.anchor.setAttribute("data-l10n-args", this.#pageL10nArgs); |
| 12024 | if (this.renderingState !== RenderingStates.FINISHED) { |
| 12025 | return; |
| 12026 | } |
| 12027 | this.image?.setAttribute("data-l10n-args", this.#pageL10nArgs); |
| 12028 | } |
| 12029 | } |
| 12030 | |
| 12031 | ;// CONCATENATED MODULE: ./web/pdf_thumbnail_viewer.js |
| 12032 | |
| 12033 | |
| 12034 | |
| 12035 | const THUMBNAIL_SCROLL_MARGIN = -19; |
| 12036 | const THUMBNAIL_SELECTED_CLASS = "selected"; |
| 12037 | class PDFThumbnailViewer { |
| 12038 | constructor({ |
| 12039 | container, |
| 12040 | eventBus, |
| 12041 | linkService, |
| 12042 | renderingQueue, |
| 12043 | pageColors |
| 12044 | }) { |
| 12045 | this.container = container; |
| 12046 | this.eventBus = eventBus; |
| 12047 | this.linkService = linkService; |
| 12048 | this.renderingQueue = renderingQueue; |
| 12049 | this.pageColors = pageColors || null; |
| 12050 | this.scroll = watchScroll(this.container, this.#scrollUpdated.bind(this)); |
| 12051 | this.#resetView(); |
| 12052 | } |
| 12053 | #scrollUpdated() { |
| 12054 | this.renderingQueue.renderHighestPriority(); |
| 12055 | } |
| 12056 | getThumbnail(index) { |
| 12057 | return this._thumbnails[index]; |
| 12058 | } |
| 12059 | #getVisibleThumbs() { |
| 12060 | return getVisibleElements({ |
| 12061 | scrollEl: this.container, |
| 12062 | views: this._thumbnails |
| 12063 | }); |
| 12064 | } |
| 12065 | scrollThumbnailIntoView(pageNumber) { |
| 12066 | if (!this.pdfDocument) { |
| 12067 | return; |
| 12068 | } |
| 12069 | const thumbnailView = this._thumbnails[pageNumber - 1]; |
| 12070 | if (!thumbnailView) { |
| 12071 | console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.'); |
| 12072 | return; |
| 12073 | } |
| 12074 | if (pageNumber !== this._currentPageNumber) { |
| 12075 | const prevThumbnailView = this._thumbnails[this._currentPageNumber - 1]; |
| 12076 | prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS); |
| 12077 | thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS); |
| 12078 | } |
| 12079 | const { |
| 12080 | first, |
| 12081 | last, |
| 12082 | views |
| 12083 | } = this.#getVisibleThumbs(); |
| 12084 | if (views.length > 0) { |
| 12085 | let shouldScroll = false; |
| 12086 | if (pageNumber <= first.id || pageNumber >= last.id) { |
| 12087 | shouldScroll = true; |
| 12088 | } else { |
| 12089 | for (const { |
| 12090 | id, |
| 12091 | percent |
| 12092 | } of views) { |
| 12093 | if (id !== pageNumber) { |
| 12094 | continue; |
| 12095 | } |
| 12096 | shouldScroll = percent < 100; |
| 12097 | break; |
| 12098 | } |
| 12099 | } |
| 12100 | if (shouldScroll) { |
| 12101 | scrollIntoView(thumbnailView.div, { |
| 12102 | top: THUMBNAIL_SCROLL_MARGIN |
| 12103 | }); |
| 12104 | } |
| 12105 | } |
| 12106 | this._currentPageNumber = pageNumber; |
| 12107 | } |
| 12108 | get pagesRotation() { |
| 12109 | return this._pagesRotation; |
| 12110 | } |
| 12111 | set pagesRotation(rotation) { |
| 12112 | if (!isValidRotation(rotation)) { |
| 12113 | throw new Error("Invalid thumbnails rotation angle."); |
| 12114 | } |
| 12115 | if (!this.pdfDocument) { |
| 12116 | return; |
| 12117 | } |
| 12118 | if (this._pagesRotation === rotation) { |
| 12119 | return; |
| 12120 | } |
| 12121 | this._pagesRotation = rotation; |
| 12122 | const updateArgs = { |
| 12123 | rotation |
| 12124 | }; |
| 12125 | for (const thumbnail of this._thumbnails) { |
| 12126 | thumbnail.update(updateArgs); |
| 12127 | } |
| 12128 | } |
| 12129 | cleanup() { |
| 12130 | for (const thumbnail of this._thumbnails) { |
| 12131 | if (thumbnail.renderingState !== RenderingStates.FINISHED) { |
| 12132 | thumbnail.reset(); |
| 12133 | } |
| 12134 | } |
| 12135 | TempImageFactory.destroyCanvas(); |
| 12136 | } |
| 12137 | #resetView() { |
| 12138 | this._thumbnails = []; |
| 12139 | this._currentPageNumber = 1; |
| 12140 | this._pageLabels = null; |
| 12141 | this._pagesRotation = 0; |
| 12142 | this.container.textContent = ""; |
| 12143 | } |
| 12144 | setDocument(pdfDocument) { |
| 12145 | if (this.pdfDocument) { |
| 12146 | this.#cancelRendering(); |
| 12147 | this.#resetView(); |
| 12148 | } |
| 12149 | this.pdfDocument = pdfDocument; |
| 12150 | if (!pdfDocument) { |
| 12151 | return; |
| 12152 | } |
| 12153 | const firstPagePromise = pdfDocument.getPage(1); |
| 12154 | const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig({ |
| 12155 | intent: "display" |
| 12156 | }); |
| 12157 | firstPagePromise.then(firstPdfPage => { |
| 12158 | const pagesCount = pdfDocument.numPages; |
| 12159 | const viewport = firstPdfPage.getViewport({ |
| 12160 | scale: 1 |
| 12161 | }); |
| 12162 | for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) { |
| 12163 | const thumbnail = new PDFThumbnailView({ |
| 12164 | container: this.container, |
| 12165 | eventBus: this.eventBus, |
| 12166 | id: pageNum, |
| 12167 | defaultViewport: viewport.clone(), |
| 12168 | optionalContentConfigPromise, |
| 12169 | linkService: this.linkService, |
| 12170 | renderingQueue: this.renderingQueue, |
| 12171 | pageColors: this.pageColors |
| 12172 | }); |
| 12173 | this._thumbnails.push(thumbnail); |
| 12174 | } |
| 12175 | this._thumbnails[0]?.setPdfPage(firstPdfPage); |
| 12176 | const thumbnailView = this._thumbnails[this._currentPageNumber - 1]; |
| 12177 | thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS); |
| 12178 | }).catch(reason => { |
| 12179 | console.error("Unable to initialize thumbnail viewer", reason); |
| 12180 | }); |
| 12181 | } |
| 12182 | #cancelRendering() { |
| 12183 | for (const thumbnail of this._thumbnails) { |
| 12184 | thumbnail.cancelRendering(); |
| 12185 | } |
| 12186 | } |
| 12187 | setPageLabels(labels) { |
| 12188 | if (!this.pdfDocument) { |
| 12189 | return; |
| 12190 | } |
| 12191 | if (!labels) { |
| 12192 | this._pageLabels = null; |
| 12193 | } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) { |
| 12194 | this._pageLabels = null; |
| 12195 | console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels."); |
| 12196 | } else { |
| 12197 | this._pageLabels = labels; |
| 12198 | } |
| 12199 | for (let i = 0, ii = this._thumbnails.length; i < ii; i++) { |
| 12200 | this._thumbnails[i].setPageLabel(this._pageLabels?.[i] ?? null); |
| 12201 | } |
| 12202 | } |
| 12203 | async #ensurePdfPageLoaded(thumbView) { |
| 12204 | if (thumbView.pdfPage) { |
| 12205 | return thumbView.pdfPage; |
| 12206 | } |
| 12207 | try { |
| 12208 | const pdfPage = await this.pdfDocument.getPage(thumbView.id); |
| 12209 | if (!thumbView.pdfPage) { |
| 12210 | thumbView.setPdfPage(pdfPage); |
| 12211 | } |
| 12212 | return pdfPage; |
| 12213 | } catch (reason) { |
| 12214 | console.error("Unable to get page for thumb view", reason); |
| 12215 | return null; |
| 12216 | } |
| 12217 | } |
| 12218 | #getScrollAhead(visible) { |
| 12219 | if (visible.first?.id === 1) { |
| 12220 | return true; |
| 12221 | } else if (visible.last?.id === this._thumbnails.length) { |
| 12222 | return false; |
| 12223 | } |
| 12224 | return this.scroll.down; |
| 12225 | } |
| 12226 | forceRendering() { |
| 12227 | const visibleThumbs = this.#getVisibleThumbs(); |
| 12228 | const scrollAhead = this.#getScrollAhead(visibleThumbs); |
| 12229 | const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, scrollAhead); |
| 12230 | if (thumbView) { |
| 12231 | this.#ensurePdfPageLoaded(thumbView).then(() => { |
| 12232 | this.renderingQueue.renderView(thumbView); |
| 12233 | }); |
| 12234 | return true; |
| 12235 | } |
| 12236 | return false; |
| 12237 | } |
| 12238 | } |
| 12239 | |
| 12240 | ;// CONCATENATED MODULE: ./web/annotation_editor_layer_builder.js |
| 12241 | |
| 12242 | |
| 12243 | class AnnotationEditorLayerBuilder { |
| 12244 | #annotationLayer = null; |
| 12245 | #drawLayer = null; |
| 12246 | #onAppend = null; |
| 12247 | #textLayer = null; |
| 12248 | #uiManager; |
| 12249 | constructor(options) { |
| 12250 | this.pdfPage = options.pdfPage; |
| 12251 | this.accessibilityManager = options.accessibilityManager; |
| 12252 | this.l10n = options.l10n; |
| 12253 | this.l10n ||= new genericl10n_GenericL10n(); |
| 12254 | this.annotationEditorLayer = null; |
| 12255 | this.div = null; |
| 12256 | this._cancelled = false; |
| 12257 | this.#uiManager = options.uiManager; |
| 12258 | this.#annotationLayer = options.annotationLayer || null; |
| 12259 | this.#textLayer = options.textLayer || null; |
| 12260 | this.#drawLayer = options.drawLayer || null; |
| 12261 | this.#onAppend = options.onAppend || null; |
| 12262 | } |
| 12263 | async render(viewport, intent = "display") { |
| 12264 | if (intent !== "display") { |
| 12265 | return; |
| 12266 | } |
| 12267 | if (this._cancelled) { |
| 12268 | return; |
| 12269 | } |
| 12270 | const clonedViewport = viewport.clone({ |
| 12271 | dontFlip: true |
| 12272 | }); |
| 12273 | if (this.div) { |
| 12274 | this.annotationEditorLayer.update({ |
| 12275 | viewport: clonedViewport |
| 12276 | }); |
| 12277 | this.show(); |
| 12278 | return; |
| 12279 | } |
| 12280 | const div = this.div = document.createElement("div"); |
| 12281 | div.className = "annotationEditorLayer"; |
| 12282 | div.hidden = true; |
| 12283 | div.dir = this.#uiManager.direction; |
| 12284 | this.#onAppend?.(div); |
| 12285 | this.annotationEditorLayer = new AnnotationEditorLayer({ |
| 12286 | uiManager: this.#uiManager, |
| 12287 | div, |
| 12288 | accessibilityManager: this.accessibilityManager, |
| 12289 | pageIndex: this.pdfPage.pageNumber - 1, |
| 12290 | l10n: this.l10n, |
| 12291 | viewport: clonedViewport, |
| 12292 | annotationLayer: this.#annotationLayer, |
| 12293 | textLayer: this.#textLayer, |
| 12294 | drawLayer: this.#drawLayer |
| 12295 | }); |
| 12296 | const parameters = { |
| 12297 | viewport: clonedViewport, |
| 12298 | div, |
| 12299 | annotations: null, |
| 12300 | intent |
| 12301 | }; |
| 12302 | this.annotationEditorLayer.render(parameters); |
| 12303 | this.show(); |
| 12304 | } |
| 12305 | cancel() { |
| 12306 | this._cancelled = true; |
| 12307 | if (!this.div) { |
| 12308 | return; |
| 12309 | } |
| 12310 | this.annotationEditorLayer.destroy(); |
| 12311 | } |
| 12312 | hide() { |
| 12313 | if (!this.div) { |
| 12314 | return; |
| 12315 | } |
| 12316 | this.div.hidden = true; |
| 12317 | } |
| 12318 | show() { |
| 12319 | if (!this.div || this.annotationEditorLayer.isInvisible) { |
| 12320 | return; |
| 12321 | } |
| 12322 | this.div.hidden = false; |
| 12323 | } |
| 12324 | } |
| 12325 | |
| 12326 | ;// CONCATENATED MODULE: ./web/annotation_layer_builder.js |
| 12327 | |
| 12328 | |
| 12329 | class AnnotationLayerBuilder { |
| 12330 | #onAppend = null; |
| 12331 | #eventAbortController = null; |
| 12332 | constructor({ |
| 12333 | pdfPage, |
| 12334 | linkService, |
| 12335 | downloadManager, |
| 12336 | annotationStorage = null, |
| 12337 | imageResourcesPath = "", |
| 12338 | renderForms = true, |
| 12339 | enableScripting = false, |
| 12340 | hasJSActionsPromise = null, |
| 12341 | fieldObjectsPromise = null, |
| 12342 | annotationCanvasMap = null, |
| 12343 | accessibilityManager = null, |
| 12344 | annotationEditorUIManager = null, |
| 12345 | onAppend = null |
| 12346 | }) { |
| 12347 | this.pdfPage = pdfPage; |
| 12348 | this.linkService = linkService; |
| 12349 | this.downloadManager = downloadManager; |
| 12350 | this.imageResourcesPath = imageResourcesPath; |
| 12351 | this.renderForms = renderForms; |
| 12352 | this.annotationStorage = annotationStorage; |
| 12353 | this.enableScripting = enableScripting; |
| 12354 | this._hasJSActionsPromise = hasJSActionsPromise || Promise.resolve(false); |
| 12355 | this._fieldObjectsPromise = fieldObjectsPromise || Promise.resolve(null); |
| 12356 | this._annotationCanvasMap = annotationCanvasMap; |
| 12357 | this._accessibilityManager = accessibilityManager; |
| 12358 | this._annotationEditorUIManager = annotationEditorUIManager; |
| 12359 | this.#onAppend = onAppend; |
| 12360 | this.annotationLayer = null; |
| 12361 | this.div = null; |
| 12362 | this._cancelled = false; |
| 12363 | this._eventBus = linkService.eventBus; |
| 12364 | } |
| 12365 | async render(viewport, intent = "display") { |
| 12366 | if (this.div) { |
| 12367 | if (this._cancelled || !this.annotationLayer) { |
| 12368 | return; |
| 12369 | } |
| 12370 | this.annotationLayer.update({ |
| 12371 | viewport: viewport.clone({ |
| 12372 | dontFlip: true |
| 12373 | }) |
| 12374 | }); |
| 12375 | return; |
| 12376 | } |
| 12377 | const [annotations, hasJSActions, fieldObjects] = await Promise.all([this.pdfPage.getAnnotations({ |
| 12378 | intent |
| 12379 | }), this._hasJSActionsPromise, this._fieldObjectsPromise]); |
| 12380 | if (this._cancelled) { |
| 12381 | return; |
| 12382 | } |
| 12383 | const div = this.div = document.createElement("div"); |
| 12384 | div.className = "annotationLayer"; |
| 12385 | this.#onAppend?.(div); |
| 12386 | if (annotations.length === 0) { |
| 12387 | this.hide(); |
| 12388 | return; |
| 12389 | } |
| 12390 | this.annotationLayer = new AnnotationLayer({ |
| 12391 | div, |
| 12392 | accessibilityManager: this._accessibilityManager, |
| 12393 | annotationCanvasMap: this._annotationCanvasMap, |
| 12394 | annotationEditorUIManager: this._annotationEditorUIManager, |
| 12395 | page: this.pdfPage, |
| 12396 | viewport: viewport.clone({ |
| 12397 | dontFlip: true |
| 12398 | }) |
| 12399 | }); |
| 12400 | await this.annotationLayer.render({ |
| 12401 | annotations, |
| 12402 | imageResourcesPath: this.imageResourcesPath, |
| 12403 | renderForms: this.renderForms, |
| 12404 | linkService: this.linkService, |
| 12405 | downloadManager: this.downloadManager, |
| 12406 | annotationStorage: this.annotationStorage, |
| 12407 | enableScripting: this.enableScripting, |
| 12408 | hasJSActions, |
| 12409 | fieldObjects |
| 12410 | }); |
| 12411 | if (this.linkService.isInPresentationMode) { |
| 12412 | this.#updatePresentationModeState(PresentationModeState.FULLSCREEN); |
| 12413 | } |
| 12414 | if (!this.#eventAbortController) { |
| 12415 | this.#eventAbortController = new AbortController(); |
| 12416 | this._eventBus?._on("presentationmodechanged", evt => { |
| 12417 | this.#updatePresentationModeState(evt.state); |
| 12418 | }, { |
| 12419 | signal: this.#eventAbortController.signal |
| 12420 | }); |
| 12421 | } |
| 12422 | } |
| 12423 | cancel() { |
| 12424 | this._cancelled = true; |
| 12425 | this.#eventAbortController?.abort(); |
| 12426 | this.#eventAbortController = null; |
| 12427 | } |
| 12428 | hide() { |
| 12429 | if (!this.div) { |
| 12430 | return; |
| 12431 | } |
| 12432 | this.div.hidden = true; |
| 12433 | } |
| 12434 | #updatePresentationModeState(state) { |
| 12435 | if (!this.div) { |
| 12436 | return; |
| 12437 | } |
| 12438 | let disableFormElements = false; |
| 12439 | switch (state) { |
| 12440 | case PresentationModeState.FULLSCREEN: |
| 12441 | disableFormElements = true; |
| 12442 | break; |
| 12443 | case PresentationModeState.NORMAL: |
| 12444 | break; |
| 12445 | default: |
| 12446 | return; |
| 12447 | } |
| 12448 | for (const section of this.div.childNodes) { |
| 12449 | if (section.hasAttribute("data-internal-link")) { |
| 12450 | continue; |
| 12451 | } |
| 12452 | section.inert = disableFormElements; |
| 12453 | } |
| 12454 | } |
| 12455 | } |
| 12456 | |
| 12457 | ;// CONCATENATED MODULE: ./web/draw_layer_builder.js |
| 12458 | |
| 12459 | class DrawLayerBuilder { |
| 12460 | #drawLayer = null; |
| 12461 | constructor(options) { |
| 12462 | this.pageIndex = options.pageIndex; |
| 12463 | } |
| 12464 | async render(intent = "display") { |
| 12465 | if (intent !== "display" || this.#drawLayer || this._cancelled) { |
| 12466 | return; |
| 12467 | } |
| 12468 | this.#drawLayer = new DrawLayer({ |
| 12469 | pageIndex: this.pageIndex |
| 12470 | }); |
| 12471 | } |
| 12472 | cancel() { |
| 12473 | this._cancelled = true; |
| 12474 | if (!this.#drawLayer) { |
| 12475 | return; |
| 12476 | } |
| 12477 | this.#drawLayer.destroy(); |
| 12478 | this.#drawLayer = null; |
| 12479 | } |
| 12480 | setParent(parent) { |
| 12481 | this.#drawLayer?.setParent(parent); |
| 12482 | } |
| 12483 | getDrawLayer() { |
| 12484 | return this.#drawLayer; |
| 12485 | } |
| 12486 | } |
| 12487 | |
| 12488 | ;// CONCATENATED MODULE: ./web/struct_tree_layer_builder.js |
| 12489 | |
| 12490 | const PDF_ROLE_TO_HTML_ROLE = { |
| 12491 | Document: null, |
| 12492 | DocumentFragment: null, |
| 12493 | Part: "group", |
| 12494 | Sect: "group", |
| 12495 | Div: "group", |
| 12496 | Aside: "note", |
| 12497 | NonStruct: "none", |
| 12498 | P: null, |
| 12499 | H: "heading", |
| 12500 | Title: null, |
| 12501 | FENote: "note", |
| 12502 | Sub: "group", |
| 12503 | Lbl: null, |
| 12504 | Span: null, |
| 12505 | Em: null, |
| 12506 | Strong: null, |
| 12507 | Link: "link", |
| 12508 | Annot: "note", |
| 12509 | Form: "form", |
| 12510 | Ruby: null, |
| 12511 | RB: null, |
| 12512 | RT: null, |
| 12513 | RP: null, |
| 12514 | Warichu: null, |
| 12515 | WT: null, |
| 12516 | WP: null, |
| 12517 | L: "list", |
| 12518 | LI: "listitem", |
| 12519 | LBody: null, |
| 12520 | Table: "table", |
| 12521 | TR: "row", |
| 12522 | TH: "columnheader", |
| 12523 | TD: "cell", |
| 12524 | THead: "columnheader", |
| 12525 | TBody: null, |
| 12526 | TFoot: null, |
| 12527 | Caption: null, |
| 12528 | Figure: "figure", |
| 12529 | Formula: null, |
| 12530 | Artifact: null |
| 12531 | }; |
| 12532 | const HEADING_PATTERN = /^H(\d+)$/; |
| 12533 | class StructTreeLayerBuilder { |
| 12534 | #treeDom = undefined; |
| 12535 | get renderingDone() { |
| 12536 | return this.#treeDom !== undefined; |
| 12537 | } |
| 12538 | render(structTree) { |
| 12539 | if (this.#treeDom !== undefined) { |
| 12540 | return this.#treeDom; |
| 12541 | } |
| 12542 | const treeDom = this.#walk(structTree); |
| 12543 | treeDom?.classList.add("structTree"); |
| 12544 | return this.#treeDom = treeDom; |
| 12545 | } |
| 12546 | hide() { |
| 12547 | if (this.#treeDom && !this.#treeDom.hidden) { |
| 12548 | this.#treeDom.hidden = true; |
| 12549 | } |
| 12550 | } |
| 12551 | show() { |
| 12552 | if (this.#treeDom?.hidden) { |
| 12553 | this.#treeDom.hidden = false; |
| 12554 | } |
| 12555 | } |
| 12556 | #setAttributes(structElement, htmlElement) { |
| 12557 | const { |
| 12558 | alt, |
| 12559 | id, |
| 12560 | lang |
| 12561 | } = structElement; |
| 12562 | if (alt !== undefined) { |
| 12563 | htmlElement.setAttribute("aria-label", removeNullCharacters(alt)); |
| 12564 | } |
| 12565 | if (id !== undefined) { |
| 12566 | htmlElement.setAttribute("aria-owns", id); |
| 12567 | } |
| 12568 | if (lang !== undefined) { |
| 12569 | htmlElement.setAttribute("lang", removeNullCharacters(lang, true)); |
| 12570 | } |
| 12571 | } |
| 12572 | #walk(node) { |
| 12573 | if (!node) { |
| 12574 | return null; |
| 12575 | } |
| 12576 | const element = document.createElement("span"); |
| 12577 | if ("role" in node) { |
| 12578 | const { |
| 12579 | role |
| 12580 | } = node; |
| 12581 | const match = role.match(HEADING_PATTERN); |
| 12582 | if (match) { |
| 12583 | element.setAttribute("role", "heading"); |
| 12584 | element.setAttribute("aria-level", match[1]); |
| 12585 | } else if (PDF_ROLE_TO_HTML_ROLE[role]) { |
| 12586 | element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[role]); |
| 12587 | } |
| 12588 | } |
| 12589 | this.#setAttributes(node, element); |
| 12590 | if (node.children) { |
| 12591 | if (node.children.length === 1 && "id" in node.children[0]) { |
| 12592 | this.#setAttributes(node.children[0], element); |
| 12593 | } else { |
| 12594 | for (const kid of node.children) { |
| 12595 | element.append(this.#walk(kid)); |
| 12596 | } |
| 12597 | } |
| 12598 | } |
| 12599 | return element; |
| 12600 | } |
| 12601 | } |
| 12602 | |
| 12603 | ;// CONCATENATED MODULE: ./web/text_accessibility.js |
| 12604 | |
| 12605 | |
| 12606 | |
| 12607 | class TextAccessibilityManager { |
| 12608 | #enabled = false; |
| 12609 | #textChildren = null; |
| 12610 | #textNodes = new Map(); |
| 12611 | #waitingElements = new Map(); |
| 12612 | setTextMapping(textDivs) { |
| 12613 | this.#textChildren = textDivs; |
| 12614 | } |
| 12615 | static #compareElementPositions(e1, e2) { |
| 12616 | const rect1 = e1.getBoundingClientRect(); |
| 12617 | const rect2 = e2.getBoundingClientRect(); |
| 12618 | if (rect1.width === 0 && rect1.height === 0) { |
| 12619 | return +1; |
| 12620 | } |
| 12621 | if (rect2.width === 0 && rect2.height === 0) { |
| 12622 | return -1; |
| 12623 | } |
| 12624 | const top1 = rect1.y; |
| 12625 | const bot1 = rect1.y + rect1.height; |
| 12626 | const mid1 = rect1.y + rect1.height / 2; |
| 12627 | const top2 = rect2.y; |
| 12628 | const bot2 = rect2.y + rect2.height; |
| 12629 | const mid2 = rect2.y + rect2.height / 2; |
| 12630 | if (mid1 <= top2 && mid2 >= bot1) { |
| 12631 | return -1; |
| 12632 | } |
| 12633 | if (mid2 <= top1 && mid1 >= bot2) { |
| 12634 | return +1; |
| 12635 | } |
| 12636 | const centerX1 = rect1.x + rect1.width / 2; |
| 12637 | const centerX2 = rect2.x + rect2.width / 2; |
| 12638 | return centerX1 - centerX2; |
| 12639 | } |
| 12640 | enable() { |
| 12641 | if (this.#enabled) { |
| 12642 | throw new Error("TextAccessibilityManager is already enabled."); |
| 12643 | } |
| 12644 | if (!this.#textChildren) { |
| 12645 | throw new Error("Text divs and strings have not been set."); |
| 12646 | } |
| 12647 | this.#enabled = true; |
| 12648 | this.#textChildren = this.#textChildren.slice(); |
| 12649 | this.#textChildren.sort(TextAccessibilityManager.#compareElementPositions); |
| 12650 | if (this.#textNodes.size > 0) { |
| 12651 | const textChildren = this.#textChildren; |
| 12652 | for (const [id, nodeIndex] of this.#textNodes) { |
| 12653 | const element = document.getElementById(id); |
| 12654 | if (!element) { |
| 12655 | this.#textNodes.delete(id); |
| 12656 | continue; |
| 12657 | } |
| 12658 | this.#addIdToAriaOwns(id, textChildren[nodeIndex]); |
| 12659 | } |
| 12660 | } |
| 12661 | for (const [element, isRemovable] of this.#waitingElements) { |
| 12662 | this.addPointerInTextLayer(element, isRemovable); |
| 12663 | } |
| 12664 | this.#waitingElements.clear(); |
| 12665 | } |
| 12666 | disable() { |
| 12667 | if (!this.#enabled) { |
| 12668 | return; |
| 12669 | } |
| 12670 | this.#waitingElements.clear(); |
| 12671 | this.#textChildren = null; |
| 12672 | this.#enabled = false; |
| 12673 | } |
| 12674 | removePointerInTextLayer(element) { |
| 12675 | if (!this.#enabled) { |
| 12676 | this.#waitingElements.delete(element); |
| 12677 | return; |
| 12678 | } |
| 12679 | const children = this.#textChildren; |
| 12680 | if (!children || children.length === 0) { |
| 12681 | return; |
| 12682 | } |
| 12683 | const { |
| 12684 | id |
| 12685 | } = element; |
| 12686 | const nodeIndex = this.#textNodes.get(id); |
| 12687 | if (nodeIndex === undefined) { |
| 12688 | return; |
| 12689 | } |
| 12690 | const node = children[nodeIndex]; |
| 12691 | this.#textNodes.delete(id); |
| 12692 | let owns = node.getAttribute("aria-owns"); |
| 12693 | if (owns?.includes(id)) { |
| 12694 | owns = owns.split(" ").filter(x => x !== id).join(" "); |
| 12695 | if (owns) { |
| 12696 | node.setAttribute("aria-owns", owns); |
| 12697 | } else { |
| 12698 | node.removeAttribute("aria-owns"); |
| 12699 | node.setAttribute("role", "presentation"); |
| 12700 | } |
| 12701 | } |
| 12702 | } |
| 12703 | #addIdToAriaOwns(id, node) { |
| 12704 | const owns = node.getAttribute("aria-owns"); |
| 12705 | if (!owns?.includes(id)) { |
| 12706 | node.setAttribute("aria-owns", owns ? `${owns} ${id}` : id); |
| 12707 | } |
| 12708 | node.removeAttribute("role"); |
| 12709 | } |
| 12710 | addPointerInTextLayer(element, isRemovable) { |
| 12711 | const { |
| 12712 | id |
| 12713 | } = element; |
| 12714 | if (!id) { |
| 12715 | return null; |
| 12716 | } |
| 12717 | if (!this.#enabled) { |
| 12718 | this.#waitingElements.set(element, isRemovable); |
| 12719 | return null; |
| 12720 | } |
| 12721 | if (isRemovable) { |
| 12722 | this.removePointerInTextLayer(element); |
| 12723 | } |
| 12724 | const children = this.#textChildren; |
| 12725 | if (!children || children.length === 0) { |
| 12726 | return null; |
| 12727 | } |
| 12728 | const index = binarySearchFirstItem(children, node => TextAccessibilityManager.#compareElementPositions(element, node) < 0); |
| 12729 | const nodeIndex = Math.max(0, index - 1); |
| 12730 | const child = children[nodeIndex]; |
| 12731 | this.#addIdToAriaOwns(id, child); |
| 12732 | this.#textNodes.set(id, nodeIndex); |
| 12733 | const parent = child.parentNode; |
| 12734 | return parent?.classList.contains("markedContent") ? parent.id : null; |
| 12735 | } |
| 12736 | moveElementInDOM(container, element, contentElement, isRemovable) { |
| 12737 | const id = this.addPointerInTextLayer(contentElement, isRemovable); |
| 12738 | if (!container.hasChildNodes()) { |
| 12739 | container.append(element); |
| 12740 | return id; |
| 12741 | } |
| 12742 | const children = Array.from(container.childNodes).filter(node => node !== element); |
| 12743 | if (children.length === 0) { |
| 12744 | return id; |
| 12745 | } |
| 12746 | const elementToCompare = contentElement || element; |
| 12747 | const index = binarySearchFirstItem(children, node => TextAccessibilityManager.#compareElementPositions(elementToCompare, node) < 0); |
| 12748 | if (index === 0) { |
| 12749 | children[0].before(element); |
| 12750 | } else { |
| 12751 | children[index - 1].after(element); |
| 12752 | } |
| 12753 | return id; |
| 12754 | } |
| 12755 | } |
| 12756 | |
| 12757 | ;// CONCATENATED MODULE: ./web/text_highlighter.js |
| 12758 | |
| 12759 | class TextHighlighter { |
| 12760 | #eventAbortController = null; |
| 12761 | constructor({ |
| 12762 | findController, |
| 12763 | eventBus, |
| 12764 | pageIndex |
| 12765 | }) { |
| 12766 | this.findController = findController; |
| 12767 | this.matches = []; |
| 12768 | this.eventBus = eventBus; |
| 12769 | this.pageIdx = pageIndex; |
| 12770 | this.textDivs = null; |
| 12771 | this.textContentItemsStr = null; |
| 12772 | this.enabled = false; |
| 12773 | } |
| 12774 | setTextMapping(divs, texts) { |
| 12775 | this.textDivs = divs; |
| 12776 | this.textContentItemsStr = texts; |
| 12777 | } |
| 12778 | enable() { |
| 12779 | if (!this.textDivs || !this.textContentItemsStr) { |
| 12780 | throw new Error("Text divs and strings have not been set."); |
| 12781 | } |
| 12782 | if (this.enabled) { |
| 12783 | throw new Error("TextHighlighter is already enabled."); |
| 12784 | } |
| 12785 | this.enabled = true; |
| 12786 | if (!this.#eventAbortController) { |
| 12787 | this.#eventAbortController = new AbortController(); |
| 12788 | this.eventBus._on("updatetextlayermatches", evt => { |
| 12789 | if (evt.pageIndex === this.pageIdx || evt.pageIndex === -1) { |
| 12790 | this._updateMatches(); |
| 12791 | } |
| 12792 | }, { |
| 12793 | signal: this.#eventAbortController.signal |
| 12794 | }); |
| 12795 | } |
| 12796 | this._updateMatches(); |
| 12797 | } |
| 12798 | disable() { |
| 12799 | if (!this.enabled) { |
| 12800 | return; |
| 12801 | } |
| 12802 | this.enabled = false; |
| 12803 | this.#eventAbortController?.abort(); |
| 12804 | this.#eventAbortController = null; |
| 12805 | this._updateMatches(true); |
| 12806 | } |
| 12807 | _convertMatches(matches, matchesLength) { |
| 12808 | if (!matches) { |
| 12809 | return []; |
| 12810 | } |
| 12811 | const { |
| 12812 | textContentItemsStr |
| 12813 | } = this; |
| 12814 | let i = 0, |
| 12815 | iIndex = 0; |
| 12816 | const end = textContentItemsStr.length - 1; |
| 12817 | const result = []; |
| 12818 | for (let m = 0, mm = matches.length; m < mm; m++) { |
| 12819 | let matchIdx = matches[m]; |
| 12820 | while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) { |
| 12821 | iIndex += textContentItemsStr[i].length; |
| 12822 | i++; |
| 12823 | } |
| 12824 | if (i === textContentItemsStr.length) { |
| 12825 | console.error("Could not find a matching mapping"); |
| 12826 | } |
| 12827 | const match = { |
| 12828 | begin: { |
| 12829 | divIdx: i, |
| 12830 | offset: matchIdx - iIndex |
| 12831 | } |
| 12832 | }; |
| 12833 | matchIdx += matchesLength[m]; |
| 12834 | while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) { |
| 12835 | iIndex += textContentItemsStr[i].length; |
| 12836 | i++; |
| 12837 | } |
| 12838 | match.end = { |
| 12839 | divIdx: i, |
| 12840 | offset: matchIdx - iIndex |
| 12841 | }; |
| 12842 | result.push(match); |
| 12843 | } |
| 12844 | return result; |
| 12845 | } |
| 12846 | _renderMatches(matches) { |
| 12847 | if (matches.length === 0) { |
| 12848 | return; |
| 12849 | } |
| 12850 | const { |
| 12851 | findController, |
| 12852 | pageIdx |
| 12853 | } = this; |
| 12854 | const { |
| 12855 | textContentItemsStr, |
| 12856 | textDivs |
| 12857 | } = this; |
| 12858 | const isSelectedPage = pageIdx === findController.selected.pageIdx; |
| 12859 | const selectedMatchIdx = findController.selected.matchIdx; |
| 12860 | const highlightAll = findController.state.highlightAll; |
| 12861 | let prevEnd = null; |
| 12862 | const infinity = { |
| 12863 | divIdx: -1, |
| 12864 | offset: undefined |
| 12865 | }; |
| 12866 | function beginText(begin, className) { |
| 12867 | const divIdx = begin.divIdx; |
| 12868 | textDivs[divIdx].textContent = ""; |
| 12869 | return appendTextToDiv(divIdx, 0, begin.offset, className); |
| 12870 | } |
| 12871 | function appendTextToDiv(divIdx, fromOffset, toOffset, className) { |
| 12872 | let div = textDivs[divIdx]; |
| 12873 | if (div.nodeType === Node.TEXT_NODE) { |
| 12874 | const span = document.createElement("span"); |
| 12875 | div.before(span); |
| 12876 | span.append(div); |
| 12877 | textDivs[divIdx] = span; |
| 12878 | div = span; |
| 12879 | } |
| 12880 | const content = textContentItemsStr[divIdx].substring(fromOffset, toOffset); |
| 12881 | const node = document.createTextNode(content); |
| 12882 | if (className) { |
| 12883 | const span = document.createElement("span"); |
| 12884 | span.className = `${className} appended`; |
| 12885 | span.append(node); |
| 12886 | div.append(span); |
| 12887 | return className.includes("selected") ? span.offsetLeft : 0; |
| 12888 | } |
| 12889 | div.append(node); |
| 12890 | return 0; |
| 12891 | } |
| 12892 | let i0 = selectedMatchIdx, |
| 12893 | i1 = i0 + 1; |
| 12894 | if (highlightAll) { |
| 12895 | i0 = 0; |
| 12896 | i1 = matches.length; |
| 12897 | } else if (!isSelectedPage) { |
| 12898 | return; |
| 12899 | } |
| 12900 | let lastDivIdx = -1; |
| 12901 | let lastOffset = -1; |
| 12902 | for (let i = i0; i < i1; i++) { |
| 12903 | const match = matches[i]; |
| 12904 | const begin = match.begin; |
| 12905 | if (begin.divIdx === lastDivIdx && begin.offset === lastOffset) { |
| 12906 | continue; |
| 12907 | } |
| 12908 | lastDivIdx = begin.divIdx; |
| 12909 | lastOffset = begin.offset; |
| 12910 | const end = match.end; |
| 12911 | const isSelected = isSelectedPage && i === selectedMatchIdx; |
| 12912 | const highlightSuffix = isSelected ? " selected" : ""; |
| 12913 | let selectedLeft = 0; |
| 12914 | if (!prevEnd || begin.divIdx !== prevEnd.divIdx) { |
| 12915 | if (prevEnd !== null) { |
| 12916 | appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset); |
| 12917 | } |
| 12918 | beginText(begin); |
| 12919 | } else { |
| 12920 | appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset); |
| 12921 | } |
| 12922 | if (begin.divIdx === end.divIdx) { |
| 12923 | selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix); |
| 12924 | } else { |
| 12925 | selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix); |
| 12926 | for (let n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) { |
| 12927 | textDivs[n0].className = "highlight middle" + highlightSuffix; |
| 12928 | } |
| 12929 | beginText(end, "highlight end" + highlightSuffix); |
| 12930 | } |
| 12931 | prevEnd = end; |
| 12932 | if (isSelected) { |
| 12933 | findController.scrollMatchIntoView({ |
| 12934 | element: textDivs[begin.divIdx], |
| 12935 | selectedLeft, |
| 12936 | pageIndex: pageIdx, |
| 12937 | matchIndex: selectedMatchIdx |
| 12938 | }); |
| 12939 | } |
| 12940 | } |
| 12941 | if (prevEnd) { |
| 12942 | appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset); |
| 12943 | } |
| 12944 | } |
| 12945 | _updateMatches(reset = false) { |
| 12946 | if (!this.enabled && !reset) { |
| 12947 | return; |
| 12948 | } |
| 12949 | const { |
| 12950 | findController, |
| 12951 | matches, |
| 12952 | pageIdx |
| 12953 | } = this; |
| 12954 | const { |
| 12955 | textContentItemsStr, |
| 12956 | textDivs |
| 12957 | } = this; |
| 12958 | let clearedUntilDivIdx = -1; |
| 12959 | for (const match of matches) { |
| 12960 | const begin = Math.max(clearedUntilDivIdx, match.begin.divIdx); |
| 12961 | for (let n = begin, end = match.end.divIdx; n <= end; n++) { |
| 12962 | const div = textDivs[n]; |
| 12963 | div.textContent = textContentItemsStr[n]; |
| 12964 | div.className = ""; |
| 12965 | } |
| 12966 | clearedUntilDivIdx = match.end.divIdx + 1; |
| 12967 | } |
| 12968 | if (!findController?.highlightMatches || reset) { |
| 12969 | return; |
| 12970 | } |
| 12971 | const pageMatches = findController.pageMatches[pageIdx] || null; |
| 12972 | const pageMatchesLength = findController.pageMatchesLength[pageIdx] || null; |
| 12973 | this.matches = this._convertMatches(pageMatches, pageMatchesLength); |
| 12974 | this._renderMatches(this.matches); |
| 12975 | } |
| 12976 | } |
| 12977 | |
| 12978 | ;// CONCATENATED MODULE: ./web/text_layer_builder.js |
| 12979 | |
| 12980 | |
| 12981 | |
| 12982 | |
| 12983 | |
| 12984 | |
| 12985 | |
| 12986 | |
| 12987 | |
| 12988 | |
| 12989 | |
| 12990 | class TextLayerBuilder { |
| 12991 | #enablePermissions = false; |
| 12992 | #onAppend = null; |
| 12993 | #renderingDone = false; |
| 12994 | #textLayer = null; |
| 12995 | static #textLayers = new Map(); |
| 12996 | static #selectionChangeAbortController = null; |
| 12997 | constructor({ |
| 12998 | pdfPage, |
| 12999 | highlighter = null, |
| 13000 | accessibilityManager = null, |
| 13001 | enablePermissions = false, |
| 13002 | onAppend = null |
| 13003 | }) { |
| 13004 | this.pdfPage = pdfPage; |
| 13005 | this.highlighter = highlighter; |
| 13006 | this.accessibilityManager = accessibilityManager; |
| 13007 | this.#enablePermissions = enablePermissions === true; |
| 13008 | this.#onAppend = onAppend; |
| 13009 | this.div = document.createElement("div"); |
| 13010 | this.div.tabIndex = 0; |
| 13011 | this.div.className = "textLayer"; |
| 13012 | } |
| 13013 | #finishRendering() { |
| 13014 | this.#renderingDone = true; |
| 13015 | const endOfContent = document.createElement("div"); |
| 13016 | endOfContent.className = "endOfContent"; |
| 13017 | this.div.append(endOfContent); |
| 13018 | this.#bindMouse(endOfContent); |
| 13019 | } |
| 13020 | async render(viewport, textContentParams = null) { |
| 13021 | if (this.#renderingDone && this.#textLayer) { |
| 13022 | this.#textLayer.update({ |
| 13023 | viewport, |
| 13024 | onBefore: this.hide.bind(this) |
| 13025 | }); |
| 13026 | this.show(); |
| 13027 | return; |
| 13028 | } |
| 13029 | this.cancel(); |
| 13030 | this.#textLayer = new TextLayer({ |
| 13031 | textContentSource: this.pdfPage.streamTextContent(textContentParams || { |
| 13032 | includeMarkedContent: true, |
| 13033 | disableNormalization: true |
| 13034 | }), |
| 13035 | container: this.div, |
| 13036 | viewport |
| 13037 | }); |
| 13038 | const { |
| 13039 | textDivs, |
| 13040 | textContentItemsStr |
| 13041 | } = this.#textLayer; |
| 13042 | this.highlighter?.setTextMapping(textDivs, textContentItemsStr); |
| 13043 | this.accessibilityManager?.setTextMapping(textDivs); |
| 13044 | await this.#textLayer.render(); |
| 13045 | this.#finishRendering(); |
| 13046 | this.#onAppend?.(this.div); |
| 13047 | this.highlighter?.enable(); |
| 13048 | this.accessibilityManager?.enable(); |
| 13049 | } |
| 13050 | hide() { |
| 13051 | if (!this.div.hidden && this.#renderingDone) { |
| 13052 | this.highlighter?.disable(); |
| 13053 | this.div.hidden = true; |
| 13054 | } |
| 13055 | } |
| 13056 | show() { |
| 13057 | if (this.div.hidden && this.#renderingDone) { |
| 13058 | this.div.hidden = false; |
| 13059 | this.highlighter?.enable(); |
| 13060 | } |
| 13061 | } |
| 13062 | cancel() { |
| 13063 | this.#textLayer?.cancel(); |
| 13064 | this.#textLayer = null; |
| 13065 | this.highlighter?.disable(); |
| 13066 | this.accessibilityManager?.disable(); |
| 13067 | TextLayerBuilder.#removeGlobalSelectionListener(this.div); |
| 13068 | } |
| 13069 | #bindMouse(end) { |
| 13070 | const { |
| 13071 | div |
| 13072 | } = this; |
| 13073 | div.addEventListener("mousedown", evt => { |
| 13074 | end.classList.add("active"); |
| 13075 | }); |
| 13076 | div.addEventListener("copy", event => { |
| 13077 | if (!this.#enablePermissions) { |
| 13078 | const selection = document.getSelection(); |
| 13079 | event.clipboardData.setData("text/plain", removeNullCharacters(normalizeUnicode(selection.toString()))); |
| 13080 | } |
| 13081 | event.preventDefault(); |
| 13082 | event.stopPropagation(); |
| 13083 | }); |
| 13084 | TextLayerBuilder.#textLayers.set(div, end); |
| 13085 | TextLayerBuilder.#enableGlobalSelectionListener(); |
| 13086 | } |
| 13087 | static #removeGlobalSelectionListener(textLayerDiv) { |
| 13088 | this.#textLayers.delete(textLayerDiv); |
| 13089 | if (this.#textLayers.size === 0) { |
| 13090 | this.#selectionChangeAbortController?.abort(); |
| 13091 | this.#selectionChangeAbortController = null; |
| 13092 | } |
| 13093 | } |
| 13094 | static #enableGlobalSelectionListener() { |
| 13095 | if (this.#selectionChangeAbortController) { |
| 13096 | return; |
| 13097 | } |
| 13098 | this.#selectionChangeAbortController = new AbortController(); |
| 13099 | const { |
| 13100 | signal |
| 13101 | } = this.#selectionChangeAbortController; |
| 13102 | const reset = (end, textLayer) => { |
| 13103 | textLayer.append(end); |
| 13104 | end.style.width = ""; |
| 13105 | end.style.height = ""; |
| 13106 | end.classList.remove("active"); |
| 13107 | }; |
| 13108 | document.addEventListener("pointerup", () => { |
| 13109 | this.#textLayers.forEach(reset); |
| 13110 | }, { |
| 13111 | signal |
| 13112 | }); |
| 13113 | var isFirefox, prevRange; |
| 13114 | document.addEventListener("selectionchange", () => { |
| 13115 | const selection = document.getSelection(); |
| 13116 | if (selection.rangeCount === 0) { |
| 13117 | this.#textLayers.forEach(reset); |
| 13118 | return; |
| 13119 | } |
| 13120 | const activeTextLayers = new Set(); |
| 13121 | for (let i = 0; i < selection.rangeCount; i++) { |
| 13122 | const range = selection.getRangeAt(i); |
| 13123 | for (const textLayerDiv of this.#textLayers.keys()) { |
| 13124 | if (!activeTextLayers.has(textLayerDiv) && range.intersectsNode(textLayerDiv)) { |
| 13125 | activeTextLayers.add(textLayerDiv); |
| 13126 | } |
| 13127 | } |
| 13128 | } |
| 13129 | for (const [textLayerDiv, endDiv] of this.#textLayers) { |
| 13130 | if (activeTextLayers.has(textLayerDiv)) { |
| 13131 | endDiv.classList.add("active"); |
| 13132 | } else { |
| 13133 | reset(endDiv, textLayerDiv); |
| 13134 | } |
| 13135 | } |
| 13136 | isFirefox ??= getComputedStyle(this.#textLayers.values().next().value).getPropertyValue("-moz-user-select") === "none"; |
| 13137 | if (isFirefox) { |
| 13138 | return; |
| 13139 | } |
| 13140 | const range = selection.getRangeAt(0); |
| 13141 | const modifyStart = prevRange && (range.compareBoundaryPoints(Range.END_TO_END, prevRange) === 0 || range.compareBoundaryPoints(Range.START_TO_END, prevRange) === 0); |
| 13142 | let anchor = modifyStart ? range.startContainer : range.endContainer; |
| 13143 | if (anchor.nodeType === Node.TEXT_NODE) { |
| 13144 | anchor = anchor.parentNode; |
| 13145 | } |
| 13146 | const parentTextLayer = anchor.parentElement.closest(".textLayer"); |
| 13147 | const endDiv = this.#textLayers.get(parentTextLayer); |
| 13148 | if (endDiv) { |
| 13149 | endDiv.style.width = parentTextLayer.style.width; |
| 13150 | endDiv.style.height = parentTextLayer.style.height; |
| 13151 | anchor.parentElement.insertBefore(endDiv, modifyStart ? anchor : anchor.nextSibling); |
| 13152 | } |
| 13153 | prevRange = range.cloneRange(); |
| 13154 | }, { |
| 13155 | signal |
| 13156 | }); |
| 13157 | } |
| 13158 | } |
| 13159 | |
| 13160 | ;// CONCATENATED MODULE: ./web/pdf_page_view.js |
| 13161 | |
| 13162 | |
| 13163 | |
| 13164 | |
| 13165 | |
| 13166 | |
| 13167 | |
| 13168 | |
| 13169 | |
| 13170 | |
| 13171 | |
| 13172 | |
| 13173 | |
| 13174 | |
| 13175 | const DEFAULT_LAYER_PROPERTIES = null; |
| 13176 | const LAYERS_ORDER = new Map([["canvasWrapper", 0], ["textLayer", 1], ["annotationLayer", 2], ["annotationEditorLayer", 3], ["xfaLayer", 3]]); |
| 13177 | class PDFPageView { |
| 13178 | #annotationMode = AnnotationMode.ENABLE_FORMS; |
| 13179 | #hasRestrictedScaling = false; |
| 13180 | #layerProperties = null; |
| 13181 | #loadingId = null; |
| 13182 | #previousRotation = null; |
| 13183 | #renderError = null; |
| 13184 | #renderingState = RenderingStates.INITIAL; |
| 13185 | #textLayerMode = TextLayerMode.ENABLE; |
| 13186 | #useThumbnailCanvas = { |
| 13187 | directDrawing: true, |
| 13188 | initialOptionalContent: true, |
| 13189 | regularAnnotations: true |
| 13190 | }; |
| 13191 | #viewportMap = new WeakMap(); |
| 13192 | #layers = [null, null, null, null]; |
| 13193 | constructor(options) { |
| 13194 | const container = options.container; |
| 13195 | const defaultViewport = options.defaultViewport; |
| 13196 | this.id = options.id; |
| 13197 | this.renderingId = "page" + this.id; |
| 13198 | this.#layerProperties = options.layerProperties || DEFAULT_LAYER_PROPERTIES; |
| 13199 | this.pdfPage = null; |
| 13200 | this.pageLabel = null; |
| 13201 | this.rotation = 0; |
| 13202 | this.scale = options.scale || DEFAULT_SCALE; |
| 13203 | this.viewport = defaultViewport; |
| 13204 | this.pdfPageRotate = defaultViewport.rotation; |
| 13205 | this._optionalContentConfigPromise = options.optionalContentConfigPromise || null; |
| 13206 | this.#textLayerMode = options.textLayerMode ?? TextLayerMode.ENABLE; |
| 13207 | this.#annotationMode = options.annotationMode ?? AnnotationMode.ENABLE_FORMS; |
| 13208 | this.imageResourcesPath = options.imageResourcesPath || ""; |
| 13209 | this.maxCanvasPixels = options.maxCanvasPixels ?? AppOptions.get("maxCanvasPixels"); |
| 13210 | this.pageColors = options.pageColors || null; |
| 13211 | this.eventBus = options.eventBus; |
| 13212 | this.renderingQueue = options.renderingQueue; |
| 13213 | this.l10n = options.l10n; |
| 13214 | this.l10n ||= new genericl10n_GenericL10n(); |
| 13215 | this.renderTask = null; |
| 13216 | this.resume = null; |
| 13217 | this._isStandalone = !this.renderingQueue?.hasViewer(); |
| 13218 | this._container = container; |
| 13219 | this._annotationCanvasMap = null; |
| 13220 | this.annotationLayer = null; |
| 13221 | this.annotationEditorLayer = null; |
| 13222 | this.textLayer = null; |
| 13223 | this.zoomLayer = null; |
| 13224 | this.xfaLayer = null; |
| 13225 | this.structTreeLayer = null; |
| 13226 | this.drawLayer = null; |
| 13227 | const div = document.createElement("div"); |
| 13228 | div.className = "page"; |
| 13229 | div.setAttribute("data-page-number", this.id); |
| 13230 | div.setAttribute("role", "region"); |
| 13231 | div.setAttribute("data-l10n-id", "pdfjs-page-landmark"); |
| 13232 | div.setAttribute("data-l10n-args", JSON.stringify({ |
| 13233 | page: this.id |
| 13234 | })); |
| 13235 | this.div = div; |
| 13236 | this.#setDimensions(); |
| 13237 | container?.append(div); |
| 13238 | if (this._isStandalone) { |
| 13239 | container?.style.setProperty("--scale-factor", this.scale * PixelsPerInch.PDF_TO_CSS_UNITS); |
| 13240 | const { |
| 13241 | optionalContentConfigPromise |
| 13242 | } = options; |
| 13243 | if (optionalContentConfigPromise) { |
| 13244 | optionalContentConfigPromise.then(optionalContentConfig => { |
| 13245 | if (optionalContentConfigPromise !== this._optionalContentConfigPromise) { |
| 13246 | return; |
| 13247 | } |
| 13248 | this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility; |
| 13249 | }); |
| 13250 | } |
| 13251 | if (!options.l10n) { |
| 13252 | this.l10n.translate(this.div); |
| 13253 | } |
| 13254 | } |
| 13255 | } |
| 13256 | #addLayer(div, name) { |
| 13257 | const pos = LAYERS_ORDER.get(name); |
| 13258 | const oldDiv = this.#layers[pos]; |
| 13259 | this.#layers[pos] = div; |
| 13260 | if (oldDiv) { |
| 13261 | oldDiv.replaceWith(div); |
| 13262 | return; |
| 13263 | } |
| 13264 | for (let i = pos - 1; i >= 0; i--) { |
| 13265 | const layer = this.#layers[i]; |
| 13266 | if (layer) { |
| 13267 | layer.after(div); |
| 13268 | return; |
| 13269 | } |
| 13270 | } |
| 13271 | this.div.prepend(div); |
| 13272 | } |
| 13273 | get renderingState() { |
| 13274 | return this.#renderingState; |
| 13275 | } |
| 13276 | set renderingState(state) { |
| 13277 | if (state === this.#renderingState) { |
| 13278 | return; |
| 13279 | } |
| 13280 | this.#renderingState = state; |
| 13281 | if (this.#loadingId) { |
| 13282 | clearTimeout(this.#loadingId); |
| 13283 | this.#loadingId = null; |
| 13284 | } |
| 13285 | switch (state) { |
| 13286 | case RenderingStates.PAUSED: |
| 13287 | this.div.classList.remove("loading"); |
| 13288 | break; |
| 13289 | case RenderingStates.RUNNING: |
| 13290 | this.div.classList.add("loadingIcon"); |
| 13291 | this.#loadingId = setTimeout(() => { |
| 13292 | this.div.classList.add("loading"); |
| 13293 | this.#loadingId = null; |
| 13294 | }, 0); |
| 13295 | break; |
| 13296 | case RenderingStates.INITIAL: |
| 13297 | case RenderingStates.FINISHED: |
| 13298 | this.div.classList.remove("loadingIcon", "loading"); |
| 13299 | break; |
| 13300 | } |
| 13301 | } |
| 13302 | #setDimensions() { |
| 13303 | const { |
| 13304 | viewport |
| 13305 | } = this; |
| 13306 | if (this.pdfPage) { |
| 13307 | if (this.#previousRotation === viewport.rotation) { |
| 13308 | return; |
| 13309 | } |
| 13310 | this.#previousRotation = viewport.rotation; |
| 13311 | } |
| 13312 | setLayerDimensions(this.div, viewport, true, false); |
| 13313 | } |
| 13314 | setPdfPage(pdfPage) { |
| 13315 | if (this._isStandalone && (this.pageColors?.foreground === "CanvasText" || this.pageColors?.background === "Canvas")) { |
| 13316 | this._container?.style.setProperty("--hcm-highlight-filter", pdfPage.filterFactory.addHighlightHCMFilter("highlight", "CanvasText", "Canvas", "HighlightText", "Highlight")); |
| 13317 | this._container?.style.setProperty("--hcm-highlight-selected-filter", pdfPage.filterFactory.addHighlightHCMFilter("highlight_selected", "CanvasText", "Canvas", "HighlightText", "Highlight")); |
| 13318 | } |
| 13319 | this.pdfPage = pdfPage; |
| 13320 | this.pdfPageRotate = pdfPage.rotate; |
| 13321 | const totalRotation = (this.rotation + this.pdfPageRotate) % 360; |
| 13322 | this.viewport = pdfPage.getViewport({ |
| 13323 | scale: this.scale * PixelsPerInch.PDF_TO_CSS_UNITS, |
| 13324 | rotation: totalRotation |
| 13325 | }); |
| 13326 | this.#setDimensions(); |
| 13327 | this.reset(); |
| 13328 | } |
| 13329 | destroy() { |
| 13330 | this.reset(); |
| 13331 | this.pdfPage?.cleanup(); |
| 13332 | } |
| 13333 | get _textHighlighter() { |
| 13334 | return shadow(this, "_textHighlighter", new TextHighlighter({ |
| 13335 | pageIndex: this.id - 1, |
| 13336 | eventBus: this.eventBus, |
| 13337 | findController: this.#layerProperties.findController |
| 13338 | })); |
| 13339 | } |
| 13340 | #dispatchLayerRendered(name, error) { |
| 13341 | this.eventBus.dispatch(name, { |
| 13342 | source: this, |
| 13343 | pageNumber: this.id, |
| 13344 | error |
| 13345 | }); |
| 13346 | } |
| 13347 | async #renderAnnotationLayer() { |
| 13348 | let error = null; |
| 13349 | try { |
| 13350 | await this.annotationLayer.render(this.viewport, "display"); |
| 13351 | } catch (ex) { |
| 13352 | console.error(`#renderAnnotationLayer: "${ex}".`); |
| 13353 | error = ex; |
| 13354 | } finally { |
| 13355 | this.#dispatchLayerRendered("annotationlayerrendered", error); |
| 13356 | } |
| 13357 | } |
| 13358 | async #renderAnnotationEditorLayer() { |
| 13359 | let error = null; |
| 13360 | try { |
| 13361 | await this.annotationEditorLayer.render(this.viewport, "display"); |
| 13362 | } catch (ex) { |
| 13363 | console.error(`#renderAnnotationEditorLayer: "${ex}".`); |
| 13364 | error = ex; |
| 13365 | } finally { |
| 13366 | this.#dispatchLayerRendered("annotationeditorlayerrendered", error); |
| 13367 | } |
| 13368 | } |
| 13369 | async #renderDrawLayer() { |
| 13370 | try { |
| 13371 | await this.drawLayer.render("display"); |
| 13372 | } catch (ex) { |
| 13373 | console.error(`#renderDrawLayer: "${ex}".`); |
| 13374 | } |
| 13375 | } |
| 13376 | async #renderXfaLayer() { |
| 13377 | let error = null; |
| 13378 | try { |
| 13379 | const result = await this.xfaLayer.render(this.viewport, "display"); |
| 13380 | if (result?.textDivs && this._textHighlighter) { |
| 13381 | this.#buildXfaTextContentItems(result.textDivs); |
| 13382 | } |
| 13383 | } catch (ex) { |
| 13384 | console.error(`#renderXfaLayer: "${ex}".`); |
| 13385 | error = ex; |
| 13386 | } finally { |
| 13387 | if (this.xfaLayer?.div) { |
| 13388 | this.l10n.pause(); |
| 13389 | this.#addLayer(this.xfaLayer.div, "xfaLayer"); |
| 13390 | this.l10n.resume(); |
| 13391 | } |
| 13392 | this.#dispatchLayerRendered("xfalayerrendered", error); |
| 13393 | } |
| 13394 | } |
| 13395 | async #renderTextLayer() { |
| 13396 | if (!this.textLayer) { |
| 13397 | return; |
| 13398 | } |
| 13399 | let error = null; |
| 13400 | try { |
| 13401 | await this.textLayer.render(this.viewport); |
| 13402 | } catch (ex) { |
| 13403 | if (ex instanceof AbortException) { |
| 13404 | return; |
| 13405 | } |
| 13406 | console.error(`#renderTextLayer: "${ex}".`); |
| 13407 | error = ex; |
| 13408 | } |
| 13409 | this.#dispatchLayerRendered("textlayerrendered", error); |
| 13410 | this.#renderStructTreeLayer(); |
| 13411 | } |
| 13412 | async #renderStructTreeLayer() { |
| 13413 | if (!this.textLayer) { |
| 13414 | return; |
| 13415 | } |
| 13416 | this.structTreeLayer ||= new StructTreeLayerBuilder(); |
| 13417 | const tree = await (!this.structTreeLayer.renderingDone ? this.pdfPage.getStructTree() : null); |
| 13418 | const treeDom = this.structTreeLayer?.render(tree); |
| 13419 | if (treeDom) { |
| 13420 | this.l10n.pause(); |
| 13421 | this.canvas?.append(treeDom); |
| 13422 | this.l10n.resume(); |
| 13423 | } |
| 13424 | this.structTreeLayer?.show(); |
| 13425 | } |
| 13426 | async #buildXfaTextContentItems(textDivs) { |
| 13427 | const text = await this.pdfPage.getTextContent(); |
| 13428 | const items = []; |
| 13429 | for (const item of text.items) { |
| 13430 | items.push(item.str); |
| 13431 | } |
| 13432 | this._textHighlighter.setTextMapping(textDivs, items); |
| 13433 | this._textHighlighter.enable(); |
| 13434 | } |
| 13435 | _resetZoomLayer(removeFromDOM = false) { |
| 13436 | if (!this.zoomLayer) { |
| 13437 | return; |
| 13438 | } |
| 13439 | const zoomLayerCanvas = this.zoomLayer.firstChild; |
| 13440 | this.#viewportMap.delete(zoomLayerCanvas); |
| 13441 | zoomLayerCanvas.width = 0; |
| 13442 | zoomLayerCanvas.height = 0; |
| 13443 | if (removeFromDOM) { |
| 13444 | this.zoomLayer.remove(); |
| 13445 | } |
| 13446 | this.zoomLayer = null; |
| 13447 | } |
| 13448 | reset({ |
| 13449 | keepZoomLayer = false, |
| 13450 | keepAnnotationLayer = false, |
| 13451 | keepAnnotationEditorLayer = false, |
| 13452 | keepXfaLayer = false, |
| 13453 | keepTextLayer = false |
| 13454 | } = {}) { |
| 13455 | this.cancelRendering({ |
| 13456 | keepAnnotationLayer, |
| 13457 | keepAnnotationEditorLayer, |
| 13458 | keepXfaLayer, |
| 13459 | keepTextLayer |
| 13460 | }); |
| 13461 | this.renderingState = RenderingStates.INITIAL; |
| 13462 | const div = this.div; |
| 13463 | const childNodes = div.childNodes, |
| 13464 | zoomLayerNode = keepZoomLayer && this.zoomLayer || null, |
| 13465 | annotationLayerNode = keepAnnotationLayer && this.annotationLayer?.div || null, |
| 13466 | annotationEditorLayerNode = keepAnnotationEditorLayer && this.annotationEditorLayer?.div || null, |
| 13467 | xfaLayerNode = keepXfaLayer && this.xfaLayer?.div || null, |
| 13468 | textLayerNode = keepTextLayer && this.textLayer?.div || null; |
| 13469 | for (let i = childNodes.length - 1; i >= 0; i--) { |
| 13470 | const node = childNodes[i]; |
| 13471 | switch (node) { |
| 13472 | case zoomLayerNode: |
| 13473 | case annotationLayerNode: |
| 13474 | case annotationEditorLayerNode: |
| 13475 | case xfaLayerNode: |
| 13476 | case textLayerNode: |
| 13477 | continue; |
| 13478 | } |
| 13479 | node.remove(); |
| 13480 | const layerIndex = this.#layers.indexOf(node); |
| 13481 | if (layerIndex >= 0) { |
| 13482 | this.#layers[layerIndex] = null; |
| 13483 | } |
| 13484 | } |
| 13485 | div.removeAttribute("data-loaded"); |
| 13486 | if (annotationLayerNode) { |
| 13487 | this.annotationLayer.hide(); |
| 13488 | } |
| 13489 | if (annotationEditorLayerNode) { |
| 13490 | this.annotationEditorLayer.hide(); |
| 13491 | } |
| 13492 | if (xfaLayerNode) { |
| 13493 | this.xfaLayer.hide(); |
| 13494 | } |
| 13495 | if (textLayerNode) { |
| 13496 | this.textLayer.hide(); |
| 13497 | } |
| 13498 | this.structTreeLayer?.hide(); |
| 13499 | if (!zoomLayerNode) { |
| 13500 | if (this.canvas) { |
| 13501 | this.#viewportMap.delete(this.canvas); |
| 13502 | this.canvas.width = 0; |
| 13503 | this.canvas.height = 0; |
| 13504 | delete this.canvas; |
| 13505 | } |
| 13506 | this._resetZoomLayer(); |
| 13507 | } |
| 13508 | } |
| 13509 | update({ |
| 13510 | scale = 0, |
| 13511 | rotation = null, |
| 13512 | optionalContentConfigPromise = null, |
| 13513 | drawingDelay = -1 |
| 13514 | }) { |
| 13515 | this.scale = scale || this.scale; |
| 13516 | if (typeof rotation === "number") { |
| 13517 | this.rotation = rotation; |
| 13518 | } |
| 13519 | if (optionalContentConfigPromise instanceof Promise) { |
| 13520 | this._optionalContentConfigPromise = optionalContentConfigPromise; |
| 13521 | optionalContentConfigPromise.then(optionalContentConfig => { |
| 13522 | if (optionalContentConfigPromise !== this._optionalContentConfigPromise) { |
| 13523 | return; |
| 13524 | } |
| 13525 | this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility; |
| 13526 | }); |
| 13527 | } |
| 13528 | this.#useThumbnailCanvas.directDrawing = true; |
| 13529 | const totalRotation = (this.rotation + this.pdfPageRotate) % 360; |
| 13530 | this.viewport = this.viewport.clone({ |
| 13531 | scale: this.scale * PixelsPerInch.PDF_TO_CSS_UNITS, |
| 13532 | rotation: totalRotation |
| 13533 | }); |
| 13534 | this.#setDimensions(); |
| 13535 | if (this._isStandalone) { |
| 13536 | this._container?.style.setProperty("--scale-factor", this.viewport.scale); |
| 13537 | } |
| 13538 | if (this.canvas) { |
| 13539 | let onlyCssZoom = false; |
| 13540 | if (this.#hasRestrictedScaling) { |
| 13541 | if (this.maxCanvasPixels === 0) { |
| 13542 | onlyCssZoom = true; |
| 13543 | } else if (this.maxCanvasPixels > 0) { |
| 13544 | const { |
| 13545 | width, |
| 13546 | height |
| 13547 | } = this.viewport; |
| 13548 | const { |
| 13549 | sx, |
| 13550 | sy |
| 13551 | } = this.outputScale; |
| 13552 | onlyCssZoom = (Math.floor(width) * sx | 0) * (Math.floor(height) * sy | 0) > this.maxCanvasPixels; |
| 13553 | } |
| 13554 | } |
| 13555 | const postponeDrawing = drawingDelay >= 0 && drawingDelay < 1000; |
| 13556 | if (postponeDrawing || onlyCssZoom) { |
| 13557 | if (postponeDrawing && !onlyCssZoom && this.renderingState !== RenderingStates.FINISHED) { |
| 13558 | this.cancelRendering({ |
| 13559 | keepZoomLayer: true, |
| 13560 | keepAnnotationLayer: true, |
| 13561 | keepAnnotationEditorLayer: true, |
| 13562 | keepXfaLayer: true, |
| 13563 | keepTextLayer: true, |
| 13564 | cancelExtraDelay: drawingDelay |
| 13565 | }); |
| 13566 | this.renderingState = RenderingStates.FINISHED; |
| 13567 | this.#useThumbnailCanvas.directDrawing = false; |
| 13568 | } |
| 13569 | this.cssTransform({ |
| 13570 | target: this.canvas, |
| 13571 | redrawAnnotationLayer: true, |
| 13572 | redrawAnnotationEditorLayer: true, |
| 13573 | redrawXfaLayer: true, |
| 13574 | redrawTextLayer: !postponeDrawing, |
| 13575 | hideTextLayer: postponeDrawing |
| 13576 | }); |
| 13577 | if (postponeDrawing) { |
| 13578 | return; |
| 13579 | } |
| 13580 | this.eventBus.dispatch("pagerendered", { |
| 13581 | source: this, |
| 13582 | pageNumber: this.id, |
| 13583 | cssTransform: true, |
| 13584 | timestamp: performance.now(), |
| 13585 | error: this.#renderError |
| 13586 | }); |
| 13587 | return; |
| 13588 | } |
| 13589 | if (!this.zoomLayer && !this.canvas.hidden) { |
| 13590 | this.zoomLayer = this.canvas.parentNode; |
| 13591 | this.zoomLayer.style.position = "absolute"; |
| 13592 | } |
| 13593 | } |
| 13594 | if (this.zoomLayer) { |
| 13595 | this.cssTransform({ |
| 13596 | target: this.zoomLayer.firstChild |
| 13597 | }); |
| 13598 | } |
| 13599 | this.reset({ |
| 13600 | keepZoomLayer: true, |
| 13601 | keepAnnotationLayer: true, |
| 13602 | keepAnnotationEditorLayer: true, |
| 13603 | keepXfaLayer: true, |
| 13604 | keepTextLayer: true |
| 13605 | }); |
| 13606 | } |
| 13607 | cancelRendering({ |
| 13608 | keepAnnotationLayer = false, |
| 13609 | keepAnnotationEditorLayer = false, |
| 13610 | keepXfaLayer = false, |
| 13611 | keepTextLayer = false, |
| 13612 | cancelExtraDelay = 0 |
| 13613 | } = {}) { |
| 13614 | if (this.renderTask) { |
| 13615 | this.renderTask.cancel(cancelExtraDelay); |
| 13616 | this.renderTask = null; |
| 13617 | } |
| 13618 | this.resume = null; |
| 13619 | if (this.textLayer && (!keepTextLayer || !this.textLayer.div)) { |
| 13620 | this.textLayer.cancel(); |
| 13621 | this.textLayer = null; |
| 13622 | } |
| 13623 | if (this.structTreeLayer && !this.textLayer) { |
| 13624 | this.structTreeLayer = null; |
| 13625 | } |
| 13626 | if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer.div)) { |
| 13627 | this.annotationLayer.cancel(); |
| 13628 | this.annotationLayer = null; |
| 13629 | this._annotationCanvasMap = null; |
| 13630 | } |
| 13631 | if (this.annotationEditorLayer && (!keepAnnotationEditorLayer || !this.annotationEditorLayer.div)) { |
| 13632 | if (this.drawLayer) { |
| 13633 | this.drawLayer.cancel(); |
| 13634 | this.drawLayer = null; |
| 13635 | } |
| 13636 | this.annotationEditorLayer.cancel(); |
| 13637 | this.annotationEditorLayer = null; |
| 13638 | } |
| 13639 | if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer.div)) { |
| 13640 | this.xfaLayer.cancel(); |
| 13641 | this.xfaLayer = null; |
| 13642 | this._textHighlighter?.disable(); |
| 13643 | } |
| 13644 | } |
| 13645 | cssTransform({ |
| 13646 | target, |
| 13647 | redrawAnnotationLayer = false, |
| 13648 | redrawAnnotationEditorLayer = false, |
| 13649 | redrawXfaLayer = false, |
| 13650 | redrawTextLayer = false, |
| 13651 | hideTextLayer = false |
| 13652 | }) { |
| 13653 | if (!target.hasAttribute("zooming")) { |
| 13654 | target.setAttribute("zooming", true); |
| 13655 | const { |
| 13656 | style |
| 13657 | } = target; |
| 13658 | style.width = style.height = ""; |
| 13659 | } |
| 13660 | const originalViewport = this.#viewportMap.get(target); |
| 13661 | if (this.viewport !== originalViewport) { |
| 13662 | const relativeRotation = this.viewport.rotation - originalViewport.rotation; |
| 13663 | const absRotation = Math.abs(relativeRotation); |
| 13664 | let scaleX = 1, |
| 13665 | scaleY = 1; |
| 13666 | if (absRotation === 90 || absRotation === 270) { |
| 13667 | const { |
| 13668 | width, |
| 13669 | height |
| 13670 | } = this.viewport; |
| 13671 | scaleX = height / width; |
| 13672 | scaleY = width / height; |
| 13673 | } |
| 13674 | target.style.transform = `rotate(${relativeRotation}deg) scale(${scaleX}, ${scaleY})`; |
| 13675 | } |
| 13676 | if (redrawAnnotationLayer && this.annotationLayer) { |
| 13677 | this.#renderAnnotationLayer(); |
| 13678 | } |
| 13679 | if (redrawAnnotationEditorLayer && this.annotationEditorLayer) { |
| 13680 | if (this.drawLayer) { |
| 13681 | this.#renderDrawLayer(); |
| 13682 | } |
| 13683 | this.#renderAnnotationEditorLayer(); |
| 13684 | } |
| 13685 | if (redrawXfaLayer && this.xfaLayer) { |
| 13686 | this.#renderXfaLayer(); |
| 13687 | } |
| 13688 | if (this.textLayer) { |
| 13689 | if (hideTextLayer) { |
| 13690 | this.textLayer.hide(); |
| 13691 | this.structTreeLayer?.hide(); |
| 13692 | } else if (redrawTextLayer) { |
| 13693 | this.#renderTextLayer(); |
| 13694 | } |
| 13695 | } |
| 13696 | } |
| 13697 | get width() { |
| 13698 | return this.viewport.width; |
| 13699 | } |
| 13700 | get height() { |
| 13701 | return this.viewport.height; |
| 13702 | } |
| 13703 | getPagePoint(x, y) { |
| 13704 | return this.viewport.convertToPdfPoint(x, y); |
| 13705 | } |
| 13706 | async #finishRenderTask(renderTask, error = null) { |
| 13707 | if (renderTask === this.renderTask) { |
| 13708 | this.renderTask = null; |
| 13709 | } |
| 13710 | if (error instanceof RenderingCancelledException) { |
| 13711 | this.#renderError = null; |
| 13712 | return; |
| 13713 | } |
| 13714 | this.#renderError = error; |
| 13715 | this.renderingState = RenderingStates.FINISHED; |
| 13716 | this._resetZoomLayer(true); |
| 13717 | this.#useThumbnailCanvas.regularAnnotations = !renderTask.separateAnnots; |
| 13718 | this.eventBus.dispatch("pagerendered", { |
| 13719 | source: this, |
| 13720 | pageNumber: this.id, |
| 13721 | cssTransform: false, |
| 13722 | timestamp: performance.now(), |
| 13723 | error: this.#renderError |
| 13724 | }); |
| 13725 | if (error) { |
| 13726 | throw error; |
| 13727 | } |
| 13728 | } |
| 13729 | async draw() { |
| 13730 | if (this.renderingState !== RenderingStates.INITIAL) { |
| 13731 | console.error("Must be in new state before drawing"); |
| 13732 | this.reset(); |
| 13733 | } |
| 13734 | const { |
| 13735 | div, |
| 13736 | l10n, |
| 13737 | pageColors, |
| 13738 | pdfPage, |
| 13739 | viewport |
| 13740 | } = this; |
| 13741 | if (!pdfPage) { |
| 13742 | this.renderingState = RenderingStates.FINISHED; |
| 13743 | throw new Error("pdfPage is not loaded"); |
| 13744 | } |
| 13745 | this.renderingState = RenderingStates.RUNNING; |
| 13746 | const canvasWrapper = document.createElement("div"); |
| 13747 | canvasWrapper.classList.add("canvasWrapper"); |
| 13748 | this.#addLayer(canvasWrapper, "canvasWrapper"); |
| 13749 | if (!this.textLayer && this.#textLayerMode !== TextLayerMode.DISABLE && !pdfPage.isPureXfa) { |
| 13750 | this._accessibilityManager ||= new TextAccessibilityManager(); |
| 13751 | this.textLayer = new TextLayerBuilder({ |
| 13752 | pdfPage, |
| 13753 | highlighter: this._textHighlighter, |
| 13754 | accessibilityManager: this._accessibilityManager, |
| 13755 | enablePermissions: this.#textLayerMode === TextLayerMode.ENABLE_PERMISSIONS, |
| 13756 | onAppend: textLayerDiv => { |
| 13757 | this.l10n.pause(); |
| 13758 | this.#addLayer(textLayerDiv, "textLayer"); |
| 13759 | this.l10n.resume(); |
| 13760 | } |
| 13761 | }); |
| 13762 | } |
| 13763 | if (!this.annotationLayer && this.#annotationMode !== AnnotationMode.DISABLE) { |
| 13764 | const { |
| 13765 | annotationStorage, |
| 13766 | annotationEditorUIManager, |
| 13767 | downloadManager, |
| 13768 | enableScripting, |
| 13769 | fieldObjectsPromise, |
| 13770 | hasJSActionsPromise, |
| 13771 | linkService |
| 13772 | } = this.#layerProperties; |
| 13773 | this._annotationCanvasMap ||= new Map(); |
| 13774 | this.annotationLayer = new AnnotationLayerBuilder({ |
| 13775 | pdfPage, |
| 13776 | annotationStorage, |
| 13777 | imageResourcesPath: this.imageResourcesPath, |
| 13778 | renderForms: this.#annotationMode === AnnotationMode.ENABLE_FORMS, |
| 13779 | linkService, |
| 13780 | downloadManager, |
| 13781 | enableScripting, |
| 13782 | hasJSActionsPromise, |
| 13783 | fieldObjectsPromise, |
| 13784 | annotationCanvasMap: this._annotationCanvasMap, |
| 13785 | accessibilityManager: this._accessibilityManager, |
| 13786 | annotationEditorUIManager, |
| 13787 | onAppend: annotationLayerDiv => { |
| 13788 | this.#addLayer(annotationLayerDiv, "annotationLayer"); |
| 13789 | } |
| 13790 | }); |
| 13791 | } |
| 13792 | const renderContinueCallback = cont => { |
| 13793 | showCanvas?.(false); |
| 13794 | if (this.renderingQueue && !this.renderingQueue.isHighestPriority(this)) { |
| 13795 | this.renderingState = RenderingStates.PAUSED; |
| 13796 | this.resume = () => { |
| 13797 | this.renderingState = RenderingStates.RUNNING; |
| 13798 | cont(); |
| 13799 | }; |
| 13800 | return; |
| 13801 | } |
| 13802 | cont(); |
| 13803 | }; |
| 13804 | const { |
| 13805 | width, |
| 13806 | height |
| 13807 | } = viewport; |
| 13808 | const canvas = document.createElement("canvas"); |
| 13809 | canvas.setAttribute("role", "presentation"); |
| 13810 | canvas.hidden = true; |
| 13811 | const hasHCM = !!(pageColors?.background && pageColors?.foreground); |
| 13812 | let showCanvas = isLastShow => { |
| 13813 | if (!hasHCM || isLastShow) { |
| 13814 | canvas.hidden = false; |
| 13815 | showCanvas = null; |
| 13816 | } |
| 13817 | }; |
| 13818 | canvasWrapper.append(canvas); |
| 13819 | this.canvas = canvas; |
| 13820 | const ctx = canvas.getContext("2d", { |
| 13821 | alpha: false |
| 13822 | }); |
| 13823 | const outputScale = this.outputScale = new OutputScale(); |
| 13824 | if (this.maxCanvasPixels === 0) { |
| 13825 | const invScale = 1 / this.scale; |
| 13826 | outputScale.sx *= invScale; |
| 13827 | outputScale.sy *= invScale; |
| 13828 | this.#hasRestrictedScaling = true; |
| 13829 | } else if (this.maxCanvasPixels > 0) { |
| 13830 | const pixelsInViewport = width * height; |
| 13831 | const maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport); |
| 13832 | if (outputScale.sx > maxScale || outputScale.sy > maxScale) { |
| 13833 | outputScale.sx = maxScale; |
| 13834 | outputScale.sy = maxScale; |
| 13835 | this.#hasRestrictedScaling = true; |
| 13836 | } else { |
| 13837 | this.#hasRestrictedScaling = false; |
| 13838 | } |
| 13839 | } |
| 13840 | const sfx = approximateFraction(outputScale.sx); |
| 13841 | const sfy = approximateFraction(outputScale.sy); |
| 13842 | canvas.width = roundToDivide(width * outputScale.sx, sfx[0]); |
| 13843 | canvas.height = roundToDivide(height * outputScale.sy, sfy[0]); |
| 13844 | const { |
| 13845 | style |
| 13846 | } = canvas; |
| 13847 | style.width = roundToDivide(width, sfx[1]) + "px"; |
| 13848 | style.height = roundToDivide(height, sfy[1]) + "px"; |
| 13849 | this.#viewportMap.set(canvas, viewport); |
| 13850 | const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null; |
| 13851 | const renderContext = { |
| 13852 | canvasContext: ctx, |
| 13853 | transform, |
| 13854 | viewport, |
| 13855 | annotationMode: this.#annotationMode, |
| 13856 | optionalContentConfigPromise: this._optionalContentConfigPromise, |
| 13857 | annotationCanvasMap: this._annotationCanvasMap, |
| 13858 | pageColors |
| 13859 | }; |
| 13860 | const renderTask = this.renderTask = pdfPage.render(renderContext); |
| 13861 | renderTask.onContinue = renderContinueCallback; |
| 13862 | const resultPromise = renderTask.promise.then(async () => { |
| 13863 | showCanvas?.(true); |
| 13864 | await this.#finishRenderTask(renderTask); |
| 13865 | this.#renderTextLayer(); |
| 13866 | if (this.annotationLayer) { |
| 13867 | await this.#renderAnnotationLayer(); |
| 13868 | } |
| 13869 | const { |
| 13870 | annotationEditorUIManager |
| 13871 | } = this.#layerProperties; |
| 13872 | if (!annotationEditorUIManager) { |
| 13873 | return; |
| 13874 | } |
| 13875 | this.drawLayer ||= new DrawLayerBuilder({ |
| 13876 | pageIndex: this.id |
| 13877 | }); |
| 13878 | await this.#renderDrawLayer(); |
| 13879 | this.drawLayer.setParent(canvasWrapper); |
| 13880 | if (!this.annotationEditorLayer) { |
| 13881 | this.annotationEditorLayer = new AnnotationEditorLayerBuilder({ |
| 13882 | uiManager: annotationEditorUIManager, |
| 13883 | pdfPage, |
| 13884 | l10n, |
| 13885 | accessibilityManager: this._accessibilityManager, |
| 13886 | annotationLayer: this.annotationLayer?.annotationLayer, |
| 13887 | textLayer: this.textLayer, |
| 13888 | drawLayer: this.drawLayer.getDrawLayer(), |
| 13889 | onAppend: annotationEditorLayerDiv => { |
| 13890 | this.#addLayer(annotationEditorLayerDiv, "annotationEditorLayer"); |
| 13891 | } |
| 13892 | }); |
| 13893 | } |
| 13894 | this.#renderAnnotationEditorLayer(); |
| 13895 | }, error => { |
| 13896 | if (!(error instanceof RenderingCancelledException)) { |
| 13897 | showCanvas?.(true); |
| 13898 | } |
| 13899 | return this.#finishRenderTask(renderTask, error); |
| 13900 | }); |
| 13901 | if (pdfPage.isPureXfa) { |
| 13902 | if (!this.xfaLayer) { |
| 13903 | const { |
| 13904 | annotationStorage, |
| 13905 | linkService |
| 13906 | } = this.#layerProperties; |
| 13907 | this.xfaLayer = new XfaLayerBuilder({ |
| 13908 | pdfPage, |
| 13909 | annotationStorage, |
| 13910 | linkService |
| 13911 | }); |
| 13912 | } |
| 13913 | this.#renderXfaLayer(); |
| 13914 | } |
| 13915 | div.setAttribute("data-loaded", true); |
| 13916 | this.eventBus.dispatch("pagerender", { |
| 13917 | source: this, |
| 13918 | pageNumber: this.id |
| 13919 | }); |
| 13920 | return resultPromise; |
| 13921 | } |
| 13922 | setPageLabel(label) { |
| 13923 | this.pageLabel = typeof label === "string" ? label : null; |
| 13924 | this.div.setAttribute("data-l10n-args", JSON.stringify({ |
| 13925 | page: this.pageLabel ?? this.id |
| 13926 | })); |
| 13927 | if (this.pageLabel !== null) { |
| 13928 | this.div.setAttribute("data-page-label", this.pageLabel); |
| 13929 | } else { |
| 13930 | this.div.removeAttribute("data-page-label"); |
| 13931 | } |
| 13932 | } |
| 13933 | get thumbnailCanvas() { |
| 13934 | const { |
| 13935 | directDrawing, |
| 13936 | initialOptionalContent, |
| 13937 | regularAnnotations |
| 13938 | } = this.#useThumbnailCanvas; |
| 13939 | return directDrawing && initialOptionalContent && regularAnnotations ? this.canvas : null; |
| 13940 | } |
| 13941 | } |
| 13942 | |
| 13943 | ;// CONCATENATED MODULE: ./web/pdf_viewer.js |
| 13944 | |
| 13945 | |
| 13946 | |
| 13947 | |
| 13948 | |
| 13949 | |
| 13950 | |
| 13951 | |
| 13952 | |
| 13953 | |
| 13954 | |
| 13955 | |
| 13956 | |
| 13957 | |
| 13958 | |
| 13959 | |
| 13960 | |
| 13961 | |
| 13962 | const DEFAULT_CACHE_SIZE = 10; |
| 13963 | const PagesCountLimit = { |
| 13964 | FORCE_SCROLL_MODE_PAGE: 15000, |
| 13965 | FORCE_LAZY_PAGE_INIT: 7500, |
| 13966 | PAUSE_EAGER_PAGE_INIT: 250 |
| 13967 | }; |
| 13968 | function isValidAnnotationEditorMode(mode) { |
| 13969 | return Object.values(AnnotationEditorType).includes(mode) && mode !== AnnotationEditorType.DISABLE; |
| 13970 | } |
| 13971 | class PDFPageViewBuffer { |
| 13972 | #buf = new Set(); |
| 13973 | #size = 0; |
| 13974 | constructor(size) { |
| 13975 | this.#size = size; |
| 13976 | } |
| 13977 | push(view) { |
| 13978 | const buf = this.#buf; |
| 13979 | if (buf.has(view)) { |
| 13980 | buf.delete(view); |
| 13981 | } |
| 13982 | buf.add(view); |
| 13983 | if (buf.size > this.#size) { |
| 13984 | this.#destroyFirstView(); |
| 13985 | } |
| 13986 | } |
| 13987 | resize(newSize, idsToKeep = null) { |
| 13988 | this.#size = newSize; |
| 13989 | const buf = this.#buf; |
| 13990 | if (idsToKeep) { |
| 13991 | const ii = buf.size; |
| 13992 | let i = 1; |
| 13993 | for (const view of buf) { |
| 13994 | if (idsToKeep.has(view.id)) { |
| 13995 | buf.delete(view); |
| 13996 | buf.add(view); |
| 13997 | } |
| 13998 | if (++i > ii) { |
| 13999 | break; |
| 14000 | } |
| 14001 | } |
| 14002 | } |
| 14003 | while (buf.size > this.#size) { |
| 14004 | this.#destroyFirstView(); |
| 14005 | } |
| 14006 | } |
| 14007 | has(view) { |
| 14008 | return this.#buf.has(view); |
| 14009 | } |
| 14010 | [Symbol.iterator]() { |
| 14011 | return this.#buf.keys(); |
| 14012 | } |
| 14013 | #destroyFirstView() { |
| 14014 | const firstView = this.#buf.keys().next().value; |
| 14015 | firstView?.destroy(); |
| 14016 | this.#buf.delete(firstView); |
| 14017 | } |
| 14018 | } |
| 14019 | class PDFViewer { |
| 14020 | #buffer = null; |
| 14021 | #altTextManager = null; |
| 14022 | #annotationEditorHighlightColors = null; |
| 14023 | #annotationEditorMode = AnnotationEditorType.NONE; |
| 14024 | #annotationEditorUIManager = null; |
| 14025 | #annotationMode = AnnotationMode.ENABLE_FORMS; |
| 14026 | #containerTopLeft = null; |
| 14027 | #enableHighlightFloatingButton = false; |
| 14028 | #enablePermissions = false; |
| 14029 | #eventAbortController = null; |
| 14030 | #mlManager = null; |
| 14031 | #getAllTextInProgress = false; |
| 14032 | #hiddenCopyElement = null; |
| 14033 | #interruptCopyCondition = false; |
| 14034 | #previousContainerHeight = 0; |
| 14035 | #resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this)); |
| 14036 | #scrollModePageState = null; |
| 14037 | #scaleTimeoutId = null; |
| 14038 | #textLayerMode = TextLayerMode.ENABLE; |
| 14039 | constructor(options) { |
| 14040 | const viewerVersion = "4.3.136"; |
| 14041 | if (version !== viewerVersion) { |
| 14042 | throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`); |
| 14043 | } |
| 14044 | this.container = options.container; |
| 14045 | this.viewer = options.viewer || options.container.firstElementChild; |
| 14046 | if (this.container?.tagName !== "DIV" || this.viewer?.tagName !== "DIV") { |
| 14047 | throw new Error("Invalid `container` and/or `viewer` option."); |
| 14048 | } |
| 14049 | if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") { |
| 14050 | throw new Error("The `container` must be absolutely positioned."); |
| 14051 | } |
| 14052 | this.#resizeObserver.observe(this.container); |
| 14053 | this.eventBus = options.eventBus; |
| 14054 | this.linkService = options.linkService || new SimpleLinkService(); |
| 14055 | this.downloadManager = options.downloadManager || null; |
| 14056 | this.findController = options.findController || null; |
| 14057 | this.#altTextManager = options.altTextManager || null; |
| 14058 | if (this.findController) { |
| 14059 | this.findController.onIsPageVisible = pageNumber => this._getVisiblePages().ids.has(pageNumber); |
| 14060 | } |
| 14061 | this._scriptingManager = options.scriptingManager || null; |
| 14062 | this.#textLayerMode = options.textLayerMode ?? TextLayerMode.ENABLE; |
| 14063 | this.#annotationMode = options.annotationMode ?? AnnotationMode.ENABLE_FORMS; |
| 14064 | this.#annotationEditorMode = options.annotationEditorMode ?? AnnotationEditorType.NONE; |
| 14065 | this.#annotationEditorHighlightColors = options.annotationEditorHighlightColors || null; |
| 14066 | this.#enableHighlightFloatingButton = options.enableHighlightFloatingButton === true; |
| 14067 | this.imageResourcesPath = options.imageResourcesPath || ""; |
| 14068 | this.enablePrintAutoRotate = options.enablePrintAutoRotate || false; |
| 14069 | this.removePageBorders = options.removePageBorders || false; |
| 14070 | this.maxCanvasPixels = options.maxCanvasPixels; |
| 14071 | this.l10n = options.l10n; |
| 14072 | this.l10n ||= new genericl10n_GenericL10n(); |
| 14073 | this.#enablePermissions = options.enablePermissions || false; |
| 14074 | this.pageColors = options.pageColors || null; |
| 14075 | this.#mlManager = options.mlManager || null; |
| 14076 | this.defaultRenderingQueue = !options.renderingQueue; |
| 14077 | if (this.defaultRenderingQueue) { |
| 14078 | this.renderingQueue = new PDFRenderingQueue(); |
| 14079 | this.renderingQueue.setViewer(this); |
| 14080 | } else { |
| 14081 | this.renderingQueue = options.renderingQueue; |
| 14082 | } |
| 14083 | this.scroll = watchScroll(this.container, this._scrollUpdate.bind(this)); |
| 14084 | this.presentationModeState = PresentationModeState.UNKNOWN; |
| 14085 | this._resetView(); |
| 14086 | if (this.removePageBorders) { |
| 14087 | this.viewer.classList.add("removePageBorders"); |
| 14088 | } |
| 14089 | this.#updateContainerHeightCss(); |
| 14090 | this.eventBus._on("thumbnailrendered", ({ |
| 14091 | pageNumber, |
| 14092 | pdfPage |
| 14093 | }) => { |
| 14094 | const pageView = this._pages[pageNumber - 1]; |
| 14095 | if (!this.#buffer.has(pageView)) { |
| 14096 | pdfPage?.cleanup(); |
| 14097 | } |
| 14098 | }); |
| 14099 | if (!options.l10n) { |
| 14100 | this.l10n.translate(this.container); |
| 14101 | } |
| 14102 | } |
| 14103 | get pagesCount() { |
| 14104 | return this._pages.length; |
| 14105 | } |
| 14106 | getPageView(index) { |
| 14107 | return this._pages[index]; |
| 14108 | } |
| 14109 | getCachedPageViews() { |
| 14110 | return new Set(this.#buffer); |
| 14111 | } |
| 14112 | get pageViewsReady() { |
| 14113 | return this._pages.every(pageView => pageView?.pdfPage); |
| 14114 | } |
| 14115 | get renderForms() { |
| 14116 | return this.#annotationMode === AnnotationMode.ENABLE_FORMS; |
| 14117 | } |
| 14118 | get enableScripting() { |
| 14119 | return !!this._scriptingManager; |
| 14120 | } |
| 14121 | get currentPageNumber() { |
| 14122 | return this._currentPageNumber; |
| 14123 | } |
| 14124 | set currentPageNumber(val) { |
| 14125 | if (!Number.isInteger(val)) { |
| 14126 | throw new Error("Invalid page number."); |
| 14127 | } |
| 14128 | if (!this.pdfDocument) { |
| 14129 | return; |
| 14130 | } |
| 14131 | if (!this._setCurrentPageNumber(val, true)) { |
| 14132 | console.error(`currentPageNumber: "${val}" is not a valid page.`); |
| 14133 | } |
| 14134 | } |
| 14135 | _setCurrentPageNumber(val, resetCurrentPageView = false) { |
| 14136 | if (this._currentPageNumber === val) { |
| 14137 | if (resetCurrentPageView) { |
| 14138 | this.#resetCurrentPageView(); |
| 14139 | } |
| 14140 | return true; |
| 14141 | } |
| 14142 | if (!(0 < val && val <= this.pagesCount)) { |
| 14143 | return false; |
| 14144 | } |
| 14145 | const previous = this._currentPageNumber; |
| 14146 | this._currentPageNumber = val; |
| 14147 | this.eventBus.dispatch("pagechanging", { |
| 14148 | source: this, |
| 14149 | pageNumber: val, |
| 14150 | pageLabel: this._pageLabels?.[val - 1] ?? null, |
| 14151 | previous |
| 14152 | }); |
| 14153 | if (resetCurrentPageView) { |
| 14154 | this.#resetCurrentPageView(); |
| 14155 | } |
| 14156 | return true; |
| 14157 | } |
| 14158 | get currentPageLabel() { |
| 14159 | return this._pageLabels?.[this._currentPageNumber - 1] ?? null; |
| 14160 | } |
| 14161 | set currentPageLabel(val) { |
| 14162 | if (!this.pdfDocument) { |
| 14163 | return; |
| 14164 | } |
| 14165 | let page = val | 0; |
| 14166 | if (this._pageLabels) { |
| 14167 | const i = this._pageLabels.indexOf(val); |
| 14168 | if (i >= 0) { |
| 14169 | page = i + 1; |
| 14170 | } |
| 14171 | } |
| 14172 | if (!this._setCurrentPageNumber(page, true)) { |
| 14173 | console.error(`currentPageLabel: "${val}" is not a valid page.`); |
| 14174 | } |
| 14175 | } |
| 14176 | get currentScale() { |
| 14177 | return this._currentScale !== UNKNOWN_SCALE ? this._currentScale : DEFAULT_SCALE; |
| 14178 | } |
| 14179 | set currentScale(val) { |
| 14180 | if (isNaN(val)) { |
| 14181 | throw new Error("Invalid numeric scale."); |
| 14182 | } |
| 14183 | if (!this.pdfDocument) { |
| 14184 | return; |
| 14185 | } |
| 14186 | this.#setScale(val, { |
| 14187 | noScroll: false |
| 14188 | }); |
| 14189 | } |
| 14190 | get currentScaleValue() { |
| 14191 | return this._currentScaleValue; |
| 14192 | } |
| 14193 | set currentScaleValue(val) { |
| 14194 | if (!this.pdfDocument) { |
| 14195 | return; |
| 14196 | } |
| 14197 | this.#setScale(val, { |
| 14198 | noScroll: false |
| 14199 | }); |
| 14200 | } |
| 14201 | get pagesRotation() { |
| 14202 | return this._pagesRotation; |
| 14203 | } |
| 14204 | set pagesRotation(rotation) { |
| 14205 | if (!isValidRotation(rotation)) { |
| 14206 | throw new Error("Invalid pages rotation angle."); |
| 14207 | } |
| 14208 | if (!this.pdfDocument) { |
| 14209 | return; |
| 14210 | } |
| 14211 | rotation %= 360; |
| 14212 | if (rotation < 0) { |
| 14213 | rotation += 360; |
| 14214 | } |
| 14215 | if (this._pagesRotation === rotation) { |
| 14216 | return; |
| 14217 | } |
| 14218 | this._pagesRotation = rotation; |
| 14219 | const pageNumber = this._currentPageNumber; |
| 14220 | this.refresh(true, { |
| 14221 | rotation |
| 14222 | }); |
| 14223 | if (this._currentScaleValue) { |
| 14224 | this.#setScale(this._currentScaleValue, { |
| 14225 | noScroll: true |
| 14226 | }); |
| 14227 | } |
| 14228 | this.eventBus.dispatch("rotationchanging", { |
| 14229 | source: this, |
| 14230 | pagesRotation: rotation, |
| 14231 | pageNumber |
| 14232 | }); |
| 14233 | if (this.defaultRenderingQueue) { |
| 14234 | this.update(); |
| 14235 | } |
| 14236 | } |
| 14237 | get firstPagePromise() { |
| 14238 | return this.pdfDocument ? this._firstPageCapability.promise : null; |
| 14239 | } |
| 14240 | get onePageRendered() { |
| 14241 | return this.pdfDocument ? this._onePageRenderedCapability.promise : null; |
| 14242 | } |
| 14243 | get pagesPromise() { |
| 14244 | return this.pdfDocument ? this._pagesCapability.promise : null; |
| 14245 | } |
| 14246 | get _layerProperties() { |
| 14247 | const self = this; |
| 14248 | return shadow(this, "_layerProperties", { |
| 14249 | get annotationEditorUIManager() { |
| 14250 | return self.#annotationEditorUIManager; |
| 14251 | }, |
| 14252 | get annotationStorage() { |
| 14253 | return self.pdfDocument?.annotationStorage; |
| 14254 | }, |
| 14255 | get downloadManager() { |
| 14256 | return self.downloadManager; |
| 14257 | }, |
| 14258 | get enableScripting() { |
| 14259 | return !!self._scriptingManager; |
| 14260 | }, |
| 14261 | get fieldObjectsPromise() { |
| 14262 | return self.pdfDocument?.getFieldObjects(); |
| 14263 | }, |
| 14264 | get findController() { |
| 14265 | return self.findController; |
| 14266 | }, |
| 14267 | get hasJSActionsPromise() { |
| 14268 | return self.pdfDocument?.hasJSActions(); |
| 14269 | }, |
| 14270 | get linkService() { |
| 14271 | return self.linkService; |
| 14272 | } |
| 14273 | }); |
| 14274 | } |
| 14275 | #initializePermissions(permissions) { |
| 14276 | const params = { |
| 14277 | annotationEditorMode: this.#annotationEditorMode, |
| 14278 | annotationMode: this.#annotationMode, |
| 14279 | textLayerMode: this.#textLayerMode |
| 14280 | }; |
| 14281 | if (!permissions) { |
| 14282 | return params; |
| 14283 | } |
| 14284 | if (!permissions.includes(PermissionFlag.COPY) && this.#textLayerMode === TextLayerMode.ENABLE) { |
| 14285 | params.textLayerMode = TextLayerMode.ENABLE_PERMISSIONS; |
| 14286 | } |
| 14287 | if (!permissions.includes(PermissionFlag.MODIFY_CONTENTS)) { |
| 14288 | params.annotationEditorMode = AnnotationEditorType.DISABLE; |
| 14289 | } |
| 14290 | if (!permissions.includes(PermissionFlag.MODIFY_ANNOTATIONS) && !permissions.includes(PermissionFlag.FILL_INTERACTIVE_FORMS) && this.#annotationMode === AnnotationMode.ENABLE_FORMS) { |
| 14291 | params.annotationMode = AnnotationMode.ENABLE; |
| 14292 | } |
| 14293 | return params; |
| 14294 | } |
| 14295 | async #onePageRenderedOrForceFetch(signal) { |
| 14296 | if (document.visibilityState === "hidden" || !this.container.offsetParent || this._getVisiblePages().views.length === 0) { |
| 14297 | return; |
| 14298 | } |
| 14299 | const hiddenCapability = Promise.withResolvers(); |
| 14300 | function onVisibilityChange() { |
| 14301 | if (document.visibilityState === "hidden") { |
| 14302 | hiddenCapability.resolve(); |
| 14303 | } |
| 14304 | } |
| 14305 | document.addEventListener("visibilitychange", onVisibilityChange, { |
| 14306 | signal |
| 14307 | }); |
| 14308 | await Promise.race([this._onePageRenderedCapability.promise, hiddenCapability.promise]); |
| 14309 | document.removeEventListener("visibilitychange", onVisibilityChange); |
| 14310 | } |
| 14311 | async getAllText() { |
| 14312 | const texts = []; |
| 14313 | const buffer = []; |
| 14314 | for (let pageNum = 1, pagesCount = this.pdfDocument.numPages; pageNum <= pagesCount; ++pageNum) { |
| 14315 | if (this.#interruptCopyCondition) { |
| 14316 | return null; |
| 14317 | } |
| 14318 | buffer.length = 0; |
| 14319 | const page = await this.pdfDocument.getPage(pageNum); |
| 14320 | const { |
| 14321 | items |
| 14322 | } = await page.getTextContent(); |
| 14323 | for (const item of items) { |
| 14324 | if (item.str) { |
| 14325 | buffer.push(item.str); |
| 14326 | } |
| 14327 | if (item.hasEOL) { |
| 14328 | buffer.push("\n"); |
| 14329 | } |
| 14330 | } |
| 14331 | texts.push(removeNullCharacters(buffer.join(""))); |
| 14332 | } |
| 14333 | return texts.join("\n"); |
| 14334 | } |
| 14335 | #copyCallback(textLayerMode, event) { |
| 14336 | const selection = document.getSelection(); |
| 14337 | const { |
| 14338 | focusNode, |
| 14339 | anchorNode |
| 14340 | } = selection; |
| 14341 | if (anchorNode && focusNode && selection.containsNode(this.#hiddenCopyElement)) { |
| 14342 | if (this.#getAllTextInProgress || textLayerMode === TextLayerMode.ENABLE_PERMISSIONS) { |
| 14343 | event.preventDefault(); |
| 14344 | event.stopPropagation(); |
| 14345 | return; |
| 14346 | } |
| 14347 | this.#getAllTextInProgress = true; |
| 14348 | const savedCursor = this.container.style.cursor; |
| 14349 | this.container.style.cursor = "wait"; |
| 14350 | const interruptCopy = ev => this.#interruptCopyCondition = ev.key === "Escape"; |
| 14351 | window.addEventListener("keydown", interruptCopy); |
| 14352 | this.getAllText().then(async text => { |
| 14353 | if (text !== null) { |
| 14354 | await navigator.clipboard.writeText(text); |
| 14355 | } |
| 14356 | }).catch(reason => { |
| 14357 | console.warn(`Something goes wrong when extracting the text: ${reason.message}`); |
| 14358 | }).finally(() => { |
| 14359 | this.#getAllTextInProgress = false; |
| 14360 | this.#interruptCopyCondition = false; |
| 14361 | window.removeEventListener("keydown", interruptCopy); |
| 14362 | this.container.style.cursor = savedCursor; |
| 14363 | }); |
| 14364 | event.preventDefault(); |
| 14365 | event.stopPropagation(); |
| 14366 | } |
| 14367 | } |
| 14368 | setDocument(pdfDocument) { |
| 14369 | if (this.pdfDocument) { |
| 14370 | this.eventBus.dispatch("pagesdestroy", { |
| 14371 | source: this |
| 14372 | }); |
| 14373 | this._cancelRendering(); |
| 14374 | this._resetView(); |
| 14375 | this.findController?.setDocument(null); |
| 14376 | this._scriptingManager?.setDocument(null); |
| 14377 | if (this.#annotationEditorUIManager) { |
| 14378 | this.#annotationEditorUIManager.destroy(); |
| 14379 | this.#annotationEditorUIManager = null; |
| 14380 | } |
| 14381 | } |
| 14382 | this.pdfDocument = pdfDocument; |
| 14383 | if (!pdfDocument) { |
| 14384 | return; |
| 14385 | } |
| 14386 | const pagesCount = pdfDocument.numPages; |
| 14387 | const firstPagePromise = pdfDocument.getPage(1); |
| 14388 | const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig({ |
| 14389 | intent: "display" |
| 14390 | }); |
| 14391 | const permissionsPromise = this.#enablePermissions ? pdfDocument.getPermissions() : Promise.resolve(); |
| 14392 | const { |
| 14393 | eventBus, |
| 14394 | pageColors, |
| 14395 | viewer |
| 14396 | } = this; |
| 14397 | this.#eventAbortController = new AbortController(); |
| 14398 | const { |
| 14399 | signal |
| 14400 | } = this.#eventAbortController; |
| 14401 | if (pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) { |
| 14402 | console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document."); |
| 14403 | const mode = this._scrollMode = ScrollMode.PAGE; |
| 14404 | eventBus.dispatch("scrollmodechanged", { |
| 14405 | source: this, |
| 14406 | mode |
| 14407 | }); |
| 14408 | } |
| 14409 | this._pagesCapability.promise.then(() => { |
| 14410 | eventBus.dispatch("pagesloaded", { |
| 14411 | source: this, |
| 14412 | pagesCount |
| 14413 | }); |
| 14414 | }, () => {}); |
| 14415 | const onBeforeDraw = evt => { |
| 14416 | const pageView = this._pages[evt.pageNumber - 1]; |
| 14417 | if (!pageView) { |
| 14418 | return; |
| 14419 | } |
| 14420 | this.#buffer.push(pageView); |
| 14421 | }; |
| 14422 | eventBus._on("pagerender", onBeforeDraw, { |
| 14423 | signal |
| 14424 | }); |
| 14425 | const onAfterDraw = evt => { |
| 14426 | if (evt.cssTransform) { |
| 14427 | return; |
| 14428 | } |
| 14429 | this._onePageRenderedCapability.resolve({ |
| 14430 | timestamp: evt.timestamp |
| 14431 | }); |
| 14432 | eventBus._off("pagerendered", onAfterDraw); |
| 14433 | }; |
| 14434 | eventBus._on("pagerendered", onAfterDraw, { |
| 14435 | signal |
| 14436 | }); |
| 14437 | Promise.all([firstPagePromise, permissionsPromise]).then(([firstPdfPage, permissions]) => { |
| 14438 | if (pdfDocument !== this.pdfDocument) { |
| 14439 | return; |
| 14440 | } |
| 14441 | this._firstPageCapability.resolve(firstPdfPage); |
| 14442 | this._optionalContentConfigPromise = optionalContentConfigPromise; |
| 14443 | const { |
| 14444 | annotationEditorMode, |
| 14445 | annotationMode, |
| 14446 | textLayerMode |
| 14447 | } = this.#initializePermissions(permissions); |
| 14448 | if (textLayerMode !== TextLayerMode.DISABLE) { |
| 14449 | const element = this.#hiddenCopyElement = document.createElement("div"); |
| 14450 | element.id = "hiddenCopyElement"; |
| 14451 | viewer.before(element); |
| 14452 | } |
| 14453 | if (annotationEditorMode !== AnnotationEditorType.DISABLE) { |
| 14454 | const mode = annotationEditorMode; |
| 14455 | if (pdfDocument.isPureXfa) { |
| 14456 | console.warn("Warning: XFA-editing is not implemented."); |
| 14457 | } else if (isValidAnnotationEditorMode(mode)) { |
| 14458 | this.#annotationEditorUIManager = new AnnotationEditorUIManager(this.container, viewer, this.#altTextManager, eventBus, pdfDocument, pageColors, this.#annotationEditorHighlightColors, this.#enableHighlightFloatingButton, this.#mlManager); |
| 14459 | eventBus.dispatch("annotationeditoruimanager", { |
| 14460 | source: this, |
| 14461 | uiManager: this.#annotationEditorUIManager |
| 14462 | }); |
| 14463 | if (mode !== AnnotationEditorType.NONE) { |
| 14464 | this.#annotationEditorUIManager.updateMode(mode); |
| 14465 | } |
| 14466 | } else { |
| 14467 | console.error(`Invalid AnnotationEditor mode: ${mode}`); |
| 14468 | } |
| 14469 | } |
| 14470 | const viewerElement = this._scrollMode === ScrollMode.PAGE ? null : viewer; |
| 14471 | const scale = this.currentScale; |
| 14472 | const viewport = firstPdfPage.getViewport({ |
| 14473 | scale: scale * PixelsPerInch.PDF_TO_CSS_UNITS |
| 14474 | }); |
| 14475 | viewer.style.setProperty("--scale-factor", viewport.scale); |
| 14476 | if (pageColors?.foreground === "CanvasText" || pageColors?.background === "Canvas") { |
| 14477 | viewer.style.setProperty("--hcm-highlight-filter", pdfDocument.filterFactory.addHighlightHCMFilter("highlight", "CanvasText", "Canvas", "HighlightText", "Highlight")); |
| 14478 | viewer.style.setProperty("--hcm-highlight-selected-filter", pdfDocument.filterFactory.addHighlightHCMFilter("highlight_selected", "CanvasText", "Canvas", "HighlightText", "ButtonText")); |
| 14479 | } |
| 14480 | for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) { |
| 14481 | const pageView = new PDFPageView({ |
| 14482 | container: viewerElement, |
| 14483 | eventBus, |
| 14484 | id: pageNum, |
| 14485 | scale, |
| 14486 | defaultViewport: viewport.clone(), |
| 14487 | optionalContentConfigPromise, |
| 14488 | renderingQueue: this.renderingQueue, |
| 14489 | textLayerMode, |
| 14490 | annotationMode, |
| 14491 | imageResourcesPath: this.imageResourcesPath, |
| 14492 | maxCanvasPixels: this.maxCanvasPixels, |
| 14493 | pageColors, |
| 14494 | l10n: this.l10n, |
| 14495 | layerProperties: this._layerProperties |
| 14496 | }); |
| 14497 | this._pages.push(pageView); |
| 14498 | } |
| 14499 | this._pages[0]?.setPdfPage(firstPdfPage); |
| 14500 | if (this._scrollMode === ScrollMode.PAGE) { |
| 14501 | this.#ensurePageViewVisible(); |
| 14502 | } else if (this._spreadMode !== SpreadMode.NONE) { |
| 14503 | this._updateSpreadMode(); |
| 14504 | } |
| 14505 | this.#onePageRenderedOrForceFetch(signal).then(async () => { |
| 14506 | if (pdfDocument !== this.pdfDocument) { |
| 14507 | return; |
| 14508 | } |
| 14509 | this.findController?.setDocument(pdfDocument); |
| 14510 | this._scriptingManager?.setDocument(pdfDocument); |
| 14511 | if (this.#hiddenCopyElement) { |
| 14512 | document.addEventListener("copy", this.#copyCallback.bind(this, textLayerMode), { |
| 14513 | signal |
| 14514 | }); |
| 14515 | } |
| 14516 | if (this.#annotationEditorUIManager) { |
| 14517 | eventBus.dispatch("annotationeditormodechanged", { |
| 14518 | source: this, |
| 14519 | mode: this.#annotationEditorMode |
| 14520 | }); |
| 14521 | } |
| 14522 | if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > PagesCountLimit.FORCE_LAZY_PAGE_INIT) { |
| 14523 | this._pagesCapability.resolve(); |
| 14524 | return; |
| 14525 | } |
| 14526 | let getPagesLeft = pagesCount - 1; |
| 14527 | if (getPagesLeft <= 0) { |
| 14528 | this._pagesCapability.resolve(); |
| 14529 | return; |
| 14530 | } |
| 14531 | for (let pageNum = 2; pageNum <= pagesCount; ++pageNum) { |
| 14532 | const promise = pdfDocument.getPage(pageNum).then(pdfPage => { |
| 14533 | const pageView = this._pages[pageNum - 1]; |
| 14534 | if (!pageView.pdfPage) { |
| 14535 | pageView.setPdfPage(pdfPage); |
| 14536 | } |
| 14537 | if (--getPagesLeft === 0) { |
| 14538 | this._pagesCapability.resolve(); |
| 14539 | } |
| 14540 | }, reason => { |
| 14541 | console.error(`Unable to get page ${pageNum} to initialize viewer`, reason); |
| 14542 | if (--getPagesLeft === 0) { |
| 14543 | this._pagesCapability.resolve(); |
| 14544 | } |
| 14545 | }); |
| 14546 | if (pageNum % PagesCountLimit.PAUSE_EAGER_PAGE_INIT === 0) { |
| 14547 | await promise; |
| 14548 | } |
| 14549 | } |
| 14550 | }); |
| 14551 | eventBus.dispatch("pagesinit", { |
| 14552 | source: this |
| 14553 | }); |
| 14554 | pdfDocument.getMetadata().then(({ |
| 14555 | info |
| 14556 | }) => { |
| 14557 | if (pdfDocument !== this.pdfDocument) { |
| 14558 | return; |
| 14559 | } |
| 14560 | if (info.Language) { |
| 14561 | viewer.lang = info.Language; |
| 14562 | } |
| 14563 | }); |
| 14564 | if (this.defaultRenderingQueue) { |
| 14565 | this.update(); |
| 14566 | } |
| 14567 | }).catch(reason => { |
| 14568 | console.error("Unable to initialize viewer", reason); |
| 14569 | this._pagesCapability.reject(reason); |
| 14570 | }); |
| 14571 | } |
| 14572 | setPageLabels(labels) { |
| 14573 | if (!this.pdfDocument) { |
| 14574 | return; |
| 14575 | } |
| 14576 | if (!labels) { |
| 14577 | this._pageLabels = null; |
| 14578 | } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) { |
| 14579 | this._pageLabels = null; |
| 14580 | console.error(`setPageLabels: Invalid page labels.`); |
| 14581 | } else { |
| 14582 | this._pageLabels = labels; |
| 14583 | } |
| 14584 | for (let i = 0, ii = this._pages.length; i < ii; i++) { |
| 14585 | this._pages[i].setPageLabel(this._pageLabels?.[i] ?? null); |
| 14586 | } |
| 14587 | } |
| 14588 | _resetView() { |
| 14589 | this._pages = []; |
| 14590 | this._currentPageNumber = 1; |
| 14591 | this._currentScale = UNKNOWN_SCALE; |
| 14592 | this._currentScaleValue = null; |
| 14593 | this._pageLabels = null; |
| 14594 | this.#buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE); |
| 14595 | this._location = null; |
| 14596 | this._pagesRotation = 0; |
| 14597 | this._optionalContentConfigPromise = null; |
| 14598 | this._firstPageCapability = Promise.withResolvers(); |
| 14599 | this._onePageRenderedCapability = Promise.withResolvers(); |
| 14600 | this._pagesCapability = Promise.withResolvers(); |
| 14601 | this._scrollMode = ScrollMode.VERTICAL; |
| 14602 | this._previousScrollMode = ScrollMode.UNKNOWN; |
| 14603 | this._spreadMode = SpreadMode.NONE; |
| 14604 | this.#scrollModePageState = { |
| 14605 | previousPageNumber: 1, |
| 14606 | scrollDown: true, |
| 14607 | pages: [] |
| 14608 | }; |
| 14609 | this.#eventAbortController?.abort(); |
| 14610 | this.#eventAbortController = null; |
| 14611 | this.viewer.textContent = ""; |
| 14612 | this._updateScrollMode(); |
| 14613 | this.viewer.removeAttribute("lang"); |
| 14614 | this.#hiddenCopyElement?.remove(); |
| 14615 | this.#hiddenCopyElement = null; |
| 14616 | } |
| 14617 | #ensurePageViewVisible() { |
| 14618 | if (this._scrollMode !== ScrollMode.PAGE) { |
| 14619 | throw new Error("#ensurePageViewVisible: Invalid scrollMode value."); |
| 14620 | } |
| 14621 | const pageNumber = this._currentPageNumber, |
| 14622 | state = this.#scrollModePageState, |
| 14623 | viewer = this.viewer; |
| 14624 | viewer.textContent = ""; |
| 14625 | state.pages.length = 0; |
| 14626 | if (this._spreadMode === SpreadMode.NONE && !this.isInPresentationMode) { |
| 14627 | const pageView = this._pages[pageNumber - 1]; |
| 14628 | viewer.append(pageView.div); |
| 14629 | state.pages.push(pageView); |
| 14630 | } else { |
| 14631 | const pageIndexSet = new Set(), |
| 14632 | parity = this._spreadMode - 1; |
| 14633 | if (parity === -1) { |
| 14634 | pageIndexSet.add(pageNumber - 1); |
| 14635 | } else if (pageNumber % 2 !== parity) { |
| 14636 | pageIndexSet.add(pageNumber - 1); |
| 14637 | pageIndexSet.add(pageNumber); |
| 14638 | } else { |
| 14639 | pageIndexSet.add(pageNumber - 2); |
| 14640 | pageIndexSet.add(pageNumber - 1); |
| 14641 | } |
| 14642 | const spread = document.createElement("div"); |
| 14643 | spread.className = "spread"; |
| 14644 | if (this.isInPresentationMode) { |
| 14645 | const dummyPage = document.createElement("div"); |
| 14646 | dummyPage.className = "dummyPage"; |
| 14647 | spread.append(dummyPage); |
| 14648 | } |
| 14649 | for (const i of pageIndexSet) { |
| 14650 | const pageView = this._pages[i]; |
| 14651 | if (!pageView) { |
| 14652 | continue; |
| 14653 | } |
| 14654 | spread.append(pageView.div); |
| 14655 | state.pages.push(pageView); |
| 14656 | } |
| 14657 | viewer.append(spread); |
| 14658 | } |
| 14659 | state.scrollDown = pageNumber >= state.previousPageNumber; |
| 14660 | state.previousPageNumber = pageNumber; |
| 14661 | } |
| 14662 | _scrollUpdate() { |
| 14663 | if (this.pagesCount === 0) { |
| 14664 | return; |
| 14665 | } |
| 14666 | this.update(); |
| 14667 | } |
| 14668 | #scrollIntoView(pageView, pageSpot = null) { |
| 14669 | const { |
| 14670 | div, |
| 14671 | id |
| 14672 | } = pageView; |
| 14673 | if (this._currentPageNumber !== id) { |
| 14674 | this._setCurrentPageNumber(id); |
| 14675 | } |
| 14676 | if (this._scrollMode === ScrollMode.PAGE) { |
| 14677 | this.#ensurePageViewVisible(); |
| 14678 | this.update(); |
| 14679 | } |
| 14680 | if (!pageSpot && !this.isInPresentationMode) { |
| 14681 | const left = div.offsetLeft + div.clientLeft, |
| 14682 | right = left + div.clientWidth; |
| 14683 | const { |
| 14684 | scrollLeft, |
| 14685 | clientWidth |
| 14686 | } = this.container; |
| 14687 | if (this._scrollMode === ScrollMode.HORIZONTAL || left < scrollLeft || right > scrollLeft + clientWidth) { |
| 14688 | pageSpot = { |
| 14689 | left: 0, |
| 14690 | top: 0 |
| 14691 | }; |
| 14692 | } |
| 14693 | } |
| 14694 | scrollIntoView(div, pageSpot); |
| 14695 | if (!this._currentScaleValue && this._location) { |
| 14696 | this._location = null; |
| 14697 | } |
| 14698 | } |
| 14699 | #isSameScale(newScale) { |
| 14700 | return newScale === this._currentScale || Math.abs(newScale - this._currentScale) < 1e-15; |
| 14701 | } |
| 14702 | #setScaleUpdatePages(newScale, newValue, { |
| 14703 | noScroll = false, |
| 14704 | preset = false, |
| 14705 | drawingDelay = -1, |
| 14706 | origin = null |
| 14707 | }) { |
| 14708 | this._currentScaleValue = newValue.toString(); |
| 14709 | if (this.#isSameScale(newScale)) { |
| 14710 | if (preset) { |
| 14711 | this.eventBus.dispatch("scalechanging", { |
| 14712 | source: this, |
| 14713 | scale: newScale, |
| 14714 | presetValue: newValue |
| 14715 | }); |
| 14716 | } |
| 14717 | return; |
| 14718 | } |
| 14719 | this.viewer.style.setProperty("--scale-factor", newScale * PixelsPerInch.PDF_TO_CSS_UNITS); |
| 14720 | const postponeDrawing = drawingDelay >= 0 && drawingDelay < 1000; |
| 14721 | this.refresh(true, { |
| 14722 | scale: newScale, |
| 14723 | drawingDelay: postponeDrawing ? drawingDelay : -1 |
| 14724 | }); |
| 14725 | if (postponeDrawing) { |
| 14726 | this.#scaleTimeoutId = setTimeout(() => { |
| 14727 | this.#scaleTimeoutId = null; |
| 14728 | this.refresh(); |
| 14729 | }, drawingDelay); |
| 14730 | } |
| 14731 | const previousScale = this._currentScale; |
| 14732 | this._currentScale = newScale; |
| 14733 | if (!noScroll) { |
| 14734 | let page = this._currentPageNumber, |
| 14735 | dest; |
| 14736 | if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) { |
| 14737 | page = this._location.pageNumber; |
| 14738 | dest = [null, { |
| 14739 | name: "XYZ" |
| 14740 | }, this._location.left, this._location.top, null]; |
| 14741 | } |
| 14742 | this.scrollPageIntoView({ |
| 14743 | pageNumber: page, |
| 14744 | destArray: dest, |
| 14745 | allowNegativeOffset: true |
| 14746 | }); |
| 14747 | if (Array.isArray(origin)) { |
| 14748 | const scaleDiff = newScale / previousScale - 1; |
| 14749 | const [top, left] = this.containerTopLeft; |
| 14750 | this.container.scrollLeft += (origin[0] - left) * scaleDiff; |
| 14751 | this.container.scrollTop += (origin[1] - top) * scaleDiff; |
| 14752 | } |
| 14753 | } |
| 14754 | this.eventBus.dispatch("scalechanging", { |
| 14755 | source: this, |
| 14756 | scale: newScale, |
| 14757 | presetValue: preset ? newValue : undefined |
| 14758 | }); |
| 14759 | if (this.defaultRenderingQueue) { |
| 14760 | this.update(); |
| 14761 | } |
| 14762 | } |
| 14763 | get #pageWidthScaleFactor() { |
| 14764 | if (this._spreadMode !== SpreadMode.NONE && this._scrollMode !== ScrollMode.HORIZONTAL) { |
| 14765 | return 2; |
| 14766 | } |
| 14767 | return 1; |
| 14768 | } |
| 14769 | #setScale(value, options) { |
| 14770 | let scale = parseFloat(value); |
| 14771 | if (scale > 0) { |
| 14772 | options.preset = false; |
| 14773 | this.#setScaleUpdatePages(scale, value, options); |
| 14774 | } else { |
| 14775 | const currentPage = this._pages[this._currentPageNumber - 1]; |
| 14776 | if (!currentPage) { |
| 14777 | return; |
| 14778 | } |
| 14779 | let hPadding = SCROLLBAR_PADDING, |
| 14780 | vPadding = VERTICAL_PADDING; |
| 14781 | if (this.isInPresentationMode) { |
| 14782 | hPadding = vPadding = 4; |
| 14783 | if (this._spreadMode !== SpreadMode.NONE) { |
| 14784 | hPadding *= 2; |
| 14785 | } |
| 14786 | } else if (this.removePageBorders) { |
| 14787 | hPadding = vPadding = 0; |
| 14788 | } else if (this._scrollMode === ScrollMode.HORIZONTAL) { |
| 14789 | [hPadding, vPadding] = [vPadding, hPadding]; |
| 14790 | } |
| 14791 | const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this.#pageWidthScaleFactor; |
| 14792 | const pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale; |
| 14793 | switch (value) { |
| 14794 | case "page-actual": |
| 14795 | scale = 1; |
| 14796 | break; |
| 14797 | case "page-width": |
| 14798 | scale = pageWidthScale; |
| 14799 | break; |
| 14800 | case "page-height": |
| 14801 | scale = pageHeightScale; |
| 14802 | break; |
| 14803 | case "page-fit": |
| 14804 | scale = Math.min(pageWidthScale, pageHeightScale); |
| 14805 | break; |
| 14806 | case "auto": |
| 14807 | const horizontalScale = isPortraitOrientation(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale); |
| 14808 | scale = Math.min(MAX_AUTO_SCALE, horizontalScale); |
| 14809 | break; |
| 14810 | default: |
| 14811 | console.error(`#setScale: "${value}" is an unknown zoom value.`); |
| 14812 | return; |
| 14813 | } |
| 14814 | options.preset = true; |
| 14815 | this.#setScaleUpdatePages(scale, value, options); |
| 14816 | } |
| 14817 | } |
| 14818 | #resetCurrentPageView() { |
| 14819 | const pageView = this._pages[this._currentPageNumber - 1]; |
| 14820 | if (this.isInPresentationMode) { |
| 14821 | this.#setScale(this._currentScaleValue, { |
| 14822 | noScroll: true |
| 14823 | }); |
| 14824 | } |
| 14825 | this.#scrollIntoView(pageView); |
| 14826 | } |
| 14827 | pageLabelToPageNumber(label) { |
| 14828 | if (!this._pageLabels) { |
| 14829 | return null; |
| 14830 | } |
| 14831 | const i = this._pageLabels.indexOf(label); |
| 14832 | if (i < 0) { |
| 14833 | return null; |
| 14834 | } |
| 14835 | return i + 1; |
| 14836 | } |
| 14837 | scrollPageIntoView({ |
| 14838 | pageNumber, |
| 14839 | destArray = null, |
| 14840 | allowNegativeOffset = false, |
| 14841 | ignoreDestinationZoom = false |
| 14842 | }) { |
| 14843 | if (!this.pdfDocument) { |
| 14844 | return; |
| 14845 | } |
| 14846 | const pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1]; |
| 14847 | if (!pageView) { |
| 14848 | console.error(`scrollPageIntoView: "${pageNumber}" is not a valid pageNumber parameter.`); |
| 14849 | return; |
| 14850 | } |
| 14851 | if (this.isInPresentationMode || !destArray) { |
| 14852 | this._setCurrentPageNumber(pageNumber, true); |
| 14853 | return; |
| 14854 | } |
| 14855 | let x = 0, |
| 14856 | y = 0; |
| 14857 | let width = 0, |
| 14858 | height = 0, |
| 14859 | widthScale, |
| 14860 | heightScale; |
| 14861 | const changeOrientation = pageView.rotation % 180 !== 0; |
| 14862 | const pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / PixelsPerInch.PDF_TO_CSS_UNITS; |
| 14863 | const pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / PixelsPerInch.PDF_TO_CSS_UNITS; |
| 14864 | let scale = 0; |
| 14865 | switch (destArray[1].name) { |
| 14866 | case "XYZ": |
| 14867 | x = destArray[2]; |
| 14868 | y = destArray[3]; |
| 14869 | scale = destArray[4]; |
| 14870 | x = x !== null ? x : 0; |
| 14871 | y = y !== null ? y : pageHeight; |
| 14872 | break; |
| 14873 | case "Fit": |
| 14874 | case "FitB": |
| 14875 | scale = "page-fit"; |
| 14876 | break; |
| 14877 | case "FitH": |
| 14878 | case "FitBH": |
| 14879 | y = destArray[2]; |
| 14880 | scale = "page-width"; |
| 14881 | if (y === null && this._location) { |
| 14882 | x = this._location.left; |
| 14883 | y = this._location.top; |
| 14884 | } else if (typeof y !== "number" || y < 0) { |
| 14885 | y = pageHeight; |
| 14886 | } |
| 14887 | break; |
| 14888 | case "FitV": |
| 14889 | case "FitBV": |
| 14890 | x = destArray[2]; |
| 14891 | width = pageWidth; |
| 14892 | height = pageHeight; |
| 14893 | scale = "page-height"; |
| 14894 | break; |
| 14895 | case "FitR": |
| 14896 | x = destArray[2]; |
| 14897 | y = destArray[3]; |
| 14898 | width = destArray[4] - x; |
| 14899 | height = destArray[5] - y; |
| 14900 | let hPadding = SCROLLBAR_PADDING, |
| 14901 | vPadding = VERTICAL_PADDING; |
| 14902 | if (this.removePageBorders) { |
| 14903 | hPadding = vPadding = 0; |
| 14904 | } |
| 14905 | widthScale = (this.container.clientWidth - hPadding) / width / PixelsPerInch.PDF_TO_CSS_UNITS; |
| 14906 | heightScale = (this.container.clientHeight - vPadding) / height / PixelsPerInch.PDF_TO_CSS_UNITS; |
| 14907 | scale = Math.min(Math.abs(widthScale), Math.abs(heightScale)); |
| 14908 | break; |
| 14909 | default: |
| 14910 | console.error(`scrollPageIntoView: "${destArray[1].name}" is not a valid destination type.`); |
| 14911 | return; |
| 14912 | } |
| 14913 | if (!ignoreDestinationZoom) { |
| 14914 | if (scale && scale !== this._currentScale) { |
| 14915 | this.currentScaleValue = scale; |
| 14916 | } else if (this._currentScale === UNKNOWN_SCALE) { |
| 14917 | this.currentScaleValue = DEFAULT_SCALE_VALUE; |
| 14918 | } |
| 14919 | } |
| 14920 | if (scale === "page-fit" && !destArray[4]) { |
| 14921 | this.#scrollIntoView(pageView); |
| 14922 | return; |
| 14923 | } |
| 14924 | const boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)]; |
| 14925 | let left = Math.min(boundingRect[0][0], boundingRect[1][0]); |
| 14926 | let top = Math.min(boundingRect[0][1], boundingRect[1][1]); |
| 14927 | if (!allowNegativeOffset) { |
| 14928 | left = Math.max(left, 0); |
| 14929 | top = Math.max(top, 0); |
| 14930 | } |
| 14931 | this.#scrollIntoView(pageView, { |
| 14932 | left, |
| 14933 | top |
| 14934 | }); |
| 14935 | } |
| 14936 | _updateLocation(firstPage) { |
| 14937 | const currentScale = this._currentScale; |
| 14938 | const currentScaleValue = this._currentScaleValue; |
| 14939 | const normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue; |
| 14940 | const pageNumber = firstPage.id; |
| 14941 | const currentPageView = this._pages[pageNumber - 1]; |
| 14942 | const container = this.container; |
| 14943 | const topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y); |
| 14944 | const intLeft = Math.round(topLeft[0]); |
| 14945 | const intTop = Math.round(topLeft[1]); |
| 14946 | let pdfOpenParams = `#page=${pageNumber}`; |
| 14947 | if (!this.isInPresentationMode) { |
| 14948 | pdfOpenParams += `&zoom=${normalizedScaleValue},${intLeft},${intTop}`; |
| 14949 | } |
| 14950 | this._location = { |
| 14951 | pageNumber, |
| 14952 | scale: normalizedScaleValue, |
| 14953 | top: intTop, |
| 14954 | left: intLeft, |
| 14955 | rotation: this._pagesRotation, |
| 14956 | pdfOpenParams |
| 14957 | }; |
| 14958 | } |
| 14959 | update() { |
| 14960 | const visible = this._getVisiblePages(); |
| 14961 | const visiblePages = visible.views, |
| 14962 | numVisiblePages = visiblePages.length; |
| 14963 | if (numVisiblePages === 0) { |
| 14964 | return; |
| 14965 | } |
| 14966 | const newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1); |
| 14967 | this.#buffer.resize(newCacheSize, visible.ids); |
| 14968 | this.renderingQueue.renderHighestPriority(visible); |
| 14969 | const isSimpleLayout = this._spreadMode === SpreadMode.NONE && (this._scrollMode === ScrollMode.PAGE || this._scrollMode === ScrollMode.VERTICAL); |
| 14970 | const currentId = this._currentPageNumber; |
| 14971 | let stillFullyVisible = false; |
| 14972 | for (const page of visiblePages) { |
| 14973 | if (page.percent < 100) { |
| 14974 | break; |
| 14975 | } |
| 14976 | if (page.id === currentId && isSimpleLayout) { |
| 14977 | stillFullyVisible = true; |
| 14978 | break; |
| 14979 | } |
| 14980 | } |
| 14981 | this._setCurrentPageNumber(stillFullyVisible ? currentId : visiblePages[0].id); |
| 14982 | this._updateLocation(visible.first); |
| 14983 | this.eventBus.dispatch("updateviewarea", { |
| 14984 | source: this, |
| 14985 | location: this._location |
| 14986 | }); |
| 14987 | } |
| 14988 | containsElement(element) { |
| 14989 | return this.container.contains(element); |
| 14990 | } |
| 14991 | focus() { |
| 14992 | this.container.focus(); |
| 14993 | } |
| 14994 | get _isContainerRtl() { |
| 14995 | return getComputedStyle(this.container).direction === "rtl"; |
| 14996 | } |
| 14997 | get isInPresentationMode() { |
| 14998 | return this.presentationModeState === PresentationModeState.FULLSCREEN; |
| 14999 | } |
| 15000 | get isChangingPresentationMode() { |
| 15001 | return this.presentationModeState === PresentationModeState.CHANGING; |
| 15002 | } |
| 15003 | get isHorizontalScrollbarEnabled() { |
| 15004 | return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth; |
| 15005 | } |
| 15006 | get isVerticalScrollbarEnabled() { |
| 15007 | return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight; |
| 15008 | } |
| 15009 | _getVisiblePages() { |
| 15010 | const views = this._scrollMode === ScrollMode.PAGE ? this.#scrollModePageState.pages : this._pages, |
| 15011 | horizontal = this._scrollMode === ScrollMode.HORIZONTAL, |
| 15012 | rtl = horizontal && this._isContainerRtl; |
| 15013 | return getVisibleElements({ |
| 15014 | scrollEl: this.container, |
| 15015 | views, |
| 15016 | sortByVisibility: true, |
| 15017 | horizontal, |
| 15018 | rtl |
| 15019 | }); |
| 15020 | } |
| 15021 | cleanup() { |
| 15022 | for (const pageView of this._pages) { |
| 15023 | if (pageView.renderingState !== RenderingStates.FINISHED) { |
| 15024 | pageView.reset(); |
| 15025 | } |
| 15026 | } |
| 15027 | } |
| 15028 | _cancelRendering() { |
| 15029 | for (const pageView of this._pages) { |
| 15030 | pageView.cancelRendering(); |
| 15031 | } |
| 15032 | } |
| 15033 | async #ensurePdfPageLoaded(pageView) { |
| 15034 | if (pageView.pdfPage) { |
| 15035 | return pageView.pdfPage; |
| 15036 | } |
| 15037 | try { |
| 15038 | const pdfPage = await this.pdfDocument.getPage(pageView.id); |
| 15039 | if (!pageView.pdfPage) { |
| 15040 | pageView.setPdfPage(pdfPage); |
| 15041 | } |
| 15042 | return pdfPage; |
| 15043 | } catch (reason) { |
| 15044 | console.error("Unable to get page for page view", reason); |
| 15045 | return null; |
| 15046 | } |
| 15047 | } |
| 15048 | #getScrollAhead(visible) { |
| 15049 | if (visible.first?.id === 1) { |
| 15050 | return true; |
| 15051 | } else if (visible.last?.id === this.pagesCount) { |
| 15052 | return false; |
| 15053 | } |
| 15054 | switch (this._scrollMode) { |
| 15055 | case ScrollMode.PAGE: |
| 15056 | return this.#scrollModePageState.scrollDown; |
| 15057 | case ScrollMode.HORIZONTAL: |
| 15058 | return this.scroll.right; |
| 15059 | } |
| 15060 | return this.scroll.down; |
| 15061 | } |
| 15062 | forceRendering(currentlyVisiblePages) { |
| 15063 | const visiblePages = currentlyVisiblePages || this._getVisiblePages(); |
| 15064 | const scrollAhead = this.#getScrollAhead(visiblePages); |
| 15065 | const preRenderExtra = this._spreadMode !== SpreadMode.NONE && this._scrollMode !== ScrollMode.HORIZONTAL; |
| 15066 | const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead, preRenderExtra); |
| 15067 | if (pageView) { |
| 15068 | this.#ensurePdfPageLoaded(pageView).then(() => { |
| 15069 | this.renderingQueue.renderView(pageView); |
| 15070 | }); |
| 15071 | return true; |
| 15072 | } |
| 15073 | return false; |
| 15074 | } |
| 15075 | get hasEqualPageSizes() { |
| 15076 | const firstPageView = this._pages[0]; |
| 15077 | for (let i = 1, ii = this._pages.length; i < ii; ++i) { |
| 15078 | const pageView = this._pages[i]; |
| 15079 | if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) { |
| 15080 | return false; |
| 15081 | } |
| 15082 | } |
| 15083 | return true; |
| 15084 | } |
| 15085 | getPagesOverview() { |
| 15086 | let initialOrientation; |
| 15087 | return this._pages.map(pageView => { |
| 15088 | const viewport = pageView.pdfPage.getViewport({ |
| 15089 | scale: 1 |
| 15090 | }); |
| 15091 | const orientation = isPortraitOrientation(viewport); |
| 15092 | if (initialOrientation === undefined) { |
| 15093 | initialOrientation = orientation; |
| 15094 | } else if (this.enablePrintAutoRotate && orientation !== initialOrientation) { |
| 15095 | return { |
| 15096 | width: viewport.height, |
| 15097 | height: viewport.width, |
| 15098 | rotation: (viewport.rotation - 90) % 360 |
| 15099 | }; |
| 15100 | } |
| 15101 | return { |
| 15102 | width: viewport.width, |
| 15103 | height: viewport.height, |
| 15104 | rotation: viewport.rotation |
| 15105 | }; |
| 15106 | }); |
| 15107 | } |
| 15108 | get optionalContentConfigPromise() { |
| 15109 | if (!this.pdfDocument) { |
| 15110 | return Promise.resolve(null); |
| 15111 | } |
| 15112 | if (!this._optionalContentConfigPromise) { |
| 15113 | console.error("optionalContentConfigPromise: Not initialized yet."); |
| 15114 | return this.pdfDocument.getOptionalContentConfig({ |
| 15115 | intent: "display" |
| 15116 | }); |
| 15117 | } |
| 15118 | return this._optionalContentConfigPromise; |
| 15119 | } |
| 15120 | set optionalContentConfigPromise(promise) { |
| 15121 | if (!(promise instanceof Promise)) { |
| 15122 | throw new Error(`Invalid optionalContentConfigPromise: ${promise}`); |
| 15123 | } |
| 15124 | if (!this.pdfDocument) { |
| 15125 | return; |
| 15126 | } |
| 15127 | if (!this._optionalContentConfigPromise) { |
| 15128 | return; |
| 15129 | } |
| 15130 | this._optionalContentConfigPromise = promise; |
| 15131 | this.refresh(false, { |
| 15132 | optionalContentConfigPromise: promise |
| 15133 | }); |
| 15134 | this.eventBus.dispatch("optionalcontentconfigchanged", { |
| 15135 | source: this, |
| 15136 | promise |
| 15137 | }); |
| 15138 | } |
| 15139 | get scrollMode() { |
| 15140 | return this._scrollMode; |
| 15141 | } |
| 15142 | set scrollMode(mode) { |
| 15143 | if (this._scrollMode === mode) { |
| 15144 | return; |
| 15145 | } |
| 15146 | if (!isValidScrollMode(mode)) { |
| 15147 | throw new Error(`Invalid scroll mode: ${mode}`); |
| 15148 | } |
| 15149 | if (this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) { |
| 15150 | return; |
| 15151 | } |
| 15152 | this._previousScrollMode = this._scrollMode; |
| 15153 | this._scrollMode = mode; |
| 15154 | this.eventBus.dispatch("scrollmodechanged", { |
| 15155 | source: this, |
| 15156 | mode |
| 15157 | }); |
| 15158 | this._updateScrollMode(this._currentPageNumber); |
| 15159 | } |
| 15160 | _updateScrollMode(pageNumber = null) { |
| 15161 | const scrollMode = this._scrollMode, |
| 15162 | viewer = this.viewer; |
| 15163 | viewer.classList.toggle("scrollHorizontal", scrollMode === ScrollMode.HORIZONTAL); |
| 15164 | viewer.classList.toggle("scrollWrapped", scrollMode === ScrollMode.WRAPPED); |
| 15165 | if (!this.pdfDocument || !pageNumber) { |
| 15166 | return; |
| 15167 | } |
| 15168 | if (scrollMode === ScrollMode.PAGE) { |
| 15169 | this.#ensurePageViewVisible(); |
| 15170 | } else if (this._previousScrollMode === ScrollMode.PAGE) { |
| 15171 | this._updateSpreadMode(); |
| 15172 | } |
| 15173 | if (this._currentScaleValue && isNaN(this._currentScaleValue)) { |
| 15174 | this.#setScale(this._currentScaleValue, { |
| 15175 | noScroll: true |
| 15176 | }); |
| 15177 | } |
| 15178 | this._setCurrentPageNumber(pageNumber, true); |
| 15179 | this.update(); |
| 15180 | } |
| 15181 | get spreadMode() { |
| 15182 | return this._spreadMode; |
| 15183 | } |
| 15184 | set spreadMode(mode) { |
| 15185 | if (this._spreadMode === mode) { |
| 15186 | return; |
| 15187 | } |
| 15188 | if (!isValidSpreadMode(mode)) { |
| 15189 | throw new Error(`Invalid spread mode: ${mode}`); |
| 15190 | } |
| 15191 | this._spreadMode = mode; |
| 15192 | this.eventBus.dispatch("spreadmodechanged", { |
| 15193 | source: this, |
| 15194 | mode |
| 15195 | }); |
| 15196 | this._updateSpreadMode(this._currentPageNumber); |
| 15197 | } |
| 15198 | _updateSpreadMode(pageNumber = null) { |
| 15199 | if (!this.pdfDocument) { |
| 15200 | return; |
| 15201 | } |
| 15202 | const viewer = this.viewer, |
| 15203 | pages = this._pages; |
| 15204 | if (this._scrollMode === ScrollMode.PAGE) { |
| 15205 | this.#ensurePageViewVisible(); |
| 15206 | } else { |
| 15207 | viewer.textContent = ""; |
| 15208 | if (this._spreadMode === SpreadMode.NONE) { |
| 15209 | for (const pageView of this._pages) { |
| 15210 | viewer.append(pageView.div); |
| 15211 | } |
| 15212 | } else { |
| 15213 | const parity = this._spreadMode - 1; |
| 15214 | let spread = null; |
| 15215 | for (let i = 0, ii = pages.length; i < ii; ++i) { |
| 15216 | if (spread === null) { |
| 15217 | spread = document.createElement("div"); |
| 15218 | spread.className = "spread"; |
| 15219 | viewer.append(spread); |
| 15220 | } else if (i % 2 === parity) { |
| 15221 | spread = spread.cloneNode(false); |
| 15222 | viewer.append(spread); |
| 15223 | } |
| 15224 | spread.append(pages[i].div); |
| 15225 | } |
| 15226 | } |
| 15227 | } |
| 15228 | if (!pageNumber) { |
| 15229 | return; |
| 15230 | } |
| 15231 | if (this._currentScaleValue && isNaN(this._currentScaleValue)) { |
| 15232 | this.#setScale(this._currentScaleValue, { |
| 15233 | noScroll: true |
| 15234 | }); |
| 15235 | } |
| 15236 | this._setCurrentPageNumber(pageNumber, true); |
| 15237 | this.update(); |
| 15238 | } |
| 15239 | _getPageAdvance(currentPageNumber, previous = false) { |
| 15240 | switch (this._scrollMode) { |
| 15241 | case ScrollMode.WRAPPED: |
| 15242 | { |
| 15243 | const { |
| 15244 | views |
| 15245 | } = this._getVisiblePages(), |
| 15246 | pageLayout = new Map(); |
| 15247 | for (const { |
| 15248 | id, |
| 15249 | y, |
| 15250 | percent, |
| 15251 | widthPercent |
| 15252 | } of views) { |
| 15253 | if (percent === 0 || widthPercent < 100) { |
| 15254 | continue; |
| 15255 | } |
| 15256 | let yArray = pageLayout.get(y); |
| 15257 | if (!yArray) { |
| 15258 | pageLayout.set(y, yArray ||= []); |
| 15259 | } |
| 15260 | yArray.push(id); |
| 15261 | } |
| 15262 | for (const yArray of pageLayout.values()) { |
| 15263 | const currentIndex = yArray.indexOf(currentPageNumber); |
| 15264 | if (currentIndex === -1) { |
| 15265 | continue; |
| 15266 | } |
| 15267 | const numPages = yArray.length; |
| 15268 | if (numPages === 1) { |
| 15269 | break; |
| 15270 | } |
| 15271 | if (previous) { |
| 15272 | for (let i = currentIndex - 1, ii = 0; i >= ii; i--) { |
| 15273 | const currentId = yArray[i], |
| 15274 | expectedId = yArray[i + 1] - 1; |
| 15275 | if (currentId < expectedId) { |
| 15276 | return currentPageNumber - expectedId; |
| 15277 | } |
| 15278 | } |
| 15279 | } else { |
| 15280 | for (let i = currentIndex + 1, ii = numPages; i < ii; i++) { |
| 15281 | const currentId = yArray[i], |
| 15282 | expectedId = yArray[i - 1] + 1; |
| 15283 | if (currentId > expectedId) { |
| 15284 | return expectedId - currentPageNumber; |
| 15285 | } |
| 15286 | } |
| 15287 | } |
| 15288 | if (previous) { |
| 15289 | const firstId = yArray[0]; |
| 15290 | if (firstId < currentPageNumber) { |
| 15291 | return currentPageNumber - firstId + 1; |
| 15292 | } |
| 15293 | } else { |
| 15294 | const lastId = yArray[numPages - 1]; |
| 15295 | if (lastId > currentPageNumber) { |
| 15296 | return lastId - currentPageNumber + 1; |
| 15297 | } |
| 15298 | } |
| 15299 | break; |
| 15300 | } |
| 15301 | break; |
| 15302 | } |
| 15303 | case ScrollMode.HORIZONTAL: |
| 15304 | { |
| 15305 | break; |
| 15306 | } |
| 15307 | case ScrollMode.PAGE: |
| 15308 | case ScrollMode.VERTICAL: |
| 15309 | { |
| 15310 | if (this._spreadMode === SpreadMode.NONE) { |
| 15311 | break; |
| 15312 | } |
| 15313 | const parity = this._spreadMode - 1; |
| 15314 | if (previous && currentPageNumber % 2 !== parity) { |
| 15315 | break; |
| 15316 | } else if (!previous && currentPageNumber % 2 === parity) { |
| 15317 | break; |
| 15318 | } |
| 15319 | const { |
| 15320 | views |
| 15321 | } = this._getVisiblePages(), |
| 15322 | expectedId = previous ? currentPageNumber - 1 : currentPageNumber + 1; |
| 15323 | for (const { |
| 15324 | id, |
| 15325 | percent, |
| 15326 | widthPercent |
| 15327 | } of views) { |
| 15328 | if (id !== expectedId) { |
| 15329 | continue; |
| 15330 | } |
| 15331 | if (percent > 0 && widthPercent === 100) { |
| 15332 | return 2; |
| 15333 | } |
| 15334 | break; |
| 15335 | } |
| 15336 | break; |
| 15337 | } |
| 15338 | } |
| 15339 | return 1; |
| 15340 | } |
| 15341 | nextPage() { |
| 15342 | const currentPageNumber = this._currentPageNumber, |
| 15343 | pagesCount = this.pagesCount; |
| 15344 | if (currentPageNumber >= pagesCount) { |
| 15345 | return false; |
| 15346 | } |
| 15347 | const advance = this._getPageAdvance(currentPageNumber, false) || 1; |
| 15348 | this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount); |
| 15349 | return true; |
| 15350 | } |
| 15351 | previousPage() { |
| 15352 | const currentPageNumber = this._currentPageNumber; |
| 15353 | if (currentPageNumber <= 1) { |
| 15354 | return false; |
| 15355 | } |
| 15356 | const advance = this._getPageAdvance(currentPageNumber, true) || 1; |
| 15357 | this.currentPageNumber = Math.max(currentPageNumber - advance, 1); |
| 15358 | return true; |
| 15359 | } |
| 15360 | updateScale({ |
| 15361 | drawingDelay, |
| 15362 | scaleFactor = null, |
| 15363 | steps = null, |
| 15364 | origin |
| 15365 | }) { |
| 15366 | if (steps === null && scaleFactor === null) { |
| 15367 | throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided."); |
| 15368 | } |
| 15369 | if (!this.pdfDocument) { |
| 15370 | return; |
| 15371 | } |
| 15372 | let newScale = this._currentScale; |
| 15373 | if (scaleFactor > 0 && scaleFactor !== 1) { |
| 15374 | newScale = Math.round(newScale * scaleFactor * 100) / 100; |
| 15375 | } else if (steps) { |
| 15376 | const delta = steps > 0 ? DEFAULT_SCALE_DELTA : 1 / DEFAULT_SCALE_DELTA; |
| 15377 | const round = steps > 0 ? Math.ceil : Math.floor; |
| 15378 | steps = Math.abs(steps); |
| 15379 | do { |
| 15380 | newScale = round((newScale * delta).toFixed(2) * 10) / 10; |
| 15381 | } while (--steps > 0); |
| 15382 | } |
| 15383 | newScale = Math.max(MIN_SCALE, Math.min(MAX_SCALE, newScale)); |
| 15384 | this.#setScale(newScale, { |
| 15385 | noScroll: false, |
| 15386 | drawingDelay, |
| 15387 | origin |
| 15388 | }); |
| 15389 | } |
| 15390 | increaseScale(options = {}) { |
| 15391 | this.updateScale({ |
| 15392 | ...options, |
| 15393 | steps: options.steps ?? 1 |
| 15394 | }); |
| 15395 | } |
| 15396 | decreaseScale(options = {}) { |
| 15397 | this.updateScale({ |
| 15398 | ...options, |
| 15399 | steps: -(options.steps ?? 1) |
| 15400 | }); |
| 15401 | } |
| 15402 | #updateContainerHeightCss(height = this.container.clientHeight) { |
| 15403 | if (height !== this.#previousContainerHeight) { |
| 15404 | this.#previousContainerHeight = height; |
| 15405 | docStyle.setProperty("--viewer-container-height", `${height}px`); |
| 15406 | } |
| 15407 | } |
| 15408 | #resizeObserverCallback(entries) { |
| 15409 | for (const entry of entries) { |
| 15410 | if (entry.target === this.container) { |
| 15411 | this.#updateContainerHeightCss(Math.floor(entry.borderBoxSize[0].blockSize)); |
| 15412 | this.#containerTopLeft = null; |
| 15413 | break; |
| 15414 | } |
| 15415 | } |
| 15416 | } |
| 15417 | get containerTopLeft() { |
| 15418 | return this.#containerTopLeft ||= [this.container.offsetTop, this.container.offsetLeft]; |
| 15419 | } |
| 15420 | get annotationEditorMode() { |
| 15421 | return this.#annotationEditorUIManager ? this.#annotationEditorMode : AnnotationEditorType.DISABLE; |
| 15422 | } |
| 15423 | set annotationEditorMode({ |
| 15424 | mode, |
| 15425 | editId = null, |
| 15426 | isFromKeyboard = false |
| 15427 | }) { |
| 15428 | if (!this.#annotationEditorUIManager) { |
| 15429 | throw new Error(`The AnnotationEditor is not enabled.`); |
| 15430 | } |
| 15431 | if (this.#annotationEditorMode === mode) { |
| 15432 | return; |
| 15433 | } |
| 15434 | if (!isValidAnnotationEditorMode(mode)) { |
| 15435 | throw new Error(`Invalid AnnotationEditor mode: ${mode}`); |
| 15436 | } |
| 15437 | if (!this.pdfDocument) { |
| 15438 | return; |
| 15439 | } |
| 15440 | this.#annotationEditorMode = mode; |
| 15441 | this.eventBus.dispatch("annotationeditormodechanged", { |
| 15442 | source: this, |
| 15443 | mode |
| 15444 | }); |
| 15445 | this.#annotationEditorUIManager.updateMode(mode, editId, isFromKeyboard); |
| 15446 | } |
| 15447 | set annotationEditorParams({ |
| 15448 | type, |
| 15449 | value |
| 15450 | }) { |
| 15451 | if (!this.#annotationEditorUIManager) { |
| 15452 | throw new Error(`The AnnotationEditor is not enabled.`); |
| 15453 | } |
| 15454 | this.#annotationEditorUIManager.updateParams(type, value); |
| 15455 | } |
| 15456 | refresh(noUpdate = false, updateArgs = Object.create(null)) { |
| 15457 | if (!this.pdfDocument) { |
| 15458 | return; |
| 15459 | } |
| 15460 | for (const pageView of this._pages) { |
| 15461 | pageView.update(updateArgs); |
| 15462 | } |
| 15463 | if (this.#scaleTimeoutId !== null) { |
| 15464 | clearTimeout(this.#scaleTimeoutId); |
| 15465 | this.#scaleTimeoutId = null; |
| 15466 | } |
| 15467 | if (!noUpdate) { |
| 15468 | this.update(); |
| 15469 | } |
| 15470 | } |
| 15471 | } |
| 15472 | |
| 15473 | ;// CONCATENATED MODULE: ./web/secondary_toolbar.js |
| 15474 | |
| 15475 | |
| 15476 | |
| 15477 | class SecondaryToolbar { |
| 15478 | #opts; |
| 15479 | constructor(options, eventBus) { |
| 15480 | this.#opts = options; |
| 15481 | const buttons = [{ |
| 15482 | element: options.presentationModeButton, |
| 15483 | eventName: "presentationmode", |
| 15484 | close: true |
| 15485 | }, { |
| 15486 | element: options.printButton, |
| 15487 | eventName: "print", |
| 15488 | close: true |
| 15489 | }, { |
| 15490 | element: options.downloadButton, |
| 15491 | eventName: "download", |
| 15492 | close: true |
| 15493 | }, { |
| 15494 | element: options.viewBookmarkButton, |
| 15495 | eventName: null, |
| 15496 | close: true |
| 15497 | }, { |
| 15498 | element: options.firstPageButton, |
| 15499 | eventName: "firstpage", |
| 15500 | close: true |
| 15501 | }, { |
| 15502 | element: options.lastPageButton, |
| 15503 | eventName: "lastpage", |
| 15504 | close: true |
| 15505 | }, { |
| 15506 | element: options.pageRotateCwButton, |
| 15507 | eventName: "rotatecw", |
| 15508 | close: false |
| 15509 | }, { |
| 15510 | element: options.pageRotateCcwButton, |
| 15511 | eventName: "rotateccw", |
| 15512 | close: false |
| 15513 | }, { |
| 15514 | element: options.cursorSelectToolButton, |
| 15515 | eventName: "switchcursortool", |
| 15516 | eventDetails: { |
| 15517 | tool: CursorTool.SELECT |
| 15518 | }, |
| 15519 | close: true |
| 15520 | }, { |
| 15521 | element: options.cursorHandToolButton, |
| 15522 | eventName: "switchcursortool", |
| 15523 | eventDetails: { |
| 15524 | tool: CursorTool.HAND |
| 15525 | }, |
| 15526 | close: true |
| 15527 | }, { |
| 15528 | element: options.scrollPageButton, |
| 15529 | eventName: "switchscrollmode", |
| 15530 | eventDetails: { |
| 15531 | mode: ScrollMode.PAGE |
| 15532 | }, |
| 15533 | close: true |
| 15534 | }, { |
| 15535 | element: options.scrollVerticalButton, |
| 15536 | eventName: "switchscrollmode", |
| 15537 | eventDetails: { |
| 15538 | mode: ScrollMode.VERTICAL |
| 15539 | }, |
| 15540 | close: true |
| 15541 | }, { |
| 15542 | element: options.scrollHorizontalButton, |
| 15543 | eventName: "switchscrollmode", |
| 15544 | eventDetails: { |
| 15545 | mode: ScrollMode.HORIZONTAL |
| 15546 | }, |
| 15547 | close: true |
| 15548 | }, { |
| 15549 | element: options.scrollWrappedButton, |
| 15550 | eventName: "switchscrollmode", |
| 15551 | eventDetails: { |
| 15552 | mode: ScrollMode.WRAPPED |
| 15553 | }, |
| 15554 | close: true |
| 15555 | }, { |
| 15556 | element: options.spreadNoneButton, |
| 15557 | eventName: "switchspreadmode", |
| 15558 | eventDetails: { |
| 15559 | mode: SpreadMode.NONE |
| 15560 | }, |
| 15561 | close: true |
| 15562 | }, { |
| 15563 | element: options.spreadOddButton, |
| 15564 | eventName: "switchspreadmode", |
| 15565 | eventDetails: { |
| 15566 | mode: SpreadMode.ODD |
| 15567 | }, |
| 15568 | close: true |
| 15569 | }, { |
| 15570 | element: options.spreadEvenButton, |
| 15571 | eventName: "switchspreadmode", |
| 15572 | eventDetails: { |
| 15573 | mode: SpreadMode.EVEN |
| 15574 | }, |
| 15575 | close: true |
| 15576 | }, { |
| 15577 | element: options.documentPropertiesButton, |
| 15578 | eventName: "documentproperties", |
| 15579 | close: true |
| 15580 | }]; |
| 15581 | buttons.push({ |
| 15582 | element: options.openFileButton, |
| 15583 | eventName: "openfile", |
| 15584 | close: true |
| 15585 | }); |
| 15586 | this.eventBus = eventBus; |
| 15587 | this.opened = false; |
| 15588 | this.#bindListeners(buttons); |
| 15589 | this.reset(); |
| 15590 | } |
| 15591 | get isOpen() { |
| 15592 | return this.opened; |
| 15593 | } |
| 15594 | setPageNumber(pageNumber) { |
| 15595 | this.pageNumber = pageNumber; |
| 15596 | this.#updateUIState(); |
| 15597 | } |
| 15598 | setPagesCount(pagesCount) { |
| 15599 | this.pagesCount = pagesCount; |
| 15600 | this.#updateUIState(); |
| 15601 | } |
| 15602 | reset() { |
| 15603 | this.pageNumber = 0; |
| 15604 | this.pagesCount = 0; |
| 15605 | this.#updateUIState(); |
| 15606 | this.eventBus.dispatch("switchcursortool", { |
| 15607 | source: this, |
| 15608 | reset: true |
| 15609 | }); |
| 15610 | this.#scrollModeChanged({ |
| 15611 | mode: ScrollMode.VERTICAL |
| 15612 | }); |
| 15613 | this.#spreadModeChanged({ |
| 15614 | mode: SpreadMode.NONE |
| 15615 | }); |
| 15616 | } |
| 15617 | #updateUIState() { |
| 15618 | const { |
| 15619 | firstPageButton, |
| 15620 | lastPageButton, |
| 15621 | pageRotateCwButton, |
| 15622 | pageRotateCcwButton |
| 15623 | } = this.#opts; |
| 15624 | firstPageButton.disabled = this.pageNumber <= 1; |
| 15625 | lastPageButton.disabled = this.pageNumber >= this.pagesCount; |
| 15626 | pageRotateCwButton.disabled = this.pagesCount === 0; |
| 15627 | pageRotateCcwButton.disabled = this.pagesCount === 0; |
| 15628 | } |
| 15629 | #bindListeners(buttons) { |
| 15630 | const { |
| 15631 | eventBus |
| 15632 | } = this; |
| 15633 | const { |
| 15634 | toggleButton |
| 15635 | } = this.#opts; |
| 15636 | toggleButton.addEventListener("click", this.toggle.bind(this)); |
| 15637 | for (const { |
| 15638 | element, |
| 15639 | eventName, |
| 15640 | close, |
| 15641 | eventDetails |
| 15642 | } of buttons) { |
| 15643 | element.addEventListener("click", evt => { |
| 15644 | if (eventName !== null) { |
| 15645 | eventBus.dispatch(eventName, { |
| 15646 | source: this, |
| 15647 | ...eventDetails |
| 15648 | }); |
| 15649 | } |
| 15650 | if (close) { |
| 15651 | this.close(); |
| 15652 | } |
| 15653 | eventBus.dispatch("reporttelemetry", { |
| 15654 | source: this, |
| 15655 | details: { |
| 15656 | type: "buttons", |
| 15657 | data: { |
| 15658 | id: element.id |
| 15659 | } |
| 15660 | } |
| 15661 | }); |
| 15662 | }); |
| 15663 | } |
| 15664 | eventBus._on("cursortoolchanged", this.#cursorToolChanged.bind(this)); |
| 15665 | eventBus._on("scrollmodechanged", this.#scrollModeChanged.bind(this)); |
| 15666 | eventBus._on("spreadmodechanged", this.#spreadModeChanged.bind(this)); |
| 15667 | } |
| 15668 | #cursorToolChanged({ |
| 15669 | tool |
| 15670 | }) { |
| 15671 | const { |
| 15672 | cursorSelectToolButton, |
| 15673 | cursorHandToolButton |
| 15674 | } = this.#opts; |
| 15675 | toggleCheckedBtn(cursorSelectToolButton, tool === CursorTool.SELECT); |
| 15676 | toggleCheckedBtn(cursorHandToolButton, tool === CursorTool.HAND); |
| 15677 | } |
| 15678 | #scrollModeChanged({ |
| 15679 | mode |
| 15680 | }) { |
| 15681 | const { |
| 15682 | scrollPageButton, |
| 15683 | scrollVerticalButton, |
| 15684 | scrollHorizontalButton, |
| 15685 | scrollWrappedButton, |
| 15686 | spreadNoneButton, |
| 15687 | spreadOddButton, |
| 15688 | spreadEvenButton |
| 15689 | } = this.#opts; |
| 15690 | toggleCheckedBtn(scrollPageButton, mode === ScrollMode.PAGE); |
| 15691 | toggleCheckedBtn(scrollVerticalButton, mode === ScrollMode.VERTICAL); |
| 15692 | toggleCheckedBtn(scrollHorizontalButton, mode === ScrollMode.HORIZONTAL); |
| 15693 | toggleCheckedBtn(scrollWrappedButton, mode === ScrollMode.WRAPPED); |
| 15694 | const forceScrollModePage = this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE; |
| 15695 | scrollPageButton.disabled = forceScrollModePage; |
| 15696 | scrollVerticalButton.disabled = forceScrollModePage; |
| 15697 | scrollHorizontalButton.disabled = forceScrollModePage; |
| 15698 | scrollWrappedButton.disabled = forceScrollModePage; |
| 15699 | const isHorizontal = mode === ScrollMode.HORIZONTAL; |
| 15700 | spreadNoneButton.disabled = isHorizontal; |
| 15701 | spreadOddButton.disabled = isHorizontal; |
| 15702 | spreadEvenButton.disabled = isHorizontal; |
| 15703 | } |
| 15704 | #spreadModeChanged({ |
| 15705 | mode |
| 15706 | }) { |
| 15707 | const { |
| 15708 | spreadNoneButton, |
| 15709 | spreadOddButton, |
| 15710 | spreadEvenButton |
| 15711 | } = this.#opts; |
| 15712 | toggleCheckedBtn(spreadNoneButton, mode === SpreadMode.NONE); |
| 15713 | toggleCheckedBtn(spreadOddButton, mode === SpreadMode.ODD); |
| 15714 | toggleCheckedBtn(spreadEvenButton, mode === SpreadMode.EVEN); |
| 15715 | } |
| 15716 | open() { |
| 15717 | if (this.opened) { |
| 15718 | return; |
| 15719 | } |
| 15720 | this.opened = true; |
| 15721 | const { |
| 15722 | toggleButton, |
| 15723 | toolbar |
| 15724 | } = this.#opts; |
| 15725 | toggleExpandedBtn(toggleButton, true, toolbar); |
| 15726 | } |
| 15727 | close() { |
| 15728 | if (!this.opened) { |
| 15729 | return; |
| 15730 | } |
| 15731 | this.opened = false; |
| 15732 | const { |
| 15733 | toggleButton, |
| 15734 | toolbar |
| 15735 | } = this.#opts; |
| 15736 | toggleExpandedBtn(toggleButton, false, toolbar); |
| 15737 | } |
| 15738 | toggle() { |
| 15739 | if (this.opened) { |
| 15740 | this.close(); |
| 15741 | } else { |
| 15742 | this.open(); |
| 15743 | } |
| 15744 | } |
| 15745 | } |
| 15746 | |
| 15747 | ;// CONCATENATED MODULE: ./web/toolbar.js |
| 15748 | |
| 15749 | |
| 15750 | class Toolbar { |
| 15751 | #opts; |
| 15752 | constructor(options, eventBus) { |
| 15753 | this.#opts = options; |
| 15754 | this.eventBus = eventBus; |
| 15755 | const buttons = [{ |
| 15756 | element: options.previous, |
| 15757 | eventName: "previouspage" |
| 15758 | }, { |
| 15759 | element: options.next, |
| 15760 | eventName: "nextpage" |
| 15761 | }, { |
| 15762 | element: options.zoomIn, |
| 15763 | eventName: "zoomin" |
| 15764 | }, { |
| 15765 | element: options.zoomOut, |
| 15766 | eventName: "zoomout" |
| 15767 | }, { |
| 15768 | element: options.print, |
| 15769 | eventName: "print" |
| 15770 | }, { |
| 15771 | element: options.download, |
| 15772 | eventName: "download" |
| 15773 | }, { |
| 15774 | element: options.editorFreeTextButton, |
| 15775 | eventName: "switchannotationeditormode", |
| 15776 | eventDetails: { |
| 15777 | get mode() { |
| 15778 | const { |
| 15779 | classList |
| 15780 | } = options.editorFreeTextButton; |
| 15781 | return classList.contains("toggled") ? AnnotationEditorType.NONE : AnnotationEditorType.FREETEXT; |
| 15782 | } |
| 15783 | } |
| 15784 | }, { |
| 15785 | element: options.editorHighlightButton, |
| 15786 | eventName: "switchannotationeditormode", |
| 15787 | eventDetails: { |
| 15788 | get mode() { |
| 15789 | const { |
| 15790 | classList |
| 15791 | } = options.editorHighlightButton; |
| 15792 | return classList.contains("toggled") ? AnnotationEditorType.NONE : AnnotationEditorType.HIGHLIGHT; |
| 15793 | } |
| 15794 | } |
| 15795 | }, { |
| 15796 | element: options.editorInkButton, |
| 15797 | eventName: "switchannotationeditormode", |
| 15798 | eventDetails: { |
| 15799 | get mode() { |
| 15800 | const { |
| 15801 | classList |
| 15802 | } = options.editorInkButton; |
| 15803 | return classList.contains("toggled") ? AnnotationEditorType.NONE : AnnotationEditorType.INK; |
| 15804 | } |
| 15805 | } |
| 15806 | }, { |
| 15807 | element: options.editorStampButton, |
| 15808 | eventName: "switchannotationeditormode", |
| 15809 | eventDetails: { |
| 15810 | get mode() { |
| 15811 | const { |
| 15812 | classList |
| 15813 | } = options.editorStampButton; |
| 15814 | return classList.contains("toggled") ? AnnotationEditorType.NONE : AnnotationEditorType.STAMP; |
| 15815 | } |
| 15816 | } |
| 15817 | }]; |
| 15818 | this.#bindListeners(buttons); |
| 15819 | if (options.editorHighlightColorPicker) { |
| 15820 | eventBus._on("annotationeditoruimanager", ({ |
| 15821 | uiManager |
| 15822 | }) => { |
| 15823 | this.#setAnnotationEditorUIManager(uiManager, options.editorHighlightColorPicker); |
| 15824 | }, { |
| 15825 | once: true |
| 15826 | }); |
| 15827 | } |
| 15828 | eventBus._on("showannotationeditorui", ({ |
| 15829 | mode |
| 15830 | }) => { |
| 15831 | switch (mode) { |
| 15832 | case AnnotationEditorType.HIGHLIGHT: |
| 15833 | options.editorHighlightButton.click(); |
| 15834 | break; |
| 15835 | } |
| 15836 | }); |
| 15837 | this.reset(); |
| 15838 | } |
| 15839 | #setAnnotationEditorUIManager(uiManager, parentContainer) { |
| 15840 | const colorPicker = new ColorPicker({ |
| 15841 | uiManager |
| 15842 | }); |
| 15843 | uiManager.setMainHighlightColorPicker(colorPicker); |
| 15844 | parentContainer.append(colorPicker.renderMainDropdown()); |
| 15845 | } |
| 15846 | setPageNumber(pageNumber, pageLabel) { |
| 15847 | this.pageNumber = pageNumber; |
| 15848 | this.pageLabel = pageLabel; |
| 15849 | this.#updateUIState(false); |
| 15850 | } |
| 15851 | setPagesCount(pagesCount, hasPageLabels) { |
| 15852 | this.pagesCount = pagesCount; |
| 15853 | this.hasPageLabels = hasPageLabels; |
| 15854 | this.#updateUIState(true); |
| 15855 | } |
| 15856 | setPageScale(pageScaleValue, pageScale) { |
| 15857 | this.pageScaleValue = (pageScaleValue || pageScale).toString(); |
| 15858 | this.pageScale = pageScale; |
| 15859 | this.#updateUIState(false); |
| 15860 | } |
| 15861 | reset() { |
| 15862 | this.pageNumber = 0; |
| 15863 | this.pageLabel = null; |
| 15864 | this.hasPageLabels = false; |
| 15865 | this.pagesCount = 0; |
| 15866 | this.pageScaleValue = DEFAULT_SCALE_VALUE; |
| 15867 | this.pageScale = DEFAULT_SCALE; |
| 15868 | this.#updateUIState(true); |
| 15869 | this.updateLoadingIndicatorState(); |
| 15870 | this.#editorModeChanged({ |
| 15871 | mode: AnnotationEditorType.DISABLE |
| 15872 | }); |
| 15873 | } |
| 15874 | #bindListeners(buttons) { |
| 15875 | const { |
| 15876 | eventBus |
| 15877 | } = this; |
| 15878 | const { |
| 15879 | pageNumber, |
| 15880 | scaleSelect |
| 15881 | } = this.#opts; |
| 15882 | const self = this; |
| 15883 | for (const { |
| 15884 | element, |
| 15885 | eventName, |
| 15886 | eventDetails |
| 15887 | } of buttons) { |
| 15888 | element.addEventListener("click", evt => { |
| 15889 | if (eventName !== null) { |
| 15890 | eventBus.dispatch(eventName, { |
| 15891 | source: this, |
| 15892 | ...eventDetails, |
| 15893 | isFromKeyboard: evt.detail === 0 |
| 15894 | }); |
| 15895 | } |
| 15896 | }); |
| 15897 | } |
| 15898 | pageNumber.addEventListener("click", function () { |
| 15899 | this.select(); |
| 15900 | }); |
| 15901 | pageNumber.addEventListener("change", function () { |
| 15902 | eventBus.dispatch("pagenumberchanged", { |
| 15903 | source: self, |
| 15904 | value: this.value |
| 15905 | }); |
| 15906 | }); |
| 15907 | scaleSelect.addEventListener("change", function () { |
| 15908 | if (this.value === "custom") { |
| 15909 | return; |
| 15910 | } |
| 15911 | eventBus.dispatch("scalechanged", { |
| 15912 | source: self, |
| 15913 | value: this.value |
| 15914 | }); |
| 15915 | }); |
| 15916 | scaleSelect.addEventListener("click", function ({ |
| 15917 | target |
| 15918 | }) { |
| 15919 | if (this.value === self.pageScaleValue && target.tagName.toUpperCase() === "OPTION") { |
| 15920 | this.blur(); |
| 15921 | } |
| 15922 | }); |
| 15923 | scaleSelect.oncontextmenu = noContextMenu; |
| 15924 | eventBus._on("annotationeditormodechanged", this.#editorModeChanged.bind(this)); |
| 15925 | } |
| 15926 | #editorModeChanged({ |
| 15927 | mode |
| 15928 | }) { |
| 15929 | const { |
| 15930 | editorFreeTextButton, |
| 15931 | editorFreeTextParamsToolbar, |
| 15932 | editorHighlightButton, |
| 15933 | editorHighlightParamsToolbar, |
| 15934 | editorInkButton, |
| 15935 | editorInkParamsToolbar, |
| 15936 | editorStampButton, |
| 15937 | editorStampParamsToolbar |
| 15938 | } = this.#opts; |
| 15939 | toggleCheckedBtn(editorFreeTextButton, mode === AnnotationEditorType.FREETEXT, editorFreeTextParamsToolbar); |
| 15940 | toggleCheckedBtn(editorHighlightButton, mode === AnnotationEditorType.HIGHLIGHT, editorHighlightParamsToolbar); |
| 15941 | toggleCheckedBtn(editorInkButton, mode === AnnotationEditorType.INK, editorInkParamsToolbar); |
| 15942 | toggleCheckedBtn(editorStampButton, mode === AnnotationEditorType.STAMP, editorStampParamsToolbar); |
| 15943 | const isDisable = mode === AnnotationEditorType.DISABLE; |
| 15944 | editorFreeTextButton.disabled = isDisable; |
| 15945 | editorHighlightButton.disabled = isDisable; |
| 15946 | editorInkButton.disabled = isDisable; |
| 15947 | editorStampButton.disabled = isDisable; |
| 15948 | } |
| 15949 | #updateUIState(resetNumPages = false) { |
| 15950 | const { |
| 15951 | pageNumber, |
| 15952 | pagesCount, |
| 15953 | pageScaleValue, |
| 15954 | pageScale |
| 15955 | } = this; |
| 15956 | const opts = this.#opts; |
| 15957 | if (resetNumPages) { |
| 15958 | if (this.hasPageLabels) { |
| 15959 | opts.pageNumber.type = "text"; |
| 15960 | opts.numPages.setAttribute("data-l10n-id", "pdfjs-page-of-pages"); |
| 15961 | } else { |
| 15962 | opts.pageNumber.type = "number"; |
| 15963 | opts.numPages.setAttribute("data-l10n-id", "pdfjs-of-pages"); |
| 15964 | opts.numPages.setAttribute("data-l10n-args", JSON.stringify({ |
| 15965 | pagesCount |
| 15966 | })); |
| 15967 | } |
| 15968 | opts.pageNumber.max = pagesCount; |
| 15969 | } |
| 15970 | if (this.hasPageLabels) { |
| 15971 | opts.pageNumber.value = this.pageLabel; |
| 15972 | opts.numPages.setAttribute("data-l10n-args", JSON.stringify({ |
| 15973 | pageNumber, |
| 15974 | pagesCount |
| 15975 | })); |
| 15976 | } else { |
| 15977 | opts.pageNumber.value = pageNumber; |
| 15978 | } |
| 15979 | opts.previous.disabled = pageNumber <= 1; |
| 15980 | opts.next.disabled = pageNumber >= pagesCount; |
| 15981 | opts.zoomOut.disabled = pageScale <= MIN_SCALE; |
| 15982 | opts.zoomIn.disabled = pageScale >= MAX_SCALE; |
| 15983 | let predefinedValueFound = false; |
| 15984 | for (const option of opts.scaleSelect.options) { |
| 15985 | if (option.value !== pageScaleValue) { |
| 15986 | option.selected = false; |
| 15987 | continue; |
| 15988 | } |
| 15989 | option.selected = true; |
| 15990 | predefinedValueFound = true; |
| 15991 | } |
| 15992 | if (!predefinedValueFound) { |
| 15993 | opts.customScaleOption.selected = true; |
| 15994 | opts.customScaleOption.setAttribute("data-l10n-args", JSON.stringify({ |
| 15995 | scale: Math.round(pageScale * 10000) / 100 |
| 15996 | })); |
| 15997 | } |
| 15998 | } |
| 15999 | updateLoadingIndicatorState(loading = false) { |
| 16000 | const { |
| 16001 | pageNumber |
| 16002 | } = this.#opts; |
| 16003 | pageNumber.classList.toggle("loading", loading); |
| 16004 | } |
| 16005 | } |
| 16006 | |
| 16007 | ;// CONCATENATED MODULE: ./web/view_history.js |
| 16008 | |
| 16009 | |
| 16010 | const DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20; |
| 16011 | class ViewHistory { |
| 16012 | constructor(fingerprint, cacheSize = DEFAULT_VIEW_HISTORY_CACHE_SIZE) { |
| 16013 | this.fingerprint = fingerprint; |
| 16014 | this.cacheSize = cacheSize; |
| 16015 | this._initializedPromise = this._readFromStorage().then(databaseStr => { |
| 16016 | const database = JSON.parse(databaseStr || "{}"); |
| 16017 | let index = -1; |
| 16018 | if (!Array.isArray(database.files)) { |
| 16019 | database.files = []; |
| 16020 | } else { |
| 16021 | while (database.files.length >= this.cacheSize) { |
| 16022 | database.files.shift(); |
| 16023 | } |
| 16024 | for (let i = 0, ii = database.files.length; i < ii; i++) { |
| 16025 | const branch = database.files[i]; |
| 16026 | if (branch.fingerprint === this.fingerprint) { |
| 16027 | index = i; |
| 16028 | break; |
| 16029 | } |
| 16030 | } |
| 16031 | } |
| 16032 | if (index === -1) { |
| 16033 | index = database.files.push({ |
| 16034 | fingerprint: this.fingerprint |
| 16035 | }) - 1; |
| 16036 | } |
| 16037 | this.file = database.files[index]; |
| 16038 | this.database = database; |
| 16039 | }); |
| 16040 | } |
| 16041 | async _writeToStorage() { |
| 16042 | const databaseStr = JSON.stringify(this.database); |
| 16043 | localStorage.setItem("pdfjs.history", databaseStr); |
| 16044 | } |
| 16045 | async _readFromStorage() { |
| 16046 | return localStorage.getItem("pdfjs.history"); |
| 16047 | } |
| 16048 | async set(name, val) { |
| 16049 | await this._initializedPromise; |
| 16050 | this.file[name] = val; |
| 16051 | return this._writeToStorage(); |
| 16052 | } |
| 16053 | async setMultiple(properties) { |
| 16054 | await this._initializedPromise; |
| 16055 | for (const name in properties) { |
| 16056 | this.file[name] = properties[name]; |
| 16057 | } |
| 16058 | return this._writeToStorage(); |
| 16059 | } |
| 16060 | async get(name, defaultValue) { |
| 16061 | await this._initializedPromise; |
| 16062 | const val = this.file[name]; |
| 16063 | return val !== undefined ? val : defaultValue; |
| 16064 | } |
| 16065 | async getMultiple(properties) { |
| 16066 | await this._initializedPromise; |
| 16067 | const values = Object.create(null); |
| 16068 | for (const name in properties) { |
| 16069 | const val = this.file[name]; |
| 16070 | values[name] = val !== undefined ? val : properties[name]; |
| 16071 | } |
| 16072 | return values; |
| 16073 | } |
| 16074 | } |
| 16075 | |
| 16076 | ;// CONCATENATED MODULE: ./web/app.js |
| 16077 | |
| 16078 | |
| 16079 | |
| 16080 | |
| 16081 | |
| 16082 | |
| 16083 | |
| 16084 | |
| 16085 | |
| 16086 | |
| 16087 | |
| 16088 | |
| 16089 | |
| 16090 | |
| 16091 | |
| 16092 | |
| 16093 | |
| 16094 | |
| 16095 | |
| 16096 | |
| 16097 | |
| 16098 | |
| 16099 | |
| 16100 | |
| 16101 | |
| 16102 | |
| 16103 | |
| 16104 | |
| 16105 | |
| 16106 | |
| 16107 | |
| 16108 | |
| 16109 | |
| 16110 | |
| 16111 | |
| 16112 | |
| 16113 | |
| 16114 | |
| 16115 | const FORCE_PAGES_LOADED_TIMEOUT = 10000; |
| 16116 | const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000; |
| 16117 | const ViewOnLoad = { |
| 16118 | UNKNOWN: -1, |
| 16119 | PREVIOUS: 0, |
| 16120 | INITIAL: 1 |
| 16121 | }; |
| 16122 | const PDFViewerApplication = { |
| 16123 | initialBookmark: document.location.hash.substring(1), |
| 16124 | _initializedCapability: { |
| 16125 | ...Promise.withResolvers(), |
| 16126 | settled: false |
| 16127 | }, |
| 16128 | appConfig: null, |
| 16129 | pdfDocument: null, |
| 16130 | pdfLoadingTask: null, |
| 16131 | printService: null, |
| 16132 | pdfViewer: null, |
| 16133 | pdfThumbnailViewer: null, |
| 16134 | pdfRenderingQueue: null, |
| 16135 | pdfPresentationMode: null, |
| 16136 | pdfDocumentProperties: null, |
| 16137 | pdfLinkService: null, |
| 16138 | pdfHistory: null, |
| 16139 | pdfSidebar: null, |
| 16140 | pdfOutlineViewer: null, |
| 16141 | pdfAttachmentViewer: null, |
| 16142 | pdfLayerViewer: null, |
| 16143 | pdfCursorTools: null, |
| 16144 | pdfScriptingManager: null, |
| 16145 | store: null, |
| 16146 | downloadManager: null, |
| 16147 | overlayManager: null, |
| 16148 | preferences: null, |
| 16149 | toolbar: null, |
| 16150 | secondaryToolbar: null, |
| 16151 | eventBus: null, |
| 16152 | l10n: null, |
| 16153 | annotationEditorParams: null, |
| 16154 | isInitialViewSet: false, |
| 16155 | downloadComplete: false, |
| 16156 | isViewerEmbedded: window.parent !== window, |
| 16157 | url: "", |
| 16158 | baseUrl: "", |
| 16159 | _downloadUrl: "", |
| 16160 | _eventBusAbortController: null, |
| 16161 | _windowAbortController: null, |
| 16162 | documentInfo: null, |
| 16163 | metadata: null, |
| 16164 | _contentDispositionFilename: null, |
| 16165 | _contentLength: null, |
| 16166 | _saveInProgress: false, |
| 16167 | _wheelUnusedTicks: 0, |
| 16168 | _wheelUnusedFactor: 1, |
| 16169 | _touchUnusedTicks: 0, |
| 16170 | _touchUnusedFactor: 1, |
| 16171 | _PDFBug: null, |
| 16172 | _hasAnnotationEditors: false, |
| 16173 | _title: document.title, |
| 16174 | _printAnnotationStoragePromise: null, |
| 16175 | _touchInfo: null, |
| 16176 | _isCtrlKeyDown: false, |
| 16177 | _nimbusDataPromise: null, |
| 16178 | _caretBrowsing: null, |
| 16179 | _isScrolling: false, |
| 16180 | async initialize(appConfig) { |
| 16181 | let l10nPromise; |
| 16182 | this.appConfig = appConfig; |
| 16183 | try { |
| 16184 | await this.preferences.initializedPromise; |
| 16185 | } catch (ex) { |
| 16186 | console.error(`initialize: "${ex.message}".`); |
| 16187 | } |
| 16188 | if (AppOptions.get("pdfBugEnabled")) { |
| 16189 | await this._parseHashParams(); |
| 16190 | } |
| 16191 | let mode; |
| 16192 | switch (AppOptions.get("viewerCssTheme")) { |
| 16193 | case 1: |
| 16194 | mode = "is-light"; |
| 16195 | break; |
| 16196 | case 2: |
| 16197 | mode = "is-dark"; |
| 16198 | break; |
| 16199 | } |
| 16200 | if (mode) { |
| 16201 | document.documentElement.classList.add(mode); |
| 16202 | } |
| 16203 | l10nPromise = this.externalServices.createL10n(); |
| 16204 | this.l10n = await l10nPromise; |
| 16205 | document.getElementsByTagName("html")[0].dir = this.l10n.getDirection(); |
| 16206 | this.l10n.translate(appConfig.appContainer || document.documentElement); |
| 16207 | if (this.isViewerEmbedded && AppOptions.get("externalLinkTarget") === LinkTarget.NONE) { |
| 16208 | AppOptions.set("externalLinkTarget", LinkTarget.TOP); |
| 16209 | } |
| 16210 | await this._initializeViewerComponents(); |
| 16211 | this.bindEvents(); |
| 16212 | this.bindWindowEvents(); |
| 16213 | this._initializedCapability.settled = true; |
| 16214 | this._initializedCapability.resolve(); |
| 16215 | }, |
| 16216 | async _parseHashParams() { |
| 16217 | const hash = document.location.hash.substring(1); |
| 16218 | if (!hash) { |
| 16219 | return; |
| 16220 | } |
| 16221 | const { |
| 16222 | mainContainer, |
| 16223 | viewerContainer |
| 16224 | } = this.appConfig, |
| 16225 | params = parseQueryString(hash); |
| 16226 | const loadPDFBug = async () => { |
| 16227 | if (this._PDFBug) { |
| 16228 | return; |
| 16229 | } |
| 16230 | const { |
| 16231 | PDFBug |
| 16232 | } = await import( /*webpackIgnore: true*/AppOptions.get("debuggerSrc")); |
| 16233 | this._PDFBug = PDFBug; |
| 16234 | }; |
| 16235 | if (params.get("disableworker") === "true") { |
| 16236 | try { |
| 16237 | GlobalWorkerOptions.workerSrc ||= AppOptions.get("workerSrc"); |
| 16238 | await import( /*webpackIgnore: true*/PDFWorker.workerSrc); |
| 16239 | } catch (ex) { |
| 16240 | console.error(`_parseHashParams: "${ex.message}".`); |
| 16241 | } |
| 16242 | } |
| 16243 | if (params.has("disablerange")) { |
| 16244 | AppOptions.set("disableRange", params.get("disablerange") === "true"); |
| 16245 | } |
| 16246 | if (params.has("disablestream")) { |
| 16247 | AppOptions.set("disableStream", params.get("disablestream") === "true"); |
| 16248 | } |
| 16249 | if (params.has("disableautofetch")) { |
| 16250 | AppOptions.set("disableAutoFetch", params.get("disableautofetch") === "true"); |
| 16251 | } |
| 16252 | if (params.has("disablefontface")) { |
| 16253 | AppOptions.set("disableFontFace", params.get("disablefontface") === "true"); |
| 16254 | } |
| 16255 | if (params.has("disablehistory")) { |
| 16256 | AppOptions.set("disableHistory", params.get("disablehistory") === "true"); |
| 16257 | } |
| 16258 | if (params.has("verbosity")) { |
| 16259 | AppOptions.set("verbosity", params.get("verbosity") | 0); |
| 16260 | } |
| 16261 | if (params.has("textlayer")) { |
| 16262 | switch (params.get("textlayer")) { |
| 16263 | case "off": |
| 16264 | AppOptions.set("textLayerMode", TextLayerMode.DISABLE); |
| 16265 | break; |
| 16266 | case "visible": |
| 16267 | case "shadow": |
| 16268 | case "hover": |
| 16269 | viewerContainer.classList.add(`textLayer-${params.get("textlayer")}`); |
| 16270 | try { |
| 16271 | await loadPDFBug(); |
| 16272 | this._PDFBug.loadCSS(); |
| 16273 | } catch (ex) { |
| 16274 | console.error(`_parseHashParams: "${ex.message}".`); |
| 16275 | } |
| 16276 | break; |
| 16277 | } |
| 16278 | } |
| 16279 | if (params.has("pdfbug")) { |
| 16280 | AppOptions.setAll({ |
| 16281 | pdfBug: true, |
| 16282 | fontExtraProperties: true |
| 16283 | }); |
| 16284 | const enabled = params.get("pdfbug").split(","); |
| 16285 | try { |
| 16286 | await loadPDFBug(); |
| 16287 | this._PDFBug.init(mainContainer, enabled); |
| 16288 | } catch (ex) { |
| 16289 | console.error(`_parseHashParams: "${ex.message}".`); |
| 16290 | } |
| 16291 | } |
| 16292 | if (params.has("locale")) { |
| 16293 | AppOptions.set("locale", params.get("locale")); |
| 16294 | } |
| 16295 | }, |
| 16296 | async _initializeViewerComponents() { |
| 16297 | const { |
| 16298 | appConfig, |
| 16299 | externalServices, |
| 16300 | l10n |
| 16301 | } = this; |
| 16302 | const eventBus = AppOptions.get("isInAutomation") ? new AutomationEventBus() : new EventBus(); |
| 16303 | this.eventBus = eventBus; |
| 16304 | this.overlayManager = new OverlayManager(); |
| 16305 | const pdfRenderingQueue = new PDFRenderingQueue(); |
| 16306 | pdfRenderingQueue.onIdle = this._cleanup.bind(this); |
| 16307 | this.pdfRenderingQueue = pdfRenderingQueue; |
| 16308 | const pdfLinkService = new PDFLinkService({ |
| 16309 | eventBus, |
| 16310 | externalLinkTarget: AppOptions.get("externalLinkTarget"), |
| 16311 | externalLinkRel: AppOptions.get("externalLinkRel"), |
| 16312 | ignoreDestinationZoom: AppOptions.get("ignoreDestinationZoom") |
| 16313 | }); |
| 16314 | this.pdfLinkService = pdfLinkService; |
| 16315 | const downloadManager = this.downloadManager = new DownloadManager(); |
| 16316 | const findController = new PDFFindController({ |
| 16317 | linkService: pdfLinkService, |
| 16318 | eventBus, |
| 16319 | updateMatchesCountOnProgress: true |
| 16320 | }); |
| 16321 | this.findController = findController; |
| 16322 | const pdfScriptingManager = new PDFScriptingManager({ |
| 16323 | eventBus, |
| 16324 | externalServices, |
| 16325 | docProperties: this._scriptingDocProperties.bind(this) |
| 16326 | }); |
| 16327 | this.pdfScriptingManager = pdfScriptingManager; |
| 16328 | const container = appConfig.mainContainer, |
| 16329 | viewer = appConfig.viewerContainer; |
| 16330 | const annotationEditorMode = AppOptions.get("annotationEditorMode"); |
| 16331 | const pageColors = AppOptions.get("forcePageColors") || window.matchMedia("(forced-colors: active)").matches ? { |
| 16332 | background: AppOptions.get("pageColorsBackground"), |
| 16333 | foreground: AppOptions.get("pageColorsForeground") |
| 16334 | } : null; |
| 16335 | const altTextManager = appConfig.altTextDialog ? new AltTextManager(appConfig.altTextDialog, container, this.overlayManager, eventBus) : null; |
| 16336 | const pdfViewer = new PDFViewer({ |
| 16337 | container, |
| 16338 | viewer, |
| 16339 | eventBus, |
| 16340 | renderingQueue: pdfRenderingQueue, |
| 16341 | linkService: pdfLinkService, |
| 16342 | downloadManager, |
| 16343 | altTextManager, |
| 16344 | findController, |
| 16345 | scriptingManager: AppOptions.get("enableScripting") && pdfScriptingManager, |
| 16346 | l10n, |
| 16347 | textLayerMode: AppOptions.get("textLayerMode"), |
| 16348 | annotationMode: AppOptions.get("annotationMode"), |
| 16349 | annotationEditorMode, |
| 16350 | annotationEditorHighlightColors: AppOptions.get("highlightEditorColors"), |
| 16351 | enableHighlightFloatingButton: AppOptions.get("enableHighlightFloatingButton"), |
| 16352 | imageResourcesPath: AppOptions.get("imageResourcesPath"), |
| 16353 | enablePrintAutoRotate: AppOptions.get("enablePrintAutoRotate"), |
| 16354 | maxCanvasPixels: AppOptions.get("maxCanvasPixels"), |
| 16355 | enablePermissions: AppOptions.get("enablePermissions"), |
| 16356 | pageColors, |
| 16357 | mlManager: this.mlManager |
| 16358 | }); |
| 16359 | this.pdfViewer = pdfViewer; |
| 16360 | pdfRenderingQueue.setViewer(pdfViewer); |
| 16361 | pdfLinkService.setViewer(pdfViewer); |
| 16362 | pdfScriptingManager.setViewer(pdfViewer); |
| 16363 | if (appConfig.sidebar?.thumbnailView) { |
| 16364 | this.pdfThumbnailViewer = new PDFThumbnailViewer({ |
| 16365 | container: appConfig.sidebar.thumbnailView, |
| 16366 | eventBus, |
| 16367 | renderingQueue: pdfRenderingQueue, |
| 16368 | linkService: pdfLinkService, |
| 16369 | pageColors |
| 16370 | }); |
| 16371 | pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer); |
| 16372 | } |
| 16373 | if (!this.isViewerEmbedded && !AppOptions.get("disableHistory")) { |
| 16374 | this.pdfHistory = new PDFHistory({ |
| 16375 | linkService: pdfLinkService, |
| 16376 | eventBus |
| 16377 | }); |
| 16378 | pdfLinkService.setHistory(this.pdfHistory); |
| 16379 | } |
| 16380 | if (!this.supportsIntegratedFind && appConfig.findBar) { |
| 16381 | this.findBar = new PDFFindBar(appConfig.findBar, eventBus); |
| 16382 | } |
| 16383 | if (appConfig.annotationEditorParams) { |
| 16384 | if (annotationEditorMode !== AnnotationEditorType.DISABLE) { |
| 16385 | if (AppOptions.get("enableStampEditor")) { |
| 16386 | appConfig.toolbar?.editorStampButton?.classList.remove("hidden"); |
| 16387 | } |
| 16388 | const editorHighlightButton = appConfig.toolbar?.editorHighlightButton; |
| 16389 | if (editorHighlightButton && AppOptions.get("enableHighlightEditor")) { |
| 16390 | editorHighlightButton.hidden = false; |
| 16391 | } |
| 16392 | this.annotationEditorParams = new AnnotationEditorParams(appConfig.annotationEditorParams, eventBus); |
| 16393 | } else { |
| 16394 | for (const id of ["editorModeButtons", "editorModeSeparator"]) { |
| 16395 | document.getElementById(id)?.classList.add("hidden"); |
| 16396 | } |
| 16397 | } |
| 16398 | } |
| 16399 | if (appConfig.documentProperties) { |
| 16400 | this.pdfDocumentProperties = new PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, l10n, () => this._docFilename); |
| 16401 | } |
| 16402 | if (appConfig.secondaryToolbar?.cursorHandToolButton) { |
| 16403 | this.pdfCursorTools = new PDFCursorTools({ |
| 16404 | container, |
| 16405 | eventBus, |
| 16406 | cursorToolOnLoad: AppOptions.get("cursorToolOnLoad") |
| 16407 | }); |
| 16408 | } |
| 16409 | if (appConfig.toolbar) { |
| 16410 | this.toolbar = new Toolbar(appConfig.toolbar, eventBus); |
| 16411 | } |
| 16412 | if (appConfig.secondaryToolbar) { |
| 16413 | this.secondaryToolbar = new SecondaryToolbar(appConfig.secondaryToolbar, eventBus); |
| 16414 | } |
| 16415 | if (this.supportsFullscreen && appConfig.secondaryToolbar?.presentationModeButton) { |
| 16416 | this.pdfPresentationMode = new PDFPresentationMode({ |
| 16417 | container, |
| 16418 | pdfViewer, |
| 16419 | eventBus |
| 16420 | }); |
| 16421 | } |
| 16422 | if (appConfig.passwordOverlay) { |
| 16423 | this.passwordPrompt = new PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.isViewerEmbedded); |
| 16424 | } |
| 16425 | if (appConfig.sidebar?.outlineView) { |
| 16426 | this.pdfOutlineViewer = new PDFOutlineViewer({ |
| 16427 | container: appConfig.sidebar.outlineView, |
| 16428 | eventBus, |
| 16429 | l10n, |
| 16430 | linkService: pdfLinkService, |
| 16431 | downloadManager |
| 16432 | }); |
| 16433 | } |
| 16434 | if (appConfig.sidebar?.attachmentsView) { |
| 16435 | this.pdfAttachmentViewer = new PDFAttachmentViewer({ |
| 16436 | container: appConfig.sidebar.attachmentsView, |
| 16437 | eventBus, |
| 16438 | l10n, |
| 16439 | downloadManager |
| 16440 | }); |
| 16441 | } |
| 16442 | if (appConfig.sidebar?.layersView) { |
| 16443 | this.pdfLayerViewer = new PDFLayerViewer({ |
| 16444 | container: appConfig.sidebar.layersView, |
| 16445 | eventBus, |
| 16446 | l10n |
| 16447 | }); |
| 16448 | } |
| 16449 | if (appConfig.sidebar) { |
| 16450 | this.pdfSidebar = new PDFSidebar({ |
| 16451 | elements: appConfig.sidebar, |
| 16452 | eventBus, |
| 16453 | l10n |
| 16454 | }); |
| 16455 | this.pdfSidebar.onToggled = this.forceRendering.bind(this); |
| 16456 | this.pdfSidebar.onUpdateThumbnails = () => { |
| 16457 | for (const pageView of pdfViewer.getCachedPageViews()) { |
| 16458 | if (pageView.renderingState === RenderingStates.FINISHED) { |
| 16459 | this.pdfThumbnailViewer.getThumbnail(pageView.id - 1)?.setImage(pageView); |
| 16460 | } |
| 16461 | } |
| 16462 | this.pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber); |
| 16463 | }; |
| 16464 | } |
| 16465 | }, |
| 16466 | async run(config) { |
| 16467 | this.preferences = new Preferences(); |
| 16468 | await this.initialize(config); |
| 16469 | const { |
| 16470 | appConfig, |
| 16471 | eventBus |
| 16472 | } = this; |
| 16473 | let file; |
| 16474 | const queryString = document.location.search.substring(1); |
| 16475 | const params = parseQueryString(queryString); |
| 16476 | file = params.get("file") ?? AppOptions.get("defaultUrl"); |
| 16477 | validateFileURL(file); |
| 16478 | const fileInput = this._openFileInput = document.createElement("input"); |
| 16479 | fileInput.id = "fileInput"; |
| 16480 | fileInput.hidden = true; |
| 16481 | fileInput.type = "file"; |
| 16482 | fileInput.value = null; |
| 16483 | document.body.append(fileInput); |
| 16484 | fileInput.addEventListener("change", function (evt) { |
| 16485 | const { |
| 16486 | files |
| 16487 | } = evt.target; |
| 16488 | if (!files || files.length === 0) { |
| 16489 | return; |
| 16490 | } |
| 16491 | eventBus.dispatch("fileinputchange", { |
| 16492 | source: this, |
| 16493 | fileInput: evt.target |
| 16494 | }); |
| 16495 | }); |
| 16496 | appConfig.mainContainer.addEventListener("dragover", function (evt) { |
| 16497 | evt.preventDefault(); |
| 16498 | evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === "copy" ? "copy" : "move"; |
| 16499 | }); |
| 16500 | appConfig.mainContainer.addEventListener("drop", function (evt) { |
| 16501 | evt.preventDefault(); |
| 16502 | const { |
| 16503 | files |
| 16504 | } = evt.dataTransfer; |
| 16505 | if (!files || files.length === 0) { |
| 16506 | return; |
| 16507 | } |
| 16508 | eventBus.dispatch("fileinputchange", { |
| 16509 | source: this, |
| 16510 | fileInput: evt.dataTransfer |
| 16511 | }); |
| 16512 | }); |
| 16513 | if (!AppOptions.get("supportsDocumentFonts")) { |
| 16514 | AppOptions.set("disableFontFace", true); |
| 16515 | this.l10n.get("pdfjs-web-fonts-disabled").then(msg => { |
| 16516 | console.warn(msg); |
| 16517 | }); |
| 16518 | } |
| 16519 | if (!this.supportsPrinting) { |
| 16520 | appConfig.toolbar?.print?.classList.add("hidden"); |
| 16521 | appConfig.secondaryToolbar?.printButton.classList.add("hidden"); |
| 16522 | } |
| 16523 | if (!this.supportsFullscreen) { |
| 16524 | appConfig.secondaryToolbar?.presentationModeButton.classList.add("hidden"); |
| 16525 | } |
| 16526 | if (this.supportsIntegratedFind) { |
| 16527 | appConfig.toolbar?.viewFind?.classList.add("hidden"); |
| 16528 | } |
| 16529 | if (file) { |
| 16530 | this.open({ |
| 16531 | url: file |
| 16532 | }); |
| 16533 | } else { |
| 16534 | this._hideViewBookmark(); |
| 16535 | } |
| 16536 | }, |
| 16537 | get externalServices() { |
| 16538 | return shadow(this, "externalServices", new ExternalServices()); |
| 16539 | }, |
| 16540 | get mlManager() { |
| 16541 | return shadow(this, "mlManager", AppOptions.get("enableML") === true ? new MLManager() : null); |
| 16542 | }, |
| 16543 | get initialized() { |
| 16544 | return this._initializedCapability.settled; |
| 16545 | }, |
| 16546 | get initializedPromise() { |
| 16547 | return this._initializedCapability.promise; |
| 16548 | }, |
| 16549 | updateZoom(steps, scaleFactor, origin) { |
| 16550 | if (this.pdfViewer.isInPresentationMode) { |
| 16551 | return; |
| 16552 | } |
| 16553 | this.pdfViewer.updateScale({ |
| 16554 | drawingDelay: AppOptions.get("defaultZoomDelay"), |
| 16555 | steps, |
| 16556 | scaleFactor, |
| 16557 | origin |
| 16558 | }); |
| 16559 | }, |
| 16560 | zoomIn() { |
| 16561 | this.updateZoom(1); |
| 16562 | }, |
| 16563 | zoomOut() { |
| 16564 | this.updateZoom(-1); |
| 16565 | }, |
| 16566 | zoomReset() { |
| 16567 | if (this.pdfViewer.isInPresentationMode) { |
| 16568 | return; |
| 16569 | } |
| 16570 | this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE; |
| 16571 | }, |
| 16572 | get pagesCount() { |
| 16573 | return this.pdfDocument ? this.pdfDocument.numPages : 0; |
| 16574 | }, |
| 16575 | get page() { |
| 16576 | return this.pdfViewer.currentPageNumber; |
| 16577 | }, |
| 16578 | set page(val) { |
| 16579 | this.pdfViewer.currentPageNumber = val; |
| 16580 | }, |
| 16581 | get supportsPrinting() { |
| 16582 | return PDFPrintServiceFactory.supportsPrinting; |
| 16583 | }, |
| 16584 | get supportsFullscreen() { |
| 16585 | return shadow(this, "supportsFullscreen", document.fullscreenEnabled); |
| 16586 | }, |
| 16587 | get supportsPinchToZoom() { |
| 16588 | return shadow(this, "supportsPinchToZoom", AppOptions.get("supportsPinchToZoom")); |
| 16589 | }, |
| 16590 | get supportsIntegratedFind() { |
| 16591 | return shadow(this, "supportsIntegratedFind", AppOptions.get("supportsIntegratedFind")); |
| 16592 | }, |
| 16593 | get loadingBar() { |
| 16594 | const barElement = document.getElementById("loadingBar"); |
| 16595 | const bar = barElement ? new ProgressBar(barElement) : null; |
| 16596 | return shadow(this, "loadingBar", bar); |
| 16597 | }, |
| 16598 | get supportsMouseWheelZoomCtrlKey() { |
| 16599 | return shadow(this, "supportsMouseWheelZoomCtrlKey", AppOptions.get("supportsMouseWheelZoomCtrlKey")); |
| 16600 | }, |
| 16601 | get supportsMouseWheelZoomMetaKey() { |
| 16602 | return shadow(this, "supportsMouseWheelZoomMetaKey", AppOptions.get("supportsMouseWheelZoomMetaKey")); |
| 16603 | }, |
| 16604 | get supportsCaretBrowsingMode() { |
| 16605 | return AppOptions.get("supportsCaretBrowsingMode"); |
| 16606 | }, |
| 16607 | moveCaret(isUp, select) { |
| 16608 | this._caretBrowsing ||= new CaretBrowsingMode(this.appConfig.mainContainer, this.appConfig.viewerContainer, this.appConfig.toolbar?.container); |
| 16609 | this._caretBrowsing.moveCaret(isUp, select); |
| 16610 | }, |
| 16611 | setTitleUsingUrl(url = "", downloadUrl = null) { |
| 16612 | this.url = url; |
| 16613 | this.baseUrl = url.split("#", 1)[0]; |
| 16614 | if (downloadUrl) { |
| 16615 | this._downloadUrl = downloadUrl === url ? this.baseUrl : downloadUrl.split("#", 1)[0]; |
| 16616 | } |
| 16617 | if (isDataScheme(url)) { |
| 16618 | this._hideViewBookmark(); |
| 16619 | } |
| 16620 | let title = pdfjs_getPdfFilenameFromUrl(url, ""); |
| 16621 | if (!title) { |
| 16622 | try { |
| 16623 | title = decodeURIComponent(getFilenameFromUrl(url)) || url; |
| 16624 | } catch { |
| 16625 | title = url; |
| 16626 | } |
| 16627 | } |
| 16628 | this.setTitle(title); |
| 16629 | }, |
| 16630 | setTitle(title = this._title) { |
| 16631 | this._title = title; |
| 16632 | if (this.isViewerEmbedded) { |
| 16633 | return; |
| 16634 | } |
| 16635 | const editorIndicator = this._hasAnnotationEditors && !this.pdfRenderingQueue.printing; |
| 16636 | document.title = `${editorIndicator ? "* " : ""}${title}`; |
| 16637 | }, |
| 16638 | get _docFilename() { |
| 16639 | return this._contentDispositionFilename || pdfjs_getPdfFilenameFromUrl(this.url); |
| 16640 | }, |
| 16641 | _hideViewBookmark() { |
| 16642 | const { |
| 16643 | secondaryToolbar |
| 16644 | } = this.appConfig; |
| 16645 | secondaryToolbar?.viewBookmarkButton.classList.add("hidden"); |
| 16646 | if (secondaryToolbar?.presentationModeButton.classList.contains("hidden")) { |
| 16647 | document.getElementById("viewBookmarkSeparator")?.classList.add("hidden"); |
| 16648 | } |
| 16649 | }, |
| 16650 | async close() { |
| 16651 | this._unblockDocumentLoadEvent(); |
| 16652 | this._hideViewBookmark(); |
| 16653 | if (!this.pdfLoadingTask) { |
| 16654 | return; |
| 16655 | } |
| 16656 | if (this.pdfDocument?.annotationStorage.size > 0 && this._annotationStorageModified) { |
| 16657 | try { |
| 16658 | await this.save(); |
| 16659 | } catch {} |
| 16660 | } |
| 16661 | const promises = []; |
| 16662 | promises.push(this.pdfLoadingTask.destroy()); |
| 16663 | this.pdfLoadingTask = null; |
| 16664 | if (this.pdfDocument) { |
| 16665 | this.pdfDocument = null; |
| 16666 | this.pdfThumbnailViewer?.setDocument(null); |
| 16667 | this.pdfViewer.setDocument(null); |
| 16668 | this.pdfLinkService.setDocument(null); |
| 16669 | this.pdfDocumentProperties?.setDocument(null); |
| 16670 | } |
| 16671 | this.pdfLinkService.externalLinkEnabled = true; |
| 16672 | this.store = null; |
| 16673 | this.isInitialViewSet = false; |
| 16674 | this.downloadComplete = false; |
| 16675 | this.url = ""; |
| 16676 | this.baseUrl = ""; |
| 16677 | this._downloadUrl = ""; |
| 16678 | this.documentInfo = null; |
| 16679 | this.metadata = null; |
| 16680 | this._contentDispositionFilename = null; |
| 16681 | this._contentLength = null; |
| 16682 | this._saveInProgress = false; |
| 16683 | this._hasAnnotationEditors = false; |
| 16684 | promises.push(this.pdfScriptingManager.destroyPromise, this.passwordPrompt.close()); |
| 16685 | this.setTitle(); |
| 16686 | this.pdfSidebar?.reset(); |
| 16687 | this.pdfOutlineViewer?.reset(); |
| 16688 | this.pdfAttachmentViewer?.reset(); |
| 16689 | this.pdfLayerViewer?.reset(); |
| 16690 | this.pdfHistory?.reset(); |
| 16691 | this.findBar?.reset(); |
| 16692 | this.toolbar?.reset(); |
| 16693 | this.secondaryToolbar?.reset(); |
| 16694 | this._PDFBug?.cleanup(); |
| 16695 | await Promise.all(promises); |
| 16696 | }, |
| 16697 | async open(args) { |
| 16698 | if (this.pdfLoadingTask) { |
| 16699 | await this.close(); |
| 16700 | } |
| 16701 | const workerParams = AppOptions.getAll(OptionKind.WORKER); |
| 16702 | Object.assign(GlobalWorkerOptions, workerParams); |
| 16703 | if (args.url) { |
| 16704 | this.setTitleUsingUrl(args.originalUrl || args.url, args.url); |
| 16705 | } |
| 16706 | const apiParams = AppOptions.getAll(OptionKind.API); |
| 16707 | const loadingTask = getDocument({ |
| 16708 | ...apiParams, |
| 16709 | ...args |
| 16710 | }); |
| 16711 | this.pdfLoadingTask = loadingTask; |
| 16712 | loadingTask.onPassword = (updateCallback, reason) => { |
| 16713 | if (this.isViewerEmbedded) { |
| 16714 | this._unblockDocumentLoadEvent(); |
| 16715 | } |
| 16716 | this.pdfLinkService.externalLinkEnabled = false; |
| 16717 | this.passwordPrompt.setUpdateCallback(updateCallback, reason); |
| 16718 | this.passwordPrompt.open(); |
| 16719 | }; |
| 16720 | loadingTask.onProgress = ({ |
| 16721 | loaded, |
| 16722 | total |
| 16723 | }) => { |
| 16724 | this.progress(loaded / total); |
| 16725 | }; |
| 16726 | return loadingTask.promise.then(pdfDocument => { |
| 16727 | this.load(pdfDocument); |
| 16728 | }, reason => { |
| 16729 | if (loadingTask !== this.pdfLoadingTask) { |
| 16730 | return undefined; |
| 16731 | } |
| 16732 | let key = "pdfjs-loading-error"; |
| 16733 | if (reason instanceof InvalidPDFException) { |
| 16734 | key = "pdfjs-invalid-file-error"; |
| 16735 | } else if (reason instanceof MissingPDFException) { |
| 16736 | key = "pdfjs-missing-file-error"; |
| 16737 | } else if (reason instanceof UnexpectedResponseException) { |
| 16738 | key = "pdfjs-unexpected-response-error"; |
| 16739 | } |
| 16740 | return this._documentError(key, { |
| 16741 | message: reason.message |
| 16742 | }).then(() => { |
| 16743 | throw reason; |
| 16744 | }); |
| 16745 | }); |
| 16746 | }, |
| 16747 | _ensureDownloadComplete() { |
| 16748 | if (this.pdfDocument && this.downloadComplete) { |
| 16749 | return; |
| 16750 | } |
| 16751 | throw new Error("PDF document not downloaded."); |
| 16752 | }, |
| 16753 | async download(options = {}) { |
| 16754 | if (location.hash) { |
| 16755 | let hash = location.hash; |
| 16756 | let hashParams = new URLSearchParams(hash.substring(1)); |
| 16757 | |
| 16758 | if(hashParams.get('key') !== null) { |
| 16759 | hashParams = '#' + atob(hashParams.get('key')); |
| 16760 | hashParams = new URLSearchParams(hashParams.substring(1)); |
| 16761 | } |
| 16762 | |
| 16763 | const element = document.querySelector('#download'); |
| 16764 | if((hashParams.get('download') === 'false' || hashParams.get('download') === '') || element.offsetParent === null){ |
| 16765 | return false; |
| 16766 | } |
| 16767 | } // added by EP developer |
| 16768 | |
| 16769 | const url = this._downloadUrl, |
| 16770 | filename = this._docFilename; |
| 16771 | try { |
| 16772 | this._ensureDownloadComplete(); |
| 16773 | const data = await this.pdfDocument.getData(); |
| 16774 | const blob = new Blob([data], { |
| 16775 | type: "application/pdf" |
| 16776 | }); |
| 16777 | await this.downloadManager.download(blob, url, filename, options); |
| 16778 | } catch { |
| 16779 | await this.downloadManager.downloadUrl(url, filename, options); |
| 16780 | } |
| 16781 | }, |
| 16782 | async save(options = {}) { |
| 16783 | if (location.hash) { |
| 16784 | let hash = location.hash; |
| 16785 | let hashParams = new URLSearchParams(hash.substring(1)); |
| 16786 | |
| 16787 | if(hashParams.get('key') !== null) { |
| 16788 | hashParams = '#' + atob(hashParams.get('key')); |
| 16789 | hashParams = new URLSearchParams(hashParams.substring(1)); |
| 16790 | } |
| 16791 | else{ |
| 16792 | return false; |
| 16793 | } |
| 16794 | |
| 16795 | const element = document.querySelector('#download'); |
| 16796 | |
| 16797 | if((hashParams.get('download') === 'false' || hashParams.get('download') === '') || element.offsetParent === null){ |
| 16798 | return false; |
| 16799 | } |
| 16800 | }// added by EP developer |
| 16801 | |
| 16802 | if (this._saveInProgress) { |
| 16803 | return; |
| 16804 | } |
| 16805 | this._saveInProgress = true; |
| 16806 | await this.pdfScriptingManager.dispatchWillSave(); |
| 16807 | const url = this._downloadUrl, |
| 16808 | filename = this._docFilename; |
| 16809 | try { |
| 16810 | this._ensureDownloadComplete(); |
| 16811 | const data = await this.pdfDocument.saveDocument(); |
| 16812 | const blob = new Blob([data], { |
| 16813 | type: "application/pdf" |
| 16814 | }); |
| 16815 | await this.downloadManager.download(blob, url, filename, options); |
| 16816 | } catch (reason) { |
| 16817 | console.error(`Error when saving the document: ${reason.message}`); |
| 16818 | await this.download(options); |
| 16819 | } finally { |
| 16820 | await this.pdfScriptingManager.dispatchDidSave(); |
| 16821 | this._saveInProgress = false; |
| 16822 | } |
| 16823 | if (this._hasAnnotationEditors) { |
| 16824 | this.externalServices.reportTelemetry({ |
| 16825 | type: "editing", |
| 16826 | data: { |
| 16827 | type: "save", |
| 16828 | stats: this.pdfDocument?.annotationStorage.editorStats |
| 16829 | } |
| 16830 | }); |
| 16831 | } |
| 16832 | }, |
| 16833 | downloadOrSave(options = {}) { |
| 16834 | if (this.pdfDocument?.annotationStorage.size > 0) { |
| 16835 | this.save(options); |
| 16836 | } else { |
| 16837 | this.download(options); |
| 16838 | } |
| 16839 | }, |
| 16840 | async _documentError(key, moreInfo = null) { |
| 16841 | this._unblockDocumentLoadEvent(); |
| 16842 | const message = await this._otherError(key || "pdfjs-loading-error", moreInfo); |
| 16843 | this.eventBus.dispatch("documenterror", { |
| 16844 | source: this, |
| 16845 | message, |
| 16846 | reason: moreInfo?.message ?? null |
| 16847 | }); |
| 16848 | }, |
| 16849 | async _otherError(key, moreInfo = null) { |
| 16850 | const message = await this.l10n.get(key); |
| 16851 | const moreInfoText = [`PDF.js v${version || "?"} (build: ${build || "?"})`]; |
| 16852 | if (moreInfo) { |
| 16853 | moreInfoText.push(`Message: ${moreInfo.message}`); |
| 16854 | if (moreInfo.stack) { |
| 16855 | moreInfoText.push(`Stack: ${moreInfo.stack}`); |
| 16856 | } else { |
| 16857 | if (moreInfo.filename) { |
| 16858 | moreInfoText.push(`File: ${moreInfo.filename}`); |
| 16859 | } |
| 16860 | if (moreInfo.lineNumber) { |
| 16861 | moreInfoText.push(`Line: ${moreInfo.lineNumber}`); |
| 16862 | } |
| 16863 | } |
| 16864 | } |
| 16865 | console.error(`${message}\n\n${moreInfoText.join("\n")}`); |
| 16866 | return message; |
| 16867 | }, |
| 16868 | progress(level) { |
| 16869 | if (!this.loadingBar || this.downloadComplete) { |
| 16870 | return; |
| 16871 | } |
| 16872 | const percent = Math.round(level * 100); |
| 16873 | if (percent <= this.loadingBar.percent) { |
| 16874 | return; |
| 16875 | } |
| 16876 | this.loadingBar.percent = percent; |
| 16877 | if (this.pdfDocument?.loadingParams.disableAutoFetch ?? AppOptions.get("disableAutoFetch")) { |
| 16878 | this.loadingBar.setDisableAutoFetch(); |
| 16879 | } |
| 16880 | }, |
| 16881 | load(pdfDocument) { |
| 16882 | this.pdfDocument = pdfDocument; |
| 16883 | pdfDocument.getDownloadInfo().then(({ |
| 16884 | length |
| 16885 | }) => { |
| 16886 | this._contentLength = length; |
| 16887 | this.downloadComplete = true; |
| 16888 | this.loadingBar?.hide(); |
| 16889 | firstPagePromise.then(() => { |
| 16890 | this.eventBus.dispatch("documentloaded", { |
| 16891 | source: this |
| 16892 | }); |
| 16893 | }); |
| 16894 | }); |
| 16895 | const pageLayoutPromise = pdfDocument.getPageLayout().catch(() => {}); |
| 16896 | const pageModePromise = pdfDocument.getPageMode().catch(() => {}); |
| 16897 | const openActionPromise = pdfDocument.getOpenAction().catch(() => {}); |
| 16898 | this.toolbar?.setPagesCount(pdfDocument.numPages, false); |
| 16899 | this.secondaryToolbar?.setPagesCount(pdfDocument.numPages); |
| 16900 | this.pdfLinkService.setDocument(pdfDocument); |
| 16901 | this.pdfDocumentProperties?.setDocument(pdfDocument); |
| 16902 | const pdfViewer = this.pdfViewer; |
| 16903 | pdfViewer.setDocument(pdfDocument); |
| 16904 | const { |
| 16905 | firstPagePromise, |
| 16906 | onePageRendered, |
| 16907 | pagesPromise |
| 16908 | } = pdfViewer; |
| 16909 | this.pdfThumbnailViewer?.setDocument(pdfDocument); |
| 16910 | const storedPromise = (this.store = new ViewHistory(pdfDocument.fingerprints[0])).getMultiple({ |
| 16911 | page: null, |
| 16912 | zoom: DEFAULT_SCALE_VALUE, |
| 16913 | scrollLeft: "0", |
| 16914 | scrollTop: "0", |
| 16915 | rotation: null, |
| 16916 | sidebarView: SidebarView.UNKNOWN, |
| 16917 | scrollMode: ScrollMode.UNKNOWN, |
| 16918 | spreadMode: SpreadMode.UNKNOWN |
| 16919 | }).catch(() => {}); |
| 16920 | firstPagePromise.then(pdfPage => { |
| 16921 | this.loadingBar?.setWidth(this.appConfig.viewerContainer); |
| 16922 | this._initializeAnnotationStorageCallbacks(pdfDocument); |
| 16923 | Promise.all([animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then(async ([timeStamp, stored, pageLayout, pageMode, openAction]) => { |
| 16924 | const viewOnLoad = AppOptions.get("viewOnLoad"); |
| 16925 | this._initializePdfHistory({ |
| 16926 | fingerprint: pdfDocument.fingerprints[0], |
| 16927 | viewOnLoad, |
| 16928 | initialDest: openAction?.dest |
| 16929 | }); |
| 16930 | const initialBookmark = this.initialBookmark; |
| 16931 | const zoom = AppOptions.get("defaultZoomValue"); |
| 16932 | let hash = zoom ? `zoom=${zoom}` : null; |
| 16933 | let rotation = null; |
| 16934 | let sidebarView = AppOptions.get("sidebarViewOnLoad"); |
| 16935 | let scrollMode = AppOptions.get("scrollModeOnLoad"); |
| 16936 | let spreadMode = AppOptions.get("spreadModeOnLoad"); |
| 16937 | if (stored?.page && viewOnLoad !== ViewOnLoad.INITIAL) { |
| 16938 | hash = `page=${stored.page}&zoom=${zoom || stored.zoom},` + `${stored.scrollLeft},${stored.scrollTop}`; |
| 16939 | rotation = parseInt(stored.rotation, 10); |
| 16940 | if (sidebarView === SidebarView.UNKNOWN) { |
| 16941 | sidebarView = stored.sidebarView | 0; |
| 16942 | } |
| 16943 | if (scrollMode === ScrollMode.UNKNOWN) { |
| 16944 | scrollMode = stored.scrollMode | 0; |
| 16945 | } |
| 16946 | if (spreadMode === SpreadMode.UNKNOWN) { |
| 16947 | spreadMode = stored.spreadMode | 0; |
| 16948 | } |
| 16949 | } |
| 16950 | if (pageMode && sidebarView === SidebarView.UNKNOWN) { |
| 16951 | sidebarView = apiPageModeToSidebarView(pageMode); |
| 16952 | } |
| 16953 | if (pageLayout && scrollMode === ScrollMode.UNKNOWN && spreadMode === SpreadMode.UNKNOWN) { |
| 16954 | const modes = apiPageLayoutToViewerModes(pageLayout); |
| 16955 | spreadMode = modes.spreadMode; |
| 16956 | } |
| 16957 | this.setInitialView(hash, { |
| 16958 | rotation, |
| 16959 | sidebarView, |
| 16960 | scrollMode, |
| 16961 | spreadMode |
| 16962 | }); |
| 16963 | this.eventBus.dispatch("documentinit", { |
| 16964 | source: this |
| 16965 | }); |
| 16966 | if (!this.isViewerEmbedded) { |
| 16967 | pdfViewer.focus(); |
| 16968 | } |
| 16969 | await Promise.race([pagesPromise, new Promise(resolve => { |
| 16970 | setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT); |
| 16971 | })]); |
| 16972 | if (!initialBookmark && !hash) { |
| 16973 | return; |
| 16974 | } |
| 16975 | if (pdfViewer.hasEqualPageSizes) { |
| 16976 | return; |
| 16977 | } |
| 16978 | this.initialBookmark = initialBookmark; |
| 16979 | pdfViewer.currentScaleValue = pdfViewer.currentScaleValue; |
| 16980 | this.setInitialView(hash); |
| 16981 | }).catch(() => { |
| 16982 | this.setInitialView(); |
| 16983 | }).then(function () { |
| 16984 | pdfViewer.update(); |
| 16985 | }); |
| 16986 | }); |
| 16987 | pagesPromise.then(() => { |
| 16988 | this._unblockDocumentLoadEvent(); |
| 16989 | this._initializeAutoPrint(pdfDocument, openActionPromise); |
| 16990 | }, reason => { |
| 16991 | this._documentError("pdfjs-loading-error", { |
| 16992 | message: reason.message |
| 16993 | }); |
| 16994 | }); |
| 16995 | onePageRendered.then(data => { |
| 16996 | this.externalServices.reportTelemetry({ |
| 16997 | type: "pageInfo", |
| 16998 | timestamp: data.timestamp |
| 16999 | }); |
| 17000 | if (this.pdfOutlineViewer) { |
| 17001 | pdfDocument.getOutline().then(outline => { |
| 17002 | if (pdfDocument !== this.pdfDocument) { |
| 17003 | return; |
| 17004 | } |
| 17005 | this.pdfOutlineViewer.render({ |
| 17006 | outline, |
| 17007 | pdfDocument |
| 17008 | }); |
| 17009 | }); |
| 17010 | } |
| 17011 | if (this.pdfAttachmentViewer) { |
| 17012 | pdfDocument.getAttachments().then(attachments => { |
| 17013 | if (pdfDocument !== this.pdfDocument) { |
| 17014 | return; |
| 17015 | } |
| 17016 | this.pdfAttachmentViewer.render({ |
| 17017 | attachments |
| 17018 | }); |
| 17019 | }); |
| 17020 | } |
| 17021 | if (this.pdfLayerViewer) { |
| 17022 | pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => { |
| 17023 | if (pdfDocument !== this.pdfDocument) { |
| 17024 | return; |
| 17025 | } |
| 17026 | this.pdfLayerViewer.render({ |
| 17027 | optionalContentConfig, |
| 17028 | pdfDocument |
| 17029 | }); |
| 17030 | }); |
| 17031 | } |
| 17032 | }); |
| 17033 | this._initializePageLabels(pdfDocument); |
| 17034 | this._initializeMetadata(pdfDocument); |
| 17035 | }, |
| 17036 | async _scriptingDocProperties(pdfDocument) { |
| 17037 | if (!this.documentInfo) { |
| 17038 | await new Promise(resolve => { |
| 17039 | this.eventBus._on("metadataloaded", resolve, { |
| 17040 | once: true |
| 17041 | }); |
| 17042 | }); |
| 17043 | if (pdfDocument !== this.pdfDocument) { |
| 17044 | return null; |
| 17045 | } |
| 17046 | } |
| 17047 | if (!this._contentLength) { |
| 17048 | await new Promise(resolve => { |
| 17049 | this.eventBus._on("documentloaded", resolve, { |
| 17050 | once: true |
| 17051 | }); |
| 17052 | }); |
| 17053 | if (pdfDocument !== this.pdfDocument) { |
| 17054 | return null; |
| 17055 | } |
| 17056 | } |
| 17057 | return { |
| 17058 | ...this.documentInfo, |
| 17059 | baseURL: this.baseUrl, |
| 17060 | filesize: this._contentLength, |
| 17061 | filename: this._docFilename, |
| 17062 | metadata: this.metadata?.getRaw(), |
| 17063 | authors: this.metadata?.get("dc:creator"), |
| 17064 | numPages: this.pagesCount, |
| 17065 | URL: this.url |
| 17066 | }; |
| 17067 | }, |
| 17068 | async _initializeAutoPrint(pdfDocument, openActionPromise) { |
| 17069 | const [openAction, jsActions] = await Promise.all([openActionPromise, this.pdfViewer.enableScripting ? null : pdfDocument.getJSActions()]); |
| 17070 | if (pdfDocument !== this.pdfDocument) { |
| 17071 | return; |
| 17072 | } |
| 17073 | let triggerAutoPrint = openAction?.action === "Print"; |
| 17074 | if (jsActions) { |
| 17075 | console.warn("Warning: JavaScript support is not enabled"); |
| 17076 | for (const name in jsActions) { |
| 17077 | if (triggerAutoPrint) { |
| 17078 | break; |
| 17079 | } |
| 17080 | switch (name) { |
| 17081 | case "WillClose": |
| 17082 | case "WillSave": |
| 17083 | case "DidSave": |
| 17084 | case "WillPrint": |
| 17085 | case "DidPrint": |
| 17086 | continue; |
| 17087 | } |
| 17088 | triggerAutoPrint = jsActions[name].some(js => AutoPrintRegExp.test(js)); |
| 17089 | } |
| 17090 | } |
| 17091 | if (triggerAutoPrint) { |
| 17092 | this.triggerPrinting(); |
| 17093 | } |
| 17094 | }, |
| 17095 | async _initializeMetadata(pdfDocument) { |
| 17096 | const { |
| 17097 | info, |
| 17098 | metadata, |
| 17099 | contentDispositionFilename, |
| 17100 | contentLength |
| 17101 | } = await pdfDocument.getMetadata(); |
| 17102 | if (pdfDocument !== this.pdfDocument) { |
| 17103 | return; |
| 17104 | } |
| 17105 | this.documentInfo = info; |
| 17106 | this.metadata = metadata; |
| 17107 | this._contentDispositionFilename ??= contentDispositionFilename; |
| 17108 | this._contentLength ??= contentLength; |
| 17109 | console.log(`PDF ${pdfDocument.fingerprints[0]} [${info.PDFFormatVersion} ` + `${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` + `(PDF.js: ${version || "?"} [${build || "?"}])`); |
| 17110 | let pdfTitle = info.Title; |
| 17111 | const metadataTitle = metadata?.get("dc:title"); |
| 17112 | if (metadataTitle) { |
| 17113 | if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) { |
| 17114 | pdfTitle = metadataTitle; |
| 17115 | } |
| 17116 | } |
| 17117 | if (pdfTitle) { |
| 17118 | this.setTitle(`${pdfTitle} - ${this._contentDispositionFilename || this._title}`); |
| 17119 | } else if (this._contentDispositionFilename) { |
| 17120 | this.setTitle(this._contentDispositionFilename); |
| 17121 | } |
| 17122 | if (info.IsXFAPresent && !info.IsAcroFormPresent && !pdfDocument.isPureXfa) { |
| 17123 | if (pdfDocument.loadingParams.enableXfa) { |
| 17124 | console.warn("Warning: XFA Foreground documents are not supported"); |
| 17125 | } else { |
| 17126 | console.warn("Warning: XFA support is not enabled"); |
| 17127 | } |
| 17128 | } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !this.pdfViewer.renderForms) { |
| 17129 | console.warn("Warning: Interactive form support is not enabled"); |
| 17130 | } |
| 17131 | if (info.IsSignaturesPresent) { |
| 17132 | console.warn("Warning: Digital signatures validation is not supported"); |
| 17133 | } |
| 17134 | this.eventBus.dispatch("metadataloaded", { |
| 17135 | source: this |
| 17136 | }); |
| 17137 | }, |
| 17138 | async _initializePageLabels(pdfDocument) { |
| 17139 | const labels = await pdfDocument.getPageLabels(); |
| 17140 | if (pdfDocument !== this.pdfDocument) { |
| 17141 | return; |
| 17142 | } |
| 17143 | if (!labels || AppOptions.get("disablePageLabels")) { |
| 17144 | return; |
| 17145 | } |
| 17146 | const numLabels = labels.length; |
| 17147 | let standardLabels = 0, |
| 17148 | emptyLabels = 0; |
| 17149 | for (let i = 0; i < numLabels; i++) { |
| 17150 | const label = labels[i]; |
| 17151 | if (label === (i + 1).toString()) { |
| 17152 | standardLabels++; |
| 17153 | } else if (label === "") { |
| 17154 | emptyLabels++; |
| 17155 | } else { |
| 17156 | break; |
| 17157 | } |
| 17158 | } |
| 17159 | if (standardLabels >= numLabels || emptyLabels >= numLabels) { |
| 17160 | return; |
| 17161 | } |
| 17162 | const { |
| 17163 | pdfViewer, |
| 17164 | pdfThumbnailViewer, |
| 17165 | toolbar |
| 17166 | } = this; |
| 17167 | pdfViewer.setPageLabels(labels); |
| 17168 | pdfThumbnailViewer?.setPageLabels(labels); |
| 17169 | toolbar?.setPagesCount(numLabels, true); |
| 17170 | toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel); |
| 17171 | }, |
| 17172 | _initializePdfHistory({ |
| 17173 | fingerprint, |
| 17174 | viewOnLoad, |
| 17175 | initialDest = null |
| 17176 | }) { |
| 17177 | if (!this.pdfHistory) { |
| 17178 | return; |
| 17179 | } |
| 17180 | this.pdfHistory.initialize({ |
| 17181 | fingerprint, |
| 17182 | resetHistory: viewOnLoad === ViewOnLoad.INITIAL, |
| 17183 | updateUrl: AppOptions.get("historyUpdateUrl") |
| 17184 | }); |
| 17185 | if (this.pdfHistory.initialBookmark) { |
| 17186 | this.initialBookmark = this.pdfHistory.initialBookmark; |
| 17187 | this.initialRotation = this.pdfHistory.initialRotation; |
| 17188 | } |
| 17189 | if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) { |
| 17190 | this.initialBookmark = JSON.stringify(initialDest); |
| 17191 | this.pdfHistory.push({ |
| 17192 | explicitDest: initialDest, |
| 17193 | pageNumber: null |
| 17194 | }); |
| 17195 | } |
| 17196 | }, |
| 17197 | _initializeAnnotationStorageCallbacks(pdfDocument) { |
| 17198 | if (pdfDocument !== this.pdfDocument) { |
| 17199 | return; |
| 17200 | } |
| 17201 | const { |
| 17202 | annotationStorage |
| 17203 | } = pdfDocument; |
| 17204 | annotationStorage.onSetModified = () => { |
| 17205 | window.addEventListener("beforeunload", beforeUnload); |
| 17206 | this._annotationStorageModified = true; |
| 17207 | }; |
| 17208 | annotationStorage.onResetModified = () => { |
| 17209 | window.removeEventListener("beforeunload", beforeUnload); |
| 17210 | delete this._annotationStorageModified; |
| 17211 | }; |
| 17212 | annotationStorage.onAnnotationEditor = typeStr => { |
| 17213 | this._hasAnnotationEditors = !!typeStr; |
| 17214 | this.setTitle(); |
| 17215 | }; |
| 17216 | }, |
| 17217 | setInitialView(storedHash, { |
| 17218 | rotation, |
| 17219 | sidebarView, |
| 17220 | scrollMode, |
| 17221 | spreadMode |
| 17222 | } = {}) { |
| 17223 | const setRotation = angle => { |
| 17224 | if (isValidRotation(angle)) { |
| 17225 | this.pdfViewer.pagesRotation = angle; |
| 17226 | } |
| 17227 | }; |
| 17228 | const setViewerModes = (scroll, spread) => { |
| 17229 | if (isValidScrollMode(scroll)) { |
| 17230 | this.pdfViewer.scrollMode = scroll; |
| 17231 | } |
| 17232 | if (isValidSpreadMode(spread)) { |
| 17233 | this.pdfViewer.spreadMode = spread; |
| 17234 | } |
| 17235 | }; |
| 17236 | this.isInitialViewSet = true; |
| 17237 | this.pdfSidebar?.setInitialView(sidebarView); |
| 17238 | setViewerModes(scrollMode, spreadMode); |
| 17239 | if (this.initialBookmark) { |
| 17240 | setRotation(this.initialRotation); |
| 17241 | delete this.initialRotation; |
| 17242 | this.pdfLinkService.setHash(this.initialBookmark); |
| 17243 | this.initialBookmark = null; |
| 17244 | } else if (storedHash) { |
| 17245 | setRotation(rotation); |
| 17246 | this.pdfLinkService.setHash(storedHash); |
| 17247 | } |
| 17248 | this.toolbar?.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel); |
| 17249 | this.secondaryToolbar?.setPageNumber(this.pdfViewer.currentPageNumber); |
| 17250 | if (!this.pdfViewer.currentScaleValue) { |
| 17251 | this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE; |
| 17252 | } |
| 17253 | }, |
| 17254 | _cleanup() { |
| 17255 | if (!this.pdfDocument) { |
| 17256 | return; |
| 17257 | } |
| 17258 | this.pdfViewer.cleanup(); |
| 17259 | this.pdfThumbnailViewer?.cleanup(); |
| 17260 | this.pdfDocument.cleanup(AppOptions.get("fontExtraProperties")); |
| 17261 | }, |
| 17262 | forceRendering() { |
| 17263 | this.pdfRenderingQueue.printing = !!this.printService; |
| 17264 | this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar?.visibleView === SidebarView.THUMBS; |
| 17265 | this.pdfRenderingQueue.renderHighestPriority(); |
| 17266 | }, |
| 17267 | beforePrint() { |
| 17268 | |
| 17269 | if (location.hash) { |
| 17270 | let hash = location.hash; |
| 17271 | let hashParams = new URLSearchParams(hash.substring(1)); |
| 17272 | if(hashParams.get('key') !== null) { |
| 17273 | hashParams = '#' + atob(hashParams.get('key')); |
| 17274 | hashParams = new URLSearchParams(hashParams.substring(1)); |
| 17275 | } |
| 17276 | const element = document.querySelector('#download'); |
| 17277 | |
| 17278 | if((hashParams.get('download') === 'false' || hashParams.get('download') === '') || element.offsetParent === null){ |
| 17279 | return false; |
| 17280 | } |
| 17281 | } // added by EP developer |
| 17282 | |
| 17283 | this._printAnnotationStoragePromise = this.pdfScriptingManager.dispatchWillPrint().catch(() => {}).then(() => this.pdfDocument?.annotationStorage.print); |
| 17284 | if (this.printService) { |
| 17285 | return; |
| 17286 | } |
| 17287 | if (!this.supportsPrinting) { |
| 17288 | this._otherError("pdfjs-printing-not-supported"); |
| 17289 | return; |
| 17290 | } |
| 17291 | if (!this.pdfViewer.pageViewsReady) { |
| 17292 | this.l10n.get("pdfjs-printing-not-ready").then(msg => { |
| 17293 | window.alert(msg); |
| 17294 | }); |
| 17295 | return; |
| 17296 | } |
| 17297 | this.printService = PDFPrintServiceFactory.createPrintService({ |
| 17298 | pdfDocument: this.pdfDocument, |
| 17299 | pagesOverview: this.pdfViewer.getPagesOverview(), |
| 17300 | printContainer: this.appConfig.printContainer, |
| 17301 | printResolution: AppOptions.get("printResolution"), |
| 17302 | printAnnotationStoragePromise: this._printAnnotationStoragePromise |
| 17303 | }); |
| 17304 | this.forceRendering(); |
| 17305 | this.setTitle(); |
| 17306 | this.printService.layout(); |
| 17307 | if (this._hasAnnotationEditors) { |
| 17308 | this.externalServices.reportTelemetry({ |
| 17309 | type: "editing", |
| 17310 | data: { |
| 17311 | type: "print", |
| 17312 | stats: this.pdfDocument?.annotationStorage.editorStats |
| 17313 | } |
| 17314 | }); |
| 17315 | } |
| 17316 | }, |
| 17317 | afterPrint() { |
| 17318 | |
| 17319 | if (location.hash) { |
| 17320 | let hash = location.hash; |
| 17321 | let hashParams = new URLSearchParams(hash.substring(1)); |
| 17322 | |
| 17323 | if(hashParams.get('key') !== null) { |
| 17324 | hashParams = '#' + atob(hashParams.get('key')); |
| 17325 | hashParams = new URLSearchParams(hashParams.substring(1)); |
| 17326 | } |
| 17327 | |
| 17328 | if(hashParams.get('download') === 'false' || hashParams.get('download') === ''){ |
| 17329 | return false; |
| 17330 | } |
| 17331 | } // added by EP developer |
| 17332 | |
| 17333 | if (this._printAnnotationStoragePromise) { |
| 17334 | this._printAnnotationStoragePromise.then(() => { |
| 17335 | this.pdfScriptingManager.dispatchDidPrint(); |
| 17336 | }); |
| 17337 | this._printAnnotationStoragePromise = null; |
| 17338 | } |
| 17339 | if (this.printService) { |
| 17340 | this.printService.destroy(); |
| 17341 | this.printService = null; |
| 17342 | this.pdfDocument?.annotationStorage.resetModified(); |
| 17343 | } |
| 17344 | this.forceRendering(); |
| 17345 | this.setTitle(); |
| 17346 | }, |
| 17347 | rotatePages(delta) { |
| 17348 | this.pdfViewer.pagesRotation += delta; |
| 17349 | }, |
| 17350 | requestPresentationMode() { |
| 17351 | this.pdfPresentationMode?.request(); |
| 17352 | }, |
| 17353 | triggerPrinting() { |
| 17354 | if (!this.supportsPrinting) { |
| 17355 | return; |
| 17356 | } |
| 17357 | window.print(); |
| 17358 | }, |
| 17359 | bindEvents() { |
| 17360 | if (this._eventBusAbortController) { |
| 17361 | return; |
| 17362 | } |
| 17363 | this._eventBusAbortController = new AbortController(); |
| 17364 | const { |
| 17365 | eventBus, |
| 17366 | _eventBusAbortController: { |
| 17367 | signal |
| 17368 | } |
| 17369 | } = this; |
| 17370 | eventBus._on("resize", webViewerResize, { |
| 17371 | signal |
| 17372 | }); |
| 17373 | eventBus._on("hashchange", webViewerHashchange, { |
| 17374 | signal |
| 17375 | }); |
| 17376 | eventBus._on("beforeprint", this.beforePrint.bind(this), { |
| 17377 | signal |
| 17378 | }); |
| 17379 | eventBus._on("afterprint", this.afterPrint.bind(this), { |
| 17380 | signal |
| 17381 | }); |
| 17382 | eventBus._on("pagerender", webViewerPageRender, { |
| 17383 | signal |
| 17384 | }); |
| 17385 | eventBus._on("pagerendered", webViewerPageRendered, { |
| 17386 | signal |
| 17387 | }); |
| 17388 | eventBus._on("updateviewarea", webViewerUpdateViewarea, { |
| 17389 | signal |
| 17390 | }); |
| 17391 | eventBus._on("pagechanging", webViewerPageChanging, { |
| 17392 | signal |
| 17393 | }); |
| 17394 | eventBus._on("scalechanging", webViewerScaleChanging, { |
| 17395 | signal |
| 17396 | }); |
| 17397 | eventBus._on("rotationchanging", webViewerRotationChanging, { |
| 17398 | signal |
| 17399 | }); |
| 17400 | eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged, { |
| 17401 | signal |
| 17402 | }); |
| 17403 | eventBus._on("pagemode", webViewerPageMode, { |
| 17404 | signal |
| 17405 | }); |
| 17406 | eventBus._on("namedaction", webViewerNamedAction, { |
| 17407 | signal |
| 17408 | }); |
| 17409 | eventBus._on("presentationmodechanged", webViewerPresentationModeChanged, { |
| 17410 | signal |
| 17411 | }); |
| 17412 | eventBus._on("presentationmode", webViewerPresentationMode, { |
| 17413 | signal |
| 17414 | }); |
| 17415 | eventBus._on("switchannotationeditormode", webViewerSwitchAnnotationEditorMode, { |
| 17416 | signal |
| 17417 | }); |
| 17418 | eventBus._on("switchannotationeditorparams", webViewerSwitchAnnotationEditorParams, { |
| 17419 | signal |
| 17420 | }); |
| 17421 | eventBus._on("print", webViewerPrint, { |
| 17422 | signal |
| 17423 | }); |
| 17424 | eventBus._on("download", webViewerDownload, { |
| 17425 | signal |
| 17426 | }); |
| 17427 | eventBus._on("firstpage", webViewerFirstPage, { |
| 17428 | signal |
| 17429 | }); |
| 17430 | eventBus._on("lastpage", webViewerLastPage, { |
| 17431 | signal |
| 17432 | }); |
| 17433 | eventBus._on("nextpage", webViewerNextPage, { |
| 17434 | signal |
| 17435 | }); |
| 17436 | eventBus._on("previouspage", webViewerPreviousPage, { |
| 17437 | signal |
| 17438 | }); |
| 17439 | eventBus._on("zoomin", webViewerZoomIn, { |
| 17440 | signal |
| 17441 | }); |
| 17442 | eventBus._on("zoomout", webViewerZoomOut, { |
| 17443 | signal |
| 17444 | }); |
| 17445 | eventBus._on("zoomreset", webViewerZoomReset, { |
| 17446 | signal |
| 17447 | }); |
| 17448 | eventBus._on("pagenumberchanged", webViewerPageNumberChanged, { |
| 17449 | signal |
| 17450 | }); |
| 17451 | eventBus._on("scalechanged", webViewerScaleChanged, { |
| 17452 | signal |
| 17453 | }); |
| 17454 | eventBus._on("rotatecw", webViewerRotateCw, { |
| 17455 | signal |
| 17456 | }); |
| 17457 | eventBus._on("rotateccw", webViewerRotateCcw, { |
| 17458 | signal |
| 17459 | }); |
| 17460 | eventBus._on("optionalcontentconfig", webViewerOptionalContentConfig, { |
| 17461 | signal |
| 17462 | }); |
| 17463 | eventBus._on("switchscrollmode", webViewerSwitchScrollMode, { |
| 17464 | signal |
| 17465 | }); |
| 17466 | eventBus._on("scrollmodechanged", webViewerScrollModeChanged, { |
| 17467 | signal |
| 17468 | }); |
| 17469 | eventBus._on("switchspreadmode", webViewerSwitchSpreadMode, { |
| 17470 | signal |
| 17471 | }); |
| 17472 | eventBus._on("spreadmodechanged", webViewerSpreadModeChanged, { |
| 17473 | signal |
| 17474 | }); |
| 17475 | eventBus._on("documentproperties", webViewerDocumentProperties, { |
| 17476 | signal |
| 17477 | }); |
| 17478 | eventBus._on("findfromurlhash", webViewerFindFromUrlHash, { |
| 17479 | signal |
| 17480 | }); |
| 17481 | eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount, { |
| 17482 | signal |
| 17483 | }); |
| 17484 | eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState, { |
| 17485 | signal |
| 17486 | }); |
| 17487 | eventBus._on("fileinputchange", webViewerFileInputChange, { |
| 17488 | signal |
| 17489 | }); |
| 17490 | eventBus._on("openfile", webViewerOpenFile, { |
| 17491 | signal |
| 17492 | }); |
| 17493 | }, |
| 17494 | bindWindowEvents() { |
| 17495 | if (this._windowAbortController) { |
| 17496 | return; |
| 17497 | } |
| 17498 | this._windowAbortController = new AbortController(); |
| 17499 | const { |
| 17500 | eventBus, |
| 17501 | appConfig: { |
| 17502 | mainContainer |
| 17503 | }, |
| 17504 | _windowAbortController: { |
| 17505 | signal |
| 17506 | } |
| 17507 | } = this; |
| 17508 | function addWindowResolutionChange(evt = null) { |
| 17509 | if (evt) { |
| 17510 | webViewerResolutionChange(evt); |
| 17511 | } |
| 17512 | const mediaQueryList = window.matchMedia(`(resolution: ${window.devicePixelRatio || 1}dppx)`); |
| 17513 | mediaQueryList.addEventListener("change", addWindowResolutionChange, { |
| 17514 | once: true, |
| 17515 | signal |
| 17516 | }); |
| 17517 | } |
| 17518 | addWindowResolutionChange(); |
| 17519 | window.addEventListener("visibilitychange", webViewerVisibilityChange, { |
| 17520 | signal |
| 17521 | }); |
| 17522 | window.addEventListener("wheel", webViewerWheel, { |
| 17523 | passive: false, |
| 17524 | signal |
| 17525 | }); |
| 17526 | window.addEventListener("touchstart", webViewerTouchStart, { |
| 17527 | passive: false, |
| 17528 | signal |
| 17529 | }); |
| 17530 | window.addEventListener("touchmove", webViewerTouchMove, { |
| 17531 | passive: false, |
| 17532 | signal |
| 17533 | }); |
| 17534 | window.addEventListener("touchend", webViewerTouchEnd, { |
| 17535 | passive: false, |
| 17536 | signal |
| 17537 | }); |
| 17538 | window.addEventListener("click", webViewerClick, { |
| 17539 | signal |
| 17540 | }); |
| 17541 | window.addEventListener("keydown", webViewerKeyDown, { |
| 17542 | signal |
| 17543 | }); |
| 17544 | window.addEventListener("keyup", webViewerKeyUp, { |
| 17545 | signal |
| 17546 | }); |
| 17547 | window.addEventListener("resize", () => { |
| 17548 | eventBus.dispatch("resize", { |
| 17549 | source: window |
| 17550 | }); |
| 17551 | }, { |
| 17552 | signal |
| 17553 | }); |
| 17554 | window.addEventListener("hashchange", () => { |
| 17555 | eventBus.dispatch("hashchange", { |
| 17556 | source: window, |
| 17557 | hash: document.location.hash.substring(1) |
| 17558 | }); |
| 17559 | }, { |
| 17560 | signal |
| 17561 | }); |
| 17562 | window.addEventListener("beforeprint", () => { |
| 17563 | eventBus.dispatch("beforeprint", { |
| 17564 | source: window |
| 17565 | }); |
| 17566 | }, { |
| 17567 | signal |
| 17568 | }); |
| 17569 | window.addEventListener("afterprint", () => { |
| 17570 | eventBus.dispatch("afterprint", { |
| 17571 | source: window |
| 17572 | }); |
| 17573 | }, { |
| 17574 | signal |
| 17575 | }); |
| 17576 | window.addEventListener("updatefromsandbox", event => { |
| 17577 | eventBus.dispatch("updatefromsandbox", { |
| 17578 | source: window, |
| 17579 | detail: event.detail |
| 17580 | }); |
| 17581 | }, { |
| 17582 | signal |
| 17583 | }); |
| 17584 | if (!("onscrollend" in document.documentElement)) { |
| 17585 | return; |
| 17586 | } |
| 17587 | ({ |
| 17588 | scrollTop: this._lastScrollTop, |
| 17589 | scrollLeft: this._lastScrollLeft |
| 17590 | } = mainContainer); |
| 17591 | const scrollend = () => { |
| 17592 | ({ |
| 17593 | scrollTop: this._lastScrollTop, |
| 17594 | scrollLeft: this._lastScrollLeft |
| 17595 | } = mainContainer); |
| 17596 | this._isScrolling = false; |
| 17597 | mainContainer.addEventListener("scroll", scroll, { |
| 17598 | passive: true, |
| 17599 | signal |
| 17600 | }); |
| 17601 | mainContainer.removeEventListener("scrollend", scrollend); |
| 17602 | mainContainer.removeEventListener("blur", scrollend); |
| 17603 | }; |
| 17604 | const scroll = () => { |
| 17605 | if (this._isCtrlKeyDown) { |
| 17606 | return; |
| 17607 | } |
| 17608 | if (this._lastScrollTop === mainContainer.scrollTop && this._lastScrollLeft === mainContainer.scrollLeft) { |
| 17609 | return; |
| 17610 | } |
| 17611 | mainContainer.removeEventListener("scroll", scroll, { |
| 17612 | passive: true |
| 17613 | }); |
| 17614 | this._isScrolling = true; |
| 17615 | mainContainer.addEventListener("scrollend", scrollend, { |
| 17616 | signal |
| 17617 | }); |
| 17618 | mainContainer.addEventListener("blur", scrollend, { |
| 17619 | signal |
| 17620 | }); |
| 17621 | }; |
| 17622 | mainContainer.addEventListener("scroll", scroll, { |
| 17623 | passive: true, |
| 17624 | signal |
| 17625 | }); |
| 17626 | }, |
| 17627 | unbindEvents() { |
| 17628 | this._eventBusAbortController?.abort(); |
| 17629 | this._eventBusAbortController = null; |
| 17630 | }, |
| 17631 | unbindWindowEvents() { |
| 17632 | this._windowAbortController?.abort(); |
| 17633 | this._windowAbortController = null; |
| 17634 | }, |
| 17635 | _accumulateTicks(ticks, prop) { |
| 17636 | if (this[prop] > 0 && ticks < 0 || this[prop] < 0 && ticks > 0) { |
| 17637 | this[prop] = 0; |
| 17638 | } |
| 17639 | this[prop] += ticks; |
| 17640 | const wholeTicks = Math.trunc(this[prop]); |
| 17641 | this[prop] -= wholeTicks; |
| 17642 | return wholeTicks; |
| 17643 | }, |
| 17644 | _accumulateFactor(previousScale, factor, prop) { |
| 17645 | if (factor === 1) { |
| 17646 | return 1; |
| 17647 | } |
| 17648 | if (this[prop] > 1 && factor < 1 || this[prop] < 1 && factor > 1) { |
| 17649 | this[prop] = 1; |
| 17650 | } |
| 17651 | const newFactor = Math.floor(previousScale * factor * this[prop] * 100) / (100 * previousScale); |
| 17652 | this[prop] = factor / newFactor; |
| 17653 | return newFactor; |
| 17654 | }, |
| 17655 | _unblockDocumentLoadEvent() { |
| 17656 | document.blockUnblockOnload?.(false); |
| 17657 | this._unblockDocumentLoadEvent = () => {}; |
| 17658 | }, |
| 17659 | get scriptingReady() { |
| 17660 | return this.pdfScriptingManager.ready; |
| 17661 | } |
| 17662 | }; |
| 17663 | initCom(PDFViewerApplication); |
| 17664 | { |
| 17665 | PDFPrintServiceFactory.initGlobals(PDFViewerApplication); |
| 17666 | } |
| 17667 | { |
| 17668 | const HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"]; |
| 17669 | var validateFileURL = function (file) { |
| 17670 | if (!file) { |
| 17671 | return; |
| 17672 | } |
| 17673 | try { |
| 17674 | const viewerOrigin = new URL(window.location.href).origin || "null"; |
| 17675 | if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) { |
| 17676 | return; |
| 17677 | } |
| 17678 | const fileOrigin = new URL(file, window.location.href).origin; |
| 17679 | if (fileOrigin !== viewerOrigin) { |
| 17680 | throw new Error("file origin does not match viewer's"); |
| 17681 | } |
| 17682 | } catch (ex) { |
| 17683 | PDFViewerApplication._documentError("pdfjs-loading-error", { |
| 17684 | message: ex.message |
| 17685 | }); |
| 17686 | throw ex; |
| 17687 | } |
| 17688 | }; |
| 17689 | } |
| 17690 | function webViewerPageRender({ |
| 17691 | pageNumber |
| 17692 | }) { |
| 17693 | if (pageNumber === PDFViewerApplication.page) { |
| 17694 | PDFViewerApplication.toolbar?.updateLoadingIndicatorState(true); |
| 17695 | } |
| 17696 | } |
| 17697 | function webViewerPageRendered({ |
| 17698 | pageNumber, |
| 17699 | error |
| 17700 | }) { |
| 17701 | if (pageNumber === PDFViewerApplication.page) { |
| 17702 | PDFViewerApplication.toolbar?.updateLoadingIndicatorState(false); |
| 17703 | } |
| 17704 | if (PDFViewerApplication.pdfSidebar?.visibleView === SidebarView.THUMBS) { |
| 17705 | const pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1); |
| 17706 | const thumbnailView = PDFViewerApplication.pdfThumbnailViewer?.getThumbnail(pageNumber - 1); |
| 17707 | if (pageView) { |
| 17708 | thumbnailView?.setImage(pageView); |
| 17709 | } |
| 17710 | } |
| 17711 | if (error) { |
| 17712 | PDFViewerApplication._otherError("pdfjs-rendering-error", error); |
| 17713 | } |
| 17714 | } |
| 17715 | function webViewerPageMode({ |
| 17716 | mode |
| 17717 | }) { |
| 17718 | let view; |
| 17719 | switch (mode) { |
| 17720 | case "thumbs": |
| 17721 | view = SidebarView.THUMBS; |
| 17722 | break; |
| 17723 | case "bookmarks": |
| 17724 | case "outline": |
| 17725 | view = SidebarView.OUTLINE; |
| 17726 | break; |
| 17727 | case "attachments": |
| 17728 | view = SidebarView.ATTACHMENTS; |
| 17729 | break; |
| 17730 | case "layers": |
| 17731 | view = SidebarView.LAYERS; |
| 17732 | break; |
| 17733 | case "none": |
| 17734 | view = SidebarView.NONE; |
| 17735 | break; |
| 17736 | default: |
| 17737 | console.error('Invalid "pagemode" hash parameter: ' + mode); |
| 17738 | return; |
| 17739 | } |
| 17740 | PDFViewerApplication.pdfSidebar?.switchView(view, true); |
| 17741 | } |
| 17742 | function webViewerNamedAction(evt) { |
| 17743 | switch (evt.action) { |
| 17744 | case "GoToPage": |
| 17745 | PDFViewerApplication.appConfig.toolbar?.pageNumber.select(); |
| 17746 | break; |
| 17747 | case "Find": |
| 17748 | if (!PDFViewerApplication.supportsIntegratedFind) { |
| 17749 | PDFViewerApplication.findBar?.toggle(); |
| 17750 | } |
| 17751 | break; |
| 17752 | case "Print": |
| 17753 | PDFViewerApplication.triggerPrinting(); |
| 17754 | break; |
| 17755 | case "SaveAs": |
| 17756 | PDFViewerApplication.downloadOrSave(); |
| 17757 | break; |
| 17758 | } |
| 17759 | } |
| 17760 | function webViewerPresentationModeChanged(evt) { |
| 17761 | PDFViewerApplication.pdfViewer.presentationModeState = evt.state; |
| 17762 | } |
| 17763 | function webViewerSidebarViewChanged({ |
| 17764 | view |
| 17765 | }) { |
| 17766 | PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = view === SidebarView.THUMBS; |
| 17767 | if (PDFViewerApplication.isInitialViewSet) { |
| 17768 | PDFViewerApplication.store?.set("sidebarView", view).catch(() => {}); |
| 17769 | } |
| 17770 | } |
| 17771 | function webViewerUpdateViewarea({ |
| 17772 | location |
| 17773 | }) { |
| 17774 | if (PDFViewerApplication.isInitialViewSet) { |
| 17775 | PDFViewerApplication.store?.setMultiple({ |
| 17776 | page: location.pageNumber, |
| 17777 | zoom: location.scale, |
| 17778 | scrollLeft: location.left, |
| 17779 | scrollTop: location.top, |
| 17780 | rotation: location.rotation |
| 17781 | }).catch(() => {}); |
| 17782 | } |
| 17783 | if (PDFViewerApplication.appConfig.secondaryToolbar) { |
| 17784 | const href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams); |
| 17785 | PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href; |
| 17786 | } |
| 17787 | } |
| 17788 | function webViewerScrollModeChanged(evt) { |
| 17789 | if (PDFViewerApplication.isInitialViewSet && !PDFViewerApplication.pdfViewer.isInPresentationMode) { |
| 17790 | PDFViewerApplication.store?.set("scrollMode", evt.mode).catch(() => {}); |
| 17791 | } |
| 17792 | } |
| 17793 | function webViewerSpreadModeChanged(evt) { |
| 17794 | if (PDFViewerApplication.isInitialViewSet && !PDFViewerApplication.pdfViewer.isInPresentationMode) { |
| 17795 | PDFViewerApplication.store?.set("spreadMode", evt.mode).catch(() => {}); |
| 17796 | } |
| 17797 | } |
| 17798 | function webViewerResize() { |
| 17799 | const { |
| 17800 | pdfDocument, |
| 17801 | pdfViewer, |
| 17802 | pdfRenderingQueue |
| 17803 | } = PDFViewerApplication; |
| 17804 | if (pdfRenderingQueue.printing && window.matchMedia("print").matches) { |
| 17805 | return; |
| 17806 | } |
| 17807 | if (!pdfDocument) { |
| 17808 | return; |
| 17809 | } |
| 17810 | const currentScaleValue = pdfViewer.currentScaleValue; |
| 17811 | if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") { |
| 17812 | pdfViewer.currentScaleValue = currentScaleValue; |
| 17813 | } |
| 17814 | pdfViewer.update(); |
| 17815 | } |
| 17816 | function webViewerHashchange(evt) { |
| 17817 | const hash = evt.hash; |
| 17818 | if (!hash) { |
| 17819 | return; |
| 17820 | } |
| 17821 | if (!PDFViewerApplication.isInitialViewSet) { |
| 17822 | PDFViewerApplication.initialBookmark = hash; |
| 17823 | } else if (!PDFViewerApplication.pdfHistory?.popStateInProgress) { |
| 17824 | PDFViewerApplication.pdfLinkService.setHash(hash); |
| 17825 | } |
| 17826 | } |
| 17827 | { |
| 17828 | var webViewerFileInputChange = function (evt) { |
| 17829 | if (PDFViewerApplication.pdfViewer?.isInPresentationMode) { |
| 17830 | return; |
| 17831 | } |
| 17832 | const file = evt.fileInput.files[0]; |
| 17833 | PDFViewerApplication.open({ |
| 17834 | url: URL.createObjectURL(file), |
| 17835 | originalUrl: file.name |
| 17836 | }); |
| 17837 | }; |
| 17838 | var webViewerOpenFile = function (evt) { |
| 17839 | PDFViewerApplication._openFileInput?.click(); |
| 17840 | }; |
| 17841 | } |
| 17842 | function webViewerPresentationMode() { |
| 17843 | PDFViewerApplication.requestPresentationMode(); |
| 17844 | } |
| 17845 | function webViewerSwitchAnnotationEditorMode(evt) { |
| 17846 | PDFViewerApplication.pdfViewer.annotationEditorMode = evt; |
| 17847 | } |
| 17848 | function webViewerSwitchAnnotationEditorParams(evt) { |
| 17849 | PDFViewerApplication.pdfViewer.annotationEditorParams = evt; |
| 17850 | } |
| 17851 | function webViewerPrint() { |
| 17852 | PDFViewerApplication.triggerPrinting(); |
| 17853 | } |
| 17854 | function webViewerDownload() { |
| 17855 | PDFViewerApplication.downloadOrSave(); |
| 17856 | } |
| 17857 | function webViewerFirstPage() { |
| 17858 | PDFViewerApplication.page = 1; |
| 17859 | } |
| 17860 | function webViewerLastPage() { |
| 17861 | PDFViewerApplication.page = PDFViewerApplication.pagesCount; |
| 17862 | } |
| 17863 | function webViewerNextPage() { |
| 17864 | PDFViewerApplication.pdfViewer.nextPage(); |
| 17865 | } |
| 17866 | function webViewerPreviousPage() { |
| 17867 | PDFViewerApplication.pdfViewer.previousPage(); |
| 17868 | } |
| 17869 | function webViewerZoomIn() { |
| 17870 | PDFViewerApplication.zoomIn(); |
| 17871 | } |
| 17872 | function webViewerZoomOut() { |
| 17873 | PDFViewerApplication.zoomOut(); |
| 17874 | } |
| 17875 | function webViewerZoomReset() { |
| 17876 | PDFViewerApplication.zoomReset(); |
| 17877 | } |
| 17878 | function webViewerPageNumberChanged(evt) { |
| 17879 | const pdfViewer = PDFViewerApplication.pdfViewer; |
| 17880 | if (evt.value !== "") { |
| 17881 | PDFViewerApplication.pdfLinkService.goToPage(evt.value); |
| 17882 | } |
| 17883 | if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) { |
| 17884 | PDFViewerApplication.toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel); |
| 17885 | } |
| 17886 | } |
| 17887 | function webViewerScaleChanged(evt) { |
| 17888 | PDFViewerApplication.pdfViewer.currentScaleValue = evt.value; |
| 17889 | } |
| 17890 | function webViewerRotateCw() { |
| 17891 | PDFViewerApplication.rotatePages(90); |
| 17892 | } |
| 17893 | function webViewerRotateCcw() { |
| 17894 | PDFViewerApplication.rotatePages(-90); |
| 17895 | } |
| 17896 | function webViewerOptionalContentConfig(evt) { |
| 17897 | PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise; |
| 17898 | } |
| 17899 | function webViewerSwitchScrollMode(evt) { |
| 17900 | PDFViewerApplication.pdfViewer.scrollMode = evt.mode; |
| 17901 | } |
| 17902 | function webViewerSwitchSpreadMode(evt) { |
| 17903 | PDFViewerApplication.pdfViewer.spreadMode = evt.mode; |
| 17904 | } |
| 17905 | function webViewerDocumentProperties() { |
| 17906 | PDFViewerApplication.pdfDocumentProperties?.open(); |
| 17907 | } |
| 17908 | function webViewerFindFromUrlHash(evt) { |
| 17909 | PDFViewerApplication.eventBus.dispatch("find", { |
| 17910 | source: evt.source, |
| 17911 | type: "", |
| 17912 | query: evt.query, |
| 17913 | caseSensitive: false, |
| 17914 | entireWord: false, |
| 17915 | highlightAll: true, |
| 17916 | findPrevious: false, |
| 17917 | matchDiacritics: true |
| 17918 | }); |
| 17919 | } |
| 17920 | function webViewerUpdateFindMatchesCount({ |
| 17921 | matchesCount |
| 17922 | }) { |
| 17923 | if (PDFViewerApplication.supportsIntegratedFind) { |
| 17924 | PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount); |
| 17925 | } else { |
| 17926 | PDFViewerApplication.findBar?.updateResultsCount(matchesCount); |
| 17927 | } |
| 17928 | } |
| 17929 | function webViewerUpdateFindControlState({ |
| 17930 | state, |
| 17931 | previous, |
| 17932 | matchesCount, |
| 17933 | rawQuery |
| 17934 | }) { |
| 17935 | if (PDFViewerApplication.supportsIntegratedFind) { |
| 17936 | PDFViewerApplication.externalServices.updateFindControlState({ |
| 17937 | result: state, |
| 17938 | findPrevious: previous, |
| 17939 | matchesCount, |
| 17940 | rawQuery |
| 17941 | }); |
| 17942 | } else { |
| 17943 | PDFViewerApplication.findBar?.updateUIState(state, previous, matchesCount); |
| 17944 | } |
| 17945 | } |
| 17946 | function webViewerScaleChanging(evt) { |
| 17947 | PDFViewerApplication.toolbar?.setPageScale(evt.presetValue, evt.scale); |
| 17948 | PDFViewerApplication.pdfViewer.update(); |
| 17949 | } |
| 17950 | function webViewerRotationChanging(evt) { |
| 17951 | if (PDFViewerApplication.pdfThumbnailViewer) { |
| 17952 | PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation; |
| 17953 | } |
| 17954 | PDFViewerApplication.forceRendering(); |
| 17955 | PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber; |
| 17956 | } |
| 17957 | function webViewerPageChanging({ |
| 17958 | pageNumber, |
| 17959 | pageLabel |
| 17960 | }) { |
| 17961 | PDFViewerApplication.toolbar?.setPageNumber(pageNumber, pageLabel); |
| 17962 | PDFViewerApplication.secondaryToolbar?.setPageNumber(pageNumber); |
| 17963 | if (PDFViewerApplication.pdfSidebar?.visibleView === SidebarView.THUMBS) { |
| 17964 | PDFViewerApplication.pdfThumbnailViewer?.scrollThumbnailIntoView(pageNumber); |
| 17965 | } |
| 17966 | const currentPage = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1); |
| 17967 | PDFViewerApplication.toolbar?.updateLoadingIndicatorState(currentPage?.renderingState === RenderingStates.RUNNING); |
| 17968 | } |
| 17969 | function webViewerResolutionChange(evt) { |
| 17970 | PDFViewerApplication.pdfViewer.refresh(); |
| 17971 | } |
| 17972 | function webViewerVisibilityChange(evt) { |
| 17973 | if (document.visibilityState === "visible") { |
| 17974 | setZoomDisabledTimeout(); |
| 17975 | } |
| 17976 | } |
| 17977 | let zoomDisabledTimeout = null; |
| 17978 | function setZoomDisabledTimeout() { |
| 17979 | if (zoomDisabledTimeout) { |
| 17980 | clearTimeout(zoomDisabledTimeout); |
| 17981 | } |
| 17982 | zoomDisabledTimeout = setTimeout(function () { |
| 17983 | zoomDisabledTimeout = null; |
| 17984 | }, WHEEL_ZOOM_DISABLED_TIMEOUT); |
| 17985 | } |
| 17986 | function webViewerWheel(evt) { |
| 17987 | const { |
| 17988 | pdfViewer, |
| 17989 | supportsMouseWheelZoomCtrlKey, |
| 17990 | supportsMouseWheelZoomMetaKey, |
| 17991 | supportsPinchToZoom |
| 17992 | } = PDFViewerApplication; |
| 17993 | if (pdfViewer.isInPresentationMode) { |
| 17994 | return; |
| 17995 | } |
| 17996 | const deltaMode = evt.deltaMode; |
| 17997 | let scaleFactor = Math.exp(-evt.deltaY / 100); |
| 17998 | const isBuiltInMac = false; |
| 17999 | const isPinchToZoom = evt.ctrlKey && !PDFViewerApplication._isCtrlKeyDown && deltaMode === WheelEvent.DOM_DELTA_PIXEL && evt.deltaX === 0 && (Math.abs(scaleFactor - 1) < 0.05 || isBuiltInMac) && evt.deltaZ === 0; |
| 18000 | const origin = [evt.clientX, evt.clientY]; |
| 18001 | if (isPinchToZoom || evt.ctrlKey && supportsMouseWheelZoomCtrlKey || evt.metaKey && supportsMouseWheelZoomMetaKey) { |
| 18002 | evt.preventDefault(); |
| 18003 | if (PDFViewerApplication._isScrolling || zoomDisabledTimeout || document.visibilityState === "hidden" || PDFViewerApplication.overlayManager.active) { |
| 18004 | return; |
| 18005 | } |
| 18006 | if (isPinchToZoom && supportsPinchToZoom) { |
| 18007 | scaleFactor = PDFViewerApplication._accumulateFactor(pdfViewer.currentScale, scaleFactor, "_wheelUnusedFactor"); |
| 18008 | PDFViewerApplication.updateZoom(null, scaleFactor, origin); |
| 18009 | } else { |
| 18010 | const delta = normalizeWheelEventDirection(evt); |
| 18011 | let ticks = 0; |
| 18012 | if (deltaMode === WheelEvent.DOM_DELTA_LINE || deltaMode === WheelEvent.DOM_DELTA_PAGE) { |
| 18013 | if (Math.abs(delta) >= 1) { |
| 18014 | ticks = Math.sign(delta); |
| 18015 | } else { |
| 18016 | ticks = PDFViewerApplication._accumulateTicks(delta, "_wheelUnusedTicks"); |
| 18017 | } |
| 18018 | } else { |
| 18019 | const PIXELS_PER_LINE_SCALE = 30; |
| 18020 | ticks = PDFViewerApplication._accumulateTicks(delta / PIXELS_PER_LINE_SCALE, "_wheelUnusedTicks"); |
| 18021 | } |
| 18022 | PDFViewerApplication.updateZoom(ticks, null, origin); |
| 18023 | } |
| 18024 | } |
| 18025 | } |
| 18026 | function webViewerTouchStart(evt) { |
| 18027 | if (PDFViewerApplication.pdfViewer.isInPresentationMode || evt.touches.length < 2) { |
| 18028 | return; |
| 18029 | } |
| 18030 | evt.preventDefault(); |
| 18031 | if (evt.touches.length !== 2 || PDFViewerApplication.overlayManager.active) { |
| 18032 | PDFViewerApplication._touchInfo = null; |
| 18033 | return; |
| 18034 | } |
| 18035 | let [touch0, touch1] = evt.touches; |
| 18036 | if (touch0.identifier > touch1.identifier) { |
| 18037 | [touch0, touch1] = [touch1, touch0]; |
| 18038 | } |
| 18039 | PDFViewerApplication._touchInfo = { |
| 18040 | touch0X: touch0.pageX, |
| 18041 | touch0Y: touch0.pageY, |
| 18042 | touch1X: touch1.pageX, |
| 18043 | touch1Y: touch1.pageY |
| 18044 | }; |
| 18045 | } |
| 18046 | function webViewerTouchMove(evt) { |
| 18047 | if (!PDFViewerApplication._touchInfo || evt.touches.length !== 2) { |
| 18048 | return; |
| 18049 | } |
| 18050 | const { |
| 18051 | pdfViewer, |
| 18052 | _touchInfo, |
| 18053 | supportsPinchToZoom |
| 18054 | } = PDFViewerApplication; |
| 18055 | let [touch0, touch1] = evt.touches; |
| 18056 | if (touch0.identifier > touch1.identifier) { |
| 18057 | [touch0, touch1] = [touch1, touch0]; |
| 18058 | } |
| 18059 | const { |
| 18060 | pageX: page0X, |
| 18061 | pageY: page0Y |
| 18062 | } = touch0; |
| 18063 | const { |
| 18064 | pageX: page1X, |
| 18065 | pageY: page1Y |
| 18066 | } = touch1; |
| 18067 | const { |
| 18068 | touch0X: pTouch0X, |
| 18069 | touch0Y: pTouch0Y, |
| 18070 | touch1X: pTouch1X, |
| 18071 | touch1Y: pTouch1Y |
| 18072 | } = _touchInfo; |
| 18073 | if (Math.abs(pTouch0X - page0X) <= 1 && Math.abs(pTouch0Y - page0Y) <= 1 && Math.abs(pTouch1X - page1X) <= 1 && Math.abs(pTouch1Y - page1Y) <= 1) { |
| 18074 | return; |
| 18075 | } |
| 18076 | _touchInfo.touch0X = page0X; |
| 18077 | _touchInfo.touch0Y = page0Y; |
| 18078 | _touchInfo.touch1X = page1X; |
| 18079 | _touchInfo.touch1Y = page1Y; |
| 18080 | if (pTouch0X === page0X && pTouch0Y === page0Y) { |
| 18081 | const v1X = pTouch1X - page0X; |
| 18082 | const v1Y = pTouch1Y - page0Y; |
| 18083 | const v2X = page1X - page0X; |
| 18084 | const v2Y = page1Y - page0Y; |
| 18085 | const det = v1X * v2Y - v1Y * v2X; |
| 18086 | if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) { |
| 18087 | return; |
| 18088 | } |
| 18089 | } else if (pTouch1X === page1X && pTouch1Y === page1Y) { |
| 18090 | const v1X = pTouch0X - page1X; |
| 18091 | const v1Y = pTouch0Y - page1Y; |
| 18092 | const v2X = page0X - page1X; |
| 18093 | const v2Y = page0Y - page1Y; |
| 18094 | const det = v1X * v2Y - v1Y * v2X; |
| 18095 | if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) { |
| 18096 | return; |
| 18097 | } |
| 18098 | } else { |
| 18099 | const diff0X = page0X - pTouch0X; |
| 18100 | const diff1X = page1X - pTouch1X; |
| 18101 | const diff0Y = page0Y - pTouch0Y; |
| 18102 | const diff1Y = page1Y - pTouch1Y; |
| 18103 | const dotProduct = diff0X * diff1X + diff0Y * diff1Y; |
| 18104 | if (dotProduct >= 0) { |
| 18105 | return; |
| 18106 | } |
| 18107 | } |
| 18108 | evt.preventDefault(); |
| 18109 | const origin = [(page0X + page1X) / 2, (page0Y + page1Y) / 2]; |
| 18110 | const distance = Math.hypot(page0X - page1X, page0Y - page1Y) || 1; |
| 18111 | const pDistance = Math.hypot(pTouch0X - pTouch1X, pTouch0Y - pTouch1Y) || 1; |
| 18112 | if (supportsPinchToZoom) { |
| 18113 | const newScaleFactor = PDFViewerApplication._accumulateFactor(pdfViewer.currentScale, distance / pDistance, "_touchUnusedFactor"); |
| 18114 | PDFViewerApplication.updateZoom(null, newScaleFactor, origin); |
| 18115 | } else { |
| 18116 | const PIXELS_PER_LINE_SCALE = 30; |
| 18117 | const ticks = PDFViewerApplication._accumulateTicks((distance - pDistance) / PIXELS_PER_LINE_SCALE, "_touchUnusedTicks"); |
| 18118 | PDFViewerApplication.updateZoom(ticks, null, origin); |
| 18119 | } |
| 18120 | } |
| 18121 | function webViewerTouchEnd(evt) { |
| 18122 | if (!PDFViewerApplication._touchInfo) { |
| 18123 | return; |
| 18124 | } |
| 18125 | evt.preventDefault(); |
| 18126 | PDFViewerApplication._touchInfo = null; |
| 18127 | PDFViewerApplication._touchUnusedTicks = 0; |
| 18128 | PDFViewerApplication._touchUnusedFactor = 1; |
| 18129 | } |
| 18130 | function webViewerClick(evt) { |
| 18131 | if (!PDFViewerApplication.secondaryToolbar?.isOpen) { |
| 18132 | return; |
| 18133 | } |
| 18134 | const appConfig = PDFViewerApplication.appConfig; |
| 18135 | if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar?.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar?.toggleButton) { |
| 18136 | PDFViewerApplication.secondaryToolbar.close(); |
| 18137 | } |
| 18138 | } |
| 18139 | function webViewerKeyUp(evt) { |
| 18140 | if (evt.key === "Control") { |
| 18141 | PDFViewerApplication._isCtrlKeyDown = false; |
| 18142 | } |
| 18143 | } |
| 18144 | function webViewerKeyDown(evt) { |
| 18145 | PDFViewerApplication._isCtrlKeyDown = evt.key === "Control"; |
| 18146 | if (PDFViewerApplication.overlayManager.active) { |
| 18147 | return; |
| 18148 | } |
| 18149 | const { |
| 18150 | eventBus, |
| 18151 | pdfViewer |
| 18152 | } = PDFViewerApplication; |
| 18153 | const isViewerInPresentationMode = pdfViewer.isInPresentationMode; |
| 18154 | let handled = false, |
| 18155 | ensureViewerFocused = false; |
| 18156 | const cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0); |
| 18157 | if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) { |
| 18158 | switch (evt.keyCode) { |
| 18159 | case 70: |
| 18160 | if (!PDFViewerApplication.supportsIntegratedFind && !evt.shiftKey) { |
| 18161 | PDFViewerApplication.findBar?.open(); |
| 18162 | handled = true; |
| 18163 | } |
| 18164 | break; |
| 18165 | case 71: |
| 18166 | if (!PDFViewerApplication.supportsIntegratedFind) { |
| 18167 | const { |
| 18168 | state |
| 18169 | } = PDFViewerApplication.findController; |
| 18170 | if (state) { |
| 18171 | const newState = { |
| 18172 | source: window, |
| 18173 | type: "again", |
| 18174 | findPrevious: cmd === 5 || cmd === 12 |
| 18175 | }; |
| 18176 | eventBus.dispatch("find", { |
| 18177 | ...state, |
| 18178 | ...newState |
| 18179 | }); |
| 18180 | } |
| 18181 | handled = true; |
| 18182 | } |
| 18183 | break; |
| 18184 | case 61: |
| 18185 | case 107: |
| 18186 | case 187: |
| 18187 | case 171: |
| 18188 | PDFViewerApplication.zoomIn(); |
| 18189 | handled = true; |
| 18190 | break; |
| 18191 | case 173: |
| 18192 | case 109: |
| 18193 | case 189: |
| 18194 | PDFViewerApplication.zoomOut(); |
| 18195 | handled = true; |
| 18196 | break; |
| 18197 | case 48: |
| 18198 | case 96: |
| 18199 | if (!isViewerInPresentationMode) { |
| 18200 | setTimeout(function () { |
| 18201 | PDFViewerApplication.zoomReset(); |
| 18202 | }); |
| 18203 | handled = false; |
| 18204 | } |
| 18205 | break; |
| 18206 | case 38: |
| 18207 | if (isViewerInPresentationMode || PDFViewerApplication.page > 1) { |
| 18208 | PDFViewerApplication.page = 1; |
| 18209 | handled = true; |
| 18210 | ensureViewerFocused = true; |
| 18211 | } |
| 18212 | break; |
| 18213 | case 40: |
| 18214 | if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) { |
| 18215 | PDFViewerApplication.page = PDFViewerApplication.pagesCount; |
| 18216 | handled = true; |
| 18217 | ensureViewerFocused = true; |
| 18218 | } |
| 18219 | break; |
| 18220 | } |
| 18221 | } |
| 18222 | if (cmd === 1 || cmd === 8) { |
| 18223 | switch (evt.keyCode) { |
| 18224 | case 83: |
| 18225 | eventBus.dispatch("download", { |
| 18226 | source: window |
| 18227 | }); |
| 18228 | handled = true; |
| 18229 | break; |
| 18230 | case 79: |
| 18231 | { |
| 18232 | eventBus.dispatch("openfile", { |
| 18233 | source: window |
| 18234 | }); |
| 18235 | handled = true; |
| 18236 | } |
| 18237 | break; |
| 18238 | } |
| 18239 | } |
| 18240 | if (cmd === 3 || cmd === 10) { |
| 18241 | switch (evt.keyCode) { |
| 18242 | case 80: |
| 18243 | PDFViewerApplication.requestPresentationMode(); |
| 18244 | handled = true; |
| 18245 | PDFViewerApplication.externalServices.reportTelemetry({ |
| 18246 | type: "buttons", |
| 18247 | data: { |
| 18248 | id: "presentationModeKeyboard" |
| 18249 | } |
| 18250 | }); |
| 18251 | break; |
| 18252 | case 71: |
| 18253 | if (PDFViewerApplication.appConfig.toolbar) { |
| 18254 | PDFViewerApplication.appConfig.toolbar.pageNumber.select(); |
| 18255 | handled = true; |
| 18256 | } |
| 18257 | break; |
| 18258 | } |
| 18259 | } |
| 18260 | if (handled) { |
| 18261 | if (ensureViewerFocused && !isViewerInPresentationMode) { |
| 18262 | pdfViewer.focus(); |
| 18263 | } |
| 18264 | evt.preventDefault(); |
| 18265 | return; |
| 18266 | } |
| 18267 | const curElement = getActiveOrFocusedElement(); |
| 18268 | const curElementTagName = curElement?.tagName.toUpperCase(); |
| 18269 | if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElementTagName === "BUTTON" && (evt.keyCode === 13 || evt.keyCode === 32) || curElement?.isContentEditable) { |
| 18270 | if (evt.keyCode !== 27) { |
| 18271 | return; |
| 18272 | } |
| 18273 | } |
| 18274 | if (cmd === 0) { |
| 18275 | let turnPage = 0, |
| 18276 | turnOnlyIfPageFit = false; |
| 18277 | switch (evt.keyCode) { |
| 18278 | case 38: |
| 18279 | if (PDFViewerApplication.supportsCaretBrowsingMode) { |
| 18280 | PDFViewerApplication.moveCaret(true, false); |
| 18281 | handled = true; |
| 18282 | break; |
| 18283 | } |
| 18284 | case 33: |
| 18285 | if (pdfViewer.isVerticalScrollbarEnabled) { |
| 18286 | turnOnlyIfPageFit = true; |
| 18287 | } |
| 18288 | turnPage = -1; |
| 18289 | break; |
| 18290 | case 8: |
| 18291 | if (!isViewerInPresentationMode) { |
| 18292 | turnOnlyIfPageFit = true; |
| 18293 | } |
| 18294 | turnPage = -1; |
| 18295 | break; |
| 18296 | case 37: |
| 18297 | if (PDFViewerApplication.supportsCaretBrowsingMode) { |
| 18298 | return; |
| 18299 | } |
| 18300 | if (pdfViewer.isHorizontalScrollbarEnabled) { |
| 18301 | turnOnlyIfPageFit = true; |
| 18302 | } |
| 18303 | case 75: |
| 18304 | case 80: |
| 18305 | turnPage = -1; |
| 18306 | break; |
| 18307 | case 27: |
| 18308 | if (PDFViewerApplication.secondaryToolbar?.isOpen) { |
| 18309 | PDFViewerApplication.secondaryToolbar.close(); |
| 18310 | handled = true; |
| 18311 | } |
| 18312 | if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar?.opened) { |
| 18313 | PDFViewerApplication.findBar.close(); |
| 18314 | handled = true; |
| 18315 | } |
| 18316 | break; |
| 18317 | case 40: |
| 18318 | if (PDFViewerApplication.supportsCaretBrowsingMode) { |
| 18319 | PDFViewerApplication.moveCaret(false, false); |
| 18320 | handled = true; |
| 18321 | break; |
| 18322 | } |
| 18323 | case 34: |
| 18324 | if (pdfViewer.isVerticalScrollbarEnabled) { |
| 18325 | turnOnlyIfPageFit = true; |
| 18326 | } |
| 18327 | turnPage = 1; |
| 18328 | break; |
| 18329 | case 13: |
| 18330 | case 32: |
| 18331 | if (!isViewerInPresentationMode) { |
| 18332 | turnOnlyIfPageFit = true; |
| 18333 | } |
| 18334 | turnPage = 1; |
| 18335 | break; |
| 18336 | case 39: |
| 18337 | if (PDFViewerApplication.supportsCaretBrowsingMode) { |
| 18338 | return; |
| 18339 | } |
| 18340 | if (pdfViewer.isHorizontalScrollbarEnabled) { |
| 18341 | turnOnlyIfPageFit = true; |
| 18342 | } |
| 18343 | case 74: |
| 18344 | case 78: |
| 18345 | turnPage = 1; |
| 18346 | break; |
| 18347 | case 36: |
| 18348 | if (isViewerInPresentationMode || PDFViewerApplication.page > 1) { |
| 18349 | PDFViewerApplication.page = 1; |
| 18350 | handled = true; |
| 18351 | ensureViewerFocused = true; |
| 18352 | } |
| 18353 | break; |
| 18354 | case 35: |
| 18355 | if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) { |
| 18356 | PDFViewerApplication.page = PDFViewerApplication.pagesCount; |
| 18357 | handled = true; |
| 18358 | ensureViewerFocused = true; |
| 18359 | } |
| 18360 | break; |
| 18361 | case 83: |
| 18362 | PDFViewerApplication.pdfCursorTools?.switchTool(CursorTool.SELECT); |
| 18363 | break; |
| 18364 | case 72: |
| 18365 | PDFViewerApplication.pdfCursorTools?.switchTool(CursorTool.HAND); |
| 18366 | break; |
| 18367 | case 82: |
| 18368 | PDFViewerApplication.rotatePages(90); |
| 18369 | break; |
| 18370 | case 115: |
| 18371 | PDFViewerApplication.pdfSidebar?.toggle(); |
| 18372 | break; |
| 18373 | } |
| 18374 | if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) { |
| 18375 | if (turnPage > 0) { |
| 18376 | pdfViewer.nextPage(); |
| 18377 | } else { |
| 18378 | pdfViewer.previousPage(); |
| 18379 | } |
| 18380 | handled = true; |
| 18381 | } |
| 18382 | } |
| 18383 | if (cmd === 4) { |
| 18384 | switch (evt.keyCode) { |
| 18385 | case 13: |
| 18386 | case 32: |
| 18387 | if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") { |
| 18388 | break; |
| 18389 | } |
| 18390 | pdfViewer.previousPage(); |
| 18391 | handled = true; |
| 18392 | break; |
| 18393 | case 38: |
| 18394 | PDFViewerApplication.moveCaret(true, true); |
| 18395 | handled = true; |
| 18396 | break; |
| 18397 | case 40: |
| 18398 | PDFViewerApplication.moveCaret(false, true); |
| 18399 | handled = true; |
| 18400 | break; |
| 18401 | case 82: |
| 18402 | PDFViewerApplication.rotatePages(-90); |
| 18403 | break; |
| 18404 | } |
| 18405 | } |
| 18406 | if (!handled && !isViewerInPresentationMode) { |
| 18407 | if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") { |
| 18408 | ensureViewerFocused = true; |
| 18409 | } |
| 18410 | } |
| 18411 | if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) { |
| 18412 | pdfViewer.focus(); |
| 18413 | } |
| 18414 | if (handled) { |
| 18415 | evt.preventDefault(); |
| 18416 | } |
| 18417 | } |
| 18418 | function beforeUnload(evt) { |
| 18419 | evt.preventDefault(); |
| 18420 | evt.returnValue = ""; |
| 18421 | return false; |
| 18422 | } |
| 18423 | function webViewerAnnotationEditorStatesChanged(data) { |
| 18424 | PDFViewerApplication.externalServices.updateEditorStates(data); |
| 18425 | } |
| 18426 | function webViewerReportTelemetry({ |
| 18427 | details |
| 18428 | }) { |
| 18429 | PDFViewerApplication.externalServices.reportTelemetry(details); |
| 18430 | } |
| 18431 | |
| 18432 | ;// CONCATENATED MODULE: ./web/viewer.js |
| 18433 | |
| 18434 | |
| 18435 | |
| 18436 | |
| 18437 | const pdfjsVersion = "4.3.136"; |
| 18438 | const pdfjsBuild = "0cec64437"; |
| 18439 | const AppConstants = { |
| 18440 | LinkTarget: LinkTarget, |
| 18441 | RenderingStates: RenderingStates, |
| 18442 | ScrollMode: ScrollMode, |
| 18443 | SpreadMode: SpreadMode |
| 18444 | }; |
| 18445 | window.PDFViewerApplication = PDFViewerApplication; |
| 18446 | window.PDFViewerApplicationConstants = AppConstants; |
| 18447 | window.PDFViewerApplicationOptions = AppOptions; |
| 18448 | function getViewerConfiguration() { |
| 18449 | return { |
| 18450 | appContainer: document.body, |
| 18451 | mainContainer: document.getElementById("viewerContainer"), |
| 18452 | viewerContainer: document.getElementById("viewer"), |
| 18453 | toolbar: { |
| 18454 | container: document.getElementById("toolbarViewer"), |
| 18455 | numPages: document.getElementById("numPages"), |
| 18456 | pageNumber: document.getElementById("pageNumber"), |
| 18457 | scaleSelect: document.getElementById("scaleSelect"), |
| 18458 | customScaleOption: document.getElementById("customScaleOption"), |
| 18459 | previous: document.getElementById("previous"), |
| 18460 | next: document.getElementById("next"), |
| 18461 | zoomIn: document.getElementById("zoomIn"), |
| 18462 | zoomOut: document.getElementById("zoomOut"), |
| 18463 | viewFind: document.getElementById("viewFind"), |
| 18464 | print: document.getElementById("print"), |
| 18465 | editorFreeTextButton: document.getElementById("editorFreeText"), |
| 18466 | editorFreeTextParamsToolbar: document.getElementById("editorFreeTextParamsToolbar"), |
| 18467 | editorHighlightButton: document.getElementById("editorHighlight"), |
| 18468 | editorHighlightParamsToolbar: document.getElementById("editorHighlightParamsToolbar"), |
| 18469 | editorHighlightColorPicker: document.getElementById("editorHighlightColorPicker"), |
| 18470 | editorInkButton: document.getElementById("editorInk"), |
| 18471 | editorInkParamsToolbar: document.getElementById("editorInkParamsToolbar"), |
| 18472 | editorStampButton: document.getElementById("editorStamp"), |
| 18473 | editorStampParamsToolbar: document.getElementById("editorStampParamsToolbar"), |
| 18474 | download: document.getElementById("download") |
| 18475 | }, |
| 18476 | secondaryToolbar: { |
| 18477 | toolbar: document.getElementById("secondaryToolbar"), |
| 18478 | toggleButton: document.getElementById("secondaryToolbarToggle"), |
| 18479 | presentationModeButton: document.getElementById("presentationMode"), |
| 18480 | openFileButton: document.getElementById("secondaryOpenFile"), |
| 18481 | printButton: document.getElementById("secondaryPrint"), |
| 18482 | downloadButton: document.getElementById("secondaryDownload"), |
| 18483 | viewBookmarkButton: document.getElementById("viewBookmark"), |
| 18484 | firstPageButton: document.getElementById("firstPage"), |
| 18485 | lastPageButton: document.getElementById("lastPage"), |
| 18486 | pageRotateCwButton: document.getElementById("pageRotateCw"), |
| 18487 | pageRotateCcwButton: document.getElementById("pageRotateCcw"), |
| 18488 | cursorSelectToolButton: document.getElementById("cursorSelectTool"), |
| 18489 | cursorHandToolButton: document.getElementById("cursorHandTool"), |
| 18490 | scrollPageButton: document.getElementById("scrollPage"), |
| 18491 | scrollVerticalButton: document.getElementById("scrollVertical"), |
| 18492 | scrollHorizontalButton: document.getElementById("scrollHorizontal"), |
| 18493 | scrollWrappedButton: document.getElementById("scrollWrapped"), |
| 18494 | spreadNoneButton: document.getElementById("spreadNone"), |
| 18495 | spreadOddButton: document.getElementById("spreadOdd"), |
| 18496 | spreadEvenButton: document.getElementById("spreadEven"), |
| 18497 | documentPropertiesButton: document.getElementById("documentProperties") |
| 18498 | }, |
| 18499 | sidebar: { |
| 18500 | outerContainer: document.getElementById("outerContainer"), |
| 18501 | sidebarContainer: document.getElementById("sidebarContainer"), |
| 18502 | toggleButton: document.getElementById("sidebarToggle"), |
| 18503 | resizer: document.getElementById("sidebarResizer"), |
| 18504 | thumbnailButton: document.getElementById("viewThumbnail"), |
| 18505 | outlineButton: document.getElementById("viewOutline"), |
| 18506 | attachmentsButton: document.getElementById("viewAttachments"), |
| 18507 | layersButton: document.getElementById("viewLayers"), |
| 18508 | thumbnailView: document.getElementById("thumbnailView"), |
| 18509 | outlineView: document.getElementById("outlineView"), |
| 18510 | attachmentsView: document.getElementById("attachmentsView"), |
| 18511 | layersView: document.getElementById("layersView"), |
| 18512 | currentOutlineItemButton: document.getElementById("currentOutlineItem") |
| 18513 | }, |
| 18514 | findBar: { |
| 18515 | bar: document.getElementById("findbar"), |
| 18516 | toggleButton: document.getElementById("viewFind"), |
| 18517 | findField: document.getElementById("findInput"), |
| 18518 | highlightAllCheckbox: document.getElementById("findHighlightAll"), |
| 18519 | caseSensitiveCheckbox: document.getElementById("findMatchCase"), |
| 18520 | matchDiacriticsCheckbox: document.getElementById("findMatchDiacritics"), |
| 18521 | entireWordCheckbox: document.getElementById("findEntireWord"), |
| 18522 | findMsg: document.getElementById("findMsg"), |
| 18523 | findResultsCount: document.getElementById("findResultsCount"), |
| 18524 | findPreviousButton: document.getElementById("findPrevious"), |
| 18525 | findNextButton: document.getElementById("findNext") |
| 18526 | }, |
| 18527 | passwordOverlay: { |
| 18528 | dialog: document.getElementById("passwordDialog"), |
| 18529 | label: document.getElementById("passwordText"), |
| 18530 | input: document.getElementById("password"), |
| 18531 | submitButton: document.getElementById("passwordSubmit"), |
| 18532 | cancelButton: document.getElementById("passwordCancel") |
| 18533 | }, |
| 18534 | documentProperties: { |
| 18535 | dialog: document.getElementById("documentPropertiesDialog"), |
| 18536 | closeButton: document.getElementById("documentPropertiesClose"), |
| 18537 | fields: { |
| 18538 | fileName: document.getElementById("fileNameField"), |
| 18539 | fileSize: document.getElementById("fileSizeField"), |
| 18540 | title: document.getElementById("titleField"), |
| 18541 | author: document.getElementById("authorField"), |
| 18542 | subject: document.getElementById("subjectField"), |
| 18543 | keywords: document.getElementById("keywordsField"), |
| 18544 | creationDate: document.getElementById("creationDateField"), |
| 18545 | modificationDate: document.getElementById("modificationDateField"), |
| 18546 | creator: document.getElementById("creatorField"), |
| 18547 | producer: document.getElementById("producerField"), |
| 18548 | version: document.getElementById("versionField"), |
| 18549 | pageCount: document.getElementById("pageCountField"), |
| 18550 | pageSize: document.getElementById("pageSizeField"), |
| 18551 | linearized: document.getElementById("linearizedField") |
| 18552 | } |
| 18553 | }, |
| 18554 | altTextDialog: { |
| 18555 | dialog: document.getElementById("altTextDialog"), |
| 18556 | optionDescription: document.getElementById("descriptionButton"), |
| 18557 | optionDecorative: document.getElementById("decorativeButton"), |
| 18558 | textarea: document.getElementById("descriptionTextarea"), |
| 18559 | cancelButton: document.getElementById("altTextCancel"), |
| 18560 | saveButton: document.getElementById("altTextSave") |
| 18561 | }, |
| 18562 | annotationEditorParams: { |
| 18563 | editorFreeTextFontSize: document.getElementById("editorFreeTextFontSize"), |
| 18564 | editorFreeTextColor: document.getElementById("editorFreeTextColor"), |
| 18565 | editorInkColor: document.getElementById("editorInkColor"), |
| 18566 | editorInkThickness: document.getElementById("editorInkThickness"), |
| 18567 | editorInkOpacity: document.getElementById("editorInkOpacity"), |
| 18568 | editorStampAddImage: document.getElementById("editorStampAddImage"), |
| 18569 | editorFreeHighlightThickness: document.getElementById("editorFreeHighlightThickness"), |
| 18570 | editorHighlightShowAll: document.getElementById("editorHighlightShowAll") |
| 18571 | }, |
| 18572 | printContainer: document.getElementById("printContainer") |
| 18573 | }; |
| 18574 | } |
| 18575 | function webViewerLoad() { |
| 18576 | const config = getViewerConfiguration(); |
| 18577 | const event = new CustomEvent("webviewerloaded", { |
| 18578 | bubbles: true, |
| 18579 | cancelable: true, |
| 18580 | detail: { |
| 18581 | source: window |
| 18582 | } |
| 18583 | }); |
| 18584 | try { |
| 18585 | parent.document.dispatchEvent(event); |
| 18586 | } catch (ex) { |
| 18587 | console.error(`webviewerloaded: ${ex}`); |
| 18588 | document.dispatchEvent(event); |
| 18589 | } |
| 18590 | PDFViewerApplication.run(config); |
| 18591 | } |
| 18592 | document.blockUnblockOnload?.(true); |
| 18593 | if (document.readyState === "interactive" || document.readyState === "complete") { |
| 18594 | webViewerLoad(); |
| 18595 | } else { |
| 18596 | document.addEventListener("DOMContentLoaded", webViewerLoad, true); |
| 18597 | } |
| 18598 | |
| 18599 | })(); |
| 18600 | |
| 18601 | var __webpack_exports__PDFViewerApplication = __webpack_exports__.PDFViewerApplication; |
| 18602 | var __webpack_exports__PDFViewerApplicationConstants = __webpack_exports__.PDFViewerApplicationConstants; |
| 18603 | var __webpack_exports__PDFViewerApplicationOptions = __webpack_exports__.PDFViewerApplicationOptions; |
| 18604 | export { __webpack_exports__PDFViewerApplication as PDFViewerApplication, __webpack_exports__PDFViewerApplicationConstants as PDFViewerApplicationConstants, __webpack_exports__PDFViewerApplicationOptions as PDFViewerApplicationOptions }; |
| 18605 | |
| 18606 | //# sourceMappingURL=viewer.js.map |