import { defineComponent, inject, ref, createElementBlock, openBlock, Fragment, createVNode } from "vue";
import { GAP as i } from "./util.mjs";
import ce from "./thumb2.mjs";
import { barProps as o } from "./bar.mjs";
import { scrollbarContextKey as o$1 } from "./constants.mjs";
import c from "../../../_virtual/plugin-vue_export-helper.mjs";
const C = /* @__PURE__ */ defineComponent({
  __name: "bar",
  props: o,
  setup(_, { expose: y }) {
    const m = _, u = inject(o$1), v = ref(0), h = ref(0), p = ref(""), d = ref(""), r = ref(1), n = ref(1);
    return y({
      handleScroll: (e) => {
        if (e) {
          const t = e.offsetHeight - i, o2 = e.offsetWidth - i;
          h.value = e.scrollTop * 100 / t * r.value, v.value = e.scrollLeft * 100 / o2 * n.value;
        }
      },
      update: () => {
        const e = u == null ? void 0 : u.wrapElement;
        if (!e)
          return;
        const t = e.offsetHeight - i, o2 = e.offsetWidth - i, c2 = t ** 2 / e.scrollHeight, f = o2 ** 2 / e.scrollWidth, s = Math.max(c2, m.minSize), i$1 = Math.max(f, m.minSize);
        r.value = c2 / (t - c2) / (s / (t - s)), n.value = f / (o2 - f) / (i$1 / (o2 - i$1)), d.value = s + i < t ? `${s}px` : "", p.value = i$1 + i < o2 ? `${i$1}px` : "";
      }
    }), (e, t) => (openBlock(), createElementBlock(Fragment, null, [
      createVNode(ce, {
        move: v.value,
        ratio: n.value,
        size: p.value,
        always: e.always
      }, null, 8, ["move", "ratio", "size", "always"]),
      createVNode(ce, {
        move: h.value,
        ratio: r.value,
        size: d.value,
        vertical: "",
        always: e.always
      }, null, 8, ["move", "ratio", "size", "always"])
    ], 64));
  }
});
var A = /* @__PURE__ */ c(C, [["__file", "bar.vue"]]);
export {
  A as default
};
