import { useState as W, useEffect as b } from "react";
const w = (t) => ({
  top: Math.ceil(t.scrollTop),
  height: t.scrollHeight,
  left: Math.ceil(t.scrollLeft),
  width: t.scrollWidth
}), R = (t) => {
  var d, u;
  const [f, i] = W({ top: 0, height: 1 / 0, width: 1 / 0, left: 0 }), l = (e) => {
    const o = e.target, s = w(o);
    i(s);
  };
  b(() => {
    const e = () => {
      if (t.current) {
        const z = w(t.current), D = setTimeout(() => i(z), 0);
        return () => clearTimeout(D);
      }
    }, o = e(), s = new ResizeObserver(e);
    return t.current && s.observe(t.current), window.addEventListener("resize", e), () => {
      o && o(), s.disconnect(), window.removeEventListener("resize", e);
    };
  }, [t]);
  const { top: n, height: r, left: h, width: c } = f, m = ((d = t.current) == null ? void 0 : d.clientHeight) ?? 0, p = r > 0 && n !== 0, S = r !== 0 && n < r - m, a = ((u = t.current) == null ? void 0 : u.clientWidth) ?? 0, v = c > 0 && h !== 0, g = c !== 0 && h < c - a;
  return [
    {
      showTopShadow: p,
      showBottomShadow: S,
      showLeftShadow: v,
      showRightShadow: g
    },
    { onScroll: l }
  ];
};
export {
  R as useScrollWrapper
};
//# sourceMappingURL=useScrollWrapper.es.js.map
