@pdf-viewer/react
Version:
A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.
1,473 lines • 120 kB
JavaScript
import { jsx as i, Fragment as fe, jsxs as W } from "react/jsx-runtime";
import * as B from "react";
import { useRef as H, useEffect as F, useCallback as N, useState as $, useMemo as k, createContext as Ye, useContext as Je, forwardRef as $e, useImperativeHandle as cn, createElement as qe, PureComponent as er, Component as tr, memo as ln } from "react";
import { ChevronUpIcon as He } from "./components/icons/ChevronUpIcon.js";
import { UIButton as re } from "./components/ui/Button.js";
import { UIInput as dn } from "./components/ui/Input.js";
import { ViewMode as Re, ScrollMode as Q, AnnotationSubType as zt, SelectionMode as nr, ZoomLevel as st } from "./utils/types.js";
import { useScrollModeContext as Ee } from "./contexts/ScrollModeContext.js";
import { useDocumentContext as ee } from "./contexts/RPDocumentContext.js";
import { useDocumentPasswordContext as rr } from "./contexts/DocumentPasswordContext.js";
import { useDarkModeContext as or } from "./contexts/DarkModeContext.js";
import "./contexts/RotationContext.js";
import { useLayerContext as ir } from "./contexts/LayerContext.js";
import { useZoomContext as Qe } from "./contexts/ZoomContext.js";
import { useViewModeContext as Ne } from "./contexts/ViewModeContext.js";
import { useVirtualScrollContext as et } from "./contexts/VirtualScrollContext.js";
import { useVirtualGridContext as un } from "./contexts/VirtualGridContext.js";
import { useSelectionModeContext as ar } from "./contexts/SelectionModeContext.js";
import { useInitialStateContext as sr } from "./contexts/InitialStateContext.js";
import { useFullScreenContext as cr } from "./contexts/FullScreenContext.js";
import "./contexts/FileInputContext.js";
import "./contexts/DropFileZoneContext.js";
import { renderPage as wt } from "./utils/renderPage.js";
import { findMatches as lr, resetDivs as dr, highlightMatches as ur, isMatchEntireWord as pr } from "./utils/highlight.js";
import { useLayoutContainer as me } from "./contexts/LayoutContainerContext.js";
import { useDimensionPagesContext as Ge } from "./contexts/DimensionPagesContext.js";
import { useLocalizationContext as ae } from "./contexts/LocalizationContext.js";
import { useHighlightContext as hr } from "./contexts/HighlightContext.js";
import "./contexts/LicenseContext.js";
import { useDownloadContext as fr } from "./contexts/DownloadContext.js";
import { useSmoothScrollContext as pn } from "./contexts/SmoothScrollContext.js";
import "./contexts/ElementPageContext.js";
import { usePagesRotateContext as Ue } from "./contexts/PagesRotateContext.js";
import { useLoaderContext as hn } from "./contexts/LoaderContext.js";
import "./components/RPConfig.js";
import { ThumbnailIcon as mr } from "./components/icons/Thumbnail.js";
import { c as ne } from "./clsx-0c6e471a.js";
import { LoaderIcon as Pt } from "./components/icons/LoaderIcon.js";
import { useInfiniteScroll as gr } from "./utils/hooks/useInfiniteScroll.js";
import { RPSplitter as vr } from "./components/layout/sidebar/RPSplitter.js";
import { useToolbarComponentContext as ge, ToolbarComponentProvider as wr } from "./contexts/ToolbarComponentContext.js";
import { useIconContext as ue, IconProvider as _r } from "./contexts/IconContext.js";
import K from "./components/ui/RPTooltip.js";
import { Container as br } from "./components/layout/Container.js";
import { WrapperLayout as Cr } from "./components/layout/WrapperLayout.js";
import { RPDropFileZone as Pr } from "./components/RPDropFileZone.js";
import { useViewportContext as Pe, ViewportProvider as Tr } from "./contexts/ViewportContext.js";
import { useThemeContext as Sr } from "./contexts/ThemeContext.js";
import * as yr from "pdfjs-dist";
import { PixelsPerInch as xr, AnnotationMode as Ir, RenderingCancelledException as Rr, AnnotationLayer as Lr } from "pdfjs-dist";
import { SimpleLinkService as Er } from "./utils/link_service.js";
import { annotationsEvents as Nr, annotationEventsHandler as Or, handleClick as At, handleAnnotationWidget as Dr, handleAnnotationLink as zr, bindLayerEvents as Ar, unbindLayerEvents as Ft } from "./utils/annotations.js";
import { normalizeSingleKeyword as Fr, sortHighlightPosition as Wr, unwrap as kr } from "./components/page/searchHighlight.js";
import { CustomElement as Mr } from "./components/page/CustomElement.js";
import { _ as Hr, U as $r } from "./Popover-48c8394c.js";
import { useMousePressed as Gr } from "./utils/hooks/useMousePressed.js";
import { useGrabScroll as Ur } from "./utils/hooks/useGrabScroll.js";
import { usePinch as Vr } from "./utils/hooks/usePinch.js";
import { useDebounce as Tt } from "./utils/hooks/useDebounce.js";
import qr from "./components/ui/PasswordModal.js";
import { getPositionFromPage as Br, getPageFromPosition as Zr } from "./utils/calculatePage.js";
import { getScrollDistance as Ae } from "./utils/getScrollDistance.js";
import { getWordPositionInPage as jr } from "./utils/getWordPositionInPage.js";
import { getThumbnailViewport as Wt } from "./utils/getThumbnailViewport.js";
import { smoothScrollTo as ct } from "./utils/smoothScrollTo.js";
import { appConsole as Kr } from "./utils/appConsole.js";
import { FileUploadTool as fn } from "./components/layout/toolbar/FileUploadTool.js";
import { DarkModeTool as Xr } from "./components/layout/toolbar/DarkModeTool.js";
import { ThreeDotIcon as Yr } from "./components/icons/ThreeDotIcon.js";
import { UIDropDown as mn } from "./components/ui/DropDown.js";
import { c as Jr, u as St, P as Ve, a as Me, b as yt, k as Qr, e as eo, i as to } from "./index-6e0e48fa.js";
import { D as no, a as lt } from "./index-e3a67935.js";
import { a as ro, u as oo, F as io, b as ao, G as Ke } from "./index-951f0f1f.js";
import { h as so } from "./component-2aa6e53b.js";
import { CloseIcon as co } from "./components/icons/CloseIcon.js";
import { dateFormatter as kt } from "./utils/dateFormatter.js";
import { PropertyItem as lo } from "./components/layout/toolbar/PropertyItem.js";
import { useOtherToolContext as uo, OtherToolProvider as po } from "./contexts/OtherToolContext.js";
import { DocumentProperties as ho } from "./components/layout/toolbar/DocumentProperties.js";
import { RotateTool as fo } from "./components/layout/toolbar/RotateTool.js";
import { ViewModeTool as mo } from "./components/layout/toolbar/ViewModeTool.js";
import { ScrollModeTool as go } from "./components/layout/toolbar/ScrollModeTool.js";
import { MenuSeparator as xt } from "./components/layout/toolbar/MenuSeparator.js";
import { FileDownloadDefaultIcon as vo } from "./components/icons/FileDownloadDefaultIcon.js";
import { MenuItem as Ce } from "./components/layout/toolbar/MenuItem.js";
import { PrintDefaultTool as wo } from "./components/icons/PrintDefaultIcon.js";
import { FullScreenTool as gn } from "./components/layout/toolbar/FullScreenTool.js";
import { GoToDownIcon as vn } from "./components/icons/GoToDownIcon.js";
import { SelectionModeTool as _o } from "./components/layout/toolbar/SelectionModeTool.js";
import { ZoomInIcon as bo } from "./components/icons/ZoomInIcon.js";
import { ZoomOutIcon as Co } from "./components/icons/ZoomOutIcon.js";
import { PAGE_PADDING as Mt } from "./utils/constants.js";
import { getZoomLevel as Po } from "./utils/getZoomLevel.js";
import { SearchIcon as To } from "./components/icons/SearchIcon.js";
import { c as J, S as Ht } from "./SearchCloseButton-ddb9877e.js";
import { UICheckbox as $t } from "./components/ui/Checkbox.js";
import { ClearIcon as So } from "./components/icons/ClearIcon.js";
import { InfoIcon as Gt } from "./components/icons/InfoIcon.js";
import './assets/RPDefaultLayout.css';const wn = () => {
const { viewMode: t } = Ne(), { scrollMode: e } = Ee(), { virtualScrollRef: n, virtualScrollableElementRef: o, pageScrollElementRef: r } = et(), { setFocusedPage: a } = ie(), l = H(), { columnCount: c } = un(), { widths: u, heights: d } = Ge(), m = H(e), v = H(t), p = H(c), { targetScrollPage: w } = pn();
F(() => {
n != null && n.scrollToItem && (l.current = n);
}, [n]), F(() => {
m.current = e, v.current = t;
}, [e, t]);
const P = N(
(_, y) => {
if (!r)
return;
const h = Math.ceil(_ / 2) * 2 - 1;
if (_ === h + 1) {
const g = {
left: u[h],
top: 0
};
return new Promise(
(s) => ct(r, g, s)
);
}
const f = {
left: 0,
top: 0
};
return r == null ? void 0 : r.scrollTo({
...f,
behavior: y
});
},
[r, u, ct]
);
return F(() => {
m.current = e, v.current = t;
}, [e, t]), F(() => {
p.current = c;
}, [c]), { scrollToPage: N(
(_, y = "smooth") => {
a(_);
const h = _ - 1;
let f = h, g = 0;
if (v.current === Re.DUAL_PAGE && m.current === Q.PAGE_SCROLLING) {
P(_, y);
return;
}
if (m.current === Q.PAGE_SCROLLING) {
a(_);
return;
}
if (!l.current || !o)
return;
const s = o;
if (w.current = _, m.current === Q.HORIZONTAL_SCROLLING) {
g = h;
const T = {
left: Ae(u, g),
top: 0
};
return s.scrollTo({
...T,
behavior: y
});
}
if (v.current === Re.DUAL_PAGE) {
g = h % 2, f = Math.floor(h / 2);
const T = {
left: Ae(u, g),
top: Ae(d, f)
};
return s.scrollTo({
...T,
behavior: y
});
}
const C = {
left: 0,
top: Ae(d, f)
};
return s.scrollTo({
...C,
behavior: y
});
},
[
o,
c,
P,
a,
ct,
d,
u
]
) };
}, yo = (t = 1) => {
const [e, n] = $(t), [o, r] = $(0), { scrollToPage: a } = wn(), l = H(1), { viewMode: c } = Ne(), { scrollMode: u } = Ee(), { widths: d } = Ge(), { pagesRef: m } = me(), v = Tt(e, 100), p = N(
(f) => {
if (!/^[0-9]*$/g.test(f.toString()) || !f)
return { success: !1, currentPage: l.current };
const s = +f;
return s < 0 || s > o ? { success: !1, currentPage: l.current } : (n(s), l.current = s, { success: !0, currentPage: +f });
},
[o]
), w = N(p, [p]), P = N(
(f) => {
const g = p(f);
return g.success && a(g.currentPage), g;
},
[p, a]
), S = N((f) => {
const g = f % 2 === 1;
if (!m || g)
return !1;
const s = g ? d[f] : d[f - 1], C = g ? d[f + 1] : d[f];
return c === Re.DUAL_PAGE && s + C < m.clientWidth;
}, [c, d, m, o]), _ = N(() => {
let f = e - 1;
S(f) && (f = e - 2), P(f);
}, [P, e, c, u, S]), y = k(() => c === Re.DUAL_PAGE && u === Q.PAGE_SCROLLING ? e === o - 1 : e === o, [e, o, c, u]), h = N(() => {
if (y)
return;
let f = e + 1;
S(f) && (f = e + 2), P(f);
}, [P, e, S, c, u, y]);
return {
focusedPage: v,
totalPages: o,
setFocusedPage: w,
setTotalPages: r,
nextPage: h,
prevPage: _,
goToPage: P
};
}, _n = Ye({
focusedPage: 0,
setFocusedPage: (t) => {
},
goToPage: (t) => ({ success: !!t, currentPage: +t }),
totalPages: 0,
setTotalPages: (t) => {
},
prevPage: () => {
},
nextPage: () => {
}
}), ie = () => {
const t = Je(_n);
return typeof (t == null ? void 0 : t.focusedPage) > "u" && Kr.error("Please use this hooks inside children component of RPProvider"), t;
}, Us = ({ children: t }) => {
const { pdf: e } = ee(), { focusedPage: n, totalPages: o, setFocusedPage: r, setTotalPages: a, goToPage: l, nextPage: c, prevPage: u } = yo();
return F(() => {
e != null && e.numPages && (a(e.numPages), r(1));
}, [e, a, r]), /* @__PURE__ */ i(
_n.Provider,
{
value: {
focusedPage: n,
totalPages: o,
setFocusedPage: r,
setTotalPages: a,
nextPage: c,
prevPage: u,
goToPage: l
},
children: t
}
);
};
const xo = () => {
const { pdf: t, pages: e } = ee(), [n, o] = $({
loadedPages: 0,
totalPages: 0,
percentage: 0
}), [r, a] = $(!1), [l, c] = $(!1), [u, d] = $(null), m = H(!1);
F(() => {
m.current;
}, [m]);
const v = N(() => {
document.documentElement.classList.remove("rp-print-html-printing"), document.body.classList.remove("rp-print-body-printing");
const f = document.querySelector(".rp-print-zone");
f && f.remove();
}, []), p = N(() => {
m.current = !1, a(!1), c(!1), d(null), o({
loadedPages: 0,
totalPages: 0,
percentage: 0
});
}, []), w = () => {
m.current = !0;
}, P = async ({
scratchCanvas: f,
pdfDocument: g,
pageNumber: s,
viewerPdfPage: C,
printResolution: b,
optionalContentConfigPromise: T,
printAnnotationStoragePromise: E
}) => {
if (m.current) {
p();
return;
}
const x = b / xr.PDF;
f.width = Math.floor(C.width * x), f.height = Math.floor(C.height * x);
const R = f.getContext("2d");
R.save(), R.fillStyle = "rgb(255, 255, 255)", R.fillRect(0, 0, f.width, f.height), R.restore();
const [D, z] = await Promise.all([
g.getPage(s),
E
]);
if (m.current) {
p();
return;
}
const A = {
canvasContext: R,
transform: [x, 0, 0, x, 0, 0],
viewport: D.getViewport({ scale: 1, rotation: C.rotation }),
intent: "print",
annotationMode: Ir.ENABLE_STORAGE,
optionalContentConfigPromise: T,
printAnnotationStorage: z
};
try {
return D.render(A).promise;
} catch (L) {
throw L instanceof Rr || console.error(L), L;
}
}, S = N(() => {
const f = window.print;
return new Promise((g) => {
const s = (T) => {
setTimeout(() => {
f.call(window), setTimeout(() => T(), 20);
}, 0);
};
if (document.querySelector(".rp-print-zone")) {
s(g);
return;
}
const b = new MutationObserver(() => {
document.querySelector(".rp-print-zone") && (s(g), b.disconnect());
});
b.observe(document.body, { childList: !0, subtree: !0 });
});
}, []), _ = async (f) => {
const g = document.createElement("img"), s = document.createElement("div");
return s.classList.add("rp-print-page"), await new Promise((C, b) => {
f.toBlob((T) => {
T ? (g.src = URL.createObjectURL(T), g.onload = () => {
URL.revokeObjectURL(g.src), C();
}, g.onerror = b) : b(new Error("Failed to create blob"));
});
}).catch(() => {
}), s.appendChild(g), s;
}, y = (f, g) => {
const s = document.createElement("div");
s.classList.add("rp-print-zone");
const C = document.createElement("style"), b = g.get(1);
if (b) {
const { width: T, height: E } = b == null ? void 0 : b.page.getViewport({ scale: 1 });
C.innerHTML = `@page { size: ${T}px ${E}px }`;
}
return s.appendChild(C), s.append(...f), s;
}, h = N(async () => {
if (!t)
return;
p();
const f = document.createElement("canvas"), g = [];
try {
t.isPureXfa && console.warn("[rp] XFA Form is not supported at the moment.");
const C = t.getOptionalContentConfig({ intent: "print" }), b = Promise.resolve(
t.annotationStorage.print ?? void 0
), T = e.size;
for (const [x, R] of e) {
if (m.current) {
p();
return;
}
const D = R.page.getViewport({ scale: 1 });
if (await P({
scratchCanvas: f,
pdfDocument: t,
pageNumber: x,
viewerPdfPage: D,
printResolution: 150,
optionalContentConfigPromise: C,
printAnnotationStoragePromise: b
}), m.current) {
p();
return;
}
const z = await _(f);
g.push(z);
const A = parseFloat((g.length / T * 100).toFixed(2));
o({
loadedPages: x,
totalPages: T,
percentage: A
});
}
if (m.current) {
p();
return;
}
const E = y(g, e);
document.body.appendChild(E), document.documentElement.classList.add("rp-print-html-printing"), document.body.classList.add("rp-print-body-printing"), a(!0), await S();
} catch (s) {
c(!0), s instanceof Error && d(s);
} finally {
f.height = 0, f.width = 0;
}
}, [t, e, m]);
return F(() => {
const f = () => {
p(), v();
};
return window.addEventListener("afterprint", f, !0), () => {
window.removeEventListener("afterprint", f, !0);
};
}, [v, p]), {
print: h,
cancel: w,
progress: n,
isComplete: r,
isError: l,
error: u
};
}, bn = Ye({
print: () => {
},
cancel: () => {
},
setOnProgress: (t) => {
},
progress: {},
setOnComplete: (t) => t(),
setOnError: (t) => {
try {
const e = new Error("Print error occurred");
t(e);
} catch (e) {
console.error("Error in setOnError callback:", e);
}
}
}), Vs = ({ children: t }) => {
const [e, n] = $(null), [o, r] = $(null), { print: a, cancel: l, progress: c, isComplete: u, isError: d, error: m } = xo(), v = N((_) => {
_ && typeof _ == "function" && r(() => _);
}, []), p = (_) => {
m && _(m);
}, w = N(
(_) => {
n(() => _);
},
[c, e]
);
F(() => {
u && o && P();
}, [u, o]), F(() => {
d && p((_) => {
console.error(_);
});
}, [d]), F(() => {
c && e && e(c);
}, [c, e]);
const P = () => {
o && (o(), r(null));
}, S = {
print: a,
cancel: l,
setOnProgress: w,
setOnComplete: v,
setOnError: p,
progress: c
};
return /* @__PURE__ */ i(bn.Provider, { value: S, children: t });
}, tt = () => {
const t = Je(bn);
if (!t)
throw new Error("usePrintContext must be used within a PrintProvider");
return t;
}, Io = () => {
const [t, e] = $({}), { pages: n } = ee(), o = k(() => Object.keys(t).length, [t]), r = N(
(l) => {
if (!n.size)
return;
const c = l > n.size ? n.size : l, u = Array.from(n.values()).slice(0, c).map((v) => {
const { thumbnailViewport: p, scale: w } = Wt(v.page, v.defaultRotation);
return {
scale: w,
page: v.page,
loading: !0,
viewport: p,
defaultRotation: v.defaultRotation
};
}), d = u.reduce((v, p) => (v[p.page.pageNumber] = p, v), {});
e(d);
const m = [];
for (const v of u) {
const p = document.createElement("canvas"), w = wt(v.page, p, {
scale: v.scale,
rotate: v.defaultRotation
}).promise.then(() => {
const P = p.toDataURL();
return {
...v,
thumbnailSrc: P,
loading: !1,
defaultRotation: v.defaultRotation
};
});
m.push(w);
}
Promise.all(m).then((v) => {
const p = v.reduce(
(w, P) => (w[P.page.pageNumber] = P, w),
{}
);
e((w) => ({ ...w, ...p }));
}).catch(() => {
});
},
[n]
);
F(() => {
r(10);
}, [r]);
const a = N(
(l) => {
if (!n)
return;
const c = n.get(l);
if (!c)
return;
e((d) => ({
...d,
[l]: {
loading: !0,
page: c.page,
viewport: c.thumbnailViewport,
scale: c.thumbnailScale,
defaultRotation: c.defaultRotation
}
}));
const u = document.createElement("canvas");
wt(c.page, u, {
scale: c.thumbnailScale,
rotate: c.defaultRotation
}).promise.then(() => {
const d = u.toDataURL(), { thumbnailViewport: m, scale: v } = Wt(c.page);
return {
scale: v,
thumbnailSrc: d,
page: c.page,
loading: !1,
viewport: m,
defaultRotation: c.defaultRotation
};
}).then((d) => {
e((m) => ({ ...m, [l]: d }));
});
},
[n]
);
return { thumbnailPages: t, addPage: a, addToPage: r, thumbnailLength: o };
}, Cn = Ye({
thumbnailPages: {},
addPage: (t) => {
},
addToPage: (t) => {
},
thumbnailLength: 0,
setActive: (t) => {
},
active: !1
}), Pn = () => Je(Cn), qs = ({
children: t,
initialThumbnailsVisible: e
}) => {
const { thumbnailPages: n, addPage: o, addToPage: r, thumbnailLength: a } = Io(), [l, c] = $(e);
return /* @__PURE__ */ i(
Cn.Provider,
{
value: { thumbnailPages: n, addPage: o, addToPage: r, thumbnailLength: a, active: l, setActive: c },
children: t
}
);
}, Ro = (t = {}, e = "") => {
const [n, o] = $(e), [r, a] = $(!1), { pdf: l, pages: c } = ee(), { widths: u, heights: d } = Ge(), m = H(!n), { currentZoom: v } = Qe(), [p, w] = $([]), { setFocusedPage: P } = ie(), { columnCount: S } = Ne(), { pageRotate: _ } = Ue(), [y, h] = $(0), { pageScrollElementRef: f, virtualScrollableElementRef: g } = et(), { scrollMode: s } = Ee(), { pagesRef: C } = me(), [b, T] = $(null), E = H({}), x = k(() => y === 0 ? null : p[y - 1], [y, p]), R = k(() => p.length, [p]);
F(() => {
if (!x || !c)
return;
const L = g || f;
if (!L || !C)
return;
const I = c.get(x.page);
if (s === Q.PAGE_SCROLLING && P(x.page), !I)
return;
let O = 0, M = 0;
if (s === Q.VERTICAL_SCROLLING) {
const le = x.page - 1, Y = S, Fe = le % Y, we = Math.floor(le / Y);
O = Ae(d, we), M = Ae(u, Fe);
}
s === Q.HORIZONTAL_SCROLLING && (M = u.slice(0, x.page - 1).reduce((le, Y) => le + Y, 0));
const G = {
height: d[x.page - 1],
width: u[x.page - 1]
}, Z = {
top: G.height / 2,
left: G.width / 2
}, j = _[x.page], { leftInPage: q, topInPage: te } = jr(
G,
Z,
x.rect,
v,
j
), X = M + q, ce = O + te, ve = {
left: Math.max(X, 0),
top: Math.max(ce, 0)
};
L.scrollTo({
...ve,
behavior: "smooth"
});
}, [
c,
P,
u,
d,
x,
s,
g,
f,
C
]);
const D = N(() => {
h((L) => R ? L + 1 > R ? 1 : L + 1 : 0);
}, [R]), z = N(() => {
h((L) => R ? L - 1 <= 0 ? R : L - 1 : 0);
}, [R]), A = N(async (L) => {
if (!L)
return {};
const I = L.numPages, O = {};
for (let M = 1; M <= I; M++) {
if (m.current)
throw "close pop over";
const G = await L.getPage(M);
O[M.toString()] = await G.getTextContent();
}
return O;
}, []);
return F(() => {
if (!n) {
m.current = !0, w([]), h(0);
return;
}
m.current = !1, a(!0), w([]), h(0), A(l).then((L) => {
E.current = L;
const O = Object.keys(L).reduce((M, G) => {
const Z = lr(
[n],
L[G],
Number(G) - 1,
t
).map((j, q) => ({ ...j, page: Number(G), pageMatchIdx: q }));
return [...M, ...Z];
}, []);
w(O), h(O.length ? 1 : 0);
}).catch(() => {
w([]), h(0);
}).finally(() => a(!1));
}, [n, A, l, t]), {
search: n,
setSearch: o,
loading: r,
matches: p,
totalMatches: R,
currentMatchPosition: y,
currentMatch: x,
nextMatch: D,
prevMatch: z,
currentMatchElement: b,
setCurrentMatchElement: T
};
}, Tn = Ye({
search: "",
setSearch: (t) => {
},
loading: !1,
matches: [],
totalMatches: 0,
currentMatchPosition: 0,
currentMatch: null,
nextMatch: () => {
},
prevMatch: () => {
},
searchOptions: {},
setSearchOptions: (t) => t,
currentMatchElement: null,
setCurrentMatchElement: (t) => {
}
}), Bs = ({
children: t,
initialSearch: e
}) => {
const [n, o] = $({}), {
loading: r,
setSearch: a,
totalMatches: l,
currentMatchPosition: c,
currentMatch: u,
search: d,
matches: m,
nextMatch: v,
prevMatch: p,
currentMatchElement: w,
setCurrentMatchElement: P
} = Ro(n, e);
return /* @__PURE__ */ i(
Tn.Provider,
{
value: {
searchOptions: n,
setSearchOptions: o,
loading: r,
setSearch: a,
totalMatches: l,
currentMatchPosition: c,
currentMatch: u,
nextMatch: v,
prevMatch: p,
search: d,
matches: m,
currentMatchElement: w,
setCurrentMatchElement: P
},
children: t
}
);
}, It = () => Je(Tn), de = {
"rp-pages": "_rp-pages_17t6t_1",
"rp-pages-horizontal-scroll": "_rp-pages-horizontal-scroll_17t6t_7",
"rp-pages-container": "_rp-pages-container_17t6t_11",
"rp-page-scrolling-wrapper": "_rp-page-scrolling-wrapper_17t6t_48",
"rp-viewer": "_rp-viewer_17t6t_53",
"rp-cursor-grab": "_rp-cursor-grab_17t6t_58",
"rp-cursor-grabbing": "_rp-cursor-grabbing_17t6t_66",
"rp-loader": "_rp-loader_17t6t_74"
}, dt = {
"rp-page-wrapper": "_rp-page-wrapper_14ohm_1",
"rp-page": "_rp-page_14ohm_1",
"rp-loader-wrapper": "_rp-loader-wrapper_14ohm_15"
}, Lo = (t) => {
const { pageNumber: e, onLoaded: n, onLoading: o } = t, r = H(null), { pages: a } = ee(), { pageRotate: l } = Ue(), c = H(), { currentZoom: u } = Qe();
return F(() => {
if (!a || u === 0)
return;
const d = a.get(e);
if (r.current && d) {
const m = r.current;
m.hidden = !0;
const v = c.current;
v && v.cancel(), o && o(), c.current = wt(d.page, m, {
scale: u,
rotate: l[e],
renderForms: !0
}), c.current.promise.then(() => {
m.hidden = !1;
}).catch(() => {
}).finally(() => {
n && n();
});
}
return () => {
var m;
(m = c.current) == null || m.cancel();
};
}, [a, e, l, u, o, n]), /* @__PURE__ */ i("canvas", { "data-rp": `page-${e}-canvas`, ref: r });
}, Eo = "_selecting_usdup_9", pe = {
"rp-text-layer": "_rp-text-layer_usdup_1",
selecting: Eo,
"rp-text-layer-text": "_rp-text-layer-text_usdup_39"
}, No = (t) => {
const { pageNumber: e } = t, { pages: n } = ee(), o = H(null), { matches: r, currentMatch: a, setCurrentMatchElement: l } = It(), [c, u] = $(
[]
), d = H(), m = H(), v = H([]), p = k(() => r.filter((f) => f.pageIndex === e - 1), [r, e]), w = N(
(f, g, s = !1) => {
if (s && dr(f, g), !p.length) {
v.current = [], u([]);
return;
}
const C = ur(p, f, g);
u(C);
},
[p]
), P = H(), S = H(!1), _ = N(() => Array.from(document.querySelectorAll('[data-rp$="-textLayer"]')), []);
F(() => ((() => {
if (P.current)
return;
P.current = new AbortController();
const { signal: g } = P.current, s = () => {
_().forEach((b) => {
const T = b.querySelector(".endOfContent");
T && (b.appendChild(T), T.style.width = "", T.style.height = "", b.classList.remove(pe.selecting));
});
};
document.addEventListener(
"pointerdown",
() => {
S.current = !0;
},
{ signal: g }
), document.addEventListener(
"pointerup",
() => {
S.current = !1, s();
},
{ signal: g }
), window.addEventListener(
"blur",
() => {
S.current = !1, s();
},
{ signal: g }
), document.addEventListener(
"keyup",
() => {
S.current || s();
},
{ signal: g }
);
let C = null;
document.addEventListener(
"selectionchange",
() => {
var A, L;
const b = document.getSelection();
if (!b)
return;
if (b.rangeCount === 0) {
s();
return;
}
const T = /* @__PURE__ */ new Set();
for (let I = 0; I < b.rangeCount; I++) {
const O = b.getRangeAt(I);
_().forEach((M) => {
O.intersectsNode(M) && !T.has(M) && T.add(M);
});
}
_().forEach((I) => {
if (T.has(I))
I.classList.add(pe.selecting);
else {
const O = I.querySelector(".endOfContent");
O && (I.appendChild(O), O.style.width = "", O.style.height = "", I.classList.remove(pe.selecting));
}
});
const E = b.getRangeAt(0);
let R = C && (E.compareBoundaryPoints(Range.END_TO_END, C) === 0 || E.compareBoundaryPoints(Range.START_TO_END, C) === 0) ? E.startContainer : E.endContainer;
R.nodeType === Node.TEXT_NODE && (R = R.parentNode);
const D = (A = R.parentElement) == null ? void 0 : A.closest(
pe["rp-text-layer"]
), z = D == null ? void 0 : D.querySelector(".endOfContent");
z && D && (z.style.width = D.style.width, z.style.height = D.style.height, (L = R.parentElement) == null || L.insertBefore(z, R.nextSibling)), C = E.cloneRange();
},
{ signal: g }
);
})(), () => {
var g;
(g = P.current) == null || g.abort(), P.current = void 0;
}), [_]);
const y = N(() => {
o.current && o.current.classList.add(pe.selecting);
}, []), h = N(() => {
o.current && o.current.classList.remove(pe.selecting);
}, []);
return F(() => {
if (v.current.forEach((s) => {
s.classList.remove("selected");
}), !c.length || !a || a.pageIndex !== e - 1)
return;
const f = p.findIndex(
(s) => JSON.stringify(s) === JSON.stringify(a)
);
if (f === -1)
return;
const g = c.filter((s) => s.index === f);
g.length && (v.current = g.map((s) => s.element), l(g[0].element), g.forEach((s) => {
s.element.classList.add("selected");
}));
}, [a, c, p]), F(() => {
const f = n.get(e);
if (!f || !o.current)
return;
const g = o.current;
return d.current && d.current.cancel(), f.page.getTextContent().then((s) => {
const C = f.page.getViewport({ scale: 1 });
return d.current = new yr.TextLayer({
viewport: C,
textContentSource: s,
container: g
}), m.current = s, g && (g.innerText = ""), d.current.render();
}).then(() => {
var T, E;
[].slice.call(g.children).forEach((x) => {
x.classList.add(pe["rp-text-layer-text"]), x.setAttribute("data-rp", "rp-text-layer-text");
});
const C = (T = d.current) == null ? void 0 : T.textDivs;
C && m.current && w(m.current, C);
const b = document.createElement("div");
b.className = "endOfContent", (E = o.current) == null || E.appendChild(b);
}).catch(() => {
}), () => {
var s;
(s = d.current) == null || s.cancel();
};
}, [n, e]), F(() => {
var s;
[].slice.call(o.current.children).forEach((C) => {
C.classList.add(pe["rp-text-layer-text"]);
});
const g = (s = d.current) == null ? void 0 : s.textDivs;
g && m.current && w(m.current, g, !0);
}, [w]), /* @__PURE__ */ i(
"div",
{
"data-rp": `page-${e}-textLayer`,
className: pe["rp-text-layer"],
ref: o,
onMouseDown: y,
onMouseUp: h
}
);
}, Oo = {
"rp-annotation-layer": "_rp-annotation-layer_1udza_1"
};
let Do = "https://unpkg.com/pdfjs-dist@4.4.168/web/images/";
const zo = (t) => {
const { pageNumber: e } = t, n = H(null), { pages: o, pdf: r } = ee(), a = H(), [l, c] = $(), { setFocusedPage: u, goToPage: d } = ie(), { scrollMode: m } = Ee(), { print: v } = tt(), { download: p } = Gn(), w = k(() => o.get(e), [o, e]), P = k(() => w == null ? void 0 : w.page.getViewport(), [w]);
F(() => {
a.current && (a.current.div.replaceChildren(), a.current = void 0);
}, [r]), F(() => {
w && w.page.getAnnotations().then((_) => {
a.current = void 0, c(_), n.current && (n.current.innerText = "");
});
}, [w]);
const S = N(
(_) => {
!l || !r || (Nr(_), Or(_, r, l).then((y) => {
var h, f;
((h = y == null ? void 0 : y.data) == null ? void 0 : h.action) === "Print" ? v() : ((f = y == null ? void 0 : y.data) == null ? void 0 : f.action) === "SaveAs" && p();
}), m === Q.PAGE_SCROLLING ? At(_, l, r, (y) => u(y.pageIndex + 1)) : At(_, l, r, (y) => d(y.pageIndex + 1)));
},
[r, l, d, u, m, v, p]
);
return F(() => {
if (!w || !l)
return;
const _ = w.page.getViewport();
if (a.current) {
a.current.update({
viewport: _.clone({ dontFlip: !0 })
});
return;
}
const y = /* @__PURE__ */ new Map([]);
for (const g of l) {
const { annotationType: s } = g;
switch (s) {
case zt.Link:
zr(g);
break;
case zt.Widget:
Dr(g, _, y);
break;
}
}
const h = new AbortController();
return (async () => {
var C;
a.current && (a.current.div.replaceChildren(), a.current = void 0), n.current && (n.current.innerText = ""), a.current = new Lr({
div: n.current,
accessibilityManager: void 0,
annotationCanvasMap: void 0,
annotationEditorUIManager: void 0,
structTreeLayer: null,
page: w.page,
viewport: _.clone({ dontFlip: !0 })
}), n.current && Ft(n.current, S);
const g = await (r == null ? void 0 : r.hasJSActions()), s = await (r == null ? void 0 : r.getFieldObjects());
if (h.signal.aborted)
throw "abort";
return (C = a.current) == null ? void 0 : C.render({
annotations: l,
annotationStorage: r == null ? void 0 : r.annotationStorage,
hasJSActions: g,
fieldObjects: s,
div: n.current,
viewport: _.clone({ dontFlip: !0 }),
page: w.page,
imageResourcesPath: Do,
renderForms: !0,
linkService: new Er(),
downloadManager: null,
enableScripting: !1
});
})().then(() => {
n.current && Ar(n.current, S);
}).catch((g) => {
if (g !== "abort")
throw g;
}), () => {
h.abort("clear"), n.current && Ft(n.current, S);
};
}, [r, l, S]), /* @__PURE__ */ i(
"div",
{
"data-rp": `page-${e}-annotationLayer`,
style: { width: `${P == null ? void 0 : P.width}px`, height: `${P == null ? void 0 : P.height}px` },
className: Oo["rp-annotation-layer"],
ref: n
}
);
}, Ao = {
"rp-text-highlight": "_rp-text-highlight_jdkf8_1"
}, Fo = ({ pageNumber: t, viewport: e }) => {
const [n, o] = $(), { pages: r } = ee(), { highlightKeywords: a } = hr(), l = !0, c = H(null), [u, d] = $(null), [m, v] = $([]);
F(() => {
c.current && d(c.current.parentElement);
}, [c]), F(() => {
(async () => {
const f = r.get(t);
if (!f || !c.current)
return;
const g = await f.page.getTextContent();
o(g);
})();
}, [r, t]);
const p = k(() => a ? a.map((h) => {
var f, g;
return {
...Fr(h.keyword, (f = h.options) == null ? void 0 : f.matchCase, (g = h.options) == null ? void 0 : g.wholeWords),
color: h.highlightColor
};
}) : [], [a]);
function w(h, f) {
if (!h)
return;
const g = `[data-rp="page-${f}-textLayer"]`;
return new Promise((s) => {
const C = h.querySelector(g);
if (C) {
s(C);
return;
}
new MutationObserver((T, E) => {
const x = h.querySelector(g);
x && (s(x), E.disconnect());
}).observe(h, { childList: !0, subtree: !0 });
});
}
function P(h) {
return new Promise((f) => {
const g = h.querySelectorAll(
'[data-rp="rp-text-layer-text"]'
);
if (g.length) {
f(Array.from(g));
return;
}
new MutationObserver((C, b) => {
const T = h.querySelectorAll(
".rp-text-layer-text"
);
T.length && (f(Array.from(T)), b.disconnect());
}).observe(h, { childList: !0, subtree: !0 });
});
}
const S = (h, f, g, s) => {
var Z;
const C = document.createRange(), b = g.firstChild;
if (!b || b.nodeType !== Node.TEXT_NODE)
return null;
const T = ((Z = b.textContent) == null ? void 0 : Z.length) ?? 0, E = s[0].charIdxInSpan, x = s.length === 1 ? E : s[s.length - 1].charIdxInSpan;
if (E > T || x + 1 > T)
return null;
C.setStart(b, E), C.setEnd(b, x + 1);
const R = document.createElement("span");
R.style.width = "auto", C.surroundContents(R);
const D = R.getBoundingClientRect(), z = h.getBoundingClientRect(), A = z.height, L = z.width, I = 100 * (D.left - z.left) / L, O = 100 * (D.top - z.top) / A, M = 100 * D.height / A, G = 100 * D.width / L;
return kr(R), {
keywordStr: f,
left: I,
top: O,
height: M,
width: G,
pageHeight: A,
pageWidth: L
};
};
async function _(h, f) {
const g = await w(u, h);
if (!g)
return;
const s = await P(g);
if (s.length) {
const C = s.map((T) => T.tagName === "BR" ? " " : T.textContent).reduce(
(T, E, x) => T.concat(
E.split("").map((R, D) => ({
char: R,
charIdxInSpan: D,
spanIdx: x
}))
),
[
{
char: "",
charIdxInSpan: 0,
spanIdx: 0
}
]
).slice(1), b = y(g, f, s, C);
v(b);
}
}
const y = (h, f, g, s) => {
const C = f.length;
if (!s.length || !C)
return [];
const b = [], T = s.map((E) => E.char).join("");
return p.forEach((E) => {
const { keyword: x, regExp: R, wholeWords: D, color: z } = E, A = x;
if (!A.trim())
return;
const L = R.flags.indexOf("g") === -1 ? new RegExp(R, `${R.flags}g`) : R;
let I;
const O = [];
for (; (I = L.exec(T)) !== null; )
D && !pr(T, I.index, I[0].length) || O.push({
keyword: L,
startIndex: I.index,
endIndex: L.lastIndex
});
const M = O.map((G) => ({
keyword: G.keyword,
indexes: s.slice(G.startIndex, G.endIndex),
color: z
}));
for (const G of M) {
const Z = G.indexes.reduce(
(j, q) => (j[q.spanIdx] = (j[q.spanIdx] || []).concat([q]), j),
{}
);
for (const j of Object.values(Z))
if (j.length !== 1 || j[0].char.trim() !== "") {
const q = j, te = g[q[0].spanIdx], X = S(
h,
A,
te,
q
);
if (X) {
const { left: ce, top: ve } = X;
if (b.find((Y) => Y.left === ce && Y.top === ve))
continue;
b.push({ ...X, highlightColor: G.color });
}
}
}
}), b.sort(Wr), b;
};
return F(() => {
(async () => {
if (!(!a || a.length === 0))
try {
await _(t, a);
} catch (f) {
console.error(f);
}
})();
}, [l, a, t, n, e]), /* @__PURE__ */ i(fe, { children: /* @__PURE__ */ i("div", { ref: c, "data-rp": `page-${t}-textHighlightLayer`, children: m.map((h, f) => /* @__PURE__ */ i(
"div",
{
className: Ao["rp-text-highlight"],
style: {
top: `${h.top}%`,
left: `${h.left}%`,
width: `${h.width}%`,
height: `${h.height}%`,
backgroundColor: h.highlightColor
}
},
f
)) }) });
}, Rt = $e((t, e) => {
const { pageNumber: n, style: o, ...r } = t, { pages: a } = ee(), { pageRotate: l } = Ue(), { textLayer: c } = ir(), { currentZoom: u } = Qe(), d = H(a.get(n)), [m, v] = $(!1), p = H(null), [w, P] = $({
width: 0,
height: 0
});
cn(e, () => p.current);
const S = k(() => d.current ? l[n] : 0, [n, l]);
F(() => {
if (a && (d.current = a.get(n), d.current)) {
const f = d.current.page.getViewport({
scale: u,
rotation: S
});
P(f);
}
}, [a, n, S, u]);
const _ = k(() => {
switch (S) {
case 90:
return `${w.width / 2}px ${w.width / 2}px`;
case -90:
case 270:
return `${w.height / 2}px ${w.height / 2}px`;
default:
return "center";
}
}, [S, w]), y = N(() => {
v(!0);
}, []), h = N(() => {
v(!1);
}, []);
return /* @__PURE__ */ i(
"div",
{
ref: p,
id: `page-${n}`,
"data-rp": `page-${n}`,
...r,
style: {
...o,
"--rp-rotate": `${S}deg`,
"--rp-page-rotate-translate": `${_}`,
"--scale-factor": u
},
className: dt["rp-page-wrapper"],
children: /* @__PURE__ */ W(
"div",
{
style: {
width: `${w.width}px`,
height: `${w.height}px`
},
className: dt["rp-page"],
children: [
/* @__PURE__ */ i(Lo, { onLoading: y, onLoaded: h, pageNumber: n }),
m && /* @__PURE__ */ i("div", { className: dt["rp-loader-wrapper"], children: /* @__PURE__ */ i(Pt, {}) }),
/* @__PURE__ */ i(Mr, { pageNumber: n }),
c && /* @__PURE__ */ i(No, { pageNumber: n }),
/* @__PURE__ */ i(Fo, { pageNumber: n, viewport: w }),
/* @__PURE__ */ i(zo, { pageNumber: n })
]
}
)
}
);
});
function Ut(t) {
if (t === void 0)
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return t;
}
function _t(t, e) {
return _t = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(n, o) {
return n.__proto__ = o, n;
}, _t(t, e);
}
function Wo(t, e) {
t.prototype = Object.create(e.prototype), t.prototype.constructor = t, _t(t, e);
}
var Vt = Number.isNaN || function(e) {
return typeof e == "number" && e !== e;
};
function ko(t, e) {
return !!(t === e || Vt(t) && Vt(e));
}
function Mo(t, e) {
if (t.length !== e.length)
return !1;
for (var n = 0; n < t.length; n++)
if (!ko(t[n], e[n]))
return !1;
return !0;
}
function ut(t, e) {
e === void 0 && (e = Mo);
var n, o = [], r, a = !1;
function l() {
for (var c = [], u = 0; u < arguments.length; u++)
c[u] = arguments[u];
return a && n === this && e(c, o) || (r = t.apply(this, c), a = !0, n = this, o = c), r;
}
return l;
}
function qt(t, e) {
if (t == null)
return {};
var n = {};
for (var o in t)
if ({}.hasOwnProperty.call(t, o)) {
if (e.indexOf(o) !== -1)
continue;
n[o] = t[o];
}
return n;
}
var Ho = typeof performance == "object" && typeof performance.now == "function", Bt = Ho ? function() {
return performance.now();
} : function() {
return Date.now();
};
function Zt(t) {
cancelAnimationFrame(t.id);
}
function $o(t, e) {
var n = Bt();
function o() {
Bt() - n >= e ? t.call(null) : r.id = requestAnimationFrame(o);
}
var r = {
id: requestAnimationFrame(o)
};
return r;
}
var pt = -1;
function Go(t) {
if (t === void 0 && (t = !1), pt === -1 || t) {
var e = document.createElement("div"), n = e.style;
n.width = "50px", n.height = "50px", n.overflow = "scroll", document.body.appendChild(e), pt = e.offsetWidth - e.clientWidth, document.body.removeChild(e);
}
return pt;
}
var Oe = null;
function jt(t) {
if (t === void 0 && (t = !1), Oe === null || t) {
var e = document.createElement("div"), n = e.style;
n.width = "50px", n.height = "50px", n.overflow = "scroll", n.direction = "rtl";
var o = document.createElement("div"), r = o.style;
return r.width = "100px", r.height = "100px", e.appendChild(o), document.body.appendChild(e), e.scrollLeft > 0 ? Oe = "positive-descending" : (e.scrollLeft = 1, e.scrollLeft === 0 ? Oe = "negative" : Oe = "positive-ascending"), document.body.removeChild(e), Oe;
}
return Oe;
}
var Uo = 150, Vo = function(e) {
var n = e.columnIndex;
e.data;
var o = e.rowIndex;
return o + ":" + n;
}, Be = null, Ze = null, je = null;
process.env.NODE_ENV !== "production" && typeof window < "u" && typeof window.WeakSet < "u" && (Be = /* @__PURE__ */ new WeakSet(), Ze = /* @__PURE__ */ new WeakSet(), je = /* @__PURE__ */ new WeakSet());
function qo(t) {
var e, n = t.getColumnOffset, o = t.getColumnStartIndexForOffset, r = t.getColumnStopIndexForStartIndex, a = t.getColumnWidth, l = t.getEstimatedTotalHeight, c = t.getEstimatedTotalWidth, u = t.getOffsetForColumnAndAlignment, d = t.getOffsetForRowAndAlignment, m = t.getRowHeight, v = t.getRowOffset, p = t.getRowStartIndexForOffset, w = t.getRowStopIndexForStartIndex, P = t.initInstanceProps, S = t.shouldResetStyleCacheOnItemSizeChange, _ = t.validateProps;
return e = /* @__PURE__ */ function(y) {
Wo(h, y);
function h(g) {
var s;
return s = y.call(this, g) || this, s._instanceProps = P(s.props, Ut(s)), s._resetIsScrollingTimeoutId = null, s._outerRef = void 0, s.state = {
instance: Ut(s),
isScrolling: !1,
horizontalScrollDirection: "forward",
scrollLeft: typeof s.props.initialScrollLeft == "number" ? s.props.initialScrollLeft : 0,
scrollTop: typeof s.props.initialScrollTop == "number" ? s.props.initialScrollTop : 0,
scrollUpdateWasRequested: !1,
verticalScrollDirection: "forward"
}, s._callOnItemsRendered = void 0, s._callOnItemsRendered = ut(function(C, b, T, E, x, R, D, z) {
return s.props.onItemsRendered({
overscanColumnStartIndex: C,
overscanColumnStopIndex: b,
overscanRowStartIndex: T,
overscanRowStopIndex: E,
visibleColumnStartIndex: x,
visibleColumnStopIndex: R,
visibleRowStartIndex: D,
visibleRowStopIndex: z
});
}), s._callOnScroll = void 0, s._callOnScroll = ut(function(C, b, T, E, x) {
return s.props.onScroll({
horizontalScrollDirection: T,
scrollLeft: C,
scrollTop: b,
verticalScrollDirection: E,
scrollUpdateWasRequested: x
});
}), s._getItemStyle = void 0, s._getItemStyle = function(C, b) {
var T = s.props, E = T.columnWidth, x = T.direction, R = T.rowHeight, D = s._getItemStyleCache(S && E, S && x, S && R), z = C + ":" + b, A;
if (D.hasOwnProperty(z))
A = D[z];
else {
var L = n(s.props, b, s._instanceProps), I = x === "rtl";
D[z] = A = {
position: "absolute",
left: I ? void 0 : L,
right: I ? L : void 0,
top: v(s.props, C, s._instanceProps),
height: m(s.props, C, s._instanceProps),
width: a(s.props, b, s._instanceProps)
};
}
return A;
}, s._getItemStyleCache = void 0, s._getItemStyleCache = ut(function(C, b, T) {
return {};
}), s._onScroll = function(C) {
var b = C.currentTarget, T = b.clientHeight, E = b.clientWidth, x = b.scrollLeft, R = b.scrollTop, D = b.scrollHeight, z = b.scrollWidth;
s.setState(function(A) {
if (A.scrollLeft === x && A.scrollTop === R)
return null;
var L = s.props.direction, I = x;
if (L === "rtl")
switch (jt()) {
case "negative":
I = -x;
break;
case "positive-descending":
I = z - E - x;
break;
}
I = Math.max(0, Math.min(I, z - E));
var O = Math.max(0, Math.min(R, D - T));
return {
isScrolling: !0,
horizontalScrollDirection: A.scrollLeft < x ? "forward" : "backward",
scrollLeft: I,
scrollTop: O,
verticalScrollDirection: A.scrollTop < R ? "forward" : "backward",
scrollUpdateWasRequested: !1
};
}, s._resetIsScrollingDebounced);
}, s._outerRefSetter = function(C) {
var b = s.props.outerRef;
s._outerRef = C, typeof b == "function" ? b(C) : b != null && typeof b == "object" && b.hasOwnProperty("current") && (b.current = C);
}, s._resetIsScrollingDebounced = function() {
s._resetIsScrollingTimeoutId !== null && Zt(s._resetIsScrollingTimeoutId), s._resetIsScrollingTimeoutId = $o(s._resetIsScrolling, Uo);
}, s._resetIsScrolling = function() {
s._resetIsScrollingTimeoutId = null, s.setState({
isScrolling: !1
}, function() {
s._getItemStyleCache(-1);
});
}, s;
}
h.getDerivedStateFromProps = function(s, C) {
return Bo(s, C), _(s), null;
};
var f = h.prototype;
return f.scrollTo = function(s) {
var C = s.scrollLeft, b = s.scrollTop;
C !== void 0 && (C = Math.max(0, C)), b !== void 0 && (b = Math.max(0, b)), this.setState(function(T) {
return C === void 0 && (C = T.scrollLeft), b === void 0 && (b = T.scrollTop), T.scrollLeft === C && T.scrollTop === b ? null : {
horizontalScrollDirection: T.scrollLeft < C ? "forward" : "backward",
scrollLeft: C,
scrollTop: b,
scrollUpdateWasRequested: !0,
verticalScrollDirection: T.scrollTop < b ? "forward" : "backward"
};
}, this._resetIsScrollingDebounced);
}, f.scrollToItem = function(s) {
var C = s.align, b = C === void 0 ? "auto" : C, T = s.columnIndex, E = s.rowIndex, x = this.props, R = x.columnCount, D = x.height, z = x.rowCount, A = x.width, L = this.state, I = L.scrollLeft, O = L.scrollTop, M = Go();
T !== void 0 && (T = Math.max(0, Math.min(T, R - 1))), E !== void 0 && (E = Math.max(0, Math.min(E, z - 1)));
var G = l(this.props, this._instanceProps), Z = c(this.props, this._instanceProps), j = Z > A ? M : 0, q = G > D ? M : 0;
this.scrollTo({
scrollLeft: T !== void 0 ? u(this.props, T, b, I, this._instanceProps, q) : I,
scrollTop: E !== void 0 ? d(this.props, E, b, O, this._instanceProps, j) : O
});
}, f.componentDidMount = function() {
var s = this.props, C = s.initialScrollLeft, b = s.initialScrollTop;
if (this._outerRef != null) {
var T = this._outerRef;
typeof C == "number" && (T.scrollLeft = C), typeof b == "number" && (T.scrollTop = b);
}
this._callPropsCallbacks();
}, f.componentDidUpdate = function() {
var s = this.props.direction, C = this.state, b = C.scrollLeft, T = C.scrollTop, E = C.scrollUpdateWasRequested;