import t from "../../utils/deviceType.js";
import { useState as r, useEffect as f } from "react";
const c = (d) => {
  const { getDeviceType: e, getHeight: i } = d || {}, [o, w] = r(() => ({
    width: typeof window < "u" ? window.innerWidth : 0,
    ...i && { height: typeof window < "u" ? window.innerHeight : 0 },
    ...e && { deviceType: typeof window < "u" ? t() : "desktop" }
  }));
  return f(() => {
    const n = () => {
      w((s) => ({
        ...s,
        width: window.innerWidth,
        ...i && { height: window.innerHeight },
        ...e && { deviceType: t() }
      }));
    };
    return typeof window < "u" && (window.addEventListener("resize", n), n()), () => {
      typeof window < "u" && window.removeEventListener("resize", n);
    };
  }, [i, e]), o;
};
export {
  c as useWindowDimensionsAndDevice
};
