"use strict";

exports.__esModule = true;
exports.createMuiTheme = exports.TestWrapper = exports.PropStruct = void 0;
exports.extractMessages = extractMessages;
exports.spyOnConsole = exports.ignoreConsoleError = exports.getStyledClassSelector = exports.getElmClasses = exports.getClassSelector = exports.getClassName = exports.generateClassName = exports.firstItemComparator = void 0;
var _react = _interopRequireDefault(require("react"));
var _styledComponents = require("styled-components");
var _unexpectedReaction = require("unexpected-reaction");
var _muiThemes = _interopRequireDefault(require("./../components/MaterialUI/muiThemes"));
var _reactRouterDom = require("react-router-dom");
var _core = require("@material-ui/core");
var _styles = require("@material-ui/core/styles");
var _reactIntl = require("react-intl");
var _reactRedux = require("react-redux");
var _NotificationContext = require("./../components/MaterialUI/Feedback/NotificationContext");
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 sinon = require("sinon");

/* istanbul ignore next */
var spyOnConsole = exports.spyOnConsole = function spyOnConsole(spyNames) {
  if (spyNames === void 0) {
    spyNames = ["log", "warn", "error"];
  }
  var spiedFuncs;
  // eslint-disable-next-line no-undef
  beforeEach(function () {
    spiedFuncs = spyNames.map(function (funcName) {
      var func = sinon.spy().named("console." + funcName);
      var oldFunc = console[funcName];
      console[funcName] = func;
      return oldFunc;
    });
  });
  // eslint-disable-next-line no-undef
  afterEach(function () {
    spiedFuncs.forEach(function (func, index) {
      var name = spyNames[index];
      console[name] = func;
    });
  });
};
var getElmClasses = exports.getElmClasses = function getElmClasses(reactElm, container) {
  var domElm = (0, _unexpectedReaction.mount)(reactElm, container ? {
    container: container
  } : undefined);
  var classes = domElm.getAttribute("class");
  if (!classes) {
    throw new Error("Class name not found in <" + (reactElm.type.name || reactElm.type) + " />");
  }
  return classes.split(" ");
};
var getClassName = exports.getClassName = function getClassName(reactElm, index, container) {
  if (index === void 0) {
    index = 0;
  }
  var classes = getElmClasses(reactElm, container);
  return classes[index] || "";
};
var getClassSelector = exports.getClassSelector = function getClassSelector(elm, index, container) {
  if (index < 0) {
    return "." + getElmClasses(elm, container).join(".");
  } else {
    var className = getClassName(elm, index, container) || "";
    return className && "." + className;
  }
};
var getStyledClassSelector = exports.getStyledClassSelector = function getStyledClassSelector(elm) {
  var component = elm.type || elm;
  if (!(0, _styledComponents.isStyledComponent)(component)) {
    throw new Error("<" + (component.name || component) + " /> is not a styled component");
  }
  // Styled component toString() function returns a stable class name
  return component.toString();
};
var firstItemComparator = exports.firstItemComparator = function firstItemComparator(a, b) {
  return a[0] > b[0] ? 1 : a[0] < b[0] ? -1 : 0;
};
var PropStruct = exports.PropStruct = _react.default.forwardRef(function (props, ref) {
  return (
    /*#__PURE__*/
    // TODO: Handle refs sensibly instead of ignoring?
    _react.default.createElement("dl", {
      id: props.id
    }, Object.entries(props).sort(firstItemComparator).map(function (_ref) {
      var _ref2 = _slicedToArray(_ref, 2),
        key = _ref2[0],
        value = _ref2[1];
      return value === undefined || value === null ? null : value === "__ignore" ? [/*#__PURE__*/_react.default.createElement(_unexpectedReaction.Ignore, {
        key: "dt-" + key
      }), /*#__PURE__*/_react.default.createElement(_unexpectedReaction.Ignore, {
        key: "dd-" + key
      })] : [/*#__PURE__*/_react.default.createElement("dt", {
        key: "dt-" + key
      }, "".concat(key, ":")), /*#__PURE__*/_react.default.createElement("dd", {
        key: "dd-" + key
      }, key === "children" ? value : typeof value === "object" ? value["$$typeof"] && value["$$typeof"] === Symbol.for("react.element") ? "React <" + (value.type.name || value.type) + ">" : /*#__PURE__*/_react.default.createElement(PropStruct, value) : typeof value === "function" ? "Function" : typeof value === "string" ? "string \"".concat(value, "\"") : typeof value === "symbol" ? "symbol ".concat(value.toString()) : typeof value + " " + value)];
    }))
  );
});
var ignoreConsoleError = exports.ignoreConsoleError = function ignoreConsoleError(func) {
  // eslint-disable-next-line no-undef
  jest.spyOn(console, "error");
  console.error.mockImplementation(function () {});
  func();
  console.error.mockRestore();
};
var createMuiTheme = exports.createMuiTheme = function createMuiTheme() {
  var applicationTheme = {
    primary: {
      main: "#1F5B7F"
    }
  };
  var themeDefinition = {
    palette: {
      primary: {
        lighter: "#f5f5f5",
        light: "#CCC",
        main: "#232323",
        dark: "#000",
        contrastText: "#fff"
      }
    }
  };
  var themes = (0, _muiThemes.default)(applicationTheme, themeDefinition);
  var muiTheme = themes.muiTheme;
  return muiTheme;
};
var generateClassName = exports.generateClassName = function generateClassName(rule, styleSheet) {
  return "".concat(styleSheet.options.classNamePrefix, "-").concat(rule.key);
};
function extractMessages() {
  var extractedMessages = {};
  for (var i = 0; i < arguments.length; i++) {
    var messages = arguments[i];
    for (var property in messages) {
      var message = messages[property];
      extractedMessages[message.id] = message.defaultMessage;
    }
  }
  return extractedMessages;
}

/* istanbul ignore next */
function DefaultLocale() {}
Intl.Locale = DefaultLocale;
var TestWrapper = exports.TestWrapper = function TestWrapper(_ref3) {
  var provider = _ref3.provider,
    intlProvider = _ref3.intlProvider,
    router = _ref3.router,
    memoryRouter = _ref3.memoryRouter,
    stylesProvider = _ref3.stylesProvider,
    muiThemeProvider = _ref3.muiThemeProvider,
    children = _ref3.children;
  var ProviderWrapper = function ProviderWrapper(_ref4) {
    var children = _ref4.children;
    if (provider == null) return children;
    return /*#__PURE__*/_react.default.createElement(_reactRedux.Provider, {
      store: provider.store
    }, children);
  };
  var IntlProvderWrapper = function IntlProvderWrapper(_ref5) {
    var _intlProvider$locale, _intlProvider$timeZon;
    var children = _ref5.children;
    if (intlProvider == null) return children;
    return /*#__PURE__*/_react.default.createElement(_reactIntl.IntlProvider, {
      locale: (_intlProvider$locale = intlProvider.locale) != null ? _intlProvider$locale : "en-US",
      timeZone: (_intlProvider$timeZon = intlProvider.timeZone) != null ? _intlProvider$timeZon : "UTC",
      messages: intlProvider.messages
    }, children);
  };
  var StylesProviderWrapper = function StylesProviderWrapper(_ref6) {
    var children = _ref6.children;
    if (stylesProvider == null) return children;
    return /*#__PURE__*/_react.default.createElement(_styles.StylesProvider, {
      generateClassName: generateClassName
    }, children);
  };
  var MuiThemeProviderWrapper = function MuiThemeProviderWrapper(_ref7) {
    var _muiThemeProvider$the;
    var children = _ref7.children;
    if (muiThemeProvider == null) return children;
    var theme = (_muiThemeProvider$the = muiThemeProvider.theme) != null ? _muiThemeProvider$the : createMuiTheme();
    return /*#__PURE__*/_react.default.createElement(_core.MuiThemeProvider, {
      theme: theme
    }, children);
  };
  var MemoryRouterWrapper = function MemoryRouterWrapper(_ref8) {
    var children = _ref8.children;
    if (memoryRouter == null) return children;
    return /*#__PURE__*/_react.default.createElement(_reactRouterDom.MemoryRouter, {
      initialEntries: memoryRouter.initialEntries
    }, children);
  };
  var RouterWrapper = function RouterWrapper(_ref9) {
    var children = _ref9.children;
    if (router == null) return children;
    return /*#__PURE__*/_react.default.createElement(_reactRouterDom.Router, {
      history: router.history
    }, children);
  };
  return /*#__PURE__*/_react.default.createElement(ProviderWrapper, null, /*#__PURE__*/_react.default.createElement(RouterWrapper, null, /*#__PURE__*/_react.default.createElement(MemoryRouterWrapper, null, /*#__PURE__*/_react.default.createElement(IntlProvderWrapper, null, /*#__PURE__*/_react.default.createElement(StylesProviderWrapper, null, /*#__PURE__*/_react.default.createElement(MuiThemeProviderWrapper, null, /*#__PURE__*/_react.default.createElement(_NotificationContext.NotificationContextProvider, null, children)))))));
};
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(spyOnConsole, "spyOnConsole", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(getElmClasses, "getElmClasses", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(getClassName, "getClassName", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(getClassSelector, "getClassSelector", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(getStyledClassSelector, "getStyledClassSelector", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(firstItemComparator, "firstItemComparator", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(PropStruct, "PropStruct", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(ignoreConsoleError, "ignoreConsoleError", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(createMuiTheme, "createMuiTheme", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(generateClassName, "generateClassName", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(extractMessages, "extractMessages", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(DefaultLocale, "DefaultLocale", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(TestWrapper, "TestWrapper", "/home/vsts/work/1/s/src/utils/testUtils.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(spyOnConsole, "spyOnConsole", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(getElmClasses, "getElmClasses", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(getClassName, "getClassName", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(getClassSelector, "getClassSelector", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(getStyledClassSelector, "getStyledClassSelector", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(firstItemComparator, "firstItemComparator", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(PropStruct, "PropStruct", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(ignoreConsoleError, "ignoreConsoleError", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(createMuiTheme, "createMuiTheme", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(generateClassName, "generateClassName", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(extractMessages, "extractMessages", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(DefaultLocale, "DefaultLocale", "/home/vsts/work/1/s/src/utils/testUtils.js");
  reactHotLoader.register(TestWrapper, "TestWrapper", "/home/vsts/work/1/s/src/utils/testUtils.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();