import { getOfflineData, getUserItems, saveOfflineData } from "./storage.js";
async function loadPackagedData() {
 const response = await fetch(chrome.runtime.getURL("data/index.json"));
 if (!response.ok) {
 throw new Error("Failed to load packaged local data");
 }
 return response.json();
}
function mergeData(packagedData, userItems) {
 return {
 ...packagedData,
 items: [...(packagedData.items || []), ...(userItems || [])]
 };
}
export async function loadOfflineData() {
 const packagedData = await loadPackagedData();
 const storedData = await getOfflineData();
 const userItems = await getUserItems();
 if (!storedData || storedData.version !== packagedData.version) {
 await saveOfflineData(packagedData);
 return mergeData(packagedData, userItems);
 }
 return mergeData(storedData, userItems);
}