import { shallowRef as n, reactive as f, watch as p, unref as b } from "vue";
import { getScrollable as r } from "../../scroll-bar/utils/index.mjs";
const h = () => {
  const t = n(), c = f({ x: 0, y: 0 }), a = f({ x: 0, y: 0 }), i = n(), s = n();
  p(
    () => t.value,
    () => {
      u();
    }
  );
  function u() {
    const e = b(t);
    if (!e)
      return;
    const { visibleSize: l, totalSize: o } = r(
      e,
      "horizontal"
    ), { visibleSize: z, totalSize: x } = r(e, "vertical");
    c.x = o - l, c.y = x - z;
  }
  function v() {
    if (!t.value)
      return;
    const { totalSize: e, visibleSize: l } = r(
      t.value,
      "vertical"
    ), o = a.y / (e - l || 1) * 100;
    s.value?.scroll(o);
  }
  function S() {
    if (!t.value)
      return;
    const { totalSize: e, visibleSize: l } = r(
      t.value,
      "horizontal"
    ), o = a.x / (e - l || 1) * 100;
    i.value?.scroll(o);
  }
  return {
    maxScrollDistance: c,
    scrollOffset: a,
    xBarRef: i,
    yBarRef: s,
    scrollYBar: v,
    scrollXBar: S,
    containerRef: t,
    updateMaxScrollDistance: u
  };
};
export {
  h as default
};
