"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.LozengeComponent = exports.ICON_SIZE = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = require("react");
var _react2 = require("@emotion/react");
var _file = _interopRequireDefault(require("@atlaskit/icon/core/file"));
var _styles = require("../styles");
var _EditToggle = require("./EditToggle");
var _ExtensionLabel = require("./ExtensionLabel");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
 * @jsxRuntime classic
 * @jsx jsx
 */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
var ICON_SIZE = exports.ICON_SIZE = 24;
var capitalizeFirstLetter = function capitalizeFirstLetter(str) {
  return str.charAt(0).toUpperCase() + str.slice(1);
};
var LozengeComponent = exports.LozengeComponent = function LozengeComponent(_ref) {
  var lozengeData = _ref.lozengeData,
    extensionName = _ref.extensionName,
    title = _ref.title,
    params = _ref.params,
    renderImage = _ref.renderImage,
    showMacroInteractionDesignUpdates = _ref.showMacroInteractionDesignUpdates,
    customContainerStyles = _ref.customContainerStyles,
    isNodeHovered = _ref.isNodeHovered,
    isNodeNested = _ref.isNodeNested,
    setIsNodeHovered = _ref.setIsNodeHovered,
    isBodiedMacro = _ref.isBodiedMacro,
    showLivePagesBodiedMacrosRendererView = _ref.showLivePagesBodiedMacrosRendererView,
    showUpdatedLivePages1PBodiedExtensionUI = _ref.showUpdatedLivePages1PBodiedExtensionUI,
    showBodiedExtensionRendererView = _ref.showBodiedExtensionRendererView,
    setShowBodiedExtensionRendererView = _ref.setShowBodiedExtensionRendererView,
    pluginInjectionApi = _ref.pluginInjectionApi;
  var capitalizedTitle = capitalizeFirstLetter(title);
  if (showMacroInteractionDesignUpdates) {
    return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_ExtensionLabel.ExtensionLabel, {
      text: capitalizedTitle,
      extensionName: extensionName,
      isNodeHovered: isNodeHovered,
      isNodeNested: isNodeNested,
      customContainerStyles: customContainerStyles,
      setIsNodeHovered: setIsNodeHovered,
      isBodiedMacro: isBodiedMacro,
      showLivePagesBodiedMacrosRendererView: showLivePagesBodiedMacrosRendererView,
      showUpdatedLivePages1PBodiedExtensionUI: showUpdatedLivePages1PBodiedExtensionUI,
      showBodiedExtensionRendererView: showBodiedExtensionRendererView,
      pluginInjectionApi: pluginInjectionApi
    }), showLivePagesBodiedMacrosRendererView && isBodiedMacro && (0, _react2.jsx)(_EditToggle.EditToggle, {
      isNodeHovered: isNodeHovered,
      setIsNodeHovered: setIsNodeHovered,
      customContainerStyles: customContainerStyles,
      showBodiedExtensionRendererView: showBodiedExtensionRendererView,
      setShowBodiedExtensionRendererView: setShowBodiedExtensionRendererView
    }));
  }
  var isBlockExtension = extensionName === 'extension';
  return (
    // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
    (0, _react2.jsx)("div", {
      "data-testid": "lozenge-fallback",
      css: _styles.placeholderFallback
    }, lozengeData && !isBlockExtension ? renderImage(_objectSpread({
      height: ICON_SIZE,
      width: ICON_SIZE
    }, lozengeData)) : (0, _react2.jsx)(_file.default, {
      label: title
    }), (0, _react2.jsx)("span", {
      className: "extension-title"
    }, capitalizedTitle), params && !isBlockExtension &&
    // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
    (0, _react2.jsx)("span", {
      css: _styles.placeholderFallbackParams
    }, Object.keys(params).map(function (key) {
      return key && " | ".concat(key, " = ").concat(params[key].value);
    })))
  );
};