"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var gradient_picker_utils_exports = {};
__export(gradient_picker_utils_exports, {
  areGradientsEqual: () => import_are_gradients_equal.areGradientsEqual,
  findLargestGapMidpoint: () => findLargestGapMidpoint,
  roundPosition: () => roundPosition
});
module.exports = __toCommonJS(gradient_picker_utils_exports);
var import_are_gradients_equal = require("./../../../../../_shared/are-gradients-equal.js");
const roundPosition = (value) => Math.round(value * 100) / 100;
const findLargestGapMidpoint = (stops) => {
  if (stops.length === 0) {
    return 1;
  }
  const sorted = stops.map((s) => s.position ?? 0).sort((a, b) => a - b);
  let bestMid = 1;
  let bestGap = 0;
  for (let i = 0; i < sorted.length - 1; i++) {
    const gap = sorted[i + 1] - sorted[i];
    if (gap > bestGap) {
      bestGap = gap;
      bestMid = sorted[i] + gap / 2;
    }
  }
  const tailGap = 1 - sorted[sorted.length - 1];
  if (tailGap > bestGap) {
    bestMid = sorted[sorted.length - 1] + tailGap / 2;
  }
  return roundPosition(bestMid);
};
//# sourceMappingURL=gradient-picker-utils.js.map
