"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireDefault(require("react"));
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _constants = require("../../../../../constants");
var _flexibleUiContext = require("../../../../../state/flexible-ui-context");
var _common = require("../common");
var _resourceTypeToLabel2 = require("./resourceTypeToLabel");
var LinkIconElement = function LinkIconElement(props) {
  var context = (0, _flexibleUiContext.useFlexibleUiContext)();
  if (!context) {
    return null;
  }
  if ((0, _platformFeatureFlags.fg)('platform_navx_smart_link_icon_label_a11y')) {
    var _ref, _resourceTypeToLabel, _context$meta, _linkIconProps$label;
    var linkIconProps = (0, _common.toLinkIconProps)(context === null || context === void 0 ? void 0 : context.linkIcon, context.type);
    if (!linkIconProps) {
      return null;
    }
    var label = (_ref = (_resourceTypeToLabel = (0, _resourceTypeToLabel2.resourceTypeToLabel)((_context$meta = context.meta) === null || _context$meta === void 0 ? void 0 : _context$meta.resourceType)) !== null && _resourceTypeToLabel !== void 0 ? _resourceTypeToLabel : (_linkIconProps$label = linkIconProps.label) === null || _linkIconProps$label === void 0 ? void 0 : _linkIconProps$label.trim()) !== null && _ref !== void 0 ? _ref : props.label;
    return /*#__PURE__*/_react.default.createElement(_common.BaseIconElement, (0, _extends2.default)({}, linkIconProps, props, {
      label: label,
      name: _constants.ElementName.LinkIcon
    }));
  }
  var data = (0, _common.toLinkIconProps)(context === null || context === void 0 ? void 0 : context.linkIcon, context.type);
  return data ? /*#__PURE__*/_react.default.createElement(_common.BaseIconElement, (0, _extends2.default)({}, data, props, {
    name: _constants.ElementName.LinkIcon
  })) : null;
};
var _default = exports.default = LinkIconElement;