"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);

// src/components/Combobox/utils.tsx
var utils_exports = {};
__export(utils_exports, {
  buildOptionTestId: () => buildOptionTestId,
  clamp: () => clamp,
  filterOptions: () => filterOptions,
  getOptionLabel: () => getOptionLabel,
  getOptionValue: () => getOptionValue,
  isOptionGroup: () => isOptionGroup
});
module.exports = __toCommonJS(utils_exports);
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, "")}`;
//# sourceMappingURL=utils.js.map
