"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useTimeout = exports.useSyncStoreOpt = exports.useSyncStore = exports.useBrowserLayoutEffect = exports.useIsoLayoutEffect = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
exports.useIsoLayoutEffect = typeof window === 'object' && !!window.document ? React.useLayoutEffect : React.useEffect;
exports.useBrowserLayoutEffect = typeof window === 'object' && !!window.document ? React.useLayoutEffect : () => { };
const useSyncStore = (store) => React.useSyncExternalStore(store.subscribe, store.getSnapshot);
exports.useSyncStore = useSyncStore;
const emptySyncStore = {
    getSnapshot: () => undefined,
    subscribe: () => () => { },
};
const useSyncStoreOpt = (store = emptySyncStore) => React.useSyncExternalStore(store.subscribe, store.getSnapshot);
exports.useSyncStoreOpt = useSyncStoreOpt;
const useTimeout = (ms, deps = [ms]) => {
    const [ready, setReady] = React.useState(false);
    React.useEffect(() => {
        if (ready)
            setReady(false);
        const timer = setTimeout(() => {
            setReady(true);
        }, ms);
        return () => {
            clearTimeout(timer);
        };
        // biome-ignore lint: useExhaustiveDependencies: want to control deps manually
    }, deps);
    return ready;
};
exports.useTimeout = useTimeout;
//# sourceMappingURL=hooks.js.map