@page-speed/lightbox 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/components/LightboxContent.d.ts +3 -2
- package/dist/components/index.js +794 -128
- package/dist/index.cjs +799 -133
- package/dist/index.js +799 -133
- package/dist/renderers/ImageRenderer.d.ts +7 -6
- package/dist/renderers/index.js +746 -94
- package/dist/types.d.ts +21 -0
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -983,7 +983,7 @@ var require_react_development = __commonJS({
|
|
|
983
983
|
}
|
|
984
984
|
return lazyType;
|
|
985
985
|
}
|
|
986
|
-
function
|
|
986
|
+
function forwardRef2(render) {
|
|
987
987
|
{
|
|
988
988
|
if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
|
|
989
989
|
error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...)).");
|
|
@@ -1044,7 +1044,7 @@ var require_react_development = __commonJS({
|
|
|
1044
1044
|
}
|
|
1045
1045
|
return false;
|
|
1046
1046
|
}
|
|
1047
|
-
function
|
|
1047
|
+
function memo2(type, compare) {
|
|
1048
1048
|
{
|
|
1049
1049
|
if (!isValidElementType(type)) {
|
|
1050
1050
|
error("memo: The first argument must be a component. Instead received: %s", type === null ? "null" : typeof type);
|
|
@@ -1104,11 +1104,11 @@ var require_react_development = __commonJS({
|
|
|
1104
1104
|
var dispatcher = resolveDispatcher();
|
|
1105
1105
|
return dispatcher.useReducer(reducer, initialArg, init);
|
|
1106
1106
|
}
|
|
1107
|
-
function
|
|
1107
|
+
function useRef5(initialValue) {
|
|
1108
1108
|
var dispatcher = resolveDispatcher();
|
|
1109
1109
|
return dispatcher.useRef(initialValue);
|
|
1110
1110
|
}
|
|
1111
|
-
function
|
|
1111
|
+
function useEffect10(create, deps) {
|
|
1112
1112
|
var dispatcher = resolveDispatcher();
|
|
1113
1113
|
return dispatcher.useEffect(create, deps);
|
|
1114
1114
|
}
|
|
@@ -1124,11 +1124,11 @@ var require_react_development = __commonJS({
|
|
|
1124
1124
|
var dispatcher = resolveDispatcher();
|
|
1125
1125
|
return dispatcher.useCallback(callback, deps);
|
|
1126
1126
|
}
|
|
1127
|
-
function
|
|
1127
|
+
function useMemo4(create, deps) {
|
|
1128
1128
|
var dispatcher = resolveDispatcher();
|
|
1129
1129
|
return dispatcher.useMemo(create, deps);
|
|
1130
1130
|
}
|
|
1131
|
-
function
|
|
1131
|
+
function useImperativeHandle2(ref, create, deps) {
|
|
1132
1132
|
var dispatcher = resolveDispatcher();
|
|
1133
1133
|
return dispatcher.useImperativeHandle(ref, create, deps);
|
|
1134
1134
|
}
|
|
@@ -1881,24 +1881,24 @@ var require_react_development = __commonJS({
|
|
|
1881
1881
|
exports2.createElement = createElement$1;
|
|
1882
1882
|
exports2.createFactory = createFactory;
|
|
1883
1883
|
exports2.createRef = createRef;
|
|
1884
|
-
exports2.forwardRef =
|
|
1884
|
+
exports2.forwardRef = forwardRef2;
|
|
1885
1885
|
exports2.isValidElement = isValidElement;
|
|
1886
1886
|
exports2.lazy = lazy;
|
|
1887
|
-
exports2.memo =
|
|
1887
|
+
exports2.memo = memo2;
|
|
1888
1888
|
exports2.startTransition = startTransition;
|
|
1889
1889
|
exports2.unstable_act = act;
|
|
1890
1890
|
exports2.useCallback = useCallback7;
|
|
1891
1891
|
exports2.useContext = useContext;
|
|
1892
1892
|
exports2.useDebugValue = useDebugValue;
|
|
1893
1893
|
exports2.useDeferredValue = useDeferredValue;
|
|
1894
|
-
exports2.useEffect =
|
|
1894
|
+
exports2.useEffect = useEffect10;
|
|
1895
1895
|
exports2.useId = useId;
|
|
1896
|
-
exports2.useImperativeHandle =
|
|
1896
|
+
exports2.useImperativeHandle = useImperativeHandle2;
|
|
1897
1897
|
exports2.useInsertionEffect = useInsertionEffect;
|
|
1898
1898
|
exports2.useLayoutEffect = useLayoutEffect;
|
|
1899
|
-
exports2.useMemo =
|
|
1899
|
+
exports2.useMemo = useMemo4;
|
|
1900
1900
|
exports2.useReducer = useReducer;
|
|
1901
|
-
exports2.useRef =
|
|
1901
|
+
exports2.useRef = useRef5;
|
|
1902
1902
|
exports2.useState = useState9;
|
|
1903
1903
|
exports2.useSyncExternalStore = useSyncExternalStore;
|
|
1904
1904
|
exports2.useTransition = useTransition;
|
|
@@ -20882,11 +20882,11 @@ __export(dist_exports, {
|
|
|
20882
20882
|
useZoom: () => useZoom
|
|
20883
20883
|
});
|
|
20884
20884
|
function usePDFDocument(url, onError) {
|
|
20885
|
-
const [document2, setDocument] = (0,
|
|
20886
|
-
const [loading, setLoading] = (0,
|
|
20887
|
-
const [error, setError] = (0,
|
|
20888
|
-
const [pdfDoc, setPdfDoc] = (0,
|
|
20889
|
-
(0,
|
|
20885
|
+
const [document2, setDocument] = (0, import_react9.useState)(null);
|
|
20886
|
+
const [loading, setLoading] = (0, import_react9.useState)(true);
|
|
20887
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
20888
|
+
const [pdfDoc, setPdfDoc] = (0, import_react9.useState)(null);
|
|
20889
|
+
(0, import_react9.useEffect)(() => {
|
|
20890
20890
|
if (!url) return;
|
|
20891
20891
|
setLoading(true);
|
|
20892
20892
|
setError(null);
|
|
@@ -20933,17 +20933,17 @@ function usePageState({
|
|
|
20933
20933
|
totalPages,
|
|
20934
20934
|
initialPage = 1
|
|
20935
20935
|
}) {
|
|
20936
|
-
const [currentPage, setCurrentPage] = (0,
|
|
20936
|
+
const [currentPage, setCurrentPage] = (0, import_react10.useState)(
|
|
20937
20937
|
Math.max(1, Math.min(initialPage, totalPages))
|
|
20938
20938
|
);
|
|
20939
|
-
const goToPage = (0,
|
|
20939
|
+
const goToPage = (0, import_react10.useCallback)((page) => {
|
|
20940
20940
|
const validPage = Math.max(1, Math.min(page, totalPages));
|
|
20941
20941
|
setCurrentPage(validPage);
|
|
20942
20942
|
}, [totalPages]);
|
|
20943
|
-
const nextPage = (0,
|
|
20943
|
+
const nextPage = (0, import_react10.useCallback)(() => {
|
|
20944
20944
|
goToPage(currentPage + 1);
|
|
20945
20945
|
}, [currentPage, goToPage]);
|
|
20946
|
-
const prevPage = (0,
|
|
20946
|
+
const prevPage = (0, import_react10.useCallback)(() => {
|
|
20947
20947
|
goToPage(currentPage - 1);
|
|
20948
20948
|
}, [currentPage, goToPage]);
|
|
20949
20949
|
return {
|
|
@@ -20956,10 +20956,10 @@ function usePageState({
|
|
|
20956
20956
|
};
|
|
20957
20957
|
}
|
|
20958
20958
|
function usePageRenderer(pdfDoc) {
|
|
20959
|
-
const cacheRef = (0,
|
|
20960
|
-
const [rendering, setRendering] = (0,
|
|
20961
|
-
const [pageInfo, setPageInfo] = (0,
|
|
20962
|
-
const renderPage = (0,
|
|
20959
|
+
const cacheRef = (0, import_react11.useRef)(/* @__PURE__ */ new Map());
|
|
20960
|
+
const [rendering, setRendering] = (0, import_react11.useState)(false);
|
|
20961
|
+
const [pageInfo, setPageInfo] = (0, import_react11.useState)(null);
|
|
20962
|
+
const renderPage = (0, import_react11.useCallback)(
|
|
20963
20963
|
async (pageNumber, scale = DEFAULT_SCALE, rotation = 0) => {
|
|
20964
20964
|
if (!pdfDoc) return null;
|
|
20965
20965
|
try {
|
|
@@ -21018,21 +21018,21 @@ function usePageRenderer(pdfDoc) {
|
|
|
21018
21018
|
return { renderPage, rendering, pageInfo };
|
|
21019
21019
|
}
|
|
21020
21020
|
function useZoom(initialZoom = 1.5) {
|
|
21021
|
-
const [zoomLevel, setZoomLevel] = (0,
|
|
21021
|
+
const [zoomLevel, setZoomLevel] = (0, import_react12.useState)(
|
|
21022
21022
|
typeof initialZoom === "number" ? initialZoom : 1.5
|
|
21023
21023
|
);
|
|
21024
|
-
const [zoomMode, setZoomMode] = (0,
|
|
21024
|
+
const [zoomMode, setZoomMode] = (0, import_react12.useState)(
|
|
21025
21025
|
typeof initialZoom === "string" ? initialZoom : "custom"
|
|
21026
21026
|
);
|
|
21027
|
-
const zoomIn = (0,
|
|
21027
|
+
const zoomIn = (0, import_react12.useCallback)(() => {
|
|
21028
21028
|
setZoomLevel((prev) => Math.min(MAX_ZOOM, prev + ZOOM_STEP));
|
|
21029
21029
|
setZoomMode("custom");
|
|
21030
21030
|
}, []);
|
|
21031
|
-
const zoomOut = (0,
|
|
21031
|
+
const zoomOut = (0, import_react12.useCallback)(() => {
|
|
21032
21032
|
setZoomLevel((prev) => Math.max(MIN_ZOOM, prev - ZOOM_STEP));
|
|
21033
21033
|
setZoomMode("custom");
|
|
21034
21034
|
}, []);
|
|
21035
|
-
const setZoom = (0,
|
|
21035
|
+
const setZoom = (0, import_react12.useCallback)((level) => {
|
|
21036
21036
|
if (typeof level === "number") {
|
|
21037
21037
|
setZoomLevel(Math.max(MIN_ZOOM, Math.min(MAX_ZOOM, level)));
|
|
21038
21038
|
setZoomMode("custom");
|
|
@@ -21051,11 +21051,11 @@ function useZoom(initialZoom = 1.5) {
|
|
|
21051
21051
|
};
|
|
21052
21052
|
}
|
|
21053
21053
|
function useSearch(pdfDoc) {
|
|
21054
|
-
const [query, setQuery] = (0,
|
|
21055
|
-
const [results, setResults] = (0,
|
|
21056
|
-
const [searching, setSearching] = (0,
|
|
21057
|
-
const [currentResultIndex, setCurrentResultIndex] = (0,
|
|
21058
|
-
const search = (0,
|
|
21054
|
+
const [query, setQuery] = (0, import_react13.useState)("");
|
|
21055
|
+
const [results, setResults] = (0, import_react13.useState)([]);
|
|
21056
|
+
const [searching, setSearching] = (0, import_react13.useState)(false);
|
|
21057
|
+
const [currentResultIndex, setCurrentResultIndex] = (0, import_react13.useState)(0);
|
|
21058
|
+
const search = (0, import_react13.useCallback)(
|
|
21059
21059
|
async (searchText) => {
|
|
21060
21060
|
if (!pdfDoc || !searchText.trim()) {
|
|
21061
21061
|
setResults([]);
|
|
@@ -21092,10 +21092,10 @@ function useSearch(pdfDoc) {
|
|
|
21092
21092
|
},
|
|
21093
21093
|
[pdfDoc]
|
|
21094
21094
|
);
|
|
21095
|
-
const nextResult = (0,
|
|
21095
|
+
const nextResult = (0, import_react13.useCallback)(() => {
|
|
21096
21096
|
setCurrentResultIndex((prev) => (prev + 1) % results.length);
|
|
21097
21097
|
}, [results.length]);
|
|
21098
|
-
const prevResult = (0,
|
|
21098
|
+
const prevResult = (0, import_react13.useCallback)(() => {
|
|
21099
21099
|
setCurrentResultIndex((prev) => (prev - 1 + results.length) % results.length);
|
|
21100
21100
|
}, [results.length]);
|
|
21101
21101
|
return {
|
|
@@ -21114,9 +21114,9 @@ function PDFCanvas({
|
|
|
21114
21114
|
scale,
|
|
21115
21115
|
onRender
|
|
21116
21116
|
}) {
|
|
21117
|
-
const containerRef = (0,
|
|
21118
|
-
const [canvas, setCanvas] = (0,
|
|
21119
|
-
(0,
|
|
21117
|
+
const containerRef = (0, import_react14.useRef)(null);
|
|
21118
|
+
const [canvas, setCanvas] = (0, import_react14.useState)(null);
|
|
21119
|
+
(0, import_react14.useEffect)(() => {
|
|
21120
21120
|
const render = async () => {
|
|
21121
21121
|
const renderedCanvas = await onRender(pageNumber, scale, 0);
|
|
21122
21122
|
if (renderedCanvas && containerRef.current) {
|
|
@@ -21131,7 +21131,7 @@ function PDFCanvas({
|
|
|
21131
21131
|
render();
|
|
21132
21132
|
}
|
|
21133
21133
|
}, [pdfDoc, pageNumber, scale, onRender]);
|
|
21134
|
-
return /* @__PURE__ */ (0,
|
|
21134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ref: containerRef, className: PDFViewer_default.canvas });
|
|
21135
21135
|
}
|
|
21136
21136
|
function PDFControls({
|
|
21137
21137
|
pageState,
|
|
@@ -21144,8 +21144,8 @@ function PDFControls({
|
|
|
21144
21144
|
url
|
|
21145
21145
|
}) {
|
|
21146
21146
|
if (!pdfDocument) return null;
|
|
21147
|
-
return /* @__PURE__ */ (0,
|
|
21148
|
-
/* @__PURE__ */ (0,
|
|
21147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: PDFViewer_default.controls, children: [
|
|
21148
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
21149
21149
|
"button",
|
|
21150
21150
|
{
|
|
21151
21151
|
onClick: pageState.prevPage,
|
|
@@ -21154,7 +21154,7 @@ function PDFControls({
|
|
|
21154
21154
|
children: "<"
|
|
21155
21155
|
}
|
|
21156
21156
|
),
|
|
21157
|
-
/* @__PURE__ */ (0,
|
|
21157
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
21158
21158
|
"input",
|
|
21159
21159
|
{
|
|
21160
21160
|
type: "number",
|
|
@@ -21165,11 +21165,11 @@ function PDFControls({
|
|
|
21165
21165
|
className: PDFViewer_default.pageInput
|
|
21166
21166
|
}
|
|
21167
21167
|
),
|
|
21168
|
-
/* @__PURE__ */ (0,
|
|
21168
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: PDFViewer_default.pageTotal, children: [
|
|
21169
21169
|
"of ",
|
|
21170
21170
|
pdfDocument.numPages
|
|
21171
21171
|
] }),
|
|
21172
|
-
/* @__PURE__ */ (0,
|
|
21172
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
21173
21173
|
"button",
|
|
21174
21174
|
{
|
|
21175
21175
|
onClick: pageState.nextPage,
|
|
@@ -21178,7 +21178,7 @@ function PDFControls({
|
|
|
21178
21178
|
children: ">"
|
|
21179
21179
|
}
|
|
21180
21180
|
),
|
|
21181
|
-
/* @__PURE__ */ (0,
|
|
21181
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
21182
21182
|
"button",
|
|
21183
21183
|
{
|
|
21184
21184
|
onClick: zoom.zoomOut,
|
|
@@ -21187,11 +21187,11 @@ function PDFControls({
|
|
|
21187
21187
|
children: "-"
|
|
21188
21188
|
}
|
|
21189
21189
|
),
|
|
21190
|
-
/* @__PURE__ */ (0,
|
|
21190
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: PDFViewer_default.zoomLevel, children: [
|
|
21191
21191
|
Math.round(zoom.zoomLevel * 100),
|
|
21192
21192
|
"%"
|
|
21193
21193
|
] }),
|
|
21194
|
-
/* @__PURE__ */ (0,
|
|
21194
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
21195
21195
|
"button",
|
|
21196
21196
|
{
|
|
21197
21197
|
onClick: zoom.zoomIn,
|
|
@@ -21200,7 +21200,7 @@ function PDFControls({
|
|
|
21200
21200
|
children: "+"
|
|
21201
21201
|
}
|
|
21202
21202
|
),
|
|
21203
|
-
/* @__PURE__ */ (0,
|
|
21203
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
21204
21204
|
"input",
|
|
21205
21205
|
{
|
|
21206
21206
|
type: "text",
|
|
@@ -21210,13 +21210,13 @@ function PDFControls({
|
|
|
21210
21210
|
className: PDFViewer_default.searchInput
|
|
21211
21211
|
}
|
|
21212
21212
|
),
|
|
21213
|
-
search.results.length > 0 && /* @__PURE__ */ (0,
|
|
21213
|
+
search.results.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: PDFViewer_default.searchResults, children: [
|
|
21214
21214
|
search.results.length,
|
|
21215
21215
|
" results"
|
|
21216
21216
|
] }),
|
|
21217
|
-
enableDownload && /* @__PURE__ */ (0,
|
|
21218
|
-
enablePrint && /* @__PURE__ */ (0,
|
|
21219
|
-
enableFullscreen && typeof document !== "undefined" && /* @__PURE__ */ (0,
|
|
21217
|
+
enableDownload && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: url, download: true, className: PDFViewer_default.button, title: "Download", children: "Download" }),
|
|
21218
|
+
enablePrint && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { onClick: () => window.print(), title: "Print", children: "Print" }),
|
|
21219
|
+
enableFullscreen && typeof document !== "undefined" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
21220
21220
|
"button",
|
|
21221
21221
|
{
|
|
21222
21222
|
onClick: () => {
|
|
@@ -21238,8 +21238,8 @@ function PDFThumbnails({
|
|
|
21238
21238
|
onSelectPage,
|
|
21239
21239
|
numPages
|
|
21240
21240
|
}) {
|
|
21241
|
-
const [thumbnails, setThumbnails] = (0,
|
|
21242
|
-
(0,
|
|
21241
|
+
const [thumbnails, setThumbnails] = (0, import_react15.useState)([]);
|
|
21242
|
+
(0, import_react15.useEffect)(() => {
|
|
21243
21243
|
const generateThumbnails = async () => {
|
|
21244
21244
|
if (!pdfDoc) return;
|
|
21245
21245
|
const thumbs = [];
|
|
@@ -21268,13 +21268,13 @@ function PDFThumbnails({
|
|
|
21268
21268
|
};
|
|
21269
21269
|
generateThumbnails();
|
|
21270
21270
|
}, [pdfDoc, numPages]);
|
|
21271
|
-
return /* @__PURE__ */ (0,
|
|
21271
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: PDFViewer_default.thumbnails, children: thumbnails.map((thumb, idx) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
21272
21272
|
"div",
|
|
21273
21273
|
{
|
|
21274
21274
|
className: `${PDFViewer_default.thumbnail} ${idx + 1 === currentPage ? PDFViewer_default.active : ""}`,
|
|
21275
21275
|
onClick: () => onSelectPage(idx + 1),
|
|
21276
21276
|
children: [
|
|
21277
|
-
/* @__PURE__ */ (0,
|
|
21277
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
21278
21278
|
"canvas",
|
|
21279
21279
|
{
|
|
21280
21280
|
width: thumb.width,
|
|
@@ -21289,7 +21289,7 @@ function PDFThumbnails({
|
|
|
21289
21289
|
}
|
|
21290
21290
|
}
|
|
21291
21291
|
),
|
|
21292
|
-
/* @__PURE__ */ (0,
|
|
21292
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: PDFViewer_default.pageNumber, children: idx + 1 })
|
|
21293
21293
|
]
|
|
21294
21294
|
},
|
|
21295
21295
|
idx
|
|
@@ -21326,35 +21326,35 @@ function PDFViewer({
|
|
|
21326
21326
|
const { renderPage, pageInfo } = usePageRenderer(pdfDoc);
|
|
21327
21327
|
const zoom = useZoom(initialZoom);
|
|
21328
21328
|
const search = useSearch(pdfDoc);
|
|
21329
|
-
(0,
|
|
21329
|
+
(0, import_react8.useEffect)(() => {
|
|
21330
21330
|
if (document2) {
|
|
21331
21331
|
onDocumentLoad?.(document2);
|
|
21332
21332
|
}
|
|
21333
21333
|
}, [document2, onDocumentLoad]);
|
|
21334
|
-
(0,
|
|
21334
|
+
(0, import_react8.useEffect)(() => {
|
|
21335
21335
|
onPageChange?.(pageState.currentPage);
|
|
21336
21336
|
}, [pageState.currentPage, onPageChange]);
|
|
21337
|
-
(0,
|
|
21337
|
+
(0, import_react8.useEffect)(() => {
|
|
21338
21338
|
if (search.results.length > 0) {
|
|
21339
21339
|
onSearchResults?.(search.results);
|
|
21340
21340
|
}
|
|
21341
21341
|
}, [search.results, onSearchResults]);
|
|
21342
21342
|
if (error) {
|
|
21343
|
-
return /* @__PURE__ */ (0,
|
|
21343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: PDFViewer_default.error, style: { height, width }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("p", { children: [
|
|
21344
21344
|
"Failed to load PDF: ",
|
|
21345
21345
|
error.message
|
|
21346
21346
|
] }) });
|
|
21347
21347
|
}
|
|
21348
21348
|
if (loading) {
|
|
21349
|
-
return /* @__PURE__ */ (0,
|
|
21349
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: PDFViewer_default.loading, style: { height, width }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { children: "Loading PDF..." }) });
|
|
21350
21350
|
}
|
|
21351
|
-
return /* @__PURE__ */ (0,
|
|
21351
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
21352
21352
|
"div",
|
|
21353
21353
|
{
|
|
21354
21354
|
className: `${PDFViewer_default.viewer} ${className || ""}`,
|
|
21355
21355
|
style: { height, width, ...style },
|
|
21356
21356
|
children: [
|
|
21357
|
-
showControls && /* @__PURE__ */ (0,
|
|
21357
|
+
showControls && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
21358
21358
|
PDFControls,
|
|
21359
21359
|
{
|
|
21360
21360
|
pageState,
|
|
@@ -21367,8 +21367,8 @@ function PDFViewer({
|
|
|
21367
21367
|
url
|
|
21368
21368
|
}
|
|
21369
21369
|
),
|
|
21370
|
-
/* @__PURE__ */ (0,
|
|
21371
|
-
showThumbnails && document2 && /* @__PURE__ */ (0,
|
|
21370
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: PDFViewer_default.content, children: [
|
|
21371
|
+
showThumbnails && document2 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
21372
21372
|
PDFThumbnails,
|
|
21373
21373
|
{
|
|
21374
21374
|
pdfDoc,
|
|
@@ -21377,7 +21377,7 @@ function PDFViewer({
|
|
|
21377
21377
|
numPages: document2.numPages
|
|
21378
21378
|
}
|
|
21379
21379
|
),
|
|
21380
|
-
/* @__PURE__ */ (0,
|
|
21380
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
21381
21381
|
PDFCanvas,
|
|
21382
21382
|
{
|
|
21383
21383
|
pdfDoc,
|
|
@@ -21455,22 +21455,22 @@ function createProgressiveFetchHandler(onProgress) {
|
|
|
21455
21455
|
return response.arrayBuffer();
|
|
21456
21456
|
};
|
|
21457
21457
|
}
|
|
21458
|
-
var
|
|
21458
|
+
var import_react8, import_react9, pdfjsLib, import_react10, import_react11, import_react12, import_react13, import_react14, import_jsx_runtime5, import_jsx_runtime6, import_react15, import_jsx_runtime7, import_jsx_runtime8, DEFAULT_SCALE, CACHE_SIZE, MIN_ZOOM, MAX_ZOOM, ZOOM_STEP, PDFViewer_default, linearizedPDFConfig;
|
|
21459
21459
|
var init_dist = __esm({
|
|
21460
21460
|
"node_modules/.pnpm/@page-speed+pdf-viewer@0.0.2_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@page-speed/pdf-viewer/dist/index.js"() {
|
|
21461
|
-
import_react4 = __toESM(require_react());
|
|
21462
|
-
import_react5 = __toESM(require_react());
|
|
21463
|
-
pdfjsLib = __toESM(require_pdf());
|
|
21464
|
-
import_react6 = __toESM(require_react());
|
|
21465
|
-
import_react7 = __toESM(require_react());
|
|
21466
21461
|
import_react8 = __toESM(require_react());
|
|
21467
21462
|
import_react9 = __toESM(require_react());
|
|
21463
|
+
pdfjsLib = __toESM(require_pdf());
|
|
21468
21464
|
import_react10 = __toESM(require_react());
|
|
21469
|
-
import_jsx_runtime4 = __toESM(require_jsx_runtime());
|
|
21470
|
-
import_jsx_runtime5 = __toESM(require_jsx_runtime());
|
|
21471
21465
|
import_react11 = __toESM(require_react());
|
|
21466
|
+
import_react12 = __toESM(require_react());
|
|
21467
|
+
import_react13 = __toESM(require_react());
|
|
21468
|
+
import_react14 = __toESM(require_react());
|
|
21469
|
+
import_jsx_runtime5 = __toESM(require_jsx_runtime());
|
|
21472
21470
|
import_jsx_runtime6 = __toESM(require_jsx_runtime());
|
|
21471
|
+
import_react15 = __toESM(require_react());
|
|
21473
21472
|
import_jsx_runtime7 = __toESM(require_jsx_runtime());
|
|
21473
|
+
import_jsx_runtime8 = __toESM(require_jsx_runtime());
|
|
21474
21474
|
if (typeof window !== "undefined") {
|
|
21475
21475
|
pdfjsLib.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjsLib.version}/pdf.worker.min.js`;
|
|
21476
21476
|
}
|
|
@@ -21507,7 +21507,7 @@ var init_dist = __esm({
|
|
|
21507
21507
|
});
|
|
21508
21508
|
|
|
21509
21509
|
// src/components/Lightbox.tsx
|
|
21510
|
-
var
|
|
21510
|
+
var import_react17 = __toESM(require_react());
|
|
21511
21511
|
|
|
21512
21512
|
// src/hooks/useGalleryState.ts
|
|
21513
21513
|
var import_react = __toESM(require_react());
|
|
@@ -21629,27 +21629,679 @@ function LightboxOverlay({
|
|
|
21629
21629
|
);
|
|
21630
21630
|
}
|
|
21631
21631
|
|
|
21632
|
+
// node_modules/.pnpm/@page-speed+img@0.4.3_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@page-speed/img/dist/core/Img.js
|
|
21633
|
+
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
|
|
21634
|
+
var import_react7 = __toESM(require_react(), 1);
|
|
21635
|
+
|
|
21636
|
+
// node_modules/.pnpm/@page-speed+hooks@0.4.3_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@page-speed/hooks/dist/chunk-JSF23IF7.js
|
|
21637
|
+
var import_react4 = __toESM(require_react(), 1);
|
|
21638
|
+
var BASE_URL = "https://octane.cdn.ing/api/v1/images/transform?";
|
|
21639
|
+
var DPR_MULTIPLIERS = [1, 2];
|
|
21640
|
+
function useOptimizedImage(options) {
|
|
21641
|
+
const {
|
|
21642
|
+
src,
|
|
21643
|
+
eager = false,
|
|
21644
|
+
threshold = 0.1,
|
|
21645
|
+
rootMargin = "50px",
|
|
21646
|
+
width,
|
|
21647
|
+
height,
|
|
21648
|
+
optixFlowConfig
|
|
21649
|
+
} = options;
|
|
21650
|
+
const optixFlowApiKey = (0, import_react4.useMemo)(() => {
|
|
21651
|
+
return optixFlowConfig?.apiKey;
|
|
21652
|
+
}, [optixFlowConfig?.apiKey]);
|
|
21653
|
+
const useOptixFlow = (0, import_react4.useMemo)(() => {
|
|
21654
|
+
return optixFlowApiKey ? true : false;
|
|
21655
|
+
}, [optixFlowApiKey]);
|
|
21656
|
+
const [state, setState] = (0, import_react4.useState)({
|
|
21657
|
+
isLoaded: false,
|
|
21658
|
+
isInView: false
|
|
21659
|
+
});
|
|
21660
|
+
const [size, setSize] = (0, import_react4.useState)({
|
|
21661
|
+
width: width ?? 0,
|
|
21662
|
+
height: height ?? 0
|
|
21663
|
+
});
|
|
21664
|
+
const imgRef = (0, import_react4.useRef)(null);
|
|
21665
|
+
const observerRef = (0, import_react4.useRef)(null);
|
|
21666
|
+
(0, import_react4.useEffect)(() => {
|
|
21667
|
+
if (width !== void 0 || height !== void 0) {
|
|
21668
|
+
setSize((prev) => ({
|
|
21669
|
+
width: width ?? prev.width,
|
|
21670
|
+
height: height ?? prev.height
|
|
21671
|
+
}));
|
|
21672
|
+
}
|
|
21673
|
+
}, [width, height]);
|
|
21674
|
+
(0, import_react4.useEffect)(() => {
|
|
21675
|
+
if (!imgRef.current) return;
|
|
21676
|
+
const calculateRenderedSize = () => {
|
|
21677
|
+
const img2 = imgRef.current;
|
|
21678
|
+
if (!img2) return;
|
|
21679
|
+
const renderedWidth = width ?? (Math.round(img2.clientWidth) || img2.naturalWidth || 0);
|
|
21680
|
+
const renderedHeight = height ?? (Math.round(img2.clientHeight) || img2.naturalHeight || 0);
|
|
21681
|
+
if (renderedWidth > 0 || renderedHeight > 0) {
|
|
21682
|
+
setSize((prev) => {
|
|
21683
|
+
if (prev.width !== renderedWidth || prev.height !== renderedHeight) {
|
|
21684
|
+
return { width: renderedWidth, height: renderedHeight };
|
|
21685
|
+
}
|
|
21686
|
+
return prev;
|
|
21687
|
+
});
|
|
21688
|
+
}
|
|
21689
|
+
};
|
|
21690
|
+
if (imgRef.current.clientWidth > 0) {
|
|
21691
|
+
calculateRenderedSize();
|
|
21692
|
+
}
|
|
21693
|
+
const img = imgRef.current;
|
|
21694
|
+
img.addEventListener("load", calculateRenderedSize);
|
|
21695
|
+
let resizeObserver = null;
|
|
21696
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
21697
|
+
resizeObserver = new ResizeObserver(() => {
|
|
21698
|
+
calculateRenderedSize();
|
|
21699
|
+
});
|
|
21700
|
+
resizeObserver.observe(img);
|
|
21701
|
+
}
|
|
21702
|
+
return () => {
|
|
21703
|
+
img.removeEventListener("load", calculateRenderedSize);
|
|
21704
|
+
resizeObserver?.disconnect();
|
|
21705
|
+
};
|
|
21706
|
+
}, [width, height, state.isLoaded]);
|
|
21707
|
+
const buildOptixFlowUrl = (0, import_react4.useCallback)(
|
|
21708
|
+
(imgWidth, imgHeight, format) => {
|
|
21709
|
+
if (!useOptixFlow) return src;
|
|
21710
|
+
if (!imgWidth || !imgHeight) return src;
|
|
21711
|
+
const params = new URLSearchParams();
|
|
21712
|
+
params.set("url", src);
|
|
21713
|
+
params.set("w", String(imgWidth));
|
|
21714
|
+
params.set("h", String(imgHeight));
|
|
21715
|
+
params.set("q", String(optixFlowConfig?.compressionLevel ?? 75));
|
|
21716
|
+
params.set("f", format);
|
|
21717
|
+
params.set("apiKey", optixFlowApiKey);
|
|
21718
|
+
return `${BASE_URL}${params.toString()}`;
|
|
21719
|
+
},
|
|
21720
|
+
[useOptixFlow, src, optixFlowConfig?.compressionLevel, optixFlowApiKey]
|
|
21721
|
+
);
|
|
21722
|
+
const generateSrcset = (0, import_react4.useCallback)(
|
|
21723
|
+
(baseWidth, baseHeight, format) => {
|
|
21724
|
+
if (!useOptixFlow || baseWidth === 0 || baseHeight === 0) return "";
|
|
21725
|
+
return DPR_MULTIPLIERS.map((dpr) => {
|
|
21726
|
+
const scaledWidth = Math.round(baseWidth * dpr);
|
|
21727
|
+
const scaledHeight = Math.round(baseHeight * dpr);
|
|
21728
|
+
const url = buildOptixFlowUrl(scaledWidth, scaledHeight, format);
|
|
21729
|
+
return `${url} ${dpr}x`;
|
|
21730
|
+
}).join(", ");
|
|
21731
|
+
},
|
|
21732
|
+
[useOptixFlow, buildOptixFlowUrl]
|
|
21733
|
+
);
|
|
21734
|
+
const primarySrc = (0, import_react4.useMemo)(() => {
|
|
21735
|
+
const hasDimensions = size.width > 0 && size.height > 0;
|
|
21736
|
+
if (!useOptixFlow || !hasDimensions) return src;
|
|
21737
|
+
const fallbackFormat = optixFlowConfig?.renderedFileType ?? "jpeg";
|
|
21738
|
+
return buildOptixFlowUrl(size.width, size.height, fallbackFormat);
|
|
21739
|
+
}, [useOptixFlow, src, size.width, size.height, optixFlowConfig?.renderedFileType, buildOptixFlowUrl]);
|
|
21740
|
+
const srcset = (0, import_react4.useMemo)(() => {
|
|
21741
|
+
return {
|
|
21742
|
+
avif: generateSrcset(size.width, size.height, "avif"),
|
|
21743
|
+
webp: generateSrcset(size.width, size.height, "webp"),
|
|
21744
|
+
jpeg: generateSrcset(size.width, size.height, "jpeg")
|
|
21745
|
+
};
|
|
21746
|
+
}, [size.width, size.height, generateSrcset]);
|
|
21747
|
+
const sizes = (0, import_react4.useMemo)(() => {
|
|
21748
|
+
if (size.width === 0) return "";
|
|
21749
|
+
return `${size.width}px`;
|
|
21750
|
+
}, [size.width]);
|
|
21751
|
+
(0, import_react4.useEffect)(() => {
|
|
21752
|
+
if (typeof window === "undefined" || !imgRef.current) {
|
|
21753
|
+
return;
|
|
21754
|
+
}
|
|
21755
|
+
if (eager) {
|
|
21756
|
+
setState({ isLoaded: false, isInView: true });
|
|
21757
|
+
return;
|
|
21758
|
+
}
|
|
21759
|
+
observerRef.current = new IntersectionObserver(
|
|
21760
|
+
([entry]) => {
|
|
21761
|
+
if (entry.isIntersecting) {
|
|
21762
|
+
setState((prev) => ({ ...prev, isInView: true }));
|
|
21763
|
+
observerRef.current?.disconnect();
|
|
21764
|
+
}
|
|
21765
|
+
},
|
|
21766
|
+
{ threshold, rootMargin }
|
|
21767
|
+
);
|
|
21768
|
+
observerRef.current.observe(imgRef.current);
|
|
21769
|
+
return () => {
|
|
21770
|
+
observerRef.current?.disconnect();
|
|
21771
|
+
};
|
|
21772
|
+
}, [eager, threshold, rootMargin]);
|
|
21773
|
+
(0, import_react4.useEffect)(() => {
|
|
21774
|
+
if (!imgRef.current) return;
|
|
21775
|
+
const handleLoad = () => {
|
|
21776
|
+
setState((prev) => ({ ...prev, isLoaded: true }));
|
|
21777
|
+
};
|
|
21778
|
+
const img = imgRef.current;
|
|
21779
|
+
if (img.complete) {
|
|
21780
|
+
handleLoad();
|
|
21781
|
+
} else {
|
|
21782
|
+
img.addEventListener("load", handleLoad);
|
|
21783
|
+
return () => img.removeEventListener("load", handleLoad);
|
|
21784
|
+
}
|
|
21785
|
+
}, [state.isInView]);
|
|
21786
|
+
const ref = (0, import_react4.useCallback)((node) => {
|
|
21787
|
+
imgRef.current = node;
|
|
21788
|
+
}, []);
|
|
21789
|
+
const emptySrcset = { avif: "", webp: "", jpeg: "" };
|
|
21790
|
+
return {
|
|
21791
|
+
ref,
|
|
21792
|
+
// Primary src uses exact rendered dimensions for Lighthouse "Properly size images" compliance
|
|
21793
|
+
src: state.isInView || eager ? primarySrc : src,
|
|
21794
|
+
// Srcset with format variants and DPR multipliers for <picture> element
|
|
21795
|
+
srcset: state.isInView || eager ? srcset : emptySrcset,
|
|
21796
|
+
// Sizes attribute for responsive image selection
|
|
21797
|
+
sizes: state.isInView || eager ? sizes : "",
|
|
21798
|
+
isLoaded: state.isLoaded,
|
|
21799
|
+
isInView: state.isInView,
|
|
21800
|
+
loading: eager ? "eager" : "lazy",
|
|
21801
|
+
size
|
|
21802
|
+
};
|
|
21803
|
+
}
|
|
21804
|
+
|
|
21805
|
+
// node_modules/.pnpm/@page-speed+img@0.4.3_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@page-speed/img/dist/utils/cache.js
|
|
21806
|
+
var l2Cache = /* @__PURE__ */ new Map();
|
|
21807
|
+
function cacheGet(key) {
|
|
21808
|
+
return l2Cache.get(key);
|
|
21809
|
+
}
|
|
21810
|
+
function cacheSet(key, value) {
|
|
21811
|
+
l2Cache.set(key, value);
|
|
21812
|
+
}
|
|
21813
|
+
|
|
21814
|
+
// node_modules/.pnpm/@page-speed+img@0.4.3_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@page-speed/img/dist/utils/api.js
|
|
21815
|
+
var DEFAULT_CDN_HOST = "https://cdn.ing";
|
|
21816
|
+
function normalizeHost(cdnHost) {
|
|
21817
|
+
return (cdnHost ?? DEFAULT_CDN_HOST).replace(/\/$/, "");
|
|
21818
|
+
}
|
|
21819
|
+
function buildPrimaryImageUrl(mediaId, cdnHost) {
|
|
21820
|
+
const host = normalizeHost(cdnHost);
|
|
21821
|
+
return `${host}/assets/images/${mediaId}`;
|
|
21822
|
+
}
|
|
21823
|
+
function buildLegacyImageUrl(mediaId, cdnHost) {
|
|
21824
|
+
const host = normalizeHost(cdnHost);
|
|
21825
|
+
return `${host}/i/r/${mediaId}`;
|
|
21826
|
+
}
|
|
21827
|
+
function buildPlaceholderImageUrl(mediaId, cdnHost) {
|
|
21828
|
+
const host = normalizeHost(cdnHost);
|
|
21829
|
+
return `${host}/assets/low_res_thumb/${mediaId}`;
|
|
21830
|
+
}
|
|
21831
|
+
function hasRenderableUrlVariant(variant) {
|
|
21832
|
+
if (!variant)
|
|
21833
|
+
return false;
|
|
21834
|
+
const candidates = [variant.sm, variant.md, variant.lg, variant.full];
|
|
21835
|
+
return candidates.some((value) => typeof value === "string" && value.trim().length > 0);
|
|
21836
|
+
}
|
|
21837
|
+
function imageVariantsHaveRenderableSource(variants) {
|
|
21838
|
+
if (!variants)
|
|
21839
|
+
return false;
|
|
21840
|
+
return ["AVIF", "WEBP", "JPEG"].some((format) => {
|
|
21841
|
+
const entry = variants?.[format];
|
|
21842
|
+
return hasRenderableUrlVariant(entry);
|
|
21843
|
+
});
|
|
21844
|
+
}
|
|
21845
|
+
function hasUrlValue(value) {
|
|
21846
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
21847
|
+
}
|
|
21848
|
+
function imageDataHasRenderableSource(data) {
|
|
21849
|
+
if (!data)
|
|
21850
|
+
return false;
|
|
21851
|
+
if (imageVariantsHaveRenderableSource(data.variants_data?.variants ?? null)) {
|
|
21852
|
+
return true;
|
|
21853
|
+
}
|
|
21854
|
+
const raw = data;
|
|
21855
|
+
const directFields = [
|
|
21856
|
+
raw.img_url,
|
|
21857
|
+
raw.file_data_url,
|
|
21858
|
+
raw.file_data_thumbnail_url,
|
|
21859
|
+
raw.img_src,
|
|
21860
|
+
raw.med_src,
|
|
21861
|
+
raw.thumb_src,
|
|
21862
|
+
raw.low_res_thumb
|
|
21863
|
+
];
|
|
21864
|
+
return directFields.some(hasUrlValue);
|
|
21865
|
+
}
|
|
21866
|
+
async function fetchFrom(url, signal) {
|
|
21867
|
+
const res = await fetch(url, { signal });
|
|
21868
|
+
if (!res.ok) {
|
|
21869
|
+
const error = new Error(`Failed to fetch image data (status ${res.status}) from ${url}`);
|
|
21870
|
+
error.status = res.status;
|
|
21871
|
+
throw error;
|
|
21872
|
+
}
|
|
21873
|
+
return await res.json();
|
|
21874
|
+
}
|
|
21875
|
+
async function fetchImageData(mediaId, options = {}) {
|
|
21876
|
+
if (!Number.isFinite(mediaId)) {
|
|
21877
|
+
throw new Error("Invalid mediaId provided to fetchImageData");
|
|
21878
|
+
}
|
|
21879
|
+
const host = normalizeHost(options.cdnHost);
|
|
21880
|
+
const cacheKey = `image:${host}:${mediaId}`;
|
|
21881
|
+
if (!options.bypassCache) {
|
|
21882
|
+
const cached = cacheGet(cacheKey);
|
|
21883
|
+
if (cached)
|
|
21884
|
+
return cached;
|
|
21885
|
+
}
|
|
21886
|
+
const urls = [buildPrimaryImageUrl(mediaId, host), buildLegacyImageUrl(mediaId, host)];
|
|
21887
|
+
let lastError;
|
|
21888
|
+
for (const url of urls) {
|
|
21889
|
+
try {
|
|
21890
|
+
const data = await fetchFrom(url, options.signal);
|
|
21891
|
+
if (imageDataHasRenderableSource(data)) {
|
|
21892
|
+
cacheSet(cacheKey, data);
|
|
21893
|
+
}
|
|
21894
|
+
return data;
|
|
21895
|
+
} catch (err) {
|
|
21896
|
+
if (err?.name === "AbortError") {
|
|
21897
|
+
throw err;
|
|
21898
|
+
}
|
|
21899
|
+
lastError = err;
|
|
21900
|
+
}
|
|
21901
|
+
}
|
|
21902
|
+
if (lastError instanceof Error) {
|
|
21903
|
+
throw lastError;
|
|
21904
|
+
}
|
|
21905
|
+
throw new Error(`Failed to fetch image data for mediaId ${mediaId}`);
|
|
21906
|
+
}
|
|
21907
|
+
|
|
21908
|
+
// node_modules/.pnpm/@page-speed+img@0.4.3_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@page-speed/img/dist/core/useMediaSelectionEffect.js
|
|
21909
|
+
var import_react5 = __toESM(require_react(), 1);
|
|
21910
|
+
var MEDIA_SELECTED_EVENT = "dt:media-selected";
|
|
21911
|
+
function useMediaSelectionEffect() {
|
|
21912
|
+
(0, import_react5.useEffect)(() => {
|
|
21913
|
+
if (typeof window === "undefined")
|
|
21914
|
+
return;
|
|
21915
|
+
const handler = () => {
|
|
21916
|
+
};
|
|
21917
|
+
window.addEventListener(MEDIA_SELECTED_EVENT, handler);
|
|
21918
|
+
return () => window.removeEventListener(MEDIA_SELECTED_EVENT, handler);
|
|
21919
|
+
}, []);
|
|
21920
|
+
}
|
|
21921
|
+
|
|
21922
|
+
// node_modules/.pnpm/@page-speed+img@0.4.3_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@page-speed/img/dist/core/useResponsiveReset.js
|
|
21923
|
+
var import_react6 = __toESM(require_react(), 1);
|
|
21924
|
+
function resetResponsivePictureState(element) {
|
|
21925
|
+
if (!element)
|
|
21926
|
+
return;
|
|
21927
|
+
element.querySelectorAll("source").forEach((source) => {
|
|
21928
|
+
const srcset = source.getAttribute("srcset");
|
|
21929
|
+
if (srcset) {
|
|
21930
|
+
source.setAttribute("data-srcset", srcset);
|
|
21931
|
+
source.removeAttribute("srcset");
|
|
21932
|
+
requestAnimationFrame(() => {
|
|
21933
|
+
source.setAttribute("srcset", srcset);
|
|
21934
|
+
});
|
|
21935
|
+
}
|
|
21936
|
+
});
|
|
21937
|
+
}
|
|
21938
|
+
function useResponsiveReset(ref) {
|
|
21939
|
+
(0, import_react6.useEffect)(() => {
|
|
21940
|
+
const element = ref.current;
|
|
21941
|
+
if (!element)
|
|
21942
|
+
return;
|
|
21943
|
+
if (element instanceof HTMLPictureElement) {
|
|
21944
|
+
resetResponsivePictureState(element);
|
|
21945
|
+
} else if (element.parentElement instanceof HTMLPictureElement) {
|
|
21946
|
+
resetResponsivePictureState(element.parentElement);
|
|
21947
|
+
}
|
|
21948
|
+
}, [ref]);
|
|
21949
|
+
}
|
|
21950
|
+
|
|
21951
|
+
// node_modules/.pnpm/@page-speed+img@0.4.3_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@page-speed/img/dist/core/Img.js
|
|
21952
|
+
var DEFAULT_WIDTHS = {
|
|
21953
|
+
sm: 640,
|
|
21954
|
+
md: 1024,
|
|
21955
|
+
lg: 1536,
|
|
21956
|
+
full: 2560
|
|
21957
|
+
};
|
|
21958
|
+
var MAX_VARIANT_REFRESH_ATTEMPTS = 5;
|
|
21959
|
+
var VARIANT_REFRESH_DELAY_MS = 3e3;
|
|
21960
|
+
var TRANSPARENT_PIXEL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
|
|
21961
|
+
var defaultOptixFlowConfig;
|
|
21962
|
+
var deprecatedMediaWarnings = /* @__PURE__ */ new Set();
|
|
21963
|
+
var readGlobalOptixFlowConfig = () => {
|
|
21964
|
+
if (typeof globalThis === "undefined")
|
|
21965
|
+
return void 0;
|
|
21966
|
+
const globalAny = globalThis;
|
|
21967
|
+
return globalAny.PageSpeedImgDefaults?.optixFlowConfig || globalAny.OpensiteImgDefaults?.optixFlowConfig || globalAny.PAGE_SPEED_IMG_DEFAULTS?.optixFlowConfig;
|
|
21968
|
+
};
|
|
21969
|
+
var resolveOptixFlowConfig = (config) => {
|
|
21970
|
+
return config ?? defaultOptixFlowConfig ?? readGlobalOptixFlowConfig();
|
|
21971
|
+
};
|
|
21972
|
+
var warnDeprecatedMediaId = (mediaId) => {
|
|
21973
|
+
if (!Number.isFinite(mediaId) || mediaId == null)
|
|
21974
|
+
return;
|
|
21975
|
+
const id = mediaId;
|
|
21976
|
+
if (deprecatedMediaWarnings.has(id))
|
|
21977
|
+
return;
|
|
21978
|
+
deprecatedMediaWarnings.add(id);
|
|
21979
|
+
if (typeof console !== "undefined" && console.warn) {
|
|
21980
|
+
console.warn("[DEPRECATED] <Img mediaId> is deprecated. Provide src + optixFlowConfig instead.", { mediaId: id });
|
|
21981
|
+
}
|
|
21982
|
+
};
|
|
21983
|
+
var isUrlString = (value) => typeof value === "string" && value.trim().length > 0;
|
|
21984
|
+
var parseDimension = (value) => {
|
|
21985
|
+
if (value === "" || value === null || typeof value === "undefined")
|
|
21986
|
+
return void 0;
|
|
21987
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
21988
|
+
return value;
|
|
21989
|
+
if (typeof value === "string") {
|
|
21990
|
+
const numeric = Number(value);
|
|
21991
|
+
if (Number.isFinite(numeric))
|
|
21992
|
+
return numeric;
|
|
21993
|
+
}
|
|
21994
|
+
return void 0;
|
|
21995
|
+
};
|
|
21996
|
+
var composeRefs = (hookRef, forwardedRef, localRef) => (0, import_react7.useCallback)((node) => {
|
|
21997
|
+
hookRef(node);
|
|
21998
|
+
localRef.current = node;
|
|
21999
|
+
if (typeof forwardedRef === "function") {
|
|
22000
|
+
forwardedRef(node);
|
|
22001
|
+
} else if (forwardedRef && typeof forwardedRef === "object") {
|
|
22002
|
+
forwardedRef.current = node;
|
|
22003
|
+
}
|
|
22004
|
+
}, [hookRef, forwardedRef, localRef]);
|
|
22005
|
+
function widthMapFromMetadata(v) {
|
|
22006
|
+
const w = v?.widths;
|
|
22007
|
+
if (!w)
|
|
22008
|
+
return null;
|
|
22009
|
+
return {
|
|
22010
|
+
sm: w.small ?? w.sm ?? DEFAULT_WIDTHS.sm,
|
|
22011
|
+
md: w.medium ?? w.md ?? DEFAULT_WIDTHS.md,
|
|
22012
|
+
lg: w.large ?? w.lg ?? DEFAULT_WIDTHS.lg,
|
|
22013
|
+
full: w.full_size ?? w.full ?? DEFAULT_WIDTHS.full
|
|
22014
|
+
};
|
|
22015
|
+
}
|
|
22016
|
+
function pickBest(sizes) {
|
|
22017
|
+
if (!sizes)
|
|
22018
|
+
return void 0;
|
|
22019
|
+
return sizes.md || sizes.lg || sizes.sm || sizes.full || Object.values(sizes).find(Boolean);
|
|
22020
|
+
}
|
|
22021
|
+
var DEFAULT_SIZES = "(max-width:640px) 640px, (max-width:1024px) 1024px, 1536px";
|
|
22022
|
+
var ModernImg = ({ sizes, loading, decoding, alt, title, src: directSrc, eager, intersectionMargin, intersectionThreshold, optixFlowConfig, forwardedRef, ...rest }) => {
|
|
22023
|
+
const imgRef = (0, import_react7.useRef)(null);
|
|
22024
|
+
const pictureRef = (0, import_react7.useRef)(null);
|
|
22025
|
+
useResponsiveReset(pictureRef);
|
|
22026
|
+
useMediaSelectionEffect();
|
|
22027
|
+
const normalizedSrc = (0, import_react7.useMemo)(() => typeof directSrc === "string" ? directSrc.trim() : "", [directSrc]);
|
|
22028
|
+
const numericWidth = (0, import_react7.useMemo)(() => parseDimension(rest.width), [rest]);
|
|
22029
|
+
const numericHeight = (0, import_react7.useMemo)(() => parseDimension(rest.height), [rest]);
|
|
22030
|
+
const resolvedOptixConfig = (0, import_react7.useMemo)(() => resolveOptixFlowConfig(optixFlowConfig), [optixFlowConfig]);
|
|
22031
|
+
const eagerLoad = eager ?? loading === "eager";
|
|
22032
|
+
const { ref: hookRef, src, srcset, sizes: computedSizes, loading: hookLoading, size } = useOptimizedImage({
|
|
22033
|
+
src: normalizedSrc,
|
|
22034
|
+
eager: eagerLoad,
|
|
22035
|
+
width: numericWidth,
|
|
22036
|
+
height: numericHeight,
|
|
22037
|
+
rootMargin: intersectionMargin ?? "200px",
|
|
22038
|
+
threshold: intersectionThreshold ?? 0.1,
|
|
22039
|
+
optixFlowConfig: resolvedOptixConfig
|
|
22040
|
+
});
|
|
22041
|
+
const mergedRef = composeRefs(hookRef, forwardedRef, imgRef);
|
|
22042
|
+
const { width, height, ...restProps } = rest;
|
|
22043
|
+
const sizesAttr = sizes ?? (computedSizes || void 0);
|
|
22044
|
+
const loadingAttr = loading ?? hookLoading ?? "lazy";
|
|
22045
|
+
const decodingAttr = decoding ?? "async";
|
|
22046
|
+
const hasSrcSet = Boolean(srcset.avif || srcset.webp || srcset.jpeg);
|
|
22047
|
+
const imgSrc = src || normalizedSrc || TRANSPARENT_PIXEL;
|
|
22048
|
+
const inlineSrcSet = hasSrcSet && !srcset.avif && !srcset.webp ? srcset.jpeg : "";
|
|
22049
|
+
const parsedWidth = parseDimension(width);
|
|
22050
|
+
const parsedHeight = parseDimension(height);
|
|
22051
|
+
const widthAttr = parsedWidth ?? (size.width || numericWidth || void 0);
|
|
22052
|
+
const heightAttr = parsedHeight ?? (size.height || numericHeight || void 0);
|
|
22053
|
+
if (!hasSrcSet) {
|
|
22054
|
+
return (0, import_jsx_runtime2.jsx)("img", { ref: mergedRef, src: imgSrc, loading: loadingAttr, decoding: decodingAttr, alt, title, width: widthAttr, height: heightAttr, ...restProps });
|
|
22055
|
+
}
|
|
22056
|
+
return (0, import_jsx_runtime2.jsxs)("picture", { ref: pictureRef, children: [srcset.avif ? (0, import_jsx_runtime2.jsx)("source", { type: "image/avif", srcSet: srcset.avif, sizes: sizesAttr }) : null, srcset.webp ? (0, import_jsx_runtime2.jsx)("source", { type: "image/webp", srcSet: srcset.webp, sizes: sizesAttr }) : null, (0, import_jsx_runtime2.jsx)("img", { ref: mergedRef, src: imgSrc, srcSet: inlineSrcSet || void 0, sizes: inlineSrcSet ? sizesAttr : void 0, loading: loadingAttr, decoding: decodingAttr, alt, title, width: widthAttr, height: heightAttr, ...restProps })] });
|
|
22057
|
+
};
|
|
22058
|
+
var LegacyImg = ({ mediaId, cdnHost, sizes, onImageData, loading, decoding, alt, title, src: directSrc, forwardedRef, ...rest }) => {
|
|
22059
|
+
const imgRef = (0, import_react7.useRef)(null);
|
|
22060
|
+
const pictureRef = (0, import_react7.useRef)(null);
|
|
22061
|
+
(0, import_react7.useImperativeHandle)(forwardedRef, () => imgRef.current);
|
|
22062
|
+
useResponsiveReset(pictureRef);
|
|
22063
|
+
useMediaSelectionEffect();
|
|
22064
|
+
const [data, setData] = (0, import_react7.useState)(null);
|
|
22065
|
+
const [retryCount, setRetryCount] = (0, import_react7.useState)(0);
|
|
22066
|
+
const hasMediaId = Number.isFinite(mediaId);
|
|
22067
|
+
const loadingAttr = loading ?? "lazy";
|
|
22068
|
+
const decodingAttr = decoding ?? "async";
|
|
22069
|
+
const [isInView, setIsInView] = (0, import_react7.useState)(() => !hasMediaId || loadingAttr !== "lazy");
|
|
22070
|
+
const cdnOrigin = (0, import_react7.useMemo)(() => (cdnHost ?? DEFAULT_CDN_HOST).replace(/\/$/, ""), [cdnHost]);
|
|
22071
|
+
(0, import_react7.useEffect)(() => {
|
|
22072
|
+
if (!hasMediaId) {
|
|
22073
|
+
setData(null);
|
|
22074
|
+
setRetryCount(0);
|
|
22075
|
+
return;
|
|
22076
|
+
}
|
|
22077
|
+
setData(null);
|
|
22078
|
+
setRetryCount(0);
|
|
22079
|
+
}, [hasMediaId, mediaId, cdnHost]);
|
|
22080
|
+
(0, import_react7.useEffect)(() => {
|
|
22081
|
+
if (!hasMediaId) {
|
|
22082
|
+
return;
|
|
22083
|
+
}
|
|
22084
|
+
const controller = new AbortController();
|
|
22085
|
+
fetchImageData(mediaId, {
|
|
22086
|
+
cdnHost,
|
|
22087
|
+
signal: controller.signal,
|
|
22088
|
+
bypassCache: retryCount > 0
|
|
22089
|
+
}).then((d) => {
|
|
22090
|
+
setData(d);
|
|
22091
|
+
onImageData?.(d);
|
|
22092
|
+
}).catch((err) => {
|
|
22093
|
+
if (err?.name !== "AbortError") {
|
|
22094
|
+
console.warn("Image data fetch failed:", err);
|
|
22095
|
+
}
|
|
22096
|
+
});
|
|
22097
|
+
return () => controller.abort();
|
|
22098
|
+
}, [hasMediaId, mediaId, cdnHost, onImageData, retryCount]);
|
|
22099
|
+
(0, import_react7.useEffect)(() => {
|
|
22100
|
+
if (!hasMediaId || loadingAttr !== "lazy") {
|
|
22101
|
+
setIsInView(true);
|
|
22102
|
+
return;
|
|
22103
|
+
}
|
|
22104
|
+
setIsInView(false);
|
|
22105
|
+
}, [hasMediaId, mediaId, loadingAttr]);
|
|
22106
|
+
(0, import_react7.useEffect)(() => {
|
|
22107
|
+
if (!hasMediaId || loadingAttr !== "lazy" || isInView) {
|
|
22108
|
+
return;
|
|
22109
|
+
}
|
|
22110
|
+
if (typeof window === "undefined" || typeof window.IntersectionObserver === "undefined") {
|
|
22111
|
+
setIsInView(true);
|
|
22112
|
+
return;
|
|
22113
|
+
}
|
|
22114
|
+
const node = imgRef.current;
|
|
22115
|
+
if (!node) {
|
|
22116
|
+
return;
|
|
22117
|
+
}
|
|
22118
|
+
const observer = new IntersectionObserver((entries) => {
|
|
22119
|
+
if (entries.some((entry) => entry.isIntersecting)) {
|
|
22120
|
+
setIsInView(true);
|
|
22121
|
+
observer.disconnect();
|
|
22122
|
+
}
|
|
22123
|
+
}, { rootMargin: "200px" });
|
|
22124
|
+
observer.observe(node);
|
|
22125
|
+
return () => observer.disconnect();
|
|
22126
|
+
}, [hasMediaId, loadingAttr, isInView]);
|
|
22127
|
+
const picture = (0, import_react7.useMemo)(() => {
|
|
22128
|
+
if (!data)
|
|
22129
|
+
return null;
|
|
22130
|
+
const v = data.variants_data?.variants ?? {};
|
|
22131
|
+
const webp2 = v.WEBP;
|
|
22132
|
+
const avif2 = v.AVIF;
|
|
22133
|
+
const jpeg2 = v.JPEG;
|
|
22134
|
+
const widths = widthMapFromMetadata(v.WEBP?.metadata) || widthMapFromMetadata(v.JPEG?.metadata) || { ...DEFAULT_WIDTHS };
|
|
22135
|
+
const ensureAbsolute = (url) => {
|
|
22136
|
+
if (!isUrlString(url))
|
|
22137
|
+
return void 0;
|
|
22138
|
+
if (/^https?:\/\//i.test(url) || url.startsWith("data:"))
|
|
22139
|
+
return url;
|
|
22140
|
+
if (url.startsWith("//"))
|
|
22141
|
+
return `https:${url}`;
|
|
22142
|
+
if (url.startsWith("/"))
|
|
22143
|
+
return `${cdnOrigin}${url}`;
|
|
22144
|
+
return `${cdnOrigin}/${url}`;
|
|
22145
|
+
};
|
|
22146
|
+
const normalizeCandidate = (candidate) => ensureAbsolute(typeof candidate === "string" ? candidate : void 0);
|
|
22147
|
+
const variantCandidates = [
|
|
22148
|
+
pickBest(webp2),
|
|
22149
|
+
pickBest(jpeg2),
|
|
22150
|
+
pickBest(avif2),
|
|
22151
|
+
webp2?.sm,
|
|
22152
|
+
webp2?.md,
|
|
22153
|
+
webp2?.lg,
|
|
22154
|
+
webp2?.full,
|
|
22155
|
+
jpeg2?.sm,
|
|
22156
|
+
jpeg2?.md,
|
|
22157
|
+
jpeg2?.lg,
|
|
22158
|
+
jpeg2?.full,
|
|
22159
|
+
avif2?.sm,
|
|
22160
|
+
avif2?.md,
|
|
22161
|
+
avif2?.lg,
|
|
22162
|
+
avif2?.full
|
|
22163
|
+
].map((candidate) => normalizeCandidate(candidate ?? void 0)).filter(isUrlString);
|
|
22164
|
+
const raw = data;
|
|
22165
|
+
const directCandidates = [
|
|
22166
|
+
raw.img_url,
|
|
22167
|
+
raw.file_data_url,
|
|
22168
|
+
raw.file_data_thumbnail_url,
|
|
22169
|
+
raw.img_src,
|
|
22170
|
+
raw.med_src,
|
|
22171
|
+
raw.thumb_src,
|
|
22172
|
+
raw.low_res_thumb
|
|
22173
|
+
].map((candidate) => isUrlString(candidate) ? normalizeCandidate(candidate) : void 0).filter(isUrlString);
|
|
22174
|
+
const fallbackCandidates = raw.fallback_url ? [normalizeCandidate(raw.fallback_url)].filter(isUrlString) : [];
|
|
22175
|
+
const fallback2 = [...variantCandidates, ...directCandidates, ...fallbackCandidates][0];
|
|
22176
|
+
if (!fallback2) {
|
|
22177
|
+
return null;
|
|
22178
|
+
}
|
|
22179
|
+
const toSrcSet2 = (sizes2) => {
|
|
22180
|
+
if (!sizes2)
|
|
22181
|
+
return void 0;
|
|
22182
|
+
const entries = [];
|
|
22183
|
+
const push = (url, width) => {
|
|
22184
|
+
const absolute = normalizeCandidate(url);
|
|
22185
|
+
if (absolute && width)
|
|
22186
|
+
entries.push(`${absolute} ${width}w`);
|
|
22187
|
+
};
|
|
22188
|
+
push(sizes2.sm, widths.sm);
|
|
22189
|
+
push(sizes2.md, widths.md);
|
|
22190
|
+
push(sizes2.lg, widths.lg);
|
|
22191
|
+
push(sizes2.full, widths.full);
|
|
22192
|
+
return entries.length ? entries.join(", ") : void 0;
|
|
22193
|
+
};
|
|
22194
|
+
return { webp: webp2, avif: avif2, jpeg: jpeg2, toSrcSet: toSrcSet2, fallback: fallback2, widths, hasVariantSource: variantCandidates.length > 0 };
|
|
22195
|
+
}, [data, cdnOrigin]);
|
|
22196
|
+
const hasVariantEntries = (0, import_react7.useMemo)(() => imageVariantsHaveRenderableSource(data?.variants_data?.variants ?? null), [data]);
|
|
22197
|
+
const variantsStatus = (0, import_react7.useMemo)(() => {
|
|
22198
|
+
const status = data?.variants_data?.status ?? data?.variants_status ?? "";
|
|
22199
|
+
return typeof status === "string" ? status.toLowerCase() : "";
|
|
22200
|
+
}, [data]);
|
|
22201
|
+
const variantsFailed = variantsStatus === "failed" || variantsStatus === "error";
|
|
22202
|
+
const shouldPollForVariants = hasMediaId && Boolean(data) && !variantsFailed && !hasVariantEntries && retryCount < MAX_VARIANT_REFRESH_ATTEMPTS;
|
|
22203
|
+
(0, import_react7.useEffect)(() => {
|
|
22204
|
+
if (!shouldPollForVariants) {
|
|
22205
|
+
return;
|
|
22206
|
+
}
|
|
22207
|
+
if (typeof window === "undefined") {
|
|
22208
|
+
return;
|
|
22209
|
+
}
|
|
22210
|
+
const timeoutId = window.setTimeout(() => {
|
|
22211
|
+
setRetryCount((count) => count + 1);
|
|
22212
|
+
}, VARIANT_REFRESH_DELAY_MS);
|
|
22213
|
+
return () => window.clearTimeout(timeoutId);
|
|
22214
|
+
}, [shouldPollForVariants]);
|
|
22215
|
+
const altAttr = (0, import_react7.useMemo)(() => {
|
|
22216
|
+
if (typeof alt === "string")
|
|
22217
|
+
return alt;
|
|
22218
|
+
return data?.meta?.content_manifest?.summary ?? void 0;
|
|
22219
|
+
}, [alt, data]);
|
|
22220
|
+
const titleAttr = (0, import_react7.useMemo)(() => {
|
|
22221
|
+
if (typeof title === "string")
|
|
22222
|
+
return title;
|
|
22223
|
+
return data?.meta?.content_manifest?.title ?? void 0;
|
|
22224
|
+
}, [title, data]);
|
|
22225
|
+
const widthAttr = (0, import_react7.useMemo)(() => data?.meta?.sizing?.width ?? data?.variants_data?.metadata?.width ?? void 0, [data]);
|
|
22226
|
+
const heightAttr = (0, import_react7.useMemo)(() => data?.meta?.sizing?.height ?? data?.variants_data?.metadata?.height ?? void 0, [data]);
|
|
22227
|
+
const dataFilename = (0, import_react7.useMemo)(() => {
|
|
22228
|
+
const base = data?.meta?.content_manifest?.optimized_filename;
|
|
22229
|
+
if (!base)
|
|
22230
|
+
return void 0;
|
|
22231
|
+
const href = picture?.fallback;
|
|
22232
|
+
if (!href)
|
|
22233
|
+
return void 0;
|
|
22234
|
+
const dot = href.lastIndexOf(".");
|
|
22235
|
+
const ext = dot > -1 ? href.slice(dot + 1).toLowerCase() : "jpg";
|
|
22236
|
+
return `${base}.${ext}`;
|
|
22237
|
+
}, [data, picture]);
|
|
22238
|
+
if (!hasMediaId) {
|
|
22239
|
+
const r = { ...rest };
|
|
22240
|
+
return (0, import_jsx_runtime2.jsx)("img", { ref: imgRef, src: directSrc, loading: loadingAttr, decoding: decodingAttr, alt: altAttr, title: titleAttr, width: r.width, height: r.height, ...r });
|
|
22241
|
+
}
|
|
22242
|
+
const placeholderSrc = buildPlaceholderImageUrl(mediaId, cdnHost);
|
|
22243
|
+
if (!data || !picture || !isInView) {
|
|
22244
|
+
const r = { ...rest };
|
|
22245
|
+
return (0, import_jsx_runtime2.jsx)("img", { ref: imgRef, src: placeholderSrc, loading: loadingAttr, decoding: decodingAttr, alt: altAttr, title: titleAttr, width: r.width ?? widthAttr, height: r.height ?? heightAttr, ...r });
|
|
22246
|
+
}
|
|
22247
|
+
const sizesAttr = sizes ?? DEFAULT_SIZES;
|
|
22248
|
+
const { webp, avif, jpeg, toSrcSet, fallback } = picture;
|
|
22249
|
+
const webpSet = toSrcSet(webp);
|
|
22250
|
+
const avifSet = toSrcSet(avif);
|
|
22251
|
+
const jpegSet = toSrcSet(jpeg);
|
|
22252
|
+
if (webpSet || avifSet || jpegSet) {
|
|
22253
|
+
return (0, import_jsx_runtime2.jsxs)("picture", { children: [avifSet ? (0, import_jsx_runtime2.jsx)("source", { type: "image/avif", srcSet: avifSet, sizes: sizesAttr }) : null, webpSet ? (0, import_jsx_runtime2.jsx)("source", { type: "image/webp", srcSet: webpSet, sizes: sizesAttr }) : null, (0, import_jsx_runtime2.jsx)("img", { ref: imgRef, src: fallback, srcSet: jpegSet && !webpSet && !avifSet ? jpegSet : void 0, sizes: jpegSet && !webpSet && !avifSet ? sizesAttr : void 0, loading: loadingAttr, decoding: decodingAttr, alt: altAttr, title: titleAttr, width: widthAttr, height: heightAttr, "data-filename": dataFilename, ...rest })] });
|
|
22254
|
+
}
|
|
22255
|
+
return (0, import_jsx_runtime2.jsx)("img", { ref: imgRef, src: fallback, loading: loadingAttr, decoding: decodingAttr, alt: altAttr, title: titleAttr, width: widthAttr, height: heightAttr, "data-filename": dataFilename, ...rest });
|
|
22256
|
+
};
|
|
22257
|
+
var ImgBase = (0, import_react7.forwardRef)(function Img(props, ref) {
|
|
22258
|
+
const hasMediaId = Number.isFinite(props.mediaId);
|
|
22259
|
+
if (hasMediaId) {
|
|
22260
|
+
warnDeprecatedMediaId(props.mediaId);
|
|
22261
|
+
return (0, import_jsx_runtime2.jsx)(LegacyImg, { ...props, forwardedRef: ref });
|
|
22262
|
+
}
|
|
22263
|
+
const hasSrc = typeof props.src === "string" && props.src.trim().length > 0;
|
|
22264
|
+
if (!hasSrc) {
|
|
22265
|
+
if (typeof console !== "undefined" && console.warn) {
|
|
22266
|
+
console.warn("<Img /> requires either src or mediaId. No src provided, rendering null.");
|
|
22267
|
+
}
|
|
22268
|
+
return null;
|
|
22269
|
+
}
|
|
22270
|
+
return (0, import_jsx_runtime2.jsx)(ModernImg, { ...props, forwardedRef: ref });
|
|
22271
|
+
});
|
|
22272
|
+
var Img2 = (0, import_react7.memo)(ImgBase);
|
|
22273
|
+
Img2.displayName = "PageSpeedImg";
|
|
22274
|
+
|
|
21632
22275
|
// src/renderers/ImageRenderer.tsx
|
|
21633
|
-
var
|
|
21634
|
-
|
|
22276
|
+
var import_jsx_runtime3 = __toESM(require_jsx_runtime());
|
|
22277
|
+
var toImgOptixFlowConfig = (config) => {
|
|
22278
|
+
if (!config) return void 0;
|
|
22279
|
+
const { compression, ...rest } = config;
|
|
22280
|
+
const base = rest;
|
|
22281
|
+
return {
|
|
22282
|
+
...base,
|
|
22283
|
+
compressionLevel: typeof compression === "number" ? compression : base.compressionLevel
|
|
22284
|
+
};
|
|
22285
|
+
};
|
|
22286
|
+
function ImageRenderer({ item, optixFlowConfig }) {
|
|
21635
22287
|
if (!item.src) return null;
|
|
21636
|
-
return /* @__PURE__ */ (0,
|
|
21637
|
-
|
|
22288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
22289
|
+
Img2,
|
|
21638
22290
|
{
|
|
21639
22291
|
className: Lightbox_default.media,
|
|
21640
22292
|
src: item.src,
|
|
21641
|
-
srcSet: item.srcSet,
|
|
21642
22293
|
alt: item.alt || item.title || "",
|
|
21643
|
-
loading: "lazy"
|
|
22294
|
+
loading: "lazy",
|
|
22295
|
+
optixFlowConfig: toImgOptixFlowConfig(optixFlowConfig)
|
|
21644
22296
|
}
|
|
21645
22297
|
);
|
|
21646
22298
|
}
|
|
21647
22299
|
|
|
21648
22300
|
// src/renderers/VideoRenderer.tsx
|
|
21649
|
-
var
|
|
22301
|
+
var import_jsx_runtime4 = __toESM(require_jsx_runtime());
|
|
21650
22302
|
function VideoRenderer({ item }) {
|
|
21651
22303
|
if (!item.src) return null;
|
|
21652
|
-
return /* @__PURE__ */ (0,
|
|
22304
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
21653
22305
|
"video",
|
|
21654
22306
|
{
|
|
21655
22307
|
className: Lightbox_default.media,
|
|
@@ -21661,8 +22313,8 @@ function VideoRenderer({ item }) {
|
|
|
21661
22313
|
}
|
|
21662
22314
|
|
|
21663
22315
|
// src/renderers/PDFRenderer.tsx
|
|
21664
|
-
var
|
|
21665
|
-
var
|
|
22316
|
+
var import_react16 = __toESM(require_react());
|
|
22317
|
+
var import_jsx_runtime9 = __toESM(require_jsx_runtime());
|
|
21666
22318
|
function loadPDFViewer() {
|
|
21667
22319
|
return Promise.resolve().then(() => (init_dist(), dist_exports)).then((mod) => ({
|
|
21668
22320
|
// The PDF viewer package exposes a named PDFViewer export.
|
|
@@ -21670,47 +22322,54 @@ function loadPDFViewer() {
|
|
|
21670
22322
|
default: mod.PDFViewer
|
|
21671
22323
|
}));
|
|
21672
22324
|
}
|
|
21673
|
-
var LazyPDFViewer =
|
|
22325
|
+
var LazyPDFViewer = import_react16.default.lazy(loadPDFViewer);
|
|
21674
22326
|
var AnyPDFViewer = LazyPDFViewer;
|
|
21675
22327
|
function PDFRenderer({ item }) {
|
|
21676
22328
|
if (!item.src) return null;
|
|
21677
|
-
return /* @__PURE__ */ (0,
|
|
21678
|
-
|
|
22329
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: Lightbox_default.pdfContainer, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
22330
|
+
import_react16.Suspense,
|
|
21679
22331
|
{
|
|
21680
|
-
fallback: /* @__PURE__ */ (0,
|
|
21681
|
-
children: /* @__PURE__ */ (0,
|
|
22332
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: Lightbox_default.pdfFallback, children: "Loading document..." }),
|
|
22333
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AnyPDFViewer, { url: item.src })
|
|
21682
22334
|
}
|
|
21683
22335
|
) });
|
|
21684
22336
|
}
|
|
21685
22337
|
|
|
21686
22338
|
// src/renderers/ComponentRenderer.tsx
|
|
21687
|
-
var
|
|
22339
|
+
var import_jsx_runtime10 = __toESM(require_jsx_runtime());
|
|
21688
22340
|
function ComponentRenderer({ item }) {
|
|
21689
22341
|
if (!item.component) return null;
|
|
21690
22342
|
const Component = item.component;
|
|
21691
|
-
return /* @__PURE__ */ (0,
|
|
22343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Component, { ...item.data || {} });
|
|
21692
22344
|
}
|
|
21693
22345
|
|
|
21694
22346
|
// src/components/LightboxContent.tsx
|
|
21695
|
-
var
|
|
21696
|
-
function LightboxContent({ item, layout }) {
|
|
22347
|
+
var import_jsx_runtime11 = __toESM(require_jsx_runtime());
|
|
22348
|
+
function LightboxContent({ item, layout, optixFlowConfig }) {
|
|
21697
22349
|
if (!item) return null;
|
|
21698
22350
|
switch (item.type) {
|
|
21699
22351
|
case "image":
|
|
21700
|
-
return /* @__PURE__ */ (0,
|
|
22352
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
22353
|
+
ImageRenderer,
|
|
22354
|
+
{
|
|
22355
|
+
item,
|
|
22356
|
+
layout,
|
|
22357
|
+
optixFlowConfig
|
|
22358
|
+
}
|
|
22359
|
+
);
|
|
21701
22360
|
case "video":
|
|
21702
|
-
return /* @__PURE__ */ (0,
|
|
22361
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(VideoRenderer, { item, layout });
|
|
21703
22362
|
case "pdf":
|
|
21704
|
-
return /* @__PURE__ */ (0,
|
|
22363
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PDFRenderer, { item, layout });
|
|
21705
22364
|
case "component":
|
|
21706
|
-
return /* @__PURE__ */ (0,
|
|
22365
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ComponentRenderer, { item });
|
|
21707
22366
|
default:
|
|
21708
22367
|
return null;
|
|
21709
22368
|
}
|
|
21710
22369
|
}
|
|
21711
22370
|
|
|
21712
22371
|
// src/components/LightboxChrome.tsx
|
|
21713
|
-
var
|
|
22372
|
+
var import_jsx_runtime12 = __toESM(require_jsx_runtime());
|
|
21714
22373
|
var DEFAULT_CONTROLS = {
|
|
21715
22374
|
navigation: true,
|
|
21716
22375
|
keyboard: true,
|
|
@@ -21740,9 +22399,9 @@ function LightboxChrome({
|
|
|
21740
22399
|
onClose
|
|
21741
22400
|
}) {
|
|
21742
22401
|
const resolved = mergeControls(controls);
|
|
21743
|
-
return /* @__PURE__ */ (0,
|
|
21744
|
-
resolved.navigation && /* @__PURE__ */ (0,
|
|
21745
|
-
/* @__PURE__ */ (0,
|
|
22402
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: Lightbox_default.chrome, children: [
|
|
22403
|
+
resolved.navigation && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: Lightbox_default.chromeSection, children: [
|
|
22404
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
21746
22405
|
"button",
|
|
21747
22406
|
{
|
|
21748
22407
|
type: "button",
|
|
@@ -21753,7 +22412,7 @@ function LightboxChrome({
|
|
|
21753
22412
|
children: "\u2039"
|
|
21754
22413
|
}
|
|
21755
22414
|
),
|
|
21756
|
-
/* @__PURE__ */ (0,
|
|
22415
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
21757
22416
|
"button",
|
|
21758
22417
|
{
|
|
21759
22418
|
type: "button",
|
|
@@ -21765,17 +22424,17 @@ function LightboxChrome({
|
|
|
21765
22424
|
}
|
|
21766
22425
|
)
|
|
21767
22426
|
] }),
|
|
21768
|
-
/* @__PURE__ */ (0,
|
|
21769
|
-
currentItem.title && /* @__PURE__ */ (0,
|
|
21770
|
-
currentItem.caption && /* @__PURE__ */ (0,
|
|
22427
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: Lightbox_default.chromeSection, children: resolved.captions && currentItem && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: Lightbox_default.captionContainer, children: [
|
|
22428
|
+
currentItem.title && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: Lightbox_default.captionTitle, children: currentItem.title }),
|
|
22429
|
+
currentItem.caption && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: Lightbox_default.captionText, children: currentItem.caption })
|
|
21771
22430
|
] }) }),
|
|
21772
|
-
/* @__PURE__ */ (0,
|
|
21773
|
-
resolved.counter && totalItems > 0 && /* @__PURE__ */ (0,
|
|
22431
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: Lightbox_default.chromeSection, children: [
|
|
22432
|
+
resolved.counter && totalItems > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: Lightbox_default.counter, children: [
|
|
21774
22433
|
currentIndex + 1,
|
|
21775
22434
|
" / ",
|
|
21776
22435
|
totalItems
|
|
21777
22436
|
] }),
|
|
21778
|
-
resolved.closeButton && /* @__PURE__ */ (0,
|
|
22437
|
+
resolved.closeButton && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
21779
22438
|
"button",
|
|
21780
22439
|
{
|
|
21781
22440
|
type: "button",
|
|
@@ -21790,7 +22449,7 @@ function LightboxChrome({
|
|
|
21790
22449
|
}
|
|
21791
22450
|
|
|
21792
22451
|
// src/components/Layouts/HorizontalLayout.tsx
|
|
21793
|
-
var
|
|
22452
|
+
var import_jsx_runtime13 = __toESM(require_jsx_runtime());
|
|
21794
22453
|
function HorizontalLayout({
|
|
21795
22454
|
content,
|
|
21796
22455
|
chrome,
|
|
@@ -21804,7 +22463,7 @@ function HorizontalLayout({
|
|
|
21804
22463
|
height,
|
|
21805
22464
|
...style
|
|
21806
22465
|
};
|
|
21807
|
-
return /* @__PURE__ */ (0,
|
|
22466
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: Lightbox_default.horizontalLayoutRoot, style: containerStyle, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
21808
22467
|
"div",
|
|
21809
22468
|
{
|
|
21810
22469
|
className: [
|
|
@@ -21812,15 +22471,15 @@ function HorizontalLayout({
|
|
|
21812
22471
|
className || ""
|
|
21813
22472
|
].join(" ").trim(),
|
|
21814
22473
|
children: [
|
|
21815
|
-
/* @__PURE__ */ (0,
|
|
21816
|
-
/* @__PURE__ */ (0,
|
|
22474
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: Lightbox_default.mainContent, children: content }),
|
|
22475
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: Lightbox_default.toolbar, children: chrome })
|
|
21817
22476
|
]
|
|
21818
22477
|
}
|
|
21819
22478
|
) });
|
|
21820
22479
|
}
|
|
21821
22480
|
|
|
21822
22481
|
// src/components/Lightbox.tsx
|
|
21823
|
-
var
|
|
22482
|
+
var import_jsx_runtime14 = __toESM(require_jsx_runtime());
|
|
21824
22483
|
function Lightbox(props) {
|
|
21825
22484
|
const { items, initialIndex = 0 } = props;
|
|
21826
22485
|
const gallery = useGalleryState({
|
|
@@ -21829,14 +22488,14 @@ function Lightbox(props) {
|
|
|
21829
22488
|
onSelect: props.onSelect
|
|
21830
22489
|
});
|
|
21831
22490
|
const { breakpoint } = useResponsiveness();
|
|
21832
|
-
const layout = (0,
|
|
22491
|
+
const layout = (0, import_react17.useMemo)(() => {
|
|
21833
22492
|
if (props.layout) return props.layout;
|
|
21834
22493
|
if (breakpoint === "mobile") return "fullscreen";
|
|
21835
22494
|
if (breakpoint === "tablet") return "vertical-split";
|
|
21836
22495
|
return "horizontal";
|
|
21837
22496
|
}, [props.layout, breakpoint]);
|
|
21838
|
-
const didCloseRef = (0,
|
|
21839
|
-
(0,
|
|
22497
|
+
const didCloseRef = (0, import_react17.useRef)(false);
|
|
22498
|
+
(0, import_react17.useEffect)(() => {
|
|
21840
22499
|
props.onOpen?.();
|
|
21841
22500
|
if (props.disableScroll === false) {
|
|
21842
22501
|
return () => {
|
|
@@ -21861,17 +22520,17 @@ function Lightbox(props) {
|
|
|
21861
22520
|
}
|
|
21862
22521
|
};
|
|
21863
22522
|
}, [props.disableScroll, props.onOpen, props.onClose]);
|
|
21864
|
-
const handleClose = (0,
|
|
22523
|
+
const handleClose = (0, import_react17.useCallback)(() => {
|
|
21865
22524
|
if (didCloseRef.current) return;
|
|
21866
22525
|
didCloseRef.current = true;
|
|
21867
22526
|
props.onClose?.();
|
|
21868
22527
|
}, [props.onClose]);
|
|
21869
|
-
const handleNext = (0,
|
|
22528
|
+
const handleNext = (0, import_react17.useCallback)(() => {
|
|
21870
22529
|
if (!gallery.canNext) return;
|
|
21871
22530
|
gallery.next();
|
|
21872
22531
|
props.onNext?.();
|
|
21873
22532
|
}, [gallery, props.onNext]);
|
|
21874
|
-
const handlePrev = (0,
|
|
22533
|
+
const handlePrev = (0, import_react17.useCallback)(() => {
|
|
21875
22534
|
if (!gallery.canPrev) return;
|
|
21876
22535
|
gallery.prev();
|
|
21877
22536
|
props.onPrev?.();
|
|
@@ -21897,19 +22556,26 @@ function Lightbox(props) {
|
|
|
21897
22556
|
captions: true,
|
|
21898
22557
|
...props.controls
|
|
21899
22558
|
};
|
|
21900
|
-
return /* @__PURE__ */ (0,
|
|
21901
|
-
/* @__PURE__ */ (0,
|
|
22559
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: Lightbox_default.lightboxPortal, role: "dialog", "aria-modal": "true", children: [
|
|
22560
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
21902
22561
|
LightboxOverlay,
|
|
21903
22562
|
{
|
|
21904
22563
|
onClose: handleClose,
|
|
21905
22564
|
closeOnBackdropClick: props.closeOnBackdropClick ?? true
|
|
21906
22565
|
}
|
|
21907
22566
|
),
|
|
21908
|
-
/* @__PURE__ */ (0,
|
|
22567
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
21909
22568
|
HorizontalLayout,
|
|
21910
22569
|
{
|
|
21911
|
-
content: /* @__PURE__ */ (0,
|
|
21912
|
-
|
|
22570
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
22571
|
+
LightboxContent,
|
|
22572
|
+
{
|
|
22573
|
+
item: currentItem,
|
|
22574
|
+
layout,
|
|
22575
|
+
optixFlowConfig: props.optixFlowConfig
|
|
22576
|
+
}
|
|
22577
|
+
),
|
|
22578
|
+
chrome: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
21913
22579
|
LightboxChrome,
|
|
21914
22580
|
{
|
|
21915
22581
|
currentIndex: gallery.currentIndex,
|
|
@@ -21933,28 +22599,28 @@ function Lightbox(props) {
|
|
|
21933
22599
|
}
|
|
21934
22600
|
|
|
21935
22601
|
// src/hooks/useLightboxState.ts
|
|
21936
|
-
var
|
|
22602
|
+
var import_react18 = __toESM(require_react());
|
|
21937
22603
|
function useLightboxState({
|
|
21938
22604
|
onOpen,
|
|
21939
22605
|
onClose,
|
|
21940
22606
|
disableScroll = true
|
|
21941
22607
|
}) {
|
|
21942
|
-
const [isOpen, setIsOpen] = (0,
|
|
21943
|
-
const open = (0,
|
|
22608
|
+
const [isOpen, setIsOpen] = (0, import_react18.useState)(false);
|
|
22609
|
+
const open = (0, import_react18.useCallback)(() => {
|
|
21944
22610
|
setIsOpen(true);
|
|
21945
22611
|
onOpen?.();
|
|
21946
22612
|
if (disableScroll) {
|
|
21947
22613
|
document.body.style.overflow = "hidden";
|
|
21948
22614
|
}
|
|
21949
22615
|
}, [onOpen, disableScroll]);
|
|
21950
|
-
const close = (0,
|
|
22616
|
+
const close = (0, import_react18.useCallback)(() => {
|
|
21951
22617
|
setIsOpen(false);
|
|
21952
22618
|
onClose?.();
|
|
21953
22619
|
if (disableScroll) {
|
|
21954
22620
|
document.body.style.overflow = "";
|
|
21955
22621
|
}
|
|
21956
22622
|
}, [onClose, disableScroll]);
|
|
21957
|
-
(0,
|
|
22623
|
+
(0, import_react18.useEffect)(() => {
|
|
21958
22624
|
return () => {
|
|
21959
22625
|
if (disableScroll) {
|
|
21960
22626
|
document.body.style.overflow = "";
|