// @ts-nocheck

/* eslint-disable */
import { checkCollinear, getDistance, moveTo } from "./math.mjs";
/**
 * From https://github.com/unsplash/react-trend/blob/master/src/helpers/DOM.helpers.js#L18
 */

export function genPath(points, radius, fill = false, height = 75) {
  const start = points.shift();
  const end = points[points.length - 1];
  return (fill ? "M".concat(start.x, " ").concat(height - start.x + 2, " L").concat(start.x, " ").concat(start.y) : "M".concat(start.x, " ").concat(start.y)) + points.map((point, index) => {
    const next = points[index + 1];
    const prev = points[index - 1] || start;
    const isCollinear = next && checkCollinear(next, point, prev);

    if (!next || isCollinear) {
      return "L".concat(point.x, " ").concat(point.y);
    }

    const threshold = Math.min(getDistance(prev, point), getDistance(next, point));
    const isTooCloseForRadius = threshold / 2 < radius;
    const radiusForPoint = isTooCloseForRadius ? threshold / 2 : radius;
    const before = moveTo(prev, point, radiusForPoint);
    const after = moveTo(next, point, radiusForPoint);
    return "L".concat(before.x, " ").concat(before.y, "S").concat(point.x, " ").concat(point.y, " ").concat(after.x, " ").concat(after.y);
  }).join('') + (fill ? "L".concat(end.x, " ").concat(height - start.x + 2, " Z") : '');
}
//# sourceMappingURL=path.mjs.map