"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 vertical_embed_viewer_exports = {};
__export(vertical_embed_viewer_exports, {
  VerticalEmbedViewer: () => VerticalEmbedViewer
});
module.exports = __toCommonJS(vertical_embed_viewer_exports);
var import_classnames = __toESM(require("classnames"));
var import_react = __toESM(require("react"));
var import_ricos_context = require("./../../ricos-context/index.js");
var import_ricos_types = require("./../../ricos-types/index.js");
var import_wix_rich_content_common = require("./../../wix-rich-content-common/index.js");
var import_card = require("../components/card.js");
var import_data_hooks = require("../data-hooks.js");
var import_types = require("../types.js");
var import_vertical_embed_styles = require("./vertical-embed-styles.js");
var import_vertical_embed_viewer_scss = __toESM(require("./vertical-embed-viewer-scss.js"));
const VerticalEmbedViewer = ({
  settings,
  componentData,
  helpers,
  nodeId
}) => {
  const { t, locale, tabIndex } = (0, import_react.useContext)(import_ricos_context.RicosContext);
  const isEditor = tabIndex === -1;
  const url = settings.changeBaseUrl ? settings.changeBaseUrl(componentData.url) : componentData.url;
  const onClick = () => helpers?.onViewerAction?.(import_types.VERTICAL_EMBED_TYPE, "Click", componentData.type, nodeId, {
    type: import_ricos_types.Node_Type.APP_EMBED,
    appEmbedData: componentData
  });
  const shouldHandleClick = !!helpers?.onViewerAction;
  const handleClick = (e) => {
    if (!shouldHandleClick) {
      e.preventDefault();
      e.stopPropagation();
      return;
    }
    onClick();
    if (url && !isEditor) {
      window.open(url, "_blank", "noreferrer");
    }
  };
  const handleKeyDown = (e) => {
    if (e.key === "Enter" || e.key === " ") {
      e.preventDefault();
      handleClick(e);
    }
  };
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)(
        import_vertical_embed_viewer_scss.default.card,
        (0, import_vertical_embed_styles.generateVerticalEmbedClasses)(componentData, settings, import_vertical_embed_viewer_scss.default)
      ),
      "data-hook": import_data_hooks.ROOT,
      "data-url": url,
      onClick: handleClick,
      onKeyDown: handleKeyDown,
      style: (0, import_vertical_embed_styles.generateVerticalEmbedStyles)(componentData, settings),
      tabIndex: isEditor ? -1 : tabIndex,
      role: "button",
      "aria-label": componentData.name,
      title: componentData.name
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_card.Card,
      {
        componentData,
        url,
        title: componentData.name,
        image: componentData?.hideImage ? void 0 : componentData.image,
        buttonText: componentData?.buttonStyles?.buttonText || t(
          {
            PRODUCT: "VerticalEmbed_Products_Button",
            EVENT: "VerticalEmbed_Events_Button",
            BOOKING: "VerticalEmbed_Bookings_Button"
          }[componentData.type]
        ),
        ribbonText: componentData.ribbonStyles?.ribbonText || t("VerticalEmbed_Ribbon"),
        direction: (0, import_wix_rich_content_common.getLangDir)(locale)
      }
    )
  );
};
//# sourceMappingURL=vertical-embed-viewer.js.map
