"use strict";

exports.__esModule = true;
exports.ptLabel = exports.default = exports.Placeholder = void 0;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _styledComponents = _interopRequireWildcard(require("styled-components"));
var _utils = require("../utils");
var _withErrorBoundary = _interopRequireDefault(require("../hocs/withErrorBoundary"));
var _useLabelMessage3 = _interopRequireDefault(require("../hooks/useLabelMessage"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var fadeCycle = (0, _styledComponents.keyframes)(["0%{opacity:0.3;}100%{opacity:0.7;}"]);
var Placeholder = exports.Placeholder = _styledComponents.default.span.withConfig({
  displayName: "Text__Placeholder",
  componentId: "sc-w7v8js-0"
})(["display:inline-block;height:1em;width:6em;border-radius:0.5em;background-color:", ";animation:", " 3s infinite alternate;"], (0, _utils.getThemeProp)(["colors", "textMedium"], "#999999"), fadeCycle);
var Text = function Text(_ref) {
  var rawMessage = _ref.message,
    error = _ref.error;
  var _useLabelMessage = (0, _useLabelMessage3.default)(rawMessage),
    _useLabelMessage2 = _slicedToArray(_useLabelMessage, 2),
    labelMessage = _useLabelMessage2[0],
    missingValues = _useLabelMessage2[1];
  if (error || !rawMessage && rawMessage !== "") {
    return /*#__PURE__*/_react.default.createElement("span", {
      style: {
        color: "red",
        backgroundColor: "white",
        fontWeight: "bold"
      }
    }, "Errored: ", error && error.message ? error.message : "No message provided");
  }
  if (missingValues) {
    return /*#__PURE__*/_react.default.createElement(Placeholder, null);
  }
  return labelMessage;
};
__signature__(Text, "useLabelMessage{[labelMessage, missingValues]}", function () {
  return [_useLabelMessage3.default];
});
__signature__(Text, "useLabelMessage{[labelMessage, missingValues]}", function () {
  return [_useLabelMessage3.default];
});
var ptLabel = exports.ptLabel = _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.shape({
  id: _propTypes.default.string.isRequired,
  defaultMessage: _propTypes.default.string.isRequired
})]);
Text.propTypes = {
  message: ptLabel
};
var _default = (0, _withErrorBoundary.default)("Text")(Text);
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(fadeCycle, "fadeCycle", "/home/vsts/work/1/s/src/components/Text.js");
  reactHotLoader.register(Placeholder, "Placeholder", "/home/vsts/work/1/s/src/components/Text.js");
  reactHotLoader.register(Text, "Text", "/home/vsts/work/1/s/src/components/Text.js");
  reactHotLoader.register(ptLabel, "ptLabel", "/home/vsts/work/1/s/src/components/Text.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/Text.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(fadeCycle, "fadeCycle", "/home/vsts/work/1/s/src/components/Text.js");
  reactHotLoader.register(Placeholder, "Placeholder", "/home/vsts/work/1/s/src/components/Text.js");
  reactHotLoader.register(Text, "Text", "/home/vsts/work/1/s/src/components/Text.js");
  reactHotLoader.register(ptLabel, "ptLabel", "/home/vsts/work/1/s/src/components/Text.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/Text.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();