"use client";
import { useControlledValue as x } from "../helpers/useControlledValue.js";
import { rangeIncludesDate as R } from "../utils/rangeIncludesDate.js";
import { addToRange as y } from "../utils/addToRange.js";
import { rangeContainsModifiers as C } from "../utils/rangeContainsModifiers.js";
function b(c, l) {
  const { disabled: d, excludeDisabled: i, selected: s, required: f, onSelect: o } = c, [r, m] = x(s, o ? s : void 0), t = o ? s : r;
  return {
    selected: t,
    select: (n, u, a) => {
      const { min: S, max: p } = c, e = n ? y(n, t, S, p, f, l) : void 0;
      return i && d && e?.from && e.to && C({ from: e.from, to: e.to }, d, l) && (e.from = n, e.to = void 0), o || m(e), o?.(e, n, u, a), e;
    },
    isSelected: (n) => t && R(t, n, !1, l)
  };
}
export {
  b as useRange
};
