/** Lottieهای لوکال (`public/lottie`) — پیش‌دانلود تا مودال/لیست خالی نماند */ const LOTTIE_FILES = { logoutConfirm: 'lottie/logoutConfirm.json', emptyList: 'lottie/emptyList.json', goldBars: 'lottie/goldBars.json', } as const export type LottieAssetKey = keyof typeof LOTTIE_FILES const cache = new Map() export function lottieSrc(key: LottieAssetKey): string { const base = import.meta.env.BASE_URL || '/' const path = `${base}${LOTTIE_FILES[key]}` return path.replace(/([^:]\/)\/+/g, '$1') } export function getLottieData(key: LottieAssetKey): string | undefined { return cache.get(key) } export async function preloadLottieAssets(): Promise { const keys = Object.keys(LOTTIE_FILES) as LottieAssetKey[] await Promise.all( keys.map(async (key) => { if (cache.has(key)) return try { const res = await fetch(lottieSrc(key)) if (!res.ok) return cache.set(key, await res.text()) } catch { /* شبکه/آفلاین — بعداً از src لوکال می‌خواند */ } }), ) }