import pureDayjs from 'dayjs';
import advancedFormat from 'dayjs/plugin/advancedFormat';
import customParseFormat from '@bigbinary/neeto-commons-frontend/utils/customParseFormatPlugin';
import duration from 'dayjs/plugin/duration';
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
import isToday from 'dayjs/plugin/isToday';
import localeData from 'dayjs/plugin/localeData';
import localizedFormat from 'dayjs/plugin/localizedFormat';
import minMax from 'dayjs/plugin/minMax';
import quarterOfYear from 'dayjs/plugin/quarterOfYear';
import relativeTime from 'dayjs/plugin/relativeTime';
import timezone from '@bigbinary/neeto-commons-frontend/utils/timezonePlugin';
import updateLocale from 'dayjs/plugin/updateLocale';
import utc from 'dayjs/plugin/utc';
import weekday from 'dayjs/plugin/weekday';
import weekOfYear from 'dayjs/plugin/weekOfYear';
import localePlugin from '../utils/localePlugin.js';
import '../index-CoBEoJgD.js';
import 'i18next';

// 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(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);
  }
};

export { initializeDayjs as default };
//# sourceMappingURL=dayjs.js.map
