"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);
var list_item_select_exports = {};
__export(list_item_select_exports, {
  ListItemSelect: () => ListItemSelect
});
module.exports = __toCommonJS(list_item_select_exports);
var import_design_system = require("@wix/design-system");
var import_classnames = __toESM(require("classnames"));
var import_react = __toESM(require("react"));
var import_ricos_context = require("./../../ricos-context/index.js");
var import_data_hooks = require("./data-hooks.js");
var import_list_item_select_scss = __toESM(require("./list-item-select-scss.js"));
const ListItemSelect = ({
  title,
  subtitle,
  prefix,
  suffix,
  dataHook,
  selected = false,
  disabled = false,
  onSelect,
  className,
  tooltip,
  ...props
}) => {
  const { isMobile } = (0, import_react.useContext)(import_ricos_context.RicosContext);
  const listItemSelect = /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)(import_list_item_select_scss.default.root, className, {
        [import_list_item_select_scss.default.selected]: selected,
        [import_list_item_select_scss.default.disabled]: disabled,
        [import_list_item_select_scss.default.mobile]: isMobile,
        [import_list_item_select_scss.default.withSubtitle]: !!subtitle
      }),
      "data-hook": (0, import_classnames.default)(import_data_hooks.LIST_ITEM_SELECT, dataHook),
      role: "option",
      "aria-selected": selected,
      "aria-disabled": disabled,
      tabIndex: disabled ? -1 : 0,
      onClick: (e) => {
        if (disabled) {
          return;
        }
        e.stopPropagation();
        onSelect?.(e);
      },
      onKeyDown: (e) => {
        if (disabled) {
          return;
        }
        if (e.key === "Enter" || e.key === " ") {
          e.stopPropagation();
          e.preventDefault();
          onSelect?.(e);
        }
      },
      ...props
    },
    /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: (0, import_classnames.default)(import_list_item_select_scss.default.content, {
          [import_list_item_select_scss.default.withSubtitle]: !!subtitle
        })
      },
      prefix && /* @__PURE__ */ import_react.default.createElement("div", { className: import_list_item_select_scss.default.prefix, "data-hook": import_data_hooks.LIST_ITEM_SELECT_PREFIX }, prefix),
      title && /* @__PURE__ */ import_react.default.createElement(
        import_design_system.Text,
        {
          size: isMobile ? "medium" : "small",
          className: import_list_item_select_scss.default.title,
          skin: disabled ? "disabled" : "standard",
          dataHook: import_data_hooks.LIST_ITEM_SELECT_TITLE
        },
        title
      ),
      subtitle && /* @__PURE__ */ import_react.default.createElement(
        import_design_system.Text,
        {
          size: isMobile ? "small" : "tiny",
          secondary: true,
          className: import_list_item_select_scss.default.subtitle,
          skin: disabled ? "disabled" : "standard",
          dataHook: import_data_hooks.LIST_ITEM_SELECT_SUBTITLE
        },
        subtitle
      ),
      suffix && /* @__PURE__ */ import_react.default.createElement("div", { className: import_list_item_select_scss.default.suffix, "data-hook": import_data_hooks.LIST_ITEM_SELECT_SUFFIX }, suffix)
    )
  );
  return tooltip ? /* @__PURE__ */ import_react.default.createElement(import_design_system.Tooltip, { content: tooltip, size: "small", moveBy: { y: 8 } }, listItemSelect) : listItemSelect;
};
//# sourceMappingURL=list-item-select.js.map
