// src/components/Combobox/utils.tsx
function isOptionGroup(options) {
  if (!options) return false;
  return typeof options[0] === "object" && "options" in options[0] && options[0].options !== void 0 && "heading" in options[0] && options[0].heading !== void 0;
}
var getOptionValue = (option) => typeof option === "string" ? option : option?.value;
var getOptionLabel = (option) => typeof option === "string" ? option : option?.label;
function filterOptions(options, inputValue) {
  if (isOptionGroup(options)) {
    return options.map((optionGroup) => ({
      ...optionGroup,
      options: optionGroup.options.filter(
        (option) => getOptionLabel(option).toLowerCase().includes(inputValue.toLowerCase())
      )
    })).filter((optionGroup) => optionGroup.options.length > 0);
  }
  return options.filter(
    (option) => getOptionLabel(option).toLowerCase().includes(inputValue.toLowerCase())
  );
}
function clamp(value, min, max) {
  return Math.min(Math.max(value, min), max);
}
var buildOptionTestId = (prefix, value) => `${prefix}-${value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "")}`;

export {
  isOptionGroup,
  getOptionValue,
  getOptionLabel,
  filterOptions,
  clamp,
  buildOptionTestId
};
//# sourceMappingURL=chunk-2JLZNSLY.js.map
