"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;exports.__esModule = true;exports.upMonthOfShape = exports.getShapeFromNativeDate = exports.getNativeDateFromShape = exports.getDateForNative = exports.getDateForComponent = void 0;var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));var _CalendarUtils = require("../../components/Calendar/CalendarUtils");



var getDateForNative = exports.getDateForNative = function getDateForNative(componentDate) {
  if (!componentDate) {
    return undefined;
  }

  var splittedDate = componentDate.split('.');

  return splittedDate[2] + "-" + splittedDate[1] + "-" + splittedDate[0];
};

var getDateForComponent = exports.getDateForComponent = function getDateForComponent(nativeDate) {
  if (!nativeDate) {
    return '';
  }

  var splittedDate = nativeDate.split('-');

  return splittedDate[2] + "." + splittedDate[1] + "." + splittedDate[0];
};

var getNativeDateFromShape = exports.getNativeDateFromShape = function getNativeDateFromShape(componentDate) {
  if (!componentDate) {
    return undefined;
  }
  var _map = [componentDate.date, componentDate.month, componentDate.year].map(function (x) {return x.toString();}),date = _map[0],month = _map[1],year = _map[2];

  return year.padStart(4, '0') + "-" + month.padStart(2, '0') + "-" + date.padStart(2, '0');
};

var upMonthOfShape = exports.upMonthOfShape = function upMonthOfShape(DateShape) {
  if (!DateShape) {
    return undefined;
  }

  return (0, _extends2.default)({}, DateShape, { month: (0, _CalendarUtils.getMonthInHumanFormat)(DateShape.month) });
};

var getShapeFromNativeDate = exports.getShapeFromNativeDate = function getShapeFromNativeDate(nativeDate) {
  if (!nativeDate) {
    return undefined;
  }

  var splittedDate = nativeDate.split('-').map(function (date) {return Number(date);});

  return { year: splittedDate[0], month: splittedDate[1], date: splittedDate[2] };
};