"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.createEffect = createEffect;
exports.predefinedEffects = void 0;
var _excluded = ["type"];

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var predefinedEffects = {
  fade: function fade() {
    return {
      initial: {
        opacity: 0
      },
      animate: {
        opacity: 1,
        duration: 'quick2',
        easing: 'linear'
      },
      exit: {
        opacity: 0,
        duration: 'quick2',
        easing: 'linear'
      }
    };
  },
  scaleFade: function scaleFade() {
    return {
      initial: {
        opacity: 0,
        transform: {
          scale: 0.85
        }
      },
      animate: {
        opacity: 1,
        transform: {
          scale: 1
        },
        duration: 'moderate2',
        easing: 'entry'
      },
      exit: {
        opacity: 0,
        transform: {
          scale: 0.85
        },
        duration: 'moderate1',
        easing: 'exit'
      }
    };
  },
  slideUpFade: function slideUpFade() {
    return {
      initial: {
        opacity: 0,
        transform: {
          translateY: 'm'
        }
      },
      animate: {
        opacity: 1,
        transform: {
          translateY: 0
        },
        duration: 'moderate1',
        easing: 'entry'
      },
      exit: {
        opacity: 0,
        transform: {
          translateY: 'm'
        },
        duration: 'moderate1',
        easing: 'exit'
      }
    };
  },
  slideDownFade: function slideDownFade() {
    return {
      initial: {
        opacity: 0,
        transform: {
          translateY: '-m'
        }
      },
      animate: {
        opacity: 1,
        transform: {
          translateY: 0
        },
        duration: 'moderate1',
        easing: 'entry'
      },
      exit: {
        opacity: 0,
        transform: {
          translateY: '-m'
        },
        duration: 'moderate1',
        easing: 'exit'
      }
    };
  },
  slideLeftFade: function slideLeftFade() {
    return {
      initial: {
        opacity: 0,
        transform: {
          translateX: 'm'
        }
      },
      animate: {
        opacity: 1,
        transform: {
          translateX: 0
        },
        duration: 'moderate2',
        easing: 'entry'
      },
      exit: {
        opacity: 0,
        transform: {
          translateX: 'm'
        },
        duration: 'moderate1',
        easing: 'exit'
      }
    };
  },
  slideRightFade: function slideRightFade() {
    return {
      initial: {
        opacity: 0,
        transform: {
          translateX: '-m'
        }
      },
      animate: {
        opacity: 1,
        transform: {
          translateX: 0
        },
        duration: 'moderate2',
        easing: 'entry'
      },
      exit: {
        opacity: 0,
        transform: {
          translateX: '-m'
        },
        duration: 'moderate1',
        easing: 'exit'
      }
    };
  }
};
exports.predefinedEffects = predefinedEffects;

function createEffect(_ref) {
  var type = _ref.type,
      customEffectProps = _objectWithoutProperties(_ref, _excluded);

  if (type && predefinedEffects[type] !== undefined) {
    return mergeDeepEffects(predefinedEffects[type](), customEffectProps);
  }

  return customEffectProps;
}
/**
 * It expects effect objects not containing arrays,
 * which will probably never happen in the future.
 */


function mergeDeepEffects(target, source) {
  Object.keys(source).forEach(function (key) {
    if (_typeof(target[key]) === 'object') {
      target[key] = mergeDeepEffects(target[key], source[key]);
    } else {
      target[key] = source[key];
    }
  });
  return target;
}