: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
warn(`Unknown optional content policy ${group.policy}.`);
warn(`Unknown group type ${group.type}.`);
setVisibility(id, visible = true) {
const group = this.#groups.get(id);
warn(`Optional content group not found: ${id}`);
group._setVisible(INTERNAL, !!visible, true);
this.#cachedGetHash = null;
for (const elem of state) {
const group = this.#groups.get(elem);
group._setVisible(INTERNAL, true);
group._setVisible(INTERNAL, false);
group._setVisible(INTERNAL, !group.visible);
this.#cachedGetHash = null;
get hasInitialVisibility() {
return this.#initialHash === null || this.getHash() === this.#initialHash;
if (!this.#groups.size) {
return this.#order.slice();
return [...this.#groups.keys()];
return this.#groups.size > 0 ? objectFromMap(this.#groups) : null;
return this.#groups.get(id) || null;
if (this.#cachedGetHash !== null) {
return this.#cachedGetHash;
const hash = new MurmurHash3_64();
for (const [id, group] of this.#groups) {
hash.update(`${id}:${group.visible}`);
return this.#cachedGetHash = hash.hexdigest();
;// CONCATENATED MODULE: ./src/display/transport_stream.js
class PDFDataTransportStream {
constructor(pdfDataRangeTransport, {
assert(pdfDataRangeTransport, 'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');
contentDispositionFilename
} = pdfDataRangeTransport;
this._progressiveDone = progressiveDone;
this._contentDispositionFilename = contentDispositionFilename;
if (initialData?.length > 0) {
const buffer = initialData instanceof Uint8Array && initialData.byteLength === initialData.buffer.byteLength ? initialData.buffer : new Uint8Array(initialData).buffer;
this._queuedChunks.push(buffer);
this._pdfDataRangeTransport = pdfDataRangeTransport;
this._isStreamingSupported = !disableStream;
this._isRangeSupported = !disableRange;
this._contentLength = length;
this._fullRequestReader = null;
pdfDataRangeTransport.addRangeListener((begin, chunk) => {
pdfDataRangeTransport.addProgressListener((loaded, total) => {
pdfDataRangeTransport.addProgressiveReadListener(chunk => {
pdfDataRangeTransport.addProgressiveDoneListener(() => {
this._onProgressiveDone();
pdfDataRangeTransport.transportReady();
const buffer = chunk instanceof Uint8Array && chunk.byteLength === chunk.buffer.byteLength ? chunk.buffer : new Uint8Array(chunk).buffer;
if (begin === undefined) {
if (this._fullRequestReader) {
this._fullRequestReader._enqueue(buffer);
this._queuedChunks.push(buffer);
const found = this._rangeReaders.some(function (rangeReader) {
if (rangeReader._begin !== begin) {
rangeReader._enqueue(buffer);
assert(found, "_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.");
get _progressiveDataLength() {
return this._fullRequestReader?._loaded ?? 0;
if (evt.total === undefined) {
this._rangeReaders[0]?.onProgress?.({
this._fullRequestReader?.onProgress?.({
this._fullRequestReader?.progressiveDone();
this._progressiveDone = true;
_removeRangeReader(reader) {
const i = this._rangeReaders.indexOf(reader);
this._rangeReaders.splice(i, 1);
assert(!this._fullRequestReader, "PDFDataTransportStream.getFullReader can only be called once.");
const queuedChunks = this._queuedChunks;
this._queuedChunks = null;
return new PDFDataTransportStreamReader(this, queuedChunks, this._progressiveDone, this._contentDispositionFilename);
getRangeReader(begin, end) {
if (end <= this._progressiveDataLength) {
const reader = new PDFDataTransportStreamRangeReader(this, begin, end);
this._pdfDataRangeTransport.requestDataRange(begin, end);
this._rangeReaders.push(reader);
cancelAllRequests(reason) {
this._fullRequestReader?.cancel(reason);
for (const reader of this._rangeReaders.slice(0)) {
this._pdfDataRangeTransport.abort();
class PDFDataTransportStreamReader {
constructor(stream, queuedChunks, progressiveDone = false, contentDispositionFilename = null) {
this._done = progressiveDone || false;
this._filename = isPdfFile(contentDispositionFilename) ? contentDispositionFilename : null;
this._queuedChunks = queuedChunks || [];
for (const chunk of this._queuedChunks) {
this._loaded += chunk.byteLength;
this._headersReady = Promise.resolve();
stream._fullRequestReader = this;
if (this._requests.length > 0) {
const requestCapability = this._requests.shift();
requestCapability.resolve({
this._queuedChunks.push(chunk);
this._loaded += chunk.byteLength;
return this._headersReady;
return this._stream._isRangeSupported;
get isStreamingSupported() {
return this._stream._isStreamingSupported;
return this._stream._contentLength;
if (this._queuedChunks.length > 0) {
const chunk = this._queuedChunks.shift();
const requestCapability = Promise.withResolvers();
this._requests.push(requestCapability);
return requestCapability.promise;
for (const requestCapability of this._requests) {
requestCapability.resolve({
this._requests.length = 0;
class PDFDataTransportStreamRangeReader {
constructor(stream, begin, end) {
this._queuedChunk = null;
if (this._requests.length === 0) {
this._queuedChunk = chunk;
const requestsCapability = this._requests.shift();
requestsCapability.resolve({
for (const requestCapability of this._requests) {
requestCapability.resolve({
this._requests.length = 0;
this._stream._removeRangeReader(this);
get isStreamingSupported() {
const chunk = this._queuedChunk;
this._queuedChunk = null;
const requestCapability = Promise.withResolvers();
this._requests.push(requestCapability);
return requestCapability.promise;
for (const requestCapability of this._requests) {
requestCapability.resolve({
this._requests.length = 0;
this._stream._removeRangeReader(this);
;// CONCATENATED MODULE: ./src/display/content_disposition.js
function getFilenameFromContentDispositionHeader(contentDisposition) {
let needsEncodingFixup = true;
let tmp = toParamRegExp("filename\\*", "i").exec(contentDisposition);
let filename = rfc2616unquote(tmp);
filename = unescape(filename);
filename = rfc5987decode(filename);
filename = rfc2047decode(filename);
return fixupEncoding(filename);
tmp = rfc2231getparam(contentDisposition);
const filename = rfc2047decode(tmp);
return fixupEncoding(filename);
tmp = toParamRegExp("filename", "i").exec(contentDisposition);
let filename = rfc2616unquote(tmp);
filename = rfc2047decode(filename);
return fixupEncoding(filename);
function toParamRegExp(attributePattern, flags) {
return new RegExp("(?:^|;)\\s*" + attributePattern + "\\s*=\\s*" + "(" + '[^";\\s][^;\\s]*' + "|" + '"(?:[^"\\\\]|\\\\"?)+"?' + ")", flags);
function textdecode(encoding, value) {
if (!/^[\x00-\xFF]+$/.test(value)) {
const decoder = new TextDecoder(encoding, {
const buffer = stringToBytes(value);
value = decoder.decode(buffer);
needsEncodingFixup = false;
function fixupEncoding(value) {
if (needsEncodingFixup && /[\x80-\xff]/.test(value)) {
value = textdecode("utf-8", value);
if (needsEncodingFixup) {
value = textdecode("iso-8859-1", value);
function rfc2231getparam(contentDispositionStr) {
const iter = toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)", "ig");
while ((match = iter.exec(contentDispositionStr)) !== null) {
let [, n, quot, part] = match;
matches[n] = [quot, part];
for (let n = 0; n < matches.length; ++n) {
let [quot, part] = matches[n];
part = rfc2616unquote(part);
part = rfc5987decode(part);
function rfc2616unquote(value) {
if (value.startsWith('"')) {
const parts = value.slice(1).split('\\"');
for (let i = 0; i < parts.length; ++i) {
const quotindex = parts[i].indexOf('"');
parts[i] = parts[i].slice(0, quotindex);
parts[i] = parts[i].replaceAll(/\\(.)/g, "$1");
function rfc5987decode(extvalue) {
const encodingend = extvalue.indexOf("'");
if (encodingend === -1) {
const encoding = extvalue.slice(0, encodingend);
const langvalue = extvalue.slice(encodingend + 1);
const value = langvalue.replace(/^[^']*'/, "");
return textdecode(encoding, value);
function rfc2047decode(value) {
if (!value.startsWith("=?") || /[\x00-\x19\x80-\xff]/.test(value)) {
return value.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g, function (matches, charset, encoding, text) {
if (encoding === "q" || encoding === "Q") {
text = text.replaceAll("_", " ");
text = text.replaceAll(/=([0-9a-fA-F]{2})/g, function (match, hex) {
return String.fromCharCode(parseInt(hex, 16));
return textdecode(charset, text);
return textdecode(charset, text);
;// CONCATENATED MODULE: ./src/display/network_utils.js
function validateRangeRequestCapabilities({
allowRangeRequests: false,
suggestedLength: undefined