"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.useRegisterResize = void 0;
const react_1 = require("react");
const resize_observer_polyfill_1 = __importDefault(require("resize-observer-polyfill"));
const useRegisterResize = (ref, onResize) => {
    (0, react_1.useEffect)(() => {
        if (!ref || !onResize)
            return;
        const observer = new resize_observer_polyfill_1.default((entries) => {
            const [entry] = entries;
            onResize(entry.target.clientHeight / window.innerWidth);
        });
        observer.observe(ref);
        return () => {
            observer.unobserve(ref);
        };
    }, [ref, onResize]);
};
exports.useRegisterResize = useRegisterResize;
