// ReBak Windows App — JavaScript interop helpers

window.rebak = {
    /**
     * Scroll an element into view.
     * @param {string} elementId
     */
    scrollIntoView: function (elementId) {
        const el = document.getElementById(elementId);
        if (el) el.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
    },

    /**
     * Apply or remove the 'dark' class on <html> to toggle dark mode.
     * @param {boolean} isDark
     */
    setDarkMode: function (isDark) {
        if (isDark) {
            document.documentElement.classList.add('dark');
        } else {
            document.documentElement.classList.remove('dark');
        }
    },

    /**
     * Read a value from localStorage.
     * @param {string} key
     * @returns {string|null}
     */
    localStorageGet: function (key) {
        return localStorage.getItem(key);
    },

    /**
     * Write a value to localStorage.
     * @param {string} key
     * @param {string} value
     */
    localStorageSet: function (key, value) {
        localStorage.setItem(key, value);
    },
};
