const T = (v, g, t, p, w, x) => {
  let c, o, i, l, z, r, M = !1, b = !1;
  "magnetize" in t.vertical && (M = t.vertical.magnetize || !1), "magnetize" in t.horizontal && (b = t.horizontal.magnetize || !1);
  const e = v?.containerHeight || 200, n = v?.containerWidth || 200, y = p?.scrollTop || 0, L = p?.scrollLeft || 0;
  "top" in t.vertical && (c = t.vertical.top), "bottom" in t.vertical && (o = t.vertical.bottom), "height" in t.vertical && (i = t.vertical.height), "left" in t.horizontal && (l = t.horizontal.left), "right" in t.horizontal && (z = t.horizontal.right), "width" in t.horizontal && (r = t.horizontal.width, !("left" in t.horizontal) && !("right" in t.horizontal) && (l = L + (n - r) / 2)), "height" in t.vertical && (i = t.vertical.height, !("top" in t.vertical) && !("bottom" in t.vertical) && (c = y + (e - i) / 2)), "percent" in t.vertical && (i = e * t.vertical.percent, c = (e - i) / 2), "percent" in t.horizontal && (r = n * t.horizontal.percent, l = (n - r) / 2);
  const h = {
    y: Math.round(c ?? (o !== void 0 ? e + o - (i || 0) : 0)),
    height: Math.round(i ?? e - (c || 0) - (o || 0)),
    x: Math.round(l ?? (z !== void 0 ? n + z - (r || 0) : 0)),
    width: Math.round(r ?? n - (l || 0) - (z || 0)),
    magnetizeBottom: M,
    magnetizeRight: b
  };
  if (!w) {
    const a = g?.top || 0, m = g?.bottom || 0;
    h.y = Math.max(h.y, a), h.height = Math.min(h.height, e - a + m);
  }
  if (!x) {
    const a = g?.left || 0, m = g?.right || 0;
    h.x = Math.max(h.x, a), h.width = Math.min(h.width, n - a + m);
  }
  return h;
};
export {
  T as getInitialSize
};
