"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/Combobox/Option.tsx
var Option_exports = {};
__export(Option_exports, {
  Option: () => Option
});
module.exports = __toCommonJS(Option_exports);
var import_react = require("react");
var import_dedupe = __toESM(require("classnames/dedupe"));

// src/components/Combobox/utils.tsx
var getOptionValue = (option) => typeof option === "string" ? option : option?.value;
var getOptionLabel = (option) => typeof option === "string" ? option : option?.label;
var buildOptionTestId = (prefix, value) => `${prefix}-${value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "")}`;

// src/components/Combobox/Option.tsx
var import_jsx_runtime = require("react/jsx-runtime");
var Option = ({
  option,
  isHighlighted,
  onOptionSelect,
  optionComponent: OptionComponent,
  optionTestIdPrefix,
  id
}) => {
  const optionRef = (0, import_react.useRef)(null);
  const optionValue = getOptionValue(option) || "";
  const testId = buildOptionTestId(
    optionTestIdPrefix || "combobox-option",
    optionValue
  );
  (0, import_react.useEffect)(() => {
    if (isHighlighted && optionRef.current && optionRef.current.scrollIntoView) {
      optionRef.current.scrollIntoView({ block: "nearest" });
    }
  }, [isHighlighted]);
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    "li",
    {
      ref: optionRef,
      role: "option",
      "data-testid": testId,
      id,
      "aria-selected": isHighlighted,
      onMouseDown: () => onOptionSelect(option),
      className: (0, import_dedupe.default)("mobius-combobox__option", "has-pii", {
        "mobius-combobox__option--is-highlighted": isHighlighted
      }),
      children: OptionComponent ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OptionComponent, { option, isHighlighted }) : getOptionLabel(option)
    },
    getOptionValue(option)
  );
};
//# sourceMappingURL=Option.js.map
