: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
this.pageLabel = typeof label === "string" ? label : null;
this.anchor.setAttribute("data-l10n-args", this.#pageL10nArgs);
if (this.renderingState !== RenderingStates.FINISHED) {
this.image?.setAttribute("data-l10n-args", this.#pageL10nArgs);
;// CONCATENATED MODULE: ./web/pdf_thumbnail_viewer.js
const THUMBNAIL_SCROLL_MARGIN = -19;
const THUMBNAIL_SELECTED_CLASS = "selected";
class PDFThumbnailViewer {
this.container = container;
this.eventBus = eventBus;
this.linkService = linkService;
this.renderingQueue = renderingQueue;
this.pageColors = pageColors || null;
this.scroll = watchScroll(this.container, this.#scrollUpdated.bind(this));
this.renderingQueue.renderHighestPriority();
return this._thumbnails[index];
return getVisibleElements({
scrollEl: this.container,
scrollThumbnailIntoView(pageNumber) {
const thumbnailView = this._thumbnails[pageNumber - 1];
console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
if (pageNumber !== this._currentPageNumber) {
const prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
} = this.#getVisibleThumbs();
let shouldScroll = false;
if (pageNumber <= first.id || pageNumber >= last.id) {
shouldScroll = percent < 100;
scrollIntoView(thumbnailView.div, {
top: THUMBNAIL_SCROLL_MARGIN
this._currentPageNumber = pageNumber;
return this._pagesRotation;
set pagesRotation(rotation) {
if (!isValidRotation(rotation)) {
throw new Error("Invalid thumbnails rotation angle.");
if (this._pagesRotation === rotation) {
this._pagesRotation = rotation;
for (const thumbnail of this._thumbnails) {
thumbnail.update(updateArgs);
for (const thumbnail of this._thumbnails) {
if (thumbnail.renderingState !== RenderingStates.FINISHED) {
TempImageFactory.destroyCanvas();
this._currentPageNumber = 1;
this.container.textContent = "";
setDocument(pdfDocument) {
this.pdfDocument = pdfDocument;
const firstPagePromise = pdfDocument.getPage(1);
const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig({
firstPagePromise.then(firstPdfPage => {
const pagesCount = pdfDocument.numPages;
const viewport = firstPdfPage.getViewport({
for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
const thumbnail = new PDFThumbnailView({
container: this.container,
defaultViewport: viewport.clone(),
optionalContentConfigPromise,
linkService: this.linkService,
renderingQueue: this.renderingQueue,
pageColors: this.pageColors
this._thumbnails.push(thumbnail);
this._thumbnails[0]?.setPdfPage(firstPdfPage);
const thumbnailView = this._thumbnails[this._currentPageNumber - 1];
thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
console.error("Unable to initialize thumbnail viewer", reason);
for (const thumbnail of this._thumbnails) {
thumbnail.cancelRendering();
} else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
this._pageLabels = labels;
for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
this._thumbnails[i].setPageLabel(this._pageLabels?.[i] ?? null);
async #ensurePdfPageLoaded(thumbView) {
return thumbView.pdfPage;
const pdfPage = await this.pdfDocument.getPage(thumbView.id);
if (!thumbView.pdfPage) {
thumbView.setPdfPage(pdfPage);
console.error("Unable to get page for thumb view", reason);
#getScrollAhead(visible) {
if (visible.first?.id === 1) {
} else if (visible.last?.id === this._thumbnails.length) {
const visibleThumbs = this.#getVisibleThumbs();
const scrollAhead = this.#getScrollAhead(visibleThumbs);
const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, scrollAhead);
this.#ensurePdfPageLoaded(thumbView).then(() => {
this.renderingQueue.renderView(thumbView);
;// CONCATENATED MODULE: ./web/annotation_editor_layer_builder.js
class AnnotationEditorLayerBuilder {
this.pdfPage = options.pdfPage;
this.accessibilityManager = options.accessibilityManager;
this.l10n = options.l10n;
this.l10n ||= new genericl10n_GenericL10n();
this.annotationEditorLayer = null;
this.#uiManager = options.uiManager;
this.#annotationLayer = options.annotationLayer || null;
this.#textLayer = options.textLayer || null;
this.#drawLayer = options.drawLayer || null;
this.#onAppend = options.onAppend || null;
async render(viewport, intent = "display") {
if (intent !== "display") {
const clonedViewport = viewport.clone({
this.annotationEditorLayer.update({
const div = this.div = document.createElement("div");
div.className = "annotationEditorLayer";
div.dir = this.#uiManager.direction;
this.annotationEditorLayer = new AnnotationEditorLayer({
uiManager: this.#uiManager,
accessibilityManager: this.accessibilityManager,
pageIndex: this.pdfPage.pageNumber - 1,
viewport: clonedViewport,
annotationLayer: this.#annotationLayer,
textLayer: this.#textLayer,
drawLayer: this.#drawLayer
viewport: clonedViewport,
this.annotationEditorLayer.render(parameters);
this.annotationEditorLayer.destroy();
if (!this.div || this.annotationEditorLayer.isInvisible) {
;// CONCATENATED MODULE: ./web/annotation_layer_builder.js
class AnnotationLayerBuilder {
#eventAbortController = null;
annotationStorage = null,
hasJSActionsPromise = null,
fieldObjectsPromise = null,
annotationCanvasMap = null,
accessibilityManager = null,
annotationEditorUIManager = null,
this.linkService = linkService;
this.downloadManager = downloadManager;
this.imageResourcesPath = imageResourcesPath;
this.renderForms = renderForms;
this.annotationStorage = annotationStorage;
this.enableScripting = enableScripting;
this._hasJSActionsPromise = hasJSActionsPromise || Promise.resolve(false);
this._fieldObjectsPromise = fieldObjectsPromise || Promise.resolve(null);
this._annotationCanvasMap = annotationCanvasMap;
this._accessibilityManager = accessibilityManager;
this._annotationEditorUIManager = annotationEditorUIManager;
this.#onAppend = onAppend;
this.annotationLayer = null;
this._eventBus = linkService.eventBus;
async render(viewport, intent = "display") {
if (this._cancelled || !this.annotationLayer) {
this.annotationLayer.update({
viewport: viewport.clone({
const [annotations, hasJSActions, fieldObjects] = await Promise.all([this.pdfPage.getAnnotations({
}), this._hasJSActionsPromise, this._fieldObjectsPromise]);
const div = this.div = document.createElement("div");
div.className = "annotationLayer";
if (annotations.length === 0) {
this.annotationLayer = new AnnotationLayer({
accessibilityManager: this._accessibilityManager,
annotationCanvasMap: this._annotationCanvasMap,
annotationEditorUIManager: this._annotationEditorUIManager,
viewport: viewport.clone({
await this.annotationLayer.render({
imageResourcesPath: this.imageResourcesPath,
renderForms: this.renderForms,
linkService: this.linkService,
downloadManager: this.downloadManager,
annotationStorage: this.annotationStorage,
enableScripting: this.enableScripting,
if (this.linkService.isInPresentationMode) {
this.#updatePresentationModeState(PresentationModeState.FULLSCREEN);
if (!this.#eventAbortController) {
this.#eventAbortController = new AbortController();
this._eventBus?._on("presentationmodechanged", evt => {
this.#updatePresentationModeState(evt.state);
signal: this.#eventAbortController.signal
this.#eventAbortController?.abort();
this.#eventAbortController = null;
#updatePresentationModeState(state) {
let disableFormElements = false;
case PresentationModeState.FULLSCREEN:
disableFormElements = true;
case PresentationModeState.NORMAL:
for (const section of this.div.childNodes) {
if (section.hasAttribute("data-internal-link")) {
section.inert = disableFormElements;
;// CONCATENATED MODULE: ./web/draw_layer_builder.js
this.pageIndex = options.pageIndex;
async render(intent = "display") {
if (intent !== "display" || this.#drawLayer || this._cancelled) {
this.#drawLayer = new DrawLayer({
pageIndex: this.pageIndex
this.#drawLayer.destroy();
this.#drawLayer?.setParent(parent);
;// CONCATENATED MODULE: ./web/struct_tree_layer_builder.js
const PDF_ROLE_TO_HTML_ROLE = {