"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "useCSSVariable", {
    enumerable: true,
    get: function() {
        return useCSSVariable;
    }
});
const _react = require("react");
const useCSSVariable = (names)=>{
    const [variables, setVariables] = (0, _react.useState)(()=>getCSSVariableValue(names ?? []));
    function getCSSVariableValue(names) {
        const root = document.documentElement;
        const styles = getComputedStyle(root);
        if (names) {
            const obj = names.reduce((acc, name, index)=>{
                acc[name] = styles.getPropertyValue(name);
                return acc;
            }, {});
            return obj;
        }
        return {};
    }
    (0, _react.useEffect)(()=>{
        if (names?.length === 0) return;
        const styleObserver = new MutationObserver((mutations)=>{
            ;
            getCSSVariableValue(names);
        });
        styleObserver.observe(document.documentElement, {
            attributes: true,
            attributeFilter: [
                "style"
            ]
        });
        return ()=>{
            styleObserver.disconnect();
        };
    }, [
        names
    ]);
    return variables;
};

//# sourceMappingURL=useCSSVariable.js.map