/* index.tsx generated by @compiled/babel-plugin v0.39.1 */
import _extends from "@babel/runtime/helpers/extends";
import "./index.compiled.css";
import * as React from 'react';
import { ax, ix } from "@compiled/react/runtime";
import { FormattedDate } from 'react-intl-next';
import AtlaskitLozenge from '@atlaskit/lozenge';
import { fg } from '@atlaskit/platform-feature-flags';
import { useFlexibleUiOptionContext } from '../../../../../../state/flexible-ui-context';
import LozengeAction from './lozenge-action';
const styles = null;
/**
 * A base element that displays a Lozenge.
 * @internal
 * @param {BaseLozengeElementProps} BaseLozengeElementProps - The props necessary for the Lozenge element.
 * @see State
 */
const BaseLozengeElement = ({
  action,
  appearance = 'default',
  className,
  maxWidth,
  name,
  onAfterChanged,
  style,
  text,
  testId = 'smart-element-lozenge'
}) => {
  const ui = useFlexibleUiOptionContext();
  if (!text) {
    return null;
  }
  const lozenge = action ? /*#__PURE__*/React.createElement(LozengeAction, _extends({
    action: action,
    appearance: appearance
  }, fg('platform_navx_sl_lozenge_max_width') ? {
    maxWidth
  } : undefined, {
    testId: testId,
    text: text,
    zIndex: ui === null || ui === void 0 ? void 0 : ui.zIndex,
    onAfterChanged: onAfterChanged
  })) : /*#__PURE__*/React.createElement(AtlaskitLozenge, _extends({
    appearance: appearance,
    isBold: true
  }, fg('platform_navx_sl_lozenge_max_width') ? {
    maxWidth
  } : undefined, {
    // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
    style: style,
    testId: `${testId}-lozenge`
  }), text);
  return /*#__PURE__*/React.createElement("span", {
    "data-smart-element": name,
    "data-smart-element-lozenge": true,
    "data-testid": testId
    // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
    ,
    className: ax(["_1e0c116y _1ul91ns9", className])
  }, lozenge);
};
export default BaseLozengeElement;
export const toDateLozengeProps = dateString => {
  if (dateString) {
    const text = Date.parse(dateString) ? /*#__PURE__*/React.createElement(FormattedDate, {
      value: new Date(dateString),
      year: "numeric",
      month: "short",
      day: "numeric",
      formatMatcher: "best fit"
    }) : dateString;
    return {
      text
    };
  }
};