"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
function s(t) {
  return {
    x: Math.round(t.x),
    y: Math.round(t.y)
  };
}
function m(t) {
  return {
    top: t.y,
    right: t.x + (t.width || 0),
    bottom: t.y + (t.height || 0),
    left: t.x
  };
}
function B(t) {
  return {
    x: t.left,
    y: t.top,
    width: t.right - t.left,
    height: t.bottom - t.top
  };
}
function w(t) {
  return s({
    x: t.x + (t.width || 0) / 2,
    y: t.y + (t.height || 0) / 2
  });
}
function M(t) {
  for (var r = t.waypoints, h = r.reduce(function(e, i, v) {
    var o = r[v - 1];
    if (o) {
      var y = e[e.length - 1], c = y && y.endLength || 0, d = L(o, i);
      e.push({
        start: o,
        end: i,
        startLength: c,
        endLength: c + d,
        length: d
      });
    }
    return e;
  }, []), f = h.reduce(function(e, i) {
    return e + i.length;
  }, 0), a = f / 2, u = 0, n = h[u]; n.endLength < a; )
    n = h[++u];
  var g = (a - n.startLength) / n.length, x = {
    x: n.start.x + (n.end.x - n.start.x) * g,
    y: n.start.y + (n.end.y - n.start.y) * g
  };
  return x;
}
function P(t) {
  return p(t) ? M(t) : w(t);
}
function L(t, r) {
  return Math.sqrt(Math.pow(t.x - r.x, 2) + Math.pow(t.y - r.y, 2));
}
function p(t) {
  return !!t.waypoints;
}
exports.asBounds = B;
exports.asTRBL = m;
exports.getBoundsMid = w;
exports.getConnectionMid = M;
exports.getMid = P;
exports.roundPoint = s;
