"use strict";

require("core-js/modules/es.symbol");

require("core-js/modules/es.symbol.description");

require("core-js/modules/es.symbol.iterator");

require("core-js/modules/es.array.concat");

require("core-js/modules/es.array.for-each");

require("core-js/modules/es.array.is-array");

require("core-js/modules/es.array.iterator");

require("core-js/modules/es.array.join");

require("core-js/modules/es.array.some");

require("core-js/modules/es.function.name");

require("core-js/modules/es.object.define-property");

require("core-js/modules/es.object.keys");

require("core-js/modules/es.object.to-string");

require("core-js/modules/es.string.iterator");

require("core-js/modules/web.dom-collections.for-each");

require("core-js/modules/web.dom-collections.iterator");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.invariantTypesMatch = exports.shallowCompare = exports.fakeChangeEvent = exports.noop = exports.getDisplayName = void 0;

var _invariant = _interopRequireDefault(require("invariant"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

var getDisplayName = function getDisplayName(component) {
  return component.displayName || component.name || 'Component';
};

exports.getDisplayName = getDisplayName;

var noop =
/* istanbul ignore next */
function noop() {};

exports.noop = noop;

var fakeChangeEvent = function fakeChangeEvent(name, value) {
  return {
    preventDefault: noop,
    target: {
      name: name,
      value: value
    }
  };
};

exports.fakeChangeEvent = fakeChangeEvent;

var shallowCompare = function shallowCompare(nextObj, currObj) {
  var keysNext = Object.keys(nextObj);
  var keysCurr = Object.keys(currObj);
  return keysNext.length !== keysCurr.length || keysNext.some(function (next) {
    return nextObj[next] !== currObj[next];
  });
};

exports.shallowCompare = shallowCompare;

var invariantTypesMatch = function invariantTypesMatch(name, oldVal, newVal) {
  var changingType = false;

  if (oldVal === null || newVal === null || typeof oldVal === 'undefined' || typeof newVal === 'undefined') {
    return;
  }

  if (_typeof(oldVal) === 'object') {
    if (oldVal && newVal) {
      var c = 'constructor'; // Shorthand for constructor

      changingType = oldVal[c] && newVal[c] && oldVal[c] === newVal[c] ? false : "Cannot convert between two object types: ".concat(oldVal.constructor, " !== ").concat(newVal.constructor);

      if (changingType === false) {
        // Compare child values
        if (oldVal.constructor === {}.constructor) {
          Object.keys(oldVal).forEach(function (key) {
            return invariantTypesMatch(name.concat(key), oldVal[key], newVal[key]);
          });
        } else if (Array.isArray(oldVal)) {
          oldVal.forEach(function (_, i) {
            return invariantTypesMatch(name.concat(i), oldVal[i], newVal[i]);
          });
        }
      }
    }
  } else {
    changingType = _typeof(oldVal) !== _typeof(newVal) ? "Cannot convert ".concat(name.join('.'), " from ").concat(_typeof(oldVal), " to ").concat(_typeof(newVal)) : false;
  }

  (0, _invariant["default"])(!changingType, changingType);
};

exports.invariantTypesMatch = invariantTypesMatch;