/**
 * @jsxRuntime classic
 * @jsx jsx
 */

import { Fragment } from 'react';

// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports -- Ignored via go/DSP-18766; jsx required at runtime for @jsxRuntime classic
import { jsx } from '@emotion/react';
import EditorFileIcon from '@atlaskit/icon/core/file';
import { placeholderFallback, placeholderFallbackParams } from '../styles';
import { EditToggle } from './EditToggle';
import { ExtensionLabel } from './ExtensionLabel';
export const ICON_SIZE = 24;
const capitalizeFirstLetter = str => {
  return str.charAt(0).toUpperCase() + str.slice(1);
};
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
export const LozengeComponent = ({
  lozengeData,
  extensionName,
  title,
  params,
  renderImage,
  showMacroInteractionDesignUpdates,
  customContainerStyles,
  isNodeHovered,
  isNodeNested,
  isNodeSelected,
  setIsNodeHovered,
  isBodiedMacro,
  showLivePagesBodiedMacrosRendererView,
  showUpdatedLivePages1PBodiedExtensionUI,
  showBodiedExtensionRendererView,
  setShowBodiedExtensionRendererView,
  pluginInjectionApi,
  isMultiBodiedMacro
}) => {
  const capitalizedTitle = capitalizeFirstLetter(title);
  if (showMacroInteractionDesignUpdates) {
    return jsx(Fragment, null, jsx(ExtensionLabel, {
      text: capitalizedTitle,
      extensionName: extensionName,
      isNodeHovered: isNodeHovered,
      isNodeNested: isNodeNested,
      isNodeSelected: isNodeSelected,
      customContainerStyles: customContainerStyles,
      setIsNodeHovered: setIsNodeHovered,
      isBodiedMacro: isBodiedMacro,
      showLivePagesBodiedMacrosRendererView: showLivePagesBodiedMacrosRendererView,
      showUpdatedLivePages1PBodiedExtensionUI: showUpdatedLivePages1PBodiedExtensionUI,
      showBodiedExtensionRendererView: showBodiedExtensionRendererView,
      pluginInjectionApi: pluginInjectionApi,
      isMultiBodiedMacro: isMultiBodiedMacro
    }), showLivePagesBodiedMacrosRendererView && isBodiedMacro && jsx(EditToggle, {
      isNodeHovered: isNodeHovered,
      setIsNodeHovered: setIsNodeHovered,
      customContainerStyles: customContainerStyles,
      showBodiedExtensionRendererView: showBodiedExtensionRendererView,
      setShowBodiedExtensionRendererView: setShowBodiedExtensionRendererView
    }));
  }
  const 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
    jsx("div", {
      "data-testid": "lozenge-fallback",
      css: placeholderFallback
    }, lozengeData && !isBlockExtension ? renderImage({
      height: ICON_SIZE,
      width: ICON_SIZE,
      ...lozengeData
    }) : jsx(EditorFileIcon, {
      label: title
    }), 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
    jsx("span", {
      css: placeholderFallbackParams
    }, Object.keys(params).map(key => key && ` | ${key} = ${params[key].value}`)))
  );
};