import AnnouncementBanner from "./alpine/announcementBanner.js";
import AnnouncementModal from "./alpine/announcementModal.js";
import Sticky from "./alpine/sticky.js";

class AlpineManager {
    constructor() {
        this.components = {};
    }

    register(name, component) {
        this.components[name] = component;

        if (window.Alpine) {
            window.Alpine.data(name, component);
        }
    }

    registerAll() {
        if (!window.Alpine) {
            return;
        }

        for (const [name, component] of Object.entries(this.components)) {
            window.Alpine.data(name, component);
        }
    }
}

// instance singleton
const alpineManager = new AlpineManager();
alpineManager.register("announcementBanner", AnnouncementBanner);
alpineManager.register("announcementModal", AnnouncementModal);
alpineManager.register("sticky", Sticky);
export default alpineManager;
