/* index.tsx generated by @compiled/babel-plugin v0.38.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';
var styles = null;
/**
 * A base element that displays a Lozenge.
 * @internal
 * @param {BaseLozengeElementProps} BaseLozengeElementProps - The props necessary for the Lozenge element.
 * @see State
 */
var BaseLozengeElement = function BaseLozengeElement(_ref) {
  var action = _ref.action,
    _ref$appearance = _ref.appearance,
    appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
    name = _ref.name,
    className = _ref.className,
    style = _ref.style,
    text = _ref.text,
    _ref$testId = _ref.testId,
    testId = _ref$testId === void 0 ? 'smart-element-lozenge' : _ref$testId,
    onAfterChanged = _ref.onAfterChanged;
  var ui = useFlexibleUiOptionContext();
  if (!text) {
    return null;
  }
  var lozenge = action ? /*#__PURE__*/React.createElement(LozengeAction, {
    action: action,
    appearance: appearance,
    testId: testId,
    text: text,
    zIndex: ui === null || ui === void 0 ? void 0 : ui.zIndex,
    onAfterChanged: onAfterChanged
  }) : /*#__PURE__*/React.createElement(AtlaskitLozenge, _extends({
    appearance: appearance
  }, fg('platform-component-visual-refresh') ? {
    isBold: true
  } : undefined, {
    // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
    style: style,
    testId: "".concat(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 var toDateLozengeProps = function toDateLozengeProps(dateString) {
  if (dateString) {
    var text = Date.parse(dateString) ? /*#__PURE__*/React.createElement(FormattedDate, {
      value: new Date(dateString),
      year: "numeric",
      month: "short",
      day: "numeric",
      formatMatcher: "best fit"
    }) : dateString;
    return {
      text: text
    };
  }
};