import AppData from "./Common/AppData";
import CategoryData from "./Common/CategoryData";
import ProductData from "./Common/ProductData";
import ComponentsInitializer from "./Components/ComponentsInitializer";
import GlobalEvents from "./Events/GlobalEvents";

jQuery(document).ready(async () => {
    try {

        await AppData.getInstance().populate();

        await CategoryData.getInstance().load();

        // Initialize global events
        GlobalEvents.handleGlobalEvents();

        // Initialize all components (filters, products, etc.)
        ComponentsInitializer.init();

        // Load products and initialize Fuse.js
        await ProductData.getInstance().load();

    } catch (error) {
        console.error('FuseCommerce: Initialization error', error);
    }
});