'use strict';

var pureDayjs = require('dayjs');
var advancedFormat = require('dayjs/plugin/advancedFormat');
var customParseFormat = require('dayjs/plugin/customParseFormat');
var duration = require('dayjs/plugin/duration');
var isSameOrAfter = require('dayjs/plugin/isSameOrAfter');
var isSameOrBefore = require('dayjs/plugin/isSameOrBefore');
var isToday = require('dayjs/plugin/isToday');
var localeData = require('dayjs/plugin/localeData');
var localizedFormat = require('dayjs/plugin/localizedFormat');
var minMax = require('dayjs/plugin/minMax');
var quarterOfYear = require('dayjs/plugin/quarterOfYear');
var relativeTime = require('dayjs/plugin/relativeTime');
var timezone = require('@bigbinary/neeto-commons-frontend/utils/timezonePlugin');
var updateLocale = require('dayjs/plugin/updateLocale');
var utc = require('dayjs/plugin/utc');
var weekday = require('dayjs/plugin/weekday');
var weekOfYear = require('dayjs/plugin/weekOfYear');
var utils_localePlugin = require('../utils/localePlugin.js');
require('../index-BskY8dVw.js');

// eslint-disable-next-line @bigbinary/neeto/use-dayjs-from-neeto-commons-fronted
var isValidTimezone = function isValidTimezone(timezone) {
  try {
    pureDayjs().tz(timezone);
    return true;
  } catch (_unused) {
    return false;
  }
};
var initializeDayjs = function initializeDayjs() {
  var _globalProps, _globalProps2;
  var skipTimezone = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  pureDayjs.extend(advancedFormat);
  pureDayjs.extend(customParseFormat);
  pureDayjs.extend(duration);
  pureDayjs.extend(isSameOrAfter);
  pureDayjs.extend(isSameOrBefore);
  pureDayjs.extend(isToday);
  pureDayjs.extend(localeData);
  pureDayjs.extend(localizedFormat);
  pureDayjs.extend(minMax);
  pureDayjs.extend(quarterOfYear);
  pureDayjs.extend(relativeTime);
  pureDayjs.extend(timezone);
  pureDayjs.extend(updateLocale);
  pureDayjs.extend(utc);
  pureDayjs.extend(weekday);
  pureDayjs.extend(weekOfYear);
  pureDayjs.extend(utils_localePlugin);
  var shouldInitializeTimezone = !skipTimezone && ((_globalProps = globalProps) === null || _globalProps === void 0 || (_globalProps = _globalProps.user) === null || _globalProps === void 0 ? void 0 : _globalProps.timeZone) && isValidTimezone((_globalProps2 = globalProps) === null || _globalProps2 === void 0 || (_globalProps2 = _globalProps2.user) === null || _globalProps2 === void 0 ? void 0 : _globalProps2.timeZone);
  if (shouldInitializeTimezone) {
    var _globalProps3;
    pureDayjs.tz.setDefault((_globalProps3 = globalProps) === null || _globalProps3 === void 0 || (_globalProps3 = _globalProps3.user) === null || _globalProps3 === void 0 ? void 0 : _globalProps3.timeZone);
  }
};

module.exports = initializeDayjs;
//# sourceMappingURL=dayjs.js.map
