import { u as useQuery } from "../_libs/react+tanstack__react-query.mjs"; import { n as trpc } from "./trpc-client-CQOIB5UU.mjs"; import { t as axios } from "../_libs/axios+[...].mjs"; //#region node_modules/.nitro/vite/services/ssr/assets/prominent-api-hooks-CNVDntUD.js var CACHE_FILENAMES = { products: "products.json", stores: "stores.json", slots: "slots.json", essentialConsts: "essential-consts.json", banners: "banners.json" }; var useGetEssentialConsts = () => { const query = trpc.common.essentialConsts.useQuery(void 0, { refetchInterval: 6e4 }); return { ...query, refetch: query.refetch }; }; function useCacheUrl(filename) { const { data: essentialConsts } = useGetEssentialConsts(); const assetsDomain = essentialConsts?.assetsDomain; const apiCacheKey = essentialConsts?.apiCacheKey; const cacheVersion = essentialConsts?.cacheVersion; if (!assetsDomain || !apiCacheKey || cacheVersion === void 0 || cacheVersion === null) return null; return `${assetsDomain}${apiCacheKey}/v-${cacheVersion}/${filename}`; } function useAllProducts() { const cacheUrl = useCacheUrl(CACHE_FILENAMES.products); return useQuery({ queryKey: ["all-products", cacheUrl], queryFn: async () => { if (!cacheUrl) throw new Error("Cache URL not available"); return (await axios.get(cacheUrl)).data; }, staleTime: 6e4, enabled: !!cacheUrl }); } function useStores() { const cacheUrl = useCacheUrl(CACHE_FILENAMES.stores); return useQuery({ queryKey: ["stores", cacheUrl], queryFn: async () => { if (!cacheUrl) throw new Error("Cache URL not available"); return (await axios.get(cacheUrl)).data; }, staleTime: 6e4, enabled: !!cacheUrl }); } function useSlots() { const cacheUrl = useCacheUrl(CACHE_FILENAMES.slots); return useQuery({ queryKey: ["slots", cacheUrl], queryFn: async () => { if (!cacheUrl) throw new Error("Cache URL not available"); return (await axios.get(cacheUrl + "?v=123")).data; }, staleTime: 6e4, enabled: !!cacheUrl }); } function useBanners() { const cacheUrl = useCacheUrl(CACHE_FILENAMES.banners); return useQuery({ queryKey: ["banners", cacheUrl], queryFn: async () => { if (!cacheUrl) throw new Error("Cache URL not available"); return (await axios.get(cacheUrl)).data; }, staleTime: 6e4, enabled: !!cacheUrl }); } function useStoreWithProducts(storeId) { const { data: essentialConsts } = useGetEssentialConsts(); const assetsDomain = essentialConsts?.assetsDomain; const apiCacheKey = essentialConsts?.apiCacheKey; const cacheVersion = essentialConsts?.cacheVersion; const cacheUrl = assetsDomain && apiCacheKey ? `${assetsDomain}${apiCacheKey}/v-${cacheVersion}/stores/${storeId}.json` : null; return useQuery({ queryKey: [ "store-with-products", storeId, cacheUrl ], queryFn: async () => { if (!cacheUrl) throw new Error("Cache URL not available"); return (await axios.get(cacheUrl)).data; }, staleTime: 6e4, enabled: !!cacheUrl }); } //#endregion export { useStores as a, useStoreWithProducts as i, useBanners as n, useSlots as r, useAllProducts as t };