PageSourceSearch

https://www.rheem.ca/vike/assets/chunks/chunk-DI_-q31T.js

js rheem.ca collected 2026-10-07 18:35:03 UTC 2,365 bytes, 71 lines download raw bytes

1import { A as onMounted, G as watch, c as computed, ct as toValue, j as onUnmounted, nt as ref } from "./chunk-DlK_RcJg.js";
2//#region utils/helper/chunkArray.ts
3function chunkArray(array, chunkSize) {
4	const chunks = [];
5	for (let i = 0; i < array.length; i += chunkSize) chunks.push(array.slice(i, i + chunkSize));
6	return chunks;
7}
8//#endregion
9//#region utils/api/composables/usePaginatedData.ts
10function usePaginatedData({ data, pageSize = 12, initialPage = 1, urlSync = false }) {
11	const urlSyncInternal = ref(urlSync);
12	const pagedData = computed(() => chunkArray(toValue(data) || [], toValue(pageSize)));
13	const pagesTotal = computed(() => pagedData.value.length);
14	const currentPage = ref(initialPage || 1);
15	const currentPageData = computed(() => toValue(pagedData)[currentPage.value - 1]);
16	watch(pagesTotal, () => {
17		if (currentPage.value > pagesTotal.value) currentPage.value = pagesTotal.value || 1;
18	});
19	function setPage(v) {
20		if (!pagesTotal.value) currentPage.value = 1;
21		else currentPage.value = v > pagesTotal.value ? pagesTotal.value : v;
22		updateURLPage(currentPage.value);
23	}
24	function next() {
25		if (currentPage.value < pagesTotal.value) {
26			currentPage.value++;
27			updateURLPage(currentPage.value);
28		}
29	}
30	function prev() {
31		if (currentPage.value > 1) {
32			currentPage.value--;
33			updateURLPage(currentPage.value);
34		}
35	}
36	if (urlSyncInternal.value && typeof window !== "undefined") {
37		onMounted(() => {
38			window.addEventListener("popstate", handlePopState);
39		});
40		onUnmounted(() => {
41			window.removeEventListener("popstate", handlePopState);
42		});
43	}
44	const handlePopState = () => {
45		const pageParam = new URL(window.location.href).searchParams.get("page");
46		if (pageParam) {
47			const pageNumber = parseInt(pageParam, 10);
48			if (pageNumber !== currentPage.value && pageNumber >= 1 && pageNumber <= pagesTotal.value) currentPage.value = pageNumber;
49		}
50	};
51	function updateURLPage(page) {
52		if (typeof window === "undefined") return;
53		const url = new URL(window.location.href);
54		if (url.searchParams.get("page") !== String(page)) {
55			url.searchParams.set("page", page.toString());
56			window.history.pushState({}, "", url.toString());
57		}
58	}
59	return {
60		currentPageData,
61		pagesTotal,
62		setPage,
63		currentPage,
64		next,
65		prev,
66		urlSync: urlSyncInternal,
67		updateURLPage
68	};
69}
70//#endregion
71export { usePaginatedData as t };

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.