Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../chunk-BN4qSVkS.cjs");
let lodash_es = require("lodash-es");
let react = require("react");
//#region src/hooks/useResizeObserver.tsx
function useResizeObserver(resizeProperties) {
	const resizeObserver = (0, react.useRef)(null);
	const [rect, setRect] = (0, react.useState)(null);
	const [selectedProperties, setSelectedProperties] = (0, react.useState)(null);
	const mounted = (0, react.useRef)(false);
	(0, react.useEffect)(() => {
		mounted.current = true;
		return () => {
			mounted.current = false;
		};
	}, []);
	const onResize = (0, react.useCallback)((entries) => {
		setTimeout(() => {
			if (mounted.current) {
				const changedRect = entries[0].contentRect;
				setRect(changedRect);
			} else if (resizeObserver.current) resizeObserver.current.disconnect();
		}, 0);
	}, [setRect]);
	const ref = (0, react.useCallback)((node) => {
		if (node && node instanceof Element && resizeProperties && resizeProperties.length > 0) {
			resizeObserver.current = new ResizeObserver(onResize);
			resizeObserver.current.observe(node);
		}
	}, [onResize, resizeProperties]);
	(0, react.useEffect)(() => {
		if (resizeProperties) {
			const selectedProps = (0, lodash_es.pick)(rect, resizeProperties);
			if (JSON.stringify(selectedProperties) !== JSON.stringify(selectedProps)) setSelectedProperties(selectedProps);
		}
	}, [
		rect,
		resizeProperties,
		setSelectedProperties,
		selectedProperties
	]);
	return {
		ref,
		rect: selectedProperties
	};
}
//#endregion
exports.useResizeObserver = useResizeObserver;
