import { defineComponent as O, useTemplateRef as U, ref as K, inject as A, watch as C, onMounted as J, createElementBlock as B, openBlock as N, toRaw as G, provide as V, Fragment as Ie, withDirectives as ae, renderSlot as oe, createElementVNode as F, vShow as ie, computed as Q, onUnmounted as Re, createBlock as de, createCommentVNode as pe, createVNode as me, mergeProps as ee, withCtx as Me, normalizeStyle as Oe, toDisplayString as fe, shallowRef as te, isRef as Be } from "vue"; import * as L from "pdfjs-dist"; import { AnnotationEditorUIManager as He, AnnotationEditorType as ge, AnnotationEditorParamsType as M } from "pdfjs-dist"; const $e = "file-attachment", Ve = "form-text", Ue = "form-select", ze = "form-checkbox", We = "form-radio", Ke = "form-button", he = ["click", "dblclick", "mouseover", "input", "change"]; function ne(a, t, e) { const o = []; if (e) for (const n of e) n[a] === t && o.push(n); return o; } function Y(a, t) { return { type: a, data: t }; } function X(a, t) { switch (a.type) { case "textarea": case "text": return Y(Ve, { fieldName: a.name, value: a.value }); case "select-one": case "select-multiple": const e = []; for (const n of a.options) e.push({ value: n.value, label: n.label }); const o = []; for (const n of a.selectedOptions) o.push({ value: n.value, label: n.label }); return Y(Ue, { fieldName: a.name, value: o, options: e }); case "checkbox": return Y(ze, { fieldName: a.name, checked: a.checked }); case "radio": return Y(We, { fieldName: a.name, ...t }); case "button": return Y(Ke, { fieldName: a.name, ...t }); } } function Xe(a) { return Y($e, a.file); } function ye(a) { for (const t of a.getElementsByTagName("span")) { let e = t.textContent; const o = JSON.parse(t.dataset.l10nArgs ?? "{}"); if (e) for (const n in o) e = e.replace(`{{${n}}}`, o[n]); t.textContent = e; } } function Ye(a, t, e) { let o = a.target; if (o.tagName !== "SECTION" && (o = o.parentNode), o.className.includes("popupAnnotation") || o.className.includes("textAnnotation")) ye(o); else if (o.className.includes("fileAttachmentAnnotation")) { ye(o); const n = o.dataset.annotationId; if (n && a.type === "dblclick") return Xe(ne("id", n, e)[0]); } else if (o.className.includes("textWidgetAnnotation") && a.type === "input") { let n = o.getElementsByTagName("input")[0]; return n || (n = o.getElementsByTagName("textarea")[0]), X(n); } else { if (o.className.includes("choiceWidgetAnnotation") && a.type === "input") return X(o.getElementsByTagName("select")[0]); if (o.className.includes("buttonWidgetAnnotation checkBox") && a.type === "change") return X(o.getElementsByTagName("input")[0]); if (o.className.includes("buttonWidgetAnnotation radioButton") && a.type === "change") { const n = o.dataset.annotationId; if (n) { const i = ne("id", n, e)[0], s = []; for (const l of ne("fieldName", i.fieldName, e)) l.buttonValue && s.push(l.buttonValue); return X(o.getElementsByTagName("input")[0], { value: i.buttonValue, defaultValue: i.fieldValue, options: s }); } } else if (o.className.includes("buttonWidgetAnnotation pushButton") && a.type === "click") { const n = o.dataset.annotationId; if (n) { const i = ne("id", n, e)[0]; return i.resetForm ? X( { name: i.fieldName, type: "button" }, { actions: i.actions, reset: !0 } ) : X( { name: i.fieldName, type: "button" }, { actions: i.actions, reset: !1 } ); } } } } const ce = Symbol(), ue = Symbol(), se = Symbol(), be = Symbol(), Le = Symbol(), Pe = Symbol(), _e = Symbol(), Ce = Symbol(); function ve(a, t, e = 0) { let o = e, n = a.length - 1; for (; o < n; ) { const i = o + n >> 1; t(a[i]) ? n = i : o = i + 1; } return o; } function je(a, t, e) { if (!a) return [t, e]; const [o, n] = a, i = t, s = t + e - 1; let l = ve(o, (h) => h >= i); o[l] > i && --l; let c = ve(o, (h) => h >= s, l); o[c] > s && --c; const d = i + n[l], y = s + n[c] + 1 - d; return [d, y]; } function qe(a) { const t = a.items, e = [0]; let o = 0; for (const n of t) n.str !== void 0 && (o += n.str.length, n.hasEOL && (o += 1), e.push(o)); return e; } function xe(a, t, e) { const o = t.items; let n = 0, i = o.length - 1; for (; n < i; ) { const u = n + i + 1 >> 1; e[u] <= a ? n = u : i = u - 1; } const s = n, l = a - e[s], c = o[s], d = Math.min(l, c && c.str?.length || 0); return { idx: s, offset: d }; } function Se(a, t, e) { const o = t.items; if (o.length === 0) return []; const n = qe(t), i = []; for (const s of a) { const l = s[0], c = s[1], d = s[2], [u, y] = e ? je(e, l, c) : [l, c], h = u + y - 1, m = xe(u, t, n), f = xe(h, t, n), r = o[f.idx], g = Math.min( f.offset + 1, r && r.str?.length || 0 ); i.push({ start: m, end: { idx: f.idx, offset: g }, str: d, oindex: l }); } return i; } function ke(a) { const t = a.items, e = []; for (const u of t) e.push(u.str || ""), u.hasEOL && e.push(` `); const o = e.join(""); if (o.length === 0) return ["", null]; const n = [0, 0]; let i = 0; const s = /([\p{Ideographic}\u3040-\u30FF])\n([\p{Ideographic}\u3040-\u30FF])|(\S)-\n|(\n)/gmu, l = o.replace( s, (u, y, h, m, f, r) => { if (y && h) { const g = r + y.length; return n.push(g - i, i + 1), i += 1, y + h; } if (m) { const g = r + m.length; return n.push(g - i, i + 2), i += 2, m; } return f ? " " : u; } ); n.push(l.length, i); const c = new Uint32Array(n.length >> 1), d = new Int32Array(n.length >> 1); for (let u = 0, y = n.length; u < y; u += 2) c[u >> 1] = n[u], d[u >> 1] = n[u + 1]; return [l, [c, d]]; } function we({ width: a, height: t, left: e, top: o }, n, i) { if (a === 0 || t === 0) return null; const s = i.getBoundingClientRect(), l = n.convertToPdfPoint( e - s.left, o - s.top ), c = n.convertToPdfPoint( e - s.left + a, o - s.top + t ); return L.Util.normalizeRect([ l[0], l[1], c[0], c[1] ]); } function Ge(a, t, e) { const o = a.getClientRects(); if (o.length === 1) return { rect: we(o[0], t, e) }; const n = [1 / 0, 1 / 0, -1 / 0, -1 / 0], i = []; let s = 0; for (const l of o) { const c = we(l, t, e); c !== null && (i[s] = i[s + 4] = c[0], i[s + 1] = i[s + 3] = c[3], i[s + 2] = i[s + 6] = c[2], i[s + 5] = i[s + 7] = c[1], L.Util.rectBoundingBox( ...c, n ), s += 8); } return { quadPoints: new Float32Array(i), rect: n }; } function Ee(a, t) { let e = a; do { if (e.nodeType === Node.TEXT_NODE) { const o = e.textContent.length; if (t <= o) return [e, t]; t -= o; } else if (e.firstChild) { e = e.firstChild; continue; } for (; !e.nextSibling && e !== a; ) e = e.parentNode; e !== a && (e = e.nextSibling); } while (e !== a); throw new Error("Offset is bigger than container's contents length."); } function Je(a, t, e, o, n, i) { const { start: s, end: l } = a, c = o[s.idx], d = o[l.idx]; if (!c || !d) return null; const u = new Range(), [y, h] = Ee(c, s.offset), [m, f] = Ee(d, l.offset); return u.setStart(y, h), u.setEnd(m, f), { id: `inferred_link_${i}`, unsafeUrl: t, url: t, annotationType: L.AnnotationType.LINK, rotation: 0, ...Ge(u, e, n), // Populated in the annotationLayer to avoid unnecessary object creation, // since most inferred links overlap existing LinkAnnotations: borderStyle: null }; } function Ze(a) { const t = new RegExp("\\b(?:https?:\\/\\/|mailto:|www\\.)(?:[\\S--[\\p{P}<>]]|\\/|[\\S--[\\[\\]]]+[\\S--[\\p{P}<>]])+|(?=\\p{L})[\\S--[@\\p{Ps}\\p{Pe}<>]]+@([\\S--[[\\p{P}--\\-]<>]]+(?:\\.[\\S--[[\\p{P}--\\-]<>]]+)+)", "gmv"); t.lastIndex = 0; const e = []; let o; for (; (o = t.exec(a)) !== null; ) { const [n, i] = o; let s; if (n.startsWith("www.") || n.startsWith("http://") || n.startsWith("https://")) s = n; else if (i) { const c = URL.parse(`http://${i}`)?.hostname; if (!c || /\.\d+$/.test(c)) continue; } s ??= n.startsWith("mailto:") ? n : `mailto:${n}`; const l = L.createValidAbsoluteUrl(s, void 0, { addDefaultProtocol: !0 }); l && e.push({ url: l.href, index: o.index, length: n.length }); } return e; } async function Qe(a, t, e) { const o = await a.getTextContent({ disableNormalization: !0, includeMarkedContent: !1 }), [n, i] = ke(o), s = Ze(n), l = s.map((u) => [ u.index, u.length, u.url ]), c = Se( l, o, i ), d = []; if (c.length > 0) { const u = document.createElement("div"); u.style.visibility = "hidden", u.className = "textLayer", t.parentElement?.appendChild(u); const y = new L.TextLayer({ textContentSource: a.streamTextContent(), container: u, viewport: e }); await y.render(); const h = y.textDivs; for (let m = 0; m < c.length; m++) { const f = c[m], r = s[m].url, g = Je( f, r, e, h, u, a._pageIndex * 100 + m ); g?.rect && d.push(g); } t.parentElement?.removeChild(u); } return d; } const et = /* @__PURE__ */ O({ __name: "AnnotationLayer", props: { page: {}, viewport: {}, document: {}, annotationsFilter: {}, annotationsMap: {}, imageResourcesPath: {}, hideForms: { type: Boolean }, enableScripting: { type: Boolean }, intent: {}, externalLinkEnabled: { type: Boolean }, externalLinkTarget: {} }, emits: ["annotation", "annotationLoaded"], setup(a, { emit: t }) { const e = a, o = t, n = U("layer"), i = K(), s = A(se), l = A(ce); function c(m) { const f = Ye( m, e.document, i.value ); Promise.resolve(f).then((r) => { r && o("annotation", r); }); } async function d() { return await G(e.document)?.getFieldObjects(); } async function u() { return await G(e.document)?.hasJSActions(); } async function y() { let f = await e.page?.getAnnotations({ intent: e.intent }); if (e.annotationsFilter) { const r = e.annotationsFilter; f = f.filter((g) => { const v = g.subtype, T = g.fieldType ? `${v}.${g.fieldType}` : null; return r?.includes(v) || T !== null && r?.includes(T); }); } return f; } async function h() { n.value.replaceChildren?.(); for (const b of he) n.value.removeEventListener(b, c); const m = G(e.document), f = e.page, r = e.viewport; i.value = await y(); const g = /* @__PURE__ */ new Map([]); for (const b of i.value) if (b.subtype === "Widget" && b.fieldType === "Btn" && b.pushButton) { const D = b.rect[2] - b.rect[0], I = b.rect[3] - b.rect[1], R = document.createElement("canvas"); R.setAttribute( "width", (D * r.scale).toString() ), R.setAttribute( "height", (I * r.scale).toString() ), g.set(b.id, R); } const v = m.annotationStorage; if (e.annotationsMap) for (const [b, D] of Object.entries(e.annotationsMap)) v.setValue(b, D); const T = s.linkService; T.setExternalLinkEnabled(e.externalLinkEnabled ?? !0), T.setExternalLinkTarget(e.externalLinkTarget ?? "_blank"); const w = { accessibilityManager: void 0, annotationCanvasMap: g, div: n.value, page: f, viewport: r.clone({ dontFlip: !0 }), annotationEditorUIManager: null, l10n: null, annotationStorage: v, linkService: T, commentManager: null, structTreeLayer: null }, _ = { annotations: i.value, viewport: r.clone({ dontFlip: !0 }), linkService: T, annotationCanvasMap: g, div: n.value, annotationStorage: v, renderForms: !e.hideForms, page: f, enableScripting: !1, hasJSActions: await u(), fieldObjects: await d(), downloadManager: null, imageResourcesPath: e.imageResourcesPath }, P = new L.AnnotationLayer(w); P.render(_).then(async () => { l.resolve(P); const b = await Qe( f, n.value, r.clone() ); P.addLinkAnnotations(b), o("annotationLoaded", await y()); }); for (const b of he) n.value.addEventListener(b, c); } return C( () => e.viewport, () => { e.page && e.viewport && n.value && h(); } ), J(() => { e.page && e.viewport && n.value && h(); }), (m, f) => (N(), B("div", { ref_key: "layer", ref: n, class: "annotationLayer", style: { display: "block" } }, null, 512)); } }); class tt { uiManager; constructor(t) { this.uiManager = t; } setUiManager(t) { this.uiManager = t; } _on(t, e) { } on(t, e) { this._on(t, e); } // In the original eventbus this dispatch method is actually the emitter // but for the sake of this library we will be using it as the listener dispatch(t, e) { if (this.uiManager) switch (t) { case "switchannotationeditorparams": this.uiManager.updateParams(e.type, e.value); break; } } } class nt { commentPopup = null; dialogElement; // Important for editor toolbar constructor(t) { this.dialogElement = document.createElement("div"), this.commentPopup = t; } setSidebarUiManager(t) { } showSidebar(t) { } hideSidebar() { } removeComments(t) { } selectComment(t) { } addComment(t) { } updateComment(t) { } makeCommentColor(t, e) { } destroyPopup() { } destroy() { } updatePopupColor(t) { } static _makeCommentColor(t, e) { return "transparent"; } toggleCommentPopup(t, e, o, n) { this.commentPopup.fn(t, e, o, n); } showDialog(t, e, o, n, i) { this.commentPopup.request(e, (s) => { e.comment = s, e.focusCommentButton(); }); } } class j extends He { editorsAvailable = []; #e = []; #t; #a; #n; #o = []; static LAYER_EMITTER_ID = 1e4; constructor(t, e, o, n, i, s, l = []) { const c = new tt(), d = []; for (const u in n) { const y = n[u]; d.push( `${u}=${y[0]},${u}_HCM=${y[1]}` ); } super( null, null, null, null, e.fn ? new nt(e) : null, null, c, t, null, d.join(","), null, null, null, null, null, !1 ), this._supportsPinchToZoom = !1, c.setUiManager(this), this._eventBus = c, this.#e = l, this.#t = o, this.#a = i, this.#n = s; } get direction() { return "ltr"; } static get _keyboardManager() { return null; } get isEditorHandlingKeyboard() { return !1; } get isEnterHandled() { return !1; } get selectedEditors() { const t = []; for (const e of this.getEditors(this.currentPageIndex)) e.isSelected && t.push(e); return t; } editAltText(t) { this.#t.request && this.#t.request(t, (e) => { t.altTextData = { altText: e, decorative: null }; }); } // NOTE: Properties and methods related to signatures getSignature() { } get signatureManager() { return null; } // NOTE: Those methods are no required for basic editing functionality // since they are related to UI interactions that are not implemented // as part of this library design, but they are defined to override and avoid errors setMainHighlightColorPicker() { } keydown() { } keyup() { } undo() { } redo() { } dragOver() { } drop() { } copy() { } cut() { } async paste() { } addNewEditorFromKeyboard() { } focusMainContainer() { this.#a.focus(); } // This could be used for the wrapper
disableUserSelect(t) { } // This could be used to control text selection for text layer a11yAlert(t, e = null) { } // This could be used to announce messages for screen readers addEditListeners() { } removeEditListeners() { } setSelected(t) { if (super.setSelected(t), t.isSelected) { const e = this.#n[j.LAYER_EMITTER_ID]; e && e("editorSelected", { editor: t }); } } // Note: Important methods to customize its original behavior addEditor(t) { if (super.addEditor(t), t.mode === ge.STAMP && (t._onResizing = () => { this.sizeSelectedEditors(t); }), t.mode === ge.INK) { const o = t._onResizing; t._onResizing = () => { o.call(t), this.sizeSelectedEditors(t); }; } const e = this.#n[j.LAYER_EMITTER_ID]; e && e("editorAdded", { editor: t }); } removeEditor(t) { super.removeEditor(t); const e = this.#n[j.LAYER_EMITTER_ID]; e && e("editorRemoved", { editor: t }); } highlightSelection(t = "", e = !1) { const o = document.getSelection(); if (!o || o.isCollapsed) return; const { anchorNode: n } = o, s = (n.nodeType === Node.TEXT_NODE ? n.parentElement : n).closest(".textLayer"); this.currentLayer.hasTextLayer(s) && super.highlightSelection(t, e); } addLayer(t) { super.addLayer(t); for (const e of this.#e) e(this.updateParams.bind(this)); } removeLayer(t) { super.removeLayer(t); } getMode() { return super.getMode(); } updateParams(t, e, o = !1) { if (super.updateParams(t, e), !o) { const n = [ M.FREETEXT_COLOR, M.HIGHLIGHT_COLOR, M.INK_COLOR ]; this.hasSelection && n.includes(t) && this.selectedEditors.forEach((s) => { const l = this.#n[s.mode]; l && l("colorChanged", { editor: s, color: e }); }); } } getId() { const t = Math.floor(Math.random() * 100); return super.getId() + t; } get currentLayer() { return super.currentLayer; } setUpDragSession() { super.setUpDragSession(), this.hasSelection && (this.#o = [], this.selectedEditors.forEach((t) => { t.isSelected && this.#o.push(t); })); } endDragSession() { const t = super.endDragSession(); return t && (this.#o = []), t; } dragSelectedEditors(t, e) { super.dragSelectedEditors(t, e), this.#o.forEach((o) => { const n = this.#n[o.mode]; n && n("dragging", { editor: o, ...this.#i(o) }); }); } sizeSelectedEditors(t) { const e = this.#n[t.mode]; e && e("resizing", { editor: t, ...this.#s(t) }); } #i(t) { return { x: t.x * t.pageDimensions[0], y: t.y * t.pageDimensions[1] }; } #s(t) { return { width: t.width * t.pageDimensions[0], height: t.height * t.pageDimensions[1], x: t.x * t.pageDimensions[0], y: t.y * t.pageDimensions[1] }; } } const ot = /* @__PURE__ */ O({ __name: "AnnotationEditorLayer", props: { page: {}, viewport: {}, document: {}, intent: {}, editorType: {}, editorLayer: { type: Boolean } }, emits: ["editorAdded", "editorRemoved", "editorSelected", "editorLoaded"], setup(a, { expose: t, emit: e }) { const o = { yellow: ["#FFEB3B", "#FFFFCC"], green: ["#8BC34A", "#53FFBC"], pink: ["#FFCBE6", "#F6B8FF"], red: ["#F44336", "#FF4F5F"], blue: ["#2196F3", "#80EBFF"] }, n = a, i = e, s = U("layer"); let l = null; const c = { fn: null, request: null }, d = { params: null, emit: null }, u = { fn: null, params: null, emit: null }, y = { params: null, emit: null }, h = { fn: (w) => { if (n.editorType !== L.AnnotationEditorType.STAMP) { console.warn("[vue-pdf] Cannot add stamp when editor type is not STAMP."); return; } typeof w == "string" ? l?.addNewEditor({ bitmapUrl: w }) : w ? l?.addNewEditor({ bitmapFile: w }) : l?.addNewEditor(); }, request: null, emit: null }; V(Ce, d), V(be, u), V(Le, c), V(Pe, h), V(_e, y); const m = A(ue), f = A(ce), r = A(se); async function g() { if (!r.uiManager && !n.editorLayer) return; const w = n.page, _ = n.viewport; if (!r.uiManager) { const I = [ d.params, u.params, y.params ].filter((re) => re !== null), R = { [L.AnnotationEditorType.FREETEXT]: d.emit, [L.AnnotationEditorType.INK]: y.emit, [L.AnnotationEditorType.STAMP]: h.emit, [L.AnnotationEditorType.HIGHLIGHT]: u.emit, [j.LAYER_EMITTER_ID]: i }; r.uiManager = new j( n.document, c, h, u.fn?.() ?? o, r.wrapper.value, R, I ); } const [P, S] = await Promise.all([ m.promise, f.promise ]); l && l.pageIndex !== w._pageIndex && (l.destroy(), l = null); const b = _.clone({ dontFlip: !0 }); if (l) { l.pause(!0), l.update({ viewport: b }), r.uiManager?.onRotationChanging({ pagesRotation: b.rotation }), r.uiManager?.onScaleChanging({ scale: b.scale }), r.uiManager?.onPageChanging({ pageNumber: w.pageNumber }), l.pause(!1), r.uiManager?.updateMode(n.editorType); return; } const D = new L.DrawLayer({ pageIndex: w.pageNumber - 1 }); D.setParent(r.wrapper.value), l = new L.AnnotationEditorLayer({ uiManager: r.uiManager, div: s.value, viewport: _.clone({ dontFlip: !0 }), enabled: !0, pageIndex: w.pageNumber - 1, l10n: null, textLayer: P ? { div: P } : void 0, // <-- Type casting to satisfy typescript bllsht :) drawLayer: D, // pdf.js types `mode` as `object` and never reads it; updateMode() below applies the editor type. mode: n.editorType, structTreeLayer: null, accessibilityManager: void 0, annotationLayer: S }), l.toggleDrawing = (I) => { s.value?.classList.toggle("drawing", !I); }, l.hasTextLayer = (I) => { const R = I.getAttribute("data-main-page"); return R ? parseInt(R) === w._pageIndex : !1; }, l.render({ viewport: _.clone({ dontFlip: !0 }) }), l.enable(), r.uiManager?.onRotationChanging({ pagesRotation: b.rotation }), r.uiManager?.onScaleChanging({ scale: b.scale }), r.uiManager?.onPageChanging({ pageNumber: w.pageNumber }), r.uiManager?.updateMode(n.editorType), i("editorLoaded"); } function v() { [ L.AnnotationEditorType.FREETEXT, L.AnnotationEditorType.HIGHLIGHT, L.AnnotationEditorType.INK, L.AnnotationEditorType.STAMP, L.AnnotationEditorType.NONE, L.AnnotationEditorType.DISABLE ].includes(n.editorType) ? g() : console.warn(`[vue-pdf] Unsupported editor type: ${n.editorType}.`); } function T() { r.uiManager?.unselectAll(); } return C( () => [n.editorLayer], ([w]) => { w && !r.uiManager ? n.page && n.viewport && s.value && v() : r.wrapper.value?.querySelectorAll("svg")?.forEach((P) => { w ? P.classList.remove("svg-editor-hidden") : P.classList.add("svg-editor-hidden"); }); } ), C( () => [n.viewport, n.editorType], () => { n.page && n.viewport && s.value && v(); } ), J(() => { n.page && n.viewport && s.value && v(); }), t({ unselectAll: T }), (w, _) => (N(), B(Ie, null, [ ae(F("div", { ref_key: "layer", ref: s, class: "annotationEditorLayer", id: "annotationEditorLayer" }, null, 512), [ [ie, a.editorLayer] ]), oe(w.$slots, "default") ], 64)); } }); function at(a, t, e) { const [o, n] = ke(a), i = ["g"]; e.ignoreCase && i.push("i"); let s = t.trim().replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); e.completeWords && (s = `\\b${s}\\b`); const l = new RegExp(s, i.join("")), c = []; let d; for (; (d = l.exec(o)) !== null; ) c.push([d.index, d[0].length, d[0]]); return [c, n]; } function it(a, t, e) { function o(n, i = -1, s = -1) { const l = t.items[n], c = []; let d = "", u = "", y = "", h = e[n]; if (!h) return; if (h.nodeType === Node.TEXT_NODE) { const r = document.createElement("span"); h.before(r), r.append(h), e[n] = r, h = r; } i >= 0 && s >= 0 ? d = l.str.substring(i, s) : i < 0 && s < 0 ? d = l.str : i >= 0 ? d = l.str.substring(i) : s >= 0 && (d = l.str.substring(0, s)); const m = document.createTextNode(d), f = document.createElement("span"); if (f.className = "highlight appended", f.append(m), c.push(f), i > 0) if (h.childNodes.length === 1 && h.childNodes[0].nodeType === Node.TEXT_NODE) { u = l.str.substring(0, i); const r = document.createTextNode(u); c.unshift(r); } else { let r = 0; const g = []; for (const v of h.childNodes) { const T = v.nodeType === Node.TEXT_NODE ? v.nodeValue : v.firstChild.nodeValue; r += T.length, r <= i ? g.push(v) : i >= r - T.length && s <= r && g.push( document.createTextNode( T.substring( 0, i - (r - T.length) ) ) ); } c.unshift(...g); } if (s > 0) { y = l.str.substring(s); const r = document.createTextNode(y); c.push(r); } h.replaceChildren(...c); } for (const n of a.sort((i, s) => i.oindex - s.oindex)) if (n.start.idx === n.end.idx) o(n.start.idx, n.start.offset, n.end.offset); else for (let i = n.start.idx, s = n.end.idx; i <= s; i++) i === n.start.idx ? o(i, n.start.offset) : i === n.end.idx ? o(i, -1, n.end.offset) : o(i); } function st(a, t) { const e = a.items.map((o) => o.str); for (let o = 0; o < t.length; o++) { const n = t[o]; if (n && n.nodeType !== Node.TEXT_NODE) { const i = document.createTextNode(e[o]); n.replaceChildren(i); } } } function rt(a, t, e) { const o = []; for (const n of a) { const [i, s] = at(t, n, e); o.push(...Se(i, t, s)); } return o; } const lt = ["data-main-page"], ct = /* @__PURE__ */ O({ __name: "TextLayer", props: { page: {}, viewport: {}, highlightText: {}, highlightOptions: {}, highlightPages: {} }, emits: ["highlight", "textLoaded"], setup(a, { emit: t }) { const e = a, o = t, n = U("layer"), i = K(); let s = [], l; const c = A(ue); function d() { return Object.assign( {}, { ignoreCase: !0, completeWords: !1 }, e.highlightOptions ); } async function u(r = !1) { const g = e.page, v = await g?.getTextContent(); if (v && (r && st(v, s), e.highlightText && (!e.highlightPages || e.highlightPages.includes(g.pageNumber)))) { const T = typeof e.highlightText == "string" ? [e.highlightText] : e.highlightText, w = rt( T, v, d() ); it(w, v, s), o("highlight", { matches: w, textContent: v, textDivs: s, page: g?.pageNumber || 1 }); } } async function y() { l?.cancel(), n.value.replaceChildren?.(); const r = e.page, g = e.viewport, v = r?.streamTextContent({ includeMarkedContent: !0, disableNormalization: !0 }), T = new L.TextLayer({ container: n.value, textContentSource: v, viewport: g }); l = T; try { await T.render(), s = T.textDivs; const w = await r?.getTextContent(); o("textLoaded", { textDivs: s, textContent: w }), h(), u(), c.resolve(n.value); } catch { } } function h() { const r = document.createElement("div"); r.className = "endOfContent", n.value?.appendChild(r), i.value = r; } function m() { i.value && i.value.classList.add("active"); } function f() { i.value && i.value.classList.remove("active"); } return C( () => e.viewport, // eslint-disable-next-line @typescript-eslint/no-unused-vars (r) => { e.page && e.viewport && n.value && y(); } ), C( () => [e.highlightText, e.highlightOptions], // eslint-disable-next-line @typescript-eslint/no-unused-vars (r) => { u(!0); }, { deep: !0 } ), J(() => { e.page && e.viewport && n.value && y(); }), (r, g) => (N(), B("div", { ref_key: "layer", ref: n, class: "textLayer", "data-main-page": a.page?._pageIndex, onMousedown: m, onMouseup: f }, null, 40, lt)); } }), ut = /* @__PURE__ */ O({ __name: "XFALayer", props: { page: {}, document: {}, viewport: {} }, emits: ["xfaLoaded"], setup(a, { emit: t }) { const e = a, o = t, n = U("layer"), i = A(se); async function s() { n.value.replaceChildren?.(); const l = G(e.document), c = e.page, d = e.viewport; if (l.isPureXfa) { const u = await c.getXfa(), y = { div: n.value, viewport: d.clone({ dontFlip: !0 }), linkService: i.linkService, annotationStorage: l?.annotationStorage, xfaHtml: u }; L.XfaLayer.render(y), o("xfaLoaded"); } } return C( () => e.viewport, (l) => { e.page && e.viewport && n.value && s(); } ), J(() => { e.page && e.viewport && n.value && s(); }), (l, c) => (N(), B("div", { ref_key: "layer", ref: n, style: { display: "block" } }, null, 512)); } }), dt = "link", pt = "internal-link"; class mt { targets = ["_blank", "_self", "_parent", "_top"]; externalLinkEnabled; externalLinkTarget; externalLinkRel; #e = null; #t = null; eventBus = null; baseUrl; _ignoreDestinationZoom = !1; pdfDocument; pdfHistory; pdfViewer; constructor(t) { this.externalLinkEnabled = !0, this.externalLinkTarget = this.targets.indexOf("_blank"), this.externalLinkRel = "noopener noreferrer", this.#t = t; } setHistory(t) { this.pdfHistory = t; } setViewer(t) { this.pdfViewer = t; } setDocument(t) { this.#e = t; } setRootEmit(t) { this.#t = t; } get pagesCount() { return this.#e?.numPages || 0; } get page() { return 0; } set page(t) { } set rotation(t) { } get rotation() { return 0; } get isInPresentationMode() { return !1; } /** * @param {string|Array} dest - The named, or explicit, PDF destination. */ async goToDestination(t) { if (!this.#e) return; let e, o; if (typeof t == "string" ? e = await this.#e.getDestination(t) : e = t, !Array.isArray(e)) { console.error( `goToDestination: "${e}" is not a valid destination array, for dest="${t}".` ); return; } const [n] = e; if (n && typeof n == "object") { if (o = this.#e.cachedPageNumber(n), !o) try { o = await this.#e.getPageIndex(n) + 1; } catch { console.error( `goToDestination: "${n}" is not a valid page reference, for dest="${t}".` ); return; } } else Number.isInteger(n) && (o = n + 1); if (!o || o < 1 || o > this.pagesCount) { console.error( `goToDestination: "${o}" is not a valid page number, for dest="${t}".` ); return; } const i = { left: 0, bottom: 0 }; switch (e[1].name) { case "XYZ": case "FitR": i.left = e[2], i.bottom = e[3]; break; case "FitV": case "FitBV": i.left = e[2]; break; case "FitH": case "FitBH": i.bottom = e[2], (i.bottom === null || typeof i.bottom != "number" || i.bottom < 0) && (i.bottom = 0); break; } this.#t("annotation", { type: pt, data: { referencedPage: o, offset: i, dest: e } }); } addLinkAttributes(t, e, o = !1) { t.style.cursor = "pointer"; const n = typeof window < "u" && window.location ? window.location.href : "about:blank"; let i; try { i = new URL(e, n); } catch { return; } if (t.addEventListener("click", (d) => { this.#t("annotation", { type: dt, data: { url: i, unsafeUrl: e } }); }), !this.externalLinkEnabled) return; const s = i.protocol.toLowerCase(); if (!(s === "http:" || s === "https:" || s === "mailto:" || s === "tel:")) return; t.href = i.toString(), o ? t.target = "_blank" : this.externalLinkTarget !== -1 ? t.target = this.targets[this.externalLinkTarget] : t.removeAttribute("target"); const c = this.externalLinkRel; t.rel = c.includes("noopener") ? c : `noopener ${c}`.trim(); } async getAttachmentContent(t) { return this.#e ? this.#e.getAttachmentContent(t) : null; } getDestinationHash(t) { return "#"; } getAnchorUrl(t) { return "#"; } setExternalLinkTarget(t) { this.externalLinkTarget = this.targets.indexOf(t); } setExternalLinkRel(t) { this.externalLinkRel = t; } setExternalLinkEnabled(t) { this.externalLinkEnabled = t; } setHash(t) { } executeNamedAction(t) { } executeSetOCGState(t) { return new Promise(() => { }); } cachePageRef(t, e) { } goToPage(t) { } goToXY(t, e, o) { } } const ft = /* @__PURE__ */ O({ __name: "VuePDF", props: { pdf: {}, page: { default: 1 }, scale: { default: 1 }, rotation: {}, fitParent: { type: Boolean }, width: {}, height: {}, textLayer: { type: Boolean }, autoDestroy: { type: Boolean, default: !1 }, imageResourcesPath: {}, hideForms: { type: Boolean }, intent: { default: "display" }, annotationLayer: { type: Boolean }, annotationsFilter: {}, annotationsMap: {}, watermarkText: {}, watermarkOptions: {}, highlightText: {}, highlightOptions: {}, highlightPages: {}, editorLayer: { type: Boolean }, editorType: { default: 0 }, externalLinkEnabled: { type: Boolean, default: !0 }, externalLinkTarget: { default: "_blank" } }, emits: ["annotation", "highlight", "loaded", "textLoaded", "annotationLoaded", "xfaLoaded", "editorLoaded", "editorAdded", "editorRemoved", "editorSelected", "error"], setup(a, { expose: t, emit: e }) { const o = a, n = e, i = U("container"), s = U("canvasWrapper"), l = U("loadingLayer"), c = K(!1); let d; const u = Q(() => ({ viewport: void 0, document: void 0, page: void 0 })), y = Q(() => ({ annotationsMap: o.annotationsMap, annotationsFilter: o.annotationsFilter, externalLinkEnabled: o.externalLinkEnabled, externalLinkTarget: o.externalLinkTarget, imageResourcesPath: o.imageResourcesPath, hideForms: o.hideForms, intent: o.intent })), h = Q(() => ({ highlightText: o.highlightText, highlightOptions: o.highlightOptions, highlightPages: o.highlightPages })), m = Q(() => ({ editorLayer: o.editorLayer, editorType: o.editorType, intent: o.intent })); let f, r; V(ce, { promise: new Promise((x) => { f = x; }), resolve: (x) => f(x) }), V(ue, { promise: new Promise((x) => { r = x; }), resolve: (x) => r(x) }); const g = { wrapper: s, container: i, uiManager: null, linkService: new mt(n) }; V(se, g); function v() { return Object.assign( {}, { columns: 4, rows: 4, rotation: 45, fontSize: 18, color: "rgba(211, 210, 211, 0.4)" }, o.watermarkOptions ); } function T(x) { if (!(typeof x == "number" && x % 90 === 0)) return 0; const p = x / 90; return p > 4 ? T(x - 360) : p < 0 ? T(x + 360) : x; } function w(x) { let p = o.scale; if (o.fitParent) { const E = s.value.parentNode.clientWidth, k = x.getViewport({ scale: 1 }).width; p = E / k; } else if (o.width) { const E = x.getViewport({ scale: 1 }).width; p = o.width / E; } else if (o.height) { const E = x.getViewport({ scale: 1 }).height; p = o.height / E; } return p; } function _(x = 1) { if (!o.watermarkText) return; const p = P(); if (!p) return; const E = p.getContext("2d"); if (!E) return; const k = v(), z = o.watermarkText, H = k.columns, $ = k.rows, q = H * $, le = k.rotation, Z = k.fontSize * x; E.font = `${Z}px Trebuchet MS`, E.fillStyle = k.color; for (let W = 0; W < q; W++) { const Ne = W % H * (p.width / H) + p.width / (H * 2), Fe = Math.floor(W / H) * (p.height / $) + p.height / ($ * 2), De = E.measureText(z).width; E.save(), E.translate(Ne, Fe), E.rotate(-le * (Math.PI / 180)), E.fillText(z, -De / 2, Z / 2), E.restore(); } } function P() { let x = null; return s.value?.childNodes.forEach((p) => { p.tagName === "CANVAS" && (x = p); }), x; } function S(x) { let p; const E = P(); E && E?.getAttribute("role") === "main" ? p = E : (p = document.createElement("canvas"), p.style.display = "block", p.setAttribute("dir", "ltr")); const k = window.devicePixelRatio || 1; return p.width = Math.floor(x.width * k), p.height = Math.floor(x.height * k), p.style.width = `${Math.floor(x.width)}px`, p.style.height = `${Math.floor(x.height)}px`, i.value?.style.setProperty("--scale-factor", `${x.scale}`), i.value?.style.setProperty("--user-unit", `${x.userUnit}`), i.value?.style.setProperty("--scale-round-y", "1px"), i.value?.style.setProperty("--scale-round-x", "1px"), i.value?.style.setProperty( "--total-scale-factor", "calc(var(--scale-factor) * var(--user-unit))" ), l.value.style.width = `${Math.floor(x.width)}px`, l.value.style.height = `${Math.floor(x.height)}px`, l.value.style.top = "0", l.value.style.left = "0", c.value = !0, p; } function b() { d && d.cancel(); } function D(x) { G(u.value.document)?.getPage(x).then((p) => { b(); const E = p.getViewport(), k = { scale: w(p), rotation: T((o.rotation || 0) + E.rotation) }, z = p.getViewport(k), H = P(), $ = S(z), q = window.devicePixelRatio || 1, le = q !== 1 ? [q, 0, 0, q, 0, 0] : void 0, Z = { canvas: $, viewport: z, annotationMode: o.hideForms ? L.AnnotationMode.ENABLE : L.AnnotationMode.ENABLE_FORMS, transform: le, intent: o.intent }; $?.getAttribute("role") !== "main" ? H && s.value?.replaceChild($, H) : $.removeAttribute("role"), g.linkService.setDocument(u.value.document), u.value.page = p, u.value.viewport = z, d = p.render(Z), d.promise.then(() => { c.value = !1, _(z.scale), n("loaded", u.value.viewport); }).catch((W) => { W instanceof L.RenderingCancelledException || n("error", W); }); }); } function I(x) { x.promise.then(async (p) => { u.value.document = p, D(o.page); }); } C( () => o.pdf, (x, p) => { b(), p && p !== x && !o.autoDestroy && p.destroy(), x !== void 0 && I(x); } ), C( () => [ o.scale, o.width, o.height, o.rotation, o.page, o.hideForms, o.intent ], () => { D(o.page); } ), J(() => { o.pdf !== void 0 && I(o.pdf); }), Re(() => { o.autoDestroy && o.pdf?.destroy(); }); function R() { o.pdf?.destroy(); } function re() { D(o.page); } function Ae() { b(); } return t({ reload: re, cancel: Ae, destroy: R }), (x, p) => (N(), B("div", { ref_key: "container", ref: i, class: "page", style: { position: "relative", "background-clip": "content-box" } }, [ F("div", { ref_key: "canvasWrapper", ref: s, class: "canvasWrapper" }, [...p[9] || (p[9] = [ F("canvas", { dir: "ltr", role: "main" }, null, -1) ])], 512), a.textLayer ? (N(), de(ct, ee({ key: 0 }, { ...u.value, ...h.value }, { onHighlight: p[0] || (p[0] = (E) => n("highlight", E)), onTextLoaded: p[1] || (p[1] = (E) => n("textLoaded", E)) }), null, 16)) : pe("", !0), a.annotationLayer ? (N(), de(et, ee({ key: 1 }, { ...u.value, ...y.value }, { onAnnotation: p[2] || (p[2] = (E) => n("annotation", E)), onAnnotationLoaded: p[3] || (p[3] = (E) => n("annotationLoaded", E)) }), null, 16)) : pe("", !0), me(ot, ee({ ...u.value, ...m.value }, { onEditorAdded: p[4] || (p[4] = (E) => n("editorAdded", E)), onEditorRemoved: p[5] || (p[5] = (E) => n("editorRemoved", E)), onEditorSelected: p[6] || (p[6] = (E) => n("editorSelected", E)), onEditorLoaded: p[7] || (p[7] = (E) => n("editorLoaded")) }), { default: Me(() => [ oe(x.$slots, "editors", {}, void 0, !0) ]), _: 3 }, 16), me(ut, ee({ ...u.value }, { onXfaLoaded: p[8] || (p[8] = (E) => n("xfaLoaded")) }), null, 16), ae(F("div", { ref_key: "loadingLayer", ref: l, style: { position: "absolute" } }, [ oe(x.$slots, "default", {}, void 0, !0) ], 512), [ [ie, c.value] ]), oe(x.$slots, "overlay", { width: u.value.viewport?.width, height: u.value.viewport?.height }, void 0, !0) ], 512)); } }), gt = (a, t) => { const e = a.__vccOpts || a; for (const [o, n] of t) e[o] = n; return e; }, Te = /* @__PURE__ */ gt(ft, [["__scopeId", "data-v-42527a4f"]]), ht = { style: { display: "none" } }, Ut = /* @__PURE__ */ O({ __name: "PDFFreeTextAnnotation", props: { color: {}, fontSize: {} }, emits: ["dragging", "colorChanged"], setup(a, { emit: t }) { const e = a, o = t, n = A(Ce); let i = null; function s(c) { i = c, l(); } function l() { i?.(M.FREETEXT_COLOR, e.color, !0), i?.(M.FREETEXT_SIZE, e.fontSize, !0); } return n.params = s, n.emit = o, C( () => [e.color, e.fontSize], () => { l(); } ), (c, d) => (N(), B("div", ht)); } }), yt = { style: { display: "none" } }, zt = /* @__PURE__ */ O({ __name: "PDFHighlightAnnotation", props: { color: {}, thickness: {}, colorOptions: {} }, emits: ["colorChanged"], setup(a, { emit: t }) { const e = a, o = t, n = A(be); let i = null; function s(c) { i = c, l(); } function l() { i?.(M.HIGHLIGHT_COLOR, e.color, !0), i?.(M.HIGHLIGHT_THICKNESS, e.thickness, !0); } return n.params = s, n.emit = o, n.fn = () => e.colorOptions, C( () => [e.color, e.thickness], () => { l(); } ), C( () => e.colorOptions, () => { console.warn( "[vue-pdf] Highlight color options can only be set once during initialization." ); } ), (c, d) => (N(), B("div", yt)); } }), vt = { style: { display: "none" } }, Wt = /* @__PURE__ */ O({ __name: "PDFInkAnnotation", props: { color: {}, thickness: {}, opacity: {} }, emits: ["dragging", "resizing", "colorChanged"], setup(a, { emit: t }) { const e = a, o = t, n = A(_e); let i = null; function s(c) { i = c, l(); } function l() { i?.(M.INK_COLOR, e.color, !0), i?.(M.INK_THICKNESS, e.thickness, !0), i?.(M.INK_OPACITY, e.opacity, !0); } return n.params = s, n.emit = o, C( () => [e.color, e.thickness, e.opacity], () => { l(); } ), (c, d) => (N(), B("div", vt)); } }), xt = { class: "commentPopupTop" }, wt = { class: "commentPopupTime" }, Et = { class: "commentPopupButtons", style: { visibility: "visible !important" } }, Tt = { class: "commentPopupText" }, Kt = /* @__PURE__ */ O({ __name: "PDFCommentAnnotation", emits: ["comment", "removed"], setup(a, { emit: t }) { const e = t, o = A(Le), n = K(!1), i = K(!1), s = K(), l = K({ x: 0, y: 0 }), c = U("popupContainer"); let d = null; function u(r, g, v, T) { if (!r) { n.value = !1; return; } if (v === void 0 ? (i.value = g, n.value = g, i.value && r.isSelected && (i.value = !1, n.value = !1)) : i.value || (n.value = v), r.isSelected = i.value, r.setCommentButtonStates({ selected: i.value, hasPopup: !0 }), r.hasComment && r.commentPopupPosition) { let [w, _] = r.commentPopupPosition; r?.elementBeforePopup?.after(c.value), l.value.x = w * 100, l.value.y = _ * 100; } try { const { contentsObj: w, richText: _, creationDate: P, modificationDate: S } = r.getData(), b = _?.str && (!w?.str || _.str === w.str) ? _.html : w?.str; s.value = { html: b, creationDate: P, modificationDate: S }, d = r; } catch { } } function y(r) { const g = L.PDFDateString.toDateObject(r); return g ? Intl.DateTimeFormat(void 0, { dateStyle: "long" }).format(g) : ""; } function h() { n.value = !1, i.value = !1, d?.editComment({ height: 0 }), d?.focus(); } function m() { d && (d.comment = null, n.value = !1, i.value = !1, d.focus(), e("removed", d)); } function f(r, g) { e("comment", r, (v) => { v !== null && v.length > 0 && g(v); }); } return o.fn = u, o.request = f, (r, g) => ae((N(), B("div", { ref_key: "popupContainer", ref: c, class: "commentPopup", tabindex: "-1", role: "dialog", "aria-modal": "false", style: Oe({ left: l.value.x + "%", top: l.value.y + "%" }) }, [ F("div", xt, [ F("time", wt, fe(y(s.value?.creationDate)), 1), ae(F("div", Et, [ F("button", { onClick: h, class: "commentPopupIcon commentPopupEdit toolbarButton", tabindex: "0", "data-l10n-id": "pdfjs-editor-edit-comment-popup-button", "aria-haspopup": "dialog" }), F("button", { onClick: m, class: "commentPopupIcon commentPopupDelete toolbarButton", tabindex: "0", "data-l10n-id": "pdfjs-editor-delete-comment-popup-button" }) ], 512), [ [ie, i.value] ]) ]), g[0] || (g[0] = F("hr", null, null, -1)), F("div", Tt, fe(s.value?.html), 1) ], 4)), [ [ie, n.value] ]); } }), bt = { style: { display: "none" } }, Xt = /* @__PURE__ */ O({ __name: "PDFStampAnnotation", emits: ["altText", "dragging", "resizing"], setup(a, { expose: t, emit: e }) { const o = e, n = A( Pe ); function i(l = null) { n?.fn?.(l); } function s(l, c) { o("altText", l, (d) => { d !== null && d.length > 0 && c(d); }); } return n.request = s, n.emit = o, t({ addStamp: i }), (l, c) => (N(), B("div", bt)); } }); function Lt(a) { return !!(typeof a == "object" && a && "gen" in a && "num" in a); } async function Pt(a, t) { return typeof t == "string" ? a.getDestination(t) : t; } async function _t(a, t) { return t && Lt(t[0]) ? t[0] : null; } const Ct = (a) => a.type === "XYZ" && a.spec.length === 3, St = (a) => a.type === "Fit" && a.spec.length === 0, kt = (a) => a.type === "FitH" && a.spec.length === 1, At = (a) => a.type === "FitV" && a.spec.length === 1, Nt = (a) => a.type === "FitR" && a.spec.length === 4, Ft = (a) => a.type === "FitB" && a.spec.length === 0, Dt = (a) => a.type === "FitBH" && a.spec.length === 1, It = (a) => a.type === "FitBV" && a.spec.length === 1; function Rt(a, t) { const e = { type: a, spec: t }; return Ct(e) || St(e) || kt(e) || At(e) || Nt(e) || Ft(e) || Dt(e) || It(e) ? e : (console.warn("no location type found for ", a, t), null); } const Mt = (a) => a && a.every((t) => !isNaN(t)); function Ot(a) { return typeof a == "string" || a instanceof URL ? { url: a } : a instanceof ArrayBuffer || ArrayBuffer.isView(a) ? { data: a } : a; } async function Bt() { return new Promise((a, t) => { const e = document.createElement("iframe"); e.width = "0px", e.height = "0px", e.style.cssText = "position: absolute; top:0; left:0", e.style.display = "none", e.onload = function() { a(e); }, document.body.appendChild(e); }); } function Ht(a, t, e) { const o = a.document.createElement("style"); o.textContent = ` @page { margin: 0; size: ${t}pt ${e}pt; } body { margin: 0; width: 100%; } canvas { page-break-after: always; page-break-before: avoid; page-break-inside: avoid; } `, a.document.head.appendChild(o); } function Yt(a, t = { onProgress: void 0, onPassword: void 0, onError: void 0, password: "" }) { const e = te(), o = te(), n = te(0), i = te({}); function s(y) { e.value && e.value.destroy(); const h = L.getDocument(Ot(y)); if (t.onProgress && (h.onProgress = t.onProgress), t.onPassword) h.onPassword = t.onPassword; else if (t.password) { const m = (f, r) => { f(t.password ?? ""); }; h.onPassword = m; } h.promise.then( async (m) => { o.value = m, e.value = m.loadingTask, n.value = m.numPages; const f = await m.getMetadata(), r = await m.getAttachments(), g = r ? Object.fromEntries(r) : {}, v = await m.getJSActions(), T = v ? Object.fromEntries(v) : null, w = await m.getOutline(); i.value = { metadata: f, attachments: g, javascript: T, outline: w }; }, (m) => { typeof t.onError == "function" && t.onError(m); } ); } async function l(y) { const h = await e.value?.promise; if (!h) return null; const m = await Pt(h, y), f = await _t(h, m); if (!f || !m) return null; const r = await h.getPageIndex(f), g = m[1].name, v = m.slice(2), T = Mt(v) ? Rt(g, v) : null; return { pageIndex: r, location: T ?? { type: "Fit", spec: [] } }; } async function c() { if (!o.value) throw new Error("Current PDFDocumentProxy have not loaded yet"); try { return await o.value.saveDocument(); } catch (y) { return console.error("Error saving PDF document:", y), await o.value.getData(); } } async function d(y = "filename") { const h = await c(), m = new Blob([h], { type: "application/pdf" }), f = URL.createObjectURL(m), r = document.createElement("a"); document.body.appendChild(r), r.href = f, r.download = y, r.style.display = "none", r.click(), setTimeout(() => { URL.revokeObjectURL(f), document.body.removeChild(r); }, 10); } async function u(y = 150, h = "filename") { if (!e.value) throw new Error("Current PDFDocumentLoadingTask have not loaded yet"); const m = await e.value.promise, f = y / 72, r = 96 / 72, g = await Bt(), v = g.contentWindow; v.document.title = h; const T = [...Array(m.numPages).keys()].map((w) => w + 1); for (const w of T) { const _ = await m.getPage(w), P = _.getViewport({ scale: 1 }); w === 1 && Ht( v, P.width * f / r, P.height * f / r ); const S = document.createElement("canvas"); S.width = P.width * f, S.height = P.height * f; const b = S.cloneNode(); v?.document.body.appendChild(b), await _?.render({ canvas: S, intent: "print", transform: [f, 0, 0, f, 0, 0], viewport: P }).promise, b.getContext("2d")?.drawImage(S, 0, 0); } v?.focus(), v?.print(), document.body.removeChild(g); } return Be(a) ? (a.value && s(a.value), C(a, () => { a.value && s(a.value); })) : a && s(a), { pdf: e, pages: n, info: i, print: u, download: d, getPDFDestination: l }; } const jt = { install(a) { a.component(Te.name, Te); } }; export { Kt as PDFCommentAnnotation, Ut as PDFFreeTextAnnotation, zt as PDFHighlightAnnotation, Wt as PDFInkAnnotation, Xt as PDFStampAnnotation, Te as VuePDF, jt as VuePDFPlugin, jt as default, Yt as usePDF };