import { __read as h } from "../../../../../../tslib/tslib.es6.es.js";
import { calcLength as f } from "../../../projection/geometry/delta-calc.es.js";
import { mix as t } from "../../../../../../popmotion/dist/es/utils/mix.es.js";
import { progress as u } from "../../../../../../popmotion/dist/es/utils/progress.es.js";
import { clamp as p } from "../../../../../../popmotion/dist/es/utils/clamp.es.js";
function y(n, m, e) {
  var i = m.min, r = m.max;
  return i !== void 0 && n < i ? n = e ? t(i, n, e.min) : Math.max(n, i) : r !== void 0 && n > r && (n = e ? t(r, n, e.max) : Math.min(n, r)), n;
}
function o(n, m, e) {
  return {
    min: m !== void 0 ? n.min + m : void 0,
    max: e !== void 0 ? n.max + e - (n.max - n.min) : void 0
  };
}
function M(n, m) {
  var e = m.top, i = m.left, r = m.bottom, l = m.right;
  return {
    x: o(n.x, i, l),
    y: o(n.y, e, r)
  };
}
function v(n, m) {
  var e, i = m.min - n.min, r = m.max - n.max;
  return m.max - m.min < n.max - n.min && (e = h([r, i], 2), i = e[0], r = e[1]), { min: i, max: r };
}
function R(n, m) {
  return {
    x: v(n.x, m.x),
    y: v(n.y, m.y)
  };
}
function V(n, m) {
  var e = 0.5, i = f(n), r = f(m);
  return r > i ? e = u(m.min, m.max - i, n.min) : i > r && (e = u(n.min, n.max - r, m.min)), p(0, 1, e);
}
function D(n, m) {
  var e = {};
  return m.min !== void 0 && (e.min = m.min - n.min), m.max !== void 0 && (e.max = m.max - n.min), e;
}
var x = 0.35;
function O(n) {
  return n === void 0 && (n = x), n === !1 ? n = 0 : n === !0 && (n = x), {
    x: a(n, "left", "right"),
    y: a(n, "top", "bottom")
  };
}
function a(n, m, e) {
  return {
    min: d(n, m),
    max: d(n, e)
  };
}
function d(n, m) {
  var e;
  return typeof n == "number" ? n : (e = n[m]) !== null && e !== void 0 ? e : 0;
}
export {
  y as applyConstraints,
  V as calcOrigin,
  o as calcRelativeAxisConstraints,
  M as calcRelativeConstraints,
  v as calcViewportAxisConstraints,
  R as calcViewportConstraints,
  x as defaultElastic,
  D as rebaseAxisConstraints,
  a as resolveAxisElastic,
  O as resolveDragElastic,
  d as resolvePointElastic
};
//# sourceMappingURL=constraints.es.js.map
