/* index.tsx generated by @compiled/babel-plugin v0.39.1 */
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.toDateLozengeProps = exports.default = void 0;
require("./index.compiled.css");
var React = _interopRequireWildcard(require("react"));
var _runtime = require("@compiled/react/runtime");
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _reactIntl = require("react-intl");
var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _tag = require("@atlaskit/tag");
var _flexibleUiContext = require("../../../../../../state/flexible-ui-context");
var _lozengeAction = _interopRequireDefault(require("./lozenge-action"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var styles = null;
var dueOnStyles = 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,
    className = _ref.className,
    maxWidth = _ref.maxWidth,
    name = _ref.name,
    onAfterChanged = _ref.onAfterChanged,
    style = _ref.style,
    text = _ref.text,
    _ref$testId = _ref.testId,
    testId = _ref$testId === void 0 ? 'smart-element-lozenge' : _ref$testId,
    isDateTag = _ref.isDateTag,
    trailingMetric = _ref.trailingMetric;
  var ui = (0, _flexibleUiContext.useFlexibleUiOptionContext)();
  if (!text) {
    return null;
  }
  var lozenge = action ? /*#__PURE__*/React.createElement(_lozengeAction.default, (0, _extends2.default)({
    action: action,
    appearance: appearance,
    maxWidth: maxWidth,
    testId: testId,
    text: text,
    zIndex: ui === null || ui === void 0 ? void 0 : ui.zIndex,
    onAfterChanged: onAfterChanged
  }, trailingMetric && (0, _platformFeatureFlags.fg)('platform-dst-lozenge-tag-badge-visual-uplifts') ? {
    trailingMetric: trailingMetric
  } : undefined)) : isDateTag ? /*#__PURE__*/React.createElement(_tag.SimpleTag, {
    text: text,
    migration_fallback: "lozenge"
  }) : /*#__PURE__*/React.createElement(_lozenge.default, (0, _extends2.default)({
    appearance: appearance,
    isBold: true,
    maxWidth: maxWidth
    // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
    ,
    style: style,
    testId: "".concat(testId, "-lozenge")
  }, trailingMetric && (0, _platformFeatureFlags.fg)('platform-dst-lozenge-tag-badge-visual-uplifts') ? {
    trailingMetric: trailingMetric
  } : undefined), 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: (0, _runtime.ax)(["_1e0c116y _1ul91ns9", isDateTag && (0, _platformFeatureFlags.fg)('platform-dst-lozenge-tag-badge-visual-uplifts') && "_19pkr5cr _2hwxr5cr _otyrr5cr _18u0r5cr", className])
  }, lozenge);
};
var _default = exports.default = BaseLozengeElement;
var toDateLozengeProps = exports.toDateLozengeProps = function toDateLozengeProps(dateString) {
  if (dateString) {
    var text = Date.parse(dateString) ? /*#__PURE__*/React.createElement(_reactIntl.FormattedDate, {
      value: new Date(dateString),
      year: "numeric",
      month: "short",
      day: "numeric",
      formatMatcher: "best fit"
    }) : dateString;
    return {
      text: text
    };
  }
};