"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 items_list_exports = {};
__export(items_list_exports, {
  ItemsList: () => ItemsList
});
module.exports = __toCommonJS(items_list_exports);
var import_design_system = require("@wix/design-system");
var import_react = __toESM(require("react"));
var import_ricos_context = require("./../../ricos-context/index.js");
var import_ui_components = require("./../../ui-components/index.js");
var import_convert_duration = require("../convert-duration.js");
var import_data_hooks = require("../data-hooks.js");
const ItemsList = ({
  items,
  onClick,
  selectedItem,
  contentType,
  modalRef,
  hasActiveSearch = false
}) => {
  const { t } = (0, import_react.useContext)(import_ricos_context.RicosContext);
  const zIndexService = (0, import_react.useContext)(import_ricos_context.ZIndexContext);
  if (items.length === 0) {
    const emptyStateSuffix = hasActiveSearch ? "NoResults" : "NoItems";
    return /* @__PURE__ */ import_react.default.createElement(import_design_system.Box, { direction: "vertical", margin: "SP4", gap: "SP2", textAlign: "center" }, /* @__PURE__ */ import_react.default.createElement(import_design_system.Text, { size: "medium", weight: "bold", secondary: true }, t(`Embed_Vertical_${contentType}_EmptyState_${emptyStateSuffix}_Title`)), /* @__PURE__ */ import_react.default.createElement(import_design_system.Text, { size: "small", secondary: true }, t(`Embed_Vertical_${contentType}_EmptyState_${emptyStateSuffix}_Description`)));
  }
  if (!modalRef) {
    return null;
  }
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, items.map((item) => {
    return /* @__PURE__ */ import_react.default.createElement(
      import_design_system.ListItemSelect,
      {
        size: "small",
        key: item.id,
        dataHook: import_data_hooks.INSERT_VERTICAL_EMBED_MODAL_ITEM,
        title: item.title,
        selected: selectedItem?.id === item.id,
        onClick: () => onClick(item),
        ellipsis: true,
        prefix: /* @__PURE__ */ import_react.default.createElement(import_design_system.Box, { width: "50px", height: "50px", margin: "6px 6px 6px 0" }, (item.image?.id || item.image?.url) && /* @__PURE__ */ import_react.default.createElement(
          import_ui_components.Image,
          {
            uri: item.image.id ?? item.image.url,
            width: 50,
            height: 50,
            displayMode: "fill",
            alt: item.title,
            shouldUseLQIP: false
          }
        )),
        subtitle: contentType === "Bookings" ? (0, import_convert_duration.convertDurations)(item.bookingDetails?.durations, t) || void 0 : contentType === "Events" ? `${item.eventDetails?.formattedDateAndTime} | ${item.eventDetails?.location}` : void 0,
        tooltipProps: {
          appendTo: modalRef,
          zIndex: zIndexService.getZIndex("TOOLTIP"),
          children: [],
          enterDelay: 1e3,
          placement: "top"
        }
      }
    );
  }));
};
//# sourceMappingURL=items-list.js.map
